X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=fedf069dcf4c8666a98443881a74ca422c6338ea;hp=88d80b2a447be77a7872e2ea3c0a82fb8f44a1cf;hb=f83d61dfe8f24c9a50ccf7e4b903b8844367ccb7;hpb=d6bdd03d915ecb800444986503b43aa488a82e36 diff --git a/dwm.c b/dwm.c index 88d80b2..fedf069 100644 --- a/dwm.c +++ b/dwm.c @@ -41,7 +41,6 @@ #endif /* XINERAMA */ /* macros */ -#define D if(1) #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) @@ -58,7 +57,8 @@ /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ -enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ +enum { NetSupported, NetWMName, NetWMState, + NetWMFullscreen, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ @@ -162,6 +162,7 @@ static void checkotherwm(void); static void cleanup(void); static void cleanupmon(Monitor *mon); static void clearurgent(Client *c); +static void clientmessage(XEvent *e); static void configure(Client *c); static void configurenotify(XEvent *e); static void configurerequest(XEvent *e); @@ -250,6 +251,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; static void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, + [ClientMessage] = clientmessage, [ConfigureRequest] = configurerequest, [ConfigureNotify] = configurenotify, [DestroyNotify] = destroynotify, @@ -815,8 +817,8 @@ void focus(Client *c) { if(!c || !ISVISIBLE(c)) for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); -// if(selmon->sel) -// unfocus(selmon->sel); + if(selmon->sel) + unfocus(selmon->sel); if(c) { if(c->mon != selmon) selmon = c->mon; @@ -848,7 +850,8 @@ focusmon(const Arg *arg) { if(!mons->next) return; - m = dirtomon(arg->i); + if((m = dirtomon(arg->i)) == selmon) + return; unfocus(selmon->sel); selmon = m; focus(NULL); @@ -1292,6 +1295,20 @@ propertynotify(XEvent *e) { } void +clientmessage(XEvent *e) { + XClientMessageEvent *cme = &e->xclient; + + if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) { + if(cme->data.l[0]) + XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32, + PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); + else + XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32, + PropModeReplace, (unsigned char*)0, 0); + } +} + +void quit(const Arg *arg) { running = False; } @@ -1389,24 +1406,9 @@ restack(Monitor *m) { void run(void) { XEvent ev; - static const char *evname[LASTEvent] = { - [ButtonPress] = "buttonpress", - [ConfigureRequest] = "configurerequest", - [ConfigureNotify] = "configurenotify", - [DestroyNotify] = "destroynotify", - [EnterNotify] = "enternotify", - [Expose] = "expose", - [FocusIn] = "focusin", - [KeyPress] = "keypress", - [MappingNotify] = "mappingnotify", - [MapRequest] = "maprequest", - [PropertyNotify] = "propertynotify", - [UnmapNotify] = "unmapnotify" - }; /* main event loop */ XSync(dpy, False); while(running && !XNextEvent(dpy, &ev)) { - D fprintf(stderr, "run event %s\n", evname[ev.type]); if(handler[ev.type]) handler[ev.type](&ev); /* call handler */ } @@ -1509,6 +1511,8 @@ setup(void) { wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); + netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); + netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); /* init cursors */ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); @@ -2017,7 +2021,7 @@ zoom(const Arg *arg) { int main(int argc, char *argv[]) { if(argc == 2 && !strcmp("-v", argv[1])) - die("dwm-"VERSION", © 2006-2009 dwm engineers, see LICENSE for details\n"); + die("dwm-"VERSION", © 2006-2010 dwm engineers, see LICENSE for details\n"); else if(argc != 1) die("usage: dwm [-v]\n"); if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())