aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-05-21 19:52:08 -0400
committerGitHub <noreply@github.com>2018-05-21 19:52:08 -0400
commit9731d080bea58fee78bd52bb5633cb37ec7edc22 (patch)
tree7fbc2b11fc371cdec7ed1b5cdbeb2224d429cace /sway/tree/container.c
parent8bbf78fdd430a7e315356ebeda36adbf48b8953d (diff)
parent4de137e02161ef8188775d50fe5dc8d9e9bb2216 (diff)
Merge pull request #2015 from RyanDwyer/stacked-layout
Implement stacked layout
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 5d88325f..9cf18f61 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -510,7 +510,7 @@ static struct sway_container *container_at_tabbed(struct sway_container *parent,
struct sway_seat *seat = input_manager_current_seat(input_manager);
// Tab titles
- int title_height = config->border_thickness * 2 + config->font_height;
+ int title_height = container_titlebar_height();
if (oy < parent->y + title_height) {
int tab_width = parent->width / parent->children->length;
int child_index = (ox - parent->x) / tab_width;
@@ -533,8 +533,23 @@ static struct sway_container *container_at_tabbed(struct sway_container *parent,
static struct sway_container *container_at_stacked(
struct sway_container *parent, double ox, double oy,
struct wlr_surface **surface, double *sx, double *sy) {
- // TODO
- return NULL;
+ if (oy < parent->y || oy > parent->y + parent->height) {
+ return NULL;
+ }
+ struct sway_seat *seat = input_manager_current_seat(input_manager);
+
+ // Title bars
+ int title_height = container_titlebar_height();
+ int child_index = (oy - parent->y) / title_height;
+ if (child_index < parent->children->length) {
+ struct sway_container *child = parent->children->items[child_index];
+ return seat_get_focus_inactive(seat, child);
+ }
+
+ // Surfaces
+ struct sway_container *current = seat_get_active_child(seat, parent);
+
+ return container_at(current, ox, oy, surface, sx, sy);
}
/**
@@ -847,3 +862,7 @@ void container_notify_child_title_changed(struct sway_container *container) {
container_update_title_textures(container);
container_notify_child_title_changed(container->parent);
}
+
+size_t container_titlebar_height() {
+ return config->font_height + TITLEBAR_V_PADDING * 2;
+}