mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
WindowServer+LibGUI: Notify clients when menus become visible/hidden
This will allow clients to react to these events.
This commit is contained in:
parent
0315741815
commit
9b740f218b
8 changed files with 49 additions and 9 deletions
|
@ -151,10 +151,10 @@ Window& Menu::ensure_menu_window()
|
|||
}
|
||||
|
||||
auto window = Window::construct(*this, WindowType::Menu);
|
||||
window->set_visible(false);
|
||||
window->set_rect(0, 0, width, window_height);
|
||||
m_menu_window = move(window);
|
||||
draw();
|
||||
|
||||
return *m_menu_window;
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,8 @@ void Menu::update_for_new_hovered_item(bool make_input)
|
|||
hovered_item()->submenu()->do_popup(hovered_item()->rect().top_right().translated(menu_window()->rect().location()), make_input, true);
|
||||
} else {
|
||||
MenuManager::the().close_everyone_not_in_lineage(*this);
|
||||
ensure_menu_window().set_visible(true);
|
||||
ensure_menu_window();
|
||||
set_visible(true);
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
|
@ -593,7 +594,7 @@ void Menu::do_popup(const Gfx::IntPoint& position, bool make_input, bool as_subm
|
|||
}
|
||||
|
||||
window.move_to(adjusted_pos);
|
||||
window.set_visible(true);
|
||||
set_visible(true);
|
||||
MenuManager::the().open_menu(*this, make_input);
|
||||
WindowManager::the().did_popup_a_menu({});
|
||||
}
|
||||
|
@ -612,4 +613,15 @@ bool Menu::is_menu_ancestor_of(const Menu& other) const
|
|||
return false;
|
||||
}
|
||||
|
||||
void Menu::set_visible(bool visible)
|
||||
{
|
||||
if (!menu_window())
|
||||
return;
|
||||
if (visible == menu_window()->is_visible())
|
||||
return;
|
||||
menu_window()->set_visible(visible);
|
||||
if (m_client)
|
||||
m_client->post_message(Messages::WindowClient::MenuVisibilityDidChange(m_menu_id, visible));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue