mirror of
https://github.com/swaywm/sway.git
synced 2025-11-14 06:59:47 -05:00
Merge branch 'wlroots' into split-containers
This commit is contained in:
commit
2187684bd0
13 changed files with 276 additions and 42 deletions
|
|
@ -33,6 +33,23 @@ static list_t *get_bfs_queue() {
|
|||
return bfs_queue;
|
||||
}
|
||||
|
||||
const char *container_type_to_str(enum sway_container_type type) {
|
||||
switch (type) {
|
||||
case C_ROOT:
|
||||
return "C_ROOT";
|
||||
case C_OUTPUT:
|
||||
return "C_OUTPUT";
|
||||
case C_WORKSPACE:
|
||||
return "C_WORKSPACE";
|
||||
case C_CONTAINER:
|
||||
return "C_CONTAINER";
|
||||
case C_VIEW:
|
||||
return "C_VIEW";
|
||||
default:
|
||||
return "C_UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
static void notify_new_container(struct sway_container *container) {
|
||||
wl_signal_emit(&root_container.sway_root->events.new_container, container);
|
||||
ipc_event_window(container, "new");
|
||||
|
|
@ -54,6 +71,7 @@ struct sway_container *container_create(enum sway_container_type type) {
|
|||
}
|
||||
|
||||
wl_signal_init(&c->events.destroy);
|
||||
wl_signal_init(&c->events.reparent);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,8 +109,10 @@ struct sway_container *container_reap_empty(struct sway_container *container) {
|
|||
if (container == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
wlr_log(L_DEBUG, "reaping %p %s", container, container->name);
|
||||
while (container->type != C_VIEW && container != &root_container && container->children->length == 0) {
|
||||
wlr_log(L_DEBUG, "Reaping %p %s '%s'", container,
|
||||
container_type_to_str(container->type), container->name);
|
||||
while (container->type != C_ROOT && container->type != C_OUTPUT
|
||||
&& container->children->length == 0) {
|
||||
if (container->type == C_WORKSPACE) {
|
||||
if (!workspace_is_visible(container)) {
|
||||
struct sway_container *parent = container->parent;
|
||||
|
|
@ -141,22 +143,46 @@ struct sway_container *container_remove_child(struct sway_container *child) {
|
|||
return parent;
|
||||
}
|
||||
|
||||
void container_move_to(struct sway_container* container,
|
||||
struct sway_container* destination) {
|
||||
void container_move_to(struct sway_container *container,
|
||||
struct sway_container *destination) {
|
||||
if (container == destination
|
||||
|| container_has_anscestor(container, destination)) {
|
||||
return;
|
||||
}
|
||||
struct sway_container *old_parent = container_remove_child(container);
|
||||
container->width = container->height = 0;
|
||||
struct sway_container *new_parent =
|
||||
container_add_sibling(destination, container);
|
||||
struct sway_container *new_parent;
|
||||
if (destination->type == C_VIEW) {
|
||||
new_parent = container_add_sibling(destination, container);
|
||||
} else {
|
||||
new_parent = destination;
|
||||
container_add_child(destination, container);
|
||||
}
|
||||
wl_signal_emit(&container->events.reparent, old_parent);
|
||||
if (container->type == C_WORKSPACE) {
|
||||
struct sway_seat *seat = sway_input_manager_get_default_seat(
|
||||
input_manager);
|
||||
if (old_parent->children->length == 0) {
|
||||
char *ws_name = workspace_next_name(old_parent->name);
|
||||
struct sway_container *ws =
|
||||
container_workspace_create(old_parent, ws_name);
|
||||
free(ws_name);
|
||||
sway_seat_set_focus(seat, ws);
|
||||
}
|
||||
container_sort_workspaces(new_parent);
|
||||
sway_seat_set_focus(seat, new_parent);
|
||||
}
|
||||
if (old_parent) {
|
||||
arrange_windows(old_parent, -1, -1);
|
||||
}
|
||||
arrange_windows(new_parent, -1, -1);
|
||||
}
|
||||
|
||||
void container_move(struct sway_container *container,
|
||||
enum movement_direction dir, int move_amt) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
enum sway_container_layout container_get_default_layout(
|
||||
struct sway_container *output) {
|
||||
if (config->default_layout != L_NONE) {
|
||||
|
|
@ -529,26 +555,6 @@ struct sway_container *container_get_in_direction(
|
|||
}
|
||||
}
|
||||
|
||||
if (dir == MOVE_PREV || dir == MOVE_NEXT) {
|
||||
int focused_idx = index_child(container);
|
||||
if (focused_idx == -1) {
|
||||
return NULL;
|
||||
} else {
|
||||
int desired = (focused_idx + (dir == MOVE_NEXT ? 1 : -1)) %
|
||||
parent->children->length;
|
||||
if (desired < 0) {
|
||||
desired += parent->children->length;
|
||||
}
|
||||
return parent->children->items[desired];
|
||||
}
|
||||
}
|
||||
|
||||
// If moving to an adjacent output we need a starting position (since this
|
||||
// output might border to multiple outputs).
|
||||
//struct wlc_point abs_pos;
|
||||
//get_layout_center_position(container, &abs_pos);
|
||||
|
||||
|
||||
// TODO WLR fullscreen
|
||||
/*
|
||||
if (container->type == C_VIEW && swayc_is_fullscreen(container)) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include <strings.h>
|
||||
#include "sway/tree/container.h"
|
||||
#include "sway/tree/layout.h"
|
||||
#include "sway/output.h"
|
||||
|
|
@ -37,3 +38,13 @@ struct sway_container *container_output_destroy(struct sway_container *output) {
|
|||
container_destroy(output);
|
||||
return &root_container;
|
||||
}
|
||||
|
||||
struct sway_container *output_by_name(const char *name) {
|
||||
for (int i = 0; i < root_container.children->length; ++i) {
|
||||
struct sway_container *output = root_container.children->items[i];
|
||||
if (strcasecmp(output->name, name) == 0){
|
||||
return output;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ bool workspace_switch(struct sway_container *workspace) {
|
|||
}
|
||||
struct sway_container *active_ws = focus;
|
||||
if (active_ws->type != C_WORKSPACE) {
|
||||
container_parent(focus, C_WORKSPACE);
|
||||
active_ws = container_parent(focus, C_WORKSPACE);
|
||||
}
|
||||
|
||||
if (config->auto_back_and_forth
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue