2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2018-10-10 16:12:38 +03:00
|
|
|
#pragma once
|
|
|
|
|
2020-06-11 21:31:53 +03:00
|
|
|
#include <AK/StringBuilder.h>
|
2020-05-13 00:28:08 +03:00
|
|
|
#include <AK/Vector.h>
|
2020-07-04 18:22:23 +03:00
|
|
|
#include <Kernel/API/KeyCode.h>
|
2020-02-06 17:04:03 +03:00
|
|
|
#include <LibCore/Event.h>
|
2020-08-14 20:56:40 +03:00
|
|
|
#include <LibGUI/FocusSource.h>
|
2020-03-16 14:36:21 +03:00
|
|
|
#include <LibGUI/WindowType.h>
|
2021-01-16 01:13:24 +03:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2020-02-06 14:04:00 +03:00
|
|
|
#include <LibGfx/Point.h>
|
|
|
|
#include <LibGfx/Rect.h>
|
2018-10-10 16:12:38 +03:00
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
class Event : public Core::Event {
|
2018-10-10 16:12:38 +03:00
|
|
|
public:
|
2019-06-07 18:13:23 +03:00
|
|
|
enum Type {
|
2019-04-10 17:56:55 +03:00
|
|
|
Show = 1000,
|
2018-10-10 16:12:38 +03:00
|
|
|
Hide,
|
|
|
|
Paint,
|
2019-04-20 18:37:28 +03:00
|
|
|
MultiPaint,
|
2019-02-09 13:19:38 +03:00
|
|
|
Resize,
|
2018-10-10 16:12:38 +03:00
|
|
|
MouseMove,
|
|
|
|
MouseDown,
|
2019-05-15 23:17:09 +03:00
|
|
|
MouseDoubleClick,
|
2018-10-10 16:12:38 +03:00
|
|
|
MouseUp,
|
2019-05-13 20:52:57 +03:00
|
|
|
MouseWheel,
|
2019-02-20 12:12:19 +03:00
|
|
|
Enter,
|
|
|
|
Leave,
|
2018-10-10 16:12:38 +03:00
|
|
|
KeyDown,
|
|
|
|
KeyUp,
|
2019-02-20 12:12:19 +03:00
|
|
|
WindowEntered,
|
|
|
|
WindowLeft,
|
2019-01-09 06:15:17 +03:00
|
|
|
WindowBecameInactive,
|
|
|
|
WindowBecameActive,
|
2020-07-15 04:17:00 +03:00
|
|
|
WindowInputEntered,
|
|
|
|
WindowInputLeft,
|
2019-01-26 13:24:16 +03:00
|
|
|
FocusIn,
|
|
|
|
FocusOut,
|
2019-02-05 12:31:37 +03:00
|
|
|
WindowCloseRequest,
|
2019-04-18 05:12:27 +03:00
|
|
|
ContextMenu,
|
2019-05-25 14:40:57 +03:00
|
|
|
EnabledChange,
|
2021-01-09 00:23:06 +03:00
|
|
|
DragEnter,
|
|
|
|
DragLeave,
|
2020-02-13 23:43:32 +03:00
|
|
|
DragMove,
|
2019-12-08 18:50:23 +03:00
|
|
|
Drop,
|
2020-03-16 14:36:21 +03:00
|
|
|
ThemeChange,
|
2021-04-04 01:02:22 +03:00
|
|
|
ScreenRectChange,
|
2019-04-20 15:40:38 +03:00
|
|
|
|
|
|
|
__Begin_WM_Events,
|
2019-04-03 22:03:12 +03:00
|
|
|
WM_WindowRemoved,
|
|
|
|
WM_WindowStateChanged,
|
2019-04-20 15:40:38 +03:00
|
|
|
WM_WindowRectChanged,
|
2019-07-28 11:18:49 +03:00
|
|
|
WM_WindowIconBitmapChanged,
|
2021-03-30 23:41:14 +03:00
|
|
|
WM_AppletAreaSizeChanged,
|
2019-04-20 15:40:38 +03:00
|
|
|
__End_WM_Events,
|
2018-10-10 16:12:38 +03:00
|
|
|
};
|
|
|
|
|
2020-08-14 20:56:40 +03:00
|
|
|
Event() { }
|
2020-02-02 17:07:41 +03:00
|
|
|
explicit Event(Type type)
|
2020-02-02 14:34:39 +03:00
|
|
|
: Core::Event(type)
|
2019-05-28 12:53:16 +03:00
|
|
|
{
|
|
|
|
}
|
2020-08-14 20:56:40 +03:00
|
|
|
virtual ~Event() { }
|
2018-10-10 16:12:38 +03:00
|
|
|
|
2019-04-10 17:56:55 +03:00
|
|
|
bool is_key_event() const { return type() == KeyUp || type() == KeyDown; }
|
|
|
|
bool is_paint_event() const { return type() == Paint; }
|
2019-04-07 15:36:10 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class WMEvent : public Event {
|
2019-04-03 22:03:12 +03:00
|
|
|
public:
|
2020-02-02 17:07:41 +03:00
|
|
|
WMEvent(Type type, int client_id, int window_id)
|
|
|
|
: Event(type)
|
2019-04-03 22:03:12 +03: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-03-30 23:41:14 +03: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 17:07:41 +03:00
|
|
|
class WMWindowRemovedEvent : public WMEvent {
|
2019-04-03 22:03:12 +03:00
|
|
|
public:
|
2020-02-02 17:07:41 +03:00
|
|
|
WMWindowRemovedEvent(int client_id, int window_id)
|
|
|
|
: WMEvent(Event::Type::WM_WindowRemoved, client_id, window_id)
|
2019-04-03 22:03:12 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class WMWindowStateChangedEvent : public WMEvent {
|
2019-04-03 22:03:12 +03:00
|
|
|
public:
|
2020-07-16 02:40:52 +03:00
|
|
|
WMWindowStateChangedEvent(int client_id, int window_id, int parent_client_id, int parent_window_id, const StringView& title, const Gfx::IntRect& rect, bool is_active, bool is_modal, WindowType window_type, bool is_minimized, bool is_frameless, int progress)
|
2020-02-02 17:07:41 +03:00
|
|
|
: WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id)
|
2020-07-16 02:40:52 +03:00
|
|
|
, m_parent_client_id(parent_client_id)
|
|
|
|
, m_parent_window_id(parent_window_id)
|
2019-04-03 22:03:12 +03:00
|
|
|
, m_title(title)
|
|
|
|
, m_rect(rect)
|
2019-04-04 17:23:23 +03:00
|
|
|
, m_window_type(window_type)
|
2019-04-13 17:59:55 +03:00
|
|
|
, m_active(is_active)
|
2020-07-16 02:40:52 +03:00
|
|
|
, m_modal(is_modal)
|
2019-04-06 01:57:51 +03:00
|
|
|
, m_minimized(is_minimized)
|
2020-05-02 13:15:48 +03:00
|
|
|
, m_frameless(is_frameless)
|
2020-05-30 23:08:26 +03:00
|
|
|
, m_progress(progress)
|
2019-04-03 22:03:12 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-16 02:40:52 +03:00
|
|
|
int parent_client_id() const { return m_parent_client_id; }
|
|
|
|
int parent_window_id() const { return m_parent_window_id; }
|
2020-09-13 14:28:33 +03:00
|
|
|
const String& title() const { return m_title; }
|
|
|
|
const Gfx::IntRect& rect() const { return m_rect; }
|
2019-04-04 14:19:26 +03:00
|
|
|
bool is_active() const { return m_active; }
|
2020-07-16 02:40:52 +03:00
|
|
|
bool is_modal() const { return m_modal; }
|
2020-02-02 17:07:41 +03:00
|
|
|
WindowType window_type() const { return m_window_type; }
|
2019-04-06 01:57:51 +03:00
|
|
|
bool is_minimized() const { return m_minimized; }
|
2020-05-02 13:15:48 +03:00
|
|
|
bool is_frameless() const { return m_frameless; }
|
2020-05-30 23:08:26 +03:00
|
|
|
int progress() const { return m_progress; }
|
2019-04-03 22:03:12 +03:00
|
|
|
|
|
|
|
private:
|
2020-07-16 02:40:52 +03:00
|
|
|
int m_parent_client_id;
|
|
|
|
int m_parent_window_id;
|
2019-04-03 22:03:12 +03:00
|
|
|
String m_title;
|
2020-06-10 11:57:59 +03:00
|
|
|
Gfx::IntRect m_rect;
|
2020-02-02 17:07:41 +03:00
|
|
|
WindowType m_window_type;
|
2019-04-13 17:59:55 +03:00
|
|
|
bool m_active;
|
2020-07-16 02:40:52 +03:00
|
|
|
bool m_modal;
|
2019-04-06 01:57:51 +03:00
|
|
|
bool m_minimized;
|
2020-05-02 13:15:48 +03:00
|
|
|
bool m_frameless;
|
2020-05-30 23:08:26 +03:00
|
|
|
int m_progress;
|
2019-04-03 22:03:12 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class WMWindowRectChangedEvent : public WMEvent {
|
2019-04-20 15:40:38 +03:00
|
|
|
public:
|
2020-06-10 11:57:59 +03:00
|
|
|
WMWindowRectChangedEvent(int client_id, int window_id, const Gfx::IntRect& rect)
|
2020-02-02 17:07:41 +03:00
|
|
|
: WMEvent(Event::Type::WM_WindowRectChanged, client_id, window_id)
|
2019-04-20 15:40:38 +03:00
|
|
|
, m_rect(rect)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-09-13 14:28:33 +03:00
|
|
|
const Gfx::IntRect& rect() const { return m_rect; }
|
2019-04-20 15:40:38 +03:00
|
|
|
|
|
|
|
private:
|
2020-06-10 11:57:59 +03:00
|
|
|
Gfx::IntRect m_rect;
|
2019-04-20 15:40:38 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class WMWindowIconBitmapChangedEvent : public WMEvent {
|
2019-07-28 11:18:49 +03:00
|
|
|
public:
|
2021-01-16 01:13:24 +03:00
|
|
|
WMWindowIconBitmapChangedEvent(int client_id, int window_id, const Gfx::Bitmap* bitmap)
|
2020-02-02 17:07:41 +03:00
|
|
|
: WMEvent(Event::Type::WM_WindowIconBitmapChanged, client_id, window_id)
|
2021-01-16 01:13:24 +03:00
|
|
|
, m_bitmap(move(bitmap))
|
2019-07-28 11:18:49 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-16 01:13:24 +03:00
|
|
|
const Gfx::Bitmap* bitmap() const { return m_bitmap; }
|
2019-07-28 11:18:49 +03:00
|
|
|
|
|
|
|
private:
|
2021-01-16 01:13:24 +03:00
|
|
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
2019-07-28 11:18:49 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class MultiPaintEvent final : public Event {
|
2019-04-20 18:37:28 +03:00
|
|
|
public:
|
2020-06-10 11:57:59 +03:00
|
|
|
explicit MultiPaintEvent(const Vector<Gfx::IntRect, 32>& rects, const Gfx::IntSize& window_size)
|
2020-02-02 17:07:41 +03:00
|
|
|
: Event(Event::MultiPaint)
|
2019-04-20 18:37:28 +03:00
|
|
|
, m_rects(rects)
|
|
|
|
, m_window_size(window_size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-06-10 11:57:59 +03:00
|
|
|
const Vector<Gfx::IntRect, 32>& rects() const { return m_rects; }
|
2020-09-13 14:28:33 +03:00
|
|
|
const Gfx::IntSize& window_size() const { return m_window_size; }
|
2019-04-20 18:37:28 +03:00
|
|
|
|
|
|
|
private:
|
2020-06-10 11:57:59 +03:00
|
|
|
Vector<Gfx::IntRect, 32> m_rects;
|
|
|
|
Gfx::IntSize m_window_size;
|
2019-04-20 18:37:28 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class PaintEvent final : public Event {
|
2018-10-10 16:12:38 +03:00
|
|
|
public:
|
2020-06-10 11:57:59 +03:00
|
|
|
explicit PaintEvent(const Gfx::IntRect& rect, const Gfx::IntSize& window_size = {})
|
2020-02-02 17:07:41 +03:00
|
|
|
: Event(Event::Paint)
|
2018-10-12 20:39:48 +03:00
|
|
|
, m_rect(rect)
|
2019-02-26 12:50:25 +03:00
|
|
|
, m_window_size(window_size)
|
2018-10-10 16:12:38 +03:00
|
|
|
{
|
|
|
|
}
|
2018-10-12 20:39:48 +03:00
|
|
|
|
2020-09-13 14:28:33 +03:00
|
|
|
const Gfx::IntRect& rect() const { return m_rect; }
|
|
|
|
const Gfx::IntSize& window_size() const { return m_window_size; }
|
2019-02-26 12:50:25 +03:00
|
|
|
|
2018-10-12 20:39:48 +03:00
|
|
|
private:
|
2020-06-10 11:57:59 +03:00
|
|
|
Gfx::IntRect m_rect;
|
|
|
|
Gfx::IntSize m_window_size;
|
2018-10-10 16:12:38 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class ResizeEvent final : public Event {
|
2019-02-09 13:19:38 +03:00
|
|
|
public:
|
2020-08-22 14:10:35 +03:00
|
|
|
explicit ResizeEvent(const Gfx::IntSize& size)
|
2020-02-02 17:07:41 +03:00
|
|
|
: Event(Event::Resize)
|
2019-02-09 13:19:38 +03:00
|
|
|
, m_size(size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-06-10 11:57:59 +03:00
|
|
|
const Gfx::IntSize& size() const { return m_size; }
|
2019-05-28 12:53:16 +03:00
|
|
|
|
2019-02-09 13:19:38 +03:00
|
|
|
private:
|
2020-06-10 11:57:59 +03:00
|
|
|
Gfx::IntSize m_size;
|
2019-02-09 13:19:38 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class ContextMenuEvent final : public Event {
|
2019-04-18 05:12:27 +03:00
|
|
|
public:
|
2020-06-10 11:57:59 +03:00
|
|
|
explicit ContextMenuEvent(const Gfx::IntPoint& position, const Gfx::IntPoint& screen_position)
|
2020-02-02 17:07:41 +03:00
|
|
|
: Event(Event::ContextMenu)
|
2019-04-18 05:12:27 +03:00
|
|
|
, m_position(position)
|
|
|
|
, m_screen_position(screen_position)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-06-10 11:57:59 +03:00
|
|
|
const Gfx::IntPoint& position() const { return m_position; }
|
|
|
|
const Gfx::IntPoint& screen_position() const { return m_screen_position; }
|
2019-04-18 05:12:27 +03:00
|
|
|
|
|
|
|
private:
|
2020-06-10 11:57:59 +03:00
|
|
|
Gfx::IntPoint m_position;
|
|
|
|
Gfx::IntPoint m_screen_position;
|
2019-04-18 05:12:27 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class ShowEvent final : public Event {
|
2018-10-10 16:12:38 +03:00
|
|
|
public:
|
2020-02-02 17:07:41 +03:00
|
|
|
ShowEvent()
|
|
|
|
: Event(Event::Show)
|
2018-10-10 16:12:38 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class HideEvent final : public Event {
|
2018-10-10 16:12:38 +03:00
|
|
|
public:
|
2020-02-02 17:07:41 +03:00
|
|
|
HideEvent()
|
|
|
|
: Event(Event::Hide)
|
2018-10-10 16:12:38 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
enum MouseButton : u8 {
|
2018-10-10 16:12:38 +03:00
|
|
|
None = 0,
|
2019-01-21 04:18:16 +03:00
|
|
|
Left = 1,
|
|
|
|
Right = 2,
|
|
|
|
Middle = 4,
|
2020-05-02 23:07:43 +03:00
|
|
|
Back = 8,
|
|
|
|
Forward = 16,
|
2018-10-10 16:12:38 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class KeyEvent final : public Event {
|
2018-10-10 16:12:38 +03: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 17:07:41 +03:00
|
|
|
: Event(type)
|
2018-10-10 16:12:38 +03:00
|
|
|
, m_key(key)
|
2019-03-03 14:32:15 +03: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 16:12:38 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-05-27 00:29:57 +03:00
|
|
|
KeyCode key() const { return m_key; }
|
2019-03-03 14:32:15 +03: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 20:50:23 +03:00
|
|
|
bool super() const { return m_modifiers & Mod_Super; }
|
2019-07-03 22:17:35 +03: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 23:31:20 +03: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 16:12:38 +03:00
|
|
|
|
2020-05-12 18:02:59 +03:00
|
|
|
String to_string() const;
|
|
|
|
|
2018-10-10 16:12:38 +03:00
|
|
|
private:
|
2020-02-02 17:07:41 +03:00
|
|
|
friend class WindowServerConnection;
|
2020-06-04 17:02:40 +03:00
|
|
|
KeyCode m_key { KeyCode::Key_Invalid };
|
2019-07-03 22:17:35 +03: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 16:12:38 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class MouseEvent final : public Event {
|
2018-10-10 16:12:38 +03:00
|
|
|
public:
|
2020-06-10 11:57:59 +03:00
|
|
|
MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta)
|
2020-02-02 17:07:41 +03:00
|
|
|
: Event(type)
|
2019-01-20 07:48:43 +03:00
|
|
|
, m_position(position)
|
2019-01-20 09:03:38 +03:00
|
|
|
, m_buttons(buttons)
|
2018-10-10 16:12:38 +03:00
|
|
|
, m_button(button)
|
2019-03-08 19:53:02 +03:00
|
|
|
, m_modifiers(modifiers)
|
2019-05-13 20:52:57 +03:00
|
|
|
, m_wheel_delta(wheel_delta)
|
2018-10-10 16:12:38 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-09-13 14:28:33 +03:00
|
|
|
const Gfx::IntPoint& position() const { return m_position; }
|
2018-10-12 02:20:06 +03:00
|
|
|
int x() const { return m_position.x(); }
|
|
|
|
int y() const { return m_position.y(); }
|
2020-02-02 17:07:41 +03:00
|
|
|
MouseButton button() const { return m_button; }
|
2019-01-20 09:03:38 +03:00
|
|
|
unsigned buttons() const { return m_buttons; }
|
2020-08-12 04:01:00 +03: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 20:50:23 +03:00
|
|
|
bool super() const { return m_modifiers & Mod_Super; }
|
2019-03-08 19:53:02 +03:00
|
|
|
unsigned modifiers() const { return m_modifiers; }
|
2019-05-13 20:52:57 +03:00
|
|
|
int wheel_delta() const { return m_wheel_delta; }
|
2018-10-10 16:12:38 +03:00
|
|
|
|
|
|
|
private:
|
2020-06-10 11:57:59 +03:00
|
|
|
Gfx::IntPoint m_position;
|
2019-01-20 09:03:38 +03:00
|
|
|
unsigned m_buttons { 0 };
|
2020-02-02 17:07:41 +03:00
|
|
|
MouseButton m_button { MouseButton::None };
|
2019-03-08 19:53:02 +03:00
|
|
|
unsigned m_modifiers { 0 };
|
2019-05-13 20:52:57 +03:00
|
|
|
int m_wheel_delta { 0 };
|
2018-10-10 16:12:38 +03:00
|
|
|
};
|
2019-12-08 18:50:23 +03:00
|
|
|
|
2020-02-13 23:43:32 +03:00
|
|
|
class DragEvent final : public Event {
|
|
|
|
public:
|
2021-01-09 13:01:41 +03:00
|
|
|
DragEvent(Type type, const Gfx::IntPoint& position, Vector<String> mime_types)
|
2020-02-13 23:43:32 +03:00
|
|
|
: Event(type)
|
|
|
|
, m_position(position)
|
2021-01-09 13:01:41 +03:00
|
|
|
, m_mime_types(move(mime_types))
|
2020-02-13 23:43:32 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-06-10 11:57:59 +03:00
|
|
|
const Gfx::IntPoint& position() const { return m_position; }
|
2021-01-09 13:01:41 +03:00
|
|
|
const Vector<String>& mime_types() const { return m_mime_types; }
|
2020-02-13 23:43:32 +03:00
|
|
|
|
|
|
|
private:
|
2020-06-10 11:57:59 +03:00
|
|
|
Gfx::IntPoint m_position;
|
2021-01-09 13:01:41 +03:00
|
|
|
Vector<String> m_mime_types;
|
2020-02-13 23:43:32 +03:00
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class DropEvent final : public Event {
|
2019-12-08 18:50:23 +03:00
|
|
|
public:
|
2020-06-10 11:57:59 +03:00
|
|
|
DropEvent(const Gfx::IntPoint&, const String& text, NonnullRefPtr<Core::MimeData> mime_data);
|
2020-02-14 15:18:34 +03:00
|
|
|
|
|
|
|
~DropEvent();
|
2019-12-08 18:50:23 +03:00
|
|
|
|
2020-06-10 11:57:59 +03:00
|
|
|
const Gfx::IntPoint& position() const { return m_position; }
|
2019-12-08 18:50:23 +03:00
|
|
|
const String& text() const { return m_text; }
|
2020-02-14 15:18:34 +03:00
|
|
|
const Core::MimeData& mime_data() const { return m_mime_data; }
|
2019-12-08 18:50:23 +03:00
|
|
|
|
|
|
|
private:
|
2020-06-10 11:57:59 +03:00
|
|
|
Gfx::IntPoint m_position;
|
2019-12-08 18:50:23 +03:00
|
|
|
String m_text;
|
2020-02-14 15:18:34 +03:00
|
|
|
NonnullRefPtr<Core::MimeData> m_mime_data;
|
2019-12-08 18:50:23 +03:00
|
|
|
};
|
2020-02-02 17:07:41 +03:00
|
|
|
|
2020-03-16 14:36:21 +03:00
|
|
|
class ThemeChangeEvent final : public Event {
|
|
|
|
public:
|
|
|
|
ThemeChangeEvent()
|
|
|
|
: Event(Type::ThemeChange)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-04 01:02:22 +03:00
|
|
|
class ScreenRectChangeEvent final : public Event {
|
|
|
|
public:
|
|
|
|
explicit ScreenRectChangeEvent(const Gfx::IntRect& rect)
|
|
|
|
: Event(Type::ScreenRectChange)
|
|
|
|
, m_rect(rect)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const Gfx::IntRect& rect() const { return m_rect; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Gfx::IntRect m_rect;
|
|
|
|
};
|
|
|
|
|
2020-08-14 20:56:40 +03: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 };
|
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
}
|