Skip to content

Commit

Permalink
Merge pull request #491 from ZigTag/rotationmodefix
Browse files Browse the repository at this point in the history
fix: rotationmode now takes mouse priority over panel buttons + alt-tab mouse disappearing fix
  • Loading branch information
jarmonik authored Sep 11, 2024
2 parents 2a9d712 + f3df116 commit 984fe39
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Src/Orbiter/Orbiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const double MinWarpLimit = 0.1; // make variable
const double MaxWarpLimit = 1e5; // make variable
DWORD g_qsaveid = 0;
DWORD g_customcmdid = 0;
int g_iCursorShowCount = 0;

// 2D info output flags
BOOL g_bOutputTime = TRUE;
Expand Down Expand Up @@ -1171,7 +1172,12 @@ void Orbiter::UpdateServerWnd (HWND hWnd)
void Orbiter::InitRotationMode ()
{
bKeepFocus = true;
ShowCursor (FALSE);

// Checks if the cursor is already hidden
if (g_iCursorShowCount == 0) {
g_iCursorShowCount = ShowCursor(FALSE);
}

SetCapture (hRenderWnd);

// Limit cursor to render window confines, so we don't miss the button up event
Expand All @@ -1191,7 +1197,11 @@ void Orbiter::ExitRotationMode ()
{
bKeepFocus = false;
ReleaseCapture ();
ShowCursor (TRUE);

// Checks if the cursor is already hidden
if (g_iCursorShowCount < 0) {
g_iCursorShowCount = ShowCursor (TRUE);
}

// Release cursor from render window confines
if (!bFullscreen && hRenderWnd) {
Expand Down Expand Up @@ -2629,6 +2639,12 @@ void Orbiter::UserJoyInput_OnRunning (DIJOYSTATE2 *js)

bool Orbiter::MouseEvent (UINT event, DWORD state, DWORD x, DWORD y)
{
// Prioritizes mouse handling while in rotation mode
if (g_pOrbiter->StickyFocus()) {
if (event == WM_MOUSEMOVE) return false; // may be lifted later
if (g_camera->ProcessMouse(event, state, x, y, simkstate)) return true;
}

if (g_pane->MIBar() && g_pane->MIBar()->ProcessMouse (event, state, x, y)) return true;
if (BroadcastMouseEvent (event, state, x, y)) return true;
if (event == WM_MOUSEMOVE) return false; // may be lifted later
Expand Down

0 comments on commit 984fe39

Please sign in to comment.