]> git.mdlowis.com Git - proto/anvil.git/commitdiff
start adding hooks for handling state messages
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 15 Aug 2024 02:54:57 +0000 (22:54 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 15 Aug 2024 02:54:57 +0000 (22:54 -0400)
anvil.c
anvil.h
client.c
ewmh.c
mouse.c

diff --git a/anvil.c b/anvil.c
index ba98d6fd993d3835c6ae4056adc7a52a8af475c9..26bdebf89827dd3819d771635c4ec32dadc90131 100644 (file)
--- a/anvil.c
+++ b/anvil.c
@@ -162,10 +162,17 @@ static void XClientMsg(XEvent* e)
     }
     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]);
+        Client* c = Client_Find(ev->window);
+        if (c)
+        {
+            Client_UpdateWindowState(c, ev->data.l[0], ev->data.l[1]);
+        }
+
+
+//        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]);
     }
 
     /*
@@ -174,8 +181,6 @@ static void XClientMsg(XEvent* e)
         * handle active window (set urgency)
 
     */
-
-
 }
 
 static void XPropNotify(XEvent* e)
diff --git a/anvil.h b/anvil.h
index 77e0b8d578d63fce14a78d3c8b028cd768bfce5a..084749438bba602e0dfa3bd25d35d6614bede971 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -166,6 +166,7 @@ void Client_Focus(Client* client);
 void Client_Close(Client* client);
 void Client_UpdateAll(void);
 void Client_Place(Client* c);
+void Client_UpdateWindowState(Client* c, int op, Atom prop);
 
 /* mouse.c */
 void Mouse_Down(XButtonEvent* ev);
@@ -190,6 +191,9 @@ 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);
+
+int EWMH_GetFlagId(Atom* atoms, size_t natoms, 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 629abfce4d1c1bdd14355ec906d712f84033f3ea..e31c32845d828ca97ce103937ec8dad98c7ec105 100644 (file)
--- a/client.c
+++ b/client.c
@@ -278,6 +278,51 @@ void Client_UpdateAll(void)
     }
 }
 
+void Client_UpdateWindowState(Client* c, int op, Atom prop)
+{
+    (void)c, (void)op;
+    if (prop == _NET_WM_STATE_HIDDEN)
+    {
+//        UpdateHiddenState(c, op);
+    }
+    else if (prop == _NET_WM_STATE_FULLSCREEN)
+    {
+//        UpdateFullscreenState(c, op);
+    }
+
+
+
+
+//    int id = EWMH_GetFlagId(WindowState, nelem(WindowState), prop);
+//    if (id >= 0)
+//    {
+//        int clearing = 0;
+//        if (op == 2)
+//        {
+//            clearing = ((c->wm_state & (1 << id)) != 0);
+//        }
+//
+//        if (clearing)
+//        {
+//            c->wm_state &= ~(1 << id);
+//        }
+//        else
+//        {
+//            c->wm_state |= (1 << id);
+//        }
+//    }
+}
+
+
+
+
+
+
+
+
+
+
+
 //void client_shade(Client* c)
 //{
 //    client_setshade(c, ((c->flags & F_SHADED) ? 0 : 1));
@@ -508,11 +553,12 @@ static void* ListDelete(void* list, void* node)
     }
 }
 
-static void UpdateState(Client* c)
-{
-    int frame_shown = 1;
-    int window_shown = 1;
-    int save_size_and_pos = 1;
+//static void UpdateState(Client* c)
+//{
+//    (void)c;
+//    int frame_shown = 1;
+//    int window_shown = 1;
+//    int save_size_and_pos = 1;
 
 /*
     if (fullscreen)
@@ -573,5 +619,5 @@ static void UpdateState(Client* c)
 
     redraw
 */
-}
+//}
 
diff --git a/ewmh.c b/ewmh.c
index 1d63ddbe5f9793dc29e65a3fcee8b05afeed384e..1ce691b29d66da0a11b6fec083371ad32fe66263 100644 (file)
--- a/ewmh.c
+++ b/ewmh.c
@@ -129,7 +129,7 @@ void EWMH_SetWindowStateFlags(Window w, int flags)
     WriteFlagHint(w, _NET_WM_STATE, WindowState, nelem(WindowState), flags);
 }
 
-static int GetFlagId(Atom* atoms, size_t natoms, Atom prop)
+int EWMH_GetFlagId(Atom* atoms, size_t natoms, Atom prop)
 {
     int id = -1;
     for (size_t i = 0; i < natoms; i++)
@@ -143,31 +143,31 @@ static int GetFlagId(Atom* atoms, size_t natoms, Atom prop)
     return id;
 }
 
-void EWMH_UpdateWindowStateFlags(Window w, int op, Atom prop)
-{
-    Client* c = Client_Find(w);
-    if (c)
-    {
-        int id = GetFlagId(WindowState, nelem(WindowState), prop);
-        if (id >= 0)
-        {
-            int clearing = 0;
-            if (op == 2)
-            {
-                clearing = ((c->wm_state & (1 << id)) != 0);
-            }
-
-            if (clearing)
-            {
-                c->wm_state &= ~(1 << id);
-            }
-            else
-            {
-                c->wm_state |= (1 << id);
-            }
-        }
-    }
-}
+//void EWMH_UpdateWindowStateFlags(Window w, int op, Atom prop)
+//{
+//    Client* c = Client_Find(w);
+//    if (c)
+//    {
+//        int id = GetFlagId(WindowState, nelem(WindowState), prop);
+//        if (id >= 0)
+//        {
+//            int clearing = 0;
+//            if (op == 2)
+//            {
+//                clearing = ((c->wm_state & (1 << id)) != 0);
+//            }
+//
+//            if (clearing)
+//            {
+//                c->wm_state &= ~(1 << id);
+//            }
+//            else
+//            {
+//                c->wm_state |= (1 << id);
+//            }
+//        }
+//    }
+//}
 
 //void EWMH_GetWindowStrut(Strut* strut)
 //{
diff --git a/mouse.c b/mouse.c
index 8ce657b3015c6a2d2062d249d790c187f87a5409..ac420c8e91997f3f9be4b39273e95383bfe86e6e 100644 (file)
--- a/mouse.c
+++ b/mouse.c
@@ -43,19 +43,6 @@ static void shade_client(Client* client)
 //    client_shade(client);
 }
 
-static void lower_client(Client* client)
-{
-    (void)client;
-//    mons_lower(loc->monitor, loc->client);
-    Client_Lower(client);
-}
-
-static void raise_client(Client* client)
-{
-    Client_Raise(client);
-//    mons_raise(loc->monitor, loc->client);
-}
-
 //static void stack_clients(Client* client)
 //{
 //    (void)client;
@@ -73,8 +60,6 @@ MouseAct Floating[] = {
     { MODKEY|ShiftMask, Button2, ButtonPress, toggle_float },
     { MODKEY,           Button2, ButtonPress, close_client },
     { 0,                Button3, ButtonPress, shade_client },
-    { 0,                Button4, ButtonPress, lower_client },
-    { 0,                Button5, ButtonPress, raise_client }
 };
 //
 //MouseAct Stacked[] = {