summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.h2
-rw-r--r--src/poll_common.c12
-rw-r--r--src/poll_common.h4
-rw-r--r--src/window.c38
-rw-r--r--src/window.h22
-rw-r--r--src/window_glfw.c28
-rw-r--r--src/window_glfw.h2
-rw-r--r--src/window_wayland.c43
-rw-r--r--src/window_x11.c24
-rw-r--r--src/window_x11.h2
10 files changed, 88 insertions, 89 deletions
diff --git a/src/common.h b/src/common.h
index acbb2e5..b986ab8 100644
--- a/src/common.h
+++ b/src/common.h
@@ -4,7 +4,7 @@
AL_UNUSED_FUNCTION_PUSH
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
static bool stl_should_refresh_common(struct stl_window *window)
{
if (window->pending_refresh) {
diff --git a/src/poll_common.c b/src/poll_common.c
index 32b5c2e..945288c 100644
--- a/src/poll_common.c
+++ b/src/poll_common.c
@@ -3,15 +3,15 @@
#include "poll_common.h"
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
bool stl_poll_common(struct aki_pollfd *fds, bool block)
{
fds[0].revents = 0;
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
fds[1].revents = 0;
#endif
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
if (aki_poll_fds(fds, 2, (block) ? -1 : 0) < 0 && errno != EINTR) {
#else
if (aki_poll_fds(fds, 1, (block) ? -1 : 0) < 0 && errno != EINTR) {
@@ -30,7 +30,7 @@ bool stl_poll_common(struct aki_pollfd *fds, bool block)
return true;
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
void stl_wake_common(struct stl_window *window, struct aki_pollfd *fds)
{
window->pending_refresh = true;
@@ -47,8 +47,8 @@ void stl_wake_common(struct stl_window *window, struct aki_pollfd *fds)
bool stl_process_events_common(struct aki_pollfd *fds)
{
-#if defined STELA_POLL_INLINE
-#if defined STELA_PAUSE
+#ifdef STELA_POLL_INLINE
+#ifdef STELA_PAUSE
if (fds[1].revents & POLLIN) {
s64 val = aki_read(fds[1].fd, &val, sizeof(s64));
al_assert(val == sizeof(s64));
diff --git a/src/poll_common.h b/src/poll_common.h
index 02ec2ee..aebf9a3 100644
--- a/src/poll_common.h
+++ b/src/poll_common.h
@@ -4,9 +4,9 @@
#include "window.h"
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
bool stl_poll_common(struct aki_pollfd *fds, bool block);
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
void stl_wake_common(struct stl_window *window, struct aki_pollfd *fds);
#endif
#endif
diff --git a/src/window.c b/src/window.c
index 4389241..c1ac53e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -16,7 +16,7 @@
void stl_window_send_pointer_pos_event(struct stl_window *window, f64 x, f64 y)
{
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
GET_EVENT_CHUNK(STELA_EVENT_POINTER_POS);
((f64 *)(&ptr[1]))[0] = x;
((f64 *)(&ptr[9]))[0] = y;
@@ -24,7 +24,7 @@ void stl_window_send_pointer_pos_event(struct stl_window *window, f64 x, f64 y)
#else
if (window->pointer_pos_callback) {
if (window->pointer_pos_callback(window->userdata, x, y)) {
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
@@ -34,14 +34,14 @@ void stl_window_send_pointer_pos_event(struct stl_window *window, f64 x, f64 y)
void stl_window_send_scroll_event(struct stl_window *window, f64 y)
{
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
GET_EVENT_CHUNK(STELA_EVENT_SCROLL);
((f64 *)(&ptr[1]))[0] = y;
APPEND_EVENT_CHUNK();
#else
if (window->scroll_callback) {
if (window->scroll_callback(window->userdata, y)) {
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
@@ -51,7 +51,7 @@ void stl_window_send_scroll_event(struct stl_window *window, f64 y)
void stl_window_send_mouse_button_event(struct stl_window *window, u8 state, u8 button)
{
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
GET_EVENT_CHUNK(STELA_EVENT_MOUSE_BUTTON);
ptr[1] = state;
ptr[2] = button;
@@ -59,7 +59,7 @@ void stl_window_send_mouse_button_event(struct stl_window *window, u8 state, u8
#else
if (window->mouse_button_callback) {
if (window->mouse_button_callback(window->userdata, state, button)) {
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
@@ -72,7 +72,7 @@ void stl_window_send_key_event(struct stl_window *window, u8 state, u8 button)
if (window->key_immediate_callback) {
window->key_immediate_callback(window->userdata, state, button);
}
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
GET_EVENT_CHUNK(STELA_EVENT_KEY);
ptr[1] = state;
ptr[2] = button;
@@ -80,7 +80,7 @@ void stl_window_send_key_event(struct stl_window *window, u8 state, u8 button)
#else
if (window->key_callback) {
if (window->key_callback(window->userdata, state, button)) {
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
@@ -90,7 +90,7 @@ void stl_window_send_key_event(struct stl_window *window, u8 state, u8 button)
void stl_window_send_resize_event(struct stl_window *window, s32 width, s32 height)
{
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
(void)width;
(void)height;
window->pending_resize = true;
@@ -99,19 +99,19 @@ void stl_window_send_resize_event(struct stl_window *window, s32 width, s32 heig
if (window->resize_callback) {
window->resize_callback(window->userdata, width, height);
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
#endif
}
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
void stl_window_send_refresh_event(struct stl_window *window)
{
if (window->refresh_callback) {
window->refresh_callback(window->userdata);
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
@@ -119,7 +119,7 @@ void stl_window_send_refresh_event(struct stl_window *window)
void stl_window_send_should_close_event(struct stl_window *window)
{
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
GET_EVENT_CHUNK(STELA_EVENT_SHOULD_CLOSE);
APPEND_EVENT_CHUNK();
#else
@@ -129,7 +129,7 @@ void stl_window_send_should_close_event(struct stl_window *window)
#endif
}
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
bool stl_window_read_events(struct stl_window *window)
{
u8 op = STELA_EVENT_NONE;
@@ -140,7 +140,7 @@ bool stl_window_read_events(struct stl_window *window)
if (window->resize_callback) {
window->resize_callback(window->userdata, width, height);
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
window->pending_resize = false;
@@ -157,7 +157,7 @@ bool stl_window_read_events(struct stl_window *window)
f64 y = ((f64 *)(&bc[9]))[0];
if (window->pointer_pos_callback) {
if (window->pointer_pos_callback(window->userdata, x, y)) {
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
@@ -168,7 +168,7 @@ bool stl_window_read_events(struct stl_window *window)
f64 y = ((f64 *)(&bc[1]))[0];
if (window->scroll_callback) {
if (window->scroll_callback(window->userdata, y)) {
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
@@ -180,7 +180,7 @@ bool stl_window_read_events(struct stl_window *window)
u8 button = bc[2];
if (window->mouse_button_callback) {
if (window->mouse_button_callback(window->userdata, state, button)) {
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
@@ -192,7 +192,7 @@ bool stl_window_read_events(struct stl_window *window)
u8 button = bc[2];
if (window->key_callback) {
if (window->key_callback(window->userdata, state, button)) {
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
window->pending_refresh = true;
#endif
}
diff --git a/src/window.h b/src/window.h
index c96b6cd..a72071a 100644
--- a/src/window.h
+++ b/src/window.h
@@ -19,15 +19,15 @@
#include <al/lib.h>
#include <al/ring_buffer.h>
-#if defined STELA_API_VULKAN
+#ifdef STELA_API_VULKAN
#include <vulkan/vulkan.h>
#endif
-#if !defined STELA_MIN_WIDTH
+#ifndef STELA_MIN_WIDTH
#define STELA_MIN_WIDTH 16
#endif
-#if !defined STELA_MIN_HEIGHT
+#ifndef STELA_MIN_HEIGHT
#define STELA_MIN_HEIGHT 16
#endif
@@ -51,13 +51,13 @@ struct stl_window {
s32 height;
s32 scale;
bool fullscreen;
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
u8 *data;
// Render thread events.
struct al_ring_buffer events;
bool pending_resize;
#endif
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
bool pending_refresh;
#endif
// Methods.
@@ -66,14 +66,14 @@ struct stl_window {
void (*resize_internal)(struct stl_window *, s32, s32);
void (*resize)(struct stl_window *, s32, s32);
void (*toggle_fullscreen)(struct stl_window *);
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
bool (*poll)(struct stl_window *, bool);
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
void (*wake)(struct stl_window *);
#endif
#endif
void (*process_events)(struct stl_window *);
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
bool (*should_refresh)(struct stl_window *);
#endif
void (*free)(struct stl_window **);
@@ -126,7 +126,7 @@ enum {
};
#define STELA_EVENT_SIZE 32
-#if !defined STELA_EVENTS_SIZE
+#ifndef STELA_EVENTS_SIZE
#define STELA_EVENTS_SIZE (STELA_EVENT_SIZE * 128)
#endif
@@ -142,10 +142,10 @@ void stl_window_send_scroll_event(struct stl_window *window, f64 y);
void stl_window_send_mouse_button_event(struct stl_window *window, u8 state, u8 button);
void stl_window_send_key_event(struct stl_window *window, u8 state, u8 button);
void stl_window_send_resize_event(struct stl_window *window, s32 width, s32 height);
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
void stl_window_send_refresh_event(struct stl_window *window);
#endif
void stl_window_send_should_close_event(struct stl_window *window);
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
bool stl_window_read_events(struct stl_window *window);
#endif
diff --git a/src/window_glfw.c b/src/window_glfw.c
index beb6bd9..0c6e5c7 100644
--- a/src/window_glfw.c
+++ b/src/window_glfw.c
@@ -4,7 +4,7 @@
#include "window_glfw.h"
#include "common.h"
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
#define STELA_GL_API GLFW_OPENGL_API
#define STELA_GLES_API GLFW_OPENGL_ES_API
@@ -106,7 +106,7 @@ static void resize_callback(GLFWwindow *window, s32 width, s32 height)
stl_window_send_resize_event(&glfw->w, width, height);
}
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
static void refresh_callback(GLFWwindow *window)
{
struct stl_window_glfw *glfw = glfwGetWindowUserPointer(window);
@@ -147,7 +147,7 @@ static bool window_glfw_create_window(struct stl_window *window, s32 width, s32
stl_gl_vers[i].major, stl_gl_vers[i].minor, stl_gl_vers[i].glsl_ver);
#endif
glfw->window = glfwCreateWindow(width, height, name, NULL, global.master_window);
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
if (glfw->window) {
al_log_info("window_glfw", "Context successfully created.");
break;
@@ -163,7 +163,7 @@ static bool window_glfw_create_window(struct stl_window *window, s32 width, s32
// This doesn't work right, at least on wayland.
if (!global.master_window) global.master_window = glfw->window;
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
glfwMakeContextCurrent(glfw->window);
glfwSwapInterval((flags & STELA_WINDOW_VSYNC) ? 1 : 0);
glfwMakeContextCurrent(NULL);
@@ -181,7 +181,7 @@ static bool window_glfw_create_window(struct stl_window *window, s32 width, s32
glfwSetMouseButtonCallback(glfw->window, mouse_button_callback);
glfwSetScrollCallback(glfw->window, scroll_callback);
glfwSetFramebufferSizeCallback(glfw->window, resize_callback);
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
glfwSetWindowRefreshCallback(glfw->window, refresh_callback);
#endif
// This seems to be called if we block too long after creating a window.
@@ -263,7 +263,7 @@ static void window_glfw_toggle_fullscreen(struct stl_window *window)
glfw->w.fullscreen = !glfw->w.fullscreen;
}
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
static bool window_glfw_poll(struct stl_window *window, bool block)
{
(void)window;
@@ -272,7 +272,7 @@ static bool window_glfw_poll(struct stl_window *window, bool block)
return true;
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
static void window_glfw_wake(struct stl_window *window)
{
struct stl_window_glfw *glfw = (struct stl_window_glfw *)window;
@@ -287,7 +287,7 @@ static void window_glfw_process_events(struct stl_window *window)
(void)window;
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
static bool window_glfw_should_refresh(struct stl_window *window)
{
return stl_should_refresh_common(window);
@@ -300,7 +300,7 @@ static void window_glfw_free(struct stl_window **window)
if (glfw->window) {
glfwDestroyWindow(glfw->window);
}
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
al_free(glfw->w.data);
#endif
al_free(glfw);
@@ -357,11 +357,11 @@ struct stl_window *stl_window_create(void)
{
al_log_info("stela", "Creating GLFW3 window.");
struct stl_window_glfw *glfw = al_alloc_object(struct stl_window_glfw);
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
glfw->w.data = al_malloc(STELA_EVENTS_SIZE);
al_ring_buffer_init(&glfw->w.events, glfw->w.data, STELA_EVENTS_SIZE);
#endif
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
glfw->w.pending_refresh = true;
#endif
glfw->w.fullscreen = false;
@@ -370,14 +370,14 @@ struct stl_window *stl_window_create(void)
glfw->w.resize_internal = window_glfw_resize_internal;
glfw->w.resize = window_glfw_resize;
glfw->w.toggle_fullscreen = window_glfw_toggle_fullscreen;
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
glfw->w.poll = window_glfw_poll;
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
glfw->w.wake = window_glfw_wake;
#endif
#endif
glfw->w.process_events = window_glfw_process_events;
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
glfw->w.should_refresh = window_glfw_should_refresh;
#endif
glfw->w.free = window_glfw_free;
diff --git a/src/window_glfw.h b/src/window_glfw.h
index 90d251f..2fa8f16 100644
--- a/src/window_glfw.h
+++ b/src/window_glfw.h
@@ -2,7 +2,7 @@
#if defined STELA_API_VULKAN
#define GLFW_INCLUDE_VULKAN
-#else
+#elif defined STELA_API_OPENGL
#include "gl_common.h"
#endif
#include <GLFW/glfw3.h>
diff --git a/src/window_wayland.c b/src/window_wayland.c
index 9b31d5f..d9ef0fb 100644
--- a/src/window_wayland.c
+++ b/src/window_wayland.c
@@ -78,7 +78,7 @@ static void handle_output_name(void *data, struct wl_output *output, const char
{
struct stl_monitor_wayland *monitor = (struct stl_monitor_wayland *)data;
(void)output;
- size_t len = al_strlen(name);
+ size_t len = al_strlen(name) + 1;
if (len >= STELA_MAX_MONITOR_NAME) {
len = STELA_MAX_MONITOR_NAME - 1;
monitor->m.name[len] = '\0';
@@ -134,7 +134,7 @@ bool stl_global_init(bool skip_graphics)
}
global.display_fd = wl_display_get_fd(global.display);
if (!skip_graphics) {
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
if (!stl_maybe_load_egl()) return false;
global.egl.display = eglGetDisplay((EGLNativeDisplayType)global.display);
if (!global.egl.display) {
@@ -144,7 +144,7 @@ bool stl_global_init(bool skip_graphics)
if (!stl_load_egl(&global.egl)) return false;
#endif
} else {
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
global.egl.display = EGL_NO_DISPLAY;
#endif
}
@@ -179,7 +179,7 @@ void stl_global_process_events()
void stl_global_close(void)
{
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
stl_terminate_egl(&global.egl);
#endif
for (u32 i = 0; i < global.monitors.size; i++) {
@@ -638,7 +638,7 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
.closed = handle_layer_surface_closed
};
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
static bool wl_egl_init(struct stl_window_wayland *wl)
{
wl->egl_window = wl_egl_window_create(wl->surface, wl->w.width, wl->w.height);
@@ -777,14 +777,14 @@ static bool window_wayland_create_window(struct stl_window *window, s32 width, s
if (!selected || !create_layer_shell(wl, selected, name)) goto err;
}
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
if (!wl_egl_init(wl)) goto err;
#endif
wl_surface_commit(wl->surface);
wl_display_roundtrip(wl->display);
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
stl_egl_make_current(&wl->egl);
stl_egl_swap_interval(&wl->egl, (flags & STELA_WINDOW_VSYNC) ? 1 : 0);
stl_egl_release_current(&wl->egl);
@@ -813,7 +813,7 @@ static void window_wayland_resize(struct stl_window *window, s32 width, s32 heig
static void window_wayland_resize_internal(struct stl_window *window, s32 width, s32 height)
{
struct stl_window_wayland *wl = (struct stl_window_wayland *)window;
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
if (stl_egl_is_ready(&wl->egl)) {
wl_egl_window_resize(wl->egl_window, width, height, 0, 0);
}
@@ -835,7 +835,7 @@ static void window_wayland_toggle_fullscreen(struct stl_window *window)
wl->w.fullscreen = !wl->w.fullscreen;
}
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
static bool window_wayland_poll(struct stl_window *window, bool block)
{
struct stl_window_wayland *wl = (struct stl_window_wayland *)window;
@@ -843,7 +843,7 @@ static bool window_wayland_poll(struct stl_window *window, bool block)
return stl_poll_common(wl->fds, block);
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
static void window_wayland_wake(struct stl_window *window)
{
struct stl_window_wayland *wl = (struct stl_window_wayland *)window;
@@ -863,7 +863,7 @@ static void window_wayland_process_events(struct stl_window *window)
}
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
static bool window_wayland_should_refresh(struct stl_window *window)
{
return stl_should_refresh_common(window);
@@ -879,7 +879,7 @@ static void destroy_surface_internal(struct stl_window_wayland *wl)
} else if (wl->layer_surface) {
zwlr_layer_surface_v1_destroy(wl->layer_surface);
}
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
if (wl->egl_window) {
stl_egl_destroy_surface(&wl->egl);
wl_egl_window_destroy(wl->egl_window);
@@ -903,19 +903,19 @@ void window_wayland_free(struct stl_window **window)
if (wl->xdg_wm_base) xdg_wm_base_destroy(wl->xdg_wm_base);
if (wl->layer_shell) zwlr_layer_shell_v1_destroy(wl->layer_shell);
if (wl->compositor) wl_compositor_destroy(wl->compositor);
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
if (stl_egl_is_ready(&wl->egl)) {
stl_egl_destroy_context(&wl->egl);
}
#endif
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
al_free(wl->w.data);
#endif
al_free(wl);
*window = NULL;
}
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
static bool window_wayland_gl_loader_load(void *data)
{
struct stl_window_wayland *wl = (struct stl_window_wayland *)data;
@@ -949,11 +949,11 @@ struct stl_window *stl_window_create(void)
{
al_log_info("stela", "Creating Wayland (EGL) window.");
struct stl_window_wayland *wl = al_alloc_object(struct stl_window_wayland);
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
wl->w.data = al_malloc(STELA_EVENTS_SIZE);
al_ring_buffer_init(&wl->w.events, wl->w.data, STELA_EVENTS_SIZE);
#endif
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
wl->w.pending_refresh = true;
#endif
wl->w.fullscreen = false;
@@ -962,19 +962,18 @@ struct stl_window *stl_window_create(void)
wl->w.resize = window_wayland_resize;
wl->w.resize_internal = window_wayland_resize_internal;
wl->w.toggle_fullscreen = window_wayland_toggle_fullscreen;
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
wl->w.poll = window_wayland_poll;
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
wl->w.wake = window_wayland_wake;
#endif
#endif
wl->w.process_events = window_wayland_process_events;
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
wl->w.should_refresh = window_wayland_should_refresh;
#endif
wl->w.free = window_wayland_free;
-#if defined STELA_API_VULKAN
-#elif defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
wl->w.get_gl_proc_address = NULL;
wl->w.gl_loader_load = window_wayland_gl_loader_load;
wl->w.gl_make_current = window_wayland_gl_make_current;
diff --git a/src/window_x11.c b/src/window_x11.c
index 4ffa4d0..300b528 100644
--- a/src/window_x11.c
+++ b/src/window_x11.c
@@ -29,7 +29,7 @@ bool stl_global_init(bool skip_graphics)
return false;
}
global.root = XRootWindow(global.x11_d, XDefaultScreen(global.x11_d));
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
if (!stl_maybe_load_egl()) return false;
global.egl.display = eglGetDisplay((EGLNativeDisplayType)global.x11_d);
if (!global.egl.display) {
@@ -44,7 +44,7 @@ bool stl_global_init(bool skip_graphics)
for (s32 i = 0; i < monitor_count; i++) {
struct stl_monitor *monitor = al_alloc_object(struct stl_monitor);
char *name = XGetAtomName(global.x11_d, info[i].name);
- size_t len = al_strlen(name);
+ size_t len = al_strlen(name) + 1;
if (len >= STELA_MAX_MONITOR_NAME) {
len = STELA_MAX_MONITOR_NAME - 1;
monitor->name[len] = '\0';
@@ -89,7 +89,7 @@ static bool x11_egl_init(struct stl_window_x11 *xw)
return false;
}
-#if defined STELA_API_OPENGL
+#ifdef STELA_API_OPENGL
xw->w.get_gl_proc_address = eglGetProcAddress;
#endif
@@ -197,14 +197,14 @@ static void window_x11_toggle_fullscreen(struct stl_window *window)
xw->w.fullscreen = !xw->w.fullscreen;
}
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
static bool window_x11_poll(struct stl_window *window, bool block)
{
struct stl_window_x11 *xw = (struct stl_window_x11 *)window;
return stl_poll_common(xw->fds, block);
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
static void window_x11_wake(struct stl_window *window)
{
struct stl_window_x11 *xw = (struct stl_window_x11 *)window;
@@ -269,7 +269,7 @@ static void window_x11_process_events(struct stl_window *window)
while (QLength(global.x11_d) > 0) { handle_next_xevent(xw); }
}
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
static bool window_x11_should_refresh(struct stl_window *window)
{
return stl_should_refresh_common(window);
@@ -280,7 +280,7 @@ static void window_x11_free(struct stl_window **window)
{
struct stl_window_x11 *xw = (struct stl_window_x11 *)*window;
// TODO: Cleanup x11 stuff.
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
al_free(xw->w.data);
#endif
al_free(xw);
@@ -337,11 +337,11 @@ struct stl_window *stl_window_create(void)
{
al_log_info("stela", "Creating X11 (EGL) window.");
struct stl_window_x11 *xw = al_alloc_object(struct stl_window_x11);
-#if defined STELA_EVENT_BUFFER
+#ifdef STELA_EVENT_BUFFER
xw->w.data = al_malloc(STELA_EVENTS_SIZE);
al_ring_buffer_init(&xw->w.events, xw->w.data, STELA_EVENTS_SIZE);
#endif
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
xw->w.pending_refresh = true;
#endif
xw->w.fullscreen = false;
@@ -350,14 +350,14 @@ struct stl_window *stl_window_create(void)
xw->w.resize_internal = window_x11_resize_internal;
xw->w.resize = window_x11_resize;
xw->w.toggle_fullscreen = window_x11_toggle_fullscreen;
-#if defined STELA_POLL_INLINE
+#ifdef STELA_POLL_INLINE
xw->w.poll = window_x11_poll;
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
xw->w.wake = window_x11_wake;
#endif
#endif
xw->w.process_events = window_x11_process_events;
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
xw->w.should_refresh = window_x11_should_refresh;
#endif
xw->w.free = window_x11_free;
diff --git a/src/window_x11.h b/src/window_x11.h
index 5392493..fc1172f 100644
--- a/src/window_x11.h
+++ b/src/window_x11.h
@@ -22,7 +22,7 @@ struct stl_window_x11 {
struct stl_window w;
Window window;
struct stl_egl egl;
-#if defined STELA_PAUSE
+#ifdef STELA_PAUSE
struct aki_pollfd fds[2];
#else
struct aki_pollfd fds[1];