summaryrefslogtreecommitdiffstats
path: root/sway/handlers.c
diff options
context:
space:
mode:
authorLibravatar D.B <thejan.2009@gmail.com>2016-10-10 20:39:48 +0200
committerLibravatar D.B <thejan.2009@gmail.com>2016-10-11 09:15:48 +0200
commit0ddc4279d1f4e6e161c36eae31fa32c950ad0c71 (patch)
tree7958906eae0e872cc8567ff8530ecd189c15daca /sway/handlers.c
parentMerge pull request #947 from alkino/fix_move_empty_workspace (diff)
downloadsway-0ddc4279d1f4e6e161c36eae31fa32c950ad0c71.tar.gz
sway-0ddc4279d1f4e6e161c36eae31fa32c950ad0c71.tar.zst
sway-0ddc4279d1f4e6e161c36eae31fa32c950ad0c71.zip
wrap workspace's child into a container if needed
If workspace has stacked/tabbed layout, its direct children should be wrapped into a container which enables them to draw the titlebar.
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 2235bc8b..48117287 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -334,6 +334,7 @@ static bool handle_view_created(wlc_handle handle) {
334 wlc_view_get_geometry(handle)->size.h, wlc_view_get_title(handle), 334 wlc_view_get_geometry(handle)->size.h, wlc_view_get_title(handle),
335 wlc_view_get_class(handle), wlc_view_get_app_id(handle)); 335 wlc_view_get_class(handle), wlc_view_get_app_id(handle));
336 336
337 bool encapsulate_view = false;
337 // TODO properly figure out how each window should be handled. 338 // TODO properly figure out how each window should be handled.
338 switch (wlc_view_get_type(handle)) { 339 switch (wlc_view_get_type(handle)) {
339 // regular view created regularly 340 // regular view created regularly
@@ -341,6 +342,12 @@ static bool handle_view_created(wlc_handle handle) {
341 if (parent) { 342 if (parent) {
342 newview = new_floating_view(handle); 343 newview = new_floating_view(handle);
343 } else { 344 } else {
345 if (focused->type == C_WORKSPACE &&
346 /* focused->children->length == 0 && */
347 (focused->layout == L_TABBED || focused->layout == L_STACKED)) {
348 // will wrap the view in a container later on
349 encapsulate_view = true;
350 }
344 newview = new_view(focused, handle); 351 newview = new_view(focused, handle);
345 wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true); 352 wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
346 } 353 }
@@ -374,6 +381,10 @@ static bool handle_view_created(wlc_handle handle) {
374 suspend_workspace_cleanup = true; 381 suspend_workspace_cleanup = true;
375 382
376 if (newview) { 383 if (newview) {
384 // first view on tabbed/stacked workspace was created, wrap it in a container
385 if (encapsulate_view && newview->parent) {
386 new_container(newview, newview->parent->workspace_layout);
387 }
377 ipc_event_window(newview, "new"); 388 ipc_event_window(newview, "new");
378 set_focused_container(newview); 389 set_focused_container(newview);
379 wlc_view_set_mask(handle, VISIBLE); 390 wlc_view_set_mask(handle, VISIBLE);
@@ -398,17 +409,6 @@ static bool handle_view_created(wlc_handle handle) {
398 if (workspace && workspace->fullscreen) { 409 if (workspace && workspace->fullscreen) {
399 set_focused_container(workspace->fullscreen); 410 set_focused_container(workspace->fullscreen);
400 } 411 }
401
402 // if parent container is a workspace, newview its only child and
403 // layout is tabbed/stacked, add a container around newview
404 swayc_t *parent_container = newview->parent;
405 if (parent_container && parent_container->type == C_WORKSPACE &&
406 parent_container->children && parent_container->children->length == 1 &&
407 (parent_container->layout == L_TABBED || parent_container->layout == L_STACKED)) {
408 swayc_t *container = new_container(newview, parent_container->layout);
409 set_focused_container(newview);
410 arrange_windows(container, -1, -1);
411 }
412 } else { 412 } else {
413 swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); 413 swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT);
414 wlc_handle *h = malloc(sizeof(wlc_handle)); 414 wlc_handle *h = malloc(sizeof(wlc_handle));