summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/events.h19
-rw-r--r--src/utils.h10
-rw-r--r--src/wayclock.cc8
-rw-r--r--src/window.h5
-rw-r--r--src/wlstate.cc8
-rw-r--r--src/wlstate.h8
6 files changed, 46 insertions, 12 deletions
diff --git a/src/events.h b/src/events.h
new file mode 100644
index 0000000..73efe55
--- /dev/null
+++ b/src/events.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "utils.h"
+#include "window.h"
+#include "wlstate.h"
+
+enum event_kind_e {
+ EVENT_KIND_CLOSE,
+};
+
+struct event_s {
+ enum event_kind_e kind;
+ struct window_s *window;
+};
+
+struct eventloop_s {
+ struct wlstate_s state;
+
+};
diff --git a/src/utils.h b/src/utils.h
index 5f9d1cb..59b5334 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -17,6 +17,16 @@ typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
+#if UINT64_MAX == UINTPTR_MAX
+typedef u64 usize;
+typedef i64 isize;
+#elif UINT32_MAX == UINTPTR_MAX
+typedef u32 usize;
+typedef i32 isize;
+#else
+#error "Unsupported pointer size"
+#endif
+
typedef struct wl_display *wl_display_t;
typedef struct wl_registry *wl_registry_t;
typedef struct wl_compositor *wl_compositor_t;
diff --git a/src/wayclock.cc b/src/wayclock.cc
index 3009f8d..7f46c40 100644
--- a/src/wayclock.cc
+++ b/src/wayclock.cc
@@ -1,14 +1,14 @@
#include "wlstate.h"
int main() {
- wl_state_s state;
- if (!wayc_wl_state_init(&state))
+ wlstate_s state;
+ if (!wayc_wlstate_init(&state))
wayc_panic("Failed to initialize Wayland state", nullptr);
while (true) {
- wayc_wl_state_update(&state);
+ wayc_wlstate_update(&state);
}
- wayc_wl_state_deinit(&state);
+ wayc_wlstate_deinit(&state);
return 0;
} \ No newline at end of file
diff --git a/src/window.h b/src/window.h
new file mode 100644
index 0000000..3b676f5
--- /dev/null
+++ b/src/window.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "utils.h"
+
+struct window_s {}; \ No newline at end of file
diff --git a/src/wlstate.cc b/src/wlstate.cc
index 1a02b5b..4b1a65f 100644
--- a/src/wlstate.cc
+++ b/src/wlstate.cc
@@ -25,7 +25,7 @@ static void wayc_registry_add(void *data, struct wl_registry *registry,
wayc_notnull(registry);
wayc_notnull(interface);
- struct wl_state_s *state = (struct wl_state_s *)data;
+ struct wlstate_s *state = (struct wlstate_s *)data;
if (!strcmp(interface, wl_compositor_interface.name)) {
wl_compositor_t compositor = (wl_compositor_t)wl_registry_bind(
@@ -57,7 +57,7 @@ static struct wl_registry_listener WAYC_REGISTRY_LISTENER = {
wayc_registry_remove,
};
-bool wayc_wl_state_init(struct wl_state_s *state) {
+bool wayc_wlstate_init(struct wlstate_s *state) {
wayc_assert(state != NULL);
wl_display_t display = wl_display_connect(NULL);
@@ -86,13 +86,13 @@ bool wayc_wl_state_init(struct wl_state_s *state) {
return true;
}
-void wayc_wl_state_deinit(struct wl_state_s *state) {
+void wayc_wlstate_deinit(struct wlstate_s *state) {
wayc_assert(state != NULL);
wl_display_disconnect(state->display);
}
-void wayc_wl_state_update(struct wl_state_s *state) {
+void wayc_wlstate_update(struct wlstate_s *state) {
wayc_assert(state != NULL);
struct pollfd pfd = {
diff --git a/src/wlstate.h b/src/wlstate.h
index 9d962c2..7bb3499 100644
--- a/src/wlstate.h
+++ b/src/wlstate.h
@@ -2,7 +2,7 @@
#include "utils.h"
-struct wl_state_s {
+struct wlstate_s {
wl_display_t display;
wl_registry_t registry;
wl_compositor_t compositor;
@@ -10,6 +10,6 @@ struct wl_state_s {
u32 eventfd;
};
-bool wayc_wl_state_init(struct wl_state_s *state);
-void wayc_wl_state_deinit(struct wl_state_s *state);
-void wayc_wl_state_update(struct wl_state_s *state);
+bool wayc_wlstate_init(struct wlstate_s *state);
+void wayc_wlstate_deinit(struct wlstate_s *state);
+void wayc_wlstate_update(struct wlstate_s *state);