Bladeren bron

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.
Spencer Dixon 4 jaren geleden
bovenliggende
commit
4f11138e8e

+ 9 - 0
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)

+ 6 - 0
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<WMSuperKeyPressedEvent>(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<WMSuperSpaceKeyPressedEvent>(wm_id));
+}
 }

+ 1 - 0
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;
 };
 
 }

+ 4 - 0
Userland/Services/Taskbar/TaskbarWindow.cpp

@@ -328,6 +328,10 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
         }
         break;
     }
+    case GUI::Event::WM_SuperSpaceKeyPressed: {
+        dbgln("super and space was pressed down");
+        break;
+    }
     default:
         break;
     }

+ 16 - 0
Userland/Services/WindowServer/WindowManager.cpp

@@ -376,6 +376,17 @@ void WindowManager::tell_wms_super_key_pressed()
     });
 }
 
+void WindowManager::tell_wms_super_space_key_pressed()
+{
+    for_each_window_manager([](WMClientConnection& conn) {
+        if (conn.window_id() < 0)
+            return IterationDecision::Continue;
+
+        conn.async_super_space_key_pressed(conn.window_id());
+        return IterationDecision::Continue;
+    });
+}
+
 static bool window_type_has_title(WindowType type)
 {
     return type == WindowType::Normal || type == WindowType::ToolWindow;
@@ -1247,6 +1258,11 @@ void WindowManager::process_key_event(KeyEvent& event)
             tell_wms_super_key_pressed();
             return;
         }
+
+        if (event.type() == Event::KeyDown && event.key() == Key_Space) {
+            tell_wms_super_space_key_pressed();
+            return;
+        }
     }
 
     if (MenuManager::the().current_menu() && event.key() != Key_Super) {

+ 1 - 0
Userland/Services/WindowServer/WindowManager.h

@@ -156,6 +156,7 @@ public:
     void tell_wms_window_rect_changed(Window&);
     void tell_wms_applet_area_size_changed(Gfx::IntSize const&);
     void tell_wms_super_key_pressed();
+    void tell_wms_super_space_key_pressed();
 
     bool is_active_window_or_accessory(Window&) const;
 

+ 1 - 0
Userland/Services/WindowServer/WindowManagerClient.ipc

@@ -6,4 +6,5 @@ endpoint WindowManagerClient
     window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect rect) =|
     applet_area_size_changed(i32 wm_id, Gfx::IntSize size) =|
     super_key_pressed(i32 wm_id) =|
+    super_space_key_pressed(i32 wm_id) =|
 }