diff options
author | taiyu <taiyu.len@gmail.com> | 2015-08-16 17:28:06 -0700 |
---|---|---|
committer | taiyu <taiyu.len@gmail.com> | 2015-08-16 17:28:06 -0700 |
commit | c024f0663176239c8b97e2957e5a7a45be5bceef (patch) | |
tree | acc5c67090bea80843188ad3b3acc048c2b33de2 /sway | |
parent | Merge pull request #46 from Luminarys/master (diff) | |
download | sway-c024f0663176239c8b97e2957e5a7a45be5bceef.tar.gz sway-c024f0663176239c8b97e2957e5a7a45be5bceef.tar.zst sway-c024f0663176239c8b97e2957e5a7a45be5bceef.zip |
handle_view_state_request
Diffstat (limited to 'sway')
-rw-r--r-- | sway/handlers.c | 37 | ||||
-rw-r--r-- | sway/layout.c | 31 |
2 files changed, 60 insertions, 8 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index 32b0051d..e57b791b 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -130,6 +130,38 @@ static void handle_view_geometry_request(wlc_handle view, const struct wlc_geome | |||
130 | // deny that shit | 130 | // deny that shit |
131 | } | 131 | } |
132 | 132 | ||
133 | static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { | ||
134 | switch(state) { | ||
135 | case WLC_BIT_FULLSCREEN: | ||
136 | { | ||
137 | //I3 just lets it become fullscreen | ||
138 | wlc_view_set_state(view,state,toggle); | ||
139 | swayc_t *c = get_swayc_for_handle(view, &root_container); | ||
140 | sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d",view,c->name,toggle); | ||
141 | if (c) { | ||
142 | arrange_windows(c->parent, -1, -1); | ||
143 | //Set it as focused window for that workspace if its going | ||
144 | //fullscreen | ||
145 | if (toggle) { | ||
146 | swayc_t *ws = c; | ||
147 | while (ws->type != C_WORKSPACE) { | ||
148 | ws = ws->parent; | ||
149 | } | ||
150 | //Set ws focus to c | ||
151 | focus_view_for(ws, c); | ||
152 | } | ||
153 | } | ||
154 | break; | ||
155 | } | ||
156 | case WLC_BIT_MAXIMIZED: | ||
157 | case WLC_BIT_RESIZING: | ||
158 | case WLC_BIT_MOVING: | ||
159 | case WLC_BIT_ACTIVATED: | ||
160 | break; | ||
161 | } | ||
162 | return; | ||
163 | } | ||
164 | |||
133 | 165 | ||
134 | static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers | 166 | static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers |
135 | *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) { | 167 | *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) { |
@@ -239,7 +271,8 @@ struct wlc_interface interface = { | |||
239 | .destroyed = handle_view_destroyed, | 271 | .destroyed = handle_view_destroyed, |
240 | .focus = handle_view_focus, | 272 | .focus = handle_view_focus, |
241 | .request = { | 273 | .request = { |
242 | .geometry = handle_view_geometry_request | 274 | .geometry = handle_view_geometry_request, |
275 | .state = handle_view_state_request | ||
243 | } | 276 | } |
244 | }, | 277 | }, |
245 | .keyboard = { | 278 | .keyboard = { |
@@ -250,6 +283,6 @@ struct wlc_interface interface = { | |||
250 | .button = handle_pointer_button | 283 | .button = handle_pointer_button |
251 | }, | 284 | }, |
252 | .compositor = { | 285 | .compositor = { |
253 | .ready = handle_wlc_ready | 286 | .ready = handle_wlc_ready |
254 | } | 287 | } |
255 | }; | 288 | }; |
diff --git a/sway/layout.c b/sway/layout.c index 20b5999c..a6d6fcbb 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -238,15 +238,17 @@ void unfocus_all(swayc_t *container) { | |||
238 | 238 | ||
239 | void focus_view(swayc_t *view) { | 239 | void focus_view(swayc_t *view) { |
240 | sway_log(L_DEBUG, "Setting focus for %p", view); | 240 | sway_log(L_DEBUG, "Setting focus for %p", view); |
241 | while (view != &root_container) { | 241 | swayc_t *c = view; |
242 | view->parent->focused = view; | 242 | //Set focus from root to view |
243 | view = view->parent; | 243 | while (c != &root_container) { |
244 | c->parent->focused = c; | ||
245 | c = c->parent; | ||
244 | } | 246 | } |
247 | //Set output | ||
248 | wlc_output_focus(c->focused->handle); | ||
249 | //get focus for views focused window | ||
245 | while (view && view->type != C_VIEW) { | 250 | while (view && view->type != C_VIEW) { |
246 | view = view->focused; | 251 | view = view->focused; |
247 | if (view && view->type == C_OUTPUT) { | ||
248 | wlc_output_focus(view->handle); | ||
249 | } | ||
250 | } | 252 | } |
251 | if (view) { | 253 | if (view) { |
252 | wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true); | 254 | wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true); |
@@ -254,3 +256,20 @@ void focus_view(swayc_t *view) { | |||
254 | } | 256 | } |
255 | } | 257 | } |
256 | 258 | ||
259 | void focus_view_for(swayc_t *top, swayc_t *view) { | ||
260 | swayc_t *find = view; | ||
261 | //Make sure top is a ancestor of view | ||
262 | while (find != top) { | ||
263 | if (find == &root_container) { | ||
264 | return; | ||
265 | } | ||
266 | find = find->parent; | ||
267 | } | ||
268 | //Set focus for top to go to view | ||
269 | while (view != top) { | ||
270 | view->parent->focused = view; | ||
271 | view = view->parent; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | |||