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