aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mgl/window/window.h8
-rw-r--r--src/window/window.c9
2 files changed, 10 insertions, 7 deletions
diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h
index 27e4409..f42d592 100644
--- a/include/mgl/window/window.h
+++ b/include/mgl/window/window.h
@@ -47,12 +47,14 @@ struct mgl_window {
typedef struct {
mgl_vec2i position;
mgl_vec2i size;
- mgl_vec2i min_size; /* (0, 0) = no limit */
- mgl_vec2i max_size; /* (0, 0) = no limit */
+ mgl_vec2i min_size; /* (0, 0) = no limit */
+ mgl_vec2i max_size; /* (0, 0) = no limit */
mgl_window_handle parent_window; /* 0 = root window */
- bool hidden;
+ bool hidden; /* false by default */
+ bool override_redirect; /* false by default */
} mgl_window_create_params;
+/* |params| can be NULL */
int mgl_window_create(mgl_window *self, const char *title, const mgl_window_create_params *params);
int mgl_window_init_from_existing_window(mgl_window *self, mgl_window_handle existing_window);
void mgl_window_deinit(mgl_window *self);
diff --git a/src/window/window.c b/src/window/window.c
index 1b15558..08c4585 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -247,8 +247,8 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
mgl_vec2i window_size = params ? params->size : (mgl_vec2i){ 0, 0 };
if(window_size.x <= 0 || window_size.y <= 0) {
- window_size.x = 1;
- window_size.y = 1;
+ window_size.x = 640;
+ window_size.y = 480;
}
self->size = window_size;
@@ -286,6 +286,7 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
}
XSetWindowAttributes window_attr;
+ window_attr.override_redirect = params ? params->override_redirect : false;
window_attr.colormap = x11_context->color_map;
window_attr.event_mask =
KeyPressMask | KeyReleaseMask |
@@ -296,7 +297,7 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
const bool hide_window = params ? params->hidden : false;
if(existing_window) {
- if(!XChangeWindowAttributes(context->connection, existing_window, CWColormap | CWEventMask, &window_attr)) {
+ if(!XChangeWindowAttributes(context->connection, existing_window, CWColormap | CWEventMask | CWOverrideRedirect, &window_attr)) {
fprintf(stderr, "XChangeWindowAttributes failed\n");
mgl_window_deinit(self);
return -1;
@@ -309,7 +310,7 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
self->window = XCreateWindow(context->connection, parent_window, params->position.x, params->position.y,
window_size.x, window_size.y, 0,
((XVisualInfo*)context->visual_info)->depth, InputOutput, ((XVisualInfo*)context->visual_info)->visual,
- CWColormap | CWEventMask, &window_attr);
+ CWColormap | CWEventMask | CWOverrideRedirect, &window_attr);
if(!self->window) {
fprintf(stderr, "XCreateWindow failed\n");
mgl_window_deinit(self);