func to save/restore window position, size?

Danny Milosavljevic danny.milo at gmx.net
Tue Feb 10 20:42:33 CET 2004


Hi,

Am Die, den 10.02.2004 schrieb Jasper Huijsmans um 20:01:
> Op di 10-02-2004, om 19:48 schreef Danny Milosavljevic:
> > Hi,
> > 
> > I want to make my mixer window remember the last opened position & size.
> > 
> > So I wondered if there is a func in libxfcegui4 to do so (give window,
> > it hooks to it, saves pos&size&screen?&desktop on "destroy" signal, and
> > calls a callback, and restores pos&size&screen?&desktop on "map"?)
> > 
> > If not, I'll try to write one... it shouldn't be all that hard.
> > 
> > (only unknown stuff is, which signal is emitted right when I am allowed
> > to call gtk_window_move, and how to get/set the desktop/screen to be
> > used)
> > 
> > Maybe store sticky/unsticky status aswell ? (ok maybe I'm going
> > overboard now)
> > 
> > Thoughts / pseudo-code ? ;)
> > 
> > cheers,
> >   Danny
> > 
> 
> Hmm, I'm not convinced this should be a library function, actually. I
> can imagine different windows do different kind of things.

Dunno :) Just got the impression I'd like to have some programs open at
the same position&size they were last... but maybe it's not *that*
common to make it worth a lib function. (although I feel that I really
find it weird to have to do the remembering window pos&sizing for the
program manually... maybe I'm just lazy ;))

Hmm :) As for these special windows doing different things, they just
don't call the hook func then ? ;)

> 
> Just save the position (+ size + ...) on "destroy" and use that info
> when recreating the window. 

yep, want to do that.

Do I connect to destroy, call
  gtk_window_get_size (gtk help says I shouldn't though O_o)
  gtk_window_get_position
  gtk_window_get_gravity
, save that to my struct?

Which signal do I call gtk_window_set_gravity, gtk_window_move,
gtk_window_resize on if I want to automate the restore, and in what
order? (or does doing that before the gtk_widget_show (window) work only
?)

Also, if I move window to the right, close window, lessen screen
width/height (xrandr...), open window, and the window would be moved
off-screen or be too widthy or too heighty, is that clamped
automatically by the set functions, does it crash or does it just do
wrong things (go offscreen) ? ;)

I'd really die laughing if mixer restored itself at a position
offscreen, never to be accessed again :) (although the mixer floating in
thin air in the middle of the room would be cool ;))

> 
> Also, if you destroy a window it is gone, so the function won't work
> anymore, right? And if you hide it the information will still be there.
> Am I missing something?

Which function ?

In the new destroy handler, it will call the passed callback with the
position&size data as parameter, and after it finished, return. So in
the callback the data is valid and the window is (still) there (although
only the data is interesting for the callback, I think).

The callback will save the data to xml in my case.
The other case (loading) can be done before starting the whole process,
filling in the struct from the xml file (in my case).

attached a mini pseudo code (unfinished) ... you should get the idea by
that :)

cheers,
   Danny

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TODO_WINDOW_POS
Type: text/x-readme
Size: 990 bytes
Desc: not available
URL: <http://mail.xfce.org/pipermail/xfce4-dev/attachments/20040210/4030aae8/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://mail.xfce.org/pipermail/xfce4-dev/attachments/20040210/4030aae8/attachment.pgp>


More information about the Xfce4-dev mailing list