From 956c86fe4728e6e5239202f1402fd65260ece7c8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 30 Mar 2022 16:10:56 +0200 Subject: Proper y offset for text, add option to create hidden window and add function to make it visible (map, unmap) --- src/window/window.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/window') diff --git a/src/window/window.c b/src/window/window.c index 3f902e3..1b15558 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -293,6 +293,8 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window PointerMotionMask | Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask | ButtonMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask | VisibilityChangeMask | PropertyChangeMask | FocusChangeMask; + const bool hide_window = params ? params->hidden : false; + if(existing_window) { if(!XChangeWindowAttributes(context->connection, existing_window, CWColormap | CWEventMask, &window_attr)) { fprintf(stderr, "XChangeWindowAttributes failed\n"); @@ -301,6 +303,8 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window } self->window = existing_window; + if(hide_window) + XUnmapWindow(context->connection, existing_window); } else { self->window = XCreateWindow(context->connection, parent_window, params->position.x, params->position.y, window_size.x, window_size.y, 0, @@ -313,7 +317,8 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window } XStoreName(context->connection, self->window, title); - XMapWindow(context->connection, self->window); + if(!hide_window) + XMapWindow(context->connection, self->window); } if(params) @@ -744,6 +749,14 @@ void mgl_window_get_scissor(mgl_window *self, mgl_scissor *scissor) { *scissor = self->scissor; } +void mgl_window_set_visible(mgl_window *self, bool visible) { + mgl_context *context = mgl_get_context(); + if(visible) + XMapWindow(context->connection, self->window); + else + XUnmapWindow(context->connection, self->window); +} + bool mgl_window_is_open(const mgl_window *self) { return self->open; } -- cgit v1.2.3