diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
38 files changed, 1885 insertions, 2784 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 2d998980c..abdb650a4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -1103,6 +1103,9 @@ static void nxagentParseSingleOption(char *name, char *value) URLDecodeInPlace(value); + if (!value) + value = ""; + if (!strcmp(name, "kbtype") || !strcmp(name, "keyboard") || !strcmp(name, "id") || diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index 2ee67b9bb..d9d203faa 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -90,6 +90,7 @@ static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] = "UTF8_STRING", /* 12 */ "_NET_WM_STATE", /* 13 */ "_NET_WM_STATE_FULLSCREEN", /* 14 */ + "NX_CUT_BUFFER_CLIENT", /* 15 */ NULL, NULL }; @@ -161,6 +162,7 @@ static void finishWMDetection(Bool verbose) void nxagentWMDetect() { + /* FIXME: verbose is always false, there's no code to set it to true */ Bool verbose = False; Bool windowManagerWasRunning = nxagentWMIsRunning; @@ -176,10 +178,8 @@ void nxagentWMDetect() finishWMDetection(verbose); } -int nxagentInitAtoms(WindowPtr pWin) +void nxagentInitAtoms() { - Atom atom; - /* * Value of nxagentAtoms[8] is "NX_AGENT_SIGNATURE". * @@ -188,43 +188,40 @@ int nxagentInitAtoms(WindowPtr pWin) * run nested. */ - atom = MakeAtom(nxagentAtomNames[8], strlen(nxagentAtomNames[8]), 1); + Atom atom = MakeAtom(nxagentAtomNames[8], strlen(nxagentAtomNames[8]), 1); if (atom == None) { #ifdef PANIC - fprintf(stderr, "nxagentInitAtoms: PANIC! Could not create [%s] atom.\n", + fprintf(stderr, "%s: PANIC! Could not create [%s] atom.\n", __func__, nxagentAtomNames[8]); #endif - - return -1; } - - return 1; + else + { + #ifdef TEST + fprintf(stderr, "nxagentInitAtoms: atom [%s] created with value [%d].\n", + nxagentAtomNames[8], atom); + #endif + } } int nxagentQueryAtoms(ScreenPtr pScreen) { - int i; static unsigned long atomGeneration = 1; int num_of_atoms = NXAGENT_NUMBER_OF_ATOMS; char *names[NXAGENT_NUMBER_OF_ATOMS]; - unsigned long int startingTime = GetTimeInMillis(); - #ifdef TEST - fprintf(stderr, "nxagentQueryAtoms: Going to create the intern atoms on real display.\n"); - - fprintf(stderr, "nxagentQueryAtoms: Starting time is [%ld].\n", startingTime); + fprintf(stderr, "%s: Going to create the intern atoms on real display.\n", __func__); #endif nxagentPrintAtomMapInfo("nxagentQueryAtoms: Entering"); - for (i = 0; i < num_of_atoms; i++) + for (int i = 0; i < num_of_atoms; i++) { names[i] = nxagentAtomNames[i]; - nxagentAtoms[i] = None; } @@ -251,10 +248,10 @@ int nxagentQueryAtoms(ScreenPtr pScreen) if (atomGeneration != serverGeneration) { #ifdef WARNING - fprintf(stderr, "nxagentQueryAtoms: The nxagent has been reset with server %ld atom %ld.\n", + fprintf(stderr, "%s: The nxagent has been reset with server %ld atom %ld.\n", __func__, serverGeneration, atomGeneration); - fprintf(stderr, "nxagentQueryAtoms: Forcing a sync to detect the window manager.\n"); + fprintf(stderr, "%s: Forcing a sync to detect the window manager.\n", __func__); #endif atomGeneration = serverGeneration; @@ -312,19 +309,11 @@ int nxagentQueryAtoms(ScreenPtr pScreen) #ifdef TEST - for (i = 0; i < num_of_atoms; i++) + for (int i = 0; i < num_of_atoms; i++) { - fprintf(stderr, "nxagentQueryAtoms: Created intern atom [%s] with id [%ld].\n", + fprintf(stderr, "%s: Created intern atom [%s] with id [%ld].\n", __func__, names[i], nxagentAtoms[i]); } - - #endif - - nxagentChangeOption(DisplayLatency, GetTimeInMillis() - startingTime); - - #ifdef TEST - fprintf(stderr, "nxagentQueryAtoms: Ending time is [%ld] reference latency is [%d] Ms.\n", - GetTimeInMillis(), nxagentOption(DisplayLatency)); #endif nxagentPrintAtomMapInfo("nxagentQueryAtoms: Exiting"); @@ -364,9 +353,8 @@ static void nxagentExpandCache(void) } /* - * Check if there is space left on the map - * and manage the possible consequent allocation, - * then cache the atom-couple. + * Check if there is space left on the map and manage the possible + * consequent allocation, then cache the atom-couple. */ static void nxagentWriteAtom(Atom local, Atom remote, const char *string, Bool duplicate) @@ -374,10 +362,9 @@ static void nxagentWriteAtom(Atom local, Atom remote, const char *string, Bool d const char *s; /* - * We could remove this string duplication if - * we know for sure that the server will not - * reset, since only at reset the dix layer - * free all the atom names. + * We could remove this string duplication if we knew for sure that + * the server will not reset, since only at reset the dix layer + * frees all the atom names. */ if (duplicate) @@ -410,19 +397,16 @@ static void nxagentWriteAtom(Atom local, Atom remote, const char *string, Bool d } /* - * FIXME: We should clean up the atom map - * at nxagent reset, in order to cancel - * all the local atoms but still maintaining - * the Xserver values and the atom names. + * FIXME: We should clean up the atom map at nxagent reset, in order + * to cancel all the local atoms but still maintaining the Xserver + * values and the atom names. */ void nxagentResetAtomMap(void) { - unsigned i; - nxagentPrintAtomMapInfo("nxagentResetAtomMap: Entering"); - for (i = 0; i < privLastAtom; i++) + for (unsigned int i = 0; i < privLastAtom; i++) { privAtomMap[i].local = None; } @@ -437,16 +421,13 @@ void nxagentResetAtomMap(void) static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet) { - XlibAtom *atom_list; - char **name_list; unsigned int i; - int ret_value = 0; int list_size = count + privLastAtom; nxagentPrintAtomMapInfo("nxagentInitAtomMap: Entering"); - atom_list = malloc((list_size) * sizeof(*atom_list)); - name_list = malloc((list_size) * sizeof(char*)); + XlibAtom *atom_list = malloc((list_size) * sizeof(*atom_list)); + char **name_list = malloc((list_size) * sizeof(char*)); if ((atom_list == NULL) || (name_list == NULL)) { @@ -470,7 +451,7 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet) * ... if successful cache them too. */ - ret_value = XInternAtoms(nxagentDisplay, name_list, list_size, False, atom_list); + int ret_value = XInternAtoms(nxagentDisplay, name_list, list_size, False, atom_list); if (ret_value == 0) { @@ -528,22 +509,19 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet) } /* - * If the nxagent has been reset, - * the local value of the atoms stored - * in cache could have the value None, - * do not call this function with None. + * If the nxagent has been reset, the local value of the atoms stored + * in cache could have the value None, do not call this function with + * None. */ static AtomMap* nxagentFindAtomByLocalValue(Atom local) { - unsigned i; - if (!ValidAtom(local)) { return NULL; } - for (i = 0; i < privLastAtom; i++) + for (unsigned int i = 0; i < privLastAtom; i++) { if (local == privAtomMap[i].local) { @@ -556,14 +534,12 @@ static AtomMap* nxagentFindAtomByLocalValue(Atom local) static AtomMap* nxagentFindAtomByRemoteValue(Atom remote) { - unsigned i; - if (remote == None || remote == BAD_RESOURCE) { return NULL; } - for (i = 0; i < privLastAtom; i++) + for (unsigned int i = 0; i < privLastAtom; i++) { if (remote == privAtomMap[i].remote) { @@ -576,9 +552,7 @@ static AtomMap* nxagentFindAtomByRemoteValue(Atom remote) static AtomMap* nxagentFindAtomByName(char *string, unsigned int length) { - unsigned i; - - for (i = 0; i < privLastAtom; i++) + for (unsigned int i = 0; i < privLastAtom; i++) { if ((length == privAtomMap[i].length) && (strcmp(string, privAtomMap[i].string) == 0)) @@ -602,7 +576,6 @@ static AtomMap* nxagentFindAtomByName(char *string, unsigned int length) Atom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit) { - Atom local; AtomMap *current; /* @@ -610,7 +583,7 @@ Atom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit) * our nxagentFindAtomByName. */ - local = MakeAtom(string, length, Makeit); + Atom local = MakeAtom(string, length, Makeit); if (!ValidAtom(local)) { @@ -634,7 +607,7 @@ Atom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit) if ((current = nxagentFindAtomByName(string, length))) { /* - * Found Cached by name. + * Found cached by name. * It means that nxagent has been reset, * but not the xserver so we still have cached its atoms. */ @@ -645,13 +618,11 @@ Atom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit) } /* - * We really have to ask Xserver for it. + * We really have to ask the Xserver for it. */ { - Atom remote; - - remote = XInternAtom(nxagentDisplay, string, !Makeit); + Atom remote = XInternAtom(nxagentDisplay, string, !Makeit); if (remote == None) { @@ -670,10 +641,6 @@ Atom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit) Atom nxagentLocalToRemoteAtom(Atom local) { - AtomMap *current; - const char *string; - Atom remote; - #ifdef TEST fprintf(stderr, "%s: entering\n", __func__); #endif @@ -681,7 +648,7 @@ Atom nxagentLocalToRemoteAtom(Atom local) if (!ValidAtom(local)) { #ifdef DEBUG - fprintf(stderr, "%s: local [%d] is no valid - returning None\n", __func__, remote); + fprintf(stderr, "%s: local [%d] is no valid - returning None\n", __func__, local); #endif return None; } @@ -694,7 +661,9 @@ Atom nxagentLocalToRemoteAtom(Atom local) return local; } - if ((current = nxagentFindAtomByLocalValue(local))) + AtomMap *current = nxagentFindAtomByLocalValue(local); + + if (current) { #ifdef TEST fprintf(stderr, "%s: local [%d] -> remote [%d]\n", __func__, local, current->remote); @@ -702,9 +671,9 @@ Atom nxagentLocalToRemoteAtom(Atom local) return current->remote; } - string = NameForAtom(local); + const char *string = NameForAtom(local); - remote = XInternAtom(nxagentDisplay, string, False); + Atom remote = XInternAtom(nxagentDisplay, string, False); if (remote == None) { @@ -726,10 +695,6 @@ Atom nxagentLocalToRemoteAtom(Atom local) Atom nxagentRemoteToLocalAtom(Atom remote) { - AtomMap *current; - char *string; - Atom local; - if (remote == None || remote == BAD_RESOURCE) { #ifdef DEBUG @@ -746,11 +711,13 @@ Atom nxagentRemoteToLocalAtom(Atom remote) return remote; } - if ((current = nxagentFindAtomByRemoteValue(remote))) + AtomMap *current = nxagentFindAtomByRemoteValue(remote); + + if (current) { if (!ValidAtom(current->local)) { - local = MakeAtom(current->string, current->length, True); + Atom local = MakeAtom(current->string, current->length, True); if (ValidAtom(local)) { @@ -772,14 +739,16 @@ Atom nxagentRemoteToLocalAtom(Atom remote) return current->local; } - if ((string = XGetAtomName(nxagentDisplay, remote))) + char *string = XGetAtomName(nxagentDisplay, remote); + + if (string) { - local = MakeAtom(string, strlen(string), True); + Atom local = MakeAtom(string, strlen(string), True); if (!ValidAtom(local)) { #ifdef WARNING - fprintf(stderr, "nxagentRemoteToLocalAtom: WARNING MakeAtom failed.\n"); + fprintf(stderr, "%s: WARNING MakeAtom failed.\n", __func__); #endif local = None; @@ -796,7 +765,7 @@ Atom nxagentRemoteToLocalAtom(Atom remote) } #ifdef WARNING - fprintf(stderr, "nxagentRemoteToLocalAtom: WARNING failed to get name from remote atom.\n"); + fprintf(stderr, "%s: WARNING failed to get name from remote atom.\n", __func__); #endif return None; @@ -806,15 +775,13 @@ Atom nxagentRemoteToLocalAtom(Atom remote) static void nxagentPrintAtomMapInfo(char *message) { - unsigned i; - fprintf(stderr, "--------------- Atom map in context [%s] ----------------------\n", message); fprintf(stderr, "nxagentPrintAtomMapInfo: Map at [%p] size [%d] number of entry [%d] auto increment [%d].\n", (void*) privAtomMap, privLastAtom, privAtomMapSize, NXAGENT_ATOM_MAP_SIZE_INCREMENT); - for (i = 0; i < privLastAtom; i++) + for (unsigned int i = 0; i < privLastAtom; i++) { - fprintf(stderr, "[%5.1d] local: %6.1lu - remote: %6.1lu - [%p] %s\n", i, + fprintf(stderr, "[%5.1d] local: %6.1u - remote: %6.1u - [%p] %s\n", i, privAtomMap[i].local, privAtomMap[i].remote, privAtomMap[i].string, validateString(privAtomMap[i].string)); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.h b/nx-X11/programs/Xserver/hw/nxagent/Atoms.h index 391e06181..cbbb7bd1d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.h @@ -30,7 +30,7 @@ #include "../../include/window.h" #include "screenint.h" -#define NXAGENT_NUMBER_OF_ATOMS 16 +#define NXAGENT_NUMBER_OF_ATOMS 17 extern Atom nxagentAtoms[NXAGENT_NUMBER_OF_ATOMS]; @@ -41,7 +41,7 @@ extern Bool nxagentWMIsRunning; * to the agent server. */ -int nxagentInitAtoms(WindowPtr pWin); +void nxagentInitAtoms(); /* * Query and create all the required atoms diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 024d685ba..5f7bdab4e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -68,30 +68,35 @@ extern Selection *CurrentSelections; int nxagentLastClipboardClient = -1; static int agentClipboardStatus; +#ifdef DEBUG static int clientAccum; +#endif Atom serverCutProperty; Atom clientCutProperty; static Window serverWindow; -static const int nxagentPrimarySelection = 0; -static const int nxagentClipboardSelection = 1; -static const int nxagentMaxSelections = 2; +const int nxagentPrimarySelection = 0; +const int nxagentClipboardSelection = 1; +const int nxagentMaxSelections = 2; typedef struct _SelectionOwner { - Atom selection; - ClientPtr client; - Window window; - WindowPtr windowPtr; - Time lastTimeChanged; - + Atom selection; /* _external_ Atom */ + ClientPtr client; /* internal client */ + Window window; /* internal window id */ + WindowPtr windowPtr; /* internal window struct */ + Time lastTimeChanged; /* internal time */ } SelectionOwner; +/* + * this contains the last selection owner in nxagent. The + * lastTimeChanged is always an internal time. If .client is NULL the + * owner is outside nxagent. .selection will _always_ contain the + * external atom of the selection + */ static SelectionOwner *lastSelectionOwner; static Atom nxagentLastRequestedSelection; -static Atom nxagentClipboardAtom; -static Atom nxagentTimestampAtom; /* * Needed to handle the notify selection event to @@ -126,8 +131,10 @@ static Atom lastServerTarget; static Time lastServerTime; static Atom serverTARGETS; +static Atom serverTIMESTAMP; static Atom serverTEXT; static Atom serverUTF8_STRING; +static Atom serverClientCutProperty; static Atom clientTARGETS; static Atom clientTEXT; static Atom clientCOMPOUND_TEXT; @@ -158,6 +165,8 @@ const char * GetClientSelectionStageString(int stage) } #define SetClientSelectionStage(stage) do {fprintf(stderr, "%s: Changing selection stage from [%s] to [%s]\n", __func__, GetClientSelectionStageString(lastClientStage), GetClientSelectionStageString(SelectionStage##stage)); lastClientStage = SelectionStage##stage;} while (0) #define PrintClientSelectionStage() do {fprintf(stderr, "%s: Current selection stage [%s]\n", __func__, GetClientSelectionStageString(lastClientStage));} while (0) +#define WINDOWID(ptr) (ptr) ? (ptr->drawable.id) : 0 +#define CLINDEX(clientptr) (clientptr) ? (clientptr->index) : -1 #else #define SetClientSelectionStage(stage) do {lastClientStage = SelectionStage##stage;} while (0) #define PrintClientSelectionStage() @@ -201,11 +210,13 @@ XFixesAgentInfoRec nxagentXFixesInfo = { -1, -1, -1, 0 }; extern Display *nxagentDisplay; Bool nxagentValidServerTargets(Atom target); -void nxagentSendSelectionNotify(Atom property); +static void endTransfer(Bool success); +#define SELECTION_SUCCESS True +#define SELECTION_FAULT False void nxagentTransferSelection(int resource); void nxagentCollectPropertyEvent(int resource); void nxagentResetSelectionOwner(void); -WindowPtr nxagentGetClipboardWindow(Atom property, WindowPtr pWin); +WindowPtr nxagentGetClipboardWindow(Atom property); void nxagentNotifyConvertFailure(ClientPtr client, Window requestor, Atom selection, Atom target, Time time); int nxagentSendNotify(xEvent *event); @@ -217,21 +228,24 @@ void nxagentPrintSelectionStat(int sel) { SelectionOwner lOwner = lastSelectionOwner[sel]; Selection curSel = CurrentSelections[sel]; - char *s =NULL; + char *s = NULL; #ifdef CLIENTIDS fprintf(stderr, " lastSelectionOwner[].client [%p] index [%d] PID [%d] Cmd [%s]\n", (void *)lOwner.client, - lOwner.client ? lOwner.client->index : -1, + CLINDEX(lOwner.client), GetClientPid(lOwner.client), GetClientCmdName(lOwner.client)); #else fprintf(stderr, " lastSelectionOwner[].client [%p] index [%d]\n", (void *)lOwner.client, - lOwner.client ? lOwner.client->index : -1); + CLINDEX(lOwner.client)); #endif fprintf(stderr, " lastSelectionOwner[].window [0x%x]\n", lOwner.window); - fprintf(stderr, " lastSelectionOwner[].windowPtr [%p]\n", (void *)lOwner.windowPtr); + if (lOwner.windowPtr) + fprintf(stderr, " lastSelectionOwner[].windowPtr [%p] ([0x%x]\n", (void *)lOwner.windowPtr, WINDOWID(lOwner.windowPtr)); + else + fprintf(stderr, " lastSelectionOwner[].windowPtr -\n"); fprintf(stderr, " lastSelectionOwner[].lastTimeChanged [%u]\n", lOwner.lastTimeChanged); /* @@ -250,13 +264,13 @@ void nxagentPrintSelectionStat(int sel) #ifdef CLIENTIDS fprintf(stderr, " CurrentSelections[].client [%p] index [%d] PID [%d] Cmd [%s]\n", (void *)curSel.client, - curSel.client ? curSel.client->index : -1, + CLINDEX(curSel.client), GetClientPid(curSel.client), GetClientCmdName(curSel.client)); #else fprintf(stderr, " CurrentSelections[].client [%p] index [%d]\n", (void *)curSel.client, - curSel.client ? curSel.client->index : -1); + CLINDEX(curSel.client); #endif fprintf(stderr, " CurrentSelections[].window [0x%x]\n", curSel.window); return; @@ -298,14 +312,17 @@ void nxagentPrintClipboardStat(char *header) fprintf(stderr, " lastServerTime (Time) [%u]\n", lastServerTime); fprintf(stderr, "lastClient\n"); - fprintf(stderr, " lastClientWindowPtr (WindowPtr) [%p]\n", (void *)lastClientWindowPtr); + if (lastClientWindowPtr) + fprintf(stderr, " lastClientWindowPtr (WindowPtr) [%p] ([0x%x])\n", (void *)lastClientWindowPtr, WINDOWID(lastClientWindowPtr)); + else + fprintf(stderr, " lastClientWindowPtr (WindowPtr) -\n"); fprintf(stderr, " lastClientClientPtr (ClientPtr) [%p]\n", (void *)lastClientClientPtr); fprintf(stderr, " lastClientRequestor (Window) [0x%x]\n", lastClientRequestor); fprintf(stderr, " lastClientProperty (Atom) [% 4d][%s]\n", lastClientProperty, NameForAtom(lastClientProperty)); fprintf(stderr, " lastClientSelection (Atom) [% 4d][%s]\n", lastClientSelection, NameForAtom(lastClientSelection)); fprintf(stderr, " lastClientTarget (Atom) [% 4d][%s]\n", lastClientTarget, NameForAtom(lastClientTarget)); - fprintf(stderr, " lastClientTime (Time) [%u]\n", lastServerTime); - fprintf(stderr, " lastClientReqTime (Time) [%u]\n", lastServerReqTime); + fprintf(stderr, " lastClientTime (Time) [%u]\n", lastClientTime); + fprintf(stderr, " lastClientReqTime (Time) [%u]\n", lastClientReqTime); fprintf(stderr, " lastClientPropertySize (unsigned long) [%lu]\n", lastClientPropertySize); fprintf(stderr, " lastClientStage (ClientSelectionStage) [%d][%s]\n", lastClientStage, GetClientSelectionStageString(lastClientStage)); @@ -323,11 +340,11 @@ void nxagentPrintClipboardStat(char *header) fprintf(stderr, " serverUTF8_STRING [% 4d][%s]\n", serverUTF8_STRING, s); SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverCutProperty); fprintf(stderr, " serverCutProperty [% 4d][%s]\n", serverCutProperty, s); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverClientCutProperty); + fprintf(stderr, " serverClientCutProperty [% 4d][%s]\n", serverClientCutProperty, s); - SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, nxagentClipboardAtom); - fprintf(stderr, " nxagentClipboardAtom [% 4d][%s]\n", nxagentClipboardAtom, s); - SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, nxagentTimestampAtom); - fprintf(stderr, " nxagentTimestampAtom [% 4d][%s]\n", nxagentTimestampAtom, s); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTIMESTAMP); + fprintf(stderr, " serverTIMESTAMP [% 4d][%s]\n", serverTIMESTAMP, s); fprintf(stderr, "Atoms (inside nxagent)\n"); fprintf(stderr, " clientTARGETS [% 4d][%s]\n", clientTARGETS, NameForAtom(clientTARGETS)); @@ -352,6 +369,85 @@ int GetWindowProperty(WindowPtr pWin, Atom property, long longOffset, long longL unsigned long *nItems, unsigned long *bytesAfter, unsigned char **propData); +/* + * Send a SelectionNotify event to the real X server and do some error + * handling (in DEBUG mode) + */ +Status SendSelectionNotifyEventToServer(XSelectionEvent *event_to_send) +{ + Window w = event_to_send->requestor; + + event_to_send->type = SelectionNotify; + event_to_send->send_event = True; + event_to_send->display = nxagentDisplay; + + Status result = XSendEvent(nxagentDisplay, w, False, 0L, (XEvent *)event_to_send); + + #ifdef DEBUG + /* + * man XSendEvent: XSendEvent returns zero if the conversion to wire + * protocol format failed and returns nonzero otherwise. XSendEvent + * can generate BadValue and BadWindow errors. + */ + if (result == 0) + { + fprintf(stderr, "%s: XSendEvent to [0x%x] failed.\n", __func__, w); + } + else + { + if (result == BadValue || result == BadWindow) + { + fprintf(stderr, "%s: WARNING! XSendEvent to [0x%x] failed: %s\n", __func__, w, GetXErrorString(result)); + } + else + { + fprintf(stderr, "%s: XSendEvent() successfully sent to [0x%x]\n", __func__, w); + } + } + #endif + + //NXFlushDisplay(nxagentDisplay, NXFlushLink); + + return result; +} + +int SendEventToClient(ClientPtr client, xEvent *pEvents) +{ + return TryClientEvents (client, pEvents, 1, NoEventMask, NoEventMask, NullGrab); +} + +int SendSelectionNotifyEventToClient(ClientPtr client, + Time time, + Window requestor, + Atom selection, + Atom target, + Atom property) +{ + xEvent x = {0}; + x.u.u.type = SelectionNotify; + x.u.selectionNotify.time = time; + x.u.selectionNotify.requestor = requestor; + x.u.selectionNotify.selection = selection; + x.u.selectionNotify.target = target; + x.u.selectionNotify.property = property; + + #ifdef DEBUG + if (property == None) + fprintf (stderr, "%s: Denying request to client [%d].\n", __func__, + CLINDEX(client)); + else + fprintf (stderr, "%s: Sending event to client [%d].\n", __func__, + CLINDEX(client)); + #endif + + return SendEventToClient(client, &x); +} + +/* + * Check if target is a valid content type target sent by the real X + * server, like .e.g XA_STRING or UTF8_STRING. Other, non content type + * targets like "TARGETS" or "TIMESTAMP" will return false. + */ Bool nxagentValidServerTargets(Atom target) { if (target == XA_STRING) @@ -383,6 +479,13 @@ Bool nxagentValidServerTargets(Atom target) #endif return False; } + else if (target == serverTIMESTAMP) + { + #ifdef DEBUG + fprintf(stderr, "%s: special target [TIMESTAMP].\n", __func__); + #endif + return False; + } #ifdef DEBUG fprintf(stderr, "%s: invalid target [%u].\n", __func__, target); @@ -390,11 +493,28 @@ Bool nxagentValidServerTargets(Atom target) return False; } +void nxagentClearSelectionOwner(SelectionOwner *owner) +{ + /* there's no owner on nxagent side anymore */ + owner->client = NULL; + owner->window = None; + owner->lastTimeChanged = GetTimeInMillis(); + /* FIXME: why is windowPtr not cleared in the function? */ +} + +void nxagentStoreSelectionOwner(SelectionOwner *owner, Selection *sel) +{ + owner->client = sel->client; + owner->window = sel->window; + owner->windowPtr = sel->pWin; + owner->lastTimeChanged = GetTimeInMillis(); +} + void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) { #ifdef DEBUG - fprintf(stderr, "%s: Called with client [%p] window [%p].\n", __func__, - (void *) pClient, (void *) pWindow); + fprintf(stderr, "%s: Called with client [%p] index [%d] window [%p] ([0x%x]).\n", __func__, + (void *) pClient, CLINDEX(pClient), (void *) pWindow, WINDOWID(pWindow)); #endif nxagentPrintClipboardStat("before nxagentClearClipboard"); @@ -413,10 +533,9 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) (void *) pClient, (void *) pWindow); #endif - lastSelectionOwner[i].client = NULL; - lastSelectionOwner[i].window = None; + /* FIXME: why is windowPtr not cleared in the function? */ + nxagentClearSelectionOwner(&lastSelectionOwner[i]); lastSelectionOwner[i].windowPtr = NULL; - lastSelectionOwner[i].lastTimeChanged = GetTimeInMillis(); lastClientWindowPtr = NULL; SetClientSelectionStage(None); @@ -434,10 +553,35 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) nxagentPrintClipboardStat("after nxagentClearClipboard"); } -void nxagentClearSelection(XEvent *X) +int nxagentFindLastSelectionOwnerIndex(Atom sel) { int i = 0; + while ((i < nxagentMaxSelections) && + (lastSelectionOwner[i].selection != sel)) + { + i++; + } + return i; +} +int nxagentFindCurrentSelectionIndex(Atom sel) +{ + int i = 0; + while ((i < NumCurrentSelections) && + (CurrentSelections[i].selection != sel)) + { + i++; + } + return i; +} + +/* + * This is called from Events.c dispatch loop on reception of a + * SelectionClear event. We receive this event if someone on the real + * X server claims the selection ownership. + */ +void nxagentClearSelection(XEvent *X) +{ #ifdef DEBUG fprintf(stderr, "%s: SelectionClear event for selection [%lu].\n", __func__, X->xselectionclear.selection); #endif @@ -450,34 +594,31 @@ void nxagentClearSelection(XEvent *X) return; } - while ((i < nxagentMaxSelections) && - (lastSelectionOwner[i].selection != X->xselectionclear.selection)) - { - i++; - } + int i = nxagentFindLastSelectionOwnerIndex(X->xselectionclear.selection); if (i < nxagentMaxSelections) { if (lastSelectionOwner[i].client != NULL) { - xEvent x; - memset(&x, 0, sizeof(xEvent)); + /* send a SelectionClear event to (our) previous owner */ + xEvent x = {0}; x.u.u.type = SelectionClear; x.u.selectionClear.time = GetTimeInMillis(); x.u.selectionClear.window = lastSelectionOwner[i].window; x.u.selectionClear.atom = CurrentSelections[i].selection; - (void) TryClientEvents(lastSelectionOwner[i].client, &x, 1, - NoEventMask, NoEventMask, - NullGrab); + SendEventToClient(lastSelectionOwner[i].client, &x); } + /* + * set the root window with the NullClient as selection owner. Our + * clients asking for the owner via XGetSelectionOwner() will get + * these for an answer + */ CurrentSelections[i].window = screenInfo.screens[0]->root->drawable.id; CurrentSelections[i].client = NullClient; - lastSelectionOwner[i].client = NULL; - lastSelectionOwner[i].window = None; - lastSelectionOwner[i].lastTimeChanged = GetTimeInMillis(); + nxagentClearSelectionOwner(&lastSelectionOwner[i]); } lastClientWindowPtr = NULL; @@ -485,13 +626,63 @@ void nxagentClearSelection(XEvent *X) nxagentPrintClipboardStat("after nxagentClearSelection"); } -void nxagentRequestSelection(XEvent *X) +/* + * Send a SelectionNotify event as reply to the RequestSelection + * event X. If success is True take the property from the event, else + * take None (which reports "failed/denied" to the requestor. + */ + +void nxagentReplyRequestSelection(XEvent *X, Bool success) { - int i = 0; - XSelectionEvent eventSelection = {0}; + XSelectionEvent eventSelection = { + .requestor = X->xselectionrequest.requestor, + .selection = X->xselectionrequest.selection, + .target = X->xselectionrequest.target, + .time = X->xselectionrequest.time, + .property = X->xselectionrequest.property + }; + + if (!success) + { + #ifdef DEBUG + fprintf(stderr, "%s: denying request\n", __func__); + #endif + eventSelection.property = None; + } + + SendSelectionNotifyEventToServer(&eventSelection); + + NXFlushDisplay(nxagentDisplay, NXFlushLink); +} +/* + * This is called from Events.c dispatch loop on reception of a + * SelectionRequest event, meaning a client of the real X server wants + * to have the selection content. The real X server knows the nxagent + * as selection owner. But in reality one of our windows is the owner, + * so we must pass the request on to the real owner. + */ +void nxagentRequestSelection(XEvent *X) +{ #ifdef DEBUG - fprintf(stderr, "%s: Got called.\n", __func__); + { + char *strTarget = XGetAtomName(nxagentDisplay, X->xselectionrequest.target); + char *strSelection = XGetAtomName(nxagentDisplay, X->xselectionrequest.selection); + char *strProperty = XGetAtomName(nxagentDisplay, X->xselectionrequest.property); + + fprintf(stderr, "%s: Received SelectionRequest from real server: selection [%ld][%s] " \ + "target [%ld][%s] requestor [%s/0x%lx] destination [%ld][%s] lastServerRequestor [0x%x]\n", + __func__, + X->xselectionrequest.selection, validateString(strSelection), + X->xselectionrequest.target, validateString(strTarget), + DisplayString(nxagentDisplay), X->xselectionrequest.requestor, + X->xselectionrequest.property, validateString(strProperty), + lastServerRequestor); + + SAFE_XFree(strTarget); + SAFE_XFree(strSelection); + SAFE_XFree(strProperty); + } #endif nxagentPrintClipboardStat("before nxagentRequestSelection"); @@ -501,112 +692,122 @@ void nxagentRequestSelection(XEvent *X) return; } + /* + * check if this request needs special treatment by checking + * if any of the following is true: + * - this is a special request like TARGETS or TIMESTAMP + * - lastServerRequestor in non-NULL (= we are currenty in the transfer phase) + * - the selection in this request is none we own. + * In all cases we'll send back a SelectionNotify event with an + * appropriate answer + */ if (!nxagentValidServerTargets(X->xselectionrequest.target) || (lastServerRequestor != None) || ((X->xselectionrequest.selection != lastSelectionOwner[nxagentPrimarySelection].selection) && (X->xselectionrequest.selection != lastSelectionOwner[nxagentClipboardSelection].selection))) { -/* -FIXME: Do we need this? - - char *strTarget; - - strTarget = XGetAtomName(nxagentDisplay, X->xselectionrequest.target); - - fprintf(stderr, "SelectionRequest event aborting sele=[%s] target=[%s]\n", - validateString(NameForAtom(X->xselectionrequest.selection)), - validateString(NameForAtom(X->xselectionrequest.target))); + if (X->xselectionrequest.target == serverTARGETS) + { + /* + * the selection request target is TARGETS. The requestor is + * asking for a list of supported data formats. Currently + * there's only one format we support: XA_STRING + * + * The selection does not matter here, we will return this for + * PRIMARY and CLIPBOARD. + * + * FIXME: shouldn't we support UTF8_STRING, too? + * FIXME: I am wondering if we should align this with + * nxagentConvertSelection, where we report more formats. + * FIXME: the perfect solution should not just answer with + * XA_STRING but ask the real owner what format it supports. The + * should then be sent to the original requestor. + * FIXME: these must be external Atoms! + */ - fprintf(stderr, "SelectionRequest event aborting sele=[%s] ext target=[%s] Atom size is [%d]\n", - validateString(NameForAtom(X->xselectionrequest.selection)), strTarget, sizeof(Atom)); + Atom targets[] = {XA_STRING}; + int numTargets = 1; - SAFE_XFree(strTarget); -*/ - memset(&eventSelection, 0, sizeof(XSelectionEvent)); - eventSelection.property = None; + #ifdef DEBUG + fprintf(stderr, "%s: available targets:\n", __func__); + for (int i = 0; i < numTargets; i++) + fprintf(stderr, "%s: %s\n", __func__, NameForAtom(targets[i])); + fprintf(stderr, "\n"); + #endif - if (X->xselectionrequest.target == serverTARGETS) - { - Atom xa_STRING = XA_STRING; - XChangeProperty (nxagentDisplay, - X->xselectionrequest.requestor, - X->xselectionrequest.property, - XInternAtom(nxagentDisplay, "ATOM", 0), - sizeof(Atom)*8, - PropModeReplace, - (unsigned char*)&xa_STRING, - 1); - eventSelection.property = X->xselectionrequest.property; + /* + * pass on the requested list by setting the property provided + * by the requestor accordingly. + */ + XChangeProperty(nxagentDisplay, + X->xselectionrequest.requestor, + X->xselectionrequest.property, + XInternAtom(nxagentDisplay, "ATOM", 0), + sizeof(Atom)*8, + PropModeReplace, + (unsigned char*)&targets, + numTargets); + + nxagentReplyRequestSelection(X, True); } - else if (X->xselectionrequest.target == nxagentTimestampAtom) + else if (X->xselectionrequest.target == serverTIMESTAMP) { - while ((i < NumCurrentSelections) && - lastSelectionOwner[i].selection != X->xselectionrequest.selection) i++; + /* + * Section 2.6.2 of the ICCCM states: + * TIMESTAMP - To avoid some race conditions, it is important + * that requestors be able to discover the timestamp the owner + * used to acquire ownership. Until and unless the protocol is + * changed so that a GetSelectionOwner request returns the + * timestamp used to acquire ownership, selection owners must + * support conversion to TIMESTAMP, returning the timestamp they + * used to obtain the selection. + * + * FIXME: ensure we are reporting an _external_ timestamp + */ - if (i < NumCurrentSelections) + int i = nxagentFindLastSelectionOwnerIndex(X->xselectionrequest.selection); + if (i < nxagentMaxSelections) { XChangeProperty(nxagentDisplay, - X->xselectionrequest.requestor, - X->xselectionrequest.property, - X->xselectionrequest.target, - 32, - PropModeReplace, - (unsigned char *) &lastSelectionOwner[i].lastTimeChanged, - 1); - eventSelection.property = X->xselectionrequest.property; + X->xselectionrequest.requestor, + X->xselectionrequest.property, + XA_INTEGER, + 32, + PropModeReplace, + (unsigned char *) &lastSelectionOwner[i].lastTimeChanged, + 1); + nxagentReplyRequestSelection(X, True); } } - - eventSelection.type = SelectionNotify; - eventSelection.send_event = True; - eventSelection.display = nxagentDisplay; - eventSelection.requestor = X->xselectionrequest.requestor; - eventSelection.selection = X->xselectionrequest.selection; - eventSelection.target = X->xselectionrequest.target; - eventSelection.time = X->xselectionrequest.time; - - #ifdef DEBUG - int result = - #endif - XSendEvent(nxagentDisplay, - eventSelection.requestor, - False, - 0L, - (XEvent *) &eventSelection); - - #ifdef DEBUG - fprintf(stderr, "%s: XSendEvent() returned [%s]\n", __func__, GetXErrorString(result)); - if (result == BadValue || result == BadWindow) - { - fprintf(stderr, "%s: WARNING! XSendEvent failed.\n", __func__); - } else { - fprintf(stderr, "%s: XSendEvent sent to window [0x%lx].\n", __func__, - eventSelection.requestor); + /* deny the request */ + nxagentReplyRequestSelection(X, False); } - #endif - return; } /* - * This is necessary in nxagentGetClipboardWindow. + * reaching this means the request is neither a special request nor + * invalid. We can process it now. */ + /* + * This is required for nxagentGetClipboardWindow. + */ nxagentLastRequestedSelection = X->xselectionrequest.selection; - /* FIXME: shouldn't we reset i to 0 here first? */ - while ((i < nxagentMaxSelections) && - (lastSelectionOwner[i].selection != X->xselectionrequest.selection)) - { - i++; - } - + /* find the index of the requested selection */ + int i = nxagentFindLastSelectionOwnerIndex(X->xselectionrequest.selection); if (i < nxagentMaxSelections) { if ((lastClientWindowPtr != NULL) && (lastSelectionOwner[i].client != NULL)) { + /* + * Request the real X server to transfer the selection content + * to the NX_CUT_BUFFER_CLIENT property of the serverWindow. + * FIXME: document how we can end up here + */ XConvertSelection(nxagentDisplay, CurrentSelections[i].selection, X->xselectionrequest.target, serverCutProperty, serverWindow, lastClientTime); @@ -617,141 +818,121 @@ FIXME: Do we need this? } else { - if (lastSelectionOwner[i].client != NULL && + /* + * if one of our clients owns the selection we ask it to copy + * the selection to the clientCutProperty on nxagent's root + * window + */ + if (lastSelectionOwner[i].client != NULL && nxagentOption(Clipboard) != ClipboardClient) { - xEvent x; - + /* + * store who on the real X server requested the data and how + * and where it wants to have it + */ lastServerProperty = X->xselectionrequest.property; lastServerRequestor = X->xselectionrequest.requestor; lastServerTarget = X->xselectionrequest.target; + lastServerTime = X->xselectionrequest.time; /* by dimbor */ if (lastServerTarget != XA_STRING) lastServerTarget = serverUTF8_STRING; - lastServerTime = X->xselectionrequest.time; - - memset(&x, 0, sizeof(xEvent)); + /* prepare the request (like XConvertSelection, but internally) */ + xEvent x = {0}; x.u.u.type = SelectionRequest; x.u.selectionRequest.time = GetTimeInMillis(); x.u.selectionRequest.owner = lastSelectionOwner[i].window; + x.u.selectionRequest.selection = CurrentSelections[i].selection; + x.u.selectionRequest.property = clientCutProperty; + x.u.selectionRequest.requestor = screenInfo.screens[0]->root->drawable.id; /* Fictitious window.*/ /* - * Fictitious window. - */ - - x.u.selectionRequest.requestor = screenInfo.screens[0]->root->drawable.id; - - /* - * Don't send the same window, some programs are - * clever and verify cut and paste operations - * inside the same window and don't Notify at all. + * Don't send the same window, some programs are clever and + * verify cut and paste operations inside the same window and + * don't Notify at all. * * x.u.selectionRequest.requestor = lastSelectionOwnerWindow; */ - x.u.selectionRequest.selection = CurrentSelections[i].selection; - /* by dimbor (idea from zahvatov) */ if (X->xselectionrequest.target != XA_STRING) x.u.selectionRequest.target = clientUTF8_STRING; else x.u.selectionRequest.target = XA_STRING; - x.u.selectionRequest.property = clientCutProperty; - - (void) TryClientEvents(lastSelectionOwner[i].client, &x, 1, - NoEventMask, NoEventMask /* CantBeFiltered */, - NullGrab); + SendEventToClient(lastSelectionOwner[i].client, &x); #ifdef DEBUG - fprintf(stderr, "%s: Executed TryClientEvents with clientCutProperty.\n", __func__); + fprintf(stderr, "%s: sent SelectionRequest event to client [%d] property [%d][%s]" \ + "target [%d][%s] requestor [0x%x].\n", __func__, + CLINDEX(lastSelectionOwner[i].client), + x.u.selectionRequest.property, NameForAtom(x.u.selectionRequest.property), + x.u.selectionRequest.target, NameForAtom(x.u.selectionRequest.target), + x.u.selectionRequest.requestor); #endif } else { - /* - * Probably we must send a Notify - * to requestor with property None. - */ - - eventSelection.type = SelectionNotify; - eventSelection.send_event = True; - eventSelection.display = nxagentDisplay; - eventSelection.requestor = X->xselectionrequest.requestor; - eventSelection.selection = X->xselectionrequest.selection; - eventSelection.target = X->xselectionrequest.target; - eventSelection.property = None; - eventSelection.time = X->xselectionrequest.time; - - #ifdef DEBUG - int result = - #endif - XSendEvent(nxagentDisplay, - eventSelection.requestor, - False, - 0L, - (XEvent *) &eventSelection); - - #ifdef DEBUG - fprintf(stderr, "%s: XSendEvent() returned [%s]\n", __func__, GetXErrorString(result)); - if (result == BadValue || result == BadWindow) - { - fprintf(stderr, "%s: WARNING! XSendEvent failed.\n", __func__); - } - else - { - fprintf(stderr, "%s: XSendEvent with property None sent to window [0x%lx].\n", __func__, - eventSelection.requestor); - } - #endif + /* deny the request */ + nxagentReplyRequestSelection(X, False); } } } nxagentPrintClipboardStat("after nxagentRequestSelection"); } -void nxagentSendSelectionNotify(Atom property) +/* + * end current selection transfer by sending a notification to the + * client and resetting the corresponding variables and the state + * machine. If success is False send a None reply, meaning "request + * denied/failed" + * Use SELECTION_SUCCESS and SELECTION_FAULT macros for success. + */ +static void endTransfer(Bool success) { - xEvent x; + if (lastClientClientPtr == NULL) + { + #ifdef DEBUG + fprintf(stderr, "%s: lastClientClientPtr is NULL - doing nothing.\n", __func__); + #endif + return; + } #ifdef DEBUG - fprintf (stderr, "%s: Sending event to client [%d].\n", __func__, - lastClientClientPtr -> index); + if (success == SELECTION_SUCCESS) + fprintf(stderr, "%s: sending notification to client [%d], property [%d][%s]\n", __func__, + CLINDEX(lastClientClientPtr), lastClientProperty, NameForAtom(lastClientProperty)); + else + fprintf(stderr, "%s: sending negative notification to client [%d]\n", __func__, + CLINDEX(lastClientClientPtr)); #endif - memset(&x, 0, sizeof(xEvent)); - x.u.u.type = SelectionNotify; - - x.u.selectionNotify.time = lastClientTime; - x.u.selectionNotify.requestor = lastClientRequestor; - x.u.selectionNotify.selection = lastClientSelection; - x.u.selectionNotify.target = lastClientTarget; + SendSelectionNotifyEventToClient(lastClientClientPtr, + lastClientTime, + lastClientRequestor, + lastClientSelection, + lastClientTarget, + success == SELECTION_SUCCESS ? lastClientProperty : None); - x.u.selectionNotify.property = property; - - TryClientEvents(lastClientClientPtr, &x, 1, NoEventMask, - NoEventMask , NullGrab); - - return; + /* + * Enable further requests from clients. + */ + lastClientWindowPtr = NULL; + SetClientSelectionStage(None); } void nxagentTransferSelection(int resource) { - int result; - if (lastClientClientPtr -> index != resource) { #ifdef DEBUG fprintf (stderr, "%s: WARNING! Inconsistent resource [%d] with current client [%d].\n", __func__, - resource, lastClientClientPtr -> index); + resource, CLINDEX(lastClientClientPtr)); #endif - nxagentSendSelectionNotify(None); - - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); + endTransfer(SELECTION_FAULT); return; } @@ -760,6 +941,8 @@ void nxagentTransferSelection(int resource) { case SelectionStageQuerySize: { + int result; + PrintClientSelectionStage(); /* * Don't get data yet, just get size. We skip @@ -793,23 +976,24 @@ void nxagentTransferSelection(int resource) { #ifdef DEBUG fprintf (stderr, "%s: Aborting selection notify procedure for client [%d].\n", __func__, - lastClientClientPtr -> index); + CLINDEX(lastClientClientPtr)); #endif - nxagentSendSelectionNotify(None); - - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); + endTransfer(SELECTION_FAULT); return; } SetClientSelectionStage(WaitSize); + NXFlushDisplay(nxagentDisplay, NXFlushLink); + break; } case SelectionStageQueryData: { + int result; + PrintClientSelectionStage(); /* @@ -846,26 +1030,27 @@ void nxagentTransferSelection(int resource) { #ifdef DEBUG fprintf (stderr, "%s: Aborting selection notify procedure for client [%d].\n", __func__, - lastClientClientPtr -> index); + CLINDEX(lastClientClientPtr)); #endif - nxagentSendSelectionNotify(None); - - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); + endTransfer(SELECTION_FAULT); return; } SetClientSelectionStage(WaitData); + /* we've seen situations where you had to move the mouse or press a + key to let the transfer complete. Flushing here fixed it */ + NXFlushDisplay(nxagentDisplay, NXFlushLink); + break; } default: { #ifdef DEBUG fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__, - GetClientSelectionStageString(lastClientStage), lastClientClientPtr -> index); + GetClientSelectionStageString(lastClientStage), CLINDEX(lastClientClientPtr)); #endif break; @@ -873,6 +1058,13 @@ void nxagentTransferSelection(int resource) } } +/* + Called from Events.c/nxagentHandlePropertyNotify + + This event is generated after XChangeProperty(), XDeleteProperty() or + XGetWindowProperty(delete=True) +*/ + void nxagentCollectPropertyEvent(int resource) { Atom atomReturnType; @@ -883,9 +1075,8 @@ void nxagentCollectPropertyEvent(int resource) int result; /* - * We have received the notification so - * we can safely retrieve data from the - * client structure. + * We have received the notification so we can safely retrieve data + * from the client structure. */ result = NXGetCollectedProperty(nxagentDisplay, @@ -901,168 +1092,151 @@ void nxagentCollectPropertyEvent(int resource) if (result == 0) { #ifdef DEBUG - fprintf (stderr, "%s: Failed to get reply data for client [%d].\n", __func__, - lastClientClientPtr -> index); + fprintf (stderr, "%s: Failed to get reply data.\n", __func__); #endif - nxagentSendSelectionNotify(None); - - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); - - SAFE_XFree(pszReturnData); - return; + endTransfer(SELECTION_FAULT); } - - if (resultFormat != 8 && resultFormat != 16 && resultFormat != 32) + else if (resultFormat != 8 && resultFormat != 16 && resultFormat != 32) { #ifdef DEBUG - fprintf (stderr, "%s: WARNING! Invalid property value.\n", __func__); + fprintf (stderr, "%s: WARNING! Invalid property format.\n", __func__); #endif - if (lastClientClientPtr != NULL) - { - nxagentSendSelectionNotify(None); - } - - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); - - SAFE_XFree(pszReturnData); - return; + endTransfer(SELECTION_FAULT); } - - switch (lastClientStage) + else { - case SelectionStageWaitSize: + switch (lastClientStage) { - PrintClientSelectionStage(); - #ifdef DEBUG - fprintf (stderr, "%s: Got size notify event for client [%d].\n", __func__, - lastClientClientPtr -> index); - #endif - - if (ulReturnBytesLeft == 0) + case SelectionStageWaitSize: { + PrintClientSelectionStage(); #ifdef DEBUG - fprintf (stderr, "%s: Aborting selection notify procedure for client [%d].\n", __func__, - lastClientClientPtr -> index); + fprintf (stderr, "%s: Got size notify event for client [%d].\n", __func__, + CLINDEX(lastClientClientPtr)); #endif - nxagentSendSelectionNotify(None); + if (ulReturnBytesLeft == 0) + { + #ifdef DEBUG + fprintf (stderr, "%s: Aborting selection notify procedure.\n", __func__); + #endif - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); + endTransfer(SELECTION_FAULT); + } + else + { + #ifdef DEBUG + fprintf(stderr, "%s: Got property size from remote server.\n", __func__); + #endif - SAFE_XFree(pszReturnData); - return; - } + /* + * Request the selection data now. + */ + lastClientPropertySize = ulReturnBytesLeft; + SetClientSelectionStage(QueryData); - #ifdef DEBUG - fprintf(stderr, "%s: Got property size from remote server.\n", __func__); - #endif + nxagentTransferSelection(resource); + } + break; + } + case SelectionStageWaitData: + { + PrintClientSelectionStage(); + #ifdef DEBUG + fprintf (stderr, "%s: Got data notify event for client [%d].\n", __func__, + CLINDEX(lastClientClientPtr)); + #endif - /* - * Request the selection data now. - */ + if (ulReturnBytesLeft != 0) + { + #ifdef DEBUG + fprintf (stderr, "%s: Aborting selection notify procedure.\n", __func__); + #endif - lastClientPropertySize = ulReturnBytesLeft; - SetClientSelectionStage(QueryData); + endTransfer(SELECTION_FAULT); + } + else + { + #ifdef DEBUG + fprintf(stderr, "%s: Got property content from remote server.\n", __func__); + #endif - nxagentTransferSelection(resource); + ChangeWindowProperty(lastClientWindowPtr, + lastClientProperty, + lastClientTarget, + resultFormat, PropModeReplace, + ulReturnItems, pszReturnData, 1); - break; - } - case SelectionStageWaitData: - { - PrintClientSelectionStage(); - #ifdef DEBUG - fprintf (stderr, "%s: Got data notify event for client [%d].\n", __func__, - lastClientClientPtr -> index); - #endif + #ifdef DEBUG + fprintf(stderr, "%s: Selection property [%d][%s] changed to [\"%*.*s\"...]\n", __func__, + lastClientProperty, validateString(NameForAtom(lastClientProperty)), + (int)(min(20, ulReturnItems * resultFormat / 8)), + (int)(min(20, ulReturnItems * resultFormat / 8)), + pszReturnData); + #endif - if (ulReturnBytesLeft != 0) + endTransfer(SELECTION_SUCCESS); + } + break; + } + default: { #ifdef DEBUG - fprintf (stderr, "%s: Aborting selection notify procedure for client [%d].\n", __func__, - lastClientClientPtr -> index); + fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__, + GetClientSelectionStageString(lastClientStage), CLINDEX(lastClientClientPtr)); #endif - - nxagentSendSelectionNotify(None); - - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); - - SAFE_XFree(pszReturnData); - return; + break; } - - #ifdef DEBUG - fprintf(stderr, "%s: Got property content from remote server.\n", __func__); - #endif - - ChangeWindowProperty(lastClientWindowPtr, - lastClientProperty, - lastClientTarget, - resultFormat, PropModeReplace, - ulReturnItems, pszReturnData, 1); - - #ifdef DEBUG - fprintf(stderr, "%s: Selection property [%s] changed to [%s]\n", __func__, - validateString(NameForAtom(lastClientProperty)), pszReturnData); - #endif - - nxagentSendSelectionNotify(lastClientProperty); - - /* - * Enable further requests from clients. - */ - - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); - - break; - } - default: - { - #ifdef DEBUG - fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__, - GetClientSelectionStageString(lastClientStage), lastClientClientPtr -> index); - #endif - - break; } } - SAFE_XFree(pszReturnData); } -void nxagentNotifySelection(XEvent *X) +/* + * This is _only_ called from Events.c dispatch loop on reception of a + * SelectionNotify event from the real X server. These events are + * sent out by nxagent itself! + */ +void nxagentHandleSelectionNotifyFromXServer(XEvent *X) { - XSelectionEvent eventSelection; - - #ifdef DEBUG - fprintf(stderr, "%s: Got called.\n", __func__); - #endif - if (agentClipboardStatus != 1) { return; } #ifdef DEBUG - fprintf(stderr, "%s: SelectionNotify event.\n", __func__); + { + XSelectionEvent * e = (XSelectionEvent *)X; + char * s = XGetAtomName(nxagentDisplay, e->property); + char * t = XGetAtomName(nxagentDisplay, e->target); + fprintf(stderr, "%s: SelectionNotify event from real X server, property "\ + "[%ld][%s] requestor [0x%lx] target [%ld][%s] time [%ld] send_event [%d].\n", + __func__, e->property, validateString(s), e->requestor, e->target, + validateString(t), e->time, e->send_event); + SAFE_XFree(s); + SAFE_XFree(t); + } #endif PrintClientSelectionStage(); if (lastClientWindowPtr != NULL) { + /* + * We reach here after a paste inside the nxagent, triggered by + * the XConvertSelection call in nxagentConvertSelection(). This + * means that data we need has been transferred to the + * serverCutProperty of the serverWindow (our window on the real X + * server). We now need to transfer it to the original requestor, + * which is stored in the lastClient* variables. + */ if ((lastClientStage == SelectionStageNone) && (X->xselection.property == serverCutProperty)) { #ifdef DEBUG fprintf(stderr, "%s: Starting selection transferral for client [%d].\n", __func__, - lastClientClientPtr -> index); + CLINDEX(lastClientClientPtr)); #endif /* @@ -1085,31 +1259,21 @@ void nxagentNotifySelection(XEvent *X) { #ifdef DEBUG fprintf(stderr, "%s: WARNING! Resetting selection transferral for client [%d].\n", __func__, - lastClientClientPtr -> index); + CLINDEX(lastClientClientPtr)); #endif - nxagentSendSelectionNotify(None); - - lastClientWindowPtr = NULL; - SetClientSelectionStage(None); + endTransfer(SELECTION_FAULT); } - - return; } else { - int i = 0; - - while ((i < nxagentMaxSelections) && (lastSelectionOwner[i].selection != X->xselection.selection)) - { - i++; - } - + int i = nxagentFindLastSelectionOwnerIndex(X->xselection.selection); if (i < nxagentMaxSelections) { + /* if the last owner was an internal one */ if ((lastSelectionOwner[i].client != NULL) && (lastSelectionOwner[i].windowPtr != NULL) && - (X->xselection.property == clientCutProperty)) + (X->xselection.property == serverClientCutProperty)) { Atom atomReturnType; int resultFormat; @@ -1117,94 +1281,97 @@ void nxagentNotifySelection(XEvent *X) unsigned long ulReturnBytesLeft; unsigned char *pszReturnData = NULL; + /* first get size values ... */ int result = GetWindowProperty(lastSelectionOwner[i].windowPtr, clientCutProperty, 0, 0, False, AnyPropertyType, &atomReturnType, &resultFormat, &ulReturnItems, &ulReturnBytesLeft, &pszReturnData); #ifdef DEBUG - fprintf(stderr, "%s: GetWindowProperty() returned [%s]\n", __func__, GetXErrorString(result)); + fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__, + lastSelectionOwner[i].window, clientCutProperty, GetXErrorString(result)); #endif if (result == BadAlloc || result == BadAtom || result == BadWindow || result == BadValue) { - fprintf (stderr, "Client GetProperty failed. Error = %s", GetXErrorString(result)); lastServerProperty = None; } else { + /* ... then use the size values for the actual request */ result = GetWindowProperty(lastSelectionOwner[i].windowPtr, clientCutProperty, 0, ulReturnBytesLeft, False, AnyPropertyType, &atomReturnType, &resultFormat, &ulReturnItems, &ulReturnBytesLeft, &pszReturnData); #ifdef DEBUG - fprintf(stderr, "%s: GetWindowProperty() returned [%s]\n", __func__, GetXErrorString(result)); + fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__, + lastSelectionOwner[i].window, clientCutProperty, GetXErrorString(result)); #endif if (result == BadAlloc || result == BadAtom || result == BadWindow || result == BadValue) { - fprintf (stderr, "SelectionNotify - XChangeProperty failed. Error = %s\n", GetXErrorString(result)); lastServerProperty = None; } else { - result = XChangeProperty(nxagentDisplay, - lastServerRequestor, - lastServerProperty, - lastServerTarget, - 8, - PropModeReplace, - pszReturnData, - ulReturnItems); + /* Fill the property on the initial requestor with the requested data */ + /* The XChangeProperty source code reveals it will always + return 1, no matter what, so no need to check the result */ + /* FIXME: better use the format returned by above request */ + XChangeProperty(nxagentDisplay, + lastServerRequestor, + lastServerProperty, + lastServerTarget, + 8, + PropModeReplace, + pszReturnData, + ulReturnItems); + + #ifdef DEBUG + { + char *s = XGetAtomName(nxagentDisplay, lastServerProperty); + fprintf(stderr, "%s: XChangeProperty sent to window [0x%x] for property [%d][%s] value [\"%*.*s\"...]\n", + __func__, + lastServerRequestor, + lastServerProperty, + s, + (int)(min(20, ulReturnItems * 8 / 8)), + (int)(min(20, ulReturnItems * 8 / 8)), + pszReturnData); + SAFE_XFree(s); + } + #endif } - #ifdef DEBUG - fprintf(stderr, "%s: XChangeProperty() returned [%s]\n", __func__, GetXErrorString(result)); - #endif + /* FIXME: free it or not? */ /* * SAFE_XFree(pszReturnData); */ - } - memset(&eventSelection, 0, sizeof(XSelectionEvent)); - eventSelection.type = SelectionNotify; - eventSelection.send_event = True; - eventSelection.display = nxagentDisplay; - eventSelection.requestor = lastServerRequestor; - - eventSelection.selection = X->xselection.selection; - /* - * eventSelection.target = X->xselection.target; + * inform the initial requestor that the requested data has + * arrived in the desired property. If we have been unable to + * get the data from the owner XChangeProperty will not have + * been called and lastServerProperty will be None which + * effectively will send a "Request denied" to the initial + * requestor. */ - - eventSelection.target = lastServerTarget; - eventSelection.property = lastServerProperty; - eventSelection.time = lastServerTime; - - /* - * eventSelection.time = CurrentTime; - * eventSelection.time = lastServerTime; - */ - + XSelectionEvent eventSelection = { + .requestor = lastServerRequestor, + .selection = X->xselection.selection, + /* .target = X->xselection.target, */ + .target = lastServerTarget, + .property = lastServerProperty, + .time = lastServerTime, + /* .time = CurrentTime */ + }; #ifdef DEBUG - fprintf(stderr, "%s: Sending event to requestor [%p].\n", __func__, (void *)eventSelection.requestor); + fprintf(stderr, "%s: Sending SelectionNotify event to requestor [%p].\n", __func__, + (void *)eventSelection.requestor); #endif - result = XSendEvent(nxagentDisplay, - eventSelection.requestor, - False, - 0L, - (XEvent *) &eventSelection); - - #ifdef DEBUG - fprintf(stderr, "%s: XSendEvent() returned [%s]\n", __func__, GetXErrorString(result)); - #endif - if (result == BadValue || result == BadWindow) - { - fprintf (stderr, "SelectionRequest - XSendEvent failed\n"); - } + SendSelectionNotifyEventToServer(&eventSelection); lastServerRequestor = None; /* allow further request */ } @@ -1213,21 +1380,24 @@ void nxagentNotifySelection(XEvent *X) } /* - * Acquire selection so we don't get selection - * requests from real X clients. + * Let nxagent's serverWindow acquire the selection. All requests from + * the real X server (or its clients) will be sent to this window. The + * real X server never communicates with our windows directly. */ - void nxagentResetSelectionOwner(void) { - int i; - if (lastServerRequestor != None) { - #ifdef TEST + /* + * we are in the process of communicating back and forth between + * real X server and nxagent's clients - let's not disturb. + */ + #if defined(TEST) || defined(DEBUG) fprintf(stderr, "%s: WARNING! Requestor window [0x%x] already found.\n", __func__, lastServerRequestor); #endif + /* FIXME: maybe we should put back the event that lead us here. */ return; } @@ -1235,39 +1405,44 @@ void nxagentResetSelectionOwner(void) * Only for PRIMARY and CLIPBOARD selections. */ - for (i = 0; i < nxagentMaxSelections; i++) + for (int i = 0; i < nxagentMaxSelections; i++) { XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime); #ifdef DEBUG - fprintf(stderr, "%s: Reset clipboard state.\n", __func__); + fprintf(stderr, "%s: Reset selection state for selection [%d].\n", __func__, i); #endif - lastSelectionOwner[i].client = NULL; - lastSelectionOwner[i].window = None; + nxagentClearSelectionOwner(&lastSelectionOwner[i]); lastSelectionOwner[i].windowPtr = NULL; - lastSelectionOwner[i].lastTimeChanged = GetTimeInMillis(); } lastClientWindowPtr = NULL; SetClientSelectionStage(None); + /* Hmm, this is already None when reaching this */ lastServerRequestor = None; - - return; } #ifdef NXAGENT_CLIPBOARD + +/* + * The callback is called from dix. This is the normal operation + * mode. The callback is also called when nxagent gets XFixes events + * from the real X server. In that case the Trap is set and the + * callback will do nothing. + */ + void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, void *args) { /* - * Only act if the Trap is unset. The trap indicates that we are - * triggered by a clipboard event originating from the real X - * server. In that case we do not want to propagate back changes to - * the real X server, because it already knows about them and we + * Only act if the trap is unset. The trap indicates that we are + * triggered by an XFixes clipboard event originating from the real + * X server. In that case we do not want to propagate back changes + * to the real X server, because it already knows about them and we * would end up in an infinite loop of events. If there was a better - * way to identify that situation during Callback processing we + * way to identify that situation during callback processing we * could get rid of the Trap... */ if (nxagentExternalClipboardEventTrap != 0) @@ -1290,7 +1465,7 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, { #ifdef DEBUG fprintf(stderr, "%s: called with SelectionCallbackKind SelectionSetOwner\n", __func__); - fprintf(stderr, "%s: pCurSel->pWin [0x%x]\n", __func__, pCurSel->pWin ? pCurSel->pWin->drawable.id : NULL); + fprintf(stderr, "%s: pCurSel->pWin [0x%x]\n", __func__, WINDOWID(pCurSel->pWin)); fprintf(stderr, "%s: pCurSel->selection [%s]\n", __func__, NameForAtom(pCurSel->selection)); #endif @@ -1326,12 +1501,12 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, } #endif +/* + * This is called from the nxagentSetSelectionCallback, so it is using + * internal Atoms + */ void nxagentSetSelectionOwner(Selection *pSelection) { - #ifdef DEBUG - fprintf(stderr, "%s: Got called.\n", __func__); - #endif - if (agentClipboardStatus != 1) { return; @@ -1342,10 +1517,14 @@ void nxagentSetSelectionOwner(Selection *pSelection) serverWindow); #endif - #ifdef TEST + #if defined(TEST) || defined(DEBUG) if (lastServerRequestor != None) { - fprintf (stderr, "%s: WARNING! Requestor window [0x%x] already found.\n", __func__, + /* + * we are in the process of communicating back and forth between + * real X server and nxagent's clients - let's not disturb + */ + fprintf (stderr, "%s: WARNING! Requestor window [0x%x] already set.\n", __func__, lastServerRequestor); } #endif @@ -1356,28 +1535,37 @@ void nxagentSetSelectionOwner(Selection *pSelection) for (int i = 0; i < nxagentMaxSelections; i++) { + /* FIXME: using CurrentSelections with the index limited my MaxSelections looks wrong */ if (pSelection->selection == CurrentSelections[i].selection) { #ifdef DEBUG - fprintf(stderr, "%s: lastSelectionOwner.client [0x%x] -> [0x%x]\n", __func__, lastSelectionOwner[i].client, pSelection->client); - fprintf(stderr, "%s: lastSelectionOwner.window [0x%x] -> [0x%x]\n", __func__, lastSelectionOwner[i].window, pSelection->window); - fprintf(stderr, "%s: lastSelectionOwner.windowPtr [0x%x] -> [0x%x] [0x%x] (serverWindow: [0x%x])\n", __func__, lastSelectionOwner[i].windowPtr, pSelection->pWin, nxagentWindow(pSelection->pWin), serverWindow); - fprintf(stderr, "%s: lastSelectionOwner.lastTimeChanged [%d]\n", __func__, lastSelectionOwner[i].lastTimeChanged); + fprintf(stderr, "%s: lastSelectionOwner.client [%p] index [%d] -> [%p] index [%d]\n", __func__, + (void *)lastSelectionOwner[i].client, + CLINDEX(lastSelectionOwner[i].client), + (void *)pSelection->client, + CLINDEX(pSelection->client)); + fprintf(stderr, "%s: lastSelectionOwner.window [0x%x] -> [0x%x]\n", __func__, + lastSelectionOwner[i].window, pSelection->window); + fprintf(stderr, "%s: lastSelectionOwner.windowPtr [%p] -> [%p] [0x%x] (serverWindow: [0x%x])\n", __func__, + (void *)lastSelectionOwner[i].windowPtr, (void *)pSelection->pWin, + nxagentWindow(pSelection->pWin), serverWindow); + fprintf(stderr, "%s: lastSelectionOwner.lastTimeChanged [%d]\n", __func__, + lastSelectionOwner[i].lastTimeChanged); #endif /* * inform the real X server that our serverWindow is the - * clipboard owner. The real owner window (inside nxagent) is - * stored in lastSelectionOwner.window. - * lastSelectionOwner.windowPtr points to the struct that - * contains all information about the owner window + * clipboard owner. */ XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime); - lastSelectionOwner[i].client = pSelection->client; - lastSelectionOwner[i].window = pSelection->window; - lastSelectionOwner[i].windowPtr = pSelection->pWin; - lastSelectionOwner[i].lastTimeChanged = GetTimeInMillis(); + /* + * The real owner window (inside nxagent) is stored in + * lastSelectionOwner.window. lastSelectionOwner.windowPtr + * points to the struct that contains all information about the + * owner window. + */ + nxagentStoreSelectionOwner(&lastSelectionOwner[i], pSelection); } } @@ -1410,12 +1598,9 @@ FIXME void nxagentNotifyConvertFailure(ClientPtr client, Window requestor, Atom selection, Atom target, Time time) { - xEvent x; - -/* -FIXME: Why this pointer can be not a valid - client pointer? -*/ + /* + * Check if the client is still valid. + */ if (clients[client -> index] != client) { #ifdef WARNING @@ -1425,43 +1610,33 @@ FIXME: Why this pointer can be not a valid return; } - memset(&x, 0, sizeof(xEvent)); - x.u.u.type = SelectionNotify; - x.u.selectionNotify.time = time; - x.u.selectionNotify.requestor = requestor; - x.u.selectionNotify.selection = selection; - x.u.selectionNotify.target = target; - x.u.selectionNotify.property = None; - - (void) TryClientEvents(client, &x, 1, NoEventMask, - NoEventMask , NullGrab); + SendSelectionNotifyEventToClient(client, time, requestor, selection, target, None); } +/* + * This is called from dix (ProcConvertSelection) if an nxagent client + * issues a ConvertSelection request. So all the Atoms are internal + * return codes: + * 0: let dix process the request + * 1: don't let dix process the request + */ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, Window requestor, Atom property, Atom target, Time time) { - const char *strTarget; - int i; - if (agentClipboardStatus != 1 || nxagentOption(Clipboard) == ClipboardServer) { return 0; } - /* - * There is a client owner on the agent side, let normal stuff happen. - */ - - /* - * Only for PRIMARY and CLIPBOARD selections. - */ - - for (i = 0; i < nxagentMaxSelections; i++) + for (int i = 0; i < nxagentMaxSelections; i++) { if ((selection == CurrentSelections[i].selection) && (lastSelectionOwner[i].client != NULL)) { + /* + * There is a client owner on the agent side, let normal dix stuff happen. + */ return 0; } } @@ -1498,111 +1673,118 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, } } - #ifdef TEST - fprintf(stderr, "%s: client [%d] ask for sel [%s] " - "on window [%x] prop [%s] target [%s].\n", __func__, - client -> index, validateString(NameForAtom(selection)), requestor, - validateString(NameForAtom(property)), validateString(NameForAtom(target))); + #if defined(TEST) || defined(DEBUG) + fprintf(stderr, "%s: client [%d] requests sel [%s] " + "on window [%x] prop [%d][%s] target [%d][%s].\n", __func__, + CLINDEX(client), validateString(NameForAtom(selection)), requestor, + property, validateString(NameForAtom(property)), + target, validateString(NameForAtom(target))); #endif - strTarget = NameForAtom(target); + const char *strTarget = NameForAtom(target); if (strTarget == NULL) { + #ifdef DEBUG + fprintf(stderr, "%s: cannot find name for target Atom [%d] - returning\n", __func__, target); + #endif return 1; } + /* + * The selection request target is TARGETS. The requestor is asking + * for a list of supported data formats. Currently there's 4 of them. + * + * FIXME: I am wondering if we should align this with + * nxagentRequestSelection, where we only report one format. + */ if (target == clientTARGETS) { - Atom xa_STRING[4]; - xEvent x; - /* --- Order changed by dimbor (prevent sending COMPOUND_TEXT to client --- */ - xa_STRING[0] = XA_STRING; - xa_STRING[1] = clientUTF8_STRING; - xa_STRING[2] = clientTEXT; - xa_STRING[3] = clientCOMPOUND_TEXT; + Atom targets[] = {XA_STRING, clientUTF8_STRING, clientTEXT, clientCOMPOUND_TEXT}; + int numTargets = 4; + + #ifdef DEBUG + fprintf(stderr, "%s: available targets:\n", __func__); + for (int i = 0; i < numTargets; i++) + fprintf(stderr, "%s: %s\n", __func__, NameForAtom(targets[i])); + fprintf(stderr, "\n"); + #endif ChangeWindowProperty(pWin, property, MakeAtom("ATOM", 4, 1), sizeof(Atom)*8, PropModeReplace, - 4, - &xa_STRING, 1); + numTargets, + &targets, + 1); - memset(&x, 0, sizeof(xEvent)); - x.u.u.type = SelectionNotify; - x.u.selectionNotify.time = time; - x.u.selectionNotify.requestor = requestor; - x.u.selectionNotify.selection = selection; - x.u.selectionNotify.target = target; - x.u.selectionNotify.property = property; - - (void) TryClientEvents(client, &x, 1, NoEventMask, - NoEventMask , NullGrab); + SendSelectionNotifyEventToClient(client, time, requestor, selection, target, property); return 1; } + /* + * Section 2.6.2 of the ICCCM states: + * "TIMESTAMP - To avoid some race conditions, it is important + * that requestors be able to discover the timestamp the owner + * used to acquire ownership. Until and unless the protocol is + * changed so that a GetSelectionOwner request returns the + * timestamp used to acquire ownership, selection owners must + * support conversion to TIMESTAMP, returning the timestamp they + * used to obtain the selection." + */ if (target == MakeAtom("TIMESTAMP", 9, 1)) { - int i = 0; - - while ((i < NumCurrentSelections) && - CurrentSelections[i].selection != selection) i++; - + int i = nxagentFindCurrentSelectionIndex(selection); if (i < NumCurrentSelections) { - xEvent x; + /* + * "If the specified property is not None, the owner should place + * the data resulting from converting the selection into the + * specified property on the requestor window and should set the + * property's type to some appropriate value, which need not be + * the same as the specified target." + */ ChangeWindowProperty(pWin, property, - target, + XA_INTEGER, 32, PropModeReplace, 1, (unsigned char *) &lastSelectionOwner[i].lastTimeChanged, 1); - memset(&x, 0, sizeof(xEvent)); - x.u.u.type = SelectionNotify; - x.u.selectionNotify.time = time; - x.u.selectionNotify.requestor = requestor; - x.u.selectionNotify.selection = selection; - x.u.selectionNotify.target = target; - x.u.selectionNotify.property = property; - - (void) TryClientEvents(client, &x, 1, NoEventMask, - NoEventMask , NullGrab); - - return 1; + SendSelectionNotifyEventToClient(client, time, requestor, selection, target, property); + return 1; } } + #ifdef DEBUG if (lastClientClientPtr == client && (GetTimeInMillis() - lastClientReqTime < 5000)) { /* - * The same client made consecutive requests - * of clipboard contents with less than 5 - * seconds time interval between them. + * The same client made consecutive requests of clipboard content + * with less than 5 seconds time interval between them. */ - #ifdef DEBUG fprintf(stderr, "%s: Consecutives request from client [%p] selection [%u] " "elapsed time [%u] clientAccum [%d]\n", __func__, (void *) client, selection, GetTimeInMillis() - lastClientReqTime, clientAccum); - #endif clientAccum++; } else { + /* reset clientAccum as now another client requested the clipboard content */ if (lastClientClientPtr != client) { clientAccum = 0; } } + #endif if ((target == clientTEXT) || (target == XA_STRING) || @@ -1611,6 +1793,10 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, { lastClientWindowPtr = pWin; SetClientSelectionStage(None); + /* + * store the original requestor, we need that later after + * serverCutProperty contains the desired selection content + */ lastClientRequestor = requestor; lastClientClientPtr = client; lastClientTime = time; @@ -1618,25 +1804,41 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, lastClientSelection = selection; lastClientTarget = target; - lastClientReqTime = (GetTimeInMillis() - lastClientReqTime) > 5000 ? - GetTimeInMillis() : lastClientReqTime; + /* if the last client request time is more than 5s ago update it. Why? */ + if ((GetTimeInMillis() - lastClientReqTime) > 5000) + lastClientReqTime = GetTimeInMillis(); if (selection == MakeAtom("CLIPBOARD", 9, 0)) { selection = lastSelectionOwner[nxagentClipboardSelection].selection; } + /* + * we only convert to either UTF8 or XA_STRING, despite accepting + * TEXT and COMPOUND_TEXT. + */ if (target == clientUTF8_STRING) { + #ifdef DEBUG + fprintf(stderr, "%s: Sending XConvertSelection with target [%d][UTF8_STRING], property [%d][NX_CUT_BUFFER_SERVER]\n", __func__, + serverUTF8_STRING, serverCutProperty); + #endif XConvertSelection(nxagentDisplay, selection, serverUTF8_STRING, serverCutProperty, serverWindow, CurrentTime); } else { + #ifdef DEBUG + fprintf(stderr, "%s: Sending XConvertSelection with target [%d][%s], property [%d][NX_CUT_BUFFER_SERVER]\n", __func__, + XA_STRING, validateString(NameForAtom(XA_STRING)), serverCutProperty); + #endif + XConvertSelection(nxagentDisplay, selection, XA_STRING, serverCutProperty, serverWindow, CurrentTime); } + /* FIXME: check returncode of XConvertSelection */ + #ifdef DEBUG fprintf(stderr, "%s: Sent XConvertSelection with target=[%s], property [%s]\n", __func__, validateString(NameForAtom(target)), validateString(NameForAtom(property))); @@ -1646,26 +1848,32 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, } else { - xEvent x; - - #ifdef DEBUG - fprintf(stderr, "%s: Xserver generates a SelectionNotify event " - "to the requestor with property None.\n", __func__); - #endif + /* deny request */ + SendSelectionNotifyEventToClient(client, time, requestor, selection, target, None); - memset(&x, 0, sizeof(xEvent)); - x.u.u.type = SelectionNotify; - x.u.selectionNotify.time = time; - x.u.selectionNotify.requestor = requestor; - x.u.selectionNotify.selection = selection; - x.u.selectionNotify.target = target; - x.u.selectionNotify.property = None; - (void) TryClientEvents(client, &x, 1, NoEventMask, NoEventMask , NullGrab); return 1; } return 0; } +/* + * This is _only_ called from ProcSendEvent in NXevents.c. It is used + * to send a SelectionNotify event to our server window which will + * trigger the dispatch loop in Events.c to run + * nxagentHandleSelectionNotifyFromXServer which in turn will take + * care of transferring the selection content from the owning client + * to to a property of the server window. + * + * Returning 1 here means the client request will not be further + * handled by dix. Returning 0 means a SelectionNotify event being + * pushed out to our clients. + * + * From https://tronche.com/gui/x/xlib/events/client-communication/selection.html: + * "This event is generated by the X server in response to a + * ConvertSelection protocol request when there is no owner for the + * selection. When there is an owner, it should be generated by the + * owner of the selection by using XSendEvent()." + */ int nxagentSendNotify(xEvent *event) { #ifdef DEBUG @@ -1681,56 +1889,92 @@ int nxagentSendNotify(xEvent *event) } #ifdef DEBUG - fprintf(stderr, "%s: property is [%d][%s].\n", __func__, event->u.selectionNotify.property, NameForAtom(event->u.selectionNotify.property)); + fprintf(stderr, "%s: property is [%d][%s].\n", __func__, + event->u.selectionNotify.property, + NameForAtom(event->u.selectionNotify.property)); + fprintf(stderr, "%s: requestor is [0x%x].\n", __func__, event->u.selectionNotify.requestor); + fprintf(stderr, "%s: lastServerRequestor is [0x%x].\n", __func__, lastServerRequestor); #endif - if (event->u.selectionNotify.property == clientCutProperty) + /* + * If we have nested sessions there are situations where we do not + * need to send out anything to the real X server because + * communication happens completely between our own clients (some of + * which can be nxagents themselves). In that case we return 0 (tell + * dix to go on) and do nothing! + */ + if (event->u.selectionNotify.property == clientCutProperty && lastServerRequestor != None) { - XSelectionEvent x; - int result; /* * Setup selection notify event to real server. + * + * .property must be a server-side Atom. As this property is only + * set on our serverWindow and normally there are no other + * properties except serverCutProperty, the only thing we need to + * ensure is that the internal Atom clientCutProperty must differ + * from the server-side serverCutProperty Atom. The actual name is + * not important. To be clean here we use a seperate + * serverClientCutProperty. */ - memset(&x, 0, sizeof(XSelectionEvent)); - x.type = SelectionNotify; - x.send_event = True; - x.display = nxagentDisplay; - x.requestor = serverWindow; + XSelectionEvent eventSelection = { + .requestor = serverWindow, + .selection = event->u.selectionNotify.selection, + .target = event->u.selectionNotify.target, + .property = serverClientCutProperty, + .time = CurrentTime, + }; /* - * On real server, the right CLIPBOARD atom is - * XInternAtom(nxagentDisplay, "CLIPBOARD", 1). + * On the real server, the right CLIPBOARD atom is + * XInternAtom(nxagentDisplay, "CLIPBOARD", 1), which is stored in + * lastSelectionOwner[nxagentClipboardSelection].selection. For + * PRIMARY there's nothing to map because that is identical on all + * X servers (defined in Xatom.h). */ if (event->u.selectionNotify.selection == MakeAtom("CLIPBOARD", 9, 0)) { - x.selection = lastSelectionOwner[nxagentClipboardSelection].selection; + eventSelection.selection = lastSelectionOwner[nxagentClipboardSelection].selection; } + + /* + * .target must be translated, too, as a client on the real + * server is requested to fill our property and it needs to know + * the format. + */ + + if (event->u.selectionNotify.target == clientUTF8_STRING) + { + eventSelection.target = serverUTF8_STRING; + } + else if (event->u.selectionNotify.target == clientTEXT) + { + eventSelection.target = serverTEXT; + } + /*else if (event->u.selectionNotify.target == clientCOMPOUND_TEXT) + { + eventSelection.target = serverCOMPOUND_TEXT; + }*/ else { - x.selection = event->u.selectionNotify.selection; + eventSelection.target = XA_STRING; } - x.target = event->u.selectionNotify.target; - x.property = event->u.selectionNotify.property; - x.time = CurrentTime; - #ifdef DEBUG - fprintf(stderr, "%s: Propagating clientCutProperty to requestor [%p].\n", __func__, (void *)x.requestor); + fprintf(stderr, "%s: mapping local to remote Atom: [%d] -> [%ld] [%s]\n", __func__, + event->u.selectionNotify.selection, eventSelection.selection, + NameForAtom(event->u.selectionNotify.selection)); + fprintf(stderr, "%s: mapping local to remote Atom: [%d] -> [%ld] [%s]\n", __func__, + event->u.selectionNotify.target, eventSelection.target, + NameForAtom(event->u.selectionNotify.target)); + fprintf(stderr, "%s: mapping local to remote Atom: [%d] -> [%ld] [%s]\n", __func__, + event->u.selectionNotify.property, eventSelection.property, + NameForAtom(event->u.selectionNotify.property)); #endif - result = XSendEvent (nxagentDisplay, x.requestor, False, - 0L, (XEvent *) &x); - - #ifdef DEBUG - fprintf(stderr, "%s: XSendEvent() returned [%s]\n", __func__, GetXErrorString(result)); - #endif - if (result == BadValue || result == BadWindow) - { - fprintf (stderr, "%s: XSendEvent failed.\n", __func__); - } + SendSelectionNotifyEventToServer(&eventSelection); return 1; } @@ -1740,43 +1984,38 @@ int nxagentSendNotify(xEvent *event) return 0; } -WindowPtr nxagentGetClipboardWindow(Atom property, WindowPtr pWin) +WindowPtr nxagentGetClipboardWindow(Atom property) { - int i = 0; - - #ifdef DEBUG - fprintf(stderr, "%s: Got called, property [%d][%s] window [%p].\n", __func__, property, NameForAtom(property), (void *)pWin); - #endif - - while ((i < nxagentMaxSelections) && - (lastSelectionOwner[i].selection != nxagentLastRequestedSelection)) - { - i++; - } + int i = nxagentFindLastSelectionOwnerIndex(nxagentLastRequestedSelection); if ((i < nxagentMaxSelections) && (property == clientCutProperty) && (lastSelectionOwner[i].windowPtr != NULL)) { #ifdef DEBUG - fprintf(stderr, "%s: Returning last clipboard owner window [%p].\n", __func__, (void *)lastSelectionOwner[i].windowPtr); + fprintf(stderr, "%s: Returning last [%d] selection owner window [%p] (0x%x).\n", __func__, + lastSelectionOwner[i].selection, + (void *)lastSelectionOwner[i].windowPtr, WINDOWID(lastSelectionOwner[i].windowPtr)); #endif return lastSelectionOwner[i].windowPtr; } else { - #ifdef DEBUG - fprintf(stderr, "%s: Returning original target window [%p].\n", __func__, (void *)pWin); - #endif - - return pWin; + return NULL; } +} +void nxagentInitSelectionOwner(SelectionOwner *owner, Atom selection) +{ + owner->selection = selection; + owner->client = NullClient; + owner->window = screenInfo.screens[0]->root->drawable.id; + owner->windowPtr = NULL; + owner->lastTimeChanged = GetTimeInMillis(); } int nxagentInitClipboard(WindowPtr pWin) { - int i; Window iWindow = nxagentWindow(pWin); #ifdef DEBUG @@ -1792,20 +2031,10 @@ int nxagentInitClipboard(WindowPtr pWin) FatalError("nxagentInitClipboard: Failed to allocate memory for the clipboard selections.\n"); } - nxagentClipboardAtom = nxagentAtoms[10]; /* CLIPBOARD */ - nxagentTimestampAtom = nxagentAtoms[11]; /* TIMESTAMP */ - - lastSelectionOwner[nxagentPrimarySelection].selection = XA_PRIMARY; - lastSelectionOwner[nxagentPrimarySelection].client = NullClient; - lastSelectionOwner[nxagentPrimarySelection].window = screenInfo.screens[0]->root->drawable.id; - lastSelectionOwner[nxagentPrimarySelection].windowPtr = NULL; - lastSelectionOwner[nxagentPrimarySelection].lastTimeChanged = GetTimeInMillis(); + serverTIMESTAMP = nxagentAtoms[11]; /* TIMESTAMP */ - lastSelectionOwner[nxagentClipboardSelection].selection = nxagentClipboardAtom; - lastSelectionOwner[nxagentClipboardSelection].client = NullClient; - lastSelectionOwner[nxagentClipboardSelection].window = screenInfo.screens[0]->root->drawable.id; - lastSelectionOwner[nxagentClipboardSelection].windowPtr = NULL; - lastSelectionOwner[nxagentClipboardSelection].lastTimeChanged = GetTimeInMillis(); + nxagentInitSelectionOwner(&lastSelectionOwner[nxagentPrimarySelection], XA_PRIMARY); + nxagentInitSelectionOwner(&lastSelectionOwner[nxagentClipboardSelection], nxagentAtoms[10]); /* CLIPBOARD */ #ifdef NXAGENT_TIMESTAMP { @@ -1827,6 +2056,8 @@ int nxagentInitClipboard(WindowPtr pWin) serverTARGETS = nxagentAtoms[6]; /* TARGETS */ serverTEXT = nxagentAtoms[7]; /* TEXT */ serverUTF8_STRING = nxagentAtoms[12]; /* UTF8_STRING */ + /* see nxagentSendNotify for an explanation */ + serverClientCutProperty = nxagentAtoms[15]; /* NX_CUT_BUFFER_CLIENT */ if (serverCutProperty == None) { @@ -1858,7 +2089,7 @@ int nxagentInitClipboard(WindowPtr pWin) fprintf(stderr, "%s: Registering for XFixesSelectionNotify events.\n", __func__); #endif - for (i = 0; i < nxagentMaxSelections; i++) + for (int i = 0; i < nxagentMaxSelections; i++) { XFixesSelectSelectionInput(nxagentDisplay, iWindow, lastSelectionOwner[i].selection, @@ -1898,7 +2129,7 @@ int nxagentInitClipboard(WindowPtr pWin) * Only for PRIMARY and CLIPBOARD selections. */ - for (i = 0; i < nxagentMaxSelections; i++) + for (int i = 0; i < nxagentMaxSelections; i++) { if (lastSelectionOwner[i].client && lastSelectionOwner[i].window) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h index 62fc32fd9..c2e783cb9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h @@ -64,6 +64,7 @@ extern int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom select void nxagentClearSelection(); void nxagentRequestSelection(); -void nxagentNotifySelection(); +void nxagentHandleSelectionNotifyFromXServer(); +int nxagentFindCurrentSelectionIndex(Atom sel); #endif /* __Clipboard_H__ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c index 33b0738ec..b04977887 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c @@ -69,11 +69,7 @@ Bool nxagentReconnectAllColormap(void *p0); Bool nxagentCreateColormap(ColormapPtr pCmap) { - VisualPtr pVisual; XColor *colors; - int i, ncolors; - Pixel red, green, blue; - Pixel redInc, greenInc, blueInc; Visual *visual; int class; @@ -83,8 +79,8 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) " visual [%lu].\n", pCmap->pVisual); #endif - pVisual = pCmap->pVisual; - ncolors = pVisual->ColormapEntries; + VisualPtr pVisual = pCmap->pVisual; + int ncolors = pVisual->ColormapEntries; pCmap->devPriv = (void *)malloc(sizeof(nxagentPrivColormap)); @@ -102,7 +98,6 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) class = pVisual->class; } - nxagentColormapPriv(pCmap)->colormap = XCreateColormap(nxagentDisplay, nxagentDefaultWindows[pCmap->pScreen->myNum], @@ -110,13 +105,15 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) (class & DynamicClass) ? AllocAll : AllocNone); - switch (class) { + switch (class) + { case StaticGray: /* read only */ colors = (XColor *)malloc(ncolors * sizeof(XColor)); - for (i = 0; i < ncolors; i++) + for (int i = 0; i < ncolors; i++) colors[i].pixel = i; XQueryColors(nxagentDisplay, nxagentColormap(pCmap), colors, ncolors); - for (i = 0; i < ncolors; i++) { + for (int i = 0; i < ncolors; i++) + { pCmap->red[i].co.local.red = colors[i].red; pCmap->red[i].co.local.green = colors[i].red; pCmap->red[i].co.local.blue = colors[i].red; @@ -126,10 +123,11 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) case StaticColor: /* read only */ colors = (XColor *)malloc(ncolors * sizeof(XColor)); - for (i = 0; i < ncolors; i++) + for (int i = 0; i < ncolors; i++) colors[i].pixel = i; XQueryColors(nxagentDisplay, nxagentColormap(pCmap), colors, ncolors); - for (i = 0; i < ncolors; i++) { + for (int i = 0; i < ncolors; i++) + { pCmap->red[i].co.local.red = colors[i].red; pCmap->red[i].co.local.green = colors[i].green; pCmap->red[i].co.local.blue = colors[i].blue; @@ -139,21 +137,29 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) case TrueColor: /* read only */ colors = (XColor *)malloc(ncolors * sizeof(XColor)); - red = green = blue = 0L; + Pixel red = 0L, green = 0L, blue = 0L; + Pixel redInc, greenInc, blueInc; redInc = lowbit(pVisual->redMask); greenInc = lowbit(pVisual->greenMask); blueInc = lowbit(pVisual->blueMask); - for (i = 0; i < ncolors; i++) { + for (int i = 0; i < ncolors; i++) + { colors[i].pixel = red | green | blue; red += redInc; - if (red > pVisual->redMask) red = 0L; + if (red > pVisual->redMask) + red = 0L; + green += greenInc; - if (green > pVisual->greenMask) green = 0L; + if (green > pVisual->greenMask) + green = 0L; + blue += blueInc; - if (blue > pVisual->blueMask) blue = 0L; + if (blue > pVisual->blueMask) + blue = 0L; } XQueryColors(nxagentDisplay, nxagentColormap(pCmap), colors, ncolors); - for (i = 0; i < ncolors; i++) { + for (int i = 0; i < ncolors; i++) + { pCmap->red[i].co.local.red = colors[i].red; pCmap->green[i].co.local.green = colors[i].green; pCmap->blue[i].co.local.blue = colors[i].blue; @@ -187,13 +193,14 @@ static int nxagentCountInstalledColormapWindows(WindowPtr pWin, void * ptr) { nxagentInstalledColormapWindows *icws = (nxagentInstalledColormapWindows *) ptr; - int i; - - for (i = 0; i < icws->numCmapIDs; i++) - if (SEARCH_PREDICATE) { + for (int i = 0; i < icws->numCmapIDs; i++) + { + if (SEARCH_PREDICATE) + { icws->numWindows++; return WT_DONTWALKCHILDREN; } + } return WT_WALKCHILDREN; } @@ -201,13 +208,15 @@ static int nxagentCountInstalledColormapWindows(WindowPtr pWin, void * ptr) static int nxagentGetInstalledColormapWindows(WindowPtr pWin, void * ptr) { nxagentInstalledColormapWindows *icws = (nxagentInstalledColormapWindows *)ptr; - int i; - for (i = 0; i < icws->numCmapIDs; i++) - if (SEARCH_PREDICATE) { + for (int i = 0; i < icws->numCmapIDs; i++) + { + if (SEARCH_PREDICATE) + { icws->windows[icws->index++] = nxagentWindow(pWin); return WT_DONTWALKCHILDREN; } + } return WT_WALKCHILDREN; } @@ -243,7 +252,8 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) icws.numCmapIDs = nxagentListInstalledColormaps(pScreen, icws.cmapIDs); icws.numWindows = 0; WalkTree(pScreen, nxagentCountInstalledColormapWindows, (void *)&icws); - if (icws.numWindows) { + if (icws.numWindows) + { icws.windows = (Window *)malloc((icws.numWindows + 1) * sizeof(Window)); icws.index = 0; WalkTree(pScreen, nxagentGetInstalledColormapWindows, (void *)&icws); @@ -257,15 +267,15 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) SAFE_free(icws.cmapIDs); - if (!nxagentSameInstalledColormapWindows(icws.windows, icws.numWindows)) { + if (!nxagentSameInstalledColormapWindows(icws.windows, icws.numWindows)) + { SAFE_free(nxagentOldInstalledColormapWindows); #ifdef _XSERVER64 { - int i; Window64 *windows = (Window64 *)malloc(numWindows * sizeof(Window64)); - for(i = 0; i < numWindows; ++i) + for(int i = 0; i < numWindows; ++i) windows[i] = icws.windows[i]; XSetWMColormapWindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], windows, numWindows); @@ -285,36 +295,36 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) This will only work with default local visual colormaps. */ if (icws.numWindows) + { + WindowPtr pWin; + Visual *visual; + ColormapPtr pCmap; + + pWin = nxagentWindowPtr(icws.windows[0]); + visual = nxagentVisualFromID(pScreen, wVisual(pWin)); + + if (visual == nxagentDefaultVisual(pScreen)) + pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), + RT_COLORMAP); + else + pCmap = (ColormapPtr)LookupIDByType(pScreen->defColormap, + RT_COLORMAP); + + if (pCmap != NULL) { - WindowPtr pWin; - Visual *visual; - ColormapPtr pCmap; - - pWin = nxagentWindowPtr(icws.windows[0]); - visual = nxagentVisualFromID(pScreen, wVisual(pWin)); - - if (visual == nxagentDefaultVisual(pScreen)) - pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), - RT_COLORMAP); - else - pCmap = (ColormapPtr)LookupIDByType(pScreen->defColormap, - RT_COLORMAP); - - if (pCmap != NULL) - { - XSetWindowColormap(nxagentDisplay, - nxagentDefaultWindows[pScreen->myNum], - nxagentColormap(pCmap)); - } - #ifdef WARNING - else - { - fprintf(stderr, "nxagentSetInstalledColormapWindows: WARNING! " - "Window at [%p] has no colormap with class [%d].\n", - (void *)pWin, pWin -> drawable.class); - } - #endif + XSetWindowColormap(nxagentDisplay, + nxagentDefaultWindows[pScreen->myNum], + nxagentColormap(pCmap)); } + #ifdef WARNING + else + { + fprintf(stderr, "nxagentSetInstalledColormapWindows: WARNING! " + "Window at [%p] has no colormap with class [%d].\n", + (void *)pWin, pWin -> drawable.class); + } + #endif + } #endif /* DUMB_WINDOW_MANAGERS */ } else @@ -347,17 +357,15 @@ void nxagentSetScreenSaverColormapWindow(ScreenPtr pScreen) void nxagentDirectInstallColormaps(ScreenPtr pScreen) { - int i, n; Colormap pCmapIDs[MAXCMAPS]; - if (!nxagentDoDirectColormaps) return; - - n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); + if (!nxagentDoDirectColormaps) + return; - for (i = 0; i < n; i++) { - ColormapPtr pCmap; + int n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); - pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); + for (int i = 0; i < n; i++) { + ColormapPtr pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); if (pCmap) XInstallColormap(nxagentDisplay, nxagentColormap(pCmap)); } @@ -365,14 +373,13 @@ void nxagentDirectInstallColormaps(ScreenPtr pScreen) void nxagentDirectUninstallColormaps(ScreenPtr pScreen) { - int i, n; Colormap pCmapIDs[MAXCMAPS]; if (!nxagentDoDirectColormaps) return; - n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); + int n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); - for (i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { ColormapPtr pCmap; pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); @@ -383,45 +390,39 @@ void nxagentDirectUninstallColormaps(ScreenPtr pScreen) void nxagentInstallColormap(ColormapPtr pCmap) { - int index; - ColormapPtr pOldCmap; - - index = pCmap->pScreen->myNum; - pOldCmap = InstalledMaps[index]; + int index = pCmap->pScreen->myNum; + ColormapPtr pOldCmap = InstalledMaps[index]; if(pCmap != pOldCmap) - { - nxagentDirectUninstallColormaps(pCmap->pScreen); + { + nxagentDirectUninstallColormaps(pCmap->pScreen); - /* Uninstall pInstalledMap. Notify all interested parties. */ - if(pOldCmap != (ColormapPtr)None) - WalkTree(pCmap->pScreen, TellLostMap, (void *)&pOldCmap->mid); + /* Uninstall pInstalledMap. Notify all interested parties. */ + if(pOldCmap != (ColormapPtr)None) + WalkTree(pCmap->pScreen, TellLostMap, (void *)&pOldCmap->mid); - InstalledMaps[index] = pCmap; - WalkTree(pCmap->pScreen, TellGainedMap, (void *)&pCmap->mid); + InstalledMaps[index] = pCmap; + WalkTree(pCmap->pScreen, TellGainedMap, (void *)&pCmap->mid); - nxagentSetInstalledColormapWindows(pCmap->pScreen); - nxagentDirectInstallColormaps(pCmap->pScreen); - } + nxagentSetInstalledColormapWindows(pCmap->pScreen); + nxagentDirectInstallColormaps(pCmap->pScreen); + } } void nxagentUninstallColormap(ColormapPtr pCmap) { - int index; - ColormapPtr pCurCmap; - - index = pCmap->pScreen->myNum; - pCurCmap = InstalledMaps[index]; + int index = pCmap->pScreen->myNum; + ColormapPtr pCurCmap = InstalledMaps[index]; if(pCmap == pCurCmap) + { + if ((unsigned int)pCmap->mid != pCmap->pScreen->defColormap) { - if ((unsigned int)pCmap->mid != pCmap->pScreen->defColormap) - { - pCurCmap = (ColormapPtr)LookupIDByType(pCmap->pScreen->defColormap, - RT_COLORMAP); - (*pCmap->pScreen->InstallColormap)(pCurCmap); - } + pCurCmap = (ColormapPtr)LookupIDByType(pCmap->pScreen->defColormap, + RT_COLORMAP); + (*pCmap->pScreen->InstallColormap)(pCurCmap); } + } } int nxagentListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIds) @@ -429,7 +430,6 @@ int nxagentListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIds) if (nxagentInstalledDefaultColormap) { *pCmapIds = InstalledMaps[pScreen->myNum]->mid; - return 1; } else @@ -443,10 +443,9 @@ void nxagentStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors) if (pCmap->pVisual->class & DynamicClass) #ifdef _XSERVER64 { - int i; XColor *pColors64 = (XColor *)malloc(nColors * sizeof(XColor) ); - for(i = 0; i < nColors; ++i) + for(int i = 0; i < nColors; ++i) { pColors64[i].pixel = pColors[i].pixel; pColors64[i].red = pColors[i].red; @@ -466,50 +465,43 @@ void nxagentStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors) void nxagentResolveColor(unsigned short *pRed, unsigned short *pGreen, unsigned short *pBlue, VisualPtr pVisual) { - int shift; - unsigned int lim; - - shift = 16 - pVisual->bitsPerRGBValue; - lim = (1 << pVisual->bitsPerRGBValue) - 1; + int shift = 16 - pVisual->bitsPerRGBValue; + unsigned int lim = (1 << pVisual->bitsPerRGBValue) - 1; if ((pVisual->class == PseudoColor) || (pVisual->class == DirectColor)) - { - /* rescale to rgb bits */ - *pRed = ((*pRed >> shift) * 65535) / lim; - *pGreen = ((*pGreen >> shift) * 65535) / lim; - *pBlue = ((*pBlue >> shift) * 65535) / lim; - } + { + /* rescale to rgb bits */ + *pRed = ((*pRed >> shift) * 65535) / lim; + *pGreen = ((*pGreen >> shift) * 65535) / lim; + *pBlue = ((*pBlue >> shift) * 65535) / lim; + } else if (pVisual->class == GrayScale) - { - /* rescale to gray then rgb bits */ - *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100; - *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim; - } + { + /* rescale to gray then rgb bits */ + *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100; + *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim; + } else if (pVisual->class == StaticGray) - { - unsigned int limg; - - limg = pVisual->ColormapEntries - 1; - /* rescale to gray then [0..limg] then [0..65535] then rgb bits */ - *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100; - *pRed = ((((*pRed * (limg + 1))) >> 16) * 65535) / limg; - *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim; - } + { + unsigned int limg = pVisual->ColormapEntries - 1; + /* rescale to gray then [0..limg] then [0..65535] then rgb bits */ + *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100; + *pRed = ((((*pRed * (limg + 1))) >> 16) * 65535) / limg; + *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim; + } else - { - unsigned limr, limg, limb; - - limr = pVisual->redMask >> pVisual->offsetRed; - limg = pVisual->greenMask >> pVisual->offsetGreen; - limb = pVisual->blueMask >> pVisual->offsetBlue; - /* rescale to [0..limN] then [0..65535] then rgb bits */ - *pRed = ((((((*pRed * (limr + 1)) >> 16) * - 65535) / limr) >> shift) * 65535) / lim; - *pGreen = ((((((*pGreen * (limg + 1)) >> 16) * - 65535) / limg) >> shift) * 65535) / lim; - *pBlue = ((((((*pBlue * (limb + 1)) >> 16) * - 65535) / limb) >> shift) * 65535) / lim; - } + { + unsigned limr = pVisual->redMask >> pVisual->offsetRed; + unsigned limg = pVisual->greenMask >> pVisual->offsetGreen; + unsigned limb = pVisual->blueMask >> pVisual->offsetBlue; + /* rescale to [0..limN] then [0..65535] then rgb bits */ + *pRed = ((((((*pRed * (limr + 1)) >> 16) * + 65535) / limr) >> shift) * 65535) / lim; + *pGreen = ((((((*pGreen * (limg + 1)) >> 16) * + 65535) / limg) >> shift) * 65535) / lim; + *pBlue = ((((((*pBlue * (limb + 1)) >> 16) * + 65535) / limb) >> shift) * 65535) / lim; + } } Bool nxagentCreateDefaultColormap(ScreenPtr pScreen) @@ -517,7 +509,6 @@ Bool nxagentCreateDefaultColormap(ScreenPtr pScreen) VisualPtr pVisual; ColormapPtr pCmap; unsigned short zero = 0, ones = 0xFFFF; - Pixel wp, bp; #if defined(DEBUG) || defined(DEBUG_COLORMAP) fprintf(stderr, "Debug: Searching for the root visual [%lu].\n", @@ -533,8 +524,8 @@ Bool nxagentCreateDefaultColormap(ScreenPtr pScreen) != Success) return False; - wp = pScreen->whitePixel; - bp = pScreen->blackPixel; + Pixel wp = pScreen->whitePixel; + Pixel bp = pScreen->blackPixel; if ((AllocColor(pCmap, &ones, &ones, &ones, &wp, 0) != Success) || (AllocColor(pCmap, &zero, &zero, &zero, &bp, 0) != @@ -553,7 +544,6 @@ static void nxagentReconnectColormap(void * p0, XID x1, void * p2) { ColormapPtr pCmap = (ColormapPtr)p0; Bool* pBool = (Bool*)p2; - VisualPtr pVisual; #ifdef NXAGENT_RECONNECT_COLORMAP_DEBUG fprintf(stderr, "nxagentReconnectColormap: %p\n", pCmap); @@ -562,7 +552,7 @@ static void nxagentReconnectColormap(void * p0, XID x1, void * p2) if (!*pBool || !pCmap) return; - pVisual = pCmap -> pVisual; + VisualPtr pVisual = pCmap -> pVisual; nxagentColormapPriv(pCmap)->colormap = XCreateColormap(nxagentDisplay, @@ -579,14 +569,13 @@ static void nxagentReconnectColormap(void * p0, XID x1, void * p2) Bool nxagentReconnectAllColormap(void *p0) { - int cid; Bool success = True; #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_COLORMAP_DEBUG) fprintf(stderr, "nxagentReconnectAllColormap\n"); #endif - for (cid = 0; (cid < MAXCLIENTS) && success; cid++) + for (int cid = 0; (cid < MAXCLIENTS) && success; cid++) { if (clients[cid] && success) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index c25afc597..c6412f38a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -2803,11 +2803,11 @@ Bool nxagentReconnectDisplay(void *p0) #endif nxagentConfineWindow = XCreateWindow(nxagentDisplay, - DefaultRootWindow(nxagentDisplay), - 0, 0, 1, 1, 0, 0, - InputOnly, - CopyFromParent, - 0L, NULL); + DefaultRootWindow(nxagentDisplay), + 0, 0, 1, 1, 0, 0, + InputOnly, + CopyFromParent, + 0L, NULL); if (nxagentReportWindowIds) { fprintf(stderr, "NXAGENT_WINDOW_ID: CONFINEMENT_WINDOW,WID:[0x%x]\n", diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 4a6a05482..cbdf17a22 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -345,7 +345,7 @@ void nxagentRemoteWindowID(Window window, Bool newline) XTextProperty tp; #endif - fprintf(stderr, "0x%lx", window); + fprintf(stderr, "0x%x", window); if (!window) { @@ -372,23 +372,21 @@ void nxagentRemoteWindowID(Window window, Bool newline) #else - if (XGetWMName(nxagentDisplay, window, &tp) != 0) + if (XGetWMName(nxagentDisplay, window, &tp) == 0) { fprintf(stderr, " (has no name) "); } else if (tp.nitems > 0) { - int count = 0; - int i, ret; - char **list = NULL; - fprintf(stderr, " \""); - ret = XmbTextPropertyToTextList(nxagentDisplay, &tp, &list, &count); + int count = 0; + char **list = NULL; + int ret = XmbTextPropertyToTextList(nxagentDisplay, &tp, &list, &count); if ((ret == Success || ret > 0) && list != NULL) { - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) { fprintf(stderr, "%s", list[i]); } @@ -426,20 +424,14 @@ void nxagentRemoteWindowID(Window window, Bool newline) void nxagentRemoteWindowInfo(Window win, int indent, Bool newLine) { XWindowAttributes attributes; - int i; if (XGetWindowAttributes(nxagentDisplay, win, &attributes) == 0) { return; } - for (i = 0; i < indent; i++) - { - fprintf(stderr, " "); - } - - fprintf(stderr, "x=%d y=%d width=%d height=%d class=%s map_state=%s " - "override_redirect=%s\n", attributes.x, attributes.y, + fprintf(stderr, "%*sx=%d y=%d width=%d height=%d class=%s map_state=%s " + "override_redirect=%s\n", indent, "", attributes.x, attributes.y, attributes.width, attributes.height, (attributes.class == 0) ? "CopyFromParent" : ((attributes.class == 1) ? "InputOutput" : "InputOnly"), @@ -456,14 +448,25 @@ void nxagentRemoteWindowInfo(Window win, int indent, Bool newLine) } -#ifdef DEBUG_TREE /* * Walk remote windows tree. + * + * FIXME: + * ========== nxagentRemoteWindowsTree ============ + * + * Root Window ID: 0x169 (the root window) (has no name) + * Parent window ID: 0x2a00063 "NX Agent" + * 0 children. + * + * ========== nxagentInternalWindowsTree ========== + * Window ID=[0x9d] Remote ID=[0x2a0007e] Name: ( has no name ) + * x=0 y=0 width=1440 height=810 class=InputOutput map_state=IsViewable override_redirect=No + * + * -> Internal root window's remote id is not listed in RemoteWindowsTree. */ void nxagentRemoteWindowsTree(Window window, int level) { - int i, j; unsigned long rootWin, parentWin; unsigned int numChildren; unsigned long *childList = NULL; @@ -488,25 +491,15 @@ void nxagentRemoteWindowsTree(Window window, int level) if (level == 0 || numChildren > 0) { - fprintf(stderr, " "); - - for (j = 0; j < level; j++) - { - fprintf(stderr, " "); - } + fprintf(stderr, "%*s", (level * 4) + 5, ""); /* 4 spaces per level */ fprintf(stderr, "%d child%s%s\n", numChildren, (numChildren == 1) ? "" : "ren", (numChildren == 1) ? ":" : "."); } - for (i = (int) numChildren - 1; i >= 0; i--) + for (int i = (int) numChildren - 1; i >= 0; i--) { - fprintf(stderr, " "); - - for (j = 0; j < level; j++) - { - fprintf(stderr, " "); - } + fprintf(stderr, "%*s", (level * 5) + 6, ""); /* 5 spaces per level */ nxagentRemoteWindowID(childList[i], TRUE); @@ -515,9 +508,8 @@ void nxagentRemoteWindowsTree(Window window, int level) nxagentRemoteWindowsTree(childList[i], level + 1); } - SAFE_XFree((char *) childList); + SAFE_XFree(childList); } -#endif /* * Print info about internal window. @@ -525,7 +517,6 @@ void nxagentRemoteWindowsTree(Window window, int level) void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) { - int i; int result; unsigned long ulReturnItems; unsigned long ulReturnBytesLeft; @@ -533,8 +524,8 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) int iReturnFormat; unsigned char *pszReturnData = NULL; - fprintf(stderr, "Window ID=[0x%lx] Remote ID=[0x%lx] ", pWin -> drawable.id, - nxagentWindow(pWin)); + fprintf(stderr, "Window ID=[0x%x] %s Remote ID=[0x%x] ", pWin -> drawable.id, + pWin->parent ? "" : "(the root window)", nxagentWindow(pWin)); result = GetWindowProperty(pWin, MakeAtom("WM_NAME", 7, False) , 0, sizeof(CARD32), False, AnyPropertyType, @@ -546,22 +537,15 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) if (result == Success && pszReturnData != NULL) { - pszReturnData[ulReturnItems] = '\0'; - - fprintf(stderr, "\"%s\"\n", (char *) pszReturnData); + fprintf(stderr, "\"%*.*s\"\n", (int)ulReturnItems, (int)ulReturnItems, (char *) pszReturnData); } else { fprintf(stderr, "%s\n", "( has no name )"); } - for (i = 0; i < indent; i++) - { - fprintf(stderr, " "); - } - - fprintf(stderr, "x=%d y=%d width=%d height=%d class=%s map_state=%s " - "override_redirect=%s", pWin -> drawable.x, pWin -> drawable.y, + fprintf(stderr, "%*sx=%d y=%d width=%d height=%d class=%s map_state=%s " + "override_redirect=%s", indent, "", pWin -> drawable.x, pWin -> drawable.y, pWin -> drawable.width, pWin -> drawable.height, (pWin -> drawable.class == 0) ? "CopyFromParent" : ((pWin -> drawable.class == 1) ? "InputOutput" : @@ -584,17 +568,11 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) void nxagentInternalWindowsTree(WindowPtr pWin, int indent) { - WindowPtr pChild; - int i; - while (pWin) { - pChild = pWin -> firstChild; + WindowPtr pChild = pWin -> firstChild; - for (i = 0; i < indent; i++) - { - fprintf(stderr, " "); - } + fprintf(stderr, "%*s", indent, ""); nxagentInternalWindowInfo(pWin, indent, TRUE); @@ -966,7 +944,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) fprintf(stderr, "nxagentDispatchEvents: Going to handle new SelectionNotify event.\n"); #endif - nxagentNotifySelection(&X); + nxagentHandleSelectionNotifyFromXServer(&X); break; } @@ -1025,7 +1003,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) case doDebugTree: { - fprintf(stderr, "\n ========== nxagentRemoteWindowsTree ==========\n"); + fprintf(stderr, "\n========== nxagentRemoteWindowsTree ============\n"); nxagentRemoteWindowsTree(nxagentWindow(screenInfo.screens[0]->root), 0); fprintf(stderr, "\n========== nxagentInternalWindowsTree ==========\n"); @@ -1228,9 +1206,9 @@ FIXME: Don't enqueue the KeyRelease event if the key was nxagentXkbNumTrap = 0; } - /* Calculate the time elapsed between this and the last event we - received. Add this delta to time we recorded for the last - KeyPress event we passed on to our clients. */ + /* Calculate the time elapsed between this and the last event we + received. Add this delta to time we recorded for the last + KeyPress event we passed on to our clients. */ memset(&x, 0, sizeof(xEvent)); x.u.u.type = KeyRelease; x.u.u.detail = nxagentConvertKeycode(X.xkey.keycode); @@ -1571,18 +1549,18 @@ FIXME: Don't enqueue the KeyRelease event if the key was { WindowPtr pWin; - #ifdef DEBUG - fprintf(stderr, "%s: Going to handle new FocusIn event [0x%x] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode)); - { - XlibWindow w; + #ifdef DEBUG + fprintf(stderr, "%s: Going to handle new FocusIn event [0x%x] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode)); + { + XlibWindow w; int revert_to; XGetInputFocus(nxagentDisplay, &w, &revert_to); - fprintf(stderr, "%s: (FocusIn): Event win [0x%x] Focus owner [0x%x] nxagentDefaultWindows[0] [0x%x]\n", __func__, X.xfocus.window, w, nxagentDefaultWindows[0]); - } + fprintf(stderr, "%s: (FocusIn): Event win [0x%x] Focus owner [0x%x] nxagentDefaultWindows[0] [0x%x]\n", __func__, X.xfocus.window, w, nxagentDefaultWindows[0]); + } #else - #ifdef TEST - fprintf(stderr, "%s: Going to handle new FocusIn event\n", __func__); - #endif + #ifdef TEST + fprintf(stderr, "%s: Going to handle new FocusIn event\n", __func__); + #endif #endif /* @@ -1614,27 +1592,27 @@ FIXME: Don't enqueue the KeyRelease event if the key was { #if defined(DEBUG) || defined(DEBUG_AUTOGRAB) fprintf(stderr, "%s: (FocusIn): grabbing\n", __func__); - #endif + #endif nxagentGrabPointerAndKeyboard(NULL); } - /* else + /* else { #if defined(DEBUG) || defined(DEBUG_AUTOGRAB) fprintf(stderr, "%s: (FocusIn): ungrabbing\n", __func__); - #endif + #endif nxagentUngrabPointerAndKeyboard(NULL); } - */ + */ } break; } case FocusOut: { - #ifdef DEBUG - fprintf(stderr, "%s: Going to handle new FocusOut event [0x%x] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode)); - #else - #ifdef TEST - fprintf(stderr, "%s: Going to handle new FocusOut event.\n", __func__); + #ifdef DEBUG + fprintf(stderr, "%s: Going to handle new FocusOut event [0x%x] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode)); + #else + #ifdef TEST + fprintf(stderr, "%s: Going to handle new FocusOut event.\n", __func__); #endif #endif @@ -1655,22 +1633,14 @@ FIXME: Don't enqueue the KeyRelease event if the key was * Force the keys all up when focus is lost. */ - int i, k; - int mask = 1; - CARD8 val; - - XEvent xM; - memset(&xM, 0, sizeof(XEvent)); - - for (i = 0; i < DOWN_LENGTH; i++) /* input.h */ + for (int i = 0; i < DOWN_LENGTH; i++) /* input.h */ { - val = inputInfo.keyboard->key->down[i]; + CARD8 val = inputInfo.keyboard->key->down[i]; if (val != 0) { - for (k = 0; k < 8; k++) + for (int k = 0; k < 8; k++) { - if (val & (mask << k)) { #ifdef NXAGENT_FIXKEYS_DEBUG fprintf(stderr, "sending KeyRelease event for keycode: %x\n", @@ -1687,6 +1657,9 @@ FIXME: Don't enqueue the KeyRelease event if the key was if (nxagentOption(ViewOnly) == 0 && nxagentOption(Shadow)) { + XEvent xM; + + memset(&xM, 0, sizeof(XEvent)); xM.type = KeyRelease; xM.xkey.display = nxagentDisplay; xM.xkey.type = KeyRelease; @@ -2241,7 +2214,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was /* * Handle the agent window's changes. */ - + if (closeSession) { if (nxagentOption(Persistent)) @@ -2960,12 +2933,7 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) if (SelectionCallback) { - int i = 0; - - while ((i < NumCurrentSelections) && - CurrentSelections[i].selection != local) - i++; - + int i = nxagentFindCurrentSelectionIndex(local); if (i < NumCurrentSelections) { SelectionInfoRec info; @@ -3230,12 +3198,10 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X) #ifdef TEST { - WindowPtr pSib; - fprintf(stderr, "nxagentCheckWindowConfiguration: Before restacking top level window [%p]\n", (void *) nxagentWindowPtr(X -> window)); - for (pSib = screenInfo.screens[0]->root -> firstChild; pSib; pSib = pSib -> nextSib) + for (WindowPtr pSib = screenInfo.screens[0]->root -> firstChild; pSib; pSib = pSib -> nextSib) { fprintf(stderr, "nxagentCheckWindowConfiguration: Top level window: [%p].\n", (void *) pSib); @@ -3594,16 +3560,13 @@ int nxagentHandleReparentNotify(XEvent* X) if (nxagentOption(Rootless)) { - WindowPtr pWin; - XlibWindow w; XlibWindow root_return = 0; XlibWindow parent_return = 0; XlibWindow *children_return = NULL; unsigned int nchildren_return = 0; Status result; - - pWin = nxagentWindowPtr(X -> xreparent.window); + WindowPtr pWin = nxagentWindowPtr(X -> xreparent.window); #ifdef TEST @@ -3697,13 +3660,11 @@ int nxagentHandleReparentNotify(XEvent* X) XlibWindow junk; XlibWindow *childrenReturn = NULL; unsigned int nchildrenReturn = 0; - Status result; XWindowAttributes attributes; int x, y; - int xParent, yParent; /* - * Calculate the absolute upper-left X e Y + * Calculate the absolute upper-left X e Y */ if ((XGetWindowAttributes(nxagentDisplay, X -> xreparent.window, @@ -3732,10 +3693,12 @@ int nxagentHandleReparentNotify(XEvent* X) if (w != DefaultRootWindow(nxagentDisplay)) { + int xParent, yParent; + do { - result = XQueryTree(nxagentDisplay, w, &rootReturn, &parentReturn, - &childrenReturn, &nchildrenReturn); + Status result = XQueryTree(nxagentDisplay, w, &rootReturn, &parentReturn, + &childrenReturn, &nchildrenReturn); SAFE_XFree(childrenReturn); @@ -3767,7 +3730,7 @@ int nxagentHandleReparentNotify(XEvent* X) /* * Difference between Absolute X and Parent X gives thickness of side frame. - * Difference between Absolute Y and Parent Y gives thickness of title bar. + * Difference between Absolute Y and Parent Y gives thickness of title bar. */ nxagentChangeOption(WMBorderWidth, (x - xParent)); @@ -3778,19 +3741,29 @@ int nxagentHandleReparentNotify(XEvent* X) return 1; } -void nxagentEnableKeyboardEvents(void) +/* + * Helper for nxagent(Enable|Disable)(Keyboard|Pointer)Events + */ +static void nxagentSwitchEventsAllScreens(Mask mask, Bool enable) { - int i; - Mask mask = nxagentGetDefaultEventMask(); + Mask newmask = nxagentGetDefaultEventMask(); - mask |= NXAGENT_KEYBOARD_EVENT_MASK; + if (enable) + newmask |= mask; + else + newmask &= ~mask; - nxagentSetDefaultEventMask(mask); + nxagentSetDefaultEventMask(newmask); - for (i = 0; i < nxagentNumScreens; i++) + for (int i = 0; i < nxagentNumScreens; i++) { - XSelectInput(nxagentDisplay, nxagentDefaultWindows[i], mask); + XSelectInput(nxagentDisplay, nxagentDefaultWindows[i], newmask); } +} + +void nxagentEnableKeyboardEvents(void) +{ + nxagentSwitchEventsAllScreens(NXAGENT_KEYBOARD_EVENT_MASK, True); XkbSelectEvents(nxagentDisplay, XkbUseCoreKbd, NXAGENT_KEYBOARD_EXTENSION_EVENT_MASK, @@ -3799,49 +3772,19 @@ void nxagentEnableKeyboardEvents(void) void nxagentDisableKeyboardEvents(void) { - int i; - Mask mask = nxagentGetDefaultEventMask(); - - mask &= ~NXAGENT_KEYBOARD_EVENT_MASK; - - nxagentSetDefaultEventMask(mask); - - for (i = 0; i < nxagentNumScreens; i++) - { - XSelectInput(nxagentDisplay, nxagentDefaultWindows[i], mask); - } + nxagentSwitchEventsAllScreens(NXAGENT_KEYBOARD_EVENT_MASK, False); XkbSelectEvents(nxagentDisplay, XkbUseCoreKbd, 0x0, 0x0); } void nxagentEnablePointerEvents(void) { - int i; - Mask mask = nxagentGetDefaultEventMask(); - - mask |= NXAGENT_POINTER_EVENT_MASK; - - nxagentSetDefaultEventMask(mask); - - for (i = 0; i < nxagentNumScreens; i++) - { - XSelectInput(nxagentDisplay, nxagentDefaultWindows[i], mask); - } + nxagentSwitchEventsAllScreens(NXAGENT_POINTER_EVENT_MASK, True); } void nxagentDisablePointerEvents(void) { - int i; - Mask mask = nxagentGetDefaultEventMask(); - - mask &= ~NXAGENT_POINTER_EVENT_MASK; - - nxagentSetDefaultEventMask(mask); - - for (i = 0; i < nxagentNumScreens; i++) - { - XSelectInput(nxagentDisplay, nxagentDefaultWindows[i], mask); - } + nxagentSwitchEventsAllScreens(NXAGENT_POINTER_EVENT_MASK, False); } void nxagentSendFakeKey(int key) @@ -4104,9 +4047,7 @@ void nxagentHandleCollectPropertyEvent(XEvent *X) unsigned long ulReturnBytesLeft; unsigned char *pszReturnData = NULL; int result; - int resource; - - resource = X -> xclient.data.l[1]; + int resource = X -> xclient.data.l[1]; if (X -> xclient.data.l[2] == False) { @@ -4232,17 +4173,14 @@ void nxagentSynchronizeExpose(void) int nxagentLookupByWindow(WindowPtr pWin) { - int i; - int j; - - for (j = 0; j < nxagentExposeQueue.length; j++) + for (int j = 0; j < nxagentExposeQueue.length; j++) { - i = (nxagentExposeQueue.start + j) % EXPOSED_SIZE; + int i = (nxagentExposeQueue.start + j) % EXPOSED_SIZE; if (nxagentExposeQueue.exposures[i].pWindow == pWin && !nxagentExposeQueue.exposures[i].remoteRegionIsCompleted) { - return i; + return i; } } @@ -4251,28 +4189,18 @@ int nxagentLookupByWindow(WindowPtr pWin) void nxagentRemoveDuplicatedKeys(XEvent *X) { - _XQEvent *prev; - _XQEvent *qelt; - - _XQEvent *qeltKeyRelease; - _XQEvent *prevKeyRelease; + _XQEvent *qelt = nxagentDisplay -> head; KeyCode lastKeycode = X -> xkey.keycode; - qelt = nxagentDisplay -> head; - if (qelt == NULL) { #ifdef TEST - int more; - fprintf(stderr, "nxagentRemoveDuplicatedKeys: Trying to read more events " "from the X server.\n"); - more = nxagentReadEvents(nxagentDisplay); - - if (more > 0) + if (nxagentReadEvents(nxagentDisplay) > 0) { fprintf(stderr, "nxagentRemoveDuplicatedKeys: Successfully read more events " "from the X server.\n"); @@ -4289,6 +4217,10 @@ void nxagentRemoveDuplicatedKeys(XEvent *X) if (qelt != NULL) { + _XQEvent *prev; + _XQEvent *qeltKeyRelease; + _XQEvent *prevKeyRelease; + prev = qeltKeyRelease = prevKeyRelease = NULL; LockDisplay(nxagentDisplay); @@ -4391,23 +4323,18 @@ void nxagentAddRectToRemoteExposeRegion(BoxPtr rect) int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr) { - RegionPtr exposeRgn; - RegionPtr remoteExposeRgn; + RegionPtr remoteExposeRgn = (RegionRec *) ptr; #ifdef DEBUG - BoxRec box; - fprintf(stderr, "nxagentClipAndSendExpose: Called.\n"); #endif - remoteExposeRgn = (RegionRec *) ptr; - if (pWin -> drawable.class != InputOnly) { - exposeRgn = RegionCreate(NULL, 1); + RegionPtr exposeRgn = RegionCreate(NULL, 1); #ifdef DEBUG - box = *RegionExtents(remoteExposeRgn); + BoxRec box = *RegionExtents(remoteExposeRgn); fprintf(stderr, "nxagentClipAndSendExpose: Root expose extents: [%d] [%d] [%d] [%d].\n", box.x1, box.y1, box.x2, box.y2); @@ -4526,14 +4453,12 @@ int nxagentUserInput(void *p) int nxagentHandleRRScreenChangeNotify(XEvent *X) { - XRRScreenChangeNotifyEvent *Xr; + XRRScreenChangeNotifyEvent *Xr = (XRRScreenChangeNotifyEvent *) X; #ifdef DEBUG fprintf(stderr, "nxagentHandleRRScreenChangeNotify called.\n"); #endif - Xr = (XRRScreenChangeNotifyEvent *) X; - nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], Xr -> width, Xr -> height, Xr -> mwidth, Xr -> mheight); @@ -4576,12 +4501,9 @@ int nxagentPendingEvents(Display *dpy) } else { - int result; int readable; - result = NXTransReadable(dpy -> fd, &readable); - - if (result == 0) + if (NXTransReadable(dpy -> fd, &readable) == 0) { if (readable > 0) { @@ -4669,11 +4591,6 @@ int nxagentWaitEvents(Display *dpy, useconds_t msec) #ifdef NX_DEBUG_INPUT -void nxagentDumpInputInfo(void) -{ - fprintf(stderr, "Dumping input info ON.\n"); -} - void nxagentGuessDumpInputInfo(ClientPtr client, Atom property, char *data) { if (strcmp(validateString(NameForAtom(property)), "NX_DEBUG_INPUT") == 0) @@ -4731,9 +4648,6 @@ static const char *nxagentGrabStateToString(int state) void nxagentDumpInputDevicesState(void) { - int i, k; - int mask = 1; - CARD8 val; DeviceIntPtr dev; GrabPtr grab; WindowPtr pWin = NULL; @@ -4743,15 +4657,15 @@ void nxagentDumpInputDevicesState(void) dev = inputInfo.keyboard; - for (i = 0; i < DOWN_LENGTH; i++) + for (int i = 0; i < DOWN_LENGTH; i++) { - val = dev -> key -> down[i]; + CARD8 val = dev -> key -> down[i]; if (val != 0) { - for (k = 0; k < 8; k++) + for (int k = 0; k < 8; k++) { - if (val & (mask << k)) + if (val & (1 << k)) { fprintf(stderr, "\n\t[%d] [%s]", i * 8 + k, XKeysymToString(XKeycodeToKeysym(nxagentDisplay, i * 8 + k, 0))); @@ -4804,15 +4718,15 @@ void nxagentDumpInputDevicesState(void) dev = inputInfo.pointer; - for (i = 0; i < DOWN_LENGTH; i++) + for (int i = 0; i < DOWN_LENGTH; i++) { - val = dev -> button -> down[i]; + CARD8 val = dev -> button -> down[i]; if (val != 0) { - for (k = 0; k < 8; k++) + for (int k = 0; k < 8; k++) { - if (val & (mask << k)) + if (val & (1 << k)) { fprintf(stderr, "\n\t[%d]", i * 8 + k); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index 7370bc56d..09ad471c8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -1692,6 +1692,7 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) const char *s; int field; + /* FIXME: use str(n)dup()? */ if ((scalableFontName = malloc(strlen(fontName) + 1)) == NULL) { #ifdef PANIC diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index df9c4ad0a..b53428f96 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -297,85 +297,27 @@ void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) pGC->stipple = lastStipple; } +#define CHECKGCVAL(cmask, member, val) do {if (mask & cmask) { values.member = (val); changeFlag += nxagentTestGC(values.member, member); } } while (0) + void nxagentChangeGC(GCPtr pGC, unsigned long mask) { #ifdef TEST static int nDiscarded; #endif - XGCValues values; - + XGCValues values = {0}; int changeFlag = 0; - if (mask & GCFunction) - { - values.function = pGC->alu; - - changeFlag |= nxagentTestGC(values.function, function); - } - - if (mask & GCPlaneMask) - { - values.plane_mask = pGC->planemask; - - changeFlag += nxagentTestGC(values.plane_mask, plane_mask); - } - - if (mask & GCForeground) - { - values.foreground = nxagentPixel(pGC->fgPixel); - - changeFlag += nxagentTestGC(values.foreground, foreground); - } - - if (mask & GCBackground) - { - values.background = nxagentPixel(pGC->bgPixel); - - changeFlag += nxagentTestGC(values.background, background); - } - - if (mask & GCLineWidth) - { - values.line_width = pGC->lineWidth; - - changeFlag += nxagentTestGC(values.line_width, line_width); - } - - if (mask & GCLineStyle) - { - values.line_style = pGC->lineStyle; - - changeFlag += nxagentTestGC(values.line_style, line_style); - } - - if (mask & GCCapStyle) - { - values.cap_style = pGC->capStyle; - - changeFlag += nxagentTestGC(values.cap_style, cap_style); - } - - if (mask & GCJoinStyle) - { - values.join_style = pGC->joinStyle; - - changeFlag += nxagentTestGC(values.join_style, join_style); - } - - if (mask & GCFillStyle) - { - values.fill_style = pGC->fillStyle; - - changeFlag += nxagentTestGC(values.fill_style, fill_style); - } - - if (mask & GCFillRule) - { - values.fill_rule = pGC->fillRule; - - changeFlag += nxagentTestGC(values.fill_rule, fill_rule); - } + CHECKGCVAL(GCFunction, function, pGC->alu); + CHECKGCVAL(GCPlaneMask, plane_mask, pGC->planemask); + CHECKGCVAL(GCForeground, foreground, nxagentPixel(pGC->fgPixel)); + CHECKGCVAL(GCBackground, background, nxagentPixel(pGC->bgPixel)); + CHECKGCVAL(GCLineWidth, line_width, pGC->lineWidth); + CHECKGCVAL(GCLineStyle, line_style, pGC->lineStyle); + CHECKGCVAL(GCCapStyle, cap_style, pGC->capStyle); + CHECKGCVAL(GCJoinStyle, join_style, pGC->joinStyle); + CHECKGCVAL(GCFillStyle, fill_style, pGC->fillStyle); + CHECKGCVAL(GCFillRule, fill_rule, pGC->fillRule); if (mask & GCTile) { @@ -460,19 +402,8 @@ void nxagentChangeGC(GCPtr pGC, unsigned long mask) changeFlag += nxagentTestGC(values.stipple, stipple); } - if (mask & GCTileStipXOrigin) - { - values.ts_x_origin = pGC->patOrg.x; - - changeFlag += nxagentTestGC(values.ts_x_origin, ts_x_origin); - } - - if (mask & GCTileStipYOrigin) - { - values.ts_y_origin = pGC->patOrg.y; - - changeFlag += nxagentTestGC(values.ts_y_origin, ts_y_origin); - } + CHECKGCVAL(GCTileStipXOrigin, ts_x_origin, pGC->patOrg.x); + CHECKGCVAL(GCTileStipYOrigin, ts_y_origin, pGC->patOrg.y); if (mask & GCFont) { @@ -483,38 +414,14 @@ void nxagentChangeGC(GCPtr pGC, unsigned long mask) else { values.font = nxagentFont(pGC->font); - changeFlag += nxagentTestGC(values.font, font); } } - if (mask & GCSubwindowMode) - { - values.subwindow_mode = pGC->subWindowMode; - - changeFlag += nxagentTestGC(values.subwindow_mode, subwindow_mode); - } - - if (mask & GCGraphicsExposures) - { - values.graphics_exposures = pGC->graphicsExposures; - - changeFlag += nxagentTestGC(values.graphics_exposures, graphics_exposures); - } - - if (mask & GCClipXOrigin) - { - values.clip_x_origin = pGC->clipOrg.x; - - changeFlag += nxagentTestGC(values.clip_x_origin, clip_x_origin); - } - - if (mask & GCClipYOrigin) - { - values.clip_y_origin = pGC->clipOrg.y; - - changeFlag += nxagentTestGC(values.clip_y_origin, clip_y_origin); - } + CHECKGCVAL(GCSubwindowMode, subwindow_mode, pGC->subWindowMode); + CHECKGCVAL(GCGraphicsExposures, graphics_exposures, pGC->graphicsExposures); + CHECKGCVAL(GCClipXOrigin, clip_x_origin, pGC->clipOrg.x); + CHECKGCVAL(GCClipYOrigin, clip_y_origin, pGC->clipOrg.y); if (mask & GCClipMask) { @@ -525,12 +432,7 @@ void nxagentChangeGC(GCPtr pGC, unsigned long mask) mask &= ~GCClipMask; } - if (mask & GCDashOffset) - { - values.dash_offset = pGC->dashOffset; - - changeFlag += nxagentTestGC(values.dash_offset, dash_offset); - } + CHECKGCVAL(GCDashOffset, dash_offset, pGC->dashOffset); if (mask & GCDashList) { @@ -543,12 +445,7 @@ void nxagentChangeGC(GCPtr pGC, unsigned long mask) } } - if (mask & GCArcMode) - { - values.arc_mode = pGC->arcMode; - - changeFlag += nxagentTestGC(values.arc_mode, arc_mode); - } + CHECKGCVAL(GCArcMode, arc_mode, pGC->arcMode); if (nxagentGCTrap == 1) { @@ -1008,10 +905,10 @@ int nxagentDestroyNewGCResourceType(void * p, XID id) return 1; } +#define SETGCVAL(mask, member, val) valuemask |= mask; values.member = (val) + static void nxagentReconnectGC(void *param0, XID param1, void * param2) { - XGCValues values; - unsigned long valuemask; GCPtr pGC = (GCPtr) param0; Bool *pBool = (Bool*)param2; @@ -1035,42 +932,29 @@ static void nxagentReconnectGC(void *param0, XID param1, void * param2) fprintf(stderr, "nxagentReconnectGC: GC at [%p].\n", (void *) pGC); #endif - valuemask = 0; - memset(&values,0,sizeof(XGCValues)); - values.function = pGC->alu; - valuemask |= GCFunction; - values.plane_mask = pGC->planemask; - valuemask |= GCPlaneMask; - values.foreground = nxagentPixel(pGC->fgPixel); - valuemask |= GCForeground; - values.background = nxagentPixel(pGC->bgPixel); - valuemask |= GCBackground; - - values.line_width = pGC->lineWidth; - valuemask |= GCLineWidth; - values.line_style = pGC->lineStyle; - valuemask |= GCLineStyle; - values.cap_style = pGC->capStyle; - valuemask |= GCCapStyle; - values.join_style = pGC->joinStyle; - valuemask |= GCJoinStyle; - values.fill_style = pGC->fillStyle; - valuemask |= GCFillStyle; - values.fill_rule = pGC->fillRule; - valuemask |= GCFillRule; - - if (!pGC -> tileIsPixel && (pGC -> tile.pixmap != NULL)) + XGCValues values = {0}; + unsigned long valuemask = 0; + SETGCVAL(GCFunction, function, pGC->alu); + SETGCVAL(GCPlaneMask, plane_mask, pGC->planemask); + SETGCVAL(GCForeground, foreground, nxagentPixel(pGC->fgPixel)); + SETGCVAL(GCBackground, background, nxagentPixel(pGC->bgPixel)); + SETGCVAL(GCLineWidth, line_width, pGC->lineWidth); + SETGCVAL(GCLineStyle, line_style, pGC->lineStyle); + SETGCVAL(GCCapStyle, cap_style, pGC->capStyle); + SETGCVAL(GCJoinStyle, join_style, pGC->joinStyle); + SETGCVAL(GCFillStyle, fill_style, pGC->fillStyle); + SETGCVAL(GCFillRule, fill_rule, pGC->fillRule); + + if (!pGC -> tileIsPixel && (pGC -> tile.pixmap != NULL)) { if (nxagentPixmapIsVirtual(pGC -> tile.pixmap)) { - values.tile = nxagentPixmap(nxagentRealPixmap(pGC -> tile.pixmap)); + SETGCVAL(GCTile, tile, nxagentPixmap(nxagentRealPixmap(pGC -> tile.pixmap))); } else { - values.tile = nxagentPixmap(pGC -> tile.pixmap); + SETGCVAL(GCTile, tile, nxagentPixmap(pGC -> tile.pixmap)); } - - valuemask |= GCTile; } if (pGC->stipple != NULL) @@ -1087,7 +971,7 @@ static void nxagentReconnectGC(void *param0, XID param1, void * param2) nxagentReconnectPixmap(nxagentRealPixmap(pGC -> stipple), 0, pBool); } - values.stipple = nxagentPixmap(nxagentRealPixmap(pGC -> stipple)); + SETGCVAL(GCStipple, stipple, nxagentPixmap(nxagentRealPixmap(pGC -> stipple))); } else { @@ -1101,42 +985,31 @@ static void nxagentReconnectGC(void *param0, XID param1, void * param2) nxagentReconnectPixmap(pGC -> stipple, 0, pBool); } - values.stipple = nxagentPixmap(pGC->stipple); + SETGCVAL(GCStipple, stipple, nxagentPixmap(pGC->stipple)); } - valuemask |= GCStipple; } - values.ts_x_origin = pGC->patOrg.x; - valuemask |= GCTileStipXOrigin; - values.ts_y_origin = pGC->patOrg.y; - valuemask |= GCTileStipYOrigin; + SETGCVAL(GCTileStipXOrigin, ts_x_origin, pGC->patOrg.x); + SETGCVAL(GCTileStipYOrigin, ts_y_origin, pGC->patOrg.y); if (pGC->font != NULL) { - values.font = nxagentFont(pGC->font); - valuemask |= GCFont; + SETGCVAL(GCFont, font, nxagentFont(pGC->font)); } - values.subwindow_mode = pGC->subWindowMode; - valuemask |= GCSubwindowMode; - values.graphics_exposures = pGC->graphicsExposures; - valuemask |= GCGraphicsExposures; - values.clip_x_origin = pGC->clipOrg.x; - valuemask |= GCClipXOrigin; - values.clip_y_origin = pGC->clipOrg.y; - valuemask |= GCClipYOrigin; - valuemask |= GCClipMask; - values.dash_offset = pGC->dashOffset; - valuemask |= GCDashOffset; + SETGCVAL(GCSubwindowMode, subwindow_mode, pGC->subWindowMode); + SETGCVAL(GCGraphicsExposures, graphics_exposures, pGC->graphicsExposures); + SETGCVAL(GCClipXOrigin, clip_x_origin, pGC->clipOrg.x); + SETGCVAL(GCClipYOrigin, clip_y_origin, pGC->clipOrg.y); + valuemask |= GCClipMask; /* FIXME: where's the ClipMask pixmap?? */ + SETGCVAL(GCDashOffset, dash_offset, pGC->dashOffset); if (pGC->dash != NULL) { - values.dashes = *pGC->dash; - valuemask |= GCDashList; + SETGCVAL(GCDashList, dashes, *pGC->dash); } - values.arc_mode = pGC->arcMode; - valuemask |= GCArcMode; + SETGCVAL(GCArcMode, arc_mode, pGC->arcMode); if ((nxagentGC(pGC) = XCreateGC(nxagentDisplay, nxagentDefaultDrawables[pGC->depth], @@ -1440,22 +1313,17 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) */ GCPtr nxagentGetScratchGC(unsigned depth, ScreenPtr pScreen) { - GCPtr pGC; - XGCValues values; - unsigned long mask; - int nxagentSaveGCTrap; - /* * The GC trap is temporarily disabled in * order to allow the remote clipmask reset * requested by GetScratchGC(). */ - nxagentSaveGCTrap = nxagentGCTrap; + int nxagentSaveGCTrap = nxagentGCTrap; nxagentGCTrap = 0; - pGC = GetScratchGC(depth, pScreen); + GCPtr pGC = GetScratchGC(depth, pScreen); nxagentGCTrap = nxagentSaveGCTrap; @@ -1468,65 +1336,31 @@ GCPtr nxagentGetScratchGC(unsigned depth, ScreenPtr pScreen) return NULL; } - mask = 0; - - values.function = pGC -> alu; - mask |= GCFunction; - - values.plane_mask = pGC -> planemask; - mask |= GCPlaneMask; - - values.foreground = nxagentPixel(pGC -> fgPixel); - mask |= GCForeground; - - values.background = nxagentPixel(pGC -> bgPixel); - mask |= GCBackground; - - values.line_width = pGC -> lineWidth; - mask |= GCLineWidth; - - values.line_style = pGC -> lineStyle; - mask |= GCLineStyle; - - values.cap_style = pGC -> capStyle; - mask |= GCCapStyle; - - values.join_style = pGC -> joinStyle; - mask |= GCJoinStyle; - - values.fill_style = pGC -> fillStyle; - mask |= GCFillStyle; - - values.fill_rule = pGC -> fillRule; - mask |= GCFillRule; - - values.arc_mode = pGC -> arcMode; - mask |= GCArcMode; - - values.ts_x_origin = pGC -> patOrg.x; - mask |= GCTileStipXOrigin; - - values.ts_y_origin = pGC -> patOrg.y; - mask |= GCTileStipYOrigin; - - values.subwindow_mode = pGC -> subWindowMode; - mask |= GCSubwindowMode; - - values.graphics_exposures = pGC -> graphicsExposures; - mask |= GCGraphicsExposures; - - /* - * The GCClipMask is set to none inside - * the GetScratchGC() function. - */ - - values.clip_x_origin = pGC -> clipOrg.x; - mask |= GCClipXOrigin; - - values.clip_y_origin = pGC -> clipOrg.y; - mask |= GCClipYOrigin; - - XChangeGC(nxagentDisplay, nxagentGC(pGC), mask, &values); + unsigned long valuemask = 0; + XGCValues values = {0}; + SETGCVAL(GCFunction, function, pGC -> alu); + SETGCVAL(GCPlaneMask, plane_mask, pGC -> planemask); + SETGCVAL(GCForeground, foreground, nxagentPixel(pGC -> fgPixel)); + SETGCVAL(GCBackground, background, nxagentPixel(pGC -> bgPixel)); + SETGCVAL(GCLineWidth, line_width, pGC -> lineWidth); + SETGCVAL(GCLineStyle, line_style, pGC -> lineStyle); + SETGCVAL(GCCapStyle, cap_style, pGC -> capStyle); + SETGCVAL(GCJoinStyle, join_style, pGC -> joinStyle); + SETGCVAL(GCFillStyle, fill_style, pGC -> fillStyle); + SETGCVAL(GCFillRule, fill_rule, pGC -> fillRule); + SETGCVAL(GCArcMode, arc_mode, pGC -> arcMode); + SETGCVAL(GCTileStipXOrigin, ts_x_origin, pGC -> patOrg.x); + SETGCVAL(GCTileStipYOrigin, ts_y_origin, pGC -> patOrg.y); + SETGCVAL(GCSubwindowMode, subwindow_mode, pGC -> subWindowMode); + SETGCVAL(GCGraphicsExposures, graphics_exposures, pGC -> graphicsExposures); + SETGCVAL(GCClipXOrigin, clip_x_origin, pGC -> clipOrg.x); + SETGCVAL(GCClipYOrigin, clip_y_origin, pGC -> clipOrg.y); + + /* The GCClipMask is set to none inside the GetScratchGC() function. */ + + /* FIXME: What about GCDashOffset? */ + + XChangeGC(nxagentDisplay, nxagentGC(pGC), valuemask, &values); memset(&(nxagentGCPriv(pGC) -> lastServerValues), 0, sizeof(XGCValues)); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Holder.c b/nx-X11/programs/Xserver/hw/nxagent/Holder.c index aae48471b..c27f67818 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Holder.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Holder.c @@ -185,8 +185,6 @@ void nxagentApplyPlaceholder(Drawable drawable, int x, int y, } XFreeGC(nxagentDisplay, gc); - - return; } #ifdef DUMP diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index a7bacaf85..e55ed2dd2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -644,23 +644,23 @@ FIXME: Should use these. pDrawable -> depth != 1 && nxagentOption(DeferLevel) >= 1) { - /* -- changed by dimbor (small "bed-sheets" never need be prevented - always put) --*/ - if (dstHeight > 16) - { - /* -------------------------------------------------------------------------------- */ - #ifdef TEST - fprintf(stderr, "nxagentPutImage: WARNING! Prevented operation on region [%d,%d,%d,%d] " - "for drawable at [%p] with drawable pixmap.\n", pRegion -> extents.x1, - pRegion -> extents.y1, pRegion -> extents.x2, pRegion -> extents.y2, - (void *) pDrawable); - #endif + /* -- changed by dimbor (small "bed-sheets" never need be prevented - always put) --*/ + if (dstHeight > 16) + { + /* -------------------------------------------------------------------------------- */ + #ifdef TEST + fprintf(stderr, "nxagentPutImage: WARNING! Prevented operation on region [%d,%d,%d,%d] " + "for drawable at [%p] with drawable pixmap.\n", pRegion -> extents.x1, + pRegion -> extents.y1, pRegion -> extents.x2, pRegion -> extents.y2, + (void *) pDrawable); + #endif - nxagentMarkCorruptedRegion(pDrawable, pRegion); + nxagentMarkCorruptedRegion(pDrawable, pRegion); - goto nxagentPutImageEnd; - /* --- changed by dimbor ---*/ - } - /* ------------------------- */ + goto nxagentPutImageEnd; + /* --- changed by dimbor ---*/ + } + /* ------------------------- */ } if (pDrawable -> type == DRAWABLE_WINDOW && diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index b3450440e..ff9538f3e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -203,18 +203,43 @@ INCLUDES = \ ### NXAGENT Defines: # -# NXAGENT_FONTCACHE_SIZE Number of cache slots -# NXAGENT_SHAPE Old shape code -# NXAGENT_GLYPHCACHE -# NXAGENT_GLYPHCACHE_SIZE Slots for glyph cache -# NXAGENT_SHAPE2 New shape code -# NXAGENT_FIXKEYS Force the release of pressed key when losing focus -# NXAGENT_EXPOSURES Manage expose events +# NXAGENT_SHAPE Old shape code +# NXAGENT_SHAPE2 New shape code +# NXAGENT_FIXKEYS Force the release of pressed key when losing focus # NXAGENT_CLIPBOARD Enables clipboard cut and paste function between X servers. -# NXAGENT_FONTEXCLUDE Exclude some specific font names (only "-ult1mo" at this moment). -# NXAGENT FULLSCREEN Fullscreen mode -# NXAGENT_RANDR_MODE_PREFIX Use prefixed (i.e., nx_<x>x<y>) RandR modes +# NXAGENT_RANDR_MODE_PREFIX Prefix for RandR modes (i.e., nx_<x>x<y>) (default: nx_) # NXAGENT_RANDR_XINERAMA_CLIPPING cut off invisible window parts in xinerama mode (you probably do not want this) +# NXAGENT_TIMESTAMP print duration for some routines +# +### macros not investigated yet: +# +# NXAGENT_PICTURE_ALWAYS_POINTS_TO_VIRTUAL +# NXAGENT_RENDER_CLEANUP +# NXAGENT_WAKEUP=<milliseconds> +# NXAGENT_ONSTART +# NXAGENT_SPLASH +# NXAGENT_ARTSD +# +### Debug macros: +# +# DEBUG_COLORMAP +# DEBUG_TREE +# NXAGENT_DEBUG +# NXAGENT_FIXKEYS_DEBUG +# NXAGENT_FONTCACHE_DEBUG +# NXAGENT_FONTMATCH_DEBUG +# NXAGENT_LOGO_DEBUG +# NXAGENT_RECONNECT_COLORMAP_DEBUG +# NXAGENT_RECONNECT_CURSOR_DEBUG +# NXAGENT_RECONNECT_DEBUG +# NXAGENT_RECONNECT_DISPLAY_DEBUG +# NXAGENT_RECONNECT_FONT_DEBUG +# NXAGENT_RECONNECT_PICTFORMAT_DEBUG +# NXAGENT_RECONNECT_PICTURE_DEBUG +# NXAGENT_RECONNECT_SCREEN_DEBUG +# NXAGENT_RECONNECT_WINDOW_DEBUG +# NXAGENT_XKBD_DEBUG +# NX_DEBUG_INPUT #if nxVersion NX_DEFINES = \ @@ -224,34 +249,26 @@ NX_DEFINES = \ #endif DEFINES = \ - -g $(OS_DEFINES) $(EXT_DEFINES) $(NX_DEFINES) \ + -g $(OS_DEFINES) $(EXT_DEFINES) $(NX_DEFINES) \ -UXF86VIDMODE -UXFreeXDGA -UXF86MISC -UXF86DRI \ -DNXAGENT_SERVER \ - -DNXAGENT_CONSTRAINCURSOR \ - -DNXAGENT_FONTCACHE_SIZE=50 \ - -DNXAGENT_GLYPHCACHE -DNXAGENT_GLYPHCACHE_SIZE=50 \ -DNXAGENT_RENDER_CLEANUP \ -DNXAGENT_SHAPE2 \ -DNXAGENT_FIXKEYS \ -DNXAGENT_CLIPBOARD \ - -DNXAGENT_EXPOSURES \ - -DNXAGENT_FONTEXCLUDE \ - -DNXAGENT_PACKEDIMAGES \ - -DNXAGENT_VISIBILITY \ -DNXAGENT_WAKEUP=1000 \ -DNXAGENT_ONSTART \ -DNXAGENT_ARTSD \ - -DNXAGENT_RANDR_MODE_PREFIX \ -UNX_DEBUG_INPUT \ - -DRANDR_10_INTERFACE=1 \ - -DRANDR_12_INTERFACE=1 \ - -DRANDR_13_INTERFACE=1 \ - -DRANDR_14_INTERFACE=1 \ - -DRANDR_15_INTERFACE=1 \ + -DRANDR_10_INTERFACE=1 \ + -DRANDR_12_INTERFACE=1 \ + -DRANDR_13_INTERFACE=1 \ + -DRANDR_14_INTERFACE=1 \ + -DRANDR_15_INTERFACE=1 \ -DPANORAMIX \ -UDEBUG_TREE \ -DSYSTEMFONTDIR=\"$(SYSTEMFONTDIR)\" \ - $(NULL) + $(NULL) all:: $(OBJS) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 2a0bceaf5..0b4ffd601 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -71,6 +71,7 @@ is" without express or implied warranty. #include "Millis.h" #include "Error.h" #include "Keystroke.h" +#include "Atoms.h" #include <nx/NX.h> #include "compext/Compext.h" @@ -148,6 +149,8 @@ extern void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, void *args); #endif +extern const char *nxagentProgName; + void ddxInitGlobals(void) { /* @@ -199,8 +202,6 @@ Bool nxagentX2go; void checkX2goAgent(void) { - extern const char *nxagentProgName; - #ifdef TEST fprintf(stderr, "%s: nxagentProgName [%s]\n", __func__, nxagentProgName); #endif @@ -221,15 +222,6 @@ void checkX2goAgent(void) void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) { - char *authority; - int i; - - #ifdef __sun - - char *environment; - - #endif - /* * Print our pid and version information. */ @@ -295,11 +287,13 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) } #endif - if ((authority = getenv("NX_XAUTHORITY"))) + char *authority = getenv("NX_XAUTHORITY"); + + if (authority) { #ifdef __sun - environment = malloc(15 + strlen(authority)); + char *environment = malloc(15 + strlen(authority)); sprintf(environment, "XAUTHORITY=%s", authority); @@ -391,7 +385,7 @@ FIXME: These variables, if not removed at all because have probably nxagentNumScreens = 1; } - for (i = 0; i < nxagentNumScreens; i++) + for (int i = 0; i < nxagentNumScreens; i++) { AddScreen(nxagentOpenScreen, argc, argv); } @@ -421,6 +415,8 @@ FIXME: These variables, if not removed at all because have probably #ifdef NXAGENT_CLIPBOARD AddCallback(&SelectionCallback, nxagentSetSelectionCallback, NULL); #endif + + nxagentInitAtoms(); } void diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index b7ed38ca3..0ebaf677b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -188,261 +188,57 @@ static void nxagentCheckRemoteKeycodes(void); static CARD8 nxagentConvertedKeycodes[] = { /* evdev pc105*/ - /* 0 */ 0, - /* 1 */ 1, - /* 2 */ 2, - /* 3 */ 3, - /* 4 */ 4, - /* 5 */ 5, - /* 6 */ 6, - /* 7 */ 7, - /* 8 */ 8, - /* 9 */ 9, - /* 10 */ 10, - /* 11 */ 11, - /* 12 */ 12, - /* 13 */ 13, - /* 14 */ 14, - /* 15 */ 15, - /* 16 */ 16, - /* 17 */ 17, - /* 18 */ 18, - /* 19 */ 19, - /* 20 */ 20, - /* 21 */ 21, - /* 22 */ 22, - /* 23 */ 23, - /* 24 */ 24, - /* 25 */ 25, - /* 26 */ 26, - /* 27 */ 27, - /* 28 */ 28, - /* 29 */ 29, - /* 30 */ 30, - /* 31 */ 31, - /* 32 */ 32, - /* 33 */ 33, - /* 34 */ 34, - /* 35 */ 35, - /* 36 */ 36, - /* 37 */ 37, - /* 38 */ 38, - /* 39 */ 39, - /* 40 */ 40, - /* 41 */ 41, - /* 42 */ 42, - /* 43 */ 43, - /* 44 */ 44, - /* 45 */ 45, - /* 46 */ 46, - /* 47 */ 47, - /* 48 */ 48, - /* 49 */ 49, - /* 50 */ 50, - /* 51 */ 51, - /* 52 */ 52, - /* 53 */ 53, - /* 54 */ 54, - /* 55 */ 55, - /* 56 */ 56, - /* 57 */ 57, - /* 58 */ 58, - /* 59 */ 59, - /* 60 */ 60, - /* 61 */ 61, - /* 62 */ 62, - /* 63 */ 63, - /* 64 */ 64, - /* 65 */ 65, - /* 66 */ 66, - /* 67 */ 67, - /* 68 */ 68, - /* 69 */ 69, - /* 70 */ 70, - /* 71 */ 71, - /* 72 */ 72, - /* 73 */ 73, - /* 74 */ 74, - /* 75 */ 75, - /* 76 */ 76, - /* 77 */ 77, - /* 78 */ 78, - /* 79 */ 79, - /* 80 */ 80, - /* 81 */ 81, - /* 82 */ 82, - /* 83 */ 83, - /* 84 */ 84, - /* 85 */ 85, - /* 86 */ 86, - /* 87 */ 87, - /* 88 */ 88, - /* 89 */ 89, - /* 90 */ 90, - /* 91 */ 91, - /* 92 */ 124, - /* 93 */ 93, - /* 94 */ 94, - /* 95 */ 95, - /* 96 */ 96, - /* 97 */ 211, - /* 98 */ 98, - /* 99 */ 99, - /* 100 */ 100, - /* 101 */ 208, - /* 102 */ 102, - /* 103 */ 103, - /* 104 */ 108, - /* 105 */ 109, - /* 106 */ 112, - /* 107 */ 111, - /* 108 */ 113, - /* 109 */ 109, - /* 110 */ 97, - /* 111 */ 98, - /* 112 */ 99, - /* 113 */ 100, - /* 114 */ 102, - /* 115 */ 103, - /* 116 */ 104, - /* 117 */ 105, - /* 118 */ 106, - /* 119 */ 107, - /* 120 */ 120, - /* 121 */ 121, - /* 122 */ 122, - /* 123 */ 123, - /* 124 */ 124, - /* 125 */ 126, - /* 126 */ 126, - /* 127 */ 110, - /* 128 */ 128, - /* 129 */ 129, - /* 130 */ 130, - /* 131 */ 131, - /* 132 */ 133, - /* 133 */ 115, - /* 134 */ 116, - /* 135 */ 117, - /* 136 */ 136, - /* 137 */ 137, - /* 138 */ 138, - /* 139 */ 139, - /* 140 */ 140, - /* 141 */ 141, - /* 142 */ 142, - /* 143 */ 143, - /* 144 */ 144, - /* 145 */ 145, - /* 146 */ 146, - /* 147 */ 147, - /* 148 */ 148, - /* 149 */ 149, - /* 150 */ 150, - /* 151 */ 151, - /* 152 */ 152, - /* 153 */ 153, - /* 154 */ 154, - /* 155 */ 155, - /* 156 */ 156, - /* 157 */ 157, - /* 158 */ 158, - /* 159 */ 159, - /* 160 */ 160, - /* 161 */ 161, - /* 162 */ 162, - /* 163 */ 163, - /* 164 */ 164, - /* 165 */ 165, - /* 166 */ 166, - /* 167 */ 167, - /* 168 */ 168, - /* 169 */ 169, - /* 170 */ 170, - /* 171 */ 171, - /* 172 */ 172, - /* 173 */ 173, - /* 174 */ 174, - /* 175 */ 175, - /* 176 */ 176, - /* 177 */ 177, - /* 178 */ 178, - /* 179 */ 179, - /* 180 */ 180, - /* 181 */ 181, - /* 182 */ 182, - /* 183 */ 183, - /* 184 */ 184, - /* 185 */ 185, - /* 186 */ 186, - /* 187 */ 187, - /* 188 */ 188, - /* 189 */ 189, - /* 190 */ 190, - /* 191 */ 118, - /* 192 */ 119, - /* 193 */ 120, - /* 194 */ 121, - /* 195 */ 122, - /* 196 */ 196, - /* 197 */ 197, - /* 198 */ 198, - /* 199 */ 199, - /* 200 */ 200, - /* 201 */ 201, - /* 202 */ 202, - /* 203 */ 93, - /* 204 */ 125, - /* 205 */ 156, - /* 206 */ 127, - /* 207 */ 128, - /* 208 */ 208, - /* 209 */ 209, - /* 210 */ 210, - /* 211 */ 211, - /* 212 */ 212, - /* 213 */ 213, - /* 214 */ 214, - /* 215 */ 215, - /* 216 */ 216, - /* 217 */ 217, - /* 218 */ 218, - /* 219 */ 219, - /* 220 */ 220, - /* 221 */ 221, - /* 222 */ 222, - /* 223 */ 223, - /* 224 */ 224, - /* 225 */ 225, - /* 226 */ 226, - /* 227 */ 227, - /* 228 */ 228, - /* 229 */ 229, - /* 230 */ 230, - /* 231 */ 231, - /* 232 */ 232, - /* 233 */ 233, - /* 234 */ 234, - /* 235 */ 235, - /* 236 */ 236, - /* 237 */ 237, - /* 238 */ 238, - /* 239 */ 239, - /* 240 */ 240, - /* 241 */ 241, - /* 242 */ 242, - /* 243 */ 243, - /* 244 */ 244, - /* 245 */ 245, - /* 246 */ 246, - /* 247 */ 247, - /* 248 */ 248, - /* 249 */ 249, - /* 250 */ 250, - /* 251 */ 251, - /* 252 */ 252, - /* 253 */ 253, - /* 254 */ 254, + /* 0 */ 0, /* 1 */ 1, /* 2 */ 2, /* 3 */ 3, /* 4 */ 4, + /* 5 */ 5, /* 6 */ 6, /* 7 */ 7, /* 8 */ 8, /* 9 */ 9, + /* 10 */ 10, /* 11 */ 11, /* 12 */ 12, /* 13 */ 13, /* 14 */ 14, + /* 15 */ 15, /* 16 */ 16, /* 17 */ 17, /* 18 */ 18, /* 19 */ 19, + /* 20 */ 20, /* 21 */ 21, /* 22 */ 22, /* 23 */ 23, /* 24 */ 24, + /* 25 */ 25, /* 26 */ 26, /* 27 */ 27, /* 28 */ 28, /* 29 */ 29, + /* 30 */ 30, /* 31 */ 31, /* 32 */ 32, /* 33 */ 33, /* 34 */ 34, + /* 35 */ 35, /* 36 */ 36, /* 37 */ 37, /* 38 */ 38, /* 39 */ 39, + /* 40 */ 40, /* 41 */ 41, /* 42 */ 42, /* 43 */ 43, /* 44 */ 44, + /* 45 */ 45, /* 46 */ 46, /* 47 */ 47, /* 48 */ 48, /* 49 */ 49, + /* 50 */ 50, /* 51 */ 51, /* 52 */ 52, /* 53 */ 53, /* 54 */ 54, + /* 55 */ 55, /* 56 */ 56, /* 57 */ 57, /* 58 */ 58, /* 59 */ 59, + /* 60 */ 60, /* 61 */ 61, /* 62 */ 62, /* 63 */ 63, /* 64 */ 64, + /* 65 */ 65, /* 66 */ 66, /* 67 */ 67, /* 68 */ 68, /* 69 */ 69, + /* 70 */ 70, /* 71 */ 71, /* 72 */ 72, /* 73 */ 73, /* 74 */ 74, + /* 75 */ 75, /* 76 */ 76, /* 77 */ 77, /* 78 */ 78, /* 79 */ 79, + /* 80 */ 80, /* 81 */ 81, /* 82 */ 82, /* 83 */ 83, /* 84 */ 84, + /* 85 */ 85, /* 86 */ 86, /* 87 */ 87, /* 88 */ 88, /* 89 */ 89, + /* 90 */ 90, /* 91 */ 91, /* 92 */ 124, /* 93 */ 93, /* 94 */ 94, + /* 95 */ 95, /* 96 */ 96, /* 97 */ 211, /* 98 */ 98, /* 99 */ 99, + /* 100 */ 100, /* 101 */ 208, /* 102 */ 102, /* 103 */ 103, /* 104 */ 108, + /* 105 */ 109, /* 106 */ 112, /* 107 */ 111, /* 108 */ 113, /* 109 */ 109, + /* 110 */ 97, /* 111 */ 98, /* 112 */ 99, /* 113 */ 100, /* 114 */ 102, + /* 115 */ 103, /* 116 */ 104, /* 117 */ 105, /* 118 */ 106, /* 119 */ 107, + /* 120 */ 120, /* 121 */ 121, /* 122 */ 122, /* 123 */ 123, /* 124 */ 124, + /* 125 */ 126, /* 126 */ 126, /* 127 */ 110, /* 128 */ 128, /* 129 */ 129, + /* 130 */ 130, /* 131 */ 131, /* 132 */ 133, /* 133 */ 115, /* 134 */ 116, + /* 135 */ 117, /* 136 */ 136, /* 137 */ 137, /* 138 */ 138, /* 139 */ 139, + /* 140 */ 140, /* 141 */ 141, /* 142 */ 142, /* 143 */ 143, /* 144 */ 144, + /* 145 */ 145, /* 146 */ 146, /* 147 */ 147, /* 148 */ 148, /* 149 */ 149, + /* 150 */ 150, /* 151 */ 151, /* 152 */ 152, /* 153 */ 153, /* 154 */ 154, + /* 155 */ 155, /* 156 */ 156, /* 157 */ 157, /* 158 */ 158, /* 159 */ 159, + /* 160 */ 160, /* 161 */ 161, /* 162 */ 162, /* 163 */ 163, /* 164 */ 164, + /* 165 */ 165, /* 166 */ 166, /* 167 */ 167, /* 168 */ 168, /* 169 */ 169, + /* 170 */ 170, /* 171 */ 171, /* 172 */ 172, /* 173 */ 173, /* 174 */ 174, + /* 175 */ 175, /* 176 */ 176, /* 177 */ 177, /* 178 */ 178, /* 179 */ 179, + /* 180 */ 180, /* 181 */ 181, /* 182 */ 182, /* 183 */ 183, /* 184 */ 184, + /* 185 */ 185, /* 186 */ 186, /* 187 */ 187, /* 188 */ 188, /* 189 */ 189, + /* 190 */ 190, /* 191 */ 118, /* 192 */ 119, /* 193 */ 120, /* 194 */ 121, + /* 195 */ 122, /* 196 */ 196, /* 197 */ 197, /* 198 */ 198, /* 199 */ 199, + /* 200 */ 200, /* 201 */ 201, /* 202 */ 202, /* 203 */ 93, /* 204 */ 125, + /* 205 */ 156, /* 206 */ 127, /* 207 */ 128, /* 208 */ 208, /* 209 */ 209, + /* 210 */ 210, /* 211 */ 211, /* 212 */ 212, /* 213 */ 213, /* 214 */ 214, + /* 215 */ 215, /* 216 */ 216, /* 217 */ 217, /* 218 */ 218, /* 219 */ 219, + /* 220 */ 220, /* 221 */ 221, /* 222 */ 222, /* 223 */ 223, /* 224 */ 224, + /* 225 */ 225, /* 226 */ 226, /* 227 */ 227, /* 228 */ 228, /* 229 */ 229, + /* 230 */ 230, /* 231 */ 231, /* 232 */ 232, /* 233 */ 233, /* 234 */ 234, + /* 235 */ 235, /* 236 */ 236, /* 237 */ 237, /* 238 */ 238, /* 239 */ 239, + /* 240 */ 240, /* 241 */ 241, /* 242 */ 242, /* 243 */ 243, /* 244 */ 244, + /* 245 */ 245, /* 246 */ 246, /* 247 */ 247, /* 248 */ 248, /* 249 */ 249, + /* 250 */ 250, /* 251 */ 251, /* 252 */ 252, /* 253 */ 253, /* 254 */ 254, /* 255 */ 255 }; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index fb2979a1f..b6d8f5817 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -434,7 +434,7 @@ void nxagentDumpKeystrokes(void) for (int i = 0; nxagentSpecialKeystrokeNames[i]; i++) maxlen = min(maxlen, strlen(nxagentSpecialKeystrokeNames[i])); - fprintf(stderr, "Current known keystrokes:\n"); + fprintf(stderr, "Currently known keystrokes:\n"); for (struct nxagentSpecialKeystrokeMap *cur = map; cur->stroke != KEYSTROKE_END_MARKER; cur++) { unsigned int mask = cur->modifierMask; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 10616834e..4a9ae73ae 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -194,6 +194,13 @@ extern int nxagentMaxAllowedResets; extern int nxagentFindClientResource(int, RESTYPE, void *); +#ifdef NXAGENT_CLIPBOARD +extern int nxagentPrimarySelection; +extern int nxagentClipboardSelection; +extern int nxagentMaxSelections; +#endif + +extern int nxOpenFont(ClientPtr, XID, Mask, unsigned, char*); void InitSelections() @@ -206,23 +213,23 @@ InitSelections() #ifdef NXAGENT_CLIPBOARD { Selection *newsels; - newsels = (Selection *)malloc(2 * sizeof(Selection)); + newsels = (Selection *)malloc(nxagentMaxSelections * sizeof(Selection)); if (!newsels) return; - NumCurrentSelections += 2; + NumCurrentSelections += nxagentMaxSelections; CurrentSelections = newsels; - CurrentSelections[0].selection = XA_PRIMARY; - CurrentSelections[0].lastTimeChanged = ClientTimeToServerTime(0); - CurrentSelections[0].window = screenInfo.screens[0]->root->drawable.id; - CurrentSelections[0].pWin = NULL; - CurrentSelections[0].client = NullClient; - - CurrentSelections[1].selection = MakeAtom("CLIPBOARD", 9, 1); - CurrentSelections[1].lastTimeChanged = ClientTimeToServerTime(0); - CurrentSelections[1].window = screenInfo.screens[0]->root->drawable.id; - CurrentSelections[1].pWin = NULL; - CurrentSelections[1].client = NullClient; + CurrentSelections[nxagentPrimarySelection].selection = XA_PRIMARY; + CurrentSelections[nxagentPrimarySelection].lastTimeChanged = ClientTimeToServerTime(0); + CurrentSelections[nxagentPrimarySelection].window = screenInfo.screens[0]->root->drawable.id; + CurrentSelections[nxagentPrimarySelection].pWin = NULL; + CurrentSelections[nxagentPrimarySelection].client = NullClient; + + CurrentSelections[nxagentClipboardSelection].selection = MakeAtom("CLIPBOARD", 9, 1); + CurrentSelections[nxagentClipboardSelection].lastTimeChanged = ClientTimeToServerTime(0); + CurrentSelections[nxagentClipboardSelection].window = screenInfo.screens[0]->root->drawable.id; + CurrentSelections[nxagentClipboardSelection].pWin = NULL; + CurrentSelections[nxagentClipboardSelection].client = NullClient; } #endif @@ -684,11 +691,7 @@ ProcConvertSelection(register ClientPtr client) (stuff->selection == MakeAtom("CLIPBOARD", 9, 0))) && nxagentOption(Clipboard) != ClipboardNone) { - int i = 0; - - while ((i < NumCurrentSelections) && - CurrentSelections[i].selection != stuff->selection) i++; - + int i = nxagentFindCurrentSelectionIndex(stuff->selection); if ((i < NumCurrentSelections) && (CurrentSelections[i].window != None)) { if (nxagentConvertSelection(client, pWin, stuff->selection, stuff->requestor, @@ -769,7 +772,6 @@ ProcOpenFont(register ClientPtr client) fontReq[stuff->nbytes]=0; if (strchr(fontReq,'*') || strchr(fontReq,'?')) { - extern int nxOpenFont(ClientPtr, XID, Mask, unsigned, char*); #ifdef NXAGENT_FONTMATCH_DEBUG fprintf(stderr, "Dispatch: ProcOpenFont try to find a common font with font pattern=%s\n",fontReq); #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index bfb208593..992a6674f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -88,13 +88,7 @@ static Bool doListFontsAndAliases(ClientPtr client, LFclosurePtr c); #include "Agent.h" #include "Font.h" -#ifndef NX_TRANS_SOCKET - -#define NX_TRANS_SOCKET - -#endif - -#ifdef NX_TRANS_SOCKET +#ifdef NXAGENT_SERVER #define NXFONTPATHLENGTH 1024 char _NXFontPath[NXFONTPATHLENGTH]; @@ -107,8 +101,6 @@ char _NXFontPath[NXFONTPATHLENGTH]; static const char *_NXGetFontPath(const char *path) { - const char *fontEnv; - /* * Check the environment only once. */ @@ -118,13 +110,13 @@ static const char *_NXGetFontPath(const char *path) return _NXFontPath; } - fontEnv = getenv("NX_FONT"); + const char *fontEnv = getenv("NX_FONT"); if (fontEnv != NULL && *fontEnv != '\0') { if (strlen(fontEnv) + 1 > NXFONTPATHLENGTH) { -#ifdef NX_TRANS_TEST +#ifdef TEST fprintf(stderr, "_NXGetFontPath: WARNING! Maximum length of font path exceeded.\n"); #endif goto _NXGetFontPathError; @@ -132,7 +124,7 @@ static const char *_NXGetFontPath(const char *path) snprintf(_NXFontPath, NXFONTPATHLENGTH, "%s", fontEnv); -#ifdef NX_TRANS_TEST +#ifdef TEST fprintf(stderr, "_NXGetFontPath: Using NX font path [%s].\n", _NXFontPath); #endif @@ -143,7 +135,7 @@ _NXGetFontPathError: snprintf(_NXFontPath, NXFONTPATHLENGTH, "%s", path); -#ifdef NX_TRANS_TEST +#ifdef TEST fprintf(stderr, "_NXGetFontPath: Using default font path [%s].\n", _NXFontPath); #endif @@ -1003,9 +995,9 @@ SetDefaultFontPath(char *path) size = 0, bad; -#ifdef NX_TRANS_SOCKET +#ifdef NXAGENT_SERVER path = (char *) _NXGetFontPath(path); -#endif /* NX_TRANS_SOCKET */ +#endif /* NXAGENT_SERVER */ start = path; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c index 78d74a0d5..031e62431 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c @@ -147,6 +147,16 @@ extern Display *nxagentDisplay; extern WindowPtr nxagentLastEnteredWindow; +#ifdef VIEWPORT_FRAME +extern void nxagentInitViewportFrame(ScreenPtr, WindowPtr); +#endif +extern int nxagentShadowInit(ScreenPtr, WindowPtr); + +#ifdef NXAGENT_CLIPBOARD +extern int nxagentSendNotify(xEvent*); +#endif + + void ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, TimeStamp time, Bool autoGrab) @@ -466,11 +476,6 @@ void DefineInitialRootWindow(register WindowPtr win) { register ScreenPtr pScreen = win->drawable.pScreen; - #ifdef VIEWPORT_FRAME - extern void nxagentInitViewportFrame(ScreenPtr, WindowPtr); - #endif - extern int nxagentShadowInit(ScreenPtr, WindowPtr); - sprite.hotPhys.pScreen = pScreen; sprite.hotPhys.x = pScreen->width / 2; sprite.hotPhys.y = pScreen->height / 2; @@ -537,7 +542,6 @@ ProcSendEvent(ClientPtr client) if (stuff -> event.u.u.type == SelectionNotify) { - extern int nxagentSendNotify(xEvent*); if (nxagentSendNotify(&stuff->event) == 1) return Success; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c index 9ec6be8ef..0b832cc7d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c @@ -95,13 +95,6 @@ ProcQueryExtension(ClientPtr client) { i = FindExtension((char *)&stuff[1], stuff->nbytes); if (i < 0 - - /* - * Hide RENDER if our implementation - * is faulty. - */ - - || (nxagentRenderTrap && strcmp(extensions[i]->name, "RENDER") == 0) #ifdef XCSECURITY /* don't show insecure extensions to untrusted clients */ || (client->trustLevel == XSecurityClientUntrusted && @@ -149,14 +142,6 @@ ProcListExtensions(ClientPtr client) !extensions[i]->secure) continue; #endif - /* - * Hide RENDER if our implementation - * is faulty. - */ - - if (nxagentRenderTrap && strcmp(extensions[i]->name, "RENDER") == 0) - continue; - total_length += strlen(extensions[i]->name) + 1; reply.nExtensions += 1 + extensions[i]->num_aliases; for (j = extensions[i]->num_aliases; --j >= 0;) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 491af5b30..7ccc04bc8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -81,6 +81,8 @@ void *nxagentMatchingFormats(PictFormatPtr pForm); void nxagentPictureCreateDefaultFormats(ScreenPtr pScreen, FormatInitRec *formats, int *nformats); +extern int nxagentPicturePrivateIndex; + PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) { @@ -303,8 +305,6 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error) static PicturePtr createSourcePicture(void) { - extern int nxagentPicturePrivateIndex; - /* * Compute size of entire PictureRect, plus privates. */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c b/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c index 9d8a46c4f..9799d80d5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c @@ -93,6 +93,14 @@ nxagentWMStateRec; #undef TEST #undef DEBUG +#ifdef NXAGENT_CLIPBOARD +extern WindowPtr nxagentGetClipboardWindow(Atom, WindowPtr); +#endif + +#ifdef NXAGENT_ARTSD +extern Atom mcop_local_atom; +#endif + int ProcChangeProperty(ClientPtr client) { @@ -127,11 +135,7 @@ ProcChangeProperty(ClientPtr client) REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize); #ifdef NXAGENT_CLIPBOARD - { - extern WindowPtr nxagentGetClipboardWindow(Atom, WindowPtr); - - pWin = nxagentGetClipboardWindow(stuff->property, NULL); - } + pWin = nxagentGetClipboardWindow(stuff->property, NULL); if (pWin == NULL) #endif @@ -168,7 +172,6 @@ ProcChangeProperty(ClientPtr client) they are already set reflecting the server side settings. Just return success. */ - extern Atom mcop_local_atom; if (stuff->property == mcop_local_atom) return client->noClientException; } @@ -549,14 +552,17 @@ ProcGetProperty(ClientPtr client) #ifdef NXAGENT_CLIPBOARD /* GetWindowProperty clipboard use only */ +/* FIXME: that's wrong, it is also called in Window.c and Events. */ +/* FIXME: should be moved to a different file, is not derived from + dix */ int GetWindowProperty(pWin, property, longOffset, longLength, delete, type, actualType, format, nItems, bytesAfter, propData ) WindowPtr pWin; Atom property; - long longOffset; - long longLength; - Bool delete; + long longOffset; + long longLength; + Bool delete; Atom type; Atom *actualType; int *format; @@ -569,24 +575,24 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, if (!pWin) { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "%s: invalid window\n", __func__); -#endif + #endif return BadWindow; } if (!ValidAtom(property)) { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "%s: invalid atom [%d]\n", __func__, property); -#endif + #endif return(BadAtom); } if ((type != AnyPropertyType) && !ValidAtom(type)) { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "%s: invalid type [%d]\n", __func__, type); -#endif + #endif return(BadAtom); } @@ -604,14 +610,14 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, if (!pProp) { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "%s: property not found [%d]\n", __func__, property); -#endif + #endif return (BadAtom); } /* If the request type and actual type don't match. Return the - property information, but not the data. */ + property information, but not the data. */ if (((type != pProp->type) && (type != AnyPropertyType)) @@ -624,20 +630,20 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, return(Success); } -/* - * Return type, format, value to client - */ + /* + * Return type, format, value to client + */ n = (pProp->format/8) * pProp->size; /* size (bytes) of prop */ ind = longOffset << 2; - /* If longOffset is invalid such that it causes "len" to - be negative, it's a value error. */ + /* If longOffset is invalid such that it causes "len" to + be negative, it's a value error. */ if (n < ind) { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "%s: negative property len\n", __func__); -#endif + #endif return BadValue; } @@ -650,9 +656,7 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, if (delete && (*bytesAfter == 0)) { /* send the event */ - xEvent event; - - memset(&event, 0, sizeof(xEvent)); + xEvent event = {0}; event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyDelete; @@ -663,7 +667,7 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, if (len) { - *propData = (unsigned char *)(pProp->data) + ind; + *propData = (unsigned char *)(pProp->data) + ind; } if (delete && (*bytesAfter == 0)) @@ -681,3 +685,50 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, return(Success); } #endif + +int +ProcDeleteProperty(register ClientPtr client) +{ + WindowPtr pWin; + REQUEST(xDeletePropertyReq); + int result; + + REQUEST_SIZE_MATCH(xDeletePropertyReq); + UpdateCurrentTime(); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + DixWriteAccess); + if (!pWin) + return(BadWindow); + if (!ValidAtom(stuff->property)) + { + client->errorValue = stuff->property; + return (BadAtom); + } + +#ifdef XCSECURITY + switch(SecurityCheckPropertyAccess(client, pWin, stuff->property, + DixDestroyAccess)) + { + case SecurityErrorOperation: + client->errorValue = stuff->property; + return BadAtom;; + case SecurityIgnoreOperation: + return Success; + } +#endif + +#ifdef NXAGENT_SERVER + /* prevent clients from deleting the NX_AGENT_VERSION property */ + { + Atom prop = MakeAtom("NX_AGENT_VERSION", strlen("NX_AGENT_VERSION"), True); + if (stuff->property == prop) + return client->noClientException; + } +#endif + + result = DeleteProperty(pWin, stuff->property); + if (client->noClientException != Success) + return(client->noClientException); + else + return(result); +} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index 190f746a4..105d7048b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -90,7 +90,7 @@ void miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box); extern int nxagentCursorSaveRenderInfo(ScreenPtr, CursorPtr); extern void nxagentCursorPostSaveRenderInfo(CursorPtr, ScreenPtr, PicturePtr, int, int); -extern int nxagentRenderRealizeCursor(ScreenPtr, CursorPtr); +extern void nxagentRenderRealizeCursor(ScreenPtr, CursorPtr); extern int nxagentCreatePicture(PicturePtr, Mask); extern void nxagentChangePicture(PicturePtr, Mask); extern int nxagentChangePictureClip(PicturePtr, int, int, xRectangle *, int, int); @@ -124,6 +124,8 @@ extern void nxagentRenderCreateConicalGradient(PicturePtr pPicture, xFixed *stops, xRenderColor *colors); +extern int nxagentAlphaEnabled; + /* * The void pointer is actually a XGlyphElt8. */ @@ -184,7 +186,6 @@ ProcRenderQueryPictFormats (ClientPtr client) int numScreens; int numSubpixel; - extern int nxagentAlphaEnabled; /* REQUEST(xRenderQueryPictFormatsReq); */ REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq); @@ -715,6 +716,9 @@ ProcRenderTrapezoids (ClientPtr client) { if (pFormat != NULL) { + if (nxagentTrapezoidExtents && nxagentTrapezoidExtents != NullBox) + free(nxagentTrapezoidExtents); + nxagentTrapezoidExtents = (BoxPtr) malloc(sizeof(BoxRec)); miTrapezoidBounds (ntraps, (xTrapezoid *) &stuff[1], nxagentTrapezoidExtents); @@ -1665,16 +1669,6 @@ ProcRenderDispatch (ClientPtr client) REQUEST(xReq); - /* - * Let the client fail if we are - * hiding the RENDER extension. - */ - - if (nxagentRenderTrap) - { - return BadRequest; - } - if (stuff->data < RenderNumberRequests) { #ifdef TEST @@ -1707,16 +1701,6 @@ SProcRenderDispatch (ClientPtr client) REQUEST(xReq); - /* - * Let the client fail if we are - * hiding the RENDER extension. - */ - - if (nxagentRenderTrap) - { - return BadRequest; - } - if (stuff->data < RenderNumberRequests) { /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c index 9a314391c..e1b55f561 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c @@ -81,6 +81,8 @@ extern void fbPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, char *pImage); +extern int nxagentImageLength(int, int, int, int, int); + void ShmExtensionInit(void) { @@ -228,7 +230,6 @@ fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) #ifdef NXAGENT_SERVER int length; char *newdata; - extern int nxagentImageLength(int, int, int, int, int); #ifdef TEST fprintf(stderr, "fbShmPutImage: Called with drawable at [%p] GC at [%p] data at [%p].\n", diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 3dcb552e5..88e68e463 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -106,7 +106,6 @@ Equipment Corporation. #include "Screen.h" #include "Options.h" -#include "Atoms.h" #include "Clipboard.h" #include "Splash.h" #include "Rootless.h" @@ -204,8 +203,6 @@ InitRootWindow(WindowPtr pWin) fprintf(stderr, "InitRootWindow: Mapping default windows.\n"); #endif - nxagentInitAtoms(pWin); - nxagentInitClipboard(pWin); nxagentMapDefaultWindows(); @@ -215,9 +212,7 @@ InitRootWindow(WindowPtr pWin) #ifdef NXAGENT_ARTSD { char artsd_port[10]; - short int nPort; - extern void nxagentPropagateArtsdProperties(ScreenPtr pScreen, char *port); - nPort = atoi(display) + 7000; + short int nPort = atoi(display) + 7000; sprintf(artsd_port,"%d", nPort); nxagentPropagateArtsdProperties(pScreen, artsd_port); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.c b/nx-X11/programs/Xserver/hw/nxagent/Options.c index 10e006a23..5c3a44c23 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.c @@ -133,7 +133,6 @@ void nxagentInitOptions(void) nxagentOptions.Xdmcp = 0; - nxagentOptions.DisplayLatency = 0; nxagentOptions.DisplayBuffer = UNDEFINED; nxagentOptions.DisplayCoalescence = 0; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.h b/nx-X11/programs/Xserver/hw/nxagent/Options.h index 88bb60e8f..02e1890b3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.h @@ -295,16 +295,6 @@ typedef struct _AgentOptions int Xdmcp; /* - * Latency of the link. It is simply set - * to a reference value, calculated based - * on the time required to complete the - * query of the agent's atoms at session - * startup. - */ - - int DisplayLatency; - - /* * Size of the Xlib display buffer. The * default is set according to the link * type. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixels.c b/nx-X11/programs/Xserver/hw/nxagent/Pixels.c index e59ef97ab..93038eab6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixels.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixels.c @@ -63,10 +63,6 @@ int nxagentUniquePixels(XImage *image) int elements = PIXEL_ELEMENTS; int unique = 0; - int total; - int ratio; - int step; - int last = -1; const char *next = image -> data; @@ -80,9 +76,9 @@ int nxagentUniquePixels(XImage *image) * Take at most 256 pixels from the image. */ - total = image -> width * image -> height; + int total = image -> width * image -> height; - step = total / elements; + int step = total / elements; if (step < PIXEL_STEP) { @@ -231,7 +227,7 @@ int nxagentUniquePixels(XImage *image) #endif } - ratio = unique * 100 / elements; + int ratio = unique * 100 / elements; #ifdef TEST fprintf(stderr, "nxagentUniquePixels: Found [%d] unique pixels out of [%d] with ratio [%d%%].\n", @@ -267,13 +263,11 @@ unsigned int Get16(const char *buffer, int order) unsigned int Get24(const char *buffer, int order) { - int i; - const char *next = (order == MSBFirst ? buffer : buffer + 2); unsigned int result = 0; - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { result <<= 8; @@ -294,13 +288,11 @@ unsigned int Get24(const char *buffer, int order) unsigned int Get32(const char *buffer, int order) { - int i; - const char *next = (order == MSBFirst ? buffer : buffer + 3); unsigned int result = 0; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { result <<= 8; @@ -341,13 +333,11 @@ void Put16(unsigned int value, char *buffer, int order) void Put24(unsigned int value, char *buffer, int order) { - int i; - if (order == MSBFirst) { buffer += 2; - for (i = 3; i > 0; i--) + for (int i = 3; i > 0; i--) { *buffer-- = (unsigned char) (value & 0xff); @@ -356,7 +346,7 @@ void Put24(unsigned int value, char *buffer, int order) } else { - for (i = 3; i > 0; i--) + for (int i = 3; i > 0; i--) { *buffer++ = (unsigned char) (value & 0xff); @@ -367,13 +357,11 @@ void Put24(unsigned int value, char *buffer, int order) void Put32(unsigned int value, char *buffer, int order) { - int i; - if (order == MSBFirst) { buffer += 3; - for (i = 4; i > 0; i--) + for (int i = 4; i > 0; i--) { *buffer-- = (unsigned char) (value & 0xff); @@ -382,7 +370,7 @@ void Put32(unsigned int value, char *buffer, int order) } else { - for (i = 4; i > 0; i--) + for (int i = 4; i > 0; i--) { *buffer++ = (unsigned char) (value & 0xff); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 58fea6c05..7a0fcd535 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -322,41 +322,6 @@ PixmapPtr nxagentCreatePixmap(ScreenPtr pScreen, int width, int height, pVirtualPriv -> pVirtualPixmap = NULL; pVirtualPriv -> pPicture = NULL; - /* - * Check that the virtual pixmap is created with - * the appropriate bits-per-plane, otherwise free - * everything and return. - */ - - if (pVirtual -> drawable.bitsPerPixel == 0) - { - #ifdef WARNING - - fprintf(stderr, "nxagentCreatePixmap: WARNING! Virtual pixmap at [%p] has invalid " - "bits per pixel.\n", (void *) pVirtual); - - fprintf(stderr, "nxagentCreatePixmap: WARNING! Real pixmap created with width [%d] " - "height [%d] depth [%d] bits per pixel [%d] and allocation hint [%d].\n", - pPixmap -> drawable.width, - pPixmap -> drawable.height = height, pPixmap -> drawable.depth, - pPixmap -> drawable.bitsPerPixel, - usage_hint); - #endif - - if (!nxagentRenderTrap) - { - #ifdef WARNING - fprintf(stderr, "Warning: Disabling render extension due to missing pixmap format.\n"); - #endif - - nxagentRenderTrap = 1; - } - - nxagentDestroyPixmap(pPixmap); - - return NullPixmap; - } - #ifdef TEST fprintf(stderr, "nxagentCreatePixmap: Created pixmap at [%p] virtual at [%p] with width [%d] " "height [%d] depth [%d] and allocation hint [%d].\n", diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index ebc1fe287..6113a419a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -114,12 +114,8 @@ XRenderPictFormat *nxagentMatchingFormats(PictFormatPtr pForm); BoxPtr nxagentGlyphsExtents; BoxPtr nxagentTrapezoidExtents; -#ifdef DEBUG - static void nxagentPrintFormat(XRenderPictFormat *pFormat); -#endif - /* * From NXglyph.c. */ @@ -150,10 +146,6 @@ int nxagentCreatePicture(PicturePtr pPicture, Mask mask); int nxagentChangePictureClip(PicturePtr pPicture, int clipType, int nRects, xRectangle *rects, int xOrigin, int yOrigin); -void nxagentDestroyPictureClip(PicturePtr pPicture); - -void nxagentValidatePicture(PicturePtr pPicture, Mask mask); - void nxagentComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); @@ -169,23 +161,8 @@ void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps); -void nxagentRasterizeTrapezoid(PicturePtr pMask, xTrapezoid *trap, - int x_off, int y_off); - -void nxagentTriangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int ntri, xTriangle *tris); - -void nxagentTriStrip(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int npoint, xPointFixed *points); - void nxagentChangePicture(PicturePtr pPicture, Mask mask); -void nxagentTriFan(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int npoint, xPointFixed *points); - void nxagentReferenceGlyphSet(GlyphSetPtr glyphSet); void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph); @@ -222,8 +199,6 @@ nxagentCleanGlyphs(xGlyphInfo *gi, int bitsToClean; int widthInBytes; int height = gi -> height; - register int i; - int j; #ifdef DEBUG fprintf(stderr, "nxagentCleanGlyphs: Found a Glyph with Depth %d, width %d, pad %d.\n", @@ -248,14 +223,14 @@ nxagentCleanGlyphs(xGlyphInfo *gi, if (ImageByteOrder(dpy) == LSBFirst) { - for (i = 3; i < bytesToClean; i += 4) + for (int i = 3; i < bytesToClean; i += 4) { images[i] = 0x00; } } else { - for (i = 0; i < bytesToClean; i += 4) + for (int i = 0; i < bytesToClean; i += 4) { images[i] = 0x00; } @@ -263,7 +238,7 @@ nxagentCleanGlyphs(xGlyphInfo *gi, #ifdef DUMP fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean); - for (i = 0; i < bytesPerLine; i++) + for (int i = 0; i < bytesPerLine; i++) { fprintf(stderr, "[%d]", images[i]); } @@ -299,8 +274,9 @@ nxagentCleanGlyphs(xGlyphInfo *gi, ImageByteOrder(dpy), BitmapBitOrder(dpy)); #endif - for (i = 1; i <= height; i++) + for (int i = 1; i <= height; i++) { + int j; if (ImageByteOrder(dpy) == BitmapBitOrder(dpy)) { for (j = 1; j <= bytesToClean; j++) @@ -350,7 +326,7 @@ nxagentCleanGlyphs(xGlyphInfo *gi, #ifdef DUMP fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean); - for (i = 0; i < bytesPerLine; i++) + for (int i = 0; i < bytesPerLine; i++) { fprintf(stderr, "[%d]", images[i]); } @@ -386,22 +362,22 @@ nxagentCleanGlyphs(xGlyphInfo *gi, { while (height > 0) { - i = bytesToClean; + int count = bytesToClean; - while (i > 0) + while (count > 0) { - *(images + (bytesPerLine - i)) = 0; + *(images + (bytesPerLine - count)) = 0; #ifdef DEBUG fprintf(stderr, "nxagentCleanGlyphs: cleaned a byte.\n"); #endif - i--; + count--; } #ifdef DUMP fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean); - for (i = 0; i < bytesPerLine; i++) + for (int i = 0; i < bytesPerLine; i++) { fprintf(stderr, "[%d]", images[i]); } @@ -458,12 +434,11 @@ void nxagentRenderExtensionInit(void) XRenderQueryVersion(nxagentDisplay, &major_version, &minor_version); /* - * As the RENDER requests are passed directly to - * the remote X server this can cause problems if - * our RENDER version is different from the version - * supported by the remote. For this reasos let's - * advertise to our clients the lowest between the - + two versions. + * As the RENDER requests are passed directly to the remote X + * server this can cause problems if our RENDER version is + * different from the version supported by the remote. For this + * reasons let's advertise to our clients the lowest between the + * two versions. */ if (major_version > SERVER_RENDER_MAJOR_VERSION || @@ -539,57 +514,41 @@ void nxagentCursorPostSaveRenderInfo(CursorPtr pCursor, ScreenPtr pScreen, nxagentCursorYOffset(pCursor, pScreen) = y; } -int nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) +void nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { - int cid; - int x, y; - - PicturePtr pPicture; - - pPicture = nxagentCursorPicture(pCursor, pScreen); + PicturePtr pPicture = nxagentCursorPicture(pCursor, pScreen); pPicture -> refcnt++; - x = nxagentCursorXOffset(pCursor, pScreen); - y = nxagentCursorYOffset(pCursor, pScreen); - - /* - * Set the lossless trap so that the image functions - * will not try to encode the image using a lossy - * compression. Drawables should have a quality flag, - * telling if they were originally encoded with a - * lossy algorithm. This would allow us to skip the - * synchronization if the cursor was already encoded - * with the best quality. - */ + int x = nxagentCursorXOffset(pCursor, pScreen); + int y = nxagentCursorYOffset(pCursor, pScreen); #ifdef TEST - fprintf(stderr, "nxagentRenderRealizeCursor: Forcing the synchronization " - "of the cursor.\n"); + fprintf(stderr, "%s: Forcing the synchronization of the cursor.\n", __func__); #endif nxagentMarkCorruptedRegion(pPicture -> pDrawable, NULL); + /* + * Set the lossless trap so that the image functions will not try to + * encode the image using a lossy compression. Drawables should have + * a quality flag, telling if they were originally encoded with a + * lossy algorithm. This would allow us to skip the synchronization + * if the cursor was already encoded with the best quality. + */ + nxagentLosslessTrap = 1; nxagentSynchronizeDrawable(pPicture -> pDrawable, DO_WAIT, NEVER_BREAK, NULL); nxagentLosslessTrap = 0; - - cid = XRenderCreateCursor(nxagentDisplay, nxagentPicture(pPicture), x, y); - - nxagentCursor(pCursor, pScreen) = cid; - - return 1; + nxagentCursor(pCursor, pScreen) = XRenderCreateCursor(nxagentDisplay, nxagentPicture(pPicture), x, y); } int nxagentCreatePicture(PicturePtr pPicture, Mask mask) { XRenderPictureAttributes attributes; unsigned long valuemask=0; - XRenderPictFormat *pForm; - - Picture id; #ifdef DEBUG fprintf(stderr, "nxagentCreatePicture: Function called with picture at [%p] and mask [%ld].\n", @@ -630,145 +589,113 @@ int nxagentCreatePicture(PicturePtr pPicture, Mask mask) if (mask & CPRepeat) { attributes.repeat = (Bool)pPicture -> repeat; - valuemask |= CPRepeat; - nxagentSetPictureRemoteValue(pPicture, repeat, attributes.repeat); } if (mask & CPAlphaMap) { attributes.alpha_map = nxagentPicturePriv(pPicture -> alphaMap) -> picture; - valuemask |= CPAlphaMap; - nxagentSetPictureRemoteValue(pPicture, alpha_map, attributes.alpha_map); } if (mask & CPAlphaXOrigin) { attributes.alpha_x_origin = pPicture -> alphaOrigin.x; - valuemask |= CPAlphaXOrigin; - nxagentSetPictureRemoteValue(pPicture, alpha_x_origin, attributes.alpha_x_origin); } if (mask & CPAlphaYOrigin) { attributes.alpha_y_origin = pPicture -> alphaOrigin.y; - valuemask |= CPAlphaYOrigin; - nxagentSetPictureRemoteValue(pPicture, alpha_y_origin, attributes.alpha_y_origin); } if (mask & CPClipXOrigin) { attributes.clip_x_origin = pPicture -> clipOrigin.x; - valuemask |= CPClipXOrigin; - nxagentSetPictureRemoteValue(pPicture, clip_x_origin, attributes.clip_x_origin); } if (mask & CPClipYOrigin) { attributes.clip_y_origin = pPicture -> clipOrigin.y; - valuemask |= CPClipYOrigin; - nxagentSetPictureRemoteValue(pPicture, clip_y_origin, attributes.clip_y_origin); } if (mask & CPGraphicsExposure) { attributes.graphics_exposures = (Bool)pPicture -> graphicsExposures; - valuemask |= CPGraphicsExposure; - nxagentSetPictureRemoteValue(pPicture, graphics_exposures, attributes.graphics_exposures); } if (mask & CPSubwindowMode) { attributes.subwindow_mode = pPicture -> subWindowMode; - valuemask |= CPSubwindowMode; - nxagentSetPictureRemoteValue(pPicture, subwindow_mode, attributes.subwindow_mode); } if (mask & CPClipMask) { attributes.clip_mask = None; - valuemask |= CPClipMask; - nxagentSetPictureRemoteValue(pPicture, clip_mask, attributes.clip_mask); } if (mask & CPPolyEdge) { attributes.poly_edge = pPicture -> polyEdge; - valuemask |= CPPolyEdge; - nxagentSetPictureRemoteValue(pPicture, poly_edge, attributes.poly_edge); } if (mask & CPPolyMode) { attributes.poly_mode = pPicture -> polyMode; - valuemask |= CPPolyMode; - nxagentSetPictureRemoteValue(pPicture, poly_mode, attributes.poly_mode); } if (mask & CPDither) { attributes.dither = pPicture -> dither; - valuemask |= CPDither; - nxagentSetPictureRemoteValue(pPicture, dither, attributes.dither); } if (mask & CPComponentAlpha) { attributes.component_alpha = pPicture -> componentAlpha; - valuemask |= CPComponentAlpha; - nxagentSetPictureRemoteValue(pPicture, component_alpha, attributes.component_alpha); } - pForm = NULL; + XRenderPictFormat *pForm = NULL; if (pPicture -> pFormat != NULL) { pForm = nxagentMatchingFormats(pPicture -> pFormat); - - #ifdef DEBUG - nxagentPrintFormat(pForm); - - #endif } if (pForm == NULL) { fprintf(stderr, "nxagentCreatePicture: WARNING! The requested format was not found.\n"); - return 0; } - id = XRenderCreatePicture(nxagentDisplay, - nxagentDrawable(pPicture -> pDrawable), - pForm, - valuemask, - &attributes); + Picture id = XRenderCreatePicture(nxagentDisplay, + nxagentDrawable(pPicture -> pDrawable), + pForm, + valuemask, + &attributes); #ifdef TEST fprintf(stderr, "nxagentCreatePicture: Created picture at [%p] with drawable at [%p].\n", @@ -776,9 +703,7 @@ int nxagentCreatePicture(PicturePtr pPicture, Mask mask) #endif #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif nxagentPicturePriv(pPicture) -> picture = id; @@ -801,9 +726,7 @@ int nxagentCreatePicture(PicturePtr pPicture, Mask mask) XRenderPictFormat *nxagentMatchingFormats(PictFormatPtr pFormat) { - int i; - - for (i = 0; i < nxagentNumFormats; i++) + for (int i = 0; i < nxagentNumFormats; i++) { if (pFormat -> type == nxagentArrayFormats[i].type && pFormat -> depth == nxagentArrayFormats[i].depth && @@ -843,9 +766,7 @@ void nxagentDestroyPicture(PicturePtr pPicture) nxagentPicturePriv(pPicture) -> picture); #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif } @@ -887,7 +808,6 @@ FIXME: Is this useful or just a waste of bandwidth? Apparently useless with QT. */ #ifndef SKIP_LOUSY_RENDER_OPERATIONS - XRenderSetPictureClipRectangles(nxagentDisplay, nxagentPicturePriv(pPicture) -> picture, xOrigin, @@ -898,13 +818,10 @@ FIXME: Is this useful or just a waste of bandwidth? nxagentSetPictureRemoteValue(pPicture, clip_x_origin, xOrigin); nxagentSetPictureRemoteValue(pPicture, clip_y_origin, yOrigin); nxagentSetPictureRemoteValue(pPicture, clip_mask, 1); - #endif #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif break; @@ -920,7 +837,6 @@ FIXME: Is this useful or just a waste of bandwidth? Apparently useless with QT. */ #ifndef SKIP_LOUSY_RENDER_OPERATIONS - XRenderSetPictureClipRectangles(nxagentDisplay, nxagentPicturePriv(pPicture) -> picture, xOrigin, @@ -931,13 +847,10 @@ FIXME: Is this useful or just a waste of bandwidth? nxagentSetPictureRemoteValue(pPicture, clip_x_origin, xOrigin); nxagentSetPictureRemoteValue(pPicture, clip_y_origin, yOrigin); nxagentSetPictureRemoteValue(pPicture, clip_mask, 1); - #endif #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif break; @@ -969,7 +882,6 @@ FIXME: Is this useful or just a waste of bandwidth? Apparently useless with QT. */ #ifndef SKIP_LOUSY_RENDER_OPERATIONS - XRenderSetPictureClipRegion(nxagentDisplay, nxagentPicturePriv(pPicture) -> picture, reg); @@ -977,13 +889,10 @@ FIXME: Is this useful or just a waste of bandwidth? nxagentSetPictureRemoteValue(pPicture, clip_x_origin, xOrigin); nxagentSetPictureRemoteValue(pPicture, clip_y_origin, yOrigin); nxagentSetPictureRemoteValue(pPicture, clip_mask, 1); - #endif #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif XDestroyRegion(reg); @@ -1003,13 +912,6 @@ FIXME: Is this useful or just a waste of bandwidth? return 1; } -void nxagentDestroyPictureClip(PicturePtr pPicture) -{ - #ifdef DEBUG - fprintf(stderr, "nxagentDestroyPictureClip: Nothing to do.\n"); - #endif -} - void nxagentChangePicture(PicturePtr pPicture, Mask mask) { XRenderPictureAttributes attributes; @@ -1028,11 +930,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPRepeat) { attributes.repeat = (Bool)pPicture -> repeat; - if (nxagentCheckPictureRemoteValue(pPicture, repeat, attributes.repeat) == 0) { valuemask |= CPRepeat; - nxagentSetPictureRemoteValue(pPicture, repeat, attributes.repeat); } } @@ -1040,11 +940,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPAlphaMap) { attributes.alpha_map = nxagentPicturePriv(pPicture -> alphaMap) -> picture; - if (nxagentCheckPictureRemoteValue(pPicture, alpha_map, attributes.alpha_map) == 0) { valuemask |= CPAlphaMap; - nxagentSetPictureRemoteValue(pPicture, alpha_map, attributes.alpha_map); } } @@ -1052,11 +950,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPAlphaXOrigin) { attributes.alpha_x_origin = pPicture -> alphaOrigin.x; - if (nxagentCheckPictureRemoteValue(pPicture, alpha_x_origin, attributes.alpha_x_origin) == 0) { valuemask |= CPAlphaXOrigin; - nxagentSetPictureRemoteValue(pPicture, alpha_x_origin, attributes.alpha_x_origin); } } @@ -1064,11 +960,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPAlphaYOrigin) { attributes.alpha_y_origin = pPicture -> alphaOrigin.y; - if (nxagentCheckPictureRemoteValue(pPicture, alpha_y_origin, attributes.alpha_y_origin) == 0) { valuemask |= CPAlphaYOrigin; - nxagentSetPictureRemoteValue(pPicture, alpha_y_origin, attributes.alpha_y_origin); } } @@ -1076,11 +970,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPClipXOrigin) { attributes.clip_x_origin = pPicture -> clipOrigin.x; - if (nxagentCheckPictureRemoteValue(pPicture, clip_x_origin, attributes.clip_x_origin) == 0) { valuemask |= CPClipXOrigin; - nxagentSetPictureRemoteValue(pPicture, clip_x_origin, attributes.clip_x_origin); } } @@ -1088,11 +980,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPClipYOrigin) { attributes.clip_y_origin = pPicture -> clipOrigin.y; - if (nxagentCheckPictureRemoteValue(pPicture, clip_y_origin, attributes.clip_y_origin) == 0) { valuemask |= CPClipYOrigin; - nxagentSetPictureRemoteValue(pPicture, clip_y_origin, attributes.clip_y_origin); } } @@ -1100,11 +990,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPGraphicsExposure) { attributes.graphics_exposures = (Bool)pPicture -> graphicsExposures; - if (nxagentCheckPictureRemoteValue(pPicture, graphics_exposures, attributes.graphics_exposures) == 0) { valuemask |= CPGraphicsExposure; - nxagentSetPictureRemoteValue(pPicture, graphics_exposures, attributes.graphics_exposures); } } @@ -1112,31 +1000,25 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPSubwindowMode) { attributes.subwindow_mode = pPicture -> subWindowMode; - if (nxagentCheckPictureRemoteValue(pPicture, subwindow_mode, attributes.subwindow_mode) == 0) { valuemask |= CPSubwindowMode; - nxagentSetPictureRemoteValue(pPicture, subwindow_mode, attributes.subwindow_mode); } } if (mask & CPClipMask) { - attributes.clip_mask = None; - /* - * The nxagent doesn't know the remote id of - * the picture's clip mask, so the clip_mask - * value is used as a boolean: it is set to 0 - * when the clip_mask is None, otherwise it is - * 1. + * The nxagent doesn't know the remote id of the picture's clip + * mask, so the clip_mask value is used as a boolean: it is set to + * 0 when the clip_mask is None, otherwise it is 1. */ + attributes.clip_mask = None; if (nxagentPicturePriv(pPicture) -> lastServerValues.clip_mask != 0) { valuemask |= CPClipMask; - nxagentSetPictureRemoteValue(pPicture, clip_mask, 0); } } @@ -1144,11 +1026,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPPolyEdge) { attributes.poly_edge = pPicture -> polyEdge; - if (nxagentCheckPictureRemoteValue(pPicture, poly_edge, attributes.poly_edge) == 0) { valuemask |= CPPolyEdge; - nxagentSetPictureRemoteValue(pPicture, poly_edge, attributes.poly_edge); } } @@ -1156,11 +1036,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPPolyMode) { attributes.poly_mode = pPicture -> polyMode; - if (nxagentCheckPictureRemoteValue(pPicture, poly_mode, attributes.poly_mode) == 0) { valuemask |= CPPolyMode; - nxagentSetPictureRemoteValue(pPicture, poly_mode, attributes.poly_mode); } } @@ -1168,11 +1046,9 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPDither) { attributes.dither = pPicture -> dither; - if (nxagentCheckPictureRemoteValue(pPicture, dither, attributes.dither) == 0) { valuemask |= CPDither; - nxagentSetPictureRemoteValue(pPicture, dither, attributes.dither); } } @@ -1180,17 +1056,14 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) if (mask & CPComponentAlpha) { attributes.component_alpha = pPicture -> componentAlpha; - if (nxagentCheckPictureRemoteValue(pPicture, component_alpha, attributes.component_alpha) == 0) { valuemask |= CPComponentAlpha; - nxagentSetPictureRemoteValue(pPicture, component_alpha, attributes.component_alpha); } } #ifdef TEST - if (pPicture && pPicture->pDrawable && pPicture -> pDrawable -> type == DRAWABLE_PIXMAP) { fprintf(stderr, "nxagentChangePicture: %sPixmap [%p] Picture [%p][%p].\n", @@ -1198,7 +1071,6 @@ void nxagentChangePicture(PicturePtr pPicture, Mask mask) (void *) pPicture -> pDrawable, (void *) nxagentPicturePriv(pPicture) -> picture, (void *) pPicture); } - #endif /* FIXME: Is this useful or just a waste of bandwidth? @@ -1208,7 +1080,6 @@ FIXME: Is this useful or just a waste of bandwidth? Without this the text is not rendered on GTK/Cairo. */ #ifndef SKIP_REALLY_ALL_LOUSY_RENDER_OPERATIONS - if (valuemask != 0) { XRenderChangePicture(nxagentDisplay, @@ -1223,20 +1094,10 @@ FIXME: Is this useful or just a waste of bandwidth? (void *) pPicture); } #endif - - #endif + #endif /* SKIP_REALLY_ALL_LOUSY_RENDER_OPERATIONS */ #ifdef DEBUG - XSync(nxagentDisplay, 0); - - #endif -} - -void nxagentValidatePicture(PicturePtr pPicture, Mask mask) -{ - #ifdef DEBUG - fprintf(stderr, "nxagentValidatePicture: Nothing to do.\n"); #endif } @@ -1244,15 +1105,12 @@ void nxagentComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pD INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height) { - RegionPtr pDstRegion; - if (pSrc == NULL || pDst == NULL) { return; } #ifdef DEBUG - if (pSrc && pSrc -> pDrawable != NULL) { fprintf(stderr, "nxagentComposite: Source Picture [%lu][%p] with drawable [%s%s][%p].\n", @@ -1281,12 +1139,11 @@ void nxagentComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pD pMask -> pDrawable -> type == DRAWABLE_PIXMAP ? "Pixmap" : "Window", (void *) pMask -> pDrawable); } - #endif if (NXAGENT_SHOULD_DEFER_COMPOSITE(pSrc, pMask, pDst)) { - pDstRegion = nxagentCreateRegion(pDst -> pDrawable, NULL, xDst, yDst, width, height); + RegionPtr pDstRegion = nxagentCreateRegion(pDst -> pDrawable, NULL, xDst, yDst, width, height); #ifdef TEST if ((pDstRegion) && (pDst && pDst->pDrawable)) { @@ -1306,11 +1163,10 @@ void nxagentComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pD } /* - * Synchronize the content of the shared memory pixmap - * but pay attention at not doing this more than once. - * We need to wait until the image data has been recom- - * posed at the X server side or the operation will use - * the wrong data. + * Synchronize the content of the shared memory pixmap but pay + * attention at not doing this more than once. We need to wait + * until the image data has been recom- posed at the X server side + * or the operation will use the wrong data. */ if (pSrc -> pDrawable != NULL) @@ -1361,14 +1217,12 @@ void nxagentComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pD } /* - * The glyphs flag have to be propagated between - * drawables, in order to avoid to encode the - * text with lossy algorithms (like JPEG). Unlu- - * ckily we have verified that if the render com- - * posite propagates the flag, the deferring of - * render trapezoids doesn't work well. Moreover, - * by commenting out this code we have not noticed - * any visual problems. + * The glyphs flag have to be propagated between drawables, in order + * to avoid to encode the text with lossy algorithms (like + * JPEG). Unlu- ckily we have verified that if the render com- + * posite propagates the flag, the deferring of render trapezoids + * doesn't work well. Moreover, by commenting out this code we have + * not noticed any visual problems. * * if (nxagentDrawableContainGlyphs(pSrc -> pDrawable) == 1) * { @@ -1391,9 +1245,7 @@ void nxagentComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pD height); #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif } @@ -1401,23 +1253,10 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlists, XGlyphElt8 *elts, int sizeID, GlyphPtr *glyphsBase) { - XRenderPictFormat *pForm; - BoxRec glyphBox; XGlyphElt8 *elements; - #ifdef SPLIT_GLYPH_LISTS - - GlyphPtr glyph; - - int x; - int y; - int i; - int j; - - #endif /* #ifdef SPLIT_GLYPH_LISTS */ - if (pSrc == NULL || pDst == NULL) { return; @@ -1432,18 +1271,13 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, } #endif - pForm = NULL; + XRenderPictFormat *pForm = NULL; if (maskFormat != NULL) { pForm = nxagentMatchingFormats(maskFormat); - - #ifdef DEBUG - nxagentPrintFormat(pForm); - #endif - if (pForm == NULL) { return; @@ -1458,10 +1292,8 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, glyphBox.y2 = nxagentGlyphsExtents -> y2; /* - * By extending the glyph extents the - * visual aspect looks nicer because - * the synchronized region is not glued - * to the fonts. + * By extending the glyph extents the visual aspect looks nicer + * because the synchronized region is not glued to the fonts. */ if (glyphBox.x2 != glyphBox.x1) @@ -1478,16 +1310,14 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, } /* - * If the destination window is hidden, the - * operation can be prevented. + * If the destination window is hidden, the operation can be + * prevented. */ if (pDst -> pDrawable -> type == DRAWABLE_WINDOW) { - RegionPtr pRegion; - - pRegion = nxagentCreateRegion(pDst -> pDrawable, NULL, glyphBox.x1, glyphBox.y1, - glyphBox.x2 - glyphBox.x1, glyphBox.y2 - glyphBox.y1); + RegionPtr pRegion = nxagentCreateRegion(pDst -> pDrawable, NULL, glyphBox.x1, glyphBox.y1, + glyphBox.x2 - glyphBox.x1, glyphBox.y2 - glyphBox.y1); if (RegionNil(pRegion) == 1) { @@ -1505,9 +1335,8 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, } /* - * Need to synchronize the pixmaps involved in - * the operation before rendering the glyphs - * on the real X server. + * Need to synchronize the pixmaps involved in the operation before + * rendering the glyphs on the real X server. */ if (pSrc -> pDrawable != NULL && @@ -1522,11 +1351,9 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, #endif /* - * If the source drawable is going to be - * repeated over the destination drawable - * during the composite operation, we need - * to synchronize the whole drawable to - * avoid graphical problems. + * If the source drawable is going to be repeated over the + * destination drawable during the composite operation, we need to + * synchronize the whole drawable to avoid graphical problems. */ if (pSrc -> repeat == 1 || nxagentGlyphsExtents == NullBox) @@ -1625,14 +1452,13 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, #endif #ifdef SPLIT_GLYPH_LISTS + GlyphPtr glyph; /* - * We split glyphs lists here and recalculate - * the offsets of each list to make them ab- - * solute and not relatives to the prior list. - * This way each time we call XRenderComposi- - * teText it has to deal only with a list of - * glyphs. This is done to further improve + * We split glyphs lists here and recalculate the offsets of each + * list to make them ab- solute and not relatives to the prior list. + * This way each time we call XRenderComposi- teText it has to deal + * only with a list of glyphs. This is done to further improve * caching. */ @@ -1640,7 +1466,10 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, if (nlists > 1) { - for (j = 1; j < nlists; j++) + int x; + int y; + + for (int j = 1; j < nlists; j++) { x = elements -> xOff; y = elements -> yOff; @@ -1650,7 +1479,7 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, j, nlists, elements -> xOff, elements -> yOff); #endif - for (i = 0; i < elements -> nchars; i++) + for (int i = 0; i < elements -> nchars; i++) { glyph = *glyphsBase++; @@ -1682,7 +1511,7 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, { case 1: { - for (j = 0; j < nlists; j++) + for (int j = 0; j < nlists; j++) { XRenderCompositeText8(nxagentDisplay, op, @@ -1698,12 +1527,11 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, elements++; } - break; } case 2: { - for (j = 0; j < nlists; j++) + for (int j = 0; j < nlists; j++) { XRenderCompositeText16(nxagentDisplay, op, @@ -1719,12 +1547,11 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, elements++; } - break; } case 4: { - for (j = 0; j < nlists; j++) + for (int j = 0; j < nlists; j++) { XRenderCompositeText32(nxagentDisplay, op, @@ -1740,7 +1567,6 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, elements++; } - break; } default: @@ -1749,7 +1575,6 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, fprintf(stderr, "nxagentGlyphs: WARNING! Invalid size id [%d].\n", sizeID); #endif - break; } } @@ -1773,7 +1598,6 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, elements -> yOff, (XGlyphElt8*) elements, nlists); - break; } case 2: @@ -1789,7 +1613,6 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, elements -> yOff, (XGlyphElt16*) elements, nlists); - break; } case 4: @@ -1805,7 +1628,6 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, elements -> yOff, (XGlyphElt32*) elements, nlists); - break; } default: @@ -1814,19 +1636,15 @@ void nxagentGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, fprintf(stderr, "nxagentGlyphs: WARNING! Invalid size id [%d].\n", sizeID); #endif - break; } } - #endif /* #ifdef SPLIT_GLYPH_LISTS */ } void nxagentCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect, xRectangle *rects) { - RegionPtr rectRegion; - if (pDst == NULL) { return; @@ -1851,7 +1669,7 @@ void nxagentCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, (op == PictOpSrc || (op == PictOpOver && color -> alpha == 0xffff))) { - rectRegion = RegionFromRects(nRect, rects, CT_REGION); + RegionPtr rectRegion = RegionFromRects(nRect, rects, CT_REGION); if (pDst -> clientClipType != CT_NONE) { @@ -1889,9 +1707,7 @@ void nxagentCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, nRect); #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif } @@ -1899,12 +1715,8 @@ void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps) { - XRenderPictFormat *pForm; - XTrapezoid *current = (XTrapezoid *) traps; - RegionPtr pDstRegion; - int remaining = ntrap; #ifdef TEST @@ -1918,18 +1730,13 @@ void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, return; } - pForm = NULL; + XRenderPictFormat *pForm = NULL; if (maskFormat != NULL) { pForm = nxagentMatchingFormats(maskFormat); - - #ifdef DEBUG - nxagentPrintFormat(pForm); - #endif - if (pForm == NULL) { return; @@ -1943,7 +1750,6 @@ FIXME: Is this useful or just a waste of bandwidth? #ifndef SKIP_LOUSY_RENDER_OPERATIONS #ifdef TEST - if (pSrc->pDrawable) { fprintf(stderr, "nxagentTrapezoids: Source is a [%s] of geometry [%d,%d].\n", (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"), @@ -1955,7 +1761,6 @@ FIXME: Is this useful or just a waste of bandwidth? (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"), pDst -> pDrawable -> width, pDst -> pDrawable -> height); } - #endif /* @@ -1994,11 +1799,11 @@ FIXME: Is this useful or just a waste of bandwidth? if (NXAGENT_SHOULD_DEFER_TRAPEZOIDS(pDst -> pDrawable)) { - pDstRegion = nxagentCreateRegion(pDst -> pDrawable, NULL, - nxagentTrapezoidExtents -> x1, - nxagentTrapezoidExtents -> y1, - nxagentTrapezoidExtents -> x2 - nxagentTrapezoidExtents -> x1, - nxagentTrapezoidExtents -> y2 - nxagentTrapezoidExtents -> y1); + RegionPtr pDstRegion = nxagentCreateRegion(pDst -> pDrawable, NULL, + nxagentTrapezoidExtents -> x1, + nxagentTrapezoidExtents -> y1, + nxagentTrapezoidExtents -> x2 - nxagentTrapezoidExtents -> x1, + nxagentTrapezoidExtents -> y2 - nxagentTrapezoidExtents -> y1); #ifdef TEST if (pDst && pDst->pDrawable) { @@ -2043,298 +1848,46 @@ FIXME: Is this useful or just a waste of bandwidth? nxagentSynchronizeBox(pDst -> pDrawable, nxagentTrapezoidExtents, NEVER_BREAK); } - XRenderCompositeTrapezoids(nxagentDisplay, - op, - nxagentPicturePriv(pSrc) -> picture, - nxagentPicturePriv(pDst) -> picture, - pForm, - xSrc, - ySrc, - (XTrapezoid *) current,remaining); - - - #endif - - #ifdef DEBUG - - XSync(nxagentDisplay, 0); - - #endif -} - -void nxagentRasterizeTrapezoid(PicturePtr pMask, xTrapezoid *trap, - int x_off, int y_off) -{ - #ifdef DEBUG - fprintf(stderr, "nxagentRasterizeTrapezoids: Nothing to do.\n"); - #endif -} - -void nxagentTriangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int ntri, xTriangle *tris) -{ - XRenderPictFormat *pForm; - - #ifdef DEBUG - fprintf(stderr, "nxagentTriangles: Source [%p] Destination [%p] Coordinates [%d,%d] Elements [%d].\n", - (void *) pSrc, (void *) pDst, xSrc, ySrc, ntri); - #endif - - if (pSrc == NULL || pDst == NULL) - { - return; - } - - pForm = NULL; - - if (maskFormat != NULL) - { - pForm = nxagentMatchingFormats(maskFormat); - - #ifdef DEBUG - - nxagentPrintFormat(pForm); - - #endif - - if (pForm == NULL) - { - return; - } - } - - /* - * If the X_RenderCompositeTriangles requests - * increment the traffic, we can defer the - * operation like nxagentTrapezoids() does. - */ - - if (pSrc -> pDrawable != NULL && - nxagentDrawableStatus(pSrc -> pDrawable) == NotSynchronized) - { - #ifdef TEST - fprintf(stderr, "nxagentTriangles: Going to synchronize the source drawable at [%p].\n", - (void *) pSrc -> pDrawable); - #endif - - nxagentSynchronizeDrawable(pSrc -> pDrawable, DO_WAIT, NEVER_BREAK, NULL); - } - - if (nxagentDrawableStatus(pDst -> pDrawable) == NotSynchronized) - { - #ifdef TEST - fprintf(stderr, "nxagentTriangles: Going to synchronize the destination drawable at [%p].\n", - (void *) pDst -> pDrawable); - #endif - - nxagentSynchronizeDrawable(pDst -> pDrawable, DO_WAIT, NEVER_BREAK, NULL); - } - - XRenderCompositeTriangles(nxagentDisplay, - op, - nxagentPicturePriv(pSrc) -> picture, - nxagentPicturePriv(pDst) -> picture, - pForm, - xSrc, - ySrc, - (XTriangle*)tris, - ntri); - - #ifdef DEBUG - - XSync(nxagentDisplay, 0); - - #endif -} - -void nxagentTriStrip(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int npoint, xPointFixed *points) -{ - XRenderPictFormat *pForm; - - #ifdef DEBUG - fprintf(stderr, "nxagentTriStrip: Source [%p] Destination [%p] Coordinates [%d,%d] Elements [%d].\n", - (void *) pSrc, (void *) pDst, xSrc, ySrc, npoint); - #endif - - if (pSrc == NULL || pDst == NULL) - { - return; - } - - pForm = NULL; - - if (maskFormat != NULL) - { - pForm = nxagentMatchingFormats(maskFormat); - - #ifdef DEBUG - - nxagentPrintFormat(pForm); - - #endif - - if (pForm == NULL) - { - return; - } - } - - /* - * If the X_RenderCompositeTriStrip requests - * increment the traffic, we can defer the - * operation like nxagentTrapezoids() does. - */ - - if (pSrc -> pDrawable != NULL && - nxagentDrawableStatus(pSrc -> pDrawable) == NotSynchronized) - { - #ifdef TEST - fprintf(stderr, "nxagentTriStrip: Going to synchronize the source drawable at [%p].\n", - (void *) pSrc -> pDrawable); - #endif - - nxagentSynchronizeDrawable(pSrc -> pDrawable, DO_WAIT, NEVER_BREAK, NULL); - } - - if (nxagentDrawableStatus(pDst -> pDrawable) == NotSynchronized) - { - #ifdef TEST - fprintf(stderr, "nxagentTriStrip: Going to synchronize the destination drawable at [%p].\n", - (void *) pDst -> pDrawable); - #endif - - nxagentSynchronizeDrawable(pDst -> pDrawable, DO_WAIT, NEVER_BREAK, NULL); - } - - XRenderCompositeTriStrip(nxagentDisplay, - op, - nxagentPicturePriv(pSrc) -> picture, - nxagentPicturePriv(pDst) -> picture, - pForm, - xSrc, - ySrc, - (XPointFixed*)points, - npoint); - - #ifdef DEBUG - - XSync(nxagentDisplay, 0); - - #endif -} + XRenderCompositeTrapezoids(nxagentDisplay, + op, + nxagentPicturePriv(pSrc) -> picture, + nxagentPicturePriv(pDst) -> picture, + pForm, + xSrc, + ySrc, + (XTrapezoid *) current,remaining); -void nxagentTriFan(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int npoint, xPointFixed *points) -{ - XRenderPictFormat *pForm; - #ifdef DEBUG - fprintf(stderr, "nxagentTriFan: Source [%p] Destination [%p] Coordinates [%d,%d] Elements [%d].\n", - (void *) pSrc, (void *) pDst, xSrc, ySrc, npoint); #endif - if (pSrc == NULL || pDst == NULL) - { - return; - } - - pForm = NULL; - - if (maskFormat != NULL) - { - pForm = nxagentMatchingFormats(maskFormat); - - #ifdef DEBUG - - nxagentPrintFormat(pForm); - - #endif - - if (pForm == NULL) - { - return; - } - } - - /* - * If the X_RenderCompositeTriFan requests - * increment the traffic, we can defer the - * operation like nxagentTrapezoids() does. - */ - - if (pSrc -> pDrawable != NULL && - nxagentDrawableStatus(pSrc -> pDrawable) == NotSynchronized) - { - #ifdef TEST - fprintf(stderr, "nxagentTriFan: Going to synchronize the source drawable at [%p].\n", - (void *) pSrc -> pDrawable); - #endif - - nxagentSynchronizeDrawable(pSrc -> pDrawable, DO_WAIT, NEVER_BREAK, NULL); - } - - if (nxagentDrawableStatus(pDst -> pDrawable) == NotSynchronized) - { - #ifdef TEST - fprintf(stderr, "nxagentTriFan: Going to synchronize the destination drawable at [%p].\n", - (void *) pDst -> pDrawable); - #endif - - nxagentSynchronizeDrawable(pDst -> pDrawable, DO_WAIT, NEVER_BREAK, NULL); - } - - XRenderCompositeTriFan(nxagentDisplay, - op, - nxagentPicturePriv(pSrc) -> picture, - nxagentPicturePriv(pDst) -> picture, - pForm, - xSrc, - ySrc, - (XPointFixed*)points, - npoint); - #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif } void nxagentQueryFormats(void) { - XRenderInfo *xri; - XExtDisplayInfo *info = NULL; - XRenderPictFormat *pformat=NULL; - - int i; - #ifdef DEBUG fprintf(stderr, "nxagentQueryFormats.\n"); #endif if (XRenderQueryFormats(nxagentDisplay)) { - #ifdef DEBUG + int i; + #ifdef DEBUG XSync(nxagentDisplay, 0); - #endif - info = (XExtDisplayInfo *) XRenderFindDisplay(nxagentDisplay); + XExtDisplayInfo *info = (XExtDisplayInfo *) XRenderFindDisplay(nxagentDisplay); #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif - xri = (XRenderInfo *) info -> data; + XRenderInfo *xri = (XRenderInfo *) info -> data; - pformat = xri -> format; + XRenderPictFormat *pformat = xri -> format; for (i = 0; i < xri -> nformat; i++) { @@ -2354,7 +1907,6 @@ void nxagentQueryFormats(void) } #ifdef DEBUG - if (nxagentNumFormats == 0) { fprintf(stderr, "nxagentQueryFormats: Number of formats is [%d].\n", @@ -2365,7 +1917,6 @@ void nxagentQueryFormats(void) fprintf(stderr, "nxagentQueryFormats: Old number of formats is [%d]. New number of formats is [%d].\n", nxagentNumFormats, i); } - #endif nxagentNumFormats = i; @@ -2374,24 +1925,17 @@ void nxagentQueryFormats(void) void nxagentCreateGlyphSet(GlyphSetPtr pGly) { - XRenderPictFormat *pForm; - #ifdef DEBUG fprintf(stderr, "nxagentCreateGlyphSet: Glyphset at [%p].\n", (void *) pGly); #endif - pForm = NULL; + XRenderPictFormat *pForm = NULL; if (pGly -> format != NULL) { pForm = nxagentMatchingFormats(pGly -> format); - - #ifdef DEBUG - nxagentPrintFormat(pForm); - #endif - if (pForm == NULL) { return; @@ -2401,9 +1945,7 @@ void nxagentCreateGlyphSet(GlyphSetPtr pGly) pGly -> remoteID = XRenderCreateGlyphSet(nxagentDisplay, pForm); #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif } @@ -2440,13 +1982,6 @@ void nxagentFreeGlyphSet(GlyphSetPtr glyphSet) void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi, int nglyphs, CARD8 *images, int sizeImages) { - GlyphRefPtr gr; - Glyph *tempGids; - - int i; - - CARD8 *normalizedImages; - #ifdef DEBUG fprintf(stderr, "nxagentAddGlyphs: Glyphset at [%p]. Number of glyphs [%d].\n", (void *) glyphSet, nglyphs); @@ -2468,12 +2003,12 @@ void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi, * as synchronized. */ - tempGids = gids; - - for (i = 0; i < nglyphs; i++) + for (int i = 0; i < nglyphs; i++) { - if ((gr = FindGlyphRef(&glyphSet -> hash, *tempGids, 0, 0)) && - gr -> glyph != DeletedGlyph) + Glyph *tempGids = gids; + GlyphRefPtr gr = FindGlyphRef(&glyphSet -> hash, *tempGids, 0, 0); + + if (gr && gr -> glyph != DeletedGlyph) { #ifdef DEBUG fprintf(stderr, "nxagentAddGlyphs: Added Glyph [%p][%ld] to glyphset [%p].\n", @@ -2486,7 +2021,7 @@ void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi, tempGids++; } - normalizedImages = NULL; + CARD8 *normalizedImages = NULL; if (sizeImages > 0) { @@ -2533,20 +2068,15 @@ void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi, } #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif } void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph) { GlyphRefPtr gr; - CARD32 *tempGids; Glyph gid; - int i; - if (glyphSet -> remoteID == 0) { #ifdef TEST @@ -2564,9 +2094,9 @@ void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph) * they can be freed. */ - tempGids = gids; + CARD32 *tempGids = gids; - for (i = 0; i < nglyph; i++) + for (int i = 0; i < nglyph; i++) { gid = (Glyph)*tempGids; @@ -2594,7 +2124,6 @@ FIXME: Is this useful or just a waste of bandwidth? Apparently useless with QT. */ #ifndef SKIP_LOUSY_RENDER_OPERATIONS - XRenderSetPictureTransform(nxagentDisplay, nxagentPicturePriv(pPicture) -> picture, (XTransform *) transform); @@ -2629,7 +2158,6 @@ FIXME: Is this useful or just a waste of bandwidth? Apparently useless with QT. */ #ifndef SKIP_LOUSY_RENDER_OPERATIONS - XRenderSetPictureFilter(nxagentDisplay, nxagentPicturePriv(pPicture) -> picture, szFilter, @@ -2644,7 +2172,6 @@ FIXME: Is this useful or just a waste of bandwidth? Bool nxagentPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats) { #ifdef RENDER - #ifdef DEBUG fprintf(stderr, "nxagentPictureInit: Screen [%p].\n", (void *) pScreen); #endif @@ -2659,20 +2186,17 @@ Bool nxagentPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats) nxagentPicturePrivateIndex = AllocatePicturePrivateIndex(); AllocatePicturePrivate(pScreen, nxagentPicturePrivateIndex, sizeof(nxagentPrivPictureRec)); - #endif return TRUE; } -#ifdef DEBUG - static void nxagentPrintFormat(XRenderPictFormat *pFormat) { +#ifdef DEBUG if (pFormat == NULL) { fprintf(stderr, "nxagentPrintFormat: WARNING! null pointer passed to function.\n"); - return; } @@ -2698,16 +2222,11 @@ static void nxagentPrintFormat(XRenderPictFormat *pFormat) pFormat -> direct.blueMask, pFormat -> direct.alpha, pFormat -> direct.alphaMask); -} - #endif +} Bool nxagentFillGlyphSet(GlyphSetPtr pGly) { - GlyphPtr glyph; - - int i; - #ifdef DEBUG fprintf(stderr, "nxagentFillGlyphSet: GlyphSet at [%p] Refcount [%ld] Glyphs [%ld] " "Format [%p] FDepth [%d] RemoteID [%ld].\n", (void *) pGly, pGly -> refcnt, @@ -2721,9 +2240,9 @@ Bool nxagentFillGlyphSet(GlyphSetPtr pGly) * corrupted the glyphs for each glyphset. */ - for (i = 0; i < pGly -> hash.hashSet -> size; i++) + for (int i = 0; i < pGly -> hash.hashSet -> size; i++) { - glyph = pGly -> hash.table[i].glyph; + GlyphPtr glyph = pGly -> hash.table[i].glyph; if (glyph && (glyph != DeletedGlyph)) { @@ -2738,12 +2257,11 @@ void nxagentReconnectGlyphSet(void* p0, XID x1, void *p2) { GlyphSetPtr pGly = (GlyphSetPtr) p0; - XRenderPictFormat *pForm = NULL; - - int i; - if (nxagentReconnectTrap == 0) { + int i; + XRenderPictFormat *pForm = NULL; + #ifdef DEBUG fprintf(stderr, "nxagentReconnectGlyphSet: GlyphSet at [%p].\n", (void *) pGly); #endif @@ -2770,9 +2288,7 @@ void nxagentReconnectGlyphSet(void* p0, XID x1, void *p2) } #ifdef DEBUG - XSync(nxagentDisplay, 0); - #endif nxagentFillGlyphSet(pGly); @@ -2786,7 +2302,6 @@ void nxagentReconnectGlyphSet(void* p0, XID x1, void *p2) Bool nxagentReconnectAllGlyphSet(void *p) { Bool success = True; - int i; nxagentQueryFormats(); @@ -2794,7 +2309,7 @@ Bool nxagentReconnectAllGlyphSet(void *p) fprintf(stderr, "nxagentReconnectAllGlyphSet\n"); #endif - for (i = 0; (i < MAXCLIENTS) && (success); i++) + for (int i = 0; (i < MAXCLIENTS) && (success); i++) { if (clients[i]) { @@ -2812,7 +2327,6 @@ void nxagentReconnectPicture(void * p0, XID x1, void *p2) unsigned long mask = 0; XRenderPictureAttributes attributes; - XRenderPictFormat *pForm; #ifdef TEST fprintf(stderr, "nxagentReconnectPicture: Called with bool [%d] and picture at [%p].\n", @@ -2835,9 +2349,8 @@ void nxagentReconnectPicture(void * p0, XID x1, void *p2) if (pPicture -> repeat) { - mask |= CPRepeat; - attributes.repeat = (Bool) pPicture -> repeat; + mask |= CPRepeat; } if (pPicture -> alphaMap) @@ -2855,48 +2368,36 @@ void nxagentReconnectPicture(void * p0, XID x1, void *p2) attributes.alpha_map = nxagentPicture(pPicture -> alphaMap); attributes.alpha_x_origin = pPicture -> alphaOrigin.x; attributes.alpha_y_origin = pPicture -> alphaOrigin.y; - mask |= (CPAlphaMap | CPAlphaXOrigin | CPAlphaYOrigin); } if (pPicture -> graphicsExposures) { attributes.graphics_exposures = pPicture -> graphicsExposures; - mask |= CPGraphicsExposure; } attributes.subwindow_mode = pPicture -> subWindowMode; - mask |= CPSubwindowMode; attributes.poly_edge = pPicture -> polyEdge; - mask |= CPPolyEdge; attributes.poly_mode = pPicture -> polyMode; - mask |= CPPolyMode; attributes.dither = pPicture -> dither; - mask |= CPDither; attributes.component_alpha = pPicture -> componentAlpha; - mask |= CPComponentAlpha; - pForm = NULL; + XRenderPictFormat *pForm = NULL; if (pPicture -> pFormat) { pForm = nxagentMatchingFormats(pPicture -> pFormat); - - #ifdef DEBUG - nxagentPrintFormat(pForm); - - #endif } if (!pForm && pPicture->pSourcePict) @@ -2927,9 +2428,7 @@ void nxagentReconnectPicture(void * p0, XID x1, void *p2) &attributes); #ifdef TEST - XSync(nxagentDisplay, 0); - #endif #ifdef TEST @@ -2953,27 +2452,24 @@ void nxagentReconnectPicture(void * p0, XID x1, void *p2) Bool nxagentReconnectAllPicture(void *p) { - int i; - Bool r; + Bool r = True; #ifdef TEST fprintf(stderr, "nxagentReconnectAllPicture: Going to recreate all pictures.\n"); #endif - for (i = 0, r = True; i < MAXCLIENTS; i++) + for (int i = 0; i < MAXCLIENTS; i++) { if (clients[i]) { FindClientResourcesByType(clients[i], PictureType, nxagentReconnectPicture, &r); #ifdef WARNING - if (!r) { fprintf(stderr, "nxagentReconnectAllPicture: WARNING! Failed to recreate " "picture for client [%d].\n", i); } - #endif } } @@ -3009,27 +2505,24 @@ void nxagentDisconnectPicture(void * p0, XID x1, void* p2) Bool nxagentDisconnectAllPicture(void) { - int i; - Bool r; + Bool r = True; #ifdef DEBUG fprintf(stderr, "nxagentDisconnectAllPicture.\n"); #endif - for (i = 0, r = True; i < MAXCLIENTS; i++) + for (int i = 0; i < MAXCLIENTS; i++) { if (clients[i]) { FindClientResourcesByType(clients[i], PictureType, nxagentDisconnectPicture, &r); #ifdef WARNING - if (!r) { fprintf(stderr, "nxagentDisconnectAllPicture: WARNING! Failed to disconnect " "picture for client [%d].\n", i); } - #endif } } @@ -3039,15 +2532,12 @@ Bool nxagentDisconnectAllPicture(void) void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color) { - Picture id; - if (nxagentRenderEnable == False) { return; } #ifdef DEBUG - fprintf(stderr, "nxagentRenderCreateSolidFill: Got called.\n"); if (pPicture == NULL) @@ -3059,13 +2549,12 @@ void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color) { fprintf(stderr, "nxagentRenderCreateSolidFill: WARNING! color pointer is NULL.\n"); } - #endif /* #ifdef DEBUG */ memset(&(nxagentPicturePriv(pPicture) -> lastServerValues), 0, sizeof(XRenderPictureAttributes_)); - id = XRenderCreateSolidFill(nxagentDisplay, (XRenderColor *) color); + Picture id = XRenderCreateSolidFill(nxagentDisplay, (XRenderColor *) color); #ifdef DEBUG XSync(nxagentDisplay, 0); @@ -3083,17 +2572,12 @@ void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1, xFixed *stops, xRenderColor *colors) { - Picture id; - - XLinearGradient linearGradient; - if (nxagentRenderEnable == False) { return; } #ifdef DEBUG - fprintf(stderr, "nxagentRenderCreateLinearGradient: Got called.\n"); if (pPicture == NULL) @@ -3120,20 +2604,21 @@ void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1, { fprintf(stderr, "nxagentRenderCreateLinearGradient: WARNING! colors pointer is NULL.\n"); } - #endif /* #ifdef DEBUG */ memset(&(nxagentPicturePriv(pPicture) -> lastServerValues), 0, sizeof(XRenderPictureAttributes_)); + XLinearGradient linearGradient; + linearGradient.p1.x = (XFixed) p1 -> x; linearGradient.p1.y = (XFixed) p1 -> y; linearGradient.p2.x = (XFixed) p2 -> x; linearGradient.p2.y = (XFixed) p2 -> y; - id = XRenderCreateLinearGradient(nxagentDisplay, &linearGradient, - (XFixed *) stops, - (XRenderColor *) colors, nStops); + Picture id = XRenderCreateLinearGradient(nxagentDisplay, &linearGradient, + (XFixed *) stops, + (XRenderColor *) colors, nStops); #ifdef DEBUG XSync(nxagentDisplay, 0); @@ -3154,17 +2639,12 @@ void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, xFixed *stops, xRenderColor *colors) { - Picture id; - - XRadialGradient radialGradient; - if (nxagentRenderEnable == False) { return; } #ifdef DEBUG - fprintf(stderr, "nxagentRenderCreateRadialGradient: Got called.\n"); if (pPicture == NULL) @@ -3191,12 +2671,13 @@ void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, { fprintf(stderr, "nxagentRenderCreateRadialGradient: WARNING! colors pointer is NULL.\n"); } - #endif /* #ifdef DEBUG */ memset(&(nxagentPicturePriv(pPicture) -> lastServerValues), 0, sizeof(XRenderPictureAttributes_)); + XRadialGradient radialGradient; + radialGradient.inner.x = (XFixed) inner -> x; radialGradient.inner.y = (XFixed) inner -> y; radialGradient.inner.radius = (XFixed) innerRadius; @@ -3204,7 +2685,7 @@ void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, radialGradient.outer.y = (XFixed) outer -> y; radialGradient.outer.radius = (XFixed) outerRadius; - id = XRenderCreateRadialGradient(nxagentDisplay, &radialGradient, + Picture id = XRenderCreateRadialGradient(nxagentDisplay, &radialGradient, (XFixed *) stops, (XRenderColor *) colors, nStops); @@ -3225,17 +2706,12 @@ void nxagentRenderCreateConicalGradient(PicturePtr pPicture, xFixed *stops, xRenderColor *colors) { - Picture id; - - XConicalGradient conicalGradient; - if (nxagentRenderEnable == False) { return; } #ifdef DEBUG - fprintf(stderr, "nxagentRenderCreateConicalGradient: Got called.\n"); if (pPicture == NULL) @@ -3257,19 +2733,20 @@ void nxagentRenderCreateConicalGradient(PicturePtr pPicture, { fprintf(stderr, "nxagentRenderCreateConicalGradient: WARNING! colors pointer is NULL.\n"); } - #endif /* #ifdef DEBUG */ memset(&(nxagentPicturePriv(pPicture) -> lastServerValues), 0, sizeof(XRenderPictureAttributes_)); + XConicalGradient conicalGradient; + conicalGradient.center.x = (XFixed) center -> x; conicalGradient.center.y = (XFixed) center -> y; conicalGradient.angle = (XFixed) angle; - id = XRenderCreateConicalGradient(nxagentDisplay, &conicalGradient, - (XFixed *) stops, - (XRenderColor *) colors, nStops); + Picture id = XRenderCreateConicalGradient(nxagentDisplay, &conicalGradient, + (XFixed *) stops, + (XRenderColor *) colors, nStops); #ifdef DEBUG XSync(nxagentDisplay, 0); @@ -3281,4 +2758,3 @@ void nxagentRenderCreateConicalGradient(PicturePtr pPicture, nxagentPicturePriv(pPicture) -> picture = id; } - diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.h b/nx-X11/programs/Xserver/hw/nxagent/Render.h index 1c56ec16b..70fefe42d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.h @@ -104,7 +104,7 @@ while (0) void nxagentRenderExtensionInit(void); Bool nxagentPictureInit(ScreenPtr, PictFormatPtr, int); -int nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); +void nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi, int nglyphs, CARD8 *images, int sizeImages); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 8285d464d..2b1146496 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -141,6 +141,10 @@ extern Bool useXpmIcon; extern Bool nxagentReportWindowIds; +#ifdef NXAGENT_TIMESTAMP +extern unsigned long startTime; +#endif + Window nxagentDefaultWindows[MAXSCREENS]; Window nxagentInputWindows[MAXSCREENS]; Window nxagentScreenSaverWindows[MAXSCREENS]; @@ -210,8 +214,14 @@ RegionRec nxagentShadowUpdateRegion; #define NXAGENT_DEFAULT_DPI 96 #define NXAGENT_AUTO_DPI -1 +#ifndef NXAGENT_RANDR_MODE_PREFIX +#define NXAGENT_RANDR_MODE_PREFIX nx_ +#endif + extern Bool nxagentAutoDPI; +extern char *nxagentKeyboard; + /* * From randr/randr.c. This was originally static * but we need it here. @@ -268,8 +278,6 @@ void nxagentSetScreenInfo(ScreenInfo *screenInfo) void nxagentSetPixmapFormats(ScreenInfo *screenInfo) { - int i; - /* * Formats are created with no care of which are supported * on the real display. Creating only formats supported @@ -279,7 +287,7 @@ void nxagentSetPixmapFormats(ScreenInfo *screenInfo) screenInfo -> numPixmapFormats = nxagentNumPixmapFormats; - for (i = 0; i < nxagentNumPixmapFormats; i++) + for (int i = 0; i < nxagentNumPixmapFormats; i++) { screenInfo -> formats[i].depth = nxagentPixmapFormats[i].depth; screenInfo -> formats[i].bitsPerPixel = nxagentPixmapFormats[i].bits_per_pixel; @@ -399,7 +407,7 @@ FIXME: We'll check for ReparentNotify and LeaveNotify events after if (!XCheckTypedWindowEvent(nxagentDisplay, nxagentFullscreenWindow, LeaveNotify, &e)) break; #ifdef TEST - fprintf(stderr, "%d: swallowing LeaveNotify event\m", __func__); + fprintf(stderr, "%s: swallowing LeaveNotify event\n", __func__); #endif } @@ -410,29 +418,23 @@ FIXME: We'll check for ReparentNotify and LeaveNotify events after Window nxagentCreateIconWindow(void) { - XSetWindowAttributes attributes; - unsigned long valuemask; - char* window_name; - XTextProperty windowName; - XSizeHints* sizeHints; - XWMHints* wmHints; - Window w; - Mask mask; - /* * Create icon window. */ - attributes.override_redirect = False; - attributes.colormap = DefaultColormap(nxagentDisplay, DefaultScreen(nxagentDisplay)); - attributes.background_pixmap = nxagentScreenSaverPixmap; - valuemask = CWOverrideRedirect | CWBackPixmap | CWColormap; + XSetWindowAttributes attributes = { + .override_redirect = False, + .colormap = DefaultColormap(nxagentDisplay, DefaultScreen(nxagentDisplay)), + .background_pixmap = nxagentScreenSaverPixmap, + }; + + unsigned long valuemask = CWOverrideRedirect | CWBackPixmap | CWColormap; #ifdef TEST fprintf(stderr, "nxagentCreateIconWindow: Going to create new icon window.\n"); #endif - w = XCreateWindow(nxagentDisplay, DefaultRootWindow(nxagentDisplay), + Window w = XCreateWindow(nxagentDisplay, DefaultRootWindow(nxagentDisplay), 0, 0, 1, 1, 0, DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)), InputOutput, @@ -452,17 +454,17 @@ Window nxagentCreateIconWindow(void) * Set hints to the window manager for the icon window. */ - window_name = nxagentWindowName; - XStringListToTextProperty(&window_name, 1, &windowName); + XSizeHints* sizeHints = XAllocSizeHints(); + XWMHints* wmHints = XAllocWMHints();; - if ((sizeHints = XAllocSizeHints())) + if (sizeHints) { sizeHints->flags = PMinSize | PMaxSize; sizeHints->min_width = sizeHints->max_width = 1; sizeHints->min_height = sizeHints->max_height = 1; } - if ((wmHints = XAllocWMHints())) + if (wmHints) { wmHints->flags = IconPixmapHint | IconMaskHint; wmHints->initial_state = IconicState; @@ -479,6 +481,7 @@ Window nxagentCreateIconWindow(void) } } + char *window_name = nxagentWindowName; Xutf8SetWMProperties(nxagentDisplay, w, window_name, window_name, NULL , 0 , sizeHints, wmHints, NULL); @@ -490,7 +493,7 @@ Window nxagentCreateIconWindow(void) * Enable events from the icon window. */ - mask = nxagentGetDefaultEventMask(); + Mask mask = nxagentGetDefaultEventMask(); XSelectInput(nxagentDisplay, w, (mask & ~(KeyPressMask | KeyReleaseMask)) | StructureNotifyMask); @@ -651,14 +654,12 @@ FIXME: Do we need to check the key grab if the Bool nxagentCreateScreenResources(ScreenPtr pScreen) { - Bool ret; - CreatePixmapProcPtr savedCreatePixmap = pScreen->CreatePixmap; ModifyPixmapHeaderProcPtr savedModifyPixmapHeader = pScreen->ModifyPixmapHeader; pScreen->CreatePixmap = fbCreatePixmap; pScreen->ModifyPixmapHeader = miModifyPixmapHeader; - ret = miCreateScreenResources(pScreen); + Bool ret = miCreateScreenResources(pScreen); pScreen->CreatePixmap = savedCreatePixmap; pScreen->ModifyPixmapHeader = savedModifyPixmapHeader; @@ -688,7 +689,6 @@ void nxagentInitViewportFrame(ScreenPtr pScreen, WindowPtr pRootWin) { int error = Success; VisualID visual = 0; - int i; XID xid; if (nxagentOption(Rootless)) @@ -696,7 +696,7 @@ void nxagentInitViewportFrame(ScreenPtr pScreen, WindowPtr pRootWin) return; } - for (i = 0; i < pScreen -> numDepths; i++) + for (int i = 0; i < pScreen -> numDepths; i++) { if (pScreen -> allowedDepths[i].depth == pRootWin -> drawable.depth) { @@ -896,7 +896,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, VisualPtr visuals; DepthPtr depths; int numVisuals, numDepths; - int i, j, depthIndex; + int depthIndex; unsigned long valuemask; XSetWindowAttributes attributes; XWindowAttributes gattributes; @@ -1198,14 +1198,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, } #ifdef NXAGENT_TIMESTAMP - - { - extern unsigned long startTime; - - fprintf(stderr, "Screen: going to open screen, time is [%d] milliseconds.\n", - GetTimeInMillis() - startTime); - } - + fprintf(stderr, "Screen: going to open screen, time is [%d] milliseconds.\n", + GetTimeInMillis() - startTime); #endif /* @@ -1226,7 +1220,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, depths = (DepthPtr) malloc(nxagentNumDepths * sizeof(DepthRec)); - for (i = 0; i < nxagentNumDepths; i++) + for (int i = 0; i < nxagentNumDepths; i++) { depths[i].depth = nxagentDepths[i]; depths[i].numVids = 0; @@ -1247,7 +1241,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, visuals = (VisualPtr) malloc(nxagentNumVisuals * sizeof(VisualRec)); - for (i = 0; i < nxagentNumVisuals; i++) + for (int i = 0; i < nxagentNumVisuals; i++) { visuals[numVisuals].vid = FakeClientID(0); visuals[numVisuals].class = nxagentVisuals[i].class; @@ -1276,20 +1270,19 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, } else { + int j; for (j = 0; j < numVisuals; j++) { - if (visuals[numVisuals].class == visuals[j].class && - visuals[numVisuals].bitsPerRGBValue == - visuals[j].bitsPerRGBValue && - visuals[numVisuals].ColormapEntries == - visuals[j].ColormapEntries && - visuals[numVisuals].nplanes == visuals[j].nplanes && - visuals[numVisuals].redMask == visuals[j].redMask && - visuals[numVisuals].greenMask == visuals[j].greenMask && - visuals[numVisuals].blueMask == visuals[j].blueMask && - visuals[numVisuals].offsetRed == visuals[j].offsetRed && - visuals[numVisuals].offsetGreen == visuals[j].offsetGreen && - visuals[numVisuals].offsetBlue == visuals[j].offsetBlue) + if (visuals[numVisuals].class == visuals[j].class && + visuals[numVisuals].bitsPerRGBValue == visuals[j].bitsPerRGBValue && + visuals[numVisuals].ColormapEntries == visuals[j].ColormapEntries && + visuals[numVisuals].nplanes == visuals[j].nplanes && + visuals[numVisuals].redMask == visuals[j].redMask && + visuals[numVisuals].greenMask == visuals[j].greenMask && + visuals[numVisuals].blueMask == visuals[j].blueMask && + visuals[numVisuals].offsetRed == visuals[j].offsetRed && + visuals[numVisuals].offsetGreen == visuals[j].offsetGreen && + visuals[numVisuals].offsetBlue == visuals[j].offsetBlue) break; } @@ -1305,7 +1298,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, (long unsigned int)visuals[numVisuals].vid); #endif - for (j = 0; j < numDepths; j++) + for (int j = 0; j < numDepths; j++) { if (depths[j].depth == nxagentVisuals[i].depth) { @@ -1466,7 +1459,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, * pixmap for each depth. */ - for (i = 0; i < numDepths; i++) + for (int i = 0; i < numDepths; i++) { nxagentMarkPlaceholderNotLoaded(i); } @@ -2133,13 +2126,8 @@ N/A XSelectInput(nxagentDisplay, DefaultRootWindow(nxagentDisplay), StructureNotifyMask); #ifdef NXAGENT_TIMESTAMP - - { - extern unsigned long startTime; - - fprintf(stderr, "Screen: open screen finished, time is [%d] milliseconds.\n", - GetTimeInMillis() - startTime); - } + fprintf(stderr, "Screen: open screen finished, time is [%d] milliseconds.\n", + GetTimeInMillis() - startTime); #endif @@ -2586,9 +2574,7 @@ void nxagentShadowSetWindowOptions(void) int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) { - int i; char *layout = NULL; - extern char *nxagentKeyboard; XlibGC gc; XGCValues value; @@ -2609,6 +2595,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) if (nxagentKeyboard != NULL) { + int i; for (i = 0; nxagentKeyboard[i] != '/' && nxagentKeyboard[i] != 0; i++); if(nxagentKeyboard[i] == 0 || nxagentKeyboard[i + 1] == 0 || i == 0) @@ -2645,7 +2632,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) if (NXShadowCreate(nxagentDisplay, layout, nxagentShadowDisplayName, (void *) &nxagentShadowDisplay) != 1) { - #ifdef PANIIC + #ifdef PANIC fprintf(stderr, "nxagentShadowInit: PANIC! Failed to initialize shadow " "display [%s].\n", nxagentShadowDisplayName); #endif @@ -2714,37 +2701,31 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) case StaticGray: { className = "StaticGray"; - break; } case StaticColor: { className = "StaticColor"; - break; } case PseudoColor: { className = "PseudoColor"; - break; } case DirectColor: { className = "DirectColor"; - break; } case GrayScale: { className = "GrayScale"; - break; } default: { className = ""; - break; } } @@ -3222,29 +3203,14 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, unsigned int lineMaster, char **buffer) { - unsigned char red; - unsigned char green; - unsigned char blue; - unsigned short color16 = 0; - unsigned char * icBuffer; - unsigned char * cBuffer = NULL; unsigned char * tBuffer = (unsigned char *) *buffer; - unsigned int lineShadow; - unsigned int length; - unsigned int c; - unsigned int pad; - unsigned int color32 = 0; - unsigned long redMask; - unsigned long greenMask; - unsigned long blueMask; - Visual *pVisual; - length = nxagentImageLength(width, height, ZPixmap, 0, nxagentShadowDepth); + unsigned int length = nxagentImageLength(width, height, ZPixmap, 0, nxagentShadowDepth); - cBuffer = malloc(length); - icBuffer = cBuffer; + unsigned char *cBuffer = malloc(length); + unsigned char *icBuffer = cBuffer; - pVisual = nxagentImageVisual((DrawablePtr) nxagentShadowPixmapPtr, nxagentShadowDepth); + Visual *pVisual = nxagentImageVisual((DrawablePtr) nxagentShadowPixmapPtr, nxagentShadowDepth); if (pVisual == NULL) { @@ -3260,9 +3226,9 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, pVisual -> red_mask, pVisual -> green_mask, pVisual -> blue_mask); #endif - redMask = nxagentShadowDisplay -> screens[0].root_visual[0].red_mask; - greenMask = nxagentShadowDisplay -> screens[0].root_visual[0].green_mask; - blueMask = nxagentShadowDisplay -> screens[0].root_visual[0].blue_mask; + unsigned long redMask = nxagentShadowDisplay -> screens[0].root_visual[0].red_mask; + unsigned long greenMask = nxagentShadowDisplay -> screens[0].root_visual[0].green_mask; + unsigned long blueMask = nxagentShadowDisplay -> screens[0].root_visual[0].blue_mask; #ifdef TEST fprintf(stderr, "nxagentCorrectDepthShadow: Master redMask [%lu] greenMask[%lu] blueMask[%lu].\n", @@ -3276,7 +3242,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, */ case 16: { - pad = lineMaster - nxagentBppMaster * width; + unsigned int pad = lineMaster - nxagentBppMaster * width; #ifdef TEST fprintf(stderr, "nxagentCorrectDepthShadow: line [%d] width[%d] pad[%d].\n", lineMaster, width, pad); @@ -3284,8 +3250,13 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, while (height > 0) { - for (c = 0; c < width ; c++) + for (unsigned int c = 0; c < width ; c++) { + unsigned char red; + unsigned char green; + unsigned char blue; + unsigned short color16; + if (imageByteOrder == LSBFirst) { color16 = *tBuffer++; @@ -3353,9 +3324,8 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, */ case 24: { - lineShadow = PixmapBytePad(width, nxagentShadowDepth); - - pad = lineShadow - nxagentBppShadow * width; + unsigned int lineShadow = PixmapBytePad(width, nxagentShadowDepth); + unsigned int pad = lineShadow - nxagentBppShadow * width; #ifdef TEST fprintf(stderr, "nxagentCorrectDepthShadow: line [%d] width[%d] pad[%d].\n", lineShadow, width, pad); @@ -3363,8 +3333,11 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, while (height > 0) { - for (c = 0; c < width; c++) + for (unsigned int c = 0; c < width; c++) { + unsigned short color16; + unsigned int color32; + if (imageByteOrder == LSBFirst) { color32 = *tBuffer++; @@ -3446,7 +3419,6 @@ void nxagentPropagateArtsdProperties(ScreenPtr pScreen, char *port) unsigned char *pszReturnData = NULL; int iReturn; - int i,in; char tchar[] = " "; /* FIXME: The port information is not used at the moment and produces a @@ -3479,8 +3451,6 @@ FIXME: The port information is not used at the moment and produces a if (iReturn == Success && atomReturnType != None && ulReturnItems > 0 && pszReturnData != NULL) { - char *local_buf; - #ifdef TEST fprintf(stderr, "nxagentPropagateArtsdProperties: Got [%ld] elements of format [%d] with [%ld] bytes left.\n", ulReturnItems, iReturnFormat, ulReturnBytesLeft); @@ -3495,12 +3465,13 @@ FIXME: The port information is not used at the moment and produces a #endif - local_buf = (char *) malloc(strlen((char*)pszReturnData) + 100); + char *local_buf = (char *) malloc(strlen((char*)pszReturnData) + 100); if (local_buf) { memset(local_buf, 0, strlen((char *) pszReturnData)); + int i, in; for (i = 0, in = 0; pszReturnData[i] != '\0'; i++) { local_buf[in]=pszReturnData[i]; @@ -3611,9 +3582,7 @@ FIXME: The port information is not used at the moment and produces a Bool nxagentReconnectScreen(void *p0) { - CARD16 w, h; PixmapPtr pPixmap = (PixmapPtr)nxagentDefaultScreen->devPrivate; - Mask mask; #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_SCREEN_DEBUG) fprintf(stderr, "nxagentReconnectScreen\n"); @@ -3634,8 +3603,8 @@ Bool nxagentReconnectScreen(void *p0) pPixmap, nxagentPixmap( pPixmap )); #endif - w = 16; - h = 16; + CARD16 w = 16; + CARD16 h = 16; (*nxagentDefaultScreen->QueryBestSize)(StippleShape, &w, &h, nxagentDefaultScreen); if (!(nxagentPixmap(nxagentDefaultScreen->PixmapPerDepth[0]) = XCreatePixmap(nxagentDisplay, @@ -3644,7 +3613,7 @@ Bool nxagentReconnectScreen(void *p0) h, 1))); - mask = nxagentGetDefaultEventMask(); + Mask mask = nxagentGetDefaultEventMask(); mask |= NXAGENT_KEYBOARD_EVENT_MASK | NXAGENT_POINTER_EVENT_MASK; nxagentSetDefaultEventMask(mask); XSelectInput(nxagentDisplay, nxagentDefaultWindows[0], mask); @@ -3663,8 +3632,8 @@ Bool nxagentReconnectScreen(void *p0) /* intersect two rectangles */ Bool intersect(int ax1, int ay1, unsigned int aw, unsigned int ah, - int bx1, int by1, unsigned int bw, unsigned int bh, - int *x, int *y, unsigned int *w, unsigned int *h) + int bx1, int by1, unsigned int bw, unsigned int bh, + int *x, int *y, unsigned int *w, unsigned int *h) { int tx1, ty1, tx2, ty2, ix, iy; unsigned int iw, ih; @@ -3721,9 +3690,9 @@ Bool intersect(int ax1, int ay1, unsigned int aw, unsigned int ah, /* intersect two rectangles, return aw/ah for w/h if resulting rectangle is (partly) outside of bounding box */ Bool intersect_bb(int ax1, int ay1, unsigned int aw, unsigned int ah, - int bx1, int by1, unsigned int bw, unsigned int bh, - int bbx1, int bby1, int bbx2, int bby2, - int *x, int *y, unsigned int *w, unsigned int *h) + int bx1, int by1, unsigned int bw, unsigned int bh, + int bbx1, int bby1, int bbx2, int bby2, + int *x, int *y, unsigned int *w, unsigned int *h) { #ifdef DEBUG @@ -3877,9 +3846,6 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen) int nxagentChangeScreenConfig(int screen, int width, int height) { - ScreenPtr pScreen; - int r; - #ifdef DEBUG fprintf(stderr, "nxagentChangeScreenConfig: called for screen [%d], width [%d] height [%d]\n", screen, width, height); #endif @@ -3923,13 +3889,13 @@ int nxagentChangeScreenConfig(int screen, int width, int height) return 0; } - pScreen = screenInfo.screens[screen] -> root -> drawable.pScreen; + ScreenPtr pScreen = screenInfo.screens[screen] -> root -> drawable.pScreen; #ifdef TEST fprintf(stderr, "nxagentChangeScreenConfig: Changing config to %d x %d\n", width, height); #endif - r = nxagentResizeScreen(pScreen, width, height, 0, 0); + int r = nxagentResizeScreen(pScreen, width, height, 0, 0); if (r != 0) { @@ -3958,21 +3924,25 @@ int nxagentChangeScreenConfig(int screen, int width, int height) /* Destroy an output after removing it from any crtc that might reference it */ -void nxagentDropOutput(RROutputPtr o) { +void nxagentDropOutput(RROutputPtr o) +{ RRCrtcPtr c = o->crtc; - if (c) { - for (int i = 0; i < c->numOutputs; i++) { - if (c->outputs[i] == o) { -#ifdef DEBUG - fprintf(stderr, "nxagentDropOutput: output [%s] is in use by crtc [%p], removing it from there\n", o->name, c); -#endif - RRCrtcSet(c, NULL, 0, 0, RR_Rotate_0, 0, NULL); + if (c) + { + for (int i = 0; i < c->numOutputs; i++) + { + if (c->outputs[i] == o) + { + #ifdef DEBUG + fprintf(stderr, "nxagentDropOutput: output [%s] is in use by crtc [%p], removing it from there\n", o->name, c); + #endif + RRCrtcSet(c, NULL, 0, 0, RR_Rotate_0, 0, NULL); } } } -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "nxagentDropOutput: destroying output [%s]\n", o->name); -#endif + #endif RROutputDestroy(o); } @@ -3993,23 +3963,22 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) int i; int number = 0; - XineramaScreenInfo *screeninfo = NULL; + XineramaScreenInfo *screeninfo = XineramaQueryScreens(nxagentDisplay, &number); - screeninfo = XineramaQueryScreens(nxagentDisplay, &number); if (number) { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() returned [%d] screens:\n", number); for (int i=0; i < number; i++) { - fprintf(stderr, "nxagentAdjustRandRXinerama: screen_number [%d] x_org [%d] y_org [%d] width [%d] height [%d]\n", screeninfo[i].screen_number, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height); + fprintf(stderr, "nxagentAdjustRandRXinerama: screen_number [%d] x_org [%d] y_org [%d] width [%d] height [%d]\n", screeninfo[i].screen_number, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height); } -#endif + #endif } else { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() failed - continuing without Xinerama\n"); -#endif + #endif } /* @@ -4020,7 +3989,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) * behaved. The single PanoramiX/Xinerama extension however * disables xinerama if only one screen exists. */ - if (number == 0) { + if (number == 0) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: faking xinerama\n"); #endif @@ -4028,8 +3998,9 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) SAFE_free(screeninfo); - if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) { - return FALSE; + if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) + { + return FALSE; } /* fake a xinerama screeninfo that covers the whole screen */ @@ -4066,7 +4037,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) bbx2 = bby2 = 0; bbx1 = bby1 = INT_MAX; - for (i = 0; i < number; i++) { + for (i = 0; i < number; i++) + { bbx2 = max(bbx2, screeninfo[i].x_org + screeninfo[i].width); bby2 = max(bby2, screeninfo[i].y_org + screeninfo[i].height); bbx1 = min(bbx1, screeninfo[i].x_org); @@ -4083,8 +4055,10 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* adjust the number of CRTCs to match the number of reported xinerama screens on the real server */ - while (number != pScrPriv->numCrtcs) { - if (number < pScrPriv->numCrtcs) { + while (number != pScrPriv->numCrtcs) + { + if (number < pScrPriv->numCrtcs) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: destroying crtc\n"); #endif @@ -4108,12 +4082,14 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* set gamma. Currently the only reason for doing this is preventing the xrandr command from complaining about missing gamma. */ - for (i = 0; i < pScrPriv->numCrtcs; i++) { - if (pScrPriv->crtcs[i]->gammaSize == 0) { - CARD16 gamma = 0; - RRCrtcGammaSetSize(pScrPriv->crtcs[i], 1); - RRCrtcGammaSet(pScrPriv->crtcs[i], &gamma, &gamma, &gamma); - RRCrtcGammaNotify(pScrPriv->crtcs[i]); + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + if (pScrPriv->crtcs[i]->gammaSize == 0) + { + CARD16 gamma = 0; + RRCrtcGammaSetSize(pScrPriv->crtcs[i], 1); + RRCrtcGammaSet(pScrPriv->crtcs[i], &gamma, &gamma, &gamma); + RRCrtcGammaNotify(pScrPriv->crtcs[i]); } } @@ -4127,13 +4103,15 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) nxagentDropOutput(pScrPriv->outputs[i]); /* add and init outputs */ - for (i = 0; i < number; i++) { - if (i >= pScrPriv->numOutputs) { + for (i = 0; i < number; i++) + { + if (i >= pScrPriv->numOutputs) + { sprintf(name, "NX%d", i+1); output = RROutputCreate(pScreen, name, strlen(name), NULL); - /* will be done later - RROutputSetConnection(output, RR_Disconnected); - */ + /* will be done later + RROutputSetConnection(output, RR_Disconnected); + */ #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: created new output [%s]\n", name); #endif @@ -4154,7 +4132,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputSetPhysicalSize(output, 0, 0); } - for (i = 0; i < pScrPriv->numOutputs; i++) { + for (i = 0; i < pScrPriv->numOutputs; i++) + { Bool disable_output = FALSE; RRModePtr mymode = NULL, prevmode = NULL; int new_x = 0; @@ -4174,23 +4153,27 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) width, height, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height, - bbx1, bby1, bbx2, bby2, + bbx1, bby1, bbx2, bby2, &new_x, &new_y, &new_w, &new_h); #endif /* save previous mode */ prevmode = pScrPriv->crtcs[i]->mode; #ifdef DEBUG - if (prevmode) { + if (prevmode) + { fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: prevmode [%s] ([%p]) refcnt [%d]\n", i, pScrPriv->outputs[i]->name, prevmode->name, (void *)prevmode, prevmode->refcnt); - } else { + } + else + { fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: no prevmode\n", i, pScrPriv->outputs[i]->name); } #endif RROutputSetCrtcs(pScrPriv->outputs[i], &(pScrPriv->crtcs[i]), 1); - if (disable_output) { + if (disable_output) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: no (valid) intersection - disconnecting\n", i, pScrPriv->outputs[i]->name); #endif @@ -4205,7 +4188,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) * mode of the output's crtc. This also leads to xinerama not * showing the disconnected head anymore. */ - if (prevmode) { + if (prevmode) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from output [%d] name [%s]\n", i, pScrPriv->outputs[i]->name); #endif @@ -4227,15 +4211,11 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) memset(&modeInfo, '\0', sizeof(modeInfo)); -#ifdef NXAGENT_RANDR_MODE_PREFIX /* avoid collisions with pre-existing default modes by using a separate namespace. If we'd simply use XxY we could not distinguish between pre-existing modes which should stay and our own modes that should be removed after use. */ - sprintf(name, "nx_%dx%d", new_w, new_h); -#else - sprintf(name, "%dx%d", new_w, new_h); -#endif + sprintf(name, "%s%dx%d", QUOTE(NXAGENT_RANDR_MODE_PREFIX), new_w, new_h); modeInfo.width = new_w; modeInfo.height = new_h; @@ -4247,27 +4227,29 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) mymode = RRModeGet(&modeInfo, name); #ifdef DEBUG - if (mymode) { + if (mymode) + { fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: mode [%s] ([%p]) created/received, refcnt [%d]\n", i, pScrPriv->outputs[i]->name, name, (void *) mymode, mymode->refcnt); } else { - /* FIXME: what is the correct behaviour in this case? */ + /* FIXME: what is the correct behaviour in this case? */ fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: mode [%s] creation failed!\n", i, pScrPriv->outputs[i]->name, name); } #endif - if (prevmode && mymode == prevmode) { + if (prevmode && mymode == prevmode) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: mymode [%s] ([%p]) == prevmode [%s] ([%p])\n", mymode->name, (void *) mymode, prevmode->name, (void *)prevmode); #endif /* if they are the same RRModeGet() has increased the - refcnt by 1. We decrease it again by calling only - RRModeDestroy() and forget about prevmode */ - RRModeDestroy(mymode); + refcnt by 1. We decrease it again by calling only + RRModeDestroy() and forget about prevmode */ + RRModeDestroy(mymode); } else - { + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d [%s]\n", mymode->name, (void *) mymode, mymode->refcnt, i, pScrPriv->outputs[i]->name); #endif @@ -4283,11 +4265,12 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* throw away the mode if otherwise unused. We do not need it anymore. We call FreeResource() to ensure the system will not try to free it again on shutdown */ - if (prevmode && prevmode->refcnt == 1) { + if (prevmode && prevmode->refcnt == 1) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s]\n", prevmode->name); #endif - FreeResource(prevmode->mode.id, 0); + FreeResource(prevmode->mode.id, 0); } RROutputChanged(pScrPriv->outputs[i], TRUE); @@ -4298,19 +4281,20 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) SAFE_free(screeninfo); #ifdef DEBUG - for (i = 0; i < pScrPriv->numCrtcs; i++) { + for (i = 0; i < pScrPriv->numCrtcs; i++) + { RRModePtr mode = pScrPriv->crtcs[i]->mode; if (mode) { - fprintf(stderr, "nxagentAdjustRandRXinerama: crtc [%d] ([%p]) has mode [%s] ([%p]), refcnt [%d] and [%d] outputs:\n", i, (void *) pScrPriv->crtcs[i], pScrPriv->crtcs[i]->mode->name, (void *)pScrPriv->crtcs[i]->mode, pScrPriv->crtcs[i]->mode->refcnt, pScrPriv->crtcs[i]->numOutputs); + fprintf(stderr, "nxagentAdjustRandRXinerama: crtc [%d] ([%p]) has mode [%s] ([%p]), refcnt [%d] and [%d] outputs:\n", i, (void *) pScrPriv->crtcs[i], pScrPriv->crtcs[i]->mode->name, (void *)pScrPriv->crtcs[i]->mode, pScrPriv->crtcs[i]->mode->refcnt, pScrPriv->crtcs[i]->numOutputs); } else { - fprintf(stderr, "nxagentAdjustRandRXinerama: crtc [%d] ([%p]) has no mode and [%d] outputs:\n", i, (void *) pScrPriv->crtcs[i], pScrPriv->crtcs[i]->numOutputs); + fprintf(stderr, "nxagentAdjustRandRXinerama: crtc [%d] ([%p]) has no mode and [%d] outputs:\n", i, (void *) pScrPriv->crtcs[i], pScrPriv->crtcs[i]->numOutputs); } if (pScrPriv->crtcs[i]->numOutputs > 0) for (int j=0; j < pScrPriv->crtcs[i]->numOutputs; j++) - fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]->crtc=[%p]\n", j, pScrPriv->crtcs[i]->outputs[j]->name, (void *)pScrPriv->crtcs[i]->outputs[j]->crtc); + fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]->crtc=[%p]\n", j, pScrPriv->crtcs[i]->outputs[j]->name, (void *)pScrPriv->crtcs[i]->outputs[j]->crtc); } #endif @@ -4338,24 +4322,13 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin) { - PixmapPtr pVirtualPixmap; - nxagentPrivPixmapPtr pPrivPixmap; - XlibGC gc; - XGCValues values; - int i; - int xSrc, ySrc, xDst, yDst, w, h; - int nRects; - int size; - BoxPtr pBox; - XRectangle *pRects; - BoxRec extents; - RegionRec cleanRegion; + XGCValues values = {0}; miBSWindowPtr pBackingStore = (miBSWindowPtr) pWin -> backStorage; - pVirtualPixmap = nxagentVirtualPixmap(pPixmap); + PixmapPtr pVirtualPixmap = nxagentVirtualPixmap(pPixmap); - pPrivPixmap = nxagentPixmapPriv(pPixmap); + nxagentPrivPixmapPtr pPrivPixmap = nxagentPixmapPriv(pPixmap); pPrivPixmap -> isBackingPixmap = 1; @@ -4364,13 +4337,14 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, values.subwindow_mode = IncludeInferiors; - gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); + XlibGC gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); /* * Initialize to the corrupted region. * Coordinates are relative to the window. */ + RegionRec cleanRegion; RegionInit(&cleanRegion, NullBox, 1); RegionCopy(&cleanRegion, nxagentCorruptedRegion((DrawablePtr) pWin)); @@ -4395,12 +4369,12 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, RegionSubtract(&cleanRegion, prgnSave, &cleanRegion); - nRects = RegionNumRects(&cleanRegion); - size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); - pBox = RegionRects(&cleanRegion); + int nRects = RegionNumRects(&cleanRegion); + int size = nRects * sizeof(XRectangle); + XRectangle *pRects = (XRectangle *) malloc(size); + BoxPtr pBox = RegionRects(&cleanRegion); - for (i = nRects; i-- > 0;) + for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; @@ -4412,12 +4386,12 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, SAFE_free(pRects); - extents = *RegionExtents(&cleanRegion); + BoxRec extents = *RegionExtents(&cleanRegion); RegionUninit(&cleanRegion); - xDst = extents.x1; - yDst = extents.y1; + int xDst = extents.x1; + int yDst = extents.y1; /* * Left here the wrong solution. The window could be not @@ -4430,11 +4404,11 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, * ySrc = yDst + yorg - pWin -> drawable.y; */ - xSrc = xDst + pBackingStore -> x; - ySrc = yDst + pBackingStore -> y; + int xSrc = xDst + pBackingStore -> x; + int ySrc = yDst + pBackingStore -> y; - w = extents.x2 - extents.x1; - h = extents.y2 - extents.y1; + int w = extents.x2 - extents.x1; + int h = extents.y2 - extents.y1; XCopyArea(nxagentDisplay, nxagentWindow(pWin), nxagentPixmap(pPixmap), gc, xSrc, ySrc, w, h, xDst, yDst); @@ -4455,18 +4429,7 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, int yorg, WindowPtr pWin) { - PixmapPtr pVirtualPixmap; - RegionPtr clipRegion; - XlibGC gc; - XGCValues values; - int i; - int xSrc, ySrc, xDst, yDst, w, h; - int nRects; - int size; - BoxPtr pBox; - XRectangle *pRects; - BoxRec extents; - miBSWindowPtr pBackingStore; + XGCValues values = {0}; /* * Limit the area to restore to the @@ -4476,16 +4439,16 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, RegionIntersect(prgnRestore, prgnRestore, &pWin -> drawable.pScreen -> root -> winSize); - pBackingStore = (miBSWindowPtr) pWin -> backStorage; + miBSWindowPtr pBackingStore = (miBSWindowPtr) pWin -> backStorage; - pVirtualPixmap = nxagentVirtualPixmap(pPixmap); + PixmapPtr pVirtualPixmap = nxagentVirtualPixmap(pPixmap); fbCopyWindowProc(&pVirtualPixmap -> drawable, &pWin -> drawable, 0, RegionRects(prgnRestore), RegionNumRects(prgnRestore), -xorg, -yorg, FALSE, FALSE, 0, 0); values.subwindow_mode = ClipByChildren; - gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); + XlibGC gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); /* * Translate the reference point to the origin of the window. @@ -4495,7 +4458,7 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, -pWin -> drawable.x - pWin -> borderWidth, -pWin -> drawable.y - pWin -> borderWidth); - clipRegion = prgnRestore; + RegionPtr clipRegion = prgnRestore; if (nxagentDrawableStatus((DrawablePtr) pPixmap) == NotSynchronized) { @@ -4541,12 +4504,12 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, RegionSubtract(clipRegion, prgnRestore, clipRegion); } - nRects = RegionNumRects(clipRegion); - size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); - pBox = RegionRects(clipRegion); + int nRects = RegionNumRects(clipRegion); + int size = nRects * sizeof(XRectangle); + XRectangle *pRects = (XRectangle *) malloc(size); + BoxPtr pBox = RegionRects(clipRegion); - for (i = nRects; i-- > 0;) + for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; @@ -4558,16 +4521,16 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, SAFE_free(pRects); - extents = *RegionExtents(clipRegion); + BoxRec extents = *RegionExtents(clipRegion); - xDst = extents.x1; - yDst = extents.y1; + int xDst = extents.x1; + int yDst = extents.y1; - xSrc = xDst - xorg + pWin -> drawable.x; - ySrc = yDst - yorg + pWin -> drawable.y; + int xSrc = xDst - xorg + pWin -> drawable.x; + int ySrc = yDst - yorg + pWin -> drawable.y; - w = extents.x2 - extents.x1; - h = extents.y2 - extents.y1; + int w = extents.x2 - extents.x1; + int h = extents.y2 - extents.y1; nxagentFlushConfigureWindow(); @@ -4661,11 +4624,7 @@ void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheig void nxagentShadowAdaptToRatio(void) { - ScreenPtr pScreen; - RegionRec region; - BoxRec box; - - pScreen = screenInfo.screens[0]; + ScreenPtr pScreen = screenInfo.screens[0]; nxagentShadowSetRatio(nxagentOption(Width) * 1.0 / nxagentShadowWidth, nxagentOption(Height) * 1.0 / nxagentShadowHeight); @@ -4676,10 +4635,14 @@ void nxagentShadowAdaptToRatio(void) WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); - box.x1 = 0; - box.y1 = 0; - box.x2 = nxagentShadowPixmapPtr -> drawable.width; - box.y2 = nxagentShadowPixmapPtr -> drawable.height; + BoxRec box = { + .x1 = 0, + .y1 = 0, + .x2 = nxagentShadowPixmapPtr -> drawable.width, + .y2 = nxagentShadowPixmapPtr -> drawable.height + }; + + RegionRec region; RegionInit(®ion, &box, 1); @@ -4690,11 +4653,9 @@ void nxagentShadowAdaptToRatio(void) void nxagentPrintGeometry(void) { - int i; - - for (i = 0; i < screenInfo.numScreens; i++) + for (int i = 0; i < screenInfo.numScreens; i++) { - if (nxagentPrintGeometryFlags && (1 << i)) + if (nxagentPrintGeometryFlags & (1 << i)) { fprintf(stderr, "Info: Screen [%d] resized to geometry [%dx%d] " "fullscreen [%d].\n", i, screenInfo.screens[i] -> width, @@ -4711,21 +4672,15 @@ void nxagentPrintGeometry(void) void nxagentShowPixmap(PixmapPtr pPixmap, int x, int y, int width, int height) { static int init = 1; - static Display *shadow; - static Window win; - - XlibGC gc; - XGCValues value; - XImage *image; - WindowPtr pWin = screenInfo.screens[0]->root; - unsigned int format; - int depth, pixmapWidth, pixmapHeight, length; - char *data; + static Display *shadow = NULL; + static Window win = 0; - depth = pPixmap -> drawable.depth; - pixmapWidth = pPixmap -> drawable.width; - pixmapHeight = pPixmap -> drawable.height; - format = (depth == 1) ? XYPixmap : ZPixmap; + int depth = pPixmap -> drawable.depth; + /* + int pixmapWidth = pPixmap -> drawable.width; + int pixmapHeight = pPixmap -> drawable.height; + */ + unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; if (init) { @@ -4770,9 +4725,9 @@ void nxagentShowPixmap(PixmapPtr pPixmap, int x, int y, int width, int height) XRaiseWindow(nxagentDisplay, win); } - length = nxagentImageLength(width, height, format, 0, depth); - - if ((data = malloc(length)) == NULL) + int length = nxagentImageLength(width, height, format, 0, depth); + char *data = malloc(length); + if (data == NULL) { #ifdef WARNING fprintf(stderr, "nxagentShowPixmap: malloc failed.\n"); @@ -4783,12 +4738,12 @@ void nxagentShowPixmap(PixmapPtr pPixmap, int x, int y, int width, int height) /* FIXME - image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), x, y, - width, height, AllPlanes, format); + XImage *image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), x, y, + width, height, AllPlanes, format); */ - image = XGetImage(nxagentDisplay, RootWindow(nxagentDisplay, 0), 0, 0, - width, height, AllPlanes, format); + XImage *image = XGetImage(nxagentDisplay, RootWindow(nxagentDisplay, 0), 0, 0, + width, height, AllPlanes, format); if (image == NULL) { @@ -4806,13 +4761,15 @@ FIXME memcpy(image -> data, data, length); - value.foreground = 0xffffff; - value.background = 0x000000; - value.plane_mask = 0xffffff; - value.fill_style = FillSolid; + XGCValues value = { + .foreground = 0xffffff, + .background = 0x000000, + .plane_mask = 0xffffff, + .fill_style = FillSolid + }; - gc = XCreateGC(shadow, win, GCBackground | - GCForeground | GCFillStyle | GCPlaneMask, &value); + XlibGC gc = XCreateGC(shadow, win, GCBackground | + GCForeground | GCFillStyle | GCPlaneMask, &value); XSync(shadow, 0); @@ -4843,26 +4800,19 @@ FIXME void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, int width, int height, int xDst, int yDst) { - Display *shadow; - - XlibGC gc; - XGCValues value; - XImage *image; - unsigned int format; - int depth, pixmapWidth, pixmapHeight, length; - char *data = NULL; - Visual *pVisual; - - depth = pPixmap -> drawable.depth; - pixmapWidth = pPixmap -> drawable.width; - pixmapHeight = pPixmap -> drawable.height; - format = (depth == 1) ? XYPixmap : ZPixmap; + Display *shadow = nxagentDisplay; - shadow = nxagentDisplay; + int depth = pPixmap -> drawable.depth; + /* + int pixmapWidth = pPixmap -> drawable.width; + int pixmapHeight = pPixmap -> drawable.height; + */ + unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; - length = nxagentImageLength(width, height, format, 0, depth); + int length = nxagentImageLength(width, height, format, 0, depth); + char *data = malloc(length); - if ((data = malloc(length)) == NULL) + if (data == NULL) { #ifdef WARNING fprintf(stderr, "nxagentFbRestoreArea: malloc failed.\n"); @@ -4870,11 +4820,13 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, return; } + + XImage *image = NULL; /* - image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), xSrc, ySrc, - width, height, AllPlanes, format); + XImage *image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), xSrc, ySrc, + width, height, AllPlanes, format); */ - + if (image == NULL) { #ifdef WARNING @@ -4892,7 +4844,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, /* FIXME */ - pVisual = nxagentImageVisual((DrawablePtr) pPixmap, depth); + Visual *pVisual = nxagentImageVisual((DrawablePtr) pPixmap, depth); if (pVisual == NULL) { @@ -4914,14 +4866,16 @@ FIXME fprintf(stderr, "nxagentFbRestoreArea: Cleaning %d bytes of image.\n", length); - value.foreground = 0xffffff; - value.background = 0x000000; - value.plane_mask = 0xffffff; - value.fill_style = FillSolid; - value.function = GXcopy; + XGCValues value = { + .foreground = 0xffffff, + .background = 0x000000, + .plane_mask = 0xffffff, + .fill_style = FillSolid, + .function = GXcopy + }; - gc = XCreateGC(shadow, nxagentWindow(screenInfo.screens[0]->root), GCBackground | - GCForeground | GCFillStyle | GCPlaneMask | GCFunction, &value); + XlibGC gc = XCreateGC(shadow, nxagentWindow(screenInfo.screens[0]->root), GCBackground | + GCForeground | GCFillStyle | GCPlaneMask | GCFunction, &value); NXCleanImage(image); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.h b/nx-X11/programs/Xserver/hw/nxagent/Screen.h index 2f93105ef..bf5d8894e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.h @@ -136,6 +136,8 @@ void nxagentSetWMNormalHintsMaxsize(ScreenPtr, int, int); void nxagentShadowSetRatio(float, float); +void nxagentPropagateArtsdProperties(ScreenPtr pScreen, char *port); + /* * Change window settings to adapt to a ratio. */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Split.c b/nx-X11/programs/Xserver/hw/nxagent/Split.c index d58d70bfd..33005e86d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Split.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Split.c @@ -792,11 +792,11 @@ void nxagentWaitDrawable(DrawablePtr pDrawable) else { fprintf(stderr, "nxagentWaitDrawable: Drawable at [%p] can now be restarted.\n", - (void *) pDrawable); + (void *) pDrawable); } #endif - + return; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Trap.c b/nx-X11/programs/Xserver/hw/nxagent/Trap.c index f219bb43c..4fe12bede 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Trap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Trap.c @@ -42,13 +42,6 @@ int nxagentGCTrap = 0; int nxagentScreenTrap = 0; /* - * Set if we detected that our RENDER - * implementation is faulty. - */ - -int nxagentRenderTrap = 0; - -/* * Set if we are executing a GC operation * only on the X side. Used to avoid * reentrancy in FB layer. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Trap.h b/nx-X11/programs/Xserver/hw/nxagent/Trap.h index 9f0c055c8..cd1e79ff7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Trap.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Trap.h @@ -27,98 +27,68 @@ #define __Traps_H__ /* - * Set if we are dispatching a render - * extension request. Used to avoid + * Set if we are dispatching a render extension request. Used to avoid * reentrancy in GC operations. */ - extern int nxagentGCTrap; /* - * Set if we are enqueing an internal - * operation, CreateWindow and Reparent- - * Window. Used to remove any screen operation. + * Set if we are enqueing an internal operation, CreateWindow and + * Reparent- Window. Used to remove any screen operation. */ - extern int nxagentScreenTrap; /* - * Set if we detected that our RENDER - * implementation is faulty. + * Set if we are executing a GC operation only on the X side. Used to + * avoid reentrancy in FB layer. */ - -extern int nxagentRenderTrap; - -/* - * Set if we are executing a GC operation - * only on the X side. Used to avoid - * reentrancy in FB layer. - */ - extern int nxagentFBTrap; /* - * Set if we are dispatching a shared - * memory extension request. + * Set if we are dispatching a shared memory extension request. */ - extern int nxagentShmTrap; /* - * Set if a shared pixmap operation is - * requested by the client. + * Set if a shared pixmap operation is requested by the client. */ - extern int nxagentShmPixmapTrap; /* - * Set if we are dispatching a XVideo - * extension request. + * Set if we are dispatching a XVideo extension request. */ - extern int nxagentXvTrap; /* - * Set if we are dispatching a GLX - * extension request. + * Set if we are dispatching a GLX extension request. */ - extern int nxagentGlxTrap; /* * Set while we are resuming the session. */ - extern int nxagentReconnectTrap; /* - * Set if we need to realize a drawable - * by using a lossless encoding. + * Set if we need to realize a drawable by using a lossless encoding. */ - extern int nxagentLosslessTrap; /* - * Set to force the synchronization of - * a drawable. + * Set to force the synchronization of a drawable. */ - extern int nxagentSplitTrap; /* - * Set to avoid CapsLock synchronization - * problems when CapsLock is the first - * key to be pressed in the session. + * Set to avoid CapsLock synchronization problems when CapsLock is the + * first key to be pressed in the session. */ - extern int nxagentXkbCapsTrap; /* - * Set to avoid NumLock synchronization - * problems when NumLock is the first - * key to be pressed in the session. + * Set to avoid NumLock synchronization problems when NumLock is the + * first key to be pressed in the session. */ - extern int nxagentXkbNumTrap; /* @@ -126,7 +96,6 @@ extern int nxagentXkbNumTrap; * the real X server. This is used to avoid endless loops if callbacks * would trigger another event by the real X server */ - extern int nxagentExternalClipboardEventTrap; #endif /* __Trap_H__ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Utils.h b/nx-X11/programs/Xserver/hw/nxagent/Utils.h index 0aebda839..e61a79144 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Utils.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Utils.h @@ -47,4 +47,8 @@ static inline const char * validateString(const char *str) { #define SAFE_XFree(what) do {if (what) {XFree(what); what = NULL;}} while (0) #define SAFE_free(what) do {free(what); what = NULL;} while (0) +/* some helper macros to produce a quoted string from other macros */ +#define QUOTEEXP(str) #str +#define QUOTE(str) QUOTEEXP(str) + #endif /* __Utils_H__ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 80e9bef3b..fadf6ffb1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -2671,7 +2671,7 @@ void nxagentDisconnectWindow(void * p0, XID x1, void * p2) nxagentCursorPriv(pCursor, pScreen) && nxagentCursor(pCursor, pScreen)) { - #ifdef NXAGENT_RECONNECT_CURSOR_DEBUG_disabled + #ifdef NXAGENT_RECONNECT_CURSOR_DEBUG char msg[] = "nxagentDisconnectWindow:"; nxagentPrintCursorInfo(pCursor, msg); |