diff options
| author | Leonardo Hernández Hernández <leohdz172@protonmail.com> | 2021-07-12 19:58:55 -0500 | 
|---|---|---|
| committer | Leonardo Hernández Hernández <leohdz172@protonmail.com> | 2022-03-24 11:35:19 -0600 | 
| commit | ae614ee5125891a4d75fac97c754207f97834a7d (patch) | |
| tree | 7f7739dbe143916c15e1982368e29dffc4c16da3 | |
| parent | feb972acd0ea130bc3af0f0f7072a70fa3c786bc (diff) | |
implement idle-inhibitor protocol
This allows clients to disable idle monitoring
Diffstat (limited to '')
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | dwl.c | 27 | 
2 files changed, 28 insertions, 1 deletions
| @@ -14,6 +14,7 @@ dwl is not meant to provide every feature under the sun. Instead, like dwm, it s  - Any features provided by dwm/Xlib: simple window borders, tags, keybindings, client rules, mouse move/resize. Providing a built-in status bar is an exception to this goal, to avoid dependencies on font rendering and/or drawing libraries when an external bar could work well.  - Configurable multi-monitor layout support, including position and rotation  - Configurable HiDPI/multi-DPI support +- Idle-inhibit protocol which lets applications such as mpv disable idle monitoring  - Provide information to external status bars via stdout/stdin  - Urgency hints via xdg-activate protocol  - Various Wayland protocols @@ -26,7 +27,6 @@ Features under consideration (possibly as patches) are:  - Protocols made trivial by wlroots  - Implement the input-inhibitor protocol to support screen lockers (see https://github.com/djpohly/dwl/pull/132) -- Implement the idle-inhibit protocol which lets applications such as mpv disable idle monitoring (see https://github.com/djpohly/dwl/pull/133)  - Implement the text-input and input-method protocols to support IME once ibus implements input-method v2 (see https://github.com/ibus/ibus/pull/2256 and https://github.com/djpohly/dwl/pull/12)  Feature *non-goals* for the main codebase include: @@ -23,6 +23,7 @@  #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_idle_inhibit_v1.h>  #include <wlr/types/wlr_layer_shell_v1.h>  #include <wlr/types/wlr_keyboard.h>  #include <wlr/types/wlr_matrix.h> @@ -219,12 +220,14 @@ static void cleanupmon(struct wl_listener *listener, void *data);  static void closemon(Monitor *m);  static void commitlayersurfacenotify(struct wl_listener *listener, void *data);  static void commitnotify(struct wl_listener *listener, void *data); +static void createidleinhibitor(struct wl_listener *listener, void *data);  static void createkeyboard(struct wlr_input_device *device);  static void createmon(struct wl_listener *listener, void *data);  static void createnotify(struct wl_listener *listener, void *data);  static void createlayersurface(struct wl_listener *listener, void *data);  static void createpointer(struct wlr_input_device *device);  static void cursorframe(struct wl_listener *listener, void *data); +static void destroyidleinhibitor(struct wl_listener *listener, void *data);  static void destroylayersurfacenotify(struct wl_listener *listener, void *data);  static void destroynotify(struct wl_listener *listener, void *data);  static Monitor *dirtomon(enum wlr_direction dir); @@ -307,6 +310,7 @@ static struct wlr_xdg_activation_v1 *activation;  static struct wl_list clients; /* tiling order */  static struct wl_list fstack;  /* focus order */  static struct wlr_idle *idle; +static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;  static struct wlr_layer_shell_v1 *layer_shell;  static struct wlr_output_manager_v1 *output_mgr;  static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr; @@ -331,6 +335,8 @@ static struct wl_listener cursor_button = {.notify = buttonpress};  static struct wl_listener cursor_frame = {.notify = cursorframe};  static struct wl_listener cursor_motion = {.notify = motionrelative};  static struct wl_listener cursor_motion_absolute = {.notify = motionabsolute}; +static struct wl_listener idle_inhibitor_create = {.notify = createidleinhibitor}; +static struct wl_listener idle_inhibitor_destroy = {.notify = destroyidleinhibitor};  static struct wl_listener layout_change = {.notify = updatemons};  static struct wl_listener new_input = {.notify = inputdevice};  static struct wl_listener new_virtual_keyboard = {.notify = virtualkeyboard}; @@ -770,6 +776,15 @@ commitnotify(struct wl_listener *listener, void *data)  }  void +createidleinhibitor(struct wl_listener *listener, void *data) +{ +	struct wlr_idle_inhibitor_v1 *idle_inhibitor = data; +	wl_signal_add(&idle_inhibitor->events.destroy, &idle_inhibitor_destroy); + +	wlr_idle_set_enabled(idle, seat, 0); +} + +void  createkeyboard(struct wlr_input_device *device)  {  	struct xkb_context *context; @@ -989,6 +1004,14 @@ cursorframe(struct wl_listener *listener, void *data)  }  void +destroyidleinhibitor(struct wl_listener *listener, void *data) +{ +	/* I've been testing and at this point the inhibitor has not yet been +	 * removed from the list, checking if it has at least one item. */ +	wlr_idle_set_enabled(idle, seat, wl_list_length(&idle_inhibit_mgr->inhibitors) <= 1); +} + +void  destroylayersurfacenotify(struct wl_listener *listener, void *data)  {  	LayerSurface *layersurface = wl_container_of(listener, layersurface, destroy); @@ -1147,6 +1170,7 @@ focusclient(Client *c, int lift)  	}  	printstatus(); +	wlr_idle_set_enabled(idle, seat, wl_list_empty(&idle_inhibit_mgr->inhibitors));  	if (!c) {  		/* With no client, all we have left is to clear focus */ @@ -1963,6 +1987,9 @@ setup(void)  	idle = wlr_idle_create(dpy); +	idle_inhibit_mgr = wlr_idle_inhibit_v1_create(dpy); +	wl_signal_add(&idle_inhibit_mgr->events.new_inhibitor, &idle_inhibitor_create); +  	layer_shell = wlr_layer_shell_v1_create(dpy);  	wl_signal_add(&layer_shell->events.new_surface, &new_layer_shell_surface); | 
