From 5500ce377a0a552bfa858232f7086c197d0ab458 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 18 Apr 2025 15:14:31 +0200 Subject: Wayland rendering now works --- src/window/x11.c | 75 ++++++-------------------------------------------------- 1 file changed, 7 insertions(+), 68 deletions(-) (limited to 'src/window/x11.c') diff --git a/src/window/x11.c b/src/window/x11.c index 113fc1a..cf44ac2 100644 --- a/src/window/x11.c +++ b/src/window/x11.c @@ -4,13 +4,6 @@ #include "../../../include/mgl/system/utf8.h" #include "../../../include/mgl/system/clock.h" -#include -#include -#include -#include -#include -#include - #include #include #include @@ -18,6 +11,13 @@ #include #include +#include +#include +#include +#include +#include +#include + static void mgl_window_x11_deinit(mgl_window *self); /* TODO: Handle XIM better. Set XIM position to text position on screen (for text input) and reset input when selecting a new text input, etc */ @@ -34,7 +34,6 @@ typedef struct { } x11_events_circular_buffer; typedef struct { - void *dpy; Window window; char *clipboard_string; size_t clipboard_size; @@ -515,16 +514,6 @@ static bool mgl_x11_setup_window(mgl_window *self, const char *title, const mgl_ self->vsync_enabled = true; mgl_graphics_set_swap_interval(&impl->graphics, (mgl_window_handle)impl->window, self->vsync_enabled); - context->gl.glEnable(GL_TEXTURE_2D); - context->gl.glEnable(GL_BLEND); - context->gl.glEnable(GL_SCISSOR_TEST); - context->gl.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - context->gl.glEnableClientState(GL_VERTEX_ARRAY); - context->gl.glEnableClientState(GL_TEXTURE_COORD_ARRAY); - context->gl.glEnableClientState(GL_COLOR_ARRAY); - context->gl.glPixelStorei(GL_PACK_ALIGNMENT, 1); - context->gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - Window dummy_w; int dummy_i; unsigned int dummy_u; @@ -1436,54 +1425,6 @@ static bool mgl_window_x11_get_clipboard(mgl_window *self, mgl_clipboard_callbac return success; } -typedef struct { - char **str; - size_t *size; -} ClipboardStringCallbackData; - -static bool clipboard_copy_string_callback(const unsigned char *data, size_t size, mgl_clipboard_type clipboard_type, void *userdata) { - ClipboardStringCallbackData *callback_data = userdata; - if(clipboard_type != MGL_CLIPBOARD_TYPE_STRING) { - free(*callback_data->str); - *callback_data->str = NULL; - *callback_data->size = 0; - return false; - } - - char *new_data = realloc(*callback_data->str, *callback_data->size + size); - if(!new_data) { - free(*callback_data->str); - *callback_data->str = NULL; - *callback_data->size = 0; - return false; - } - - memcpy(new_data + *callback_data->size, data, size); - - *callback_data->str = new_data; - *callback_data->size += size; - return true; -} - -static bool mgl_window_x11_get_clipboard_string(mgl_window *self, char **str, size_t *size) { - assert(str); - assert(size); - - *str = NULL; - *size = 0; - - ClipboardStringCallbackData callback_data; - callback_data.str = str; - callback_data.size = size; - const bool success = mgl_window_x11_get_clipboard(self, clipboard_copy_string_callback, &callback_data, MGL_CLIPBOARD_TYPE_STRING); - if(!success) { - free(*str); - *str = NULL; - *size = 0; - } - return success; -} - static void mgl_window_x11_set_key_repeat_enabled(mgl_window *self, bool enabled) { self->key_repeat_enabled = enabled; } @@ -1535,13 +1476,11 @@ bool mgl_window_x11_init(mgl_window *self, const char *title, const mgl_window_c self->set_size_limits = mgl_window_x11_set_size_limits; self->set_clipboard = mgl_window_x11_set_clipboard; self->get_clipboard = mgl_window_x11_get_clipboard; - self->get_clipboard_string = mgl_window_x11_get_clipboard_string; self->set_key_repeat_enabled = mgl_window_x11_set_key_repeat_enabled; self->flush = mgl_window_x11_flush; self->get_egl_display = mgl_window_x11_get_egl_display; self->get_egl_context = mgl_window_x11_get_egl_context; self->for_each_active_monitor_output = mgl_window_x11_for_each_active_monitor_output; - self->impl = impl; /* TODO: Use CLIPBOARD_MANAGER and SAVE_TARGETS to save clipboard in clipboard manager on exit */ -- cgit v1.2.3-70-g09d2