diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2024-05-23 14:34:24 +0200 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2024-05-23 14:34:24 +0200 |
| commit | 61dbaa7b8243f6868f9f900b0113136a48cd9be4 (patch) | |
| tree | 9599c595325bb01fad96f7a48394faef34569f6d | |
| parent | c04cb31d9fd4971bc4dac94998428fbbcabef5c9 (diff) | |
idle_inhibit: Ignore inhibitors when locked
When a session is locked, no views are visible and there is no way to
interact with the user session. This means that all inhibitors based on
visibility - with the exception being inhibitors on the session lock
surfaces themselves - become inert, allowing the session to go idle.
The only inhibitor type on normal views that one could argue should
remain active is INHIBIT_IDLE_OPEN, but for now we disable all view
inhibitors regardless of type.
| -rw-r--r-- | sway/desktop/idle_inhibit_v1.c | 14 | ||||
| -rw-r--r-- | sway/lock.c | 7 | ||||
| -rw-r--r-- | sway/tree/view.c | 4 |
3 files changed, 25 insertions, 0 deletions
diff --git a/sway/desktop/idle_inhibit_v1.c b/sway/desktop/idle_inhibit_v1.c index f3af7aa1..d241cdaf 100644 --- a/sway/desktop/idle_inhibit_v1.c +++ b/sway/desktop/idle_inhibit_v1.c @@ -1,5 +1,6 @@ #include <stdlib.h> #include <wlr/types/wlr_idle_notify_v1.h> +#include <wlr/types/wlr_session_lock_v1.h> #include "log.h" #include "sway/desktop/idle_inhibit_v1.h" #include "sway/input/seat.h" @@ -103,6 +104,19 @@ void sway_idle_inhibit_v1_user_inhibitor_destroy( } bool sway_idle_inhibit_v1_is_active(struct sway_idle_inhibitor_v1 *inhibitor) { + if (server.session_lock.lock) { + // A session lock is active. In this case, only application inhibitors + // on the session lock surface can have any effect. + if (inhibitor->mode != INHIBIT_IDLE_APPLICATION) { + return false; + } + struct wlr_surface *wlr_surface = inhibitor->wlr_inhibitor->surface; + if (!wlr_session_lock_surface_v1_try_from_wlr_surface(wlr_surface)) { + return false; + } + return wlr_surface->mapped; + } + switch (inhibitor->mode) { case INHIBIT_IDLE_APPLICATION:; // If there is no view associated with the inhibitor, assume visible diff --git a/sway/lock.c b/sway/lock.c index 43f31330..c8975c74 100644 --- a/sway/lock.c +++ b/sway/lock.c @@ -234,6 +234,9 @@ static void handle_unlock(struct wl_listener *listener, void *data) { struct sway_output *output = root->outputs->items[i]; arrange_layers(output); } + + // Views are now visible, so check if we need to activate inhibition again. + sway_idle_inhibit_v1_check_active(); } static void handle_abandon(struct wl_listener *listener, void *data) { @@ -297,6 +300,10 @@ static void handle_session_lock(struct wl_listener *listener, void *data) { wlr_session_lock_v1_send_locked(lock); server.session_lock.lock = sway_lock; + + // The lock screen covers everything, so check if any active inhibition got + // deactivated due to lost visibility. + sway_idle_inhibit_v1_check_active(); } static void handle_session_lock_destroy(struct wl_listener *listener, void *data) { diff --git a/sway/tree/view.c b/sway/tree/view.c index a5617fb4..16080a2f 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -218,6 +218,10 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, } bool view_inhibit_idle(struct sway_view *view) { + if (server.session_lock.lock) { + return false; + } + struct sway_idle_inhibitor_v1 *user_inhibitor = sway_idle_inhibit_v1_user_inhibitor_for_view(view); |
