Don't allow resize when maximized, and prepare for potential fullscreen mode
Some checks failed
Build / build-deb (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Successful in 1m29s
Build / download-system-deps (push) Successful in 3m46s
Build / get-source-code (push) Has been cancelled

This commit is contained in:
Zachary Hall 2025-01-14 16:22:51 -08:00
parent 80f29047bd
commit a2a93558a8
2 changed files with 31 additions and 19 deletions

View file

@ -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;

View file

@ -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<bool> touchScreenModeOverride;