blob: c7e2f60fdc5e294185260dab84be810641f10578 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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());
}
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;
}
|