mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:57:41 +00:00
Taskbar+Desktop: Add super+D keyboard shortcut
This shortcut has the same effect as pressing the "Show Desktop" button in the taskbar. This shortcut already exists in Windows.
This commit is contained in:
parent
12682f0bcc
commit
5a3321b899
7 changed files with 38 additions and 0 deletions
|
@ -64,6 +64,12 @@ void ConnectionToWindowManagerServer::super_space_key_pressed(i32 wm_id)
|
||||||
Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
|
Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionToWindowManagerServer::super_d_key_pressed(i32 wm_id)
|
||||||
|
{
|
||||||
|
if (auto* window = Window::from_window_id(wm_id))
|
||||||
|
Core::EventLoop::current().post_event(*window, make<WMSuperDKeyPressedEvent>(wm_id));
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectionToWindowManagerServer::super_digit_key_pressed(i32 wm_id, u8 digit)
|
void ConnectionToWindowManagerServer::super_digit_key_pressed(i32 wm_id, u8 digit)
|
||||||
{
|
{
|
||||||
if (auto* window = Window::from_window_id(wm_id))
|
if (auto* window = Window::from_window_id(wm_id))
|
||||||
|
|
|
@ -34,6 +34,7 @@ private:
|
||||||
virtual void applet_area_size_changed(i32, Gfx::IntSize const&) override;
|
virtual void applet_area_size_changed(i32, Gfx::IntSize const&) override;
|
||||||
virtual void super_key_pressed(i32) override;
|
virtual void super_key_pressed(i32) override;
|
||||||
virtual void super_space_key_pressed(i32) override;
|
virtual void super_space_key_pressed(i32) override;
|
||||||
|
virtual void super_d_key_pressed(i32) override;
|
||||||
virtual void super_digit_key_pressed(i32, u8) override;
|
virtual void super_digit_key_pressed(i32, u8) override;
|
||||||
virtual void workspace_changed(i32, u32, u32) override;
|
virtual void workspace_changed(i32, u32, u32) override;
|
||||||
virtual void keymap_changed(i32, String const&) override;
|
virtual void keymap_changed(i32, String const&) override;
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
WM_AppletAreaSizeChanged,
|
WM_AppletAreaSizeChanged,
|
||||||
WM_SuperKeyPressed,
|
WM_SuperKeyPressed,
|
||||||
WM_SuperSpaceKeyPressed,
|
WM_SuperSpaceKeyPressed,
|
||||||
|
WM_SuperDKeyPressed,
|
||||||
WM_SuperDigitKeyPressed,
|
WM_SuperDigitKeyPressed,
|
||||||
WM_WorkspaceChanged,
|
WM_WorkspaceChanged,
|
||||||
WM_KeymapChanged,
|
WM_KeymapChanged,
|
||||||
|
@ -117,6 +118,14 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WMSuperDKeyPressedEvent : public WMEvent {
|
||||||
|
public:
|
||||||
|
explicit WMSuperDKeyPressedEvent(int client_id)
|
||||||
|
: WMEvent(Event::Type::WM_SuperDKeyPressed, client_id, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class WMSuperDigitKeyPressedEvent : public WMEvent {
|
class WMSuperDigitKeyPressedEvent : public WMEvent {
|
||||||
public:
|
public:
|
||||||
WMSuperDigitKeyPressedEvent(int client_id, u8 digit)
|
WMSuperDigitKeyPressedEvent(int client_id, u8 digit)
|
||||||
|
|
|
@ -344,6 +344,10 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
|
||||||
warnln("failed to spawn 'Assistant' when requested via Super+Space");
|
warnln("failed to spawn 'Assistant' when requested via Super+Space");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GUI::Event::WM_SuperDKeyPressed: {
|
||||||
|
toggle_show_desktop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GUI::Event::WM_SuperDigitKeyPressed: {
|
case GUI::Event::WM_SuperDigitKeyPressed: {
|
||||||
auto& digit_event = static_cast<GUI::WMSuperDigitKeyPressedEvent&>(event);
|
auto& digit_event = static_cast<GUI::WMSuperDigitKeyPressedEvent&>(event);
|
||||||
auto index = digit_event.digit() != 0 ? digit_event.digit() - 1 : 9;
|
auto index = digit_event.digit() != 0 ? digit_event.digit() - 1 : 9;
|
||||||
|
|
|
@ -542,6 +542,17 @@ void WindowManager::tell_wms_super_space_key_pressed()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::tell_wms_super_d_key_pressed()
|
||||||
|
{
|
||||||
|
for_each_window_manager([](WMConnectionFromClient& conn) {
|
||||||
|
if (conn.window_id() < 0)
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
|
||||||
|
conn.async_super_d_key_pressed(conn.window_id());
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::tell_wms_super_digit_key_pressed(u8 digit)
|
void WindowManager::tell_wms_super_digit_key_pressed(u8 digit)
|
||||||
{
|
{
|
||||||
for_each_window_manager([digit](WMConnectionFromClient& conn) {
|
for_each_window_manager([digit](WMConnectionFromClient& conn) {
|
||||||
|
@ -1605,6 +1616,11 @@ void WindowManager::process_key_event(KeyEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.type() == Event::KeyDown && event.key() == Key_D) {
|
||||||
|
tell_wms_super_d_key_pressed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.type() == Event::KeyDown && event.key() >= Key_0 && event.key() <= Key_9) {
|
if (event.type() == Event::KeyDown && event.key() >= Key_0 && event.key() <= Key_9) {
|
||||||
auto digit = event.key() - Key_0;
|
auto digit = event.key() - Key_0;
|
||||||
tell_wms_super_digit_key_pressed(digit);
|
tell_wms_super_digit_key_pressed(digit);
|
||||||
|
|
|
@ -187,6 +187,7 @@ public:
|
||||||
void tell_wms_applet_area_size_changed(Gfx::IntSize const&);
|
void tell_wms_applet_area_size_changed(Gfx::IntSize const&);
|
||||||
void tell_wms_super_key_pressed();
|
void tell_wms_super_key_pressed();
|
||||||
void tell_wms_super_space_key_pressed();
|
void tell_wms_super_space_key_pressed();
|
||||||
|
void tell_wms_super_d_key_pressed();
|
||||||
void tell_wms_super_digit_key_pressed(u8);
|
void tell_wms_super_digit_key_pressed(u8);
|
||||||
void tell_wms_current_window_stack_changed();
|
void tell_wms_current_window_stack_changed();
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ endpoint WindowManagerClient
|
||||||
applet_area_size_changed(i32 wm_id, Gfx::IntSize size) =|
|
applet_area_size_changed(i32 wm_id, Gfx::IntSize size) =|
|
||||||
super_key_pressed(i32 wm_id) =|
|
super_key_pressed(i32 wm_id) =|
|
||||||
super_space_key_pressed(i32 wm_id) =|
|
super_space_key_pressed(i32 wm_id) =|
|
||||||
|
super_d_key_pressed(i32 wm_id) =|
|
||||||
super_digit_key_pressed(i32 wm_id, u8 digit) =|
|
super_digit_key_pressed(i32 wm_id, u8 digit) =|
|
||||||
workspace_changed(i32 wm_id, u32 row, u32 column) =|
|
workspace_changed(i32 wm_id, u32 row, u32 column) =|
|
||||||
keymap_changed(i32 wm_id, [UTF8] String keymap) =|
|
keymap_changed(i32 wm_id, [UTF8] String keymap) =|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue