Skip to content
Open
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
30 changes: 25 additions & 5 deletions appframework/sdlmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,9 +1472,6 @@ void CSDLMgr::SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight )
}

mode.format = (Uint32)SDL_PIXELFORMAT_RGBX8888;

m_flMouseXScale = ( float )nWidth / ( float )mode.w;
m_flMouseYScale = ( float )nHeight / ( float )mode.h;
}
else
{
Expand All @@ -1483,8 +1480,6 @@ void CSDLMgr::SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight )
mode.w = nWidth;
mode.h = nHeight;
mode.driverdata = 0;
m_flMouseXScale = 1.0f;
m_flMouseYScale = 1.0f;
}

SDL_SetWindowDisplayMode( m_Window, &mode );
Expand Down Expand Up @@ -1531,6 +1526,31 @@ void CSDLMgr::SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight )

m_bFullScreen = bFullScreen;
}

if (bFullScreen)
{
int drawableW, drawableH;
SDL_GL_GetDrawableSize(m_Window, &drawableW, &drawableH);

if ( drawableW > 0 && drawableH > 0 )
{
// Use drawable size for accurate mouse scaling, including macOS devices
// with camera notch
m_flMouseXScale = (float)nWidth / (float)drawableW;
m_flMouseYScale = (float)nHeight / (float)drawableH;
}
else {
// Fallback to mode dimensions if drawable size unavailable
m_flMouseXScale = (float)nWidth / (float)mode.w;
m_flMouseYScale = (float)nHeight / (float)mode.h;
}
}
else
{
// Use 1:1 scaling for windowed mode
m_flMouseXScale = 1.0f;
m_flMouseYScale = 1.0f;
}
}


Expand Down