/* * Copyright 2010 Johan Veenhuizen */ #include #include #include #include "wind.h" #define MWM_HINTS_DECORATIONS (1L << 1) #define MWM_DECOR_TITLE (1L << 3) typedef struct { CARD32 flags; CARD32 functions; CARD32 decorations; INT32 inputMode; CARD32 status; } PropMotifWmHints; static Atom MOTIF_WM_HINTS; static void reloadhints(struct client *); static PropMotifWmHints *gethints(struct client *); void mwm_startwm(void) { MOTIF_WM_HINTS = XInternAtom(dpy, "_MOTIF_WM_HINTS", False); } void mwm_manage(struct client *c) { reloadhints(c); } void mwm_propertynotify(struct client *c, XPropertyEvent *e) { if (e->atom == MOTIF_WM_HINTS) reloadhints(c); } /* * We ignore all hints except the title decor hint. If the window * does not want a title, we remove it's frame completely. */ static void reloadhints(struct client *c) { Bool undecorated = False; PropMotifWmHints *h = gethints(c); if (h != NULL) { if (h->flags & MWM_HINTS_DECORATIONS) { if ((h->decorations & MWM_DECOR_TITLE) == 0) undecorated = True; } XFree(h); } csetundecorated(c, undecorated); } static PropMotifWmHints *gethints(struct client *c) { unsigned long n = 0; PropMotifWmHints *h = getprop(cgetwin(c), MOTIF_WM_HINTS, MOTIF_WM_HINTS, 32, &n); if (h != NULL && n != 5) { XFree(h); h = NULL; } return h; }