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

WindowServer: Fixed Menubar resize issue

The menubar bar wasn't being resized correctly, as the underlying Window
was never being resized when `DisplayProperties` was chaning the
resolution while the system was running. `m_window` now gets the
correct window size when it's been updated, so a reboot isn't required.
This commit is contained in:
Jesse Buhagiar 2019-10-30 21:06:32 +11:00 committed by Andreas Kling
parent f37cf5ea4a
commit d0c11bbcc3
3 changed files with 19 additions and 3 deletions

View file

@ -9,6 +9,7 @@
WSMenuManager::WSMenuManager()
{
m_username = getlogin();
m_needs_window_resize = false;
m_timer = CTimer::construct(300, [this] {
static time_t last_update_time;
@ -45,6 +46,11 @@ void WSMenuManager::draw()
auto& wm = WSWindowManager::the();
auto menubar_rect = wm.menubar_rect();
if (m_needs_window_resize) {
m_window->set_rect(menubar_rect);
m_needs_window_resize = false;
}
Painter painter(*window().backing_store());
painter.fill_rect(menubar_rect, Color::WarmGray);
@ -134,8 +140,8 @@ void WSMenuManager::handle_menu_mouse_event(WSMenu& menu, const WSMouseEvent& ev
{
auto& wm = WSWindowManager::the();
bool is_hover_with_any_menu_open = event.type() == WSMouseEvent::MouseMove
&& !m_open_menu_stack.is_empty()
&& (m_open_menu_stack.first()->menubar() || m_open_menu_stack.first() == wm.system_menu());
&& !m_open_menu_stack.is_empty()
&& (m_open_menu_stack.first()->menubar() || m_open_menu_stack.first() == wm.system_menu());
bool is_mousedown_with_left_button = event.type() == WSMouseEvent::MouseDown && event.button() == MouseButton::Left;
bool should_open_menu = &menu != wm.current_menu() && (is_hover_with_any_menu_open || is_mousedown_with_left_button);
@ -157,3 +163,8 @@ void WSMenuManager::handle_menu_mouse_event(WSMenu& menu, const WSMouseEvent& ev
return;
}
}
void WSMenuManager::set_needs_window_resize()
{
m_needs_window_resize = true;
}