From 5d9c58fd1664d4e27ff41fb33d58d436e3942042 Mon Sep 17 00:00:00 2001 From: casey Date: Thu, 28 Jul 2016 19:26:39 -0700 Subject: [PATCH] Allow tab / shift+tab to defocus command window. --- src/musikbox/app/layout/MainLayout.cpp | 37 +++++++++++++++----------- src/musikbox/app/layout/MainLayout.h | 1 + 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/musikbox/app/layout/MainLayout.cpp b/src/musikbox/app/layout/MainLayout.cpp index f95af0e8c..f7ed37c24 100755 --- a/src/musikbox/app/layout/MainLayout.cpp +++ b/src/musikbox/app/layout/MainLayout.cpp @@ -92,11 +92,11 @@ cursespp::IWindowPtr MainLayout::GetFocus() { IWindowPtr MainLayout::FocusNext() { return (this->shortcutsFocused) - ? this->shortcuts : this->layout->FocusNext(); + ? this->BlurShortcuts() : this->layout->FocusNext(); } IWindowPtr MainLayout::FocusPrev() { return (this->shortcutsFocused) - ? this->shortcuts : this->layout->FocusPrev(); + ? this->BlurShortcuts() : this->layout->FocusPrev(); } void MainLayout::SetMainLayout(std::shared_ptr layout) { @@ -132,6 +132,25 @@ void MainLayout::SetMainLayout(std::shared_ptr layout) { } } +cursespp::IWindowPtr MainLayout::BlurShortcuts() { + this->shortcuts->Blur(); + this->shortcutsFocused = false; + + if (this->layout) { + bool refocused = false; + if (this->lastFocus) { + refocused = this->layout->SetFocus(this->lastFocus); + this->lastFocus.reset(); + } + + if (!refocused) { + this->layout->FocusNext(); + } + } + + return this->layout ? this->layout->GetFocus() : IWindowPtr(); +} + bool MainLayout::KeyPress(const std::string& key) { if (prefs->GetBool(box::prefs::keys::EscFocusesShortcuts)) { if (key == "^[" || @@ -149,19 +168,7 @@ bool MainLayout::KeyPress(const std::string& key) { } } else { - this->shortcuts->Blur(); - - if (this->layout) { - bool refocused = false; - if (this->lastFocus) { - refocused = this->layout->SetFocus(this->lastFocus); - this->lastFocus.reset(); - } - - if (!refocused) { - this->layout->FocusNext(); - } - } + this->BlurShortcuts(); } this->shortcutsFocused diff --git a/src/musikbox/app/layout/MainLayout.h b/src/musikbox/app/layout/MainLayout.h index 5e3eeff78..d80643847 100755 --- a/src/musikbox/app/layout/MainLayout.h +++ b/src/musikbox/app/layout/MainLayout.h @@ -69,6 +69,7 @@ namespace musik { private: void Initialize(); + cursespp::IWindowPtr BlurShortcuts(); std::shared_ptr prefs; std::shared_ptr shortcuts;