From 975525e617d5c6c1b031c97b5d0429f078fa20a0 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sun, 11 Aug 2024 22:50:04 -0400 Subject: [PATCH] add hook for handling client messages for EWMH --- anvil.c | 22 ++++++++++++++-------- anvil.h | 1 + client.c | 4 ++-- ewmh.c | 6 ++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/anvil.c b/anvil.c index 6f11a30..4b3b0da 100644 --- a/anvil.c +++ b/anvil.c @@ -107,7 +107,7 @@ static void XBtnMotion(XEvent* e) { /* make sure we get just the latest event */ XMotionEvent *ev = &e->xmotion; - printf("BTN_MV(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root); +// printf("BTN_MV(w: 0x%lx x: %d y: %d rx: %d ry: %d)\n", ev->window, ev->x, ev->y, ev->x_root, ev->y_root); while (XCheckTypedWindowEvent(X.disp, ev->window, ev->type, e)); Mouse_Drag(ev); @@ -117,7 +117,7 @@ static void XBtnMotion(XEvent* e) static void XConfigRequest(XEvent* e) { XConfigureRequestEvent* ev = &(e->xconfigurerequest); - printf("CONF(w: 0x%lx x: %d y: %d w: %d h: %d)\n", ev->window, ev->x, ev->y, ev->width, ev->height); +// printf("CONF(w: 0x%lx x: %d y: %d w: %d h: %d)\n", ev->window, ev->x, ev->y, ev->width, ev->height); XWindowChanges wc; wc.x = ev->x; wc.y = ev->y; @@ -156,10 +156,17 @@ static void XClientMsg(XEvent* e) { XClientMessageEvent* ev = &(e->xclient); printf("CLIENT_MSG(w: 0x%lx a: '%s')\n", ev->window, XGetAtomName(X.disp, ev->message_type)); -// if (ev->message_type == _NET_ACTIVE_WINDOW) -// { -//// mons_activate(ev->window); -// } + if (ev->message_type == _NET_ACTIVE_WINDOW) + { +// mons_activate(ev->window); + } + else if (ev->message_type == _NET_WM_STATE) + { + printf(" %ld\n", ev->data.l[0]); + printf(" %s\n", XGetAtomName(X.disp, ev->data.l[1])); + EWMH_UpdateWindowStateFlags( + ev->window, ev->data.l[0], ev->data.l[1]); + } } static void XPropNotify(XEvent* e) @@ -189,7 +196,7 @@ static void XExpose(XEvent* e) XExposeEvent* ev = &(e->xexpose); if (ev->count == 0) { - printf("EXPOSE(w: 0x%lx)\n", ev->window); +// printf("EXPOSE(w: 0x%lx)\n", ev->window); Client* c = Client_Find(ev->window); if (c) { @@ -318,7 +325,6 @@ int main(void) /* initialize all the things */ Atoms_Init(); - EWMH_Init(); InitCursors(); InitFont(); Client_InitAll(); diff --git a/anvil.h b/anvil.h index 71e3f08..e41d675 100644 --- a/anvil.h +++ b/anvil.h @@ -190,6 +190,7 @@ char* EWMH_GetName(Window w); int EWMH_GetWindowTypeFlags(Window w); int EWMH_GetWindowStateFlags(Window w); void EWMH_SetWindowStateFlags(Window w, int flags); +void EWMH_UpdateWindowStateFlags(Window w, int op, Atom prop); //void EWMH_GetWindowStrut(Strut* strut); int EWMH_GetWindowPid(Window w); void EWMH_SetWindowFrameExtents(Window w, int left, int right, int top, int bottom); diff --git a/client.c b/client.c index 58bf229..081137b 100644 --- a/client.c +++ b/client.c @@ -134,7 +134,7 @@ void Client_MoveResize(Client* c) int minheight = (shaded || !floating ? MIN_HEIGHT : 3*MIN_HEIGHT); if (c->w < minheight) c->w = minheight; if (c->h < minheight) c->h = minheight; - printf("XMoveResize(0x%lx, %d, %d, %d, %d)\n", c->frame, c->x, c->y, c->w, c->h); +// printf("XMoveResize(0x%lx, %d, %d, %d, %d)\n", c->frame, c->x, c->y, c->w, c->h); XMoveResizeWindow(X.disp, c->frame, c->x, c->y, c->w, (shaded ? minheight : c->h)); if ( !(c->flags & F_SHADED) ) { @@ -142,7 +142,7 @@ void Client_MoveResize(Client* c) int child_h = c->h - FRAME_HEIGHT_SUM; if (child_w < 1) c->w = 1; if (child_h < 1) c->h = 1; - printf("XResize(0x%lx, %d, %d)\n", c->win, c->w, c->h); +// printf("XResize(0x%lx, %d, %d)\n", c->win, c->w, c->h); XResizeWindow(X.disp, c->win, child_w, child_h); } Client_Place(c); diff --git a/ewmh.c b/ewmh.c index acd4bad..aa9a1a9 100644 --- a/ewmh.c +++ b/ewmh.c @@ -181,6 +181,12 @@ void EWMH_SetWindowStateFlags(Window w, int flags) WriteFlagHint(w, _NET_WM_STATE, WindowStates, nelem(WindowStates), flags); } +void EWMH_UpdateWindowStateFlags(Window w, int op, Atom prop) +{ + (void)w, (void)op, (void)prop; +} + + //void EWMH_GetWindowStrut(Strut* strut) //{ // // Read _NET_WM_STRUT_PARTIAL -- 2.51.0