mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
Add idle tracking
Note that this does not do much without an idle manager "on the other side". See, for example, swayidle: https://github.com/swaywm/sway/blob/master/swayidle/swayidle.1.scd Fixes #7.
This commit is contained in:
parent
96372c145f
commit
bf58eadf50
3 changed files with 30 additions and 0 deletions
11
cage.c
11
cage.c
|
|
@ -20,6 +20,7 @@
|
|||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#if CAGE_HAS_XWAYLAND
|
||||
#include <wlr/types/wlr_xcursor_manager.h>
|
||||
|
|
@ -151,6 +152,13 @@ main(int argc, char *argv[])
|
|||
goto end;
|
||||
}
|
||||
|
||||
server.idle = wlr_idle_create(server.wl_display);
|
||||
if (!server.idle) {
|
||||
wlr_log(WLR_ERROR, "Unable to create the idle tracker");
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
xdg_shell = wlr_xdg_shell_create(server.wl_display);
|
||||
if (!xdg_shell) {
|
||||
wlr_log(WLR_ERROR, "Unable to create the XDG shell interface");
|
||||
|
|
@ -228,6 +236,9 @@ end:
|
|||
wlr_xcursor_manager_destroy(xcursor_manager);
|
||||
#endif
|
||||
wlr_xdg_shell_destroy(xdg_shell);
|
||||
if (server.idle) {
|
||||
wlr_idle_destroy(server.idle);
|
||||
}
|
||||
wlr_data_device_manager_destroy(data_device_mgr);
|
||||
wlr_compositor_destroy(compositor);
|
||||
wlr_output_layout_destroy(server.output_layout);
|
||||
|
|
|
|||
17
seat.c
17
seat.c
|
|
@ -13,6 +13,7 @@
|
|||
#include <wayland-server.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_xcursor_manager.h>
|
||||
|
|
@ -195,6 +196,8 @@ handle_keyboard_modifiers(struct wl_listener *listener, void *data)
|
|||
wlr_seat_set_keyboard(keyboard->seat->seat, keyboard->device);
|
||||
wlr_seat_keyboard_notify_modifiers(keyboard->seat->seat,
|
||||
&keyboard->device->keyboard->modifiers);
|
||||
|
||||
wlr_idle_notify_activity(keyboard->seat->server->idle, keyboard->seat->seat);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -209,6 +212,7 @@ handle_keybinding(struct cg_server *server, xkb_keysym_t sym)
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
wlr_idle_notify_activity(server->idle, server->seat->seat);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -242,6 +246,8 @@ handle_keyboard_key(struct wl_listener *listener, void *data)
|
|||
wlr_seat_keyboard_notify_key(seat->seat, event->time_msec,
|
||||
event->keycode, event->state);
|
||||
}
|
||||
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -381,6 +387,8 @@ handle_touch_down(struct wl_listener *listener, void *data)
|
|||
press_cursor_button(seat, event->device, event->time_msec,
|
||||
BTN_LEFT, WLR_BUTTON_PRESSED, lx, ly);
|
||||
}
|
||||
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -400,6 +408,7 @@ handle_touch_up(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
wlr_seat_touch_notify_up(seat->seat, event->time_msec, event->touch_id);
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -435,6 +444,8 @@ handle_touch_motion(struct wl_listener *listener, void *data)
|
|||
seat->touch_x = lx;
|
||||
seat->touch_y = ly;
|
||||
}
|
||||
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -446,6 +457,7 @@ handle_cursor_axis(struct wl_listener *listener, void *data)
|
|||
wlr_seat_pointer_notify_axis(seat->seat,
|
||||
event->time_msec, event->orientation, event->delta,
|
||||
event->delta_discrete, event->source);
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -459,6 +471,7 @@ handle_cursor_button(struct wl_listener *listener, void *data)
|
|||
press_cursor_button(seat, event->device, event->time_msec,
|
||||
event->button, event->state,
|
||||
seat->cursor->x, seat->cursor->y);
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -482,6 +495,8 @@ process_cursor_motion(struct cg_seat *seat, uint32_t time)
|
|||
wlr_seat_pointer_notify_motion(wlr_seat, time, sx, sy);
|
||||
}
|
||||
}
|
||||
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -492,6 +507,7 @@ handle_cursor_motion_absolute(struct wl_listener *listener, void *data)
|
|||
|
||||
wlr_cursor_warp_absolute(seat->cursor, event->device, event->x, event->y);
|
||||
process_cursor_motion(seat, event->time_msec);
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -502,6 +518,7 @@ handle_cursor_motion(struct wl_listener *listener, void *data)
|
|||
|
||||
wlr_cursor_move(seat->cursor, event->device, event->delta_x, event->delta_y);
|
||||
process_cursor_motion(seat, event->time_msec);
|
||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
2
server.h
2
server.h
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#if CAGE_HAS_XWAYLAND
|
||||
#include <wlr/xwayland.h>
|
||||
|
|
@ -21,6 +22,7 @@ struct cg_server {
|
|||
struct wl_list views;
|
||||
|
||||
struct cg_seat *seat;
|
||||
struct wlr_idle *idle;
|
||||
|
||||
struct wlr_output_layout *output_layout;
|
||||
struct cg_output *output;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue