better not process events early, could cause troubles later.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 30 Nov 2009 14:10:46 +0000 (14:10 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 30 Nov 2009 14:10:46 +0000 (14:10 +0000)
added a function - wm_window_get_size_ghost(), which looks into the ghost window directly so events dont need processing first.

source/blender/editors/interface/interface.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm_window.h
source/creator/creator.c

index 23ad50d448b0628ec7b43b1636e782e0be0157f6..70bef5534a19be30e0b0e5f5db5d72ceef4e186e 100644 (file)
@@ -320,7 +320,11 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
        int startx, starty;
        int width, height;
        
-       wm_window_get_size(window, &xmax, &ymax);
+       /* note: this is used for the splash where window bounds event has not been
+        * updated by ghost, get the window bounds from ghost directly */
+
+       // wm_window_get_size(window, &xmax, &ymax);
+       wm_window_get_size_ghost(window, &xmax, &ymax);
        
        ui_bounds_block(block);
        
index d62ed7dd13a3bbd650cf15d2a8d6cccfb1044b88..09eecf2f4255fdd4c42a594dda058aae9bbf8717 100644 (file)
@@ -161,10 +161,6 @@ void WM_init_splash(bContext *C)
        
        if(wm->windows.first) {
                CTX_wm_window_set(C, wm->windows.first);
-
-               /* needed to get the right screen size for centering the splash */
-               wm_window_process_events(C);
-
                WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, NULL);
                CTX_wm_window_set(C, prevwin);
        }
index 78d70c96ad6956eb5e4bcba7d2dd5d13e9cbb9c0..75325a1d9f98d44a1b0ccadf0891fd3f9a8ce46e 100644 (file)
@@ -936,6 +936,15 @@ void wm_window_get_size(wmWindow *win, int *width_r, int *height_r)
        *height_r= win->sizey;
 }
 
+/* exceptional case: - splash is called before events are processed
+ * this means we dont actually know the window size so get this from GHOST */
+void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r)
+{
+       GHOST_RectangleHandle bounds= GHOST_GetClientBounds(win->ghostwin);
+       *width_r= GHOST_GetWidthRectangle(bounds);
+       *height_r= GHOST_GetHeightRectangle(bounds);
+}
+
 void wm_window_set_size(wmWindow *win, int width, int height) 
 {
        GHOST_SetClientSize(win->ghostwin, width, height);
index f0a2c0ec9a99873c68234b8e8121737e834e4576..4328f91510160ba034ce0b2f8ac595459dd404d8 100644 (file)
@@ -50,6 +50,7 @@ void          wm_window_raise                 (wmWindow *win);
 void           wm_window_lower                 (wmWindow *win);
 void           wm_window_set_size              (wmWindow *win, int width, int height);
 void           wm_window_get_size              (wmWindow *win, int *width_r, int *height_r);
+void           wm_window_get_size_ghost        (wmWindow *win, int *width_r, int *height_r);
 void           wm_window_get_position  (wmWindow *win, int *posx_r, int *posy_r);
 void           wm_window_set_title             (wmWindow *win, char *title);
 void           wm_window_swap_buffers  (wmWindow *win);
index f17cb95fe3f8465d6979ca8cd5ecbeed0efc7e34..3a9ee9859e8092bc9df2f5db84379a1a2f5d6cbd 100644 (file)
@@ -890,11 +890,8 @@ int main(int argc, char **argv)
                WM_exit(C);
        }
 
-       if(!G.background && !file_loaded) {
-               /* careful, calls wm_window_process_events but seems safe
-                * since its called first in WM_main */
+       if(!G.background && !file_loaded)
                WM_init_splash(C);
-       }
 
        WM_main(C);