mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
LibGUI+WindowServer: Add WM_SuperKeyPressed event
This commit adds an event called WM_SuperKeyPressed which is sent to all windows via WindowManagerServerConnection. The event is fired from WindowManager when the super key is pressed, which is the windows key on most keyboards :)
This commit is contained in:
parent
ec3596545a
commit
88ecfa164a
6 changed files with 45 additions and 1 deletions
|
@ -34,6 +34,7 @@
|
|||
#include "Window.h"
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGUI/WindowManagerServerConnection.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/CharacterBitmap.h>
|
||||
#include <LibGfx/Font.h>
|
||||
|
@ -377,6 +378,17 @@ void WindowManager::tell_wms_applet_area_size_changed(const Gfx::IntSize& size)
|
|||
});
|
||||
}
|
||||
|
||||
void WindowManager::tell_wms_super_key_pressed()
|
||||
{
|
||||
for_each_window_manager([](WMClientConnection& conn) {
|
||||
if (conn.window_id() < 0)
|
||||
return IterationDecision::Continue;
|
||||
|
||||
conn.post_message(Messages::WindowManagerClient::SuperKeyPressed(conn.window_id()));
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
static bool window_type_has_title(WindowType type)
|
||||
{
|
||||
return type == WindowType::Normal || type == WindowType::ToolWindow;
|
||||
|
@ -1182,6 +1194,9 @@ Gfx::IntRect WindowManager::arena_rect_for_type(WindowType type) const
|
|||
void WindowManager::event(Core::Event& event)
|
||||
{
|
||||
if (static_cast<Event&>(event).is_mouse_event()) {
|
||||
if (event.type() != Event::MouseMove)
|
||||
m_previous_event_was_super_keydown = false;
|
||||
|
||||
Window* hovered_window = nullptr;
|
||||
process_mouse_event(static_cast<MouseEvent&>(event), hovered_window);
|
||||
set_hovered_window(hovered_window);
|
||||
|
@ -1211,7 +1226,17 @@ void WindowManager::event(Core::Event& event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (MenuManager::the().current_menu()) {
|
||||
if (key_event.type() == Event::KeyDown && key_event.key() == Key_Super) {
|
||||
m_previous_event_was_super_keydown = true;
|
||||
} else if (m_previous_event_was_super_keydown) {
|
||||
m_previous_event_was_super_keydown = false;
|
||||
if (!m_dnd_client && key_event.type() == Event::KeyUp && key_event.key() == Key_Super) {
|
||||
tell_wms_super_key_pressed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (MenuManager::the().current_menu() && key_event.key() != Key_Super) {
|
||||
MenuManager::the().dispatch_event(event);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue