From cf073198b401f0bf0a6bdb43c5be253dfcabc1e9 Mon Sep 17 00:00:00 2001 From: Jyrki Vesterinen Date: Thu, 2 Nov 2017 19:34:14 +0200 Subject: [PATCH] Fix tooltips still being drawn over Simply use the list of event dispatchers like the old code did. --- src/gui/core/event/handler.cpp | 11 +++++++++++ src/gui/core/event/handler.hpp | 5 +++++ src/gui/widgets/window.cpp | 11 ++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gui/core/event/handler.cpp b/src/gui/core/event/handler.cpp index 1ccf7aebe9654..0d457cbfb4cfb 100644 --- a/src/gui/core/event/handler.cpp +++ b/src/gui/core/event/handler.cpp @@ -146,6 +146,11 @@ class sdl_event_handler : public events::sdl_handler */ void disconnect(dispatcher* dispatcher); + /** + * Returns all dispatchers in the Z order. + */ + std::vector& get_dispatchers() { return dispatchers_; } + /** The dispatcher that captured the mouse focus. */ dispatcher* mouse_focus; @@ -807,6 +812,12 @@ void disconnect_dispatcher(dispatcher* dispatcher) handler_->disconnect(dispatcher); } +std::vector& get_all_dispatchers() +{ + assert(handler_); + return handler_->get_dispatchers(); +} + void init_mouse_location() { point mouse = get_mouse_position(); diff --git a/src/gui/core/event/handler.hpp b/src/gui/core/event/handler.hpp index d41794dab997b..23bf9545124ed 100644 --- a/src/gui/core/event/handler.hpp +++ b/src/gui/core/event/handler.hpp @@ -247,6 +247,11 @@ void connect_dispatcher(dispatcher* dispatcher); */ void disconnect_dispatcher(dispatcher* dispatcher); +/** + * Gets all event dispatchers in the Z order. + */ +std::vector& get_all_dispatchers(); + /** * Initializes the location of the mouse. * diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 20cd170ac3f61..b2014db17628f 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -1225,15 +1225,12 @@ void window_swap_grid(grid* g, void window::redraw_windows_on_top() const { - auto me = std::find(open_window_stack.begin(), open_window_stack.end(), this); - if(me == open_window_stack.end()) { - // Known to happen for tooltips. - return; - } + std::vector& dispatchers = event::get_all_dispatchers(); + auto me = std::find(dispatchers.begin(), dispatchers.end(), this); - for(auto it = std::next(me); it != open_window_stack.end(); ++it) { + for(auto it = std::next(me); it != dispatchers.end(); ++it) { // Note that setting an entire window dirty like this is expensive. - (*it)->set_is_dirty(true); + dynamic_cast(**it).set_is_dirty(true); } }