GUI: prepare for new HiDPI strategy
This commit is contained in:
parent
dc229078cc
commit
375d060f48
|
@ -5012,7 +5012,30 @@ bool FurnaceGUI::init() {
|
||||||
|
|
||||||
e->setAutoNotePoly(noteInputPoly);
|
e->setAutoNotePoly(noteInputPoly);
|
||||||
|
|
||||||
|
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER,"1");
|
||||||
|
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS,"0");
|
||||||
|
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS,"0");
|
||||||
|
// don't disable compositing on KWin
|
||||||
|
#if SDL_VERSION_ATLEAST(2,0,22)
|
||||||
|
SDL_SetHint(SDL_HINT_X11_WINDOW_TYPE,"_NET_WM_WINDOW_TYPE_NORMAL");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// initialize SDL
|
||||||
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
|
const char* videoBackend=SDL_GetCurrentVideoDriver();
|
||||||
|
if (videoBackend!=NULL) {
|
||||||
|
if (strcmp(videoBackend,"wayland")==0 ||
|
||||||
|
strcmp(videoBackend,"cocoa")==0 ||
|
||||||
|
strcmp(videoBackend,"uikit")==0) {
|
||||||
|
sysManagedScale=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: get scaling factor
|
||||||
|
|
||||||
#if !(defined(__APPLE__) || defined(_WIN32))
|
#if !(defined(__APPLE__) || defined(_WIN32))
|
||||||
|
// get the icon (on macOS and Windows the icon is bundled with the app)
|
||||||
unsigned char* furIcon=getFurnaceIcon();
|
unsigned char* furIcon=getFurnaceIcon();
|
||||||
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
||||||
#endif
|
#endif
|
||||||
|
@ -5023,8 +5046,10 @@ bool FurnaceGUI::init() {
|
||||||
scrX=0;
|
scrX=0;
|
||||||
scrY=0;
|
scrY=0;
|
||||||
#else
|
#else
|
||||||
scrW=scrConfW=e->getConfInt("lastWindowWidth",1280);
|
double defaultW=1280*(sysManagedScale?1.0:dpiScale);
|
||||||
scrH=scrConfH=e->getConfInt("lastWindowHeight",800);
|
double defaultH=800*(sysManagedScale?1.0:dpiScale);
|
||||||
|
scrW=scrConfW=e->getConfInt("lastWindowWidth",(int)defaultW);
|
||||||
|
scrH=scrConfH=e->getConfInt("lastWindowHeight",(int)defaultH);
|
||||||
scrX=scrConfX=e->getConfInt("lastWindowX",SDL_WINDOWPOS_CENTERED);
|
scrX=scrConfX=e->getConfInt("lastWindowX",SDL_WINDOWPOS_CENTERED);
|
||||||
scrY=scrConfY=e->getConfInt("lastWindowY",SDL_WINDOWPOS_CENTERED);
|
scrY=scrConfY=e->getConfInt("lastWindowY",SDL_WINDOWPOS_CENTERED);
|
||||||
scrMax=e->getConfBool("lastWindowMax",false);
|
scrMax=e->getConfBool("lastWindowMax",false);
|
||||||
|
@ -5036,16 +5061,6 @@ bool FurnaceGUI::init() {
|
||||||
SDL_Rect displaySize;
|
SDL_Rect displaySize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER,"1");
|
|
||||||
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS,"0");
|
|
||||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS,"0");
|
|
||||||
// don't disable compositing on KWin
|
|
||||||
#if SDL_VERSION_ATLEAST(2,0,22)
|
|
||||||
SDL_SetHint(SDL_HINT_X11_WINDOW_TYPE,"_NET_WM_WINDOW_TYPE_NORMAL");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
|
||||||
|
|
||||||
#ifndef IS_MOBILE
|
#ifndef IS_MOBILE
|
||||||
// if window would spawn out of bounds, force it to be get default position
|
// if window would spawn out of bounds, force it to be get default position
|
||||||
if (!detectOutOfBoundsWindow()) {
|
if (!detectOutOfBoundsWindow()) {
|
||||||
|
@ -5055,12 +5070,13 @@ bool FurnaceGUI::init() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sdlWin=SDL_CreateWindow("Furnace",scrX,scrY,scrW*dpiScale,scrH*dpiScale,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI|(scrMax?SDL_WINDOW_MAXIMIZED:0)|(fullScreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
sdlWin=SDL_CreateWindow("Furnace",scrX,scrY,scrW,scrH,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI|(scrMax?SDL_WINDOW_MAXIMIZED:0)|(fullScreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
||||||
if (sdlWin==NULL) {
|
if (sdlWin==NULL) {
|
||||||
lastError=fmt::sprintf("could not open window! %s",SDL_GetError());
|
lastError=fmt::sprintf("could not open window! %s",SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove this
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
if (settings.dpiScale<0.5f) {
|
if (settings.dpiScale<0.5f) {
|
||||||
// TODO: replace with a function to actually detect the display scaling factor as it's unreliable.
|
// TODO: replace with a function to actually detect the display scaling factor as it's unreliable.
|
||||||
|
@ -5358,6 +5374,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
scrConfX(SDL_WINDOWPOS_CENTERED),
|
scrConfX(SDL_WINDOWPOS_CENTERED),
|
||||||
scrConfY(SDL_WINDOWPOS_CENTERED),
|
scrConfY(SDL_WINDOWPOS_CENTERED),
|
||||||
scrMax(false),
|
scrMax(false),
|
||||||
|
sysManagedScale(false),
|
||||||
dpiScale(1),
|
dpiScale(1),
|
||||||
aboutScroll(0),
|
aboutScroll(0),
|
||||||
aboutSin(0),
|
aboutSin(0),
|
||||||
|
|
|
@ -1064,7 +1064,7 @@ class FurnaceGUI {
|
||||||
|
|
||||||
int scrW, scrH, scrConfW, scrConfH;
|
int scrW, scrH, scrConfW, scrConfH;
|
||||||
int scrX, scrY, scrConfX, scrConfY;
|
int scrX, scrY, scrConfX, scrConfY;
|
||||||
bool scrMax;
|
bool scrMax, sysManagedScale;
|
||||||
|
|
||||||
double dpiScale;
|
double dpiScale;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue