Only SetSelectionOwner when syncing selections

When a client becomes the selection owner, and sets the selection, an
XFixes event is raised, and gamescope responds by retrieving the contents
of the selection, and re-setting ourWindow as the owner of the selection.
We don't need to call XChangeProperty when syncing across Xwayland
instances, as that gets called when a client makes a SelectionRequest.
This commit is contained in:
Alex Maese 2023-07-31 18:24:17 -05:00 committed by Joshie
parent a883f133a3
commit a64a5a8653

View file

@ -4748,7 +4748,7 @@ handle_client_message(xwayland_ctx_t *ctx, XClientMessageEvent *ev)
} }
} }
static void x11_set_selection(xwayland_ctx_t *ctx, std::string contents, int selectionTarget) static void x11_set_selection_owner(xwayland_ctx_t *ctx, std::string contents, int selectionTarget)
{ {
Atom target; Atom target;
if (selectionTarget == CLIPBOARD) if (selectionTarget == CLIPBOARD)
@ -4765,9 +4765,6 @@ static void x11_set_selection(xwayland_ctx_t *ctx, std::string contents, int sel
} }
XSetSelectionOwner(ctx->dpy, target, ctx->ourWindow, CurrentTime); XSetSelectionOwner(ctx->dpy, target, ctx->ourWindow, CurrentTime);
XChangeProperty(ctx->dpy, ctx->ourWindow, target, ctx->atoms.utf8StringAtom, 8, PropModeReplace,
(unsigned char *)contents.c_str(), contents.length());
XFlush(ctx->dpy);
} }
void gamescope_set_selection(std::string contents, int selection) void gamescope_set_selection(std::string contents, int selection)
@ -4781,11 +4778,10 @@ void gamescope_set_selection(std::string contents, int selection)
primarySelection = contents; primarySelection = contents;
} }
for (int i = 0; i < g_nXWaylandCount; i++) gamescope_xwayland_server_t *server = NULL;
for (int i = 0; (server = wlserver_get_xwayland_server(i)); i++)
{ {
gamescope_xwayland_server_t *server = wlserver_get_xwayland_server(i); x11_set_selection_owner(server->ctx.get(), contents, selection);
xwayland_ctx_t *ctx = server->ctx.get();
x11_set_selection(ctx, contents, selection);
} }
} }