Skip to content

Commit

Permalink
xrEngine, xrGame: fix cursor in main menu with non-native screen
Browse files Browse the repository at this point in the history
resolution
  • Loading branch information
eagleivg committed Jul 14, 2018
1 parent 290d9f2 commit 56c79eb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
13 changes: 5 additions & 8 deletions src/xrEngine/Device_Initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@ void CRenderDevice::Initialize()
}
// Save window properties
m_dwWindowStyle = SDL_GetWindowFlags(m_sdlWnd);
if (SDL_GetDisplayBounds(0, &m_rcWindowBounds) != 0)
{
Log("SDL_GetDisplayBounds m_rcWindowBounds failed: %s", SDL_GetError());
}

if (SDL_GetDisplayBounds(0, &m_rcWindowClient) != 0)
{
Log("SDL_GetDisplayBounds m_rcWindowClient failed: %s", SDL_GetError());
}
SDL_GetWindowPosition(m_sdlWnd, &m_rcWindowClient.x, &m_rcWindowClient.y);
int w = 0, h = 0;
SDL_GetWindowSize(m_sdlWnd, &w, &h);
m_rcWindowClient.w = m_rcWindowClient.x + w;
m_rcWindowClient.h = m_rcWindowClient.y + h;
}

void CRenderDevice::DumpStatistics(IGameFont& font, IPerformanceAlert* alert)
Expand Down
5 changes: 5 additions & 0 deletions src/xrEngine/Device_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ void CRenderDevice::Create()
fASPECT = 1.f;
const bool noEd = !editor();
GEnv.Render->Create(m_sdlWnd, dwWidth, dwHeight, fWidth_2, fHeight_2, noEd);
SDL_GetWindowPosition(m_sdlWnd, &m_rcWindowClient.x, &m_rcWindowClient.y);
int w = 0, h = 0;
SDL_GetWindowSize(m_sdlWnd, &w, &h);
m_rcWindowClient.w = m_rcWindowClient.x + w;
m_rcWindowClient.h = m_rcWindowClient.y + h;
Memory.mem_compact();
b_is_Ready = TRUE;
_SetupStates();
Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/IInputReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ BOOL IInputReceiver::IR_GetBtnState(int btn)

void IInputReceiver::IR_GetMousePosScreen(Ivector2& p)
{
SDL_GetGlobalMouseState(&p.x, &p.y);
SDL_GetMouseState(&p.x, &p.y);
}

void IInputReceiver::IR_GetMousePosReal(SDL_Window *m_sdlWnd, Ivector2& p)
Expand Down
3 changes: 0 additions & 3 deletions src/xrEngine/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ class ENGINE_API CRenderDeviceData
u32 dwWidth;
u32 dwHeight;

// Real application window resolution
SDL_Rect m_rcWindowBounds;

// Real game window resolution
SDL_Rect m_rcWindowClient;

Expand Down
11 changes: 8 additions & 3 deletions src/xrGame/UICursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ void CUICursor::InitInternal()
m_static->SetWndSize(sz);
m_static->SetStretchTexture(true);

u32 screen_size_x = Device.m_rcWindowClient.w;
u32 screen_size_y = Device.m_rcWindowClient.h;
m_b_use_win_cursor = (screen_size_y > Device.dwHeight && screen_size_x > Device.dwWidth);
SDL_Rect display;
if (SDL_GetDisplayBounds(0, &display) != 0)
{
Log("SDL_GetDisplayBounds display failed: %s", SDL_GetError());
}
u32 screen_size_x = display.w - display.x;
u32 screen_size_y = display.h - display.y;
m_b_use_win_cursor = (screen_size_y >= Device.dwHeight && screen_size_x >= Device.dwWidth);
}

//--------------------------------------------------------------------
Expand Down

0 comments on commit 56c79eb

Please sign in to comment.