2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-10-10 15:12:38 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-06-11 21:31:53 +03:00
|
|
|
#include <AK/StringBuilder.h>
|
2020-05-12 23:28:08 +02:00
|
|
|
#include <AK/Vector.h>
|
2020-07-04 17:22:23 +02:00
|
|
|
#include <Kernel/API/KeyCode.h>
|
2020-02-06 15:04:03 +01:00
|
|
|
#include <LibCore/Event.h>
|
2020-08-14 19:56:40 +02:00
|
|
|
#include <LibGUI/FocusSource.h>
|
2021-04-17 18:16:54 +02:00
|
|
|
#include <LibGUI/Forward.h>
|
2020-03-16 13:36:21 +02:00
|
|
|
#include <LibGUI/WindowType.h>
|
2021-01-15 23:13:24 +01:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2020-02-06 12:04:00 +01:00
|
|
|
#include <LibGfx/Point.h>
|
|
|
|
|
#include <LibGfx/Rect.h>
|
2018-10-10 15:12:38 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
|
class Event : public Core::Event {
|
2018-10-10 15:12:38 +02:00
|
|
|
public:
|
2019-06-07 17:13:23 +02:00
|
|
|
enum Type {
|
2019-04-10 16:56:55 +02:00
|
|
|
Show = 1000,
|
2018-10-10 15:12:38 +02:00
|
|
|
Hide,
|
|
|
|
|
Paint,
|
2019-04-20 17:37:28 +02:00
|
|
|
MultiPaint,
|
2019-02-09 11:19:38 +01:00
|
|
|
Resize,
|
2018-10-10 15:12:38 +02:00
|
|
|
MouseMove,
|
|
|
|
|
MouseDown,
|
2019-05-15 22:17:09 +02:00
|
|
|
MouseDoubleClick,
|
2018-10-10 15:12:38 +02:00
|
|
|
MouseUp,
|
2019-05-13 19:52:57 +02:00
|
|
|
MouseWheel,
|
2019-02-20 10:12:19 +01:00
|
|
|
Enter,
|
|
|
|
|
Leave,
|
2018-10-10 15:12:38 +02:00
|
|
|
KeyDown,
|
|
|
|
|
KeyUp,
|
2019-02-20 10:12:19 +01:00
|
|
|
WindowEntered,
|
|
|
|
|
WindowLeft,
|
2019-01-09 04:15:17 +01:00
|
|
|
WindowBecameInactive,
|
|
|
|
|
WindowBecameActive,
|
2020-07-14 19:17:00 -06:00
|
|
|
WindowInputEntered,
|
|
|
|
|
WindowInputLeft,
|
2019-01-26 11:24:16 +01:00
|
|
|
FocusIn,
|
|
|
|
|
FocusOut,
|
2019-02-05 10:31:37 +01:00
|
|
|
WindowCloseRequest,
|
2019-04-18 04:12:27 +02:00
|
|
|
ContextMenu,
|
2019-05-25 13:40:57 +02:00
|
|
|
EnabledChange,
|
2021-01-08 22:23:06 +01:00
|
|
|
DragEnter,
|
|
|
|
|
DragLeave,
|
2020-02-13 21:43:32 +01:00
|
|
|
DragMove,
|
2019-12-08 16:50:23 +01:00
|
|
|
Drop,
|
2020-03-16 13:36:21 +02:00
|
|
|
ThemeChange,
|
2021-07-12 09:57:34 +02:00
|
|
|
FontsChange,
|
2021-06-13 06:16:06 -06:00
|
|
|
ScreenRectsChange,
|
2021-04-17 18:16:54 +02:00
|
|
|
ActionEnter,
|
|
|
|
|
ActionLeave,
|
2021-08-24 13:01:01 +01:00
|
|
|
AppletAreaRectChange,
|
2019-04-20 14:40:38 +02:00
|
|
|
|
|
|
|
|
__Begin_WM_Events,
|
2019-04-03 21:03:12 +02:00
|
|
|
WM_WindowRemoved,
|
|
|
|
|
WM_WindowStateChanged,
|
2019-04-20 14:40:38 +02:00
|
|
|
WM_WindowRectChanged,
|
2019-07-28 10:18:49 +02:00
|
|
|
WM_WindowIconBitmapChanged,
|
2021-03-30 22:41:14 +02:00
|
|
|
WM_AppletAreaSizeChanged,
|
2021-04-17 23:21:24 +01:00
|
|
|
WM_SuperKeyPressed,
|
2021-06-21 19:32:46 -04:00
|
|
|
WM_SuperSpaceKeyPressed,
|
2021-11-13 12:11:35 +01:00
|
|
|
WM_WorkspaceChanged,
|
2019-04-20 14:40:38 +02:00
|
|
|
__End_WM_Events,
|
2018-10-10 15:12:38 +02:00
|
|
|
};
|
|
|
|
|
|
2020-08-14 19:56:40 +02:00
|
|
|
Event() { }
|
2020-02-02 15:07:41 +01:00
|
|
|
explicit Event(Type type)
|
2020-02-02 12:34:39 +01:00
|
|
|
: Core::Event(type)
|
2019-05-28 11:53:16 +02:00
|
|
|
{
|
|
|
|
|
}
|
2020-08-14 19:56:40 +02:00
|
|
|
virtual ~Event() { }
|
2018-10-10 15:12:38 +02:00
|
|
|
|
2019-04-10 16:56:55 +02:00
|
|
|
bool is_key_event() const { return type() == KeyUp || type() == KeyDown; }
|
|
|
|
|
bool is_paint_event() const { return type() == Paint; }
|
2019-04-07 14:36:10 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class WMEvent : public Event {
|
2019-04-03 21:03:12 +02:00
|
|
|
public:
|
2020-02-02 15:07:41 +01:00
|
|
|
WMEvent(Type type, int client_id, int window_id)
|
|
|
|
|
: Event(type)
|
2019-04-03 21:03:12 +02:00
|
|
|
, m_client_id(client_id)
|
|
|
|
|
, m_window_id(window_id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int client_id() const { return m_client_id; }
|
|
|
|
|
int window_id() const { return m_window_id; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_client_id { -1 };
|
|
|
|
|
int m_window_id { -1 };
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-17 23:21:24 +01:00
|
|
|
class WMSuperKeyPressedEvent : public WMEvent {
|
|
|
|
|
public:
|
|
|
|
|
explicit WMSuperKeyPressedEvent(int client_id)
|
|
|
|
|
: WMEvent(Event::Type::WM_SuperKeyPressed, client_id, 0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-21 19:32:46 -04:00
|
|
|
class WMSuperSpaceKeyPressedEvent : public WMEvent {
|
|
|
|
|
public:
|
|
|
|
|
explicit WMSuperSpaceKeyPressedEvent(int client_id)
|
|
|
|
|
: WMEvent(Event::Type::WM_SuperSpaceKeyPressed, client_id, 0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-30 22:41:14 +02:00
|
|
|
class WMAppletAreaSizeChangedEvent : public WMEvent {
|
|
|
|
|
public:
|
|
|
|
|
explicit WMAppletAreaSizeChangedEvent(const Gfx::IntSize& size)
|
|
|
|
|
: WMEvent(Event::Type::WM_AppletAreaSizeChanged, 0, 0)
|
|
|
|
|
, m_size(size)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Gfx::IntSize& size() const { return m_size; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Gfx::IntSize m_size;
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class WMWindowRemovedEvent : public WMEvent {
|
2019-04-03 21:03:12 +02:00
|
|
|
public:
|
2020-02-02 15:07:41 +01:00
|
|
|
WMWindowRemovedEvent(int client_id, int window_id)
|
|
|
|
|
: WMEvent(Event::Type::WM_WindowRemoved, client_id, window_id)
|
2019-04-03 21:03:12 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class WMWindowStateChangedEvent : public WMEvent {
|
2019-04-03 21:03:12 +02:00
|
|
|
public:
|
2021-11-13 12:11:35 +01:00
|
|
|
WMWindowStateChangedEvent(int client_id, int window_id, int parent_client_id, int parent_window_id, StringView title, const Gfx::IntRect& rect, unsigned workspace_row, unsigned workspace_column, bool is_active, bool is_modal, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress)
|
2020-02-02 15:07:41 +01:00
|
|
|
: WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id)
|
2020-07-15 17:40:52 -06:00
|
|
|
, m_parent_client_id(parent_client_id)
|
|
|
|
|
, m_parent_window_id(parent_window_id)
|
2019-04-03 21:03:12 +02:00
|
|
|
, m_title(title)
|
|
|
|
|
, m_rect(rect)
|
2019-04-04 16:23:23 +02:00
|
|
|
, m_window_type(window_type)
|
2021-11-13 12:11:35 +01:00
|
|
|
, m_workspace_row(workspace_row)
|
|
|
|
|
, m_workspace_column(workspace_column)
|
2019-04-13 16:59:55 +02:00
|
|
|
, m_active(is_active)
|
2020-07-15 17:40:52 -06:00
|
|
|
, m_modal(is_modal)
|
2019-04-06 00:57:51 +02:00
|
|
|
, m_minimized(is_minimized)
|
2020-05-02 12:15:48 +02:00
|
|
|
, m_frameless(is_frameless)
|
2020-05-30 22:08:26 +02:00
|
|
|
, m_progress(progress)
|
2019-04-03 21:03:12 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-15 17:40:52 -06:00
|
|
|
int parent_client_id() const { return m_parent_client_id; }
|
|
|
|
|
int parent_window_id() const { return m_parent_window_id; }
|
2020-09-13 13:28:33 +02:00
|
|
|
const String& title() const { return m_title; }
|
|
|
|
|
const Gfx::IntRect& rect() const { return m_rect; }
|
2019-04-04 13:19:26 +02:00
|
|
|
bool is_active() const { return m_active; }
|
2020-07-15 17:40:52 -06:00
|
|
|
bool is_modal() const { return m_modal; }
|
2020-02-02 15:07:41 +01:00
|
|
|
WindowType window_type() const { return m_window_type; }
|
2019-04-06 00:57:51 +02:00
|
|
|
bool is_minimized() const { return m_minimized; }
|
2020-05-02 12:15:48 +02:00
|
|
|
bool is_frameless() const { return m_frameless; }
|
2021-05-02 10:42:25 +02:00
|
|
|
Optional<int> progress() const { return m_progress; }
|
2021-11-13 12:11:35 +01:00
|
|
|
unsigned workspace_row() const { return m_workspace_row; }
|
|
|
|
|
unsigned workspace_column() const { return m_workspace_column; }
|
2019-04-03 21:03:12 +02:00
|
|
|
|
|
|
|
|
private:
|
2020-07-15 17:40:52 -06:00
|
|
|
int m_parent_client_id;
|
|
|
|
|
int m_parent_window_id;
|
2019-04-03 21:03:12 +02:00
|
|
|
String m_title;
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect m_rect;
|
2020-02-02 15:07:41 +01:00
|
|
|
WindowType m_window_type;
|
2021-11-13 12:11:35 +01:00
|
|
|
unsigned m_workspace_row;
|
|
|
|
|
unsigned m_workspace_column;
|
2019-04-13 16:59:55 +02:00
|
|
|
bool m_active;
|
2020-07-15 17:40:52 -06:00
|
|
|
bool m_modal;
|
2019-04-06 00:57:51 +02:00
|
|
|
bool m_minimized;
|
2020-05-02 12:15:48 +02:00
|
|
|
bool m_frameless;
|
2021-05-02 10:42:25 +02:00
|
|
|
Optional<int> m_progress;
|
2019-04-03 21:03:12 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class WMWindowRectChangedEvent : public WMEvent {
|
2019-04-20 14:40:38 +02:00
|
|
|
public:
|
2020-06-10 10:57:59 +02:00
|
|
|
WMWindowRectChangedEvent(int client_id, int window_id, const Gfx::IntRect& rect)
|
2020-02-02 15:07:41 +01:00
|
|
|
: WMEvent(Event::Type::WM_WindowRectChanged, client_id, window_id)
|
2019-04-20 14:40:38 +02:00
|
|
|
, m_rect(rect)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-13 13:28:33 +02:00
|
|
|
const Gfx::IntRect& rect() const { return m_rect; }
|
2019-04-20 14:40:38 +02:00
|
|
|
|
|
|
|
|
private:
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect m_rect;
|
2019-04-20 14:40:38 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class WMWindowIconBitmapChangedEvent : public WMEvent {
|
2019-07-28 10:18:49 +02:00
|
|
|
public:
|
2021-01-15 23:13:24 +01:00
|
|
|
WMWindowIconBitmapChangedEvent(int client_id, int window_id, const Gfx::Bitmap* bitmap)
|
2020-02-02 15:07:41 +01:00
|
|
|
: WMEvent(Event::Type::WM_WindowIconBitmapChanged, client_id, window_id)
|
2021-01-15 23:13:24 +01:00
|
|
|
, m_bitmap(move(bitmap))
|
2019-07-28 10:18:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-15 23:13:24 +01:00
|
|
|
const Gfx::Bitmap* bitmap() const { return m_bitmap; }
|
2019-07-28 10:18:49 +02:00
|
|
|
|
|
|
|
|
private:
|
2021-01-15 23:13:24 +01:00
|
|
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
2019-07-28 10:18:49 +02:00
|
|
|
};
|
|
|
|
|
|
2021-11-13 12:11:35 +01:00
|
|
|
class WMWorkspaceChangedEvent : public WMEvent {
|
2021-06-30 19:12:02 -06:00
|
|
|
public:
|
2021-11-13 12:11:35 +01:00
|
|
|
explicit WMWorkspaceChangedEvent(int client_id, unsigned current_row, unsigned current_column)
|
|
|
|
|
: WMEvent(Event::Type::WM_WorkspaceChanged, client_id, 0)
|
2021-06-30 19:12:02 -06:00
|
|
|
, m_current_row(current_row)
|
|
|
|
|
, m_current_column(current_column)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned current_row() const { return m_current_row; }
|
|
|
|
|
unsigned current_column() const { return m_current_column; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const unsigned m_current_row;
|
|
|
|
|
const unsigned m_current_column;
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class MultiPaintEvent final : public Event {
|
2019-04-20 17:37:28 +02:00
|
|
|
public:
|
2021-10-23 17:38:38 +02:00
|
|
|
explicit MultiPaintEvent(Vector<Gfx::IntRect, 32> rects, Gfx::IntSize const& window_size)
|
2020-02-02 15:07:41 +01:00
|
|
|
: Event(Event::MultiPaint)
|
2021-10-23 17:38:38 +02:00
|
|
|
, m_rects(move(rects))
|
2019-04-20 17:37:28 +02:00
|
|
|
, m_window_size(window_size)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
const Vector<Gfx::IntRect, 32>& rects() const { return m_rects; }
|
2020-09-13 13:28:33 +02:00
|
|
|
const Gfx::IntSize& window_size() const { return m_window_size; }
|
2019-04-20 17:37:28 +02:00
|
|
|
|
|
|
|
|
private:
|
2020-06-10 10:57:59 +02:00
|
|
|
Vector<Gfx::IntRect, 32> m_rects;
|
|
|
|
|
Gfx::IntSize m_window_size;
|
2019-04-20 17:37:28 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class PaintEvent final : public Event {
|
2018-10-10 15:12:38 +02:00
|
|
|
public:
|
2020-06-10 10:57:59 +02:00
|
|
|
explicit PaintEvent(const Gfx::IntRect& rect, const Gfx::IntSize& window_size = {})
|
2020-02-02 15:07:41 +01:00
|
|
|
: Event(Event::Paint)
|
2018-10-12 19:39:48 +02:00
|
|
|
, m_rect(rect)
|
2019-02-26 10:50:25 +01:00
|
|
|
, m_window_size(window_size)
|
2018-10-10 15:12:38 +02:00
|
|
|
{
|
|
|
|
|
}
|
2018-10-12 19:39:48 +02:00
|
|
|
|
2020-09-13 13:28:33 +02:00
|
|
|
const Gfx::IntRect& rect() const { return m_rect; }
|
|
|
|
|
const Gfx::IntSize& window_size() const { return m_window_size; }
|
2019-02-26 10:50:25 +01:00
|
|
|
|
2018-10-12 19:39:48 +02:00
|
|
|
private:
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect m_rect;
|
|
|
|
|
Gfx::IntSize m_window_size;
|
2018-10-10 15:12:38 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class ResizeEvent final : public Event {
|
2019-02-09 11:19:38 +01:00
|
|
|
public:
|
2020-08-22 13:10:35 +02:00
|
|
|
explicit ResizeEvent(const Gfx::IntSize& size)
|
2020-02-02 15:07:41 +01:00
|
|
|
: Event(Event::Resize)
|
2019-02-09 11:19:38 +01:00
|
|
|
, m_size(size)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
const Gfx::IntSize& size() const { return m_size; }
|
2019-05-28 11:53:16 +02:00
|
|
|
|
2019-02-09 11:19:38 +01:00
|
|
|
private:
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntSize m_size;
|
2019-02-09 11:19:38 +01:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class ContextMenuEvent final : public Event {
|
2019-04-18 04:12:27 +02:00
|
|
|
public:
|
2020-06-10 10:57:59 +02:00
|
|
|
explicit ContextMenuEvent(const Gfx::IntPoint& position, const Gfx::IntPoint& screen_position)
|
2020-02-02 15:07:41 +01:00
|
|
|
: Event(Event::ContextMenu)
|
2019-04-18 04:12:27 +02:00
|
|
|
, m_position(position)
|
|
|
|
|
, m_screen_position(screen_position)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
const Gfx::IntPoint& position() const { return m_position; }
|
|
|
|
|
const Gfx::IntPoint& screen_position() const { return m_screen_position; }
|
2019-04-18 04:12:27 +02:00
|
|
|
|
|
|
|
|
private:
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntPoint m_position;
|
|
|
|
|
Gfx::IntPoint m_screen_position;
|
2019-04-18 04:12:27 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class ShowEvent final : public Event {
|
2018-10-10 15:12:38 +02:00
|
|
|
public:
|
2020-02-02 15:07:41 +01:00
|
|
|
ShowEvent()
|
|
|
|
|
: Event(Event::Show)
|
2018-10-10 15:12:38 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class HideEvent final : public Event {
|
2018-10-10 15:12:38 +02:00
|
|
|
public:
|
2020-02-02 15:07:41 +01:00
|
|
|
HideEvent()
|
|
|
|
|
: Event(Event::Hide)
|
2018-10-10 15:12:38 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
enum MouseButton : u8 {
|
2018-10-10 15:12:38 +02:00
|
|
|
None = 0,
|
2021-10-27 13:20:27 +02:00
|
|
|
Primary = 1,
|
|
|
|
|
Secondary = 2,
|
2019-01-21 02:18:16 +01:00
|
|
|
Middle = 4,
|
2021-10-27 18:49:04 +02:00
|
|
|
Backward = 8,
|
2020-05-02 22:07:43 +02:00
|
|
|
Forward = 16,
|
2018-10-10 15:12:38 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class KeyEvent final : public Event {
|
2018-10-10 15:12:38 +02:00
|
|
|
public:
|
2020-06-11 21:31:53 +03:00
|
|
|
KeyEvent(Type type, KeyCode key, u8 modifiers, u32 code_point, u32 scancode)
|
2020-02-02 15:07:41 +01:00
|
|
|
: Event(type)
|
2018-10-10 15:12:38 +02:00
|
|
|
, m_key(key)
|
2019-03-03 12:32:15 +01:00
|
|
|
, m_modifiers(modifiers)
|
2020-06-11 21:31:53 +03:00
|
|
|
, m_code_point(code_point)
|
2020-05-30 15:53:06 +03:00
|
|
|
, m_scancode(scancode)
|
2018-10-10 15:12:38 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 00:29:57 +03:00
|
|
|
KeyCode key() const { return m_key; }
|
2019-03-03 12:32:15 +01:00
|
|
|
bool ctrl() const { return m_modifiers & Mod_Ctrl; }
|
|
|
|
|
bool alt() const { return m_modifiers & Mod_Alt; }
|
|
|
|
|
bool shift() const { return m_modifiers & Mod_Shift; }
|
2021-03-11 18:50:23 +01:00
|
|
|
bool super() const { return m_modifiers & Mod_Super; }
|
2019-07-03 21:17:35 +02:00
|
|
|
u8 modifiers() const { return m_modifiers; }
|
2020-06-11 21:31:53 +03:00
|
|
|
u32 code_point() const { return m_code_point; }
|
|
|
|
|
String text() const
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb;
|
2020-08-05 16:31:20 -04:00
|
|
|
sb.append_code_point(m_code_point);
|
2020-06-11 21:31:53 +03:00
|
|
|
return sb.to_string();
|
|
|
|
|
}
|
2020-05-30 15:53:06 +03:00
|
|
|
u32 scancode() const { return m_scancode; }
|
2018-10-10 15:12:38 +02:00
|
|
|
|
2020-05-12 17:02:59 +02:00
|
|
|
String to_string() const;
|
|
|
|
|
|
2021-10-23 14:31:48 +02:00
|
|
|
bool is_arrow_key() const
|
|
|
|
|
{
|
|
|
|
|
switch (m_key) {
|
|
|
|
|
case KeyCode::Key_Up:
|
|
|
|
|
case KeyCode::Key_Down:
|
|
|
|
|
case KeyCode::Key_Left:
|
|
|
|
|
case KeyCode::Key_Right:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-10 15:12:38 +02:00
|
|
|
private:
|
2020-02-02 15:07:41 +01:00
|
|
|
friend class WindowServerConnection;
|
2020-06-04 16:02:40 +02:00
|
|
|
KeyCode m_key { KeyCode::Key_Invalid };
|
2019-07-03 21:17:35 +02:00
|
|
|
u8 m_modifiers { 0 };
|
2020-06-11 21:31:53 +03:00
|
|
|
u32 m_code_point { 0 };
|
2020-05-30 15:53:06 +03:00
|
|
|
u32 m_scancode { 0 };
|
2018-10-10 15:12:38 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class MouseEvent final : public Event {
|
2018-10-10 15:12:38 +02:00
|
|
|
public:
|
2020-06-10 10:57:59 +02:00
|
|
|
MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta)
|
2020-02-02 15:07:41 +01:00
|
|
|
: Event(type)
|
2019-01-20 05:48:43 +01:00
|
|
|
, m_position(position)
|
2019-01-20 07:03:38 +01:00
|
|
|
, m_buttons(buttons)
|
2018-10-10 15:12:38 +02:00
|
|
|
, m_button(button)
|
2019-03-08 17:53:02 +01:00
|
|
|
, m_modifiers(modifiers)
|
2019-05-13 19:52:57 +02:00
|
|
|
, m_wheel_delta(wheel_delta)
|
2018-10-10 15:12:38 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-13 13:28:33 +02:00
|
|
|
const Gfx::IntPoint& position() const { return m_position; }
|
2018-10-12 01:20:06 +02:00
|
|
|
int x() const { return m_position.x(); }
|
|
|
|
|
int y() const { return m_position.y(); }
|
2020-02-02 15:07:41 +01:00
|
|
|
MouseButton button() const { return m_button; }
|
2019-01-20 07:03:38 +01:00
|
|
|
unsigned buttons() const { return m_buttons; }
|
2020-08-11 21:01:00 -04:00
|
|
|
bool ctrl() const { return m_modifiers & Mod_Ctrl; }
|
|
|
|
|
bool alt() const { return m_modifiers & Mod_Alt; }
|
|
|
|
|
bool shift() const { return m_modifiers & Mod_Shift; }
|
2021-03-11 18:50:23 +01:00
|
|
|
bool super() const { return m_modifiers & Mod_Super; }
|
2019-03-08 17:53:02 +01:00
|
|
|
unsigned modifiers() const { return m_modifiers; }
|
2019-05-13 19:52:57 +02:00
|
|
|
int wheel_delta() const { return m_wheel_delta; }
|
2018-10-10 15:12:38 +02:00
|
|
|
|
|
|
|
|
private:
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntPoint m_position;
|
2019-01-20 07:03:38 +01:00
|
|
|
unsigned m_buttons { 0 };
|
2020-02-02 15:07:41 +01:00
|
|
|
MouseButton m_button { MouseButton::None };
|
2019-03-08 17:53:02 +01:00
|
|
|
unsigned m_modifiers { 0 };
|
2019-05-13 19:52:57 +02:00
|
|
|
int m_wheel_delta { 0 };
|
2018-10-10 15:12:38 +02:00
|
|
|
};
|
2019-12-08 16:50:23 +01:00
|
|
|
|
2020-02-13 21:43:32 +01:00
|
|
|
class DragEvent final : public Event {
|
|
|
|
|
public:
|
2021-01-09 11:01:41 +01:00
|
|
|
DragEvent(Type type, const Gfx::IntPoint& position, Vector<String> mime_types)
|
2020-02-13 21:43:32 +01:00
|
|
|
: Event(type)
|
|
|
|
|
, m_position(position)
|
2021-01-09 11:01:41 +01:00
|
|
|
, m_mime_types(move(mime_types))
|
2020-02-13 21:43:32 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
const Gfx::IntPoint& position() const { return m_position; }
|
2021-01-09 11:01:41 +01:00
|
|
|
const Vector<String>& mime_types() const { return m_mime_types; }
|
2020-02-13 21:43:32 +01:00
|
|
|
|
|
|
|
|
private:
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntPoint m_position;
|
2021-01-09 11:01:41 +01:00
|
|
|
Vector<String> m_mime_types;
|
2020-02-13 21:43:32 +01:00
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class DropEvent final : public Event {
|
2019-12-08 16:50:23 +01:00
|
|
|
public:
|
2020-06-10 10:57:59 +02:00
|
|
|
DropEvent(const Gfx::IntPoint&, const String& text, NonnullRefPtr<Core::MimeData> mime_data);
|
2020-02-14 13:18:34 +01:00
|
|
|
|
|
|
|
|
~DropEvent();
|
2019-12-08 16:50:23 +01:00
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
const Gfx::IntPoint& position() const { return m_position; }
|
2019-12-08 16:50:23 +01:00
|
|
|
const String& text() const { return m_text; }
|
2020-02-14 13:18:34 +01:00
|
|
|
const Core::MimeData& mime_data() const { return m_mime_data; }
|
2019-12-08 16:50:23 +01:00
|
|
|
|
|
|
|
|
private:
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntPoint m_position;
|
2019-12-08 16:50:23 +01:00
|
|
|
String m_text;
|
2020-02-14 13:18:34 +01:00
|
|
|
NonnullRefPtr<Core::MimeData> m_mime_data;
|
2019-12-08 16:50:23 +01:00
|
|
|
};
|
2020-02-02 15:07:41 +01:00
|
|
|
|
2020-03-16 13:36:21 +02:00
|
|
|
class ThemeChangeEvent final : public Event {
|
|
|
|
|
public:
|
|
|
|
|
ThemeChangeEvent()
|
|
|
|
|
: Event(Type::ThemeChange)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-12 09:57:34 +02:00
|
|
|
class FontsChangeEvent final : public Event {
|
|
|
|
|
public:
|
|
|
|
|
FontsChangeEvent()
|
|
|
|
|
: Event(Type::FontsChange)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-13 06:16:06 -06:00
|
|
|
class ScreenRectsChangeEvent final : public Event {
|
2021-04-04 00:02:22 +02:00
|
|
|
public:
|
2021-06-13 06:16:06 -06:00
|
|
|
explicit ScreenRectsChangeEvent(const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index)
|
|
|
|
|
: Event(Type::ScreenRectsChange)
|
|
|
|
|
, m_rects(rects)
|
|
|
|
|
, m_main_screen_index(main_screen_index)
|
2021-04-04 00:02:22 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 06:16:06 -06:00
|
|
|
const Vector<Gfx::IntRect, 4>& rects() const { return m_rects; }
|
|
|
|
|
size_t main_screen_index() const { return m_main_screen_index; }
|
2021-04-04 00:02:22 +02:00
|
|
|
|
|
|
|
|
private:
|
2021-06-13 06:16:06 -06:00
|
|
|
Vector<Gfx::IntRect, 4> m_rects;
|
|
|
|
|
size_t m_main_screen_index;
|
2021-04-04 00:02:22 +02:00
|
|
|
};
|
|
|
|
|
|
2021-08-24 13:01:01 +01:00
|
|
|
class AppletAreaRectChangeEvent final : public Event {
|
|
|
|
|
public:
|
|
|
|
|
explicit AppletAreaRectChangeEvent(Gfx::IntRect rect)
|
|
|
|
|
: Event(Type::AppletAreaRectChange)
|
|
|
|
|
, m_rect(rect)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::IntRect rect() const { return m_rect; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Gfx::IntRect const m_rect;
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-14 19:56:40 +02:00
|
|
|
class FocusEvent final : public Event {
|
|
|
|
|
public:
|
|
|
|
|
explicit FocusEvent(Type type, FocusSource source)
|
|
|
|
|
: Event(type)
|
|
|
|
|
, m_source(source)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FocusSource source() const { return m_source; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
FocusSource m_source { FocusSource::Programmatic };
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-17 18:16:54 +02:00
|
|
|
class ActionEvent final : public Event {
|
|
|
|
|
public:
|
|
|
|
|
ActionEvent(Type, Action&);
|
|
|
|
|
~ActionEvent();
|
|
|
|
|
|
|
|
|
|
Action const& action() const { return *m_action; }
|
|
|
|
|
Action& action() { return *m_action; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
NonnullRefPtr<Action> m_action;
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
}
|