Skip to content

Commit d0c11bb

Browse files
Quaker762awesomekling
authored andcommitted
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.
1 parent f37cf5e commit d0c11bb

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Servers/WindowServer/WSMenuManager.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
WSMenuManager::WSMenuManager()
1010
{
1111
m_username = getlogin();
12+
m_needs_window_resize = false;
1213

1314
m_timer = CTimer::construct(300, [this] {
1415
static time_t last_update_time;
@@ -45,6 +46,11 @@ void WSMenuManager::draw()
4546
auto& wm = WSWindowManager::the();
4647
auto menubar_rect = wm.menubar_rect();
4748

49+
if (m_needs_window_resize) {
50+
m_window->set_rect(menubar_rect);
51+
m_needs_window_resize = false;
52+
}
53+
4854
Painter painter(*window().backing_store());
4955

5056
painter.fill_rect(menubar_rect, Color::WarmGray);
@@ -134,8 +140,8 @@ void WSMenuManager::handle_menu_mouse_event(WSMenu& menu, const WSMouseEvent& ev
134140
{
135141
auto& wm = WSWindowManager::the();
136142
bool is_hover_with_any_menu_open = event.type() == WSMouseEvent::MouseMove
137-
&& !m_open_menu_stack.is_empty()
138-
&& (m_open_menu_stack.first()->menubar() || m_open_menu_stack.first() == wm.system_menu());
143+
&& !m_open_menu_stack.is_empty()
144+
&& (m_open_menu_stack.first()->menubar() || m_open_menu_stack.first() == wm.system_menu());
139145
bool is_mousedown_with_left_button = event.type() == WSMouseEvent::MouseDown && event.button() == MouseButton::Left;
140146
bool should_open_menu = &menu != wm.current_menu() && (is_hover_with_any_menu_open || is_mousedown_with_left_button);
141147

@@ -157,3 +163,8 @@ void WSMenuManager::handle_menu_mouse_event(WSMenu& menu, const WSMouseEvent& ev
157163
return;
158164
}
159165
}
166+
167+
void WSMenuManager::set_needs_window_resize()
168+
{
169+
m_needs_window_resize = true;
170+
}

Servers/WindowServer/WSMenuManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class WSMenuManager final : public CObject {
2121

2222
Vector<WeakPtr<WSMenu>>& open_menu_stack() { return m_open_menu_stack; }
2323

24+
void set_needs_window_resize();
25+
2426
private:
2527
WSWindow& window() { return *m_window; }
2628
const WSWindow& window() const { return *m_window; }
@@ -36,4 +38,6 @@ class WSMenuManager final : public CObject {
3638
RefPtr<CTimer> m_timer;
3739

3840
Vector<WeakPtr<WSMenu>> m_open_menu_stack;
41+
42+
bool m_needs_window_resize;
3943
};

Servers/WindowServer/WSWindowManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ const Font& WSWindowManager::app_menu_font() const
196196
void WSWindowManager::set_resolution(int width, int height)
197197
{
198198
WSCompositor::the().set_resolution(width, height);
199+
m_menu_manager.set_needs_window_resize();
199200
WSClientConnection::for_each_client([&](WSClientConnection& client) {
200201
client.notify_about_new_screen_rect(WSScreen::the().rect());
201202
});
@@ -421,7 +422,7 @@ void WSWindowManager::start_window_drag(WSWindow& window, const WSMouseEvent& ev
421422
if (window.is_maximized()) {
422423
auto width_before_resize = window.width();
423424
window.set_maximized(false);
424-
window.move_to(m_drag_origin.x() - (window.width() * ((float) m_drag_origin.x() / width_before_resize)), m_drag_origin.y());
425+
window.move_to(m_drag_origin.x() - (window.width() * ((float)m_drag_origin.x() / width_before_resize)), m_drag_origin.y());
425426
}
426427
m_drag_window_origin = window.position();
427428
invalidate(window);

0 commit comments

Comments
 (0)