mirror of
https://github.com/swaywm/sway.git
synced 2024-11-18 22:19:14 +00:00
commit
6b962ebd22
|
@ -8,6 +8,8 @@
|
|||
|
||||
extern swayc_t root_container;
|
||||
|
||||
extern list_t *scratchpad;
|
||||
|
||||
extern int min_sane_w;
|
||||
extern int min_sane_h;
|
||||
|
||||
|
|
|
@ -344,7 +344,7 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char *
|
|||
}
|
||||
|
||||
static bool cmd_move(struct sway_config *config, int argc, char **argv) {
|
||||
if (!checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1)) {
|
||||
if (!checkarg(argc, "move", EXPECTED_AT_LEAST, 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -381,6 +381,24 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) {
|
|||
ws = workspace_create(ws_name);
|
||||
}
|
||||
move_container_to(view, get_focused_container(ws));
|
||||
} else if (strcasecmp(argv[0], "scratchpad") == 0) {
|
||||
if (view->type != C_CONTAINER && view->type != C_VIEW) {
|
||||
return false;
|
||||
}
|
||||
swayc_t *view = get_focused_container(&root_container);
|
||||
list_add(scratchpad, view);
|
||||
if (!view->is_floating) {
|
||||
destroy_container(remove_child(view));
|
||||
} else {
|
||||
remove_child(view);
|
||||
}
|
||||
wlc_view_set_mask(view->handle, 0);
|
||||
arrange_windows(swayc_active_workspace(), -1, -1);
|
||||
swayc_t *focused = container_under_pointer();
|
||||
if (focused == NULL) {
|
||||
focused = swayc_active_workspace();
|
||||
}
|
||||
set_focused_container(focused);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -572,6 +590,37 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
|
|||
return false;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (scratchpad->length > 0) {
|
||||
swayc_t *view = scratchpad->items[0];
|
||||
list_del(scratchpad, 0);
|
||||
add_floating(swayc_active_workspace(), view);
|
||||
view->x = (swayc_active_workspace()->width - view->width)/2;
|
||||
view->y = (swayc_active_workspace()->height - view->height)/2;
|
||||
if (view->desired_width != -1) {
|
||||
view->width = view->desired_width;
|
||||
}
|
||||
if (view->desired_height != -1) {
|
||||
view->height = view->desired_height;
|
||||
}
|
||||
wlc_view_set_mask(view->handle, VISIBLE);
|
||||
arrange_windows(swayc_active_workspace(), -1, -1);
|
||||
swayc_t *focused = container_under_pointer();
|
||||
if (focused == NULL) {
|
||||
focused = swayc_active_workspace();
|
||||
}
|
||||
set_focused_container(focused);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool cmd_set(struct sway_config *config, int argc, char **argv) {
|
||||
if (!checkarg(argc, "set", EXPECTED_EQUAL_TO, 2)) {
|
||||
return false;
|
||||
|
@ -742,6 +791,7 @@ static struct cmd_handler handlers[] = {
|
|||
{ "output", cmd_output},
|
||||
{ "reload", cmd_reload },
|
||||
{ "resize", cmd_resize },
|
||||
{ "scratchpad", cmd_scratchpad },
|
||||
{ "set", cmd_set },
|
||||
{ "split", cmd_split },
|
||||
{ "splith", cmd_splith },
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "focus.h"
|
||||
|
||||
swayc_t root_container;
|
||||
list_t *scratchpad;
|
||||
|
||||
int min_sane_h = 60;
|
||||
int min_sane_w = 100;
|
||||
|
@ -20,16 +21,27 @@ void init_layout(void) {
|
|||
root_container.children = create_list();
|
||||
root_container.handle = -1;
|
||||
root_container.visible = true;
|
||||
scratchpad = create_list();
|
||||
}
|
||||
|
||||
int index_child(const swayc_t *child) {
|
||||
swayc_t *parent = child->parent;
|
||||
int i, len = parent->children->length;
|
||||
int i, len;
|
||||
if (!child->is_floating) {
|
||||
len = parent->children->length;
|
||||
for (i = 0; i < len; ++i) {
|
||||
if (parent->children->items[i] == child) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = parent->floating->length;
|
||||
for (i = 0; i < len; ++i) {
|
||||
if (parent->floating->items[i] == child) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sway_assert(i < len, "Stray container")) {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue