1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:28:11 +00:00

Start refactoring the windowing system to use an event loop.

Userspace programs can now open /dev/gui_events and read a stream of GUI_Event
structs one at a time.

I was stuck on a stupid problem where we'd reenter Scheduler::yield() due to
having one of the has_data_available_for_reading() implementations using locks.
This commit is contained in:
Andreas Kling 2019-01-14 14:21:51 +01:00
parent b4da4e8fbd
commit b0e3f73375
46 changed files with 283 additions and 292 deletions

View file

@ -11,23 +11,60 @@ struct GUI_WindowFlags { enum {
typedef unsigned GUI_Color;
struct GUI_Point {
int x;
int y;
};
struct GUI_Size {
int width;
int height;
};
struct GUI_Rect {
GUI_Point location;
GUI_Size size;
};
struct GUI_CreateWindowParameters {
Rect rect;
GUI_Rect rect;
Color background_color;
unsigned flags { 0 };
char title[128];
};
enum class GUI_WidgetType : unsigned {
Label,
Button,
enum class GUI_MouseButton : unsigned char {
NoButton = 0,
Left = 1,
Right = 2,
Middle = 4,
};
struct GUI_CreateWidgetParameters {
GUI_WidgetType type;
Rect rect;
Color background_color;
bool opaque { true };
unsigned flags { 0 };
char text[256];
struct GUI_Event {
enum Type : unsigned {
Invalid,
Paint,
MouseMove,
MouseDown,
MouseUp,
};
Type type { Invalid };
int window_id { -1 };
union {
struct {
GUI_Rect rect;
} paint;
struct {
GUI_Point position;
GUI_MouseButton button;
} mouse;
};
};
inline Rect::Rect(const GUI_Rect& r) : Rect(r.location, r.size) { }
inline Point::Point(const GUI_Point& p) : Point(p.x, p.y) { }
inline Size::Size(const GUI_Size& s) : Size(s.width, s.height) { }
inline Rect::operator GUI_Rect() const { return { m_location, m_size }; }
inline Point::operator GUI_Point() const { return { m_x, m_y }; }
inline Size::operator GUI_Size() const { return { m_width, m_height }; }