From 6736a0597756240b18a840fd51501e845d0d70a4 Mon Sep 17 00:00:00 2001 From: minus Date: Fri, 21 Aug 2015 23:36:01 +0200 Subject: [PATCH] added hiding and showing scratchpad views credits go to taiyu. also prevent moving anything but views to scratchpad --- sway/commands.c | 13 +++++++------ sway/layout.c | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sway/commands.c b/sway/commands.c index 39776d89e..e267084a7 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -319,18 +319,19 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) { swayc_t *view = get_focused_container(&root_container); if (strcasecmp(argv[0], "left") == 0) { - move_container(view,&root_container,MOVE_LEFT); + move_container(view, &root_container, MOVE_LEFT); } else if (strcasecmp(argv[0], "right") == 0) { - move_container(view,&root_container,MOVE_RIGHT); + move_container(view, &root_container, MOVE_RIGHT); } else if (strcasecmp(argv[0], "up") == 0) { - move_container(view,&root_container,MOVE_UP); + move_container(view, &root_container, MOVE_UP); } else if (strcasecmp(argv[0], "down") == 0) { - move_container(view,&root_container,MOVE_DOWN); - } else if (strcasecmp(argv[0], "scratchpad") == 0) { + move_container(view, &root_container, MOVE_DOWN); + } else if (strcasecmp(argv[0], "scratchpad") == 0 && view->type == C_VIEW) { swayc_t *parent = view->parent; destroy_container(remove_child(view)); scratchpad_push(view); - set_focused_container(parent); + set_focused_container(get_focused_view(parent)); + arrange_windows(parent, -1, -1); } else { return false; } diff --git a/sway/layout.c b/sway/layout.c index 6b7bdae34..381e72e3d 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -471,6 +471,8 @@ void view_set_floating(swayc_t *view, bool floating) { void scratchpad_push(swayc_t *view) { add_floating(scratchpad, view); + wlc_view_set_mask(view->handle, 2); // invisible mask + wlc_view_send_to_back(view->handle); } swayc_t *scratchpad_pop(void) { @@ -478,6 +480,7 @@ swayc_t *scratchpad_pop(void) { return NULL; } swayc_t *view = scratchpad->floating->items[0]; + wlc_view_set_mask(view->handle, 1); // visible mask remove_child(view); return view; }