Bug 188264

Summary: [patch] No way to paste primary selection in GTK Programs using x11-toolkits/gtk20 and x11/toolkits/gtk30
Product: Ports & Packages Reporter: Anonymized Account <no-reply>
Component: Individual Port(s)Assignee: freebsd-gnome (Nobody) <gnome>
Status: Closed FIXED    
Severity: Affects Only Me CC: jbeich
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugzilla.gnome.org/show_bug.cgi?id=643391
Attachments:
Description Flags
gtk-shiftinsert.tar
none
x11-toolkits/gtk20
none
x11-toolkits/gtk30
none
x11-toolkits/gtk20
none
x11-toolkits/gtk30
none
x11-toolkits/gtk30, upstream version
none
gtk30 log, upstream version
none
x11-toolkits/gtk20, upstream version
none
gtk20 log, upstream version
none
x11-toolkits/gtk30 3.14.7 none

Description Anonymized Account freebsd_committer freebsd_triage 2014-04-04 20:00:00 UTC
Shift-Insert is not pasting primary selection. Instead, it is bound to paste the
clipboard (for which Control-V is already used). Hence, there is no
keyboard-only way to insert primary selection. One must drag the mouse to there
and middle click. This makes interaction between terminals and GTK
uncomfortable.

Fix: Compile with the patches included.
How-To-Repeat: 1. Select someting in terminal emulator (tested: xterm, urxvt).
2. Switch to a GTK-based program, select an entry field.
3. Press Shift-Insert, also try Control-V, - observe no response.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2014-04-04 23:39:54 UTC
State Changed
From-To: open->open

Rescue this PR from the 'pending' category. 


Comment 2 Mark Linimon freebsd_committer freebsd_triage 2014-04-04 23:39:54 UTC
Responsible Changed
From-To: gnats-admin->gnome
Comment 3 Anonymized Account freebsd_committer freebsd_triage 2014-10-14 15:51:10 UTC
Created attachment 148305 [details]
x11-toolkits/gtk20
Comment 4 Anonymized Account freebsd_committer freebsd_triage 2014-10-14 15:51:40 UTC
Created attachment 148306 [details]
x11-toolkits/gtk30
Comment 5 Anonymized Account freebsd_committer freebsd_triage 2014-10-14 15:54:17 UTC
Made the fix use "SHIFT_INSERT_FIX" knob. Also added NLS knob.
Comment 6 Jan Beich freebsd_committer freebsd_triage 2014-10-19 04:09:47 UTC
> +.if ${PORT_OPTIONS:MSHIFT_INSERT_FIX}
> +EXTRA_PATCHES=	${FILESDIR}/extra-patch-gtk_gtkentry.c \
> +	${FILESDIR}/extra-patch-gtk_gtkentry.h \
> +	${FILESDIR}/extra-patch-gtk_gtktextview.c \
> +	${FILESDIR}/extra-patch-gtk_gtktextview.h
> +.endif
> +

The files are not present in the patch. Both gtk20 and gtk30. Did you forget to |svn add| before |svn diff|?
Comment 7 Anonymized Account freebsd_committer freebsd_triage 2014-10-19 05:32:37 UTC
Sorry, will fix.
Comment 8 Anonymized Account freebsd_committer freebsd_triage 2014-10-19 05:33:02 UTC
Created attachment 148459 [details]
x11-toolkits/gtk20
Comment 9 Anonymized Account freebsd_committer freebsd_triage 2014-10-19 05:34:11 UTC
Created attachment 148460 [details]
x11-toolkits/gtk30
Comment 10 Jan Beich freebsd_committer freebsd_triage 2014-11-22 13:23:26 UTC
Patches need to be rebased after Gnome 3.14.1 landed in ports r372768. And it seems they're different from those in upstream bug.
Comment 11 Jan Beich freebsd_committer freebsd_triage 2014-11-22 17:37:14 UTC
Created attachment 149715 [details]
x11-toolkits/gtk30, upstream version

The implementation from that bug + shift-insert fix from here. files/patch-gnome-bug643391 is applied unconditionally as it only provides "paste-selection" for custom keybindings. Notable difference is being able to bind GDK_SELECTION_SECONDARY.
Comment 12 Jan Beich freebsd_committer freebsd_triage 2014-11-22 17:40:17 UTC
Created attachment 149716 [details]
gtk30 log, upstream version
Comment 13 Jan Beich freebsd_committer freebsd_triage 2014-11-22 18:05:46 UTC
Created attachment 149723 [details]
x11-toolkits/gtk20, upstream version
Comment 14 Jan Beich freebsd_committer freebsd_triage 2014-11-22 18:07:01 UTC
Created attachment 149724 [details]
gtk20 log, upstream version
Comment 15 Jan Beich freebsd_committer freebsd_triage 2014-11-22 18:21:17 UTC
With www/firefox both versions work fine in open/save dialog and fail elsewhere:

(firefox:61133): Gtk-CRITICAL **: IA__gtk_widget_get_clipboard: assertion 'gtk_widget_has_screen (widget)' failed

(firefox:61133): Gtk-CRITICAL **: IA__gtk_clipboard_request_text: assertion 'clipboard != NULL' failed

or (GTK3 option)

(firefox:61465): Gtk-CRITICAL **: gtk_widget_get_clipboard: assertion 'gtk_widget_has_screen (widget)' failed

(firefox:61465): Gtk-CRITICAL **: gtk_clipboard_request_text: assertion 'clipboard != NULL' failed
Comment 16 Anonymized Account freebsd_committer freebsd_triage 2014-12-28 07:51:29 UTC
Been working fine here, so far.
Comment 17 Anonymized Account freebsd_committer freebsd_triage 2015-01-16 10:36:42 UTC
Created attachment 151732 [details]
x11-toolkits/gtk30 3.14.7

Positions to patch have changed again
Comment 18 Anonymized Account freebsd_committer freebsd_triage 2016-07-02 12:15:19 UTC
The problem with this patch is, in some programs for whatever reason it still does not work, likely because they use own key bindings. And GNOME folks, as well as some authors of GTK-based programs are never going to admit there is a problem with that.


In case someone stumbles upon this, there are two workarounds that are better than the solution: they work across all GUI toolkits, as not only GTK seems to suffer from the same problem.


A) Sync primary selection and clipboard manually.

Assign window manager key bindings for x11/xsel-conrad (x11/xsel might work, too):

$ xsel -p | xsel -b -i # Copy from primary to clipboard
$ xsel -b | xsel -p -i # Copy from clipboard to primary


B) Sync automatically.

This seems the best way. Has been around since at least 2009, but for some reason is rarely if ever mentioned: https://bbs.archlinux.org/viewtopic.php?id=22682 .

Run two instances of deskutils/autocutsel:

$ autocutsel -selection CLIPBOARD -fork
$ autocutsel -selection PRIMARY -fork