Skip to content

Commit a4200c9

Browse files
remove mouse position scaling
1 parent 8e47c40 commit a4200c9

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

desktop/src/cef.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ impl ViewInfo {
7777
_ => {}
7878
}
7979
}
80-
pub(crate) fn scale(&self) -> f64 {
81-
self.scale
82-
}
8380
pub(crate) fn zoom(&self) -> f64 {
8481
self.scale.ln() / 1.2_f64.ln()
8582
}

desktop/src/cef/context/singlethreaded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl CefContext for SingleThreadedCefContext {
2020
}
2121

2222
fn handle_window_event(&mut self, event: &WindowEvent) {
23-
input::handle_window_event(&self.browser, &mut self.input_state, event, self.event_handler.as_ref());
23+
input::handle_window_event(&self.browser, &mut self.input_state, event);
2424
}
2525

2626
fn notify_view_info_changed(&self) {

desktop/src/cef/input.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
use cef::sys::{cef_event_flags_t, cef_key_event_type_t, cef_mouse_button_type_t};
22
use cef::{Browser, ImplBrowser, ImplBrowserHost, KeyEvent, KeyEventType, MouseEvent};
33
use std::time::Instant;
4-
use winit::dpi::LogicalPosition;
4+
use winit::dpi::PhysicalPosition;
55
use winit::event::{ButtonSource, ElementState, MouseButton, MouseScrollDelta, WindowEvent};
66

77
mod keymap;
88
use keymap::{ToNativeKeycode, ToVKBits};
99

10-
use crate::cef::CefEventHandler;
11-
1210
use super::consts::{MULTICLICK_ALLOWED_TRAVEL, MULTICLICK_TIMEOUT, PINCH_ZOOM_SPEED, SCROLL_LINE_HEIGHT, SCROLL_LINE_WIDTH, SCROLL_SPEED_X, SCROLL_SPEED_Y};
1311

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) {
1513
match event {
1614
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);
1916

2017
let Some(host) = browser.host() else { return };
2118
host.send_mouse_move_event(Some(&input_state.into()), 0);
2219
}
2320
WindowEvent::PointerLeft { position, .. } => {
2421
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);
2723
}
2824

2925
let Some(host) = browser.host() else { return };
@@ -163,7 +159,7 @@ impl InputState {
163159
self.modifiers = *modifiers;
164160
}
165161

166-
fn cursor_move(&mut self, position: &LogicalPosition<f64>) {
162+
fn cursor_move(&mut self, position: &PhysicalPosition<f64>) {
167163
self.mouse_position = position.into();
168164
}
169165

@@ -210,8 +206,8 @@ pub(crate) struct MousePosition {
210206
x: usize,
211207
y: usize,
212208
}
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 {
215211
Self {
216212
x: position.x as usize,
217213
y: position.y as usize,

0 commit comments

Comments
 (0)