Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward ClientMessages to nxproxy side #1016

Merged
merged 1 commit into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions nx-X11/programs/Xserver/hw/nxagent/Events.c
Original file line number Diff line number Diff line change
Expand Up @@ -4505,6 +4505,70 @@ int nxagentWaitEvents(Display *dpy, useconds_t msec)
return 1;
}

void ForwardClientMessage(ClientPtr client, xSendEventReq *stuff)
{
Atom netwmstate = MakeAtom("_NET_WM_STATE", strlen("_NET_WM_STATE"), False);
Atom wmchangestate = MakeAtom("WM_CHANGE_STATE", strlen("WM_CHANGE_STATE"), False);
WindowPtr pWin = (WindowPtr)SecurityLookupWindow(stuff->destination, client,
DixReadAccess);

if (stuff->event.u.clientMessage.u.l.type == netwmstate || stuff->event.u.clientMessage.u.l.type == wmchangestate)
{
if (pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id)
{
#ifdef DEBUG
fprintf(stderr, "%s: dest [0x%x] window [0x%x] clmsg.type [%d]->[%d]\n", __func__, stuff->destination, stuff->event.u.clientMessage.window, stuff->event.u.clientMessage.u.l.type, nxagentLocalToRemoteAtom(stuff->event.u.clientMessage.u.l.type));
#endif

XEvent X = {0};
X.xany.type = ClientMessage;

WindowPtr pWin2 = (WindowPtr)SecurityLookupWindow(stuff->event.u.clientMessage.window, client,
DixReadAccess);
X.xclient.window = nxagentWindowPriv(pWin2)->window;
X.xclient.format = stuff->event.u.u.detail;
X.xclient.send_event = True;
X.xclient.serial = 0;

if (X.xclient.format == 32)
{
X.xclient.message_type = nxagentLocalToRemoteAtom(stuff->event.u.clientMessage.u.l.type);
X.xclient.data.l[0] = stuff->event.u.clientMessage.u.l.longs0;
X.xclient.data.l[1] = nxagentLocalToRemoteAtom(stuff->event.u.clientMessage.u.l.longs1);
X.xclient.data.l[2] = nxagentLocalToRemoteAtom(stuff->event.u.clientMessage.u.l.longs2);
X.xclient.data.l[3] = nxagentLocalToRemoteAtom(stuff->event.u.clientMessage.u.l.longs3);
X.xclient.data.l[4] = nxagentLocalToRemoteAtom(stuff->event.u.clientMessage.u.l.longs4);
//X.xclient.data.l[3] = stuff->event.u.clientMessage.u.l.longs3;
//X.xclient.data.l[4] = stuff->event.u.clientMessage.u.l.longs4;
#ifdef DEBUG
for (int i = 0; i < 5; i++)
{
fprintf(stderr, "%s: data[%d] [%ld]\n", __func__, i, X.xclient.data.l[i]);
}
#endif
}
else
return; // ERROR!

#ifdef DEBUG
fprintf(stderr, "%s: window [0x%lx]\n", __func__, X.xclient.window);
fprintf(stderr, "%s: message_type [%ld]\n", __func__, X.xclient.message_type);
fprintf(stderr, "%s: format [%d]\n", __func__, X.xclient.format);
#endif

XlibWindow dest;
dest = DefaultRootWindow(nxagentDisplay);

Status stat = XSendEvent(nxagentDisplay, dest, stuff->propagate, stuff->eventMask, &X);
XFlush(nxagentDisplay);
#ifdef DEBUG
fprintf(stderr, "%s: send to window [0x%lx]\n", __func__, dest);
fprintf(stderr, "%s: return Status [%d]\n", __func__, stat);
#endif
}
}
}

#ifdef NX_DEBUG_INPUT

void nxagentGuessDumpInputInfo(ClientPtr client, Atom property, char *data)
Expand Down
2 changes: 2 additions & 0 deletions nx-X11/programs/Xserver/hw/nxagent/Events.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,6 @@ int nxagentPendingEvents(Display *dpy);

int nxagentWaitEvents(Display *, useconds_t msec);

void ForwardClientMessage(ClientPtr client, xSendEventReq *stuff);

#endif /* __Events_H__ */
6 changes: 6 additions & 0 deletions nx-X11/programs/Xserver/hw/nxagent/NXevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ ProcSendEvent(ClientPtr client)

REQUEST_SIZE_MATCH(xSendEventReq);

if (nxagentOption(Rootless) && stuff->event.u.u.type == ClientMessage)
{
ForwardClientMessage(client, stuff);
return Success;
}

if (stuff -> event.u.u.type == SelectionNotify)
{
if (nxagentSendNotify(&stuff->event) == 1)
Expand Down