[vlc-devel] [PATCH] skins2: use per-monitor work area when maximizing on Win32
Felix Paul Kühne
fkuehne at videolan.org
Sat Oct 17 10:57:48 UTC 2026
Hello,
Please open a merge request on gitlab. We no longer accept code submissions by email for many years now.
Best regards,
Felix
> On 17. Oct 2026, at 11:56, Mohd Ayaan <sheikhayaan408 at gmail.com> wrote:
>
> WindowManager::maximize() calls OSFactory::getWorkArea(). On Win32 this
> is SystemParametersInfo(SPI_GETWORKAREA), which only returns the primary
> monitor's work area, so on a multi-monitor setup the window is moved and
> resized against the wrong screen.
>
> Win32Factory::getMonitorInfo(OSWindow*) already resolves the monitor
> containing the window via MonitorFromWindow, but returns the full monitor
> rect (rcMonitor) rather than the work area.
>
> Add a non-pure getWorkArea(OSWindow*) overload that defaults to the
> existing parameterless implementation, leaving the X11, OS2 and macOS
> factories unchanged. Override it in Win32Factory to return the rcWork of
> the monitor containing the window, falling back to the old behaviour if
> GetMonitorInfo fails. Pass the window from WindowManager::maximize().
>
> Refs #30199
>
> Signed-off-by: Mohd Ayaan <sheikhayaan408 at gmail.com>
> ---
> modules/gui/skins2/src/os_factory.hpp | 7 +++++++
> modules/gui/skins2/src/window_manager.cpp | 3 ++-
> modules/gui/skins2/win32/win32_factory.cpp | 12 ++++++++++++
> modules/gui/skins2/win32/win32_factory.hpp | 3 +++
> 4 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/modules/gui/skins2/src/os_factory.hpp b/modules/gui/skins2/src/os_factory.hpp
> index 245947d..c3eb71e 100644
> --- a/modules/gui/skins2/src/os_factory.hpp
> +++ b/modules/gui/skins2/src/os_factory.hpp
> @@ -132,6 +132,13 @@ public:
> /// Get the work area (screen area without taskbars)
> virtual SkinsRect getWorkArea() const = 0;
>
> + /// Get the work area for the monitor containing a given window
> + virtual SkinsRect getWorkArea( OSWindow *pWindow ) const
> + {
> + (void)pWindow;
> + return getWorkArea();
> + }
> +
> /// Get the position of the mouse
> virtual void getMousePos( int &rXPos, int &rYPos ) const = 0;
>
> diff --git a/modules/gui/skins2/src/window_manager.cpp b/modules/gui/skins2/src/window_manager.cpp
> index 1d2f32e..9a837d8 100644
> --- a/modules/gui/skins2/src/window_manager.cpp
> +++ b/modules/gui/skins2/src/window_manager.cpp
> @@ -317,7 +317,8 @@ void WindowManager::maximize( TopWindow &rWindow )
> rWindow.getTop() + rWindow.getHeight() );
>
> // maximise the window within the current screen (multiple screens allowed)
> - SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea();
> + OSFactory *pFactory = OSFactory::instance( getIntf() );
> + SkinsRect workArea = pFactory->getWorkArea( rWindow.getOSWindow() );
>
> // Move the window
> startMove( rWindow );
> diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
> index 4f2df1a..2b125c5 100644
> --- a/modules/gui/skins2/win32/win32_factory.cpp
> +++ b/modules/gui/skins2/win32/win32_factory.cpp
> @@ -456,6 +456,18 @@ SkinsRect Win32Factory::getWorkArea() const
> return SkinsRect( r.left, r.top, r.right, r.bottom );
> }
>
> +SkinsRect Win32Factory::getWorkArea( OSWindow *pWindow ) const
> +{
> + Win32Window *pWin = (Win32Window*)pWindow;
> + HMONITOR hmon = MonitorFromWindow( pWin->getHandle(),
> + MONITOR_DEFAULTTONEAREST );
> + MONITORINFO mi;
> + mi.cbSize = sizeof( MONITORINFO );
> + if( hmon && GetMonitorInfo( hmon, &mi ) )
> + return SkinsRect( mi.rcWork.left, mi.rcWork.top,
> + mi.rcWork.right, mi.rcWork.bottom );
> + return getWorkArea();
> +}
>
> void Win32Factory::getMousePos( int &rXPos, int &rYPos ) const
> {
> diff --git a/modules/gui/skins2/win32/win32_factory.hpp b/modules/gui/skins2/win32/win32_factory.hpp
> index 460aa86..2b22609 100644
> --- a/modules/gui/skins2/win32/win32_factory.hpp
> +++ b/modules/gui/skins2/win32/win32_factory.hpp
> @@ -111,6 +111,9 @@ public:
> /// Get the work area (screen area without taskbars)
> virtual SkinsRect getWorkArea() const;
>
> + /// Get the work area for the monitor containing a given window
> + virtual SkinsRect getWorkArea( OSWindow *pWindow ) const;
> +
> /// Get the position of the mouse
> virtual void getMousePos( int &rXPos, int &rYPos ) const;
>
> --
> 2.53.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list