mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +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:
parent
0d2bfc4ea0
commit
4f6b9b64c3
2 changed files with 9 additions and 7 deletions
|
@ -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()) {
|
if (m_hovered_item && m_hovered_item->is_submenu()) {
|
||||||
ASSERT(m_hovered_item == &m_items.at(m_current_index));
|
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);
|
m_hovered_item->submenu()->popup(m_hovered_item->rect().top_right().translated(menu_window()->rect().location()), true);
|
||||||
} else {
|
} else {
|
||||||
WSMenuManager::the().close_everyone_not_in_lineage(*this);
|
WSMenuManager::the().close_everyone_not_in_lineage(*this);
|
||||||
|
WSMenuManager::the().set_current_menu(this);
|
||||||
|
menu_window()->set_visible(true);
|
||||||
}
|
}
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
@ -239,7 +241,7 @@ void WSMenu::decend_into_submenu_at_hovered_item()
|
||||||
ASSERT(submenu->m_current_index == 0);
|
ASSERT(submenu->m_current_index == 0);
|
||||||
submenu->m_hovered_item = &submenu->m_items.at(0);
|
submenu->m_hovered_item = &submenu->m_items.at(0);
|
||||||
ASSERT(submenu->m_hovered_item->type() != WSMenuItem::Separator);
|
ASSERT(submenu->m_hovered_item->type() != WSMenuItem::Separator);
|
||||||
submenu->redraw_for_new_hovered_item();
|
submenu->update_for_new_hovered_item();
|
||||||
m_in_submenu = true;
|
m_in_submenu = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +261,7 @@ void WSMenu::event(CEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_in_submenu = false;
|
m_in_submenu = false;
|
||||||
redraw_for_new_hovered_item();
|
update_for_new_hovered_item();
|
||||||
return;
|
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
|
// Default to the first item on key press if one has not been selected yet
|
||||||
if (!m_hovered_item) {
|
if (!m_hovered_item) {
|
||||||
m_hovered_item = &m_items.at(0);
|
m_hovered_item = &m_items.at(0);
|
||||||
redraw_for_new_hovered_item();
|
update_for_new_hovered_item();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +311,7 @@ void WSMenu::event(CEvent& event)
|
||||||
m_hovered_item = &m_items.at(m_current_index);
|
m_hovered_item = &m_items.at(m_current_index);
|
||||||
} while (m_hovered_item->type() == WSMenuItem::Separator);
|
} while (m_hovered_item->type() == WSMenuItem::Separator);
|
||||||
|
|
||||||
redraw_for_new_hovered_item();
|
update_for_new_hovered_item();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +325,7 @@ void WSMenu::event(CEvent& event)
|
||||||
m_hovered_item = &m_items.at(m_current_index);
|
m_hovered_item = &m_items.at(m_current_index);
|
||||||
} while (m_hovered_item->type() == WSMenuItem::Separator);
|
} while (m_hovered_item->type() == WSMenuItem::Separator);
|
||||||
|
|
||||||
redraw_for_new_hovered_item();
|
update_for_new_hovered_item();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ private:
|
||||||
int padding_between_text_and_shortcut() const { return 50; }
|
int padding_between_text_and_shortcut() const { return 50; }
|
||||||
void did_activate(WSMenuItem&);
|
void did_activate(WSMenuItem&);
|
||||||
void open_hovered_item();
|
void open_hovered_item();
|
||||||
void redraw_for_new_hovered_item();
|
void update_for_new_hovered_item();
|
||||||
void decend_into_submenu_at_hovered_item();
|
void decend_into_submenu_at_hovered_item();
|
||||||
|
|
||||||
WSClientConnection* m_client { nullptr };
|
WSClientConnection* m_client { nullptr };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue