mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
cage: hook up cursor motion handler
This commit is contained in:
parent
d683e2904f
commit
2899abf95f
2 changed files with 36 additions and 0 deletions
35
cageng.c
35
cageng.c
|
|
@ -223,6 +223,39 @@ handle_new_output(struct wl_listener *listener, void *user_data)
|
||||||
cage_output_init(output, wlr_output);
|
cage_output_init(output, wlr_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
desktop_surface_at(struct cg_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
|
||||||
|
{
|
||||||
|
struct wlr_output *wlr_output = wlr_output_layout_output_at(server->output_layout, lx, ly);
|
||||||
|
struct cg_output *output = wlr_output->data;
|
||||||
|
|
||||||
|
cage_output_surface_at(output, lx, ly, surface, sx, sy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_cursor_motion(struct wl_listener *listener, void *user_data)
|
||||||
|
{
|
||||||
|
struct cg_server *server = wl_container_of(listener, server, cursor_motion);
|
||||||
|
struct wlr_cursor *wlr_cursor = server->seat->cursor->wlr_cursor;
|
||||||
|
struct wlr_seat *wlr_seat = server->seat->wlr_seat;
|
||||||
|
uint32_t time = *(uint32_t *) user_data;
|
||||||
|
|
||||||
|
double sx, sy;
|
||||||
|
struct wlr_surface *surface = NULL;
|
||||||
|
desktop_surface_at(server, wlr_cursor->x, wlr_cursor->y, &surface, &sx, &sy);
|
||||||
|
|
||||||
|
if (!surface) {
|
||||||
|
wlr_seat_pointer_clear_focus(wlr_seat);
|
||||||
|
} else {
|
||||||
|
wlr_seat_pointer_notify_enter(wlr_seat, surface, sx, sy);
|
||||||
|
|
||||||
|
bool focus_changed = wlr_seat->pointer_state.focused_surface != surface;
|
||||||
|
if (!focus_changed && time > 0) {
|
||||||
|
wlr_seat_pointer_notify_motion(wlr_seat, time, sx, sy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_new_input(struct wl_listener *listener, void *user_data)
|
handle_new_input(struct wl_listener *listener, void *user_data)
|
||||||
{
|
{
|
||||||
|
|
@ -431,6 +464,8 @@ main(int argc, char *argv[])
|
||||||
server.seat = seat;
|
server.seat = seat;
|
||||||
server.new_input.notify = handle_new_input;
|
server.new_input.notify = handle_new_input;
|
||||||
wl_signal_add(&backend->events.new_input, &server.new_input);
|
wl_signal_add(&backend->events.new_input, &server.new_input);
|
||||||
|
server.cursor_motion.notify = handle_cursor_motion;
|
||||||
|
wl_signal_add(&seat->cursor->events.motion, &server.cursor_motion);
|
||||||
|
|
||||||
const char *socket = wl_display_add_socket_auto(server.wl_display);
|
const char *socket = wl_display_add_socket_auto(server.wl_display);
|
||||||
if (!socket) {
|
if (!socket) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ struct cg_server {
|
||||||
|
|
||||||
struct cg_seat *seat;
|
struct cg_seat *seat;
|
||||||
struct wl_listener new_input;
|
struct wl_listener new_input;
|
||||||
|
struct wl_listener cursor_motion;
|
||||||
|
|
||||||
/* Includes disabled outputs. */
|
/* Includes disabled outputs. */
|
||||||
struct wl_list outputs; // cg_output::link
|
struct wl_list outputs; // cg_output::link
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue