[AD] Centering the Allegro window on the Windows desktop

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


The attached patch by gnolam makes the Allegro window always be centred on 
the Windows desktop when it's created. I think this makes sense, so if no 
one objects I'm going to apply it tomorrow after some testing.
At the very least, I think the window should reappear centred if a graphics 
mode is set after set_gfx_mode(GFX_TEXT,...) has been called, as this 
should restore the graphics system to an uninitialized state.

See this thread for further details: http://www.allegro.cc/forums/
view_thread.php?_id=452581#target

Evert
--- wwnd.c.old	Thu Sep 30 21:01:00 2004
+++ wwnd.c	Sat Jan 22 19:59:55 2005
@@ -582,16 +582,14 @@
    RECT working_area, win_size;
 
    if (!user_wnd) {
-      if (last_wnd_x < 0) {
-         /* first window placement: try to center it */
-         SystemParametersInfo(SPI_GETWORKAREA, 0, &working_area, 0);
-         last_wnd_x = (working_area.left + working_area.right - w)/2;
-         last_wnd_y = (working_area.top + working_area.bottom - h)/2;
+      /* window placement: try to center it */
+      SystemParametersInfo(SPI_GETWORKAREA, 0, &working_area, 0);
+      last_wnd_x = (working_area.left + working_area.right - w)/2;
+      last_wnd_y = (working_area.top + working_area.bottom - h)/2;
 
 #ifdef ALLEGRO_COLORCONV_ALIGNED_WIDTH
-         last_wnd_x &= 0xfffffffc;
+      last_wnd_x &= 0xfffffffc;
 #endif
-      }
 
       win_size.left = last_wnd_x;
       win_size.top = last_wnd_y;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/