From 6c26911c3df6b02a0ee19899e71207f372b718b3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 20 Apr 2017 00:17:42 +0200 Subject: Fix T51248: user preferences window size not adapted to DPI. --- source/blender/windowmanager/WM_api.h | 2 +- source/blender/windowmanager/intern/wm_operators.c | 8 ++++---- source/blender/windowmanager/intern/wm_window.c | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1cfd20defe0..492dec2cc10 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -102,7 +102,7 @@ enum { }; struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect); -struct wmWindow *WM_window_open_temp(struct bContext *C, const struct rcti *rect_init, int type); +struct wmWindow *WM_window_open_temp(struct bContext *C, int x, int y, int sizex, int sizey, int type); /* returns true if draw method is triple buffer */ bool WM_is_draw_triple(struct wmWindow *win); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d827ccafda8..d3ebd3e4d2c 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1799,13 +1799,13 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar if (version_suffix != NULL && version_suffix[0]) { /* placed after the version number in the image, * placing y is tricky to match baseline */ - int x = 260 - (2 * UI_DPI_WINDOW_FAC); - int y = 242 + (4 * UI_DPI_WINDOW_FAC); - int w = 240; + int x = 260 * U.pixelsize - (2 * UI_DPI_FAC); + int y = 242 * U.pixelsize + (4 * UI_DPI_FAC); + int w = 240 * U.pixelsize; /* hack to have text draw 'text_sel' */ UI_block_emboss_set(block, UI_EMBOSS_NONE); - but = uiDefBut(block, UI_BTYPE_LABEL, 0, version_suffix, x * U.pixelsize, y * U.pixelsize, w * U.pixelsize, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + but = uiDefBut(block, UI_BTYPE_LABEL, 0, version_suffix, x, y, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); /* XXX, set internal flag - UI_SELECT */ UI_but_flag_enable(but, 1); UI_block_emboss_set(block, UI_EMBOSS); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index aaf77946412..de169881bc4 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -642,14 +642,27 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect) * \param type: WM_WINDOW_RENDER, WM_WINDOW_USERPREFS... * \return the window or NULL. */ -wmWindow *WM_window_open_temp(bContext *C, const rcti *rect_init, int type) +wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, int type) { wmWindow *win_prev = CTX_wm_window(C); wmWindow *win; ScrArea *sa; Scene *scene = CTX_data_scene(C); const char *title; - rcti rect = *rect_init; + + /* convert to native OS window coordinates */ + const float native_pixel_size = GHOST_GetNativePixelSize(win_prev->ghostwin); + x /= native_pixel_size; + y /= native_pixel_size; + sizex /= native_pixel_size; + sizey /= native_pixel_size; + + /* calculate postition */ + rcti rect; + rect.xmin = x + win_prev->posx - sizex / 2; + rect.ymin = y + win_prev->posy - sizey / 2; + rect.xmax = rect.xmin + sizex; + rect.ymax = rect.ymin + sizey; /* changes rect to fit within desktop */ wm_window_check_position(&rect); -- cgit v1.2.3