mirror of https://github.com/libsdl-org/SDL.git
Windows allows windows to be resized to zero height.
Changed the window client rect validation to take this into account. Fixes https://github.com/libsdl-org/SDL/issues/9796
This commit is contained in:
parent
47b0c75470
commit
96bf12444c
|
|
@ -330,10 +330,10 @@ void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
|
||||||
winrect->bottom = sdlrect->y + sdlrect->h - 1;
|
winrect->bottom = sdlrect->y + sdlrect->h - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WIN_IsRectEmpty(const RECT *rect)
|
bool WIN_WindowRectValid(const RECT *rect)
|
||||||
{
|
{
|
||||||
// Calculating this manually because Xbox does not support Win32 IsRectEmpty.
|
// A window can be resized to zero height, but not zero width
|
||||||
return (rect->right <= rect->left) || (rect->bottom <= rect->top);
|
return (rect->right > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some GUIDs we need to know without linking to libraries that aren't available before Vista.
|
// Some GUIDs we need to know without linking to libraries that aren't available before Vista.
|
||||||
|
|
|
||||||
|
|
@ -156,8 +156,8 @@ extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
|
||||||
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
|
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
|
||||||
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
|
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
|
||||||
|
|
||||||
// Returns true if the rect is empty
|
// Returns false if a window client rect is not valid
|
||||||
extern BOOL WIN_IsRectEmpty(const RECT *rect);
|
bool WIN_WindowRectValid(const RECT *rect);
|
||||||
|
|
||||||
extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);
|
extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1792,7 +1792,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data->disable_move_size_events) {
|
if (!data->disable_move_size_events) {
|
||||||
if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) {
|
if (GetClientRect(hwnd, &rect) && WIN_WindowRectValid(&rect)) {
|
||||||
ClientToScreen(hwnd, (LPPOINT) &rect);
|
ClientToScreen(hwnd, (LPPOINT) &rect);
|
||||||
ClientToScreen(hwnd, (LPPOINT) &rect + 1);
|
ClientToScreen(hwnd, (LPPOINT) &rect + 1);
|
||||||
|
|
||||||
|
|
@ -1804,7 +1804,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moving the window from one display to another can change the size of the window (in the handling of SDL_EVENT_WINDOW_MOVED), so we need to re-query the bounds
|
// Moving the window from one display to another can change the size of the window (in the handling of SDL_EVENT_WINDOW_MOVED), so we need to re-query the bounds
|
||||||
if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) {
|
if (GetClientRect(hwnd, &rect) && WIN_WindowRectValid(&rect)) {
|
||||||
w = rect.right;
|
w = rect.right;
|
||||||
h = rect.bottom;
|
h = rect.bottom;
|
||||||
|
|
||||||
|
|
@ -2084,7 +2084,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
||||||
RECT rect;
|
RECT rect;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
|
||||||
if (!GetClientRect(hwnd, &rect) || WIN_IsRectEmpty(&rect)) {
|
if (!GetClientRect(hwnd, &rect) || !WIN_WindowRectValid(&rect)) {
|
||||||
if (inputs) {
|
if (inputs) {
|
||||||
SDL_small_free(inputs, isstack);
|
SDL_small_free(inputs, isstack);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -535,7 +535,7 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwn
|
||||||
}
|
}
|
||||||
if (!(window->flags & SDL_WINDOW_MINIMIZED)) {
|
if (!(window->flags & SDL_WINDOW_MINIMIZED)) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) {
|
if (GetClientRect(hwnd, &rect) && WIN_WindowRectValid(&rect)) {
|
||||||
int w = rect.right;
|
int w = rect.right;
|
||||||
int h = rect.bottom;
|
int h = rect.bottom;
|
||||||
|
|
||||||
|
|
@ -1062,7 +1062,7 @@ void WIN_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *
|
||||||
HWND hwnd = data->hwnd;
|
HWND hwnd = data->hwnd;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) {
|
if (GetClientRect(hwnd, &rect) && WIN_WindowRectValid(&rect)) {
|
||||||
*w = rect.right;
|
*w = rect.right;
|
||||||
*h = rect.bottom;
|
*h = rect.bottom;
|
||||||
} else if (window->last_pixel_w && window->last_pixel_h) {
|
} else if (window->last_pixel_w && window->last_pixel_h) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue