Skip to content

Commit eeade65

Browse files
committed
nxagent: Pass down if window manager has been detected
At start a rootless nxagent checks if the real X server has a Window Manager running. It uses a standard detection routine that tries to select a special input (SubStructureRedirect). As only one client per X server is allowed to select that input one can deduce from the success of this operation if a Window Manager is running. If nxagent is run in rootless mode and has not found a Window Manager on the real X server it will grab all input (see Screen.c:nxagentOpenScreen). If any client of the nxagent runs the standard Window Manager detection routine against a rootless nxagent it will _not_ see the Window Manager. If this client happens to be a rootless nxagent again it will then grab all input which is undesired here. Other clients might do other undesired stuff in that case. To avoid all that a rootless nxagent now tries to detect if a client runs that detection routine and returns the result of its own check to the client.
1 parent 59a0620 commit eeade65

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

nx-X11/programs/Xserver/dix/events.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,11 @@ OtherClientGone(void * value, XID id)
29702970
}
29712971

29722972
int
2973+
#ifdef NXAGENT_SERVER
2974+
Xorg_EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
2975+
#else
29732976
EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
2977+
#endif
29742978
{
29752979
Mask check;
29762980
OtherClients * others;

nx-X11/programs/Xserver/hw/nxagent/NXevents.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,37 @@ DefineInitialRootWindow(register WindowPtr win)
416416
}
417417
}
418418

419+
#ifdef NXAGENT_SERVER
420+
extern Bool nxagentWMIsRunning;
421+
422+
int
423+
EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
424+
{
425+
int res = Xorg_EventSelectForWindow(pWin, client, mask);
426+
427+
/*
428+
* intercept SelectInput calls for SubStructureRedirect. The
429+
* standard way of checking for a Window Manager is trying to
430+
* SelectInput on SubStructureRedirect. If it fails it can be
431+
* deduced there's a Window Manager running since
432+
* SubStructureRedirect is only allowed for ONE client. In a
433+
* rootless session there is (and should be) no Window Manager so
434+
* we report the WM state we found on the real X server. This
435+
* also helps for nesting rootless nxagents.
436+
*/
437+
438+
if ((mask & SubstructureRedirectMask) && (nxagentOption(Rootless) == 1))
439+
{
440+
#ifdef DEBUG
441+
fprintf(stderr, "%s: WM check detected\n", __func__);
442+
#endif
443+
if (nxagentWMIsRunning)
444+
return BadAccess;
445+
}
446+
return res;
447+
}
448+
#endif
449+
419450
int
420451
ProcSendEvent(ClientPtr client)
421452
{

0 commit comments

Comments
 (0)