Skip to content

Commit

Permalink
replace cursor visibility with mouse capture
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmanLP committed Dec 18, 2024
1 parent 378781d commit 34d4d5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/graphic/Fast3D/Fast3dWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ void Fast3dWindow::OnFullscreenChanged(bool isNowFullscreen) {

if (isNowFullscreen) {
auto menuBar = wnd->GetGui()->GetMenuBar();
wnd->SetCursorVisibility(menuBar && menuBar->IsVisible() || wnd->ShouldForceCursorVisibility() ||
CVarGetInteger("gWindows.Menu", 0));
wnd->SetMouseCapture(!(menuBar && menuBar->IsVisible() || wnd->ShouldForceCursorVisibility() ||
CVarGetInteger("gWindows.Menu", 0)));
} else {
wnd->SetCursorVisibility(true);
wnd->SetMouseCapture(false);
}
}
} // namespace Fast
13 changes: 6 additions & 7 deletions src/window/gui/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,8 @@ void Gui::DrawMenu() {
GetMenuBar()->ToggleVisibility();
}
if (wnd->IsFullscreen()) {
// TODO: mouse capture?
Context::GetInstance()->GetWindow()->SetCursorVisibility(GetMenuOrMenubarVisible() ||
wnd->ShouldForceCursorVisibility());
Context::GetInstance()->GetWindow()->SetMouseCapture(!(GetMenuOrMenubarVisible() ||
wnd->ShouldForceCursorVisibility()));
}
if (CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && GetMenuOrMenubarVisible()) {
mImGuiIo->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
Expand Down Expand Up @@ -963,9 +962,9 @@ void Gui::SetMenuBar(std::shared_ptr<GuiMenuBar> menuBar) {
}

if (Context::GetInstance()->GetWindow()->IsFullscreen()) {
Context::GetInstance()->GetWindow()->SetCursorVisibility(
Context::GetInstance()->GetWindow()->SetMouseCapture(!(
(GetMenuBar() && GetMenuBar()->IsVisible()) ||
Context::GetInstance()->GetWindow()->ShouldForceCursorVisibility());
Context::GetInstance()->GetWindow()->ShouldForceCursorVisibility()));
}
}

Expand All @@ -977,9 +976,9 @@ void Gui::SetMenu(std::shared_ptr<GuiWindow> menu) {
}

if (Context::GetInstance()->GetWindow()->IsFullscreen()) {
Context::GetInstance()->GetWindow()->SetCursorVisibility(
Context::GetInstance()->GetWindow()->SetMouseCapture(!(
(GetMenu() && GetMenu()->IsVisible()) ||
Context::GetInstance()->GetWindow()->ShouldForceCursorVisibility());
Context::GetInstance()->GetWindow()->ShouldForceCursorVisibility()));
}
}

Expand Down

0 comments on commit 34d4d5c

Please sign in to comment.