Qt/windows: use Qt's high dpi scaling

This commit is contained in:
Megamouse 2018-07-20 07:48:11 +02:00
parent 9717e19be2
commit 79003cd089
2 changed files with 18 additions and 16 deletions

View file

@ -94,12 +94,8 @@ int main(int argc, char** argv)
{ {
logs::set_init(); logs::set_init();
#ifdef _WIN32 #if defined(_WIN32) || defined(__APPLE__)
// use this instead of SetProcessDPIAware if Qt ever fully supports this on windows QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// at the moment it can't display QCombobox frames for example
// I think there was an issue with gsframe if I recall correctly, so look out for that
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
SetProcessDPIAware();
#else #else
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
#endif #endif

View file

@ -252,20 +252,26 @@ void gs_frame::delete_context(draw_context_t ctx)
int gs_frame::client_width() int gs_frame::client_width()
{ {
#if defined(_WIN32) || defined(__APPLE__) #ifdef _WIN32
return size().width(); RECT rect;
#else if (GetClientRect(HWND(winId()), &rect))
return size().width() * devicePixelRatio(); {
#endif return rect.right - rect.left;
}
#endif // _WIN32
return width() * devicePixelRatio();
} }
int gs_frame::client_height() int gs_frame::client_height()
{ {
#if defined(_WIN32) || defined(__APPLE__) #ifdef _WIN32
return size().height(); RECT rect;
#else if (GetClientRect(HWND(winId()), &rect))
return size().height() * devicePixelRatio(); {
#endif return rect.bottom - rect.top;
}
#endif // _WIN32
return height() * devicePixelRatio();
} }
void gs_frame::flip(draw_context_t, bool /*skip_frame*/) void gs_frame::flip(draw_context_t, bool /*skip_frame*/)