[go: up one dir, main page]

Menu

[241c66]: / mwm.c  Maximize  Restore  History

Download this file

75 lines (60 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright 2010 Johan Veenhuizen
*/
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#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;
}