Commit 337afd83 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Events.c: add more DEBUG output

parent 8deda7bd
......@@ -3135,8 +3135,26 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X)
return 1;
}
#define DEBUG
#define TEST
int nxagentHandleConfigureNotify(XEvent* X)
{
#ifdef DEBUG
fprintf(stderr, "%s: Event info:\n", __func__);
fprintf(stderr, "%s: X->serial [%ld]\n", __func__, X->xconfigure.serial);
fprintf(stderr, "%s: X->override_redirect [%d]\n", __func__, X->xconfigure.override_redirect);
fprintf(stderr, "%s: X->border_width [%d]\n", __func__, X->xconfigure.border_width);
fprintf(stderr, "%s: X->send_event [%d]\n", __func__, X->xconfigure.send_event);
fprintf(stderr, "%s: X->window [0x%lx]\n", __func__, X->xconfigure.window);
fprintf(stderr, "%s: X->event [0x%lx]\n", __func__, X->xconfigure.event);
fprintf(stderr, "%s: X->x, X->y [%d][%d]\n", __func__, X->xconfigure.x, X->xconfigure.y);
fprintf(stderr, "%s: X->width, X->height [%d][%d]\n", __func__, X->xconfigure.width, X->xconfigure.height);
fprintf(stderr, "%s: References:\n", __func__);
fprintf(stderr, "%s: DefaultWindow[0]: [0x%x]\n", __func__, nxagentDefaultWindows[0]);
fprintf(stderr, "%s: DefaultRootWindow(DISPLAY) [0x%lx]\n", __func__, DefaultRootWindow(nxagentDisplay));
#endif
if (nxagentOption(Rootless) == True)
{
int sendEventAnyway = 0;
......@@ -3326,6 +3344,10 @@ int nxagentHandleConfigureNotify(XEvent* X)
if (!nxagentWMIsRunning || X -> xconfigure.send_event)
{
updatePos = True;
#ifdef DEBUG
fprintf(stderr, "%s: Accumulating event %d: x [%d] y [%d] width [%d] height [%d]\n", __func__, count,
X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height);
#endif
newX = X -> xconfigure.x;
newY = X -> xconfigure.y;
}
......@@ -3340,10 +3362,11 @@ int nxagentHandleConfigureNotify(XEvent* X)
}
}
if (updatePos)
if (updatePos && (nxagentOption(X) != newX || nxagentOption(Y) != newY))
{
#ifdef DEBUG
fprintf(stderr, "%s: Updating nxagent window position [%d,%d]\n", __func__, newX, newY);
fprintf(stderr, "%s: Updating nxagent window position [%d,%d] -> [%d,%d]\n", __func__,
nxagentOption(X), nxagentOption(Y), newX, newY);
#endif
nxagentChangeOption(X, newX);
nxagentChangeOption(Y, newY);
......@@ -3356,8 +3379,16 @@ int nxagentHandleConfigureNotify(XEvent* X)
nxagentShadowResize = 1;
}
nxagentChangeOption(Width, X -> xconfigure.width);
nxagentChangeOption(Height, X -> xconfigure.height);
if (nxagentOption(Width) != X->xconfigure.width || nxagentOption(Height) != X->xconfigure.height)
{
#ifdef DEBUG
fprintf(stderr, "%s: Updating width and height [%d,%d] -> [%d,%d]\n", __func__,
nxagentOption(Width), nxagentOption(Height),
X->xconfigure.width, X->xconfigure.height);
#endif
nxagentChangeOption(Width, X -> xconfigure.width);
nxagentChangeOption(Height, X -> xconfigure.height);
}
nxagentChangeOption(ViewportXSpan, (int) X -> xconfigure.width -
(int) nxagentOption(RootWidth));
......@@ -3378,9 +3409,6 @@ int nxagentHandleConfigureNotify(XEvent* X)
doRandR = False;
}
nxagentChangeOption(Width, X -> xconfigure.width);
nxagentChangeOption(Height, X -> xconfigure.height);
XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0,
X -> xconfigure.width, X -> xconfigure.height);
......@@ -3449,13 +3477,31 @@ int nxagentHandleConfigureNotify(XEvent* X)
}
}
#ifdef TEST
fprintf(stderr, "%s: received for unexpected window [%ld]\n", __func__, X -> xconfigure.window);
#endif
return 0;
}
int nxagentHandleReparentNotify(XEvent* X)
{
#ifdef TEST
fprintf(stderr, "%s: Going to handle a new reparent event.\n", __func__);
fprintf(stderr, "%s: Going to handle a new reparent event (serial [%ld].\n", __func__, X->xreparent.serial);
#endif
#ifdef DEBUG
fprintf(stderr, "%s: Event info:\n", __func__);
fprintf(stderr, "%s: X->send_event [%d]\n", __func__, X->xreparent.send_event);
fprintf(stderr, "%s: X->event [0x%lx]\n", __func__, X->xreparent.event);
fprintf(stderr, "%s: X->window [0x%lx]\n", __func__, X->xreparent.window);
fprintf(stderr, "%s: X->parent [0x%lx]\n", __func__, X->xreparent.parent);
fprintf(stderr, "%s: X->x, X->y [%d][%d]\n", __func__, X->xreparent.x, X->xreparent.y);
fprintf(stderr, "%s: X->override_redirect [%d]\n", __func__, X->xreparent.override_redirect);
fprintf(stderr, "%s: References:\n", __func__);
fprintf(stderr, "%s: DefaultWindow[0]: [0x%x]\n", __func__, nxagentDefaultWindows[0]);
fprintf(stderr, "%s: RootWindow(DISPLAY, 0): [0x%lx]\n", __func__, RootWindow(nxagentDisplay, 0));
fprintf(stderr, "%s: DefaultRootWindow(DISPLAY): [0x%lx]\n", __func__, DefaultRootWindow(nxagentDisplay));
#endif
if (nxagentOption(Rootless))
......@@ -3560,21 +3606,30 @@ int nxagentHandleReparentNotify(XEvent* X)
&attributes) == 0))
{
#ifdef WARNING
fprintf(stderr, "%s: WARNING! XGetWindowAttributes failed.\n", __func__);
fprintf(stderr, "%s: WARNING! XGetWindowAttributes for parent window failed.\n", __func__);
#endif
return 1;
}
XlibWindow junk;
int x = attributes.x;
int y = attributes.y;
XlibWindow junk;
#ifdef DEBUG
int before_x = x;
int before_y = y;
#endif
XTranslateCoordinates(nxagentDisplay, X -> xreparent.window,
attributes.root, -attributes.border_width,
-attributes.border_width, &x, &y, &junk);
/*
#ifdef DEBUG
fprintf(stderr, "%s: translated coordinates x,y [%d,%d] -> [%d,%d].\n", __func__, before_x, before_y, x, y);
#endif
/*
* Calculate the parent X and parent Y.
*/
......@@ -3623,6 +3678,18 @@ int nxagentHandleReparentNotify(XEvent* X)
nxagentChangeOption(WMBorderWidth, (x - attributes.x));
nxagentChangeOption(WMTitleHeight, (y - attributes.y));
#ifdef DEBUG
fprintf(stderr, "%s: WMBorderWidth [%d]\n", __func__, nxagentOption(WMBorderWidth));
fprintf(stderr, "%s: WMTitleHeight [%d]\n", __func__, nxagentOption(WMTitleHeight));
fprintf(stderr, "%s: win_gravity [%d]\n", __func__, attributes.win_gravity);
fprintf(stderr, "%s: bit_gravity [%d]\n", __func__, attributes.bit_gravity);
fprintf(stderr, "%s: border_width [%d]\n", __func__, attributes.border_width);
fprintf(stderr, "%s: height [%d]\n", __func__, attributes.height);
fprintf(stderr, "%s: width [%d]\n", __func__, attributes.width);
fprintf(stderr, "%s: x [%d]\n", __func__, attributes.x);
fprintf(stderr, "%s: y [%d]\n", __func__, attributes.y);
#endif
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment