You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix editor auto scale on Windows
This commit is contained in:
@@ -1331,17 +1331,17 @@ Rect2i DisplayServerWindows::screen_get_usable_rect(int p_screen) const {
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
int current_index;
|
||||
int screen;
|
||||
int dpi;
|
||||
} EnumDpiData;
|
||||
|
||||
static int QueryDpiForMonitor(HMONITOR hmon, MONITOR_DPI_TYPE dpiType = MDT_DEFAULT) {
|
||||
static int QueryDpiForMonitor(HMONITOR hmon) {
|
||||
int dpiX = 96, dpiY = 96;
|
||||
|
||||
UINT x = 0, y = 0;
|
||||
if (hmon) {
|
||||
HRESULT hr = GetDpiForMonitor(hmon, dpiType, &x, &y);
|
||||
HRESULT hr = GetDpiForMonitor(hmon, MDT_DEFAULT, &x, &y);
|
||||
if (SUCCEEDED(hr) && (x > 0) && (y > 0)) {
|
||||
dpiX = (int)x;
|
||||
dpiY = (int)y;
|
||||
@@ -1367,11 +1367,13 @@ static int QueryDpiForMonitor(HMONITOR hmon, MONITOR_DPI_TYPE dpiType = MDT_DEFA
|
||||
|
||||
static BOOL CALLBACK _MonitorEnumProcDpi(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
||||
EnumDpiData *data = (EnumDpiData *)dwData;
|
||||
if (data->count == data->screen) {
|
||||
data->dpi = QueryDpiForMonitor(hMonitor);
|
||||
}
|
||||
|
||||
data->count++;
|
||||
data->current_index++;
|
||||
|
||||
if (data->current_index == data->screen) {
|
||||
data->dpi = QueryDpiForMonitor(hMonitor);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1379,11 +1381,11 @@ int DisplayServerWindows::screen_get_dpi(int p_screen) const {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
p_screen = _get_screen_index(p_screen);
|
||||
int screen_count = get_screen_count();
|
||||
ERR_FAIL_INDEX_V(p_screen, screen_count, 72);
|
||||
|
||||
EnumDpiData data = { 0, p_screen, 72 };
|
||||
EnumDpiData data = { -1, p_screen, 96 };
|
||||
EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcDpi, (LPARAM)&data);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(data.current_index < p_screen, 96, vformat("Screen index %d out of range [0, %d].", p_screen, data.current_index));
|
||||
return data.dpi;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user