mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-11-15 19:47:57 +01:00
Move floating windows to front when focused
This commit is contained in:
parent
0f14abf512
commit
15dc5286e2
3 changed files with 25 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "log.h"
|
||||
|
||||
list_t *create_list(void) {
|
||||
list_t *list = malloc(sizeof(list_t));
|
||||
|
@ -82,6 +83,20 @@ void list_swap(list_t *list, int src, int dest) {
|
|||
list->items[dest] = tmp;
|
||||
}
|
||||
|
||||
void list_move_to_end(list_t *list, void *item) {
|
||||
int i;
|
||||
for (i = 0; i < list->length; ++i) {
|
||||
if (list->items[i] == item) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!sway_assert(i < list->length, "Item not found in list")) {
|
||||
return;
|
||||
}
|
||||
list_del(list, i);
|
||||
list_add(list, item);
|
||||
}
|
||||
|
||||
static void list_rotate(list_t *list, int from, int to) {
|
||||
void *tmp = list->items[to];
|
||||
|
||||
|
|
|
@ -24,4 +24,6 @@ int list_seq_find(list_t *list, int compare(const void *item, const void *cmp_to
|
|||
void list_stable_sort(list_t *list, int compare(const void *a, const void *b));
|
||||
// swap two elements in a list
|
||||
void list_swap(list_t *list, int src, int dest);
|
||||
// move item to end of list
|
||||
void list_move_to_end(list_t *list, void *item);
|
||||
#endif
|
||||
|
|
|
@ -666,6 +666,14 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
|||
container_damage_whole(container->parent);
|
||||
}
|
||||
|
||||
// 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.
|
||||
// This must happen for both the pending and current children lists.
|
||||
if (container_is_floating(container)) {
|
||||
list_move_to_end(container->parent->children, container);
|
||||
list_move_to_end(container->parent->current.children, container);
|
||||
}
|
||||
|
||||
// clean up unfocused empty workspace on new output
|
||||
if (new_output_last_ws) {
|
||||
if (!workspace_is_visible(new_output_last_ws)
|
||||
|
|
Loading…
Reference in a new issue