Skip to content

Commit cb87f01

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 360cb5d commit cb87f01

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -2948,7 +2948,11 @@ OtherClientGone(void * value, XID id)
29482948
}
29492949

29502950
int
2951+
#ifdef NXAGENT_SERVER
2952+
Xorg_EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
2953+
#else
29512954
EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
2955+
#endif
29522956
{
29532957
Mask check;
29542958
OtherClients * others;

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

+31
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,37 @@ DefineInitialRootWindow(register WindowPtr win)
520520
}
521521
}
522522

523+
#ifdef NXAGENT_SERVER
524+
extern Bool nxagentWMIsRunning;
525+
526+
int
527+
EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
528+
{
529+
int res = Xorg_EventSelectForWindow(pWin, client, mask);
530+
531+
/*
532+
* intercept SelectInput calls for SubStructureRedirect. The
533+
* standard way of checking for a Window Manager is trying to
534+
* SelectInput on SubStructureRedirect. If it fails it can be
535+
* deduced there's a Window Manager running since
536+
* SubStructureRedirect is only allowed for ONE client. In a
537+
* rootless session there is (and should be) no Window Manager so
538+
* we report the WM state we found on the real X server. This
539+
* also helps for nesting rootless nxagents.
540+
*/
541+
542+
if ((mask & SubstructureRedirectMask) && (nxagentOption(Rootless) == 1))
543+
{
544+
#ifdef DEBUG
545+
fprintf(stderr, "%s: WM check detected\n", __func__);
546+
#endif
547+
if (nxagentWMIsRunning)
548+
return BadAccess;
549+
}
550+
return res;
551+
}
552+
#endif
553+
523554
int
524555
ProcSendEvent(ClientPtr client)
525556
{

0 commit comments

Comments
 (0)