This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathEvent.h
131 lines (111 loc) · 3.81 KB
/
Event.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
This file is part of duckOS.
duckOS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
duckOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with duckOS. If not, see <https://www.gnu.org/licenses/>.
Copyright (c) Byteduck 2016-2021. All rights reserved.
*/
#pragma once
#include "Window.h"
#include <sys/socketfs.h>
#include <sys/input.h>
#define PEVENT_UNKNOWN 0
#define PEVENT_WINDOW_CREATE 1
#define PEVENT_WINDOW_DESTROY 2
#define PEVENT_WINDOW_MOVE 3
#define PEVENT_WINDOW_RESIZE 4
#define PEVENT_MOUSE_MOVE 5
#define PEVENT_KEY 6
#define PEVENT_FONT_RESPONSE 7
#define PEVENT_MOUSE_BUTTON 8
#define PEVENT_MOUSE_LEAVE 9
#define PEVENT_MOUSE_SCROLL 10
#define PEVENT_WINDOW_FOCUS 11
#define POND_MOUSE1 1
#define POND_MOUSE2 2
#define POND_MOUSE3 4
namespace Pond {
class Window;
/**
* An event triggered when a window is created belonging to this process.
*/
struct WindowCreateEvent {
int type; ///< Equal to PEVENT_WINDOW_CREATE
Window* window; ///< The window created.
};
struct WindowDestroyEvent {
int type; ///< Equal to PEVENT_WINDOW_DESTROY
int id; ///< The ID of the window destroyed
};
struct WindowMoveEvent {
int type; ///< Equal to PEVENT_WINDOW_MOVE
Gfx::Point old_pos; ///< The previous position of the window
Window* window; ///< The window that moved
};
struct WindowResizeEvent {
int type; ///< Equal to PEVENT_WINDOW_RESIZE
Gfx::Rect old_rect; ///< The previous rect of the window
Window* window; ///< The window that was resized
};
struct MouseMoveEvent {
int type; ///< Equal to PEVENT_MOUSE_MOVE
Gfx::Point delta; ///< The change in position of the mouse.
Gfx::Point new_pos; ///< The new position of the mouse.
Gfx::Point abs_pos; ///< The absolute position of the mouse relative to the display.
Window* window;
};
struct MouseButtonEvent {
int type; ///< Equal to PEVENT_MOUSE_BUTTON
unsigned int old_buttons; ///< The previous buttons of the mouse.
unsigned int new_buttons; ///< The new buttons of the mouse.
Window* window;
};
struct MouseScrollEvent {
int type; ///< Equal to PEVENT_MOUSE_SCROLL
int scroll; ///< The amount scrolled;
Window* window;
};
struct MouseLeaveEvent {
int type; ///< Equal to PEVENT_MOUSE_LEAVE
Gfx::Point last_pos; ///< The last relative position of the mouse in the window.
Window* window;
};
struct KeyEvent {
int type; ///< Equal to PEVENT_KEY
uint16_t scancode; ///< The scancode of the key pressed or released.
uint8_t key; ///< The key pressed or released.
uint8_t character; ///< The character of the key pressed or released.
uint8_t modifiers; ///< The bitfield of modifier keys active for the key event
Window* window; ///< The window the event was triggered on
};
struct FontResponseEvent {
int type; ///< Equal to PEVENT_FONT_RESPONSE
Gfx::Font* font;
};
struct WindowFocusEvent {
int type; /// < Equal to PEVENT_WINDOW_FOCUS
Window* window; /// < The window that was focused / unfocused
bool focused; /// < Whether the window is focused
};
union Event {
int type; ///< The type of event that this PEvent refers to.
WindowCreateEvent window_create;
WindowDestroyEvent window_destroy;
WindowMoveEvent window_move;
WindowResizeEvent window_resize;
MouseMoveEvent mouse_move;
MouseButtonEvent mouse_button;
MouseScrollEvent mouse_scroll;
MouseLeaveEvent mouse_leave;
KeyEvent key;
FontResponseEvent font_response;
WindowFocusEvent window_focus;
};
}