From 38ca94e0ed2fe33ab71076680e9f70409a2e4115 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 1 Sep 2016 08:34:52 -0400 Subject: Tweak how swaylock surfaces are handled Fixes #875 --- sway/extensions.c | 14 ++++---------- sway/focus.c | 15 +++++++-------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/sway/extensions.c b/sway/extensions.c index 70ec537d..60cd8d41 100644 --- a/sway/extensions.c +++ b/sway/extensions.c @@ -119,27 +119,21 @@ static void set_lock_surface(struct wl_client *client, struct wl_resource *resou if (!swayc_is_child_of(view, workspace)) { move_container_to(view, workspace); } - // make the view floating so it doesn't rearrange other - // siblings. + // make the view floating so it doesn't rearrange other siblings. if (!view->is_floating) { - // Remove view from its current location destroy_container(remove_child(view)); - // and move it into workspace floating add_floating(workspace, view); } wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true); - workspace->fullscreen = view; - ipc_event_window(view, "fullscreen_mode"); + wlc_view_bring_to_front(view->handle); + wlc_view_focus(view->handle); desktop_shell.is_locked = true; - // reset input state input_init(); - // set focus if the lockscreen is spawned on the currently - // active output + arrange_windows(workspace, -1, -1); swayc_t *focus_output = swayc_active_output(); if (focus_output == output) { set_focused_container(view); } - arrange_windows(workspace, -1, -1); list_add(desktop_shell.lock_surfaces, surface); wl_resource_set_destructor(surface, lock_surface_destructor); } else { diff --git a/sway/focus.c b/sway/focus.c index 9207260d..02e61ac2 100644 --- a/sway/focus.c +++ b/sway/focus.c @@ -3,6 +3,7 @@ #include "sway/workspace.h" #include "sway/layout.h" #include "sway/config.h" +#include "sway/extensions.h" #include "sway/input_state.h" #include "sway/ipc-server.h" #include "sway/border.h" @@ -88,7 +89,6 @@ swayc_t *get_focused_container(swayc_t *parent) { if (!parent) { return swayc_active_workspace(); } - // get focused container while (!parent->is_focused && parent->focused) { parent = parent->focused; } @@ -132,24 +132,24 @@ bool set_focused_container(swayc_t *c) { p->is_focused = false; } - // get new focused view and set focus to it. if (!(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) { - // unactivate previous focus if (focused->type == C_VIEW) { wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); } update_container_border(focused); - // activate current focus if (c->type == C_VIEW) { wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true); } - // set focus - wlc_view_focus(c->handle); + if (!desktop_shell.is_locked) { + // If the system is locked, we do everything _but_ actually setting + // focus. This includes making our internals think that this view is + // focused. + wlc_view_focus(c->handle); + } if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) { update_container_border(c); } - // rearrange if parent container is tabbed/stacked swayc_t *parent = swayc_tabbed_stacked_ancestor(c); if (parent != NULL) { arrange_backgrounds(); @@ -174,7 +174,6 @@ bool set_focused_container_for(swayc_t *a, swayc_t *c) { return false; } swayc_t *find = c; - // Ensure that a is an ancestor of c while (find != a && (find = find->parent)) { if (find == &root_container) { return false; -- cgit v1.2.3-54-g00ecf