diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2022-12-10 10:55:10 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-10 10:55:10 +1000 |
commit | 4fdc2a6bc95b74bde0b0369fccf21d844171243d (patch) | |
tree | b6ce71f3aa9fc406fbe6cb3cc2b02f82c9c5f9cb | |
parent | 60eba26f9bb2d2d3d916790de71ff368c994912c (diff) | |
parent | b6d48048c71c9c0211f45dbb6df702dda4fb3c39 (diff) |
Merge pull request #22232 from enen92/osx_fullscreen_resize
[macOS][nativewindow] Resize/reposition while in fullscreen (XBMC_FUL…
-rw-r--r-- | xbmc/application/Application.cpp | 11 | ||||
-rw-r--r-- | xbmc/windowing/XBMC_events.h | 36 | ||||
-rw-r--r-- | xbmc/windowing/osx/OpenGL/OSXGLWindow.mm | 19 |
3 files changed, 45 insertions, 21 deletions
diff --git a/xbmc/application/Application.cpp b/xbmc/application/Application.cpp index b3edbdf0ca..4ead646f9b 100644 --- a/xbmc/application/Application.cpp +++ b/xbmc/application/Application.cpp @@ -295,12 +295,23 @@ void CApplication::HandlePortEvents() //auto& gfxContext = CServiceBroker::GetWinSystem()->GetGfxContext(); //gfxContext.SetVideoResolution(gfxContext.GetVideoResolution(), true); // try to resize window back to it's full screen size + //! TODO: DX windowing should emit XBMC_FULLSCREEN_UPDATE instead with the proper dimensions + //! and position to avoid the ifdef in common code auto& res_info = CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP); CServiceBroker::GetWinSystem()->ResizeWindow(res_info.iScreenWidth, res_info.iScreenHeight, 0, 0); } #endif } break; + case XBMC_FULLSCREEN_UPDATE: + { + if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_fullScreen) + { + CServiceBroker::GetWinSystem()->ResizeWindow(newEvent.resize.w, newEvent.resize.h, + newEvent.move.x, newEvent.move.y); + } + break; + } case XBMC_VIDEOMOVE: { CServiceBroker::GetWinSystem()->OnMove(newEvent.move.x, newEvent.move.y); diff --git a/xbmc/windowing/XBMC_events.h b/xbmc/windowing/XBMC_events.h index ba9f9e315f..d9bf3ea8ed 100644 --- a/xbmc/windowing/XBMC_events.h +++ b/xbmc/windowing/XBMC_events.h @@ -19,23 +19,25 @@ #include "input/XBMC_keyboard.h" /* Event enumerations */ -typedef enum { - XBMC_NOEVENT = 0, /* Unused (do not remove) */ - XBMC_KEYDOWN, /* Keys pressed */ - XBMC_KEYUP, /* Keys released */ - XBMC_MOUSEMOTION, /* Mouse moved */ - XBMC_MOUSEBUTTONDOWN, /* Mouse button pressed */ - XBMC_MOUSEBUTTONUP, /* Mouse button released */ - XBMC_QUIT, /* User-requested quit */ - XBMC_VIDEORESIZE, /* User resized video mode */ - XBMC_VIDEOMOVE, /* User moved the window */ - XBMC_MODECHANGE, /* Video mode must be changed */ - XBMC_TOUCH, - XBMC_BUTTON, /* Button (remote) pressed */ - XBMC_SETFOCUS, - XBMC_USEREVENT, - - XBMC_MAXEVENT = 256 /* XBMC_EventType is represented as uchar */ +typedef enum +{ + XBMC_NOEVENT = 0, /* Unused (do not remove) */ + XBMC_KEYDOWN, /* Keys pressed */ + XBMC_KEYUP, /* Keys released */ + XBMC_MOUSEMOTION, /* Mouse moved */ + XBMC_MOUSEBUTTONDOWN, /* Mouse button pressed */ + XBMC_MOUSEBUTTONUP, /* Mouse button released */ + XBMC_QUIT, /* User-requested quit */ + XBMC_VIDEORESIZE, /* User resized video mode */ + XBMC_FULLSCREEN_UPDATE, /* Triggered by an OS event when Kodi is running in fullscreen, rescale and repositioning is required */ + XBMC_VIDEOMOVE, /* User moved the window */ + XBMC_MODECHANGE, /* Video mode must be changed */ + XBMC_TOUCH, + XBMC_BUTTON, /* Button (remote) pressed */ + XBMC_SETFOCUS, + XBMC_USEREVENT, + + XBMC_MAXEVENT = 256 /* XBMC_EventType is represented as uchar */ } XBMC_EventType; /* Keyboard event structure */ diff --git a/xbmc/windowing/osx/OpenGL/OSXGLWindow.mm b/xbmc/windowing/osx/OpenGL/OSXGLWindow.mm index efa6bd4640..8ee26fcb0a 100644 --- a/xbmc/windowing/osx/OpenGL/OSXGLWindow.mm +++ b/xbmc/windowing/osx/OpenGL/OSXGLWindow.mm @@ -100,20 +100,32 @@ int width = static_cast<int>(rect.size.width); int height = static_cast<int>(rect.size.height); + XBMC_Event newEvent = {}; + if (!CServiceBroker::GetWinSystem()->IsFullScreen()) { RESOLUTION res_index = RES_DESKTOP; if ((width == CDisplaySettings::GetInstance().GetResolutionInfo(res_index).iWidth) && (height == CDisplaySettings::GetInstance().GetResolutionInfo(res_index).iHeight)) return; + + newEvent.type = XBMC_VIDEORESIZE; } - XBMC_Event newEvent = {}; - newEvent.type = XBMC_VIDEORESIZE; + else + { + // macos may trigger a resize/rescale event just after Kodi has entered fullscreen + // (from windowDidEndLiveResize). Kodi needs to rescale the UI - use a different event + // type since XBMC_VIDEORESIZE is supposed to only be used in windowed mode + newEvent.type = XBMC_FULLSCREEN_UPDATE; + newEvent.move.x = -1; + newEvent.move.y = -1; + } + newEvent.resize.w = width; newEvent.resize.h = height; // check for valid sizes cause in some cases - // we are hit during fullscreen transition from osx + // we are hit during fullscreen transition from macos // and might be technically "zero" sized if (newEvent.resize.w != 0 && newEvent.resize.h != 0) { @@ -121,7 +133,6 @@ if (appPort) appPort->OnEvent(newEvent); } - //CServiceBroker::GetGUI()->GetWindowManager().MarkDirty(); } } |