mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
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.
This commit is contained in:
parent
66c13edb98
commit
4f11138e8e
Notes:
sideshowbarker
2024-07-18 11:24:48 +09:00
Author: https://github.com/SpencerCDixon Commit: https://github.com/SerenityOS/serenity/commit/4f11138e8eb Pull-request: https://github.com/SerenityOS/serenity/pull/8266 Reviewed-by: https://github.com/Mandar12 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
7 changed files with 38 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) =|
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue