Search for workspace size (screen size smaller than taskbar) using GTK

How to create a main window filling the entire desktop without covering (or covering) the taskbar and without maximizing it ? I can find the whole screen size and adjust the corresponding window as follows:

window = gtk.Window()
screen = window.get_screen()
window.resize(screen.get_width(), screen.get_height())

but the bottom of the window closes the taskbar.

+5
source share
2 answers

For this, you are completely dependent on your window manager, and the key problem here is:

without maximization

, , , , , .

, , , .

, :

import gtk

# Even I am ashamed by this
# Set up a one-time signal handler to detect size changes
def _on_size_req(win, req):
    x, y, w, h = win.get_allocation()
    print x, y, w, h   # just to prove to you its working
    win.disconnect(win.connection_id)
    win.unmaximize()
    win.window.move_resize(x, y, w, h)

# Create the window, connect the signal, then maximise it
w = gtk.Window()
w.show_all()
w.connection_id = w.connect('size-request', _on_size_req)
# Maximizing will fire the signal handler just once,
# unmaximize, and then resize to the previously set size for maximization.
w.maximize()

# run this monstrosity
gtk.main()
+9

All Articles