Skip to content

Commit 56c79eb

Browse files
committed
xrEngine, xrGame: fix cursor in main menu with non-native screen
resolution
1 parent 290d9f2 commit 56c79eb

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

src/xrEngine/Device_Initialize.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,12 @@ void CRenderDevice::Initialize()
6060
}
6161
// Save window properties
6262
m_dwWindowStyle = SDL_GetWindowFlags(m_sdlWnd);
63-
if (SDL_GetDisplayBounds(0, &m_rcWindowBounds) != 0)
64-
{
65-
Log("SDL_GetDisplayBounds m_rcWindowBounds failed: %s", SDL_GetError());
66-
}
6763

68-
if (SDL_GetDisplayBounds(0, &m_rcWindowClient) != 0)
69-
{
70-
Log("SDL_GetDisplayBounds m_rcWindowClient failed: %s", SDL_GetError());
71-
}
64+
SDL_GetWindowPosition(m_sdlWnd, &m_rcWindowClient.x, &m_rcWindowClient.y);
65+
int w = 0, h = 0;
66+
SDL_GetWindowSize(m_sdlWnd, &w, &h);
67+
m_rcWindowClient.w = m_rcWindowClient.x + w;
68+
m_rcWindowClient.h = m_rcWindowClient.y + h;
7269
}
7370

7471
void CRenderDevice::DumpStatistics(IGameFont& font, IPerformanceAlert* alert)

src/xrEngine/Device_create.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ void CRenderDevice::Create()
3939
fASPECT = 1.f;
4040
const bool noEd = !editor();
4141
GEnv.Render->Create(m_sdlWnd, dwWidth, dwHeight, fWidth_2, fHeight_2, noEd);
42+
SDL_GetWindowPosition(m_sdlWnd, &m_rcWindowClient.x, &m_rcWindowClient.y);
43+
int w = 0, h = 0;
44+
SDL_GetWindowSize(m_sdlWnd, &w, &h);
45+
m_rcWindowClient.w = m_rcWindowClient.x + w;
46+
m_rcWindowClient.h = m_rcWindowClient.y + h;
4247
Memory.mem_compact();
4348
b_is_Ready = TRUE;
4449
_SetupStates();

src/xrEngine/IInputReceiver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ BOOL IInputReceiver::IR_GetBtnState(int btn)
5252

5353
void IInputReceiver::IR_GetMousePosScreen(Ivector2& p)
5454
{
55-
SDL_GetGlobalMouseState(&p.x, &p.y);
55+
SDL_GetMouseState(&p.x, &p.y);
5656
}
5757

5858
void IInputReceiver::IR_GetMousePosReal(SDL_Window *m_sdlWnd, Ivector2& p)

src/xrEngine/device.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ class ENGINE_API CRenderDeviceData
6262
u32 dwWidth;
6363
u32 dwHeight;
6464

65-
// Real application window resolution
66-
SDL_Rect m_rcWindowBounds;
67-
6865
// Real game window resolution
6966
SDL_Rect m_rcWindowClient;
7067

src/xrGame/UICursor.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ void CUICursor::InitInternal()
5656
m_static->SetWndSize(sz);
5757
m_static->SetStretchTexture(true);
5858

59-
u32 screen_size_x = Device.m_rcWindowClient.w;
60-
u32 screen_size_y = Device.m_rcWindowClient.h;
61-
m_b_use_win_cursor = (screen_size_y > Device.dwHeight && screen_size_x > Device.dwWidth);
59+
SDL_Rect display;
60+
if (SDL_GetDisplayBounds(0, &display) != 0)
61+
{
62+
Log("SDL_GetDisplayBounds display failed: %s", SDL_GetError());
63+
}
64+
u32 screen_size_x = display.w - display.x;
65+
u32 screen_size_y = display.h - display.y;
66+
m_b_use_win_cursor = (screen_size_y >= Device.dwHeight && screen_size_x >= Device.dwWidth);
6267
}
6368

6469
//--------------------------------------------------------------------

0 commit comments

Comments
 (0)