Ruby Tk "on top"


I’ve been wondering how to make a window fullscreen in Ruby Tk. I came
across this which is what I’m using now:

require ‘tk’
r = Tk.root
r.overrideredirect = true
r.geometry = “#{r.winfo_screenwidth}x#{r.winfo_screenheight}+0+0”
Tk.root.state = ‘zoomed’

However, in OS X, this “fullscreen” window still sits behind the dock
and menu bar. Is there some way to tell the window manager to put this
“on top” of everything, even the dock and menu bar? I had a look through
the Tk wm reference but couldn’t find anything very useful.


I’ve only played around with Ruby Tk on OS X only a little, but my
feeling is that Tk has no concept of a window manager having a screen-
top menu bar rather than window-top menu bars. And I’m pretty sure it
had no concept of a OS X style dock. Therefore, I think you will have
to live with the following:

  1. Hide the dock.
  2. Adjust your window geometry to exclude the OS X menu bar area.

Not what you want, I admit. Perhaps someone more knowledgeable than
me will reply with a better idea.

Regards, Morton

I think the guys did a good job integrating Tk with the OS X GUI, the
menu bar items actually end up on top (try add a TkMenubar item, it’ll
end up on top of the screen, and not on the window:) I don’t think Tk
has to take the geometry of the native GUI into consideration, since all
it needs to do is request “on-top-ness” from the WM, regardless of what
the WM GUI is like, whether it’s a dock, a taskbar, or a 3D virtual cube
:slight_smile: But yes, if I don’t find a real solution, the workaround would have
to be to hide the dock though some ugly hack (read Applescript… ugh!)
and resize the window accordingly.