aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c56
-rw-r--r--sway/tree/layout.c181
-rw-r--r--sway/tree/output.c12
-rw-r--r--sway/tree/view.c188
-rw-r--r--sway/tree/workspace.c16
5 files changed, 331 insertions, 122 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 746dbf1f..4db93ce8 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -33,12 +33,29 @@ 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");
}
-static struct sway_container *container_create(enum sway_container_type type) {
+struct sway_container *container_create(enum sway_container_type type) {
// next id starts at 1 because 0 is assigned to root_container in layout.c
static size_t next_id = 1;
struct sway_container *c = calloc(1, sizeof(struct sway_container));
@@ -54,11 +71,12 @@ static struct sway_container *container_create(enum sway_container_type type) {
}
wl_signal_init(&c->events.destroy);
+ wl_signal_init(&c->events.reparent);
return c;
}
-struct sway_container *container_destroy(struct sway_container *cont) {
+static struct sway_container *_container_destroy(struct sway_container *cont) {
if (cont == NULL) {
return NULL;
}
@@ -66,13 +84,14 @@ struct sway_container *container_destroy(struct sway_container *cont) {
wl_signal_emit(&cont->events.destroy, cont);
struct sway_container *parent = cont->parent;
- if (cont->children) {
+ if (cont->children != NULL) {
// remove children until there are no more, container_destroy calls
// container_remove_child, which removes child from this container
- while (cont->children->length) {
- container_destroy(cont->children->items[0]);
+ while (cont->children != NULL && cont->children->length != 0) {
+ struct sway_container *child = cont->children->items[0];
+ container_remove_child(child);
+ container_destroy(child);
}
- list_free(cont->children);
}
if (cont->marks) {
list_foreach(cont->marks, free);
@@ -84,10 +103,19 @@ struct sway_container *container_destroy(struct sway_container *cont) {
if (cont->name) {
free(cont->name);
}
+ list_free(cont->children);
+ cont->children = NULL;
free(cont);
return parent;
}
+struct sway_container *container_destroy(struct sway_container *cont) {
+ struct sway_container *parent = _container_destroy(cont);
+ parent = container_reap_empty(parent);
+ arrange_windows(&root_container, -1, -1);
+ return parent;
+}
+
struct sway_container *container_output_create(
struct sway_output *sway_output) {
struct wlr_box size;
@@ -144,7 +172,7 @@ struct sway_container *container_output_create(
struct sway_seat *seat = NULL;
wl_list_for_each(seat, &input_manager->seats, link) {
if (!seat->has_focus) {
- sway_seat_set_focus(seat, ws);
+ seat_set_focus(seat, ws);
}
}
@@ -395,3 +423,17 @@ bool container_has_anscestor(struct sway_container *descendant,
}
return false;
}
+
+static bool find_child_func(struct sway_container *con, void *data) {
+ struct sway_container *child = data;
+ return con == child;
+}
+
+bool container_has_child(struct sway_container *con,
+ struct sway_container *child) {
+ if (child == NULL || child->type == C_VIEW ||
+ child->children->length == 0) {
+ return false;
+ }
+ return container_find(con, find_child_func, child);
+}
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index ce0682dc..95a84d12 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200809L
+#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
@@ -57,7 +58,7 @@ void layout_init(void) {
root_container.sway_root = calloc(1, sizeof(*root_container.sway_root));
root_container.sway_root->output_layout = wlr_output_layout_create();
- wl_list_init(&root_container.sway_root->unmanaged_views);
+ wl_list_init(&root_container.sway_root->xwayland_unmanaged);
wl_signal_init(&root_container.sway_root->events.new_container);
root_container.sway_root->output_layout_change.notify =
@@ -103,11 +104,13 @@ void container_add_child(struct sway_container *parent,
}
struct sway_container *container_reap_empty(struct sway_container *container) {
- if (!sway_assert(container, "reaping null container")) {
+ if (container == NULL) {
return NULL;
}
- wlr_log(L_DEBUG, "reaping %p %s", container, container->name);
- while (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;
@@ -135,25 +138,49 @@ struct sway_container *container_remove_child(struct sway_container *child) {
}
}
child->parent = NULL;
- return container_reap_empty(parent);
+ 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 = 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);
+ seat_set_focus(seat, ws);
+ }
+ container_sort_workspaces(new_parent);
+ 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) {
@@ -248,8 +275,8 @@ void arrange_windows(struct sway_container *container,
struct wlr_box *area = &output->sway_output->usable_area;
wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
area->width, area->height, area->x, area->y);
- container->width = area->width;
- container->height = area->height;
+ container->width = width = area->width;
+ container->height = height = area->height;
container->x = x = area->x;
container->y = y = area->y;
wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
@@ -261,7 +288,7 @@ void arrange_windows(struct sway_container *container,
{
container->width = width;
container->height = height;
- view_set_size(container->sway_view,
+ view_configure(container->sway_view, container->x, container->y,
container->width, container->height);
wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f",
container->width, container->height,
@@ -322,7 +349,14 @@ static void apply_horiz_layout(struct sway_container *container,
wlr_log(L_DEBUG,
"Calculating arrangement for %p:%d (will scale %f by %f)",
child, child->type, width, scale);
- view_set_position(child->sway_view, child_x, y);
+
+ if (child->type == C_VIEW) {
+ view_configure(child->sway_view, child_x, y, child->width,
+ child->height);
+ } else {
+ child->x = child_x;
+ child->y = y;
+ }
if (i == end - 1) {
double remaining_width = x + width - child_x;
@@ -373,7 +407,13 @@ void apply_vert_layout(struct sway_container *container,
wlr_log(L_DEBUG,
"Calculating arrangement for %p:%d (will scale %f by %f)",
child, child->type, height, scale);
- view_set_position(child->sway_view, x, child_y);
+ if (child->type == C_VIEW) {
+ view_configure(child->sway_view, x, child_y, child->width,
+ child->height);
+ } else {
+ child->x = x;
+ child->y = child_y;
+ }
if (i == end - 1) {
double remaining_height = y + height - child_y;
@@ -404,7 +444,7 @@ static struct sway_container *get_swayc_in_output_direction(
return NULL;
}
- struct sway_container *ws = sway_seat_get_focus_inactive(seat, output);
+ struct sway_container *ws = seat_get_focus_inactive(seat, output);
if (ws->type != C_WORKSPACE) {
ws = container_parent(ws, C_WORKSPACE);
}
@@ -425,7 +465,7 @@ static struct sway_container *get_swayc_in_output_direction(
case MOVE_UP:
case MOVE_DOWN: {
struct sway_container *focused =
- sway_seat_get_focus_inactive(seat, ws);
+ seat_get_focus_inactive(seat, ws);
if (focused && focused->parent) {
struct sway_container *parent = focused->parent;
if (parent->layout == L_VERT) {
@@ -505,11 +545,11 @@ static struct sway_container *sway_output_from_wlr(struct wlr_output *output) {
return NULL;
}
-static struct sway_container *get_swayc_in_direction_under(
- struct sway_container *container, enum movement_direction dir,
- struct sway_seat *seat, struct sway_container *limit) {
+struct sway_container *container_get_in_direction(
+ struct sway_container *container, struct sway_seat *seat,
+ enum movement_direction dir) {
if (dir == MOVE_CHILD) {
- return sway_seat_get_focus_inactive(seat, container);
+ return seat_get_focus_inactive(seat, container);
}
struct sway_container *parent = container->parent;
@@ -521,26 +561,6 @@ static struct sway_container *get_swayc_in_direction_under(
}
}
- 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)) {
@@ -559,7 +579,6 @@ static struct sway_container *get_swayc_in_direction_under(
struct sway_container *wrap_candidate = NULL;
while (true) {
- // Test if we can even make a difference here
bool can_move = false;
int desired;
int idx = index_child(container);
@@ -589,7 +608,7 @@ static struct sway_container *get_swayc_in_direction_under(
}
if (next->children && next->children->length) {
// TODO consider floating children as well
- return sway_seat_get_focus_inactive(seat, next);
+ return seat_get_focus_by_type(seat, next, C_VIEW);
} else {
return next;
}
@@ -619,21 +638,23 @@ static struct sway_container *get_swayc_in_direction_under(
wrap_candidate = parent->children->items[0];
}
if (config->force_focus_wrapping) {
- return wrap_candidate;
+ return seat_get_focus_by_type(seat,
+ wrap_candidate, C_VIEW);
}
}
} else {
wlr_log(L_DEBUG,
"cont %d-%p dir %i sibling %d: %p", idx,
container, dir, desired, parent->children->items[desired]);
- return parent->children->items[desired];
+ return seat_get_focus_by_type(seat,
+ parent->children->items[desired], C_VIEW);
}
}
if (!can_move) {
container = parent;
parent = parent->parent;
- if (!parent || container == limit) {
+ if (!parent) {
// wrapping is the last chance
return wrap_candidate;
}
@@ -641,8 +662,70 @@ static struct sway_container *get_swayc_in_direction_under(
}
}
-struct sway_container *container_get_in_direction(
- struct sway_container *container, struct sway_seat *seat,
- enum movement_direction dir) {
- return get_swayc_in_direction_under(container, dir, seat, NULL);
+struct sway_container *container_replace_child(struct sway_container *child,
+ struct sway_container *new_child) {
+ struct sway_container *parent = child->parent;
+ if (parent == NULL) {
+ return NULL;
+ }
+ int i = index_child(child);
+
+ // TODO floating
+ parent->children->items[i] = new_child;
+ new_child->parent = parent;
+ child->parent = NULL;
+
+ // Set geometry for new child
+ new_child->x = child->x;
+ new_child->y = child->y;
+ new_child->width = child->width;
+ new_child->height = child->height;
+
+ // reset geometry for child
+ child->width = 0;
+ child->height = 0;
+
+ return parent;
+}
+
+struct sway_container *container_split(struct sway_container *child,
+ enum sway_container_layout layout) {
+ // TODO floating: cannot split a floating container
+ if (!sway_assert(child, "child cannot be null")) {
+ return NULL;
+ }
+ struct sway_container *cont = container_create(C_CONTAINER);
+
+ wlr_log(L_DEBUG, "creating container %p around %p", cont, child);
+
+ cont->prev_layout = L_NONE;
+ cont->width = child->width;
+ cont->height = child->height;
+ cont->x = child->x;
+ cont->y = child->y;
+
+ if (child->type == C_WORKSPACE) {
+ struct sway_seat *seat = input_manager_get_default_seat(input_manager);
+ struct sway_container *workspace = child;
+ bool set_focus = (seat_get_focus(seat) == workspace);
+
+ while (workspace->children->length) {
+ struct sway_container *ws_child = workspace->children->items[0];
+ container_remove_child(ws_child);
+ container_add_child(cont, ws_child);
+ }
+
+ container_add_child(workspace, cont);
+ container_set_layout(workspace, layout);
+
+ if (set_focus) {
+ seat_set_focus(seat, cont);
+ }
+ } else {
+ cont->layout = layout;
+ container_replace_child(child, cont);
+ container_add_child(cont, child);
+ }
+
+ return cont;
}
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 7248fd00..0509db23 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -1,3 +1,4 @@
+#include <strings.h>
#include "sway/tree/container.h"
#include "sway/tree/layout.h"
#include "sway/output.h"
@@ -29,6 +30,7 @@ struct sway_container *container_output_destroy(struct sway_container *output) {
wl_list_remove(&output->sway_output->destroy.link);
wl_list_remove(&output->sway_output->mode.link);
wl_list_remove(&output->sway_output->transform.link);
+ wl_list_remove(&output->sway_output->scale.link);
wl_list_remove(&output->sway_output->damage_destroy.link);
wl_list_remove(&output->sway_output->damage_frame.link);
@@ -37,3 +39,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;
+}
diff --git a/sway/tree/view.c b/sway/tree/view.c
index b7d1a41b..09c804e4 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/types/wlr_output_layout.h>
#include "log.h"
@@ -6,82 +7,117 @@
#include "sway/tree/layout.h"
#include "sway/tree/view.h"
+struct sway_view *view_create(enum sway_view_type type,
+ const struct sway_view_impl *impl) {
+ struct sway_view *view = calloc(1, sizeof(struct sway_view));
+ if (view == NULL) {
+ return NULL;
+ }
+ view->type = type;
+ view->impl = impl;
+ return view;
+}
+
+void view_destroy(struct sway_view *view) {
+ if (view == NULL) {
+ return;
+ }
+
+ if (view->surface != NULL) {
+ view_unmap(view);
+ }
+
+ container_view_destroy(view->swayc);
+ free(view);
+}
+
const char *view_get_title(struct sway_view *view) {
- if (view->iface.get_prop) {
- return view->iface.get_prop(view, VIEW_PROP_TITLE);
+ if (view->impl->get_prop) {
+ return view->impl->get_prop(view, VIEW_PROP_TITLE);
}
return NULL;
}
const char *view_get_app_id(struct sway_view *view) {
- if (view->iface.get_prop) {
- return view->iface.get_prop(view, VIEW_PROP_APP_ID);
+ if (view->impl->get_prop) {
+ return view->impl->get_prop(view, VIEW_PROP_APP_ID);
}
return NULL;
}
const char *view_get_class(struct sway_view *view) {
- if (view->iface.get_prop) {
- return view->iface.get_prop(view, VIEW_PROP_CLASS);
+ if (view->impl->get_prop) {
+ return view->impl->get_prop(view, VIEW_PROP_CLASS);
}
return NULL;
}
const char *view_get_instance(struct sway_view *view) {
- if (view->iface.get_prop) {
- return view->iface.get_prop(view, VIEW_PROP_INSTANCE);
+ if (view->impl->get_prop) {
+ return view->impl->get_prop(view, VIEW_PROP_INSTANCE);
}
return NULL;
}
-void view_set_size(struct sway_view *view, int width, int height) {
- if (view->iface.set_size) {
- struct wlr_box box = {
- .x = view->swayc->x,
- .y = view->swayc->y,
- .width = view->width,
- .height = view->height,
- };
- view->iface.set_size(view, width, height);
- view_update_outputs(view, &box);
+void view_configure(struct sway_view *view, double ox, double oy, int width,
+ int height) {
+ if (view->impl->configure) {
+ view->impl->configure(view, ox, oy, width, height);
}
}
-// TODO make view coordinates in layout coordinates
-void view_set_position(struct sway_view *view, double ox, double oy) {
- if (view->iface.set_position) {
- struct wlr_box box = {
- .x = view->swayc->x,
- .y = view->swayc->y,
- .width = view->width,
- .height = view->height,
- };
- view->iface.set_position(view, ox, oy);
- view_update_outputs(view, &box);
+void view_set_activated(struct sway_view *view, bool activated) {
+ if (view->impl->set_activated) {
+ view->impl->set_activated(view, activated);
}
}
-void view_set_activated(struct sway_view *view, bool activated) {
- if (view->iface.set_activated) {
- view->iface.set_activated(view, activated);
+void view_close(struct sway_view *view) {
+ if (view->impl->close) {
+ view->impl->close(view);
}
}
-void view_close(struct sway_view *view) {
- if (view->iface.close) {
- view->iface.close(view);
+struct sway_container *container_view_destroy(struct sway_container *view) {
+ if (!view) {
+ return NULL;
}
+ wlr_log(L_DEBUG, "Destroying view '%s'", view->name);
+ struct sway_container *parent = container_destroy(view);
+ arrange_windows(parent, -1, -1);
+ return parent;
+}
+
+void view_damage_whole(struct sway_view *view) {
+ for (int i = 0; i < root_container.children->length; ++i) {
+ struct sway_container *cont = root_container.children->items[i];
+ if (cont->type == C_OUTPUT) {
+ output_damage_whole_view(cont->sway_output, view);
+ }
+ }
+}
+
+void view_damage_from(struct sway_view *view) {
+ // TODO
+ view_damage_whole(view);
+}
+
+static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) {
+ struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
+
+ box->x = output->x + view->swayc->x;
+ box->y = output->y + view->swayc->y;
+ box->width = view->width;
+ box->height = view->height;
}
-void view_update_outputs(struct sway_view *view, const struct wlr_box *before) {
+static void view_update_outputs(struct sway_view *view,
+ const struct wlr_box *before) {
+ struct wlr_box box;
+ view_get_layout_box(view, &box);
+
struct wlr_output_layout *output_layout =
root_container.sway_root->output_layout;
- struct wlr_box box = {
- .x = view->swayc->x,
- .y = view->swayc->y,
- .width = view->width,
- .height = view->height,
- };
struct wlr_output_layout_output *layout_output;
wl_list_for_each(layout_output, &output_layout->outputs, link) {
bool intersected = before != NULL && wlr_output_layout_intersects(
@@ -97,27 +133,63 @@ void view_update_outputs(struct sway_view *view, const struct wlr_box *before) {
}
}
-struct sway_container *container_view_destroy(struct sway_container *view) {
- if (!view) {
- return NULL;
+void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
+ if (!sway_assert(view->surface == NULL, "cannot map mapped view")) {
+ return;
}
- wlr_log(L_DEBUG, "Destroying view '%s'", view->name);
- struct sway_container *parent = container_destroy(view);
- arrange_windows(parent, -1, -1);
- return parent;
+
+ struct sway_seat *seat = input_manager_current_seat(input_manager);
+ struct sway_container *focus = seat_get_focus_inactive(seat,
+ &root_container);
+ struct sway_container *cont = container_view_create(focus, view);
+
+ view->surface = wlr_surface;
+ view->swayc = cont;
+
+ arrange_windows(cont->parent, -1, -1);
+ input_manager_set_focus(input_manager, cont);
+
+ view_damage_whole(view);
+ view_update_outputs(view, NULL);
}
-void view_damage_whole(struct sway_view *view) {
- struct sway_container *cont = NULL;
- for (int i = 0; i < root_container.children->length; ++i) {
- cont = root_container.children->items[i];
- if (cont->type == C_OUTPUT) {
- output_damage_whole_view(cont->sway_output, view);
- }
+void view_unmap(struct sway_view *view) {
+ if (!sway_assert(view->surface != NULL, "cannot unmap unmapped view")) {
+ return;
}
+
+ view_damage_whole(view);
+
+ container_view_destroy(view->swayc);
+
+ view->swayc = NULL;
+ view->surface = NULL;
}
-void view_damage_from(struct sway_view *view) {
- // TODO
+void view_update_position(struct sway_view *view, double ox, double oy) {
+ if (view->swayc->x == ox && view->swayc->y == oy) {
+ return;
+ }
+
+ struct wlr_box box;
+ view_get_layout_box(view, &box);
+ view_damage_whole(view);
+ view->swayc->x = ox;
+ view->swayc->y = oy;
+ view_update_outputs(view, &box);
+ view_damage_whole(view);
+}
+
+void view_update_size(struct sway_view *view, int width, int height) {
+ if (view->width == width && view->height == height) {
+ return;
+ }
+
+ struct wlr_box box;
+ view_get_layout_box(view, &box);
+ view_damage_whole(view);
+ view->width = width;
+ view->height = height;
+ view_update_outputs(view, &box);
view_damage_whole(view);
}
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index d6fd7c70..8077de2e 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -176,7 +176,7 @@ static bool _workspace_by_name(struct sway_container *view, void *data) {
struct sway_container *workspace_by_name(const char *name) {
struct sway_seat *seat = input_manager_current_seat(input_manager);
struct sway_container *current_workspace = NULL, *current_output = NULL;
- struct sway_container *focus = sway_seat_get_focus(seat);
+ struct sway_container *focus = seat_get_focus(seat);
if (focus) {
current_workspace = container_parent(focus, C_WORKSPACE);
current_output = container_parent(focus, C_OUTPUT);
@@ -218,7 +218,7 @@ struct sway_container *workspace_create(const char *name) {
// Otherwise create a new one
struct sway_seat *seat = input_manager_current_seat(input_manager);
struct sway_container *focus =
- sway_seat_get_focus_inactive(seat, &root_container);
+ seat_get_focus_inactive(seat, &root_container);
parent = focus;
parent = container_parent(parent, C_OUTPUT);
struct sway_container *new_ws = container_workspace_create(parent, name);
@@ -278,7 +278,7 @@ struct sway_container *workspace_output_prev_next_impl(
}
struct sway_seat *seat = input_manager_current_seat(input_manager);
- struct sway_container *focus = sway_seat_get_focus_inactive(seat, output);
+ struct sway_container *focus = seat_get_focus_inactive(seat, output);
struct sway_container *workspace = (focus->type == C_WORKSPACE ?
focus :
container_parent(focus, C_WORKSPACE));
@@ -363,13 +363,13 @@ bool workspace_switch(struct sway_container *workspace) {
}
struct sway_seat *seat = input_manager_current_seat(input_manager);
struct sway_container *focus =
- sway_seat_get_focus_inactive(seat, &root_container);
+ seat_get_focus_inactive(seat, &root_container);
if (!seat || !focus) {
return false;
}
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
@@ -394,11 +394,11 @@ bool workspace_switch(struct sway_container *workspace) {
wlr_log(L_DEBUG, "Switching to workspace %p:%s",
workspace, workspace->name);
- struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace);
+ struct sway_container *next = seat_get_focus_inactive(seat, workspace);
if (next == NULL) {
next = workspace;
}
- sway_seat_set_focus(seat, next);
+ seat_set_focus(seat, next);
struct sway_container *output = container_parent(workspace, C_OUTPUT);
arrange_windows(output, -1, -1);
return true;
@@ -407,7 +407,7 @@ bool workspace_switch(struct sway_container *workspace) {
bool workspace_is_visible(struct sway_container *ws) {
struct sway_container *output = container_parent(ws, C_OUTPUT);
struct sway_seat *seat = input_manager_current_seat(input_manager);
- struct sway_container *focus = sway_seat_get_focus_inactive(seat, output);
+ struct sway_container *focus = seat_get_focus_inactive(seat, output);
if (focus->type != C_WORKSPACE) {
focus = container_parent(focus, C_WORKSPACE);
}