mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 00:16:22 +01:00
more changes
This commit is contained in:
parent
4606fb1ee3
commit
63bc0d3b54
5 changed files with 19 additions and 13 deletions
|
@ -13,7 +13,7 @@ void add_child(swayc_t *parent, swayc_t *child);
|
||||||
//Returns parent container which needs to be rearranged.
|
//Returns parent container which needs to be rearranged.
|
||||||
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
|
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
|
||||||
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
||||||
swayc_t *remove_child(swayc_t *parent, swayc_t *child);
|
swayc_t *remove_child(swayc_t *child);
|
||||||
|
|
||||||
//Layout
|
//Layout
|
||||||
void arrange_windows(swayc_t *container, int width, int height);
|
void arrange_windows(swayc_t *container, int width, int height);
|
||||||
|
|
|
@ -27,10 +27,7 @@ static void free_swayc(swayc_t *c) {
|
||||||
list_free(c->children);
|
list_free(c->children);
|
||||||
}
|
}
|
||||||
if (c->parent) {
|
if (c->parent) {
|
||||||
if (c->parent->focused == c) {
|
remove_child(c);
|
||||||
c->parent->focused = NULL;
|
|
||||||
}
|
|
||||||
remove_child(c->parent, c);
|
|
||||||
}
|
}
|
||||||
if (c->name) {
|
if (c->name) {
|
||||||
free(c->name);
|
free(c->name);
|
||||||
|
@ -118,6 +115,11 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
|
||||||
//reorder focus
|
//reorder focus
|
||||||
cont->focused = workspace->focused;
|
cont->focused = workspace->focused;
|
||||||
workspace->focused = cont;
|
workspace->focused = cont;
|
||||||
|
//set all children focu to container
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < workspace->children->length; ++i) {
|
||||||
|
((swayc_t *)workspace->children->items[i])->parent = cont;
|
||||||
|
}
|
||||||
//Swap children
|
//Swap children
|
||||||
list_t *tmp_list = workspace->children;
|
list_t *tmp_list = workspace->children;
|
||||||
workspace->children = cont->children;
|
workspace->children = cont->children;
|
||||||
|
@ -204,7 +206,7 @@ swayc_t *destroy_output(swayc_t *output) {
|
||||||
if (output->children->length == 0) {
|
if (output->children->length == 0) {
|
||||||
//TODO move workspaces to other outputs
|
//TODO move workspaces to other outputs
|
||||||
}
|
}
|
||||||
sway_log(L_DEBUG, "OUTPUT: Destroying output '%u'", (unsigned int)output->handle);
|
sway_log(L_DEBUG, "OUTPUT: Destroying output '%lu'", output->handle);
|
||||||
free_swayc(output);
|
free_swayc(output);
|
||||||
return &root_container;
|
return &root_container;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +248,6 @@ swayc_t *destroy_view(swayc_t *view) {
|
||||||
if (parent->type == C_CONTAINER) {
|
if (parent->type == C_CONTAINER) {
|
||||||
return destroy_container(parent);
|
return destroy_container(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ void set_focused_container(swayc_t *c) {
|
||||||
if (!locked_view_focus) {
|
if (!locked_view_focus) {
|
||||||
p = get_focused_view(c);
|
p = get_focused_view(c);
|
||||||
//Set focus to p
|
//Set focus to p
|
||||||
if (p && p != prev_view && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
|
if (p && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
|
||||||
if (prev_view) {
|
if (prev_view) {
|
||||||
wlc_view_set_state(prev_view->handle, WLC_BIT_ACTIVATED, false);
|
wlc_view_set_state(prev_view->handle, WLC_BIT_ACTIVATED, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ static bool pointer_test(swayc_t *view, void *_origin) {
|
||||||
|
|
||||||
swayc_t *container_under_pointer(void) {
|
swayc_t *container_under_pointer(void) {
|
||||||
//root.output->workspace
|
//root.output->workspace
|
||||||
|
if (!root_container.focused || !root_container.focused->focused) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
swayc_t *lookup = root_container.focused->focused;
|
swayc_t *lookup = root_container.focused->focused;
|
||||||
//Case of empty workspace
|
//Case of empty workspace
|
||||||
if (lookup->children == 0) {
|
if (lookup->children == 0) {
|
||||||
|
@ -174,9 +177,6 @@ static void handle_view_destroyed(wlc_handle handle) {
|
||||||
if (view) {
|
if (view) {
|
||||||
swayc_t *parent = destroy_view(view);
|
swayc_t *parent = destroy_view(view);
|
||||||
arrange_windows(parent, -1, -1);
|
arrange_windows(parent, -1, -1);
|
||||||
if (!focused || focused == view) {
|
|
||||||
set_focused_container(container_under_pointer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//takes keyboard focus
|
//takes keyboard focus
|
||||||
|
|
|
@ -60,8 +60,9 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
swayc_t *remove_child(swayc_t *parent, swayc_t *child) {
|
swayc_t *remove_child(swayc_t *child) {
|
||||||
int i;
|
int i;
|
||||||
|
swayc_t *parent = child->parent;
|
||||||
// Special case for floating views
|
// Special case for floating views
|
||||||
if (child->is_floating) {
|
if (child->is_floating) {
|
||||||
for (i = 0; i < parent->floating->length; ++i) {
|
for (i = 0; i < parent->floating->length; ++i) {
|
||||||
|
@ -79,7 +80,11 @@ swayc_t *remove_child(swayc_t *parent, swayc_t *child) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (parent->focused == child) {
|
if (parent->focused == child) {
|
||||||
parent->focused = NULL;
|
if (parent->children->length > 0) {
|
||||||
|
parent->focused = parent->children->items[i?i-1:0];
|
||||||
|
} else {
|
||||||
|
parent->focused = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue