Commit 5d2dbfaa authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Window.c: scope improvements

plus some whitespace improvements
parent dfcb5d0b
...@@ -764,10 +764,6 @@ void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn) ...@@ -764,10 +764,6 @@ void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn)
void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
{ {
Window w;
XSetWindowAttributes attributes;
unsigned long valuemask;
if (nxagentOption(Rootless)) if (nxagentOption(Rootless))
{ {
return; return;
...@@ -787,14 +783,16 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) ...@@ -787,14 +783,16 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
} }
} }
w = nxagentDefaultWindows[pScreen -> myNum]; Window w = nxagentDefaultWindows[pScreen -> myNum];
/* /*
* override_redirect makes the window manager ignore the window and * override_redirect makes the window manager ignore the window and
* not add decorations, see ICCCM) * not add decorations, see ICCCM)
*/ */
attributes.override_redirect = switchOn; XSetWindowAttributes attributes = {
valuemask = CWOverrideRedirect; .override_redirect = switchOn
};
unsigned long valuemask = CWOverrideRedirect;
XUnmapWindow(nxagentDisplay, w); XUnmapWindow(nxagentDisplay, w);
XChangeWindowAttributes(nxagentDisplay, w, valuemask, &attributes); XChangeWindowAttributes(nxagentDisplay, w, valuemask, &attributes);
...@@ -1411,10 +1409,9 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) ...@@ -1411,10 +1409,9 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask)
Window parent_return; Window parent_return;
Window *children_return = NULL; Window *children_return = NULL;
unsigned int nchildren_return; unsigned int nchildren_return;
Status result;
result = XQueryTree(nxagentDisplay, DefaultRootWindow(nxagentDisplay), Status result = XQueryTree(nxagentDisplay, DefaultRootWindow(nxagentDisplay),
&root_return, &parent_return, &children_return, &nchildren_return); &root_return, &parent_return, &children_return, &nchildren_return);
if (result) if (result)
{ {
...@@ -1622,7 +1619,6 @@ Bool nxagentChangeWindowAttributes(WindowPtr pWin, unsigned long mask) ...@@ -1622,7 +1619,6 @@ Bool nxagentChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
case ParentRelative: case ParentRelative:
{ {
attributes.background_pixmap = ParentRelative; attributes.background_pixmap = ParentRelative;
break; break;
} }
case BackgroundPixmap: case BackgroundPixmap:
...@@ -1665,7 +1661,6 @@ Bool nxagentChangeWindowAttributes(WindowPtr pWin, unsigned long mask) ...@@ -1665,7 +1661,6 @@ Bool nxagentChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
case BackgroundPixel: case BackgroundPixel:
{ {
mask &= ~CWBackPixmap; mask &= ~CWBackPixmap;
break; break;
} }
} }
...@@ -1987,8 +1982,6 @@ void nxagentFrameBufferPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) ...@@ -1987,8 +1982,6 @@ void nxagentFrameBufferPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
void nxagentPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what) void nxagentPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
{ {
RegionRec temp;
if (pWin -> realized) if (pWin -> realized)
{ {
BoxPtr pBox = RegionRects(pRegion); BoxPtr pBox = RegionRects(pRegion);
...@@ -2017,6 +2010,7 @@ void nxagentPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what) ...@@ -2017,6 +2010,7 @@ void nxagentPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
* so we need to clip ourselves. * so we need to clip ourselves.
*/ */
RegionRec temp;
RegionInit(&temp, NullBox, 1); RegionInit(&temp, NullBox, 1);
RegionIntersect(&temp, pRegion, &pWin -> clipList); RegionIntersect(&temp, pRegion, &pWin -> clipList);
nxagentFrameBufferPaintWindow(pWin, &temp, what); nxagentFrameBufferPaintWindow(pWin, &temp, what);
...@@ -2025,14 +2019,13 @@ void nxagentPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what) ...@@ -2025,14 +2019,13 @@ void nxagentPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
void nxagentPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what) void nxagentPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
{ {
RegionRec temp;
/* /*
* The framebuffer operations don't take care of * The framebuffer operations don't take care of
* clipping to the actual area of the framebuffer * clipping to the actual area of the framebuffer
* so we need to clip ourselves. * so we need to clip ourselves.
*/ */
RegionRec temp;
RegionInit(&temp, NullBox, 1); RegionInit(&temp, NullBox, 1);
RegionIntersect(&temp, pRegion, &pWin -> borderClip); RegionIntersect(&temp, pRegion, &pWin -> borderClip);
nxagentFrameBufferPaintWindow(pWin, &temp, what); nxagentFrameBufferPaintWindow(pWin, &temp, what);
...@@ -2148,8 +2141,6 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo ...@@ -2148,8 +2141,6 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo
* final region by referring to the first element of the vector. * final region by referring to the first element of the vector.
*/ */
RegionRec temp;
BoxRec box;
if (nxagentSessionState != SESSION_DOWN) if (nxagentSessionState != SESSION_DOWN)
{ {
...@@ -2181,13 +2172,14 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo ...@@ -2181,13 +2172,14 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo
nxagentExposeArrayIsInitialized = 1; nxagentExposeArrayIsInitialized = 1;
} }
RegionRec temp;
RegionInit(&temp, (BoxRec *) NULL, 1); RegionInit(&temp, (BoxRec *) NULL, 1);
if (pRgn != NULL) if (pRgn != NULL)
{ {
if (RegionNumRects(pRgn) > RECTLIMIT) if (RegionNumRects(pRgn) > RECTLIMIT)
{ {
box = *RegionExtents(pRgn); BoxRec box = *RegionExtents(pRgn);
RegionEmpty(pRgn); RegionEmpty(pRgn);
RegionInit(pRgn, &box, 1); RegionInit(pRgn, &box, 1);
...@@ -2300,9 +2292,6 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo ...@@ -2300,9 +2292,6 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo
#ifdef SHAPE #ifdef SHAPE
static Bool nxagentRegionEqual(RegionPtr pReg1, RegionPtr pReg2) static Bool nxagentRegionEqual(RegionPtr pReg1, RegionPtr pReg2)
{ {
BoxPtr pBox1, pBox2;
unsigned int n1, n2;
if (pReg1 == pReg2) if (pReg1 == pReg2)
{ {
return True; return True;
...@@ -2313,11 +2302,11 @@ static Bool nxagentRegionEqual(RegionPtr pReg1, RegionPtr pReg2) ...@@ -2313,11 +2302,11 @@ static Bool nxagentRegionEqual(RegionPtr pReg1, RegionPtr pReg2)
return False; return False;
} }
pBox1 = RegionRects(pReg1); BoxPtr pBox1 = RegionRects(pReg1);
n1 = RegionNumRects(pReg1); int n1 = RegionNumRects(pReg1);
pBox2 = RegionRects(pReg2); BoxPtr pBox2 = RegionRects(pReg2);
n2 = RegionNumRects(pReg2); int n2 = RegionNumRects(pReg2);
if (n1 != n2) if (n1 != n2)
{ {
...@@ -2339,9 +2328,6 @@ static Bool nxagentRegionEqual(RegionPtr pReg1, RegionPtr pReg2) ...@@ -2339,9 +2328,6 @@ static Bool nxagentRegionEqual(RegionPtr pReg1, RegionPtr pReg2)
void nxagentShapeWindow(WindowPtr pWin) void nxagentShapeWindow(WindowPtr pWin)
{ {
Region reg;
BoxPtr pBox;
if (NXDisplayError(nxagentDisplay) == 1) if (NXDisplayError(nxagentDisplay) == 1)
{ {
return; return;
...@@ -2379,8 +2365,8 @@ void nxagentShapeWindow(WindowPtr pWin) ...@@ -2379,8 +2365,8 @@ void nxagentShapeWindow(WindowPtr pWin)
RegionCopy(nxagentWindowPriv(pWin)->boundingShape, wBoundingShape(pWin)); RegionCopy(nxagentWindowPriv(pWin)->boundingShape, wBoundingShape(pWin));
reg = XCreateRegion(); Region reg = XCreateRegion();
pBox = RegionRects(nxagentWindowPriv(pWin)->boundingShape); BoxPtr pBox = RegionRects(nxagentWindowPriv(pWin)->boundingShape);
for (int i = 0; for (int i = 0;
i < RegionNumRects(nxagentWindowPriv(pWin)->boundingShape); i < RegionNumRects(nxagentWindowPriv(pWin)->boundingShape);
i++) i++)
...@@ -2438,8 +2424,8 @@ void nxagentShapeWindow(WindowPtr pWin) ...@@ -2438,8 +2424,8 @@ void nxagentShapeWindow(WindowPtr pWin)
RegionCopy(nxagentWindowPriv(pWin)->clipShape, wClipShape(pWin)); RegionCopy(nxagentWindowPriv(pWin)->clipShape, wClipShape(pWin));
reg = XCreateRegion(); Region reg = XCreateRegion();
pBox = RegionRects(nxagentWindowPriv(pWin)->clipShape); BoxPtr pBox = RegionRects(nxagentWindowPriv(pWin)->clipShape);
for (int i = 0; for (int i = 0;
i < RegionNumRects(nxagentWindowPriv(pWin)->clipShape); i < RegionNumRects(nxagentWindowPriv(pWin)->clipShape);
i++) i++)
...@@ -2640,8 +2626,7 @@ Bool nxagentDisconnectAllWindows(void) ...@@ -2640,8 +2626,7 @@ Bool nxagentDisconnectAllWindows(void)
for (int i = 0; i < screenInfo.numScreens; i++) for (int i = 0; i < screenInfo.numScreens; i++)
{ {
WindowPtr pWin = screenInfo.screens[i]->root; nxagentTraverseWindow(screenInfo.screens[i]->root, nxagentDisconnectWindow, &succeeded);
nxagentTraverseWindow( pWin, nxagentDisconnectWindow, &succeeded);
nxagentDefaultWindows[i] = None; nxagentDefaultWindows[i] = None;
} }
...@@ -2706,7 +2691,7 @@ void nxagentDisconnectWindow(void * p0, XID x1, void * p2) ...@@ -2706,7 +2691,7 @@ void nxagentDisconnectWindow(void * p0, XID x1, void * p2)
if (DeleteProperty(pWin, prop) != Success) if (DeleteProperty(pWin, prop) != Success)
{ {
fprintf(stderr, "nxagentDisconnectWindow: Deleting NX_REAL_WINDOW failed.\n"); fprintf(stderr, "nxagentDisconnectWindow: Deleting NX_REAL_WINDOW failed.\n");
} }
#ifdef DEBUG #ifdef DEBUG
else else
...@@ -3061,7 +3046,6 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer ...@@ -3061,7 +3046,6 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer
if (nxagentWindowTopLevel(pWin)) if (nxagentWindowTopLevel(pWin))
{ {
int ret;
Atom type; Atom type;
int format; int format;
unsigned long nItems, bytesLeft; unsigned long nItems, bytesLeft;
...@@ -3071,11 +3055,11 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer ...@@ -3071,11 +3055,11 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer
unsigned char *data64 = NULL; unsigned char *data64 = NULL;
#endif #endif
ret = GetWindowProperty(pWin, int ret = GetWindowProperty(pWin,
XA_WM_NORMAL_HINTS, XA_WM_NORMAL_HINTS,
0, sizeof(XSizeHints), 0, sizeof(XSizeHints),
False, XA_WM_SIZE_HINTS, False, XA_WM_SIZE_HINTS,
&type, &format, &nItems, &bytesLeft, &data); &type, &format, &nItems, &bytesLeft, &data);
/* /*
* 72 is the number of bytes returned by * 72 is the number of bytes returned by
...@@ -3087,7 +3071,6 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer ...@@ -3087,7 +3071,6 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer
bytesLeft == 0 && bytesLeft == 0 &&
type == XA_WM_SIZE_HINTS) type == XA_WM_SIZE_HINTS)
{ {
XSizeHints *props;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentReconnectWindow: setting WMSizeHints on window %p [%lx - %lx].\n", fprintf(stderr, "nxagentReconnectWindow: setting WMSizeHints on window %p [%lx - %lx].\n",
(void*)pWin, pWin -> drawable.id, nxagentWindow(pWin)); (void*)pWin, pWin -> drawable.id, nxagentWindow(pWin));
...@@ -3108,9 +3091,9 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer ...@@ -3108,9 +3091,9 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer
*(data64 + i) = *(data + i - 4); *(data64 + i) = *(data + i - 4);
} }
props = (XSizeHints *) data64; XSizeHints *props = (XSizeHints *) data64;
#else #else
props = (XSizeHints *) data; XSizeHints *props = (XSizeHints *) data;
#endif /* _XSERVER64 */ #endif /* _XSERVER64 */
hints = *props; hints = *props;
...@@ -3164,15 +3147,14 @@ static void nxagentReconfigureWindowCursor(void * param0, XID param1, void * dat ...@@ -3164,15 +3147,14 @@ static void nxagentReconfigureWindowCursor(void * param0, XID param1, void * dat
{ {
WindowPtr pWin = (WindowPtr)param0; WindowPtr pWin = (WindowPtr)param0;
Bool *pBool = (Bool*)data_buffer; Bool *pBool = (Bool*)data_buffer;
CursorPtr pCursor; CursorPtr pCursor;
ScreenPtr pScreen;
if (!pWin || !*pBool || !(pCursor = wCursor(pWin))) if (!pWin || !*pBool || !(pCursor = wCursor(pWin)))
{ {
return; return;
} }
pScreen = pWin -> drawable.pScreen; ScreenPtr pScreen = pWin -> drawable.pScreen;
if (!(nxagentCursorPriv(pCursor, pScreen))) if (!(nxagentCursorPriv(pCursor, pScreen)))
{ {
...@@ -3308,27 +3290,23 @@ Bool nxagentCheckIllegalRootMonitoring(WindowPtr pWin, Mask mask) ...@@ -3308,27 +3290,23 @@ Bool nxagentCheckIllegalRootMonitoring(WindowPtr pWin, Mask mask)
Bool nxagentCheckWindowIntegrity(WindowPtr pWin) Bool nxagentCheckWindowIntegrity(WindowPtr pWin)
{ {
Bool integrity = True; Bool integrity = True;
XImage *image;
char *data;
int format;
unsigned long plane_mask = AllPlanes;
unsigned int width, height, length, depth;
width = pWin -> drawable.width; unsigned int width = pWin -> drawable.width;
height = pWin -> drawable.height; unsigned int height = pWin -> drawable.height;
depth = pWin -> drawable.depth; unsigned int depth = pWin -> drawable.depth;
format = (depth == 1) ? XYPixmap : ZPixmap; int format = (depth == 1) ? XYPixmap : ZPixmap;
if (width && height) if (width && height)
{ {
length = nxagentImageLength(width, height, format, 0, depth); unsigned int length = nxagentImageLength(width, height, format, 0, depth);
data = calloc(1, length); char *data = calloc(1, length);
if (data == NULL) if (data == NULL)
{ {
FatalError("nxagentCheckWindowIntegrity: Failed to allocate a buffer of size %d.\n", length); FatalError("nxagentCheckWindowIntegrity: Failed to allocate a buffer of size %d.\n", length);
} }
image = XGetImage(nxagentDisplay, nxagentWindow(pWin), 0, 0, unsigned long plane_mask = AllPlanes;
XImage *image = XGetImage(nxagentDisplay, nxagentWindow(pWin), 0, 0,
width, height, plane_mask, format); width, height, plane_mask, format);
if (image == NULL) if (image == NULL)
{ {
...@@ -3396,7 +3374,6 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin) ...@@ -3396,7 +3374,6 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin)
Bool nxagentIsIconic(WindowPtr pWin) Bool nxagentIsIconic(WindowPtr pWin)
{ {
int iReturn;
unsigned long ulReturnItems; unsigned long ulReturnItems;
unsigned long ulReturnBytesLeft; unsigned long ulReturnBytesLeft;
Atom atomReturnType; Atom atomReturnType;
...@@ -3408,9 +3385,9 @@ Bool nxagentIsIconic(WindowPtr pWin) ...@@ -3408,9 +3385,9 @@ Bool nxagentIsIconic(WindowPtr pWin)
return 0; return 0;
} }
iReturn = GetWindowProperty(pWin, MakeAtom("WM_STATE", 8, False), 0, sizeof(CARD32), False, int iReturn = GetWindowProperty(pWin, MakeAtom("WM_STATE", 8, False), 0, sizeof(CARD32), False,
AnyPropertyType, &atomReturnType, &iReturnFormat, AnyPropertyType, &atomReturnType, &iReturnFormat,
&ulReturnItems, &ulReturnBytesLeft, &pszReturnData); &ulReturnItems, &ulReturnBytesLeft, &pszReturnData);
if (iReturn == Success) if (iReturn == Success)
{ {
...@@ -3734,7 +3711,6 @@ void nxagentDeleteStaticResizedWindow(unsigned long sequence) ...@@ -3734,7 +3711,6 @@ void nxagentDeleteStaticResizedWindow(unsigned long sequence)
StaticResizedWindowStruct *nxagentFindStaticResizedWindow(unsigned long sequence) StaticResizedWindowStruct *nxagentFindStaticResizedWindow(unsigned long sequence)
{ {
StaticResizedWindowStruct *index;
StaticResizedWindowStruct *ret = NULL; StaticResizedWindowStruct *ret = NULL;
if (nxagentStaticResizedWindowList == NULL) if (nxagentStaticResizedWindowList == NULL)
...@@ -3742,7 +3718,7 @@ StaticResizedWindowStruct *nxagentFindStaticResizedWindow(unsigned long sequence ...@@ -3742,7 +3718,7 @@ StaticResizedWindowStruct *nxagentFindStaticResizedWindow(unsigned long sequence
return NULL; return NULL;
} }
index = nxagentStaticResizedWindowList; StaticResizedWindowStruct *index = nxagentStaticResizedWindowList;
while (index && index -> sequence > sequence) while (index && index -> sequence > sequence)
{ {
......
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