Merge pull request #2242 from RyanDwyer/floating-zindex

Move floating windows to front when focused
This commit is contained in:
Drew DeVault 2018-07-11 04:38:46 -07:00 committed by GitHub
commit 00daa17446
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "log.h"
list_t *create_list(void) { list_t *create_list(void) {
list_t *list = malloc(sizeof(list_t)); 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; 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) { static void list_rotate(list_t *list, int from, int to) {
void *tmp = list->items[to]; void *tmp = list->items[to];

View file

@ -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)); void list_stable_sort(list_t *list, int compare(const void *a, const void *b));
// swap two elements in a list // swap two elements in a list
void list_swap(list_t *list, int src, int dest); 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 #endif

View file

@ -666,6 +666,14 @@ void seat_set_focus_warp(struct sway_seat *seat,
container_damage_whole(container->parent); 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 // clean up unfocused empty workspace on new output
if (new_output_last_ws) { if (new_output_last_ws) {
if (!workspace_is_visible(new_output_last_ws) if (!workspace_is_visible(new_output_last_ws)