mirror of
https://github.com/swaywm/sway.git
synced 2026-04-29 06:46:22 -04:00
added scratchpad (WIP)
views that are pushed to the scratchpad still render and accept input. latter only if no other view took focus afterwards
This commit is contained in:
parent
4e0a3b9c72
commit
f4b4c5851a
3 changed files with 50 additions and 3 deletions
|
|
@ -32,4 +32,9 @@ void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge ed
|
||||||
|
|
||||||
void view_set_floating(swayc_t *view, bool floating);
|
void view_set_floating(swayc_t *view, bool floating);
|
||||||
|
|
||||||
|
// Scratchpad
|
||||||
|
|
||||||
|
void scratchpad_push(swayc_t *view);
|
||||||
|
swayc_t *scratchpad_pop(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -200,13 +200,13 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
||||||
swayc_t *view = get_focused_container(&root_container);
|
swayc_t *view = get_focused_container(&root_container);
|
||||||
|
|
||||||
bool floating;
|
bool floating;
|
||||||
if (strcasecmp(argv[0], "toggle") != 0) {
|
if (strcasecmp(argv[0], "toggle") == 0) {
|
||||||
floating = !view->is_floating;
|
floating = !view->is_floating;
|
||||||
}
|
}
|
||||||
else if (strcasecmp(argv[0], "enable") != 0) {
|
else if (strcasecmp(argv[0], "enable") == 0) {
|
||||||
floating = true;
|
floating = true;
|
||||||
}
|
}
|
||||||
else if (strcasecmp(argv[0], "disable") != 0) {
|
else if (strcasecmp(argv[0], "disable") == 0) {
|
||||||
floating = false;
|
floating = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -326,12 +326,36 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) {
|
||||||
move_container(view,&root_container,MOVE_UP);
|
move_container(view,&root_container,MOVE_UP);
|
||||||
} else if (strcasecmp(argv[0], "down") == 0) {
|
} else if (strcasecmp(argv[0], "down") == 0) {
|
||||||
move_container(view,&root_container,MOVE_DOWN);
|
move_container(view,&root_container,MOVE_DOWN);
|
||||||
|
} else if (strcasecmp(argv[0], "scratchpad") == 0) {
|
||||||
|
swayc_t *parent = view->parent;
|
||||||
|
destroy_container(remove_child(view));
|
||||||
|
scratchpad_push(view);
|
||||||
|
set_focused_container(parent);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool cmd_scratchpad(struct sway_config *config, int argc, char **argv) {
|
||||||
|
if (!checkarg(argc, "scratchpad", EXPECTED_EQUAL_TO, 1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp(argv[0], "show") != 0) {
|
||||||
|
sway_log(L_ERROR, "scratchpad - unknown token '%s', expected show", argv[0]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
swayc_t *view = scratchpad_pop();
|
||||||
|
if (view == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
view_set_floating(view, true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool cmd_output(struct sway_config *config, int argc, char **argv) {
|
static bool cmd_output(struct sway_config *config, int argc, char **argv) {
|
||||||
if (!checkarg(argc, "output", EXPECTED_AT_LEAST, 1)) {
|
if (!checkarg(argc, "output", EXPECTED_AT_LEAST, 1)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -668,6 +692,7 @@ static struct cmd_handler handlers[] = {
|
||||||
{ "output", cmd_output},
|
{ "output", cmd_output},
|
||||||
{ "reload", cmd_reload },
|
{ "reload", cmd_reload },
|
||||||
{ "resize", cmd_resize },
|
{ "resize", cmd_resize },
|
||||||
|
{ "scratchpad", cmd_scratchpad },
|
||||||
{ "set", cmd_set },
|
{ "set", cmd_set },
|
||||||
{ "split", cmd_split },
|
{ "split", cmd_split },
|
||||||
{ "splith", cmd_splith },
|
{ "splith", cmd_splith },
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,15 @@ swayc_t root_container;
|
||||||
int min_sane_h = 60;
|
int min_sane_h = 60;
|
||||||
int min_sane_w = 100;
|
int min_sane_w = 100;
|
||||||
|
|
||||||
|
static swayc_t *scratchpad = NULL;
|
||||||
|
|
||||||
void init_layout(void) {
|
void init_layout(void) {
|
||||||
root_container.type = C_ROOT;
|
root_container.type = C_ROOT;
|
||||||
root_container.layout = L_NONE;
|
root_container.layout = L_NONE;
|
||||||
root_container.children = create_list();
|
root_container.children = create_list();
|
||||||
root_container.handle = -1;
|
root_container.handle = -1;
|
||||||
|
|
||||||
|
scratchpad = new_workspace(&root_container, "__i3_scratch");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int index_child(swayc_t *parent, swayc_t *child) {
|
static int index_child(swayc_t *parent, swayc_t *child) {
|
||||||
|
|
@ -464,3 +468,16 @@ void view_set_floating(swayc_t *view, bool floating) {
|
||||||
arrange_windows(swayc_active_workspace(), -1, -1);
|
arrange_windows(swayc_active_workspace(), -1, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scratchpad_push(swayc_t *view) {
|
||||||
|
add_floating(scratchpad, view);
|
||||||
|
}
|
||||||
|
|
||||||
|
swayc_t *scratchpad_pop(void) {
|
||||||
|
if (scratchpad->floating->length == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
swayc_t *view = scratchpad->floating->items[0];
|
||||||
|
remove_child(view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue