setting uposition() and move() values for multi screen PC’s
Further to my last post about PHP-GTK and positioning an application on a screen…
I have also discovered that,
- if you have 2 screens on a Windows XP PC
- where screen B extends screen A horizontally
Then,
The GDK screen width is the screen width of A plus screen width of B.
Also
- If you turn off screen B
- Then, close down the GTK application
- Then, re-start the GTK application again…
…the GDKScreen size is still the same as before.
This implies that the screen dimensions are set at the start-up of the operating system and for screen dimension changes to take effect one must re-start the computer or reset the values via the MS screen properties dialogue.
Furthermore, as a two-screen-PC-user I find that having applications appear in the centre of the screen((width of screen A + width of screen B) / 2) is quite an annoying place for the application to be positioned. In effect, it puts it half on one screen and half on the other.
I’m not sure if its possible to determine the number of screens via some environment variable. I guess if the total screen width is over n pixels then it might be sensible to place it off centre.

Also, if screen A is not the same height as screen B, then the derived GDK screen height value may be misleading. If the bottoms of both screens are flush, the official screen height might be set to the height of screen B. Or, if the screen B is positioned lower than screen A, the screen height might even be set to (the height of screen B) + (the offset value of between top of screen B and top of screen A).
All of these nuances make me wonder if there is not some tried and tested formula or UI pattern for positioning a window upon start-up. Perhaps you know of some ‘window start-up positioning class’ that is freely available out there. Or is it just best to leave these things to the OS? Feel free to add a comment below.
Aaaaaah!
Using:
$winodw->set_position(gtk::WIN_POS_CENTER);
This centers the window in the active screen. That makes things a lot easier.
See: http://gtk.php.net/manual/en/gtk.enum.windowposition.php
