From 4f11138e8eb7b03161a5d85dfc31e7a43902f79d Mon Sep 17 00:00:00 2001 From: Spencer Dixon Date: Mon, 21 Jun 2021 19:32:46 -0400 Subject: LibGUI+WindowServer: Add new WMEvent Super+Space To make Assistant useful we need a way to quickly trigger it. I've added a new specialized event coming from the window server for when a user is holding down 'Super' and hits 'Space'. The Taskbar will be able to listen for this event and spawn a new instance of the Assistant if it's not already running. --- Userland/Libraries/LibGUI/Event.h | 9 +++++++++ Userland/Libraries/LibGUI/WindowManagerServerConnection.cpp | 6 ++++++ Userland/Libraries/LibGUI/WindowManagerServerConnection.h | 1 + 3 files changed, 16 insertions(+) (limited to 'Userland/Libraries/LibGUI') diff --git a/Userland/Libraries/LibGUI/Event.h b/Userland/Libraries/LibGUI/Event.h index edbf4ad2c9..92035a8d05 100644 --- a/Userland/Libraries/LibGUI/Event.h +++ b/Userland/Libraries/LibGUI/Event.h @@ -63,6 +63,7 @@ public: WM_WindowIconBitmapChanged, WM_AppletAreaSizeChanged, WM_SuperKeyPressed, + WM_SuperSpaceKeyPressed, __End_WM_Events, }; @@ -102,6 +103,14 @@ public: } }; +class WMSuperSpaceKeyPressedEvent : public WMEvent { +public: + explicit WMSuperSpaceKeyPressedEvent(int client_id) + : WMEvent(Event::Type::WM_SuperSpaceKeyPressed, client_id, 0) + { + } +}; + class WMAppletAreaSizeChangedEvent : public WMEvent { public: explicit WMAppletAreaSizeChangedEvent(const Gfx::IntSize& size) diff --git a/Userland/Libraries/LibGUI/WindowManagerServerConnection.cpp b/Userland/Libraries/LibGUI/WindowManagerServerConnection.cpp index 681e52489e..b3bc301624 100644 --- a/Userland/Libraries/LibGUI/WindowManagerServerConnection.cpp +++ b/Userland/Libraries/LibGUI/WindowManagerServerConnection.cpp @@ -57,4 +57,10 @@ void WindowManagerServerConnection::super_key_pressed(i32 wm_id) if (auto* window = Window::from_window_id(wm_id)) Core::EventLoop::current().post_event(*window, make(wm_id)); } + +void WindowManagerServerConnection::super_space_key_pressed(i32 wm_id) +{ + if (auto* window = Window::from_window_id(wm_id)) + Core::EventLoop::current().post_event(*window, make(wm_id)); +} } diff --git a/Userland/Libraries/LibGUI/WindowManagerServerConnection.h b/Userland/Libraries/LibGUI/WindowManagerServerConnection.h index eddeaf25e5..990dbd1841 100644 --- a/Userland/Libraries/LibGUI/WindowManagerServerConnection.h +++ b/Userland/Libraries/LibGUI/WindowManagerServerConnection.h @@ -32,6 +32,7 @@ private: virtual void window_rect_changed(i32, i32, i32, Gfx::IntRect const&) override; 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; }; } -- cgit v1.2.3