1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:47:35 +00:00

LibGUI+WindowServer: Add new WMEvent Super+Digit

This adds a keyboard event for Super+0 to Super+9. Later to be consumed
in the taskbar.

Currently only this keyboard sequence is supported:
  - Super key down
  - Digit key down

But not this:
  - Super key down
  - Digit key down
  - Digit key up
  - Digit key down
This commit is contained in:
Jan Grau 2022-02-23 21:43:50 +01:00 committed by Linus Groh
parent 001b08dec9
commit 6992a07afc
6 changed files with 41 additions and 0 deletions

View file

@ -66,6 +66,7 @@ public:
WM_AppletAreaSizeChanged,
WM_SuperKeyPressed,
WM_SuperSpaceKeyPressed,
WM_SuperDigitKeyPressed,
WM_WorkspaceChanged,
WM_KeymapChanged,
__End_WM_Events,
@ -115,6 +116,20 @@ public:
}
};
class WMSuperDigitKeyPressedEvent : public WMEvent {
public:
WMSuperDigitKeyPressedEvent(int client_id, u8 digit)
: WMEvent(Event::Type::WM_SuperDigitKeyPressed, client_id, 0)
, m_digit(digit)
{
}
u8 digit() const { return m_digit; }
private:
u8 m_digit { 0 };
};
class WMAppletAreaSizeChangedEvent : public WMEvent {
public:
explicit WMAppletAreaSizeChangedEvent(const Gfx::IntSize& size)

View file

@ -64,6 +64,12 @@ void WindowManagerServerConnection::super_space_key_pressed(i32 wm_id)
Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
}
void WindowManagerServerConnection::super_digit_key_pressed(i32 wm_id, u8 digit)
{
if (auto* window = Window::from_window_id(wm_id))
Core::EventLoop::current().post_event(*window, make<WMSuperDigitKeyPressedEvent>(wm_id, digit));
}
void WindowManagerServerConnection::workspace_changed(i32 wm_id, u32 row, u32 column)
{
if (auto* window = Window::from_window_id(wm_id))

View file

@ -34,6 +34,7 @@ private:
virtual void applet_area_size_changed(i32, Gfx::IntSize const&) override;
virtual void super_key_pressed(i32) override;
virtual void super_space_key_pressed(i32) override;
virtual void super_digit_key_pressed(i32, u8) override;
virtual void workspace_changed(i32, u32, u32) override;
virtual void keymap_changed(i32, String const&) override;
};