Skip to content

Commit

Permalink
nxagent: Pass down if window manager has been detected
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
uli42 committed Jun 9, 2021
1 parent 59a0620 commit eeade65
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nx-X11/programs/Xserver/dix/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -2970,7 +2970,11 @@ OtherClientGone(void * value, XID id)
}

int
#ifdef NXAGENT_SERVER
Xorg_EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
#else
EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
#endif
{
Mask check;
OtherClients * others;
Expand Down
31 changes: 31 additions & 0 deletions nx-X11/programs/Xserver/hw/nxagent/NXevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,37 @@ DefineInitialRootWindow(register WindowPtr win)
}
}

#ifdef NXAGENT_SERVER
extern Bool nxagentWMIsRunning;

int
EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
{
int res = Xorg_EventSelectForWindow(pWin, client, mask);

/*
* intercept SelectInput calls for SubStructureRedirect. The
* standard way of checking for a Window Manager is trying to
* SelectInput on SubStructureRedirect. If it fails it can be
* deduced there's a Window Manager running since
* SubStructureRedirect is only allowed for ONE client. In a
* rootless session there is (and should be) no Window Manager so
* we report the WM state we found on the real X server. This
* also helps for nesting rootless nxagents.
*/

if ((mask & SubstructureRedirectMask) && (nxagentOption(Rootless) == 1))
{
#ifdef DEBUG
fprintf(stderr, "%s: WM check detected\n", __func__);
#endif
if (nxagentWMIsRunning)
return BadAccess;
}
return res;
}
#endif

int
ProcSendEvent(ClientPtr client)
{
Expand Down

0 comments on commit eeade65

Please sign in to comment.