mirror of https://github.com/mpv-player/mpv
wayland: cleanup check_for_resize function
xdg_toplevel_resize_edge enum values allow for this to work, e.g. `TOP | LEFT = TOP_LEFT` No functional change.
This commit is contained in:
parent
ca7aeb71ee
commit
43d896657e
|
@ -224,7 +224,7 @@ struct vo_wayland_tranche {
|
||||||
static bool single_output_spanned(struct vo_wayland_state *wl);
|
static bool single_output_spanned(struct vo_wayland_state *wl);
|
||||||
|
|
||||||
static int check_for_resize(struct vo_wayland_state *wl, int edge_pixels,
|
static int check_for_resize(struct vo_wayland_state *wl, int edge_pixels,
|
||||||
enum xdg_toplevel_resize_edge *edge);
|
enum xdg_toplevel_resize_edge *edges);
|
||||||
static int get_mods(struct vo_wayland_seat *seat);
|
static int get_mods(struct vo_wayland_seat *seat);
|
||||||
static int greatest_common_divisor(int a, int b);
|
static int greatest_common_divisor(int a, int b);
|
||||||
static int handle_round(int scale, int n);
|
static int handle_round(int scale, int n);
|
||||||
|
@ -327,7 +327,6 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
} else {
|
} else {
|
||||||
button = 0;
|
button = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum xdg_toplevel_resize_edge edges;
|
enum xdg_toplevel_resize_edge edges;
|
||||||
if (!mp_input_test_dragging(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y) &&
|
if (!mp_input_test_dragging(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y) &&
|
||||||
!wl->locked_size && (button == MP_MBTN_LEFT) && (state == MP_KEY_STATE_DOWN) &&
|
!wl->locked_size && (button == MP_MBTN_LEFT) && (state == MP_KEY_STATE_DOWN) &&
|
||||||
|
@ -1894,39 +1893,24 @@ static void check_dnd_fd(struct vo_wayland_state *wl)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_for_resize(struct vo_wayland_state *wl, int edge_pixels,
|
static int check_for_resize(struct vo_wayland_state *wl, int edge_pixels,
|
||||||
enum xdg_toplevel_resize_edge *edge)
|
enum xdg_toplevel_resize_edge *edges)
|
||||||
{
|
{
|
||||||
if (wl->opts->fullscreen || wl->opts->window_maximized)
|
if (wl->opts->fullscreen || wl->opts->window_maximized)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int pos[2] = { wl->mouse_x, wl->mouse_y };
|
int pos[2] = { wl->mouse_x, wl->mouse_y };
|
||||||
int left_edge = pos[0] < edge_pixels;
|
*edges = 0;
|
||||||
int top_edge = pos[1] < edge_pixels;
|
|
||||||
int right_edge = pos[0] > (mp_rect_w(wl->geometry) - edge_pixels);
|
|
||||||
int bottom_edge = pos[1] > (mp_rect_h(wl->geometry) - edge_pixels);
|
|
||||||
|
|
||||||
if (left_edge) {
|
if (pos[0] < edge_pixels)
|
||||||
*edge = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
|
*edges |= XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
|
||||||
if (top_edge)
|
if (pos[0] > (mp_rect_w(wl->geometry) - edge_pixels))
|
||||||
*edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
|
*edges |= XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
|
||||||
else if (bottom_edge)
|
if (pos[1] < edge_pixels)
|
||||||
*edge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
|
*edges |= XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
||||||
} else if (right_edge) {
|
if (pos[1] > (mp_rect_h(wl->geometry) - edge_pixels))
|
||||||
*edge = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
|
*edges |= XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
|
||||||
if (top_edge)
|
|
||||||
*edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
|
|
||||||
else if (bottom_edge)
|
|
||||||
*edge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
|
|
||||||
} else if (top_edge) {
|
|
||||||
*edge = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
|
||||||
} else if (bottom_edge) {
|
|
||||||
*edge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
|
|
||||||
} else {
|
|
||||||
*edge = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return *edges;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool create_input(struct vo_wayland_state *wl)
|
static bool create_input(struct vo_wayland_state *wl)
|
||||||
|
|
Loading…
Reference in New Issue