diff options
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 24 |
1 files changed, 21 insertions, 3 deletions
| @@ -41,7 +41,6 @@ | |||
| 41 | #endif /* XINERAMA */ | 41 | #endif /* XINERAMA */ |
| 42 | 42 | ||
| 43 | /* macros */ | 43 | /* macros */ |
| 44 | #define D if(1) | ||
| 45 | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) | 44 | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) |
| 46 | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) | 45 | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
| 47 | #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) | 46 | #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) |
| @@ -58,7 +57,8 @@ | |||
| 58 | /* enums */ | 57 | /* enums */ |
| 59 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | 58 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ |
| 60 | enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ | 59 | enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ |
| 61 | enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ | 60 | enum { NetSupported, NetWMName, NetWMState, |
| 61 | NetWMFullscreen, NetLast }; /* EWMH atoms */ | ||
| 62 | enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ | 62 | enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ |
| 63 | enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, | 63 | enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, |
| 64 | ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ | 64 | ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ |
| @@ -162,6 +162,7 @@ static void checkotherwm(void); | |||
| 162 | static void cleanup(void); | 162 | static void cleanup(void); |
| 163 | static void cleanupmon(Monitor *mon); | 163 | static void cleanupmon(Monitor *mon); |
| 164 | static void clearurgent(Client *c); | 164 | static void clearurgent(Client *c); |
| 165 | static void clientmessage(XEvent *e); | ||
| 165 | static void configure(Client *c); | 166 | static void configure(Client *c); |
| 166 | static void configurenotify(XEvent *e); | 167 | static void configurenotify(XEvent *e); |
| 167 | static void configurerequest(XEvent *e); | 168 | static void configurerequest(XEvent *e); |
| @@ -250,6 +251,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *); | |||
| 250 | static unsigned int numlockmask = 0; | 251 | static unsigned int numlockmask = 0; |
| 251 | static void (*handler[LASTEvent]) (XEvent *) = { | 252 | static void (*handler[LASTEvent]) (XEvent *) = { |
| 252 | [ButtonPress] = buttonpress, | 253 | [ButtonPress] = buttonpress, |
| 254 | [ClientMessage] = clientmessage, | ||
| 253 | [ConfigureRequest] = configurerequest, | 255 | [ConfigureRequest] = configurerequest, |
| 254 | [ConfigureNotify] = configurenotify, | 256 | [ConfigureNotify] = configurenotify, |
| 255 | [DestroyNotify] = destroynotify, | 257 | [DestroyNotify] = destroynotify, |
| @@ -1293,6 +1295,20 @@ propertynotify(XEvent *e) { | |||
| 1293 | } | 1295 | } |
| 1294 | 1296 | ||
| 1295 | void | 1297 | void |
| 1298 | clientmessage(XEvent *e) { | ||
| 1299 | XClientMessageEvent *cme = &e->xclient; | ||
| 1300 | |||
| 1301 | if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) { | ||
| 1302 | if(cme->data.l[0]) | ||
| 1303 | XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32, | ||
| 1304 | PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); | ||
| 1305 | else | ||
| 1306 | XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32, | ||
| 1307 | PropModeReplace, (unsigned char*)0, 0); | ||
| 1308 | } | ||
| 1309 | } | ||
| 1310 | |||
| 1311 | void | ||
| 1296 | quit(const Arg *arg) { | 1312 | quit(const Arg *arg) { |
| 1297 | running = False; | 1313 | running = False; |
| 1298 | } | 1314 | } |
| @@ -1392,6 +1408,7 @@ run(void) { | |||
| 1392 | XEvent ev; | 1408 | XEvent ev; |
| 1393 | static const char *evname[LASTEvent] = { | 1409 | static const char *evname[LASTEvent] = { |
| 1394 | [ButtonPress] = "buttonpress", | 1410 | [ButtonPress] = "buttonpress", |
| 1411 | [ClientMessage] = "clientmessage", | ||
| 1395 | [ConfigureRequest] = "configurerequest", | 1412 | [ConfigureRequest] = "configurerequest", |
| 1396 | [ConfigureNotify] = "configurenotify", | 1413 | [ConfigureNotify] = "configurenotify", |
| 1397 | [DestroyNotify] = "destroynotify", | 1414 | [DestroyNotify] = "destroynotify", |
| @@ -1407,7 +1424,6 @@ run(void) { | |||
| 1407 | /* main event loop */ | 1424 | /* main event loop */ |
| 1408 | XSync(dpy, False); | 1425 | XSync(dpy, False); |
| 1409 | while(running && !XNextEvent(dpy, &ev)) { | 1426 | while(running && !XNextEvent(dpy, &ev)) { |
| 1410 | D fprintf(stderr, "run event %s %ld\n", evname[ev.type], ev.xany.window); | ||
| 1411 | if(handler[ev.type]) | 1427 | if(handler[ev.type]) |
| 1412 | handler[ev.type](&ev); /* call handler */ | 1428 | handler[ev.type](&ev); /* call handler */ |
| 1413 | } | 1429 | } |
| @@ -1510,6 +1526,8 @@ setup(void) { | |||
| 1510 | wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); | 1526 | wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); |
| 1511 | netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); | 1527 | netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); |
| 1512 | netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); | 1528 | netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); |
| 1529 | netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); | ||
| 1530 | netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); | ||
| 1513 | /* init cursors */ | 1531 | /* init cursors */ |
| 1514 | cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); | 1532 | cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); |
| 1515 | cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); | 1533 | cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); |
