You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When the Servo window gains focus, it should update the mouse coordinate #11130
This is important for browserhtml. We need this to build automated tests.
in ports/glutin, the mouse coordinate is updated when receiving a glutin mousemove event.
When Servo starts, as the mouse moves, mouse_pos is updated. Then Servo loses focus. User moves the mouse. When Servo gains focus, the mouse is likely not at mouse_pos anymore. That means:
mouseover is not triggered and :hover styles are not applied for element below the mouse
if a click occurs before the mouse is moved, the clicked is triggered for the element that was under the latest known coordinate (right before losing focus)
We should update mouse_pos when gaining focus, and fire a mousemove event if it changed.
There is a Focused(bool) glutin event, but it doesn't come with new mouse coordinates.
If someone can tell me how to get the mouse coordinates from a didBecomeKey notification, i can take care of the rest (is NSEvent::locationInWindow(nil) supposed to work?).
We get a NSAppKitDefined nsevent before getting the focus notification. So maybe we can use that to get a nsevent instance and do nsevent.locationInWindow().
First thing first, a click should not rely on the previous mousemove coordinate, but on the actual coordinate.
In Glutin:
In src/events.rs, we need to change MouseInput(ElementState, MouseButton) to MouseInput(ElementState, MouseButton, Option<(i32, i32)>). Option<(i32, i32)> will hold the new coordinates.
In src/api/cocoa/mod.rs, MouseInput events should include the coordinates (see how we retrieve the coordinates in NSRightMouseDragged). For other platforms, we can just use None for now.
In Servo:
In ports/glutin/window.rs, for Event::MouseInput events, if coordinates are present, self.mouse_pos should be updated and a WindowEvent::MouseWindowMoveEventClass should also be fired in addition to any event handle_mouse will eventually fire.
changed the title [-]When the Servo window gains focus, it should udpate the mouse coordinate[/-][+]When the Servo window gains focus, it should update the mouse coordinate[/+]on May 12, 2016
@mrmiywj thanks for landing the first part. Now we need a glutin update in Servo with the changes I'm describing in the second part of #11130 (comment)
Activity
tschneidereit commentedon May 11, 2016
In addition, a
mouseoutevent (with the current coordinates) should be fired upon losing focus, and any:hoverstates reset.paulrouget commentedon May 11, 2016
That will happen automatically. When I'm talking about mousemove, I'm talking about
WindowEvent::MouseWindowMoveEventClass.paulrouget commentedon May 11, 2016
If someone can tell me how to get the mouse coordinates from a
didBecomeKeynotification, i can take care of the rest (isNSEvent::locationInWindow(nil)supposed to work?)./cc @pcwalton
paulrouget commentedon May 11, 2016
We get a
NSAppKitDefinednsevent before getting the focus notification. So maybe we can use that to get anseventinstance and donsevent.locationInWindow().paulrouget commentedon May 12, 2016
When a Firefox window is unfocused, the chrome still get mouse events.
I think this is done with NSTrackingArea:
paulrouget commentedon May 12, 2016
First thing first, a click should not rely on the previous mousemove coordinate, but on the actual coordinate.
In Glutin:
In
src/events.rs, we need to changeMouseInput(ElementState, MouseButton)toMouseInput(ElementState, MouseButton, Option<(i32, i32)>).Option<(i32, i32)>will hold the new coordinates.In
src/api/cocoa/mod.rs,MouseInputevents should include the coordinates (see how we retrieve the coordinates inNSRightMouseDragged). For other platforms, we can just useNonefor now.In Servo:
In
ports/glutin/window.rs, forEvent::MouseInputevents, if coordinates are present,self.mouse_posshould be updated and aWindowEvent::MouseWindowMoveEventClassshould also be fired in addition to any eventhandle_mousewill eventually fire.[-]When the Servo window gains focus, it should udpate the mouse coordinate[/-][+]When the Servo window gains focus, it should update the mouse coordinate[/+]6 remaining items
paulrouget commentedon Jun 7, 2016
@mrmiywj Yes. I think the proper way of doing it is what I described here: #11130 (comment) - that would partially address this issue.
mrmiywj commentedon Jun 7, 2016
@paulrouget
But, will the Glutin's maintainer approve our modification of its APIs?
paulrouget commentedon Jun 7, 2016
This should not a be a problem.
mrmiywj commentedon Jun 12, 2016
@paulrouget
I've pushed a PR to glutin to fix this issue. Could you review it?
Auto merge of #97 - mrmiywj:return-coordinates-in-MouseInput, r=nox
paulrouget commentedon Jun 16, 2016
@mrmiywj thanks for landing the first part. Now we need a glutin update in Servo with the changes I'm describing in the second part of #11130 (comment)
Update Glutin to pick up borderless window performance fixes on Mac.
Auto merge of #11940 - pcwalton:glutinupupup, r=larsbergstrom
Update Glutin to pick up borderless window performance fixes on Mac.
Auto merge of #11940 - pcwalton:glutinupupup, r=mbrubeck
Update Glutin to pick up borderless window performance fixes on Mac.
Auto merge of #11979 - ConnorGBrewster:glutinupupup, r=frewsxcv
Auto merge of #11794 - mrmiywj:update-mouse-coordinate-when-focus, r=…