summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-03-07 11:16:45 -0600
committerDudemanguy <random342@airmail.cc>2023-03-08 14:06:22 +0000
commitb313a242c24637484a68c29ee679f45432d85bb7 (patch)
tree3e1290a5d251f5a0c4a24ab99122a3e16a145fef /video/out
parent855b619cc9872a2919d071166d5b50d6a2a8a708 (diff)
downloadmpv-b313a242c24637484a68c29ee679f45432d85bb7.tar.bz2
mpv-b313a242c24637484a68c29ee679f45432d85bb7.tar.xz
wayland: use correct x/y coordinates for the cursor
While adding fractional scale support, the coordinates for wayland changed to always include the scaling parameter. The pointer stuff actually did too. However, the check_for_resize function used the unscaled, local surface coordinates. Likely, it was neccesary at the time since wl->geometry used to report unscaled coordinates. In light of that, we can just simply use mouse_x/y instead for this function to make it work correctly with the right/bottom edges. mouse_unscaled becomes completely unneccesary, so just drop it. Some minor style changes included just because.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/wayland_common.c24
-rw-r--r--video/out/wayland_common.h2
2 files changed, 11 insertions, 15 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 664afd3d44..bb1a5e672f 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -171,8 +171,8 @@ struct vo_wayland_output {
struct wl_list link;
};
-static int check_for_resize(struct vo_wayland_state *wl, wl_fixed_t x_w, wl_fixed_t y_w,
- int edge_pixels, enum xdg_toplevel_resize_edge *edge);
+static int check_for_resize(struct vo_wayland_state *wl, int edge_pixels,
+ enum xdg_toplevel_resize_edge *edge);
static int get_mods(struct vo_wayland_state *wl);
static int lookupkey(int key);
static int set_cursor_visibility(struct vo_wayland_state *wl, bool on);
@@ -218,8 +218,6 @@ static void pointer_handle_motion(void *data, struct wl_pointer *pointer,
wl->mouse_x = wl_fixed_to_int(sx) * wl->scaling;
wl->mouse_y = wl_fixed_to_int(sy) * wl->scaling;
- wl->mouse_unscaled_x = sx;
- wl->mouse_unscaled_y = sy;
if (!wl->toplevel_configured)
mp_input_set_mouse_pos(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y);
@@ -269,15 +267,15 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
if (!mp_input_test_dragging(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y) &&
(!wl->vo_opts->fullscreen) && (!wl->vo_opts->window_maximized) &&
- (button == MP_MBTN_LEFT) && (state == MP_KEY_STATE_DOWN)) {
+ (button == MP_MBTN_LEFT) && (state == MP_KEY_STATE_DOWN))
+ {
uint32_t edges;
// Implement an edge resize zone if there are no decorations
- if (!wl->vo_opts->border &&
- check_for_resize(wl, wl->mouse_unscaled_x, wl->mouse_unscaled_y,
- wl->opts->edge_pixels_pointer, &edges))
+ if (!wl->vo_opts->border && check_for_resize(wl, wl->opts->edge_pixels_pointer, &edges)) {
xdg_toplevel_resize(wl->xdg_toplevel, wl->seat, serial, edges);
- else
+ } else {
window_move(wl, serial);
+ }
// Explictly send an UP event after the client finishes a move/resize
mp_input_put_key(wl->vo->input_ctx, button | MP_KEY_STATE_UP);
}
@@ -324,7 +322,7 @@ static void touch_handle_down(void *data, struct wl_touch *wl_touch,
enum xdg_toplevel_resize_edge edge;
if (!mp_input_test_dragging(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y)) {
- if (check_for_resize(wl, x_w, y_w, wl->opts->edge_pixels_touch, &edge)) {
+ if (check_for_resize(wl, wl->opts->edge_pixels_touch, &edge)) {
xdg_toplevel_resize(wl->xdg_toplevel, wl->seat, serial, edge);
} else {
xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial);
@@ -1374,13 +1372,13 @@ end:
}
}
-static int check_for_resize(struct vo_wayland_state *wl, wl_fixed_t x_w, wl_fixed_t y_w,
- int edge_pixels, enum xdg_toplevel_resize_edge *edge)
+static int check_for_resize(struct vo_wayland_state *wl, int edge_pixels,
+ enum xdg_toplevel_resize_edge *edge)
{
if (wl->vo_opts->fullscreen || wl->vo_opts->window_maximized)
return 0;
- int pos[2] = { wl_fixed_to_double(x_w), wl_fixed_to_double(y_w) };
+ int pos[2] = { wl->mouse_x, wl->mouse_y };
int left_edge = pos[0] < edge_pixels;
int top_edge = pos[1] < edge_pixels;
int right_edge = pos[0] > (mp_rect_w(wl->geometry) - edge_pixels);
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index c9921cc60b..d22e91d5e5 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -75,8 +75,6 @@ struct vo_wayland_state {
bool state_change;
bool toplevel_configured;
int display_fd;
- int mouse_unscaled_x;
- int mouse_unscaled_y;
int mouse_x;
int mouse_y;
int pending_vo_events;