Bug 188264 - [patch] No way to paste primary selection in GTK Programs using x11-toolkits/gtk20 and x11/toolkits/gtk30
Summary: [patch] No way to paste primary selection in GTK Programs using x11-toolkits/...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-gnome mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-04 20:00 UTC by Michael Danilov
Modified: 2016-07-02 12:16 UTC (History)
1 user (show)

See Also:


Attachments
gtk-shiftinsert.tar (3.09 KB, text/plain)
2014-04-04 20:00 UTC, Michael Danilov
no flags Details
x11-toolkits/gtk20 (26.49 KB, patch)
2014-10-14 15:51 UTC, Michael Danilov
no flags Details | Diff
x11-toolkits/gtk30 (29.48 KB, patch)
2014-10-14 15:51 UTC, Michael Danilov
no flags Details | Diff
x11-toolkits/gtk20 (34.94 KB, patch)
2014-10-19 05:33 UTC, Michael Danilov
no flags Details | Diff
x11-toolkits/gtk30 (37.80 KB, patch)
2014-10-19 05:34 UTC, Michael Danilov
no flags Details | Diff
x11-toolkits/gtk30, upstream version (10.94 KB, patch)
2014-11-22 17:37 UTC, Jan Beich
no flags Details | Diff
gtk30 log, upstream version (236.43 KB, text/plain)
2014-11-22 17:40 UTC, Jan Beich
no flags Details
x11-toolkits/gtk20, upstream version (10.94 KB, patch)
2014-11-22 18:05 UTC, Jan Beich
no flags Details | Diff
gtk20 log, upstream version (84.58 KB, application/x-gzip)
2014-11-22 18:07 UTC, Jan Beich
no flags Details
x11-toolkits/gtk30 3.14.7 (11.03 KB, patch)
2015-01-16 10:36 UTC, Michael Danilov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Danilov 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 Michael Danilov 2014-10-14 15:51:10 UTC
Created attachment 148305 [details]
x11-toolkits/gtk20
Comment 4 Michael Danilov 2014-10-14 15:51:40 UTC
Created attachment 148306 [details]
x11-toolkits/gtk30
Comment 5 Michael Danilov 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 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 Michael Danilov 2014-10-19 05:32:37 UTC
Sorry, will fix.
Comment 8 Michael Danilov 2014-10-19 05:33:02 UTC
Created attachment 148459 [details]
x11-toolkits/gtk20
Comment 9 Michael Danilov 2014-10-19 05:34:11 UTC
Created attachment 148460 [details]
x11-toolkits/gtk30
Comment 10 Jan Beich freebsd_committer 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 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 2014-11-22 17:40:17 UTC
Created attachment 149716 [details]
gtk30 log, upstream version
Comment 13 Jan Beich freebsd_committer 2014-11-22 18:05:46 UTC
Created attachment 149723 [details]
x11-toolkits/gtk20, upstream version
Comment 14 Jan Beich freebsd_committer 2014-11-22 18:07:01 UTC
Created attachment 149724 [details]
gtk20 log, upstream version
Comment 15 Jan Beich freebsd_committer 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 Michael Danilov 2014-12-28 07:51:29 UTC
Been working fine here, so far.
Comment 17 Michael Danilov 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 Michael Danilov 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