mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 15:25: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:
parent
da475ce3f5
commit
2e9cc75d11
10 changed files with 92 additions and 35 deletions
|
@ -314,3 +314,34 @@ void WSWindow::request_update(const Rect& rect)
|
|||
}
|
||||
m_pending_paint_rects.add(rect);
|
||||
}
|
||||
|
||||
void WSWindow::popup_window_menu(const Point& position)
|
||||
{
|
||||
if (!m_window_menu) {
|
||||
m_window_menu = make<WSMenu>(nullptr, -1, "(Window Menu)");
|
||||
m_window_menu->add_item(make<WSMenuItem>(*m_window_menu, 1, "Minimize"));
|
||||
m_window_menu->add_item(make<WSMenuItem>(*m_window_menu, 2, "Unminimize"));
|
||||
m_window_menu->add_item(make<WSMenuItem>(*m_window_menu, 3, "Close"));
|
||||
|
||||
m_window_menu->on_item_activation = [&](auto& item) {
|
||||
switch (item.identifier()) {
|
||||
case 1:
|
||||
set_minimized(true);
|
||||
break;
|
||||
case 2:
|
||||
set_minimized(false);
|
||||
break;
|
||||
case 3:
|
||||
request_close();
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
m_window_menu->popup(position);
|
||||
}
|
||||
|
||||
void WSWindow::request_close()
|
||||
{
|
||||
WSEvent close_request(WSEvent::WindowCloseRequest);
|
||||
event(close_request);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue