aboutsummaryrefslogtreecommitdiff
path: root/src/window/window.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-25 14:56:49 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-25 14:56:49 +0200
commitb4799373f7fb9c8faec813e78a955438301cb9d1 (patch)
tree580b177912b3922b34681122099d742a57fd853b /src/window/window.c
parent05da9076d3d1b0d770c13572368f974786edcd92 (diff)
Add sprite set size/height functions, option to hide window decorations in create window
Diffstat (limited to 'src/window/window.c')
-rw-r--r--src/window/window.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/window/window.c b/src/window/window.c
index 17066a0..8681db9 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -76,6 +76,7 @@ typedef struct {
Atom net_wm_window_type_atom;
Atom net_wm_window_type_normal_atom;
Atom net_wm_window_type_dialog_atom;
+ Atom motif_wm_hints_atom;
Cursor default_cursor;
Cursor invisible_cursor;
unsigned int prev_keycode_pressed;
@@ -156,6 +157,7 @@ static int x11_context_init(x11_context *self, bool alpha) {
self->glx_context = NULL;
self->xim = NULL;
self->xic = NULL;
+ /* TODO: Create all of these with one XInternAtoms call instead */
self->clipboard_atom = XInternAtom(context->connection, "CLIPBOARD", False);
self->targets_atom = XInternAtom(context->connection, "TARGETS", False);
self->text_atom = XInternAtom(context->connection, "TEXT", False);
@@ -172,6 +174,7 @@ static int x11_context_init(x11_context *self, bool alpha) {
self->net_wm_window_type_atom = XInternAtom(context->connection, "_NET_WM_WINDOW_TYPE", False);
self->net_wm_window_type_normal_atom = XInternAtom(context->connection, "_NET_WM_WINDOW_TYPE_NORMAL", False);
self->net_wm_window_type_dialog_atom = XInternAtom(context->connection, "_NET_WM_WINDOW_TYPE_DIALOG", False);
+ self->motif_wm_hints_atom = XInternAtom(context->connection, "_MOTIF_WM_HINTS", False);
self->default_cursor = None;
self->invisible_cursor = None;
@@ -501,6 +504,30 @@ static void mgl_set_window_type(mgl_window *self, mgl_window_type window_type) {
}
}
+typedef struct {
+ unsigned long flags;
+ unsigned long functions;
+ unsigned long decorations;
+ long input_mode;
+ unsigned long status;
+} MotifHints;
+
+#define MWM_HINTS_DECORATIONS 2
+
+#define MWM_DECOR_NONE 0
+#define MWM_DECOR_ALL 1
+
+static void mgl_window_set_decorations_visible(mgl_window *self, bool visible) {
+ mgl_context *context = mgl_get_context();
+ x11_context *x11_context = self->context;
+
+ MotifHints motif_hints = {0};
+ motif_hints.flags = MWM_HINTS_DECORATIONS;
+ motif_hints.decorations = visible ? MWM_DECOR_ALL : MWM_DECOR_NONE;
+
+ XChangeProperty(context->connection, self->window, x11_context->motif_wm_hints_atom, x11_context->motif_wm_hints_atom, 32, PropModeReplace, (unsigned char*)&motif_hints, sizeof(motif_hints) / sizeof(long));
+}
+
static int mgl_window_init(mgl_window *self, const char *title, const mgl_window_create_params *params, Window existing_window) {
self->window = 0;
self->context = NULL;
@@ -588,6 +615,11 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
}
self->window = existing_window;
+
+ if(params && params->hide_decorations) {
+ mgl_window_set_decorations_visible(self, false);
+ }
+
if(hide_window)
XUnmapWindow(context->connection, existing_window);
} else {
@@ -601,6 +633,10 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
return -1;
}
+ if(params && params->hide_decorations) {
+ mgl_window_set_decorations_visible(self, false);
+ }
+
mgl_window_set_title(self, title);
if(!hide_window)
XMapWindow(context->connection, self->window);
@@ -625,7 +661,7 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
char host_name[HOST_NAME_MAX];
if(gethostname(host_name, sizeof(host_name)) == 0) {
XTextProperty txt_prop;
- txt_prop.value = host_name;
+ txt_prop.value = (unsigned char*)host_name;
txt_prop.encoding = XA_STRING;
txt_prop.format = 8;
txt_prop.nitems = strlen(host_name);
@@ -641,6 +677,7 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
XSetTransientForHint(context->connection, self->window, params->transient_for_window);
}
+ /* TODO: Move this to above XMapWindow? */
mgl_window_type window_type = params ? params->window_type : MGL_WINDOW_TYPE_NORMAL;
mgl_set_window_type(self, window_type);