Implement consistent primary selection handling for X11

Bug #1794623 reported by Olivier
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Wishlist
Ian McInerney

Bug Description

Hello,

On my Debian Linux, with KiCad 5.0.0, I experience the following bug:

When selecting a numerical value with the mouse (typically from a property window), the value fills the "clipboard buffer", but at the same time, the "primary selection" is emptied. The latter shouldn't happen and the "primary selection" should equally be filled with the value. As a consequence of this bug, the numerical values can not be pasted with the middle mouse button in other applications.

Can you reproduce?

Best regards,

Olivier

Example 1:
In Eeschema, open the property dialog of a label, and copy the content of the filed "Size".
Result:
$ xclip -selection primary -o
Error: target STRING not available # <-- THIS IS A PROBLEM
$ xclip -selection clipboard -o
1.5

Example 2:
In Pcbnew, open the property dialog of a footprint, and copy the content of the field "Width"
Result:
$ xclip -selection primary -o
Error: target STRING not available # <-- THIS IS A PROBLEM
$ xclip -selection clipboard -o
1

Note:
The bug does not happen with text values. Only with numerical values.

---
Application: kicad
Version: 5.0.0+dfsg1-2, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.60.0 OpenSSL/1.1.0e zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) libssh2/1.7.0 nghttp2/1.27.0 librtmp/2.3
Platform: Linux 4.14.0-3-amd64 x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
    Boost: 1.62.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.61.0
    Compiler: GCC 8.2.0 with C++ ABI 1013

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=OFF

Tags: gtk ui
Seth Hillbrand (sethh)
Changed in kicad:
importance: Undecided → Wishlist
status: New → Triaged
summary: - X Window primary selection becomes empty when selecting numerical values
+ Implement consistent primary selection handling for X11
Revision history for this message
Ian McInerney (imcinerney) wrote :

This looks to have been fixed at some point, since I can't reproduce the original test case in either 5.1.4 or master.

Changed in kicad:
status: Triaged → Fix Committed
Revision history for this message
Ian McInerney (imcinerney) wrote :

Whoops, spoke to soon. It looks like this is only a problem if the string is only numbers, and works if there is text in it.

Changed in kicad:
status: Fix Committed → Triaged
tags: added: gtk
removed: linux
Revision history for this message
Ian McInerney (imcinerney) wrote :

Looks like this is being caused by the unit binder in the text controls. When it parses the text, it will update the text in the control with the result. This causes the selection to be lost.

@devs, what are your thoughts on preserving the selection? Since it changes the information in the field, we can't guarantee that the same digits are even in there (for instance, it will convert mm to in for the control). I think the most we could do is to select everything in the control if there is a selection in the original text, or just mark this as won't fix for these controls.

Revision history for this message
Jeff Young (jeyjey) wrote :

The UNIT_BINDER does more than just parsing. It will also evaluate (for instance, 3 + 4 will become 7).

Selecting the (entire) result makes sense to me. But I don't use X11, so I'm happy with "Won't Fix" too. ;)

Revision history for this message
Ian McInerney (imcinerney) wrote :

I found another alternative, we can load the primary selection clipboard with our own data and not rely on GTK to do it for us.

In the attached patch I have made it so the primary clipboard is loaded with the selected portion of the original string after we replace the string in the text entry. This makes the selection available to other programs, and also is exactly what the user selected (otherwise, selecting after we replace would give them the evaluated string not what they entered). It also saves/restores the selection extents for the text entry across the set/kill focus events (since the original text is also restored).

Changed in kicad:
assignee: nobody → Ian McInerney (imcinerney)
Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision 2b387f4b4d472fa90f9ea548a56334eaec035f42
https://git.launchpad.net/kicad/patch/?id=2b387f4b4d472fa90f9ea548a56334eaec035f42

Changed in kicad:
status: Triaged → Fix Committed
Revision history for this message
Seth Hillbrand (sethh) wrote :

Looks good Ian. Thanks!

Changed in kicad:
milestone: none → 5.1.5
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.