Unverified Commit a261b724 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/code_cleanup' into 3.6.x

parents 0e2b7479 adca0cc9
...@@ -46,19 +46,13 @@ int nxagentCheckBinder(int argc, char *argv[], int i) ...@@ -46,19 +46,13 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
{ {
if (++i < argc) if (++i < argc)
{ {
char *display; char *display = argv[i];
char *found;
int port;
display = argv[i];
/* /*
* Check if a display specification follows * Check if a display specification follows the -B switch.
* the -B switch.
*/ */
found = rindex(display, ':'); char *found = rindex(display, ':');
if (found == NULL || *(found + 1) == '\0' || if (found == NULL || *(found + 1) == '\0' ||
isdigit(*(found + 1)) == 0) isdigit(*(found + 1)) == 0)
...@@ -69,7 +63,7 @@ int nxagentCheckBinder(int argc, char *argv[], int i) ...@@ -69,7 +63,7 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
return 0; return 0;
} }
port = atoi(found + 1); int port = atoi(found + 1);
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentCheckBinder: Identified agent display port [%d].\n", fprintf(stderr, "nxagentCheckBinder: Identified agent display port [%d].\n",
...@@ -78,8 +72,8 @@ int nxagentCheckBinder(int argc, char *argv[], int i) ...@@ -78,8 +72,8 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
/* /*
* The NX options must be specified in the DISPLAY * The NX options must be specified in the DISPLAY
* environment. Check if the display specified on * environment. Check if the display specified on the command line
* the command line matches the NX virtual display. * matches the NX virtual display.
*/ */
display = getenv("DISPLAY"); display = getenv("DISPLAY");
...@@ -108,8 +102,8 @@ int nxagentCheckBinder(int argc, char *argv[], int i) ...@@ -108,8 +102,8 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
#endif #endif
/* /*
* Save the proxy options. They will be later * Save the proxy options. They will be later used to create the
* used to create the transport. * transport.
*/ */
nxagentChangeOption(Rootless, False); nxagentChangeOption(Rootless, False);
...@@ -117,10 +111,9 @@ int nxagentCheckBinder(int argc, char *argv[], int i) ...@@ -117,10 +111,9 @@ int nxagentCheckBinder(int argc, char *argv[], int i)
nxagentChangeOption(Binder, True); nxagentChangeOption(Binder, True);
/* /*
* FIXME: This now points to the buffer that was * FIXME: This now points to the buffer that was returned by
* returned by getenv(). It is to be decided how * getenv(). It is to be decided how to handle the values of type
* to handle the values of type string in the * string in the Options repository.
* Options repository.
*/ */
nxagentChangeOption(BinderOptions, display); nxagentChangeOption(BinderOptions, display);
......
...@@ -115,4 +115,3 @@ nxagentFourByteSwap(unsigned char *buf, int nbytes) ...@@ -115,4 +115,3 @@ nxagentFourByteSwap(unsigned char *buf, int nbytes)
buf[2] = c; buf[2] = c;
} }
} }
...@@ -54,8 +54,7 @@ ...@@ -54,8 +54,7 @@
#include "Utils.h" #include "Utils.h"
/* /*
* Need to include this after the stub * Need to include this after the stub definition of GC in Agent.h.
* definition of GC in Agent.h.
*/ */
#include "compext/Compext.h" #include "compext/Compext.h"
...@@ -70,22 +69,20 @@ ...@@ -70,22 +69,20 @@
#undef DEBUG #undef DEBUG
/* /*
* Returns the last signal delivered * Returns the last signal delivered to the process.
* to the process.
*/ */
extern int _X11TransSocketCheckSignal(void); extern int _X11TransSocketCheckSignal(void);
/* /*
* Time in milliseconds of first iteration * Time in milliseconds of first iteration through the dispatcher.
* through the dispatcher.
*/ */
unsigned long nxagentStartTime = -1; unsigned long nxagentStartTime = -1;
/* /*
* If defined, add a function checking if we * If defined, add a function checking if we need a null timeout after
* need a null timeout after a client wakeup. * a client wakeup.
*/ */
#undef CHECK_RESTARTED_CLIENTS #undef CHECK_RESTARTED_CLIENTS
...@@ -103,8 +100,8 @@ void nxagentCheckRestartedClients(struct timeval **timeout); ...@@ -103,8 +100,8 @@ void nxagentCheckRestartedClients(struct timeval **timeout);
int nxagentClientPrivateIndex; int nxagentClientPrivateIndex;
/* /*
* The master nxagent holds in nxagentShadowCounter * The master nxagent holds in nxagentShadowCounter the number of
* the number of shadow nxagents connected to itself. * shadow nxagents connected to itself.
*/ */
int nxagentShadowCounter = 0; int nxagentShadowCounter = 0;
...@@ -120,8 +117,8 @@ void nxagentInitClientPrivates(ClientPtr client) ...@@ -120,8 +117,8 @@ void nxagentInitClientPrivates(ClientPtr client)
} }
/* /*
* Guess the running application based on the * Guess the running application based on the properties attached to
* properties attached to its main window. * its main window.
*/ */
void nxagentGuessClientHint(ClientPtr client, Atom property, char *data) void nxagentGuessClientHint(ClientPtr client, Atom property, char *data)
...@@ -199,8 +196,8 @@ void nxagentGuessShadowHint(ClientPtr client, Atom property) ...@@ -199,8 +196,8 @@ void nxagentGuessShadowHint(ClientPtr client, Atom property)
#endif #endif
/* /*
* From this moment on we ignore the visibility * From this moment on we ignore the visibility checks to keep
* checks to keep the windows updated. * the windows updated.
*/ */
nxagentChangeOption(IgnoreVisibility, 1); nxagentChangeOption(IgnoreVisibility, 1);
...@@ -210,7 +207,6 @@ void nxagentGuessShadowHint(ClientPtr client, Atom property) ...@@ -210,7 +207,6 @@ void nxagentGuessShadowHint(ClientPtr client, Atom property)
void nxagentCheckIfShadowAgent(ClientPtr client) void nxagentCheckIfShadowAgent(ClientPtr client)
{ {
if (nxagentClientPriv(client) -> clientHint == NXAGENT_SHADOW) if (nxagentClientPriv(client) -> clientHint == NXAGENT_SHADOW)
{ {
#ifdef TEST #ifdef TEST
...@@ -234,14 +230,11 @@ void nxagentCheckIfShadowAgent(ClientPtr client) ...@@ -234,14 +230,11 @@ void nxagentCheckIfShadowAgent(ClientPtr client)
nxagentShadowCounter); nxagentShadowCounter);
#endif #endif
if (nxagentShadowCounter == 0) if (nxagentShadowCounter == 0)
{ {
/* /*
* The last shadow nxagent has been detached * The last shadow nxagent has been detached from master
* from master nxagent. * nxagent. The master nxagent could do some action here.
* The master nxagent could do some action
* here.
*/ */
#ifdef TEST #ifdef TEST
...@@ -255,13 +248,11 @@ void nxagentCheckIfShadowAgent(ClientPtr client) ...@@ -255,13 +248,11 @@ void nxagentCheckIfShadowAgent(ClientPtr client)
void nxagentWakeupByReconnect(void) void nxagentWakeupByReconnect(void)
{ {
int i;
#ifdef TEST #ifdef TEST
fprintf(stderr, "++++++nxagentWakeupByReconnect: Going to wakeup all clients.\n"); fprintf(stderr, "++++++nxagentWakeupByReconnect: Going to wakeup all clients.\n");
#endif #endif
for (i = 1; i < currentMaxClients; i++) for (int i = 1; i < currentMaxClients; i++)
{ {
if (clients[i] != NULL) if (clients[i] != NULL)
{ {
...@@ -343,8 +334,7 @@ void nxagentWaitWakeupBySplit(ClientPtr client) ...@@ -343,8 +334,7 @@ void nxagentWaitWakeupBySplit(ClientPtr client)
#endif #endif
/* /*
* Be sure we intercept an I/O error * Be sure we intercept an I/O error as well as an interrupt.
* as well as an interrupt.
*/ */
#ifdef USE_FINISH_SPLIT #ifdef USE_FINISH_SPLIT
...@@ -358,11 +348,9 @@ void nxagentWaitWakeupBySplit(ClientPtr client) ...@@ -358,11 +348,9 @@ void nxagentWaitWakeupBySplit(ClientPtr client)
for (;;) for (;;)
{ {
/* /*
* Can we handle all the possible events here * Can we handle all the possible events here or we need to select
* or we need to select only the split events? * only the split events? Handling all the possible events would
* Handling all the possible events would pre- * preempt the queue and make a better use of the link.
* empt the queue and make a better use of the
* link.
*/ */
#ifdef WAIT_ALL_EVENTS #ifdef WAIT_ALL_EVENTS
...@@ -407,9 +395,9 @@ void nxagentWaitWakeupBySplit(ClientPtr client) ...@@ -407,9 +395,9 @@ void nxagentWaitWakeupBySplit(ClientPtr client)
int nxagentSuspendBySplit(ClientPtr client) int nxagentSuspendBySplit(ClientPtr client)
{ {
/* /*
FIXME: Should record a serial number for the client, so that FIXME: Should record a serial number for the client, so that the
the client is not restarted because of an end of split client is not restarted because of an end of split of a
of a previous client with the same index. previous client with the same index.
*/ */
if (client -> index < MAX_CONNECTIONS) if (client -> index < MAX_CONNECTIONS)
{ {
...@@ -453,9 +441,9 @@ FIXME: Should record a serial number for the client, so that ...@@ -453,9 +441,9 @@ FIXME: Should record a serial number for the client, so that
int nxagentWakeupBySplit(ClientPtr client) int nxagentWakeupBySplit(ClientPtr client)
{ {
/* /*
FIXME: Should record a serial number for the client, so that FIXME: Should record a serial number for the client, so that the
the client is not restarted because of the end of the client is not restarted because of the end of the split for a
split for a previous client with the same index. previous client with the same index.
*/ */
if (client -> index < MAX_CONNECTIONS) if (client -> index < MAX_CONNECTIONS)
{ {
...@@ -498,16 +486,13 @@ void nxagentCheckRestartedClients(struct timeval **timeout) ...@@ -498,16 +486,13 @@ void nxagentCheckRestartedClients(struct timeval **timeout)
{ {
static struct timeval zero; static struct timeval zero;
int i;
/* /*
* If any of the restarted clients had requests * If any of the restarted clients had requests in input we'll need
* in input we'll need to enter the select with * to enter the select with a null timeout, or we will block until
* a null timeout, or we will block until any * any other client becomes available.
* 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 && if (clients[i] != NULL && clients[i] -> osPrivate != NULL &&
nxagentNeedWakeup(clients[i]) == 0) nxagentNeedWakeup(clients[i]) == 0)
...@@ -542,5 +527,4 @@ void nxagentCheckRestartedClients(struct timeval **timeout) ...@@ -542,5 +527,4 @@ void nxagentCheckRestartedClients(struct timeval **timeout)
} }
} }
} }
#endif #endif
...@@ -296,12 +296,10 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) ...@@ -296,12 +296,10 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
*/ */
if (icws.numWindows) if (icws.numWindows)
{ {
WindowPtr pWin;
Visual *visual;
ColormapPtr pCmap; ColormapPtr pCmap;
pWin = nxagentWindowPtr(icws.windows[0]); WindowPtr pWin = nxagentWindowPtr(icws.windows[0]);
visual = nxagentVisualFromID(pScreen, wVisual(pWin)); Visual *visual = nxagentVisualFromID(pScreen, wVisual(pWin));
if (visual == nxagentDefaultVisual(pScreen)) if (visual == nxagentDefaultVisual(pScreen))
pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin),
...@@ -380,9 +378,7 @@ void nxagentDirectUninstallColormaps(ScreenPtr pScreen) ...@@ -380,9 +378,7 @@ void nxagentDirectUninstallColormaps(ScreenPtr pScreen)
int n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); int n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
ColormapPtr pCmap; ColormapPtr pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP);
pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP);
if (pCmap) if (pCmap)
XUninstallColormap(nxagentDisplay, nxagentColormap(pCmap)); XUninstallColormap(nxagentDisplay, nxagentColormap(pCmap));
} }
......
...@@ -44,8 +44,7 @@ ...@@ -44,8 +44,7 @@
#undef DEBUG #undef DEBUG
/* /*
* Set if the composite extension is supported * Set if the composite extension is supported by the remote display.
* by the remote display.
*/ */
int nxagentCompositeEnable = UNDEFINED; int nxagentCompositeEnable = UNDEFINED;
...@@ -53,8 +52,7 @@ int nxagentCompositeEnable = UNDEFINED; ...@@ -53,8 +52,7 @@ int nxagentCompositeEnable = UNDEFINED;
void nxagentCompositeExtensionInit(void) void nxagentCompositeExtensionInit(void)
{ {
/* /*
* Set the flag only if the initialization * Set the flag only if the initialization completes.
* completes.
*/ */
nxagentCompositeEnable = 0; nxagentCompositeEnable = 0;
...@@ -70,8 +68,8 @@ void nxagentCompositeExtensionInit(void) ...@@ -70,8 +68,8 @@ void nxagentCompositeExtensionInit(void)
if (XCompositeQueryExtension(nxagentDisplay, &eventBase, &errorBase) == 1) if (XCompositeQueryExtension(nxagentDisplay, &eventBase, &errorBase) == 1)
{ {
/* /*
* At the moment we don't need to care * At the moment we don't need to care the version of the
* the version of the extension. * extension.
*/ */
#ifdef TEST #ifdef TEST
...@@ -117,8 +115,6 @@ void nxagentCompositeExtensionInit(void) ...@@ -117,8 +115,6 @@ void nxagentCompositeExtensionInit(void)
void nxagentRedirectDefaultWindows(void) void nxagentRedirectDefaultWindows(void)
{ {
int i;
if (nxagentOption(Rootless) == 1 || if (nxagentOption(Rootless) == 1 ||
nxagentCompositeEnable == 0) nxagentCompositeEnable == 0)
{ {
...@@ -131,7 +127,7 @@ void nxagentRedirectDefaultWindows(void) ...@@ -131,7 +127,7 @@ void nxagentRedirectDefaultWindows(void)
return; return;
} }
for (i = 0; i < screenInfo.numScreens; i++) for (int i = 0; i < screenInfo.numScreens; i++)
{ {
WindowPtr pWin = screenInfo.screens[i]->root; WindowPtr pWin = screenInfo.screens[i]->root;
...@@ -143,13 +139,12 @@ void nxagentRedirectDefaultWindows(void) ...@@ -143,13 +139,12 @@ void nxagentRedirectDefaultWindows(void)
#endif #endif
/* /*
* When trying to redirect only the top level window, * When trying to redirect only the top level window, and not the
* and not the subwindows, we incur in a strange be- * subwindows, we incur in a strange be- haviour. The top level is
* haviour. The top level is unmapped, mapped, unmap- * unmapped, mapped, unmap- ped and then reparented. This at first
* ped and then reparented. This at first makes the * makes the agent think that the window manager is gone, then the
* agent think that the window manager is gone, then * agent window disappears. To make thinks even more weird, this
* the agent window disappears. To make thinks even * happens only at reconnection.
* more weird, this happens only at reconnection.
*/ */
XCompositeRedirectSubwindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], XCompositeRedirectSubwindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
......
...@@ -198,7 +198,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -198,7 +198,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_KILL_SESSION_TYPE; type = DIALOG_KILL_SESSION_TYPE;
local = DIALOG_KILL_SESSION_LOCAL; local = DIALOG_KILL_SESSION_LOCAL;
pid = &nxagentKillDialogPid; pid = &nxagentKillDialogPid;
break; break;
} }
case DIALOG_SUSPEND_SESSION: case DIALOG_SUSPEND_SESSION:
...@@ -207,7 +206,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -207,7 +206,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_SUSPEND_SESSION_TYPE; type = DIALOG_SUSPEND_SESSION_TYPE;
local = DIALOG_SUSPEND_SESSION_LOCAL; local = DIALOG_SUSPEND_SESSION_LOCAL;
pid = &nxagentSuspendDialogPid; pid = &nxagentSuspendDialogPid;
break; break;
} }
case DIALOG_ROOTLESS: case DIALOG_ROOTLESS:
...@@ -216,7 +214,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -216,7 +214,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_ROOTLESS_TYPE; type = DIALOG_ROOTLESS_TYPE;
local = DIALOG_ROOTLESS_LOCAL; local = DIALOG_ROOTLESS_LOCAL;
pid = &nxagentRootlessDialogPid; pid = &nxagentRootlessDialogPid;
break; break;
} }
case DIALOG_PULLDOWN: case DIALOG_PULLDOWN:
...@@ -226,7 +223,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -226,7 +223,6 @@ void nxagentLaunchDialog(DialogType dialogType)
local = DIALOG_PULLDOWN_LOCAL; local = DIALOG_PULLDOWN_LOCAL;
pid = &nxagentPulldownDialogPid; pid = &nxagentPulldownDialogPid;
window = nxagentPulldownWindow; window = nxagentPulldownWindow;
break; break;
} }
case DIALOG_FONT_REPLACEMENT: case DIALOG_FONT_REPLACEMENT:
...@@ -235,7 +231,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -235,7 +231,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_FONT_REPLACEMENT_TYPE; type = DIALOG_FONT_REPLACEMENT_TYPE;
local = DIALOG_FONT_REPLACEMENT_LOCAL; local = DIALOG_FONT_REPLACEMENT_LOCAL;
pid = &nxagentFontsReplacementDialogPid; pid = &nxagentFontsReplacementDialogPid;
break; break;
} }
case DIALOG_FAILED_RECONNECTION: case DIALOG_FAILED_RECONNECTION:
...@@ -244,7 +239,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -244,7 +239,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_FAILED_RECONNECTION_TYPE; type = DIALOG_FAILED_RECONNECTION_TYPE;
local = DIALOG_FAILED_RECONNECTION_LOCAL; local = DIALOG_FAILED_RECONNECTION_LOCAL;
pid = &nxagentFailedReconnectionDialogPid; pid = &nxagentFailedReconnectionDialogPid;
break; break;
} }
case DIALOG_ENABLE_DESKTOP_RESIZE_MODE: case DIALOG_ENABLE_DESKTOP_RESIZE_MODE:
...@@ -253,7 +247,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -253,7 +247,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_TYPE; type = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_TYPE;
local = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_LOCAL; local = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_LOCAL;
pid = &nxagentEnableRandRModeDialogPid; pid = &nxagentEnableRandRModeDialogPid;
break; break;
} }
case DIALOG_DISABLE_DESKTOP_RESIZE_MODE: case DIALOG_DISABLE_DESKTOP_RESIZE_MODE:
...@@ -262,7 +255,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -262,7 +255,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_TYPE; type = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_TYPE;
local = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_LOCAL; local = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_LOCAL;
pid = &nxagentDisableRandRModeDialogPid; pid = &nxagentDisableRandRModeDialogPid;
break; break;
} }
case DIALOG_ENABLE_DEFER_MODE: case DIALOG_ENABLE_DEFER_MODE:
...@@ -271,7 +263,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -271,7 +263,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_ENABLE_DEFER_MODE_TYPE; type = DIALOG_ENABLE_DEFER_MODE_TYPE;
local = DIALOG_ENABLE_DEFER_MODE_LOCAL; local = DIALOG_ENABLE_DEFER_MODE_LOCAL;
pid = &nxagentEnableDeferModePid; pid = &nxagentEnableDeferModePid;
break; break;
} }
case DIALOG_DISABLE_DEFER_MODE: case DIALOG_DISABLE_DEFER_MODE:
...@@ -280,7 +271,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -280,7 +271,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_DISABLE_DEFER_MODE_TYPE; type = DIALOG_DISABLE_DEFER_MODE_TYPE;
local = DIALOG_DISABLE_DEFER_MODE_LOCAL; local = DIALOG_DISABLE_DEFER_MODE_LOCAL;
pid = &nxagentDisableDeferModePid; pid = &nxagentDisableDeferModePid;
break; break;
} }
case DIALOG_ENABLE_AUTOGRAB_MODE: case DIALOG_ENABLE_AUTOGRAB_MODE:
...@@ -289,7 +279,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -289,7 +279,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_ENABLE_AUTOGRAB_MODE_TYPE; type = DIALOG_ENABLE_AUTOGRAB_MODE_TYPE;
local = DIALOG_ENABLE_AUTOGRAB_MODE_LOCAL; local = DIALOG_ENABLE_AUTOGRAB_MODE_LOCAL;
pid = &nxagentEnableAutograbModePid; pid = &nxagentEnableAutograbModePid;
break; break;
} }
case DIALOG_DISABLE_AUTOGRAB_MODE: case DIALOG_DISABLE_AUTOGRAB_MODE:
...@@ -298,7 +287,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -298,7 +287,6 @@ void nxagentLaunchDialog(DialogType dialogType)
type = DIALOG_DISABLE_AUTOGRAB_MODE_TYPE; type = DIALOG_DISABLE_AUTOGRAB_MODE_TYPE;
local = DIALOG_DISABLE_AUTOGRAB_MODE_LOCAL; local = DIALOG_DISABLE_AUTOGRAB_MODE_LOCAL;
pid = &nxagentDisableAutograbModePid; pid = &nxagentDisableAutograbModePid;
break; break;
} }
default: default:
...@@ -306,7 +294,6 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -306,7 +294,6 @@ void nxagentLaunchDialog(DialogType dialogType)
#ifdef WARNING #ifdef WARNING
fprintf(stderr, "nxagentLaunchDialog: Unknown Dialog type [%d].\n", dialogType); fprintf(stderr, "nxagentLaunchDialog: Unknown Dialog type [%d].\n", dialogType);
#endif #endif
return; return;
} }
} }
...@@ -325,8 +312,7 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -325,8 +312,7 @@ void nxagentLaunchDialog(DialogType dialogType)
} }
/* /*
* We don't want to receive SIGCHLD * We don't want to receive SIGCHLD before we store the child pid.
* before we store the child pid.
*/ */
sigemptyset(&set); sigemptyset(&set);
...@@ -346,8 +332,7 @@ void nxagentLaunchDialog(DialogType dialogType) ...@@ -346,8 +332,7 @@ void nxagentLaunchDialog(DialogType dialogType)
dialogDisplay[0] = '\0'; dialogDisplay[0] = '\0';
/* /*
* Restore the previous set of * Restore the previous set of blocked signal.
* blocked signal.
*/ */
sigprocmask(SIG_SETMASK, &oldSet, NULL); sigprocmask(SIG_SETMASK, &oldSet, NULL);
...@@ -385,17 +370,16 @@ void nxagentFailedReconnectionDialog(int alert, char *error) ...@@ -385,17 +370,16 @@ void nxagentFailedReconnectionDialog(int alert, char *error)
NXTransAlert(alert, NX_ALERT_REMOTE); NXTransAlert(alert, NX_ALERT_REMOTE);
/* /*
* Make it possible to interrupt the * Make it possible to interrupt the loop with a signal.
* loop with a signal.
*/ */
while (NXDisplayError(nxagentDisplay) == 0 && while (NXDisplayError(nxagentDisplay) == 0 &&
NXTransRunning(NX_FD_ANY) == 1) NXTransRunning(NX_FD_ANY) == 1)
{ {
struct timeval timeout; struct timeval timeout = {
.tv_sec = 30,
timeout.tv_sec = 30; .tv_usec = 0,
timeout.tv_usec = 0; };
NXTransContinue(&timeout); NXTransContinue(&timeout);
} }
...@@ -477,73 +461,61 @@ void nxagentTerminateDialog(DialogType type) ...@@ -477,73 +461,61 @@ void nxagentTerminateDialog(DialogType type)
case DIALOG_KILL_SESSION: case DIALOG_KILL_SESSION:
{ {
pid = nxagentKillDialogPid; pid = nxagentKillDialogPid;
break; break;
} }
case DIALOG_SUSPEND_SESSION: case DIALOG_SUSPEND_SESSION:
{ {
pid = nxagentSuspendDialogPid; pid = nxagentSuspendDialogPid;
break; break;
} }
case DIALOG_ROOTLESS: case DIALOG_ROOTLESS:
{ {
pid = nxagentRootlessDialogPid; pid = nxagentRootlessDialogPid;
break; break;
} }
case DIALOG_PULLDOWN: case DIALOG_PULLDOWN:
{ {
pid = nxagentPulldownDialogPid; pid = nxagentPulldownDialogPid;
break; break;
} }
case DIALOG_FONT_REPLACEMENT: case DIALOG_FONT_REPLACEMENT:
{ {
pid = nxagentFontsReplacementDialogPid; pid = nxagentFontsReplacementDialogPid;
break; break;
} }
case DIALOG_FAILED_RECONNECTION: case DIALOG_FAILED_RECONNECTION:
{ {
pid = nxagentFailedReconnectionDialogPid; pid = nxagentFailedReconnectionDialogPid;
break; break;
} }
case DIALOG_ENABLE_DESKTOP_RESIZE_MODE: case DIALOG_ENABLE_DESKTOP_RESIZE_MODE:
{ {
pid = nxagentEnableRandRModeDialogPid; pid = nxagentEnableRandRModeDialogPid;
break; break;
} }
case DIALOG_DISABLE_DESKTOP_RESIZE_MODE: case DIALOG_DISABLE_DESKTOP_RESIZE_MODE:
{ {
pid = nxagentDisableRandRModeDialogPid; pid = nxagentDisableRandRModeDialogPid;
break; break;
} }
case DIALOG_ENABLE_DEFER_MODE: case DIALOG_ENABLE_DEFER_MODE:
{ {
pid = nxagentEnableDeferModePid; pid = nxagentEnableDeferModePid;
break; break;
} }
case DIALOG_DISABLE_DEFER_MODE: case DIALOG_DISABLE_DEFER_MODE:
{ {
pid = nxagentDisableDeferModePid; pid = nxagentDisableDeferModePid;
break; break;
} }
case DIALOG_ENABLE_AUTOGRAB_MODE: case DIALOG_ENABLE_AUTOGRAB_MODE:
{ {
pid = nxagentEnableAutograbModePid; pid = nxagentEnableAutograbModePid;
break; break;
} }
case DIALOG_DISABLE_AUTOGRAB_MODE: case DIALOG_DISABLE_AUTOGRAB_MODE:
{ {
pid = nxagentDisableAutograbModePid; pid = nxagentDisableAutograbModePid;
break; break;
} }
default: default:
...@@ -551,7 +523,6 @@ void nxagentTerminateDialog(DialogType type) ...@@ -551,7 +523,6 @@ void nxagentTerminateDialog(DialogType type)
#ifdef WARNING #ifdef WARNING
fprintf(stderr, "nxagentTerminateDialog: Unknown dialog type [%d].\n", type); fprintf(stderr, "nxagentTerminateDialog: Unknown dialog type [%d].\n", type);
#endif #endif
return; return;
} }
} }
...@@ -577,13 +548,11 @@ void nxagentTerminateDialog(DialogType type) ...@@ -577,13 +548,11 @@ void nxagentTerminateDialog(DialogType type)
void nxagentTerminateDialogs(void) void nxagentTerminateDialogs(void)
{ {
DialogType type;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentTerminateDialogs: Terminating all the running dialogs.\n"); fprintf(stderr, "nxagentTerminateDialogs: Terminating all the running dialogs.\n");
#endif #endif
for (type = DIALOG_FIRST_TAG; type < DIALOG_LAST_TAG; type++) for (DialogType type = DIALOG_FIRST_TAG; type < DIALOG_LAST_TAG; type++)
{ {
nxagentTerminateDialog(type); nxagentTerminateDialog(type);
} }
......
...@@ -325,16 +325,13 @@ void nxagentEndRedirectToClientsLog(void) ...@@ -325,16 +325,13 @@ void nxagentEndRedirectToClientsLog(void)
char *nxagentGetHomePath(void) char *nxagentGetHomePath(void)
{ {
char *homeEnv;
char *homePath;
if (*nxagentHomeDir == '\0') if (*nxagentHomeDir == '\0')
{ {
/* /*
* Check the NX_HOME environment. * Check the NX_HOME environment.
*/ */
homeEnv = getenv("NX_HOME"); char *homeEnv = getenv("NX_HOME");
if (homeEnv == NULL || *homeEnv == '\0') if (homeEnv == NULL || *homeEnv == '\0')
{ {
...@@ -369,7 +366,7 @@ char *nxagentGetHomePath(void) ...@@ -369,7 +366,7 @@ char *nxagentGetHomePath(void)
#endif #endif
} }
homePath = strdup(nxagentHomeDir); char *homePath = strdup(nxagentHomeDir);
if (homePath == NULL) if (homePath == NULL)
{ {
...@@ -385,19 +382,13 @@ char *nxagentGetHomePath(void) ...@@ -385,19 +382,13 @@ char *nxagentGetHomePath(void)
char *nxagentGetRootPath(void) char *nxagentGetRootPath(void)
{ {
char *rootEnv;
char *homeEnv;
char *rootPath;
struct stat dirStat;
if (*nxagentRootDir == '\0') if (*nxagentRootDir == '\0')
{ {
/* /*
* Check the NX_ROOT environment. * Check the NX_ROOT environment.
*/ */
rootEnv = getenv("NX_ROOT"); char *rootEnv = getenv("NX_ROOT");
if (rootEnv == NULL || *rootEnv == '\0') if (rootEnv == NULL || *rootEnv == '\0')
{ {
...@@ -406,12 +397,11 @@ char *nxagentGetRootPath(void) ...@@ -406,12 +397,11 @@ char *nxagentGetRootPath(void)
#endif #endif
/* /*
* We will determine the root NX directory * We will determine the root NX directory based on the NX_HOME
* based on the NX_HOME or HOME directory * or HOME directory settings.
* settings.
*/ */
homeEnv = nxagentGetHomePath(); char *homeEnv = nxagentGetHomePath();
if (homeEnv == NULL) if (homeEnv == NULL)
{ {
...@@ -443,6 +433,7 @@ char *nxagentGetRootPath(void) ...@@ -443,6 +433,7 @@ char *nxagentGetRootPath(void)
* Create the NX root directory. * Create the NX root directory.
*/ */
struct stat dirStat;
if ((stat(nxagentRootDir, &dirStat) == -1) && (errno == ENOENT)) if ((stat(nxagentRootDir, &dirStat) == -1) && (errno == ENOENT))
{ {
if (mkdir(nxagentRootDir, 0777) < 0 && (errno != EEXIST)) if (mkdir(nxagentRootDir, 0777) < 0 && (errno != EEXIST))
...@@ -478,7 +469,7 @@ char *nxagentGetRootPath(void) ...@@ -478,7 +469,7 @@ char *nxagentGetRootPath(void)
} }
rootPath = strdup(nxagentRootDir); char *rootPath = strdup(nxagentRootDir);
if (rootPath == NULL) if (rootPath == NULL)
{ {
...@@ -494,19 +485,12 @@ char *nxagentGetRootPath(void) ...@@ -494,19 +485,12 @@ char *nxagentGetRootPath(void)
char *nxagentGetSessionPath(void) char *nxagentGetSessionPath(void)
{ {
char *rootPath;
char *sessionPath;
struct stat dirStat;
if (*nxagentSessionDir == '\0') if (*nxagentSessionDir == '\0')
{ {
/* /*
* If nxagentSessionId does not exist we * If nxagentSessionId does not exist we assume that the
* assume that the sessionPath cannot be * sessionPath cannot be realized and do not use the clients log
* realized and do not use the clients * file.
* log file.
*/ */
if (*nxagentSessionId == '\0') if (*nxagentSessionId == '\0')
...@@ -518,7 +502,7 @@ char *nxagentGetSessionPath(void) ...@@ -518,7 +502,7 @@ char *nxagentGetSessionPath(void)
return NULL; return NULL;
} }
rootPath = nxagentGetRootPath(); char *rootPath = nxagentGetRootPath();
if (rootPath == NULL) if (rootPath == NULL)
{ {
...@@ -544,6 +528,7 @@ char *nxagentGetSessionPath(void) ...@@ -544,6 +528,7 @@ char *nxagentGetSessionPath(void)
SAFE_free(rootPath); SAFE_free(rootPath);
struct stat dirStat;
if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT)) if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT))
{ {
if (mkdir(nxagentSessionDir, 0777) < 0 && (errno != EEXIST)) if (mkdir(nxagentSessionDir, 0777) < 0 && (errno != EEXIST))
...@@ -564,7 +549,7 @@ char *nxagentGetSessionPath(void) ...@@ -564,7 +549,7 @@ char *nxagentGetSessionPath(void)
} }
sessionPath = strdup(nxagentSessionDir); char *sessionPath = strdup(nxagentSessionDir);
if (sessionPath == NULL) if (sessionPath == NULL)
{ {
...@@ -580,7 +565,6 @@ char *nxagentGetSessionPath(void) ...@@ -580,7 +565,6 @@ char *nxagentGetSessionPath(void)
void nxagentGetClientsPath(void) void nxagentGetClientsPath(void)
{ {
if (*nxagentClientsLogName == '\0') if (*nxagentClientsLogName == '\0')
{ {
char *sessionPath = nxagentGetSessionPath(); char *sessionPath = nxagentGetSessionPath();
......
...@@ -159,8 +159,7 @@ static struct _nxagentFailedToReconnectFonts ...@@ -159,8 +159,7 @@ static struct _nxagentFailedToReconnectFonts
} nxagentFailedToReconnectFonts = {NULL, NULL, 0, 0}; } nxagentFailedToReconnectFonts = {NULL, NULL, 0, 0};
/* /*
* This is used if nxagentFullGeneration is true * This is used if nxagentFullGeneration is true in CloseDisplay().
* in CloseDisplay().
*/ */
void nxagentFreeFontCache(void) void nxagentFreeFontCache(void)
...@@ -218,8 +217,7 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) ...@@ -218,8 +217,7 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames)
} }
/* /*
* Avoid querying again the remote * Avoid querying again the remote fonts.
* fonts.
*/ */
if (nxagentRemoteFontList.length > 0) if (nxagentRemoteFontList.length > 0)
...@@ -228,13 +226,11 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) ...@@ -228,13 +226,11 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames)
} }
/* /*
* We can't retrieve the full remote font * We can't retrieve the full remote font list with a single query,
* list with a single query, because the * because the number of dashes in the pattern acts as a rule to
* number of dashes in the pattern acts as * select how to search for the font names, so the pattern '*' is
* a rule to select how to search for the * useful to retrieve the font aliases, while the other one will
* font names, so the pattern '*' is useful * select the 'real' fonts.
* to retrieve the font aliases, while the
* other one will select the 'real' fonts.
*/ */
for (int p = 0; p < patternsQt; p++) for (int p = 0; p < patternsQt; p++)
...@@ -246,8 +242,8 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) ...@@ -246,8 +242,8 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames)
#endif #endif
/* /*
* Add the ListFont request pattern to the list with * Add the ListFont request pattern to the list with the last
* the last requested maxnames. * requested maxnames.
*/ */
nxagentListRemoteAddName(searchPattern, maxNames); nxagentListRemoteAddName(searchPattern, maxNames);
...@@ -686,11 +682,10 @@ int nxagentDestroyNewFontResourceType(void * p, XID id) ...@@ -686,11 +682,10 @@ int nxagentDestroyNewFontResourceType(void * p, XID id)
#endif #endif
/* /*
FIXME: It happens that this resource had been already FIXME: It happens that this resource had been already destroyed. We
destroyed. We should verify if the same font is should verify if the same font is assigned both to the server
assigned both to the server client and another client and another client. We had a crash when freeing server
client. We had a crash when freeing server client client resources.
resources.
*/ */
if (nxagentFontPriv((FontPtr) p) != NULL) if (nxagentFontPriv((FontPtr) p) != NULL)
{ {
...@@ -706,14 +701,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -706,14 +701,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
char substFontBuf[512];; char substFontBuf[512];;
/* X Logical Font Description Conventions /* X Logical Font Description Conventions require 14 fields in the
* require 14 fields in the font names. * font names.
* *
*/ */
char *searchFields[FIELDS+1]; char *searchFields[FIELDS+1];
char *fontNameFields[FIELDS+1]; char *fontNameFields[FIELDS+1];
int i;
int j;
int numSearchFields = 0; int numSearchFields = 0;
int numFontFields = 0; int numFontFields = 0;
int weight = 0; int weight = 0;
...@@ -753,7 +746,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -753,7 +746,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
} }
else 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, "-"); numSearchFields = nxagentSplitString(nxagentRemoteFontList.list[i]->name, searchFields, FIELDS+1, "-");
...@@ -778,7 +771,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -778,7 +771,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
tempWeight = 0; tempWeight = 0;
for (j = 0; j < FIELDS; j++) for (int j = 0; j < FIELDS; j++)
{ {
if (strcasecmp(searchFields[fieldOrder[j]], fontNameFields[fieldOrder[j]]) == 0 || if (strcasecmp(searchFields[fieldOrder[j]], fontNameFields[fieldOrder[j]]) == 0 ||
strcmp(searchFields[fieldOrder[j]], "") == 0 || strcmp(searchFields[fieldOrder[j]], "") == 0 ||
...@@ -806,7 +799,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -806,7 +799,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
#endif #endif
} }
for (j = 0; j < numSearchFields; j++) for (int j = 0; j < numSearchFields; j++)
{ {
SAFE_free(searchFields[j]); SAFE_free(searchFields[j]);
} }
...@@ -823,7 +816,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -823,7 +816,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
fontStruct = nxagentLoadQueryFont(dpy, substFontBuf, pFont); fontStruct = nxagentLoadQueryFont(dpy, substFontBuf, pFont);
for (j = 0; j < numFontFields; j++) for (int j = 0; j < numFontFields; j++)
{ {
SAFE_free(fontNameFields[j]); SAFE_free(fontNameFields[j]);
} }
...@@ -833,13 +826,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -833,13 +826,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2)
{ {
nxagentPrivFont *privFont;
Bool *pBool = (Bool*)param2; Bool *pBool = (Bool*)param2;
if (pFont == NULL || !*pBool) if (pFont == NULL || !*pBool)
return; return;
privFont = nxagentFontPriv(pFont); nxagentPrivFont *privFont = nxagentFontPriv(pFont);
#ifdef NXAGENT_RECONNECT_FONT_DEBUG #ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf(stderr, "nxagentFontDisconnect: pFont %p, XID %lx\n", fprintf(stderr, "nxagentFontDisconnect: pFont %p, XID %lx\n",
...@@ -936,13 +928,12 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id) ...@@ -936,13 +928,12 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id)
static void nxagentFontReconnect(FontPtr pFont, XID param1, void * param2) static void nxagentFontReconnect(FontPtr pFont, XID param1, void * param2)
{ {
int i; int i;
nxagentPrivFont *privFont;
Bool *pBool = (Bool*)param2; Bool *pBool = (Bool*)param2;
if (pFont == NULL) if (pFont == NULL)
return; return;
privFont = nxagentFontPriv(pFont); nxagentPrivFont *privFont = nxagentFontPriv(pFont);
#ifdef NXAGENT_RECONNECT_FONT_DEBUG #ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf(stderr, "nxagentFontReconnect: pFont %p - XID %lx - name %s\n", fprintf(stderr, "nxagentFontReconnect: pFont %p - XID %lx - name %s\n",
...@@ -1067,8 +1058,7 @@ static void nxagentCleanCacheAfterReconnect(void) ...@@ -1067,8 +1058,7 @@ static void nxagentCleanCacheAfterReconnect(void)
for (j = CACHE_INDEX - 1; CACHE_FSTRUCT(j) == NULL; j--); for (j = CACHE_INDEX - 1; CACHE_FSTRUCT(j) == NULL; j--);
/* /*
* Now we can swap the two entry * Now we can swap the two entry and reduce the Cache index
* and reduce the Cache index
*/ */
swapEntryPtr = CACHE_ENTRY(i); swapEntryPtr = CACHE_ENTRY(i);
CACHE_ENTRY(i) = CACHE_ENTRY(j); CACHE_ENTRY(i) = CACHE_ENTRY(j);
...@@ -1109,9 +1099,8 @@ Bool nxagentReconnectAllFonts(void *p0) ...@@ -1109,9 +1099,8 @@ Bool nxagentReconnectAllFonts(void *p0)
#endif #endif
/* /*
* The resource type RT_NX_FONT is created on the * The resource type RT_NX_FONT is created on the server client
* server client only, so we can avoid to loop * only, so we can avoid to loop through all the clients.
* through all the clients.
*/ */
FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT,
...@@ -1341,9 +1330,8 @@ Bool nxagentDisconnectAllFonts(void) ...@@ -1341,9 +1330,8 @@ Bool nxagentDisconnectAllFonts(void)
nxagentFreeCacheBeforeReconnect(); nxagentFreeCacheBeforeReconnect();
/* /*
* The resource type RT_NX_FONT is created on the * The resource type RT_NX_FONT is created on the server client
* server client only, so we can avoid to loop * only, so we can avoid to loop through all the clients.
* through all the clients.
*/ */
FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT,
...@@ -1630,26 +1618,17 @@ int nxagentFreeFont(XFontStruct *fs) ...@@ -1630,26 +1618,17 @@ int nxagentFreeFont(XFontStruct *fs)
int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
{ {
int seplen; int seplen = strlen(sep);
int fieldlen; int len = strlen(string);
int last;
int len;
int i;
char *current;
char *next;
seplen = strlen(sep);
len = strlen(string);
current = string; char *current = string;
i = 0; int i = 0;
last = 0; int last = 0;
for (;;) for (;;)
{ {
next = NULL; char *next = NULL;
if (current < string + len) if (current < string + len)
{ {
...@@ -1662,7 +1641,7 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) ...@@ -1662,7 +1641,7 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
last = 1; last = 1;
} }
fieldlen = next - current; int fieldlen = next - current;
if (i < nfields) if (i < nfields)
{ {
...@@ -1689,8 +1668,6 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) ...@@ -1689,8 +1668,6 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
{ {
char *scalableFontName; char *scalableFontName;
const char *s;
int field;
/* FIXME: use str(n)dup()? */ /* FIXME: use str(n)dup()? */
if ((scalableFontName = malloc(strlen(fontName) + 1)) == NULL) if ((scalableFontName = malloc(strlen(fontName) + 1)) == NULL)
...@@ -1709,9 +1686,9 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) ...@@ -1709,9 +1686,9 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
goto MakeScalableFontNameError; goto MakeScalableFontNameError;
} }
s = fontName; const char *s = fontName;
field = 0; int field = 0;
while (s != NULL) while (s != NULL)
{ {
......
...@@ -89,44 +89,35 @@ is" without express or implied warranty. ...@@ -89,44 +89,35 @@ is" without express or implied warranty.
/* /*
* ProcVector array defined in tables.c. * ProcVector array defined in tables.c.
*/ */
extern int (*ProcVector[256])(ClientPtr); extern int (*ProcVector[256])(ClientPtr);
/* /*
* From the fb code. * From the fb code.
*/ */
extern int fbGCPrivateIndex; extern int fbGCPrivateIndex;
#ifdef DPMSExtension
/* /*
* Stubs for the DPMS extension. * Stubs for the DPMS extension.
*/ */
#ifdef DPMSExtension
void DPMSSet(int level); void DPMSSet(int level);
int DPMSGet(int *level); int DPMSGet(int *level);
Bool DPMSSupported(void); Bool DPMSSupported(void);
#endif #endif
/* /*
* Our error logging function. * Our error logging function.
*/ */
void OsVendorVErrorFFunction(const char *f, va_list args); void OsVendorVErrorFFunction(const char *f, va_list args);
/* /*
* True if this is a fatal error. * True if this is a fatal error.
*/ */
extern int OsVendorVErrorFFatal; extern int OsVendorVErrorFFatal;
/* /*
* Redirect the error output to a * Redirect the error output to a different file
* different file
*/ */
extern void (*OsVendorStartRedirectErrorFProc)(); extern void (*OsVendorStartRedirectErrorFProc)();
extern void (*OsVendorEndRedirectErrorFProc)(); extern void (*OsVendorEndRedirectErrorFProc)();
...@@ -136,11 +127,8 @@ void OsVendorStartRedirectErrorFFunction(); ...@@ -136,11 +127,8 @@ void OsVendorStartRedirectErrorFFunction();
void OsVendorEndRedirectErrorFFunction(); void OsVendorEndRedirectErrorFFunction();
/* /*
* Called by InitGlobals() in the * Called by InitGlobals() in the new X server tree.
* new X server tree.
*/ */
static void nxagentGrabServerCallback(CallbackListPtr *callbacks, void *data, static void nxagentGrabServerCallback(CallbackListPtr *callbacks, void *data,
void *args); void *args);
...@@ -164,12 +152,11 @@ void ddxInitGlobals(void) ...@@ -164,12 +152,11 @@ void ddxInitGlobals(void)
} }
/* /*
* Set if the remote display supports * Set if the remote display supports backing store.
* backing store.
*/ */
/* /*
FIXME: These, if not removed, should at least FIXME: These, if not removed, should at least be moved to Display.h
be moved to Display.h and Display.c. and Display.c.
*/ */
int nxagentBackingStore; int nxagentBackingStore;
int nxagentSaveUnder; int nxagentSaveUnder;
...@@ -187,7 +174,6 @@ int nxagentSaveUnder; ...@@ -187,7 +174,6 @@ int nxagentSaveUnder;
* nxagentOpenScreen * nxagentOpenScreen
* InitInput * InitInput
*/ */
int nxagentDoFullGeneration = 1; int nxagentDoFullGeneration = 1;
/* /*
...@@ -197,9 +183,8 @@ int nxagentDoFullGeneration = 1; ...@@ -197,9 +183,8 @@ int nxagentDoFullGeneration = 1;
Bool nxagentX2go; Bool nxagentX2go;
/* /*
* Check if agent is x2go agent * Check if agent is X2goAgent
*/ */
void checkX2goAgent(void) void checkX2goAgent(void)
{ {
#ifdef TEST #ifdef TEST
...@@ -215,11 +200,9 @@ void checkX2goAgent(void) ...@@ -215,11 +200,9 @@ void checkX2goAgent(void)
nxagentX2go = False; nxagentX2go = False;
} }
/* /*
* Called at X server's initialization. * Called at X server's initialization.
*/ */
void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
{ {
/* /*
...@@ -244,8 +227,8 @@ 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 * Avoid slowness due to buggy_repeat workaround in libcairo
* in libcairo versions >= 1.10. * versions >= 1.10.
*/ */
SetVendorRelease(70000000); SetVendorRelease(70000000);
...@@ -260,9 +243,8 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) ...@@ -260,9 +243,8 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
} }
/* /*
* Unset the LD_LIBRARY_PATH variable in * Unset the LD_LIBRARY_PATH variable in Popen() before calling
* Popen() before calling execl() in the * execl() in the child process.
* child process.
*/ */
NXUnsetLibraryPath(1); NXUnsetLibraryPath(1);
...@@ -314,15 +296,13 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) ...@@ -314,15 +296,13 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
nxagentInitBSPixmapList(); nxagentInitBSPixmapList();
/* /*
* Open the display. We are at the early startup and * Open the display. We are at the early startup and the information
* the information we'll get from the remote X server * we'll get from the remote X server will mandate some of the
* will mandate some of the characteristics of the * characteristics of the session, like the screen depth. Note that
* session, like the screen depth. Note that this re- * this reliance on the remote display at session startup should be
* liance on the remote display at session startup * removed. We should always operate at 32 bpp, internally, and do
* should be removed. We should always operate at 32 * the required translations as soon as the graphic operation needs
* bpp, internally, and do the required translations * to be realized on the remote display.
* as soon as the graphic operation needs to be real-
* ized on the remote display.
*/ */
nxagentOpenDisplay(argc, argv); nxagentOpenDisplay(argc, argv);
...@@ -393,9 +373,8 @@ FIXME: These variables, if not removed at all because have probably ...@@ -393,9 +373,8 @@ FIXME: These variables, if not removed at all because have probably
nxagentNumScreens = screenInfo->numScreens; nxagentNumScreens = screenInfo->numScreens;
/* /*
* Initialize the GCs used by the synchro- * Initialize the GCs used by the synchronization put images. We do
* nization put images. We do it here beca- * it here because we use the nxagentDefaultScreen.
* use we use the nxagentDefaultScreen.
*/ */
nxagentAllocateGraphicContexts(); nxagentAllocateGraphicContexts();
...@@ -403,8 +382,7 @@ FIXME: These variables, if not removed at all because have probably ...@@ -403,8 +382,7 @@ FIXME: These variables, if not removed at all because have probably
nxagentDoFullGeneration = nxagentFullGeneration; nxagentDoFullGeneration = nxagentFullGeneration;
/* /*
* Use a solid black root window * Use a solid black root window background.
* background.
*/ */
if (!whiteRoot) if (!whiteRoot)
...@@ -419,15 +397,12 @@ FIXME: These variables, if not removed at all because have probably ...@@ -419,15 +397,12 @@ FIXME: These variables, if not removed at all because have probably
nxagentInitAtoms(); nxagentInitAtoms();
} }
void void nxagentNotifyConnection(int fd, int ready, void *data)
nxagentNotifyConnection(int fd, int ready, void *data)
{ {
nxagentDispatchEvents(NULL); nxagentDispatchEvents(NULL);
} }
void InitInput(argc, argv) void InitInput(int argc, char *argv[])
int argc;
char *argv[];
{ {
void *ptr, *kbd; void *ptr, *kbd;
...@@ -440,9 +415,8 @@ void InitInput(argc, argv) ...@@ -440,9 +415,8 @@ void InitInput(argc, argv)
mieqInit(kbd, ptr); mieqInit(kbd, ptr);
/* /*
* Add the display descriptor to the * Add the display descriptor to the set of descriptors awaited by
* set of descriptors awaited by the * the dispatcher.
* dispatcher.
*/ */
nxagentAddXConnection(); nxagentAddXConnection();
...@@ -457,10 +431,9 @@ void InitInput(argc, argv) ...@@ -457,10 +431,9 @@ void InitInput(argc, argv)
} }
/* /*
* We let the proxy flush the link on our behalf * We let the proxy flush the link on our behalf after having opened
* after having opened the display. We are now * the display. We are now entering the dispatcher. From now on
* entering the dispatcher. From now on we'll * we'll flush the proxy link explicitly.
* flush the proxy link explicitly.
*/ */
#ifdef TEST #ifdef TEST
...@@ -471,11 +444,9 @@ void InitInput(argc, argv) ...@@ -471,11 +444,9 @@ void InitInput(argc, argv)
} }
/* /*
* DDX specific abort routine. This is called * DDX specific abort routine. This is called by AbortServer() that,
* by AbortServer() that, in turn, is called * in turn, is called by FatalError().
* by FatalError().
*/ */
void AbortDDX(void) void AbortDDX(void)
{ {
nxagentDoFullGeneration = True; nxagentDoFullGeneration = True;
...@@ -483,9 +454,8 @@ void AbortDDX(void) ...@@ -483,9 +454,8 @@ void AbortDDX(void)
nxagentCloseDisplay(); nxagentCloseDisplay();
/* /*
* Do the required finalization if we * Do the required finalization if we are not going through the
* are not going through the normal * normal X server shutdown.
* X server shutdown.
*/ */
if ((dispatchException & DE_TERMINATE) == 0) if ((dispatchException & DE_TERMINATE) == 0)
...@@ -497,7 +467,6 @@ void AbortDDX(void) ...@@ -497,7 +467,6 @@ void AbortDDX(void)
/* /*
* Called by GiveUp(). * Called by GiveUp().
*/ */
void ddxGiveUp(void) void ddxGiveUp(void)
{ {
AbortDDX(); AbortDDX();
...@@ -515,12 +484,10 @@ void OsVendorInit(void) ...@@ -515,12 +484,10 @@ void OsVendorInit(void)
void OsVendorFatalError(void) void OsVendorFatalError(void)
{ {
/* /*
* Let the session terminate gracely * Let the session terminate gracely from an user's standpoint.
* from an user's standpoint.
*/ */
fprintf(stderr, "Session: Aborting session at '%s'.\n", GetTimeAsString()); fprintf(stderr, "Session: Aborting session at '%s'.\n", GetTimeAsString());
fprintf(stderr, "Session: Session aborted at '%s'.\n", GetTimeAsString()); fprintf(stderr, "Session: Session aborted at '%s'.\n", GetTimeAsString());
} }
...@@ -566,7 +533,6 @@ static void nxagentGrabServerCallback(CallbackListPtr *callbacks, void *data, ...@@ -566,7 +533,6 @@ static void nxagentGrabServerCallback(CallbackListPtr *callbacks, void *data,
} }
#ifdef DPMSExtension #ifdef DPMSExtension
void DPMSSet(int level) void DPMSSet(int level)
{ {
} }
...@@ -580,5 +546,4 @@ Bool DPMSSupported(void) ...@@ -580,5 +546,4 @@ Bool DPMSSupported(void)
{ {
return 0; return 0;
} }
#endif #endif
...@@ -104,10 +104,9 @@ static void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, cha ...@@ -104,10 +104,9 @@ static void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, cha
#endif #endif
/* /*
* Unfortunately we cannot just include XKBlib.h. * Unfortunately we cannot just include XKBlib.h. It conflicts with
* It conflicts with the server side definitions * the server side definitions of the same symbols. This is more a X
* of the same symbols. This is more a X problem * problem than our.
* than our.
*/ */
#ifdef XKB #ifdef XKB
...@@ -158,8 +157,7 @@ static char *nxagentRemoteOptions = NULL; ...@@ -158,8 +157,7 @@ static char *nxagentRemoteOptions = NULL;
XkbAgentInfoRec nxagentXkbInfo = { -1, -1, -1, -1, -1 }; XkbAgentInfoRec nxagentXkbInfo = { -1, -1, -1, -1, -1 };
/* /*
* Keyboard status, updated through XKB * Keyboard status, updated through XKB events.
* events.
*/ */
XkbAgentStateRec nxagentXkbState = { 0, 0, 0, 0, 0 }; XkbAgentStateRec nxagentXkbState = { 0, 0, 0, 0, 0 };
...@@ -283,9 +281,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) ...@@ -283,9 +281,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
/* /*
* We want to prevent agent generating auto-repeated * We want to prevent agent generating auto-repeated
* keystrokes. Let's intercept any attempt by appli- * keystrokes. Let's intercept any attempt by appli- cations to
* cations to change the default timeouts on the * change the default timeouts on the nxagent device.
* nxagent device.
*/ */
#ifdef TEST #ifdef TEST
...@@ -305,8 +302,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) ...@@ -305,8 +302,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
#endif #endif
/* /*
* If enabled, propagate the changes to the * If enabled, propagate the changes to the devices attached to the
* devices attached to the real X server. * real X server.
*/ */
if (nxagentOption(DeviceControl)) if (nxagentOption(DeviceControl))
...@@ -315,10 +312,7 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) ...@@ -315,10 +312,7 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
fprintf(stderr, "%s: WARNING! Propagating changes to keyboard settings.\n", __func__); fprintf(stderr, "%s: WARNING! Propagating changes to keyboard settings.\n", __func__);
#endif #endif
unsigned long value_mask = KBKeyClickPercent | unsigned long value_mask = KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration;
KBBellPercent |
KBBellPitch |
KBBellDuration;
XKeyboardControl values = { XKeyboardControl values = {
.key_click_percent = ctrl->click, .key_click_percent = ctrl->click,
...@@ -328,8 +322,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) ...@@ -328,8 +322,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
}; };
/* /*
* Don't propagate the auto repeat mode. It is forced to be * Don't propagate the auto repeat mode. It is forced to be off in
* off in the agent server. * the agent server.
* *
* value_mask |= KBAutoRepeatMode; * value_mask |= KBAutoRepeatMode;
* values.auto_repeat_mode = ctrl->autoRepeat ? * values.auto_repeat_mode = ctrl->autoRepeat ?
...@@ -339,9 +333,9 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) ...@@ -339,9 +333,9 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
XChangeKeyboardControl(nxagentDisplay, value_mask, &values); XChangeKeyboardControl(nxagentDisplay, value_mask, &values);
/* /*
* At this point, we need to walk through the vector and * At this point, we need to walk through the vector and compare
* compare it to the current server vector. If there are * it to the current server vector. If there are differences,
* differences, report them. * report them.
*/ */
value_mask = KBLed | KBLedMode; value_mask = KBLed | KBLedMode;
...@@ -403,11 +397,11 @@ N/A ...@@ -403,11 +397,11 @@ N/A
#endif #endif
/* /*
* Prevent agent from generating auto-repeat keystroke. * Prevent agent from generating auto-repeat keystroke. Note
* Note that this is working only if XKB is enabled. * that this is working only if XKB is enabled. A better
* A better solution should account cases where XKB is * solution should account cases where XKB is not
* not available. Check also the behaviour of the * available. Check also the behaviour of the DeviceControl
* DeviceControl nxagent option. * nxagent option.
*/ */
XkbDfltRepeatDelay = ~ 0; XkbDfltRepeatDelay = ~ 0;
...@@ -429,10 +423,9 @@ N/A ...@@ -429,10 +423,9 @@ N/A
#ifdef _XSERVER64 #ifdef _XSERVER64
{ {
KeySym64 *keymap64 = XGetKeyboardMapping(nxagentDisplay, KeySym64 *keymap64 = XGetKeyboardMapping(nxagentDisplay,
min_keycode, min_keycode,
max_keycode - min_keycode + 1, max_keycode - min_keycode + 1,
&mapWidth); &mapWidth);
if (keymap64 == NULL) if (keymap64 == NULL)
{ {
XFreeModifiermap(modifier_keymap); XFreeModifiermap(modifier_keymap);
...@@ -607,8 +600,8 @@ XkbError: ...@@ -607,8 +600,8 @@ XkbError:
} }
/* /*
* There is no description for pc105 on Solaris. * There is no description for pc105 on Solaris. Need to
* Need to revert to the closest approximation. * revert to the closest approximation.
*/ */
#ifdef TEST #ifdef TEST
...@@ -870,7 +863,6 @@ void nxagentNotifyKeyboardChanges(int oldMinKeycode, int oldMaxKeycode) ...@@ -870,7 +863,6 @@ void nxagentNotifyKeyboardChanges(int oldMinKeycode, int oldMaxKeycode)
#endif #endif
xEvent event = {0}; xEvent event = {0};
event.u.u.type = MappingNotify; event.u.u.type = MappingNotify;
event.u.mappingNotify.request = MappingKeyboard; event.u.mappingNotify.request = MappingKeyboard;
event.u.mappingNotify.firstKeyCode = inputInfo.keyboard -> key -> curKeySyms.minKeyCode; event.u.mappingNotify.firstKeyCode = inputInfo.keyboard -> key -> curKeySyms.minKeyCode;
...@@ -943,12 +935,11 @@ int nxagentResetKeyboard(void) ...@@ -943,12 +935,11 @@ int nxagentResetKeyboard(void)
} }
#endif #endif
dev->key=NULL; dev->key = NULL;
} }
dev->focus=NULL; dev->focus = NULL;
dev->kbdfeed = NULL;
dev->kbdfeed=NULL;
#ifdef XKB #ifdef XKB
nxagentTuneXkbWrapper(); nxagentTuneXkbWrapper();
...@@ -1094,37 +1085,37 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) ...@@ -1094,37 +1085,37 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev)
if (dev->key) if (dev->key)
{ {
#ifdef XKB #ifdef XKB
if (noXkbExtension == 0 && dev->key->xkbInfo) if (noXkbExtension == 0 && dev->key->xkbInfo)
{ {
XkbFreeInfo(dev->key->xkbInfo); XkbFreeInfo(dev->key->xkbInfo);
dev->key->xkbInfo = NULL; dev->key->xkbInfo = NULL;
} }
#endif #endif
SAFE_free(dev->key->curKeySyms.map); SAFE_free(dev->key->curKeySyms.map);
SAFE_free(dev->key->modifierKeyMap); SAFE_free(dev->key->modifierKeyMap);
SAFE_free(dev->key); SAFE_free(dev->key);
} }
if (dev->focus) if (dev->focus)
{ {
SAFE_free(dev->focus->trace); SAFE_free(dev->focus->trace);
SAFE_free(dev->focus); SAFE_free(dev->focus);
} }
if (dev->kbdfeed) if (dev->kbdfeed)
{ {
for (KbdFeedbackPtr k = dev->kbdfeed, knext; k; k = knext) for (KbdFeedbackPtr k = dev->kbdfeed, knext; k; k = knext)
{ {
knext = k->next; knext = k->next;
#ifdef XKB #ifdef XKB
if (k->xkb_sli) if (k->xkb_sli)
XkbFreeSrvLedInfo(k->xkb_sli); XkbFreeSrvLedInfo(k->xkb_sli);
#endif #endif
SAFE_free(k); SAFE_free(k);
} }
dev->kbdfeed = NULL; dev->kbdfeed = NULL;
} }
#ifdef DEBUG #ifdef DEBUG
......
...@@ -80,6 +80,7 @@ miTrapezoids (CARD8 op, ...@@ -80,6 +80,7 @@ miTrapezoids (CARD8 op,
xDst = traps[0].left.p1.x >> 16; xDst = traps[0].left.p1.x >> 16;
yDst = traps[0].left.p1.y >> 16; yDst = traps[0].left.p1.y >> 16;
#ifdef NXAGENT_SERVER
if (nxagentTrapezoidExtents != NullBox) if (nxagentTrapezoidExtents != NullBox)
{ {
memcpy(&bounds, nxagentTrapezoidExtents, sizeof(BoxRec)); memcpy(&bounds, nxagentTrapezoidExtents, sizeof(BoxRec));
...@@ -92,7 +93,9 @@ miTrapezoids (CARD8 op, ...@@ -92,7 +93,9 @@ miTrapezoids (CARD8 op,
memcpy(nxagentTrapezoidExtents, &bounds, sizeof(BoxRec)); memcpy(nxagentTrapezoidExtents, &bounds, sizeof(BoxRec));
} }
#else
miTrapezoidBounds (ntrap, traps, &bounds);
#endif
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
return; return;
pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
......
...@@ -34,10 +34,9 @@ ...@@ -34,10 +34,9 @@
#include "Utils.h" #include "Utils.h"
/* /*
* Instead of having a single options repository * Instead of having a single options repository data could be
* data could be attached to the display or the * attached to the display or the screen. The macro nxagentOption()
* screen. The macro nxagentOption() should make * should make the transition simple.
* the transition simple.
*/ */
AgentOptionsRec nxagentOptions; AgentOptionsRec nxagentOptions;
...@@ -52,8 +51,8 @@ AgentOptionsPtr nxagentOptionsPtr = &nxagentOptions; ...@@ -52,8 +51,8 @@ AgentOptionsPtr nxagentOptionsPtr = &nxagentOptions;
unsigned int nxagentPrintGeometryFlags = 0; unsigned int nxagentPrintGeometryFlags = 0;
/* /*
* This must be called at startup to initialize * This must be called at startup to initialize the options repository
* the options repository to the default values. * to the default values.
*/ */
void nxagentInitOptions(void) void nxagentInitOptions(void)
...@@ -176,12 +175,10 @@ void nxagentInitOptions(void) ...@@ -176,12 +175,10 @@ void nxagentInitOptions(void)
} }
/* /*
* This is called at session reconnection * This is called at session reconnection to reset some options to
* to reset some options to their default * their default values. The reason to avoid calling the
* values. The reason to avoid calling the * nxagentInitOptions() is that not all the options can change value
* nxagentInitOptions() is that not all the * when reconnecting.
* options can change value when reconnec-
* ting.
*/ */
void nxagentResetOptions(void) void nxagentResetOptions(void)
......
...@@ -94,346 +94,267 @@ typedef enum _KeycodeConversion ...@@ -94,346 +94,267 @@ typedef enum _KeycodeConversion
typedef struct _AgentOptions typedef struct _AgentOptions
{ {
/* /*
* Link type of the NX connection or none, * Link type of the NX connection or none, if this is a direct X11
* if this is a direct X11 connection. * connection.
*/ */
int LinkType; int LinkType;
/* /*
* Is agent running in desktop mode? This * Is agent running in desktop mode? This is presently the default.
* is presently the default.
*/ */
int Desktop; int Desktop;
/* /*
* True if user activated rootless mode. * True if user activated rootless mode.
*/ */
int Rootless; int Rootless;
/* /*
* True for shadow mode. * True for shadow mode.
*/ */
int Shadow; int Shadow;
/* /*
* True if user activated persistent mode. * True if user activated persistent mode.
*/ */
int Persistent; int Persistent;
/* /*
* True if user activated fullscreen mode. * True if user activated fullscreen mode.
*/ */
int Fullscreen; int Fullscreen;
/* /*
* True if the fullscreen NX session will * True if the fullscreen NX session will extend on all available
* extend on all available screens. * screens.
*/ */
int AllScreens; int AllScreens;
/* /*
* Set to the auto-disconnect timeout, if * Set to the auto-disconnect timeout, if the user activated this
* the user activated this feature. * feature.
*/ */
int Timeout; int Timeout;
/* /*
* Geometry of the agent's window. * Geometry of the agent's window.
*/ */
int X, Y, Width, Height;
int X;
int Y;
int Width;
int Height;
int BorderWidth; int BorderWidth;
/* /*
* Geometry of the agent's window in window * Geometry of the agent's window in window mode. Used to restore
* mode. Used to restore window size when * window size when switching back to window mode from fullscreen.
* switching back to window mode from full-
* screen.
*/ */
int WMBorderWidth; int WMBorderWidth;
int WMTitleHeight; int WMTitleHeight;
int SavedX; int SavedX, SavedY, SavedWidth, SavedHeight;
int SavedY;
int SavedWidth;
int SavedHeight;
int SavedRootWidth; int SavedRootWidth, SavedRootHeight;
int SavedRootHeight;
/* /*
* Set if agent is running nested in another * Set if agent is running nested in another agent X server.
* agent X server.
*/ */
int Nested; int Nested;
/* /*
* Selected backing-store mode. * Selected backing-store mode.
*/ */
BackingStoreMode BackingStore; BackingStoreMode BackingStore;
/* /*
* Selected clipboard mode. * Selected clipboard mode.
*/ */
ClipboardMode Clipboard; ClipboardMode Clipboard;
/* /*
* Enable agent to use the MITSHM extension in * Enable agent to use the MITSHM extension in path from remote
* path from remote proxy to the real X server. * proxy to the real X server.
*/ */
int SharedMemory; int SharedMemory;
/* /*
* Enable agent to use shared Pixmaps * Enable agent to use shared Pixmaps
*/ */
int SharedPixmaps; int SharedPixmaps;
/* /*
* Enable agent to propagate keyboard and pointer * Enable agent to propagate keyboard and pointer device
* device configuration to the remote X server. * configuration to the remote X server.
*/ */
int DeviceControl; int DeviceControl;
/* /*
* Explicitly asked config propagation. * Explicitly asked config propagation.
*/ */
int DeviceControlUserDefined; int DeviceControlUserDefined;
/* /*
* Resuming keyboard device corrects keymap if session * Resuming keyboard device corrects keymap if session migrates
* migrates across platforms with different keycode * across platforms with different keycode layout.
* layout.
*/ */
int ResetKeyboardAtResume; int ResetKeyboardAtResume;
/* /*
* Reset server when the last client disconnects. * Reset server when the last client disconnects.
*/ */
int Reset; int Reset;
/* /*
* Geometry of the agent root window, relative to * Geometry of the agent root window, relative to the agent default
* the agent default window. * window.
*/ */
int RootX, RootY, RootWidth, RootHeight;
int RootX;
int RootY;
int RootWidth;
int RootHeight;
/* /*
* Horizontal and vertical span of the * Horizontal and vertical span of the agent viewport.
* agent viewport.
*/ */
int ViewportXSpan, ViewportYSpan;
int ViewportXSpan;
int ViewportYSpan;
/* /*
* True if the user can resize the desktop * True if the user can resize the desktop by dragging the window
* by dragging the window border. * border.
*/ */
int DesktopResize; int DesktopResize;
/* /*
* The scaling ratio of the shadow agent. * The scaling ratio of the shadow agent.
*/ */
int Ratio, XRatio, YRatio;
int Ratio; float FloatRatio, FloatXRatio, FloatYRatio;
int XRatio;
int YRatio;
float FloatRatio;
float FloatXRatio;
float FloatYRatio;
/* /*
* The shadow agent uses the Damage extension. * The shadow agent uses the Damage extension.
*/ */
int UseDamage; int UseDamage;
/* /*
* Was the agent run with the -B option? * Was the agent run with the -B option?
*/ */
int Binder; int Binder;
char *BinderOptions; char *BinderOptions;
/* /*
* Set if the agent has to connect to a * Set if the agent has to connect to a desktop manager to start the
* desktop manager to start the session. * session.
*/ */
int Xdmcp; int Xdmcp;
/* /*
* Size of the Xlib display buffer. The * Size of the Xlib display buffer. The default is set according to
* default is set according to the link * the link type.
* type.
*/ */
int DisplayBuffer; int DisplayBuffer;
/* /*
* Buffer coalescence timeout. * Buffer coalescence timeout.
*/ */
int DisplayCoalescence; int DisplayCoalescence;
/* /*
* Use the composite extension when * Use the composite extension when available on the remote display.
* available on the remote display.
*/ */
int Composite; int Composite;
/* /*
* If set, don't skip internal operations * If set, don't skip internal operations when the agent window is
* when the agent window is not fully visible. * not fully visible.
*/ */
int IgnoreVisibility; int IgnoreVisibility;
/* /*
* If set, prevent the shadow session to * If set, prevent the shadow session to interact with master
* interact with master display. * display.
*/ */
int ViewOnly; int ViewOnly;
/* /*
* If true select a lossy or lossless comp- * If true select a lossy or lossless compression method based on
* ression method based on the characterist- * the characteristics of the image.
* ics of the image.
*/ */
int Adaptive; int Adaptive;
/* /*
* Stream the images and update the display * Stream the images and update the display when the image has been
* when the image has been completely trans- * completely transerred.
* ferred.
*/ */
int Streaming; int Streaming;
/* /*
* Use a lazy approach in updating the remote * Use a lazy approach in updating the remote display. This means
* display. This means delaying the bandwidth * delaying the bandwidth consuming graphic operations and
* consuming graphic operations and synchroniz- * synchronizing the screen at idle time.
* ing the screen at idle time.
*/ */
int DeferLevel; int DeferLevel;
/* /*
* Maximum elapsed time before a new full * Maximum elapsed time before a new full synchronization.
* synchronization.
*/ */
unsigned long DeferTimeout; unsigned long DeferTimeout;
/* /*
* Maximum size of the tile used when sending * Maximum size of the tile used when sending an image to the remote
* an image to the remote display. * display.
*/ */
int TileWidth, TileHeight;
int TileWidth;
int TileHeight;
/* /*
* Enabling/disabling the pulldown menu. * Enabling/disabling the pulldown menu.
*/ */
int Menu; int Menu;
/* /*
* Enabling/disabling the magic pixel. * Enabling/disabling the magic pixel.
*/ */
int MagicPixel; int MagicPixel;
/* /*
* Specify the Operative System of the client. * Specify the Operative System of the client.
*/ */
int ClientOs; int ClientOs;
/* /*
* Inhibit some XKEYBOARD requests. * Inhibit some XKEYBOARD requests.
*/ */
int InhibitXkb; int InhibitXkb;
/* /*
* Maximum number of bytes that can be pasted from * Maximum number of bytes that can be pasted from an NX session
* an NX session into an external application. * into an external application.
*/ */
int CopyBufferSize; int CopyBufferSize;
/* /*
* Max image data rate to the encoder input. * Max image data rate to the encoder input.
*/ */
int ImageRateLimit; int ImageRateLimit;
/* /*
* True if agent should not exit if there are no * True if agent should not exit if there are no clients in rootless
* clients in rootless mode * mode
*/ */
int NoRootlessExit; int NoRootlessExit;
/* /*
* Store if the user wants Xinerama. There are variables called * Store if the user wants Xinerama. There are variables called
* noPanoramiXExtension and noRRXineramaExtensison in os/utils.c but * noPanoramiXExtension and noRRXineramaExtensison in os/utils.c but
* we cannot rely on them because RandR and PanoramiX change their * we cannot rely on them because RandR and PanoramiX change their
* values when trying to initialize. So we use this variable to * values when trying to initialize. So we use this variable to save
* save the user preference provided by the -/+(rr)xinerama parameter(s) * the user preference provided by the -/+(rr)xinerama parameter(s)
* before initializing those extensions. * before initializing those extensions.
*/ */
int Xinerama; int Xinerama;
/* /*
* Sleep delay in microseconds. * Sleep delay in microseconds.
*/ */
unsigned int SleepTime; unsigned int SleepTime;
/* /*
* Tolerance - tightens or loosens reconnect checks. * Tolerance - tightens or loosens reconnect checks.
*/ */
ToleranceChecksMode ReconnectTolerance; ToleranceChecksMode ReconnectTolerance;
/* /*
...@@ -473,8 +394,7 @@ extern AgentOptionsPtr nxagentOptionsPtr; ...@@ -473,8 +394,7 @@ extern AgentOptionsPtr nxagentOptionsPtr;
extern void nxagentInitOptions(void); extern void nxagentInitOptions(void);
/* /*
* Initialize some options to the default values * Initialize some options to the default values at reconnection.
* at reconnection.
*/ */
extern void nxagentResetOptions(void); extern void nxagentResetOptions(void);
...@@ -486,8 +406,8 @@ extern void nxagentResetOptions(void); ...@@ -486,8 +406,8 @@ extern void nxagentResetOptions(void);
extern void nxagentSaveOptions(void); extern void nxagentSaveOptions(void);
/* /*
* Restore the options reset by nxagentResetOptions * Restore the options reset by nxagentResetOptions to their backup
* to their backup value. * value.
*/ */
extern void nxagentRestoreOptions(void); extern void nxagentRestoreOptions(void);
......
...@@ -56,8 +56,6 @@ static int nxagentComparePixels(const void *p1, const void *p2) ...@@ -56,8 +56,6 @@ static int nxagentComparePixels(const void *p1, const void *p2)
int nxagentUniquePixels(XImage *image) int nxagentUniquePixels(XImage *image)
{ {
int i = 0;
int pixels[PIXEL_ELEMENTS]; int pixels[PIXEL_ELEMENTS];
int elements = PIXEL_ELEMENTS; int elements = PIXEL_ELEMENTS;
...@@ -132,15 +130,14 @@ int nxagentUniquePixels(XImage *image) ...@@ -132,15 +130,14 @@ int nxagentUniquePixels(XImage *image)
#endif #endif
/* /*
* Take one pixel every n from the image and * Take one pixel every n from the image and add it to the array.
* add it to the array.
*/ */
switch (image -> bits_per_pixel) switch (image -> bits_per_pixel)
{ {
case 32: case 32:
{ {
for (i = 0; i < elements; i++) for (int i = 0; i < elements; i++)
{ {
pixels[i] = Get32(next, image -> byte_order); pixels[i] = Get32(next, image -> byte_order);
...@@ -156,7 +153,7 @@ int nxagentUniquePixels(XImage *image) ...@@ -156,7 +153,7 @@ int nxagentUniquePixels(XImage *image)
} }
case 24: case 24:
{ {
for (i = 0; i < elements; i++) for (int i = 0; i < elements; i++)
{ {
pixels[i] = Get24(next, image -> byte_order); pixels[i] = Get24(next, image -> byte_order);
...@@ -174,14 +171,12 @@ int nxagentUniquePixels(XImage *image) ...@@ -174,14 +171,12 @@ int nxagentUniquePixels(XImage *image)
case 15: case 15:
{ {
/* /*
* Note that the padding bytes at the end * Note that the padding bytes at the end of the scanline are
* of the scanline are included in the set. * included in the set. This is not a big problem. What we want
* This is not a big problem. What we want * to find out is just how compressible is the image data.
* 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); pixels[i] = Get16(next, image -> byte_order);
...@@ -212,7 +207,7 @@ int nxagentUniquePixels(XImage *image) ...@@ -212,7 +207,7 @@ int nxagentUniquePixels(XImage *image)
qsort(pixels, elements, sizeof(int), nxagentComparePixels); qsort(pixels, elements, sizeof(int), nxagentComparePixels);
for (i = 0; i < elements; i++) for (int i = 0; i < elements; i++)
{ {
if (last != pixels[i]) if (last != pixels[i])
{ {
......
...@@ -66,8 +66,8 @@ is" without express or implied warranty. ...@@ -66,8 +66,8 @@ is" without express or implied warranty.
#undef DEBUG #undef DEBUG
/* /*
* The nxagentReversePointerMap array is used to * The nxagentReversePointerMap array is used to memorize remote
* memorize remote display pointer map. * display pointer map.
*/ */
unsigned char nxagentReversePointerMap[MAXBUTTONS]; unsigned char nxagentReversePointerMap[MAXBUTTONS];
...@@ -76,13 +76,12 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl) ...@@ -76,13 +76,12 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl)
{ {
/* /*
* The original behaviour was to reset the pointer settings * The original behaviour was to reset the pointer settings
* (acceleration and alas) to the default values. What the * (acceleration and alas) to the default values. What the average
* average user expects, on the contrary, is to have agent * user expects, on the contrary, is to have agent inheriting
* inheriting whatever value is set on the real X display. * whatever value is set on the real X display. Having to reflect
* Having to reflect changes made inside the agent session, * changes made inside the agent session, the correct behavior would
* the correct behavior would be saving the original values * be saving the original values and restoring them as soon as focus
* and restoring them as soon as focus leaves the agent's * leaves the agent's window.
* window.
*/ */
if (nxagentOption(DeviceControl) == True) if (nxagentOption(DeviceControl) == True)
...@@ -104,10 +103,6 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl) ...@@ -104,10 +103,6 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl)
int nxagentPointerProc(DeviceIntPtr pDev, int onoff) int nxagentPointerProc(DeviceIntPtr pDev, int onoff)
{ {
CARD8 map[MAXBUTTONS];
int nmap;
int i;
switch (onoff) switch (onoff)
{ {
case DEVICE_INIT: case DEVICE_INIT:
...@@ -121,8 +116,10 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) ...@@ -121,8 +116,10 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff)
return Success; return Success;
} }
nmap = XGetPointerMapping(nxagentDisplay, map, MAXBUTTONS); CARD8 map[MAXBUTTONS];
for (i = 0; i <= nmap; i++)
int nmap = XGetPointerMapping(nxagentDisplay, map, MAXBUTTONS);
for (int i = 0; i <= nmap; i++)
map[i] = i; /* buttons are already mapped */ map[i] = i; /* buttons are already mapped */
InitPointerDeviceStruct((DevicePtr) pDev, map, nmap, InitPointerDeviceStruct((DevicePtr) pDev, map, nmap,
miPointerGetMotionEvents, miPointerGetMotionEvents,
...@@ -174,10 +171,6 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) ...@@ -174,10 +171,6 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff)
void nxagentInitPointerMap(void) void nxagentInitPointerMap(void)
{ {
int numButtons;
int i;
unsigned char pointerMap[MAXBUTTONS]; unsigned char pointerMap[MAXBUTTONS];
#ifdef DEBUG #ifdef DEBUG
...@@ -185,13 +178,13 @@ void nxagentInitPointerMap(void) ...@@ -185,13 +178,13 @@ void nxagentInitPointerMap(void)
"pointer map from remote display.\n"); "pointer map from remote display.\n");
#endif #endif
numButtons = XGetPointerMapping(nxagentDisplay, pointerMap, MAXBUTTONS); int numButtons = XGetPointerMapping(nxagentDisplay, pointerMap, MAXBUTTONS);
/* /*
* Computing revers pointer map. * Computing revers pointer map.
*/ */
for (i = 1; i <= numButtons; i++) for (int i = 1; i <= numButtons; i++)
{ {
nxagentReversePointerMap[pointerMap[i - 1]] = i; nxagentReversePointerMap[pointerMap[i - 1]] = i;
} }
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "compext/Compext.h" #include "compext/Compext.h"
/* /*
* Set here the required log level. * Set here the required log level.
*/ */
...@@ -47,9 +46,8 @@ ...@@ -47,9 +46,8 @@
#undef DEBUG #undef DEBUG
/* /*
* This should be a macro but for now * This should be a macro but for now we make it a real function to
* we make it a real function to log * log a warning in the logs.
* a warning in the logs.
*/ */
DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable) DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable)
...@@ -73,13 +71,11 @@ DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable) ...@@ -73,13 +71,11 @@ DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable)
void nxagentInitSplitResources(void) void nxagentInitSplitResources(void)
{ {
int resource;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentInitSplitResources: Initializing the split resources.\n"); fprintf(stderr, "nxagentInitSplitResources: Initializing the split resources.\n");
#endif #endif
for (resource = 0; resource < NXNumberOfResources; resource++) for (int resource = 0; resource < NXNumberOfResources; resource++)
{ {
SplitResourcePtr pResource = &nxagentSplitResources[resource]; SplitResourcePtr pResource = &nxagentSplitResources[resource];
...@@ -97,8 +93,6 @@ SplitResourcePtr nxagentAllocSplitResource(void) ...@@ -97,8 +93,6 @@ SplitResourcePtr nxagentAllocSplitResource(void)
{ {
int resource; int resource;
SplitResourcePtr pResource;
for (;;) for (;;)
{ {
resource = NXAllocSplit(nxagentDisplay, NXAnyResource); resource = NXAllocSplit(nxagentDisplay, NXAnyResource);
...@@ -124,7 +118,7 @@ FIXME: Must deal with the case all resources are exausted. ...@@ -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 || if (pResource -> pending != 0 || pResource -> split != NXNoResource ||
pResource -> unpack != NXNoResource || pResource -> drawable != NULL || pResource -> unpack != NXNoResource || pResource -> drawable != NULL ||
...@@ -217,13 +211,11 @@ FIXME: This must be implemented. ...@@ -217,13 +211,11 @@ FIXME: This must be implemented.
void nxagentReleaseAllSplits(void) void nxagentReleaseAllSplits(void)
{ {
int resource;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentReleaseAllSplits: Going to release all the split resources.\n"); fprintf(stderr, "nxagentReleaseAllSplits: Going to release all the split resources.\n");
#endif #endif
for (resource = 0; resource < NXNumberOfResources; resource++) for (int resource = 0; resource < NXNumberOfResources; resource++)
{ {
SplitResourcePtr pResource = &nxagentSplitResources[resource]; SplitResourcePtr pResource = &nxagentSplitResources[resource];
...@@ -329,11 +321,9 @@ static void nxagentCheckResource(SplitResourcePtr pResource, int resource) ...@@ -329,11 +321,9 @@ static void nxagentCheckResource(SplitResourcePtr pResource, int resource)
int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC) int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC)
{ {
SplitResourcePtr pResource;
pDrawable = nxagentSplitDrawable(pDrawable); pDrawable = nxagentSplitDrawable(pDrawable);
pResource = nxagentAllocSplitResource(); SplitResourcePtr pResource = nxagentAllocSplitResource();
if (pDrawable -> type == DRAWABLE_PIXMAP) if (pDrawable -> type == DRAWABLE_PIXMAP)
{ {
...@@ -348,8 +338,7 @@ int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC) ...@@ -348,8 +338,7 @@ int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC)
pResource -> commit = 1; pResource -> commit = 1;
/* /*
* Make a copy of the GC so the client * Make a copy of the GC so the client can safely remove it.
* can safely remove it.
*/ */
pResource -> gc = CreateScratchGC(pDrawable -> pScreen, pDrawable -> depth); pResource -> gc = CreateScratchGC(pDrawable -> pScreen, pDrawable -> depth);
...@@ -400,17 +389,14 @@ FIXME: What do we do here? ...@@ -400,17 +389,14 @@ FIXME: What do we do here?
} }
/* /*
* Set the region to be the current * Set the region to be the current streaming region.
* streaming region.
*/ */
void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion) void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion)
{ {
SplitResourcePtr pResource;
pDrawable = nxagentSplitDrawable(pDrawable); pDrawable = nxagentSplitDrawable(pDrawable);
pResource = nxagentSplitResource(pDrawable); SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
#ifdef TEST #ifdef TEST
...@@ -442,18 +428,16 @@ void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion) ...@@ -442,18 +428,16 @@ void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion)
} }
/* /*
* Remove the association between the drawable * Remove the association between the drawable and the split
* and the split resource. The resource is not * resource. The resource is not deallocated until the end of the
* deallocated until the end of the split. * split.
*/ */
void nxagentReleaseSplit(DrawablePtr pDrawable) void nxagentReleaseSplit(DrawablePtr pDrawable)
{ {
SplitResourcePtr pResource;
pDrawable = nxagentSplitDrawable(pDrawable); pDrawable = nxagentSplitDrawable(pDrawable);
pResource = nxagentSplitResource(pDrawable); SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
if (pResource == NULL) if (pResource == NULL)
{ {
...@@ -477,10 +461,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable) ...@@ -477,10 +461,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
if (pResource -> region != NullRegion) if (pResource -> region != NullRegion)
{ {
/* /*
* If we have a region the commits * If we have a region the commits had to be still valid. In this
* had to be still valid. In this * case tell the proxy to abort the data transfer.
* case tell the proxy to abort the
* data transfer.
*/ */
#ifdef TEST #ifdef TEST
...@@ -528,8 +510,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable) ...@@ -528,8 +510,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
} }
/* /*
* Remove the association between the * Remove the association between the drawable and the resource
* drawable and the resource record. * record.
*/ */
#ifdef TEST #ifdef TEST
...@@ -547,9 +529,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable) ...@@ -547,9 +529,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
} }
/* /*
* Invalidate the commits and remove the * Invalidate the commits and remove the association between the
* association between the resource and * resource and the drawable.
* the drawable.
*/ */
pResource -> drawable = NULL; pResource -> drawable = NULL;
...@@ -558,11 +539,9 @@ void nxagentReleaseSplit(DrawablePtr pDrawable) ...@@ -558,11 +539,9 @@ void nxagentReleaseSplit(DrawablePtr pDrawable)
void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion) void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
{ {
SplitResourcePtr pResource;
pDrawable = nxagentSplitDrawable(pDrawable); pDrawable = nxagentSplitDrawable(pDrawable);
pResource = nxagentSplitResource(pDrawable); SplitResourcePtr pResource = nxagentSplitResource(pDrawable);
if (pResource == NULL) if (pResource == NULL)
{ {
...@@ -607,9 +586,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion) ...@@ -607,9 +586,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
#endif #endif
/* /*
* If a null region is passed as parameter, * If a null region is passed as parameter, we assume that all the
* we assume that all the commits have to * commits have to be discarded.
* be discarded.
*/ */
if (pRegion == NullRegion) if (pRegion == NullRegion)
...@@ -626,9 +604,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion) ...@@ -626,9 +604,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion)
RegionRec tmpRegion; RegionRec tmpRegion;
/* /*
* Check if the provided region overlaps * Check if the provided region overlaps the area covered by the
* the area covered by the image being * image being streamed.
* streamed.
*/ */
RegionInit(&tmpRegion, NullBox, 1); RegionInit(&tmpRegion, NullBox, 1);
...@@ -698,10 +675,9 @@ void nxagentFreeSplit(int resource) ...@@ -698,10 +675,9 @@ void nxagentFreeSplit(int resource)
else else
{ {
/* /*
* The end of the split has come after we have * The end of the split has come after we have invalidated the
* invalidated the operation and removed the * operation and removed the association to the drawable. This
* association to the drawable. This happens, * happens, for example, if the drawable is destroyed.
* for example, if the drawable is destroyed.
*/ */
fprintf(stderr, "nxagentFreeSplit: WARNING! Releasing invalidated resource [%d].\n", fprintf(stderr, "nxagentFreeSplit: WARNING! Releasing invalidated resource [%d].\n",
...@@ -718,8 +694,8 @@ void nxagentFreeSplit(int resource) ...@@ -718,8 +694,8 @@ void nxagentFreeSplit(int resource)
} }
/* /*
FIXME: This must be enabled when the vanilla FIXME: This must be enabled when the vanilla synchronization procedure
synchronization procedure is working. is working.
*/ */
#define USE_FINISH_SPLIT #define USE_FINISH_SPLIT
...@@ -747,8 +723,7 @@ void nxagentWaitDrawable(DrawablePtr pDrawable) ...@@ -747,8 +723,7 @@ void nxagentWaitDrawable(DrawablePtr pDrawable)
#endif #endif
/* /*
* Be sure we intercept an I/O error * Be sure we intercept an I/O error as well as an interrupt.
* as well as an interrupt.
*/ */
#ifdef USE_FINISH_SPLIT #ifdef USE_FINISH_SPLIT
...@@ -762,21 +737,18 @@ void nxagentWaitDrawable(DrawablePtr pDrawable) ...@@ -762,21 +737,18 @@ void nxagentWaitDrawable(DrawablePtr pDrawable)
for (;;) for (;;)
{ {
/* /*
* Handling all the possible events here * Handling all the possible events here preempts the queue and
* preempts the queue and makes a better * makes a better use of the link.
* use of the link.
* *
* We should better use XIfEvent() instead * We should better use XIfEvent() instead of looping again and
* of looping again and again through the * again through the event queue.
* event queue.
*/ */
nxagentDispatchEvents(NULL); nxagentDispatchEvents(NULL);
/* /*
* Wait indefinitely until the resource * Wait indefinitely until the resource is released or the display
* is released or the display is shut * is shut down.
* down.
*/ */
if (nxagentSplitResource(pDrawable) == NULL || if (nxagentSplitResource(pDrawable) == NULL ||
...@@ -821,16 +793,14 @@ void nxagentWaitCommitEvent(int resource) ...@@ -821,16 +793,14 @@ void nxagentWaitCommitEvent(int resource)
XEvent event; XEvent event;
/* /*
* Check if there is any commit pending. As * Check if there is any commit pending. As we are at it, handle any
* we are at it, handle any commit, even those * commit, even those commits pertaining to other resources.
* commits pertaining to other resources.
* *
* We can receive some commits even if we'll * We can receive some commits even if we'll later receive a
* later receive a no-split event. The proxy, * no-split event. The proxy, in fact, may have missed to find the
* in fact, may have missed to find the image * image in the memory cache and could have loaded it from disk (so
* in the memory cache and could have loaded it * requiring a commit) before we marked the end of the split
* from disk (so requiring a commit) before we * sequence.
* marked the end of the split sequence.
*/ */
while (nxagentCheckEvents(nxagentDisplay, &event, while (nxagentCheckEvents(nxagentDisplay, &event,
...@@ -866,9 +836,8 @@ int nxagentWaitSplitEvent(int resource) ...@@ -866,9 +836,8 @@ int nxagentWaitSplitEvent(int resource)
int split = 0; int split = 0;
/* /*
* Don't flush the link. We only want to * Don't flush the link. We only want to query the NX transport to
* query the NX transport to check whether * check whether the operation caused a split.
* the operation caused a split.
*/ */
NXFlushDisplay(nxagentDisplay, NXFlushBuffer); NXFlushDisplay(nxagentDisplay, NXFlushBuffer);
...@@ -1223,10 +1192,9 @@ void nxagentSetCorruptedTimestamp(DrawablePtr pDrawable) ...@@ -1223,10 +1192,9 @@ void nxagentSetCorruptedTimestamp(DrawablePtr pDrawable)
} }
/* /*
* Reset the timestamp taken when the drawable * Reset the timestamp taken when the drawable became initially
* became initially corrupted. The timestamp is * corrupted. The timestamp is reset only after the drawable has been
* reset only after the drawable has been fully * fully synchronized.
* synchronized.
*/ */
void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable) void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable)
...@@ -1253,4 +1221,3 @@ void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable) ...@@ -1253,4 +1221,3 @@ void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable)
} }
} }
} }
...@@ -64,19 +64,17 @@ Visual nxagentAlphaVisual; ...@@ -64,19 +64,17 @@ Visual nxagentAlphaVisual;
Visual *nxagentVisual(VisualPtr pVisual) Visual *nxagentVisual(VisualPtr pVisual)
{ {
XVisualInfo visual; XVisualInfo visual = {
.class = pVisual->class,
int i; .bits_per_rgb = pVisual->bitsPerRGBValue,
.colormap_size = pVisual->ColormapEntries,
visual.class = pVisual->class; .depth = pVisual->nplanes,
visual.bits_per_rgb = pVisual->bitsPerRGBValue; .red_mask = pVisual->redMask,
visual.colormap_size = pVisual->ColormapEntries; .green_mask = pVisual->greenMask,
visual.depth = pVisual->nplanes; .blue_mask = pVisual->blueMask
visual.red_mask = pVisual->redMask; };
visual.green_mask = pVisual->greenMask;
visual.blue_mask = pVisual->blueMask; for (int i = 0; i < nxagentNumVisuals; i++)
for (i = 0; i < nxagentNumVisuals; i++)
{ {
if (nxagentCompareVisuals(visual, nxagentVisuals[i]) == 1) if (nxagentCompareVisuals(visual, nxagentVisuals[i]) == 1)
{ {
...@@ -89,9 +87,7 @@ Visual *nxagentVisual(VisualPtr pVisual) ...@@ -89,9 +87,7 @@ Visual *nxagentVisual(VisualPtr pVisual)
Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual) Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual)
{ {
int i; for (int i = 0; i < pScreen->numVisuals; i++)
for (i = 0; i < pScreen->numVisuals; i++)
{ {
if (pScreen->visuals[i].vid == visual) if (pScreen->visuals[i].vid == visual)
{ {
...@@ -104,9 +100,7 @@ Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual) ...@@ -104,9 +100,7 @@ Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual)
Colormap nxagentDefaultVisualColormap(Visual *visual) Colormap nxagentDefaultVisualColormap(Visual *visual)
{ {
int i; for (int i = 0; i < nxagentNumVisuals; i++)
for (i = 0; i < nxagentNumVisuals; i++)
{ {
if (nxagentVisuals[i].visual == visual) if (nxagentVisuals[i].visual == visual)
{ {
...@@ -117,18 +111,16 @@ Colormap nxagentDefaultVisualColormap(Visual *visual) ...@@ -117,18 +111,16 @@ Colormap nxagentDefaultVisualColormap(Visual *visual)
return None; return None;
} }
#if 0
/* /*
* This is currently unused. It should serve * This is currently unused. It should serve the scope of matching a
* the scope of matching a visual whenever * visual whenever a drawable has a different depth than the real
* a drawable has a different depth than the * display.
* real display.
*/ */
Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth) Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth)
{ {
int i; for (int i = 0; i < pScreen->numVisuals; i++)
for (i = 0; i < pScreen->numVisuals; i++)
{ {
if (pScreen->visuals[i].nplanes == depth) if (pScreen->visuals[i].nplanes == depth)
{ {
...@@ -138,11 +130,11 @@ Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth) ...@@ -138,11 +130,11 @@ Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth)
return NULL; return NULL;
} }
#endif
/* /*
* Create a fake 32 bits depth visual and * Create a fake 32 bits depth visual and initialize it based on the
* initialize it based on the endianness * endianness of the remote display.
* of the remote display.
*/ */
void nxagentInitAlphaVisual(void) void nxagentInitAlphaVisual(void)
...@@ -150,9 +142,8 @@ void nxagentInitAlphaVisual(void) ...@@ -150,9 +142,8 @@ void nxagentInitAlphaVisual(void)
nxagentAlphaVisual.visualid = XAllocID(nxagentDisplay); nxagentAlphaVisual.visualid = XAllocID(nxagentDisplay);
/* /*
* Color masks are referred to bits inside * Color masks are referred to bits inside the pixel. This is
* the pixel. This is independent from the * independent from the endianness.
* endianness.
*/ */
nxagentAlphaVisual.red_mask = 0x00ff0000; nxagentAlphaVisual.red_mask = 0x00ff0000;
......
...@@ -42,7 +42,10 @@ is" without express or implied warranty. ...@@ -42,7 +42,10 @@ is" without express or implied warranty.
Visual *nxagentVisual(VisualPtr pVisual); Visual *nxagentVisual(VisualPtr pVisual);
Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual); Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual);
#if 0
Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth); Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth);
#endif
Colormap nxagentDefaultVisualColormap(Visual *visual); Colormap nxagentDefaultVisualColormap(Visual *visual);
...@@ -50,17 +53,14 @@ Colormap nxagentDefaultVisualColormap(Visual *visual); ...@@ -50,17 +53,14 @@ Colormap nxagentDefaultVisualColormap(Visual *visual);
nxagentVisualFromID((pScreen), (pScreen) -> rootVisual) nxagentVisualFromID((pScreen), (pScreen) -> rootVisual)
/* /*
* Visual generated by Xorg and Xfree86 at * Visual generated by Xorg and Xfree86 at 16-bit depth differs on the
* 16-bit depth differs on the bits_per_rgb * bits_per_rgb value, so we avoid checking it.
* value, so we avoid checking it.
*/ */
/* /*
* Some Solaris X servers uses the color * Some Solaris X servers uses the color masks inverted, so that the
* masks inverted, so that the red and * red and the blue mask are switched. To reconnect the session on
* the blue mask are switched. To reconnect * this displays, we do a double check, as workaround.
* the session on this displays, we do a
* double check, as workaround.
*/ */
#define nxagentCompareVisuals(v1, v2) \ #define nxagentCompareVisuals(v1, v2) \
......
...@@ -1037,6 +1037,7 @@ miSetShape(pWin) ...@@ -1037,6 +1037,7 @@ miSetShape(pWin)
(pWin, 0, 0, pOldClip, (pWin, 0, 0, pOldClip,
pWin->drawable.x, pWin->drawable.y); pWin->drawable.x, pWin->drawable.y);
#ifdef NXAGENT_SERVER
/* /*
* Applies to NXAGENT_SERVER builds: * Applies to NXAGENT_SERVER builds:
* *
...@@ -1056,6 +1057,9 @@ miSetShape(pWin) ...@@ -1056,6 +1057,9 @@ miSetShape(pWin)
*/ */
if (WasViewable && pOldClip) if (WasViewable && pOldClip)
#else
if (WasViewable)
#endif
RegionDestroy(pOldClip); RegionDestroy(pOldClip);
if (bsExposed) if (bsExposed)
{ {
......
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