better not process events early, could cause troubles later.

added a function - wm_window_get_size_ghost(), which looks into the ghost window directly so events dont need processing first.
This commit is contained in:
Campbell Barton
2009-11-30 14:10:46 +00:00
parent ab4a141560
commit b911d83091
5 changed files with 16 additions and 9 deletions

View File

@@ -320,7 +320,11 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
int startx, starty; int startx, starty;
int width, height; 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); ui_bounds_block(block);

View File

@@ -161,10 +161,6 @@ void WM_init_splash(bContext *C)
if(wm->windows.first) { if(wm->windows.first) {
CTX_wm_window_set(C, 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); WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, NULL);
CTX_wm_window_set(C, prevwin); CTX_wm_window_set(C, prevwin);
} }

View File

@@ -936,6 +936,15 @@ void wm_window_get_size(wmWindow *win, int *width_r, int *height_r)
*height_r= win->sizey; *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) void wm_window_set_size(wmWindow *win, int width, int height)
{ {
GHOST_SetClientSize(win->ghostwin, width, height); GHOST_SetClientSize(win->ghostwin, width, height);

View File

@@ -50,6 +50,7 @@ void wm_window_raise (wmWindow *win);
void wm_window_lower (wmWindow *win); void wm_window_lower (wmWindow *win);
void wm_window_set_size (wmWindow *win, int width, int height); 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 (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_get_position (wmWindow *win, int *posx_r, int *posy_r);
void wm_window_set_title (wmWindow *win, char *title); void wm_window_set_title (wmWindow *win, char *title);
void wm_window_swap_buffers (wmWindow *win); void wm_window_swap_buffers (wmWindow *win);

View File

@@ -890,11 +890,8 @@ int main(int argc, char **argv)
WM_exit(C); WM_exit(C);
} }
if(!G.background && !file_loaded) { if(!G.background && !file_loaded)
/* careful, calls wm_window_process_events but seems safe
* since its called first in WM_main */
WM_init_splash(C); WM_init_splash(C);
}
WM_main(C); WM_main(C);