mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
WindowServer+TaskBar: Add a taskbar window button popup menu.
This patch only hooks up the minimize and unminimize actions.
This commit is contained in:
parent
c5c4e54a67
commit
956bd23aae
17 changed files with 158 additions and 56 deletions
48
Applications/Taskbar/TaskbarButton.cpp
Normal file
48
Applications/Taskbar/TaskbarButton.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#include "TaskbarButton.h"
|
||||
#include <WindowServer/WSAPITypes.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
|
||||
static void set_window_minimized_state(const WindowIdentifier& identifier, bool minimized)
|
||||
{
|
||||
WSAPI_ClientMessage message;
|
||||
message.type = WSAPI_ClientMessage::Type::WM_SetWindowMinimized;
|
||||
message.wm.client_id = identifier.client_id();
|
||||
message.wm.window_id = identifier.window_id();
|
||||
message.wm.minimized = minimized;
|
||||
bool success = GEventLoop::post_message_to_server(message);
|
||||
ASSERT(success);
|
||||
}
|
||||
|
||||
TaskbarButton::TaskbarButton(const WindowIdentifier& identifier, GWidget* parent)
|
||||
: GButton(parent)
|
||||
, m_identifier(identifier)
|
||||
{
|
||||
}
|
||||
|
||||
TaskbarButton::~TaskbarButton()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskbarButton::context_menu_event(GContextMenuEvent&)
|
||||
{
|
||||
ensure_menu().popup(screen_relative_rect().location(), /* top_anchored */ false);
|
||||
}
|
||||
|
||||
GMenu& TaskbarButton::ensure_menu()
|
||||
{
|
||||
if (!m_menu) {
|
||||
m_menu = make<GMenu>("");
|
||||
m_menu->add_action(GAction::create("Minimize", [this] (auto&) {
|
||||
set_window_minimized_state(m_identifier, true);
|
||||
}));
|
||||
m_menu->add_action(GAction::create("Unminimize", [this] (auto&) {
|
||||
set_window_minimized_state(m_identifier, false);
|
||||
}));
|
||||
m_menu->add_action(GAction::create("Close", [this] (auto&) {
|
||||
dbgprintf("FIXME: Close!\n");
|
||||
}));
|
||||
}
|
||||
return *m_menu;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue