Add keybind F11 to toggle fullscreen

Records the choice through the same user_value
path as a settings-menu edit.
This commit is contained in:
Dipshet
2026-08-07 23:24:01 +02:00
parent 90c1ef45ff
commit 4ca74fd107
2 changed files with 22 additions and 0 deletions
+16
View File
@@ -498,6 +498,19 @@ bool ReXApp::OnInitialize() {
window_->AddListener(this);
window_->AddInputListener(this, 0);
// F11 toggles borderless fullscreen (rebindable via the bind_fullscreen
// cvar). The change is recorded through the same path as a settings-menu
// edit (SetFlagByName -> user_value), so "Save to config" persists it and
// the next launch starts in the chosen mode.
rex::ui::RegisterBind("bind_fullscreen", "F11", "Toggle fullscreen", [this] {
if (!window_) {
return;
}
bool new_fullscreen = !window_->IsFullscreen();
window_->SetFullscreen(new_fullscreen);
rex::cvar::SetFlagByName("fullscreen", new_fullscreen ? "true" : "false");
});
// Attach window to input system so deferred drivers (e.g. MnK) can register
if (runtime_ && runtime_->input_system()) {
static_cast<rex::input::InputSystem*>(runtime_->input_system())->AttachWindow(window_.get());
@@ -610,6 +623,9 @@ void ReXApp::OnDestroy() {
// Notify subclass before cleanup
OnShutdown();
// The fullscreen bind's callback captures this - drop it before teardown.
rex::ui::UnregisterBind("bind_fullscreen");
// ImGui cleanup (reverse of setup)
settings_overlay_.reset();
console_overlay_.reset();
+6
View File
@@ -209,6 +209,12 @@ void UnregisterBind(std::string_view name) {
}
bool ProcessKeyEvent(KeyEvent& e) {
// Auto-repeat never fires binds: every bind is a toggle-style action, so a
// held key would fire it once per repeat (fullscreen thrash, overlay
// flicker). Only the initial down transition counts.
if (e.prev_state()) {
return false;
}
std::lock_guard lock(g_binds_mutex);
for (auto& entry : g_binds) {
if (!entry.callback)