Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upwhen window gains focus, update mouse coordinate #11794
Conversation
|
cc @paulrouget |
|
You can update glutin by modifying the Cargo.toml file under ports/glutin and running |
| self.mouse_pos.set(Point2D::new(x, y)); | ||
| self.handle_mouse(mouse_button, element_state, x, y); | ||
| self.event_queue.borrow_mut().push( | ||
| WindowEvent::MouseWindowMoveEventClass(Point2D::typed(x as f32, y as f32))); |
This comment has been minimized.
This comment has been minimized.
paulrouget
Jun 20, 2016
Contributor
You need a move event, but also a click event. So you'll need to call handle_mouse here as well.
This comment has been minimized.
This comment has been minimized.
mrmiywj
Jun 20, 2016
Author
Contributor
Hmm, I'm wrong here. But I do think the solution should be:
- set the new position
- push the
MouseWindowMoveEventClassintoevent_queue - call
handle_mouse
For the move event, should I also call handle_mouse? I though handle_mouse is only for the click event.
This comment has been minimized.
This comment has been minimized.
paulrouget
Jun 20, 2016
Contributor
I believe the mousemove event should happen when the window gains focus.
See my latest comment.
| @@ -17,7 +17,7 @@ log = "0.3.5" | |||
| msg = {path = "../../components/msg"} | |||
| net_traits = {path = "../../components/net_traits"} | |||
| script_traits = {path = "../../components/script_traits"} | |||
| servo-glutin = "0.4" | |||
| servo-glutin = { git = "https://github.com/servo/glutin"} | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
r? @paulrouget |
|
@bors-servo delegate=paulrouget |
|
|
|
STR:
Ideally, we should get a mouse move event when 6) happens. <style>
div {
width: 0px;
height: 0px;
position: absolute;
border: 2px solid red;
top: 0;
left: 0;
}
</style>
<div></div>
<script>
var div = document.querySelector("div");
window.addEventListener("click", e => {
div.style.top = e.clientY - 2 + "px";
div.style.left = e.clientX - 2 + "px";
});
</script> |
|
@paulrouget
Is there anything wrong with my modification to |
|
The change to gluten will need to be published, and then we'll need to use the version from crates.io instead of git. |
|
@jdm |
|
|
It also complains. QAQ |
|
Oh, undo your check to that cargo.toml too. Mention servo-glutin 0.4 or 0.4.24 |
|
Sorry for that maybe I cannot understand what you said.
Or just like the
|
|
You may need to run |
|
Looks like there's a change missing to Servo's code:
I think it's supposed to be |
| @@ -279,7 +288,8 @@ impl Window { | |||
| MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy), | |||
| }; | |||
| let phase = glutin_phase_to_touch_event_type(phase); | |||
| self.scroll_window(dx, dy, phase); | |||
| self.scroll_window( | |||
| dx, dy, phase); | |||
This comment has been minimized.
This comment has been minimized.
| let mouse_pos = self.mouse_pos.get(); | ||
| self.handle_mouse(mouse_button, element_state, mouse_pos.x, mouse_pos.y); | ||
| } | ||
| mouse_button == MouseButton::Right { |
This comment has been minimized.
This comment has been minimized.
KiChjang
Jul 5, 2016
Member
I think the problem is here, the mouse_button here should match up with the last line's mouse_button columns, and the match expression on the next line should be de-indented once.
|
@KiChjang Is the indent correct now? |
| self.handle_mouse(mouse_button, element_state, mouse_pos.x, mouse_pos.y); | ||
| } | ||
| } | ||
| } |
This comment has been minimized.
This comment has been minimized.
KiChjang
Jul 5, 2016
Member
The last one is correct, but you can see that the one above it is indented too much to the right. De-indenting once should fix it.
|
I think it's due to the two lines of if conditions, which may mistake my emacs auto-intending. |
|
@bors-servo r+ Thank you! |
|
|
…KiChjang when window gains focus, update mouse coordinate <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11130 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because these cannot be tested automated. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11794) <!-- Reviewable:end -->
|
|
mrmiywj commentedJun 19, 2016
•
edited by larsbergstrom
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is