comms: Simplify _CommsFindCommsWindow()
No need to check with XGetGeometry(). If XGetWindowProperty() succeeds we are good.
This commit is contained in:
parent
a85954ad53
commit
048c7bd36c
46
api/comms.c
46
api/comms.c
|
@ -12,48 +12,38 @@ static EXID my_win = 0;
|
||||||
static EXID Atom_ENL_COMMS = 0;
|
static EXID Atom_ENL_COMMS = 0;
|
||||||
static EXID Atom_ENL_MSG = 0;
|
static EXID Atom_ENL_MSG = 0;
|
||||||
|
|
||||||
static void
|
static EXID
|
||||||
_CommsFindCommsWindow(void)
|
_CommsFindCommsWindow(void)
|
||||||
{
|
{
|
||||||
unsigned char *s;
|
unsigned char *s;
|
||||||
Atom ar;
|
Atom ar;
|
||||||
unsigned long num, after;
|
unsigned long num, after;
|
||||||
int format;
|
int format;
|
||||||
Window rt;
|
EXID cwin;
|
||||||
int dint;
|
|
||||||
unsigned int duint;
|
|
||||||
|
|
||||||
|
/* Get root window ENLIGHTENMENT_COMMS property */
|
||||||
|
cwin = 0;
|
||||||
s = NULL;
|
s = NULL;
|
||||||
XGetWindowProperty(disp, root, Atom_ENL_COMMS, 0, 14, False,
|
XGetWindowProperty(disp, root, Atom_ENL_COMMS, 0, 14, False,
|
||||||
AnyPropertyType, &ar, &format, &num, &after, &s);
|
AnyPropertyType, &ar, &format, &num, &after, &s);
|
||||||
if (s)
|
if (!s)
|
||||||
{
|
goto done;
|
||||||
sscanf((char *)s, "%*s %x", (unsigned int *)&comms_win);
|
|
||||||
XFree(s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
comms_win = 0;
|
|
||||||
|
|
||||||
if (comms_win)
|
sscanf((char *)s, "%*s %x", &cwin);
|
||||||
{
|
XFree(s);
|
||||||
if (!XGetGeometry(disp, comms_win, &rt, &dint, &dint,
|
|
||||||
&duint, &duint, &duint, &duint))
|
/* Check that cwin exists and has ENLIGHTENMENT_COMMS */
|
||||||
comms_win = 0;
|
|
||||||
s = NULL;
|
s = NULL;
|
||||||
if (comms_win)
|
XGetWindowProperty(disp, cwin, Atom_ENL_COMMS, 0, 14, False,
|
||||||
{
|
|
||||||
XGetWindowProperty(disp, comms_win, Atom_ENL_COMMS, 0, 14, False,
|
|
||||||
AnyPropertyType, &ar, &format, &num, &after, &s);
|
AnyPropertyType, &ar, &format, &num, &after, &s);
|
||||||
if (s)
|
if (!s)
|
||||||
|
goto done;
|
||||||
XFree(s);
|
XFree(s);
|
||||||
else
|
|
||||||
comms_win = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (comms_win)
|
XSelectInput(disp, cwin, StructureNotifyMask | SubstructureNotifyMask);
|
||||||
XSelectInput(disp, comms_win,
|
|
||||||
StructureNotifyMask | SubstructureNotifyMask);
|
done:
|
||||||
|
return cwin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -66,7 +56,7 @@ CommsSetup(void)
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
_CommsFindCommsWindow();
|
comms_win = _CommsFindCommsWindow();
|
||||||
if (comms_win != None)
|
if (comms_win != None)
|
||||||
break;
|
break;
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
Loading…
Reference in New Issue