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 | |
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
-rw-r--r-- | include/layout.h | 9 | ||||
-rw-r--r-- | include/log.h | 4 | ||||
-rw-r--r-- | sway/handlers.c | 37 | ||||
-rw-r--r-- | sway/layout.c | 31 |
4 files changed, 68 insertions, 13 deletions
diff --git a/include/layout.h b/include/layout.h index a136f917..38a1f24b 100644 --- a/include/layout.h +++ b/include/layout.h | |||
@@ -10,16 +10,19 @@ extern swayc_t root_container; | |||
10 | void init_layout(void); | 10 | void init_layout(void); |
11 | 11 | ||
12 | void add_child(swayc_t *parent, swayc_t *child); | 12 | void add_child(swayc_t *parent, swayc_t *child); |
13 | //Returns parent container wihch needs to be rearranged. | 13 | //Returns parent container which needs to be rearranged. |
14 | swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); | 14 | swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); |
15 | swayc_t *replace_child(swayc_t *child, swayc_t *new_child); | 15 | swayc_t *replace_child(swayc_t *child, swayc_t *new_child); |
16 | swayc_t *remove_child(swayc_t *parent, swayc_t *child); | 16 | swayc_t *remove_child(swayc_t *parent, swayc_t *child); |
17 | 17 | ||
18 | //Layout | ||
19 | void arrange_windows(swayc_t *container, int width, int height); | ||
20 | |||
21 | //Focus | ||
18 | void unfocus_all(swayc_t *container); | 22 | void unfocus_all(swayc_t *container); |
19 | void focus_view(swayc_t *view); | 23 | void focus_view(swayc_t *view); |
20 | void arrange_windows(swayc_t *container, int width, int height); | 24 | void focus_view_for(swayc_t *ancestor, swayc_t *container); |
21 | swayc_t *get_focused_container(swayc_t *parent); | 25 | swayc_t *get_focused_container(swayc_t *parent); |
22 | |||
23 | swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent); | 26 | swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent); |
24 | 27 | ||
25 | #endif | 28 | #endif |
diff --git a/include/log.h b/include/log.h index e5075a39..d35b2a54 100644 --- a/include/log.h +++ b/include/log.h | |||
@@ -10,7 +10,7 @@ typedef enum { | |||
10 | 10 | ||
11 | void init_log(int verbosity); | 11 | void init_log(int verbosity); |
12 | void sway_log_colors(int mode); | 12 | void sway_log_colors(int mode); |
13 | void sway_log(int verbosity, char* format, ...); | 13 | void sway_log(int verbosity, char* format, ...) __attribute__((format(printf,2,3))); |
14 | void sway_abort(char* format, ...); | 14 | void sway_abort(char* format, ...)__attribute__((format(printf,1,2))); |
15 | 15 | ||
16 | #endif | 16 | #endif |
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 | |||