Merge branch 'master' into soc-2019-openxr
authorJulian Eisel <eiseljulian@gmail.com>
Thu, 11 Jul 2019 17:26:30 +0000 (19:26 +0200)
committerJulian Eisel <eiseljulian@gmail.com>
Thu, 11 Jul 2019 18:28:19 +0000 (20:28 +0200)
1  2 
release/scripts/startup/bl_ui/space_topbar.py
source/blender/blenkernel/BKE_global.h
source/blender/blenloader/intern/readfile.c
source/blender/draw/intern/draw_manager.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c

index 4c0f66f714a08da291f6e3fa207000897315d4d0,d17b88176913f39a86e4131c97fbd2a706daed7c..42c372855ca91f7bddae224794150c734da5943d
@@@ -708,77 -685,63 +708,83 @@@ static void wm_window_ghostwindow_ensur
  #endif
    }
  
 -  for (win = wm->windows.first; win; win = win->next) {
 -    if (win->ghostwin == NULL) {
 -      if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
 -        win->posx = wm_init_state.start_x;
 -        win->posy = wm_init_state.start_y;
 -        win->sizex = wm_init_state.size_x;
 -        win->sizey = wm_init_state.size_y;
 -
 -        if (wm_init_state.override_flag & WIN_OVERRIDE_GEOM) {
 -          win->windowstate = GHOST_kWindowStateNormal;
 -          wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM;
 -        }
 -        else {
 -          win->windowstate = GHOST_WINDOW_STATE_DEFAULT;
 -        }
 -      }
 +  if (win->ghostwin == NULL) {
 +    if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
 +      win->posx = wm_init_state.start_x;
 +      win->posy = wm_init_state.start_y;
 +      win->sizex = wm_init_state.size_x;
 +      win->sizey = wm_init_state.size_y;
  
 -      if (wm_init_state.override_flag & WIN_OVERRIDE_WINSTATE) {
 -        win->windowstate = wm_init_state.windowstate;
 -        wm_init_state.override_flag &= ~WIN_OVERRIDE_WINSTATE;
 +      if (wm_init_state.override_flag & WIN_OVERRIDE_GEOM) {
 +        win->windowstate = GHOST_kWindowStateNormal;
 +        wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM;
        }
 -
 -      /* without this, cursor restore may fail, T45456 */
 -      if (win->cursor == 0) {
 -        win->cursor = CURSOR_STD;
 +      else {
 +        win->windowstate = GHOST_WINDOW_STATE_DEFAULT;
        }
 -
 -      wm_window_ghostwindow_add(wm, "Blender", win);
      }
  
 -    if (win->ghostwin != NULL) {
 -      /* If we have no ghostwin this is a buggy window that should be removed.
 -       * However we still need to initialize it correctly so the screen doesn't hang. */
 +    if (wm_init_state.override_flag & WIN_OVERRIDE_WINSTATE) {
 +      win->windowstate = wm_init_state.windowstate;
 +      wm_init_state.override_flag &= ~WIN_OVERRIDE_WINSTATE;
 +    }
  
 -      /* happens after fileread */
 -      wm_window_ensure_eventstate(win);
 +    /* without this, cursor restore may fail, T45456 */
 +    if (win->cursor == 0) {
 +      win->cursor = CURSOR_STD;
      }
  
 -    /* add keymap handlers (1 handler for all keys in map!) */
 -    keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0);
 -    WM_event_add_keymap_handler(&win->handlers, keymap);
 +    wm_window_ghostwindow_add(wm, "Blender", win, context_type);
 +  }
-   /* happens after fileread */
-   wm_window_ensure_eventstate(win);
 -    keymap = WM_keymap_ensure(wm->defaultconf, "Screen", 0, 0);
 -    WM_event_add_keymap_handler(&win->handlers, keymap);
++  if (win->ghostwin != NULL) {
++    /* If we have no ghostwin this is a buggy window that should be removed.
++     * However we still need to initialize it correctly so the screen doesn't hang. */
 -    keymap = WM_keymap_ensure(wm->defaultconf, "Screen Editing", 0, 0);
 -    WM_event_add_keymap_handler(&win->modalhandlers, keymap);
++    /* happens after fileread */
++    wm_window_ensure_eventstate(win);
++  }
  
 -    /* add drop boxes */
 -    {
 -      ListBase *lb = WM_dropboxmap_find("Window", 0, 0);
 -      WM_event_add_dropbox_handler(&win->handlers, lb);
 -    }
 -    wm_window_title(wm, win);
 +  /* add keymap handlers (1 handler for all keys in map!) */
 +  keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0);
 +  WM_event_add_keymap_handler(&win->handlers, keymap);
  
 -    /* add topbar */
 -    ED_screen_global_areas_refresh(win);
 +  keymap = WM_keymap_ensure(wm->defaultconf, "Screen", 0, 0);
 +  WM_event_add_keymap_handler(&win->handlers, keymap);
 +
 +  keymap = WM_keymap_ensure(wm->defaultconf, "Screen Editing", 0, 0);
 +  WM_event_add_keymap_handler(&win->modalhandlers, keymap);
 +
 +  /* add drop boxes */
 +  {
 +    ListBase *lb = WM_dropboxmap_find("Window", 0, 0);
 +    WM_event_add_dropbox_handler(&win->handlers, lb);
 +  }
 +  wm_window_title(wm, win);
 +
 +  /* add topbar */
 +  ED_screen_global_areas_refresh(win);
 +}
 +
 +/**
 + * Initialize #wmWindow without ghostwin, open these and clear.
 + *
 + * window size is read from window, if 0 it uses prefsize
 + * called in #WM_check, also inits stuff after file read.
 + *
 + * \warning
 + * After running, 'win->ghostwin' can be NULL in rare cases
 + * (where OpenGL driver fails to create a context for eg).
 + * We could remove them with #wm_window_ghostwindows_remove_invalid
 + * but better not since caller may continue to use.
 + * Instead, caller needs to handle the error case and cleanup.
 + */
 +void wm_window_ghostwindows_ensure(wmWindowManager *wm)
 +{
 +  BLI_assert(G.background == false);
 +
 +  for (wmWindow *win = wm->windows.first; win; win = win->next) {
 +    wm_window_ghostwindow_ensure(wm, win, GHOST_kDrawingContextTypeOpenGL);
    }
  }