Solved Keep an application window always on top

Hi,

I wrote a little RubyTk application to keep track of different times in world
timezones I need to be aware of. Picture attached.

I have a problem, the application should stay always above all other
windows in all desktops. It does so for a while, but after many hours
of work it happens that basically all applications window start to lay
above it !

In am using WindowMaker in FreeBSD-11.2

This is the Window configuration in Tk, the best I cound find:
Code:
$root = TkRoot.new { borderwidth 1; relief "solid";  wm_overrideredirect true ;
                     wm_attributes :type => "utility", :topmost => true  }

bye
Nicola


6157
 
I'm not familiar with Ruby, but with Python + Tkinter + X11 + Xlib. I assume that it all works very similar, so the following might be helpful nonetheless.

X11 can report certain events: The VisibilityNotify event is sent when your window is obscured by another window (fully or partially). Alternatively, the ConfigureNotify event is sent when the stacking order of your window changes (among other things), e. g. when another window is moved on top of it. For details, see the Xlib Programming Manual (links):
 • VisibilityNotify Event
 • ConfigureNotify Event
I'm sure that RubyTk supports X11 events. Please refer to its documentation to find out how to do that. Once you receive such an event, just move the window back to the top. With the standard Xlib, that can be done with the XRaiseWindow() function; the RubyTk equivalent is probably similar.
 
I was lucky with these commands, basically toggling the "toplevel" state from time to time.

Code:
 $root.attributes("topmost",false)
 $root.attributes("topmost",true)
# extra  
# $root.raise

I am convinced this unusual behaviour is related to sleep/unsleep the virtual machine. (my FreeBSD on laptop lives inside a VirtualBox VM). In any case the 3 lines above are enough to work around it.

bye
 
Back
Top