Commit b1d15688 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Display.c: reformat comments

parent 838572f7
...@@ -212,20 +212,18 @@ int nxagentServerOrder(void) ...@@ -212,20 +212,18 @@ int nxagentServerOrder(void)
} }
/* /*
* FIXME: This error handler is not printing anything * FIXME: This error handler is not printing anything in the session
* in the session log. This is OK once the session is * log. This is OK once the session is started, because the error is
* started, because the error is handled by the other * handled by the other layers, but not before that point, as the
* layers, but not before that point, as the agent * agent would die without giving any feedback to the user (or, worse,
* would die without giving any feedback to the user * to the NX server). We should check how many requests have been
* (or, worse, to the NX server). We should check how * handled for this display and print a message if the display dies
* many requests have been handled for this display * before the session is up and running.
* 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 * FIXME: This should be moved to Error.c, The other handlers should
* handlers should be probably moved to Handlers.c. * be probably moved to Handlers.c.
*/ */
int nxagentIOErrorHandler(Display *display) int nxagentIOErrorHandler(Display *display)
...@@ -246,11 +244,9 @@ int nxagentIOErrorHandler(Display *display) ...@@ -246,11 +244,9 @@ int nxagentIOErrorHandler(Display *display)
} }
/* /*
* Force a shutdown of any connection attempt * Force a shutdown of any connection attempt while connecting to the
* while connecting to the remote display. * remote display. This is needed to avoid a hang up in case of
* This is needed to avoid a hang up in case * loopback connections to our own listening sockets.
* of loopback connections to our own listen-
* ing sockets.
*/ */
static void nxagentRejectConnection(int signal) static void nxagentRejectConnection(int signal)
...@@ -266,16 +262,15 @@ static void nxagentRejectConnection(int signal) ...@@ -266,16 +262,15 @@ static void nxagentRejectConnection(int signal)
#endif #endif
/* /*
* A further timeout is unlikely to happen * A further timeout is unlikely to happen in the case of loopback
* in the case of loopback connections. * connections.
*/ */
alarm(5); alarm(5);
} }
/* /*
* Ignore the signal if the NX transport is * Ignore the signal if the NX transport is not running.
* not running.
*/ */
static void nxagentSigusrHandler(int signal) static void nxagentSigusrHandler(int signal)
...@@ -379,8 +374,8 @@ static void nxagentSigchldHandler(int signal) ...@@ -379,8 +374,8 @@ static void nxagentSigchldHandler(int signal)
int options = WNOHANG | WUNTRACED; int options = WNOHANG | WUNTRACED;
/* /*
* Try with the pid of the dialog process. * Try with the pid of the dialog process. Leave the other children
* Leave the other children unaffected. * unaffected.
*/ */
if (nxagentRootlessDialogPid) if (nxagentRootlessDialogPid)
...@@ -574,22 +569,19 @@ Display *nxagentInternalOpenDisplay(char *display) ...@@ -574,22 +569,19 @@ Display *nxagentInternalOpenDisplay(char *display)
int result; int result;
/* /*
* Stop the smart schedule timer since * Stop the smart schedule timer since it uses SIGALRM as we do.
* it uses SIGALRM as we do.
*/ */
nxagentStopTimer(); nxagentStopTimer();
/* /*
* Install the handler rejecting a possible * Install the handler rejecting a possible loopback connection.
* loopback connection.
*/ */
/* /*
FIXME: Should print a warning if the user tries to let FIXME: Should print a warning if the user tries to let the agent
the agent impersonate the same display as the impersonate the same display as the display where the agent is
display where the agent is supposed to connect. supposed to connect. We actually handle this by means of
We actually handle this by means of RejectWell- RejectWellKnownSockets() but without giving a friendly
KnownSockets() but without giving a friendly
explanation for the error to the user. explanation for the error to the user.
*/ */
...@@ -645,9 +637,8 @@ static void nxagentDisplayBlockHandler(Display *display, int reason) ...@@ -645,9 +637,8 @@ static void nxagentDisplayBlockHandler(Display *display, int reason)
if (nxagentDisplay != NULL) if (nxagentDisplay != NULL)
{ {
/* /*
* Don't allow the smart schedule to * Don't allow the smart schedule to interrupt the agent while
* interrupt the agent while waiting * waiting for the remote display.
* for the remote display.
*/ */
#ifdef DEBUG #ifdef DEBUG
...@@ -674,8 +665,7 @@ static void nxagentDisplayBlockHandler(Display *display, int reason) ...@@ -674,8 +665,7 @@ static void nxagentDisplayBlockHandler(Display *display, int reason)
{ {
/* /*
* Let the dispatch attend the next * Let the dispatch attend the next client.
* client.
*/ */
#ifdef DEBUG #ifdef DEBUG
...@@ -799,18 +789,17 @@ static int nxagentDisplayErrorPredicate(Display *display, int error) ...@@ -799,18 +789,17 @@ static int nxagentDisplayErrorPredicate(Display *display, int error)
void nxagentInstallDisplayHandlers(void) void nxagentInstallDisplayHandlers(void)
{ {
/* /*
* If the display was already opened, be sure * If the display was already opened, be sure all structures are
* all structures are freed. * freed.
*/ */
nxagentResetDisplayHandlers(); nxagentResetDisplayHandlers();
/* /*
* We want the Xlib I/O error handler to return, * We want the Xlib I/O error handler to return, instead of quitting
* instead of quitting the application. Using * the application. Using setjmp()/longjmp() leaves the door open to
* setjmp()/longjmp() leaves the door open to * unexpected bugs when dealing with interaction with the other X
* unexpected bugs when dealing with interaction * server layers.
* with the other X server layers.
*/ */
NXHandleDisplayError(1); NXHandleDisplayError(1);
...@@ -828,14 +817,12 @@ void nxagentInstallDisplayHandlers(void) ...@@ -828,14 +817,12 @@ void nxagentInstallDisplayHandlers(void)
XSetIOErrorHandler(nxagentIOErrorHandler); XSetIOErrorHandler(nxagentIOErrorHandler);
/* /*
* Let Xlib become aware of our interrupts. In theory * Let Xlib become aware of our interrupts. In theory we don't need
* we don't need to have the error handler installed * to have the error handler installed during the normal operations
* during the normal operations and could simply let * and could simply let the dispatcher handle the interrupts. In
* the dispatcher handle the interrupts. In practice * practice it's better to have Xlib invalidating the display as
* it's better to have Xlib invalidating the display * soon as possible rather than incurring in the risk of entering a
* as soon as possible rather than incurring in the * loop that doesn't care checking the display errors explicitly.
* risk of entering a loop that doesn't care checking
* the display errors explicitly.
*/ */
#ifdef TEST #ifdef TEST
...@@ -848,8 +835,8 @@ void nxagentInstallDisplayHandlers(void) ...@@ -848,8 +835,8 @@ void nxagentInstallDisplayHandlers(void)
void nxagentPostInstallDisplayHandlers(void) void nxagentPostInstallDisplayHandlers(void)
{ {
/* /*
* This is executed after having opened the * This is executed after having opened the display, once we know
* display, once we know the display address. * the display address.
*/ */
if (nxagentDisplay != NULL) if (nxagentDisplay != NULL)
...@@ -881,15 +868,13 @@ void nxagentResetDisplayHandlers(void) ...@@ -881,15 +868,13 @@ void nxagentResetDisplayHandlers(void)
if (nxagentDisplay != NULL) if (nxagentDisplay != NULL)
{ {
/* /*
* Free the internal nxcompext * Free the internal nxcompext structures.
* structures.
*/ */
NXResetDisplay(nxagentDisplay); NXResetDisplay(nxagentDisplay);
/* /*
* Remove the display descriptor * Remove the display descriptor from the listened sockets.
* from the listened sockets.
*/ */
nxagentRemoveXConnection(); nxagentRemoveXConnection();
...@@ -912,8 +897,7 @@ void nxagentResetDisplayHandlers(void) ...@@ -912,8 +897,7 @@ void nxagentResetDisplayHandlers(void)
nxagentCongestion = 0; nxagentCongestion = 0;
/* /*
* Reset the counter of synchronization * Reset the counter of synchronization requests pending.
* requests pending.
*/ */
nxagentTokens.soft = 0; nxagentTokens.soft = 0;
...@@ -937,9 +921,8 @@ void nxagentInstallSignalHandlers(void) ...@@ -937,9 +921,8 @@ void nxagentInstallSignalHandlers(void)
#endif #endif
/* /*
* Keep the default X server's handlers for * Keep the default X server's handlers for SIGINT and SIGTERM and
* SIGINT and SIGTERM and restore the other * restore the other signals of interest to our defaults.
* signals of interest to our defaults.
*/ */
struct sigaction newAction; struct sigaction newAction;
...@@ -947,9 +930,9 @@ void nxagentInstallSignalHandlers(void) ...@@ -947,9 +930,9 @@ void nxagentInstallSignalHandlers(void)
int result; int result;
/* /*
* By default nxcomp installs its signal handlers. * By default nxcomp installs its signal handlers. We need to
* We need to ensure that SIGUSR1 and SIGUSR2 are * ensure that SIGUSR1 and SIGUSR2 are ignored if the NX transport
* ignored if the NX transport is not running. * is not running.
*/ */
newAction.sa_handler = nxagentSigusrHandler; newAction.sa_handler = nxagentSigusrHandler;
...@@ -993,8 +976,7 @@ void nxagentInstallSignalHandlers(void) ...@@ -993,8 +976,7 @@ void nxagentInstallSignalHandlers(void)
} }
/* /*
* Let the smart schedule set the SIGALRM * Let the smart schedule set the SIGALRM handler again.
* handler again.
*/ */
nxagentInitTimer(); nxagentInitTimer();
...@@ -1043,13 +1025,12 @@ void nxagentPostInstallSignalHandlers(void) ...@@ -1043,13 +1025,12 @@ void nxagentPostInstallSignalHandlers(void)
#endif #endif
/* /*
* Reconfigure our signal handlers to work well * Reconfigure our signal handlers to work well with the NX
* with the NX transport. * transport.
* *
* Let our handlers manage the SIGINT and SIGTERM. * Let our handlers manage the SIGINT and SIGTERM. The following
* The following calls will tell the NX transport * calls will tell the NX transport to restore the old handlers
* to restore the old handlers (those originally * (those originally installed by us or the X server).
* installed by us or the X server).
*/ */
NXTransSignal(SIGINT, NX_SIGNAL_DISABLE); NXTransSignal(SIGINT, NX_SIGNAL_DISABLE);
...@@ -1062,16 +1043,14 @@ void nxagentPostInstallSignalHandlers(void) ...@@ -1062,16 +1043,14 @@ void nxagentPostInstallSignalHandlers(void)
NXTransSignal(SIGHUP, NX_SIGNAL_DISABLE); NXTransSignal(SIGHUP, NX_SIGNAL_DISABLE);
/* /*
* Both the proxy and the agent need to catch * Both the proxy and the agent need to catch their children, so
* their children, so we'll have to send the * we'll have to send the signal to transport.
* signal to transport.
*/ */
NXTransSignal(SIGCHLD, NX_SIGNAL_DISABLE); NXTransSignal(SIGCHLD, NX_SIGNAL_DISABLE);
/* /*
* Let the NX transport take care of SIGUSR1 * Let the NX transport take care of SIGUSR1 and SIGUSR2.
* and SIGUSR2.
*/ */
} }
...@@ -1084,8 +1063,7 @@ void nxagentResetSignalHandlers(void) ...@@ -1084,8 +1063,7 @@ void nxagentResetSignalHandlers(void)
memset(&newAction, 0, sizeof(newAction)); memset(&newAction, 0, sizeof(newAction));
/* /*
* Reset the signal handlers * Reset the signal handlers to a well known state.
* to a well known state.
*/ */
#ifdef TEST #ifdef TEST
...@@ -1111,8 +1089,7 @@ void nxagentResetSignalHandlers(void) ...@@ -1111,8 +1089,7 @@ void nxagentResetSignalHandlers(void)
} }
/* /*
* Let the smart schedule set the SIGALRM * Let the smart schedule set the SIGALRM handler again.
* handler again.
*/ */
nxagentInitTimer(); nxagentInitTimer();
...@@ -1134,8 +1111,8 @@ void nxagentOpenDisplay(int argc, char *argv[]) ...@@ -1134,8 +1111,8 @@ void nxagentOpenDisplay(int argc, char *argv[])
#endif #endif
/* /*
* Initialize the reconnector only in the case * Initialize the reconnector only in the case of persistent
* of persistent sessions. * sessions.
*/ */
if (nxagentOption(Persistent)) if (nxagentOption(Persistent))
...@@ -1163,8 +1140,8 @@ void nxagentOpenDisplay(int argc, char *argv[]) ...@@ -1163,8 +1140,8 @@ void nxagentOpenDisplay(int argc, char *argv[])
if (nxagentDisplay == NULL) if (nxagentDisplay == NULL)
{ {
/* /*
FIXME: The agent should never exit the program with a FatalError() FIXME: The agent should never exit the program with a FatalError() but
but rather use a specific function that may eventually call rather use a specific function that may eventually call
FatalError() on its turn. FatalError() on its turn.
*/ */
FatalError("Unable to open display '%s'.\n", nxagentDisplayName); FatalError("Unable to open display '%s'.\n", nxagentDisplayName);
...@@ -1264,18 +1241,17 @@ N/A ...@@ -1264,18 +1241,17 @@ N/A
#endif #endif
/* /*
* Initialize the agent's event mask that will be requested * Initialize the agent's event mask that will be requested for the
* for the root and all the top level windows. If the nested * root and all the top level windows. If the nested window is a
* window is a child of an existing window, we will need to * child of an existing window, we will need to receive
* receive StructureNotify events. If we are going to manage * StructureNotify events. If we are going to manage the changes in
* the changes in root window's visibility we'll also need * root window's visibility we'll also need VisibilityChange events.
* VisibilityChange events.
*/ */
/* /*
FIXME: Use of nxagentParentWindow is strongly deprecated. FIXME: Use of nxagentParentWindow is strongly deprecated. We need
We need also to clarify which events are selected also to clarify which events are selected in the different
in the different operating modes. operating modes.
*/ */
nxagentInitDefaultEventMask(); nxagentInitDefaultEventMask();
...@@ -1290,9 +1266,8 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. ...@@ -1290,9 +1266,8 @@ FIXME: Use of nxagentParentWindow is strongly deprecated.
(void) nxagentCheckForPixmapFormatsCompatibility(); (void) nxagentCheckForPixmapFormatsCompatibility();
/* /*
* Create a pixmap for each depth matching the * Create a pixmap for each depth matching the local supported
* local supported formats with format available * formats with format available on the remote display.
* on the remote display.
*/ */
nxagentSetDefaultDrawables(); nxagentSetDefaultDrawables();
...@@ -1305,16 +1280,15 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. ...@@ -1305,16 +1280,15 @@ FIXME: Use of nxagentParentWindow is strongly deprecated.
#endif #endif
/* /*
* This GC is referenced in Cursor.c. It can be * This GC is referenced in Cursor.c. It can be probably removed.
* probably removed.
*/ */
nxagentBitmapGC = XCreateGC(nxagentDisplay, nxagentDefaultDrawables[1], 0L, NULL); nxagentBitmapGC = XCreateGC(nxagentDisplay, nxagentDefaultDrawables[1], 0L, NULL);
/* /*
* Note that this "confine window" is useless at the * Note that this "confine windoqw" is useless at the moment as we
* moment as we reimplement nxagentConstrainCursor() * reimplement nxagentConstrainCursor() to skip the "constrain"
* to skip the "constrain" stuff. * stuff.
*/ */
#ifdef TEST #ifdef TEST
...@@ -1568,10 +1542,10 @@ void nxagentInitDepths(void) ...@@ -1568,10 +1542,10 @@ void nxagentInitDepths(void)
void nxagentInitPixmapFormats(void) void nxagentInitPixmapFormats(void)
{ {
/* /*
* Formats are created with no care of which are supported * Formats are created with no care of which are supported on the
* on the real display. Creating only formats supported * real display. Creating only formats supported by the remote end
* by the remote end makes troublesome handling migration * makes troublesome handling migration of session from a display to
* of session from a display to another. * another.
*/ */
nxagentNumPixmapFormats = 0; nxagentNumPixmapFormats = 0;
...@@ -1732,11 +1706,9 @@ void nxagentCloseDisplay(void) ...@@ -1732,11 +1706,9 @@ void nxagentCloseDisplay(void)
} }
/* /*
* If nxagentDoFullGeneration is true, all * If nxagentDoFullGeneration is true, all the X resources will be
* the X resources will be destroyed upon * destroyed upon closing the display connection, so there is no
* closing the display connection, so there * real need to generate additional traffic
* is no real need to generate additional
* traffic
*/ */
SAFE_free(nxagentDefaultColormaps); SAFE_free(nxagentDefaultColormaps);
...@@ -1753,8 +1725,7 @@ FIXME: Is this needed? ...@@ -1753,8 +1725,7 @@ FIXME: Is this needed?
*/ */
/* /*
* Free the image cache. This is useful * Free the image cache. This is useful for detecting memory leaks.
* for detecting memory leaks.
*/ */
if (nxagentDisplay != NULL) if (nxagentDisplay != NULL)
...@@ -1836,14 +1807,11 @@ void nxagentBackupDisplayInfo(void) ...@@ -1836,14 +1807,11 @@ void nxagentBackupDisplayInfo(void)
} }
/* /*
* Since we need the display structure * Since we need the display structure in order to behave correctly
* in order to behave correctly when no X * when no X connection is available, we must always have a good
* connection is available, we must always * display record. It can be discarded only when a new X connection
* have a good display record. * is available, so we store it in order to destroy whenever the
* It can be discarded only when a new X * reconnection succeeds.
* connection is available, so we store it
* in order to destroy whenever the recon-
* nection succed.
*/ */
nxagentDisplayBackup = nxagentDisplay; nxagentDisplayBackup = nxagentDisplay;
...@@ -1925,9 +1893,8 @@ void nxagentDisconnectDisplay(void) ...@@ -1925,9 +1893,8 @@ void nxagentDisconnectDisplay(void)
case GOT_VISUAL_INFO: case GOT_VISUAL_INFO:
case OPENED: case OPENED:
/* /*
* Actually we need the nxagentDisplay * Actually we need the nxagentDisplay structure in order to let
* structure in order to let the agent * the agent go when no X connection is available.
* go when no X connection is available.
*/ */
if (nxagentDisplay && if (nxagentDisplay &&
...@@ -2328,10 +2295,9 @@ static int nxagentInitAndCheckVisuals(int flexibility) ...@@ -2328,10 +2295,9 @@ static int nxagentInitAndCheckVisuals(int flexibility)
if (nxagentCompareVisuals(nxagentVisuals[i], viList[n]) == 1) if (nxagentCompareVisuals(nxagentVisuals[i], viList[n]) == 1)
{ {
/* /*
FIXME: Should the visual be ignored in this case? FIXME: Should the visual be ignored in this case? We can flag the
We can flag the visuals with inverted masks, visuals with inverted masks, and use this information to switch
and use this information to switch the masks the masks when contacting the remote X server.
when contacting the remote X server.
*/ */
if (nxagentVisuals[i].red_mask == viList[n].blue_mask && if (nxagentVisuals[i].red_mask == viList[n].blue_mask &&
nxagentVisuals[i].blue_mask == viList[n].red_mask) nxagentVisuals[i].blue_mask == viList[n].red_mask)
...@@ -2502,9 +2468,8 @@ Bool nxagentReconnectDisplay(void *p0) ...@@ -2502,9 +2468,8 @@ Bool nxagentReconnectDisplay(void *p0)
DefaultScreenOfDisplay(nxagentDisplay)); DefaultScreenOfDisplay(nxagentDisplay));
/* /*
* After processing the arguments all the * After processing the arguments all the timeout values have been
* timeout values have been set. Now we * set. Now we have to change the screen-saver timeout.
* have to change the screen-saver timeout.
*/ */
nxagentSetScreenSaverTime(); nxagentSetScreenSaverTime();
...@@ -2585,8 +2550,7 @@ Bool nxagentReconnectDisplay(void *p0) ...@@ -2585,8 +2550,7 @@ Bool nxagentReconnectDisplay(void *p0)
SAFE_XFree(nxagentRemotePixmapFormats); SAFE_XFree(nxagentRemotePixmapFormats);
/* /*
* Check if all the required pixmap * Check if all the required pixmap formats are supported.
* formats are supported.
*/ */
nxagentInitPixmapFormats(); nxagentInitPixmapFormats();
...@@ -2602,9 +2566,8 @@ Bool nxagentReconnectDisplay(void *p0) ...@@ -2602,9 +2566,8 @@ Bool nxagentReconnectDisplay(void *p0)
reconnectDisplayState = GOT_PIXMAP_FORMAT_LIST; reconnectDisplayState = GOT_PIXMAP_FORMAT_LIST;
/* /*
* Create a pixmap for each depth matching the * Create a pixmap for each depth matching the local supported
* local supported formats with format available * formats with format available on the remote display.
* on the remote display.
*/ */
nxagentSetDefaultDrawables(); nxagentSetDefaultDrawables();
...@@ -2632,12 +2595,11 @@ Bool nxagentReconnectDisplay(void *p0) ...@@ -2632,12 +2595,11 @@ Bool nxagentReconnectDisplay(void *p0)
nxagentWhitePixel = WhitePixel(nxagentDisplay, DefaultScreen(nxagentDisplay)); nxagentWhitePixel = WhitePixel(nxagentDisplay, DefaultScreen(nxagentDisplay));
/* /*
* Initialize the agent's event mask that will be requested * Initialize the agent's event mask that will be requested for the
* for the root or all the top level windows. If the nested * root or all the top level windows. If the nested window is a
* window is a child of an existing window we will need to * child of an existing window we will need to receive
* receive StructureNotify events. If we are going to manage * StructureNotify events. If we are going to manage the changes in
* the changes in root window's visibility we'll also need * root window's visibility we'll also need VisibilityChange events.
* VisibilityChange events.
*/ */
nxagentInitDefaultEventMask(); nxagentInitDefaultEventMask();
...@@ -2667,8 +2629,7 @@ Bool nxagentReconnectDisplay(void *p0) ...@@ -2667,8 +2629,7 @@ Bool nxagentReconnectDisplay(void *p0)
useXpmIcon = nxagentMakeIcon(nxagentDisplay, &nxagentIconPixmap, &nxagentIconShape); useXpmIcon = nxagentMakeIcon(nxagentDisplay, &nxagentIconPixmap, &nxagentIconShape);
/* /*
* All went fine. We can continue * All went fine. We can continue handling our clients.
* handling our clients.
*/ */
reconnectDisplayState = EVERYTHING_DONE; reconnectDisplayState = EVERYTHING_DONE;
...@@ -2701,10 +2662,9 @@ void nxagentRemoveXConnection(void) ...@@ -2701,10 +2662,9 @@ void nxagentRemoveXConnection(void)
} }
/* /*
* Force an I/O error and wait until the NX trans- * Force an I/O error and wait until the NX transport is gone. It must
* port is gone. It must be called before suspend- * be called before suspending or terminating a session to ensure that
* ing or terminating a session to ensure that the * the NX transport is terminated first.
* NX transport is terminated first.
*/ */
void nxagentWaitDisplay(void) void nxagentWaitDisplay(void)
...@@ -2742,8 +2702,7 @@ void nxagentWaitDisplay(void) ...@@ -2742,8 +2702,7 @@ void nxagentWaitDisplay(void)
#endif #endif
/* /*
* Be sure the signal handlers are * Be sure the signal handlers are in a known state.
* in a known state.
*/ */
nxagentResetSignalHandlers(); nxagentResetSignalHandlers();
...@@ -2760,9 +2719,9 @@ void nxagentWaitDisplay(void) ...@@ -2760,9 +2719,9 @@ void nxagentWaitDisplay(void)
void nxagentAbortDisplay(void) void nxagentAbortDisplay(void)
{ {
/* /*
* Be sure the X server socket in .X11-unix is * Be sure the X server socket in .X11-unix is deleted otherwise
* deleted otherwise other users may to become * other users may to become unable to run a session on the same
* unable to run a session on the same display. * display.
*/ */
#ifdef TEST #ifdef TEST
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment