kuthulux / gnome-connection-manager

repository for gnome-connection-manager from kuthulu.com/gcm
Other
68 stars 28 forks source link

Copy selection to clipboard erases on text un-select #44

Closed Hakun1n closed 3 years ago

Hakun1n commented 4 years ago

When you un-select the text in terminal by simple "click" OR select text in other application (like in text editor) so basically the selection gets UN-selected in GCM it actually WIPES OUT the clipboard buffer.

Steps to reproduce: 1] Enable "Copy selection to clipboard" in settings 2] Open GCM and also open some text editor (like geditr, xed, ... whatever) 3] Select some text in GCM (now it gets copied to clipboard buffer as well) 4] ALT+TAB to text editor and CTRL+V => Works OK 5] Go back to GCM and just CLICK somewhere so the text gets UN-selected 6] ALT+TAB to text editor an CTRL+V => NOTHING gets pasted (clipboard buffer is empty)

If you keep clipboad manager history open during the process you can clearly notice that the buffer gets emptied in step 5 when you click.

Alternative way to reproduce: 1] Enable "Copy selection to clipboard" in settings 2] Open GCM and also open some text editor (like geditr, xed, ... whatever). Put some text inside. 3] Select some text in GCM (now it gets copied to clipboard buffer as well) 4] ALT+TAB to text editor and CTRL+V => Works OK 5] Now SELECT that "sometext" from step 2] (At this point the selected text in GCM gets unselected) 6] Now CTRL+V => Again nothing gets pasted and the clipboard buffer is empty.

Expected behavior: "Losing selection" (=nothing is selected either by clicking or another application gets text selected) in GCM should not "copy nothig" and wipe the clipboard buffer. Only real text selection should put a new content to clipboard buffer.

OS: Fedora32 (Plasma)

Alex

kuthulux commented 4 years ago

using Ubuntu with unity and X11 here: I dont get that behaviour, the clipboard doesn't get cleared by clicking (in gcm or another app) or selecting text in another app using mouse or keyboard.

I think the clipboard gets cleared in your case because when the selection is changed (clear the selected text in the terminal by clicking or selecting text in another app) the new text is copied to the clipboard, and in this case that text is blank. In my case the clipboard just ignores the blank text, but in your case it is set as the clipboard content.

try this patch and let me know how it works.

diff --git a/gnome_connection_manager.py b/gnome_connection_manager.py
index 15119f8..7127017 100755
--- a/gnome_connection_manager.py
+++ b/gnome_connection_manager.py
@@ -765,8 +765,9 @@ class Wmain(SimpleGladeApp):
         return False

     def on_terminal_selection(self, widget, *args):
-        if conf.AUTO_COPY_SELECTION:
-            self.terminal_copy(widget)
+        if conf.AUTO_COPY_SELECTION:            
+            if widget.get_has_selection():
+                self.terminal_copy(widget)
         return True
Hakun1n commented 4 years ago

Hi, sorry for a bit late response. Anyway the provided patch FIXED the issue. Clicking in GCM or in any other app does not clear the clipboard any more. Also selecting text in any other app (which leads to un-select the text previously selected in GCM) does not clear the clipboard. Whatever was in clipboard from GCM stays there till i explicitly copy (via context or ctrl+c) or till i select another text in GCM.

Thanks a lot for a fix!!

Alex

pstast commented 4 years ago

I had the same problem - clipboard content is cleared whenever I click in terminal window or in any other window of any other application. Ubuntu 20.04.

I confirm that the above patch fixes the problem.

ksowa commented 3 years ago

@kuthulux your fix worked great in my case as well. I had the exact same issue after upgrading from Ubuntu 18.04 to 20.04.

Thank you!