1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:17:35 +00:00

WindowServer: Fix incorrect current menu when switching to new item

We were forgetting to update the current menu when switching to a new
item.

We also rename the function from implying that only a redraw is
happening, as is actually not the case. It is now more correctly named:
update_for_new_hovered_item()
This commit is contained in:
Shannon Booth 2020-01-12 15:52:54 +13:00 committed by Andreas Kling
parent 0d2bfc4ea0
commit 4f6b9b64c3
2 changed files with 9 additions and 7 deletions

View file

@ -207,7 +207,7 @@ void WSMenu::draw()
}
}
void WSMenu::redraw_for_new_hovered_item()
void WSMenu::update_for_new_hovered_item()
{
if (m_hovered_item && m_hovered_item->is_submenu()) {
ASSERT(m_hovered_item == &m_items.at(m_current_index));
@ -215,6 +215,8 @@ void WSMenu::redraw_for_new_hovered_item()
m_hovered_item->submenu()->popup(m_hovered_item->rect().top_right().translated(menu_window()->rect().location()), true);
} else {
WSMenuManager::the().close_everyone_not_in_lineage(*this);
WSMenuManager::the().set_current_menu(this);
menu_window()->set_visible(true);
}
redraw();
}
@ -239,7 +241,7 @@ void WSMenu::decend_into_submenu_at_hovered_item()
ASSERT(submenu->m_current_index == 0);
submenu->m_hovered_item = &submenu->m_items.at(0);
ASSERT(submenu->m_hovered_item->type() != WSMenuItem::Separator);
submenu->redraw_for_new_hovered_item();
submenu->update_for_new_hovered_item();
m_in_submenu = true;
}
@ -259,7 +261,7 @@ void WSMenu::event(CEvent& event)
}
m_in_submenu = false;
redraw_for_new_hovered_item();
update_for_new_hovered_item();
return;
}
@ -280,7 +282,7 @@ void WSMenu::event(CEvent& event)
// Default to the first item on key press if one has not been selected yet
if (!m_hovered_item) {
m_hovered_item = &m_items.at(0);
redraw_for_new_hovered_item();
update_for_new_hovered_item();
return;
}
@ -309,7 +311,7 @@ void WSMenu::event(CEvent& event)
m_hovered_item = &m_items.at(m_current_index);
} while (m_hovered_item->type() == WSMenuItem::Separator);
redraw_for_new_hovered_item();
update_for_new_hovered_item();
return;
}
@ -323,7 +325,7 @@ void WSMenu::event(CEvent& event)
m_hovered_item = &m_items.at(m_current_index);
} while (m_hovered_item->type() == WSMenuItem::Separator);
redraw_for_new_hovered_item();
update_for_new_hovered_item();
return;
}