X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dwm.c;h=a1a34e2db99b7d374dbb88067fb26d1765341ae4;hb=5d9ae3f3b7ad904218add1c2559eec9a7a073e3e;hp=018f929c7f6caf1bde03532ed97919ab940e1653;hpb=f7c097e8029c7d0dc00db52fc04a2b8192fc2bc9;p=dwm.git diff --git a/dwm.c b/dwm.c index 018f929..a1a34e2 100644 --- a/dwm.c +++ b/dwm.c @@ -40,9 +40,24 @@ #include #include #include -#ifdef XINERAMA +/* + * TODO: Idea: + * I intend to not provide real Xinerama support, but instead having a Column + * tilecols[] array which is used by tile(), and a Column maxcols[] arrays which is used by + * monocle(). Those arrays should be initialized in config.h. For simplicity + * reasons mwfact should be replaced with a more advanced method which + * implements the same, but using the boundary between tilecols[0] and + * tilecols[1] instead. Besides this, get rid of BARPOS and use instead the + * following mechanism: + * + * #define BX 0 + * #define BY 0 + * #define BW sw + * bh is calculated automatically and should be used for the + */ +//#ifdef XINERAMA #include -#endif +//#endif /* macros */ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) @@ -76,6 +91,10 @@ struct Client { Window win; }; +typedef struct { + int x, y, w, h; +} Column; + typedef struct { int x, y, w, h; unsigned long norm[ColLast]; @@ -153,6 +172,7 @@ void killclient(const char *arg); void manage(Window w, XWindowAttributes *wa); void mappingnotify(XEvent *e); void maprequest(XEvent *e); +void monocle(void); void movemouse(Client *c); Client *nexttiled(Client *c); void propertynotify(XEvent *e); @@ -194,7 +214,7 @@ void selectview(const char *arg); /* variables */ char stext[256], buf[256]; double mwfact; -int screen, sx, sy, sw, sh, wax, way, waw, wah, xscreens; +int screen, sx, sy, sw, sh, wax, way, waw, wah, ncols; int (*xerrorxlib)(Display *, XErrorEvent *); unsigned int bh, bpos; unsigned int blw = 0; @@ -223,14 +243,12 @@ Bool *seltags; Client *clients = NULL; Client *sel = NULL; Client *stack = NULL; +Column *cols = NULL; Cursor cursor[CurLast]; Display *dpy; DC dc = {0}; Layout *lt; Window root, barwin; -#ifdef XINERAMA -XineramaScreenInfo *info = NULL; -#endif /* configuration, allows nested code to access above variables */ #include "config.h" @@ -392,10 +410,6 @@ cleanup(void) { XFreeCursor(dpy, cursor[CurResize]); XFreeCursor(dpy, cursor[CurMove]); XDestroyWindow(dpy, barwin); -#if XINERAMA - if(info) - XFree(info); -#endif XSync(dpy, False); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); } @@ -1002,8 +1016,6 @@ manage(Window w, XWindowAttributes *wa) { c->tags = emallocz(TAGSZ); c->win = w; - applyrules(c); - c->x = wa->x + sx; c->y = wa->y + sy; c->w = wa->width; @@ -1038,6 +1050,8 @@ manage(Window w, XWindowAttributes *wa) { for(t = clients; t && t->win != trans; t = t->next); if(t) memcpy(c->tags, t->tags, TAGSZ); + else + applyrules(c); if(!c->isfloating) c->isfloating = (rettrans == Success) || c->isfixed; attach(c); @@ -1071,6 +1085,15 @@ maprequest(XEvent *e) { manage(ev->window, &wa); } +void +monocle(void) { + Client *c; + + domwfact = dozoom = False; + for(c = nexttiled(clients); c; c = nexttiled(c->next)) + resize(c, wax, way, waw - 2 * c->border, wah - 2 * c->border, RESIZEHINTS); +} + void movemouse(Client *c) { int x1, y1, ocx, ocy, di, nx, ny; @@ -1412,7 +1435,7 @@ setlayout(const char *arg) { } else { for(i = 0; i < LENGTH(layouts); i++) - if(arg == layouts[i].symbol) + if(!strcmp(arg, layouts[i].symbol)) break; if(i == LENGTH(layouts)) return; @@ -1448,8 +1471,12 @@ setmwfact(const char *arg) { void setup(void) { + int screens = 1; unsigned int i; XSetWindowAttributes wa; +//#ifdef XINERAMA + XineramaScreenInfo *info; +//#endif /* init screen */ screen = DefaultScreen(dpy); @@ -1458,6 +1485,14 @@ setup(void) { sy = 0; sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); + if(XineramaIsActive(dpy)) { + if((info = XineramaQueryScreens(dpy, &screens))) { + sx = info[0].x_org; + sy = info[0].y_org; + sw = info[0].width; + sh = info[0].height; + } + } /* init atoms */ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); @@ -1472,11 +1507,36 @@ setup(void) { cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); -#ifdef XINERAMA - if(XineramaIsActive(dpy)) - info = XineramaQueryScreens(dpy, &xscreens); + ncols = 2; +#if 0 + if(XineramaIsActive(dpy)) { + if((info = XineramaQueryScreens(dpy, &screens))) { + if(screens >= 1) { + sx = info[0].x_org; + sy = info[0].y_org; + sw = info[0].width; + sh = info[0].height; + } + else { + ncols = screens; + cols = emallocz(ncols * sizeof(Column)); + for(i = 0; i < ncols; i++) { + cols[i].x = info[i].x_org; + cols[i].y = info[i].y_org; + cols[i].w = info[i].width; + cols[i].h = info[i].height; + } + } + XFree(info); + } + } + else + { + cols = emallocz(ncols * sizeof(Column)); + cols[0].x = sx; + cols[0].y = sy; + } #endif - /* init appearance */ dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); dc.norm[ColBG] = getcolor(NORMBGCOLOR); @@ -1811,7 +1871,10 @@ updatewmhints(Client *c) { XWMHints *wmh; if((wmh = XGetWMHints(dpy, c->win))) { - c->isurgent = (wmh->flags & XUrgencyHint) ? True : False; + if(c == sel) + sel->isurgent = False; + else + c->isurgent = (wmh->flags & XUrgencyHint) ? True : False; XFree(wmh); } }