667
edits
Changes
no edit summary
Attach a 'mousemove' event listener, move your mouse, access event.screenX:
<pre>
221 NS_METHOD nsDOMMouseEvent::GetScreenX(PRInt32* aScreenX)
222 {
223 NS_ENSURE_ARG_POINTER(aScreenX);
224 *aScreenX = GetScreenPoint().x;
225 return NS_OK;
226 }
</pre>
this calls nsDOMUIEvent::GetScreenPoint:
<pre>
126 nsDOMUIEvent::GetScreenPoint()
127 {
128 if (!mEvent ||
129 (mEvent->eventStructType != NS_MOUSE_EVENT &&
130 mEvent->eventStructType != NS_POPUP_EVENT &&
131 mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
132 mEvent->eventStructType != NS_MOZTOUCH_EVENT &&
133 mEvent->eventStructType != NS_DRAG_EVENT &&
134 mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT)) {
135 return nsIntPoint(0, 0);
136 }
137
138 if (!((nsGUIEvent*)mEvent)->widget ) {
139 return mEvent->refPoint;
140 }
141
142 nsIntPoint offset = mEvent->refPoint + // <---------------------here
143 ((nsGUIEvent*)mEvent)->widget->WidgetToScreenOffset();
144 nscoord factor = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
145 return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
146 nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
147 }
</pre>
<pre>