mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
src/cursor.c: Keep sending motion events for out-of-layer-surface
Previously, motion events for a cursor which had been pressed on a surface and then moved out of the surface were only sent for XDG and X11 surfaces. This patch includes layer surfaces as well. Fixes #483
This commit is contained in:
parent
8e6d37772e
commit
921c877f79
3 changed files with 36 additions and 21 deletions
|
|
@ -95,8 +95,8 @@ struct seat {
|
||||||
struct wlr_layer_surface_v1 *focused_layer;
|
struct wlr_layer_surface_v1 *focused_layer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pressed view/surface will usually be NULL and is only set on button
|
* pressed view/surface/node will usually be NULL and is only set on
|
||||||
* press while the mouse is over a view surface and reset to NULL on
|
* button press while the mouse is over a surface and reset to NULL on
|
||||||
* button release.
|
* button release.
|
||||||
* It is used to send cursor motion events to a surface even though
|
* It is used to send cursor motion events to a surface even though
|
||||||
* the cursor has left the surface in the meantime.
|
* the cursor has left the surface in the meantime.
|
||||||
|
|
@ -106,6 +106,7 @@ struct seat {
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
struct view *view;
|
struct view *view;
|
||||||
|
struct wlr_scene_node *node;
|
||||||
struct wlr_surface *surface;
|
struct wlr_surface *surface;
|
||||||
} pressed;
|
} pressed;
|
||||||
|
|
||||||
|
|
|
||||||
48
src/cursor.c
48
src/cursor.c
|
|
@ -289,29 +289,36 @@ process_cursor_motion(struct server *server, uint32_t time)
|
||||||
* or selecting text even if the cursor moves outside of
|
* or selecting text even if the cursor moves outside of
|
||||||
* the surface.
|
* the surface.
|
||||||
*/
|
*/
|
||||||
|
int lx, ly;
|
||||||
view = server->seat.pressed.view;
|
view = server->seat.pressed.view;
|
||||||
if (!view) {
|
if (view) {
|
||||||
/* Button press originated on a layer surface, just ignore */
|
lx = view->x;
|
||||||
|
ly = view->y;
|
||||||
|
} else if (wlr_surface_is_layer_surface(server->seat.pressed.surface)) {
|
||||||
|
wlr_scene_node_coords(server->seat.pressed.node, &lx, &ly);
|
||||||
|
} else {
|
||||||
|
wlr_log(WLR_ERROR, "Can't detect surface for out-of-surface movement");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sx = server->seat.cursor->x - view->x;
|
sx = server->seat.cursor->x - lx;
|
||||||
sy = server->seat.cursor->y - view->y;
|
sy = server->seat.cursor->y - ly;
|
||||||
/*
|
|
||||||
* X11 apps expect to be able to receive motion events outside
|
if (view && view->type == LAB_XDG_SHELL_VIEW) {
|
||||||
* the window area (this is necessary for client-side move/resize
|
/*
|
||||||
* handles to work properly). So do not clamp the motion
|
* X11 apps expect to be able to receive motion events outside
|
||||||
* coordinates for XWayland surfaces.
|
* the window area (this is necessary for client-side move/resize
|
||||||
*/
|
* handles to work properly). So only clamp the motion coordinates
|
||||||
if (view->type == LAB_XDG_SHELL_VIEW) {
|
* for XDG surfaces.
|
||||||
|
*/
|
||||||
sx = sx < 0 ? 0 : (sx > view->w ? view->w : sx);
|
sx = sx < 0 ? 0 : (sx > view->w ? view->w : sx);
|
||||||
sy = sy < 0 ? 0 : (sy > view->h ? view->h : sy);
|
sy = sy < 0 ? 0 : (sy > view->h ? view->h : sy);
|
||||||
}
|
|
||||||
if (view->type == LAB_XDG_SHELL_VIEW && view->xdg_surface) {
|
|
||||||
/* Take into account invisible CSD borders */
|
/* Take into account invisible CSD borders */
|
||||||
struct wlr_box geo;
|
if (view->xdg_surface) {
|
||||||
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo);
|
struct wlr_box geo;
|
||||||
sx += geo.x;
|
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo);
|
||||||
sy += geo.y;
|
sx += geo.x;
|
||||||
|
sy += geo.y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wlr_seat_pointer_notify_motion(server->seat.seat, time, sx, sy);
|
wlr_seat_pointer_notify_motion(server->seat.seat, time, sx, sy);
|
||||||
} else if (surface && !input_inhibit_blocks_surface(
|
} else if (surface && !input_inhibit_blocks_surface(
|
||||||
|
|
@ -367,6 +374,7 @@ start_drag(struct wl_listener *listener, void *data)
|
||||||
struct seat *seat = wl_container_of(listener, seat, start_drag);
|
struct seat *seat = wl_container_of(listener, seat, start_drag);
|
||||||
struct wlr_drag *wlr_drag = data;
|
struct wlr_drag *wlr_drag = data;
|
||||||
seat->pressed.view = NULL;
|
seat->pressed.view = NULL;
|
||||||
|
seat->pressed.node = NULL;
|
||||||
seat->pressed.surface = NULL;
|
seat->pressed.surface = NULL;
|
||||||
seat->drag_icon = wlr_drag->icon;
|
seat->drag_icon = wlr_drag->icon;
|
||||||
if (!seat->drag_icon) {
|
if (!seat->drag_icon) {
|
||||||
|
|
@ -715,6 +723,7 @@ cursor_button(struct wl_listener *listener, void *data)
|
||||||
/* handle _release_ */
|
/* handle _release_ */
|
||||||
if (event->state == WLR_BUTTON_RELEASED) {
|
if (event->state == WLR_BUTTON_RELEASED) {
|
||||||
seat->pressed.view = NULL;
|
seat->pressed.view = NULL;
|
||||||
|
seat->pressed.node = NULL;
|
||||||
if (seat->pressed.surface && seat->pressed.surface != surface) {
|
if (seat->pressed.surface && seat->pressed.surface != surface) {
|
||||||
/*
|
/*
|
||||||
* Button released but originally pressed over a different surface.
|
* Button released but originally pressed over a different surface.
|
||||||
|
|
@ -755,8 +764,9 @@ cursor_button(struct wl_listener *listener, void *data)
|
||||||
|
|
||||||
/* Handle _press */
|
/* Handle _press */
|
||||||
if (surface) {
|
if (surface) {
|
||||||
server->seat.pressed.view = view;
|
seat->pressed.view = view;
|
||||||
server->seat.pressed.surface = surface;
|
seat->pressed.node = node;
|
||||||
|
seat->pressed.surface = surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
if (server->input_mode == LAB_INPUT_STATE_MENU) {
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,10 @@ unmap(struct lab_layer_surface *layer)
|
||||||
if (seat->focused_layer == layer->scene_layer_surface->layer_surface) {
|
if (seat->focused_layer == layer->scene_layer_surface->layer_surface) {
|
||||||
seat_set_focus_layer(seat, NULL);
|
seat_set_focus_layer(seat, NULL);
|
||||||
}
|
}
|
||||||
|
if (seat->pressed.surface == layer->scene_layer_surface->layer_surface->surface) {
|
||||||
|
seat->pressed.node = NULL;
|
||||||
|
seat->pressed.surface = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue