|
1 | 1 | use cef::sys::{cef_event_flags_t, cef_key_event_type_t, cef_mouse_button_type_t}; |
2 | 2 | use cef::{Browser, ImplBrowser, ImplBrowserHost, KeyEvent, KeyEventType, MouseEvent}; |
3 | 3 | use std::time::Instant; |
4 | | -use winit::dpi::LogicalPosition; |
| 4 | +use winit::dpi::PhysicalPosition; |
5 | 5 | use winit::event::{ButtonSource, ElementState, MouseButton, MouseScrollDelta, WindowEvent}; |
6 | 6 |
|
7 | 7 | mod keymap; |
8 | 8 | use keymap::{ToNativeKeycode, ToVKBits}; |
9 | 9 |
|
10 | | -use crate::cef::CefEventHandler; |
11 | | - |
12 | 10 | use super::consts::{MULTICLICK_ALLOWED_TRAVEL, MULTICLICK_TIMEOUT, PINCH_ZOOM_SPEED, SCROLL_LINE_HEIGHT, SCROLL_LINE_WIDTH, SCROLL_SPEED_X, SCROLL_SPEED_Y}; |
13 | 11 |
|
14 | | -pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputState, event: &WindowEvent, event_handler: &dyn CefEventHandler) { |
| 12 | +pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputState, event: &WindowEvent) { |
15 | 13 | match event { |
16 | 14 | WindowEvent::PointerMoved { position, .. } | WindowEvent::PointerEntered { position, .. } => { |
17 | | - let scale = event_handler.view_info().scale(); |
18 | | - input_state.cursor_move(&position.to_logical(scale)); |
| 15 | + input_state.cursor_move(&position); |
19 | 16 |
|
20 | 17 | let Some(host) = browser.host() else { return }; |
21 | 18 | host.send_mouse_move_event(Some(&input_state.into()), 0); |
22 | 19 | } |
23 | 20 | WindowEvent::PointerLeft { position, .. } => { |
24 | 21 | if let Some(position) = position { |
25 | | - let scale = event_handler.view_info().scale(); |
26 | | - input_state.cursor_move(&position.to_logical(scale)); |
| 22 | + input_state.cursor_move(&position); |
27 | 23 | } |
28 | 24 |
|
29 | 25 | let Some(host) = browser.host() else { return }; |
@@ -163,7 +159,7 @@ impl InputState { |
163 | 159 | self.modifiers = *modifiers; |
164 | 160 | } |
165 | 161 |
|
166 | | - fn cursor_move(&mut self, position: &LogicalPosition<f64>) { |
| 162 | + fn cursor_move(&mut self, position: &PhysicalPosition<f64>) { |
167 | 163 | self.mouse_position = position.into(); |
168 | 164 | } |
169 | 165 |
|
@@ -210,8 +206,8 @@ pub(crate) struct MousePosition { |
210 | 206 | x: usize, |
211 | 207 | y: usize, |
212 | 208 | } |
213 | | -impl From<&LogicalPosition<f64>> for MousePosition { |
214 | | - fn from(position: &LogicalPosition<f64>) -> Self { |
| 209 | +impl From<&PhysicalPosition<f64>> for MousePosition { |
| 210 | + fn from(position: &PhysicalPosition<f64>) -> Self { |
215 | 211 | Self { |
216 | 212 | x: position.x as usize, |
217 | 213 | y: position.y as usize, |
|
0 commit comments