Unverified Commit 13211ec6 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/window_resize_bug' into 3.6.x

parents 7a02b4ab 2d99cdd1
......@@ -159,6 +159,7 @@ Pixmap nxagentScreenSaverPixmap;
XlibGC nxagentBitmapGC;
#ifdef NX_CONFINE_WINDOW
/*
* The "confine" window is used in the nxagentConstrainCursor
* procedure. We are currently overriding the original Xnest
......@@ -166,6 +167,7 @@ XlibGC nxagentBitmapGC;
*/
Window nxagentConfineWindow;
#endif
Pixmap nxagentIconPixmap;
Pixmap nxagentIconShape;
......@@ -1105,6 +1107,42 @@ void nxagentResetSignalHandlers(void)
nxagentInitTimer();
}
/*
* currently unused it seems
*/
void nxagentOpenConfineWindow(void)
{
#ifdef NX_CONFINE_WINDOW
nxagentConfineWindow = XCreateWindow(nxagentDisplay,
DefaultRootWindow(nxagentDisplay),
0, 0, 1, 1, 0, 0,
InputOnly,
CopyFromParent,
0L, NULL);
if (nxagentReportWindowIds) {
fprintf(stderr, "NXAGENT_WINDOW_ID: CONFINEMENT_WINDOW,WID:[0x%x]\n",
nxagentConfineWindow);
}
#ifdef DEBUG
{
char *winname = NULL;
if (-1 != asprintf(&winname, "%s Confine", nxagentWindowName))
{
Xutf8SetWMProperties(nxagentDisplay, nxagentConfineWindow,
winname, winname, NULL , 0 , NULL, NULL, NULL);
SAFE_free(winname);
}
}
#endif
#ifdef TEST
fprintf(stderr, "%s: Created agent's confine window with id [0x%x].\n", __func__, nxagentConfineWindow);
#endif
#endif
}
void nxagentOpenDisplay(int argc, char *argv[])
{
if (!nxagentDoFullGeneration)
......@@ -1298,21 +1336,7 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. We need
fprintf(stderr, "nxagentOpenDisplay: Going to create agent's confine window.\n");
#endif
nxagentConfineWindow = XCreateWindow(nxagentDisplay,
DefaultRootWindow(nxagentDisplay),
0, 0, 1, 1, 0, 0,
InputOnly,
CopyFromParent,
0L, NULL);
if (nxagentReportWindowIds) {
fprintf(stderr, "NXAGENT_WINDOW_ID: CONFINEMENT_WINDOW,WID:[0x%x]\n",
nxagentConfineWindow);
}
#ifdef TEST
fprintf(stderr, "nxagentOpenDisplay: Created agent's confine window with id [0x%x].\n",
nxagentConfineWindow);
#endif
nxagentOpenConfineWindow();
if (!(nxagentUserGeometry.flag & XValue))
{
......@@ -2665,21 +2689,7 @@ Bool nxagentReconnectDisplay(void *p0)
fprintf(stderr, "nxagentReconnectDisplay: Going to create agent's confine window.\n");
#endif
nxagentConfineWindow = XCreateWindow(nxagentDisplay,
DefaultRootWindow(nxagentDisplay),
0, 0, 1, 1, 0, 0,
InputOnly,
CopyFromParent,
0L, NULL);
if (nxagentReportWindowIds) {
fprintf(stderr, "NXAGENT_WINDOW_ID: CONFINEMENT_WINDOW,WID:[0x%x]\n",
nxagentConfineWindow);
}
#ifdef TEST
fprintf(stderr, "nxagentReconnectDisplay: Created agent's confine window with id [0x%x].\n",
nxagentConfineWindow);
#endif
nxagentOpenConfineWindow();
useXpmIcon = nxagentMakeIcon(nxagentDisplay, &nxagentIconPixmap, &nxagentIconShape);
......
......@@ -59,6 +59,7 @@ extern Pixel nxagentWhitePixel;
extern Drawable nxagentDefaultDrawables[MAXDEPTH + 1];
extern Pixmap nxagentScreenSaverPixmap;
#ifdef NX_CONFINE_WINDOW
/*
* The "confine" window is used in nxagentConstrainCursor().
* We are currently overriding the original Xnest behaviour
......@@ -66,6 +67,7 @@ extern Pixmap nxagentScreenSaverPixmap;
*/
extern Window nxagentConfineWindow;
#endif
/*
* Keyboard and pointer are handled as they were hardware
......
......@@ -588,7 +588,7 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen)
nxagentLaunchDialog(DIALOG_ENABLE_DESKTOP_RESIZE_MODE);
nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentOption(Height));
nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentOption(Height), True);
if (nxagentOption(ClientOs) == ClientOsWinnt)
{
......@@ -2082,7 +2082,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already
X.xmap.window == nxagentDefaultWindows[nxagentScreen(X.xmap.window)->myNum])
{
nxagentChangeScreenConfig(nxagentScreen(X.xmap.window)->myNum, nxagentOption(Width),
nxagentOption(Height));
nxagentOption(Height), True);
}
break;
......@@ -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;
......@@ -3257,7 +3275,7 @@ int nxagentHandleConfigureNotify(XEvent* X)
return 1;
}
}
else
else /* (nxagentOption(Rootless) == True) */
{
/*
* Save the position of the agent default window. Don't save the
......@@ -3280,7 +3298,7 @@ int nxagentHandleConfigureNotify(XEvent* X)
{
/*
* - WITHOUT window manager any position change is relevant
* - WITH window manager only synthetic position changes send
* - WITH window manager only synthetic position changes sent
* by the window manager are relevant, see ICCCM Chapter 4,
* "Configuring the Window"
*/
......@@ -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));
......@@ -3371,21 +3402,19 @@ int nxagentHandleConfigureNotify(XEvent* X)
/* FIXME: Comment makes no sense */
if (nxagentOption(Shadow) == 1 ||
(nxagentOption(Width) == nxagentOption(RootWidth) &&
nxagentOption(Height) == nxagentOption(RootHeight) &&
nxagentOption(X) == nxagentOption(RootX) &&
nxagentOption(Y) == nxagentOption(RootY)))
nxagentOption(Height) == nxagentOption(RootHeight) &&
nxagentOption(X) == nxagentOption(RootX) &&
nxagentOption(Y) == nxagentOption(RootY)))
{
doRandR = False;
}
nxagentChangeOption(Width, X -> xconfigure.width);
nxagentChangeOption(Height, X -> xconfigure.height);
XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0,
X -> xconfigure.width, X -> xconfigure.height);
if (nxagentOption(Fullscreen) == 0)
{
/* FIXME: has already been done some lines above */
nxagentMoveViewport(pScreen, 0, 0);
}
else
......@@ -3412,9 +3441,16 @@ int nxagentHandleConfigureNotify(XEvent* X)
fprintf(stderr,"%s: Width %d Height %d.\n", __func__,
nxagentOption(Width), nxagentOption(Height));
#endif
/*
* we are processing a ConfigureNotifyEvent that brought us
* the current window size. If we issue a XResizeWindow()
* again with these values we might end up in loop if the
* window manager adjusts the size, which is perfectly
* legal for it to do. So we prevent the XResizeWindow call
* from happening.
*/
nxagentChangeScreenConfig(0, nxagentOption(Width),
nxagentOption(Height));
nxagentOption(Height), False);
}
}
......@@ -3435,20 +3471,38 @@ int nxagentHandleConfigureNotify(XEvent* X)
nxagentChangeOption(RootHeight, X -> xconfigure.height);
nxagentChangeScreenConfig(0, nxagentOption(Width),
nxagentOption(Height));
nxagentOption(Height), True);
return 1;
}
}
}
#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))
......@@ -3548,32 +3602,39 @@ int nxagentHandleReparentNotify(XEvent* X)
* Calculate the absolute upper-left X e Y
*/
XlibWindow parent = X -> xreparent.parent;
XWindowAttributes attributes;
if ((XGetWindowAttributes(nxagentDisplay, X -> xreparent.window,
&attributes) == 0))
if ((XGetWindowAttributes(nxagentDisplay, parent, &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;
XTranslateCoordinates(nxagentDisplay, X -> xreparent.window,
#ifdef DEBUG
int before_x = x;
int before_y = y;
#endif
XTranslateCoordinates(nxagentDisplay, parent,
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.
*/
XlibWindow w = X -> xreparent.parent;
if (w != DefaultRootWindow(nxagentDisplay))
if (parent != DefaultRootWindow(nxagentDisplay))
{
XlibWindow rootReturn = 0;
XlibWindow parentReturn = 0;
......@@ -3582,7 +3643,7 @@ int nxagentHandleReparentNotify(XEvent* X)
do
{
Status result = XQueryTree(nxagentDisplay, w, &rootReturn, &parentReturn,
Status result = XQueryTree(nxagentDisplay, parent, &rootReturn, &parentReturn,
&childrenReturn, &nchildrenReturn);
SAFE_XFree(childrenReturn);
......@@ -3592,7 +3653,7 @@ int nxagentHandleReparentNotify(XEvent* X)
break;
}
w = parentReturn;
parent = parentReturn;
}
while (True);
......@@ -3600,7 +3661,7 @@ int nxagentHandleReparentNotify(XEvent* X)
* WM reparented. Find edge of the frame.
*/
if (XGetWindowAttributes(nxagentDisplay, w, &attributes) == 0)
if (XGetWindowAttributes(nxagentDisplay, parent, &attributes) == 0)
{
#ifdef WARNING
fprintf(stderr, "%s: WARNING! XGetWindowAttributes failed for parent window.\n", __func__);
......@@ -3616,6 +3677,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
}
}
......@@ -4309,11 +4382,13 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X)
fprintf(stderr, "%s: Called.\n", __func__);
#endif
nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], Xr -> width, Xr -> height,
Xr -> mwidth, Xr -> mheight);
nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)],
Xr -> width, Xr -> height,
Xr -> mwidth, Xr -> mheight, True);
nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)], screenInfo.screens[0]->root,
Xr -> width, Xr -> height);
nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)],
screenInfo.screens[0]->root,
Xr -> width, Xr -> height);
nxagentShadowSetWindowsSize();
......
......@@ -378,7 +378,7 @@ int nxagentRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
*/
int r = nxagentResizeScreen(pScreen, pSize -> width, pSize -> height,
pSize -> mmWidth, pSize -> mmHeight);
pSize -> mmWidth, pSize -> mmHeight, True);
nxagentMoveViewport(pScreen, 0, 0);
......@@ -448,7 +448,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height,
nxagentChangeOption(Height, height);
}
int result = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight);
int result = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight, True);
if (result == 1 && nxagentOption(DesktopResize) == 1 &&
nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0)
......
......@@ -405,10 +405,8 @@ void nxagentNotifyConnection(int fd, int ready, void *data)
void InitInput(int argc, char *argv[])
{
void *ptr, *kbd;
ptr = AddInputDevice(nxagentPointerProc, True);
kbd = AddInputDevice(nxagentKeyboardProc, True);
void *ptr = AddInputDevice(nxagentPointerProc, True);
void *kbd = AddInputDevice(nxagentKeyboardProc, True);
RegisterPointerDevice(ptr);
RegisterKeyboardDevice(kbd);
......
......@@ -149,7 +149,7 @@ InitRootWindow(WindowPtr pWin)
if (nxagentOption(Rootless))
{
#ifdef TEST
fprintf(stderr, "InitRootWindow: Assigned agent root to window at [%p][%ld] with parent [%p].\n",
fprintf(stderr, "InitRootWindow: Assigned agent root to window at [%p][%d] with parent [%p].\n",
(void *) pWin, nxagentWindowPriv(pWin)->window, (void *) pWin -> parent);
#endif
......@@ -381,13 +381,12 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP
#ifdef TEST
if (nxagentWindowTopLevel(pWin))
{
fprintf(stderr, "ConfigureWindow: pWin [%p] mask [%lu] client [%p]\n",
pWin, mask, client);
fprintf(stderr, "ConfigureWindow: pWin [%p] mask [%u] client [%p]\n",
(void *)pWin, mask, (void *)client);
fprintf(stderr, "ConfigureWindow: x [%d] y [%d] w [%d] h [%d] CWStackMode [%d] "
"smode [%d] pSib [%p]\n",
x, y, w, h, (mask & CWStackMode) ? 1 : 0, smode, pSib);
x, y, w, h, (mask & CWStackMode) ? 1 : 0, smode, (void *)pSib);
}
#endif
......@@ -683,7 +682,7 @@ MapWindow(register WindowPtr pWin, ClientPtr client)
#ifdef TEST
if (nxagentWindowTopLevel(pWin))
{
fprintf(stderr, "MapWindow: pWin [%p] client [%p]\n", pWin, client);
fprintf(stderr, "MapWindow: pWin [%p] client [%p]\n", (void *)pWin, (void *)client);
}
#endif
#endif
......
......@@ -633,7 +633,7 @@ Bool nxagentReconnectSession(void)
if (nxagentResizeDesktopAtStartup || nxagentOption(Rootless) == True || nxagentOption(Xinerama) == True)
{
nxagentChangeScreenConfig(0, nxagentOption(RootWidth),
nxagentOption(RootHeight));
nxagentOption(RootHeight), True);
nxagentResizeDesktopAtStartup = False;
}
......
......@@ -177,7 +177,7 @@ void nxagentPrintAgentGeometry(char *hdrMessage, char *prefix);
*/
int nxagentShadowResize = 0;
WindowPtr nxagentShadowWindowPtr = NULL;
static XID accessPixmapID;
......@@ -466,9 +466,23 @@ Window nxagentCreateIconWindow(void)
}
}
char *winname = NULL;
#ifdef DEBUG
if (-1 == asprintf(&winname, "%s Icon", nxagentWindowName))
{
/* If memory allocation wasn't possible, or some other error
occurs, these functions will return -1, and the contents of
winname are undefined. */
winname = NULL;
}
#endif
Xutf8SetWMProperties(nxagentDisplay, w,
nxagentWindowName, nxagentWindowName,
NULL , 0 , sizeHints, wmHints, NULL);
winname ? winname : nxagentWindowName,
winname ? winname : nxagentWindowName,
NULL , 0 , sizeHints, wmHints, NULL);
SAFE_free(winname);
SAFE_XFree(sizeHints);
SAFE_XFree(wmHints);
......@@ -766,32 +780,36 @@ void nxagentPrintAgentGeometry(char *hdrMessage, char *prefix)
if (hdrMessage)
{
fprintf(stderr, "--------------- %s -----------------.\n", hdrMessage);
fprintf(stderr, "%s /--------------- %s -----------------.\n", prefix, hdrMessage);
}
fprintf(stderr, "%s Root window at offset (%d,%d) size (%d,%d).\n", prefix,
fprintf(stderr, "%s | Root window at offset (%d,%d) size (%d,%d).\n", prefix,
nxagentOption(RootX), nxagentOption(RootY),
nxagentOption(RootWidth), nxagentOption(RootHeight));
fprintf(stderr, "%s Default window at offset (%d,%d) size (%d,%d) border size %d.\n", prefix,
fprintf(stderr, "%s | Default window at offset (%d,%d) size (%d,%d) border size %d.\n", prefix,
nxagentOption(X), nxagentOption(Y), nxagentOption(Width), nxagentOption(Height),
nxagentOption(BorderWidth));
fprintf(stderr, "%s Span between root window and default window is (%d,%d).\n", prefix,
fprintf(stderr, "%s | Span between root window and default window is (%d,%d).\n", prefix,
nxagentOption(ViewportXSpan), nxagentOption(ViewportYSpan));
fprintf(stderr, "%s Default window in window mode has offset (%d,%d) and size (%d,%d).\n", prefix,
fprintf(stderr, "%s | Default window in window mode has offset (%d,%d) and size (%d,%d).\n", prefix,
nxagentOption(SavedX), nxagentOption(SavedY), nxagentOption(SavedWidth), nxagentOption(SavedHeight));
fprintf(stderr, "%s Fullscreen is %s.\n", prefix,
fprintf(stderr, "%s | Fullscreen is %s.\n", prefix,
nxagentOption(Fullscreen) ? "ON" : "OFF");
fprintf(stderr, "%s Desktop resize mode is %s.\n", prefix,
fprintf(stderr, "%s | Desktop resize mode is %s.\n", prefix,
nxagentOption(DesktopResize) ? "ON" : "OFF");
fprintf(stderr, "%s Resize desktop at startup is %s.\n", prefix,
fprintf(stderr, "%s | Resize desktop at startup is %s.\n", prefix,
nxagentResizeDesktopAtStartup ? "ON" : "OFF");
if (hdrMessage)
{
fprintf(stderr, "%s \\--------------- %s -----------------.\n", prefix, hdrMessage);
}
#endif
}
......@@ -819,28 +837,10 @@ void freeDepths(DepthPtr depths, int num)
SAFE_free(depths);
}
Bool nxagentOpenScreen(ScreenPtr pScreen,
int argc, char *argv[])
Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
{
VisualPtr visuals;
DepthPtr depths;
int numVisuals, numDepths;
int depthIndex;
unsigned long valuemask;
XSetWindowAttributes attributes;
XWindowAttributes gattributes;
Mask mask;
Bool resetAgentPosition = False;
VisualID defaultVisual;
int rootDepth;
void * pFrameBufferBits;
int bitsPerPixel;
int sizeInBytes;
int defaultVisualIndex = 0;
#ifdef TEST
fprintf(stderr, "nxagentOpenScreen: Called for screen index [%d].\n",
pScreen->myNum);
......@@ -971,7 +971,6 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
#endif
nxagentChangeOption(Fullscreen, False);
nxagentChangeOption(AllScreens, False);
nxagentFullscreenWindow = 0;
......@@ -1147,7 +1146,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
* Initialize the depths.
*/
depths = (DepthPtr) malloc(nxagentNumDepths * sizeof(DepthRec));
DepthPtr depths = (DepthPtr) malloc(nxagentNumDepths * sizeof(DepthRec));
for (int i = 0; i < nxagentNumDepths; i++)
{
......@@ -1162,13 +1161,15 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
#if defined(DEBUG) || defined(DEBUG_COLORMAP)
fprintf(stderr, "Debug: Setting up visuals. Original array has size "
"[%d].\n", nxagentNumVisuals);
"[%d].\n", nxagentNumVisuals);
#endif
numVisuals = 0;
numDepths = nxagentNumDepths;
int numVisuals = 0;
int numDepths = nxagentNumDepths;
visuals = (VisualPtr) malloc(nxagentNumVisuals * sizeof(VisualRec));
VisualPtr visuals = (VisualPtr) malloc(nxagentNumVisuals * sizeof(VisualRec));
int defaultVisualIndex = 0;
for (int i = 0; i < nxagentNumVisuals; i++)
{
......@@ -1194,7 +1195,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
#if defined(DEBUG) || defined(DEBUG_COLORMAP)
fprintf(stderr, "Debug: Set default visual index [%d].\n" ,
defaultVisualIndex);
defaultVisualIndex);
#endif
}
else
......@@ -1214,17 +1215,16 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
visuals[numVisuals].offsetBlue == visuals[j].offsetBlue)
break;
}
if (j < numVisuals)
continue;
}
depthIndex = UNDEFINED;
int depthIndex = UNDEFINED;
#if defined(DEBUG) || defined(DEBUG_COLORMAP)
fprintf(stderr, "Debug: Added visual [%lu].\n" ,
(long unsigned int)visuals[numVisuals].vid);
(long unsigned int)visuals[numVisuals].vid);
#endif
for (int j = 0; j < numDepths; j++)
......@@ -1264,7 +1264,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
#if defined(DEBUG) || defined(DEBUG_COLORMAP)
fprintf(stderr, "Debug: Registered visual [%lu] for depth [%d (%d)].\n" ,
(long unsigned int)visuals[numVisuals].vid, depthIndex,
depths[depthIndex].depth);
depths[depthIndex].depth);
#endif
numVisuals++;
......@@ -1275,15 +1275,16 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
defaultVisualIndex, (long unsigned int)visuals[defaultVisualIndex].vid);
fprintf(stderr, "Debug: Setting root depth [%d].\n",
visuals[defaultVisualIndex].nplanes);
visuals[defaultVisualIndex].nplanes);
#endif
defaultVisual = visuals[defaultVisualIndex].vid;
rootDepth = visuals[defaultVisualIndex].nplanes;
VisualID defaultVisual = visuals[defaultVisualIndex].vid;
int rootDepth = visuals[defaultVisualIndex].nplanes;
nxagentInitAlphaVisual();
bitsPerPixel = nxagentBitsPerPixel(rootDepth);
int bitsPerPixel = nxagentBitsPerPixel(rootDepth);
int sizeInBytes;
if (bitsPerPixel == 1)
{
......@@ -1299,7 +1300,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
"[%d] bitsPerPixel [%d] sizeInBytes [%d]\n", rootDepth, bitsPerPixel, sizeInBytes);
#endif
pFrameBufferBits = (char *) malloc(sizeInBytes);
void * pFrameBufferBits = (char *) malloc(sizeInBytes);
if (!pFrameBufferBits)
{
......@@ -1314,13 +1315,16 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
rootDepth, (long unsigned int)defaultVisual);
#endif
if ((monitorResolution < 1) && (nxagentAutoDPI == False))
if (monitorResolution < 1)
{
monitorResolution = NXAGENT_DEFAULT_DPI;
}
else if ((monitorResolution < 1) && (nxagentAutoDPI == True))
{
monitorResolution = NXAGENT_AUTO_DPI;
if (nxagentAutoDPI)
{
monitorResolution = NXAGENT_AUTO_DPI;
}
else
{
monitorResolution = NXAGENT_DEFAULT_DPI;
}
}
if (!fbScreenInit(pScreen, pFrameBufferBits, nxagentOption(RootWidth), nxagentOption(RootHeight),
......@@ -1338,9 +1342,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
#endif
/*
* Complete the initialization of the GLX
* extension. This will add the GLX visuals
* and will modify numVisuals and numDepths.
* Complete the initialization of the GLX extension. This will add
* the GLX visuals and will modify numVisuals and numDepths.
*/
#if defined(DEBUG) || defined(DEBUG_COLORMAP)
......@@ -1359,8 +1362,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
#endif
/*
* Replace the visuals and depths initialized
* by fbScreenInit with our own.
* Replace the visuals and depths initialized by fbScreenInit with
* our own.
*/
freeDepths(pScreen->allowedDepths, pScreen->numDepths);
......@@ -1374,9 +1377,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
pScreen -> rootVisual = defaultVisual;
/*
* Set up the internal structures used for
* tracking the proxy resources associated
* to the unpack and split operations.
* Set up the internal structures used for tracking the proxy
* resources associated to the unpack and split operations.
*/
nxagentInitSplitResources();
......@@ -1403,23 +1405,20 @@ N/A
* and a GetGeometry (asynchronous) reply.
*/
XWindowAttributes gattributes;
XGetWindowAttributes(nxagentDisplay, nxagentParentWindow, &gattributes);
nxagentChangeOption(Width, gattributes.width);
nxagentChangeOption(Height, gattributes.height);
}
if (nxagentOption(AllScreens))
{
attributes.override_redirect = True;
}
if (nxagentOption(Fullscreen))
{
/*
* We need to disable the host's screensaver or
* it will otherwise grab the screen even if it
* is under agent's control.
* We need to disable the host's screensaver or it will
* otherwise grab the screen even if it is under agent's
* control.
*/
XSetScreenSaver(nxagentDisplay, 0, 0, DefaultExposures, DefaultBlanking);
......@@ -1442,7 +1441,7 @@ N/A
*
* if (!miScreenInit(pScreen, NULL, nxagentOption(RootWidth),
* nxagentOption(RootHeight), 1, 1, nxagentOption(RootWidth),
* visuals[nxagentDefaultVisualIndex].nplanes, / * Root depth. * /
* visuals[nxagentDefaultVisualIndex].nplanes, / * Root depth. * /
* numDepths, depths,
* visuals[nxagentDefaultVisualIndex].vid,* Root visual. * /
* numVisuals, visuals))
......@@ -1492,7 +1491,7 @@ N/A
/*
* Window Procedures.
*
*
* Note that the following functions are not
* replaced with nxagent counterparts:
*
......@@ -1526,9 +1525,8 @@ N/A
pScreen->DestroyPixmap = nxagentDestroyPixmap;
/*
* This is originally miModifyPixmapHeader()
* from miscrinit.c. It is used to recycle
* the scratch pixmap for this screen.
* This is originally miModifyPixmapHeader() from miscrinit.c. It
* is used to recycle the scratch pixmap for this screen.
*/
pScreen->ModifyPixmapHeader = nxagentModifyPixmapHeader;
......@@ -1597,18 +1595,16 @@ N/A
#ifdef RENDER
/*
* Initialize picture support. This have to be
* placed here because miDCInitialize calls
* DamageSetup, that should wrap the picture
* screen functions. So PictureInit has to be
* called before.
* Initialize picture support. This have to be placed here because
* miDCInitialize calls DamageSetup, that should wrap the picture
* screen functions. So PictureInit has to be called before.
*/
if (nxagentRenderEnable && !nxagentReconnectTrap)
{
if (!nxagentPictureInit(pScreen, 0, 0))
{
nxagentRenderEnable = False;
nxagentRenderEnable = False;
return FALSE;
}
......@@ -1648,8 +1644,7 @@ N/A
nxagentOption(Height)) / 32)
/*
* Complete the initialization of the RANDR
* extension.
* Complete the initialization of the RANDR extension.
*/
nxagentInitRandRExtension(pScreen);
......@@ -1662,15 +1657,16 @@ N/A
if (nxagentDoFullGeneration == 1 ||
nxagentReconnectTrap == 1)
{
valuemask = CWBackPixel | CWEventMask | CWColormap |
(nxagentOption(AllScreens) == 1 ? CWOverrideRedirect : 0);
attributes.background_pixel = nxagentBlackPixel;
attributes.event_mask = nxagentGetDefaultEventMask();
attributes.colormap = nxagentDefaultVisualColormap(nxagentDefaultVisual(pScreen));
unsigned long valuemask = CWBackPixel | CWEventMask | CWColormap;
XSetWindowAttributes attributes = {
.background_pixel = nxagentBlackPixel,
.event_mask = nxagentGetDefaultEventMask(),
.colormap = nxagentDefaultVisualColormap(nxagentDefaultVisual(pScreen))
};
if (nxagentOption(AllScreens) == 1)
{
valuemask |= CWOverrideRedirect;
attributes.override_redirect = True;
}
......@@ -1683,7 +1679,6 @@ N/A
* it will otherwise grab the screen even if it
* is under agent's control.
*/
XSetScreenSaver(nxagentDisplay, 0, 0, DefaultExposures, DefaultBlanking);
}
}
......@@ -1697,29 +1692,16 @@ N/A
{
nxagentDefaultWindows[pScreen->myNum] = nxagentParentWindow;
mask = nxagentGetDefaultEventMask();
XSelectInput(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], mask);
XSelectInput(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], nxagentGetDefaultEventMask());
}
else
{
/*
* Create any top-level window as a child of the
* real root of the remote display. See also the
* InitRootWindow() procedure and the function
* handling the splash screen.
* Create any top-level window as a child of the real root of
* the remote display. See also the InitRootWindow() procedure
* and the function handling the splash screen.
*/
if (nxagentOption(Rootless) == True)
{
nxagentDefaultWindows[pScreen->myNum] = DefaultRootWindow(nxagentDisplay);
#ifdef TEST
fprintf(stderr, "nxagentOpenScreen: Using root window id [%ld].\n",
(long int)nxagentDefaultWindows[pScreen->myNum]);
#endif
}
#ifdef TEST
fprintf(stderr, "nxagentOpenScreen: Going to create new default window.\n");
#endif
......@@ -1743,15 +1725,13 @@ N/A
}
#ifdef TEST
fprintf(stderr, "nxagentOpenScreen: Created new default window for screen [%d] with id [0x%x].\n",
fprintf(stderr, "%s: Created new default window for screen [%d] with id [0x%x].\n", __func__,
pScreen->myNum, nxagentDefaultWindows[pScreen->myNum]);
#endif
if (nxagentOption(Rootless) == 0)
{
valuemask = CWEventMask;
mask = PointerMotionMask;
attributes.event_mask = mask;
XSetWindowAttributes inpattributes = {.event_mask = PointerMotionMask};
nxagentInputWindows[pScreen->myNum] =
XCreateWindow(nxagentDisplay,
......@@ -1761,15 +1741,27 @@ N/A
nxagentOption(Height),
0, 0, InputOnly,
nxagentDefaultVisual(pScreen),
valuemask , &attributes);
CWEventMask, &inpattributes);
if (nxagentReportWindowIds)
{
fprintf(stderr, "NXAGENT_WINDOW_ID: INPUT_WINDOW:[%d],WID:[0x%x]\n", pScreen->myNum, nxagentInputWindows[pScreen->myNum]);
}
#ifdef DEBUG
{
char *winname = NULL;
if (-1 != asprintf(&winname, "%s Input", nxagentWindowName))
{
Xutf8SetWMProperties(nxagentDisplay, nxagentInputWindows[pScreen->myNum],
winname, winname, NULL , 0 , NULL, NULL, NULL);
SAFE_free(winname);
}
}
#endif
#ifdef TEST
fprintf(stderr, "nxagentOpenScreen: Created new input window for screen [%d] with id [0x%x].\n",
fprintf(stderr, "%s: Created new input window for screen [%d] with id [0x%x].\n", __func__,
pScreen->myNum, nxagentInputWindows[pScreen->myNum]);
#endif
}
......@@ -1826,9 +1818,7 @@ N/A
strlen("X-AGENT"));
}
mask = nxagentGetDefaultEventMask();
XSelectInput(nxagentDisplay, nxagentFullscreenWindow, mask);
XSelectInput(nxagentDisplay, nxagentFullscreenWindow, nxagentGetDefaultEventMask());
}
XSizeHints* sizeHints = XAllocSizeHints();
......@@ -1873,11 +1863,24 @@ N/A
}
}
char *winname = NULL;
#ifdef DEBUG
if (-1 == asprintf(&winname, "%s Default[%d]", nxagentWindowName, pScreen->myNum))
{
/* If memory allocation wasn't possible, or some other error
occurs, these functions will return -1, and the contents of
winname are undefined. */
winname = NULL;
}
#endif
Xutf8SetWMProperties(nxagentDisplay,
nxagentDefaultWindows[pScreen->myNum],
nxagentWindowName,
nxagentWindowName,
argv , argc , sizeHints, wmHints, NULL);
nxagentDefaultWindows[pScreen->myNum],
winname ? winname : nxagentWindowName,
winname ? winname : nxagentWindowName,
argv , argc , sizeHints, wmHints, NULL);
SAFE_free(winname);
SAFE_XFree(sizeHints);
SAFE_XFree(wmHints);
......@@ -1931,10 +1934,9 @@ N/A
}
/*
* The purpose of this check is to verify if there
* is a window manager running. Unfortunately due
* to the way we manage the intern atoms call, the
* atom will always exist.
* The purpose of this check is to verify if there is a window
* manager running. Unfortunately due to the way we manage the
* intern atoms call, the atom will always exist.
*/
if (nxagentWMIsRunning)
......@@ -1976,9 +1978,9 @@ N/A
else
{
/*
* We should always enable the configuration of the
* remote X server's devices if we are running full-
* screen and there is no WM running.
* We should always enable the configuration of the remote X
* server's devices if we are running fullscreen and there is no
* WM running.
*/
if (nxagentOption(Fullscreen))
......@@ -1992,9 +1994,8 @@ N/A
}
/*
* Inform the user whether the agent's clients will
* be able to change the real X server's keyboard
* and pointer settings.
* Inform the user whether the agent's clients will be able to
* change the real X server's keyboard and pointer settings.
*/
if (nxagentOption(DeviceControl) == False)
......@@ -2028,9 +2029,8 @@ N/A
#endif /* RENDER */
/*
* Check if the composite extension is
* supported on the remote display and
* prepare the agent for its use.
* Check if the composite extension is supported on the remote
* display and prepare the agent for its use.
*/
nxagentCompositeExtensionInit();
......@@ -2243,12 +2243,17 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable)
}
Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
int mmWidth, int mmHeight)
int mmWidth, int mmHeight, Bool doresize)
{
#ifdef DEBUG
fprintf(stderr, "%s: called with w [%d] (%dmm) h [%d] (%dmm) doresize [%d]\n",
__func__, width, mmWidth, height, mmHeight, doresize);
#endif
#ifdef TEST
nxagentPrintAgentGeometry("Before Resize Screen", "nxagentResizeScreen:");
#endif
/*
* Change screen properties.
*/
......@@ -2262,26 +2267,25 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
pScreen -> height = height;
/*
* Compute screen dimensions if they aren't given.
* Compute screen dimensions if they aren't provided.
*/
if (mmWidth == 0)
{
if (monitorResolution < 0)
{
mmWidth = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay));
mmWidth = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay));
}
else
{
mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10);
mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10);
}
if (mmWidth < 1)
{
mmWidth = 1;
}
}
if (mmHeight == 0)
......@@ -2300,23 +2304,22 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
{
mmHeight = 1;
}
}
pScreen -> mmWidth = mmWidth;
pScreen -> mmHeight = mmHeight;
#ifdef DEBUG
fprintf(stderr, "%s: old w [%d] (%dmm) h [%d] (%dmm) new w [%d] (%dmm) h [%d] (%dmm)\n",
__func__, oldWidth, oldMmWidth, oldHeight, oldMmHeight, width, mmWidth, height, mmHeight);
#endif
PixmapPtr pPixmap = fbGetScreenPixmap(pScreen);
char *fbBits = realloc(pPixmap -> devPrivate.ptr, PixmapBytePad(width, pScreen->rootDepth) *
height * BitsPerPixel(pScreen->rootDepth) / 8);
height * BitsPerPixel(pScreen->rootDepth) / 8);
if (fbBits == NULL)
{
pScreen -> width = oldWidth;
pScreen -> height = oldHeight;
pScreen -> mmWidth = oldMmWidth;
pScreen -> mmHeight = oldMmHeight;
goto nxagentResizeScreenError;
}
......@@ -2329,15 +2332,13 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
FIXME: We should try to restore the previously
reallocated frame buffer pixmap.
*/
pScreen -> width = oldWidth;
pScreen -> height = oldHeight;
pScreen -> mmWidth = oldMmWidth;
pScreen -> mmHeight = oldMmHeight;
goto nxagentResizeScreenError;
}
#ifdef DEBUG
fprintf(stderr, "%s: setting RootWidth/Height to [%d]x[%d]\n", __func__, width, height);
#endif
nxagentChangeOption(RootWidth, width);
nxagentChangeOption(RootHeight, height);
......@@ -2365,10 +2366,19 @@ FIXME: We should try to restore the previously
{
nxagentSetWMNormalHints(pScreen->myNum, width, height);
XResizeWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], width, height);
if (doresize)
{
#ifdef DEBUG
fprintf(stderr, "%s: resizing DefaultWindow to [%d]x[%d]\n", __func__, width, height);
#endif
XResizeWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], width, height);
}
if (nxagentOption(Rootless) == 0)
{
#ifdef DEBUG
fprintf(stderr, "%s: resizing InputWindow to [%d]x[%d]\n", __func__, width, height);
#endif
XResizeWindow(nxagentDisplay, nxagentInputWindows[pScreen -> myNum], width, height);
}
}
......@@ -2389,10 +2399,18 @@ FIXME: We should try to restore the previously
RegionInit(&pScreen->root -> clipList, &box, 1);
RegionInit(&pScreen->root -> borderClip, &box, 1);
#ifdef DEBUG
fprintf(stderr, "%s: calling PositionWindow() [0,0] for root Window\n", __func__);
#endif
(*pScreen -> PositionWindow)(pScreen->root, 0, 0);
nxagentSetRootClip(pScreen, 1);
#ifdef DEBUG
fprintf(stderr, "%s: moving root window to [%d,%d]\n", __func__, nxagentOption(RootX), nxagentOption(RootY));
#endif
XMoveWindow(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root),
nxagentOption(RootX), nxagentOption(RootY));
......@@ -2413,6 +2431,14 @@ FIXME: We should try to restore the previously
return 1;
nxagentResizeScreenError:
#ifdef DEBUG
fprintf(stderr, "%s: nxagentResizeScreenError\n", __func__);
#endif
pScreen -> width = oldWidth;
pScreen -> height = oldHeight;
pScreen -> mmWidth = oldMmWidth;
pScreen -> mmHeight = oldMmHeight;
return 0;
}
......@@ -2449,7 +2475,7 @@ void nxagentShadowSetWindowsSize(void)
XResizeWindow(nxagentDisplay, nxagentDefaultWindows[0],
nxagentOption(Width), nxagentOption(Height));
XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0,
XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0,
nxagentOption(Width), nxagentOption(Height));
}
......@@ -2691,7 +2717,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin)
AddResource(accessWindowID, RT_WINDOW, (void *)nxagentShadowWindowPtr);
nxagentResizeScreen(pScreen, nxagentShadowWidth, nxagentShadowHeight, pScreen -> mmWidth, pScreen -> mmHeight);
nxagentResizeScreen(pScreen, nxagentShadowWidth, nxagentShadowHeight, pScreen -> mmWidth, pScreen -> mmHeight, True);
nxagentShadowCreateMainWindow(pScreen, pWin, nxagentShadowWidth, nxagentShadowHeight);
......@@ -2759,7 +2785,7 @@ int nxagentShadowCreateMainWindow(ScreenPtr pScreen, WindowPtr pWin, int width,
nxagentShadowPixmapPtr -> drawable.id = accessPixmapID;
#ifdef TEST
fprintf(stderr, "nxagentShadowCreateMainWindow: nxagentShadowPixmapPtr [%p] PixmapM -> drawable.id [%lu].\n",
fprintf(stderr, "nxagentShadowCreateMainWindow: nxagentShadowPixmapPtr [%p] PixmapM -> drawable.id [%u].\n",
(void *)nxagentShadowPixmapPtr, nxagentShadowPixmapPtr -> drawable.id);
fprintf(stderr, "nxagentShadowCreateMainWindow: Create pixmap with width [%d] height [%d] depth [%d].\n",
nxagentShadowWidth, nxagentShadowHeight, (int)nxagentShadowDepth);
......@@ -2836,10 +2862,10 @@ int nxagentShadowCreateMainWindow(ScreenPtr pScreen, WindowPtr pWin, int width,
{
#ifdef TEST
fprintf(stderr, "nxagentShadowCreateMainWindow: Create window with nxagentShadowWindowPtr [%p]"
"nxagentShadowWindowPtr -> drawable.id [%lu].\n", (void *) nxagentShadowWindowPtr,
"nxagentShadowWindowPtr -> drawable.id [%u].\n", (void *) nxagentShadowWindowPtr,
nxagentShadowWindowPtr -> drawable.id);
fprintf(stderr, "nxagentShadowCreateMainWindow: parent nxagentShadowWindowPtr [%p] parent -> drawable.id [%lu].\n",
fprintf(stderr, "nxagentShadowCreateMainWindow: parent nxagentShadowWindowPtr [%p] parent -> drawable.id [%u].\n",
(void *)nxagentShadowWindowPtr->parent, nxagentShadowWindowPtr -> parent -> drawable.id);
#endif
......@@ -3401,7 +3427,7 @@ Bool nxagentReconnectScreen(void *p0)
return False;
}
nxagentPixmap(pPixmap) = XCreatePixmap(nxagentDisplay,
nxagentPixmap(pPixmap) = XCreatePixmap(nxagentDisplay,
nxagentDefaultWindows[nxagentDefaultScreen->myNum],
pPixmap -> drawable.width,
pPixmap -> drawable.height,
......@@ -3415,10 +3441,10 @@ Bool nxagentReconnectScreen(void *p0)
CARD16 h = 16;
(*nxagentDefaultScreen->QueryBestSize)(StippleShape, &w, &h, nxagentDefaultScreen);
if (!(nxagentPixmap(nxagentDefaultScreen->PixmapPerDepth[0]) =
XCreatePixmap(nxagentDisplay,
XCreatePixmap(nxagentDisplay,
nxagentDefaultDrawables[1],
w,
h,
w,
h,
1)));
Mask mask = nxagentGetDefaultEventMask();
......@@ -3440,7 +3466,7 @@ Bool nxagentReconnectScreen(void *p0)
nxagentSetTimeoutTimer(0);
return True;
return True;
}
/* intersect two rectangles */
......@@ -3621,8 +3647,8 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen)
}
#ifdef TEST
fprintf(stderr, "%s: Going to destroy mode %p with refcnt %d.\n",
__func__, nxagentRRCustomMode, nxagentRRCustomMode->refcnt);
fprintf(stderr, "%s: Going to destroy mode [%p] with refcnt [%d].\n",
__func__, (void *)nxagentRRCustomMode, nxagentRRCustomMode->refcnt);
#endif
RRModeDestroy(nxagentRRCustomMode);
......@@ -3646,10 +3672,10 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen)
RRScreenSizeNotify(pScreen);
}
int nxagentChangeScreenConfig(int screen, int width, int height)
int nxagentChangeScreenConfig(int screen, int width, int height, Bool doresize)
{
#ifdef DEBUG
fprintf(stderr, "nxagentChangeScreenConfig: called for screen [%d], width [%d] height [%d]\n", screen, width, height);
fprintf(stderr, "nxagentChangeScreenConfig: called for screen [%d], width [%d] height [%d] doresize [%d]\n", screen, width, height, doresize);
#endif
#ifdef TEST
......@@ -3675,7 +3701,7 @@ int nxagentChangeScreenConfig(int screen, int width, int height)
fprintf(stderr, "nxagentChangeScreenConfig: grabstate [UNKNOWN], client [%p]\n", (void *) nxagentGrabServerInfo.client);
#endif
if (nxagentGrabServerInfo.grabstate == SERVER_GRABBED && nxagentGrabServerInfo.client != NULL)
if (nxagentGrabServerInfo.grabstate == SERVER_GRABBED)
{
/*
* If any client grabbed the server it won't expect screen
......@@ -3697,7 +3723,7 @@ int nxagentChangeScreenConfig(int screen, int width, int height)
fprintf(stderr, "nxagentChangeScreenConfig: Changing config to %d x %d\n", width, height);
#endif
int r = nxagentResizeScreen(pScreen, width, height, 0, 0);
int r = nxagentResizeScreen(pScreen, width, height, 0, 0, doresize);
if (r != 0)
{
......@@ -3907,7 +3933,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
sprintf(name, "NX%d", i+1);
output = RROutputCreate(pScreen, name, strlen(name), NULL);
/* will be done later
RROutputSetConnection(output, RR_Disconnected);
RROutputSetConnection(output, RR_Disconnected);
*/
#ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: created new output [%s]\n", name);
......@@ -4620,7 +4646,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc,
XImage *image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), xSrc, ySrc,
width, height, AllPlanes, format);
*/
if (image == NULL)
{
#ifdef WARNING
......@@ -4645,9 +4671,9 @@ FIXME
#ifdef WARNING
fprintf(stderr, "nxagentFbRestoreArea: WARNING! Visual not found. Using default visual.\n");
#endif
pVisual = nxagentVisuals[nxagentDefaultVisualIndex].visual;
}
}
image = XCreateImage(nxagentDisplay, pVisual,
depth, format, 0, (char *) data,
......
......@@ -110,9 +110,9 @@ Window nxagentCreateIconWindow(void);
Bool nxagentMagicPixelZone(int x, int y);
Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
int mmWidth, int mmHeight);
int mmWidth, int mmHeight, Bool doresize);
int nxagentChangeScreenConfig(int screen, int width, int height);
int nxagentChangeScreenConfig(int screen, int width, int height, Bool doresize);
int nxagentAdjustRandRXinerama(ScreenPtr pScreen);
......
......@@ -380,6 +380,8 @@ Bool nxagentCreateWindow(WindowPtr pWin)
if (nxagentOption(Rootless) == 1)
{
nxagentWindowPriv(pWin) -> isMapped = 0;
if (pWin != nxagentRootlessWindow)
{
WindowPtr pParent = pWin -> parent;
......@@ -388,23 +390,33 @@ Bool nxagentCreateWindow(WindowPtr pWin)
{
nxagentWindowPriv(pWin) -> isMapped = 1;
}
else
{
nxagentWindowPriv(pWin) -> isMapped = 0;
}
}
else
{
nxagentWindowPriv(pWin) -> isMapped = 0;
}
}
if (nxagentReportPrivateWindowIds)
{
fprintf(stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x],INT:[0x%x]\n", nxagentWindowPriv(pWin)->window, pWin->drawable.id);
fprintf(stderr, "NXAGENT_WINDOW_ID: %s_WINDOW,WID:[0x%x],INT:[0x%x]\n",
(pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id) ? "ROOT" : "PRIVATE",
nxagentWindowPriv(pWin)->window, pWin->drawable.id);
}
#ifdef DEBUG
{
char *winname = NULL;
if (-1 != asprintf(&winname, "%s %s[0x%lx]", nxagentWindowName,
(pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id) ? "Root" : "Private",
pWin->drawable.id))
{
Xutf8SetWMProperties(nxagentDisplay, nxagentWindowPriv(pWin)->window,
winname, winname, NULL , 0 , NULL, NULL, NULL);
SAFE_free(winname);
}
}
#endif
#ifdef TEST
fprintf(stderr, "nxagentCreateWindow: Created new window with id [0x%x].\n",
fprintf(stderr, "%s: Created new window with id [0x%x].\n", __func__,
nxagentWindowPriv(pWin)->window);
#endif
......@@ -804,11 +816,14 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
for (i = 0; i < 100 && nxagentWMIsRunning; i++)
{
#ifdef TEST
fprintf(stderr, "nxagentSwitchAllScreens: WARNING! Going to wait for the ReparentNotify event.\n");
fprintf(stderr, "%s: WARNING! Going to wait for the ReparentNotify event.\n", __func__);
#endif
if (XCheckTypedWindowEvent(nxagentDisplay, w, ReparentNotify, &e))
{
#ifdef TEST
fprintf(stderr, "%s: found ReparentNotify event in iteration [%d].\n", __func__, i);
#endif
break;
}
......@@ -891,7 +906,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
if (nxagentOption(Shadow) == 0)
{
nxagentChangeScreenConfig(0, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)),
HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), True);
}
else
{
......@@ -907,7 +922,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
*/
#ifdef WARNING
fprintf(stderr, "nxagentSwitchAllScreens: WARNING! Expected ReparentNotify event missing.\n");
fprintf(stderr, "%s: WARNING! Expected ReparentNotify event missing.\n", __func__);
#endif
nxagentWMIsRunning = False;
......@@ -945,7 +960,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
if (nxagentOption(Shadow) == 0)
{
nxagentChangeScreenConfig(0, nxagentOption(RootWidth),
nxagentOption(RootHeight));
nxagentOption(RootHeight), True);
}
}
......@@ -958,6 +973,9 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
if (nxagentOption(WMBorderWidth) > 0)
{
#ifdef DEBUG
fprintf(stderr, "%s: WMBorderWidth [%d]\n", __func__, nxagentOption(WMBorderWidth));
#endif
nxagentChangeOption(X, nxagentOption(SavedX) - nxagentOption(WMBorderWidth));
}
else
......@@ -967,6 +985,9 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
if (nxagentOption(WMTitleHeight) > 0)
{
#ifdef DEBUG
fprintf(stderr, "%s: WMTitleHeight [%d]\n", __func__, nxagentOption(WMTitleHeight));
#endif
nxagentChangeOption(Y, nxagentOption(SavedY) - nxagentOption(WMTitleHeight));
}
else
......@@ -2993,8 +3014,26 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer
if (nxagentReportPrivateWindowIds)
{
fprintf(stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x],INT:[0x%x]\n", nxagentWindowPriv(pWin)->window, pWin->drawable.id);
fprintf(stderr, "NXAGENT_WINDOW_ID: %s_WINDOW,WID:[0x%x],INT:[0x%x]\n",
(pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id) ? "ROOT" : "PRIVATE",
nxagentWindowPriv(pWin)->window, pWin->drawable.id);
}
#ifdef DEBUG
{
char *winname = NULL;
if (-1 != asprintf(&winname, "%s %s[0x%lx]", nxagentWindowName,
(pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id) ? "Root" : "Private",
pWin->drawable.id))
{
Xutf8SetWMProperties(nxagentDisplay, nxagentWindowPriv(pWin)->window,
winname, winname, NULL , 0 , NULL, NULL, NULL);
SAFE_free(winname);
}
}
#endif
#ifdef TEST
fprintf(stderr, "nxagentReconnectWindow: Created new window with id [0x%x].\n",
nxagentWindowPriv(pWin)->window);
......
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