GUI: fix non-working mouse events after minimizing
This commit is contained in:
parent
403bc76d18
commit
e19538af2e
|
@ -65,6 +65,7 @@
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_sdl.h"
|
#include "imgui_impl_sdl.h"
|
||||||
|
#include <stdio.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
|
@ -288,6 +289,7 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||||
if (!platform_io.Monitors.empty() && platform_io.Monitors[0].DpiScale > 1.0f)
|
if (!platform_io.Monitors.empty() && platform_io.Monitors[0].DpiScale > 1.0f)
|
||||||
{
|
{
|
||||||
// The Framebuffer is scaled by an integer ceiling of the actual ratio, so 2.0 not 1.685 on Mac!
|
// The Framebuffer is scaled by an integer ceiling of the actual ratio, so 2.0 not 1.685 on Mac!
|
||||||
|
//printf("multiply by %f\n",platform_io.Monitors[0].DpiScale);
|
||||||
mouse_pos.x *= std::ceil(platform_io.Monitors[0].DpiScale);
|
mouse_pos.x *= std::ceil(platform_io.Monitors[0].DpiScale);
|
||||||
mouse_pos.y *= std::ceil(platform_io.Monitors[0].DpiScale);
|
mouse_pos.y *= std::ceil(platform_io.Monitors[0].DpiScale);
|
||||||
}
|
}
|
||||||
|
@ -690,10 +692,11 @@ void ImGui_ImplSDL2_NewFrame()
|
||||||
|
|
||||||
// On Apple and Wayland, The window size is reported in Low DPI, even when running in high DPI mode
|
// On Apple and Wayland, The window size is reported in Low DPI, even when running in high DPI mode
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
if (!platform_io.Monitors.empty() /*&& platform_io.Monitors[0].DpiScale > 1.0f*/ && display_h != h)
|
if (!platform_io.Monitors.empty() /*&& platform_io.Monitors[0].DpiScale > 1.0f*/ && display_h != h && w != 0)
|
||||||
{
|
{
|
||||||
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||||
io.DisplaySize = ImVec2((float)display_w, (float)display_h);
|
io.DisplaySize = ImVec2((float)display_w, (float)display_h);
|
||||||
|
//printf("write %d/%d to DpiScale\n",display_w,w);
|
||||||
platform_io.Monitors[0].DpiScale=(float)display_w/(float)w;
|
platform_io.Monitors[0].DpiScale=(float)display_w/(float)w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,6 +378,14 @@ void FurnaceGUI::drawDebug() {
|
||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
if (ImGui::TreeNode("Window Debug")) {
|
||||||
|
ImGui::Text("Screen: %dx%d+%d+%d",scrW,scrH,scrX,scrY);
|
||||||
|
ImGui::Text("Screen (Conf): %dx%d+%d+%d",scrConfW,scrConfH,scrConfX,scrConfY);
|
||||||
|
ImGui::Text("Canvas: %dx%d",canvasW,canvasH);
|
||||||
|
ImGui::Text("Maximized: %d",scrMax);
|
||||||
|
ImGui::Text("System Managed Scale: %d",sysManagedScale);
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
if (ImGui::TreeNode("Playground")) {
|
if (ImGui::TreeNode("Playground")) {
|
||||||
if (pgSys<0 || pgSys>=e->song.systemLen) pgSys=0;
|
if (pgSys<0 || pgSys>=e->song.systemLen) pgSys=0;
|
||||||
if (ImGui::BeginCombo("Chip",fmt::sprintf("%d. %s",pgSys+1,e->getSystemName(e->song.system[pgSys])).c_str())) {
|
if (ImGui::BeginCombo("Chip",fmt::sprintf("%d. %s",pgSys+1,e->getSystemName(e->song.system[pgSys])).c_str())) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <SDL_error.h>
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
// OK, sorry for inserting the define here but I'm so tired of this extension
|
// OK, sorry for inserting the define here but I'm so tired of this extension
|
||||||
/**
|
/**
|
||||||
|
@ -3074,6 +3075,7 @@ bool FurnaceGUI::loop() {
|
||||||
|
|
||||||
// update config x/y/w/h values based on scrMax state
|
// update config x/y/w/h values based on scrMax state
|
||||||
if (updateWindow) {
|
if (updateWindow) {
|
||||||
|
logV("updateWindow is true");
|
||||||
if (!scrMax) {
|
if (!scrMax) {
|
||||||
scrConfX=scrX;
|
scrConfX=scrX;
|
||||||
scrConfY=scrY;
|
scrConfY=scrY;
|
||||||
|
@ -3082,7 +3084,11 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update canvas size as well
|
// update canvas size as well
|
||||||
SDL_GetRendererOutputSize(sdlRend,&canvasW,&canvasH);
|
if (SDL_GetRendererOutputSize(sdlRend,&canvasW,&canvasH)!=0) {
|
||||||
|
logW("updateWindow: error while getting output size! %s",SDL_GetError());
|
||||||
|
} else {
|
||||||
|
logV("updateWindow: canvas size %dx%d",canvasW,canvasH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;
|
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;
|
||||||
|
|
Loading…
Reference in a new issue