Commit 9e6e4313 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Window.c: some code simplifications

parent ea275309
...@@ -721,7 +721,7 @@ void nxagentRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib) ...@@ -721,7 +721,7 @@ void nxagentRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib)
void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn) void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn)
{ {
XEvent e; XEvent e = {0};
if (nxagentOption(Rootless) == 1) if (nxagentOption(Rootless) == 1)
{ {
...@@ -759,8 +759,6 @@ void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn) ...@@ -759,8 +759,6 @@ void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn)
nxagentChangeOption(Fullscreen, switchOn); nxagentChangeOption(Fullscreen, switchOn);
memset(&e, 0, sizeof(e));
e.xclient.type = ClientMessage; e.xclient.type = ClientMessage;
e.xclient.message_type = nxagentAtoms[13]; /* _NET_WM_STATE */ e.xclient.message_type = nxagentAtoms[13]; /* _NET_WM_STATE */
e.xclient.display = nxagentDisplay; e.xclient.display = nxagentDisplay;
...@@ -1066,14 +1064,8 @@ void nxagentUpdateViewportFrame(int x, int y, int w, int h) ...@@ -1066,14 +1064,8 @@ void nxagentUpdateViewportFrame(int x, int y, int w, int h)
void nxagentMoveViewport(ScreenPtr pScreen, int hShift, int vShift) void nxagentMoveViewport(ScreenPtr pScreen, int hShift, int vShift)
{ {
int newX; int newX, newY, oldX = 0, oldY = 0;
int newY;
int oldX;
int oldY;
Bool doMove = False; Bool doMove = False;
oldX = 0;
oldY = 0;
if (nxagentOption(Rootless)) if (nxagentOption(Rootless))
{ {
...@@ -1244,11 +1236,9 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) ...@@ -1244,11 +1236,9 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask)
{ {
unsigned int valuemask; unsigned int valuemask;
XWindowChanges values; XWindowChanges values;
int offX, offY;
int j; int j;
int offX = nxagentWindowPriv(pWin)->x - pWin->origin.x;
offX = nxagentWindowPriv(pWin)->x - pWin->origin.x; int offY = nxagentWindowPriv(pWin)->y - pWin->origin.y;
offY = nxagentWindowPriv(pWin)->y - pWin->origin.y;
if (nxagentScreenTrap == 1) if (nxagentScreenTrap == 1)
{ {
...@@ -1789,9 +1779,7 @@ Bool nxagentChangeWindowAttributes(WindowPtr pWin, unsigned long mask) ...@@ -1789,9 +1779,7 @@ Bool nxagentChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
if (mask & CWColormap) if (mask & CWColormap)
{ {
ColormapPtr pCmap; ColormapPtr pCmap = (ColormapPtr) LookupIDByType(wColormap(pWin), RT_COLORMAP);
pCmap = (ColormapPtr) LookupIDByType(wColormap(pWin), RT_COLORMAP);
/* /*
FIXME: When the caller is nxagentReconfigureWindow FIXME: When the caller is nxagentReconfigureWindow
...@@ -2098,14 +2086,10 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo ...@@ -2098,14 +2086,10 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo
{ {
int i; int i;
XSetWindowAttributes attributes;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentWindowExposures: Initializing expose queue.\n"); fprintf(stderr, "nxagentWindowExposures: Initializing expose queue.\n");
#endif #endif
attributes.event_mask = StructureNotifyMask;
for (i = 0; i < EXPOSED_SIZE; i++) for (i = 0; i < EXPOSED_SIZE; i++)
{ {
nxagentExposeQueue.exposures[i].pWindow = NULL; nxagentExposeQueue.exposures[i].pWindow = NULL;
...@@ -2119,6 +2103,7 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo ...@@ -2119,6 +2103,7 @@ void nxagentWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_expo
nxagentExposeQueue.length = 0; nxagentExposeQueue.length = 0;
nxagentExposeSerial = 0; nxagentExposeSerial = 0;
XSetWindowAttributes attributes = {.event_mask = StructureNotifyMask};
nxagentConfiguredSynchroWindow = XCreateWindow(nxagentDisplay, DefaultRootWindow(nxagentDisplay), 0, 0, nxagentConfiguredSynchroWindow = XCreateWindow(nxagentDisplay, DefaultRootWindow(nxagentDisplay), 0, 0,
1, 1, 0, 0, InputOutput, 0, CWEventMask, &attributes); 1, 1, 0, 0, InputOutput, 0, CWEventMask, &attributes);
...@@ -2423,7 +2408,6 @@ static int nxagentForceExposure(WindowPtr pWin, void * ptr) ...@@ -2423,7 +2408,6 @@ static int nxagentForceExposure(WindowPtr pWin, void * ptr)
if (pWin -> drawable.class != InputOnly) if (pWin -> drawable.class != InputOnly)
{ {
BoxRec Box; BoxRec Box;
RegionPtr exposedRgn;
WindowPtr pRoot = pWin->drawable.pScreen->root; WindowPtr pRoot = pWin->drawable.pScreen->root;
Box.x1 = pWin->drawable.x; Box.x1 = pWin->drawable.x;
...@@ -2431,7 +2415,8 @@ static int nxagentForceExposure(WindowPtr pWin, void * ptr) ...@@ -2431,7 +2415,8 @@ static int nxagentForceExposure(WindowPtr pWin, void * ptr)
Box.x2 = Box.x1 + pWin->drawable.width; Box.x2 = Box.x1 + pWin->drawable.width;
Box.y2 = Box.y1 + pWin->drawable.height; Box.y2 = Box.y1 + pWin->drawable.height;
exposedRgn = RegionCreate(&Box, 1); RegionPtr exposedRgn = RegionCreate(&Box, 1);
RegionIntersect(exposedRgn, exposedRgn, &pRoot->winSize); RegionIntersect(exposedRgn, exposedRgn, &pRoot->winSize);
if (exposedRgn != NULL && RegionNotEmpty(exposedRgn) != 0) if (exposedRgn != NULL && RegionNotEmpty(exposedRgn) != 0)
...@@ -3270,15 +3255,12 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin) ...@@ -3270,15 +3255,12 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin)
if (width && height) if (width && height)
{ {
length = nxagentImageLength(width, height, format, 0, depth); length = nxagentImageLength(width, height, format, 0, depth);
data = malloc(length); 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);
} }
memset(data, 0, length);
image = XGetImage(nxagentDisplay, nxagentWindow(pWin), 0, 0, image = XGetImage(nxagentDisplay, nxagentWindow(pWin), 0, 0,
width, height, plane_mask, format); width, height, plane_mask, format);
if (image == NULL) if (image == NULL)
...@@ -3378,14 +3360,10 @@ Bool nxagentIsIconic(WindowPtr pWin) ...@@ -3378,14 +3360,10 @@ Bool nxagentIsIconic(WindowPtr pWin)
void nxagentSetTopLevelEventMask(WindowPtr pWin) void nxagentSetTopLevelEventMask(WindowPtr pWin)
{ {
unsigned long mask = CWEventMask;
XSetWindowAttributes attributes;
if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin)) if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin))
{ {
attributes.event_mask = nxagentGetEventMask(pWin); XSetWindowAttributes attributes = {.event_mask = nxagentGetEventMask(pWin)};
XChangeWindowAttributes(nxagentDisplay, nxagentWindow(pWin), CWEventMask, &attributes);
XChangeWindowAttributes(nxagentDisplay, nxagentWindow(pWin), mask, &attributes);
} }
} }
...@@ -3541,29 +3519,21 @@ void nxagentAddConfiguredWindow(WindowPtr pWin, unsigned int valuemask) ...@@ -3541,29 +3519,21 @@ void nxagentAddConfiguredWindow(WindowPtr pWin, unsigned int valuemask)
valuemask |= CWStackingOrder; valuemask |= CWStackingOrder;
} }
if (nxagentConfiguredWindowList == NULL)
{ {
ConfiguredWindowStruct *tmp = nxagentConfiguredWindowList;
nxagentConfiguredWindowList = malloc(sizeof(ConfiguredWindowStruct)); nxagentConfiguredWindowList = malloc(sizeof(ConfiguredWindowStruct));
nxagentConfiguredWindowList -> next = NULL; nxagentConfiguredWindowList -> next = tmp; /* can be NULL */
nxagentConfiguredWindowList -> prev = NULL; nxagentConfiguredWindowList -> prev = NULL;
nxagentConfiguredWindowList -> pWin = pWin; nxagentConfiguredWindowList -> pWin = pWin;
} nxagentConfiguredWindowList -> valuemask = valuemask;
else
{
ConfiguredWindowStruct *tmp;
tmp = malloc(sizeof(ConfiguredWindowStruct)); if (tmp)
{
tmp -> next = nxagentConfiguredWindowList; tmp -> prev = nxagentConfiguredWindowList;
nxagentConfiguredWindowList -> prev = tmp; }
tmp -> prev = NULL;
nxagentConfiguredWindowList = tmp;
nxagentConfiguredWindowList -> pWin = pWin;
} }
nxagentConfiguredWindowList -> valuemask = valuemask;
return; return;
} }
...@@ -3623,22 +3593,15 @@ void nxagentDeleteConfiguredWindow(WindowPtr pWin) ...@@ -3623,22 +3593,15 @@ void nxagentDeleteConfiguredWindow(WindowPtr pWin)
void nxagentAddStaticResizedWindow(WindowPtr pWin, unsigned long sequence, int offX, int offY) void nxagentAddStaticResizedWindow(WindowPtr pWin, unsigned long sequence, int offX, int offY)
{ {
if (nxagentStaticResizedWindowList == NULL) StaticResizedWindowStruct *tmp = nxagentStaticResizedWindowList;
{
nxagentStaticResizedWindowList = malloc(sizeof(StaticResizedWindowStruct));
nxagentStaticResizedWindowList -> next = NULL;
nxagentStaticResizedWindowList -> prev = NULL;
}
else
{
StaticResizedWindowStruct *tmp;
tmp = malloc(sizeof(StaticResizedWindowStruct)); nxagentStaticResizedWindowList = malloc(sizeof(StaticResizedWindowStruct));
nxagentStaticResizedWindowList -> next = tmp;
nxagentStaticResizedWindowList -> prev = NULL;
tmp -> next = nxagentStaticResizedWindowList; if (tmp)
nxagentStaticResizedWindowList -> prev = tmp; {
tmp -> prev = NULL; tmp -> prev = nxagentStaticResizedWindowList;
nxagentStaticResizedWindowList = tmp;
} }
nxagentStaticResizedWindowList -> pWin = pWin; nxagentStaticResizedWindowList -> pWin = pWin;
......
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