aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Binder.c29
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c1
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Client.c72
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Colormap.c10
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Composite.c27
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Cursor.c233
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Dialog.c47
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Display.c478
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Drawable.c777
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Error.c44
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.c927
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Font.c93
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/GC.c210
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/GCOps.c314
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Handlers.c208
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Image.c521
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Init.c101
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keyboard.c107
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c5
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Options.c21
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Options.h194
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Pixels.c21
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Pointer.c35
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Split.c129
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Visual.c55
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Visual.h16
26 files changed, 1793 insertions, 2882 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Binder.c b/nx-X11/programs/Xserver/hw/nxagent/Binder.c
index 1a6c4e969..518c016c4 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Binder.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Binder.c
@@ -46,19 +46,13 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
{
if (++i < argc)
{
- char *display;
- char *found;
-
- int port;
-
- display = argv[i];
+ char *display = argv[i];
/*
- * Check if a display specification follows
- * the -B switch.
+ * Check if a display specification follows the -B switch.
*/
- found = rindex(display, ':');
+ char *found = rindex(display, ':');
if (found == NULL || *(found + 1) == '\0' ||
isdigit(*(found + 1)) == 0)
@@ -69,7 +63,7 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
return 0;
}
- port = atoi(found + 1);
+ int port = atoi(found + 1);
#ifdef TEST
fprintf(stderr, "nxagentCheckBinder: Identified agent display port [%d].\n",
@@ -78,8 +72,8 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
/*
* The NX options must be specified in the DISPLAY
- * environment. Check if the display specified on
- * the command line matches the NX virtual display.
+ * environment. Check if the display specified on the command line
+ * matches the NX virtual display.
*/
display = getenv("DISPLAY");
@@ -108,8 +102,8 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
#endif
/*
- * Save the proxy options. They will be later
- * used to create the transport.
+ * Save the proxy options. They will be later used to create the
+ * transport.
*/
nxagentChangeOption(Rootless, False);
@@ -117,10 +111,9 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
nxagentChangeOption(Binder, True);
/*
- * FIXME: This now points to the buffer that was
- * returned by getenv(). It is to be decided how
- * to handle the values of type string in the
- * Options repository.
+ * FIXME: This now points to the buffer that was returned by
+ * getenv(). It is to be decided how to handle the values of type
+ * string in the Options repository.
*/
nxagentChangeOption(BinderOptions, display);
diff --git a/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c b/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c
index b889d2a62..567c1c302 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c
@@ -115,4 +115,3 @@ nxagentFourByteSwap(unsigned char *buf, int nbytes)
buf[2] = c;
}
}
-
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.c b/nx-X11/programs/Xserver/hw/nxagent/Client.c
index 6ea0c4fcf..e04a03dc1 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Client.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Client.c
@@ -54,8 +54,7 @@
#include "Utils.h"
/*
- * Need to include this after the stub
- * definition of GC in Agent.h.
+ * Need to include this after the stub definition of GC in Agent.h.
*/
#include "compext/Compext.h"
@@ -70,22 +69,20 @@
#undef DEBUG
/*
- * Returns the last signal delivered
- * to the process.
+ * Returns the last signal delivered to the process.
*/
extern int _X11TransSocketCheckSignal(void);
/*
- * Time in milliseconds of first iteration
- * through the dispatcher.
+ * Time in milliseconds of first iteration through the dispatcher.
*/
unsigned long nxagentStartTime = -1;
/*
- * If defined, add a function checking if we
- * need a null timeout after a client wakeup.
+ * If defined, add a function checking if we need a null timeout after
+ * a client wakeup.
*/
#undef CHECK_RESTARTED_CLIENTS
@@ -103,8 +100,8 @@ void nxagentCheckRestartedClients(struct timeval **timeout);
int nxagentClientPrivateIndex;
/*
- * The master nxagent holds in nxagentShadowCounter
- * the number of shadow nxagents connected to itself.
+ * The master nxagent holds in nxagentShadowCounter the number of
+ * shadow nxagents connected to itself.
*/
int nxagentShadowCounter = 0;
@@ -120,8 +117,8 @@ void nxagentInitClientPrivates(ClientPtr client)
}
/*
- * Guess the running application based on the
- * properties attached to its main window.
+ * Guess the running application based on the properties attached to
+ * its main window.
*/
void nxagentGuessClientHint(ClientPtr client, Atom property, char *data)
@@ -199,8 +196,8 @@ void nxagentGuessShadowHint(ClientPtr client, Atom property)
#endif
/*
- * From this moment on we ignore the visibility
- * checks to keep the windows updated.
+ * From this moment on we ignore the visibility checks to keep
+ * the windows updated.
*/
nxagentChangeOption(IgnoreVisibility, 1);
@@ -210,7 +207,6 @@ void nxagentGuessShadowHint(ClientPtr client, Atom property)
void nxagentCheckIfShadowAgent(ClientPtr client)
{
-
if (nxagentClientPriv(client) -> clientHint == NXAGENT_SHADOW)
{
#ifdef TEST
@@ -234,14 +230,11 @@ void nxagentCheckIfShadowAgent(ClientPtr client)
nxagentShadowCounter);
#endif
-
if (nxagentShadowCounter == 0)
{
/*
- * The last shadow nxagent has been detached
- * from master nxagent.
- * The master nxagent could do some action
- * here.
+ * The last shadow nxagent has been detached from master
+ * nxagent. The master nxagent could do some action here.
*/
#ifdef TEST
@@ -255,13 +248,11 @@ void nxagentCheckIfShadowAgent(ClientPtr client)
void nxagentWakeupByReconnect(void)
{
- int i;
-
#ifdef TEST
fprintf(stderr, "++++++nxagentWakeupByReconnect: Going to wakeup all clients.\n");
#endif
- for (i = 1; i < currentMaxClients; i++)
+ for (int i = 1; i < currentMaxClients; i++)
{
if (clients[i] != NULL)
{
@@ -343,8 +334,7 @@ void nxagentWaitWakeupBySplit(ClientPtr client)
#endif
/*
- * Be sure we intercept an I/O error
- * as well as an interrupt.
+ * Be sure we intercept an I/O error as well as an interrupt.
*/
#ifdef USE_FINISH_SPLIT
@@ -358,11 +348,9 @@ void nxagentWaitWakeupBySplit(ClientPtr client)
for (;;)
{
/*
- * Can we handle all the possible events here
- * or we need to select only the split events?
- * Handling all the possible events would pre-
- * empt the queue and make a better use of the
- * link.
+ * Can we handle all the possible events here or we need to select
+ * only the split events? Handling all the possible events would
+ * preempt the queue and make a better use of the link.
*/
#ifdef WAIT_ALL_EVENTS
@@ -407,9 +395,9 @@ void nxagentWaitWakeupBySplit(ClientPtr client)
int nxagentSuspendBySplit(ClientPtr client)
{
/*
-FIXME: Should record a serial number for the client, so that
- the client is not restarted because of an end of split
- of a previous client with the same index.
+FIXME: Should record a serial number for the client, so that the
+ client is not restarted because of an end of split of a
+ previous client with the same index.
*/
if (client -> index < MAX_CONNECTIONS)
{
@@ -453,9 +441,9 @@ FIXME: Should record a serial number for the client, so that
int nxagentWakeupBySplit(ClientPtr client)
{
/*
-FIXME: Should record a serial number for the client, so that
- the client is not restarted because of the end of the
- split for a previous client with the same index.
+FIXME: Should record a serial number for the client, so that the
+ client is not restarted because of the end of the split for a
+ previous client with the same index.
*/
if (client -> index < MAX_CONNECTIONS)
{
@@ -498,16 +486,13 @@ void nxagentCheckRestartedClients(struct timeval **timeout)
{
static struct timeval zero;
- int i;
-
/*
- * If any of the restarted clients had requests
- * in input we'll need to enter the select with
- * a null timeout, or we will block until any
- * other client becomes available.
+ * If any of the restarted clients had requests in input we'll need
+ * to enter the select with a null timeout, or we will block until
+ * any other client becomes available.
*/
- for (i = 1; i < currentMaxClients; i++)
+ for (int i = 1; i < currentMaxClients; i++)
{
if (clients[i] != NULL && clients[i] -> osPrivate != NULL &&
nxagentNeedWakeup(clients[i]) == 0)
@@ -542,5 +527,4 @@ void nxagentCheckRestartedClients(struct timeval **timeout)
}
}
}
-
#endif
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c
index b04977887..9308390fe 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c
@@ -296,12 +296,10 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
*/
if (icws.numWindows)
{
- WindowPtr pWin;
- Visual *visual;
ColormapPtr pCmap;
- pWin = nxagentWindowPtr(icws.windows[0]);
- visual = nxagentVisualFromID(pScreen, wVisual(pWin));
+ WindowPtr pWin = nxagentWindowPtr(icws.windows[0]);
+ Visual *visual = nxagentVisualFromID(pScreen, wVisual(pWin));
if (visual == nxagentDefaultVisual(pScreen))
pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin),
@@ -380,9 +378,7 @@ void nxagentDirectUninstallColormaps(ScreenPtr pScreen)
int n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs);
for (int i = 0; i < n; i++) {
- ColormapPtr pCmap;
-
- pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP);
+ ColormapPtr pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP);
if (pCmap)
XUninstallColormap(nxagentDisplay, nxagentColormap(pCmap));
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Composite.c b/nx-X11/programs/Xserver/hw/nxagent/Composite.c
index e48671879..af29f8ebc 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Composite.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Composite.c
@@ -44,8 +44,7 @@
#undef DEBUG
/*
- * Set if the composite extension is supported
- * by the remote display.
+ * Set if the composite extension is supported by the remote display.
*/
int nxagentCompositeEnable = UNDEFINED;
@@ -53,8 +52,7 @@ int nxagentCompositeEnable = UNDEFINED;
void nxagentCompositeExtensionInit(void)
{
/*
- * Set the flag only if the initialization
- * completes.
+ * Set the flag only if the initialization completes.
*/
nxagentCompositeEnable = 0;
@@ -70,8 +68,8 @@ void nxagentCompositeExtensionInit(void)
if (XCompositeQueryExtension(nxagentDisplay, &eventBase, &errorBase) == 1)
{
/*
- * At the moment we don't need to care
- * the version of the extension.
+ * At the moment we don't need to care the version of the
+ * extension.
*/
#ifdef TEST
@@ -117,8 +115,6 @@ void nxagentCompositeExtensionInit(void)
void nxagentRedirectDefaultWindows(void)
{
- int i;
-
if (nxagentOption(Rootless) == 1 ||
nxagentCompositeEnable == 0)
{
@@ -131,7 +127,7 @@ void nxagentRedirectDefaultWindows(void)
return;
}
- for (i = 0; i < screenInfo.numScreens; i++)
+ for (int i = 0; i < screenInfo.numScreens; i++)
{
WindowPtr pWin = screenInfo.screens[i]->root;
@@ -143,13 +139,12 @@ void nxagentRedirectDefaultWindows(void)
#endif
/*
- * When trying to redirect only the top level window,
- * and not the subwindows, we incur in a strange be-
- * haviour. The top level is unmapped, mapped, unmap-
- * ped and then reparented. This at first makes the
- * agent think that the window manager is gone, then
- * the agent window disappears. To make thinks even
- * more weird, this happens only at reconnection.
+ * When trying to redirect only the top level window, and not the
+ * subwindows, we incur in a strange be- haviour. The top level is
+ * unmapped, mapped, unmap- ped and then reparented. This at first
+ * makes the agent think that the window manager is gone, then the
+ * agent window disappears. To make thinks even more weird, this
+ * happens only at reconnection.
*/
XCompositeRedirectSubwindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c
index 75382d4e8..0c667a00c 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c
@@ -78,10 +78,8 @@ is" without express or implied warranty.
#undef DEBUG
/*
- * Defined in Display.c. There are huge
- * problems mixing the GC definition in
- * Xlib with the server code. This must
- * be reworked.
+ * Defined in Display.c. There are huge problems mixing the GC
+ * definition in Xlib with the server code. This must be reworked.
*/
extern XlibGC nxagentBitmapGC;
@@ -95,24 +93,20 @@ extern CursorPtr GetSpriteCursor(void);
void nxagentConstrainCursor(ScreenPtr pScreen, BoxPtr pBox)
{
#ifdef TEST
-
- int width, height;
-
- width = nxagentOption(RootWidth);
- height = nxagentOption(RootHeight);
+ int width = nxagentOption(RootWidth);
+ int height = nxagentOption(RootHeight);
if (pBox->x1 <= 0 && pBox->y1 <= 0 &&
pBox->x2 >= width && pBox->y2 >= height)
{
- fprintf(stderr, "nxagentConstrainCursor: Called with box [%d,%d,%d,%d]. "
- "Skipping the operation.\n", pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ fprintf(stderr, "%s: Called with box [%d,%d,%d,%d]. Skipping the operation.\n",
+ __func__, pBox->x1, pBox->y1, pBox->x2, pBox->y2);
}
else
{
- fprintf(stderr, "nxagentConstrainCursor: WARNING! Called with box [%d,%d,%d,%d].\n",
+ fprintf(stderr, "%s: WARNING! Called with box [%d,%d,%d,%d].\n", __func__,
pBox->x1, pBox->y1, pBox->x2, pBox->y2);
}
-
#endif
}
@@ -124,16 +118,12 @@ void nxagentCursorLimits(ScreenPtr pScreen, CursorPtr pCursor,
Bool nxagentDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor)
{
-
/*
- * Don't define the root cursor
- * so that nxagent root window
- * inherits the parent's cursor.
+ * Don't define the root cursor so that nxagent root window inherits
+ * the parent's cursor.
*/
- Cursor cursor;
-
- cursor = (pCursor != rootCursor) ? nxagentCursor(pCursor, pScreen): None;
+ Cursor cursor = (pCursor != rootCursor) ? nxagentCursor(pCursor, pScreen): None;
if (nxagentOption(Rootless) == False)
{
@@ -142,7 +132,7 @@ Bool nxagentDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor)
cursor);
#ifdef TEST
- fprintf(stderr, "nxagentDisplayCursor: Called for cursor at [%p] with private [%p].\n",
+ fprintf(stderr, "%s: Called for cursor at [%p] with private [%p].\n", __func__,
(void *) pCursor, pCursor->devPriv[pScreen->myNum]);
#endif
}
@@ -152,56 +142,46 @@ Bool nxagentDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor)
Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
{
- XImage *image;
- Pixmap source, mask;
- XColor fg_color, bg_color;
- unsigned long valuemask;
- XGCValues values;
-
#ifdef TEST
- fprintf(stderr, "nxagentRealizeCursor: Called for cursor at [%p].\n", (void *) pCursor);
+ fprintf(stderr, "%s: Called for cursor at [%p].\n", __func__, (void *) pCursor);
#endif
- valuemask = GCFunction |
- GCPlaneMask |
- GCForeground |
- GCBackground |
- GCClipMask;
+ unsigned long valuemask = GCFunction | GCPlaneMask | GCForeground | GCBackground | GCClipMask;
- values.function = GXcopy;
- values.plane_mask = AllPlanes;
- values.foreground = 1L;
- values.background = 0L;
- values.clip_mask = None;
+ XGCValues values = {
+ .function = GXcopy,
+ .plane_mask = AllPlanes,
+ .foreground = 1L,
+ .background = 0L,
+ .clip_mask = None,
+ };
XChangeGC(nxagentDisplay, nxagentBitmapGC, valuemask, &values);
- source = XCreatePixmap(nxagentDisplay,
- nxagentDefaultWindows[pScreen->myNum],
- pCursor->bits->width,
- pCursor->bits->height,
- 1);
-
- mask = XCreatePixmap(nxagentDisplay,
- nxagentDefaultWindows[pScreen->myNum],
- pCursor->bits->width,
- pCursor->bits->height,
- 1);
-
- image = XCreateImage(nxagentDisplay,
- nxagentDefaultVisual(pScreen),
- 1, XYBitmap, 0,
- (char *)pCursor->bits->source,
- pCursor->bits->width,
- pCursor->bits->height,
- BitmapPad(nxagentDisplay), 0);
+ Pixmap source = XCreatePixmap(nxagentDisplay,
+ nxagentDefaultWindows[pScreen->myNum],
+ pCursor->bits->width,
+ pCursor->bits->height,
+ 1);
+
+ Pixmap mask = XCreatePixmap(nxagentDisplay,
+ nxagentDefaultWindows[pScreen->myNum],
+ pCursor->bits->width,
+ pCursor->bits->height,
+ 1);
+
+ XImage *image = XCreateImage(nxagentDisplay,
+ nxagentDefaultVisual(pScreen),
+ 1, XYBitmap, 0,
+ (char *)pCursor->bits->source,
+ pCursor->bits->width,
+ pCursor->bits->height,
+ BitmapPad(nxagentDisplay), 0);
/*
- * If we used nxagentImageNormalize() here,
- * we'd swap our own cursor data in place.
- * Change byte_order and bitmap_bit_order
- * in the image struct to let Xlib do the
- * swap for us.
+ * If we used nxagentImageNormalize() here, we'd swap our own cursor
+ * data in place. Change byte_order and bitmap_bit_order in the
+ * image struct to let Xlib do the swap for us.
*/
image -> byte_order = IMAGE_BYTE_ORDER;
@@ -232,13 +212,17 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
SAFE_XFree(image);
- fg_color.red = pCursor->foreRed;
- fg_color.green = pCursor->foreGreen;
- fg_color.blue = pCursor->foreBlue;
+ XColor fg_color = {
+ .red = pCursor->foreRed,
+ .green = pCursor->foreGreen,
+ .blue = pCursor->foreBlue,
+ };
- bg_color.red = pCursor->backRed;
- bg_color.green = pCursor->backGreen;
- bg_color.blue = pCursor->backBlue;
+ XColor bg_color = {
+ .red = pCursor->backRed,
+ .green = pCursor->backGreen,
+ .blue = pCursor->backBlue,
+ };
pCursor->devPriv[pScreen->myNum] = (void *) malloc(sizeof(nxagentPrivCursor));
@@ -249,7 +233,7 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
nxagentCursorUsesRender(pCursor, pScreen) = 0;
#ifdef TEST
- fprintf(stderr, "nxagentRealizeCursor: Set cursor private at [%p] cursor is [%ld].\n",
+ fprintf(stderr, "%s: Set cursor private at [%p] cursor is [%ld].\n", __func__,
(void *) nxagentCursorPriv(pCursor, pScreen),
nxagentCursorPriv(pCursor, pScreen) -> cursor);
#endif
@@ -282,15 +266,17 @@ Bool nxagentUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
void nxagentRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor,
Bool displayed)
{
- XColor fg_color, bg_color;
-
- fg_color.red = pCursor->foreRed;
- fg_color.green = pCursor->foreGreen;
- fg_color.blue = pCursor->foreBlue;
-
- bg_color.red = pCursor->backRed;
- bg_color.green = pCursor->backGreen;
- bg_color.blue = pCursor->backBlue;
+ XColor fg_color = {
+ .red = pCursor->foreRed,
+ .green = pCursor->foreGreen,
+ .blue = pCursor->foreBlue,
+ };
+
+ XColor bg_color = {
+ .red = pCursor->backRed,
+ .green = pCursor->backGreen,
+ .blue = pCursor->backBlue,
+ };
XRecolorCursor(nxagentDisplay,
nxagentCursor(pCursor, pScreen),
@@ -310,10 +296,9 @@ Bool nxagentSetCursorPosition(ScreenPtr pScreen, int x, int y,
else
{
/*
- * Calling miSetCursorPosition with generateEvent == 0
- * causes a crash in miPoiterUpdate().
+ * Calling miSetCursorPosition with generateEvent == 0 causes a
+ * crash in miPoiterUpdate().
*/
-
return 1;
}
}
@@ -323,15 +308,8 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2)
Bool* pBool = (Bool*)p2;
CursorPtr pCursor = (CursorPtr) p0;
- AnimCurPtr ac;
- int j;
-
- #ifdef TEST
- fprintf(stderr, "nxagentReconnectCursor: pCursor at [%p]\n", pCursor);
- #endif
-
- #ifdef NXAGENT_RECONNECT_CURSOR_DEBUG
- fprintf(stderr, "nxagentReconnectCursor: pCursor at [%p]\n", pCursor);
+ #if defined( TEST) || defined(NXAGENT_RECONNECT_CURSOR_DEBUG)
+ fprintf(stderr, "%s: pCursor at [%p]\n", __func__, pCursor);
#endif
if (!*pBool || !pCursor)
@@ -344,22 +322,21 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2)
if (nxagentIsAnimCursor(pCursor))
{
#ifdef TEST
- fprintf(stderr, "nxagentReconnectCursor: nxagentIsAnimCursor pCursor at [%p]\n", pCursor);
+ fprintf(stderr, "%s: nxagentIsAnimCursor pCursor at [%p]\n", __func__, pCursor);
#endif
- ac = nxagentGetAnimCursor(pCursor);
+ AnimCurPtr ac = nxagentGetAnimCursor(pCursor);
- for (j = 0; j < ac->nelt; j++)
+ for (int j = 0; j < ac->nelt; j++)
{
nxagentReconnectCursor (ac->elts[j].pCursor, x1, p2);
#ifdef TEST
- fprintf(stderr, "nxagentReconnectCursor: Iteration [%d] pCursor at [%p]\n", j, ac->elts[j].pCursor);
+ fprintf(stderr, "%s: Iteration [%d] pCursor at [%p]\n", __func__, j, ac->elts[j].pCursor);
#endif
}
}
}
-
else
{
if (nxagentCursorUsesRender(pCursor, nxagentDefaultScreen))
@@ -376,14 +353,14 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2)
free(nxagentCursorPriv(pCursor, nxagentDefaultScreen));
if (!nxagentRealizeCursor(nxagentDefaultScreen, pCursor))
{
- fprintf(stderr, "nxagentReconnectCursor: nxagentRealizeCursor failed\n");
+ fprintf(stderr, "%s: nxagentRealizeCursor failed\n", __func__);
*pBool = False;
}
}
}
#ifdef NXAGENT_RECONNECT_CURSOR_DEBUG
- fprintf(stderr, "nxagentReconnectCursor: %p - ID %lx\n", pCursor, nxagentCursor(pCursor, nxagentDefaultScreen));
+ fprintf(stderr, "%s: %p - ID %lx\n", __func__, pCursor, nxagentCursor(pCursor, nxagentDefaultScreen));
#endif
}
@@ -405,29 +382,26 @@ void nxagentReDisplayCurrentCursor(void)
Bool nxagentReconnectAllCursor(void *p0)
{
- int i;
Bool r = True;
GrabPtr grab = inputInfo.pointer -> grab;
#if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_CURSOR_DEBUG)
- fprintf(stderr, "nxagentReconnectAllCursor\n");
+ fprintf(stderr, "%s\n", __func__);
#endif
- for (i = 0, r = 1; i < MAXCLIENTS; r = 1, i++)
+ for (int i = 0; i < MAXCLIENTS; r = 1, i++)
{
if (clients[i])
{
FindClientResourcesByType(clients[i], RT_CURSOR, nxagentReconnectCursor, &r);
#ifdef WARNING
-
if (r == False)
{
- fprintf(stderr, "nxagentReconnectAllCursor: WARNING! Failed to recreate "
- "cursor for client [%d].\n", i);
+ fprintf(stderr, "%s: WARNING! Failed to recreate "
+ "cursor for client [%d].\n", __func__, i);
}
-
#endif
}
}
@@ -445,9 +419,6 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2)
Bool* pBool = (Bool *) p2;
CursorPtr pCursor = (CursorPtr) p0;
- AnimCurPtr ac;
- int j;
-
if (!*pBool || !pCursor)
{
return;
@@ -458,17 +429,17 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2)
if (nxagentIsAnimCursor(pCursor))
{
#ifdef TEST
- fprintf(stderr, "nxagentDisconnectCursor: nxagentIsAnimCursor pCursor at [%p]\n", pCursor);
+ fprintf(stderr, "%s: nxagentIsAnimCursor pCursor at [%p]\n", __func__, pCursor);
#endif
- ac = nxagentGetAnimCursor(pCursor);
+ AnimCurPtr ac = nxagentGetAnimCursor(pCursor);
- for (j = 0; j < ac->nelt; j++)
+ for (int j = 0; j < ac->nelt; j++)
{
nxagentDisconnectCursor (ac->elts[j].pCursor, x1, p2);
#ifdef TEST
- fprintf(stderr, "nxagentDisconnectCursor: Iteration [%d] pCursor at [%p]\n", j, ac->elts[j].pCursor);
+ fprintf(stderr, "%s: Iteration [%d] pCursor at [%p]\n", __func__, j, ac->elts[j].pCursor);
#endif
}
}
@@ -476,29 +447,28 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2)
}
#ifdef NXAGENT_RECONNECT_CURSOR_DEBUG
- fprintf(stderr, "nxagentDisconnectCursor: %p - ID %lx\n",
- pCursor,
- nxagentCursor(pCursor, nxagentDefaultScreen));
+ fprintf(stderr, "%s: %p - ID %lx\n", __func__, pCursor,
+ nxagentCursor(pCursor, nxagentDefaultScreen));
#endif
#ifdef TEST
- fprintf(stderr, "nxagentDisconnectCursor: Called with bool [%d].\n", *pBool);
+ fprintf(stderr, "%s: Called with bool [%d].\n", __func__, *pBool);
- fprintf(stderr, "nxagentDisconnectCursor: Pointer to cursor is [%p] with counter [%d].\n",
+ fprintf(stderr, "%s: Pointer to cursor is [%p] with counter [%d].\n", __func__,
(void *) pCursor, pCursor -> refcnt);
- fprintf(stderr, "nxagentDisconnectCursor: Dummy screen is at [%p].\n",
+ fprintf(stderr, "%s: Dummy screen is at [%p].\n", __func__,
(void *) nxagentDefaultScreen);
- fprintf(stderr, "nxagentDisconnectCursor: Cursor private is at [%p].\n",
+ fprintf(stderr, "%s: Cursor private is at [%p].\n", __func__,
(void *) nxagentCursorPriv(pCursor, nxagentDefaultScreen));
#endif
#ifdef TEST
- fprintf(stderr, "nxagentDisconnectCursor: Dummy screen number is [%d].\n",
+ fprintf(stderr, "%s: Dummy screen number is [%d].\n", __func__,
nxagentDefaultScreen -> myNum);
- fprintf(stderr, "nxagentDisconnectCursor: Cursor is [%ld].\n",
+ fprintf(stderr, "%s: Cursor is [%ld].\n", __func__,
nxagentCursor(pCursor, nxagentDefaultScreen));
#endif
@@ -510,7 +480,7 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2)
int ret = 1;
#if defined(NXAGENT_RECONNECT_CURSOR_DEBUG) || defined(NXAGENT_RECONNECT_PICTURE_DEBUG)
- fprintf(stderr, "nxagentDisconnectCursor: disconnecting attached picture %p\n", pPicture);
+ fprintf(stderr, "%s: disconnecting attached picture %p\n", __func__, pPicture);
#endif
nxagentDisconnectPicture(pPicture, 0, &ret);
@@ -519,29 +489,26 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2)
Bool nxagentDisconnectAllCursor(void)
{
- int i;
Bool r = True;
GrabPtr grab = inputInfo.pointer -> grab;
#ifdef TEST
- fprintf(stderr, "nxagentDisconnectAllCursor: Going to iterate through cursor resources.\n");
+ fprintf(stderr, "%s: Going to iterate through cursor resources.\n", __func__);
#endif
- for (i = 0, r = 1; i < MAXCLIENTS; r = 1, i++)
+ for (int i = 0; i < MAXCLIENTS; r = 1, i++)
{
if (clients[i])
{
FindClientResourcesByType(clients[i], RT_CURSOR, nxagentDisconnectCursor, &r);
#ifdef WARNING
-
if (r == False)
{
- fprintf(stderr, "nxagentDisconnectAllCursor: WARNING! Failed to disconnect "
- "cursor for client [%d].\n", i);
+ fprintf(stderr, "%s: WARNING! Failed to disconnect "
+ "cursor for client [%d].\n", __func__, i);
}
-
#endif
}
}
@@ -572,23 +539,19 @@ void nxagentListCursor(void *p0, void *p1, void *p2)
void nxagentListCursors(void)
{
- int i;
- Bool r;
+ Bool r = True;
- for (i = 0, r = 1; i < MAXCLIENTS; r = 1, i++)
+ for (int i = 0; i < MAXCLIENTS; r = 1, i++)
{
if (clients[i])
{
FindClientResourcesByType(clients[i], RT_CURSOR, nxagentListCursor, &r);
#ifdef WARNING
-
if (r == False)
{
- fprintf(stderr, "nxagentListCursors: WARNING! Failed to list "
- "cursor for client [%d].\n", i);
+ fprintf(stderr, "%s: WARNING! Failed to list cursor for client [%d].\n", __func__, i);
}
-
#endif
}
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c
index 0dcdda5a4..c20a6a475 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c
@@ -198,7 +198,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_KILL_SESSION_TYPE;
local = DIALOG_KILL_SESSION_LOCAL;
pid = &nxagentKillDialogPid;
-
break;
}
case DIALOG_SUSPEND_SESSION:
@@ -207,7 +206,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_SUSPEND_SESSION_TYPE;
local = DIALOG_SUSPEND_SESSION_LOCAL;
pid = &nxagentSuspendDialogPid;
-
break;
}
case DIALOG_ROOTLESS:
@@ -216,7 +214,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_ROOTLESS_TYPE;
local = DIALOG_ROOTLESS_LOCAL;
pid = &nxagentRootlessDialogPid;
-
break;
}
case DIALOG_PULLDOWN:
@@ -226,7 +223,6 @@ void nxagentLaunchDialog(DialogType dialogType)
local = DIALOG_PULLDOWN_LOCAL;
pid = &nxagentPulldownDialogPid;
window = nxagentPulldownWindow;
-
break;
}
case DIALOG_FONT_REPLACEMENT:
@@ -235,7 +231,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_FONT_REPLACEMENT_TYPE;
local = DIALOG_FONT_REPLACEMENT_LOCAL;
pid = &nxagentFontsReplacementDialogPid;
-
break;
}
case DIALOG_FAILED_RECONNECTION:
@@ -244,7 +239,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_FAILED_RECONNECTION_TYPE;
local = DIALOG_FAILED_RECONNECTION_LOCAL;
pid = &nxagentFailedReconnectionDialogPid;
-
break;
}
case DIALOG_ENABLE_DESKTOP_RESIZE_MODE:
@@ -253,7 +247,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_TYPE;
local = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_LOCAL;
pid = &nxagentEnableRandRModeDialogPid;
-
break;
}
case DIALOG_DISABLE_DESKTOP_RESIZE_MODE:
@@ -262,7 +255,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_TYPE;
local = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_LOCAL;
pid = &nxagentDisableRandRModeDialogPid;
-
break;
}
case DIALOG_ENABLE_DEFER_MODE:
@@ -271,7 +263,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_ENABLE_DEFER_MODE_TYPE;
local = DIALOG_ENABLE_DEFER_MODE_LOCAL;
pid = &nxagentEnableDeferModePid;
-
break;
}
case DIALOG_DISABLE_DEFER_MODE:
@@ -280,7 +271,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_DISABLE_DEFER_MODE_TYPE;
local = DIALOG_DISABLE_DEFER_MODE_LOCAL;
pid = &nxagentDisableDeferModePid;
-
break;
}
case DIALOG_ENABLE_AUTOGRAB_MODE:
@@ -289,7 +279,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_ENABLE_AUTOGRAB_MODE_TYPE;
local = DIALOG_ENABLE_AUTOGRAB_MODE_LOCAL;
pid = &nxagentEnableAutograbModePid;
-
break;
}
case DIALOG_DISABLE_AUTOGRAB_MODE:
@@ -298,7 +287,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_DISABLE_AUTOGRAB_MODE_TYPE;
local = DIALOG_DISABLE_AUTOGRAB_MODE_LOCAL;
pid = &nxagentDisableAutograbModePid;
-
break;
}
default:
@@ -306,7 +294,6 @@ void nxagentLaunchDialog(DialogType dialogType)
#ifdef WARNING
fprintf(stderr, "nxagentLaunchDialog: Unknown Dialog type [%d].\n", dialogType);
#endif
-
return;
}
}
@@ -325,8 +312,7 @@ void nxagentLaunchDialog(DialogType dialogType)
}
/*
- * We don't want to receive SIGCHLD
- * before we store the child pid.
+ * We don't want to receive SIGCHLD before we store the child pid.
*/
sigemptyset(&set);
@@ -346,8 +332,7 @@ void nxagentLaunchDialog(DialogType dialogType)
dialogDisplay[0] = '\0';
/*
- * Restore the previous set of
- * blocked signal.
+ * Restore the previous set of blocked signal.
*/
sigprocmask(SIG_SETMASK, &oldSet, NULL);
@@ -385,17 +370,16 @@ void nxagentFailedReconnectionDialog(int alert, char *error)
NXTransAlert(alert, NX_ALERT_REMOTE);
/*
- * Make it possible to interrupt the
- * loop with a signal.
+ * Make it possible to interrupt the loop with a signal.
*/
while (NXDisplayError(nxagentDisplay) == 0 &&
NXTransRunning(NX_FD_ANY) == 1)
{
- struct timeval timeout;
-
- timeout.tv_sec = 30;
- timeout.tv_usec = 0;
+ struct timeval timeout = {
+ .tv_sec = 30,
+ .tv_usec = 0,
+ };
NXTransContinue(&timeout);
}
@@ -477,73 +461,61 @@ void nxagentTerminateDialog(DialogType type)
case DIALOG_KILL_SESSION:
{
pid = nxagentKillDialogPid;
-
break;
}
case DIALOG_SUSPEND_SESSION:
{
pid = nxagentSuspendDialogPid;
-
break;
}
case DIALOG_ROOTLESS:
{
pid = nxagentRootlessDialogPid;
-
break;
}
case DIALOG_PULLDOWN:
{
pid = nxagentPulldownDialogPid;
-
break;
}
case DIALOG_FONT_REPLACEMENT:
{
pid = nxagentFontsReplacementDialogPid;
-
break;
}
case DIALOG_FAILED_RECONNECTION:
{
pid = nxagentFailedReconnectionDialogPid;
-
break;
}
case DIALOG_ENABLE_DESKTOP_RESIZE_MODE:
{
pid = nxagentEnableRandRModeDialogPid;
-
break;
}
case DIALOG_DISABLE_DESKTOP_RESIZE_MODE:
{
pid = nxagentDisableRandRModeDialogPid;
-
break;
}
case DIALOG_ENABLE_DEFER_MODE:
{
pid = nxagentEnableDeferModePid;
-
break;
}
case DIALOG_DISABLE_DEFER_MODE:
{
pid = nxagentDisableDeferModePid;
-
break;
}
case DIALOG_ENABLE_AUTOGRAB_MODE:
{
pid = nxagentEnableAutograbModePid;
-
break;
}
case DIALOG_DISABLE_AUTOGRAB_MODE:
{
pid = nxagentDisableAutograbModePid;
-
break;
}
default:
@@ -551,7 +523,6 @@ void nxagentTerminateDialog(DialogType type)
#ifdef WARNING
fprintf(stderr, "nxagentTerminateDialog: Unknown dialog type [%d].\n", type);
#endif
-
return;
}
}
@@ -577,13 +548,11 @@ void nxagentTerminateDialog(DialogType type)
void nxagentTerminateDialogs(void)
{
- DialogType type;
-
#ifdef DEBUG
fprintf(stderr, "nxagentTerminateDialogs: Terminating all the running dialogs.\n");
#endif
- for (type = DIALOG_FIRST_TAG; type < DIALOG_LAST_TAG; type++)
+ for (DialogType type = DIALOG_FIRST_TAG; type < DIALOG_LAST_TAG; type++)
{
nxagentTerminateDialog(type);
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c
index 6d62a978f..a93fd2418 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Display.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c
@@ -152,8 +152,8 @@ Drawable nxagentDefaultDrawables[MAXDEPTH + 1];
Pixmap nxagentScreenSaverPixmap;
/*
- * Also used in Cursor.c. There are huge problems
- * using GC definition. This is to be reworked.
+ * Also used in Cursor.c. There are huge problems using GC
+ * definition. This is to be reworked.
*/
XlibGC nxagentBitmapGC;
@@ -212,20 +212,18 @@ int nxagentServerOrder(void)
}
/*
- * FIXME: This error handler is not printing anything
- * in the session log. This is OK once the session is
- * started, because the error is handled by the other
- * layers, but not before that point, as the agent
- * would die without giving any feedback to the user
- * (or, worse, to the NX server). We should check how
- * many requests have been handled for this display
- * and print a message if the display dies before the
- * session is up and running.
+ * FIXME: This error handler is not printing anything in the session
+ * log. This is OK once the session is started, because the error is
+ * handled by the other layers, but not before that point, as the
+ * agent would die without giving any feedback to the user (or, worse,
+ * to the NX server). We should check how many requests have been
+ * handled for this display and print a message if the display dies
+ * before the session is up and running.
*/
/*
- * FIXME: This should be moved to Error.c, The other
- * handlers should be probably moved to Handlers.c.
+ * FIXME: This should be moved to Error.c, The other handlers should
+ * be probably moved to Handlers.c.
*/
int nxagentIOErrorHandler(Display *display)
@@ -246,11 +244,9 @@ int nxagentIOErrorHandler(Display *display)
}
/*
- * Force a shutdown of any connection attempt
- * while connecting to the remote display.
- * This is needed to avoid a hang up in case
- * of loopback connections to our own listen-
- * ing sockets.
+ * Force a shutdown of any connection attempt while connecting to the
+ * remote display. This is needed to avoid a hang up in case of
+ * loopback connections to our own listening sockets.
*/
static void nxagentRejectConnection(int signal)
@@ -266,16 +262,15 @@ static void nxagentRejectConnection(int signal)
#endif
/*
- * A further timeout is unlikely to happen
- * in the case of loopback connections.
+ * A further timeout is unlikely to happen in the case of loopback
+ * connections.
*/
alarm(5);
}
/*
- * Ignore the signal if the NX transport is
- * not running.
+ * Ignore the signal if the NX transport is not running.
*/
static void nxagentSigusrHandler(int signal)
@@ -371,17 +366,16 @@ static void nxagentSigchldHandler(int signal)
{
int pid = 0;
int status;
- int options;
#ifdef TEST
fprintf(stderr, "nxagentSigchldHandler: Going to check the children processes.\n");
#endif
- options = WNOHANG | WUNTRACED;
+ int options = WNOHANG | WUNTRACED;
/*
- * Try with the pid of the dialog process.
- * Leave the other children unaffected.
+ * Try with the pid of the dialog process. Leave the other children
+ * unaffected.
*/
if (nxagentRootlessDialogPid)
@@ -567,30 +561,25 @@ static void nxagentSigchldHandler(int signal)
Display *nxagentInternalOpenDisplay(char *display)
{
- Display *newDisplay;
-
struct sigaction oldAction;
struct sigaction newAction;
int result;
/*
- * Stop the smart schedule timer since
- * it uses SIGALRM as we do.
+ * Stop the smart schedule timer since it uses SIGALRM as we do.
*/
nxagentStopTimer();
/*
- * Install the handler rejecting a possible
- * loopback connection.
+ * Install the handler rejecting a possible loopback connection.
*/
/*
-FIXME: Should print a warning if the user tries to let
- the agent impersonate the same display as the
- display where the agent is supposed to connect.
- We actually handle this by means of RejectWell-
- KnownSockets() but without giving a friendly
+FIXME: Should print a warning if the user tries to let the agent
+ impersonate the same display as the display where the agent is
+ supposed to connect. We actually handle this by means of
+ RejectWellKnownSockets() but without giving a friendly
explanation for the error to the user.
*/
@@ -615,7 +604,7 @@ FIXME: Should print a warning if the user tries to let
display);
#endif
- newDisplay = XOpenDisplay(display);
+ Display *newDisplay = XOpenDisplay(display);
alarm(0);
@@ -646,9 +635,8 @@ static void nxagentDisplayBlockHandler(Display *display, int reason)
if (nxagentDisplay != NULL)
{
/*
- * Don't allow the smart schedule to
- * interrupt the agent while waiting
- * for the remote display.
+ * Don't allow the smart schedule to interrupt the agent while
+ * waiting for the remote display.
*/
#ifdef DEBUG
@@ -675,8 +663,7 @@ static void nxagentDisplayBlockHandler(Display *display, int reason)
{
/*
- * Let the dispatch attend the next
- * client.
+ * Let the dispatch attend the next client.
*/
#ifdef DEBUG
@@ -732,8 +719,6 @@ int nxagentGetDataRate(void)
static void nxagentDisplayFlushHandler(Display *display, int length)
{
- CARD32 time;
-
if (nxagentDisplay != NULL)
{
#ifdef TEST
@@ -752,9 +737,7 @@ static void nxagentDisplayFlushHandler(Display *display, int length)
{
nxagentFlush = GetTimeInMillis();
- time = nxagentFlush;
-
- time = time - nxagentLastTime;
+ CARD32 time = nxagentFlush - nxagentLastTime;
if (time < nxagentRateTime)
{
@@ -804,18 +787,17 @@ static int nxagentDisplayErrorPredicate(Display *display, int error)
void nxagentInstallDisplayHandlers(void)
{
/*
- * If the display was already opened, be sure
- * all structures are freed.
+ * If the display was already opened, be sure all structures are
+ * freed.
*/
nxagentResetDisplayHandlers();
/*
- * We want the Xlib I/O error handler to return,
- * instead of quitting the application. Using
- * setjmp()/longjmp() leaves the door open to
- * unexpected bugs when dealing with interaction
- * with the other X server layers.
+ * We want the Xlib I/O error handler to return, instead of quitting
+ * the application. Using setjmp()/longjmp() leaves the door open to
+ * unexpected bugs when dealing with interaction with the other X
+ * server layers.
*/
NXHandleDisplayError(1);
@@ -833,14 +815,12 @@ void nxagentInstallDisplayHandlers(void)
XSetIOErrorHandler(nxagentIOErrorHandler);
/*
- * Let Xlib become aware of our interrupts. In theory
- * we don't need to have the error handler installed
- * during the normal operations and could simply let
- * the dispatcher handle the interrupts. In practice
- * it's better to have Xlib invalidating the display
- * as soon as possible rather than incurring in the
- * risk of entering a loop that doesn't care checking
- * the display errors explicitly.
+ * Let Xlib become aware of our interrupts. In theory we don't need
+ * to have the error handler installed during the normal operations
+ * and could simply let the dispatcher handle the interrupts. In
+ * practice it's better to have Xlib invalidating the display as
+ * soon as possible rather than incurring in the risk of entering a
+ * loop that doesn't care checking the display errors explicitly.
*/
#ifdef TEST
@@ -853,8 +833,8 @@ void nxagentInstallDisplayHandlers(void)
void nxagentPostInstallDisplayHandlers(void)
{
/*
- * This is executed after having opened the
- * display, once we know the display address.
+ * This is executed after having opened the display, once we know
+ * the display address.
*/
if (nxagentDisplay != NULL)
@@ -886,15 +866,13 @@ void nxagentResetDisplayHandlers(void)
if (nxagentDisplay != NULL)
{
/*
- * Free the internal nxcompext
- * structures.
+ * Free the internal nxcompext structures.
*/
NXResetDisplay(nxagentDisplay);
/*
- * Remove the display descriptor
- * from the listened sockets.
+ * Remove the display descriptor from the listened sockets.
*/
nxagentRemoveXConnection();
@@ -917,8 +895,7 @@ void nxagentResetDisplayHandlers(void)
nxagentCongestion = 0;
/*
- * Reset the counter of synchronization
- * requests pending.
+ * Reset the counter of synchronization requests pending.
*/
nxagentTokens.soft = 0;
@@ -942,9 +919,8 @@ void nxagentInstallSignalHandlers(void)
#endif
/*
- * Keep the default X server's handlers for
- * SIGINT and SIGTERM and restore the other
- * signals of interest to our defaults.
+ * Keep the default X server's handlers for SIGINT and SIGTERM and
+ * restore the other signals of interest to our defaults.
*/
struct sigaction newAction;
@@ -952,9 +928,9 @@ void nxagentInstallSignalHandlers(void)
int result;
/*
- * By default nxcomp installs its signal handlers.
- * We need to ensure that SIGUSR1 and SIGUSR2 are
- * ignored if the NX transport is not running.
+ * By default nxcomp installs its signal handlers. We need to
+ * ensure that SIGUSR1 and SIGUSR2 are ignored if the NX transport
+ * is not running.
*/
newAction.sa_handler = nxagentSigusrHandler;
@@ -998,8 +974,7 @@ void nxagentInstallSignalHandlers(void)
}
/*
- * Let the smart schedule set the SIGALRM
- * handler again.
+ * Let the smart schedule set the SIGALRM handler again.
*/
nxagentInitTimer();
@@ -1048,13 +1023,12 @@ void nxagentPostInstallSignalHandlers(void)
#endif
/*
- * Reconfigure our signal handlers to work well
- * with the NX transport.
+ * Reconfigure our signal handlers to work well with the NX
+ * transport.
*
- * Let our handlers manage the SIGINT and SIGTERM.
- * The following calls will tell the NX transport
- * to restore the old handlers (those originally
- * installed by us or the X server).
+ * Let our handlers manage the SIGINT and SIGTERM. The following
+ * calls will tell the NX transport to restore the old handlers
+ * (those originally installed by us or the X server).
*/
NXTransSignal(SIGINT, NX_SIGNAL_DISABLE);
@@ -1067,16 +1041,14 @@ void nxagentPostInstallSignalHandlers(void)
NXTransSignal(SIGHUP, NX_SIGNAL_DISABLE);
/*
- * Both the proxy and the agent need to catch
- * their children, so we'll have to send the
- * signal to transport.
+ * Both the proxy and the agent need to catch their children, so
+ * we'll have to send the signal to transport.
*/
NXTransSignal(SIGCHLD, NX_SIGNAL_DISABLE);
/*
- * Let the NX transport take care of SIGUSR1
- * and SIGUSR2.
+ * Let the NX transport take care of SIGUSR1 and SIGUSR2.
*/
}
@@ -1089,8 +1061,7 @@ void nxagentResetSignalHandlers(void)
memset(&newAction, 0, sizeof(newAction));
/*
- * Reset the signal handlers
- * to a well known state.
+ * Reset the signal handlers to a well known state.
*/
#ifdef TEST
@@ -1116,8 +1087,7 @@ void nxagentResetSignalHandlers(void)
}
/*
- * Let the smart schedule set the SIGALRM
- * handler again.
+ * Let the smart schedule set the SIGALRM handler again.
*/
nxagentInitTimer();
@@ -1126,9 +1096,8 @@ void nxagentResetSignalHandlers(void)
void nxagentOpenDisplay(int argc, char *argv[])
{
- int i;
-
- if (!nxagentDoFullGeneration) return;
+ if (!nxagentDoFullGeneration)
+ return;
#ifdef NXAGENT_TIMESTAMP
@@ -1140,8 +1109,8 @@ void nxagentOpenDisplay(int argc, char *argv[])
#endif
/*
- * Initialize the reconnector only in the case
- * of persistent sessions.
+ * Initialize the reconnector only in the case of persistent
+ * sessions.
*/
if (nxagentOption(Persistent))
@@ -1169,8 +1138,8 @@ void nxagentOpenDisplay(int argc, char *argv[])
if (nxagentDisplay == NULL)
{
/*
-FIXME: The agent should never exit the program with a FatalError()
- but rather use a specific function that may eventually call
+FIXME: The agent should never exit the program with a FatalError() but
+ rather use a specific function that may eventually call
FatalError() on its turn.
*/
FatalError("Unable to open display '%s'.\n", nxagentDisplayName);
@@ -1217,9 +1186,8 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
DefaultScreenOfDisplay(nxagentDisplay));
/*
- * Processing the arguments all the timeouts
- * have been set. Now we have to change the
- * screen-saver timeout.
+ * Processing the arguments all the timeouts have been set. Now we
+ * have to change the screen-saver timeout.
*/
nxagentSetScreenSaverTime();
@@ -1230,7 +1198,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
nxagentDefaultColormaps = (Colormap *)malloc(nxagentNumDefaultColormaps *
sizeof(Colormap));
- for (i = 0; i < nxagentNumDefaultColormaps; i++)
+ for (int i = 0; i < nxagentNumDefaultColormaps; i++)
{
nxagentDefaultColormaps[i] = XCreateColormap(nxagentDisplay,
DefaultRootWindow(nxagentDisplay),
@@ -1270,18 +1238,17 @@ N/A
#endif
/*
- * Initialize the agent's event mask that will be requested
- * for the root and all the top level windows. If the nested
- * window is a child of an existing window, we will need to
- * receive StructureNotify events. If we are going to manage
- * the changes in root window's visibility we'll also need
- * VisibilityChange events.
+ * Initialize the agent's event mask that will be requested for the
+ * root and all the top level windows. If the nested window is a
+ * child of an existing window, we will need to receive
+ * StructureNotify events. If we are going to manage the changes in
+ * root window's visibility we'll also need VisibilityChange events.
*/
/*
-FIXME: Use of nxagentParentWindow is strongly deprecated.
- We need also to clarify which events are selected
- in the different operating modes.
+FIXME: Use of nxagentParentWindow is strongly deprecated. We need
+ also to clarify which events are selected in the different
+ operating modes.
*/
nxagentInitDefaultEventMask();
@@ -1296,9 +1263,8 @@ FIXME: Use of nxagentParentWindow is strongly deprecated.
(void) nxagentCheckForPixmapFormatsCompatibility();
/*
- * Create a pixmap for each depth matching the
- * local supported formats with format available
- * on the remote display.
+ * Create a pixmap for each depth matching the local supported
+ * formats with format available on the remote display.
*/
nxagentSetDefaultDrawables();
@@ -1311,16 +1277,15 @@ FIXME: Use of nxagentParentWindow is strongly deprecated.
#endif
/*
- * This GC is referenced in Cursor.c. It can be
- * probably removed.
+ * This GC is referenced in Cursor.c. It can be probably removed.
*/
nxagentBitmapGC = XCreateGC(nxagentDisplay, nxagentDefaultDrawables[1], 0L, NULL);
/*
- * Note that this "confine window" is useless at the
- * moment as we reimplement nxagentConstrainCursor()
- * to skip the "constrain" stuff.
+ * Note that this "confine window" is useless at the moment as we
+ * reimplement nxagentConstrainCursor() to skip the "constrain"
+ * stuff.
*/
#ifdef TEST
@@ -1446,15 +1411,11 @@ N/A
void nxagentSetDefaultVisual(void)
{
- XVisualInfo vi;
-
- int i;
-
if (nxagentUserDefaultClass || nxagentUserDefaultDepth)
{
nxagentDefaultVisualIndex = UNDEFINED;
- for (i = 0; i < nxagentNumVisuals; i++)
+ for (int i = 0; i < nxagentNumVisuals; i++)
{
if ((!nxagentUserDefaultClass ||
nxagentVisuals[i].class == nxagentDefaultClass)
@@ -1463,7 +1424,6 @@ void nxagentSetDefaultVisual(void)
nxagentVisuals[i].depth == nxagentDefaultDepth))
{
nxagentDefaultVisualIndex = i;
-
break;
}
}
@@ -1475,11 +1435,13 @@ void nxagentSetDefaultVisual(void)
}
else
{
+ XVisualInfo vi = {0};
+
vi.visualid = XVisualIDFromVisual(DefaultVisual(nxagentDisplay,
DefaultScreen(nxagentDisplay)));
nxagentDefaultVisualIndex = 0;
- for (i = 0; i < nxagentNumVisuals; i++)
+ for (int i = 0; i < nxagentNumVisuals; i++)
{
if (vi.visualid == nxagentVisuals[i].visualid)
{
@@ -1491,20 +1453,18 @@ void nxagentSetDefaultVisual(void)
void nxagentInitVisuals(void)
{
- XVisualInfo vi;
- XVisualInfo *viList = NULL;
-
- long mask;
- int i, viNumList;
+ XVisualInfo vi = {
+ .screen = DefaultScreen(nxagentDisplay),
+ .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)),
+ };
+ long mask = VisualScreenMask;
+ int viNumList;
+ XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, mask, &vi, &viNumList);
- mask = VisualScreenMask;
- vi.screen = DefaultScreen(nxagentDisplay);
- vi.depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay));
- viList = XGetVisualInfo(nxagentDisplay, mask, &vi, &viNumList);
nxagentVisuals = (XVisualInfo *) malloc(viNumList * sizeof(XVisualInfo));
nxagentNumVisuals = 0;
- for (i = 0; i < viNumList; i++)
+ for (int i = 0; i < viNumList; i++)
{
if (viList[i].depth == vi.depth)
{
@@ -1547,10 +1507,6 @@ void nxagentInitVisuals(void)
void nxagentInitDepths(void)
{
- #ifdef TEST
- int i;
- #endif
-
nxagentDepths = XListDepths(nxagentDisplay, DefaultScreen(nxagentDisplay),
&nxagentNumDepths);
@@ -1568,7 +1524,7 @@ void nxagentInitDepths(void)
fprintf(stderr, "nxagentInitDepths: Got [%d] available depths:\n",
nxagentNumDepths);
- for (i = 0; i < nxagentNumDepths; i++)
+ for (int i = 0; i < nxagentNumDepths; i++)
{
fprintf(stderr, " [%d]", nxagentDepths[i]);
}
@@ -1580,14 +1536,11 @@ void nxagentInitDepths(void)
void nxagentInitPixmapFormats(void)
{
- int i, j;
- int depth;
-
/*
- * Formats are created with no care of which are supported
- * on the real display. Creating only formats supported
- * by the remote end makes troublesome handling migration
- * of session from a display to another.
+ * Formats are created with no care of which are supported on the
+ * real display. Creating only formats supported by the remote end
+ * makes troublesome handling migration of session from a display to
+ * another.
*/
nxagentNumPixmapFormats = 0;
@@ -1598,9 +1551,9 @@ XXX: Some X server doesn't list 1 among available depths...
nxagentPixmapFormats = malloc((nxagentNumDepths + 1) * sizeof(XPixmapFormatValues));
- for (i = 1; i <= MAXDEPTH; i++)
+ for (int i = 1; i <= MAXDEPTH; i++)
{
- depth = 0;
+ int depth = 0;
if (i == 1)
{
@@ -1608,7 +1561,7 @@ XXX: Some X server doesn't list 1 among available depths...
}
else
{
- for (j = 0; j < nxagentNumDepths; j++)
+ for (int j = 0; j < nxagentNumDepths; j++)
{
if (nxagentDepths[j] == i)
{
@@ -1655,7 +1608,7 @@ XXX: Some X server doesn't list 1 among available depths...
fprintf(stderr, "nxagentInitPixmapFormats: Got [%d] available remote pixmap formats:\n",
nxagentRemoteNumPixmapFormats);
- for (i = 0; i < nxagentRemoteNumPixmapFormats; i++)
+ for (int i = 0; i < nxagentRemoteNumPixmapFormats; i++)
{
fprintf(stderr, "nxagentInitPixmapFormats: Remote pixmap format [%d]: depth [%d] "
"bits_per_pixel [%d] scanline_pad [%d].\n", i, nxagentRemotePixmapFormats[i].depth,
@@ -1667,14 +1620,12 @@ XXX: Some X server doesn't list 1 among available depths...
void nxagentSetDefaultDrawables(void)
{
- int i, j;
-
- for (i = 0; i <= MAXDEPTH; i++)
+ for (int i = 0; i <= MAXDEPTH; i++)
{
nxagentDefaultDrawables[i] = None;
}
- for (i = 0; i < nxagentNumPixmapFormats; i++)
+ for (int i = 0; i < nxagentNumPixmapFormats; i++)
{
#ifdef TEST
fprintf(stderr, "nxagentSetDefaultDrawables: Checking remote pixmap format [%d] with depth [%d] "
@@ -1695,7 +1646,7 @@ void nxagentSetDefaultDrawables(void)
}
}
- for (j = 0; j < nxagentNumDepths; j++)
+ for (int j = 0; j < nxagentNumDepths; j++)
{
#ifdef TEST
fprintf(stderr, "nxagentSetDefaultDrawables: Checking depth at index [%d] with pixmap depth [%d] "
@@ -1750,11 +1701,9 @@ void nxagentCloseDisplay(void)
}
/*
- * If nxagentDoFullGeneration is true, all
- * the X resources will be destroyed upon
- * closing the display connection, so there
- * is no real need to generate additional
- * traffic
+ * If nxagentDoFullGeneration is true, all the X resources will be
+ * destroyed upon closing the display connection, so there is no
+ * real need to generate additional traffic
*/
SAFE_free(nxagentDefaultColormaps);
@@ -1771,14 +1720,12 @@ FIXME: Is this needed?
*/
/*
- * Free the image cache. This is useful
- * for detecting memory leaks.
+ * Free the image cache. This is useful for detecting memory leaks.
*/
if (nxagentDisplay != NULL)
{
NXFreeCache(nxagentDisplay);
-
NXResetDisplay(nxagentDisplay);
}
@@ -1855,14 +1802,11 @@ void nxagentBackupDisplayInfo(void)
}
/*
- * Since we need the display structure
- * in order to behave correctly when no X
- * connection is available, we must always
- * have a good display record.
- * It can be discarded only when a new X
- * connection is available, so we store it
- * in order to destroy whenever the recon-
- * nection succed.
+ * Since we need the display structure in order to behave correctly
+ * when no X connection is available, we must always have a good
+ * display record. It can be discarded only when a new X connection
+ * is available, so we store it in order to destroy whenever the
+ * reconnection succeeds.
*/
nxagentDisplayBackup = nxagentDisplay;
@@ -1934,9 +1878,7 @@ void nxagentDisconnectDisplay(void)
case ALLOC_DEF_COLORMAP:
if (nxagentDefaultColormaps)
{
- int i;
-
- for (i = 0; i < nxagentNumDefaultColormaps; i++)
+ for (int i = 0; i < nxagentNumDefaultColormaps; i++)
{
nxagentDefaultColormaps[i] = None;
}
@@ -1944,9 +1886,8 @@ void nxagentDisconnectDisplay(void)
case GOT_VISUAL_INFO:
case OPENED:
/*
- * Actually we need the nxagentDisplay
- * structure in order to let the agent
- * go when no X connection is available.
+ * Actually we need the nxagentDisplay structure in order to let
+ * the agent go when no X connection is available.
*/
if (nxagentDisplay &&
@@ -1970,21 +1911,18 @@ static int nxagentCheckForDefaultDepthCompatibility(void)
/*
* Depending on the (reconnect) tolerance checks value, this
* function checks stricter or looser:
- * - Strict means that the old and new default depth values
- * must match exactly.
- * - Safe or Risky means that the default depth values might differ,
- * but the new default depth value must be at least as
- * high as the former default depth value. This is
- * recommended, because it allows clients with a
- * higher default depth value to still connect, but
- * not lose functionality.
+ * - Strict means that the old and new default depth values must
+ * match exactly.
+ * - Safe or Risky means that the default depth values might
+ * differ, but the new default depth value must be at least as
+ * high as the former default depth value. This is recommended,
+ * because it allows clients with a higher default depth value
+ * to still connect, but not lose functionality.
* - Bypass means that all of these checks are essentially
* deactivated. This is probably a very bad idea.
*/
- int dDepth;
-
- dDepth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay));
+ int dDepth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay));
const unsigned int tolerance = nxagentOption(ReconnectTolerance);
@@ -1996,7 +1934,6 @@ static int nxagentCheckForDefaultDepthCompatibility(void)
"is [%d], former default depth value is [%d].\n", tolerance,
ToleranceChecksBypass, dDepth, nxagentDefaultDepthRecBackup);
#endif
-
return 1;
}
@@ -2006,7 +1943,6 @@ static int nxagentCheckForDefaultDepthCompatibility(void)
fprintf(stderr, "nxagentCheckForDefaultDepthCompatibility: New default depth [%d] "
"matches with old default depth.\n", dDepth);
#endif
-
return 1;
}
else if ((ToleranceChecksSafe <= tolerance) && (nxagentDefaultDepthRecBackup < dDepth))
@@ -2016,7 +1952,6 @@ static int nxagentCheckForDefaultDepthCompatibility(void)
"higher than the old default depth [%d] at tolerance [%u].\n", dDepth,
nxagentDefaultDepthRecBackup, tolerance);
#endif
-
return 1;
}
else
@@ -2026,7 +1961,6 @@ static int nxagentCheckForDefaultDepthCompatibility(void)
"doesn't match with old default depth [%d] at tolerance [%u].\n", dDepth,
nxagentDefaultDepthRecBackup, tolerance);
#endif
-
return 0;
}
}
@@ -2036,18 +1970,16 @@ static int nxagentCheckForDepthsCompatibility(void)
/*
* Depending on the (reconnect) tolerance checks value, this
* function checks stricter or looser:
- * - Strict means that the number of old and new depths must
- * match exactly and every old depth value must be
- * available in the new depth array.
- * - Safe means that the number of depths might diverge,
- * but all former depth must also be included in the
- * new depth array. This is recommended, because
- * it allows clients with more depths to still
- * connect, but not lose functionality.
+ * - Strict means that the number of old and new depths must match
+ * exactly and every old depth value must be available in the
+ * new depth array.
+ * - Safe means that the number of depths might diverge, but all
+ * former depth must also be included in the new depth
+ * array. This is recommended, because it allows clients with
+ * more depths to still connect, but not lose functionality.
* - Risky means that the new depths array is allowed to be
- * smaller than the old depths array, but at least
- * one depth value must be included in both.
- * This is potentially unsafe.
+ * smaller than the old depths array, but at least one depth
+ * value must be included in both. This is potentially unsafe.
* - Bypass or higher means that all of these checks are
* essentially deactivated. This is a very bad idea.
*/
@@ -2062,7 +1994,6 @@ static int nxagentCheckForDepthsCompatibility(void)
"is [%d], number of old depths is [%d].\n", tolerance, ToleranceChecksBypass,
nxagentNumDepths, nxagentNumDepthsRecBackup);
#endif
-
return 1;
}
@@ -2074,7 +2005,6 @@ static int nxagentCheckForDepthsCompatibility(void)
"depths [%d].\n", nxagentNumDepths,
nxagentNumDepthsRecBackup);
#endif
-
return 0;
}
@@ -2086,7 +2016,6 @@ static int nxagentCheckForDepthsCompatibility(void)
"lower than number of old depths [%d].\n", tolerance,
nxagentNumDepths, nxagentNumDepthsRecBackup);
#endif
-
return 0;
}
@@ -2102,7 +2031,6 @@ static int nxagentCheckForDepthsCompatibility(void)
bool compatible = true;
bool one_match = false;
- bool matched = false;
int total_matches = 0;
/*
@@ -2124,7 +2052,7 @@ static int nxagentCheckForDepthsCompatibility(void)
*/
for (int i = 0; i < nxagentNumDepths; ++i)
{
- matched = false;
+ bool matched = false;
for (int j = 0; j < nxagentNumDepthsRecBackup; ++j)
{
@@ -2194,20 +2122,18 @@ static int nxagentCheckForPixmapFormatsCompatibility(void)
/*
* Depending on the (reconnect) tolerance checks value, this
* function checks stricter or looser:
- * - Strict means that the number of internal and external
- * pixmap formats must match exactly and every
- * internal pixmap format must be available in the
- * external pixmap format array.
- * - Safe means that the number of pixmap formats might
- * diverge, but all internal pixmap formats must
- * also be included in the external pixmap formats
- * array. This is recommended, because it allows
- * clients with more pixmap formats to still connect,
+ * - Strict means that the number of internal and external pixmap
+ * formats must match exactly and every internal pixmap format
+ * must be available in the external pixmap format array.
+ * - Safe means that the number of pixmap formats might diverge,
+ * but all internal pixmap formats must also be included in the
+ * external pixmap formats array. This is recommended, because
+ * it allows clients with more pixmap formats to still connect,
* but not lose functionality.
- * - Risky means that the internal pixmap formats array is
- * allowed to be smaller than the external pixmap
- * formats array, but at least one pixmap format must
- * be included in both. This is potentially unsafe.
+ * - Risky means that the internal pixmap formats array is allowed
+ * to be smaller than the external pixmap formats array, but at
+ * least one pixmap format must be included in both. This is
+ * potentially unsafe.
* - Bypass or higher means that all of these checks are
* essentially deactivated. This is a very bad idea.
*/
@@ -2222,7 +2148,6 @@ static int nxagentCheckForPixmapFormatsCompatibility(void)
"pixmap formats is [%d], number of externally available pixmap formats is [%d].\n",
tolerance, ToleranceChecksBypass, nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats);
#endif
-
return 1;
}
@@ -2233,7 +2158,6 @@ static int nxagentCheckForPixmapFormatsCompatibility(void)
"of internal pixmap formats [%d] doesn't match with number of remote formats [%d].\n",
nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats);
#endif
-
return 0;
}
@@ -2244,7 +2168,6 @@ static int nxagentCheckForPixmapFormatsCompatibility(void)
"and number of internal pixmap formats [%d] higher than number of external formats [%d].\n",
tolerance, nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats);
#endif
-
return 0;
}
@@ -2260,12 +2183,11 @@ static int nxagentCheckForPixmapFormatsCompatibility(void)
*/
bool compatible = true;
- bool matched = false;
int total_matches = 0;
for (int i = 0; i < nxagentNumPixmapFormats; ++i)
{
- matched = false;
+ bool matched = false;
for (int j = 0; j < nxagentRemoteNumPixmapFormats; ++j)
{
@@ -2327,36 +2249,31 @@ static int nxagentCheckForPixmapFormatsCompatibility(void)
static int nxagentInitAndCheckVisuals(int flexibility)
{
/* FIXME: does this also need work? */
- XVisualInfo viTemplate;
- XVisualInfo *viList;
- XVisualInfo *newVisuals;
- long viMask;
- int i, n;
- bool matched;
- bool compatible = true;
+ long viMask = VisualScreenMask;
+ XVisualInfo viTemplate = {
+ .screen = DefaultScreen(nxagentDisplay),
+ .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)),
+ };
int viNumList;
+ XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, viMask, &viTemplate, &viNumList);
- viMask = VisualScreenMask;
- viTemplate.screen = DefaultScreen(nxagentDisplay);
- viTemplate.depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay));
- viList = XGetVisualInfo(nxagentDisplay, viMask, &viTemplate, &viNumList);
+ XVisualInfo *newVisuals = malloc(sizeof(XVisualInfo) * nxagentNumVisuals);
- newVisuals = malloc(sizeof(XVisualInfo) * nxagentNumVisuals);
+ bool compatible = true;
- for (i = 0; i < nxagentNumVisuals; i++)
+ for (int i = 0; i < nxagentNumVisuals; i++)
{
- matched = false;
+ bool matched = false;
- for (n = 0; n < viNumList; n++)
+ for (int n = 0; n < viNumList; n++)
{
if (nxagentCompareVisuals(nxagentVisuals[i], viList[n]) == 1)
{
/*
-FIXME: Should the visual be ignored in this case?
- We can flag the visuals with inverted masks,
- and use this information to switch the masks
- when contacting the remote X server.
+FIXME: Should the visual be ignored in this case? We can flag the
+ visuals with inverted masks, and use this information to switch
+ the masks when contacting the remote X server.
*/
if (nxagentVisuals[i].red_mask == viList[n].blue_mask &&
nxagentVisuals[i].blue_mask == viList[n].red_mask)
@@ -2441,7 +2358,6 @@ static int nxagentCheckForColormapsCompatibility(int flexibility)
fprintf(stderr, "nxagentCheckForColormapsCompatibility: Number of new colormaps [%d] "
"matches with old colormaps.\n", nxagentNumDefaultColormaps);
#endif
-
return 1;
}
else
@@ -2451,14 +2367,12 @@ static int nxagentCheckForColormapsCompatibility(int flexibility)
"doesn't match with old colormaps [%d].\n", nxagentNumDefaultColormaps,
nxagentNumDefaultColormapsRecBackup);
#endif
-
return 0;
}
}
Bool nxagentReconnectDisplay(void *p0)
{
- int i;
int flexibility = *(int*)p0;
#if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_DISPLAY_DEBUG)
@@ -2528,9 +2442,8 @@ Bool nxagentReconnectDisplay(void *p0)
DefaultScreenOfDisplay(nxagentDisplay));
/*
- * After processing the arguments all the
- * timeout values have been set. Now we
- * have to change the screen-saver timeout.
+ * After processing the arguments all the timeout values have been
+ * set. Now we have to change the screen-saver timeout.
*/
nxagentSetScreenSaverTime();
@@ -2569,7 +2482,7 @@ Bool nxagentReconnectDisplay(void *p0)
reconnectDisplayState = ALLOC_DEF_COLORMAP;
- for (i = 0; i < nxagentNumDefaultColormaps; i++)
+ for (int i = 0; i < nxagentNumDefaultColormaps; i++)
{
if (nxagentVisualHasBeenIgnored[i])
{
@@ -2611,8 +2524,7 @@ Bool nxagentReconnectDisplay(void *p0)
SAFE_XFree(nxagentRemotePixmapFormats);
/*
- * Check if all the required pixmap
- * formats are supported.
+ * Check if all the required pixmap formats are supported.
*/
nxagentInitPixmapFormats();
@@ -2628,9 +2540,8 @@ Bool nxagentReconnectDisplay(void *p0)
reconnectDisplayState = GOT_PIXMAP_FORMAT_LIST;
/*
- * Create a pixmap for each depth matching the
- * local supported formats with format available
- * on the remote display.
+ * Create a pixmap for each depth matching the local supported
+ * formats with format available on the remote display.
*/
nxagentSetDefaultDrawables();
@@ -2658,12 +2569,11 @@ Bool nxagentReconnectDisplay(void *p0)
nxagentWhitePixel = WhitePixel(nxagentDisplay, DefaultScreen(nxagentDisplay));
/*
- * Initialize the agent's event mask that will be requested
- * for the root or all the top level windows. If the nested
- * window is a child of an existing window we will need to
- * receive StructureNotify events. If we are going to manage
- * the changes in root window's visibility we'll also need
- * VisibilityChange events.
+ * Initialize the agent's event mask that will be requested for the
+ * root or all the top level windows. If the nested window is a
+ * child of an existing window we will need to receive
+ * StructureNotify events. If we are going to manage the changes in
+ * root window's visibility we'll also need VisibilityChange events.
*/
nxagentInitDefaultEventMask();
@@ -2693,8 +2603,7 @@ Bool nxagentReconnectDisplay(void *p0)
useXpmIcon = nxagentMakeIcon(nxagentDisplay, &nxagentIconPixmap, &nxagentIconShape);
/*
- * All went fine. We can continue
- * handling our clients.
+ * All went fine. We can continue handling our clients.
*/
reconnectDisplayState = EVERYTHING_DONE;
@@ -2704,9 +2613,7 @@ Bool nxagentReconnectDisplay(void *p0)
void nxagentAddXConnection(void)
{
- int fd = XConnectionNumber(nxagentDisplay);
-
- nxagentXConnectionNumber = fd;
+ nxagentXConnectionNumber = XConnectionNumber(nxagentDisplay);
#ifdef TEST
fprintf(stderr, "nxagentAddXConnection: Adding the X connection [%d] "
@@ -2727,10 +2634,9 @@ void nxagentRemoveXConnection(void)
}
/*
- * Force an I/O error and wait until the NX trans-
- * port is gone. It must be called before suspend-
- * ing or terminating a session to ensure that the
- * NX transport is terminated first.
+ * Force an I/O error and wait until the NX transport is gone. It must
+ * be called before suspending or terminating a session to ensure that
+ * the NX transport is terminated first.
*/
void nxagentWaitDisplay(void)
@@ -2768,27 +2674,25 @@ void nxagentWaitDisplay(void)
#endif
/*
- * Be sure the signal handlers are
- * in a known state.
+ * Be sure the signal handlers are in a known state.
*/
nxagentResetSignalHandlers();
}
/*
- * This has not to do with the remote display but
- * with the X server that the agent is impersonating.
- * We have it here to be consistent with the other
- * cleanup procedures which have mainly to do with
- * the Xlib display connection.
+ * This has not to do with the remote display but with the X server
+ * that the agent is impersonating. We have it here to be consistent
+ * with the other cleanup procedures which have mainly to do with the
+ * Xlib display connection.
*/
void nxagentAbortDisplay(void)
{
/*
- * Be sure the X server socket in .X11-unix is
- * deleted otherwise other users may to become
- * unable to run a session on the same display.
+ * Be sure the X server socket in .X11-unix is deleted otherwise
+ * other users may to become unable to run a session on the same
+ * display.
*/
#ifdef TEST
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c
index 7574ec7b0..7c69c99d9 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c
@@ -55,26 +55,23 @@
#undef DUMP
/*
- * The list of rectangles composing a region
- * s returned by nxagentGetOptimizedRegion-
- * Boxes() instead of RegionRects().
+ * The list of rectangles composing a region s returned by
+ * nxagentGetOptimizedRegion- Boxes() instead of RegionRects().
*/
#define USE_OPTIMIZED_BOXES
/*
- * The rectangles composing a region are de-
- * fragmented to reduce the number of synch-
- * ronizing PutImage's.
+ * The rectangles composing a region are de- fragmented to reduce the
+ * number of synch- ronizing PutImage's.
*/
#define ADVANCED_BOXES_DEFRAG
/*
- * If defined, send the XClearArea at the end
- * of the loop synchronizing the shadow pixmap.
- * In this way, large images can be split but
- * the user will see more updates together.
+ * If defined, send the XClearArea at the end of the loop
+ * synchronizing the shadow pixmap. In this way, large images can be
+ * split but the user will see more updates together.
*/
#undef COLLECTED_UPDATES
@@ -104,9 +101,8 @@ _nxagentSynchronizationRec nxagentSynchronization = { (DrawablePtr) NULL, 0, 0,
RegionPtr nxagentDeferredBackgroundExposures = NullRegion;
/*
- * Predicate functions used to synchronize the
- * content of the remote drawable with the data
- * stored in the virtual frame-buffer.
+ * Predicate functions used to synchronize the content of the remote
+ * drawable with the data stored in the virtual frame-buffer.
*/
void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2);
@@ -126,12 +122,8 @@ int nxagentSkipImage = 0;
static int nxagentTooManyImageData(void)
{
- unsigned int r;
- unsigned int limit;
-
- limit = nxagentOption(ImageRateLimit);
-
- r = nxagentGetDataRate() / 1000;
+ unsigned int limit = nxagentOption(ImageRateLimit);
+ unsigned int r = nxagentGetDataRate() / 1000;
#ifdef TEST
if (r > limit)
@@ -145,8 +137,6 @@ static int nxagentTooManyImageData(void)
int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int breakMask, WindowPtr owner)
{
- int result;
-
pDrawable = nxagentSplitDrawable(pDrawable);
if (nxagentLosslessTrap == 0)
@@ -164,19 +154,17 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre
}
/*
- * What we want here is to avoid drawing on the
- * framebuffer and just perform the operation
- * on the real X server. This is the purpose of
- * the FB trap. At the same time we also want
- * to avoid a split, so that the image will be
- * transferred in a single operation.
+ * What we want here is to avoid drawing on the framebuffer and just
+ * perform the operation on the real X server. This is the purpose
+ * of the FB trap. At the same time we also want to avoid a split,
+ * so that the image will be transferred in a single operation.
*/
nxagentFBTrap = 1;
nxagentSplitTrap = 1;
- result = nxagentSynchronizeDrawableData(pDrawable, breakMask, owner);
+ int result = nxagentSynchronizeDrawableData(pDrawable, breakMask, owner);
nxagentSplitTrap = 0;
@@ -188,7 +176,6 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre
}
#ifdef TEST
-
if (nxagentDrawableStatus(pDrawable) == Synchronized)
{
fprintf(stderr, "nxagentSynchronizeDrawable: Drawable %s [%p] with id [%ld] now synchronized.\n",
@@ -199,7 +186,6 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre
fprintf(stderr, "nxagentSynchronizeDrawable: Drawable %s [%p] with id [%ld] not fully synchronized.\n",
nxagentDrawableType(pDrawable), (void *) pDrawable, pDrawable -> id);
}
-
#endif
return result;
@@ -207,31 +193,27 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre
int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask, WindowPtr owner)
{
- int width, height, depth, length;
- unsigned int leftPad, format;
-
char *data = NULL;
- DrawablePtr pSrcDrawable;
- GCPtr pGC;
-
int success;
if (pDrawable -> type == DRAWABLE_PIXMAP)
{
- leftPad = 0;
+ GCPtr pGC;
+
+ unsigned int leftPad = 0;
- width = pDrawable -> width;
- height = pDrawable -> height;
- depth = pDrawable -> depth;
+ int width = pDrawable -> width;
+ int height = pDrawable -> height;
+ int depth = pDrawable -> depth;
#ifdef TEST
fprintf(stderr, "nxagentSynchronizeDrawableData: Synchronizing drawable (%s) with geometry [%d][%d][%d].\n",
nxagentDrawableType(pDrawable), width, height, depth);
#endif
- format = (depth == 1) ? XYPixmap : ZPixmap;
+ unsigned int format = (depth == 1) ? XYPixmap : ZPixmap;
- length = nxagentImageLength(width, height, format, leftPad, depth);
+ int length = nxagentImageLength(width, height, format, leftPad, depth);
if ((data = malloc(length)) == NULL)
{
@@ -244,14 +226,13 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
goto nxagentSynchronizeDrawableDataEnd;
}
- pSrcDrawable = (pDrawable -> type == DRAWABLE_PIXMAP ?
- ((DrawablePtr) nxagentVirtualPixmap((PixmapPtr) pDrawable)) :
- pDrawable);
+ DrawablePtr pSrcDrawable = (pDrawable -> type == DRAWABLE_PIXMAP ?
+ ((DrawablePtr) nxagentVirtualPixmap((PixmapPtr) pDrawable)) :
+ pDrawable);
/*
- * Synchronize the whole pixmap if we need
- * to download a fresh copy with lossless
- * compression turned off.
+ * Synchronize the whole pixmap if we need to download a fresh
+ * copy with lossless compression turned off.
*/
if (nxagentLosslessTrap == 1)
@@ -289,10 +270,9 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
else if (nxagentReconnectTrap == 1)
{
/*
- * The pixmap data is not synchronized unless
- * we need it. We noticed we have to reconnect
- * the pixmaps used by the GC's clip mask.
- * The other data will be synchronized on demand.
+ * The pixmap data is not synchronized unless we need it. We
+ * noticed we have to reconnect the pixmaps used by the GC's
+ * clip mask. The other data will be synchronized on demand.
*/
if (pDrawable -> depth == 1)
@@ -357,9 +337,8 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
}
/*
- * By calling this function with the NullRegion
- * as parameter we are requesting to synchro-
- * nize the full visible corrupted region of
+ * By calling this function with the NullRegion as parameter we are
+ * requesting to synchronize the full visible corrupted region of
* the drawable.
*/
@@ -372,53 +351,26 @@ nxagentSynchronizeDrawableDataEnd:
}
/*
- * If pRegion is NullRegion, all the viewable
- * corrupted region will be synchronized.
+ * If pRegion is NullRegion, all the viewable corrupted region will be
+ * synchronized.
*/
int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned int breakMask, WindowPtr owner)
{
- GCPtr pGC;
DrawablePtr pSrcDrawable;
- BoxPtr pBox;
- RegionPtr clipRegion;
- RegionRec tileRegion;
- RegionRec exposeRegion;
- BoxRec box;
- BoxRec tileBox;
+ int leftPad = 0;
+ int success = 0;
+ char *data = NULL;
+ GCPtr pGC = NULL;
+ RegionPtr clipRegion = NullRegion;
#ifdef COLLECTED_UPDATES
RegionRec collectedUpdates;
- #endif
-
- char *data;
-
- int nBox;
- int x, y;
- int w, h;
- int extentWidth, extentHeight;
- int tileWidth, tileHeight;
- int length, format, leftPad;
- int i;
- int saveTrap;
- int success;
- int useStoredBitmap;
-
- unsigned long now;
- unsigned long elapsedTime;
-
-
- leftPad = 0;
- success = 0;
- data = NULL;
- pGC = NULL;
- clipRegion = NullRegion;
-
- #ifdef COLLECTED_UPDATES
RegionInit(&collectedUpdates, NullBox, 1);
#endif
+ RegionRec exposeRegion;
RegionInit(&exposeRegion, NullBox, 1);
if (nxagentDrawableBitmap(pDrawable) != NullPixmap &&
@@ -434,12 +386,11 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
}
/*
- * The stored bitmap may be used if we
- * are going to synchronize the full
- * drawable.
+ * The stored bitmap may be used if we are going to synchronize the
+ * full drawable.
*/
- useStoredBitmap = (nxagentDrawableBitmap(pDrawable) != NullPixmap && pRegion == NullRegion);
+ int useStoredBitmap = (nxagentDrawableBitmap(pDrawable) != NullPixmap && pRegion == NullRegion);
if (useStoredBitmap != 0)
{
@@ -454,24 +405,21 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
RegionNumRects(nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable))));
#endif
- clipRegion = nxagentCreateRegion(pDrawable, NULL, 0, 0, pDrawable -> width, pDrawable -> height);
+ RegionPtr clipRegion = nxagentCreateRegion(pDrawable, NULL, 0, 0, pDrawable -> width, pDrawable -> height);
/*
- * Intersecting the viewable region of the
- * drawable with the region remaining from
- * a previous loop.
+ * Intersecting the viewable region of the drawable with the
+ * region remaining from a previous loop.
*/
RegionIntersect(clipRegion, clipRegion,
nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)));
/*
- * The bitmap regions used in the synchro-
- * nizations are only those corrupted also
- * on the drawable. In this way, if we put
- * a tile in a bad position (e.g. if the
- * corrupted region moves), the next synch-
- * ronization will fix the error.
+ * The bitmap regions used in the synchronizations are only those
+ * corrupted also on the drawable. In this way, if we put a tile
+ * in a bad position (e.g. if the corrupted region moves), the
+ * next synchronization will fix the error.
*/
RegionIntersect(clipRegion, clipRegion,
@@ -495,8 +443,8 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
}
/*
- * Using the saved bitmap as source, instead
- * of the drawable itself.
+ * Using the saved bitmap as source, instead of the drawable
+ * itself.
*/
pSrcDrawable = ((DrawablePtr) nxagentVirtualPixmap(nxagentDrawableBitmap(pDrawable)));
@@ -524,15 +472,14 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
}
/*
- * Creating a region containing the viewable
- * area of drawable.
+ * Creating a region containing the viewable area of drawable.
*/
clipRegion = nxagentCreateRegion(pDrawable, NULL, 0, 0, pDrawable -> width, pDrawable -> height);
/*
- * If the corrupted region is not viewable, we
- * can skip the synchronization.
+ * If the corrupted region is not viewable, we can skip the
+ * synchronization.
*/
RegionIntersect(clipRegion, clipRegion, nxagentCorruptedRegion(pDrawable));
@@ -550,10 +497,9 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
}
/*
- * We can skip the synchronization if the re-
- * quested region is not corrupted. Specifying
- * a NullRegion as parameter, all the viewable
- * corrupted region will be synchronized.
+ * We can skip the synchronization if the requested region is not
+ * corrupted. Specifying a NullRegion as parameter, all the
+ * viewable corrupted region will be synchronized.
*/
if (pRegion != NullRegion)
@@ -585,7 +531,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
nxagentDrawableType(pDrawable), (void *) pDrawable);
#endif
- saveTrap = nxagentGCTrap;
+ int saveTrap = nxagentGCTrap;
nxagentGCTrap = 0;
@@ -618,14 +564,13 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#endif
/*
- * We are going to synchronize the corrupted
- * area, so we use the corrupted extents as
- * maximum size of the image data. It's im-
- * portant to avoid using the drawable size,
- * because in case of a huge window it had to
- * result in a failed data memory allocation.
+ * We are going to synchronize the corrupted area, so we use the
+ * corrupted extents as maximum size of the image data. It's
+ * important to avoid using the drawable size, because in case of a
+ * huge window it had to result in a failed data memory allocation.
*/
+ int w, h, extentWidth, extentHeight, tileWidth, tileHeight;
extentWidth = clipRegion -> extents.x2 - clipRegion -> extents.x1;
extentHeight = clipRegion -> extents.y2 - clipRegion -> extents.y1;
@@ -636,6 +581,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
fprintf(stderr, "nxagentSynchronizeRegion: Using tiles of size [%dx%d].\n", tileWidth, tileHeight);
#endif
+ int length, format;
data = nxagentAllocateImageData(w, h, pDrawable -> depth, &length, &format);
if (data == NULL)
@@ -645,8 +591,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
fprintf(stderr, "nxagentSynchronizeRegion: WARNING! Failed to allocate memory for synchronization.\n");
/*
- * Print detailed information if the
- * image length is zero.
+ * Print detailed information if the image length is zero.
*/
if (length == 0)
@@ -664,17 +609,17 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#ifndef USE_OPTIMIZED_BOXES
- pBox = RegionRects(clipRegion);
+ BoxPtr pBox = RegionRects(clipRegion);
#else
- pBox = nxagentGetOptimizedRegionBoxes(clipRegion);
+ BoxPtr pBox = nxagentGetOptimizedRegionBoxes(clipRegion);
#endif /* USE_OPTIMIZED_BOXES */
- nBox = RegionNumRects(clipRegion);
+ int nBox = RegionNumRects(clipRegion);
- now = GetTimeInMillis();
+ unsigned long now = GetTimeInMillis();
nxagentSynchronization.abort = 0;
@@ -682,7 +627,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
* Going to split the updated region into small blocks.
*/
- for (i = 0; i < nBox; i++)
+ for (int i = 0; i < nBox; i++)
{
#ifdef USE_OPTIMIZED_BOXES
@@ -694,13 +639,13 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#endif
- box = pBox[i];
+ BoxRec box = pBox[i];
- for (y = box.y1; y < box.y2; y += h)
+ for (int y = box.y1; y < box.y2; y += h)
{
h = min(box.y2 - y, tileHeight);
- for (x = box.x1; x < box.x2; x += w)
+ for (int x = box.x1; x < box.x2; x += w)
{
w = min(box.x2 - x, tileWidth);
@@ -727,12 +672,11 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
if (canBreakOnTimeout(breakMask))
{
/*
- * Abort the synchronization loop if it
- * lasts for more than DeferTimeout
- * milliseconds.
+ * Abort the synchronization loop if it lasts for more than
+ * DeferTimeout milliseconds.
*/
- elapsedTime = GetTimeInMillis() - now;
+ unsigned long elapsedTime = GetTimeInMillis() - now;
if (elapsedTime > nxagentOption(DeferTimeout))
{
@@ -781,10 +725,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
goto nxagentSynchronizeRegionStop;
}
- tileBox.x1 = x;
- tileBox.y1 = y;
- tileBox.x2 = x + w;
- tileBox.y2 = y + h;
+ BoxRec tileBox = {.x1 = x, .y1 = y, .x2 = x + w, .y2 = y + h};
#ifdef DEBUG
fprintf(stderr, "nxagentSynchronizeRegion: Going to synchronize tile [%d,%d,%d,%d].\n",
@@ -794,10 +735,10 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
nxagentGetImage(pSrcDrawable, x, y, w, h, format, AllPlanes, data);
/*
- * Going to unmark the synchronized
- * region.
+ * Going to unmark the synchronized region.
*/
+ RegionRec tileRegion;
RegionInit(&tileRegion, &tileBox, 1);
RegionUnion(&exposeRegion, &exposeRegion, &tileRegion);
@@ -809,30 +750,26 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
if (useStoredBitmap != 0)
{
/*
- * When a bitmap's tile is synchronized,
- * we can clear the corresponding region.
- * We can't use the nxagentUnmarkCorrupted-
- * Region because we have not a resource
- * associated to this pixmap.
+ * When a bitmap's tile is synchronized, we can clear the
+ * corresponding region. We can't use the
+ * nxagentUnmarkCorruptedRegion because we have not a
+ * resource associated to this pixmap.
*/
RegionSubtract(nxagentPixmapCorruptedRegion(nxagentDrawableBitmap(pDrawable)),
nxagentPixmapCorruptedRegion(nxagentDrawableBitmap(pDrawable)), &tileRegion);
/*
- * The drawable's corrupted region can
- * be cleared if the bitmap's tile data
- * matches the drawable's content at the
+ * The drawable's corrupted region can be cleared if the
+ * bitmap's tile data matches the drawable's content at the
* same position.
*/
if (nxagentDrawableStatus(pDrawable) == NotSynchronized)
{
- char *cmpData;
-
int cmpLength, cmpFormat;
- cmpData = nxagentAllocateImageData(w, h, pDrawable -> depth, &cmpLength, &cmpFormat);
+ char *cmpData = nxagentAllocateImageData(w, h, pDrawable -> depth, &cmpLength, &cmpFormat);
if (cmpData != NULL)
{
@@ -882,8 +819,8 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
}
/*
- * Realize the image after comparing the
- * source data with the bitmap data.
+ * Realize the image after comparing the source data with the
+ * bitmap data.
*/
nxagentRealizeImage(pDrawable, pGC, pDrawable -> depth,
@@ -899,16 +836,11 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
(nxagentOption(XRatio) != DONT_SCALE ||
nxagentOption(YRatio) != DONT_SCALE))
{
- int scaledx;
- int scaledy;
- int scaledw;
- int scaledh;
-
- scaledx = nxagentScale(x, nxagentOption(XRatio));
- scaledy = nxagentScale(y, nxagentOption(YRatio));
+ int scaledx = nxagentScale(x, nxagentOption(XRatio));
+ int scaledy = nxagentScale(y, nxagentOption(YRatio));
- scaledw = nxagentScale(x + w, nxagentOption(XRatio)) - scaledx;
- scaledh = nxagentScale(y + h, nxagentOption(YRatio)) - scaledy;
+ int scaledw = nxagentScale(x + w, nxagentOption(XRatio)) - scaledx;
+ int scaledh = nxagentScale(y + h, nxagentOption(YRatio)) - scaledy;
XClearArea(nxagentDisplay, nxagentWindow(owner), scaledx, scaledy, scaledw, scaledh, 0);
}
@@ -921,9 +853,8 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#endif /* #if !defined(COLLECTED_UPDATES) */
/*
- * Abort the loop on the user's input.
- * This is done here to check for events
- * read after the flush caused by the
+ * Abort the loop on the user's input. This is done here to
+ * check for events read after the flush caused by the
* PutImage.
*/
@@ -959,10 +890,9 @@ nxagentSynchronizeRegionStop:
if (nxagentSynchronization.abort == 1)
{
/*
- * Storing the pointer to the drawable we
- * were synchronizing when the loop aborted.
- * It is used in nxagentSynchronizeDrawable-
- * Predicate.
+ * Storing the pointer to the drawable we were synchronizing
+ * when the loop aborted. It is used in
+ * nxagentSynchronizeDrawablePredicate.
*/
nxagentSynchronization.pDrawable = pDrawable;
@@ -993,14 +923,12 @@ nxagentSynchronizeRegionStop:
nxagentIsCorruptedBackground((PixmapPtr) pDrawable) == 1 &&
RegionNil(&exposeRegion) == 0)
{
- struct nxagentExposeBackground eb;
+ struct nxagentExposeBackground eb = {
+ .pBackground = (PixmapPtr) pDrawable,
+ .pExpose = &exposeRegion,
+ };
- int i;
-
- eb.pBackground = (PixmapPtr) pDrawable;
- eb.pExpose = &exposeRegion;
-
- for (i = 0; i < MAXCLIENTS; i++)
+ for (int i = 0; i < MAXCLIENTS; i++)
{
if (clients[i] != NULL)
{
@@ -1019,27 +947,22 @@ nxagentSynchronizeRegionStop:
RegionValidate(&collectedUpdates, &overlap);
- for (i = 0; i < RegionNumRects(&collectedUpdates); i++)
+ for (int i = 0; i < RegionNumRects(&collectedUpdates); i++)
{
- x = RegionRects(&collectedUpdates)[i].x1;
- y = RegionRects(&collectedUpdates)[i].y1;
- w = RegionRects(&collectedUpdates)[i].x2 - RegionRects(&collectedUpdates)[i].x1;
- h = RegionRects(&collectedUpdates)[i].y2 - RegionRects(&collectedUpdates)[i].y1;
+ int x = RegionRects(&collectedUpdates)[i].x1;
+ int y = RegionRects(&collectedUpdates)[i].y1;
+ int w = RegionRects(&collectedUpdates)[i].x2 - RegionRects(&collectedUpdates)[i].x1;
+ int h = RegionRects(&collectedUpdates)[i].y2 - RegionRects(&collectedUpdates)[i].y1;
if (nxagentOption(Shadow) == 1 &&
(nxagentOption(XRatio) != DONT_SCALE ||
nxagentOption(YRatio) != DONT_SCALE))
{
- int scaledx;
- int scaledy;
- int scaledw;
- int scaledh;
-
- scaledx = nxagentScale(x, nxagentOption(XRatio));
- scaledy = nxagentScale(y, nxagentOption(YRatio));
+ int scaledx = nxagentScale(x, nxagentOption(XRatio));
+ int scaledy = nxagentScale(y, nxagentOption(YRatio));
- scaledw = nxagentScale(x + w, nxagentOption(XRatio)) - scaledx;
- scaledh = nxagentScale(y + h, nxagentOption(YRatio)) - scaledy;
+ int scaledw = nxagentScale(x + w, nxagentOption(XRatio)) - scaledx;
+ int scaledh = nxagentScale(y + h, nxagentOption(YRatio)) - scaledy;
XClearArea(nxagentDisplay, nxagentWindow(owner), scaledx, scaledy, scaledw, scaledh, 0);
}
@@ -1074,8 +997,6 @@ nxagentSynchronizeRegionFree:
void nxagentSynchronizeBox(DrawablePtr pDrawable, BoxPtr pBox, unsigned int breakMask)
{
- RegionPtr pRegion;
-
if (nxagentDrawableStatus(pDrawable) == Synchronized)
{
#ifdef TEST
@@ -1102,7 +1023,7 @@ void nxagentSynchronizeBox(DrawablePtr pDrawable, BoxPtr pBox, unsigned int brea
pBox -> x1, pBox -> y1, pBox -> x2, pBox -> y2);
#endif
- pRegion = nxagentCreateRegion(pDrawable, NULL, pBox -> x1, pBox -> y1,
+ RegionPtr pRegion = nxagentCreateRegion(pDrawable, NULL, pBox -> x1, pBox -> y1,
pBox -> x2 - pBox -> x1, pBox -> y2 - pBox -> y1);
@@ -1138,10 +1059,9 @@ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2)
int shouldClearHiddenRegion = 1;
/*
- * The nxagentSynchronization.abort propa-
- * gates a break condition across the resour-
- * ces loop, in order to block also the sub-
- * sequent synchronizations.
+ * The nxagentSynchronization.abort propagates a break condition
+ * across the resources loop, in order to block also the subsequent
+ * synchronizations.
*/
if (nxagentSynchronization.abort == 1 ||
@@ -1151,10 +1071,9 @@ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2)
}
/*
- * In order to implement a kind of round-robin
- * synchronization, the previous incomplete
- * drawable synchronization is saved to jump
- * to the next resource available of same type.
+ * In order to implement a kind of round-robin synchronization, the
+ * previous incomplete drawable synchronization is saved to jump to
+ * the next resource available of same type.
*/
if (nxagentSynchronization.pDrawable != NULL &&
@@ -1186,10 +1105,8 @@ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2)
if (pDrawable -> type == DRAWABLE_PIXMAP)
{
/*
- * The pixmaps to be synchronized are those
- * used as background or used as source of
- * any deferred operations for at least 2
- * times.
+ * The pixmaps to be synchronized are those used as background or
+ * used as source of any deferred operations for at least 2 times.
*/
if (NXAGENT_SHOULD_SYNCHRONIZE_PIXMAP(pDrawable) == 0)
@@ -1234,17 +1151,15 @@ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2)
}
/*
- * Postpone the synchronization if we went
- * out of bandwidth or if the display blocks.
- * The pixmap synchronization is more careful
+ * Postpone the synchronization if we went out of bandwidth or if
+ * the display blocks. The pixmap synchronization is more careful
* with bandwidth usage.
*/
/*
-FIXME: This condition sounds only as a
- complication, as the break parameters
- are already checked while synchroni-
- zing the drawable.
+FIXME: This condition sounds only as a complication, as the break
+ parameters are already checked while synchronizing the
+ drawable.
if (breakOnCongestion(*breakMask) == 1 ||
(pDrawable -> type == DRAWABLE_PIXMAP &&
@@ -1275,10 +1190,9 @@ FIXME: This condition sounds only as a
#endif
/*
- * The stored bitmap is destroyed inside
- * the synchronization loop, so we have
- * to check here its presence to know if
- * we can clear the dirty windows.
+ * The stored bitmap is destroyed inside the synchronization loop,
+ * so we have to check here its presence to know if we can clear the
+ * dirty windows.
*/
shouldClearHiddenRegion = (nxagentDrawableBitmap(pDrawable) == NullPixmap);
@@ -1293,10 +1207,9 @@ FIXME: This condition sounds only as a
#endif
/*
- * If the remaining corrupted region is on
- * an hidden section (not viewable or outside
- * of the pixmap's area) of a drawable,
- * we can clear it.
+ * If the remaining corrupted region is on an hidden section (not
+ * viewable or outside of the pixmap's area) of a drawable, we can
+ * clear it.
*/
if (nxagentSynchronization.abort == 0 &&
@@ -1314,14 +1227,9 @@ FIXME: This condition sounds only as a
void nxagentSynchronizationLoop(unsigned int mask)
{
- unsigned int breakMask;
-
- int doRoundRobin;
-
/*
-FIXME: All drawables should be set as synchronized and
- never marked as corrupted while the display is
- down.
+FIXME: All drawables should be set as synchronized and never marked as
+ corrupted while the display is down.
*/
nxagentSkipImage = nxagentTooManyImageData();
@@ -1358,17 +1266,15 @@ FIXME: All drawables should be set as synchronized and
"blocking [%d].\n", nxagentCongestion, nxagentBlocking);
#endif
- breakMask = mask;
+ unsigned int breakMask = mask;
/*
- * The resource counter can be reset if we
- * have not aborted the synchronization loop,
- * if we are not skipping resources to do
- * round-robin and if the bitmaps are all
- * synchronized.
+ * The resource counter can be reset if we have not aborted the
+ * synchronization loop, if we are not skipping resources to do
+ * round-robin and if the bitmaps are all synchronized.
*/
- doRoundRobin = (nxagentSynchronization.pDrawable != NULL);
+ int doRoundRobin = (nxagentSynchronization.pDrawable != NULL);
nxagentSynchronization.abort = 0;
@@ -1436,11 +1342,10 @@ FIXME: All drawables should be set as synchronized and
}
/*
- * If there is bandwidth remaining, synchronize
- * the pixmaps. Synchronizing a pixmap doesn't
- * produce any visible results. Better is to
- * synchronize them on demand, before using the
- * pixmap in a copy or in a composite operation.
+ * If there is bandwidth remaining, synchronize the
+ * pixmaps. Synchronizing a pixmap doesn't produce any visible
+ * results. Better is to synchronize them on demand, before using
+ * the pixmap in a copy or in a composite operation.
*/
if (nxagentSynchronization.abort == 0 &&
@@ -1474,9 +1379,8 @@ FIXME: All drawables should be set as synchronized and
}
/*
- * If the last synchronized drawable has been
- * removed, we have to reset the variable sto-
- * ring its pointer.
+ * If the last synchronized drawable has been removed, we have to
+ * reset the variable sto- ring its pointer.
*/
if (nxagentSynchronization.pDrawable != NULL &&
@@ -1508,15 +1412,8 @@ FIXME: All drawables should be set as synchronized and
RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
int width, int height)
{
- RegionPtr pRegion;
- BoxRec box;
-
- box.x1 = x;
- box.y1 = y;
- box.x2 = x + width;
- box.y2 = y + height;
-
- pRegion = RegionCreate(&box, 1);
+ BoxRec box = {.x1 = x, .y1 = y, .x2 = x + width, .y2 = y + height};
+ RegionPtr pRegion = RegionCreate(&box, 1);
/*
* Clipping the region.
@@ -1524,22 +1421,17 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
if (pDrawable -> type == DRAWABLE_PIXMAP)
{
- BoxRec tmpBox;
- RegionRec tmpRegion;
-
/*
- * The region created doesn't need to be clipped
- * if it has the pixmap dimensions.
+ * The region created doesn't need to be clipped if it has the
+ * pixmap dimensions.
*/
if (x != 0 || y != 0 ||
width != pDrawable -> width ||
height != pDrawable -> height)
{
- tmpBox.x1 = 0;
- tmpBox.y1 = 0;
- tmpBox.x2 = pDrawable -> width;
- tmpBox.y2 = pDrawable -> height;
+ BoxRec tmpBox = {.x1 = 0, .y1 = 0, .x2 = pDrawable -> width, .y2 = pDrawable -> height};
+ RegionRec tmpRegion;
RegionInit(&tmpRegion, &tmpBox, 1);
@@ -1551,9 +1443,8 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
else
{
/*
- * We use the clipList because the borderClip
- * contains also parts of the window covered
- * by its children.
+ * We use the clipList because the borderClip contains also parts
+ * of the window covered by its children.
*/
RegionTranslate(pRegion,
@@ -1579,8 +1470,8 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
#endif
/*
- * If the pRegion is NIL we don't need
- * to intersect it with the GC's clipmask.
+ * If the pRegion is NIL we don't need to intersect it with the GC's
+ * clipmask.
*/
if (RegionNil(pRegion) == 0 &&
@@ -1594,9 +1485,9 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
RegionCopy(&clipRegion, (RegionPtr) pGC -> clientClip);
/*
- * The clip origin is relative to the origin of
- * the destination drawable. The clip mask coor-
- * dinates are relative to the clip origin.
+ * The clip origin is relative to the origin of the destination
+ * drawable. The clip mask coor- dinates are relative to the clip
+ * origin.
*/
if (pGC -> clipOrg.x != 0 || pGC -> clipOrg.y != 0)
@@ -1620,11 +1511,6 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
{
- int x;
- int y;
- int width;
- int height;
-
if (pRegion != NullRegion && RegionNil(pRegion) == 1)
{
#ifdef TEST
@@ -1636,10 +1522,9 @@ void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
}
/*
- * If the drawable was synchronized, the counter
- * reporting the number of corrupted drawables
- * must be increased. Moreover the corrupted ti-
- * mestamp must be set.
+ * If the drawable was synchronized, the counter reporting the
+ * number of corrupted drawables must be increased. Moreover the
+ * corrupted ti- mestamp must be set.
*/
if (nxagentDrawableStatus(pDrawable) == Synchronized)
@@ -1654,11 +1539,11 @@ void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
if (pRegion == NullRegion)
{
- x = 0;
- y = 0;
+ int x = 0;
+ int y = 0;
- width = pDrawable -> width;
- height = pDrawable -> height;
+ int width = pDrawable -> width;
+ int height = pDrawable -> height;
#ifdef TEST
fprintf(stderr, "nxagentMarkCorruptedRegion: Fully invalidating %s [%p] with "
@@ -1700,8 +1585,6 @@ void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
{
- int oldStatus;
-
if (pRegion != NullRegion && RegionNil(pRegion) == 1)
{
#ifdef TEST
@@ -1712,7 +1595,7 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
return;
}
- oldStatus = nxagentDrawableStatus(pDrawable);
+ int oldStatus = nxagentDrawableStatus(pDrawable);
if (oldStatus == Synchronized)
{
@@ -1752,9 +1635,8 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
}
/*
- * If the drawable becomes synchronized, the
- * counter reporting the number of corrupted
- * drawables must be decreased. Moreover the
+ * If the drawable becomes synchronized, the counter reporting the
+ * number of corrupted drawables must be decreased. Moreover the
* corrupted timestamp must be reset.
*/
@@ -1777,8 +1659,8 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
nxagentResetCorruptedTimestamp(pDrawable);
/*
- * If the resource is no longer dirty,
- * the associated bitmap is destroyed.
+ * If the resource is no longer dirty, the associated bitmap is
+ * destroyed.
*/
if (nxagentDrawableBitmap(pDrawable) != NullPixmap)
@@ -1791,9 +1673,8 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask)
{
/*
- * If a window is resized, its corrupted
- * region is moved according to the bit
- * gravity.
+ * If a window is resized, its corrupted region is moved according
+ * to the bit gravity.
*/
if (nxagentDrawableStatus((DrawablePtr) pWin) == NotSynchronized)
@@ -1819,18 +1700,17 @@ void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask)
nx, ny);
/*
- * Having moved the corrupted region, we
- * need to invalidate the pending commits
- * or otherwise the image will fall in
- * the wrong area.
+ * Having moved the corrupted region, we need to invalidate the
+ * pending commits or otherwise the image will fall in the wrong
+ * area.
*/
nxagentValidateSplit((DrawablePtr) pWin, NULL);
/*
- * The window reconfiguration invalidates
- * the synchronization bitmap.
+ * The window reconfiguration invalidates the synchronization
+ * bitmap.
*/
nxagentDestroyDrawableBitmap((DrawablePtr) pWin);
@@ -1839,13 +1719,12 @@ void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask)
}
/*
- * The DDX layer uses an 'Y-X banding' representation of
- * regions: it sorts all rectangles composing a region
- * using first the y-dimension, than the x-dimension; mo-
- * reover it organizes the rectangles in 'bands' sharing
- * the same y-dimension. This representation does not mi-
- * nimize the number of rectangles. For example, the fol-
- * lowing region has 4 rectangles:
+ * The DDX layer uses an 'Y-X banding' representation of regions: it
+ * sorts all rectangles composing a region using first the
+ * y-dimension, than the x-dimension; moreover it organizes the
+ * rectangles in 'bands' sharing the same y-dimension. This
+ * representation does not minimize the number of rectangles. For
+ * example, the following region has 4 rectangles:
*
* +-----------+
* | | +---+
@@ -1853,40 +1732,30 @@ void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask)
* | | +---+
* +-----------+
*
- * The rectangle 'B' creates a band which splits the rec-
- * tangle A in 3 parts, for a total of 3 bands. The num-
- * ber of rectangles composing the region is 4.
+ * The rectangle 'B' creates a band which splits the rectangle A in 3
+ * parts, for a total of 3 bands. The number of rectangles composing
+ * the region is 4.
*
- * This kind of representation is not advisable for the
- * lazy synchronization because, in the example above,
- * the nxagent had to send 4 put images instead of 2.
+ * This kind of representation is not advisable for the lazy
+ * synchronization because, in the example above, the nxagent had to
+ * send 4 put images instead of 2.
*
- * To minimize the problem we use the following function:
- * by traversing the list of rectangles we merge all bo-
- * xes with same x coordinates and coincident y, in order
- * to create an X-Y banding.
+ * To minimize the problem we use the following function: by
+ * traversing the list of rectangles we merge all boxes with same x
+ * coordinates and coincident y, in order to create an X-Y banding.
*
- * Be careful: all the coordinates of boxes merged are
- * set to 0, so take care of this when looping through
- * the box list returned by this function.
+ * Be careful: all the coordinates of boxes merged are set to 0, so
+ * take care of this when looping through the box list returned by
+ * this function.
*/
BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
{
- BoxPtr pBox;
-
BoxRec boxExtents;
- int nBox;
- int i, j;
-
- #ifdef DEBUG
- int nBoxOptim;
- #endif
-
- pBox = RegionRects(pRegion);
+ BoxPtr pBox = RegionRects(pRegion);
- nBox = RegionNumRects(pRegion);
+ int nBox = RegionNumRects(pRegion);
#ifdef TEST
fprintf(stderr, "nxagentGetOptimizedRegionBoxes: Going to optimize region at [%p] with [%d] rects.\n",
@@ -1899,21 +1768,19 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
}
#ifdef DEBUG
- nBoxOptim = nBox;
+ int nBoxOptim = nBox;
#endif
/*
- * The boxes are now grouped to grown as much
- * as possible, using their overlapping vertex
- * as rule.
+ * The boxes are now grouped to grown as much as possible, using
+ * their overlapping vertex as rule.
*/
- for (i = 0; i < nBox; i++)
+ for (int i = 0; i < nBox; i++)
{
/*
- * If the coordinates are (0,0) the box
- * has been already merged, so we can skip
- * it.
+ * If the coordinates are (0,0) the box has been already merged,
+ * so we can skip it.
*/
if (pBox[i].x1 == 0 && pBox[i].y1 == 0 &&
@@ -1937,7 +1804,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
boxExtents.y2 = pBox[i].y2;
- for (j = i+1; j < nBox; j++)
+ for (int j = i+1; j < nBox; j++)
{
if (pBox[j].x1 == 0 && pBox[j].y1 == 0 &&
pBox[j].x2 == 0 && pBox[j].y2 == 0)
@@ -1951,12 +1818,10 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
#endif
/*
- * Each consequent box is merged if its
- * higher side overlaps the lower side
- * of current box.
- * In case of ADVANCED_BOXES_DEFRAG the higher
- * side must be included within a range
- * defined by INCLUDE_MARGIN.
+ * Each consequent box is merged if its higher side overlaps the
+ * lower side of current box. In case of ADVANCED_BOXES_DEFRAG
+ * the higher side must be included within a range defined by
+ * INCLUDE_MARGIN.
*/
#ifndef ADVANCED_BOXES_DEFRAG
@@ -2006,11 +1871,9 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
}
/*
- * By appending a box to another, we have
- * to remove it from the box list. We do
- * this by setting its coordinates to (0,0)
- * and by checking their value in the main
- * loop.
+ * By appending a box to another, we have to remove it from
+ * the box list. We do this by setting its coordinates to
+ * (0,0) and by checking their value in the main loop.
*/
pBox[j].x1 = pBox[j].y1 = pBox[j].x2 = pBox[j].y2 = 0;
@@ -2039,13 +1902,12 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
#ifdef ADVANCED_BOXES_DEFRAG
/*
- * The new list need to be validated to
- * avoid boxes overlapping. This code may
- * be improved to remove also the partial-
- * ly overlapping boxes.
+ * The new list need to be validated to avoid boxes
+ * overlapping. This code may be improved to remove also the
+ * partial- ly overlapping boxes.
*/
- for (i = 0; i < nBox; i++)
+ for (int i = 0; i < nBox; i++)
{
if (pBox[i].x1 == 0 && pBox[i].y1 == 0 &&
pBox[i].x2 == 0 && pBox[i].y2 == 0)
@@ -2063,7 +1925,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
boxExtents.x2 = pBox[i].x2;
boxExtents.y2 = pBox[i].y2;
- for (j = i+1; j < nBox; j++)
+ for (int j = i+1; j < nBox; j++)
{
if (pBox[j].x1 == 0 && pBox[j].y1 == 0 &&
pBox[j].x2 == 0 && pBox[j].y2 == 0)
@@ -2082,9 +1944,8 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
boxExtents.y2 >= pBox[j].y2))
{
/*
- * If a box is completely inside
- * another, we set its coordinates
- * to 0 to consider it as merged.
+ * If a box is completely inside another, we set its
+ * coordinates to 0 to consider it as merged.
*/
#ifdef DEBUG
@@ -2115,19 +1976,14 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
{
- XImage *ximage;
- Visual *pVisual;
- char *data;
-
- int depth, format, length;
int leftPad = 0;
- unsigned long pixel;
- depth = pDrawable -> depth;
- format = (depth == 1) ? XYPixmap : ZPixmap;
- length = nxagentImageLength(1, 1, format, leftPad, depth);
+ int depth = pDrawable -> depth;
+ int format = (depth == 1) ? XYPixmap : ZPixmap;
+ int length = nxagentImageLength(1, 1, format, leftPad, depth);
- if ((data = malloc(length)) == NULL)
+ char * data = malloc(length);
+ if (data == NULL)
{
#ifdef WARNING
fprintf(stderr, "nxagentGetColor: WARNING! Failed to allocate memory for the operation.\n");
@@ -2136,7 +1992,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
return -1;
}
- pVisual = nxagentImageVisual(pDrawable, depth);
+ Visual *pVisual = nxagentImageVisual(pDrawable, depth);
if (pVisual == NULL)
{
@@ -2149,9 +2005,9 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
fbGetImage(pDrawable, xPixel, yPixel, 1, 1, format, AllPlanes, data);
- ximage = XCreateImage(nxagentDisplay, pVisual, depth, format, leftPad, (char *) data,
- 1, 1, BitmapPad(nxagentDisplay),
- nxagentImagePad(1, format, leftPad, 1));
+ XImage *ximage = XCreateImage(nxagentDisplay, pVisual, depth, format, leftPad, (char *) data,
+ 1, 1, BitmapPad(nxagentDisplay),
+ nxagentImagePad(1, format, leftPad, 1));
if (ximage == NULL)
{
@@ -2164,7 +2020,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
return -1;
}
- pixel = XGetPixel(ximage, 0, 0);
+ unsigned long pixel = XGetPixel(ximage, 0, 0);
XDestroyImage(ximage);
@@ -2172,34 +2028,30 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
}
/*
- * This function could be used to determine
- * the ClearArea color of corrupted regions
- * on screen.
+ * This function could be used to determine the ClearArea color of
+ * corrupted regions on screen.
*/
unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion)
{
- int xPicker, yPicker;
-
if (RegionNil(pRegion) == 1)
{
return nxagentGetDrawableColor(pDrawable);
}
/*
- * The pixel used as reference is the first
- * outer pixel at the bottom right corner
- * of corrupted region extents.
+ * The pixel used as reference is the first outer pixel at the
+ * bottom right corner of corrupted region extents.
*/
- xPicker = pRegion -> extents.x2 + 1;
+ int xPicker = pRegion -> extents.x2 + 1;
if (xPicker > pDrawable -> width)
{
xPicker = pDrawable -> width;
}
- yPicker = pRegion -> extents.y2 + 1;
+ int yPicker = pRegion -> extents.y2 + 1;
if (yPicker > pDrawable -> height)
{
@@ -2211,30 +2063,17 @@ unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion)
unsigned long nxagentGetDrawableColor(DrawablePtr pDrawable)
{
- int xPicker, yPicker;
-
/*
- * The pixel used to determine the co-
- * lor of a drawable is at coordinates
- * (x + width - 4, y + 4).
+ * The pixel used to determine the color of a drawable is at
+ * coordinates (x + width - 4, y + 4).
*/
- xPicker = pDrawable -> width - 4;
-
- yPicker = 4;
-
- return nxagentGetColor(pDrawable, xPicker, yPicker);
+ return nxagentGetColor(pDrawable, pDrawable -> width - 4, 4);
}
void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
{
- WindowPtr pWin;
- BoxPtr pBox;
-
- unsigned long color;
unsigned long backupPixel = 0;
- int nBox, i;
- int restore;
#ifdef DEBUG
static int nBoxCleared;
@@ -2258,13 +2097,13 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
return;
}
- pWin = (WindowPtr) pDrawable;
+ WindowPtr pWin = (WindowPtr) pDrawable;
- restore = 0;
+ int restore = 0;
/*
- * If the window has already a background, we
- * can hope it will be nice.
+ * If the window has already a background, we can hope it will be
+ * nice.
*/
if (pWin -> backgroundState != None)
@@ -2282,7 +2121,7 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
backupPixel = pWin -> background.pixel;
- color = nxagentGetDrawableColor((DrawablePtr) pWin);
+ unsigned long color = nxagentGetDrawableColor((DrawablePtr) pWin);
if (color == -1)
{
@@ -2302,11 +2141,11 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
restore = 1;
}
- pBox = nxagentGetOptimizedRegionBoxes(pRegion);
+ BoxPtr pBox = nxagentGetOptimizedRegionBoxes(pRegion);
- nBox = RegionNumRects(pRegion);
+ int nBox = RegionNumRects(pRegion);
- for (i = 0; i < nBox; i++)
+ for (int i = 0; i < nBox; i++)
{
if (pBox[i].x1 == 0 && pBox[i].y1 == 0 &&
pBox[i].x2 == 0 && pBox[i].y2 == 0)
@@ -2339,21 +2178,14 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
void nxagentFillRemoteRegion(DrawablePtr pDrawable, RegionPtr pRegion)
{
- GCPtr pGC;
- BoxPtr pBox;
- XRectangle *pRects;
-
- int nrects;
- int i;
-
if (RegionNil(pRegion) == 1)
{
return;
}
- pGC = nxagentGetGraphicContext(pDrawable);
+ GCPtr pGC = nxagentGetGraphicContext(pDrawable);
- nrects = RegionNumRects(pRegion);
+ int nrects = RegionNumRects(pRegion);
#ifdef TEST
fprintf(stderr, "nxagentFillRemoteRegion: Going to fill remote region [%d,%d,%d,%d] rects [%d] with color [%lu].\n",
@@ -2370,11 +2202,10 @@ void nxagentFillRemoteRegion(DrawablePtr pDrawable, RegionPtr pRegion)
}
else
{
- pBox = RegionRects(pRegion);
+ BoxPtr pBox = RegionRects(pRegion);
+ XRectangle *pRects = malloc(nrects * sizeof(XRectangle));
- pRects = malloc(nrects * sizeof(XRectangle));
-
- for (i = 0; i < nrects; i++)
+ for (int i = 0; i < nrects; i++)
{
pRects[i].x = pBox[i].x1;
pRects[i].y = pBox[i].y1;
@@ -2428,20 +2259,14 @@ int nxagentDestroyCorruptedBackgroundResource(void * p, XID id)
void nxagentPointsToDirtyRegion(DrawablePtr pDrawable, int mode,
int nPoints, xPoint *pPoints)
{
- RegionPtr pRegion;
- RegionRec tmpRegion;
- BoxRec box, extents;
-
- xPoint *xp;
- int np;
-
- np = nPoints;
- xp = pPoints;
-
- pRegion = RegionCreate(NullBox, 1);
+ RegionPtr pRegion = RegionCreate(NullBox, 1);
+ int np = nPoints;
while (np--)
{
+ BoxRec box;
+ xPoint *xp = pPoints;
+
if (CoordModePrevious)
{
box.x1 = box.x2 = (xp-1) -> x + xp -> x;
@@ -2463,6 +2288,7 @@ void nxagentPointsToDirtyRegion(DrawablePtr pDrawable, int mode,
* this loop could become less expensive.
*/
+ RegionRec tmpRegion;
RegionInit(&tmpRegion, &box, 1);
RegionUnion(pRegion, pRegion, &tmpRegion);
@@ -2472,7 +2298,7 @@ void nxagentPointsToDirtyRegion(DrawablePtr pDrawable, int mode,
xp++;
}
- extents = *RegionExtents(pRegion);
+ BoxRec extents = *RegionExtents(pRegion);
RegionReset(pRegion, &extents);
@@ -2604,35 +2430,27 @@ void nxagentRegionsOnScreen(void)
#endif
/*
- * If the synchronization loop breaks and the
- * drawable synchronization cannot be completed,
- * the remaining data is stored in a bitmap.
- * The synchronization loop is then restarted
- * using the bitmap as source instead of the
- * drawable.
+ * If the synchronization loop breaks and the drawable synchronization
+ * cannot be completed, the remaining data is stored in a bitmap. The
+ * synchronization loop is then restarted using the bitmap as source
+ * instead of the drawable.
*/
void nxagentCreateDrawableBitmap(DrawablePtr pDrawable)
{
- PixmapPtr pBitmap;
GCPtr pGC = NULL;
RegionPtr pClipRegion = NullRegion;
- int x, y;
- int w, h;
- int saveTrap;
-
#ifdef TEST
fprintf(stderr, "nxagentCreateDrawableBitmap: Creating synchronization bitmap for [%s] at [%p].\n",
nxagentDrawableType(pDrawable), (void *) pDrawable);
#endif
/*
- * The bitmap is created only in the
- * nxagent.
+ * The bitmap is created only in the nxagent.
*/
- saveTrap = nxagentGCTrap;
+ int saveTrap = nxagentGCTrap;
nxagentGCTrap = 1;
@@ -2646,9 +2464,8 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable)
}
/*
- * Should create a function to append
- * a bitmap to another, instead of
- * destroying the old one.
+ * Should create a function to append a bitmap to another, instead
+ * of destroying the old one.
*/
if (nxagentDrawableBitmap(pDrawable) != NullPixmap)
@@ -2683,15 +2500,14 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable)
}
/*
- * FIXME: A better way it would be create the bitmap
- * with the same extents of the clipRegion. This
- * requires to save the offset with respect to the
- * drawable origin like in the backing store. This
- * becomes particularly important when the drawable
- * is a huge window, because the pixmap creation
- * would fail.
+ * FIXME: A better way it would be create the bitmap with the same
+ * extents of the clipRegion. This requires to save the offset with
+ * respect to the drawable origin like in the backing store. This
+ * becomes particularly important when the drawable is a huge
+ * window, because the pixmap creation would fail.
*/
+ PixmapPtr pBitmap;
pBitmap = nxagentCreatePixmap(pDrawable -> pScreen, pDrawable -> width, pDrawable -> height, pDrawable -> depth, 0);
if (pBitmap == NULL)
@@ -2707,10 +2523,10 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable)
ValidateGC((DrawablePtr) pBitmap, pGC);
- x = pClipRegion -> extents.x1;
- y = pClipRegion -> extents.y1;
- w = pClipRegion -> extents.x2 - pClipRegion -> extents.x1;
- h = pClipRegion -> extents.y2 - pClipRegion -> extents.y1;
+ int x = pClipRegion -> extents.x1;
+ int y = pClipRegion -> extents.y1;
+ int w = pClipRegion -> extents.x2 - pClipRegion -> extents.x1;
+ int h = pClipRegion -> extents.y2 - pClipRegion -> extents.y1;
nxagentCopyArea(pDrawable, (DrawablePtr) pBitmap, pGC, x, y, w, h, x, y);
@@ -2850,9 +2666,8 @@ void nxagentAllocateCorruptedResource(DrawablePtr pDrawable, RESTYPE type)
if (nxagentPixmapPriv(pRealPixmap) -> corruptedBackgroundId == 0)
{
/*
- * When a pixmap is added to the background
- * corrupted resources, it must be removed
- * from the pixmap corrupted resources.
+ * When a pixmap is added to the background corrupted resources,
+ * it must be removed from the pixmap corrupted resources.
*/
nxagentDestroyCorruptedResource(pDrawable, RT_NX_CORR_PIXMAP);
@@ -2873,8 +2688,8 @@ void nxagentAllocateCorruptedResource(DrawablePtr pDrawable, RESTYPE type)
else if (type == RT_NX_CORR_PIXMAP)
{
/*
- * The shared memory pixmaps are always dirty
- * and shouldn't be synchronized.
+ * The shared memory pixmaps are always dirty and shouldn't be
+ * synchronized.
*/
if (nxagentPixmapUsageCounter((PixmapPtr) pDrawable) >= MINIMUM_PIXMAP_USAGE_COUNTER &&
@@ -3044,11 +2859,9 @@ int nxagentSynchronizationPredicate(void)
}
/*
- * If there are resources to synchronize
- * but the conditions to start the loop
- * are not satisfied, a little delay is
- * requested to check for a new loop as
- * soon as possible.
+ * If there are resources to synchronize but the conditions to start
+ * the loop are not satisfied, a little delay is requested to check
+ * for a new loop as soon as possible.
*/
return Delayed;
@@ -3150,7 +2963,6 @@ nxagentSendBackgroundExposeEnd:
void nxagentExposeBackgroundPredicate(void *p0, XID x1, void *p2)
{
WindowPtr pWin = (WindowPtr) p0;
- WindowPtr pParent;
struct nxagentExposeBackground *pPair = p2;
@@ -3176,7 +2988,7 @@ void nxagentExposeBackgroundPredicate(void *p0, XID x1, void *p2)
(void *) pWin);
#endif
- pParent = pWin -> parent;
+ WindowPtr pParent = pWin -> parent;
while (pParent != NULL)
{
@@ -3204,21 +3016,14 @@ void nxagentExposeBackgroundPredicate(void *p0, XID x1, void *p2)
int nxagentClipAndSendClearExpose(WindowPtr pWin, void * ptr)
{
- RegionPtr exposeRgn;
- RegionPtr remoteExposeRgn;
-
- #ifdef DEBUG
- BoxRec box;
- #endif
-
- remoteExposeRgn = (RegionRec *) ptr;
+ RegionPtr remoteExposeRgn = (RegionRec *) ptr;
if (nxagentWindowPriv(pWin) -> deferredBackgroundExpose == 1)
{
- exposeRgn = RegionCreate(NULL, 1);
+ RegionPtr exposeRgn = RegionCreate(NULL, 1);
#ifdef DEBUG
- box = *RegionExtents(remoteExposeRgn);
+ BoxRec box = *RegionExtents(remoteExposeRgn);
fprintf(stderr, "nxagentClipAndSendClearExpose: Background expose extents: [%d,%d,%d,%d].\n",
box.x1, box.y1, box.x2, box.y2);
@@ -3232,9 +3037,8 @@ int nxagentClipAndSendClearExpose(WindowPtr pWin, void * ptr)
RegionIntersect(exposeRgn, remoteExposeRgn, &pWin -> clipList);
/*
- * If the region will be synchronized,
- * the expose on corrupted regions can
- * be ignored.
+ * If the region will be synchronized, the expose on corrupted
+ * regions can be ignored.
*/
RegionSubtract(exposeRgn, exposeRgn, nxagentCorruptedRegion((DrawablePtr) pWin));
@@ -3295,4 +3099,3 @@ void nxagentSendDeferredBackgroundExposures(void)
RegionEmpty(nxagentDeferredBackgroundExposures);
}
}
-
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c
index 0d4ef3107..6b91ea94d 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Error.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c
@@ -325,16 +325,13 @@ void nxagentEndRedirectToClientsLog(void)
char *nxagentGetHomePath(void)
{
- char *homeEnv;
- char *homePath;
-
if (*nxagentHomeDir == '\0')
{
/*
* Check the NX_HOME environment.
*/
- homeEnv = getenv("NX_HOME");
+ char *homeEnv = getenv("NX_HOME");
if (homeEnv == NULL || *homeEnv == '\0')
{
@@ -369,7 +366,7 @@ char *nxagentGetHomePath(void)
#endif
}
- homePath = strdup(nxagentHomeDir);
+ char *homePath = strdup(nxagentHomeDir);
if (homePath == NULL)
{
@@ -385,19 +382,13 @@ char *nxagentGetHomePath(void)
char *nxagentGetRootPath(void)
{
- char *rootEnv;
- char *homeEnv;
- char *rootPath;
-
- struct stat dirStat;
-
if (*nxagentRootDir == '\0')
{
/*
* Check the NX_ROOT environment.
*/
- rootEnv = getenv("NX_ROOT");
+ char *rootEnv = getenv("NX_ROOT");
if (rootEnv == NULL || *rootEnv == '\0')
{
@@ -406,12 +397,11 @@ char *nxagentGetRootPath(void)
#endif
/*
- * We will determine the root NX directory
- * based on the NX_HOME or HOME directory
- * settings.
+ * We will determine the root NX directory based on the NX_HOME
+ * or HOME directory settings.
*/
- homeEnv = nxagentGetHomePath();
+ char *homeEnv = nxagentGetHomePath();
if (homeEnv == NULL)
{
@@ -443,6 +433,7 @@ char *nxagentGetRootPath(void)
* Create the NX root directory.
*/
+ struct stat dirStat;
if ((stat(nxagentRootDir, &dirStat) == -1) && (errno == ENOENT))
{
if (mkdir(nxagentRootDir, 0777) < 0 && (errno != EEXIST))
@@ -478,7 +469,7 @@ char *nxagentGetRootPath(void)
}
- rootPath = strdup(nxagentRootDir);
+ char *rootPath = strdup(nxagentRootDir);
if (rootPath == NULL)
{
@@ -494,19 +485,12 @@ char *nxagentGetRootPath(void)
char *nxagentGetSessionPath(void)
{
-
- char *rootPath;
- char *sessionPath;
-
- struct stat dirStat;
-
if (*nxagentSessionDir == '\0')
{
/*
- * If nxagentSessionId does not exist we
- * assume that the sessionPath cannot be
- * realized and do not use the clients
- * log file.
+ * If nxagentSessionId does not exist we assume that the
+ * sessionPath cannot be realized and do not use the clients log
+ * file.
*/
if (*nxagentSessionId == '\0')
@@ -518,7 +502,7 @@ char *nxagentGetSessionPath(void)
return NULL;
}
- rootPath = nxagentGetRootPath();
+ char *rootPath = nxagentGetRootPath();
if (rootPath == NULL)
{
@@ -544,6 +528,7 @@ char *nxagentGetSessionPath(void)
SAFE_free(rootPath);
+ struct stat dirStat;
if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT))
{
if (mkdir(nxagentSessionDir, 0777) < 0 && (errno != EEXIST))
@@ -564,7 +549,7 @@ char *nxagentGetSessionPath(void)
}
- sessionPath = strdup(nxagentSessionDir);
+ char *sessionPath = strdup(nxagentSessionDir);
if (sessionPath == NULL)
{
@@ -580,7 +565,6 @@ char *nxagentGetSessionPath(void)
void nxagentGetClientsPath(void)
{
-
if (*nxagentClientsLogName == '\0')
{
char *sessionPath = nxagentGetSessionPath();
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c
index cbdf17a22..b9d3a9238 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c
@@ -105,9 +105,8 @@
#include "compext/Compext.h"
/*
- * Set here the required log level. Please note
- * that if you want to enable DEBUG here, then
- * you need to enable DEBUG even in Rootless.c
+ * Set here the required log level. Please note that if you want to
+ * enable DEBUG here, then you need to enable DEBUG even in Rootless.c
*/
#define PANIC
@@ -163,8 +162,7 @@ PropertyRequestRec nxagentPropertyRequests[NXNumberOfResources];
void nxagentHandleCollectPropertyEvent(XEvent*);
/*
- * Finalize the asynchronous handling
- * of the X_GrabPointer requests.
+ * Finalize the asynchronous handling of the X_GrabPointer requests.
*/
void nxagentHandleCollectGrabPointerEvent(int resource);
@@ -172,8 +170,8 @@ void nxagentHandleCollectGrabPointerEvent(int resource);
Bool nxagentCollectGrabPointerPredicate(Display *display, XEvent *X, XPointer ptr);
/*
- * Used in Handlers.c to synchronize
- * the agent with the remote X server.
+ * Used in Handlers.c to synchronize the agent with the remote X
+ * server.
*/
void nxagentHandleCollectInputFocusEvent(int resource);
@@ -193,12 +191,12 @@ static Cursor viewportCursor;
#define nextinc(x) ((x) < MAX_INC ? (x) += INC_STEP : (x))
/*
- * Keyboard and pointer are handled as they were real devices by
- * Xnest and we inherit this behaviour. The following mask will
- * contain the event mask selected for the root window of the
- * agent. All the keyboard and pointer events will be translated
- * by the agent and sent to the internal clients according to
- * events selected by the inferior windows.
+ * Keyboard and pointer are handled as they were real devices by Xnest
+ * and we inherit this behaviour. The following mask will contain the
+ * event mask selected for the root window of the agent. All the
+ * keyboard and pointer events will be translated by the agent and
+ * sent to the internal clients according to events selected by the
+ * inferior windows.
*/
static Mask defaultEventMask;
@@ -206,9 +204,8 @@ static Mask defaultEventMask;
static int lastEventSerial = 0;
/*
- * Used to mask the appropriate bits in
- * the state reported by XkbStateNotify
- * and XkbGetIndicatorState.
+ * Used to mask the appropriate bits in the state reported by
+ * XkbStateNotify and XkbGetIndicatorState.
*/
#define CAPSFLAG_IN_REPLY 1
@@ -221,8 +218,8 @@ CARD32 nxagentLastKeyPressTime = 0;
Time nxagentLastServerTime = 0;
/*
- * Used for storing windows that need to
- * receive expose events from the agent.
+ * Used for storing windows that need to receive expose events from
+ * the agent.
*/
#define nxagentExposeQueueHead nxagentExposeQueue.exposures[nxagentExposeQueue.start]
@@ -246,16 +243,14 @@ int GetWindowProperty(WindowPtr pWin, Atom property, long longOffset,
unsigned char **propData);
/*
- * Associate a resource to a drawable and
- * store the region affected by the split
- * operation.
+ * Associate a resource to a drawable and store the region affected by
+ * the split operation.
*/
SplitResourceRec nxagentSplitResources[NXNumberOfResources];
/*
- * Associate a resource to an unpack
- * operation.
+ * Associate a resource to an unpack operation.
*/
UnpackResourceRec nxagentUnpackResources[NXNumberOfResources];
@@ -269,8 +264,7 @@ Bool nxagentLastWindowDestroyed = False;
Time nxagentLastWindowDestroyedTime = 0;
/*
- * Set this flag when an user input event
- * is received.
+ * Set this flag when an user input event is received.
*/
int nxagentInputEvent = 0;
@@ -294,7 +288,7 @@ void ProcessInputEvents(void)
#ifdef NX_DEBUG_INPUT
if (nxagentDebugInput == 1)
{
- fprintf(stderr, "ProcessInputEvents: Processing input.\n");
+ fprintf(stderr, "%s: Processing input.\n", __func__);
}
#endif
@@ -306,26 +300,10 @@ char * nxagentGetNotifyMode(int mode)
{
switch (mode)
{
- case NotifyNormal:
- {
- return "NotifyNormal";
- break;
- }
- case NotifyGrab:
- {
- return "NotifyGrab";
- break;
- }
- case NotifyUngrab:
- {
- return "NotifyUngrab";
- break;
- }
- case NotifyWhileGrabbed:
- {
- return "NotifyWhileGrabbed";
- break;
- }
+ case NotifyNormal: return "NotifyNormal";
+ case NotifyGrab: return "NotifyGrab";
+ case NotifyUngrab: return "NotifyUngrab";
+ case NotifyWhileGrabbed: return "NotifyWhileGrabbed";
}
return "Unknown";
}
@@ -474,7 +452,7 @@ void nxagentRemoteWindowsTree(Window window, int level)
if (!XQueryTree(nxagentDisplay, window, &rootWin, &parentWin, &childList,
&numChildren))
{
- fprintf(stderr, "nxagentRemoteWindowsTree - XQueryTree failed.\n");
+ fprintf(stderr, "%s - XQueryTree failed.\n", __func__);
return;
}
@@ -517,7 +495,6 @@ void nxagentRemoteWindowsTree(Window window, int level)
void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine)
{
- int result;
unsigned long ulReturnItems;
unsigned long ulReturnBytesLeft;
Atom atomReturnType;
@@ -527,11 +504,11 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine)
fprintf(stderr, "Window ID=[0x%x] %s Remote ID=[0x%x] ", pWin -> drawable.id,
pWin->parent ? "" : "(the root window)", nxagentWindow(pWin));
- result = GetWindowProperty(pWin, MakeAtom("WM_NAME", 7, False) , 0,
- sizeof(CARD32), False, AnyPropertyType,
- &atomReturnType, &iReturnFormat,
- &ulReturnItems, &ulReturnBytesLeft,
- &pszReturnData);
+ int result = GetWindowProperty(pWin, MakeAtom("WM_NAME", 7, False) , 0,
+ sizeof(CARD32), False, AnyPropertyType,
+ &atomReturnType, &iReturnFormat,
+ &ulReturnItems, &ulReturnBytesLeft,
+ &pszReturnData);
fprintf(stderr, "Name: ");
@@ -589,7 +566,7 @@ void nxagentInternalWindowsTree(WindowPtr pWin, int indent)
void nxagentSwitchResizeMode(ScreenPtr pScreen)
{
#ifdef DEBUG
- fprintf(stderr, "nxagentSwitchResizeMode called.\n");
+ fprintf(stderr, "%s: Called.\n", __func__);
#endif
int desktopResize = nxagentOption(DesktopResize);
@@ -728,9 +705,8 @@ static void nxagentToggleAutoGrab(void)
static Bool nxagentExposurePredicate(Display *display, XEvent *event, XPointer window)
{
/*
- * Handle both Expose and ProcessedExpose events.
- * The latters are those not filtered by function
- * nxagentWindowExposures().
+ * Handle both Expose and ProcessedExpose events. The latters are
+ * those not filtered by function nxagentWindowExposures().
*/
if (window)
@@ -866,8 +842,8 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
#endif
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new events with "
- "predicate [%p].\n", *(void **)&predicate);
+ fprintf(stderr, "%s: Going to handle new events with predicate [%p].\n", __func__,
+ *(void **)&predicate);
#endif
if (nxagentRemoteExposeRegion == NULL)
@@ -876,37 +852,34 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
}
/*
- * We must read here, even if apparently there is
- * nothing to read. The ioctl() based readable
- * function, in fact, is often unable to detect a
- * failure of the socket, in particular if the
- * agent was connected to the proxy and the proxy
- * is gone. Thus we must trust the wakeup handler
- * that called us after the select().
+ * We must read here, even if apparently there is nothing to
+ * read. The ioctl() based readable function, in fact, is often
+ * unable to detect a failure of the socket, in particular if the
+ * agent was connected to the proxy and the proxy is gone. Thus we
+ * must trust the wakeup handler that called us after the select().
*/
#ifdef TEST
if (nxagentPendingEvents(nxagentDisplay) == 0)
{
- fprintf(stderr, "nxagentDispatchEvents: PANIC! No event needs to be dispatched.\n");
+ fprintf(stderr, "%s: PANIC! No event needs to be dispatched.\n", __func__);
}
#endif
/*
- * We want to process all the events already in
- * the queue, plus any additional event that may
- * be read from the network. If no event can be
- * read, we want to continue handling our clients
- * without flushing the output buffer.
+ * We want to process all the events already in the queue, plus any
+ * additional event that may be read from the network. If no event
+ * can be read, we want to continue handling our clients without
+ * flushing the output buffer.
*/
while (nxagentCheckEvents(nxagentDisplay, &X, predicate != NULL ? predicate :
nxagentAnyEventPredicate, NULL) == 1)
{
#ifdef DEBUG
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new event type [%d].\n",
+ fprintf(stderr, "%s: Going to handle new event type [%d].\n", __func__,
X.type);
#endif
@@ -921,7 +894,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
case SelectionClear:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new SelectionClear event.\n");
+ fprintf(stderr, "%s: Going to handle new SelectionClear event.\n", __func__);
#endif
nxagentClearSelection(&X);
@@ -931,7 +904,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
case SelectionRequest:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new SelectionRequest event.\n");
+ fprintf(stderr, "%s: Going to handle new SelectionRequest event.\n", __func__);
#endif
nxagentRequestSelection(&X);
@@ -941,7 +914,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
case SelectionNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new SelectionNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new SelectionNotify event.\n", __func__);
#endif
nxagentHandleSelectionNotifyFromXServer(&X);
@@ -954,8 +927,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
case PropertyNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: PropertyNotify on "
- "prop %d[%s] window %lx state %d\n",
+ fprintf(stderr, "%s: PropertyNotify on prop %d[%s] window %lx state %d\n", __func__,
(int)X.xproperty.atom, validateString(XGetAtomName(nxagentDisplay, X.xproperty.atom)),
X.xproperty.window, X.xproperty.state);
#endif
@@ -968,10 +940,8 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
{
enum HandleEventResult result;
- KeySym keysym;
-
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new KeyPress event.\n");
+ fprintf(stderr, "%s: Going to handle new KeyPress event.\n", __func__);
#endif
nxagentInputEvent = 1;
@@ -1023,67 +993,56 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
case doMinimize:
{
minimize = TRUE;
-
break;
}
case doSwitchFullscreen:
{
switchFullscreen = TRUE;
-
break;
}
case doSwitchAllScreens:
{
switchAllScreens = TRUE;
-
break;
}
case doViewportMoveUp:
{
nxagentMoveViewport(pScreen, 0, -nxagentOption(Height));
-
break;
}
case doViewportMoveDown:
{
nxagentMoveViewport(pScreen, 0, nxagentOption(Height));
-
break;
}
case doViewportMoveLeft:
{
nxagentMoveViewport(pScreen, -nxagentOption(Width), 0);
-
break;
}
case doViewportMoveRight:
{
nxagentMoveViewport(pScreen, nxagentOption(Width), 0);
-
break;
}
case doViewportUp:
{
nxagentMoveViewport(pScreen, 0, -nextinc(viewportInc));
-
break;
}
case doViewportDown:
{
nxagentMoveViewport(pScreen, 0, +nextinc(viewportInc));
-
break;
}
case doViewportLeft:
{
nxagentMoveViewport(pScreen, -nextinc(viewportInc), 0);
-
break;
}
case doViewportRight:
{
nxagentMoveViewport(pScreen, +nextinc(viewportInc), 0);
-
break;
}
case doSwitchResizeMode:
@@ -1108,34 +1067,29 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
{
nxagentSwitchDeferMode();
}
-
break;
}
case doAutoGrab:
{
nxagentToggleAutoGrab();
-
break;
}
default:
{
FatalError("nxagentDispatchEvent: handleKeyPress returned unknown value\n");
-
break;
}
}
/*
- * Elide multiple KeyPress/KeyRelease events of
- * the same key and generate a single pair. This
- * is intended to reduce the impact of the laten-
- * cy on the key auto-repeat, handled by the re-
- * mote X server. We may optionally do that only
- * if the timestamps in the events show an exces-
- * sive delay.
+ * Elide multiple KeyPress/KeyRelease events of the same key
+ * and generate a single pair. This is intended to reduce the
+ * impact of the latency on the key auto-repeat, handled by
+ * the remote X server. We may optionally do that only if the
+ * timestamps in the events show an exces- sive delay.
*/
- keysym = XKeycodeToKeysym(nxagentDisplay, X.xkey.keycode, 0);
+ KeySym keysym = XKeycodeToKeysym(nxagentDisplay, X.xkey.keycode, 0);
if (nxagentMonitoredDuplicate(keysym) == 1)
{
@@ -1157,18 +1111,17 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
int sendKey = 0;
/*
-FIXME: If we don't flush the queue here, it could happen
- that the inputInfo structure will not be up to date
- when we perform the following check on down keys.
+FIXME: If we don't flush the queue here, it could happen that the
+ inputInfo structure will not be up to date when we perform the
+ following check on down keys.
*/
ProcessInputEvents();
/*
-FIXME: Don't enqueue the KeyRelease event if the key was
- not already pressed. This workaround avoids a fake
- KeyPress being enqueued by the XKEYBOARD extension.
- Another solution would be to let the events
- enqueued and to remove the KeyPress afterwards.
+FIXME: Don't enqueue the KeyRelease event if the key was not already
+ pressed. This workaround avoids a fake KeyPress being enqueued
+ by the XKEYBOARD extension. Another solution would be to let
+ the events enqueued and to remove the KeyPress afterwards.
*/
if (BitIsOn(inputInfo.keyboard -> key -> down,
nxagentConvertKeycode(X.xkey.keycode)))
@@ -1177,7 +1130,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
}
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new KeyRelease event.\n");
+ fprintf(stderr, "%s: Going to handle new KeyRelease event.\n", __func__);
#endif
nxagentInputEvent = 1;
@@ -1206,9 +1159,9 @@ FIXME: Don't enqueue the KeyRelease event if the key was
nxagentXkbNumTrap = 0;
}
- /* Calculate the time elapsed between this and the last event we
- received. Add this delta to time we recorded for the last
- KeyPress event we passed on to our clients. */
+ /* Calculate the time elapsed between this and the last event
+ we received. Add this delta to time we recorded for the
+ last KeyPress event we passed on to our clients. */
memset(&x, 0, sizeof(xEvent));
x.u.u.type = KeyRelease;
x.u.u.detail = nxagentConvertKeycode(X.xkey.keycode);
@@ -1257,7 +1210,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
#ifdef NX_DEBUG_INPUT
if (nxagentDebugInput == 1)
{
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new ButtonPress event.\n");
+ fprintf(stderr, "%s: Going to handle new ButtonPress event.\n", __func__);
}
#endif
@@ -1322,7 +1275,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
#ifdef NX_DEBUG_INPUT
if (nxagentDebugInput == 1)
{
- fprintf(stderr, "nxagentDispatchEvents: Adding ButtonPress event.\n");
+ fprintf(stderr, "%s: Adding ButtonPress event.\n", __func__);
}
#endif
@@ -1356,7 +1309,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
#ifdef NX_DEBUG_INPUT
if (nxagentDebugInput == 1)
{
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new ButtonRelease event.\n");
+ fprintf(stderr, "%s: Going to handle new ButtonRelease event.\n", __func__);
}
#endif
@@ -1396,7 +1349,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
#ifdef NX_DEBUG_INPUT
if (nxagentDebugInput == 1)
{
- fprintf(stderr, "nxagentDispatchEvents: Adding ButtonRelease event.\n");
+ fprintf(stderr, "%s: Adding ButtonRelease event.\n", __func__);
}
#endif
@@ -1430,17 +1383,17 @@ FIXME: Don't enqueue the KeyRelease event if the key was
ScreenPtr pScreen = nxagentScreen(X.xmotion.window);
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new MotionNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new MotionNotify event.\n", __func__);
#endif
#ifdef NX_DEBUG_INPUT
if (nxagentDebugInput == 1)
{
- fprintf(stderr, "nxagentDispatchEvents: Handling motion notify window [%ld] root [%ld] child [%ld].\n",
- X.xmotion.window, X.xmotion.root, X.xmotion.subwindow);
+ fprintf(stderr, "%s: Handling motion notify window [%ld] root [%ld] child [%ld].\n",
+ __func__, X.xmotion.window, X.xmotion.root, X.xmotion.subwindow);
- fprintf(stderr, "nxagentDispatchEvents: Pointer at [%d][%d] relative root [%d][%d].\n",
- X.xmotion.x, X.xmotion.y, X.xmotion.x_root, X.xmotion.y_root);
+ fprintf(stderr, "%s: Pointer at [%d][%d] relative root [%d][%d].\n", __func__,
+ X.xmotion.x, X.xmotion.y, X.xmotion.x_root, X.xmotion.y_root);
}
#endif
@@ -1491,7 +1444,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
#ifdef NX_DEBUG_INPUT
if (nxagentDebugInput == 1)
{
- fprintf(stderr, "nxagentDispatchEvents: Adding motion event [%d, %d] to the queue.\n",
+ fprintf(stderr, "%s: Adding motion event [%d, %d] to the queue.\n", __func__,
x.u.keyButtonPointer.rootX, x.u.keyButtonPointer.rootY);
}
#endif
@@ -1550,23 +1503,22 @@ FIXME: Don't enqueue the KeyRelease event if the key was
WindowPtr pWin;
#ifdef DEBUG
- fprintf(stderr, "%s: Going to handle new FocusIn event [0x%x] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode));
+ fprintf(stderr, "%s: Going to handle new FocusIn event [0x%lx] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode));
{
XlibWindow w;
int revert_to;
XGetInputFocus(nxagentDisplay, &w, &revert_to);
- fprintf(stderr, "%s: (FocusIn): Event win [0x%x] Focus owner [0x%x] nxagentDefaultWindows[0] [0x%x]\n", __func__, X.xfocus.window, w, nxagentDefaultWindows[0]);
+ fprintf(stderr, "%s: (FocusIn): Event win [0x%lx] Focus owner [0x%lx] nxagentDefaultWindows[0] [0x%x]\n", __func__, X.xfocus.window, w, nxagentDefaultWindows[0]);
}
#else
#ifdef TEST
- fprintf(stderr, "%s: Going to handle new FocusIn event\n", __func__);
+ fprintf(stderr, "%s: Going to handle new FocusIn event\n", __func__);
#endif
#endif
/*
- * Here we change the focus state in the agent.
- * It looks like this is needed only for root-
- * less mode at the present moment.
+ * Here we change the focus state in the agent. It looks like
+ * this is needed only for rootless mode at present.
*/
if (nxagentOption(Rootless) &&
@@ -1609,7 +1561,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case FocusOut:
{
#ifdef DEBUG
- fprintf(stderr, "%s: Going to handle new FocusOut event [0x%x] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode));
+ fprintf(stderr, "%s: Going to handle new FocusOut event [0x%lx] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode));
#else
#ifdef TEST
fprintf(stderr, "%s: Going to handle new FocusOut event.\n", __func__);
@@ -1657,9 +1609,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
if (nxagentOption(ViewOnly) == 0 && nxagentOption(Shadow))
{
- XEvent xM;
-
- memset(&xM, 0, sizeof(XEvent));
+ XEvent xM = {0};
xM.type = KeyRelease;
xM.xkey.display = nxagentDisplay;
xM.xkey.type = KeyRelease;
@@ -1699,7 +1649,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case KeymapNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new KeymapNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new KeymapNotify event.\n", __func__);
#endif
break;
@@ -1708,14 +1658,14 @@ FIXME: Don't enqueue the KeyRelease event if the key was
{
WindowPtr pWin;
- WindowPtr pTLWin = NULL;
-
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new EnterNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new EnterNotify event.\n", __func__);
#endif
if (nxagentOption(Rootless))
{
+ WindowPtr pTLWin = NULL;
+
pWin = nxagentWindowPtr(X.xcrossing.window);
if (pWin != NULL)
@@ -1731,7 +1681,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
}
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: nxagentLastEnteredTopLevelWindow [%p].\n",
+ fprintf(stderr, "%s: nxagentLastEnteredTopLevelWindow [%p].\n", __func__,
(void *)nxagentLastEnteredTopLevelWindow);
#endif
}
@@ -1743,21 +1693,18 @@ FIXME: Don't enqueue the KeyRelease event if the key was
pWin -> drawable.y != X.xcrossing.y_root - X.xcrossing.y - pWin -> borderWidth))
{
/*
- * This code is useful for finding the window
- * position. It should be re-implemented by
- * following the ICCCM 4.1.5 recommendations.
+ * This code is useful for finding the window position. It
+ * should be re-implemented by following the ICCCM 4.1.5
+ * recommendations.
*/
- XID values[4];
- register XID *value = values;
- Mask mask = 0;
- ClientPtr pClient = wClient(pWin);
-
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: pWin -> drawable.x [%d] pWin -> drawable.y [%d].\n",
+ fprintf(stderr, "%s: pWin -> drawable.x [%d] pWin -> drawable.y [%d].\n", __func__,
pWin -> drawable.x, pWin -> drawable.y);
#endif
+ XID values[4];
+ register XID *value = values;
*value++ = (XID) (X.xcrossing.x_root - X.xcrossing.x - pWin -> borderWidth);
*value++ = (XID) (X.xcrossing.y_root - X.xcrossing.y - pWin -> borderWidth);
@@ -1766,11 +1713,11 @@ FIXME: Don't enqueue the KeyRelease event if the key was
* nxagentWindowPriv(pWin)->y = (X.xcrossing.y_root - X.xcrossing.y);
*/
- mask = CWX | CWY;
+ Mask mask = CWX | CWY;
nxagentScreenTrap = 1;
- ConfigureWindow(pWin, mask, (XID *) values, pClient);
+ ConfigureWindow(pWin, mask, (XID *) values, wClient(pWin));
nxagentScreenTrap = 0;
}
@@ -1820,7 +1767,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case LeaveNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new LeaveNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new LeaveNotify event.\n", __func__);
#endif
if (nxagentOption(Rootless) && X.xcrossing.mode == NotifyNormal &&
@@ -1856,7 +1803,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case DestroyNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new DestroyNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new DestroyNotify event.\n", __func__);
#endif
if (nxagentParentWindow != (Window) 0 &&
@@ -1872,7 +1819,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
enum HandleEventResult result;
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new ClientMessage event.\n");
+ fprintf(stderr, "%s: Going to handle new ClientMessage event.\n", __func__);
#endif
nxagentHandleClientMessageEvent(&X, &result);
@@ -1887,7 +1834,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case VisibilityNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new VisibilityNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new VisibilityNotify event.\n", __func__);
#endif
if (X.xvisibility.window != nxagentDefaultWindows[0])
@@ -1914,7 +1861,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
}
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Suppressing visibility notify on window [%lx].\n",
+ fprintf(stderr, "%s: Suppressing visibility notify on window [%lx].\n", __func__,
X.xvisibility.window);
#endif
@@ -1922,7 +1869,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
}
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Visibility notify state is [%d] with previous [%d].\n",
+ fprintf(stderr, "%s: Visibility notify state is [%d] with previous [%d].\n", __func__,
X.xvisibility.state, nxagentVisibility);
#endif
@@ -1933,10 +1880,10 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case Expose:
{
#ifdef DEBUG
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new Expose event.\n");
+ fprintf(stderr, "%s: Going to handle new Expose event.\n", __func__);
- fprintf(stderr, "nxagentDispatchEvents: WARNING! Received Expose event "
- "for drawable [%lx] geometry [%d, %d, %d, %d] count [%d].\n",
+ fprintf(stderr, "%s: WARNING! Received Expose event for drawable [%lx]"
+ " geometry [%d, %d, %d, %d] count [%d].\n", __func__,
X.xexpose.window, X.xexpose.x, X.xexpose.y, X.xexpose.width,
X.xexpose.height, X.xexpose.count);
#endif
@@ -1948,10 +1895,10 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case GraphicsExpose:
{
#ifdef DEBUG
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new GraphicsExpose event.\n");
+ fprintf(stderr, "%s: Going to handle new GraphicsExpose event.\n", __func__);
- fprintf(stderr, "nxagentDispatchEvents: WARNING! Received GraphicsExpose event "
- "for drawable [%lx] geometry [%d, %d, %d, %d] count [%d].\n",
+ fprintf(stderr, "%s: WARNING! Received GraphicsExpose event "
+ "for drawable [%lx] geometry [%d, %d, %d, %d] count [%d].\n", __func__,
X.xgraphicsexpose.drawable, X.xgraphicsexpose.x, X.xgraphicsexpose.y,
X.xgraphicsexpose.width, X.xgraphicsexpose.height,
X.xgraphicsexpose.count);
@@ -1964,34 +1911,22 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case NoExpose:
{
#ifdef DEBUG
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new NoExpose event.\n");
-
- fprintf(stderr, "nxagentDispatchEvents: WARNING! Received NoExpose event for "
- "drawable [%lx].\n", X.xnoexpose.drawable);
+ fprintf(stderr, "%s: Going to handle new NoExpose event.\n", __func__);
+ fprintf(stderr, "%s: WARNING! Received NoExpose event for drawable [%lx].\n", __func__, X.xnoexpose.drawable);
#endif
break;
}
case CirculateNotify:
{
- /*
- * WindowPtr pWin;
- * WindowPtr pSib;
- * ClientPtr pClient;
-
- * XID values[2];
- * register XID *value = values;
- * Mask mask = 0;
- */
-
#ifdef WARNING
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new CirculateNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new CirculateNotify event.\n", __func__);
#endif
/*
* FIXME: Do we need this?
*
- * pWin = nxagentWindowPtr(X.xcirculate.window);
+ * WindowPtr pWin = nxagentWindowPtr(X.xcirculate.window);
*
* if (!pWin)
* {
@@ -2014,7 +1949,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case ConfigureNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new ConfigureNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new ConfigureNotify event.\n", __func__);
#endif
if (nxagentConfiguredSynchroWindow == X.xconfigure.window)
@@ -2024,14 +1959,13 @@ FIXME: Don't enqueue the KeyRelease event if the key was
#ifdef WARNING
if (nxagentVerbose == 1)
{
- fprintf(stderr, "nxagentDispatchEvents: Requested ConfigureNotify changes didn't take place.\n");
+ fprintf(stderr, "%s: Requested ConfigureNotify changes didn't take place.\n", __func__);
}
#endif
}
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Received ConfigureNotify and going to call "
- "nxagentSynchronizeExpose.\n");
+ fprintf(stderr, "%s: Received ConfigureNotify and going to call nxagentSynchronizeExpose.\n", __func__);
#endif
nxagentSynchronizeExpose();
@@ -2046,7 +1980,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case GravityNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new GravityNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new GravityNotify event.\n", __func__);
#endif
break;
@@ -2054,7 +1988,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case ReparentNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new ReparentNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new ReparentNotify event.\n", __func__);
#endif
nxagentHandleReparentNotify(&X);
@@ -2064,7 +1998,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case UnmapNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new UnmapNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new UnmapNotify event.\n", __func__);
#endif
if (nxagentOption(Rootless) == 1)
@@ -2095,7 +2029,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
case MapNotify:
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Going to handle new MapNotify event.\n");
+ fprintf(stderr, "%s: Going to handle new MapNotify event.\n", __func__);
#endif
if (nxagentOption(Rootless) == 1)
@@ -2106,11 +2040,9 @@ FIXME: Don't enqueue the KeyRelease event if the key was
((pWin = nxagentWindowPtr(X.xmap.window)) != NULL &&
nxagentWindowTopLevel(pWin) == 1))
{
- ClientPtr pClient = wClient(pWin);
-
nxagentScreenTrap = 1;
- MapWindow(pWin, pClient);
+ MapWindow(pWin, wClient(pWin));
nxagentScreenTrap = 0;
}
@@ -2141,8 +2073,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was
/*
* without window manager there will be no ConfigureNotify
- * event that would trigger xinerama updates. So we do that once
- * the nxagent window gets mapped.
+ * event that would trigger xinerama updates. So we do that
+ * once the nxagent window gets mapped.
*/
if (!nxagentWMIsRunning &&
X.xmap.window == nxagentDefaultWindows[nxagentScreen(X.xmap.window)->myNum])
@@ -2158,12 +2090,12 @@ FIXME: Don't enqueue the KeyRelease event if the key was
XMappingEvent *mappingEvent = (XMappingEvent *) &X;
#ifdef DEBUG
- fprintf(stderr, "nxagentDispatchEvents: WARNING! Going to handle new MappingNotify event.\n");
+ fprintf(stderr, "%s: WARNING! Going to handle new MappingNotify event.\n", __func__);
#endif
if (mappingEvent -> request == MappingPointer)
{
- nxagentInitPointerMap();
+ nxagentInitPointerMap();
}
break;
@@ -2171,15 +2103,13 @@ FIXME: Don't enqueue the KeyRelease event if the key was
default:
{
/*
- * Let's check if this is a XKB
- * state modification event.
+ * Let's check if this is a XKB state modification event.
*/
if (nxagentHandleXkbKeyboardStateEvent(&X) == 0 && nxagentHandleXFixesSelectionNotify(&X) == 0)
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: WARNING! Unhandled event code [%d].\n",
- X.type);
+ fprintf(stderr, "%s: WARNING! Unhandled event code [%d].\n", __func__, X.type);
#endif
}
@@ -2280,8 +2210,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
#endif
/*
- * Let the underlying X server code
- * process the input events.
+ * Let the underlying X server code process the input events.
*/
#ifdef BLOCKS
@@ -2291,14 +2220,13 @@ FIXME: Don't enqueue the KeyRelease event if the key was
ProcessInputEvents();
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Output pending flag is [%d] critical [%d].\n",
+ fprintf(stderr, "%s: Output pending flag is [%d] critical [%d].\n", __func__,
NewOutputPending, CriticalOutputPending);
#endif
/*
- * Write the events to our clients. We may
- * flush only in the case of critical output
- * but this doesn't seem beneficial.
+ * Write the events to our clients. We may flush only in the case of
+ * critical output but this doesn't seem beneficial.
*
* if (CriticalOutputPending == 1)
* {
@@ -2309,19 +2237,17 @@ FIXME: Don't enqueue the KeyRelease event if the key was
if (NewOutputPending == 1)
{
#ifdef TEST
- fprintf(stderr, "nxagentDispatchEvents: Flushed the processed events to clients.\n");
+ fprintf(stderr, "%s: Flushed the processed events to clients.\n", __func__);
#endif
FlushAllOutput();
}
#ifdef TEST
-
if (nxagentPendingEvents(nxagentDisplay) > 0)
{
- fprintf(stderr, "nxagentDispatchEvents: WARNING! More events need to be dispatched.\n");
+ fprintf(stderr, "%s: WARNING! More events need to be dispatched.\n", __func__);
}
-
#endif
#ifdef BLOCKS
@@ -2330,8 +2256,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was
}
/*
- * Functions providing the ad-hoc handling
- * of the remote X events.
+ * Functions providing the ad-hoc handling of the remote X events.
*/
int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result)
@@ -2395,7 +2320,7 @@ int nxagentHandlePropertyNotify(XEvent *X)
if (nxagentOption(Rootless) && !nxagentNotifyMatchChangeProperty((XPropertyEvent *) X))
{
#ifdef TEST
- fprintf(stderr, "nxagentHandlePropertyNotify: Property %ld on window %lx.\n",
+ fprintf(stderr, "%s: Property %ld on window %lx.\n", __func__,
X -> xproperty.atom, X -> xproperty.window);
#endif
@@ -2406,7 +2331,7 @@ int nxagentHandlePropertyNotify(XEvent *X)
if (resource == -1)
{
#ifdef WARNING
- fprintf(stderr, "nxagentHandlePropertyNotify: WARNING! Asynchronous get property queue is full.\n");
+ fprintf(stderr, "%s: WARNING! Asynchronous get property queue is full.\n", __func__);
#endif
return 0;
@@ -2422,7 +2347,7 @@ int nxagentHandlePropertyNotify(XEvent *X)
#ifdef TEST
else
{
- fprintf(stderr, "nxagentHandlePropertyNotify: Failed to look up remote window property.\n");
+ fprintf(stderr, "%s: Failed to look up remote window property.\n", __func__);
}
#endif
}
@@ -2432,30 +2357,23 @@ int nxagentHandlePropertyNotify(XEvent *X)
int nxagentHandleExposeEvent(XEvent *X)
{
- WindowPtr pWin = NULL;
- Window window = None;
-
- RegionRec sum;
- RegionRec add;
- BoxRec box;
- int index = 0;
- int overlap = 0;
-
StaticResizedWindowStruct *resizedWinPtr = NULL;
#ifdef DEBUG
- fprintf(stderr, "nxagentHandleExposeEvent: Checking remote expose events.\n");
-
- fprintf(stderr, "nxagentHandleExposeEvent: Looking for window id [%ld].\n",
- X -> xexpose.window);
+ fprintf(stderr, "%s: Checking remote expose events.\n", __func__);
+ fprintf(stderr, "%s: Looking for window id [%ld].\n", __func__, X -> xexpose.window);
#endif
- window = X -> xexpose.window;
+ Window window = X -> xexpose.window;
- pWin = nxagentWindowPtr(window);
+ WindowPtr pWin = nxagentWindowPtr(window);
if (pWin != NULL)
{
+ RegionRec sum;
+ RegionRec add;
+ BoxRec box;
+
RegionInit(&sum, (BoxRec *) NULL, 1);
/*
FIXME: This can be maybe optimized by consuming the
@@ -2464,8 +2382,7 @@ FIXME: This can be maybe optimized by consuming the
do
{
#ifdef DEBUG
- fprintf(stderr, "nxagentHandleExposeEvent: Adding event for window id [%ld].\n",
- X -> xexpose.window);
+ fprintf(stderr, "%s: Adding event for window id [%ld].\n", __func__, X -> xexpose.window);
#endif
box.x1 = pWin -> drawable.x + wBorderWidth(pWin) + X -> xexpose.x;
@@ -2501,14 +2418,14 @@ FIXME: This can be maybe optimized by consuming the
while (nxagentCheckEvents(nxagentDisplay, X, nxagentExposurePredicate,
(XPointer) &window) == 1);
+ int overlap = 0;
RegionValidate(&sum, &overlap);
RegionIntersect(&sum, &sum,
&pWin->drawable.pScreen->root->winSize);
#ifdef DEBUG
- fprintf(stderr, "nxagentHandleExposeEvent: Sending events for window id [%ld].\n",
- X -> xexpose.window);
+ fprintf(stderr, "%s: Sending events for window id [%ld].\n", __func__, X -> xexpose.window);
#endif
/*
@@ -2516,7 +2433,7 @@ FIXME: This can be maybe optimized by consuming the
* save received exposes for later processing.
*/
- index = nxagentLookupByWindow(pWin);
+ int index = nxagentLookupByWindow(pWin);
if (index == -1)
{
@@ -2535,7 +2452,7 @@ FIXME: This can be maybe optimized by consuming the
nxagentExposeQueue.exposures[index].remoteRegion, &sum);
#ifdef TEST
- fprintf(stderr, "nxagentHandleExposeEvent: Added region for window [%u] to position [%d].\n",
+ fprintf(stderr, "%s: Added region for window [%u] to position [%d].\n", __func__,
nxagentWindow(pWin), index);
#endif
@@ -2558,19 +2475,16 @@ FIXME: This can be maybe optimized by consuming the
int nxagentHandleGraphicsExposeEvent(XEvent *X)
{
/*
- * Send an expose event to client, instead of graphics
- * expose. If target drawable is a backing pixmap, send
- * expose event for the saved window, else do nothing.
+ * Send an expose event to client, instead of graphics expose. If
+ * target drawable is a backing pixmap, send expose event for the
+ * saved window, else do nothing.
*/
- RegionPtr exposeRegion;
- BoxRec rect;
- WindowPtr pWin;
StoringPixmapPtr pStoringPixmapRec = NULL;
miBSWindowPtr pBSwindow = NULL;
int drawableType;
- pWin = nxagentWindowPtr(X -> xgraphicsexpose.drawable);
+ WindowPtr pWin = nxagentWindowPtr(X -> xgraphicsexpose.drawable);
if (pWin != NULL)
{
@@ -2588,7 +2502,7 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X)
if (pStoringPixmapRec == NULL)
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleGraphicsExposeEvent: WARNING! Storing pixmap not found.\n");
+ fprintf(stderr, "%s: WARNING! Storing pixmap not found.\n", __func__);
#endif
return 1;
@@ -2599,7 +2513,7 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X)
if (pBSwindow == NULL)
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleGraphicsExposeEvent: WARNING! Back storage not found.\n");
+ fprintf(stderr, "%s: WARNING! Back storage not found.\n", __func__);
#endif
return 1;
@@ -2609,38 +2523,37 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X)
}
/*
- * Rectangle affected by GraphicsExpose
- * event.
+ * Rectangle affected by GraphicsExpose event.
*/
- rect.x1 = X -> xgraphicsexpose.x;
- rect.y1 = X -> xgraphicsexpose.y;
- rect.x2 = rect.x1 + X -> xgraphicsexpose.width;
- rect.y2 = rect.y1 + X -> xgraphicsexpose.height;
+ BoxRec rect = {
+ .x1 = X -> xgraphicsexpose.x,
+ .y1 = X -> xgraphicsexpose.y,
+ .x2 = rect.x1 + X -> xgraphicsexpose.width,
+ .y2 = rect.y1 + X -> xgraphicsexpose.height,
+ };
- exposeRegion = RegionCreate(&rect, 0);
+ RegionPtr exposeRegion = RegionCreate(&rect, 0);
if (drawableType == DRAWABLE_PIXMAP)
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleGraphicsExposeEvent: Handling GraphicsExpose event on pixmap with id"
- " [%lu].\n", X -> xgraphicsexpose.drawable);
+ fprintf(stderr, "%s: Handling GraphicsExpose event on pixmap with id [%lu].\n",
+ __func__, X -> xgraphicsexpose.drawable);
#endif
/*
- * The exposeRegion coordinates are relative
- * to the pixmap to which GraphicsExpose
- * event refers. But the BS coordinates of
- * the savedRegion are relative to the
- * window.
+ * The exposeRegion coordinates are relative to the pixmap to
+ * which GraphicsExpose event refers. But the BS coordinates of
+ * the savedRegion are relative to the window.
*/
RegionTranslate(exposeRegion, pStoringPixmapRec -> backingStoreX,
pStoringPixmapRec -> backingStoreY);
/*
- * We remove from SavedRegion the part
- * affected by the GraphicsExpose event.
+ * We remove from SavedRegion the part affected by the
+ * GraphicsExpose event.
*/
RegionSubtract(&(pBSwindow -> SavedRegion), &(pBSwindow -> SavedRegion),
@@ -2648,9 +2561,8 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X)
}
/*
- * Store the exposeRegion in order to send
- * the expose event later. The coordinates
- * must be relative to the screen.
+ * Store the exposeRegion in order to send the expose event
+ * later. The coordinates must be relative to the screen.
*/
RegionTranslate(exposeRegion, pWin -> drawable.x, pWin -> drawable.y);
@@ -2667,14 +2579,13 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
*result = doNothing;
#ifdef TEST
- fprintf(stderr, "nxagentHandleClientMessageEvent: ClientMessage event window [%ld] with "
- "type [%ld] format [%d].\n", X -> xclient.window, X -> xclient.message_type,
- X -> xclient.format);
+ fprintf(stderr, "%s: ClientMessage event window [%ld] with type [%ld] format [%d].\n",
+ __func__, X -> xclient.window, X -> xclient.message_type, X -> xclient.format);
#endif
/*
- * If window is 0, message_type is 0 and format is
- * 32 then we assume event is coming from proxy.
+ * If window is 0, message_type is 0 and format is 32 then we assume
+ * event is coming from proxy.
*/
if (X -> xclient.window == 0 &&
@@ -2693,7 +2604,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
if (!ValidAtom(message_type))
{
#ifdef WARNING
- fprintf(stderr, "nxagentHandleClientMessageEvent: WARNING Invalid type in client message.\n");
+ fprintf(stderr, "%s: WARNING Invalid type in client message.\n", __func__);
#endif
return 0;
@@ -2712,12 +2623,9 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
if (message_type == MakeAtom("WM_PROTOCOLS", strlen("WM_PROTOCOLS"), False))
{
- xEvent x;
-
- memset(&x, 0, sizeof(xEvent));
+ xEvent x = {0};
x.u.u.type = ClientMessage;
x.u.u.detail = X -> xclient.format;
-
x.u.clientMessage.window = pWin -> drawable.id;
x.u.clientMessage.u.l.type = message_type;
x.u.clientMessage.u.l.longs0 = nxagentRemoteToLocalAtom(X -> xclient.data.l[0]);
@@ -2726,8 +2634,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
if (!ValidAtom(x.u.clientMessage.u.l.longs0))
{
#ifdef WARNING
- fprintf(stderr, "nxagentHandleClientMessageEvent: WARNING Invalid value in client message "
- "of type WM_PROTOCOLS.\n");
+ fprintf(stderr, "%s: WARNING Invalid value in client message of type WM_PROTOCOLS.\n", __func__);
#endif
return 0;
@@ -2735,8 +2642,8 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
#ifdef TEST
else
{
- fprintf(stderr, "nxagentHandleClientMessageEvent: Sent client message of type WM_PROTOCOLS "
- "and value [%s].\n", validateString(NameForAtom(x.u.clientMessage.u.l.longs0)));
+ fprintf(stderr, "%s: Sent client message of type WM_PROTOCOLS and value [%s].\n", __func__,
+ validateString(NameForAtom(x.u.clientMessage.u.l.longs0)));
}
#endif
@@ -2745,7 +2652,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
else
{
#ifdef WARNING
- fprintf(stderr, "nxagentHandleClientMessageEvent: Ignored message type %ld [%s].\n",
+ fprintf(stderr, "%s: Ignored message type %ld [%s].\n", __func__,
(long int) message_type, validateString(NameForAtom(message_type)));
#endif
@@ -2757,11 +2664,8 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
if (X -> xclient.message_type == nxagentAtoms[1]) /* WM_PROTOCOLS */
{
- Atom deleteWMatom, wmAtom;
-
- wmAtom = (Atom) X -> xclient.data.l[0];
-
- deleteWMatom = nxagentAtoms[2]; /* WM_DELETE_WINDOW */
+ Atom wmAtom = (Atom) X -> xclient.data.l[0];
+ Atom deleteWMatom = nxagentAtoms[2]; /* WM_DELETE_WINDOW */
if (wmAtom == deleteWMatom)
{
@@ -2772,7 +2676,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
else
{
#ifdef TEST
- fprintf(stderr, "Events: WM_DELETE_WINDOW arrived Atom = %u.\n", wmAtom);
+ fprintf(stderr, "%s: WM_DELETE_WINDOW arrived Atom = %u.\n", __func__, wmAtom);
#endif
if (X -> xclient.window == nxagentIconWindow)
@@ -2905,14 +2809,12 @@ int nxagentHandleXkbKeyboardStateEvent(XEvent *X)
int nxagentHandleXFixesSelectionNotify(XEvent *X)
{
- Atom local;
-
XFixesSelectionEvent *xfixesEvent = (XFixesSelectionEvent *) X;
if (nxagentXFixesInfo.Initialized == 0)
{
#ifdef DEBUG
- fprintf(stderr, "nxagentHandleXFixesSelectionNotify: XFixes not initialized - doing nothing.\n");
+ fprintf(stderr, "%s: XFixes not initialized - doing nothing.\n", __func__);
#endif
return 0;
}
@@ -2920,35 +2822,33 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X)
if (xfixesEvent -> type != (nxagentXFixesInfo.EventBase + XFixesSelectionNotify))
{
#ifdef DEBUG
- fprintf(stderr, "nxagentHandleXFixesSelectionNotify: event type is [%d] - doing nothing.\n", xfixesEvent->type);
+ fprintf(stderr, "%s: event type is [%d] - doing nothing.\n", __func__, xfixesEvent->type);
#endif
return 0;
}
#ifdef TEST
- fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Handling event.\n");
+ fprintf(stderr, "%s: Handling event.\n", __func__);
#endif
- local = nxagentRemoteToLocalAtom(xfixesEvent -> xfixesselection.selection);
+ Atom local = nxagentRemoteToLocalAtom(xfixesEvent -> xfixesselection.selection);
if (SelectionCallback)
{
int i = nxagentFindCurrentSelectionIndex(local);
if (i < NumCurrentSelections)
{
- SelectionInfoRec info;
-
if (CurrentSelections[i].client != 0)
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Do nothing.\n");
+ fprintf(stderr, "%s: Do nothing.\n", __func__);
#endif
return 1;
}
#ifdef TEST
- fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Calling callbacks for %d [%s] selection.\n",
+ fprintf(stderr, "%s: Calling callbacks for %d [%s] selection.\n", __func__,
CurrentSelections[i].selection, NameForAtom(CurrentSelections[i].selection));
#endif
@@ -2956,31 +2856,25 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X)
fprintf(stderr, "%s: CurrentSelections[i].lastTimeChanged [%d]\n", __func__, CurrentSelections[i].lastTimeChanged.milliseconds);
fprintf(stderr, "%s: Event timestamp [%ld]\n", __func__, xfixesEvent->xfixesselection.timestamp);
fprintf(stderr, "%s: Event selection timestamp [%ld]\n", __func__, xfixesEvent->xfixesselection.selection_timestamp);
- fprintf(stderr, "%s: Event selection window [0x%x]\n", __func__, xfixesEvent->xfixesselection.window);
- fprintf(stderr, "%s: Event selection owner [0x%x]\n", __func__, xfixesEvent->xfixesselection.owner);
+ fprintf(stderr, "%s: Event selection window [0x%lx]\n", __func__, xfixesEvent->xfixesselection.window);
+ fprintf(stderr, "%s: Event selection owner [0x%lx]\n", __func__, xfixesEvent->xfixesselection.owner);
fprintf(stderr, "%s: Event selection [%s]\n", __func__, NameForAtom(nxagentRemoteToLocalAtom(xfixesEvent->xfixesselection.selection)));
- fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Subtype ");
+ fprintf(stderr, "%s: Subtype ", __func__);
switch (xfixesEvent -> xfixesselection.subtype)
{
- case SelectionSetOwner:
- fprintf(stderr, "SelectionSetOwner.\n");
- break;
- case SelectionWindowDestroy:
- fprintf(stderr, "SelectionWindowDestroy.\n");
- break;
- case SelectionClientClose:
- fprintf(stderr, "SelectionClientClose.\n");
- break;
- default:
- fprintf(stderr, ".\n");
- break;
+ case SelectionSetOwner: fprintf(stderr, "SelectionSetOwner.\n"); break;
+ case SelectionWindowDestroy: fprintf(stderr, "SelectionWindowDestroy.\n"); break;
+ case SelectionClientClose: fprintf(stderr, "SelectionClientClose.\n"); break;
+ default: fprintf(stderr, ".\n"); break;
}
#endif
- info.selection = &CurrentSelections[i];
- info.kind = xfixesEvent->xfixesselection.subtype;
+ SelectionInfoRec info = {
+ .selection = &CurrentSelections[i],
+ .kind = xfixesEvent->xfixesselection.subtype
+ };
/*
* The trap indicates that we are triggered by a clipboard event
@@ -3007,10 +2901,8 @@ int nxagentHandleProxyEvent(XEvent *X)
case NXStartSplitNotify:
{
/*
- * We should never receive such events
- * in the event loop, as they should
- * be caught at the time the split is
- * initiated.
+ * We should never receive such events in the event loop, as
+ * they should be caught at the time the split is initiated.
*/
#ifdef PANIC
@@ -3019,13 +2911,11 @@ int nxagentHandleProxyEvent(XEvent *X)
if (X -> xclient.data.l[0] == NXNoSplitNotify)
{
- fprintf(stderr, "nxagentHandleProxyEvent: PANIC! NXNoSplitNotify received "
- "with client [%d].\n", client);
+ fprintf(stderr, "%s: PANIC! NXNoSplitNotify received with client [%d].\n", __func__, client);
}
else
{
- fprintf(stderr, "nxagentHandleProxyEvent: PANIC! NXStartSplitNotify received "
- "with client [%d].\n", client);
+ fprintf(stderr, "%s: PANIC! NXStartSplitNotify received with client [%d].\n", __func__, client);
}
#endif
@@ -3035,10 +2925,9 @@ int nxagentHandleProxyEvent(XEvent *X)
case NXCommitSplitNotify:
{
/*
- * We need to commit an image. Image can be the
- * result of a PutSubImage() generated by Xlib,
- * so there can be more than a single image to
- * commit, even if only one PutImage was perfor-
+ * We need to commit an image. Image can be the result of a
+ * PutSubImage() generated by Xlib, so there can be more than a
+ * single image to commit, even if only one PutImage was perfor-
* med by the agent.
*/
@@ -3047,8 +2936,8 @@ int nxagentHandleProxyEvent(XEvent *X)
int position = (int) X -> xclient.data.l[3];
#ifdef TEST
- fprintf(stderr, "nxagentHandleProxyEvent: NXCommitSplitNotify received with "
- "client [%d] request [%d] and position [%d].\n",
+ fprintf(stderr, "%s: NXCommitSplitNotify received with client [%d]"
+ " request [%d] and position [%d].\n", __func__,
client, request, position);
#endif
@@ -3059,15 +2948,14 @@ int nxagentHandleProxyEvent(XEvent *X)
case NXEndSplitNotify:
{
/*
- * All images for the split were transferred and
- * we need to restart the client.
+ * All images for the split were transferred and we need to
+ * restart the client.
*/
int client = (int) X -> xclient.data.l[1];
#ifdef TEST
- fprintf(stderr, "nxagentHandleProxyEvent: NXEndSplitNotify received with "
- "client [%d].\n", client);
+ fprintf(stderr, "%s: NXEndSplitNotify received with client [%d].\n", __func__, client);
#endif
nxagentHandleEndSplitEvent(client);
@@ -3081,7 +2969,7 @@ int nxagentHandleProxyEvent(XEvent *X)
*/
#ifdef TEST
- fprintf(stderr, "nxagentHandleProxyEvent: NXEmptySplitNotify received.\n");
+ fprintf(stderr, "%s: NXEmptySplitNotify received.\n", __func__);
#endif
nxagentHandleEmptySplitEvent();
@@ -3093,8 +2981,7 @@ int nxagentHandleProxyEvent(XEvent *X)
#ifdef TEST
int resource = (int) X -> xclient.data.l[1];
- fprintf(stderr, "nxagentHandleProxyEvent: NXCollectPropertyNotify received with resource [%d].\n",
- resource);
+ fprintf(stderr, "%s: NXCollectPropertyNotify received with resource [%d].\n", __func__, resource);
#endif
nxagentHandleCollectPropertyEvent(X);
@@ -3106,8 +2993,7 @@ int nxagentHandleProxyEvent(XEvent *X)
int resource = (int) X -> xclient.data.l[1];
#ifdef TEST
- fprintf(stderr, "nxagentHandleProxyEvent: NXCollectGrabPointerNotify received with resource [%d].\n",
- resource);
+ fprintf(stderr, "%s: NXCollectGrabPointerNotify received with resource [%d].\n", __func__, resource);
#endif
nxagentHandleCollectGrabPointerEvent(resource);
@@ -3123,8 +3009,7 @@ int nxagentHandleProxyEvent(XEvent *X)
*/
#ifdef TEST
- fprintf(stderr, "nxagentHandleProxyEvent: NXCollectInputFocusNotify received with resource [%d].\n",
- resource);
+ fprintf(stderr, "%s: NXCollectInputFocusNotify received with resource [%d].\n", __func__, resource);
#endif
nxagentHandleCollectInputFocusEvent(resource);
@@ -3138,7 +3023,7 @@ int nxagentHandleProxyEvent(XEvent *X)
*/
#ifdef WARNING
- fprintf(stderr, "nxagentHandleProxyEvent: WARNING! Not a recognized ClientMessage proxy event [%d].\n",
+ fprintf(stderr, "%s: WARNING! Not a recognized ClientMessage proxy event [%d].\n", __func__,
(int) X -> xclient.data.l[0]);
#endif
@@ -3148,9 +3033,8 @@ int nxagentHandleProxyEvent(XEvent *X)
}
/*
- * In this function it is assumed that we never
- * get a configure with both stacking order and
- * geometry changed, this way we can ignore
+ * In this function it is assumed that we never get a configure with
+ * both stacking order and geometry changed, this way we can ignore
* stacking changes if the geometry has changed.
*/
@@ -3190,7 +3074,7 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X)
if (geometryChanged)
{
#ifdef TEST
- fprintf(stderr, "nxagentCheckWindowConfiguration: Configure frame. No restack.\n");
+ fprintf(stderr, "%s: Configure frame. No restack.\n", __func__);
#endif
return 1;
@@ -3198,13 +3082,12 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X)
#ifdef TEST
{
- fprintf(stderr, "nxagentCheckWindowConfiguration: Before restacking top level window [%p]\n",
+ fprintf(stderr, "%s: Before restacking top level window [%p]\n", __func__,
(void *) nxagentWindowPtr(X -> window));
for (WindowPtr pSib = screenInfo.screens[0]->root -> firstChild; pSib; pSib = pSib -> nextSib)
{
- fprintf(stderr, "nxagentCheckWindowConfiguration: Top level window: [%p].\n",
- (void *) pSib);
+ fprintf(stderr, "%s: Top level window: [%p].\n", __func__, (void *) pSib);
}
}
#endif
@@ -3219,15 +3102,14 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X)
else
{
#ifdef WARNING
- fprintf(stderr, "nxagentCheckWindowConfiguration: WARNING! Failed QueryTree request.\n");
+ fprintf(stderr, "%s: WARNING! Failed QueryTree request.\n", __func__);
#endif
}
SAFE_XFree(children_return);
#if 0
- fprintf(stderr, "nxagentCheckWindowConfiguration: Trees match: %s\n",
- nxagentRootlessTreesMatch() ? "Yes" : "No");
+ fprintf(stderr, "%s: Trees match: %s\n", __func__, nxagentRootlessTreesMatch() ? "Yes" : "No");
#endif
return 1;
@@ -3237,30 +3119,28 @@ int nxagentHandleConfigureNotify(XEvent* X)
{
if (nxagentOption(Rootless) == True)
{
- ClientPtr pClient;
- WindowPtr pWinWindow;
- WindowPtr pWin;
int sendEventAnyway = 0;
- pWinWindow = nxagentWindowPtr(X -> xconfigure.window);
+ WindowPtr pWinWindow = nxagentWindowPtr(X -> xconfigure.window);
#ifdef TEST
{
WindowPtr pWinEvent = nxagentWindowPtr(X -> xconfigure.event);
- fprintf(stderr, "nxagentHandleConfigureNotify: Generating window is [%p][%ld] target [%p][%ld].\n",
+ fprintf(stderr, "%s: Generating window is [%p][%ld] target [%p][%ld].\n", __func__,
(void *) pWinEvent, X -> xconfigure.event, (void *) pWinWindow, X -> xconfigure.window);
}
#endif
#ifdef TEST
- fprintf(stderr, "nxagentHandleConfigureNotify: New configuration for window [%p][%ld] is [%d][%d][%d][%d] "
- "send_event [%i].\n", (void *) pWinWindow, X -> xconfigure.window,
+ fprintf(stderr, "%s: New configuration for window [%p][%ld] is [%d][%d][%d][%d] send_event [%i].\n",
+ __func__, (void *) pWinWindow, X -> xconfigure.window,
X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width,
X -> xconfigure.height, X -> xconfigure.send_event);
#endif
- if ((pWin = nxagentRootlessTopLevelWindow(X -> xconfigure.window)) != NULL)
+ WindowPtr pWin = nxagentRootlessTopLevelWindow(X -> xconfigure.window);
+ if (pWin != NULL)
{
/*
* Checking for new geometry or stacking order changes.
@@ -3274,11 +3154,9 @@ int nxagentHandleConfigureNotify(XEvent* X)
if (nxagentWindowTopLevel(pWinWindow) && !X -> xconfigure.override_redirect)
{
XID values[5];
- Mask mask = 0;
-
register XID *value = values;
- pClient = wClient(pWinWindow);
+ Mask mask = CWHeight | CWWidth | CWBorderWidth;
/* FIXME: override_redirect is always FALSE here */
if (X -> xconfigure.send_event || !nxagentWMIsRunning ||
@@ -3306,26 +3184,23 @@ int nxagentHandleConfigureNotify(XEvent* X)
* nxagentWindowPriv(pWinWindow)->height = X -> xconfigure.height;
*/
- mask |= CWHeight | CWWidth | CWBorderWidth;
-
nxagentScreenTrap = 1;
- ConfigureWindow(pWinWindow, mask, (XID *) values, pClient);
+ ConfigureWindow(pWinWindow, mask, (XID *) values, wClient(pWinWindow));
nxagentScreenTrap = 0;
nxagentCheckWindowConfiguration((XConfigureEvent*)X);
/*
- * This workaround should help with
- * Java 1.6.0 that seems to ignore
- * non-synthetic events.
+ * This workaround should help with Java 1.6.0 that seems to
+ * ignore non-synthetic events.
*/
if (nxagentOption(ClientOs) == ClientOsWinnt)
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleConfigureNotify: Apply workaround for NXWin.\n");
+ fprintf(stderr, "%s: Apply workaround for NXWin.\n", __func__);
#endif
sendEventAnyway = 1;
@@ -3333,11 +3208,9 @@ int nxagentHandleConfigureNotify(XEvent* X)
if (sendEventAnyway || X -> xconfigure.send_event)
{
- xEvent x;
+ xEvent x = {0};
- memset(&x, 0, sizeof(xEvent));
- x.u.u.type = X -> xconfigure.type;
- x.u.u.type |= 0x80;
+ x.u.u.type = X -> xconfigure.type | 0x80;
x.u.configureNotify.event = pWinWindow -> drawable.id;
x.u.configureNotify.window = pWinWindow -> drawable.id;
@@ -3358,7 +3231,7 @@ int nxagentHandleConfigureNotify(XEvent* X)
x.u.configureNotify.borderWidth = X -> xconfigure.border_width;
x.u.configureNotify.override = X -> xconfigure.override_redirect;
- TryClientEvents(pClient, &x, 1, 1, 1, 0);
+ TryClientEvents(wClient(pWinWindow), &x, 1, 1, 1, 0);
}
return 1;
@@ -3367,15 +3240,14 @@ int nxagentHandleConfigureNotify(XEvent* X)
else
{
/*
- * Save the position of the agent default window. Don't
- * save the values if the agent is in fullscreen mode.
+ * Save the position of the agent default window. Don't save the
+ * values if the agent is in fullscreen mode.
*
- * If we use these values to restore the position of a
- * window after that we have dynamically changed the
- * fullscreen attribute, depending on the behaviour of
- * window manager, we could be not able to place the
- * window exactly in the requested position, so let the
- * window manager do the job for us.
+ * If we use these values to restore the position of a window
+ * after that we have dynamically changed the fullscreen
+ * attribute, depending on the behaviour of window manager, we
+ * could be not able to place the window exactly in the requested
+ * position, so let the window manager do the job for us.
*/
ScreenPtr pScreen = nxagentScreen(X -> xconfigure.window);
@@ -3517,7 +3389,7 @@ int nxagentHandleConfigureNotify(XEvent* X)
if (doRandR)
{
#ifdef TEST
- fprintf(stderr,"nxagentHandleConfigureNotify: Width %d Height %d.\n",
+ fprintf(stderr,"%s: Width %d Height %d.\n", __func__,
nxagentOption(Width), nxagentOption(Height));
#endif
@@ -3533,7 +3405,8 @@ int nxagentHandleConfigureNotify(XEvent* X)
if ( (X -> xconfigure.window == DefaultRootWindow(nxagentDisplay)) || nxagentFullscreenWindow )
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleConfigureNotify: remote root window has changed: %d,%d %dx%d\n", X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height);
+ fprintf(stderr, "%s: remote root window has changed: %d,%d %dx%d\n", __func__,
+ X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height);
#endif
nxagentChangeOption(RootX, X -> xconfigure.x);
@@ -3555,17 +3428,11 @@ int nxagentHandleConfigureNotify(XEvent* X)
int nxagentHandleReparentNotify(XEvent* X)
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleReparentNotify: Going to handle a new reparent event.\n");
+ fprintf(stderr, "%s: Going to handle a new reparent event.\n", __func__);
#endif
if (nxagentOption(Rootless))
{
- XlibWindow w;
- XlibWindow root_return = 0;
- XlibWindow parent_return = 0;
- XlibWindow *children_return = NULL;
- unsigned int nchildren_return = 0;
- Status result;
WindowPtr pWin = nxagentWindowPtr(X -> xreparent.window);
#ifdef TEST
@@ -3574,7 +3441,7 @@ int nxagentHandleReparentNotify(XEvent* X)
WindowPtr pParent = nxagentWindowPtr(X -> xreparent.parent);
WindowPtr pEvent = nxagentWindowPtr(X -> xreparent.event);
- fprintf(stderr, "nxagentHandleReparentNotify: event %p[%lx] window %p[%lx] parent %p[%lx] at (%d, %d)\n",
+ fprintf(stderr, "%s: event %p[%lx] window %p[%lx] parent %p[%lx] at (%d, %d)\n", __func__,
(void*)pEvent, X -> xreparent.event, (void*)pWin, X -> xreparent.window,
(void*)pParent, X -> xreparent.parent, X -> xreparent.x, X -> xreparent.y);
}
@@ -3584,13 +3451,17 @@ int nxagentHandleReparentNotify(XEvent* X)
if (nxagentWindowTopLevel(pWin))
{
/*
- * If the window manager reparents our top level
- * window, we need to know the new top level
- * ancestor.
+ * If the window manager reparents our top level window, we need
+ * to know the new top level ancestor.
*/
- w = None;
- parent_return = X -> xreparent.parent;
+ XlibWindow w = None;
+ XlibWindow root_return = 0;
+ XlibWindow *children_return = NULL;
+ unsigned int nchildren_return = 0;
+ Status result;
+
+ XlibWindow parent_return = X -> xreparent.parent;
while (parent_return != RootWindow(nxagentDisplay, 0))
{
@@ -3603,7 +3474,7 @@ int nxagentHandleReparentNotify(XEvent* X)
if (!result)
{
#ifdef WARNING
- fprintf(stderr, "nxagentHandleReparentNotify: WARNING! Failed QueryTree request.\n");
+ fprintf(stderr, "%s: WARNING! Failed QueryTree request.\n", __func__);
#endif
break;
@@ -3617,9 +3488,8 @@ int nxagentHandleReparentNotify(XEvent* X)
nxagentRootlessAddTopLevelWindow(pWin, w);
#ifdef TEST
- fprintf(stderr, "nxagentHandleReparentNotify: new top level window [%ld].\n", w);
- fprintf(stderr, "nxagentHandleReparentNotify: reparented window [%ld].\n",
- X -> xreparent.window);
+ fprintf(stderr, "%s: new top level window [%ld].\n", __func__, w);
+ fprintf(stderr, "%s: reparented window [%ld].\n", __func__, X -> xreparent.window);
#endif
result = XQueryTree(nxagentDisplay, DefaultRootWindow(nxagentDisplay),
@@ -3632,7 +3502,7 @@ int nxagentHandleReparentNotify(XEvent* X)
else
{
#ifdef WARNING
- fprintf(stderr, "nxagentHandleReparentNotify: WARNING! Failed QueryTree request.\n");
+ fprintf(stderr, "%s: WARNING! Failed QueryTree request.\n", __func__);
#endif
}
@@ -3641,8 +3511,8 @@ int nxagentHandleReparentNotify(XEvent* X)
else
{
#ifdef TEST
- fprintf(stderr, "nxagentHandleReparentNotify: Window at [%p] has been reparented to [%ld]"
- " top level parent [%ld].\n", (void *) pWin, X -> xreparent.parent, w);
+ fprintf(stderr, "%s: Window at [%p] has been reparented to [%ld] top level parent [%ld].\n",
+ __func__, (void *) pWin, X -> xreparent.parent, w);
#endif
nxagentRootlessDelTopLevelWindow(pWin);
@@ -3654,33 +3524,25 @@ int nxagentHandleReparentNotify(XEvent* X)
else if (nxagentWMIsRunning && nxagentOption(Fullscreen) == 0 &&
nxagentOption(WMBorderWidth) == -1)
{
- XlibWindow w;
- XlibWindow rootReturn = 0;
- XlibWindow parentReturn = 0;
- XlibWindow junk;
- XlibWindow *childrenReturn = NULL;
- unsigned int nchildrenReturn = 0;
- XWindowAttributes attributes;
- int x, y;
-
/*
* Calculate the absolute upper-left X e Y
*/
+ XWindowAttributes attributes;
if ((XGetWindowAttributes(nxagentDisplay, X -> xreparent.window,
&attributes) == 0))
{
#ifdef WARNING
- fprintf(stderr, "nxagentHandleReparentNotify: WARNING! "
- "XGetWindowAttributes failed.\n");
+ fprintf(stderr, "%s: WARNING! XGetWindowAttributes failed.\n", __func__);
#endif
return 1;
}
- x = attributes.x;
- y = attributes.y;
+ int x = attributes.x;
+ int y = attributes.y;
+ XlibWindow junk;
XTranslateCoordinates(nxagentDisplay, X -> xreparent.window,
attributes.root, -attributes.border_width,
-attributes.border_width, &x, &y, &junk);
@@ -3689,11 +3551,14 @@ int nxagentHandleReparentNotify(XEvent* X)
* Calculate the parent X and parent Y.
*/
- w = X -> xreparent.parent;
+ XlibWindow w = X -> xreparent.parent;
if (w != DefaultRootWindow(nxagentDisplay))
{
- int xParent, yParent;
+ XlibWindow rootReturn = 0;
+ XlibWindow parentReturn = 0;
+ XlibWindow *childrenReturn = NULL;
+ unsigned int nchildrenReturn = 0;
do
{
@@ -3718,23 +3583,19 @@ int nxagentHandleReparentNotify(XEvent* X)
if (XGetWindowAttributes(nxagentDisplay, w, &attributes) == 0)
{
#ifdef WARNING
- fprintf(stderr, "nxagentHandleReparentNotify: WARNING! "
- "XGetWindowAttributes failed for parent window.\n");
+ fprintf(stderr, "%s: WARNING! XGetWindowAttributes failed for parent window.\n", __func__);
#endif
return 1;
}
- xParent = attributes.x;
- yParent = attributes.y;
-
/*
* Difference between Absolute X and Parent X gives thickness of side frame.
* Difference between Absolute Y and Parent Y gives thickness of title bar.
*/
- nxagentChangeOption(WMBorderWidth, (x - xParent));
- nxagentChangeOption(WMTitleHeight, (y - yParent));
+ nxagentChangeOption(WMBorderWidth, (x - attributes.x));
+ nxagentChangeOption(WMTitleHeight, (y - attributes.y));
}
}
@@ -3789,12 +3650,9 @@ void nxagentDisablePointerEvents(void)
void nxagentSendFakeKey(int key)
{
- xEvent fake;
- Time now;
-
- now = GetTimeInMillis();
+ Time now = GetTimeInMillis();
- memset(&fake, 0, sizeof(xEvent));
+ xEvent fake = {0};
fake.u.u.type = KeyPress;
fake.u.u.detail = key;
fake.u.keyButtonPointer.time = now;
@@ -3810,9 +3668,7 @@ void nxagentSendFakeKey(int key)
int nxagentInitXkbKeyboardState(void)
{
- XEvent X;
-
- unsigned int modifiers;
+ XEvent X = {0};
XkbEvent *xkbev = (XkbEvent *) &X;
@@ -3825,8 +3681,7 @@ int nxagentInitXkbKeyboardState(void)
fprintf(stderr, "%s: Initializing XKB state.\n", __func__);
#endif
- memset(&X, 0, sizeof(XEvent));
-
+ unsigned int modifiers;
XkbGetIndicatorState(nxagentDisplay, XkbUseCoreKbd, &modifiers);
xkbev -> state.locked_mods = 0x0;
@@ -3873,17 +3728,13 @@ int nxagentWaitForResource(GetResourceFuncPtr pGetResource, PredicateFuncPtr pPr
void nxagentGrabPointerAndKeyboard(XEvent *X)
{
- unsigned long now;
-
- int resource;
-
- int result;
-
#ifdef TEST
- fprintf(stderr, "nxagentGrabPointerAndKeyboard: Grabbing pointer and keyboard with event at [%p].\n",
+ fprintf(stderr, "%s: Grabbing pointer and keyboard with event at [%p].\n", __func__,
(void *) X);
#endif
+ unsigned long now;
+
if (X != NULL)
{
now = X -> xcrossing.time;
@@ -3894,15 +3745,13 @@ void nxagentGrabPointerAndKeyboard(XEvent *X)
}
#ifdef TEST
- fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to grab the keyboard in context [B1].\n");
+ fprintf(stderr, "%s: Going to grab the keyboard in context [B1].\n", __func__);
#endif
- if (nxagentFullscreenWindow)
- result = XGrabKeyboard(nxagentDisplay, nxagentFullscreenWindow,
- True, GrabModeAsync, GrabModeAsync, now);
- else
- result = XGrabKeyboard(nxagentDisplay, RootWindow(nxagentDisplay, DefaultScreen(nxagentDisplay)),
- True, GrabModeAsync, GrabModeAsync, now);
+ int result = XGrabKeyboard(nxagentDisplay,
+ nxagentFullscreenWindow ? nxagentFullscreenWindow
+ : RootWindow(nxagentDisplay, DefaultScreen(nxagentDisplay)),
+ True, GrabModeAsync, GrabModeAsync, now);
if (result != GrabSuccess)
{
@@ -3919,20 +3768,19 @@ void nxagentGrabPointerAndKeyboard(XEvent *X)
#endif
/*
- * The smart scheduler could be stopped while
- * waiting for the reply. In this case we need
- * to yield explicitly to avoid to be stuck in
- * the dispatch loop forever.
+ * The smart scheduler could be stopped while waiting for the
+ * reply. In this case we need to yield explicitly to avoid to be
+ * stuck in the dispatch loop forever.
*/
isItTimeToYield = 1;
#ifdef TEST
- fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to grab the pointer in context [B2].\n");
+ fprintf(stderr, "%s: Going to grab the pointer in context [B2].\n", __func__);
#endif
- resource = nxagentWaitForResource(NXGetCollectGrabPointerResource,
- nxagentCollectGrabPointerPredicate);
+ int resource = nxagentWaitForResource(NXGetCollectGrabPointerResource,
+ nxagentCollectGrabPointerPredicate);
if (nxagentFullscreenWindow)
NXCollectGrabPointer(nxagentDisplay, resource,
@@ -3949,7 +3797,7 @@ void nxagentGrabPointerAndKeyboard(XEvent *X)
if (X != NULL)
{
#ifdef TEST
- fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to force focus in context [B4].\n");
+ fprintf(stderr, "%s: Going to force focus in context [B4].\n", __func__);
#endif
XSetInputFocus(nxagentDisplay, nxagentFullscreenWindow,
@@ -3962,7 +3810,7 @@ void nxagentUngrabPointerAndKeyboard(XEvent *X)
unsigned long now;
#ifdef TEST
- fprintf(stderr, "nxagentUngrabPointerAndKeyboard: Ungrabbing pointer and keyboard with event at [%p].\n",
+ fprintf(stderr, "%s: Ungrabbing pointer and keyboard with event at [%p].\n", __func__,
(void *) X);
#endif
@@ -3976,13 +3824,13 @@ void nxagentUngrabPointerAndKeyboard(XEvent *X)
}
#ifdef TEST
- fprintf(stderr, "nxagentUngrabPointerAndKeyboard: Going to ungrab the keyboard in context [B5].\n");
+ fprintf(stderr, "%s: Going to ungrab the keyboard in context [B5].\n", __func__);
#endif
XUngrabKeyboard(nxagentDisplay, now);
#ifdef TEST
- fprintf(stderr, "nxagentUngrabPointerAndKeyboard: Going to ungrab the pointer in context [B6].\n");
+ fprintf(stderr, "%s: Going to ungrab the pointer in context [B6].\n", __func__);
#endif
XUngrabPointer(nxagentDisplay, now);
@@ -4031,28 +3879,19 @@ void nxagentHandleCollectGrabPointerEvent(int resource)
if (NXGetCollectedGrabPointer(nxagentDisplay, resource, &status) == 0)
{
#ifdef PANIC
- fprintf(stderr, "nxagentHandleCollectGrabPointerEvent: PANIC! Failed to get GrabPointer "
- "reply for resource [%d].\n", resource);
+ fprintf(stderr, "%s: PANIC! Failed to get GrabPointer reply for resource [%d].\n", __func__, resource);
#endif
}
}
void nxagentHandleCollectPropertyEvent(XEvent *X)
{
- Window window;
- Atom property;
- Atom atomReturnType;
- int resultFormat;
- unsigned long ulReturnItems;
- unsigned long ulReturnBytesLeft;
- unsigned char *pszReturnData = NULL;
- int result;
int resource = X -> xclient.data.l[1];
if (X -> xclient.data.l[2] == False)
{
#ifdef DEBUG
- fprintf (stderr, "nxagentHandleCollectPropertyEvent: Failed to get reply data for client [%d].\n",
+ fprintf (stderr, "%s: Failed to get reply data for client [%d].\n", __func__,
resource);
#endif
@@ -4065,18 +3904,24 @@ void nxagentHandleCollectPropertyEvent(XEvent *X)
}
else
{
- result = NXGetCollectedProperty(nxagentDisplay,
- resource,
- &atomReturnType,
- &resultFormat,
- &ulReturnItems,
- &ulReturnBytesLeft,
- &pszReturnData);
+ Atom atomReturnType;
+ int resultFormat;
+ unsigned long ulReturnItems;
+ unsigned long ulReturnBytesLeft;
+ unsigned char *pszReturnData = NULL;
+
+ int result = NXGetCollectedProperty(nxagentDisplay,
+ resource,
+ &atomReturnType,
+ &resultFormat,
+ &ulReturnItems,
+ &ulReturnBytesLeft,
+ &pszReturnData);
if (result == True)
{
- window = nxagentPropertyRequests[resource].window;
- property = nxagentPropertyRequests[resource].property;
+ Window window = nxagentPropertyRequests[resource].window;
+ Atom property = nxagentPropertyRequests[resource].property;
nxagentImportProperty(window, property, atomReturnType, resultFormat,
ulReturnItems, ulReturnBytesLeft, pszReturnData);
@@ -4084,7 +3929,7 @@ void nxagentHandleCollectPropertyEvent(XEvent *X)
else
{
#ifdef DEBUG
- fprintf (stderr, "nxagentHandleCollectPropertyEvent: Failed to get reply data for client [%d].\n",
+ fprintf (stderr, "%s: Failed to get reply data for client [%d].\n", __func__,
resource);
#endif
}
@@ -4097,19 +3942,17 @@ void nxagentHandleCollectPropertyEvent(XEvent *X)
void nxagentSynchronizeExpose(void)
{
- WindowPtr pWin;
-
if (nxagentExposeQueue.length <= 0)
{
#ifdef TEST
- fprintf(stderr, "nxagentSynchronizeExpose: PANIC! Called with nxagentExposeQueue.length [%d].\n",
+ fprintf(stderr, "%s: PANIC! Called with nxagentExposeQueue.length [%d].\n", __func__,
nxagentExposeQueue.length);
#endif
return;
}
- pWin = nxagentExposeQueueHead.pWindow;
+ WindowPtr pWin = nxagentExposeQueueHead.pWindow;
if (pWin)
{
@@ -4136,8 +3979,8 @@ void nxagentSynchronizeExpose(void)
((pWin -> eventMask|wOtherEventMasks(pWin)) & ExposureMask))
{
#ifdef TEST
- fprintf(stderr, "nxagentSynchronizeExpose: Going to call miWindowExposures"
- " for window [%d] - rects [%d].\n", nxagentWindow(pWin),
+ fprintf(stderr, "%s: Going to call miWindowExposures for window [%d] - rects [%d].\n",
+ __func__, nxagentWindow(pWin),
RegionNumRects(nxagentExposeQueueHead.remoteRegion));
#endif
@@ -4152,16 +3995,13 @@ void nxagentSynchronizeExpose(void)
{
RegionDestroy(nxagentExposeQueueHead.localRegion);
}
-
nxagentExposeQueueHead.localRegion = NullRegion;
if (nxagentExposeQueueHead.remoteRegion != NullRegion)
{
RegionDestroy(nxagentExposeQueueHead.remoteRegion);
}
-
nxagentExposeQueueHead.remoteRegion = NullRegion;
-
nxagentExposeQueueHead.remoteRegionIsCompleted = False;
nxagentExposeQueue.start = (nxagentExposeQueue.start + 1) % EXPOSED_SIZE;
@@ -4197,13 +4037,11 @@ void nxagentRemoveDuplicatedKeys(XEvent *X)
{
#ifdef TEST
- fprintf(stderr, "nxagentRemoveDuplicatedKeys: Trying to read more events "
- "from the X server.\n");
+ fprintf(stderr, "%s: Trying to read more events from the X server.\n", __func__);
if (nxagentReadEvents(nxagentDisplay) > 0)
{
- fprintf(stderr, "nxagentRemoveDuplicatedKeys: Successfully read more events "
- "from the X server.\n");
+ fprintf(stderr, "%s: Successfully read more events from the X server.\n", __func__);
}
#else
@@ -4280,7 +4118,7 @@ void nxagentInitRemoteExposeRegion(void)
if (nxagentRemoteExposeRegion == NULL)
{
#ifdef PANIC
- fprintf(stderr, "nxagentInitRemoteExposeRegion: PANIC! Failed to create expose region.\n");
+ fprintf(stderr, "%s: PANIC! Failed to create expose region.\n", __func__);
#endif
}
}
@@ -4291,7 +4129,7 @@ void nxagentForwardRemoteExpose(void)
if (RegionNotEmpty(nxagentRemoteExposeRegion))
{
#ifdef DEBUG
- fprintf(stderr, "nxagentForwardRemoteExpose: Going to forward events.\n");
+ fprintf(stderr, "%s: Going to forward events.\n", __func__);
#endif
TraverseTree(screenInfo.screens[0]->root, nxagentClipAndSendExpose, (void *)nxagentRemoteExposeRegion);
@@ -4306,13 +4144,12 @@ void nxagentForwardRemoteExpose(void)
void nxagentAddRectToRemoteExposeRegion(BoxPtr rect)
{
- RegionRec exposeRegion;
-
if (nxagentRemoteExposeRegion == NULL)
{
return;
}
+ RegionRec exposeRegion;
RegionInit(&exposeRegion, rect, 1);
RegionUnion(nxagentRemoteExposeRegion,
@@ -4326,7 +4163,7 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr)
RegionPtr remoteExposeRgn = (RegionRec *) ptr;
#ifdef DEBUG
- fprintf(stderr, "nxagentClipAndSendExpose: Called.\n");
+ fprintf(stderr, "%s: Called.\n", __func__);
#endif
if (pWin -> drawable.class != InputOnly)
@@ -4336,12 +4173,12 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr)
#ifdef DEBUG
BoxRec box = *RegionExtents(remoteExposeRgn);
- fprintf(stderr, "nxagentClipAndSendExpose: Root expose extents: [%d] [%d] [%d] [%d].\n",
+ fprintf(stderr, "%s: Root expose extents: [%d] [%d] [%d] [%d].\n", __func__,
box.x1, box.y1, box.x2, box.y2);
box = *RegionExtents(&pWin -> clipList);
- fprintf(stderr, "nxagentClipAndSendExpose: Clip list extents for window at [%p]: [%d] [%d] [%d] [%d].\n",
+ fprintf(stderr, "%s: Clip list extents for window at [%p]: [%d] [%d] [%d] [%d].\n", __func__,
(void *)pWin, box.x1, box.y1, box.x2, box.y2);
#endif
@@ -4350,14 +4187,13 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr)
if (RegionNotEmpty(exposeRgn))
{
#ifdef DEBUG
- fprintf(stderr, "nxagentClipAndSendExpose: Forwarding expose to window at [%p] pWin.\n",
+ fprintf(stderr, "%s: Forwarding expose to window at [%p] pWin.\n", __func__,
(void *)pWin);
#endif
/*
- * The miWindowExposures() clears out the
- * region parameters, so the subtract ope-
- * ration must be done before calling it.
+ * The miWindowExposures() clears out the region parameters, so
+ * the subtract ope- ration must be done before calling it.
*/
RegionSubtract(remoteExposeRgn, remoteExposeRgn, exposeRgn);
@@ -4371,7 +4207,7 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr)
if (RegionNotEmpty(remoteExposeRgn))
{
#ifdef DEBUG
- fprintf(stderr, "nxagentClipAndSendExpose: Region not empty. Walk children.\n");
+ fprintf(stderr, "%s: Region not empty. Walk children.\n", __func__);
#endif
return WT_WALKCHILDREN;
@@ -4379,7 +4215,7 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr)
else
{
#ifdef DEBUG
- fprintf(stderr, "nxagentClipAndSendExpose: Region empty. Stop walking.\n");
+ fprintf(stderr, "%s: Region empty. Stop walking.\n", __func__);
#endif
return WT_STOPWALKING;
@@ -4391,13 +4227,10 @@ int nxagentUserInput(void *p)
int result = 0;
/*
- * This function is used as callback in
- * the polling handler of agent in shadow
- * mode. When inside the polling loop the
- * handlers are never called, so we have
- * to dispatch enqueued events to eventu-
- * ally change the nxagentInputEvent sta-
- * tus.
+ * This function is used as callback in the polling handler of agent
+ * in shadow mode. When inside the polling loop the handlers are
+ * never called, so we have to dispatch enqueued events to
+ * eventually change the nxagentInputEvent status.
*/
if (nxagentOption(Shadow) == 1 &&
@@ -4414,11 +4247,9 @@ int nxagentUserInput(void *p)
}
/*
- * The agent working in shadow mode synch-
- * ronizes the remote X server even if a
- * button/key is not released (i.e. when
- * scrolling a long browser's page), in
- * order to update the screen smoothly.
+ * The agent working in shadow mode synchronizes the remote X server
+ * even if a button/key is not released (i.e. when scrolling a long
+ * browser's page), in order to update the screen smoothly.
*/
if (nxagentOption(Shadow) == 1)
@@ -4429,9 +4260,8 @@ int nxagentUserInput(void *p)
if (result == 0)
{
/*
- * If there is at least one button/key down,
- * we are receiving an input. This is not a
- * condition to break a synchronization loop
+ * If there is at least one button/key down, we are receiving an
+ * input. This is not a condition to break a synchronization loop
* if there is enough bandwidth.
*/
@@ -4440,7 +4270,7 @@ int nxagentUserInput(void *p)
nxagentKeyDown > 0))
{
#ifdef TEST
- fprintf(stderr, "nxagentUserInput: Buttons [%d] Keys [%d].\n",
+ fprintf(stderr, "%s: Buttons [%d] Keys [%d].\n", __func__,
inputInfo.pointer -> button -> buttonsDown, nxagentKeyDown);
#endif
@@ -4456,7 +4286,7 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X)
XRRScreenChangeNotifyEvent *Xr = (XRRScreenChangeNotifyEvent *) X;
#ifdef DEBUG
- fprintf(stderr, "nxagentHandleRRScreenChangeNotify called.\n");
+ fprintf(stderr, "%s: Called.\n", __func__);
#endif
nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], Xr -> width, Xr -> height,
@@ -4471,13 +4301,11 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X)
}
/*
- * Returns true if there is any event waiting to
- * be dispatched. This function is critical for
- * the performance because it is called very,
- * very often. It must also handle the case when
- * the display is down. The display descriptor,
- * in fact, may have been reused by some other
- * client.
+ * Returns true if there is any event waiting to be dispatched. This
+ * function is critical for the performance because it is called very,
+ * very often. It must also handle the case when the display is
+ * down. The display descriptor, in fact, may have been reused by some
+ * other client.
*/
int nxagentPendingEvents(Display *dpy)
@@ -4485,7 +4313,7 @@ int nxagentPendingEvents(Display *dpy)
if (_XGetIOError(dpy) != 0)
{
#ifdef DEBUG
- fprintf(stderr, "nxagentPendingEvents: Returning error with display down.\n");
+ fprintf(stderr, "%s: Returning error with display down.\n", __func__);
#endif
return -1;
@@ -4493,7 +4321,7 @@ int nxagentPendingEvents(Display *dpy)
else if (XQLength(dpy) > 0)
{
#ifdef DEBUG
- fprintf(stderr, "nxagentPendingEvents: Returning true with [%d] events queued.\n",
+ fprintf(stderr, "%s: Returning true with [%d] events queued.\n", __func__,
XQLength(dpy));
#endif
@@ -4508,7 +4336,7 @@ int nxagentPendingEvents(Display *dpy)
if (readable > 0)
{
#ifdef DEBUG
- fprintf(stderr, "nxagentPendingEvents: Returning true with [%d] bytes readable.\n",
+ fprintf(stderr, "%s: Returning true with [%d] bytes readable.\n", __func__,
readable);
#endif
@@ -4516,7 +4344,7 @@ int nxagentPendingEvents(Display *dpy)
}
#ifdef DEBUG
- fprintf(stderr, "nxagentPendingEvents: Returning false with [%d] bytes readable.\n",
+ fprintf(stderr, "%s: Returning false with [%d] bytes readable.\n", __func__,
readable);
#endif
@@ -4524,7 +4352,7 @@ int nxagentPendingEvents(Display *dpy)
}
#ifdef TEST
- fprintf(stderr, "nxagentPendingEvents: WARNING! Error detected on the X display.\n");
+ fprintf(stderr, "%s: WARNING! Error detected on the X display.\n", __func__);
#endif
NXForceDisplayError(dpy);
@@ -4540,7 +4368,7 @@ int nxagentPendingEvents(Display *dpy)
int nxagentWaitEvents(Display *dpy, useconds_t msec)
{
#ifdef DEBUG
- fprintf(stderr, "nxagentWaitEvents called.\n");
+ fprintf(stderr, "%s: Called.\n", __func__);
#endif
NXFlushDisplay(dpy, NXFlushLink);
@@ -4625,37 +4453,26 @@ static const char *nxagentGrabStateToString(int state)
{
switch (state)
{
- case 0:
- return "NOT_GRABBED";
- case 1:
- return "THAWED";
- case 2:
- return "THAWED_BOTH";
- case 3:
- return "FREEZE_NEXT_EVENT";
- case 4:
- return "FREEZE_BOTH_NEXT_EVENT";
- case 5:
- return "FROZEN_NO_EVENT";
- case 6:
- return "FROZEN_WITH_EVENT";
- case 7:
- return "THAW_OTHERS";
- default:
- return "unknown state";
+ case 0: return "NOT_GRABBED";
+ case 1: return "THAWED";
+ case 2: return "THAWED_BOTH";
+ case 3: return "FREEZE_NEXT_EVENT";
+ case 4: return "FREEZE_BOTH_NEXT_EVENT";
+ case 5: return "FROZEN_NO_EVENT";
+ case 6: return "FROZEN_WITH_EVENT";
+ case 7: return "THAW_OTHERS";
+ default: return "unknown state";
}
}
void nxagentDumpInputDevicesState(void)
{
- DeviceIntPtr dev;
- GrabPtr grab;
WindowPtr pWin = NULL;
fprintf(stderr, "\n*** Dump input devices state: BEGIN ***"
"\nKeys down:");
- dev = inputInfo.keyboard;
+ DeviceIntPtr dev = inputInfo.keyboard;
for (int i = 0; i < DOWN_LENGTH; i++)
{
@@ -4683,7 +4500,7 @@ void nxagentDumpInputDevicesState(void)
dev -> fromPassiveGrab ? "Yes" : "No",
dev -> activatingKey);
- grab = dev -> grab;
+ GrabPtr grab = dev -> grab;
if (grab)
{
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c
index 09ad471c8..93fb93295 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Font.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c
@@ -159,8 +159,7 @@ static struct _nxagentFailedToReconnectFonts
} nxagentFailedToReconnectFonts = {NULL, NULL, 0, 0};
/*
- * This is used if nxagentFullGeneration is true
- * in CloseDisplay().
+ * This is used if nxagentFullGeneration is true in CloseDisplay().
*/
void nxagentFreeFontCache(void)
@@ -218,8 +217,7 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames)
}
/*
- * Avoid querying again the remote
- * fonts.
+ * Avoid querying again the remote fonts.
*/
if (nxagentRemoteFontList.length > 0)
@@ -228,13 +226,11 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames)
}
/*
- * We can't retrieve the full remote font
- * list with a single query, because the
- * number of dashes in the pattern acts as
- * a rule to select how to search for the
- * font names, so the pattern '*' is useful
- * to retrieve the font aliases, while the
- * other one will select the 'real' fonts.
+ * We can't retrieve the full remote font list with a single query,
+ * because the number of dashes in the pattern acts as a rule to
+ * select how to search for the font names, so the pattern '*' is
+ * useful to retrieve the font aliases, while the other one will
+ * select the 'real' fonts.
*/
for (int p = 0; p < patternsQt; p++)
@@ -246,8 +242,8 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames)
#endif
/*
- * Add the ListFont request pattern to the list with
- * the last requested maxnames.
+ * Add the ListFont request pattern to the list with the last
+ * requested maxnames.
*/
nxagentListRemoteAddName(searchPattern, maxNames);
@@ -686,11 +682,10 @@ int nxagentDestroyNewFontResourceType(void * p, XID id)
#endif
/*
-FIXME: It happens that this resource had been already
- destroyed. We should verify if the same font is
- assigned both to the server client and another
- client. We had a crash when freeing server client
- resources.
+FIXME: It happens that this resource had been already destroyed. We
+ should verify if the same font is assigned both to the server
+ client and another client. We had a crash when freeing server
+ client resources.
*/
if (nxagentFontPriv((FontPtr) p) != NULL)
{
@@ -706,14 +701,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
char substFontBuf[512];;
- /* X Logical Font Description Conventions
- * require 14 fields in the font names.
+ /* X Logical Font Description Conventions require 14 fields in the
+ * font names.
*
*/
char *searchFields[FIELDS+1];
char *fontNameFields[FIELDS+1];
- int i;
- int j;
int numSearchFields = 0;
int numFontFields = 0;
int weight = 0;
@@ -753,7 +746,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
}
else
{
- for (i = 1 ; i < nxagentRemoteFontList.length ; i++)
+ for (int i = 1 ; i < nxagentRemoteFontList.length ; i++)
{
numSearchFields = nxagentSplitString(nxagentRemoteFontList.list[i]->name, searchFields, FIELDS+1, "-");
@@ -778,7 +771,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
tempWeight = 0;
- for (j = 0; j < FIELDS; j++)
+ for (int j = 0; j < FIELDS; j++)
{
if (strcasecmp(searchFields[fieldOrder[j]], fontNameFields[fieldOrder[j]]) == 0 ||
strcmp(searchFields[fieldOrder[j]], "") == 0 ||
@@ -806,7 +799,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
#endif
}
- for (j = 0; j < numSearchFields; j++)
+ for (int j = 0; j < numSearchFields; j++)
{
SAFE_free(searchFields[j]);
}
@@ -823,7 +816,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
fontStruct = nxagentLoadQueryFont(dpy, substFontBuf, pFont);
- for (j = 0; j < numFontFields; j++)
+ for (int j = 0; j < numFontFields; j++)
{
SAFE_free(fontNameFields[j]);
}
@@ -833,13 +826,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2)
{
- nxagentPrivFont *privFont;
Bool *pBool = (Bool*)param2;
if (pFont == NULL || !*pBool)
return;
- privFont = nxagentFontPriv(pFont);
+ nxagentPrivFont *privFont = nxagentFontPriv(pFont);
#ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf(stderr, "nxagentFontDisconnect: pFont %p, XID %lx\n",
@@ -936,13 +928,12 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id)
static void nxagentFontReconnect(FontPtr pFont, XID param1, void * param2)
{
int i;
- nxagentPrivFont *privFont;
Bool *pBool = (Bool*)param2;
if (pFont == NULL)
return;
- privFont = nxagentFontPriv(pFont);
+ nxagentPrivFont *privFont = nxagentFontPriv(pFont);
#ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf(stderr, "nxagentFontReconnect: pFont %p - XID %lx - name %s\n",
@@ -1067,8 +1058,7 @@ static void nxagentCleanCacheAfterReconnect(void)
for (j = CACHE_INDEX - 1; CACHE_FSTRUCT(j) == NULL; j--);
/*
- * Now we can swap the two entry
- * and reduce the Cache index
+ * Now we can swap the two entry and reduce the Cache index
*/
swapEntryPtr = CACHE_ENTRY(i);
CACHE_ENTRY(i) = CACHE_ENTRY(j);
@@ -1109,9 +1099,8 @@ Bool nxagentReconnectAllFonts(void *p0)
#endif
/*
- * The resource type RT_NX_FONT is created on the
- * server client only, so we can avoid to loop
- * through all the clients.
+ * The resource type RT_NX_FONT is created on the server client
+ * only, so we can avoid to loop through all the clients.
*/
FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT,
@@ -1341,9 +1330,8 @@ Bool nxagentDisconnectAllFonts(void)
nxagentFreeCacheBeforeReconnect();
/*
- * The resource type RT_NX_FONT is created on the
- * server client only, so we can avoid to loop
- * through all the clients.
+ * The resource type RT_NX_FONT is created on the server client
+ * only, so we can avoid to loop through all the clients.
*/
FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT,
@@ -1630,26 +1618,17 @@ int nxagentFreeFont(XFontStruct *fs)
int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
{
- int seplen;
- int fieldlen;
- int last;
- int len;
- int i;
-
- char *current;
- char *next;
-
- seplen = strlen(sep);
- len = strlen(string);
+ int seplen = strlen(sep);
+ int len = strlen(string);
- current = string;
+ char *current = string;
- i = 0;
- last = 0;
+ int i = 0;
+ int last = 0;
for (;;)
{
- next = NULL;
+ char *next = NULL;
if (current < string + len)
{
@@ -1662,7 +1641,7 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
last = 1;
}
- fieldlen = next - current;
+ int fieldlen = next - current;
if (i < nfields)
{
@@ -1689,8 +1668,6 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
{
char *scalableFontName;
- const char *s;
- int field;
/* FIXME: use str(n)dup()? */
if ((scalableFontName = malloc(strlen(fontName) + 1)) == NULL)
@@ -1709,9 +1686,9 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
goto MakeScalableFontNameError;
}
- s = fontName;
+ const char *s = fontName;
- field = 0;
+ int field = 0;
while (s != NULL)
{
diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c
index b53428f96..1feb62a4d 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/GC.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c
@@ -66,6 +66,7 @@ is" without express or implied warranty.
#include "../../fb/fb.h"
RESTYPE RT_NX_GC;
+
/*
* Set here the required log level.
*/
@@ -142,8 +143,6 @@ static GCOps nxagentOps =
Bool nxagentCreateGC(GCPtr pGC)
{
- FbGCPrivPtr pPriv;
-
pGC->clientClipType = CT_NONE;
pGC->clientClip = NULL;
@@ -163,11 +162,9 @@ Bool nxagentCreateGC(GCPtr pGC)
}
/*
- * We create the GC based on the default
- * drawables. The proxy knows this and
- * optimizes the encoding of the create
- * GC message to include the id of the
- * drawable in the checksum.
+ * We create the GC based on the default drawables. The proxy knows
+ * this and optimizes the encoding of the create GC message to
+ * include the id of the drawable in the checksum.
*/
nxagentGCPriv(pGC)->gc = XCreateGC(nxagentDisplay,
@@ -178,7 +175,7 @@ Bool nxagentCreateGC(GCPtr pGC)
fprintf(stderr, "nxagentCreateGC: GC [%p]\n", (void *) pGC);
#endif
- pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr;
+ FbGCPrivPtr pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr;
fbGetRotatedPixmap(pGC) = 0;
fbGetExpose(pGC) = 1;
@@ -187,24 +184,18 @@ Bool nxagentCreateGC(GCPtr pGC)
pPriv->bpp = BitsPerPixel (pGC->depth);
- nxagentGCPriv(pGC)->nClipRects = 0;
-
- memset(&(nxagentGCPriv(pGC) -> lastServerValues), 0, sizeof(XGCValues));
-
/*
* Init to default GC values.
*/
+ memset(&(nxagentGCPriv(pGC) -> lastServerValues), 0, sizeof(XGCValues));
nxagentGCPriv(pGC) -> lastServerValues.background = 1;
-
nxagentGCPriv(pGC) -> lastServerValues.plane_mask = ~0;
-
nxagentGCPriv(pGC) -> lastServerValues.graphics_exposures = 1;
-
nxagentGCPriv(pGC) -> lastServerValues.dashes = 4;
+ nxagentGCPriv(pGC) -> nClipRects = 0;
nxagentGCPriv(pGC) -> mid = FakeClientID(serverClient -> index);
-
nxagentGCPriv(pGC) -> pPixmap = NULL;
AddResource(nxagentGCPriv(pGC) -> mid, RT_NX_GC, (void *) pGC);
@@ -214,8 +205,6 @@ Bool nxagentCreateGC(GCPtr pGC)
void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
{
- PixmapPtr lastTile, lastStipple;
-
DrawablePtr pVirtual = (pDrawable -> type == DRAWABLE_PIXMAP) ?
nxagentVirtualDrawable(pDrawable) :
pDrawable;
@@ -233,9 +222,9 @@ void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
pGC -> tile.pixmap = nxagentVirtualPixmap(pGC -> tile.pixmap);
}
- lastTile = pGC -> tile.pixmap;
+ PixmapPtr lastTile = pGC -> tile.pixmap;
- lastStipple = pGC->stipple;
+ PixmapPtr lastStipple = pGC->stipple;
if (lastStipple)
{
@@ -251,8 +240,8 @@ void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
if (pVirtual -> bitsPerPixel == 0)
{
/*
- * Don't enter fbValidateGC() with 0 bpp
- * or agent will block in a endless loop.
+ * Don't enter fbValidateGC() with 0 bpp or agent will block in a
+ * endless loop.
*/
#ifdef WARNING
@@ -331,13 +320,11 @@ void nxagentChangeGC(GCPtr pGC, unsigned long mask)
nxagentGCTrap == 0)
{
/*
- * If the tile is corrupted and is not too
- * much large, it can be synchronized imme-
- * diately. In the other cases, the tile is
- * cleared with a solid color to become usa-
- * ble. This approach should solve the high
- * delay on slow links waiting for a back-
- * ground tile to be synchronized.
+ * If the tile is corrupted and is not too large, it can be
+ * synchronized immediately. In the other cases, the tile is
+ * cleared with a solid color to become usable. This approach
+ * should solve the high delay on slow links waiting for a
+ * background tile to be synchronized.
*/
if (nxagentOption(DeferLevel) >= 2 &&
@@ -473,7 +460,7 @@ void nxagentCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
#ifdef TEST
fprintf(stderr, "nxagentCopyGC: Copying the GC with source at [%p] destination "
- "at [%p] mask [%lu].\n", pGCSrc, pGCDst, mask);
+ "at [%p] mask [%lu].\n", (void *)pGCSrc, (void *)pGCDst, mask);
#endif
/*
@@ -485,8 +472,8 @@ void nxagentCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
XCopyGC(nxagentDisplay, nxagentGC(pGCSrc), mask, nxagentGC(pGCDst));
/*
- * Copy the private foreground field
- * of the GC if GCForeground is set.
+ * Copy the private foreground field of the GC if GCForeground is
+ * set.
*/
nxagentCopyGCPriv(GCForeground,foreground,pGCSrc,mask,pGCDst);
@@ -510,9 +497,6 @@ void nxagentDestroyGC(GCPtr pGC)
void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
{
- int i, size;
- BoxPtr pBox;
- XRectangle *pRects;
int clipsMatch = 0;
#ifdef TEST
@@ -525,13 +509,11 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
case CT_NONE:
{
clipsMatch = (pGC -> clientClipType == None);
-
break;
}
case CT_REGION:
{
clipsMatch = nxagentCompareRegions(pGC -> clientClip, (RegionPtr) pValue);
-
break;
}
case CT_UNSORTED:
@@ -540,17 +522,13 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
case CT_YXBANDED:
{
RegionPtr pReg = RegionFromRects(nRects, (xRectangle *)pValue, type);
-
clipsMatch = nxagentCompareRegions(pGC -> clientClip, pReg);
-
RegionDestroy(pReg);
-
break;
}
default:
{
clipsMatch = 0;
-
break;
}
}
@@ -570,19 +548,19 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
{
XSetClipMask(nxagentDisplay, nxagentGC(pGC), None);
}
-
break;
}
case CT_REGION:
{
if (clipsMatch == 0 && nxagentGCTrap == 0)
{
+ XRectangle *pRects;
nRects = RegionNumRects((RegionPtr)pValue);
- size = nRects * sizeof(*pRects);
+ int size = nRects * sizeof(*pRects);
pRects = (XRectangle *) malloc(size);
- pBox = RegionRects((RegionPtr)pValue);
+ BoxPtr pBox = RegionRects((RegionPtr)pValue);
- for (i = nRects; i-- > 0;)
+ for (int i = nRects; i-- > 0;)
{
pRects[i].x = pBox[i].x1;
pRects[i].y = pBox[i].y1;
@@ -594,7 +572,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
pRects, nRects, Unsorted);
SAFE_free(pRects);
}
-
break;
}
case CT_PIXMAP:
@@ -623,7 +600,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
pGC->clipOrg.x, pGC->clipOrg.y,
(XRectangle *)pValue, nRects, Unsorted);
}
-
break;
}
case CT_YSORTED:
@@ -634,7 +610,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
pGC->clipOrg.x, pGC->clipOrg.y,
(XRectangle *)pValue, nRects, YSorted);
}
-
break;
}
case CT_YXSORTED:
@@ -645,7 +620,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
pGC->clipOrg.x, pGC->clipOrg.y,
(XRectangle *)pValue, nRects, YXSorted);
}
-
break;
}
case CT_YXBANDED:
@@ -656,7 +630,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
pGC->clipOrg.x, pGC->clipOrg.y,
(XRectangle *)pValue, nRects, YXBanded);
}
-
break;
}
}
@@ -669,9 +642,8 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects)
case CT_YXBANDED:
{
/*
- * Other parts of the server can only
- * deal with CT_NONE, CT_PIXMAP and
- * CT_REGION client clips.
+ * Other parts of the server can only deal with CT_NONE,
+ * CT_PIXMAP and CT_REGION client clips.
*/
pGC->clientClip = (void *) RegionFromRects(nRects,
@@ -742,8 +714,6 @@ void nxagentDestroyClipHelper(GCPtr pGC)
void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
{
- RegionPtr pRgn;
-
#ifdef TEST
fprintf(stderr, "nxagentCopyClip: Going to copy clip from GC [%p] to GC [%p]\n",
(void *) pGCDst, (void *) pGCSrc);
@@ -754,7 +724,7 @@ void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
case CT_REGION:
if (nxagentGCPriv(pGCSrc)->pPixmap == NULL)
{
- pRgn = RegionCreate(NULL, 1);
+ RegionPtr pRgn = RegionCreate(NULL, 1);
RegionCopy(pRgn, pGCSrc->clientClip);
nxagentChangeClip(pGCDst, CT_REGION, pRgn, 0);
}
@@ -777,11 +747,9 @@ void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
nxagentChangeClip(pGCDst, CT_PIXMAP, pGCSrc->clientClip, 0);
break;
-
case CT_NONE:
nxagentDestroyClip(pGCDst);
break;
-
}
}
@@ -896,7 +864,7 @@ int nxagentDestroyNewGCResourceType(void * p, XID id)
*/
#ifdef TEST
- fprintf(stderr, "nxagentDestroyNewGCResourceType: Destroying mirror id [%ld] for GC at [%p].\n",
+ fprintf(stderr, "nxagentDestroyNewGCResourceType: Destroying mirror id [%u] for GC at [%p].\n",
nxagentGCPriv((GCPtr) p) -> mid, (void *) p);
#endif
@@ -1029,7 +997,6 @@ static void nxagentReconnectGC(void *param0, XID param1, void * param2)
Bool nxagentReconnectAllGCs(void *p0)
{
- int cid;
Bool GCSuccess = True;
#ifdef DEBUG
@@ -1037,14 +1004,13 @@ Bool nxagentReconnectAllGCs(void *p0)
#endif
/*
- * The resource type RT_NX_GC is created on the
- * server client only, so we can avoid to loop
- * through all the clients.
+ * The resource type RT_NX_GC is created on the server client only,
+ * so we can avoid to loop through all the clients.
*/
FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, nxagentReconnectGC, &GCSuccess);
- for (cid = 0; (cid < MAXCLIENTS) && GCSuccess; cid++)
+ for (int cid = 0; (cid < MAXCLIENTS) && GCSuccess; cid++)
{
if (clients[cid])
{
@@ -1076,21 +1042,18 @@ void nxagentDisconnectGC(void * p0, XID x1, void * p2)
fprintf(stderr, "nxagentDisconnectGC: WARNING! pGC is NULL.\n");
#endif
}
-
return;
}
if (pGC -> stipple)
{
PixmapPtr pMap = pGC -> stipple;
-
nxagentDisconnectPixmap(nxagentRealPixmap(pMap), 0, pBool);
}
}
Bool nxagentDisconnectAllGCs(void)
{
- int cid;
Bool success = True;
#ifdef DEBUG
@@ -1098,15 +1061,14 @@ Bool nxagentDisconnectAllGCs(void)
#endif
/*
- * The resource type RT_NX_GC is created on the
- * server client only, so we can avoid to loop
- * through all the clients.
+ * The resource type RT_NX_GC is created on the server client only,
+ * so we can avoid to loop through all the clients.
*/
FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC,
(FindResType) nxagentDisconnectGC, &success);
- for (cid = 0; (cid < MAXCLIENTS) && success; cid++)
+ for (int cid = 0; (cid < MAXCLIENTS) && success; cid++)
{
if (clients[cid])
{
@@ -1132,10 +1094,6 @@ Bool nxagentDisconnectAllGCs(void)
static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
{
- int i, size;
- BoxPtr pBox;
- XRectangle *pRects;
-
#ifdef TEST
fprintf(stderr, "nxagentReconnectClip: going to change clip on GC [%p]\n",
(void *) pGC);
@@ -1152,15 +1110,14 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
case CT_NONE:
XSetClipMask(nxagentDisplay, nxagentGC(pGC), None);
break;
-
case CT_REGION:
if (nxagentGCPriv(pGC)->pPixmap == NULL)
{
nRects = RegionNumRects((RegionPtr)pValue);
- size = nRects * sizeof(*pRects);
- pRects = (XRectangle *) malloc(size);
- pBox = RegionRects((RegionPtr)pValue);
- for (i = nRects; i-- > 0;) {
+ int size = nRects * sizeof(XRectangle *);
+ XRectangle *pRects = (XRectangle *) malloc(size);
+ BoxPtr pBox = RegionRects((RegionPtr)pValue);
+ for (int i = nRects; i-- > 0;) {
pRects[i].x = pBox[i].x1;
pRects[i].y = pBox[i].y1;
pRects[i].width = pBox[i].x2 - pBox[i].x1;
@@ -1168,10 +1125,9 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
}
/*
- * Originally, the clip origin area were 0,0
- * but it didn't work with kedit and family,
- * because it got the clip mask of the pixmap
- * all traslated.
+ * Originally, the clip origin area were 0,0 but it didn't
+ * work with kedit and family, because it got the clip mask of
+ * the pixmap all traslated.
*/
XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC -> clipOrg.x, pGC -> clipOrg.y,
@@ -1185,11 +1141,8 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
XSetClipOrigin(nxagentDisplay, nxagentGC(pGC), pGC -> clipOrg.x, pGC -> clipOrg.y);
}
-
break;
-
case CT_PIXMAP:
-
XSetClipMask(nxagentDisplay, nxagentGC(pGC),
nxagentPixmap((PixmapPtr)pValue));
@@ -1204,25 +1157,21 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
type = CT_REGION;
break;
-
case CT_UNSORTED:
XSetClipRectangles(nxagentDisplay, nxagentGC(pGC),
pGC->clipOrg.x, pGC->clipOrg.y,
(XRectangle *)pValue, nRects, Unsorted);
break;
-
case CT_YSORTED:
XSetClipRectangles(nxagentDisplay, nxagentGC(pGC),
pGC->clipOrg.x, pGC->clipOrg.y,
(XRectangle *)pValue, nRects, YSorted);
break;
-
case CT_YXSORTED:
XSetClipRectangles(nxagentDisplay, nxagentGC(pGC),
pGC->clipOrg.x, pGC->clipOrg.y,
(XRectangle *)pValue, nRects, YXSorted);
break;
-
case CT_YXBANDED:
XSetClipRectangles(nxagentDisplay, nxagentGC(pGC),
pGC->clipOrg.x, pGC->clipOrg.y,
@@ -1241,8 +1190,8 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
case CT_YXBANDED:
/*
- * other parts of server can only deal with CT_NONE,
- * CT_PIXMAP and CT_REGION client clips.
+ * other parts of server can only deal with CT_NONE, CT_PIXMAP
+ * and CT_REGION client clips.
*/
pGC->clientClip = (void *) RegionFromRects(nRects,
@@ -1262,8 +1211,6 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects)
static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2)
{
- int i;
-
/*
* It returns 1 if regions are equal, 0 otherwise
*/
@@ -1292,7 +1239,7 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2)
else if ((*RegionExtents(r1)).y2 != (*RegionExtents(r2)).y2) return 0;
else
{
- for (i = 0; i < RegionNumRects(r1); i++)
+ for (int i = 0; i < RegionNumRects(r1); i++)
{
if (RegionRects(r1)[i].x1 != RegionRects(r2)[i].x1) return 0;
else if (RegionRects(r1)[i].x2 != RegionRects(r2)[i].x2) return 0;
@@ -1300,23 +1247,19 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2)
else if (RegionRects(r1)[i].y2 != RegionRects(r2)[i].y2) return 0;
}
}
-
return 1;
}
/*
- * This function have to be called in the place
- * of GetScratchGC if the GC will be used to per-
- * form operations also on the remote X Server.
- * This is why we call the XChangeGC at the end of
- * the function.
+ * This function have to be called in the place of GetScratchGC if the
+ * GC will be used to perform operations also on the remote X Server.
+ * This is why we call the XChangeGC at the end of the function.
*/
GCPtr nxagentGetScratchGC(unsigned depth, ScreenPtr pScreen)
{
/*
- * The GC trap is temporarily disabled in
- * order to allow the remote clipmask reset
- * requested by GetScratchGC().
+ * The GC trap is temporarily disabled in order to allow the remote
+ * clipmask reset requested by GetScratchGC().
*/
int nxagentSaveGCTrap = nxagentGCTrap;
@@ -1368,8 +1311,7 @@ GCPtr nxagentGetScratchGC(unsigned depth, ScreenPtr pScreen)
}
/*
- * This function is only a wrapper for
- * FreeScratchGC.
+ * This function is only a wrapper for FreeScratchGC.
*/
void nxagentFreeScratchGC(GCPtr pGC)
{
@@ -1386,18 +1328,14 @@ void nxagentFreeScratchGC(GCPtr pGC)
}
/*
- * The GCs belonging to this list are used
- * only in the synchronization put images,
- * to be sure they preserve the default va-
- * lues and to avoid XChangeGC() requests.
+ * The GCs belonging to this list are used only in the synchronization
+ * put images, to be sure they preserve the default values and to
+ * avoid XChangeGC() requests.
*/
GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable)
{
- int i;
- int result;
-
- for (i = 0; i < nxagentGraphicContextsSize; i++)
+ for (int i = 0; i < nxagentGraphicContextsSize; i++)
{
if (pDrawable -> depth == nxagentGraphicContexts[i].depth)
{
@@ -1416,7 +1354,7 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable)
fprintf(stderr, "nxagentGetGraphicContext: Going to reconnect the GC.\n");
#endif
- result = 1;
+ int result = 1;
nxagentReconnectGC(nxagentGraphicContexts[i].pGC, (XID) 0, &result);
@@ -1441,18 +1379,12 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable)
GCPtr nxagentCreateGraphicContext(int depth)
{
- GCPtr pGC;
-
- nxagentGraphicContextsPtr nxagentGCs;
-
- XID attributes[2];
-
/*
- * We have not found a GC, so we have
- * to spread the list and add a new GC.
+ * We have not found a GC, so we have to spread the list and add a
+ * new GC.
*/
- nxagentGCs = realloc(nxagentGraphicContexts, (nxagentGraphicContextsSize + 1) * sizeof(nxagentGraphicContextsRec));
+ nxagentGraphicContextsPtr nxagentGCs = realloc(nxagentGraphicContexts, (nxagentGraphicContextsSize + 1) * sizeof(nxagentGraphicContextsRec));
if (nxagentGCs == NULL)
{
@@ -1465,7 +1397,7 @@ GCPtr nxagentCreateGraphicContext(int depth)
nxagentGraphicContexts = nxagentGCs;
- pGC = CreateScratchGC(nxagentDefaultScreen, depth);
+ GCPtr pGC = CreateScratchGC(nxagentDefaultScreen, depth);
if (pGC == NULL)
{
@@ -1481,6 +1413,8 @@ GCPtr nxagentCreateGraphicContext(int depth)
* Color used in nxagentFillRemoteRegion().
*/
+ XID attributes[2];
+
attributes[0] = 0xc1c1c1;
if (depth == 15 || depth == 16)
@@ -1489,9 +1423,8 @@ GCPtr nxagentCreateGraphicContext(int depth)
}
/*
- * The IncludeInferiors property is useful to
- * solve problems when synchronizing windows
- * covered by an invisible child.
+ * The IncludeInferiors property is useful to solve problems when
+ * synchronizing windows covered by an invisible child.
*/
attributes[1] = IncludeInferiors;
@@ -1513,32 +1446,25 @@ GCPtr nxagentCreateGraphicContext(int depth)
}
/*
- * This initialization is called in the InitOutput()
- * function immediately after opening the screen,
- * which is used to create the GCs.
+ * This initialization is called in the InitOutput() function
+ * immediately after opening the screen, which is used to create the
+ * GCs.
*/
void nxagentAllocateGraphicContexts(void)
{
- int *depths;
-
- int i;
+ int *depths = nxagentDepths;
- depths = nxagentDepths;
-
- for (i = 0; i < nxagentNumDepths; i++)
+ for (int i = 0; i < nxagentNumDepths; i++)
{
nxagentCreateGraphicContext(*depths);
-
depths++;
}
}
void nxagentDisconnectGraphicContexts(void)
{
- int i;
-
- for (i = 0; i < nxagentGraphicContextsSize; i++)
+ for (int i = 0; i < nxagentGraphicContextsSize; i++)
{
nxagentGraphicContexts[i].dirty = 1;
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c
index 7db1aff58..5ac341990 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c
@@ -95,8 +95,7 @@ static int nxagentSaveGCTrap;
RegionPtr nxagentBitBlitHelper(GC *pGC);
/*
- * The NX agent implementation of the
- * X server's graphics functions.
+ * The NX agent implementation of the X server's graphics functions.
*/
void nxagentFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans,
@@ -170,7 +169,7 @@ void nxagentQueryBestSize(int class, unsigned short *pwidth,
case StippleShape:
width = *pwidth;
if (!width) break;
- /* Return the closes power of two not less than what they gave me */
+ /* Return the closest power of two not less than what they gave me */
test = 0x80000000;
/* Find the highest 1 bit in the width given */
while(!(test & width))
@@ -192,9 +191,8 @@ RegionPtr nxagentBitBlitHelper(GC *pGC)
#endif
/*
- * Force NullRegion. We consider enough the graphics
- * expose events generated internally by the nxagent
- * server.
+ * Force NullRegion. We consider enough the graphics expose events
+ * generated internally by the nxagent server.
*/
#ifdef TEST
@@ -205,28 +203,22 @@ RegionPtr nxagentBitBlitHelper(GC *pGC)
}
/*
- * The deferring of X_RenderCompositeTrapezoids caused
- * an ugly effect on pulldown menu: as the background
- * may be not synchronized, the text floats in an invi-
- * sible window. To avoid such effects, we use a system
- * to guess if the destination target of a copy area
- * is a popup, by assuming that those kind of windows
- * use the override redirect property.
+ * The deferring of X_RenderCompositeTrapezoids caused an ugly effect
+ * on pulldown menu: as the background may be not synchronized, the
+ * text floats in an invisible window. To avoid such effects, we use a
+ * system to guess if the destination target of a copy area is a
+ * popup, by assuming that those kind of windows use the override
+ * redirect property.
*/
int nxagentWindowIsPopup(DrawablePtr pDrawable)
{
- WindowPtr parent;
-
- int windowIsPopup;
- int level;
-
if (pDrawable -> type != DRAWABLE_WINDOW)
{
return 0;
}
- windowIsPopup = 0;
+ int windowIsPopup = 0;
if (((WindowPtr) pDrawable) -> overrideRedirect == 1)
{
@@ -234,16 +226,14 @@ int nxagentWindowIsPopup(DrawablePtr pDrawable)
}
else
{
- parent = ((WindowPtr) pDrawable) -> parent;
+ WindowPtr parent = ((WindowPtr) pDrawable) -> parent;
/*
- * Go up on the tree until a parent
- * exists or 4 windows has been che-
- * cked. This seems a good limit to
- * up children's popup.
+ * Go up on the tree until a parent exists or 4 windows has been
+ * checked. This seems a good limit to up children's popup.
*/
- level = 0;
+ int level = 0;
while (parent != NULL && ++level <= 4)
{
@@ -255,7 +245,6 @@ int nxagentWindowIsPopup(DrawablePtr pDrawable)
if (parent -> overrideRedirect == 1)
{
windowIsPopup = 1;
-
break;
}
@@ -272,33 +261,25 @@ int nxagentWindowIsPopup(DrawablePtr pDrawable)
}
/*
- * This function returns 1 if the
- * XCopyArea request must be skipped.
+ * This function returns 1 if the XCopyArea request must be skipped.
*/
int nxagentDeferCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
GCPtr pGC, int srcx, int srcy, int width,
int height, int dstx, int dsty)
{
- RegionPtr pSrcRegion;
- RegionPtr pClipRegion, pCorruptedRegion;
- RegionRec corruptedRegion, tmpRegion;
-
/*
- * If the destination drawable is a popup
- * window, we try to synchronize the source
- * drawable to show a nice menu. Anyway if
- * this synchronization breaks, the copy area
- * is handled in the normal way.
+ * If the destination drawable is a popup window, we try to
+ * synchronize the source drawable to show a nice menu. Anyway if
+ * this synchronization breaks, the copy area is handled in the
+ * normal way.
*/
/*
-FIXME: The popup could be synchronized with one
- single put image, clipped to the corrup-
- ted region. As an intermediate step, the
- pixmap to synchronize could be copied on
- a cleared scratch pixmap, in order to
- have a solid color in the clipped regions.
+FIXME: The popup could be synchronized with one single put image,
+ clipped to the corrupted region. As an intermediate step, the
+ pixmap to synchronize could be copied on a cleared scratch
+ pixmap, in order to have a solid color in the clipped regions.
*/
if (nxagentOption(DeferLevel) >= 2 &&
@@ -306,7 +287,7 @@ FIXME: The popup could be synchronized with one
nxagentPixmapContainTrapezoids((PixmapPtr) pSrcDrawable) == 1 &&
nxagentWindowIsPopup(pDstDrawable) == 1)
{
- pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height);
+ RegionPtr pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height);
#ifdef DEBUG
fprintf(stderr, "nxagentDeferCopyArea: Copying to a popup menu. Source region [%d,%d,%d,%d].\n",
@@ -314,6 +295,7 @@ FIXME: The popup could be synchronized with one
pSrcRegion -> extents.x2, pSrcRegion -> extents.y2);
#endif
+ RegionRec corruptedRegion;
RegionInit(&corruptedRegion, NullBox, 1);
RegionIntersect(&corruptedRegion,
@@ -340,28 +322,25 @@ FIXME: The popup could be synchronized with one
}
/*
- * We are going to decide if the source drawable
- * must be synchronized before using it, or if
- * the copy will be clipped to the synchronized
- * source region.
+ * We are going to decide if the source drawable must be
+ * synchronized before using it, or if the copy will be clipped to
+ * the synchronized source region.
*/
if ((pDstDrawable -> type == DRAWABLE_PIXMAP &&
nxagentOption(DeferLevel) > 0) || nxagentOption(DeferLevel) >= 3)
{
- pClipRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy,
- width, height);
+ RegionPtr pClipRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy,
+ width, height);
/*
- * We called this variable pCorruptedRegion
- * because in the worst case the corrupted
- * region will be equal to the destination
- * region. The GC's clip mask is used to
- * narrow the destination.
+ * We called this variable pCorruptedRegion because in the worst
+ * case the corrupted region will be equal to the destination
+ * region. The GC's clip mask is used to narrow the destination.
*/
- pCorruptedRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty,
- width, height);
+ RegionPtr pCorruptedRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty,
+ width, height);
#ifdef DEBUG
fprintf(stderr, "nxagentDeferCopyArea: Copy area source region is [%d,%d,%d,%d].\n",
@@ -393,6 +372,7 @@ FIXME: The popup could be synchronized with one
}
else
{
+ RegionRec tmpRegion;
RegionInit(&tmpRegion, NullBox, 1);
#ifdef DEBUG
@@ -419,28 +399,27 @@ FIXME: The popup could be synchronized with one
}
/*
- * The corrupted region on the destination
- * drawable is composed by the areas of the
- * destination that we are not going to copy.
+ * The corrupted region on the destination drawable is composed by
+ * the areas of the destination that we are not going to copy.
*/
RegionSubtract(pCorruptedRegion, pCorruptedRegion, pClipRegion);
#ifdef DEBUG
- fprintf(stderr, "nxagentDeferCopyArea: Recomputed clip region is [%d,%d,%d,%d][%ld].\n",
+ fprintf(stderr, "nxagentDeferCopyArea: Recomputed clip region is [%d,%d,%d,%d][%d].\n",
pClipRegion -> extents.x1, pClipRegion -> extents.y1,
pClipRegion -> extents.x2, pClipRegion -> extents.y2,
RegionNumRects(pClipRegion));
- fprintf(stderr, "nxagentDeferCopyArea: Inherited corrupted region is [%d,%d,%d,%d][%ld].\n",
+ fprintf(stderr, "nxagentDeferCopyArea: Inherited corrupted region is [%d,%d,%d,%d][%d].\n",
pCorruptedRegion -> extents.x1, pCorruptedRegion -> extents.y1,
pCorruptedRegion -> extents.x2, pCorruptedRegion -> extents.y2,
RegionNumRects(pCorruptedRegion));
#endif
/*
- * The destination drawable inherits both the
- * synchronized and the corrupted region.
+ * The destination drawable inherits both the synchronized and the
+ * corrupted region.
*/
if (RegionNil(pClipRegion) == 0)
@@ -455,20 +434,15 @@ FIXME: The popup could be synchronized with one
if (RegionNil(pClipRegion) == 0)
{
- GCPtr targetGC;
-
- CARD32 targetAttributes[2];
-
Bool pClipRegionFree = True;
/*
- * As we want to copy only the synchronized
- * areas of the source drawable, we create
- * a new GC copying the original one and
+ * As we want to copy only the synchronized areas of the source
+ * drawable, we create a new GC copying the original one and
* setting a new clip mask.
*/
- targetGC = GetScratchGC(pDstDrawable -> depth, pDstDrawable -> pScreen);
+ GCPtr targetGC = GetScratchGC(pDstDrawable -> depth, pDstDrawable -> pScreen);
ValidateGC(pDstDrawable, targetGC);
@@ -479,9 +453,8 @@ FIXME: The popup could be synchronized with one
if (RegionNumRects(pClipRegion) == 1)
{
/*
- * If the region to copy is formed by one
- * rectangle, we change only the copy coor-
- * dinates.
+ * If the region to copy is formed by one rectangle, we change
+ * only the copy coordinates.
*/
srcx = srcx + pClipRegion -> extents.x1 - dstx;
@@ -495,11 +468,12 @@ FIXME: The popup could be synchronized with one
}
else
{
+ CARD32 targetAttributes[2];
+
/*
- * Setting the clip mask origin. This
- * operation must precede the clip chan-
- * ge, because the origin information is
- * used in the XSetClipRectangles().
+ * Setting the clip mask origin. This operation must precede
+ * the clip change, because the origin information is used in
+ * the XSetClipRectangles().
*/
targetAttributes[0] = 0;
@@ -514,8 +488,8 @@ FIXME: The popup could be synchronized with one
nxagentChangeClip(targetGC, CT_REGION, pClipRegion, 0);
/*
- * Next call to nxagentChangeClip() will destroy
- * pClipRegion, so it has not to be freed.
+ * Next call to nxagentChangeClip() will destroy pClipRegion,
+ * so it has not to be freed.
*/
pClipRegionFree = False;
@@ -549,9 +523,8 @@ FIXME: The popup could be synchronized with one
#endif
/*
- * The pClipRegion is destroyed calling nxagentChangeClip(),
- * so we deallocate it explicitly only if we don't change
- * the clip.
+ * The pClipRegion is destroyed calling nxagentChangeClip(), so
+ * we deallocate it explicitly only if we don't change the clip.
*/
nxagentFreeRegion(pSrcDrawable, pClipRegion);
@@ -563,7 +536,7 @@ FIXME: The popup could be synchronized with one
}
else
{
- pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height);
+ RegionPtr pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height);
#ifdef DEBUG
fprintf(stderr, "nxagentDeferCopyArea: Source region [%d,%d,%d,%d].\n",
@@ -571,6 +544,7 @@ FIXME: The popup could be synchronized with one
pSrcRegion -> extents.x2, pSrcRegion -> extents.y2);
#endif
+ RegionRec corruptedRegion;
RegionInit(&corruptedRegion, NullBox, 1);
RegionIntersect(&corruptedRegion,
@@ -598,12 +572,6 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
GCPtr pGC, int srcx, int srcy, int width,
int height, int dstx, int dsty)
{
- int leftPad = 0;
- unsigned int format;
- unsigned long planeMask = 0xffffffff;
-
- RegionPtr pDstRegion;
-
int skip = 0;
#ifdef TEST
@@ -614,9 +582,9 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
#endif
/*
- * Here, before using fbDoCopy() called by fbCopyArea(),
- * it should be provided that the cast in fbDoCopy() from
- * int to short int would not cut off significative bits.
+ * Here, before using fbDoCopy() called by fbCopyArea(), it should be
+ * provided that the cast in fbDoCopy() from int to short int would
+ * not cut off significative bits.
*/
if (dstx + pDstDrawable->x + width > 32767)
@@ -725,9 +693,9 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
}
/*
- * Try to detect if the copy area is to a window
- * that is unmapped or fully covered. Similarly
- * to the check in Image.c, this is of little use.
+ * Try to detect if the copy area is to a window that is unmapped or
+ * fully covered. Similarly to the check in Image.c, this is of
+ * little use.
*/
if (nxagentOption(IgnoreVisibility) == 0 && pDstDrawable -> type == DRAWABLE_WINDOW &&
@@ -743,24 +711,21 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
}
/*
- * If the pixmap is on shared memory, we can't
- * know if the pixmap content is changed and
- * so have to translate the operation in a put
- * image operation. This can seriously affect
- * the performance.
+ * If the pixmap is on shared memory, we can't know if the pixmap
+ * content is changed and so have to translate the operation in a
+ * put image operation. This can seriously affect the performance.
*/
if (pSrcDrawable -> type == DRAWABLE_PIXMAP &&
nxagentIsShmPixmap((PixmapPtr) pSrcDrawable))
{
char *data;
- int depth, length;
- depth = pSrcDrawable -> depth;
+ int depth = pSrcDrawable -> depth;
- format = (depth == 1) ? XYPixmap : ZPixmap;
+ unsigned int format = (depth == 1) ? XYPixmap : ZPixmap;
- length = nxagentImageLength(width, height, format, leftPad, depth);
+ int length = nxagentImageLength(width, height, format, 0, depth);
if ((data = malloc(length)) == NULL)
{
@@ -771,15 +736,16 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
return NullRegion;
}
+ unsigned long planeMask = 0xffffffff;
fbGetImage(nxagentVirtualDrawable(pSrcDrawable), srcx, srcy, width, height, format, planeMask, data);
/*
- * If the source is a shared memory pixmap,
- * put the image directly to the destination.
+ * If the source is a shared memory pixmap, put the image directly
+ * to the destination.
*/
nxagentPutImage(pDstDrawable, pGC, depth, dstx, dsty,
- width, height, leftPad, format, data);
+ width, height, 0, format, data);
#ifdef TEST
fprintf(stderr,"nxagentCopyArea: Realize Pixmap %p virtual %p x %d y %d w %d h %d\n",
@@ -790,10 +756,9 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
SAFE_free(data);
/*
- * If the source is a shared memory pixmap, the
- * content of the framebuffer has been placed
- * directly on the destination so we can skip
- * the copy area operation.
+ * If the source is a shared memory pixmap, the content of the
+ * framebuffer has been placed directly on the destination so we
+ * can skip the copy area operation.
*/
skip = 1;
@@ -825,13 +790,13 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
nxagentGC(pGC), srcx, srcy, width, height, dstx, dsty);
/*
- * The copy area restored the synchroni-
- * zation status of destination drawable.
+ * The copy area restored the synchronization status of
+ * destination drawable.
*/
if (nxagentDrawableStatus(pDstDrawable) == NotSynchronized)
{
- pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height);
+ RegionPtr pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height);
nxagentUnmarkCorruptedRegion(pDstDrawable, pDstRegion);
@@ -876,8 +841,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
else if (pDstDrawable -> type == DRAWABLE_PIXMAP)
{
/*
- * If we are here the source drawable
- * must be a window.
+ * If we are here the source drawable must be a window.
*/
if (((WindowPtr) pSrcDrawable) -> viewable)
@@ -894,8 +858,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
else
{
/*
- * If we are here the source drawable
- * must be a window.
+ * If we are here the source drawable must be a window.
*/
if (((WindowPtr) pSrcDrawable) -> viewable)
@@ -918,13 +881,6 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
GCPtr pGC, int srcx, int srcy, int width, int height,
int dstx, int dsty, unsigned long plane)
{
- unsigned int format;
- int leftPad = 0;
- unsigned long planeMask = 0xffffffff;
-
- RegionPtr pSrcRegion, pDstRegion;
- RegionRec corruptedRegion;
-
int skip = 0;
#ifdef TEST
@@ -963,24 +919,21 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
}
/*
- * If the pixmap is on shared memory, we can't
- * know if the pixmap content is changed and
- * so have to translate the operation in a put
- * image operation. This can seriously affect
- * the performance.
+ * If the pixmap is on shared memory, we can't know if the pixmap
+ * content is changed and so have to translate the operation in a
+ * put image operation. This can seriously affect the performance.
*/
if (pSrcDrawable -> type == DRAWABLE_PIXMAP &&
nxagentIsShmPixmap((PixmapPtr) pSrcDrawable))
{
char *data;
- int depth, length;
- depth = pSrcDrawable -> depth;
+ int depth = pSrcDrawable -> depth;
- format = (depth == 1) ? XYPixmap : ZPixmap;
+ unsigned int format = (depth == 1) ? XYPixmap : ZPixmap;
- length = nxagentImageLength(width, height, format, leftPad, depth);
+ int length = nxagentImageLength(width, height, format, 0, depth);
if ((data = malloc(length)) == NULL)
{
@@ -991,15 +944,16 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
return 0;
}
+ unsigned long planeMask = 0xffffffff;
fbGetImage(nxagentVirtualDrawable(pSrcDrawable), srcx, srcy, width, height, format, planeMask, data);
/*
- * If the source is a shared memory pixmap,
- * put the image directly to the destination.
+ * If the source is a shared memory pixmap, put the image directly
+ * to the destination.
*/
nxagentPutImage(pDstDrawable, pGC, depth, dstx, dsty,
- width, height, leftPad, format, data);
+ width, height, 0, format, data);
#ifdef TEST
fprintf(stderr,"nxagentCopyPlane: Synchronize Pixmap %p virtual %p x %d y %d w %d h %d \n",
@@ -1010,10 +964,9 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
SAFE_free(data);
/*
- * If the source is a shared memory pixmap, the
- * content of the framebuffer has been placed
- * directly on the destination so we can skip
- * the copy plane operation.
+ * If the source is a shared memory pixmap, the content of the
+ * framebuffer has been placed directly on the destination so we
+ * can skip the copy plane operation.
*/
skip = 1;
@@ -1024,7 +977,7 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
if (pDstDrawable -> type == DRAWABLE_PIXMAP &&
nxagentOption(DeferLevel) > 0)
{
- pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height);
+ RegionPtr pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height);
nxagentMarkCorruptedRegion(pDstDrawable, pDstRegion);
@@ -1034,7 +987,9 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
}
else
{
- pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height);
+ RegionPtr pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height);
+
+ RegionRec corruptedRegion;
RegionInit(&corruptedRegion, NullBox, 1);
@@ -1050,7 +1005,7 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
nxagentSynchronizeRegion(pSrcDrawable, &corruptedRegion /*pSrcRegion*/, NEVER_BREAK, NULL);
- pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height);
+ RegionPtr pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height);
nxagentUnmarkCorruptedRegion(pDstDrawable, pDstRegion);
@@ -1464,34 +1419,30 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape,
}
/*
- * The coordinate-mode must be CoordModePrevious
- * to make better use of differential encoding of
- * X_FillPoly request by the side of proxy.
+ * The coordinate-mode must be CoordModePrevious to make better use
+ * of differential encoding of X_FillPoly request by the side of
+ * proxy.
*/
if (mode == CoordModeOrigin)
{
- int i;
-
mode = CoordModePrevious;
newPoints = malloc(nPoints * sizeof(xPoint));
/*
- * The first point is always relative
- * to the drawable's origin.
+ * The first point is always relative to the drawable's origin.
*/
newPoints[0].x = pPoints[0].x;
newPoints[0].y = pPoints[0].y;
/*
- * If coordinate-mode is CoordModePrevious,
- * the points following the first are rela-
- * tive to the previous point.
+ * If coordinate-mode is CoordModePrevious, the points following
+ * the first are relative to the previous point.
*/
- for (i = 1; i < nPoints; i++)
+ for (int i = 1; i < nPoints; i++)
{
newPoints[i].x = pPoints[i].x - pPoints[i-1].x;
newPoints[i].y = pPoints[i].y - pPoints[i-1].y;
@@ -1551,10 +1502,6 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape,
void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
int nRectangles, xRectangle *pRectangles)
{
- RegionPtr rectRegion;
-
- int inheritCorruptedRegion;
-
#ifdef TEST
if (nRectangles == 1)
@@ -1586,15 +1533,14 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
}
/*
- * The PolyFillRect acts in two ways: if the GC
- * has a corrupted tile, the operation propagates
- * the corrupted region on the destination. In
- * other cases, because the PolyFillRect will
- * cover the destination, any corrupted region
- * intersecting the target will be cleared.
+ * The PolyFillRect acts in two ways: if the GC has a corrupted
+ * tile, the operation propagates the corrupted region on the
+ * destination. In other cases, because the PolyFillRect will cover
+ * the destination, any corrupted region intersecting the target
+ * will be cleared.
*/
- inheritCorruptedRegion = 0;
+ int inheritCorruptedRegion = 0;
if (pGC -> fillStyle == FillTiled &&
pGC -> tileIsPixel == 0 && pGC -> tile.pixmap != NULL)
@@ -1616,7 +1562,7 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
if (inheritCorruptedRegion == 1 || nxagentDrawableStatus(pDrawable) == NotSynchronized)
{
- rectRegion = RegionFromRects(nRectangles, pRectangles, CT_REGION);
+ RegionPtr rectRegion = RegionFromRects(nRectangles, pRectangles, CT_REGION);
if (pGC -> clientClip != NULL)
{
@@ -1639,10 +1585,9 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
if (inheritCorruptedRegion == 1)
{
/*
- * The fill style should affect the cor-
- * rupted region propagation: if the tile
- * is not completely corrupted the region
- * should be 'tiled' over the destination.
+ * The fill style should affect the corrupted region
+ * propagation: if the tile is not completely corrupted the
+ * region should be 'tiled' over the destination.
*/
nxagentMarkCorruptedRegion(pDrawable, rectRegion);
@@ -1656,11 +1601,10 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
else
{
/*
- * The stipple mask computation could cause
- * an high fragmentation of the destination
- * region. An analysis should be done to exa-
- * mine the better solution (e.g.rdesktop
- * uses stipples to draw texts).
+ * The stipple mask computation could cause an high
+ * fragmentation of the destination region. An analysis should
+ * be done to examine the better solution (e.g.rdesktop uses
+ * stipples to draw texts).
*/
#ifdef TEST
@@ -1784,11 +1728,8 @@ void nxagentPolyFillArc(DrawablePtr pDrawable, GCPtr pGC,
int nxagentPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x,
int y, int count, char *string)
{
- int width;
-
/*
- * While the session is suspended
- * the font structure is NULL.
+ * While the session is suspended the font structure is NULL.
*/
if (nxagentFontStruct(pGC -> font) == NULL)
@@ -1796,7 +1737,7 @@ int nxagentPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x,
return x;
}
- width = XTextWidth(nxagentFontStruct(pGC->font), string, count);
+ int width = XTextWidth(nxagentFontStruct(pGC->font), string, count);
if (nxagentGCTrap == 1)
{
@@ -1857,11 +1798,8 @@ int nxagentPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x,
int nxagentPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x,
int y, int count, unsigned short *string)
{
- int width;
-
/*
- * While the session is suspended
- * the font structure is NULL.
+ * While the session is suspended the font structure is NULL.
*/
if (nxagentFontStruct(pGC -> font) == NULL)
@@ -1869,7 +1807,7 @@ int nxagentPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x,
return x;
}
- width = XTextWidth16(nxagentFontStruct(pGC->font), (XChar2b *)string, count);
+ int width = XTextWidth16(nxagentFontStruct(pGC->font), (XChar2b *)string, count);
if (nxagentGCTrap == 1)
{
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c
index 7311889b7..f1455b935 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c
@@ -57,47 +57,42 @@
#undef DUMP
/*
- * Log begin and end of the important
- * handlers.
+ * Log begin and end of the important handlers.
*/
#undef BLOCKS
/*
- * If not defined, flush immediately
- * upon entering the block handler.
+ * If not defined, flush immediately upon entering the block handler.
*/
#define FLUSH_AFTER_MULTIPLE_READS
/*
- * The soft limit should roughly match
- * the size of the Xlib I/O buffer.
+ * The soft limit should roughly match the size of the Xlib I/O
+ * buffer.
*/
#define BYTES_BEFORE_SOFT_TOKEN 2048
#define BYTES_BEFORE_HARD_TOKEN 65536
/*
- * Maximum number of synchronization
- * requests before waiting for the
+ * Maximum number of synchronization requests before waiting for the
* remote.
*/
#define TOKENS_PENDING_LIMIT 8
/*
- * Limits are very unobtrusive. We don't
- * want to interfere with the normal
- * dispatching.
+ * Limits are very unobtrusive. We don't want to interfere with the
+ * normal dispatching.
*/
#define BYTES_BEFORE_YIELD 1048576
#define TIME_BEFORE_YIELD 500
/*
- * Dynamically reduce the display buffer
- * size after a congestion.
+ * Dynamically reduce the display buffer size after a congestion.
*/
#undef DYNAMIC_DISPLAY_BUFFER
@@ -116,16 +111,14 @@ extern void nxagentDumpInputDevicesState(void);
#endif
/*
- * Used in the handling of the X desktop
- * manager protocol.
+ * Used in the handling of the X desktop manager protocol.
*/
int nxagentXdmcpUp = 0;
int nxagentXdmcpAlertUp = 0;
/*
- * Also used in the block, wakeup and
- * sync handlers.
+ * Also used in the block, wakeup and sync handlers.
*/
int nxagentBuffer;
@@ -136,30 +129,28 @@ double nxagentBytesIn;
double nxagentBytesOut;
/*
- * Total number of descriptors ready
- * as reported by the wakeup handler.
+ * Total number of descriptors ready as reported by the wakeup
+ * handler.
*/
int nxagentReady;
/*
- * Timestamp of the last write to the
- * remote display.
+ * Timestamp of the last write to the remote display.
*/
int nxagentFlush;
/*
- * Arbitrate the bandwidth among our
- * clients.
+ * Arbitrate the bandwidth among our clients.
*/
struct _TokensRec nxagentTokens = { 0, 0, 0 };
struct _DispatchRec nxagentDispatch = { UNDEFINED, 0, 0, 0 };
/*
- * Called just before blocking, waiting
- * for our clients or the X server.
+ * Called just before blocking, waiting for our clients or the X
+ * server.
*/
extern int nxagentSkipImage;
@@ -179,15 +170,13 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
static int now;
/*
- * Pending bytes to write to the
- * network.
+ * Pending bytes to write to the network.
*/
static int flushable;
/*
- * Set if we need to synchronize
- * any drawable.
+ * Set if we need to synchronize any drawable.
*/
static int synchronize;
@@ -242,8 +231,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif
/*
- * Slow down the agent if the session is
- * not connected to a valid display.
+ * Slow down the agent if the session is not connected to a valid
+ * display.
*/
if (NXDisplayError(nxagentDisplay) == 1 && nxagentShadowCounter == 0 && nxagentOption(SleepTime) > 0)
@@ -263,8 +252,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif
/*
- * Update the shadow display. This is
- * only for test purposes.
+ * Update the shadow display. This is only for test purposes.
*/
#ifdef DUMP
@@ -276,17 +264,14 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif
/*
- * We need this here because some window
- * configuration changes can be generated
- * by the X server outside the control of
- * the DIX.
+ * We need this here because some window configuration changes can
+ * be generated by the X server outside the control of the DIX.
*/
nxagentFlushConfigureWindow();
/*
- * Check whether there is any drawable to
- * synchronize.
+ * Check whether there is any drawable to synchronize.
*/
#ifdef TEST
@@ -300,33 +285,28 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
nxagentCorruptedPixmaps > 0);
/*
- * The synchronization function requires a mask as
- * parameter:
+ * The synchronization function requires a mask as parameter:
*
- * EVENT_BREAK Breaks if an user input, like
- * a key press or a mouse move,
- * is detected.
+ * EVENT_BREAK Breaks if an user input, like a key press
+ * or a mouse move, is detected.
*
- * CONGESTION_BREAK Breaks if the congestion beco-
- * mes greater than 4.
+ * CONGESTION_BREAK Breaks if the congestion becomes greater
+ * than 4.
*
- * BLOCKING_BREAK Breaks if the display descript-
- * or becomes blocked for write
- * during the loop.
+ * BLOCKING_BREAK Breaks if the display descriptor becomes
+ * blocked for write during the loop.
*
- * ALWAYS_BREAK Any of the previous conditions
- * is met.
+ * ALWAYS_BREAK Any of the previous conditions is met.
*
- * NEVER_BREAK The loop continues until all
- * the drawables are synchronized.
+ * NEVER_BREAK The loop continues until all the drawables
+ * are synchronized.
*/
if (synchronize == 1)
{
/*
- * We should not enter the synchronization
- * loop if there is any user input pending,
- * i.e. if we are in the middle of a scroll
+ * We should not enter the synchronization loop if there is any
+ * user input pending, i.e. if we are in the middle of a scroll
* operation.
*/
@@ -361,9 +341,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif
/*
- * Check if we have more corrupted resources
- * and whether the conditions are satisfied
- * to continue with the synchronization.
+ * Check if we have more corrupted resources and whether the
+ * conditions are satisfied to continue with the synchronization.
*/
synchronize = (nxagentCongestion <= 4 &&
@@ -405,9 +384,9 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
}
/*
- * If the remote X server is blocking, reduce the
- * amount of data sent in a single display update
- * by reducing the size of the display buffer.
+ * If the remote X server is blocking, reduce the amount of data
+ * sent in a single display update by reducing the size of the
+ * display buffer.
*/
#ifdef DYNAMIC_DISPLAY_BUFFER
@@ -445,8 +424,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#endif /* #ifdef DYNAMIC_DISPLAY_BUFFER */
/*
- * Dispatch to the clients the events that
- * may have become available.
+ * Dispatch to the clients the events that may have become
+ * available.
*/
if (nxagentPendingEvents(nxagentDisplay) > 0)
@@ -459,9 +438,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
}
/*
- * Check if there is any data remaining,
- * either in the display buffer or in
- * the NX transport.
+ * Check if there is any data remaining, either in the display
+ * buffer or in the NX transport.
*/
flushable = NXDisplayFlushable(nxagentDisplay);
@@ -471,9 +449,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#ifdef FLUSH_AFTER_MULTIPLE_READS
/*
- * Flush all the outstanding data if
- * the wakeup handler didn't detect
- * any activity.
+ * Flush all the outstanding data if the wakeup handler didn't
+ * detect any activity.
*/
if (nxagentReady == 0 || now - nxagentFlush >=
@@ -487,8 +464,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
NXFlushDisplay(nxagentDisplay, NXFlushLink);
/*
- * New events may have become available
- * after the flush.
+ * New events may have become available after the flush.
*/
if (nxagentPendingEvents(nxagentDisplay) > 0)
@@ -516,9 +492,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
#else /* #ifdef FLUSH_AFTER_MULTIPLE_READS */
/*
- * We are entering the select. Tell the NX
- * transport to write any produced data to
- * the remote end.
+ * We are entering the select. Tell the NX transport to write any
+ * produced data to the remote end.
*/
NXFlushDisplay(nxagentDisplay, NXFlushLink);
@@ -556,12 +531,11 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask)
}
/*
- * WaitForSomething() sets a zero timeout if there
- * are clients with input, but doesn't stop the
- * timer. The select is then interrupted to update
- * the schedule time even if, what the dispatcher
- * cares, is only the number of ticks at the time
- * the client is scheduled in.
+ * WaitForSomething() sets a zero timeout if there are clients with
+ * input, but doesn't stop the timer. The select is then interrupted
+ * to update the schedule time even if, what the dispatcher cares,
+ * is only the number of ticks at the time the client is scheduled
+ * in.
*/
#ifdef DEBUG
@@ -641,8 +615,7 @@ void nxagentWakeupHandler(void * data, int count, void * mask)
else if (nxagentQueuedEvents(nxagentDisplay) == 1)
{
/*
- * We may have left some events in
- * the queue.
+ * We may have left some events in the queue.
*/
#ifdef TEST
@@ -674,9 +647,8 @@ void nxagentWakeupHandler(void * data, int count, void * mask)
#endif
/*
- * If the XDM connection can't be established
- * we'll need to create a dialog to notify the
- * user and give him/her a chance to terminate
+ * If the XDM connection can't be established we'll need to create a
+ * dialog to notify the user and give him/her a chance to terminate
* the session.
*/
@@ -813,14 +785,12 @@ void nxagentShadowBlockHandler(void * data, struct timeval **timeout, void * mas
}
/*
- * We are entering the select. Tell the NX
- * transport to write any produced data to
- * the remote end.
+ * We are entering the select. Tell the NX transport to write any
+ * produced data to the remote end.
*/
/*
-FIXME: Must queue multiple writes and handle
- the events by resembling the ordinary
- block handler.
+FIXME: Must queue multiple writes and handle the events by resembling
+ the ordinary block handler.
*/
NXFlushDisplay(nxagentDisplay, NXFlushLink);
@@ -929,8 +899,7 @@ void nxagentShadowWakeupHandler(void * data, int count, void * mask)
else if (nxagentQueuedEvents(nxagentDisplay) == 1)
{
/*
- * We may have left some events in
- * the queue.
+ * We may have left some events in the queue.
*/
#ifdef TEST
@@ -1022,13 +991,11 @@ Bool nxagentCollectInputFocusPredicate(Display *display, XEvent *X, XPointer ptr
void nxagentDispatchHandler(ClientPtr client, int in, int out)
{
/*
- * This function is called by the dispatcher (with 0
- * bytes out) after a new request has been processed.
- * It is also called by the write handler (with 0
- * bytes in) after more data has been written to the
- * display. It may be optionally called in the block
- * and wakeup handlers. In this case both in and out
- * must be 0.
+ * This function is called by the dispatcher (with 0 bytes out)
+ * after a new request has been processed. It is also called by the
+ * write handler (with 0 bytes in) after more data has been written
+ * to the display. It may be optionally called in the block and
+ * wakeup handlers. In this case both in and out must be 0.
*/
if (out > 0)
@@ -1050,14 +1017,12 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
#endif
/*
- * Don't take care of the synchronization if
- * the NX transport is running. The NX trans-
- * port has its own token-based control flow.
+ * Don't take care of the synchronization if the NX transport is
+ * running. The NX transport has its own token-based control flow.
*
- * We can't produce more output here because
- * we are in the middle of the flush. We will
- * take care of the sync requests when called
- * by the dispatcher.
+ * We can't produce more output here because we are in the middle
+ * of the flush. We will take care of the sync requests when
+ * called by the dispatcher.
*/
if (nxagentOption(LinkType) == LINK_TYPE_NONE)
@@ -1079,8 +1044,8 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
{
/*
- * Pay attention to the next client if this
- * client produced enough output.
+ * Pay attention to the next client if this client produced
+ * enough output.
*/
if (nxagentBytesOut - nxagentDispatch.out > BYTES_BEFORE_YIELD)
@@ -1142,12 +1107,11 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
#endif
/*
- * When using the dumb scheduler, before reading from
- * another client, the dispatcher tries to drain all
- * the input from the client being processed. This
- * means that, if isItTimeToYield is never set and the
- * client never produces any output, we'll stick into
- * the inner dispatch loop forever.
+ * When using the dumb scheduler, before reading from another
+ * client, the dispatcher tries to drain all the input from the
+ * client being processed. This means that, if isItTimeToYield is
+ * never set and the client never produces any output, we'll stick
+ * into the inner dispatch loop forever.
*/
if (!SmartScheduleSignalEnable)
@@ -1228,10 +1192,9 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
else if (nxagentTokens.soft > BYTES_BEFORE_SOFT_TOKEN)
{
/*
- * Alternatively, the amounts of bytes
- * accounted for each sync request may
- * be decreased according to the number
- * of pending replies already awaited.
+ * Alternatively, the amounts of bytes accounted for each sync
+ * request may be decreased according to the number of pending
+ * replies already awaited.
*
* else if (nxagentTokens.soft > (BYTES_BEFORE_SOFT_TOKEN / (nxagentTokens.pending + 1)))
*/
@@ -1239,9 +1202,8 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
int resource;
/*
- * Wait eventually for the number of
- * synchronization requests to return
- * below the limit.
+ * Wait eventually for the number of synchronization requests to
+ * return below the limit.
*/
#ifdef TEST
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c
index e55ed2dd2..34d5cf9f9 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Image.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c
@@ -59,9 +59,8 @@
#undef DUMP
/*
- * Don't pack the images having a width, a
- * height or a data size smaller or equal
- * to these thresholds.
+ * Don't pack the images having a width, a height or a data size
+ * smaller or equal to these thresholds.
*/
#define IMAGE_PACK_WIDTH 2
@@ -69,16 +68,14 @@
#define IMAGE_PACK_LENGTH 512
/*
- * Compress the image with a lossless encoder
- * if the percentage of discrete pixels in the
- * image is below this threshold.
+ * Compress the image with a lossless encoder if the percentage of
+ * discrete pixels in the image is below this threshold.
*/
#define IMAGE_UNIQUE_RATIO 10
/*
- * Preferred pack and split parameters we
- * got from the NX transport.
+ * Preferred pack and split parameters we got from the NX transport.
*/
int nxagentPackLossless = -1;
@@ -94,8 +91,8 @@ int nxagentAlphaEnabled = 0;
int nxagentAlphaCompat = 0;
/*
- * Used to reformat image when connecting to
- * displays having different byte order.
+ * Used to reformat image when connecting to displays having different
+ * byte order.
*/
extern void nxagentBitOrderInvert(unsigned char *, int);
@@ -103,22 +100,20 @@ extern void nxagentTwoByteSwap(unsigned char *, register int);
extern void nxagentFourByteSwap(register unsigned char *, register int);
/*
- * Store the last visual used to unpack
- * the images for the given client.
+ * Store the last visual used to unpack the images for the given
+ * client.
*/
static VisualID nxagentUnpackVisualId[MAX_CONNECTIONS];
/*
- * Store the last alpha data set for the
- * client.
+ * Store the last alpha data set for the client.
*/
typedef struct _UnpackAlpha
{
char *data;
int size;
-
} UnpackAlphaRec;
typedef UnpackAlphaRec *UnpackAlphaPtr;
@@ -126,9 +121,8 @@ typedef UnpackAlphaRec *UnpackAlphaPtr;
static UnpackAlphaPtr nxagentUnpackAlpha[MAX_CONNECTIONS];
/*
- * Encode the imade alpha channel by using
- * a specific encoding, separating it from
- * the rest of the RGB data.
+ * Encode the imade alpha channel by using a specific encoding,
+ * separating it from the rest of the RGB data.
*/
static char *nxagentImageAlpha(XImage *ximage);
@@ -141,10 +135,9 @@ static void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientP
static char *nxagentImageCopy(XImage *source, XImage *destination);
/*
- * Return true if the image can be cached.
- * Don't cache the images packed with the
- * bitmap method as the encoding is little
- * more expensive than a copy.
+ * Return true if the image can be cached. Don't cache the images
+ * packed with the bitmap method as the encoding is little more
+ * expensive than a copy.
*/
#define nxagentNeedCache(image, method) \
@@ -152,10 +145,8 @@ static char *nxagentImageCopy(XImage *source, XImage *destination);
((method) != PACK_BITMAP_16M_COLORS)
/*
- * With the bitmap encoding, if the image
- * is 32 bits-per-pixel the 4th byte is not
- * transmitted, so we don't need to clean
- * the image.
+ * With the bitmap encoding, if the image is 32 bits-per-pixel the 4th
+ * byte is not transmitted, so we don't need to clean the image.
*/
#define nxagentNeedClean(image, method) \
@@ -180,7 +171,6 @@ typedef struct _ImageStatisticsRec
double totalMatches;
double totalEncoded;
double totalAdded;
-
} ImageStatisticsRec;
ImageStatisticsRec nxagentImageStatistics;
@@ -188,11 +178,10 @@ ImageStatisticsRec nxagentImageStatistics;
int nxagentImageReformat(char *base, int nbytes, int bpp, int order)
{
/*
- * This is used whenever we need to swap the image data.
- * If we got an image from an X server having a different
- * endianness, we will need to reformat the image to match
- * our own image-order so that ProcGetImage can return
- * the expected format to the client.
+ * This is used whenever we need to swap the image data. If we got
+ * an image from an X server having a different endianness, we will
+ * need to reformat the image to match our own image-order so that
+ * ProcGetImage can return the expected format to the client.
*/
switch (bpp)
@@ -266,7 +255,6 @@ int nxagentImageLength(int width, int height, int format, int leftPad, int depth
else if (format == XYPixmap)
{
line = BitmapBytePad(width + leftPad);
-
line *= depth;
}
else if (format == ZPixmap)
@@ -298,10 +286,9 @@ int nxagentImagePad(int width, int format, int leftPad, int depth)
}
/*
- * Only copy the data, not the structure.
- * The data pointed by the destination is
- * lost. Used to clone two images that
- * point to the same data.
+ * Only copy the data, not the structure. The data pointed by the
+ * destination is lost. Used to clone two images that point to the
+ * same data.
*/
char *nxagentImageCopy(XImage *source, XImage *destination)
@@ -330,21 +317,13 @@ char *nxagentImageCopy(XImage *source, XImage *destination)
char *nxagentImageAlpha(XImage *image)
{
- char *pData;
-
- char *pSrcData;
- char *pDstData;
-
- int size;
- int offset;
-
/*
* Use one byte per pixel.
*/
- size = (image -> bytes_per_line * image -> height) >> 2;
+ int size = (image -> bytes_per_line * image -> height) >> 2;
- pData = malloc(size);
+ char *pData = malloc(size);
if (pData == NULL)
{
@@ -352,14 +331,13 @@ char *nxagentImageAlpha(XImage *image)
}
/*
- * The image is supposed to be in
- * server order.
+ * The image is supposed to be in server order.
*/
- offset = (image -> byte_order == MSBFirst) ? 0 : 3;
+ int offset = (image -> byte_order == MSBFirst) ? 0 : 3;
- pSrcData = image -> data;
- pDstData = pData;
+ char *pSrcData = image -> data;
+ char *pDstData = pData;
while (size-- > 0)
{
@@ -372,8 +350,7 @@ char *nxagentImageAlpha(XImage *image)
}
/*
- * Write down the image cache statistics
- * to the buffer.
+ * Write down the image cache statistics to the buffer.
*/
void nxagentImageStatisticsHandler(char **buffer, int type)
@@ -389,9 +366,8 @@ FIXME: Agent cache statistics have to be implemented.
}
/*
- * This should be called only for drawables
- * having a depth of 32. In the other cases,
- * it would only generate useless traffic.
+ * This should be called only for drawables having a depth of 32. In
+ * the other cases, it would only generate useless traffic.
*/
void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientPtr pClient)
@@ -412,16 +388,15 @@ void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientPtr pCli
}
/*
- * If we are synchronizing the drawable, discard
- * any unpack alpha stored for the client. The
- * alpha data, in fact, may be still traveling
- * and so we either wait until the end of the
- * split or send a fresh copy.
+ * If we are synchronizing the drawable, discard any unpack alpha
+ * stored for the client. The alpha data, in fact, may be still
+ * traveling and so we either wait until the end of the split or
+ * send a fresh copy.
*/
/*
-FIXME: Here the split trap is always set and so the caching of
- the alpha channel is useless. I remember we set the trap
- because of the cursor but why is it always set now?
+FIXME: Here the split trap is always set and so the caching of the
+ alpha channel is useless. I remember we set the trap because of
+ the cursor but why is it always set now?
*/
#ifdef DEBUG
fprintf(stderr, "nxagentSetUnpackAlpha: Checking alpha channel for client [%d] with trap [%d].\n",
@@ -439,9 +414,8 @@ FIXME: Here the split trap is always set and so the caching of
#endif
/*
- * Check if we are connected to a newer proxy
- * version and so can send the alpha data in
- * compressed form.
+ * Check if we are connected to a newer proxy version and so can
+ * send the alpha data in compressed form.
*/
if (nxagentAlphaCompat == 0)
@@ -488,16 +462,14 @@ FIXME: Here the split trap is always set and so the caching of
}
/*
- * The NX agent's implementation of the
- * X server's image functions.
+ * The NX agent's implementation of the X server's image functions.
*/
void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
int dstX, int dstY, int dstWidth, int dstHeight,
int leftPad, int format, char *data)
{
- int length;
-
+ /* will be checked at nxagentPutImageEnd */
RegionPtr pRegion = NullRegion;
int resource = 0;
@@ -511,21 +483,18 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
#endif
/*
- * If the display is down and there is not an
- * nxagent attached, sleep for a while but
- * still give a chance to the client to write
+ * If the display is down and there is not an nxagent attached,
+ * sleep for a while but still give a chance to the client to write
* to the framebuffer.
*/
- length = nxagentImageLength(dstWidth, dstHeight, format, leftPad, depth);
+ int length = nxagentImageLength(dstWidth, dstHeight, format, leftPad, depth);
if (nxagentShadowCounter == 0 &&
NXDisplayError(nxagentDisplay) == 1 &&
nxagentOption(SleepTime) > 0)
{
- int us;
-
- us = nxagentOption(SleepTime) * 4 * (length / 1024);
+ int us = nxagentOption(SleepTime) * 4 * (length / 1024);
us = (us < 10000 ? 10000 : (us > 1000000 ? 1000000 : us));
@@ -538,11 +507,11 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
}
/*
- * This is of little use because clients usually write
- * to windows only after an expose event, and, in the
- * rare case they use a direct put image to the window
- * (for a media player it should be a necessity), they
- * are likely to monitor the visibility of the window.
+ * This is of little use because clients usually write to windows
+ * only after an expose event, and, in the rare case they use a
+ * direct put image to the window (for a media player it should be a
+ * necessity), they are likely to monitor the visibility of the
+ * window.
*/
if (nxagentOption(IgnoreVisibility) == 0 && pDrawable -> type == DRAWABLE_WINDOW &&
@@ -559,9 +528,8 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
}
/*
- * This is more interesting. Check if the operation
- * will produce a visible result based on the clip
- * list of the window and the GC.
+ * This is more interesting. Check if the operation will produce a
+ * visible result based on the clip list of the window and the GC.
*/
pRegion = nxagentCreateRegion(pDrawable, pGC, dstX, dstY, dstWidth, dstHeight);
@@ -618,9 +586,8 @@ FIXME: Should use these.
}
/*
- * We are going to realize the operation
- * on the real display. Let's check if
- * the link is down.
+ * We are going to realize the operation on the real display. Let's
+ * check if the link is down.
*/
if (NXDisplayError(nxagentDisplay) == 1)
@@ -629,13 +596,11 @@ FIXME: Should use these.
}
/*
- * Mark the region as corrupted and skip the operation
- * if we went out of bandwidth. The drawable will be
- * synchronized at later time. Don't do that if the
- * image is likely to be a shape or a clip mask, if we
- * are here because we are actually synchronizing the
- * drawable or if the drawable's corrupted region is
- * over-age.
+ * Mark the region as corrupted and skip the operation if we went
+ * out of bandwidth. The drawable will be synchronized at later
+ * time. Don't do that if the image is likely to be a shape or a
+ * clip mask, if we are here because we are actually synchronizing
+ * the drawable or if the drawable's corrupted region is over-age.
*/
if (NXAGENT_SHOULD_DEFER_PUTIMAGE(pDrawable))
@@ -687,8 +652,7 @@ FIXME: Should use these.
#endif
/*
- * Check whether we need to enclose the
- * image in a split sequence.
+ * Check whether we need to enclose the image in a split sequence.
*/
/*
FIXME: Should we disable the split with link LAN?
@@ -700,12 +664,11 @@ FIXME: Should we disable the split with link LAN?
split = (nxagentOption(Streaming) == 1 &&
nxagentOption(LinkType) != LINK_TYPE_NONE
/*
-FIXME: Do we stream the images from GLX or Xv? If we do that,
- we should also write on the frame buffer, including the
- images put on windows, to be able to reconstruct the
- region that is out of sync. Surely we should not try to
- cache the GLX and Xv images in memory or save them in
- the image cache on disk.
+FIXME: Do we stream the images from GLX or Xv? If we do that, we
+ should also write on the frame buffer, including the images put
+ on windows, to be able to reconstruct the region that is out of
+ sync. Surely we should not try to cache the GLX and Xv images
+ in memory or save them in the image cache on disk.
*/
/*
FIXME: Temporarily stream the GLX data.
@@ -716,21 +679,18 @@ FIXME: Temporarily stream the GLX data.
);
/*
- * Never split images whose depth
- * is less than 15.
+ * Never split images whose depth is less than 15.
*/
if (split == 1 && (nxagentSplitTrap == 1 || depth < 15))
{
#ifdef TEST
-
if (nxagentSplitTrap == 1 ||
nxagentReconnectTrap == 1)
{
fprintf(stderr, "nxagentPutImage: Not splitting with reconnection [%d] trap [%d] "
"depth [%d].\n", nxagentSplitTrap, nxagentReconnectTrap, depth);
}
-
#endif
split = 0;
@@ -744,7 +704,6 @@ FIXME: Temporarily stream the GLX data.
#endif
#ifdef TEST
-
if (split == 1)
{
fprintf(stderr, "nxagentPutImage: Splitting the image with size [%d] "
@@ -757,13 +716,11 @@ FIXME: Temporarily stream the GLX data.
"link [%d] GLX [%d] Xv [%d].\n", length, nxagentOption(LinkType),
nxagentGlxTrap, nxagentXvTrap);
}
-
#endif
/*
- * If the image was originated by a GLX
- * or Xvideo request, temporarily disable
- * the use of the cache.
+ * If the image was originated by a GLX or Xvideo request,
+ * temporarily disable the use of the cache.
*/
if (nxagentOption(LinkType) != LINK_TYPE_NONE &&
@@ -779,17 +736,15 @@ FIXME: Temporarily stream the GLX data.
}
/*
- * Enclose the next messages in a split
- * sequence. The proxy will tell us if
- * the split took place.
+ * Enclose the next messages in a split sequence. The proxy will
+ * tell us if the split took place.
*/
if (split == 1)
{
/*
- * If the drawable is already being split,
- * expand the region. Currently drawables
- * can't have more than a single split
+ * If the drawable is already being split, expand the
+ * region. Currently drawables can't have more than a single split
* region.
*/
@@ -800,9 +755,8 @@ FIXME: Temporarily stream the GLX data.
(void *) pDrawable);
#endif
/*
-FIXME: Should probably intersect the region with
- the region being split to also invalidate
- the commits.
+FIXME: Should probably intersect the region with the region being
+ split to also invalidate the commits.
*/
nxagentMarkCorruptedRegion(pDrawable, pRegion);
@@ -811,9 +765,8 @@ FIXME: Should probably intersect the region with
else
{
/*
- * Assign a new resource to the drawable.
- * Will also assign the GC to use for the
- * operation.
+ * Assign a new resource to the drawable. Will also assign the
+ * GC to use for the operation.
*/
resource = nxagentCreateSplit(pDrawable, &pGC);
@@ -835,12 +788,11 @@ FIXME: Should probably intersect the region with
NXEndSplit(nxagentDisplay, resource);
/*
- * Now we need to check if all the messages went
- * straight through the output stream or any of
- * them required a split. If no split will take
- * place, we will remove the association with the
- * drawable and release the resource at the time
- * we will handle the no-split event.
+ * Now we need to check if all the messages went straight through
+ * the output stream or any of them required a split. If no split
+ * will take place, we will remove the association with the
+ * drawable and release the resource at the time we will handle
+ * the no-split event.
*/
split = nxagentWaitSplitEvent(resource);
@@ -854,10 +806,9 @@ FIXME: Should probably intersect the region with
#endif
/*
- * Marking the corrupted region we will check
- * if the region intersects the split region,
- * therefore the split region must be added
- * later.
+ * Marking the corrupted region we will check if the region
+ * intersects the split region, therefore the split region must
+ * be added later.
*/
nxagentMarkCorruptedRegion(pDrawable, pRegion);
@@ -873,9 +824,8 @@ FIXME: Should probably intersect the region with
}
/*
- * The split value could be changed by a
- * no-split event in the block above, so
- * here we have to check the value again.
+ * The split value could be changed by a no-split event in the block
+ * above, so here we have to check the value again.
*/
if (split == 0)
@@ -883,9 +833,8 @@ FIXME: Should probably intersect the region with
if (nxagentDrawableStatus(pDrawable) == NotSynchronized)
{
/*
- * We just covered the drawable with
- * a solid image. We can consider the
- * overlapping region as synchronized.
+ * We just covered the drawable with a solid image. We can
+ * consider the overlapping region as synchronized.
*/
#ifdef TEST
@@ -923,15 +872,9 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
int x, int y, int w, int h, int leftPad,
int format, char *data)
{
- int length;
-
- int bytesPerLine;
- int numSubImages;
- int totalHeight;
-
/*
- * NXPutPackedImage is longer than PutPackedImage
- * so that we subtract the bigger one to be sure.
+ * NXPutPackedImage is longer than PutPackedImage so that we
+ * subtract the bigger one to be sure.
*/
const int subSize = (MAX_REQUEST_SIZE << 2) - sizeof(xNXPutPackedImageReq);
@@ -942,7 +885,6 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
XImage *image = NULL;
-
if (NXDisplayError(nxagentDisplay) == 1)
{
#ifdef TEST
@@ -953,8 +895,7 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
}
/*
- * Get the visual according to the
- * drawable and depth.
+ * Get the visual according to the drawable and depth.
*/
pVisual = nxagentImageVisual(pDrawable, depth);
@@ -972,21 +913,21 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
* Get bytes per line according to format.
*/
- bytesPerLine = nxagentImagePad(w, format, leftPad, depth);
+ int bytesPerLine = nxagentImagePad(w, format, leftPad, depth);
if (nxagentOption(Shadow) == 1 && format == ZPixmap &&
(nxagentOption(XRatio) != DONT_SCALE ||
nxagentOption(YRatio) != DONT_SCALE) &&
pDrawable == (DrawablePtr) nxagentShadowPixmapPtr)
{
- int scaledx;
- int scaledy;
-
image = XCreateImage(nxagentDisplay, pVisual, depth, ZPixmap,
0, data, w, h, BitmapPad(nxagentDisplay), bytesPerLine);
if (image != NULL)
{
+ int scaledx;
+ int scaledy;
+
image -> byte_order = IMAGE_BYTE_ORDER;
image -> bitmap_bit_order = BITMAP_BIT_ORDER;
@@ -1021,13 +962,13 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
goto nxagentRealizeImageEnd;
}
- totalHeight = h;
+ int totalHeight = h;
- length = bytesPerLine * h;
+ int length = bytesPerLine * h;
h = (subSize < length ? subSize : length) / bytesPerLine;
- numSubImages = totalHeight / h + 1;
+ int numSubImages = totalHeight / h + 1;
while (numSubImages > 0)
{
@@ -1096,13 +1037,13 @@ void nxagentPutSubImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
/*
* XCreateImage is the place where the leftPad should be passed.
- * The image data is received from our client unmodified. In
- * theory what we would need to do is just creating an appropri-
- * ate XImage structure based on the incoming data and let Xlib
- * do the rest. Probably we don't have to pass leftPad again in
- * the src_x of XPutImage otherwise the src_x would make Xlib
- * to take into account the xoffset field twice. Unfortunately
- * passing the leftPad doesn't work.
+ * The image data is received from our client unmodified. In theory
+ * what we would need to do is just creating an appropriate XImage
+ * structure based on the incoming data and let Xlib do the
+ * rest. Probably we don't have to pass leftPad again in the src_x
+ * of XPutImage otherwise the src_x would make Xlib to take into
+ * account the xoffset field twice. Unfortunately passing the
+ * leftPad doesn't work.
*
* plainImage = XCreateImage(nxagentDisplay, pVisual,
* depth, format, leftPad, data,
@@ -1156,10 +1097,9 @@ FIXME: Should use an unpack resource here.
#endif
/*
- * We got the image data from the X client or
- * from the frame-buffer with our own endianness.
- * Byte swap the image data if the display has
- * a different endianness than our own.
+ * We got the image data from the X client or from the frame-buffer
+ * with our own endianness. Byte swap the image data if the display
+ * has a different endianness than our own.
*/
if (nxagentImageNormalize(plainImage) != 0)
@@ -1176,10 +1116,9 @@ FIXME: Should use an unpack resource here.
#endif
/*
- * Check if the user requested to pack the
- * image but don't pack it if we are not
- * connected to a proxy or if the depth is
- * less than 15 bpp.
+ * Check if the user requested to pack the image but don't pack it
+ * if we are not connected to a proxy or if the depth is less than
+ * 15 bpp.
*/
pack = (nxagentOption(LinkType) != LINK_TYPE_NONE &&
@@ -1190,9 +1129,8 @@ FIXME: Should use an unpack resource here.
if (pack == 1 && lossless == 0)
{
/*
- * Force the image to be sent as a plain
- * bitmap if we don't have any lossless
- * encoder available.
+ * Force the image to be sent as a plain bitmap if we don't have
+ * any lossless encoder available.
*/
if (w <= IMAGE_PACK_WIDTH || h <= IMAGE_PACK_HEIGHT ||
@@ -1231,8 +1169,8 @@ FIXME: Should use an unpack resource here.
if (pack == 1)
{
/*
- * Set the geometry and alpha channel
- * to be used for the unpacked image.
+ * Set the geometry and alpha channel to be used for the unpacked
+ * image.
*/
if (nxagentUnpackVisualId[client -> index] != pVisual -> visualid)
@@ -1248,9 +1186,8 @@ FIXME: Should use an unpack resource here.
}
/*
- * Check if the image is supposed to carry
- * the alpha data in the fourth byte and,
- * if so, send the alpha channel using the
+ * Check if the image is supposed to carry the alpha data in the
+ * fourth byte and, if so, send the alpha channel using the
* specific encoding.
*/
@@ -1260,46 +1197,43 @@ FIXME: Should use an unpack resource here.
}
/*
- * If the image doesn't come from the XVideo or the
- * GLX extension try to locate it in the cache. The
- * case of the lossless trap is also special, as we
- * want to eventually encode the image again using
- * a lossless compression.
+ * If the image doesn't come from the XVideo or the GLX extension
+ * try to locate it in the cache. The case of the lossless trap is
+ * also special, as we want to eventually encode the image again
+ * using a lossless compression.
*/
/*
-FIXME: Should try to locate the image anyway, if the lossless
- trap is set, and if the image was encoded by a lossy
- compressor, roll back the changes and encode the image
- again using the preferred method.
+FIXME: Should try to locate the image anyway, if the lossless trap is
+ set, and if the image was encoded by a lossy compressor, roll
+ back the changes and encode the image again using the preferred
+ method.
*/
if (nxagentNeedCache(plainImage, packMethod) &&
nxagentGlxTrap == 0 && nxagentXvTrap == 0 &&
nxagentLosslessTrap == 0 && NXImageCacheSize > 0)
{
/*
- * Be sure that the padding bits are
- * cleaned before calculating the MD5
- * checksum.
+ * Be sure that the padding bits are cleaned before calculating
+ * the MD5 checksum.
*/
/*
FIXME: There should be a callback registered by the agent that
- provides a statistics report, in text format, telling
- for example how many images were searched in the cache,
- how many were found, how many drawables are to be synch-
- ronized, etc. This statistics report would be included
- by the proxy in its stat output.
+ provides a statistics report, in text format, telling for
+ example how many images were searched in the cache, how many
+ were found, how many drawables are to be synchronized,
+ etc. This statistics report would be included by the proxy in
+ its stat output.
*/
clean = 1;
NXCleanImage(plainImage);
/*
- * Will return a pointer to the image and checksum
- * taken from the cache, if found. If the image is
- * not found, the function returns a null image and
- * a pointer to the calculated checksum. It is up
- * to the application to free the memory. We will
- * use the checksum to add the image in the cache.
+ * Will return a pointer to the image and checksum taken from
+ * the cache, if found. If the image is not found, the function
+ * returns a null image and a pointer to the calculated
+ * checksum. It is up to the application to free the memory. We
+ * will use the checksum to add the image in the cache.
*/
packedImage = NXCacheFindImage(plainImage, &packMethod, &packedChecksum);
@@ -1336,9 +1270,8 @@ FIXME: There should be a callback registered by the agent that
}
/*
- * If a specific encoder was not mandated,
- * try to guess if a lossless encoder will
- * compress better.
+ * If a specific encoder was not mandated, try to guess if a
+ * lossless encoder will compress better.
*/
if (lossless == 0 && nxagentOption(Adaptive) == 1)
@@ -1366,8 +1299,7 @@ FIXME: There should be a callback registered by the agent that
}
/*
- * Encode the image using the selected
- * pack method.
+ * Encode the image using the selected pack method.
*/
if (packMethod == PACK_RLE_16M_COLORS ||
@@ -1375,13 +1307,11 @@ FIXME: There should be a callback registered by the agent that
packMethod == PACK_BITMAP_16M_COLORS)
{
/*
- * Cleanup the image if we didn't do that yet.
- * We assume that the JPEG and PNG compression
- * methods will actually ignore the padding
- * bytes. In other words, bitmap images prod-
- * ucing the same visual output should produce
- * compressed images that are bitwise the same
- * regardless the padding bits.
+ * Cleanup the image if we didn't do that yet. We assume that
+ * the JPEG and PNG compression methods will actually ignore the
+ * padding bytes. In other words, bitmap images producing the
+ * same visual output should produce compressed images that are
+ * bitwise the same regardless the padding bits.
*/
if (clean == 0)
@@ -1397,30 +1327,25 @@ FIXME: There should be a callback registered by the agent that
switch (packMethod)
{
/*
- * If nothing is done by the bitmap encoder,
- * it saves an allocation and a memory copy
- * by setting the data field of the packed
- * image to the original data. We need to
- * check this at the time we will free the
- * packed image.
+ * If nothing is done by the bitmap encoder, it saves an
+ * allocation and a memory copy by setting the data field of
+ * the packed image to the original data. We need to check
+ * this at the time we will free the packed image.
*/
case PACK_BITMAP_16M_COLORS:
{
packedImage = NXEncodeBitmap(plainImage, packMethod, packQuality);
-
break;
}
case PACK_RGB_16M_COLORS:
{
packedImage = NXEncodeRgb(plainImage, packMethod, packQuality);
-
break;
}
default:
{
packedImage = NXEncodeRle(plainImage, packMethod, packQuality);
-
break;
}
}
@@ -1447,8 +1372,8 @@ FIXME: There should be a callback registered by the agent that
}
/*
- * If we didn't produce a valid packed
- * image, send the image as a X bitmap.
+ * If we didn't produce a valid packed image, send the image as a X
+ * bitmap.
*/
if (packedImage != NULL)
@@ -1467,10 +1392,8 @@ FIXME: There should be a callback registered by the agent that
0, 0, x, y, w, h);
/*
- * Add the image only if we have a valid
- * checksum. This is the case only if we
- * originally tried to find the image in
- * cache.
+ * Add the image only if we have a valid checksum. This is the
+ * case only if we originally tried to find the image in cache.
*/
if (NXImageCacheSize > 0 && packedChecksum != NULL)
@@ -1481,9 +1404,8 @@ FIXME: There should be a callback registered by the agent that
#endif
/*
- * Check if both the plain and the packed
- * image point to the same data. In this
- * case we need a copy.
+ * Check if both the plain and the packed image point to the
+ * same data. In this case we need a copy.
*/
if (packedImage -> data == plainImage -> data &&
@@ -1504,19 +1426,17 @@ FIXME: There should be a callback registered by the agent that
else
{
/*
- * Clean the image to help the proxy to match
- * the checksum in its cache. Do that only if
- * the differential compression is enabled and
- * if the image is not supposed to carry the
- * alpha data in the fourth byte of the pixel.
+ * Clean the image to help the proxy to match the checksum in its
+ * cache. Do that only if the differential compression is enabled
+ * and if the image is not supposed to carry the alpha data in the
+ * fourth byte of the pixel.
*/
/*
FIXME: If we failed to encode the image by any of the available
- methods, for example if we couldn't allocate memory, we
- may need to ripristinate the alpha channel, that in the
- meanwhile was sent in the unpack alpha message. This can
- be done here, if the clean flag is true and we are going
- to send a plain image.
+ methods, for example if we couldn't allocate memory, we may
+ need to ripristinate the alpha channel, that in the meanwhile
+ was sent in the unpack alpha message. This can be done here, if
+ the clean flag is true and we are going to send a plain image.
*/
if (clean == 0)
{
@@ -1610,17 +1530,14 @@ void nxagentGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
}
/*
- * We have to reset the visual cache before
- * connecting to another display, so that a
- * new unpack geometry can be communicated
- * to the new proxy.
+ * We have to reset the visual cache before connecting to another
+ * display, so that a new unpack geometry can be communicated to the
+ * new proxy.
*/
void nxagentResetVisualCache(void)
{
- int i;
-
- for (i = 0; i < MAX_CONNECTIONS; i++)
+ for (int i = 0; i < MAX_CONNECTIONS; i++)
{
nxagentUnpackVisualId[i] = None;
}
@@ -1628,9 +1545,7 @@ void nxagentResetVisualCache(void)
void nxagentResetAlphaCache(void)
{
- int i;
-
- for (i = 0; i < MAX_CONNECTIONS; i++)
+ for (int i = 0; i < MAX_CONNECTIONS; i++)
{
if (nxagentUnpackAlpha[i])
{
@@ -1643,55 +1558,25 @@ void nxagentResetAlphaCache(void)
int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio,
XImage **pImage, int *scaledx, int *scaledy)
{
- int x1;
- int x2;
- int y1;
- int y2;
-
- int xx1;
- int xx2;
- int yy1;
- int yy2;
-
- int newWidth;
- int newHeight;
-
- int i;
- int j;
- int k;
- int l;
-
- unsigned long val;
-
- XImage *newImage;
XImage *image = *pImage;
- #ifdef FAST_GET_PUT_PIXEL
-
- register char *srcPixel;
- register char *dstPixel;
-
- int i;
-
- #endif
-
if (image == NULL)
{
return 0;
}
- x1 = (xRatio * x) >> PRECISION;
- x2 = (xRatio * (x + image -> width)) >> PRECISION;
+ int x1 = (xRatio * x) >> PRECISION;
+ int x2 = (xRatio * (x + image -> width)) >> PRECISION;
- y1 = (yRatio * y) >> PRECISION;
- y2 = (yRatio * (y + image -> height)) >> PRECISION;
+ int y1 = (yRatio * y) >> PRECISION;
+ int y2 = (yRatio * (y + image -> height)) >> PRECISION;
- newWidth = x2 - x1;
- newHeight = y2 - y1;
+ int newWidth = x2 - x1;
+ int newHeight = y2 - y1;
- newImage = XCreateImage(nxagentDisplay, NULL, image -> depth, image -> format, 0, NULL,
- newWidth, newHeight, BitmapPad(nxagentDisplay),
- PixmapBytePad(newWidth, image -> depth));
+ XImage *newImage = XCreateImage(nxagentDisplay, NULL, image -> depth, image -> format, 0, NULL,
+ newWidth, newHeight, BitmapPad(nxagentDisplay),
+ PixmapBytePad(newWidth, image -> depth));
if (newImage == NULL)
{
@@ -1725,39 +1610,40 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio,
newImage -> width = newWidth;
newImage -> height = newHeight;
- for (j = y; j < y + image -> height; j++)
+ for (int j = y; j < y + image -> height; j++)
{
- yy1 = (yRatio * j) >> PRECISION;
- yy2 = (yRatio * (j + 1)) >> PRECISION;
+ int yy1 = (yRatio * j) >> PRECISION;
+ int yy2 = (yRatio * (j + 1)) >> PRECISION;
- for (i = x; i < x + image -> width; i++)
+ for (int i = x; i < x + image -> width; i++)
{
+ unsigned long val;
+
#ifndef FAST_GET_PUT_PIXEL
val = XGetPixel(image, i - x, j - y);
#else
- srcPixel = &image -> data[(j * image -> bytes_per_line) +
- ((i * image -> bits_per_pixel) >> 3)];
-
- dstPixel = (char *) &val;
+ char * srcPixel = &image -> data[(j * image -> bytes_per_line) +
+ ((i * image -> bits_per_pixel) >> 3)];
+ char * dstPixel = (char *) &val;
val = 0;
- for (i = (image -> bits_per_pixel + 7) >> 3; --i >= 0; )
+ for (int m = (image -> bits_per_pixel + 7) >> 3; --m >= 0; )
{
*dstPixel++ = *srcPixel++;
}
#endif
- xx1 = (xRatio * i) >> PRECISION;
- xx2 = (xRatio * (i + 1)) >> PRECISION;
+ int xx1 = (xRatio * i) >> PRECISION;
+ int xx2 = (xRatio * (i + 1)) >> PRECISION;
- for (l = yy1; l < yy2; l++)
+ for (int l = yy1; l < yy2; l++)
{
- for (k = xx1; k < xx2; k++)
+ for (int k = xx1; k < xx2; k++)
{
#ifndef FAST_GET_PUT_PIXEL
@@ -1765,12 +1651,12 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio,
#else
- dstPixel = &newImage -> data[((l - y1) * newImage -> bytes_per_line) +
+ char *dstPixel = &newImage -> data[((l - y1) * newImage -> bytes_per_line) +
(((k - x1) * newImage -> bits_per_pixel) >> 3)];
- srcPixel = (char *) &val;
+ char *srcPixel = (char *) &val;
- for (i = (newImage -> bits_per_pixel + 7) >> 3; --i >= 0; )
+ for (int m = (newImage -> bits_per_pixel + 7) >> 3; --m >= 0; )
{
*dstPixel++ = *srcPixel++;
}
@@ -1794,19 +1680,12 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio,
char *nxagentAllocateImageData(int width, int height, int depth, int *length, int *format)
{
- char *data;
-
- int leftPad;
-
- leftPad = 0;
-
*format = (depth == 1) ? XYPixmap : ZPixmap;
- *length = nxagentImageLength(width, height, *format, leftPad, depth);
+ *length = nxagentImageLength(width, height, *format, 0, depth);
- data = NULL;
-
- if ((data = malloc(*length)) == NULL)
+ char *data = malloc(*length);
+ if (data == NULL)
{
#ifdef WARNING
fprintf(stderr, "nxagentAllocateImageData: WARNING! Failed to allocate [%d] bytes of memory.\n", *length);
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c
index 0b4ffd601..3cba1a89d 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Init.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c
@@ -89,44 +89,35 @@ is" without express or implied warranty.
/*
* ProcVector array defined in tables.c.
*/
-
extern int (*ProcVector[256])(ClientPtr);
/*
* From the fb code.
*/
-
extern int fbGCPrivateIndex;
+#ifdef DPMSExtension
/*
* Stubs for the DPMS extension.
*/
-
-#ifdef DPMSExtension
-
void DPMSSet(int level);
int DPMSGet(int *level);
Bool DPMSSupported(void);
-
#endif
/*
* Our error logging function.
*/
-
void OsVendorVErrorFFunction(const char *f, va_list args);
/*
* True if this is a fatal error.
*/
-
extern int OsVendorVErrorFFatal;
/*
- * Redirect the error output to a
- * different file
+ * Redirect the error output to a different file
*/
-
extern void (*OsVendorStartRedirectErrorFProc)();
extern void (*OsVendorEndRedirectErrorFProc)();
@@ -136,11 +127,8 @@ void OsVendorStartRedirectErrorFFunction();
void OsVendorEndRedirectErrorFFunction();
/*
- * Called by InitGlobals() in the
- * new X server tree.
+ * Called by InitGlobals() in the new X server tree.
*/
-
-
static void nxagentGrabServerCallback(CallbackListPtr *callbacks, void *data,
void *args);
@@ -164,12 +152,11 @@ void ddxInitGlobals(void)
}
/*
- * Set if the remote display supports
- * backing store.
+ * Set if the remote display supports backing store.
*/
/*
-FIXME: These, if not removed, should at least
- be moved to Display.h and Display.c.
+FIXME: These, if not removed, should at least be moved to Display.h
+ and Display.c.
*/
int nxagentBackingStore;
int nxagentSaveUnder;
@@ -187,7 +174,6 @@ int nxagentSaveUnder;
* nxagentOpenScreen
* InitInput
*/
-
int nxagentDoFullGeneration = 1;
/*
@@ -197,9 +183,8 @@ int nxagentDoFullGeneration = 1;
Bool nxagentX2go;
/*
- * Check if agent is x2go agent
+ * Check if agent is X2goAgent
*/
-
void checkX2goAgent(void)
{
#ifdef TEST
@@ -215,11 +200,9 @@ void checkX2goAgent(void)
nxagentX2go = False;
}
-
/*
* Called at X server's initialization.
*/
-
void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
{
/*
@@ -244,8 +227,8 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
}
/*
- * Avoid slowness due to buggy_repeat workaround
- * in libcairo versions >= 1.10.
+ * Avoid slowness due to buggy_repeat workaround in libcairo
+ * versions >= 1.10.
*/
SetVendorRelease(70000000);
@@ -260,9 +243,8 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
}
/*
- * Unset the LD_LIBRARY_PATH variable in
- * Popen() before calling execl() in the
- * child process.
+ * Unset the LD_LIBRARY_PATH variable in Popen() before calling
+ * execl() in the child process.
*/
NXUnsetLibraryPath(1);
@@ -314,15 +296,13 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
nxagentInitBSPixmapList();
/*
- * Open the display. We are at the early startup and
- * the information we'll get from the remote X server
- * will mandate some of the characteristics of the
- * session, like the screen depth. Note that this re-
- * liance on the remote display at session startup
- * should be removed. We should always operate at 32
- * bpp, internally, and do the required translations
- * as soon as the graphic operation needs to be real-
- * ized on the remote display.
+ * Open the display. We are at the early startup and the information
+ * we'll get from the remote X server will mandate some of the
+ * characteristics of the session, like the screen depth. Note that
+ * this reliance on the remote display at session startup should be
+ * removed. We should always operate at 32 bpp, internally, and do
+ * the required translations as soon as the graphic operation needs
+ * to be realized on the remote display.
*/
nxagentOpenDisplay(argc, argv);
@@ -393,9 +373,8 @@ FIXME: These variables, if not removed at all because have probably
nxagentNumScreens = screenInfo->numScreens;
/*
- * Initialize the GCs used by the synchro-
- * nization put images. We do it here beca-
- * use we use the nxagentDefaultScreen.
+ * Initialize the GCs used by the synchronization put images. We do
+ * it here because we use the nxagentDefaultScreen.
*/
nxagentAllocateGraphicContexts();
@@ -403,8 +382,7 @@ FIXME: These variables, if not removed at all because have probably
nxagentDoFullGeneration = nxagentFullGeneration;
/*
- * Use a solid black root window
- * background.
+ * Use a solid black root window background.
*/
if (!whiteRoot)
@@ -419,15 +397,12 @@ FIXME: These variables, if not removed at all because have probably
nxagentInitAtoms();
}
-void
-nxagentNotifyConnection(int fd, int ready, void *data)
+void nxagentNotifyConnection(int fd, int ready, void *data)
{
nxagentDispatchEvents(NULL);
}
-void InitInput(argc, argv)
- int argc;
- char *argv[];
+void InitInput(int argc, char *argv[])
{
void *ptr, *kbd;
@@ -440,9 +415,8 @@ void InitInput(argc, argv)
mieqInit(kbd, ptr);
/*
- * Add the display descriptor to the
- * set of descriptors awaited by the
- * dispatcher.
+ * Add the display descriptor to the set of descriptors awaited by
+ * the dispatcher.
*/
nxagentAddXConnection();
@@ -457,10 +431,9 @@ void InitInput(argc, argv)
}
/*
- * We let the proxy flush the link on our behalf
- * after having opened the display. We are now
- * entering the dispatcher. From now on we'll
- * flush the proxy link explicitly.
+ * We let the proxy flush the link on our behalf after having opened
+ * the display. We are now entering the dispatcher. From now on
+ * we'll flush the proxy link explicitly.
*/
#ifdef TEST
@@ -471,11 +444,9 @@ void InitInput(argc, argv)
}
/*
- * DDX specific abort routine. This is called
- * by AbortServer() that, in turn, is called
- * by FatalError().
+ * DDX specific abort routine. This is called by AbortServer() that,
+ * in turn, is called by FatalError().
*/
-
void AbortDDX(void)
{
nxagentDoFullGeneration = True;
@@ -483,9 +454,8 @@ void AbortDDX(void)
nxagentCloseDisplay();
/*
- * Do the required finalization if we
- * are not going through the normal
- * X server shutdown.
+ * Do the required finalization if we are not going through the
+ * normal X server shutdown.
*/
if ((dispatchException & DE_TERMINATE) == 0)
@@ -497,7 +467,6 @@ void AbortDDX(void)
/*
* Called by GiveUp().
*/
-
void ddxGiveUp(void)
{
AbortDDX();
@@ -515,12 +484,10 @@ void OsVendorInit(void)
void OsVendorFatalError(void)
{
/*
- * Let the session terminate gracely
- * from an user's standpoint.
+ * Let the session terminate gracely from an user's standpoint.
*/
fprintf(stderr, "Session: Aborting session at '%s'.\n", GetTimeAsString());
-
fprintf(stderr, "Session: Session aborted at '%s'.\n", GetTimeAsString());
}
@@ -566,7 +533,6 @@ static void nxagentGrabServerCallback(CallbackListPtr *callbacks, void *data,
}
#ifdef DPMSExtension
-
void DPMSSet(int level)
{
}
@@ -580,5 +546,4 @@ Bool DPMSSupported(void)
{
return 0;
}
-
#endif
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index a79052080..faabb2ebe 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -104,10 +104,9 @@ static void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, cha
#endif
/*
- * Unfortunately we cannot just include XKBlib.h.
- * It conflicts with the server side definitions
- * of the same symbols. This is more a X problem
- * than our.
+ * Unfortunately we cannot just include XKBlib.h. It conflicts with
+ * the server side definitions of the same symbols. This is more a X
+ * problem than our.
*/
#ifdef XKB
@@ -158,8 +157,7 @@ static char *nxagentRemoteOptions = NULL;
XkbAgentInfoRec nxagentXkbInfo = { -1, -1, -1, -1, -1 };
/*
- * Keyboard status, updated through XKB
- * events.
+ * Keyboard status, updated through XKB events.
*/
XkbAgentStateRec nxagentXkbState = { 0, 0, 0, 0, 0 };
@@ -283,9 +281,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
/*
* We want to prevent agent generating auto-repeated
- * keystrokes. Let's intercept any attempt by appli-
- * cations to change the default timeouts on the
- * nxagent device.
+ * keystrokes. Let's intercept any attempt by appli- cations to
+ * change the default timeouts on the nxagent device.
*/
#ifdef TEST
@@ -305,8 +302,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
#endif
/*
- * If enabled, propagate the changes to the
- * devices attached to the real X server.
+ * If enabled, propagate the changes to the devices attached to the
+ * real X server.
*/
if (nxagentOption(DeviceControl))
@@ -315,10 +312,7 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
fprintf(stderr, "%s: WARNING! Propagating changes to keyboard settings.\n", __func__);
#endif
- unsigned long value_mask = KBKeyClickPercent |
- KBBellPercent |
- KBBellPitch |
- KBBellDuration;
+ unsigned long value_mask = KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration;
XKeyboardControl values = {
.key_click_percent = ctrl->click,
@@ -328,8 +322,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
};
/*
- * Don't propagate the auto repeat mode. It is forced to be
- * off in the agent server.
+ * Don't propagate the auto repeat mode. It is forced to be off in
+ * the agent server.
*
* value_mask |= KBAutoRepeatMode;
* values.auto_repeat_mode = ctrl->autoRepeat ?
@@ -339,9 +333,9 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
XChangeKeyboardControl(nxagentDisplay, value_mask, &values);
/*
- * At this point, we need to walk through the vector and
- * compare it to the current server vector. If there are
- * differences, report them.
+ * At this point, we need to walk through the vector and compare
+ * it to the current server vector. If there are differences,
+ * report them.
*/
value_mask = KBLed | KBLedMode;
@@ -403,11 +397,11 @@ N/A
#endif
/*
- * Prevent agent from generating auto-repeat keystroke.
- * Note that this is working only if XKB is enabled.
- * A better solution should account cases where XKB is
- * not available. Check also the behaviour of the
- * DeviceControl nxagent option.
+ * Prevent agent from generating auto-repeat keystroke. Note
+ * that this is working only if XKB is enabled. A better
+ * solution should account cases where XKB is not
+ * available. Check also the behaviour of the DeviceControl
+ * nxagent option.
*/
XkbDfltRepeatDelay = ~ 0;
@@ -429,10 +423,9 @@ N/A
#ifdef _XSERVER64
{
KeySym64 *keymap64 = XGetKeyboardMapping(nxagentDisplay,
- min_keycode,
- max_keycode - min_keycode + 1,
- &mapWidth);
-
+ min_keycode,
+ max_keycode - min_keycode + 1,
+ &mapWidth);
if (keymap64 == NULL)
{
XFreeModifiermap(modifier_keymap);
@@ -607,8 +600,8 @@ XkbError:
}
/*
- * There is no description for pc105 on Solaris.
- * Need to revert to the closest approximation.
+ * There is no description for pc105 on Solaris. Need to
+ * revert to the closest approximation.
*/
#ifdef TEST
@@ -870,7 +863,6 @@ void nxagentNotifyKeyboardChanges(int oldMinKeycode, int oldMaxKeycode)
#endif
xEvent event = {0};
-
event.u.u.type = MappingNotify;
event.u.mappingNotify.request = MappingKeyboard;
event.u.mappingNotify.firstKeyCode = inputInfo.keyboard -> key -> curKeySyms.minKeyCode;
@@ -943,12 +935,11 @@ int nxagentResetKeyboard(void)
}
#endif
- dev->key=NULL;
+ dev->key = NULL;
}
- dev->focus=NULL;
-
- dev->kbdfeed=NULL;
+ dev->focus = NULL;
+ dev->kbdfeed = NULL;
#ifdef XKB
nxagentTuneXkbWrapper();
@@ -1094,37 +1085,37 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev)
if (dev->key)
{
- #ifdef XKB
- if (noXkbExtension == 0 && dev->key->xkbInfo)
- {
- XkbFreeInfo(dev->key->xkbInfo);
- dev->key->xkbInfo = NULL;
- }
- #endif
+ #ifdef XKB
+ if (noXkbExtension == 0 && dev->key->xkbInfo)
+ {
+ XkbFreeInfo(dev->key->xkbInfo);
+ dev->key->xkbInfo = NULL;
+ }
+ #endif
- SAFE_free(dev->key->curKeySyms.map);
- SAFE_free(dev->key->modifierKeyMap);
- SAFE_free(dev->key);
+ SAFE_free(dev->key->curKeySyms.map);
+ SAFE_free(dev->key->modifierKeyMap);
+ SAFE_free(dev->key);
}
if (dev->focus)
{
- SAFE_free(dev->focus->trace);
- SAFE_free(dev->focus);
+ SAFE_free(dev->focus->trace);
+ SAFE_free(dev->focus);
}
if (dev->kbdfeed)
{
- for (KbdFeedbackPtr k = dev->kbdfeed, knext; k; k = knext)
- {
- knext = k->next;
- #ifdef XKB
- if (k->xkb_sli)
- XkbFreeSrvLedInfo(k->xkb_sli);
- #endif
- SAFE_free(k);
- }
- dev->kbdfeed = NULL;
+ for (KbdFeedbackPtr k = dev->kbdfeed, knext; k; k = knext)
+ {
+ knext = k->next;
+ #ifdef XKB
+ if (k->xkb_sli)
+ XkbFreeSrvLedInfo(k->xkb_sli);
+ #endif
+ SAFE_free(k);
+ }
+ dev->kbdfeed = NULL;
}
#ifdef DEBUG
diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c b/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c
index 1988ca102..08666a3f8 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c
@@ -80,6 +80,7 @@ miTrapezoids (CARD8 op,
xDst = traps[0].left.p1.x >> 16;
yDst = traps[0].left.p1.y >> 16;
+#ifdef NXAGENT_SERVER
if (nxagentTrapezoidExtents != NullBox)
{
memcpy(&bounds, nxagentTrapezoidExtents, sizeof(BoxRec));
@@ -92,7 +93,9 @@ miTrapezoids (CARD8 op,
memcpy(nxagentTrapezoidExtents, &bounds, sizeof(BoxRec));
}
-
+#else
+ miTrapezoidBounds (ntrap, traps, &bounds);
+#endif
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
return;
pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.c b/nx-X11/programs/Xserver/hw/nxagent/Options.c
index 5c3a44c23..9e11dc5f2 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Options.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Options.c
@@ -34,10 +34,9 @@
#include "Utils.h"
/*
- * Instead of having a single options repository
- * data could be attached to the display or the
- * screen. The macro nxagentOption() should make
- * the transition simple.
+ * Instead of having a single options repository data could be
+ * attached to the display or the screen. The macro nxagentOption()
+ * should make the transition simple.
*/
AgentOptionsRec nxagentOptions;
@@ -52,8 +51,8 @@ AgentOptionsPtr nxagentOptionsPtr = &nxagentOptions;
unsigned int nxagentPrintGeometryFlags = 0;
/*
- * This must be called at startup to initialize
- * the options repository to the default values.
+ * This must be called at startup to initialize the options repository
+ * to the default values.
*/
void nxagentInitOptions(void)
@@ -176,12 +175,10 @@ void nxagentInitOptions(void)
}
/*
- * This is called at session reconnection
- * to reset some options to their default
- * values. The reason to avoid calling the
- * nxagentInitOptions() is that not all the
- * options can change value when reconnec-
- * ting.
+ * This is called at session reconnection to reset some options to
+ * their default values. The reason to avoid calling the
+ * nxagentInitOptions() is that not all the options can change value
+ * when reconnecting.
*/
void nxagentResetOptions(void)
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.h b/nx-X11/programs/Xserver/hw/nxagent/Options.h
index 02e1890b3..d791d2294 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Options.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Options.h
@@ -94,346 +94,267 @@ typedef enum _KeycodeConversion
typedef struct _AgentOptions
{
/*
- * Link type of the NX connection or none,
- * if this is a direct X11 connection.
+ * Link type of the NX connection or none, if this is a direct X11
+ * connection.
*/
-
int LinkType;
/*
- * Is agent running in desktop mode? This
- * is presently the default.
+ * Is agent running in desktop mode? This is presently the default.
*/
-
int Desktop;
/*
* True if user activated rootless mode.
*/
-
int Rootless;
/*
* True for shadow mode.
*/
-
int Shadow;
/*
* True if user activated persistent mode.
*/
-
int Persistent;
/*
* True if user activated fullscreen mode.
*/
-
int Fullscreen;
/*
- * True if the fullscreen NX session will
- * extend on all available screens.
+ * True if the fullscreen NX session will extend on all available
+ * screens.
*/
-
int AllScreens;
/*
- * Set to the auto-disconnect timeout, if
- * the user activated this feature.
+ * Set to the auto-disconnect timeout, if the user activated this
+ * feature.
*/
-
int Timeout;
/*
* Geometry of the agent's window.
*/
-
- int X;
- int Y;
- int Width;
- int Height;
+ int X, Y, Width, Height;
int BorderWidth;
/*
- * Geometry of the agent's window in window
- * mode. Used to restore window size when
- * switching back to window mode from full-
- * screen.
+ * Geometry of the agent's window in window mode. Used to restore
+ * window size when switching back to window mode from fullscreen.
*/
-
int WMBorderWidth;
int WMTitleHeight;
- int SavedX;
- int SavedY;
- int SavedWidth;
- int SavedHeight;
+ int SavedX, SavedY, SavedWidth, SavedHeight;
- int SavedRootWidth;
- int SavedRootHeight;
+ int SavedRootWidth, SavedRootHeight;
/*
- * Set if agent is running nested in another
- * agent X server.
+ * Set if agent is running nested in another agent X server.
*/
-
int Nested;
/*
* Selected backing-store mode.
*/
-
BackingStoreMode BackingStore;
/*
* Selected clipboard mode.
*/
-
ClipboardMode Clipboard;
/*
- * Enable agent to use the MITSHM extension in
- * path from remote proxy to the real X server.
+ * Enable agent to use the MITSHM extension in path from remote
+ * proxy to the real X server.
*/
-
int SharedMemory;
/*
* Enable agent to use shared Pixmaps
*/
-
int SharedPixmaps;
/*
- * Enable agent to propagate keyboard and pointer
- * device configuration to the remote X server.
+ * Enable agent to propagate keyboard and pointer device
+ * configuration to the remote X server.
*/
-
int DeviceControl;
/*
* Explicitly asked config propagation.
*/
-
int DeviceControlUserDefined;
/*
- * Resuming keyboard device corrects keymap if session
- * migrates across platforms with different keycode
- * layout.
+ * Resuming keyboard device corrects keymap if session migrates
+ * across platforms with different keycode layout.
*/
-
int ResetKeyboardAtResume;
/*
* Reset server when the last client disconnects.
*/
-
int Reset;
/*
- * Geometry of the agent root window, relative to
- * the agent default window.
+ * Geometry of the agent root window, relative to the agent default
+ * window.
*/
-
- int RootX;
- int RootY;
- int RootWidth;
- int RootHeight;
+ int RootX, RootY, RootWidth, RootHeight;
/*
- * Horizontal and vertical span of the
- * agent viewport.
+ * Horizontal and vertical span of the agent viewport.
*/
-
- int ViewportXSpan;
- int ViewportYSpan;
+ int ViewportXSpan, ViewportYSpan;
/*
- * True if the user can resize the desktop
- * by dragging the window border.
+ * True if the user can resize the desktop by dragging the window
+ * border.
*/
-
int DesktopResize;
/*
* The scaling ratio of the shadow agent.
*/
+ int Ratio, XRatio, YRatio;
- int Ratio;
-
- int XRatio;
-
- int YRatio;
-
- float FloatRatio;
-
- float FloatXRatio;
-
- float FloatYRatio;
+ float FloatRatio, FloatXRatio, FloatYRatio;
/*
* The shadow agent uses the Damage extension.
*/
-
int UseDamage;
/*
* Was the agent run with the -B option?
*/
-
int Binder;
-
char *BinderOptions;
/*
- * Set if the agent has to connect to a
- * desktop manager to start the session.
+ * Set if the agent has to connect to a desktop manager to start the
+ * session.
*/
-
int Xdmcp;
/*
- * Size of the Xlib display buffer. The
- * default is set according to the link
- * type.
+ * Size of the Xlib display buffer. The default is set according to
+ * the link type.
*/
-
int DisplayBuffer;
/*
* Buffer coalescence timeout.
*/
-
int DisplayCoalescence;
/*
- * Use the composite extension when
- * available on the remote display.
+ * Use the composite extension when available on the remote display.
*/
-
int Composite;
/*
- * If set, don't skip internal operations
- * when the agent window is not fully visible.
+ * If set, don't skip internal operations when the agent window is
+ * not fully visible.
*/
-
int IgnoreVisibility;
/*
- * If set, prevent the shadow session to
- * interact with master display.
+ * If set, prevent the shadow session to interact with master
+ * display.
*/
-
int ViewOnly;
/*
- * If true select a lossy or lossless comp-
- * ression method based on the characterist-
- * ics of the image.
+ * If true select a lossy or lossless compression method based on
+ * the characteristics of the image.
*/
-
int Adaptive;
/*
- * Stream the images and update the display
- * when the image has been completely trans-
- * ferred.
+ * Stream the images and update the display when the image has been
+ * completely transerred.
*/
-
int Streaming;
/*
- * Use a lazy approach in updating the remote
- * display. This means delaying the bandwidth
- * consuming graphic operations and synchroniz-
- * ing the screen at idle time.
+ * Use a lazy approach in updating the remote display. This means
+ * delaying the bandwidth consuming graphic operations and
+ * synchronizing the screen at idle time.
*/
-
int DeferLevel;
/*
- * Maximum elapsed time before a new full
- * synchronization.
+ * Maximum elapsed time before a new full synchronization.
*/
-
unsigned long DeferTimeout;
/*
- * Maximum size of the tile used when sending
- * an image to the remote display.
+ * Maximum size of the tile used when sending an image to the remote
+ * display.
*/
-
- int TileWidth;
- int TileHeight;
+ int TileWidth, TileHeight;
/*
* Enabling/disabling the pulldown menu.
*/
-
int Menu;
/*
* Enabling/disabling the magic pixel.
*/
-
int MagicPixel;
/*
* Specify the Operative System of the client.
*/
-
int ClientOs;
/*
* Inhibit some XKEYBOARD requests.
*/
-
int InhibitXkb;
/*
- * Maximum number of bytes that can be pasted from
- * an NX session into an external application.
+ * Maximum number of bytes that can be pasted from an NX session
+ * into an external application.
*/
-
int CopyBufferSize;
/*
* Max image data rate to the encoder input.
*/
-
int ImageRateLimit;
/*
- * True if agent should not exit if there are no
- * clients in rootless mode
+ * True if agent should not exit if there are no clients in rootless
+ * mode
*/
-
int NoRootlessExit;
/*
* Store if the user wants Xinerama. There are variables called
* noPanoramiXExtension and noRRXineramaExtensison in os/utils.c but
* we cannot rely on them because RandR and PanoramiX change their
- * values when trying to initialize. So we use this variable to
- * save the user preference provided by the -/+(rr)xinerama parameter(s)
+ * values when trying to initialize. So we use this variable to save
+ * the user preference provided by the -/+(rr)xinerama parameter(s)
* before initializing those extensions.
*/
-
int Xinerama;
/*
* Sleep delay in microseconds.
*/
-
unsigned int SleepTime;
/*
* Tolerance - tightens or loosens reconnect checks.
*/
-
ToleranceChecksMode ReconnectTolerance;
/*
@@ -473,8 +394,7 @@ extern AgentOptionsPtr nxagentOptionsPtr;
extern void nxagentInitOptions(void);
/*
- * Initialize some options to the default values
- * at reconnection.
+ * Initialize some options to the default values at reconnection.
*/
extern void nxagentResetOptions(void);
@@ -486,8 +406,8 @@ extern void nxagentResetOptions(void);
extern void nxagentSaveOptions(void);
/*
- * Restore the options reset by nxagentResetOptions
- * to their backup value.
+ * Restore the options reset by nxagentResetOptions to their backup
+ * value.
*/
extern void nxagentRestoreOptions(void);
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixels.c b/nx-X11/programs/Xserver/hw/nxagent/Pixels.c
index 93038eab6..8aaa9ecd8 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Pixels.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Pixels.c
@@ -56,8 +56,6 @@ static int nxagentComparePixels(const void *p1, const void *p2)
int nxagentUniquePixels(XImage *image)
{
- int i = 0;
-
int pixels[PIXEL_ELEMENTS];
int elements = PIXEL_ELEMENTS;
@@ -132,15 +130,14 @@ int nxagentUniquePixels(XImage *image)
#endif
/*
- * Take one pixel every n from the image and
- * add it to the array.
+ * Take one pixel every n from the image and add it to the array.
*/
switch (image -> bits_per_pixel)
{
case 32:
{
- for (i = 0; i < elements; i++)
+ for (int i = 0; i < elements; i++)
{
pixels[i] = Get32(next, image -> byte_order);
@@ -156,7 +153,7 @@ int nxagentUniquePixels(XImage *image)
}
case 24:
{
- for (i = 0; i < elements; i++)
+ for (int i = 0; i < elements; i++)
{
pixels[i] = Get24(next, image -> byte_order);
@@ -174,14 +171,12 @@ int nxagentUniquePixels(XImage *image)
case 15:
{
/*
- * Note that the padding bytes at the end
- * of the scanline are included in the set.
- * This is not a big problem. What we want
- * to find out is just how compressible is
- * the image data.
+ * Note that the padding bytes at the end of the scanline are
+ * included in the set. This is not a big problem. What we want
+ * to find out is just how compressible is the image data.
*/
- for (i = 0; i < elements; i++)
+ for (int i = 0; i < elements; i++)
{
pixels[i] = Get16(next, image -> byte_order);
@@ -212,7 +207,7 @@ int nxagentUniquePixels(XImage *image)
qsort(pixels, elements, sizeof(int), nxagentComparePixels);
- for (i = 0; i < elements; i++)
+ for (int i = 0; i < elements; i++)
{
if (last != pixels[i])
{
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c
index d344f34b0..379a19fa0 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c
@@ -66,8 +66,8 @@ is" without express or implied warranty.
#undef DEBUG
/*
- * The nxagentReversePointerMap array is used to
- * memorize remote display pointer map.
+ * The nxagentReversePointerMap array is used to memorize remote
+ * display pointer map.
*/
unsigned char nxagentReversePointerMap[MAXBUTTONS];
@@ -76,13 +76,12 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl)
{
/*
* The original behaviour was to reset the pointer settings
- * (acceleration and alas) to the default values. What the
- * average user expects, on the contrary, is to have agent
- * inheriting whatever value is set on the real X display.
- * Having to reflect changes made inside the agent session,
- * the correct behavior would be saving the original values
- * and restoring them as soon as focus leaves the agent's
- * window.
+ * (acceleration and alas) to the default values. What the average
+ * user expects, on the contrary, is to have agent inheriting
+ * whatever value is set on the real X display. Having to reflect
+ * changes made inside the agent session, the correct behavior would
+ * be saving the original values and restoring them as soon as focus
+ * leaves the agent's window.
*/
if (nxagentOption(DeviceControl) == True)
@@ -104,10 +103,6 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl)
int nxagentPointerProc(DeviceIntPtr pDev, int onoff)
{
- CARD8 map[MAXBUTTONS];
- int nmap;
- int i;
-
switch (onoff)
{
case DEVICE_INIT:
@@ -121,8 +116,10 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff)
return Success;
}
- nmap = XGetPointerMapping(nxagentDisplay, map, MAXBUTTONS);
- for (i = 0; i <= nmap; i++)
+ CARD8 map[MAXBUTTONS];
+
+ int nmap = XGetPointerMapping(nxagentDisplay, map, MAXBUTTONS);
+ for (int i = 0; i <= nmap; i++)
map[i] = i; /* buttons are already mapped */
InitPointerDeviceStruct((DevicePtr) pDev, map, nmap,
miPointerGetMotionEvents,
@@ -174,10 +171,6 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff)
void nxagentInitPointerMap(void)
{
- int numButtons;
-
- int i;
-
unsigned char pointerMap[MAXBUTTONS];
#ifdef DEBUG
@@ -185,13 +178,13 @@ void nxagentInitPointerMap(void)
"pointer map from remote display.\n");
#endif
- numButtons = XGetPointerMapping(nxagentDisplay, pointerMap, MAXBUTTONS);
+ int numButtons = XGetPointerMapping(nxagentDisplay, pointerMap, MAXBUTTONS);
/*
* Computing revers pointer map.
*/
- for (i = 1; i <= numButtons; i++)
+ for (int i = 1; i <= numButtons; i++)
{
nxagentReversePointerMap[pointerMap[i - 1]] = i;
}
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Split.c b/nx-X11/programs/Xserver/hw/nxagent/Split.c
index 33005e86d..4dac8f5b2 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Split.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Split.c
@@ -36,7 +36,6 @@
#include "compext/Compext.h"
-
/*
* Set here the required log level.
*/
@@ -47,9 +46,8 @@
#undef DEBUG
/*
- * This should be a macro but for now
- * we make it a real function to log
- * a warning in the logs.
+ * This should be a macro but for now we make it a real function to
+ * log a warning in the logs.
*/
DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable)
@@ -73,13 +71,11 @@ DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable)
void nxagentInitSplitResources(void)
{
- int resource;
-
#ifdef TEST
fprintf(stderr, "nxagentInitSplitResources: Initializing the split resources.\n");
#endif
- for (resource = 0; resource < NXNumberOfResources; resource++)
+ for (int resource = 0; resource < NXNumberOfResources; resource++)
{
SplitResourcePtr pResource = &nxagentSplitResources[resource];
@@ -97,8 +93,6 @@ SplitResourcePtr nxagentAllocSplitResource(void)
{
int resource;
- SplitResourcePtr pResource;
-
for (;;)
{
resource = NXAllocSplit(nxagentDisplay, NXAnyResource);
@@ -124,7 +118,7 @@ FIXME: Must deal with the case all resources are exausted.
}
}
- pResource = &nxagentSplitResources[resource];
+ SplitResourcePtr pResource = &nxagentSplitResources[resource];
if (pResource -> pending != 0 || pResource -> split != NXNoResource ||
pResource -> unpack != NXNoResource || pResource -> drawable != NULL ||
@@ -217,13 +211,11 @@ FIXME: This must be implemented.
void nxagentReleaseAllSplits(void)
{
- int resource;
-
#ifdef TEST
fprintf(stderr, "nxagentReleaseAllSplits: Going to release all the split resources.\n");
#endif
- for (resource = 0; resource < NXNumberOfResources; resource++)
+ for (int resource = 0; resource < NXNumberOfResources; resource++)
{
SplitResourcePtr pResource = &nxagentSplitResources[resource];
@@ -329,11 +321,9 @@ static void nxagentCheckResource(SplitResourcePtr pResource, int resource)
int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC)
{
- SplitResourcePtr pResource;
-
pDrawable = nxagentSplitDrawable(pDrawable);
- pResource = nxagentAllocSplitResource();
+ SplitResourcePtr pResource = nxagentAllocSplitResource();
if (pDrawable -> type == DRAWABLE_PIXMAP)
{
@@ -348,8 +338,7 @@ int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC)
pResource -> commit = 1;
/*
- * Make a copy of the GC so the client
- * can safely remove it.
+ * Make a copy of the GC so the client can safely remove it.
*/
pResource -> gc = CreateScratchGC(pDrawable -> pScreen, pDrawable -> depth);
@@ -400,17 +389,14 @@ FIXME: What do we do here?
}
/*
- * Set the region to be the current
- * streaming region.
+ * Set the region to be the current streaming region.
*/
void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion)
{
- SplitResourcePtr pResource;
-
pDrawable = nxagentSplitDrawable(pDrawable);
- pResource = nxagentSplitResource(pDrawable);
+ SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
#ifdef TEST
@@ -442,18 +428,16 @@ void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion)
}
/*
- * Remove the association between the drawable
- * and the split resource. The resource is not
- * deallocated until the end of the split.
+ * Remove the association between the drawable and the split
+ * resource. The resource is not deallocated until the end of the
+ * split.
*/
void nxagentReleaseSplit(DrawablePtr pDrawable)
{
- SplitResourcePtr pResource;
-
pDrawable = nxagentSplitDrawable(pDrawable);
- pResource = nxagentSplitResource(pDrawable);
+ SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
if (pResource == NULL)
{
@@ -477,10 +461,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
if (pResource -> region != NullRegion)
{
/*
- * If we have a region the commits
- * had to be still valid. In this
- * case tell the proxy to abort the
- * data transfer.
+ * If we have a region the commits had to be still valid. In this
+ * case tell the proxy to abort the data transfer.
*/
#ifdef TEST
@@ -528,8 +510,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
}
/*
- * Remove the association between the
- * drawable and the resource record.
+ * Remove the association between the drawable and the resource
+ * record.
*/
#ifdef TEST
@@ -547,9 +529,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
}
/*
- * Invalidate the commits and remove the
- * association between the resource and
- * the drawable.
+ * Invalidate the commits and remove the association between the
+ * resource and the drawable.
*/
pResource -> drawable = NULL;
@@ -558,11 +539,9 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
{
- SplitResourcePtr pResource;
-
pDrawable = nxagentSplitDrawable(pDrawable);
- pResource = nxagentSplitResource(pDrawable);
+ SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
if (pResource == NULL)
{
@@ -607,9 +586,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
#endif
/*
- * If a null region is passed as parameter,
- * we assume that all the commits have to
- * be discarded.
+ * If a null region is passed as parameter, we assume that all the
+ * commits have to be discarded.
*/
if (pRegion == NullRegion)
@@ -626,9 +604,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
RegionRec tmpRegion;
/*
- * Check if the provided region overlaps
- * the area covered by the image being
- * streamed.
+ * Check if the provided region overlaps the area covered by the
+ * image being streamed.
*/
RegionInit(&tmpRegion, NullBox, 1);
@@ -698,10 +675,9 @@ void nxagentFreeSplit(int resource)
else
{
/*
- * The end of the split has come after we have
- * invalidated the operation and removed the
- * association to the drawable. This happens,
- * for example, if the drawable is destroyed.
+ * The end of the split has come after we have invalidated the
+ * operation and removed the association to the drawable. This
+ * happens, for example, if the drawable is destroyed.
*/
fprintf(stderr, "nxagentFreeSplit: WARNING! Releasing invalidated resource [%d].\n",
@@ -718,8 +694,8 @@ void nxagentFreeSplit(int resource)
}
/*
-FIXME: This must be enabled when the vanilla
- synchronization procedure is working.
+FIXME: This must be enabled when the vanilla synchronization procedure
+ is working.
*/
#define USE_FINISH_SPLIT
@@ -747,8 +723,7 @@ void nxagentWaitDrawable(DrawablePtr pDrawable)
#endif
/*
- * Be sure we intercept an I/O error
- * as well as an interrupt.
+ * Be sure we intercept an I/O error as well as an interrupt.
*/
#ifdef USE_FINISH_SPLIT
@@ -762,21 +737,18 @@ void nxagentWaitDrawable(DrawablePtr pDrawable)
for (;;)
{
/*
- * Handling all the possible events here
- * preempts the queue and makes a better
- * use of the link.
+ * Handling all the possible events here preempts the queue and
+ * makes a better use of the link.
*
- * We should better use XIfEvent() instead
- * of looping again and again through the
- * event queue.
+ * We should better use XIfEvent() instead of looping again and
+ * again through the event queue.
*/
nxagentDispatchEvents(NULL);
/*
- * Wait indefinitely until the resource
- * is released or the display is shut
- * down.
+ * Wait indefinitely until the resource is released or the display
+ * is shut down.
*/
if (nxagentSplitResource(pDrawable) == NULL ||
@@ -821,16 +793,14 @@ void nxagentWaitCommitEvent(int resource)
XEvent event;
/*
- * Check if there is any commit pending. As
- * we are at it, handle any commit, even those
- * commits pertaining to other resources.
+ * Check if there is any commit pending. As we are at it, handle any
+ * commit, even those commits pertaining to other resources.
*
- * We can receive some commits even if we'll
- * later receive a no-split event. The proxy,
- * in fact, may have missed to find the image
- * in the memory cache and could have loaded it
- * from disk (so requiring a commit) before we
- * marked the end of the split sequence.
+ * We can receive some commits even if we'll later receive a
+ * no-split event. The proxy, in fact, may have missed to find the
+ * image in the memory cache and could have loaded it from disk (so
+ * requiring a commit) before we marked the end of the split
+ * sequence.
*/
while (nxagentCheckEvents(nxagentDisplay, &event,
@@ -866,9 +836,8 @@ int nxagentWaitSplitEvent(int resource)
int split = 0;
/*
- * Don't flush the link. We only want to
- * query the NX transport to check whether
- * the operation caused a split.
+ * Don't flush the link. We only want to query the NX transport to
+ * check whether the operation caused a split.
*/
NXFlushDisplay(nxagentDisplay, NXFlushBuffer);
@@ -1223,10 +1192,9 @@ void nxagentSetCorruptedTimestamp(DrawablePtr pDrawable)
}
/*
- * Reset the timestamp taken when the drawable
- * became initially corrupted. The timestamp is
- * reset only after the drawable has been fully
- * synchronized.
+ * Reset the timestamp taken when the drawable became initially
+ * corrupted. The timestamp is reset only after the drawable has been
+ * fully synchronized.
*/
void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable)
@@ -1253,4 +1221,3 @@ void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable)
}
}
}
-
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Visual.c b/nx-X11/programs/Xserver/hw/nxagent/Visual.c
index a29560d43..6be82148f 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Visual.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Visual.c
@@ -64,19 +64,17 @@ Visual nxagentAlphaVisual;
Visual *nxagentVisual(VisualPtr pVisual)
{
- XVisualInfo visual;
-
- int i;
-
- visual.class = pVisual->class;
- visual.bits_per_rgb = pVisual->bitsPerRGBValue;
- visual.colormap_size = pVisual->ColormapEntries;
- visual.depth = pVisual->nplanes;
- visual.red_mask = pVisual->redMask;
- visual.green_mask = pVisual->greenMask;
- visual.blue_mask = pVisual->blueMask;
-
- for (i = 0; i < nxagentNumVisuals; i++)
+ XVisualInfo visual = {
+ .class = pVisual->class,
+ .bits_per_rgb = pVisual->bitsPerRGBValue,
+ .colormap_size = pVisual->ColormapEntries,
+ .depth = pVisual->nplanes,
+ .red_mask = pVisual->redMask,
+ .green_mask = pVisual->greenMask,
+ .blue_mask = pVisual->blueMask
+ };
+
+ for (int i = 0; i < nxagentNumVisuals; i++)
{
if (nxagentCompareVisuals(visual, nxagentVisuals[i]) == 1)
{
@@ -89,9 +87,7 @@ Visual *nxagentVisual(VisualPtr pVisual)
Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual)
{
- int i;
-
- for (i = 0; i < pScreen->numVisuals; i++)
+ for (int i = 0; i < pScreen->numVisuals; i++)
{
if (pScreen->visuals[i].vid == visual)
{
@@ -104,9 +100,7 @@ Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual)
Colormap nxagentDefaultVisualColormap(Visual *visual)
{
- int i;
-
- for (i = 0; i < nxagentNumVisuals; i++)
+ for (int i = 0; i < nxagentNumVisuals; i++)
{
if (nxagentVisuals[i].visual == visual)
{
@@ -117,18 +111,16 @@ Colormap nxagentDefaultVisualColormap(Visual *visual)
return None;
}
+#if 0
/*
- * This is currently unused. It should serve
- * the scope of matching a visual whenever
- * a drawable has a different depth than the
- * real display.
+ * This is currently unused. It should serve the scope of matching a
+ * visual whenever a drawable has a different depth than the real
+ * display.
*/
Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth)
{
- int i;
-
- for (i = 0; i < pScreen->numVisuals; i++)
+ for (int i = 0; i < pScreen->numVisuals; i++)
{
if (pScreen->visuals[i].nplanes == depth)
{
@@ -138,11 +130,11 @@ Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth)
return NULL;
}
+#endif
/*
- * Create a fake 32 bits depth visual and
- * initialize it based on the endianness
- * of the remote display.
+ * Create a fake 32 bits depth visual and initialize it based on the
+ * endianness of the remote display.
*/
void nxagentInitAlphaVisual(void)
@@ -150,9 +142,8 @@ void nxagentInitAlphaVisual(void)
nxagentAlphaVisual.visualid = XAllocID(nxagentDisplay);
/*
- * Color masks are referred to bits inside
- * the pixel. This is independent from the
- * endianness.
+ * Color masks are referred to bits inside the pixel. This is
+ * independent from the endianness.
*/
nxagentAlphaVisual.red_mask = 0x00ff0000;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Visual.h b/nx-X11/programs/Xserver/hw/nxagent/Visual.h
index 70799f3f8..40946f3c0 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Visual.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Visual.h
@@ -42,7 +42,10 @@ is" without express or implied warranty.
Visual *nxagentVisual(VisualPtr pVisual);
Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual);
+
+#if 0
Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth);
+#endif
Colormap nxagentDefaultVisualColormap(Visual *visual);
@@ -50,17 +53,14 @@ Colormap nxagentDefaultVisualColormap(Visual *visual);
nxagentVisualFromID((pScreen), (pScreen) -> rootVisual)
/*
- * Visual generated by Xorg and Xfree86 at
- * 16-bit depth differs on the bits_per_rgb
- * value, so we avoid checking it.
+ * Visual generated by Xorg and Xfree86 at 16-bit depth differs on the
+ * bits_per_rgb value, so we avoid checking it.
*/
/*
- * Some Solaris X servers uses the color
- * masks inverted, so that the red and
- * the blue mask are switched. To reconnect
- * the session on this displays, we do a
- * double check, as workaround.
+ * Some Solaris X servers uses the color masks inverted, so that the
+ * red and the blue mask are switched. To reconnect the session on
+ * this displays, we do a double check, as workaround.
*/
#define nxagentCompareVisuals(v1, v2) \