Enlightenment CVS committal
Author : kwo
Project : e16
Module : e
Dir : e16/e/src
Modified Files:
Tag: branch-exp
E.h comms.c evhandlers.c ewmh.c hints.c ipc.c main.c session.c
x.c
Log Message:
Switch IPC stuff to use new callbacks. Merge.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.314.2.19
retrieving revision 1.314.2.20
diff -u -3 -r1.314.2.19 -r1.314.2.20
--- E.h 15 Aug 2004 16:25:32 -0000 1.314.2.19
+++ E.h 17 Aug 2004 22:46:59 -0000 1.314.2.20
@@ -100,8 +100,10 @@
#if HAVE___ATTRIBUTE__
#define __UNUSED__ __attribute__((unused))
+#define __PRINTF__ __attribute__((__format__(__printf__, 1, 2)))
#else
#define __UNUSED__
+#define __PRINTF__
#endif
/* workaround for 64bit architectures - xlib expects 32bit CARDINALS to be */
@@ -1494,18 +1496,11 @@
unsigned char *bpy);
/* comms.c */
-void CommsSetup(void);
-void CommsFindCommsWindow(void);
+void CommsInit(void);
void CommsSend(Client * c, const char *s);
void CommsSendToMasterWM(const char *s);
void CommsBroadcast(const char *s);
void CommsBroadcastToSlaveWMs(const char *s);
-Client *MakeClient(Window win);
-void ListFreeClient(void *ptr);
-void DeleteClient(Client * c);
-void ClientConfigure(Client * c, const char *param,
- const char *value);
-void HandleComms(XClientMessageEvent * ev);
/* config.c */
void ConfigAlertLoad(const char *txt);
@@ -2078,13 +2073,7 @@
void SetupFallbackClasses(void);
/* ipc.c */
-
-#if HAVE___ATTRIBUTE__
-void IpcPrintf(const char *fmt, ...)
- __attribute__ ((__format__(__printf__, 1, 2)));
-#else
-void IpcPrintf(const char *fmt, ...);
-#endif
+void __PRINTF__ IpcPrintf(const char *fmt, ...);
int HandleIPC(const char *params, Client * c);
void ButtonIPC(int val, void *data);
@@ -2182,7 +2171,7 @@
char *EDirUserCache(void);
void Quicksort(void **a, int l, int r,
int (*CompareFunc) (void *d1, void *d2));
-void Eprintf(const char *fmt, ...);
+void __PRINTF__ Eprintf(const char *fmt, ...);
/* moveresize.c */
int ActionMoveStart(EWin * ewin, const void *params,
@@ -2485,7 +2474,8 @@
void EMoveResizeWindow(Display * d, Window win, int x, int y,
int w, int h);
void EDestroyWindow(Display * d, Window win);
-void EForgetWindow(Display * d, Window win);
+void ERegisterWindow(Display * d, Window win);
+void EUnregisterWindow(Display * d, Window win);
void EMapWindow(Display * d, Window win);
void EUnmapWindow(Display * d, Window win);
void EShapeCombineMask(Display * d, Window win, int dest, int x,
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/comms.c,v
retrieving revision 1.62.2.1
retrieving revision 1.62.2.2
diff -u -3 -r1.62.2.1 -r1.62.2.2
--- comms.c 8 Aug 2004 22:31:40 -0000 1.62.2.1
+++ comms.c 17 Aug 2004 22:47:02 -0000 1.62.2.2
@@ -42,15 +42,262 @@
static Atom XA_ENLIGHTENMENT_COMMS = 0;
static Atom XA_ENL_MSG = 0;
+static void ClientHandleEvents(XEvent * ev, void *cc);
+
+static Client *
+ClientCreate(Window win)
+{
+ Client *c;
+ char st[32];
+
+ EDBUG(6, "ClientCreate");
+
+ c = Emalloc(sizeof(Client));
+ if (!c)
+ EDBUG_RETURN(NULL);
+
+ Esnprintf(st, sizeof(st), "%8x", (int)win);
+ c->name = Estrdup(st);
+ c->win = win;
+ c->msg = NULL;
+ c->clientname = NULL;
+ c->version = NULL;
+ c->author = NULL;
+ c->email = NULL;
+ c->web = NULL;
+ c->address = NULL;
+ c->info = NULL;
+ c->pmap = 0;
+ ERegisterWindow(disp, win);
+ EventCallbackRegister(win, 0, ClientHandleEvents, c);
+ AddItem(c, st, win, LIST_TYPE_CLIENT);
+ XSelectInput(disp, win, StructureNotifyMask | SubstructureNotifyMask);
+
+ EDBUG_RETURN(c);
+}
+
+static void
+ClientDestroy(Client * c)
+{
+ Window win;
+
+ EDBUG(6, "ClientDestroy");
+
+ if (!c)
+ EDBUG_RETURN_;
+
+ win = c->win;
+ RemoveItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_CLIENT);
+ EventCallbackUnregister(win, 0, ClientHandleEvents, c);
+ EUnregisterWindow(disp, win);
+ if (c->name)
+ Efree(c->name);
+ if (c->msg)
+ Efree(c->msg);
+ if (c->clientname)
+ Efree(c->clientname);
+ if (c->version)
+ Efree(c->version);
+ if (c->author)
+ Efree(c->author);
+ if (c->email)
+ Efree(c->email);
+ if (c->web)
+ Efree(c->web);
+ if (c->address)
+ Efree(c->address);
+ if (c->info)
+ Efree(c->info);
+ Efree(c);
+
+ EDBUG_RETURN_;
+}
+
+static int
+ClientConfigure(Client * c, const char *str)
+{
+ char param[64], value[64];
+
+ sscanf(str, "%60s %60s", param, value);
+
+ if (!strcmp(param, "clientname"))
+ {
+ if (c->clientname)
+ Efree(c->clientname);
+ c->clientname = Estrdup(value);
+ }
+ else if (!strcmp(param, "version"))
+ {
+ if (c->version)
+ Efree(c->version);
+ c->version = Estrdup(value);
+ }
+ else if (!strcmp(param, "author"))
+ {
+ if (c->author)
+ Efree(c->author);
+ c->author = Estrdup(value);
+ }
+ else if (!strcmp(param, "email"))
+ {
+ if (c->email)
+ Efree(c->email);
+ c->email = Estrdup(value);
+ }
+ else if (!strcmp(param, "web"))
+ {
+ if (c->web)
+ Efree(c->web);
+ c->web = Estrdup(value);
+ }
+ else if (!strcmp(param, "address"))
+ {
+ if (c->address)
+ Efree(c->address);
+ c->address = Estrdup(value);
+ }
+ else if (!strcmp(param, "info"))
+ {
+ if (c->info)
+ Efree(c->info);
+ c->info = Estrdup(value);
+ }
+ else if (!strcmp(param, "pixmap"))
+ {
+ c->pmap = 0;
+ sscanf(value, "%x", (int *)&c->pmap);
+ }
+ else
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+static char *
+ClientCommsGet(Client ** c, XClientMessageEvent * ev)
+{
+ char s[13], s2[9], *msg;
+ int i;
+ Window win = 0;
+ Client *cl;
+
+ EDBUG(5, "ClientCommsGet");
+ if ((!ev) || (!c))
+ EDBUG_RETURN(NULL);
+ if (ev->message_type != XA_ENL_MSG)
+ EDBUG_RETURN(NULL);
+
+ s[12] = 0;
+ s2[8] = 0;
+ msg = NULL;
+ for (i = 0; i < 8; i++)
+ s2[i] = ev->data.b[i];
+ for (i = 0; i < 12; i++)
+ s[i] = ev->data.b[i + 8];
+ sscanf(s2, "%lx", &win);
+ cl = (Client *) FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_CLIENT);
+ if (!cl)
+ {
+ cl = ClientCreate(win);
+ if (!cl)
+ EDBUG_RETURN(NULL);
+ }
+
+ if (cl->msg)
+ {
+ /* append text to end of msg */
+ cl->msg = Erealloc(cl->msg, strlen(cl->msg) + strlen(s) + 1);
+ if (!cl->msg)
+ EDBUG_RETURN(NULL);
+ strcat(cl->msg, s);
+ }
+ else
+ {
+ /* new msg */
+ cl->msg = Emalloc(strlen(s) + 1);
+ if (!cl->msg)
+ EDBUG_RETURN(NULL);
+ strcpy(cl->msg, s);
+ }
+ if (strlen(s) < 12)
+ {
+ msg = cl->msg;
+ cl->msg = NULL;
+ *c = cl;
+ }
+ EDBUG_RETURN(msg);
+}
+
+static void
+ClientHandleComms(XClientMessageEvent * ev)
+{
+ Client *c;
+ char *s;
+ const char *s1, *s2;
+
+ EDBUG(4, "ClientHandleComms");
+
+ s = ClientCommsGet(&c, ev);
+ if (!s)
+ EDBUG_RETURN_;
+
+ if (!strncmp(s, "set ", 4) && !strchr(s, '.'))
+ {
+ /* The old Client set command (used by epplets) */
+ if (ClientConfigure(c, s) == 0)
+ goto done;
+ }
+
+ if (!HandleIPC(s, c))
+ {
+ s1 = (c->clientname) ? c->clientname : "UNKNOWN";
+ s2 = (c->version) ? c->version : "UNKNOWN";
+ DialogOK(_("E IPC Error"),
+ _("Received Unknown Client Message.\n"
+ "Client Name: %s\n" "Client Version: %s\n"
+ "Message Contents:\n\n" "%s\n"), s1, s2, s);
+ SoundPlay("SOUND_ERROR_IPC");
+ }
+
+ done:
+ Efree(s);
+
+ EDBUG_RETURN_;
+}
+
+static void
+ClientHandleEvents(XEvent * ev, void *cc)
+{
+ Client *c = (Client *) cc;
+
+#if 0
+ Eprintf("ClientHandleEvents: type=%d win=%#lx\n", ev->type, ev->xany.window);
+#endif
+ switch (ev->type)
+ {
+ case DestroyNotify:
+ ClientDestroy(c);
+ break;
+ case ClientMessage:
+ ClientHandleComms(&(ev->xclient));
+ break;
+ }
+}
+
void
-CommsSetup(void)
+CommsInit(void)
{
char s[1024];
EDBUG(5, "CommsSetup");
comms_win = XCreateSimpleWindow(disp, VRoot.win, -100, -100, 5, 5, 0, 0, 0);
+ ERegisterWindow(disp, comms_win);
XSelectInput(disp, comms_win, StructureNotifyMask | SubstructureNotifyMask);
+ EventCallbackRegister(comms_win, 0, ClientHandleEvents, NULL);
+
Esnprintf(s, sizeof(s), "WINID %8x", (int)comms_win);
XA_ENLIGHTENMENT_COMMS = XInternAtom(disp, "ENLIGHTENMENT_COMMS", False);
XChangeProperty(disp, comms_win, XA_ENLIGHTENMENT_COMMS, XA_STRING, 8,
@@ -63,56 +310,6 @@
EDBUG_RETURN_;
}
-void
-CommsFindCommsWindow(void)
-{
- unsigned char *s;
- Atom a, ar;
- unsigned long num, after;
- int format;
- Window rt;
- int dint;
- unsigned int duint;
-
- EDBUG(6, "CommsFindCommsWindow");
- a = XA_ENLIGHTENMENT_COMMS;
- if (a != None)
- {
- s = NULL;
- XGetWindowProperty(disp, VRoot.win, a, 0, 14, False, AnyPropertyType,
- &ar, &format, &num, &after, &s);
- if (s)
- {
- comms_win = 0;
- sscanf((char *)s, "%*s %lx", &comms_win);
- XFree(s);
- }
- else
- {
- (comms_win = 0);
- }
- if (comms_win)
- {
- if (!EGetGeometry
- (disp, comms_win, &rt, &dint, &dint, &duint, &duint, &duint,
- &duint))
- 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;
- }
- }
- }
- EDBUG_RETURN_;
-}
-
static void
CommsDoSend(Window win, const char *s)
{
@@ -202,64 +399,6 @@
EDBUG_RETURN_;
}
-static char *
-CommsGet(Client ** c, XClientMessageEvent * ev)
-{
- char s[13], s2[9], *msg, st[32];
- int i;
- Window win = 0;
- Client *cl;
-
- EDBUG(5, "CommsGet");
- if ((!ev) || (!c))
- EDBUG_RETURN(NULL);
- if (ev->message_type != XA_ENL_MSG)
- EDBUG_RETURN(NULL);
-
- s[12] = 0;
- s2[8] = 0;
- msg = NULL;
- for (i = 0; i < 8; i++)
- s2[i] = ev->data.b[i];
- for (i = 0; i < 12; i++)
- s[i] = ev->data.b[i + 8];
- sscanf(s2, "%lx", &win);
- cl = (Client *) FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_CLIENT);
- if (!cl)
- {
- cl = MakeClient(win);
- if (!cl)
- EDBUG_RETURN(NULL);
- Esnprintf(st, sizeof(st), "%8x", (int)win);
- cl->name = Estrdup(st);
- AddItem((void *)cl, st, cl->win, LIST_TYPE_CLIENT);
- XSelectInput(disp, win, StructureNotifyMask | SubstructureNotifyMask);
- }
- if (cl->msg)
- {
- /* append text to end of msg */
- cl->msg = Erealloc(cl->msg, strlen(cl->msg) + strlen(s) + 1);
- if (!cl->msg)
- EDBUG_RETURN(NULL);
- strcat(cl->msg, s);
- }
- else
- {
- /* new msg */
- cl->msg = Emalloc(strlen(s) + 1);
- if (!cl->msg)
- EDBUG_RETURN(NULL);
- strcpy(cl->msg, s);
- }
- if (strlen(s) < 12)
- {
- msg = cl->msg;
- cl->msg = NULL;
- *c = cl;
- }
- EDBUG_RETURN(msg);
-}
-
void
CommsBroadcast(const char *s)
{
@@ -280,148 +419,3 @@
freestrlist(l, num);
EDBUG_RETURN_;
}
-
-Client *
-MakeClient(Window win)
-{
- Client *c;
-
- EDBUG(6, "MakeClient");
- c = Emalloc(sizeof(Client));
- if (!c)
- EDBUG_RETURN(NULL);
- c->name = NULL;
- c->win = win;
- c->msg = NULL;
- c->clientname = NULL;
- c->version = NULL;
- c->author = NULL;
- c->email = NULL;
- c->web = NULL;
- c->address = NULL;
- c->info = NULL;
- c->pmap = 0;
- EDBUG_RETURN(c);
-}
-
-void
-ListFreeClient(void *ptr)
-{
- Client *c;
-
- EDBUG(6, "ListFreeClient");
- c = (Client *) ptr;
- if (!c)
- EDBUG_RETURN_;
- if (c->name)
- Efree(c->name);
- if (c->msg)
- Efree(c->msg);
- if (c->clientname)
- Efree(c->clientname);
- if (c->version)
- Efree(c->version);
- if (c->author)
- Efree(c->author);
- if (c->email)
- Efree(c->email);
- if (c->web)
- Efree(c->web);
- if (c->address)
- Efree(c->address);
- if (c->info)
- Efree(c->info);
- Efree(c);
- EDBUG_RETURN_;
-}
-
-void
-DeleteClient(Client * c)
-{
- Client *cc;
-
- EDBUG(6, "DeleteClient");
- cc = RemoveItem(NULL, c->win, LIST_FINDBY_ID, LIST_TYPE_CLIENT);
- ListFreeClient(cc);
- EDBUG_RETURN_;
-}
-
-void
-ClientConfigure(Client * c, const char *param, const char *value)
-{
- if (!strcmp(param, "clientname"))
- {
- if (c->clientname)
- Efree(c->clientname);
- c->clientname = Estrdup(value);
- }
- else if (!strcmp(param, "version"))
- {
- if (c->version)
- Efree(c->version);
- c->version = Estrdup(value);
- }
- else if (!strcmp(param, "author"))
- {
- if (c->author)
- Efree(c->author);
- c->author = Estrdup(value);
- }
- else if (!strcmp(param, "email"))
- {
- if (c->email)
- Efree(c->email);
- c->email = Estrdup(value);
- }
- else if (!strcmp(param, "web"))
- {
- if (c->web)
- Efree(c->web);
- c->web = Estrdup(value);
- }
- else if (!strcmp(param, "address"))
- {
- if (c->address)
- Efree(c->address);
- c->address = Estrdup(value);
- }
- else if (!strcmp(param, "info"))
- {
- if (c->info)
- Efree(c->info);
- c->info = Estrdup(value);
- }
- else if (!strcmp(param, "pixmap"))
- {
- c->pmap = 0;
- sscanf(value, "%x", (int *)&c->pmap);
- }
-}
-
-void
-HandleComms(XClientMessageEvent * ev)
-{
- Client *c;
- char *s;
- const char *s1, *s2;
-
- EDBUG(4, "HandleComms");
-
- s = CommsGet(&c, ev);
- if (!s)
- EDBUG_RETURN_;
-
- if (!HandleIPC(s, c))
- {
- s1 = (c->clientname) ? c->clientname : "UNKNOWN";
- s2 = (c->version) ? c->version : "UNKNOWN";
- DialogOK(_("E IPC Error"),
- _("Received Unknown Client Message.\n"
- "Client Name: %s\n" "Client Version: %s\n"
- "Message Contents:\n\n" "%s\n"), s1, s2, s);
- SoundPlay("SOUND_ERROR_IPC");
- }
- Efree(s);
-
- EDBUG_RETURN_;
-}
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/evhandlers.c,v
retrieving revision 1.173.2.12
retrieving revision 1.173.2.13
diff -u -3 -r1.173.2.12 -r1.173.2.13
--- evhandlers.c 15 Aug 2004 15:49:04 -0000 1.173.2.12
+++ evhandlers.c 17 Aug 2004 22:47:03 -0000 1.173.2.13
@@ -236,12 +236,9 @@
{
Window win = ev->xdestroywindow.window;
EWin *ewin;
- Client *c;
EDBUG(5, "HandleDestroy");
- EForgetWindow(disp, win);
-
ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN);
if (ewin)
{
@@ -249,10 +246,6 @@
EDBUG_RETURN_;
}
- c = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_CLIENT);
- if (c)
- DeleteClient(c);
-
EDBUG_RETURN_;
}
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ewmh.c,v
retrieving revision 1.55.2.2
retrieving revision 1.55.2.3
diff -u -3 -r1.55.2.2 -r1.55.2.3
--- ewmh.c 8 Aug 2004 00:02:18 -0000 1.55.2.2
+++ ewmh.c 17 Aug 2004 22:47:07 -0000 1.55.2.3
@@ -833,7 +833,7 @@
}
else if (event->message_type == _NET_SHOWING_DESKTOP)
{
- Eprintf("EWMH_ProcessClientMessage: _NET_SHOWING_DESKTOP: %d\n",
+ Eprintf("EWMH_ProcessClientMessage: _NET_SHOWING_DESKTOP: %ld\n",
event->data.l[0]);
EWMH_SetShowingDesktop(event->data.l[0]);
goto done;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/hints.c,v
retrieving revision 1.25
retrieving revision 1.25.2.1
diff -u -3 -r1.25 -r1.25.2.1
--- hints.c 4 Jul 2004 08:47:28 -0000 1.25
+++ hints.c 17 Aug 2004 22:47:07 -0000 1.25.2.1
@@ -328,9 +328,7 @@
if (name == NULL)
EDBUG_RETURN_;
- if (!memcmp(name, "ENL_", 4))
- HandleComms(event);
- else if (!memcmp(name, "WM_", 3))
+ if (!memcmp(name, "WM_", 3))
ICCCM_ProcessClientMessage(event);
#if ENABLE_EWMH
else if (!memcmp(name, "_NET_", 5))
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ipc.c,v
retrieving revision 1.174.2.9
retrieving revision 1.174.2.10
diff -u -3 -r1.174.2.9 -r1.174.2.10
--- ipc.c 15 Aug 2004 15:49:04 -0000 1.174.2.9
+++ ipc.c 17 Aug 2004 22:47:07 -0000 1.174.2.10
@@ -4158,23 +4158,9 @@
}
static void
-IPC_Set(const char *params, Client * c)
+IPC_Set(const char *params, Client * c __UNUSED__)
{
- char param1[FILEPATH_LEN_MAX], param2[FILEPATH_LEN_MAX];
-
- word(params, 1, param1);
-
- /* The new set configuration parameter command */
- if (strchr(param1, '.') || param1[0] == '?')
- {
- ConfigurationSet(params);
- return;
- }
-
- /* The old Client set command (used by epplets) */
- word(params, 2, param2);
-
- ClientConfigure(c, param1, param2);
+ ConfigurationSet(params);
}
static void
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/main.c,v
retrieving revision 1.99.2.7
retrieving revision 1.99.2.8
diff -u -3 -r1.99.2.7 -r1.99.2.8
--- main.c 15 Aug 2004 12:16:39 -0000 1.99.2.7
+++ main.c 17 Aug 2004 22:47:08 -0000 1.99.2.8
@@ -233,8 +233,7 @@
BlumFlimFrub();
ZoomInit();
SetupDirs();
- CommsSetup();
- CommsFindCommsWindow();
+ CommsInit();
LoadGroups();
LoadSnapInfo();
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/session.c,v
retrieving revision 1.75.2.2
retrieving revision 1.75.2.3
diff -u -3 -r1.75.2.2 -r1.75.2.3
--- session.c 15 Aug 2004 07:28:28 -0000 1.75.2.2
+++ session.c 17 Aug 2004 22:47:08 -0000 1.75.2.3
@@ -1235,7 +1235,7 @@
EDBUG(9, "EExit");
if (EventDebug(EDBUG_TYPE_SESSION))
- Eprintf("EExit(%p)\n", exitcode);
+ Eprintf("EExit(%d)\n", exitcode);
SaveSession(1);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/x.c,v
retrieving revision 1.71.2.4
retrieving revision 1.71.2.5
diff -u -3 -r1.71.2.4 -r1.71.2.5
--- x.c 15 Aug 2004 12:16:39 -0000 1.71.2.4
+++ x.c 17 Aug 2004 22:47:08 -0000 1.71.2.5
@@ -57,7 +57,7 @@
static XContext xid_context = 0;
static EXID *
-NewXID(void)
+EXidCreate(void)
{
EXID *xid;
@@ -67,59 +67,71 @@
}
static void
-AddXID(EXID * xid)
+EXidDestroy(EXID * xid)
+{
+ if (xid->rects)
+ XFree(xid->rects);
+#if 0
+ if (xid->cbl.lst)
+ Eprintf("EventCallbacksUnregister: %p %#lx\n", xid, win);
+#endif
+ if (xid->cbl.lst)
+ Efree(xid->cbl.lst);
+ Efree(xid);
+}
+
+static void
+EXidAdd(EXID * xid)
{
if (!xid_context)
xid_context = XUniqueContext();
+
XSaveContext(disp, xid->win, xid_context, (XPointer) xid);
AddItem(xid, "", xid->win, LIST_TYPE_XID);
}
-static EXID *
-FindXID(Window win)
+static void
+EXidDelete(Window win)
{
EXID *xid;
- XPointer xp;
if (xid_context == 0)
xid_context = XUniqueContext();
- xp = NULL;
- if (XFindContext(disp, win, xid_context, &xp) == XCNOENT)
- xp = NULL;
- xid = (EXID *) xp;
- return xid;
+
+ xid = RemoveItem("", win, LIST_FINDBY_ID, LIST_TYPE_XID);
+ if (!xid)
+ return;
+
+ XDeleteContext(disp, win, xid_context);
+ if (xid->in_use)
+ xid->do_del = 1;
+ else
+ EXidDestroy(xid);
}
-static void
-DelXID(Window win)
+static EXID *
+EXidFind(Window win)
{
EXID *xid;
+ XPointer xp;
if (xid_context == 0)
xid_context = XUniqueContext();
- xid = RemoveItem("", win, LIST_FINDBY_ID, LIST_TYPE_XID);
- if (xid)
- {
- XDeleteContext(disp, win, xid_context);
- if (xid->rects)
- XFree(xid->rects);
-#if 0
- if (xid->cbl.lst)
- Eprintf("EventCallbacksUnregister: %p %#lx\n", xid, win);
-#endif
- if (xid->cbl.lst)
- Efree(xid->cbl.lst);
- Efree(xid);
- }
+
+ xp = NULL;
+ if (XFindContext(disp, win, xid_context, &xp) == XCNOENT)
+ xp = NULL;
+ xid = (EXID *) xp;
+ return xid;
}
static void
-SetXID(Window win, Window parent, int x, int y, int w, int h,
- int depth __UNUSED__)
+EXidSet(Window win, Window parent, int x, int y, int w, int h,
+ int depth __UNUSED__)
{
EXID *xid;
- xid = NewXID();
+ xid = EXidCreate();
xid->parent = parent;
xid->win = win;
xid->x = x;
@@ -127,23 +139,20 @@
xid->w = w;
xid->h = h;
xid->depth = VRoot.depth;
- AddXID(xid);
+#if 0
+ Eprintf("EXidSet: %#lx\n", xid->win);
+#endif
+ EXidAdd(xid);
}
void
EventCallbackRegister(Window win, int type __UNUSED__, EventCallbackFunc * func,
void *prm)
{
- static char first = 1;
EXID *xid;
EventCallbackItem *eci;
- if (first)
- {
- SetXID(VRoot.win, None, 0, 0, VRoot.w, VRoot.h, VRoot.depth);
- first = 0;
- }
- xid = FindXID(win);
+ xid = EXidFind(win);
#if 0
Eprintf("EventCallbackRegister: %p %#lx\n", xid, win);
#endif
@@ -171,7 +180,7 @@
EventCallbackItem *eci;
int i;
- xid = FindXID(win);
+ xid = EXidFind(win);
#if 0
Eprintf("EventCallbackUnregister: %p %#lx\n", xid, win);
#endif
@@ -208,7 +217,7 @@
EventCallbackItem *eci;
int i;
- xid = FindXID(ev->xany.window);
+ xid = EXidFind(ev->xany.window);
if (xid == NULL)
return;
@@ -223,8 +232,7 @@
eci->func(ev, eci->prm);
if (xid->do_del)
{
- xid->in_use = 0;
- EDestroyWindow(disp, xid->win); // Pass disp?
+ EXidDestroy(xid);
return;
}
}
@@ -270,7 +278,7 @@
VRoot.vis,
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
CWColormap | CWBackPixmap | CWBorderPixel, &attr);
- SetXID(win, parent, x, y, w, h, VRoot.depth);
+ EXidSet(win, parent, x, y, w, h, VRoot.depth);
EDBUG_RETURN(win);
}
@@ -280,7 +288,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if ((x != xid->x) || (y != xid->y))
@@ -299,7 +307,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if ((w != xid->w) || (h != xid->h))
@@ -318,7 +326,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if ((w != xid->w) || (h != xid->h) || (x != xid->x) || (y != xid->y))
@@ -343,18 +351,13 @@
SlideoutsHideIfContextWin(win);
#endif
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
EXID **lst;
int i, num;
- if (xid->in_use)
- {
- xid->do_del = 1;
- return;
- }
- DelXID(win);
+ EXidDelete(win);
XDestroyWindow(d, win);
lst = (EXID **) ListItemType(&num, LIST_TYPE_XID);
if (lst)
@@ -372,9 +375,20 @@
}
void
-EForgetWindow(Display * d __UNUSED__, Window win)
+ERegisterWindow(Display * d, Window win)
+{
+ Window rr;
+ int x, y;
+ unsigned int w, h, bw, depth;
+
+ XGetGeometry(d, win, &rr, &x, &y, &w, &h, &bw, &depth);
+ EXidSet(win, None, x, y, w, h, depth);
+}
+
+void
+EUnregisterWindow(Display * d __UNUSED__, Window win)
{
- DelXID(win);
+ EXidDelete(win);
}
void
@@ -382,7 +396,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if (!xid->mapped)
@@ -400,7 +414,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if (xid->mapped)
@@ -419,7 +433,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
char wasshaped = 0;
@@ -486,7 +500,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if (n_rects == 1)
@@ -533,7 +547,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
xid->num_rect = 0;
@@ -566,7 +580,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
XRectangle *r;
@@ -603,7 +617,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if (parent == xid->parent)
@@ -632,7 +646,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if (xid->mapped)
@@ -655,7 +669,7 @@
int ok;
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if (x)
@@ -691,7 +705,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
char doit = 0;
@@ -730,7 +744,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
xid->bgpmap = pmap;
@@ -745,7 +759,7 @@
{
EXID *xid;
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
{
if (xid->bgpmap)
@@ -774,7 +788,7 @@
attr.override_redirect = False;
win = XCreateWindow(disp, parent, x, y, w, h, 0, 0, InputOnly, VRoot.vis,
CWOverrideRedirect, &attr);
- SetXID(win, parent, x, y, w, h, VRoot.depth);
+ EXidSet(win, parent, x, y, w, h, VRoot.depth);
EDBUG_RETURN(win);
}
@@ -871,7 +885,7 @@
EDBUG(7, "GetWinParent");
- xid = FindXID(win);
+ xid = EXidFind(win);
if (xid)
return xid->parent;
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs