Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 25 May 2016, 09:24
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Weird gtkdialog bug [SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 983
Location: Japan

PostPosted: Thu 04 Sep 2014, 09:00    Post subject:  Weird gtkdialog bug [SOLVED]
Subject description: Dialog pops-up, dies immediately
 

I need a dialog that
- has a defined height
- opens at current mouse position
- exits when it loses focus (e.g. user clicks outside of dialog)

Something like this:
Code:
export DIALOG='
<window  height-request="200" window-position="2">
<button ok></button>
<action signal="focus-out-event">Exit:0</action>
</window>'
gtkdialog -p DIALOG


This code does not work when no other windows are open in current desktop (or all other windows are minimized) and the dialog is called from a keyboard shortcut or ROX panel. However it works when the mouse pointer is over the JWM tray. It also works on such otherwise empty desktop when any one of the conditions
- window-position="2"
- height-request
- action signal="focus-out-event"
is removed. It also works when height is set to a smaller size or window-position set to 1

On desktops where at least one other window exists everything works as expected. Any idea how to prevent this bug?
 
 
 

Last edited by MochiMoppel on Mon 14 Mar 2016, 01:42; edited 2 times in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4248
Location: Ontario

PostPosted: Thu 04 Sep 2014, 17:49    Post subject:  

Just a guess…

Have you tried putting a frame inside the window and giving
it some width and height request??? I've noticed that frames
make gtkdialog act more reliably.

I've also added in other widgets such as text widgets
as a way of getting a minimum height. That is a method to avoid

height-request="200"
_________________________________

Maybe adding
<hseparator></hseparator>

or

<vseparator></vseparator>

would make it act different??


__________________________
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 983
Location: Japan

PostPosted: Tue 09 Sep 2014, 00:40    Post subject:  

don570 wrote:
Have you tried putting a frame inside the window and giving it some width and height request???
width and height for a frame?

No, nothing works. I think the problem is that gtkdialog and the window managers have different ideas what constitutes a focus-out-event. For example this works differently in Openbox and JWM:
Code:
export DIALOG='
<window  skip_taskbar_hint="true" >
<button ok></button>
<action signal="focus-out-event">beep</action>
</window>'
gtkdialog -p DIALOG

Openbox would beep even when resizing the dialog window but would ignore when another window gets focus. Very strange.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4248
Location: Ontario

PostPosted: Tue 09 Sep 2014, 19:39    Post subject:  

Zigbert uses a separate app to make a right click pop up a window.
Examples : pfind and pmusic
However it does have a bug in Openbox window manager.

____________________________________________________
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 983
Location: Japan

PostPosted: Mon 14 Mar 2016, 01:39    Post subject: Re: Weird gtkdialog bug
Subject description: Dialog pops-up, dies immediately
 

MochiMoppel wrote:
On desktops where at least one other window exists everything works as expected. Any idea how to prevent this bug?
Yes, MochiMoppel Laughing

I finally figured out that this is a timing problem. When nothing else has focus I guess that JWM tries to switch focus immediately to the newly creating gtkdialog window, but for some settings gtkdialog needs time and when gtkdialog takes too long JWM loses patience and sends a focus-out event. Gtkdialog dies an untimely death.

The solution is to prevent a focus-out action while the gtkdialog window is still under construction. I save the start time in a variable and prevent any focus-out action for 50 centiseconds after start:
Code:
#!/bin/bash
export DIALOG='
<window  height-request="200" window-position="2">
<button ok></button>
<text visible="false">
   <variable>START</variable>
   <input>date +%s%2N</input>
</text>
<action signal="focus-out-event" condition="command_is_true(NOW=$(date +%s%2N);[ $((NOW-START)) -gt 50 ] && echo true)">Exit:0</action>
</window>'
gtkdialog -p DIALOG
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 628

PostPosted: Mon 14 Mar 2016, 10:01    Post subject:  

Fyi, the dialog you posted above doesn't behave as described in post #1. I'm on Fatdog64 with openbox and test the dialog by opening a Terminal window and typing
Code:

sh << EOF
#!/bin/bash
export DIALOG='
<window  height-request="200" window-position="2">
<button ok></button>
<text visible="false">
   <variable>START</variable>
   <input>date +%s%2N</input>
</text>
<action signal="focus-out-event" condition="command_is_true(NOW=$(date +%s%2N);[ $((NOW-START)) -gt 50 ] && echo true)">Exit:0</action>
</window>'
gtkdialog -p DIALOG
EOF

I see an OK box under the mouse pointer, move the mouse outside the window and nothing happens. Clicking the window under the OK box switches the active window but the OK box is still running. Clicking the OK button closes the OK box.

_________________
Fatdog64-702|+Packages|Findnrun|+forum|OpenMediaVault
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 983
Location: Japan

PostPosted: Sat 26 Mar 2016, 22:31    Post subject:  

step wrote:
Fyi, the dialog you posted above doesn't behave as described in post #1. I'm on Fatdog64 with openbox
step, thanks for testing. I checked again and your observations confirm what I already mentioned in my 2nd post: openbox interprets <action signal="focus-out-event"> differently. The original script "works" in openbox in the sense that it always opens the dialog, but then the dialog doesn't close as it should. Not a problem for me as I don't use openbox anymore.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0543s ][ Queries: 11 (0.0049s) ][ GZIP on ]