From 6686616107f775f66bdab55c427349cb8096c9a9 Mon Sep 17 00:00:00 2001 From: Mike Lowis Date: Wed, 7 Aug 2024 16:31:11 -0400 Subject: [PATCH] Added reading and partial handling of transient_for hint. These are dialogs that will float. They should also be mapped to same workspace as their parent window and be centered on screen --- anvil.h | 2 +- client.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/anvil.h b/anvil.h index a020dd9..e086b8f 100644 --- a/anvil.h +++ b/anvil.h @@ -81,7 +81,7 @@ typedef struct Client { struct Client* col_next; struct Client* col_prev; char* name; - Window frame, win; + Window frame, win, transient_for; int state, flags, wspace, x, y, w, h, rel_x, rel_y; long hint_flags, wm_flags; XWMHints hints; diff --git a/client.c b/client.c index b4b7e01..4139f7b 100644 --- a/client.c +++ b/client.c @@ -333,7 +333,8 @@ static void ReadProps(Client* c) // TODO: Read the class and instance of the window /* WM_TRANSIENT_FOR - marks the window as a pop-up for another window */ - // TODO: read the transient_for property and use ti to handle pop-ups better + c->transient_for = None; + XGetTransientForHint(X.disp, c->win, &(c->transient_for)); /* WM_CLIENT_MACHINE - */ // TODO: read client machine property @@ -341,7 +342,7 @@ static void ReadProps(Client* c) /* check if the window is a dialog */ XGetWindowProperty( X.disp, c->win, _NET_WM_WINDOW_TYPE, 0L, -1, False, XA_ATOM, &actual_type, &format, &n, &extra, (unsigned char **)&wintype); - if (wintype && *wintype == _NET_WM_WINDOW_TYPE_DIALOG) + if ((wintype && *wintype == _NET_WM_WINDOW_TYPE_DIALOG) || (c->transient_for != None)) { c->flags |= F_DIALOG|F_FLOATING; } @@ -442,7 +443,6 @@ static int MonitorOverlap(Monitor* mon, Client* c) int top = max(ctop, mon->y); int bot = min(cbot, mon->y + mon->h); - /* return the overlapped area */ int area = 0; if (left < right && top < bot) -- 2.51.0