statusline_palette = NULL;
}
-static void create_led_font(int monid)
+static void create_led_font(HWND parent, int monid)
{
HDC hdc;
LPLOGPALETTE lp;
hdc = CreateCompatibleDC(NULL);
if (hdc) {
- int y = GetDeviceCaps(hdc, LOGPIXELSY);
+ int y = getdpiforwindow(parent);
int fontsize = -MulDiv(6, y, 72);
fontsize = fontsize * statusline_get_multiplier(monid) / 100;
lp = (LOGPALETTE *)xcalloc(uae_u8, sizeof(LOGPALETTE) + 3 * sizeof(PALETTEENTRY));
}
}
-bool createstatusline(int monid)
+bool createstatusline(HWND parentHwnd, int monid)
{
struct AmigaMonitor *mon = &AMonitors[monid];
BITMAPINFO *bi;
SelectObject(statusline_hdc, statusline_bitmap);
RealizePalette(statusline_hdc);
- create_led_font(monid);
+ create_led_font(parentHwnd, monid);
statusline_font = CreateFont(-10, 0,
0, 0,
static CLOSETOUCHINPUTHANDLE pCloseTouchInputHandle;
#endif
+ADJUSTWINDOWRECTEXFORDPI pAdjustWindowRectExForDpi;
+typedef HRESULT(CALLBACK* GETDPIFORMONITOR)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*);
+static GETDPIFORMONITOR pGetDpiForMonitor;
+typedef UINT(CALLBACK* GETDPIFORWINDOW)(HWND);
+static GETDPIFORWINDOW pGetDpiForWindow;
+
int getdpiformonitor(HMONITOR mon)
{
if (mon) {
if (!shcore)
shcore = LoadLibrary(_T("Shcore.dll"));
if (shcore) {
- typedef HRESULT(CALLBACK *GETDPIFORMONITOR)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *);
- GETDPIFORMONITOR pGetDpiForMonitor = (GETDPIFORMONITOR)GetProcAddress(shcore, "GetDpiForMonitor");
+ if (!pGetDpiForMonitor) {
+ pGetDpiForMonitor = (GETDPIFORMONITOR)GetProcAddress(shcore, "GetDpiForMonitor");
+ }
if (pGetDpiForMonitor) {
UINT x, y;
if (SUCCEEDED(pGetDpiForMonitor(mon, MDT_EFFECTIVE_DPI, &x, &y)))
int getdpiforwindow(HWND hwnd)
{
- typedef UINT(CALLBACK *GETDPIFORWINDOW)(HWND);
- GETDPIFORWINDOW pGetDpiForWindow = (GETDPIFORWINDOW)GetProcAddress(userdll, "GetDpiForWindow");
+ if (!pGetDpiForWindow) {
+ pGetDpiForWindow = (GETDPIFORWINDOW)GetProcAddress(userdll, "GetDpiForWindow");
+ }
if (pGetDpiForWindow)
return pGetDpiForWindow(hwnd);
HDC hdc = GetDC(NULL);
LPMINMAXINFO lpmmi;
lpmmi = (LPMINMAXINFO)lParam;
lpmmi->ptMinTrackSize.x = 160 + mon->window_extra_width;
- lpmmi->ptMinTrackSize.y = 128 + mon->window_extra_height + mon->window_extra_height_bar;
+ lpmmi->ptMinTrackSize.y = 128 + mon->window_extra_height;
lpmmi->ptMaxTrackSize.x = max_uae_width + mon->window_extra_width;
- lpmmi->ptMaxTrackSize.y = max_uae_height + mon->window_extra_height + mon->window_extra_height_bar;
+ lpmmi->ptMaxTrackSize.y = max_uae_height + mon->window_extra_height;
}
return 0;
int w = mon->mainwin_rect.right - mon->mainwin_rect.left;
int h = mon->mainwin_rect.bottom - mon->mainwin_rect.top;
if (w != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.width + mon->window_extra_width ||
- h != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height + mon->window_extra_height + mon->window_extra_height_bar) {
+ h != changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height + mon->window_extra_height) {
changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.width = w - mon->window_extra_width;
- changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height = h - (mon->window_extra_height + mon->window_extra_height_bar);
+ changed_prefs.gfx_monitor[mon->monitor_id].gfx_size_win.height = h - mon->window_extra_height;
set_config_changed();
}
}
}
}
}
+ pAdjustWindowRectExForDpi = (ADJUSTWINDOWRECTEXFORDPI)GetProcAddress(userdll, "AdjustWindowRectExForDpi");
InitCommonControls ();
while (md - Displays < MAX_DISPLAYS && md->monitorid) {
if (!_tcscmp (md->adapterid, lpmi.szDevice)) {
TCHAR tmp[1000];
+ md->monitor = h;
md->rect = lpmi.rcMonitor;
md->workrect = lpmi.rcWork;
adjustappbar(&md->rect, &md->workrect);
struct MultiDisplay *md = &Displays[i];
if (!_tcscmp (md->adapterid, lpmi.szDevice) && !memcmp(&md->rect, &lpmi.rcMonitor, sizeof RECT)) {
md->workrect = lpmi.rcWork;
+ md->monitor = h;
adjustappbar(&md->rect, &md->workrect);
return TRUE;
}
return def;
wi.cbSize = sizeof wi;
if (GetWindowInfo(h, &wi)) {
- int dpi = getdpiforwindow(h);
def = wi.rcWindow.bottom - wi.rcWindow.top;
- def = def * dpi / 96;
}
DestroyWindow(h);
return def;
GetWindowRect (mon->hAmigaWnd, &r);
int sbheight = currprefs.win32_statusbar ? getstatuswindowheight(mon->monitor_id, mon->hAmigaWnd) : 0;
+ int dpi = getdpiforwindow(mon->hAmigaWnd);
x = r.left;
y = r.top;
else
ny = rc.top + (rc.bottom - rc.top - nh);
}
- if (w != nw || h != nh || x != nx || y != ny || sbheight != mon->window_extra_height_bar) {
+ if (w != nw || h != nh || x != nx || y != ny || sbheight != mon->window_extra_height_bar || dpi != mon->dpi) {
w = nw;
h = nh;
x = nx;
y = ny;
- mon->window_extra_height_bar = sbheight;
mon->in_sizemove++;
if (mon->hMainWnd && !fsw && !dxfs && !d3dfs && !rp_isactive()) {
+ if (dpi != mon->dpi) {
+ mon->window_extra_height -= mon->window_extra_height_bar;
+ mon->window_extra_height += sbheight;
+ } else {
+ mon->window_extra_height += (sbheight - mon->window_extra_height_bar);
+ }
+
GetWindowRect(mon->hMainWnd, &r);
+#if 0
+ RECT r2;
+ GetClientRect(mon->hMainWnd, &r2);
+ if (pAdjustWindowRectExForDpi) {
+ HMONITOR mon = MonitorFromRect(&r, MONITOR_DEFAULTTONEAREST);
+ pAdjustWindowRectExForDpi(&r, borderless ? WS_POPUP : style, FALSE, exstyle, getdpiformonitor(mon));
+ } else {
+ AdjustWindowRectEx(&r, borderless ? WS_POPUP : style, FALSE, exstyle);
+ }
+#endif
x = r.left;
y = r.top;
- SetWindowPos(mon->hMainWnd, HWND_TOP, x, y, w + mon->window_extra_width, h + mon->window_extra_height + mon->window_extra_height_bar,
+ SetWindowPos(mon->hMainWnd, HWND_TOP, x, y, w + mon->window_extra_width, h + mon->window_extra_height,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER);
x = gap;
y = gap;
SetWindowPos(mon->hAmigaWnd, HWND_TOP, x, y, w, h,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER);
mon->in_sizemove--;
+ mon->dpi = dpi;
} else {
w = nw;
h = nh;
y = ny;
}
createstatuswindow(mon);
- createstatusline(mon->monitor_id);
+ createstatusline(mon->hAmigaWnd, mon->monitor_id);
updatewinrect(mon, false);
GetWindowRect (mon->hMainWnd, &mon->mainwin_rect);
if (d3dfs || dxfs)
mon->amigawin_rect.left, mon->amigawin_rect.top, mon->amigawin_rect.right - mon->amigawin_rect.left, mon->amigawin_rect.bottom - mon->amigawin_rect.top);
updatemouseclip(mon);
rp_screenmode_changed ();
+ mon->window_extra_height_bar = sbheight;
return 1;
}
oldx = rc.left;
oldy = rc.top;
- AdjustWindowRect (&rc, borderless ? WS_POPUP : style, FALSE);
+ if (pAdjustWindowRectExForDpi) {
+ HMONITOR mon = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST);
+ pAdjustWindowRectExForDpi(&rc, borderless ? WS_POPUP : style, FALSE, exstyle, getdpiformonitor(mon));
+ } else {
+ AdjustWindowRectEx(&rc, borderless ? WS_POPUP : style, FALSE, exstyle);
+ }
mon->win_x_diff = rc.left - oldx;
mon->win_y_diff = rc.top - oldy;
break;
}
GetWindowRect(mon->hMainWnd, &rc2);
- mon->window_extra_width = (rc2.right - rc2.left) - mon->currentmode.current_width;
- mon->window_extra_height = (rc2.bottom - rc2.top) - mon->currentmode.current_height;
- mon->window_extra_height -= sbheight;
- mon->window_extra_height_bar = sbheight;
+ mon->window_extra_width = rc2.right - rc2.left - mon->currentmode.current_width;
+ mon->window_extra_height = rc2.bottom - rc2.top - mon->currentmode.current_height;
createstatuswindow(mon);
- createstatusline(mon->monitor_id);
+ createstatusline(mon->hMainWnd, mon->monitor_id);
} else {
x = rc.left;
y = rc.top;
movecursor (x + w / 2, y + h / 2);
addnotifications (mon->hAmigaWnd, FALSE, FALSE);
mon->window_extra_height_bar = sbheight;
+ mon->dpi = getdpiforwindow(mon->hAmigaWnd);
if (mon->monitor_id) {
ShowWindow(mon->hMainWnd, SW_SHOWNOACTIVATE);
display_param_init(mon);
- createstatusline(mon->monitor_id);
+ createstatusline(mon->hAmigaWnd, mon->monitor_id);
picasso_refresh(mon->monitor_id);
#ifdef RETROPLATFORM
rp_set_hwnd_delayed ();