Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2013-01-12 21:07:49 +0400
committerTon Roosendaal <ton@blender.org>2013-01-12 21:07:49 +0400
commitfa759d8ffdd6c2a66270e8e85a53f608f4cd7ad0 (patch)
tree35f28ba5d460f3d4823b592dcc53a9176a2da155 /source/blender/windowmanager/intern/wm_window.c
parent47ee5f56b6c6aa2eb78ff20dc24b10b2b7476b94 (diff)
Mac HiDPI ("retina") handling:
OK - so you have this nice crisp screen, and still you want to add extra monitors to the laptop! That means Blender should switch back and forth to HiDPI modes, when you move a window to another monitor. This code makes the pixelsize scale factor a window property, and handles an event when a window moves to another monitor. It then changes the native pixelsize nicely and refreshes entire UI. You can also have one Blender window on high, and other on low resolution. Stretching a Blender window from 1 monitor to the other works too, but that is Apple magic handling it.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_window.c')
-rw-r--r--source/blender/windowmanager/intern/wm_window.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 9e0f8613a1a..e6a40187bfe 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -377,7 +377,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
/* displays with larger native pixels, like Macbook. Used to scale dpi with */
/* needed here, because it's used before it reads userdef */
- U.pixelsize = GHOST_GetNativePixelSize();
+ U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin);
BKE_userdef_state();
/* store actual window size in blender window */
@@ -595,12 +595,13 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
static void wm_convert_cursor_position(wmWindow *win, int *x, int *y)
{
-
+ float fac = GHOST_GetNativePixelSize(win->ghostwin);
+
GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y);
- *x *= GHOST_GetNativePixelSize();
+ *x *= fac;
*y = (win->sizey - 1) - *y;
- *y *= GHOST_GetNativePixelSize();
+ *y *= fac;
}
@@ -661,6 +662,10 @@ void wm_window_make_drawable(bContext *C, wmWindow *win)
printf("%s: set drawable %d\n", __func__, win->winid);
}
GHOST_ActivateWindowDrawingContext(win->ghostwin);
+
+ /* this can change per window */
+ U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin);
+ BKE_userdef_state();
}
}
@@ -947,6 +952,15 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
break;
}
+ case GHOST_kEventNativeResolutionChange:
+ // printf("change, pixel size %f\n", GHOST_GetNativePixelSize(win->ghostwin));
+
+ U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin);
+ BKE_userdef_state();
+ WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
+
+ break;
case GHOST_kEventTrackpad:
{
GHOST_TEventTrackpadData *pd = data;
@@ -1289,7 +1303,7 @@ void WM_init_native_pixels(int do_it)
void WM_cursor_warp(wmWindow *win, int x, int y)
{
if (win && win->ghostwin) {
- float f = GHOST_GetNativePixelSize();
+ float f = GHOST_GetNativePixelSize(win->ghostwin);
int oldx = x, oldy = y;
x = x / f;
@@ -1308,14 +1322,14 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
/* mac retina opens window in size X, but it has up to 2 x more pixels */
int WM_window_pixels_x(wmWindow *win)
{
- float f = GHOST_GetNativePixelSize();
+ float f = GHOST_GetNativePixelSize(win->ghostwin);
return (int)(f * (float)win->sizex);
}
int WM_window_pixels_y(wmWindow *win)
{
- float f = GHOST_GetNativePixelSize();
+ float f = GHOST_GetNativePixelSize(win->ghostwin);
return (int)(f * (float)win->sizey);