Skip to content

Commit 78f47ab

Browse files
committed
Merge pull request #94022 from Riteo/a-fraction-of-the-work
Wayland: Switch pointer position handling to doubles
2 parents 091212b + 2ff5011 commit 78f47ab

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

platform/linuxbsd/wayland/wayland_thread.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1416,10 +1416,10 @@ void WaylandThread::_wl_pointer_on_motion(void *data, struct wl_pointer *wl_poin
14161416
PointerData &pd = ss->pointer_data_buffer;
14171417

14181418
// TODO: Scale only when sending the Wayland message.
1419-
pd.position.x = wl_fixed_to_int(surface_x);
1420-
pd.position.y = wl_fixed_to_int(surface_y);
1419+
pd.position.x = wl_fixed_to_double(surface_x);
1420+
pd.position.y = wl_fixed_to_double(surface_y);
14211421

1422-
pd.position = scale_vector2i(pd.position, window_state_get_scale_factor(ws));
1422+
pd.position *= window_state_get_scale_factor(ws);
14231423

14241424
pd.motion_time = time;
14251425
}
@@ -1532,7 +1532,7 @@ void WaylandThread::_wl_pointer_on_frame(void *data, struct wl_pointer *wl_point
15321532
mm->set_position(pd.position);
15331533
mm->set_global_position(pd.position);
15341534

1535-
Vector2i pos_delta = pd.position - old_pd.position;
1535+
Vector2 pos_delta = pd.position - old_pd.position;
15361536

15371537
if (old_pd.relative_motion_time != pd.relative_motion_time) {
15381538
uint32_t time_delta = pd.relative_motion_time - old_pd.relative_motion_time;
@@ -1649,7 +1649,7 @@ void WaylandThread::_wl_pointer_on_frame(void *data, struct wl_pointer *wl_point
16491649

16501650
// We have to set the last position pressed here as we can't take for
16511651
// granted what the individual events might have seen due to them not having
1652-
// a garaunteed order.
1652+
// a guaranteed order.
16531653
if (mb->is_pressed()) {
16541654
pd.last_pressed_position = pd.position;
16551655
}
@@ -2388,9 +2388,9 @@ void WaylandThread::_wp_tablet_tool_on_motion(void *data, struct zwp_tablet_tool
23882388

23892389
double scale_factor = window_state_get_scale_factor(ws);
23902390

2391-
td.position.x = wl_fixed_to_int(x);
2392-
td.position.y = wl_fixed_to_int(y);
2393-
td.position = scale_vector2i(td.position, scale_factor);
2391+
td.position.x = wl_fixed_to_double(x);
2392+
td.position.y = wl_fixed_to_double(y);
2393+
td.position *= scale_factor;
23942394

23952395
td.motion_time = OS::get_singleton()->get_ticks_msec();
23962396
}
@@ -2520,7 +2520,7 @@ void WaylandThread::_wp_tablet_tool_on_frame(void *data, struct zwp_tablet_tool_
25202520
mm->set_relative(td.position - old_td.position);
25212521
mm->set_relative_screen_position(mm->get_relative());
25222522

2523-
Vector2i pos_delta = td.position - old_td.position;
2523+
Vector2 pos_delta = td.position - old_td.position;
25242524
uint32_t time_delta = td.motion_time - old_td.motion_time;
25252525
mm->set_velocity((Vector2)pos_delta / time_delta);
25262526

platform/linuxbsd/wayland/wayland_thread.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class WaylandThread {
295295
};
296296

297297
struct PointerData {
298-
Point2i position;
298+
Point2 position;
299299
uint32_t motion_time = 0;
300300

301301
// Relative motion has its own optional event and so needs its own time.
@@ -305,7 +305,7 @@ class WaylandThread {
305305
BitField<MouseButtonMask> pressed_button_mask;
306306

307307
MouseButton last_button_pressed = MouseButton::NONE;
308-
Point2i last_pressed_position;
308+
Point2 last_pressed_position;
309309

310310
// This is needed to check for a new double click every time.
311311
bool double_click_begun = false;
@@ -325,14 +325,14 @@ class WaylandThread {
325325
};
326326

327327
struct TabletToolData {
328-
Point2i position;
328+
Point2 position;
329329
Vector2 tilt;
330330
uint32_t pressure = 0;
331331

332332
BitField<MouseButtonMask> pressed_button_mask;
333333

334334
MouseButton last_button_pressed = MouseButton::NONE;
335-
Point2i last_pressed_position;
335+
Point2 last_pressed_position;
336336

337337
bool double_click_begun = false;
338338

0 commit comments

Comments
 (0)