diff --git a/backends/ui/imgui/RendererBackend.cpp b/backends/ui/imgui/RendererBackend.cpp index 7ee4850..a636845 100644 --- a/backends/ui/imgui/RendererBackend.cpp +++ b/backends/ui/imgui/RendererBackend.cpp @@ -425,6 +425,12 @@ bool RendererBackend::BeginMainMenuBar() { return false; } } +bool RendererBackend::is_fullscreen() { + return SDL_GetWindowFlags(window) & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP); +} +bool RendererBackend::is_maximized() { + return SDL_GetWindowFlags(window) & SDL_WINDOW_MAXIMIZED; +} SDL_HitTestResult RendererBackend::HitTest(SDL_Window *window, const SDL_Point *area) { int w, h; bool rtop, rbottom, rleft, rright; @@ -433,27 +439,31 @@ SDL_HitTestResult RendererBackend::HitTest(SDL_Window *window, const SDL_Point * rleft = area->x <= 4; rright = area->x >= w-5; rbottom = area->y >= h-5; - if (rtop) { - if (rright) { - return SDL_HITTEST_RESIZE_TOPRIGHT; + if (is_fullscreen()) return SDL_HITTEST_NORMAL; + if (!is_maximized()) { + if (rtop) { + if (rright) { + return SDL_HITTEST_RESIZE_TOPRIGHT; + } else if (rleft) { + return SDL_HITTEST_RESIZE_TOPLEFT; + } else { + return SDL_HITTEST_RESIZE_TOP; + } + } else if (rbottom) { + if (rright) { + return SDL_HITTEST_RESIZE_BOTTOMRIGHT; + } else if (rleft) { + return SDL_HITTEST_RESIZE_BOTTOMLEFT; + } else { + return SDL_HITTEST_RESIZE_BOTTOM; + } } else if (rleft) { - return SDL_HITTEST_RESIZE_TOPLEFT; - } else { - return SDL_HITTEST_RESIZE_TOP; + return SDL_HITTEST_RESIZE_LEFT; + } else if (rright) { + return SDL_HITTEST_RESIZE_RIGHT; } - } else if (rbottom) { - if (rright) { - return SDL_HITTEST_RESIZE_BOTTOMRIGHT; - } else if (rleft) { - return SDL_HITTEST_RESIZE_BOTTOMLEFT; - } else { - return SDL_HITTEST_RESIZE_BOTTOM; - } - } else if (rleft) { - return SDL_HITTEST_RESIZE_LEFT; - } else if (rright) { - return SDL_HITTEST_RESIZE_RIGHT; - } else if (area->y < (16 * this->scale) && (area->x < menubar_start || (area->x > menubar_end && area->x < title_btn_start))) { + } + if (area->y < (16 * this->scale) && (area->x < menubar_start || (area->x > menubar_end && area->x < title_btn_start))) { return SDL_HITTEST_DRAGGABLE; } else { return SDL_HITTEST_NORMAL; diff --git a/backends/ui/imgui/RendererBackend.h b/backends/ui/imgui/RendererBackend.h index 200e4ef..157cdd3 100644 --- a/backends/ui/imgui/RendererBackend.h +++ b/backends/ui/imgui/RendererBackend.h @@ -31,6 +31,8 @@ class RendererBackend { int menubar_end; int title_btn_start; public: + bool is_fullscreen(); + bool is_maximized(); int window_border_radius = 8; SDL_HitTestResult HitTest(SDL_Window *window, const SDL_Point *area); std::optional touchScreenModeOverride;