diff options
-rw-r--r-- | include/mgl/window/window.h | 2 | ||||
-rw-r--r-- | src/window/window.c | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h index 3a1faac..77589c9 100644 --- a/include/mgl/window/window.h +++ b/include/mgl/window/window.h @@ -11,6 +11,7 @@ /* Vsync is automatically set for created windows, if supported by the system */ +typedef union _XEvent XEvent; typedef struct mgl_event mgl_event; /* x11 window handle. TODO: Add others when wayland, etc is added */ typedef unsigned long mgl_window_handle; @@ -112,6 +113,7 @@ void mgl_window_deinit(mgl_window *self); void mgl_window_clear(mgl_window *self, mgl_color color); bool mgl_window_poll_event(mgl_window *self, mgl_event *event); +bool mgl_window_inject_x11_event(mgl_window *self, XEvent *xev, mgl_event *event); void mgl_window_display(mgl_window *self); /* diff --git a/src/window/window.c b/src/window/window.c index d3ec04e..5fcd466 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -1602,6 +1602,13 @@ bool mgl_window_poll_event(mgl_window *self, mgl_event *event) { } } +bool mgl_window_inject_x11_event(mgl_window *self, XEvent *xev, mgl_event *event) { + mgl_context *context = mgl_get_context(); + event->type = MGL_EVENT_UNKNOWN; + mgl_window_on_receive_event(self, xev, event, context); + return event->type != MGL_EVENT_UNKNOWN; +} + void mgl_window_display(mgl_window *self) { mgl_context *context = mgl_get_context(); x11_context_swap_buffers(self->context, self->window); @@ -1654,6 +1661,7 @@ void mgl_window_set_visible(mgl_window *self, bool visible) { XMapWindow(context->connection, self->window); else XUnmapWindow(context->connection, self->window); + XFlush(context->connection); } bool mgl_window_is_open(const mgl_window *self) { |