Skip to content

Commit

Permalink
Fix tooltips still being drawn over
Browse files Browse the repository at this point in the history
Simply use the list of event dispatchers like the old code did.
  • Loading branch information
jyrkive committed Nov 2, 2017
1 parent 54d7f61 commit a82eb44
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/gui/core/event/handler.cpp
Expand Up @@ -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<dispatcher*>& get_dispatchers() { return dispatchers_; }

/** The dispatcher that captured the mouse focus. */
dispatcher* mouse_focus;

Expand Down Expand Up @@ -807,6 +812,12 @@ void disconnect_dispatcher(dispatcher* dispatcher)
handler_->disconnect(dispatcher);
}

std::vector<dispatcher*>& get_all_dispatchers()
{
assert(handler_);
return handler_->get_dispatchers();
}

void init_mouse_location()
{
point mouse = get_mouse_position();
Expand Down
5 changes: 5 additions & 0 deletions src/gui/core/event/handler.hpp
Expand Up @@ -247,6 +247,11 @@ void connect_dispatcher(dispatcher* dispatcher);
*/
void disconnect_dispatcher(dispatcher* dispatcher);

/**
* Gets all event dispatchers in the Z order.
*/
std::vector<dispatcher*>& get_all_dispatchers();

/**
* Initializes the location of the mouse.
*
Expand Down
11 changes: 4 additions & 7 deletions src/gui/widgets/window.cpp
Expand Up @@ -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<dispatcher*>& 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<widget&>(**it).set_is_dirty(true);
}
}

Expand Down

0 comments on commit a82eb44

Please sign in to comment.