Fix T51889: new file or load factory settings results in broken UI.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 7 Jul 2017 22:44:31 +0000 (00:44 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 7 Jul 2017 22:54:05 +0000 (00:54 +0200)
Fix some cases that still assumed there to be a global DPI, instead of a per
window DPI that needs to be set before reading U.dpi.

source/blender/blenfont/BLF_api.h
source/blender/blenfont/intern/blf.c
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/blender.c
source/blender/editors/screen/screen_edit.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_window.c
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

index 1f38d64924c88af54961c7141a70176506802993..8c8aef3de57fbae6e111d7232afa087c2888d7b4 100644 (file)
@@ -38,7 +38,7 @@ struct rctf;
 struct ColorManagedDisplay;
 struct ResultBLF;
 
-int BLF_init(int points, int dpi);
+int BLF_init(void);
 void BLF_exit(void);
 void BLF_default_dpi(int dpi);
 void BLF_default_set(int fontid);
index 132a0ec38086178cecf6394dbb4ca260b1ec820b..5bd62980b6da621b5b8d7fd66a02d0442b487a59 100644 (file)
@@ -96,15 +96,16 @@ static FontBLF *blf_get(int fontid)
        return NULL;
 }
 
-int BLF_init(int points, int dpi)
+int BLF_init(void)
 {
        int i;
 
        for (i = 0; i < BLF_MAX_FONT; i++)
                global_font[i] = NULL;
 
-       global_font_points = points;
-       global_font_dpi = dpi;
+       global_font_points = 11;
+       global_font_dpi = 72;
+
        return blf_font_init();
 }
 
index d55926ffb1eb65d688e4249ded7bc324f9e75a1b..ec0bfa6f5faafacb6bbf54ad33fbaf5a3bc0cb7f 100644 (file)
@@ -50,7 +50,6 @@ void BKE_blender_version_string(
 
 void BKE_blender_userdef_set_data(struct UserDef *userdef);
 void BKE_blender_userdef_free_data(struct UserDef *userdef);
-void BKE_blender_userdef_refresh(void);
 
 void BKE_blender_userdef_set_app_template(struct UserDef *userdef);
 
index ceb641073e0fea75a8026d57ec4f2cfcaedeb052..2624019e63ae59b7a72c7751830b6753b4ea8a42 100644 (file)
@@ -225,19 +225,6 @@ void BKE_blender_userdef_free_data(UserDef *userdef)
 #undef U
 }
 
-/**
- * Handle changes in settings that need refreshing.
- */
-void BKE_blender_userdef_refresh(void)
-{
-       /* prevent accidents */
-       if (U.pixelsize == 0) U.pixelsize = 1;
-       
-       BLF_default_dpi(U.pixelsize * U.dpi);
-       U.widget_unit = (U.pixelsize * U.dpi * 20 + 36) / 72;
-
-}
-
 /**
  * Write U from userdef.
  * This function defines which settings a template will override for the user preferences.
index 18f02aff482aa30969cc684d8bb66d1bce5c6506..f469686b0b220a4550eb863724c85562314dc2bc 100644 (file)
@@ -1228,6 +1228,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
                winrct.ymax = winsize_y - 1;
                
                /* header size depends on DPI, let's verify */
+               WM_window_set_dpi(win);
                screen_refresh_headersizes();
                
                screen_test_scale(win->screen, winsize_x, winsize_y);
index 492dec2cc10d1ea34fe4813a39dff335e22611ab..60a39b24208f1161753ce3d724d2afed8e0fd8d1 100644 (file)
@@ -103,6 +103,7 @@ enum {
 
 struct wmWindow        *WM_window_open(struct bContext *C, const struct rcti *rect);
 struct wmWindow *WM_window_open_temp(struct bContext *C, int x, int y, int sizex, int sizey, int type);
+void             WM_window_set_dpi(wmWindow *win);
                        
                        /* returns true if draw method is triple buffer */
 bool           WM_is_draw_triple(struct wmWindow *win);
index ae0b687a21a8969e1b9c49ca933e83bb4419b4f2..b4a6366fb4e306d71c5267afa131fbedd4e007dd 100644 (file)
@@ -342,8 +342,6 @@ static void wm_init_userdef(bContext *C, const bool read_userdef_from_memory)
 
        /* update tempdir from user preferences */
        BKE_tempdir_init(U.tempdir);
-
-       BKE_blender_userdef_refresh();
 }
 
 
index 9bafe72d80546b5f99018d0ca90e178df3871e94..00a9976e8be31019ad5e9da32356d6036cb303c2 100644 (file)
@@ -181,7 +181,7 @@ void WM_init(bContext *C, int argc, const char **argv)
        ED_file_init();         /* for fsmenu */
        ED_node_init_butfuncs();
        
-       BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
+       BLF_init(); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
        BLT_lang_init();
 
        /* Enforce loading the UI for the initial homefile */
index de169881bc4274b22be5130ce1e6b2d6eb21b20a..8afeb8e7b3d156b9f3dc7d2190ffa9c8e0a7554b 100644 (file)
@@ -375,7 +375,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
        }
 }
 
-static void wm_window_set_dpi(wmWindow *win)
+void WM_window_set_dpi(wmWindow *win)
 {
        int auto_dpi = GHOST_GetDPIHint(win->ghostwin);
 
@@ -406,8 +406,10 @@ static void wm_window_set_dpi(wmWindow *win)
        U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin) * pixelsize;
        U.dpi = dpi / pixelsize;
        U.virtual_pixel = (pixelsize == 1) ? VIRTUAL_PIXEL_NATIVE : VIRTUAL_PIXEL_DOUBLE;
+       U.widget_unit = (U.pixelsize * U.dpi * 20 + 36) / 72;
 
-       BKE_blender_userdef_refresh();
+       /* update font drawing */
+       BLF_default_dpi(U.pixelsize * U.dpi);
 }
 
 /* belongs to below */
@@ -483,7 +485,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
                }
                
                /* needed here, because it's used before it reads userdef */
-               wm_window_set_dpi(win);
+               WM_window_set_dpi(win);
                
                wm_window_swap_buffers(win);
                
@@ -870,7 +872,7 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
                GHOST_ActivateWindowDrawingContext(win->ghostwin);
                
                /* this can change per window */
-               wm_window_set_dpi(win);
+               WM_window_set_dpi(win);
        }
 }
 
@@ -1070,7 +1072,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
                                        WM_jobs_stop(wm, win->screen, NULL);
                                }
 
-                               wm_window_set_dpi(win);
+                               WM_window_set_dpi(win);
                                
                                /* win32: gives undefined window size when minimized */
                                if (state != GHOST_kWindowStateMinimized) {
@@ -1157,11 +1159,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
 
                        case GHOST_kEventWindowDPIHintChanged:
                        {
-                               wm_window_set_dpi(win);
+                               WM_window_set_dpi(win);
                                /* font's are stored at each DPI level, without this we can easy load 100's of fonts */
                                BLF_cache_clear();
 
-                               BKE_blender_userdef_refresh();
                                WM_main_add_notifier(NC_WINDOW, NULL);      /* full redraw */
                                WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);    /* refresh region sizes */
                                break;
@@ -1247,7 +1248,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
                        {
                                // only update if the actual pixel size changes
                                float prev_pixelsize = U.pixelsize;
-                               wm_window_set_dpi(win);
+                               WM_window_set_dpi(win);
 
                                if (U.pixelsize != prev_pixelsize) {
                                        // close all popups since they are positioned with the pixel
index 0c206dfce3ddde58b94b4cf885c34685bcab13a2..906e9d9a821533e05df25ef662bafd27f6b5ed9b 100644 (file)
@@ -516,7 +516,7 @@ int main(
 #endif
 
        // Setup builtin font for BLF (mostly copied from creator.c, wm_init_exit.c and interface_style.c)
-       BLF_init(11, U.dpi);
+       BLF_init();
        BLT_lang_init();
        BLT_lang_set("");