GTK selection bugs

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

GTK selection bugs

#1 Post by MochiMoppel »

Left click bug
After shutting down parcellite I noticed that something is wrong with middle mouse button pasting. It turned out that this is what someone described as the Left-click clears PRIMARY buffer bug. I checked with the newest tahrpup. The bug is still there. Most users will not notice as the presence of a clipboard manager like parcellite or clipit miraculously "fixes" the bug. Anyway, it's a bug I can live with.

Variable bug
This is more serious and haven't found a cure or work around. I would be grateful for any help.

The problem arises when assigning a selection to a variable or directly to a widget. Something like
SELECTION=$(xclip -o) will assign the contents of the X selection (PRIMARY) buffer to the variable SELECTION. Used in a Gtkdialog code this works as expected after the user made a selection in a different window. Gtkdialog will then put the selection content into the variable SELECTION. However this does not work and causes Gtkdialog to freeze when the selection was made in the Gtkdialog window itself. Apparently this is not a xclip bug because it also happens with similar selection tools like xsel.

To confirm, that this is a GTK bug and not a Gtkdialog bug I checked with my recent YAD form demo code. When a user selects files in ROX-Filer and then pushes the "Refresh file list" button", the file names will appear in the form. When the user selects something else , e.g. text in a Geany window and then pushes the button,YAD will show an info text. However when the user selects something in the YAD form and then pushes the button, YAD will freeze (to test this, run the code from a console because it will not be possible anymore to close the YAD window. Close the console instead).

The same thing happens in Gtkdialog. Below a small example, this time using the clipboard (and for obvious reasons executed in a console window :wink: ). Copy some text in a different window and then push the "Paste" button. Should work without problems. Copying something from the dialog and pasting it to a different window will also work, but pushing the "Paste" button will make the dialog unresponsive. Any idea how I can prevent this?

Edit1: I was hoping that writing the selection/clipboard content to a file and then reading the file would prevent the bug, but this doesn't work. Already the attempt to write the X selection to a file (command: xclip -o > file) will trigger the bug.

Edit2: Writing the selection/clipboard content to a file and then reading the file can indeed be used as a work around if the xclip command is executed in a separate console window. This window may still freeze, but killing the window can be automated and at least the main dialog stays alive. Not a great solution, but it works.

Code: Select all

#!/bin/bash
echo -n '' | xclip	-selection clipboard	# clear clipboard
urxvt -e bash -c "echo -n '<window>
<vbox>
	<text label=\"Content of clipboard:\" selectable=\"true\"></text>
	<entry>
		<input>xclip -o	-selection clipboard</input>
		<variable>vENTRY</variable>
	</entry>
	<button has-focus=\"true\" label=\"Paste from clipboard\">
		<action>refresh:vENTRY</action>
	</button>
	<button cancel></button>
</vbox>
</window>'|gtkdialog -s"
Attachments
clipboard_test.png
(4.46 KiB) Downloaded 490 times
Last edited by MochiMoppel on Wed 15 Jun 2016, 01:53, edited 2 times in total.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#2 Post by 01micko »

I can confirm the 'variable' bug in slacko-630

While it is certainly possible that this is a gtk/gdk (or even glib) bug it is also entirely possible that this is an xlib bug.

After all, copying to the clipboard is an x-server task.

I've no idea where to start looking! It would be nice if we could confirm the bug in the qt or even the fltk toolkits. That would certainly narrow it down.

EDIT: I can confirm it bugs out with gtk+-3.0 as well.
Last edited by 01micko on Mon 13 Jun 2016, 21:45, edited 1 time in total.
Puppy Linux Blog - contact me for access

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

Re: GTK selection bugs

#3 Post by Sailor Enceladus »

MochiMoppel wrote:Left click bug
After shutting down parcellite I noticed that something is wrong with middle mouse button pasting. It turned out that this is what someone described as the Left-click clears PRIMARY buffer bug. I checked with the newest tahrpup. The bug is still there. Most users will not notice as the presence of a clipboard manager like parcellite or clipit miraculously "fixes" the bug. Anyway, it's a bug I can live with.
I don't know if this is related, but sometimes when I copy stuff with right-click copy or Ctrl-C (into parcellite I guess?) it works when I paste it, and sometimes it doesn't work at all, like I never even copied it in the first place. The times when it works or doesn't seem to be random, and doing it again to same block of text sometimes works when it didn't the last time - lol. I know these things are never random and there is always a source of the problem though, maybe I'll read your buffer link in a bit.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#4 Post by MochiMoppel »

01micko wrote:I can confirm the 'variable' bug in slacko-630
Hmm...with what did you confirm? I tried 630 but couldn't find xclip or any replacement. Did you remove it on purpose?

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#5 Post by 01micko »

MochiMoppel wrote:
01micko wrote:I can confirm the 'variable' bug in slacko-630
Hmm...with what did you confirm? I tried 630 but couldn't find xclip or any replacement. Did you remove it on purpose?
Hmm.. it _may_ have been left out inadvertently :oops: but it is in subsequent beta releases (running slacko64-6.3.0.3 right now). Nevertheless, the bug shows its face. I'm still wondering if it's an xlib bug.
Puppy Linux Blog - contact me for access

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#6 Post by MochiMoppel »

01micko wrote: it _may_ have been left out inadvertently
I'm relieved :lol:
It seems that it never worked right. Checked with Puppy4.2 where the bug behaved less mean: xclip -o returns an empty string, but otherwise the dialog stays alive and can be shut normally. But there is another show stopper: xclip -o works only once. It returns the selection made outside the current window, and it returns an empty string for the selection made inside the current window, but that's it. Even when selections are changed, xclip -o would return whatever it returned the first time. It is as if GTK had saved the primary selection. Very strange. While this is going on, xclip keeps working normally in a console window.

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

Re: GTK selection bugs

#7 Post by Sailor Enceladus »

Thought I fixed the "copy buffer disappearing" by disabling Parcellite but it can happen either way (with it on or off). Meh.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#8 Post by MochiMoppel »

The bug still exists but I now found a workaround :D
Needs a temporary file and the xclip command must be finished with '&'. Trying <input> to echo xclip output directly into the entry widget would cause gtkdialog to freeze.

Code: Select all

#!/bin/bash
## Workaround for the GTK Selection bug http://www.murga-linux.com/puppy/viewtopic.php?t=107159
echo -n '<window><vbox>
<text label="Text copied from this label (and not only text copied from other running applications) should be pastable with below icon" selectable="true"></text> 
<entry secondary-icon-stock="gtk-clear" secondary-icon-tooltip-text="clear & paste from clipboard"> 
	<variable>vENTRY</variable>
	<input file>/tmp/clipcontent</input> 
	<action signal="secondary-icon-press">xclip -o -selection clipboard > /tmp/clipcontent &</action>
	<action signal="secondary-icon-release">refresh:vENTRY</action>
	<action signal="secondary-icon-release">rm /tmp/clipcontent</action>
</entry> 
<button has-focus="true" label="Cancel"></button> 
</vbox></window>'| gtkdialog -s
Attachments
clear_entry_and_paste_clipboard_content.png
(5.43 KiB) Downloaded 116 times

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#9 Post by bigpup »

What specific versions of Puppy??
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

Post Reply