Fix: Interactive Docking support on High-DPI/Retina Displays
When dragging an area from one window to another, the target location was out by the monitor dot-pitch on macOS Retina displays. This commit fixes this by converting the window position coordinates to the display native pixel size via a new `WM_window_pixels_coords` API function. Pull Request: https://projects.blender.org/blender/blender/pulls/125926
This commit is contained in:
committed by
Harley Acheson
parent
24e6b33942
commit
a9f9062df2
@@ -3841,8 +3841,15 @@ static AreaDockTarget area_docking_target(sAreaJoinData *jd, const wmEvent *even
|
||||
}
|
||||
|
||||
/* Convert to local coordinates in sa2. */
|
||||
const int x = event->xy[0] + jd->win1->posx - jd->win2->posx - jd->sa2->totrct.xmin;
|
||||
const int y = event->xy[1] + jd->win1->posy - jd->win2->posy - jd->sa2->totrct.ymin;
|
||||
int win1_posx = jd->win1->posx;
|
||||
int win1_posy = jd->win1->posy;
|
||||
int win2_posx = jd->win2->posx;
|
||||
int win2_posy = jd->win2->posy;
|
||||
WM_window_pixels_coords(jd->win1, &win1_posx, &win1_posy);
|
||||
WM_window_pixels_coords(jd->win2, &win2_posx, &win2_posy);
|
||||
|
||||
const int x = event->xy[0] + win1_posx - win2_posx - jd->sa2->totrct.xmin;
|
||||
const int y = event->xy[1] + win1_posy - win2_posy - jd->sa2->totrct.ymin;
|
||||
|
||||
const float fac_x = float(x) / float(jd->sa2->winx);
|
||||
const float fac_y = float(y) / float(jd->sa2->winy);
|
||||
|
||||
@@ -275,6 +275,7 @@ bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2],
|
||||
*/
|
||||
int WM_window_pixels_x(const wmWindow *win);
|
||||
int WM_window_pixels_y(const wmWindow *win);
|
||||
void WM_window_pixels_coords(const wmWindow *win, int *x, int *y);
|
||||
/**
|
||||
* Get boundaries usable by all window contents, including global areas.
|
||||
*/
|
||||
|
||||
@@ -2672,15 +2672,23 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
|
||||
|
||||
int WM_window_pixels_x(const wmWindow *win)
|
||||
{
|
||||
float f = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
const float fac = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
return int(f * float(win->sizex));
|
||||
return int(fac * float(win->sizex));
|
||||
}
|
||||
int WM_window_pixels_y(const wmWindow *win)
|
||||
{
|
||||
float f = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
const float fac = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
return int(f * float(win->sizey));
|
||||
return int(fac * float(win->sizey));
|
||||
}
|
||||
|
||||
void WM_window_pixels_coords(const wmWindow *win, int *x, int *y)
|
||||
{
|
||||
const float fac = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
*x *= fac;
|
||||
*y *= fac;
|
||||
}
|
||||
|
||||
void WM_window_rect_calc(const wmWindow *win, rcti *r_rect)
|
||||
|
||||
Reference in New Issue
Block a user