]> git.mdlowis.com Git - proto/anvil.git/commitdiff
add hook for handling client messages for EWMH
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 12 Aug 2024 02:50:04 +0000 (22:50 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 12 Aug 2024 02:50:04 +0000 (22:50 -0400)
anvil.c
anvil.h
client.c
ewmh.c

diff --git a/anvil.c b/anvil.c
index 6f11a302480cc976e925eae2feb4d94f5efda2b1..4b3b0da9519f7921fd0339e86b2e47d83606bb84 100644 (file)
--- 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 71e3f0855c4df438f708ebfe7127968da630ff01..e41d6753b3af52ede6a6eed92b344ec3992d61b4 100644 (file)
--- 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);
index 58bf2299164b09bfb876f5e75e081689cc086177..081137b7dacd13e573ec5a6f8cb1c77bf2b75e8f 100644 (file)
--- 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 acd4bad6cfdb6fde3e42ae92b42a2b0c886a9836..aa9a1a9ab3673188c189772ef7e7e7308040a5a2 100644 (file)
--- 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