Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/bzflag/playing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ static void mouseClamp()
{
// only clamp when it might be useful
if (HUDDialogStack::get()->isActive() || (myTank == NULL) || !myTank->isAlive() ||
myTank->isPaused() || (myTank->getTeam() == ObserverTeam))
myTank->isPaused() || (myTank->getTeam() == ObserverTeam) || unmapped)
{
mainWindow->disableConfineToMotionbox();
return;
Expand Down Expand Up @@ -1133,6 +1133,9 @@ static void doEvent(BzfDisplay *disply)
unmapped = false;
if (shouldGrabMouse())
mainWindow->grabMouse();
if(mainWindow->isGrabEnabled())
mainWindow->getWindow()->enableGrabMouse(true); // distinct from grabMouse(), for some reason
mouseClamp();
break;

case BzfEvent::Unmap:
Expand Down Expand Up @@ -1175,6 +1178,7 @@ static void doEvent(BzfDisplay *disply)

unmapped = true;
mainWindow->ungrabMouse();
mainWindow->getWindow()->enableGrabMouse(false); // distinct from ungrabMouse(), for some reason
break;

case BzfEvent::KeyUp:
Expand Down
16 changes: 16 additions & 0 deletions src/platform/SDL2Display.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,22 @@ bool SDLDisplay::setupEvent(BzfEvent& _event, const SDL_Event& event) const
case SDL_WINDOWEVENT:
switch (event.window.event)
{
#ifdef __APPLE__
case SDL_WINDOWEVENT_MOVED:
{
// Work around a bug in SDL2 that was causing an offset viewport on macOS when restoring a fullscreen window
// running at a resolution different from the desktop resolution. The issue only occurred when clicking on
// the application icon, not the minimized window. The window moves to a negative position, so we'll
// detect that and toggle windowed/full screen to fix it.
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
if ((event.window.data1 < 0 || event.window.data2 < 0) && SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN)
{
SDL_SetWindowFullscreen(window, 0);
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
}
}
break;
#endif
case SDL_WINDOWEVENT_RESIZED:
_event.type = BzfEvent::Resize;
_event.resize.width = event.window.data1;
Expand Down