aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD.B <thejan.2009@gmail.com>2016-10-10 20:39:48 +0200
committerD.B <thejan.2009@gmail.com>2016-10-11 09:15:48 +0200
commit0ddc4279d1f4e6e161c36eae31fa32c950ad0c71 (patch)
tree7958906eae0e872cc8567ff8530ecd189c15daca
parent6446e4409f1e6e106c1576683c858df785e3cf38 (diff)
downloadsway-0ddc4279d1f4e6e161c36eae31fa32c950ad0c71.tar.xz
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.
-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) {
wlc_view_get_geometry(handle)->size.h, wlc_view_get_title(handle),
wlc_view_get_class(handle), wlc_view_get_app_id(handle));
+ bool encapsulate_view = false;
// TODO properly figure out how each window should be handled.
switch (wlc_view_get_type(handle)) {
// regular view created regularly
@@ -341,6 +342,12 @@ static bool handle_view_created(wlc_handle handle) {
if (parent) {
newview = new_floating_view(handle);
} else {
+ if (focused->type == C_WORKSPACE &&
+ /* focused->children->length == 0 && */
+ (focused->layout == L_TABBED || focused->layout == L_STACKED)) {
+ // will wrap the view in a container later on
+ encapsulate_view = true;
+ }
newview = new_view(focused, handle);
wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
}
@@ -374,6 +381,10 @@ static bool handle_view_created(wlc_handle handle) {
suspend_workspace_cleanup = true;
if (newview) {
+ // first view on tabbed/stacked workspace was created, wrap it in a container
+ if (encapsulate_view && newview->parent) {
+ new_container(newview, newview->parent->workspace_layout);
+ }
ipc_event_window(newview, "new");
set_focused_container(newview);
wlc_view_set_mask(handle, VISIBLE);
@@ -398,17 +409,6 @@ static bool handle_view_created(wlc_handle handle) {
if (workspace && workspace->fullscreen) {
set_focused_container(workspace->fullscreen);
}
-
- // if parent container is a workspace, newview its only child and
- // layout is tabbed/stacked, add a container around newview
- swayc_t *parent_container = newview->parent;
- if (parent_container && parent_container->type == C_WORKSPACE &&
- parent_container->children && parent_container->children->length == 1 &&
- (parent_container->layout == L_TABBED || parent_container->layout == L_STACKED)) {
- swayc_t *container = new_container(newview, parent_container->layout);
- set_focused_container(newview);
- arrange_windows(container, -1, -1);
- }
} else {
swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT);
wlc_handle *h = malloc(sizeof(wlc_handle));