From db944a1a25e3a650f4d9cf457fdd09aa80d84ef6 Mon Sep 17 00:00:00 2001 From: seanpringle Date: Mon, 3 Sep 2012 16:09:49 +1000 Subject: [PATCH] ewmh above, only above fullscreen --- config.h | 4 ++++ xoat.1 | 7 ++++++- xoat.c | 37 +++++++++++++++++++++++++++---------- xoat.h | 2 ++ xoat.md | 5 ++++- 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/config.h b/config.h index 1e685ce..bfc5f72 100644 --- a/config.h +++ b/config.h @@ -4,6 +4,7 @@ #define BORDER_BLUR "Dark Gray" #define BORDER_FOCUS "Royal Blue" #define BORDER_URGENT "Red" +#define BORDER_ABOVE "Dark Green" // There are three static tiles called SPOT1, SPOT2, and SPOT3. // Want more tiles? Different layouts? Floating? Go away ;) @@ -68,6 +69,9 @@ binding keys[] = { // Toggle current window full screen. { .mod = Mod4Mask, .key = XK_f, .act = ACTION_FULLSCREEN_TOGGLE }, + // Toggle current window above. + { .mod = Mod4Mask, .key = XK_a, .act = ACTION_ABOVE_TOGGLE }, + // Switch focus between monitors. { .mod = Mod4Mask, .key = XK_Right, .act = ACTION_FOCUS_MONITOR_INC }, { .mod = Mod4Mask, .key = XK_Left, .act = ACTION_FOCUS_MONITOR_DEC }, diff --git a/xoat.1 b/xoat.1 index 6ede2e3..ff4727c 100644 --- a/xoat.1 +++ b/xoat.1 @@ -62,11 +62,16 @@ Close a window. .RE .TP .B Mod4-f -Toggle fullscreen. +Toggle state fullscreen. While in fullscreen mode, an window is considered to be in tile 1. .RS .RE .TP +.B Mod4-a +Toggle state above (only placed above fullscreen windows). +.RS +.RE +.TP .B Mod4-Right Focus next monitor. .RS diff --git a/xoat.c b/xoat.c index 7029c29..70e2d4d 100644 --- a/xoat.c +++ b/xoat.c @@ -490,6 +490,8 @@ void client_stack(client *c, stack *all, stack *raise) // raise a window and all its transients void client_raise(client *c) { + if (!c) return; + int i; stack raise, all, family; memset(&raise, 0, sizeof(stack)); memset(&family, 0, sizeof(stack)); @@ -498,21 +500,23 @@ void client_raise(client *c) for (i = 0; i < all.depth; i++) { client *o = all.clients[i]; - // docks stay on top if (o && o->type == atoms[_NET_WM_WINDOW_TYPE_DOCK]) + client_stack(o, &all, &raise); + } + // above only counts for fullscreen windows + if (client_state(c, atoms[_NET_WM_STATE_FULLSCREEN])) + { + for (i = 0; i < all.depth; i++) { - raise.clients[raise.depth] = o; - raise.windows[raise.depth++] = o->window; + client *o = all.clients[i]; + if (o && client_state(o, atoms[_NET_WM_STATE_ABOVE])) + client_stack(o, &all, &raise); } } while (c->trans) { client *t = window_client(c->transient_for); - if (t) - { - family.clients[family.depth++] = t; - c = t; - } + if (t) c = family.clients[family.depth++] = t; } client_stack(c, &all, &raise); @@ -526,6 +530,9 @@ void client_raise(client *c) // lower a window and all its transients void client_lower(client *c) { + if (!c || client_state(c, atoms[_NET_WM_STATE_ABOVE])) + return; + stack lower, all; memset(&lower, 0, sizeof(stack)); windows_visible(&all); @@ -596,8 +603,8 @@ void window_listen(Window win) void client_review(client *c) { XSetWindowBorder(display, c->window, - color_get(c->window == current ? BORDER_FOCUS: - (c->urgent ? BORDER_URGENT: BORDER_BLUR))); + color_get(c->window == current ? BORDER_FOCUS: (c->urgent ? BORDER_URGENT: + (client_state(c, atoms[_NET_WM_STATE_ABOVE]) ? BORDER_ABOVE: BORDER_BLUR)))); XSetWindowBorderWidth(display, c->window, client_state(c, atoms[_NET_WM_STATE_FULLSCREEN]) ? 0: BORDER); } @@ -829,6 +836,16 @@ void key_press(XKeyEvent *e) client_review(c); client_spot(c, c->spot, 1); break; + case ACTION_ABOVE_TOGGLE: + spot = c->spot; + client_raise(c); + if (client_state(c, atoms[_NET_WM_STATE_ABOVE])) + client_drop_state(c, atoms[_NET_WM_STATE_ABOVE]); + else + client_add_state(c, atoms[_NET_WM_STATE_ABOVE]); + client_review(c); + client_raise(c); + break; case ACTION_TAG: c->tags |= (unsigned int)num; client_set_tags(c); diff --git a/xoat.h b/xoat.h index 7f3d010..be256e8 100644 --- a/xoat.h +++ b/xoat.h @@ -129,6 +129,7 @@ int struts[4] = { 0, 0, 0, 0 }; X(_NET_WM_WINDOW_TYPE_DIALOG),\ X(_NET_WM_STATE),\ X(_NET_WM_STATE_FULLSCREEN),\ + X(_NET_WM_STATE_ABOVE),\ X(_NET_WM_STATE_DEMANDS_ATTENTION),\ X(WM_DELETE_WINDOW),\ X(WM_TAKE_FOCUS),\ @@ -158,6 +159,7 @@ enum { ACTION_FOCUS_MONITOR_INC, ACTION_FOCUS_MONITOR_DEC, ACTION_FULLSCREEN_TOGGLE, + ACTION_ABOVE_TOGGLE, ACTION_TAG, ACTION_UNTAG, ACTION_RAISE_TAG, diff --git a/xoat.md b/xoat.md index e9c8495..a9d2a77 100644 --- a/xoat.md +++ b/xoat.md @@ -48,7 +48,10 @@ Mod4-Escape : Close a window. Mod4-f -: Toggle fullscreen. While in fullscreen mode, an window is considered to be in tile 1. +: Toggle state fullscreen. While in fullscreen mode, an window is considered to be in tile 1. + +Mod4-a +: Toggle state above (only placed above fullscreen windows). Mod4-Right : Focus next monitor.