Skip to content

When the Servo window gains focus, it should update the mouse coordinate #11130

Closed

Description

@paulrouget

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:

  1. mouseover is not triggered and :hover styles are not applied for element below the mouse
  2. 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.

Activity

  1. tschneidereit commented on May 11, 2016

    @tschneidereit
    Contributor

    In addition, a mouseout event (with the current coordinates) should be fired upon losing focus, and any :hover states reset.

  2. paulrouget commented on May 11, 2016

    @paulrouget
    ContributorAuthor

    In addition, a mouseout event (with the current coordinates) should be fired upon losing focus, and any :hover states reset.

    That will happen automatically. When I'm talking about mousemove, I'm talking about WindowEvent::MouseWindowMoveEventClass.

  3. paulrouget commented on May 11, 2016

    @paulrouget
    ContributorAuthor

    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?).

    /cc @pcwalton

  4. added
    C-looking for assistance
    P-mac
    on May 11, 2016
  5. paulrouget commented on May 11, 2016

    @paulrouget
    ContributorAuthor

    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().

  6. added
    E-less-complex
    and removed
    C-looking for assistance
    on May 12, 2016
  7. paulrouget commented on May 12, 2016

    @paulrouget
    ContributorAuthor

    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.

  8. 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
  9. 6 remaining items

  10. paulrouget commented on Jun 7, 2016

    @paulrouget
    ContributorAuthor

    @mrmiywj Yes. I think the proper way of doing it is what I described here: #11130 (comment) - that would partially address this issue.

  11. mrmiywj commented on Jun 7, 2016

    @mrmiywj
    Contributor

    @paulrouget
    But, will the Glutin's maintainer approve our modification of its APIs?

  12. paulrouget commented on Jun 7, 2016

    @paulrouget
    ContributorAuthor

    But, will the Glutin's maintainer approve our modification of its APIs?

    This should not a be a problem.

  13. mrmiywj commented on Jun 12, 2016

    @mrmiywj
    Contributor

    @paulrouget
    I've pushed a PR to glutin to fix this issue. Could you review it?

  14. added a commit that references this issue on Jun 16, 2016
  15. paulrouget commented on Jun 16, 2016

    @paulrouget
    ContributorAuthor

    @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)

  16. added a commit that references this issue on Jun 30, 2016
  17. added a commit that references this issue on Jun 30, 2016
  18. added a commit that references this issue on Jul 1, 2016
  19. added
    C-has-open-pr
    on Jul 4, 2016
  20. added a commit that references this issue on Jul 5, 2016
    d99ff8d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-gfx/compositingC-assignedC-has-open-prE-less-complexP-mac

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions