summaryrefslogtreecommitdiffstats
path: root/sway/focus.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2016-08-03 22:26:23 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2016-08-03 23:24:53 -0400
commit81eb9ea12c322b8b966779ec2e170820e06c5eb7 (patch)
tree40cf7b6ba839cf633b8629dd141fa75c7cec0ab8 /sway/focus.c
parentMerge pull request #827 from acrisci/bug/ipc-id-uint (diff)
downloadsway-81eb9ea12c322b8b966779ec2e170820e06c5eb7.tar.gz
sway-81eb9ea12c322b8b966779ec2e170820e06c5eb7.tar.zst
sway-81eb9ea12c322b8b966779ec2e170820e06c5eb7.zip
Simplify focus setting
Merge the main rendering paths of all containers to make focus setting a bit simpler and easier to follow.
Diffstat (limited to 'sway/focus.c')
-rw-r--r--sway/focus.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/sway/focus.c b/sway/focus.c
index 6583f802..1ea88ad4 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -29,8 +29,6 @@ static void update_focus(swayc_t *c) {
29 29
30 // Case where output changes 30 // Case where output changes
31 case C_OUTPUT: 31 case C_OUTPUT:
32 // update borders for views in prev
33 container_map(prev, map_update_view_border, NULL);
34 wlc_output_focus(c->handle); 32 wlc_output_focus(c->handle);
35 break; 33 break;
36 34
@@ -54,8 +52,6 @@ static void update_focus(swayc_t *c) {
54 default: 52 default:
55 case C_VIEW: 53 case C_VIEW:
56 case C_CONTAINER: 54 case C_CONTAINER:
57 // TODO whatever to do when container changes
58 // for example, stacked and tabbing change stuff.
59 break; 55 break;
60 } 56 }
61 } 57 }
@@ -110,18 +106,17 @@ bool set_focused_container(swayc_t *c) {
110 active_ws_child_count = active_ws->children->length + active_ws->floating->length; 106 active_ws_child_count = active_ws->children->length + active_ws->floating->length;
111 } 107 }
112 108
113 swayc_log(L_DEBUG, c, "Setting focus to %p:%" PRIuPTR, c, c->handle);
114
115 // Get workspace for c, get that workspaces current focused container.
116 swayc_t *workspace = swayc_active_workspace_for(c); 109 swayc_t *workspace = swayc_active_workspace_for(c);
117 swayc_t *focused = get_focused_container(workspace); 110 swayc_t *focused = get_focused_container(&root_container);
118 111
119 if (swayc_is_fullscreen(focused) && focused != c) { 112 if (swayc_is_fullscreen(get_focused_container(workspace))) {
120 // if switching to a workspace with a fullscreen view, 113 // if switching to a workspace with a fullscreen view,
121 // focus on the fullscreen view 114 // focus on the fullscreen view
122 c = focused; 115 c = get_focused_container(workspace);
123 } 116 }
124 117
118 swayc_log(L_DEBUG, c, "Setting focus to %p:%" PRIuPTR, c, c->handle);
119
125 if (c->type == C_VIEW) { 120 if (c->type == C_VIEW) {
126 // dispatch a window event 121 // dispatch a window event
127 ipc_event_window(c, "focus"); 122 ipc_event_window(c, "focus");
@@ -139,7 +134,7 @@ bool set_focused_container(swayc_t *c) {
139 } 134 }
140 135
141 // get new focused view and set focus to it. 136 // get new focused view and set focus to it.
142 if (c->type == C_CONTAINER || (c->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP))) { 137 if (!(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
143 // unactivate previous focus 138 // unactivate previous focus
144 if (focused->type == C_VIEW) { 139 if (focused->type == C_VIEW) {
145 wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); 140 wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false);
@@ -149,7 +144,7 @@ bool set_focused_container(swayc_t *c) {
149 if (c->type == C_VIEW) { 144 if (c->type == C_VIEW) {
150 wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true); 145 wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true);
151 } 146 }
152 // set focus if view_focus is unlocked 147 // set focus
153 wlc_view_focus(c->handle); 148 wlc_view_focus(c->handle);
154 if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) { 149 if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) {
155 update_container_border(c); 150 update_container_border(c);
@@ -161,10 +156,6 @@ bool set_focused_container(swayc_t *c) {
161 arrange_backgrounds(); 156 arrange_backgrounds();
162 arrange_windows(parent, -1, -1); 157 arrange_windows(parent, -1, -1);
163 } 158 }
164 } else if (c->type == C_WORKSPACE) {
165 // remove previous focus if view_focus is unlocked
166 update_container_border(c);
167 wlc_view_focus(0);
168 } 159 }
169 160
170 if (active_ws != workspace) { 161 if (active_ws != workspace) {