diff options
author | Hans-Peter Deifel <hpdeifel@gmx.de> | 2012-11-18 19:21:53 +0100 |
---|---|---|
committer | Thorsten Wißmann <re06huxa@stud.informatik.uni-erlangen.de> | 2012-11-19 10:16:50 +0100 |
commit | 13ab74e025bd7d0cb0066a39281e48040d081976 (patch) | |
tree | bfdcef5fdd08db506848fa04f43272d24bca4548 /src | |
parent | d269a0d4b04fc60620dbbaffb6744bb0cf9f330b (diff) |
Only include clients in _NET_CLIENT_LIST_STACKING
Frames and other X-windows created by the WM shouldn't appear in
_NET_CLIENT_LIST_STACKING.
Diffstat (limited to 'src')
-rw-r--r-- | src/ewmh.c | 5 | ||||
-rw-r--r-- | src/monitor.c | 14 | ||||
-rw-r--r-- | src/monitor.h | 5 | ||||
-rw-r--r-- | src/stack.c | 45 | ||||
-rw-r--r-- | src/stack.h | 5 |
5 files changed, 44 insertions, 30 deletions
@@ -15,6 +15,7 @@ #include <string.h> #include <stdio.h> #include <stdint.h> +#include <stdbool.h> #include <X11/Xlib.h> #include <X11/Xproto.h> @@ -165,10 +166,10 @@ void ewmh_get_original_client_list(Window** buf, unsigned long *count) { } void ewmh_update_client_list_stacking() { - int count = monitor_stack_window_count(); + int count = monitor_stack_window_count(true); Window* buf = g_new(Window, count); int remain; - monitor_stack_to_window_buf(buf, count, &remain); + monitor_stack_to_window_buf(buf, count, true, &remain); array_reverse(buf, count, sizeof(buf[0])); XChangeProperty(g_display, g_root, g_netatom[NetClientListStacking], diff --git a/src/monitor.c b/src/monitor.c index a039c4f1..ea99018d 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -6,6 +6,7 @@ #include <assert.h> #include <string.h> #include <stdio.h> +#include <stdbool.h> #ifdef XINERAMA #include <X11/extensions/Xinerama.h> #endif /* XINERAMA */ @@ -974,12 +975,13 @@ int detect_monitors_command(int argc, char **argv, GString* output) { return ret; } -int monitor_stack_window_count() { - return stack_window_count(g_monitor_stack); +int monitor_stack_window_count(bool only_clients) { + return stack_window_count(g_monitor_stack, only_clients); } -void monitor_stack_to_window_buf(Window* buf, int len, int* remain_len) { - stack_to_window_buf(g_monitor_stack, buf, len, remain_len); +void monitor_stack_to_window_buf(Window* buf, int len, bool only_clients, + int* remain_len) { + stack_to_window_buf(g_monitor_stack, buf, len, only_clients, remain_len); } HSStack* get_monitor_stack() { @@ -1004,10 +1006,10 @@ int monitor_raise_command(int argc, char** argv, GString* output) { } void monitor_restack(HSMonitor* monitor) { - int count = 1 + stack_window_count(monitor->tag->stack); + int count = 1 + stack_window_count(monitor->tag->stack, false); Window* buf = g_new(Window, count); buf[0] = monitor->stacking_window; - stack_to_window_buf(monitor->tag->stack, buf + 1, count - 1, NULL); + stack_to_window_buf(monitor->tag->stack, buf + 1, count - 1, false, NULL); /* remove a focused fullscreen client */ Window win = frame_focused_window(monitor->tag->frame); HSClient* client = win ? get_client_from_window(win) : NULL; diff --git a/src/monitor.h b/src/monitor.h index a23adca6..57e036cd 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -82,8 +82,9 @@ void all_monitors_apply_layout(); void ensure_monitors_are_available(); void monitor_restack(HSMonitor* monitor); -int monitor_stack_window_count(); -void monitor_stack_to_window_buf(Window* buf, int len, int* remain_len); +int monitor_stack_window_count(bool only_clients); +void monitor_stack_to_window_buf(Window* buf, int len, bool only_clients, + int* remain_len); struct HSStack* get_monitor_stack(); diff --git a/src/stack.c b/src/stack.c index 549b04a2..5915e893 100644 --- a/src/stack.c +++ b/src/stack.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <string.h> #include <assert.h> +#include <stdbool.h> static struct HSTreeInterface stack_nth_child(HSTree root, size_t idx); static size_t stack_child_count(HSTree root); @@ -208,9 +209,9 @@ int print_stack_command(int argc, char** argv, GString* output) { return 0; } -int stack_window_count(HSStack* stack) { +int stack_window_count(HSStack* stack, bool only_clients) { int counter = 0; - stack_to_window_buf(stack, NULL, 0, &counter); + stack_to_window_buf(stack, NULL, 0, only_clients, &counter); return -counter; } @@ -219,6 +220,7 @@ struct s2wb { int len; Window* buf; int missing; /* number of slices that could not find space in buf */ + bool only_clients; /* whether to include windows that aren't clients */ HSLayer layer; /* the layer the slice should be added to */ }; @@ -240,25 +242,30 @@ static void slice_to_window_buf(HSSlice* s, struct s2wb* data) { } break; case SLICE_WINDOW: - if (data->len) { - data->buf[0] = s->data.window; - data->buf++; - data->len--; - } else { - data->missing++; + if (!data->only_clients) { + if (data->len) { + data->buf[0] = s->data.window; + data->buf++; + data->len--; + } else { + data->missing++; + } } break; case SLICE_MONITOR: tag = s->data.monitor->tag; - if (data->len) { - data->buf[0] = s->data.monitor->stacking_window; - data->buf++; - data->len--; - } else { - data->missing++; + if (!data->only_clients) { + if (data->len) { + data->buf[0] = s->data.monitor->stacking_window; + data->buf++; + data->len--; + } else { + data->missing++; + } } int remain_len = 0; /* remaining length */ - stack_to_window_buf(tag->stack, data->buf, data->len, &remain_len); + stack_to_window_buf(tag->stack, data->buf, data->len, + data->only_clients, &remain_len); int len_used = data->len - remain_len; if (remain_len >= 0) { data->buf += len_used; @@ -271,11 +278,13 @@ static void slice_to_window_buf(HSSlice* s, struct s2wb* data) { } } -void stack_to_window_buf(HSStack* stack, Window* buf, int len, int* remain_len) { +void stack_to_window_buf(HSStack* stack, Window* buf, int len, + bool only_clients, int* remain_len) { struct s2wb data = { .len = len, .buf = buf, .missing = 0, + .only_clients = only_clients, }; for (int i = 0; i < LAYER_COUNT; i++) { data.layer = i; @@ -296,9 +305,9 @@ void stack_restack(HSStack* stack) { if (!stack->dirty) { return; } - int count = stack_window_count(stack); + int count = stack_window_count(stack, false); Window* buf = g_new0(Window, count); - stack_to_window_buf(stack, buf, count, NULL); + stack_to_window_buf(stack, buf, count, false, NULL); XRestackWindows(g_display, buf, count); stack->dirty = false; ewmh_update_client_list_stacking(); diff --git a/src/stack.h b/src/stack.h index fd29b337..c3fd9ee8 100644 --- a/src/stack.h +++ b/src/stack.h @@ -69,8 +69,9 @@ void stack_clear_layer(HSStack* s, HSLayer layer); int print_stack_command(int argc, char** argv, GString* output); // returns the number of windows in this stack -int stack_window_count(HSStack* stack); -void stack_to_window_buf(HSStack* stack, Window* buf, int len, int* remain_len); +int stack_window_count(HSStack* stack, bool only_clients); +void stack_to_window_buf(HSStack* stack, Window* buf, int len, bool only_clients, + int* remain_len); void stack_restack(HSStack* stack); Window stack_lowest_window(HSStack* stack); |