From f134f725fe1806edebd4e6d97034b69cf58910c1 Mon Sep 17 00:00:00 2001 From: Casey Langen Date: Thu, 7 Jul 2016 20:44:23 -0700 Subject: [PATCH] Fixed bug that may result in the Cursor drawing incorrecty for a frame. --- src/musikbox/Main.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/musikbox/Main.cpp b/src/musikbox/Main.cpp index 4ad60d9ed..0eb8d733e 100644 --- a/src/musikbox/Main.cpp +++ b/src/musikbox/Main.cpp @@ -93,10 +93,26 @@ struct WindowState { IKeyHandler* keyHandler; }; +static void checkDrawCursor(WindowState& current) { + if (current.input != NULL) { + curs_set(1); + + if (current.focused) { + wtimeout(current.focused->GetContent(), IDLE_TIMEOUT_MS); + } + } + else { + curs_set(0); + } +} + static void updateFocusedWindow(WindowState& current, IWindowPtr window) { - current.focused = window; - current.input = dynamic_cast(window.get()); - current.keyHandler = dynamic_cast(window.get()); + if (current.focused != window) { + current.focused = window; + current.input = dynamic_cast(window.get()); + current.keyHandler = dynamic_cast(window.get()); + checkDrawCursor(current); + } } static void ensureFocusIsValid(WindowState& current) { @@ -129,26 +145,12 @@ static void changeLayout(WindowState& current, ILayoutPtr newLayout) { } } -static void checkDrawCursor(WindowState& current) { - if (current.input != NULL) { - curs_set(1); - - if (current.focused) { - wtimeout(current.focused->GetContent(), IDLE_TIMEOUT_MS); - } - } - else { - curs_set(0); - } -} - static void focusNextInLayout(WindowState& current) { if (!current.layout) { return; } updateFocusedWindow(current, current.layout->FocusNext()); - checkDrawCursor(current); } static void focusPrevInLayout(WindowState& current) { @@ -157,7 +159,6 @@ static void focusPrevInLayout(WindowState& current) { } updateFocusedWindow(current, current.layout->FocusPrev()); - checkDrawCursor(current); } static inline std::string readKeyPress(int64 ch) {