diff --git a/src/window/gui/Gui.cpp b/src/window/gui/Gui.cpp index ba768044b..a4cef5437 100644 --- a/src/window/gui/Gui.cpp +++ b/src/window/gui/Gui.cpp @@ -65,10 +65,6 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARA #endif -#ifndef USER_DEFAULT_SCREEN_DPI -#define USER_DEFAULT_SCREEN_DPI 96 -#endif - namespace LUS { #define TOGGLE_BTN ImGuiKey_F1 #define TOGGLE_PAD_BTN ImGuiKey_GamepadBack @@ -283,8 +279,6 @@ void Gui::Update(WindowEvent event) { mNeedsConsoleVariableSave = false; } - float dpiScale = 0; - switch (Context::GetInstance()->GetWindow()->GetWindowBackend()) { #ifdef __WIIU__ case WindowBackend::GX2: @@ -295,26 +289,6 @@ void Gui::Update(WindowEvent event) { case WindowBackend::SDL_METAL: ImGui_ImplSDL2_ProcessEvent(static_cast(event.Sdl.Event)); -#ifdef __SWITCH__ - // Switch doesn't support SDL_WINDOWEVENT_DISPLAY_CHANGED - if (mDpiInit) { -#else - if (static_cast(event.Sdl.Event)->window.event == SDL_WINDOWEVENT_DISPLAY_CHANGED || - mDpiInit) { -#endif - int display = 0; - if (Context::GetInstance()->GetWindow()->GetWindowBackend() == WindowBackend::SDL_OPENGL) { - display = SDL_GetWindowDisplayIndex(static_cast(mImpl.Opengl.Window)); - } else { - display = SDL_GetWindowDisplayIndex(static_cast(mImpl.Metal.Window)); - } - - float dpi; - if (SDL_GetDisplayDPI(display, &dpi, nullptr, nullptr) == 0) { - dpiScale = dpi / USER_DEFAULT_SCREEN_DPI; - } - } - #ifdef __SWITCH__ LUS::Switch::ImGuiProcessEvent(mImGuiIo->WantTextInput); #endif @@ -327,30 +301,11 @@ void Gui::Update(WindowEvent event) { case WindowBackend::DX11: ImGui_ImplWin32_WndProcHandler(static_cast(event.Win32.Handle), event.Win32.Msg, event.Win32.Param1, event.Win32.Param2); - - if (event.Win32.Msg == WM_DPICHANGED || mDpiInit) { - HMONITOR monitor = MonitorFromWindow(static_cast(event.Win32.Handle), MONITOR_DEFAULTTONEAREST); - dpiScale = (float)ImGui_ImplWin32_GetDpiScaleForMonitor(monitor); - } break; #endif default: break; } - - if (dpiScale > 0) { - if (mDpiInit) { - mLastDpiScale = 1.f; - mDpiInit = false; - } - - float diff = dpiScale / mLastDpiScale; - mLastDpiScale = dpiScale; - - ImGui::GetStyle().ScaleAllSizes(diff); - ImFont* font = ImGui::GetFont(); - font->Scale *= diff; - } } bool Gui::ImGuiGamepadNavigationEnabled() { @@ -367,24 +322,12 @@ void Gui::UnblockImGuiGamepadNavigation() { } } -float Gui::GetCurrentDpiScale() { - if (mLastDpiScale <= 0) { - return 1.f; - } - - return mLastDpiScale; -} - void Gui::DrawMenu() { LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")->Update(); ImGuiBackendNewFrame(); ImGuiWMNewFrame(); ImGui::NewFrame(); - if (mLastDpiScale == 0) { - mDpiInit = true; - } - const std::shared_ptr wnd = Context::GetInstance()->GetWindow(); const std::shared_ptr conf = Context::GetInstance()->GetConfig(); diff --git a/src/window/gui/Gui.h b/src/window/gui/Gui.h index 3a4f3d6ee..c3dd0ca0f 100644 --- a/src/window/gui/Gui.h +++ b/src/window/gui/Gui.h @@ -92,7 +92,6 @@ class Gui { bool ImGuiGamepadNavigationEnabled(); void BlockImGuiGamepadNavigation(); void UnblockImGuiGamepadNavigation(); - float GetCurrentDpiScale(); protected: void ImGuiWMInit(); @@ -112,9 +111,6 @@ class Gui { std::shared_ptr mMenuBar; std::map mGuiTextures; std::map> mGuiWindows; - - bool mDpiInit = false; - float mLastDpiScale = 0; }; } // namespace LUS