diff options
author | Guido Cella <guidocella91@gmail.com> | 2020-08-28 20:18:42 +0200 |
---|---|---|
committer | Guido Cella <guido@guidocella.xyz> | 2020-12-19 12:34:32 +0100 |
commit | 41cc23e1cfc248eb10878fd172ca969ed27a5f44 (patch) | |
tree | 00a3502e947138ae48968deea30a14977c79342e /dwl.c | |
parent | 1024928c15cebbeb1c652a6ba4a243f1c330bac8 (diff) |
Implement the idle protocol
It allows clients such as swayidle and chat applications to monitor user
idle time.
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -20,6 +20,7 @@ #include <wlr/types/wlr_export_dmabuf_v1.h> #include <wlr/types/wlr_gamma_control_v1.h> #include <wlr/types/wlr_input_device.h> +#include <wlr/types/wlr_idle.h> #include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_keyboard.h> #include <wlr/types/wlr_matrix.h> @@ -292,6 +293,7 @@ static struct wl_list clients; /* tiling order */ static struct wl_list fstack; /* focus order */ static struct wl_list stack; /* stacking z-order */ static struct wl_list independents; +static struct wlr_idle *idle; static struct wlr_layer_shell_v1 *layer_shell; static struct wlr_xdg_decoration_manager_v1 *xdeco_mgr; static struct wlr_output_manager_v1 *output_mgr; @@ -611,6 +613,7 @@ axisnotify(struct wl_listener *listener, void *data) /* This event is forwarded by the cursor when a pointer emits an axis event, * for example when you move the scroll wheel. */ struct wlr_event_pointer_axis *event = data; + wlr_idle_notify_activity(idle, seat); /* Notify the client with pointer focus of the axis event. */ wlr_seat_pointer_notify_axis(seat, event->time_msec, event->orientation, event->delta, @@ -626,6 +629,8 @@ buttonpress(struct wl_listener *listener, void *data) Client *c; const Button *b; + wlr_idle_notify_activity(idle, seat); + switch (event->state) { case WLR_BUTTON_PRESSED:; /* Change focus if the button was _pressed_ over a client */ @@ -1217,6 +1222,9 @@ keypress(struct wl_listener *listener, void *data) int handled = 0; uint32_t mods = wlr_keyboard_get_modifiers(kb->device->keyboard); + + wlr_idle_notify_activity(idle, seat); + /* On _press_, attempt to process a compositor keybinding. */ if (event->state == WLR_KEY_PRESSED) for (i = 0; i < nsyms; i++) @@ -1346,6 +1354,8 @@ motionnotify(uint32_t time) time = now.tv_sec * 1000 + now.tv_nsec / 1000000; } + wlr_idle_notify_activity(idle, seat); + /* Update selmon (even while dragging a window) */ if (sloppyfocus) selmon = xytomon(cursor->x, cursor->y); @@ -1999,6 +2009,8 @@ setup(void) wl_list_init(&stack); wl_list_init(&independents); + idle = wlr_idle_create(dpy); + layer_shell = wlr_layer_shell_v1_create(dpy); wl_signal_add(&layer_shell->events.new_surface, &new_layer_shell_surface); |