mirror of
https://github.com/NickHu/sway
synced 2024-12-28 22:23:30 +01:00
Simplify raising a container in seat
* Factor out raising a floating window into s separate function to enable reuse.
This commit is contained in:
parent
298ccb539c
commit
ec713125c6
1 changed files with 15 additions and 19 deletions
|
@ -606,6 +606,18 @@ static int handle_urgent_timeout(void *data) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void container_raise_floating(struct sway_container *con) {
|
||||||
|
// Bring container to front by putting it at the end of the floating list.
|
||||||
|
struct sway_container *floater = con;
|
||||||
|
while (floater->parent) {
|
||||||
|
floater = floater->parent;
|
||||||
|
}
|
||||||
|
if (container_is_floating(floater)) {
|
||||||
|
list_move_to_end(floater->workspace->floating, floater);
|
||||||
|
node_set_dirty(&floater->workspace->node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
|
void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
|
||||||
bool warp, bool notify) {
|
bool warp, bool notify) {
|
||||||
if (seat->focused_layer) {
|
if (seat->focused_layer) {
|
||||||
|
@ -733,16 +745,8 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've focused a floating container, bring it to the front.
|
// If we've focused a floating container, bring it to the front.
|
||||||
// We do this by putting it at the end of the floating list.
|
|
||||||
if (container && config->raise_floating) {
|
if (container && config->raise_floating) {
|
||||||
struct sway_container *floater = container;
|
container_raise_floating(container);
|
||||||
while (floater->parent) {
|
|
||||||
floater = floater->parent;
|
|
||||||
}
|
|
||||||
if (container_is_floating(floater)) {
|
|
||||||
list_move_to_end(floater->workspace->floating, floater);
|
|
||||||
node_set_dirty(&floater->workspace->node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_focus) {
|
if (last_focus) {
|
||||||
|
@ -1018,17 +1022,9 @@ void seat_begin_down(struct sway_seat *seat, struct sway_container *con,
|
||||||
seat->op_ref_con_ly = sy;
|
seat->op_ref_con_ly = sy;
|
||||||
seat->op_moved = false;
|
seat->op_moved = false;
|
||||||
|
|
||||||
// If we've focused a floating container, bring it to the front.
|
// In case the container was not raised by gaining focus, raise on click
|
||||||
// We do this by putting it at the end of the floating list.
|
|
||||||
if (con && !config->raise_floating) {
|
if (con && !config->raise_floating) {
|
||||||
struct sway_container *floater = con;
|
container_raise_floating(con);
|
||||||
while (floater->parent) {
|
|
||||||
floater = floater->parent;
|
|
||||||
}
|
|
||||||
if (container_is_floating(floater)) {
|
|
||||||
list_move_to_end(floater->workspace->floating, floater);
|
|
||||||
node_set_dirty(&floater->workspace->node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue