summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--include/border.h1
-rw-r--r--sway/border.c6
-rw-r--r--sway/focus.c23
3 files changed, 7 insertions, 23 deletions
diff --git a/include/border.h b/include/border.h
index b72dc5dc..c30c9da3 100644
--- a/include/border.h
+++ b/include/border.h
@@ -22,7 +22,6 @@ void border_clear(struct border *border);
22void update_container_border(swayc_t *container); 22void update_container_border(swayc_t *container);
23 23
24void render_view_borders(wlc_handle view); 24void render_view_borders(wlc_handle view);
25void map_update_view_border(swayc_t *view, void *data);
26int get_font_text_height(const char *font); 25int get_font_text_height(const char *font);
27bool should_hide_top_border(swayc_t *con, double y); 26bool should_hide_top_border(swayc_t *con, double y);
28 27
diff --git a/sway/border.c b/sway/border.c
index 46343d61..304f8b87 100644
--- a/sway/border.c
+++ b/sway/border.c
@@ -415,12 +415,6 @@ void update_container_border(swayc_t *container) {
415 } 415 }
416} 416}
417 417
418void map_update_view_border(swayc_t *view, void *data) {
419 if (view->type == C_VIEW) {
420 update_view_border(view);
421 }
422}
423
424void render_view_borders(wlc_handle view) { 418void render_view_borders(wlc_handle view) {
425 swayc_t *c = swayc_by_handle(view); 419 swayc_t *c = swayc_by_handle(view);
426 420
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) {