aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Display.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Display.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Display.c478
1 files changed, 191 insertions, 287 deletions
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