diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h index aadc5c2259..64d026bcae 100644 --- a/include/SDL3/SDL_video.h +++ b/include/SDL3/SDL_video.h @@ -132,7 +132,7 @@ typedef enum SDL_WINDOW_FULLSCREEN = 0x00000001, /**< window is in fullscreen mode */ SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ SDL_WINDOW_OCCLUDED = 0x00000004, /**< window is occluded */ - SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ + SDL_WINDOW_HIDDEN = 0x00000008, /**< window is neither mapped onto the desktop nor shown in the taskbar/dock/window list; SDL_ShowWindow() is required for it to become visible */ SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 10071cdf04..a111928274 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -643,7 +643,7 @@ static void Cocoa_SendExposedEventIfVisible(SDL_Window *window) int newVisibility = [[change objectForKey:@"new"] intValue]; if (newVisibility) { SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_SHOWN, 0, 0); - } else { + } else if (![_data.nswindow isMiniaturized]) { SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); } } @@ -662,7 +662,7 @@ static void Cocoa_SendExposedEventIfVisible(SDL_Window *window) if (wasVisible != isVisible) { if (isVisible) { SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_SHOWN, 0, 0); - } else { + } else if (![_data.nswindow isMiniaturized]) { SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index d70dcda0c6..d414ee66a1 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -1579,12 +1579,19 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } } - if (changed & SDL_WINDOW_MAXIMIZED) { - if (flags & SDL_WINDOW_MAXIMIZED) { - SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); - } else { - SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); - } + if ((changed & SDL_WINDOW_MAXIMIZED) && ((flags & SDL_WINDOW_MAXIMIZED) && !(flags & SDL_WINDOW_MINIMIZED))) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); + } + if ((changed & SDL_WINDOW_MINIMIZED) && (flags & SDL_WINDOW_MINIMIZED)) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); + } + if (((changed & SDL_WINDOW_MAXIMIZED) || (changed & SDL_WINDOW_MINIMIZED)) && + (!(flags & SDL_WINDOW_MAXIMIZED) && !(flags & SDL_WINDOW_MINIMIZED))) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + } + + if (changed & SDL_WINDOW_OCCLUDED) { + SDL_SendWindowEvent(data->window, (flags & SDL_WINDOW_OCCLUDED) ? SDL_EVENT_WINDOW_OCCLUDED : SDL_EVENT_WINDOW_EXPOSED, 0, 0); } } else if (xevent->xproperty.atom == videodata->XKLAVIER_STATE) { /* Hack for Ubuntu 12.04 (etc) that doesn't send MappingNotify diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 2eb231bced..664de3603e 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -238,7 +238,7 @@ Uint32 X11_GetNetWMState(SDL_VideoDevice *_this, SDL_Window *window, Window xwin for (i = 0; i < numItems; ++i) { if (atoms[i] == _NET_WM_STATE_HIDDEN) { - flags |= SDL_WINDOW_HIDDEN; + flags |= SDL_WINDOW_MINIMIZED | SDL_WINDOW_OCCLUDED; } else if (atoms[i] == _NET_WM_STATE_FOCUSED) { flags |= SDL_WINDOW_INPUT_FOCUS; } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) {