From 166c2a3687d2819184457490132dd0c109238873 Mon Sep 17 00:00:00 2001 From: "D.B" Date: Tue, 11 Oct 2016 09:11:56 +0200 Subject: [PATCH] generalize wrapping views under workspaces --- sway/handlers.c | 11 ----------- sway/layout.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index 75f2d5a6..9a84182a 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -334,7 +334,6 @@ 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 @@ -342,12 +341,6 @@ 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->workspace_layout == L_TABBED || focused->workspace_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); } @@ -381,10 +374,6 @@ 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); diff --git a/sway/layout.c b/sway/layout.c index a57306e0..8565113d 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -66,6 +66,11 @@ void add_child(swayc_t *parent, swayc_t *child) { if (!parent->focused) { parent->focused = child; } + + // wrap view into a container + if (parent->type == C_WORKSPACE && child->type == C_VIEW) { + new_container(child, parent->workspace_layout); + } } void insert_child(swayc_t *parent, swayc_t *child, int index) { @@ -80,6 +85,11 @@ void insert_child(swayc_t *parent, swayc_t *child, int index) { if (!parent->focused) { parent->focused = child; } + + // wrap view into a container + if (parent->type == C_WORKSPACE && child->type == C_VIEW) { + new_container(child, parent->workspace_layout); + } } void add_floating(swayc_t *ws, swayc_t *child) {