diff --git a/src/musikbox/CommandWindow.cpp b/src/musikbox/CommandWindow.cpp index c83e29027..f05defea7 100755 --- a/src/musikbox/CommandWindow.cpp +++ b/src/musikbox/CommandWindow.cpp @@ -51,6 +51,14 @@ CommandWindow::~CommandWindow() { delete[] buffer; } +void CommandWindow::Show() { + Window::Show(); + + wmove(this->GetContent(), 0, 0); + std::string buf(buffer, bufferPosition); + wprintw(this->GetContent(), "%s", buf.c_str()); +} + void CommandWindow::Focus() { wmove(this->GetContent(), 0, bufferPosition); } diff --git a/src/musikbox/CommandWindow.h b/src/musikbox/CommandWindow.h index bc762916c..4ebf25eba 100755 --- a/src/musikbox/CommandWindow.h +++ b/src/musikbox/CommandWindow.h @@ -23,6 +23,7 @@ class CommandWindow : public Window, public IInput, public sigslot::has_slots<> virtual void WriteChar(int64 ch); virtual void Focus(); + virtual void Show(); private: void ListPlugins() const; diff --git a/src/musikbox/LayoutBase.cpp b/src/musikbox/LayoutBase.cpp index 86bf3abc2..fd5dfde53 100755 --- a/src/musikbox/LayoutBase.cpp +++ b/src/musikbox/LayoutBase.cpp @@ -113,6 +113,10 @@ void LayoutBase::IndexFocusables() { for (size_t i = 0; i < this->children.size(); i++) { AddFocusable(this->children.at(i)); } + + if (focusedWindow) { + this->focused = find(this->focusable, focusedWindow); + } } void LayoutBase::SortFocusables() { diff --git a/src/musikbox/Main.cpp b/src/musikbox/Main.cpp index 2718ba3fc..4c5a611a1 100644 --- a/src/musikbox/Main.cpp +++ b/src/musikbox/Main.cpp @@ -81,13 +81,14 @@ void changeLayout(WindowState& current, ILayout* newLayout) { current.layout = newLayout; current.layout->Layout(); current.layout->Show(); - current.focused = newLayout->GetFocus(); + current.focused = current.layout->GetFocus(); current.input = dynamic_cast(current.focused); current.scrollable = dynamic_cast(current.focused); } if (current.input) { curs_set(1); + current.input->Focus(); wtimeout(current.focused->GetContent(), IDLE_TIMEOUT_MS); } else { @@ -176,11 +177,6 @@ int main(int argc, char* argv[]) WindowState state = { 0 }; changeLayout(state, &mainLayout); - if (state.input != NULL) { - curs_set(1); - wtimeout(state.focused->GetContent(), IDLE_TIMEOUT_MS); - } - while (!quit) { /* if the focused item is an IInput, then get characters from it, so it can draw a pretty cursor if it wants */