python - Save and restore window size and position when using HeaderBar -


in application, i’d restore position , sizes of application windows after restart. currently, i’m using gtk.window.get_size() , gtk.window.get_position() obtain size , position, , gtk.window.resize() , gtk.window.move() restore them.

this worked @ first, now, i’ve changed application use gtk.headerbar, , neither position nor size correct anymore.

the documentation gtk.window.get_position() states expected behavior. says

the correct mechanism support session management protocol (see “gnomeclient” object in gnome libraries example) , allow window manager save window sizes , positions.

but don‘t know how works or how implement it.

so, how save , restore window position , size when using headerbar? portable solution best, @ least x11 , wayland should supportable.

there have been various issues gtk_window_get_size(), gtk_window_set_size() , client side decorations have been fixed gtk+ 3.20 — see the release notes 3.20 version.

make sure you're using latest stable version of gtk+ if want restore size of window, , never use allocated size, size returned gtk_window_get_size(). it's important note should not query window's state during destruction, whenever state changes. see, instance, saving window state page on gnome wiki.

as position: should aware global coordinate systems not available on wayland (and mir), , cannot query position of window on screen, nor set manually on windowing system.

the gnomeclient api has long since been deprecated, , state saving part of session management not work. documentation needs fixed.


Comments