mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
WindowServer: Add unadjusted position members to Menu
Used to determine Menu relationships by proxy
This commit is contained in:
parent
7c9ad6cc2f
commit
6c35aac617
Notes:
sideshowbarker
2024-07-17 07:20:23 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/6c35aac617 Pull-request: https://github.com/SerenityOS/serenity/pull/15157
3 changed files with 6 additions and 1 deletions
|
@ -635,7 +635,7 @@ void Menu::do_popup(Gfx::IntPoint const& position, bool make_input, bool as_subm
|
|||
redraw_if_theme_changed();
|
||||
|
||||
constexpr auto margin = 10;
|
||||
Gfx::IntPoint adjusted_pos = position;
|
||||
Gfx::IntPoint adjusted_pos = m_unadjusted_position = position;
|
||||
|
||||
if (adjusted_pos.x() + window.width() > screen.rect().right() - margin) {
|
||||
// Vertically translate the window by its full width, i.e. flip it at its vertical axis.
|
||||
|
|
|
@ -74,6 +74,9 @@ public:
|
|||
Gfx::IntRect rect_in_window_menubar() const { return m_rect_in_window_menubar; }
|
||||
void set_rect_in_window_menubar(Gfx::IntRect const& rect) { m_rect_in_window_menubar = rect; }
|
||||
|
||||
Gfx::IntPoint unadjusted_position() const { return m_unadjusted_position; }
|
||||
void set_unadjusted_position(Gfx::IntPoint const& position) { m_unadjusted_position = position; }
|
||||
|
||||
Window* menu_window() { return m_menu_window.ptr(); }
|
||||
Window& ensure_menu_window(Gfx::IntPoint const&);
|
||||
|
||||
|
@ -150,6 +153,7 @@ private:
|
|||
String m_name;
|
||||
u32 m_alt_shortcut_character { 0 };
|
||||
Gfx::IntRect m_rect_in_window_menubar;
|
||||
Gfx::IntPoint m_unadjusted_position;
|
||||
NonnullOwnPtrVector<MenuItem> m_items;
|
||||
RefPtr<Window> m_menu_window;
|
||||
|
||||
|
|
|
@ -892,6 +892,7 @@ void WindowFrame::open_menubar_menu(Menu& menu)
|
|||
auto menubar_rect = this->menubar_rect();
|
||||
MenuManager::the().close_everyone();
|
||||
auto position = menu.rect_in_window_menubar().bottom_left().translated(rect().location()).translated(menubar_rect.location());
|
||||
menu.set_unadjusted_position(position);
|
||||
auto& window = menu.ensure_menu_window(position);
|
||||
auto window_rect = window.rect();
|
||||
auto& screen = Screen::closest_to_rect(window_rect);
|
||||
|
|
Loading…
Reference in a new issue