mirror of
https://github.com/swaywm/sway.git
synced 2026-05-04 06:46:25 -04:00
refactor container_at to return the correct container in tabbed layout
This commit is contained in:
parent
986358d5a2
commit
56102da124
2 changed files with 45 additions and 13 deletions
|
|
@ -222,10 +222,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
|
||||||
seat_set_focus(cursor->seat, cont);
|
seat_set_focus(cursor->seat, cont);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//TODO: set focus on top border click for tabbed view
|
seat_set_focus(cursor->seat, cont);
|
||||||
if (cont && cont->parent->layout != L_TABBED) {
|
|
||||||
seat_set_focus(cursor->seat, cont);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_seat_pointer_notify_button(cursor->seat->wlr_seat,
|
wlr_seat_pointer_notify_button(cursor->seat->wlr_seat,
|
||||||
|
|
|
||||||
|
|
@ -421,6 +421,8 @@ struct sway_container *container_at(struct sway_container *parent,
|
||||||
|
|
||||||
list_add(queue, parent);
|
list_add(queue, parent);
|
||||||
|
|
||||||
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||||
|
struct sway_container *focus = seat_get_focus_inactive(seat, parent);
|
||||||
struct sway_container *swayc = NULL;
|
struct sway_container *swayc = NULL;
|
||||||
while (queue->length) {
|
while (queue->length) {
|
||||||
swayc = queue->items[0];
|
swayc = queue->items[0];
|
||||||
|
|
@ -460,21 +462,54 @@ struct sway_container *container_at(struct sway_container *parent,
|
||||||
view_sx, view_sy, &_sx, &_sy);
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (_surface) {
|
|
||||||
*sx = _sx;
|
|
||||||
*sy = _sy;
|
|
||||||
*surface = _surface;
|
|
||||||
return swayc;
|
|
||||||
}
|
|
||||||
// Check the view's decorations
|
// Check the view's decorations
|
||||||
struct wlr_box swayc_box = {
|
struct wlr_box swayc_box = {
|
||||||
.x = swayc->x,
|
.x = swayc->x,
|
||||||
.y = swayc->y,
|
.y = swayc->y,
|
||||||
.width = swayc->width,
|
.width = swayc->width,
|
||||||
.height = swayc->height,
|
.height = swayc->height
|
||||||
};
|
};
|
||||||
if (wlr_box_contains_point(&swayc_box, ox, oy)) {
|
// Check which tab the mouse is on
|
||||||
return swayc;
|
int depth;
|
||||||
|
int num_tabs = swayc->parent->children->length;
|
||||||
|
double tab_width = swayc->width / num_tabs;
|
||||||
|
struct wlr_box tab_box = {
|
||||||
|
.y = swayc->y,
|
||||||
|
.width = swayc->width / num_tabs,
|
||||||
|
.height = swayc->sway_view->y - swayc->y
|
||||||
|
};
|
||||||
|
switch (swayc->parent->layout) {
|
||||||
|
case L_NONE:
|
||||||
|
case L_HORIZ:
|
||||||
|
case L_VERT:
|
||||||
|
if (_surface) {
|
||||||
|
*sx = _sx;
|
||||||
|
*sy = _sy;
|
||||||
|
*surface = _surface;
|
||||||
|
return swayc;
|
||||||
|
}
|
||||||
|
if (wlr_box_contains_point(&swayc_box, ox, oy)) {
|
||||||
|
return swayc;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case L_TABBED:
|
||||||
|
for (depth = 0; depth < num_tabs; ++depth) {
|
||||||
|
tab_box.x = swayc->x + depth * tab_width;
|
||||||
|
*sx = _sx;
|
||||||
|
*sy = _sy;
|
||||||
|
*surface = _surface;
|
||||||
|
if (wlr_box_contains_point(&tab_box, ox, oy)) {
|
||||||
|
return swayc->parent->children->items[depth];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (focus == swayc) {
|
||||||
|
return swayc;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case L_STACKED:
|
||||||
|
break;
|
||||||
|
case L_FLOATING:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list_cat(queue, swayc->children);
|
list_cat(queue, swayc->children);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue