1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 20:45:08 +00:00

WindowServer+Taskbar: Let WindowServer manage the "window menus".

Taskbar now simply asks the WindowServer to popup a window menu when right
clicking on a taskbar button.

This patch also implements the "close" menu item, and furthermore makes the
window menu show up when you left-click a window's titlebar icon. :^)
This commit is contained in:
Andreas Kling 2019-06-21 11:03:43 +02:00
parent da475ce3f5
commit 2e9cc75d11
10 changed files with 92 additions and 35 deletions

View file

@ -91,8 +91,7 @@ WSWindowFrame::WSWindowFrame(WSWindow& window)
s_unmaximize_button_bitmap = &CharacterBitmap::create_from_ascii(s_unmaximize_button_bitmap_data, s_unmaximize_button_bitmap_width, s_unmaximize_button_bitmap_height).leak_ref();
m_buttons.append(make<WSButton>(*this, *s_close_button_bitmap, [this](auto&) {
WSEvent close_request(WSEvent::WindowCloseRequest);
m_window.event(close_request);
m_window.request_close();
}));
if (window.is_resizable()) {
@ -271,6 +270,11 @@ void WSWindowFrame::on_mouse_event(const WSMouseEvent& event)
if (m_window.type() != WSWindowType::Normal)
return;
if (event.type() == WSEvent::MouseDown && event.button() == MouseButton::Left && title_bar_icon_rect().contains(event.position())) {
m_window.popup_window_menu(event.position().translated(rect().location()));
return;
}
// This is slightly hackish, but expand the title bar rect by one pixel downwards,
// so that mouse events between the title bar and window contents don't act like
// mouse events on the border.