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 9561cc6cdcc8da83481dd9ccc2f21968e82c301c
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Fri Dec 15 08:15:29 2023 +0100
comms: Refactor atom handling code
---
api/comms.c | 75 ++++++++++++++++++++++++++++++-------------------------------
1 file changed, 37 insertions(+), 38 deletions(-)
diff --git a/api/comms.c b/api/comms.c
index ca373e0..d3baae9 100644
--- a/api/comms.c
+++ b/api/comms.c
@@ -5,52 +5,52 @@
#include <unistd.h>
#include "comms.h"
-static Window comms_win = 0;
-static Window my_win = 0;
+#define EXID unsigned int
+
+static EXID comms_win = 0;
+static EXID my_win = 0;
+static EXID Atom_ENL_COMMS = 0;
+static EXID Atom_ENL_MSG = 0;
static void
_CommsFindCommsWindow(void)
{
unsigned char *s;
- Atom a, ar;
+ Atom ar;
unsigned long num, after;
int format;
Window rt;
int dint;
unsigned int duint;
- a = XInternAtom(disp, "ENLIGHTENMENT_COMMS", True);
- if (a != None)
+ s = NULL;
+ XGetWindowProperty(disp, root, Atom_ENL_COMMS, 0, 14, False,
+ AnyPropertyType, &ar, &format, &num, &after, &s);
+ if (s)
{
- s = NULL;
- XGetWindowProperty(disp, root, a, 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;
+ sscanf((char *)s, "%*s %x", (unsigned int *)&comms_win);
+ XFree(s);
+ }
+ else
+ comms_win = 0;
+ if (comms_win)
+ {
+ if (!XGetGeometry(disp, comms_win, &rt, &dint, &dint,
+ &duint, &duint, &duint, &duint))
+ comms_win = 0;
+ s = NULL;
if (comms_win)
{
- if (!XGetGeometry(disp, comms_win, &rt, &dint, &dint,
- &duint, &duint, &duint, &duint))
+ XGetWindowProperty(disp, comms_win, Atom_ENL_COMMS, 0, 14, False,
+ AnyPropertyType, &ar, &format, &num, &after, &s);
+ if (s)
+ XFree(s);
+ else
comms_win = 0;
- s = NULL;
- if (comms_win)
- {
- XGetWindowProperty(disp, comms_win, a, 0, 14, False,
- AnyPropertyType, &ar, &format, &num,
- &after, &s);
- if (s)
- XFree(s);
- else
- comms_win = 0;
- }
}
}
+
if (comms_win)
XSelectInput(disp, comms_win,
StructureNotifyMask | SubstructureNotifyMask);
@@ -59,6 +59,11 @@ _CommsFindCommsWindow(void)
void
CommsSetup(void)
{
+ if (Atom_ENL_COMMS == 0)
+ Atom_ENL_COMMS = XInternAtom(disp, "ENLIGHTENMENT_COMMS", False);
+ if (Atom_ENL_MSG == 0)
+ Atom_ENL_MSG = XInternAtom(disp, "ENL_MSG", False);
+
for (;;)
{
_CommsFindCommsWindow();
@@ -87,14 +92,12 @@ CommsHandleDestroy(Window xwin)
int
CommsHandlePropertyNotify(XEvent *ev)
{
- Atom a = 0;
-
if (comms_win)
return 0;
- if (!a)
- a = XInternAtom(disp, "ENLIGHTENMENT_COMMS", True);
- if (a == ev->xproperty.atom)
+
+ if (ev->xproperty.atom == Atom_ENL_COMMS)
CommsSetup();
+
if (comms_win)
return 1;
return 0;
@@ -103,19 +106,15 @@ CommsHandlePropertyNotify(XEvent *ev)
int
CommsSend(const char *buf, unsigned int len)
{
- static Atom a = None;
char ss[21];
unsigned int i, j, k;
XEvent ev;
- if (!a)
- a = XInternAtom(disp, "ENL_MSG", False);
-
ev.xclient.type = ClientMessage;
ev.xclient.serial = 0;
ev.xclient.send_event = True;
ev.xclient.window = comms_win;
- ev.xclient.message_type = a;
+ ev.xclient.message_type = Atom_ENL_MSG;
ev.xclient.format = 8;
for (i = 0; i < len + 1; i += 12)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.