struct wlr_layer_surface_v1 *focused_layer;
/**
- * active_view will usually be NULL and is only set on button press
- * while the mouse is over a view surface and reset to NULL on button
- * release.
+ * pressed view/surface will usually be NULL and is only set on button
+ * press while the mouse is over a view surface and reset to NULL on
+ * button release.
* It is used to send cursor motion events to a surface even though
* the cursor has left the surface in the meantime.
*
* This allows to keep dragging a scrollbar or selecting text even
* when moving outside of the window.
*/
- struct view *active_view;
+ struct {
+ struct view *view;
+ struct wlr_surface *surface;
+ } pressed;
struct wl_client *active_client_while_inhibited;
struct wl_list inputs;
hover->node = NULL;
}
- if (server->seat.active_view && !server->seat.drag_icon) {
+ if (server->seat.pressed.surface &&
+ server->seat.pressed.surface != surface &&
+ !server->seat.drag_icon) {
/*
* Button has been pressed while over a view surface
* and is still held down. Just send the adjusted motion
* events to the focused surface so we can keep scrolling
* or selecting text even if the cursor moves outside of
* the surface.
+ *
+ * TODO: This seems to miss calculations for invisible CSD borders.
+ * Tracked at https://github.com/labwc/labwc/issues/340
*/
- view = server->seat.active_view;
- double sx = server->seat.cursor->x - view->x;
- double sy = server->seat.cursor->y - view->y;
+ view = server->seat.pressed.view;
+ sx = server->seat.cursor->x - view->x;
+ sy = server->seat.cursor->y - view->y;
sx = sx < 0 ? 0 : (sx > view->w ? view->w : sx);
sy = sy < 0 ? 0 : (sy > view->h ? view->h : sy);
wlr_seat_pointer_notify_motion(server->seat.seat, time, sx, sy);
- } else if (surface &&
- !input_inhibit_blocks_surface(&server->seat, surface->resource)) {
+ } else if (surface && !input_inhibit_blocks_surface(
+ &server->seat, surface->resource)) {
bool focus_changed =
wlr_seat->pointer_state.focused_surface != surface;
/*
{
struct seat *seat = wl_container_of(listener, seat, start_drag);
struct wlr_drag *wlr_drag = data;
- seat->active_view = NULL;
+ seat->pressed.view = NULL;
+ seat->pressed.surface = NULL;
seat->drag_icon = wlr_drag->icon;
if (!seat->drag_icon) {
wlr_log(WLR_ERROR,
/* handle _release_ */
if (event->state == WLR_BUTTON_RELEASED) {
- server->seat.active_view = NULL;
+ server->seat.pressed.view = NULL;
+ server->seat.pressed.surface = NULL;
if (server->input_mode == LAB_INPUT_STATE_MENU) {
if (close_menu) {
/* Handle _press */
if (view_area == LAB_SSD_CLIENT) {
- server->seat.active_view = view;
+ server->seat.pressed.view = view;
+ server->seat.pressed.surface = surface;
}
if (server->input_mode == LAB_INPUT_STATE_MENU) {