/*
* Common logic shared by cursor_update_focus(), process_cursor_motion()
- * and cursor_axis()
+ * and process_cursor_axis()
*/
-static bool
-cursor_update_common(struct server *server, struct cursor_context *ctx,
- bool cursor_has_moved, double *sx, double *sy)
+static void
+cursor_update_common(struct server *server, const struct cursor_context *ctx,
+ struct cursor_context *notified_ctx)
{
struct seat *seat = &server->seat;
struct wlr_seat *wlr_seat = seat->seat;
* interactive move/resize, window switcher and
* menu interaction.
*/
- return false;
+ return;
}
/* TODO: verify drag_icon logic */
if (seat->pressed.ctx.surface && ctx->surface != seat->pressed.ctx.surface
&& !update_pressed_surface(seat, ctx)
&& !seat->drag.active) {
- if (cursor_has_moved) {
+ if (notified_ctx) {
/*
* Button has been pressed while over another
* surface and is still held down. Just send
*/
int lx, ly;
wlr_scene_node_coords(seat->pressed.ctx.node, &lx, &ly);
- *sx = server->seat.cursor->x - lx;
- *sy = server->seat.cursor->y - ly;
- return true;
+ *notified_ctx = seat->pressed.ctx;
+ notified_ctx->sx = server->seat.cursor->x - lx;
+ notified_ctx->sy = server->seat.cursor->y - ly;
}
- return false;
+ return;
+ }
+
+ if (notified_ctx) {
+ *notified_ctx = *ctx;
}
if (ctx->surface) {
wlr_seat_pointer_notify_enter(wlr_seat, ctx->surface,
ctx->sx, ctx->sy);
seat->server_cursor = LAB_CURSOR_CLIENT;
- if (cursor_has_moved) {
- *sx = ctx->sx;
- *sy = ctx->sy;
- return true;
- }
} else {
/*
* Cursor is over a server (labwc) surface. Clear focus
cursor_set(seat, cursor);
}
}
- return false;
}
enum lab_edge
struct wlr_surface *old_focused_surface =
seat->seat->pointer_state.focused_surface;
- bool notify = cursor_update_common(server, &ctx,
- /* cursor_has_moved */ true, sx, sy);
+ /*
+ * Cursor context that is actually interacting with cursor and should
+ * be notified to the client. E.g. it is cleared when menu is open,
+ * and the pressed view is set while out-of-surface dragging.
+ */
+ struct cursor_context notified_ctx = {0};
+ cursor_update_common(server, &ctx, ¬ified_ctx);
struct wlr_surface *new_focused_surface =
seat->seat->pointer_state.focused_surface;
new_focused_surface, rc.raise_on_focus);
}
- return notify;
+ *sx = notified_ctx.sx;
+ *sy = notified_ctx.sy;
+ return notified_ctx.surface;
}
static void
ctx.surface, rc.raise_on_focus);
}
- double sx, sy;
- cursor_update_common(server, &ctx, /*cursor_has_moved*/ false, &sx, &sy);
+ cursor_update_common(server, &ctx, NULL);
}
void
/* Bindings swallow mouse events if activated */
if (ctx.surface && !consumed) {
/* Make sure we are sending the events to the surface under the cursor */
- double sx, sy;
- cursor_update_common(server, &ctx, /*cursor_has_moved*/ false, &sx, &sy);
+ cursor_update_common(server, &ctx, NULL);
return true;
}