Skip to content

Commit

Permalink
#4441 re-claim the clipboard selection whenever we get a token
Browse files Browse the repository at this point in the history
this can be disabled by setting XPRA_CLIPBOARD_RECLAIM=0
  • Loading branch information
totaam committed Dec 13, 2024
1 parent 885a52f commit faf1e5c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions xpra/x11/gtk_x11/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import List, Dict, Tuple, Iterable, Callable, Any
from gi.repository import GLib, GObject, Gdk # @UnresolvedImport

from xpra.util import envbool
from xpra.gtk_common.error import xsync, xswallow
from xpra.gtk_common.gobject_util import one_arg_signal, n_arg_signal
from xpra.gtk_common.gtk_util import get_default_root_window
Expand Down Expand Up @@ -48,6 +49,8 @@

MAX_DATA_SIZE : int = 4*1024*1024

RECLAIM = envbool("XPRA_CLIPBOARD_RECLAIM", True)

BLACKLISTED_CLIPBOARD_CLIENTS: List[str] = os.environ.get(
"XPRA_BLACKLISTED_CLIPBOARD_CLIENTS",
"clipit,Software,gnome-shell"
Expand Down Expand Up @@ -187,15 +190,14 @@ def claim(self) -> None:
try:
with xsync:
owner = X11Window.XGetSelectionOwner(self._selection)
if owner==self.xid:
self.owned = True
log("claim() we already own the '%s' selection", self._selection)
return
setsel = X11Window.XSetSelectionOwner(self.xid, self._selection, time)
owner = X11Window.XGetSelectionOwner(self._selection)
self.owned = owner==self.xid
log("claim_selection: set selection owner returned %s, owner=%#x, owned=%s",
setsel, owner, self.owned)
if RECLAIM or not self.owned:
setsel = X11Window.XSetSelectionOwner(self.xid, self._selection, time)
owner = X11Window.XGetSelectionOwner(self._selection)
self.owned = owner == self.xid
log("claim_selection: set selection owner returned %s, owner=%#x, owned=%s",
setsel, owner, self.owned)
else:
log("we already owned the %r selection", self._selection)
if not self.owned:
log.warn("Warning: we failed to get ownership of the '%s' clipboard selection", self._selection)
return
Expand Down

0 comments on commit faf1e5c

Please sign in to comment.