diff --git a/src/musikbox/Main.cpp b/src/musikbox/Main.cpp index d65ffb820..6e191d1af 100644 --- a/src/musikbox/Main.cpp +++ b/src/musikbox/Main.cpp @@ -35,6 +35,7 @@ #include "stdafx.h" #include +#include #include #include @@ -58,6 +59,9 @@ using namespace musik::core::audio; using namespace musik::box; using namespace cursespp; +#define MIN_WIDTH 60 +#define MIN_HEIGHT 14 + #ifdef WIN32 int _main(int argc, _TCHAR* argv[]); @@ -79,7 +83,7 @@ int main(int argc, char* argv[]) #endif #ifdef __PDCURSES__ - PDC_set_resize_limits(12, 60, 60, 250); + PDC_set_resize_limits(MIN_HEIGHT, MIN_WIDTH, 60, 250); resize_term(26, 100); /* must be before app init */ #endif @@ -124,7 +128,15 @@ int main(int argc, char* argv[]) }); app.SetResizeHandler([&]() { - mainLayout->Layout(); + int cx = Screen::GetWidth(); + int cy = Screen::GetHeight(); + if (cx <= MIN_WIDTH || cy <= MIN_HEIGHT) { + Window::Freeze(); + } + else { + Window::Unfreeze(); + mainLayout->Layout(); + } }); app.Run(mainLayout); diff --git a/src/musikbox/app/layout/MainLayout.cpp b/src/musikbox/app/layout/MainLayout.cpp index 1bf0e7c35..20c79dc53 100755 --- a/src/musikbox/app/layout/MainLayout.cpp +++ b/src/musikbox/app/layout/MainLayout.cpp @@ -113,17 +113,19 @@ void MainLayout::SetMainLayout(std::shared_ptr layout) { } this->layout = layout; - this->topLevelLayout = dynamic_cast(layout.get()); - this->shortcuts->RemoveAll(); - if (this->topLevelLayout) { - this->topLevelLayout->SetShortcutsWindow(this->shortcuts.get()); - } - this->AddWindow(layout); - this->layout->SetFocusOrder(0); - this->Show(); - this->Layout(); + if (this->layout) { + this->topLevelLayout = dynamic_cast(layout.get()); + if (this->topLevelLayout) { + this->topLevelLayout->SetShortcutsWindow(this->shortcuts.get()); + } + + this->AddWindow(layout); + this->layout->SetFocusOrder(0); + this->Show(); + this->Layout(); + } } } diff --git a/src/musikbox/cursespp/App.cpp b/src/musikbox/cursespp/App.cpp index 8fc8f23d1..914164f32 100755 --- a/src/musikbox/cursespp/App.cpp +++ b/src/musikbox/cursespp/App.cpp @@ -173,7 +173,10 @@ void App::Run(ILayoutPtr layout) { resizeAt = App::Now() + REDRAW_DEBOUNCE_MS; } /* order: focused input, global key handler, then layout. */ - else if (!this->state.input || !this->state.input->Write(kn)) { + else if (!this->state.input || + !this->state.focused->IsVisible() || + !this->state.input->Write(kn)) + { if (!keyHandler || !keyHandler(kn)) { if (!this->state.keyHandler || !this->state.keyHandler->KeyPress(kn)) { this->state.layout->KeyPress(kn); diff --git a/src/musikbox/cursespp/Window.cpp b/src/musikbox/cursespp/Window.cpp index f23354ad1..1031f9d50 100755 --- a/src/musikbox/cursespp/Window.cpp +++ b/src/musikbox/cursespp/Window.cpp @@ -44,9 +44,10 @@ using namespace cursespp; static int NEXT_ID = 0; static bool drawPending = false; +static bool freeze = false; void Window::WriteToScreen(IInput* input) { - if (drawPending) { + if (drawPending && !freeze) { drawPending = false; update_panels(); @@ -72,6 +73,20 @@ void Window::Invalidate() { drawPending = true; } +void Window::Freeze() { + if (!freeze) { + freeze = true; + Window::Invalidate(); + } +} + +void Window::Unfreeze() { + if (freeze) { + freeze = false; + Window::Invalidate(); + } +} + Window::Window(IWindow *parent) { this->frame = this->content = 0; this->framePanel = this->contentPanel = 0; diff --git a/src/musikbox/cursespp/Window.h b/src/musikbox/cursespp/Window.h index f74c9047b..35f3b1e82 100755 --- a/src/musikbox/cursespp/Window.h +++ b/src/musikbox/cursespp/Window.h @@ -88,6 +88,8 @@ namespace cursespp { static void WriteToScreen(IInput* input); static void Invalidate(); + static void Freeze(); + static void Unfreeze(); protected: IWindow* GetParent() const;