summaryrefslogtreecommitdiffstats
path: root/sway/focus.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/focus.c')
-rw-r--r--sway/focus.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/sway/focus.c b/sway/focus.c
index 145e5584..02e61ac2 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -1,13 +1,13 @@
1#include <wlc/wlc.h> 1#include <wlc/wlc.h>
2 2#include "sway/focus.h"
3#include "focus.h" 3#include "sway/workspace.h"
4#include "sway/layout.h"
5#include "sway/config.h"
6#include "sway/extensions.h"
7#include "sway/input_state.h"
8#include "sway/ipc-server.h"
9#include "sway/border.h"
4#include "log.h" 10#include "log.h"
5#include "workspace.h"
6#include "layout.h"
7#include "config.h"
8#include "input_state.h"
9#include "ipc-server.h"
10#include "border.h"
11 11
12bool locked_container_focus = false; 12bool locked_container_focus = false;
13bool suspend_workspace_cleanup = false; 13bool suspend_workspace_cleanup = false;
@@ -89,7 +89,6 @@ swayc_t *get_focused_container(swayc_t *parent) {
89 if (!parent) { 89 if (!parent) {
90 return swayc_active_workspace(); 90 return swayc_active_workspace();
91 } 91 }
92 // get focused container
93 while (!parent->is_focused && parent->focused) { 92 while (!parent->is_focused && parent->focused) {
94 parent = parent->focused; 93 parent = parent->focused;
95 } 94 }
@@ -133,24 +132,24 @@ bool set_focused_container(swayc_t *c) {
133 p->is_focused = false; 132 p->is_focused = false;
134 } 133 }
135 134
136 // get new focused view and set focus to it.
137 if (!(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) { 135 if (!(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
138 // unactivate previous focus
139 if (focused->type == C_VIEW) { 136 if (focused->type == C_VIEW) {
140 wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); 137 wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false);
141 } 138 }
142 update_container_border(focused); 139 update_container_border(focused);
143 // activate current focus
144 if (c->type == C_VIEW) { 140 if (c->type == C_VIEW) {
145 wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true); 141 wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true);
146 } 142 }
147 // set focus 143 if (!desktop_shell.is_locked) {
148 wlc_view_focus(c->handle); 144 // If the system is locked, we do everything _but_ actually setting
145 // focus. This includes making our internals think that this view is
146 // focused.
147 wlc_view_focus(c->handle);
148 }
149 if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) { 149 if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) {
150 update_container_border(c); 150 update_container_border(c);
151 } 151 }
152 152
153 // rearrange if parent container is tabbed/stacked
154 swayc_t *parent = swayc_tabbed_stacked_ancestor(c); 153 swayc_t *parent = swayc_tabbed_stacked_ancestor(c);
155 if (parent != NULL) { 154 if (parent != NULL) {
156 arrange_backgrounds(); 155 arrange_backgrounds();
@@ -175,7 +174,6 @@ bool set_focused_container_for(swayc_t *a, swayc_t *c) {
175 return false; 174 return false;
176 } 175 }
177 swayc_t *find = c; 176 swayc_t *find = c;
178 // Ensure that a is an ancestor of c
179 while (find != a && (find = find->parent)) { 177 while (find != a && (find = find->parent)) {
180 if (find == &root_container) { 178 if (find == &root_container) {
181 return false; 179 return false;