This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository e16-epplets.

View the commit online.

commit 048c7bd36cbf07510373e23f20a43b011ca7ccbf
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Fri Dec 15 08:34:53 2023 +0100

    comms: Simplify _CommsFindCommsWindow()
    
    No need to check with XGetGeometry(). If XGetWindowProperty() succeeds
    we are good.
---
 api/comms.c | 52 +++++++++++++++++++++-------------------------------
 1 file changed, 21 insertions(+), 31 deletions(-)

diff --git a/api/comms.c b/api/comms.c
index 609b95a..01eab9c 100644
--- a/api/comms.c
+++ b/api/comms.c
@@ -12,48 +12,38 @@ static EXID     my_win = 0;
 static EXID     Atom_ENL_COMMS = 0;
 static EXID     Atom_ENL_MSG = 0;
 
-static void
+static          EXID
 _CommsFindCommsWindow(void)
 {
     unsigned char  *s;
     Atom            ar;
     unsigned long   num, after;
     int             format;
-    Window          rt;
-    int             dint;
-    unsigned int    duint;
+    EXID            cwin;
 
+    /* Get root window ENLIGHTENMENT_COMMS property */
+    cwin = 0;
     s = NULL;
     XGetWindowProperty(disp, root, Atom_ENL_COMMS, 0, 14, False,
                        AnyPropertyType, &ar, &format, &num, &after, &s);
-    if (s)
-    {
-        sscanf((char *)s, "%*s %x", (unsigned int *)&comms_win);
-        XFree(s);
-    }
-    else
-        comms_win = 0;
+    if (!s)
+        goto done;
 
-    if (comms_win)
-    {
-        if (!XGetGeometry(disp, comms_win, &rt, &dint, &dint,
-                          &duint, &duint, &duint, &duint))
-            comms_win = 0;
-        s = NULL;
-        if (comms_win)
-        {
-            XGetWindowProperty(disp, comms_win, Atom_ENL_COMMS, 0, 14, False,
-                               AnyPropertyType, &ar, &format, &num, &after, &s);
-            if (s)
-                XFree(s);
-            else
-                comms_win = 0;
-        }
-    }
+    sscanf((char *)s, "%*s %x", &cwin);
+    XFree(s);
 
-    if (comms_win)
-        XSelectInput(disp, comms_win,
-                     StructureNotifyMask | SubstructureNotifyMask);
+    /* Check that cwin exists and has ENLIGHTENMENT_COMMS */
+    s = NULL;
+    XGetWindowProperty(disp, cwin, Atom_ENL_COMMS, 0, 14, False,
+                       AnyPropertyType, &ar, &format, &num, &after, &s);
+    if (!s)
+        goto done;
+    XFree(s);
+
+    XSelectInput(disp, cwin, StructureNotifyMask | SubstructureNotifyMask);
+
+  done:
+    return cwin;
 }
 
 void
@@ -66,7 +56,7 @@ CommsSetup(void)
 
     for (;;)
     {
-        _CommsFindCommsWindow();
+        comms_win = _CommsFindCommsWindow();
         if (comms_win != None)
             break;
         sleep(1);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to