rework: removing monitor from rules
This commit is contained in:
@@ -11,10 +11,10 @@ static const char *colors[][3] = {
|
|||||||
|
|
||||||
static const char *tags[] = { "1", "2", "3" };
|
static const char *tags[] = { "1", "2", "3" };
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
{ "st-256color", "st-256color", NULL, 1, 0, -1 },
|
{ "st-256color", "st-256color", NULL, 1, 0 },
|
||||||
{ "librewolf", "Navigator", NULL, 1 << 1, 0, -1 },
|
{ "librewolf", "Navigator", NULL, 1 << 1, 0 },
|
||||||
{ "PrismLauncher", "prismlauncher", NULL, 1 << 2, 0, -1 },
|
{ "PrismLauncher", "prismlauncher", NULL, 1 << 2, 0 },
|
||||||
{ "steam", "steamwebhelper", NULL, 1 << 2, 0, -1 },
|
{ "steam", "steamwebhelper", NULL, 1 << 2, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float mfact = 0.55;
|
static const float mfact = 0.55;
|
||||||
|
|||||||
+73
-244
@@ -17,13 +17,11 @@
|
|||||||
#include "drw.h"
|
#include "drw.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
@@ -110,7 +108,6 @@ typedef struct {
|
|||||||
const char *title;
|
const char *title;
|
||||||
unsigned int tags;
|
unsigned int tags;
|
||||||
int isfloating;
|
int isfloating;
|
||||||
int monitor;
|
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
/* function declarations */
|
/* function declarations */
|
||||||
@@ -175,7 +172,6 @@ static void unmanage(Client *c, int destroyed);
|
|||||||
static void unmapnotify(XEvent *e);
|
static void unmapnotify(XEvent *e);
|
||||||
static void updatebars(void);
|
static void updatebars(void);
|
||||||
static int updategeom(void);
|
static int updategeom(void);
|
||||||
static void updatenumlockmask(void);
|
|
||||||
static void updatesizehints(Client *c);
|
static void updatesizehints(Client *c);
|
||||||
static void updatestatus(void);
|
static void updatestatus(void);
|
||||||
static void updatetitle(Client *c);
|
static void updatetitle(Client *c);
|
||||||
@@ -228,13 +224,10 @@ static Window root, wmcheckwin;
|
|||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
/* function implementations */
|
/* function implementations */
|
||||||
void
|
void applyrules(Client *c) {
|
||||||
applyrules(Client *c)
|
|
||||||
{
|
|
||||||
const char *class, *instance;
|
const char *class, *instance;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const Rule *r;
|
const Rule *r;
|
||||||
Monitor *m;
|
|
||||||
XClassHint ch = { NULL, NULL };
|
XClassHint ch = { NULL, NULL };
|
||||||
|
|
||||||
/* rule matching */
|
/* rule matching */
|
||||||
@@ -252,9 +245,6 @@ applyrules(Client *c)
|
|||||||
{
|
{
|
||||||
c->isfloating = r->isfloating;
|
c->isfloating = r->isfloating;
|
||||||
c->tags |= r->tags;
|
c->tags |= r->tags;
|
||||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
|
||||||
if (m)
|
|
||||||
c->mon = m;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ch.res_class)
|
if (ch.res_class)
|
||||||
@@ -264,9 +254,7 @@ applyrules(Client *c)
|
|||||||
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
|
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact) {
|
||||||
applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
|
|
||||||
{
|
|
||||||
int baseismin;
|
int baseismin;
|
||||||
Monitor *m = c->mon;
|
Monitor *m = c->mon;
|
||||||
|
|
||||||
@@ -332,9 +320,7 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
|
|||||||
return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
|
return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void arrange(Monitor *m) {
|
||||||
arrange(Monitor *m)
|
|
||||||
{
|
|
||||||
if (m)
|
if (m)
|
||||||
showhide(m->stack);
|
showhide(m->stack);
|
||||||
else for (m = mons; m; m = m->next)
|
else for (m = mons; m; m = m->next)
|
||||||
@@ -346,31 +332,23 @@ arrange(Monitor *m)
|
|||||||
arrangemon(m);
|
arrangemon(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void arrangemon(Monitor *m) {
|
||||||
arrangemon(Monitor *m)
|
|
||||||
{
|
|
||||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
|
||||||
if (m->lt[m->sellt]->arrange)
|
if (m->lt[m->sellt]->arrange)
|
||||||
m->lt[m->sellt]->arrange(m);
|
m->lt[m->sellt]->arrange(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void attach(Client *c) {
|
||||||
attach(Client *c)
|
|
||||||
{
|
|
||||||
c->next = c->mon->clients;
|
c->next = c->mon->clients;
|
||||||
c->mon->clients = c;
|
c->mon->clients = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void attachstack(Client *c) {
|
||||||
attachstack(Client *c)
|
|
||||||
{
|
|
||||||
c->snext = c->mon->stack;
|
c->snext = c->mon->stack;
|
||||||
c->mon->stack = c;
|
c->mon->stack = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void cleanup(void) {
|
||||||
cleanup(void)
|
|
||||||
{
|
|
||||||
Arg a = {.ui = ~0};
|
Arg a = {.ui = ~0};
|
||||||
Layout foo = { "", NULL };
|
Layout foo = { "", NULL };
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
@@ -396,9 +374,7 @@ cleanup(void)
|
|||||||
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
|
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void cleanupmon(Monitor *mon) {
|
||||||
cleanupmon(Monitor *mon)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
|
||||||
if (mon == mons)
|
if (mon == mons)
|
||||||
@@ -412,9 +388,7 @@ cleanupmon(Monitor *mon)
|
|||||||
free(mon);
|
free(mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void clientmessage(XEvent *e) {
|
||||||
clientmessage(XEvent *e)
|
|
||||||
{
|
|
||||||
XClientMessageEvent *cme = &e->xclient;
|
XClientMessageEvent *cme = &e->xclient;
|
||||||
Client *c = wintoclient(cme->window);
|
Client *c = wintoclient(cme->window);
|
||||||
|
|
||||||
@@ -431,9 +405,7 @@ clientmessage(XEvent *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void configure(Client *c) {
|
||||||
configure(Client *c)
|
|
||||||
{
|
|
||||||
XConfigureEvent ce;
|
XConfigureEvent ce;
|
||||||
|
|
||||||
ce.type = ConfigureNotify;
|
ce.type = ConfigureNotify;
|
||||||
@@ -450,9 +422,7 @@ configure(Client *c)
|
|||||||
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
|
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void configurenotify(XEvent *e) {
|
||||||
configurenotify(XEvent *e)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
Client *c;
|
Client *c;
|
||||||
XConfigureEvent *ev = &e->xconfigure;
|
XConfigureEvent *ev = &e->xconfigure;
|
||||||
@@ -478,9 +448,7 @@ configurenotify(XEvent *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void configurerequest(XEvent *e) {
|
||||||
configurerequest(XEvent *e)
|
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||||
@@ -530,9 +498,7 @@ configurerequest(XEvent *e)
|
|||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
Monitor *
|
Monitor * createmon(void) {
|
||||||
createmon(void)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
|
||||||
m = ecalloc(1, sizeof(Monitor));
|
m = ecalloc(1, sizeof(Monitor));
|
||||||
@@ -548,9 +514,7 @@ createmon(void)
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void destroynotify(XEvent *e) {
|
||||||
destroynotify(XEvent *e)
|
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
||||||
|
|
||||||
@@ -558,18 +522,14 @@ destroynotify(XEvent *e)
|
|||||||
unmanage(c, 1);
|
unmanage(c, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void detach(Client *c) {
|
||||||
detach(Client *c)
|
|
||||||
{
|
|
||||||
Client **tc;
|
Client **tc;
|
||||||
|
|
||||||
for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
|
for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
|
||||||
*tc = c->next;
|
*tc = c->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void detachstack(Client *c) {
|
||||||
detachstack(Client *c)
|
|
||||||
{
|
|
||||||
Client **tc, *t;
|
Client **tc, *t;
|
||||||
|
|
||||||
for (tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext);
|
for (tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext);
|
||||||
@@ -581,9 +541,7 @@ detachstack(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void drawbar(Monitor *m) {
|
||||||
drawbar(Monitor *m)
|
|
||||||
{
|
|
||||||
int x, w, tw = 0;
|
int x, w, tw = 0;
|
||||||
|
|
||||||
int boxs = drw->fonts->h / 9;
|
int boxs = drw->fonts->h / 9;
|
||||||
@@ -637,18 +595,14 @@ drawbar(Monitor *m)
|
|||||||
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void drawbars(void) {
|
||||||
drawbars(void)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
|
||||||
for (m = mons; m; m = m->next)
|
for (m = mons; m; m = m->next)
|
||||||
drawbar(m);
|
drawbar(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void enternotify(XEvent *e) {
|
||||||
enternotify(XEvent *e)
|
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XCrossingEvent *ev = &e->xcrossing;
|
XCrossingEvent *ev = &e->xcrossing;
|
||||||
@@ -665,9 +619,7 @@ enternotify(XEvent *e)
|
|||||||
focus(c);
|
focus(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void expose(XEvent *e) {
|
||||||
expose(XEvent *e)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XExposeEvent *ev = &e->xexpose;
|
XExposeEvent *ev = &e->xexpose;
|
||||||
|
|
||||||
@@ -675,9 +627,7 @@ expose(XEvent *e)
|
|||||||
drawbar(m);
|
drawbar(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void focus(Client *c) {
|
||||||
focus(Client *c)
|
|
||||||
{
|
|
||||||
if (!c || !ISVISIBLE(c))
|
if (!c || !ISVISIBLE(c))
|
||||||
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
||||||
if (selmon->sel && selmon->sel != c)
|
if (selmon->sel && selmon->sel != c)
|
||||||
@@ -700,18 +650,14 @@ focus(Client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* there are some broken focus acquiring clients needing extra handling */
|
/* there are some broken focus acquiring clients needing extra handling */
|
||||||
void
|
void focusin(XEvent *e) {
|
||||||
focusin(XEvent *e)
|
|
||||||
{
|
|
||||||
XFocusChangeEvent *ev = &e->xfocus;
|
XFocusChangeEvent *ev = &e->xfocus;
|
||||||
|
|
||||||
if (selmon->sel && ev->window != selmon->sel->win)
|
if (selmon->sel && ev->window != selmon->sel->win)
|
||||||
setfocus(selmon->sel);
|
setfocus(selmon->sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void focusstack(const Arg *arg) {
|
||||||
focusstack(const Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c = NULL, *i;
|
Client *c = NULL, *i;
|
||||||
|
|
||||||
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||||
@@ -735,9 +681,7 @@ focusstack(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom
|
Atom getatomprop(Client *c, Atom prop) {
|
||||||
getatomprop(Client *c, Atom prop)
|
|
||||||
{
|
|
||||||
int di;
|
int di;
|
||||||
unsigned long dl;
|
unsigned long dl;
|
||||||
unsigned char *p = NULL;
|
unsigned char *p = NULL;
|
||||||
@@ -751,9 +695,7 @@ getatomprop(Client *c, Atom prop)
|
|||||||
return atom;
|
return atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int getrootptr(int *x, int *y) {
|
||||||
getrootptr(int *x, int *y)
|
|
||||||
{
|
|
||||||
int di;
|
int di;
|
||||||
unsigned int dui;
|
unsigned int dui;
|
||||||
Window dummy;
|
Window dummy;
|
||||||
@@ -761,9 +703,7 @@ getrootptr(int *x, int *y)
|
|||||||
return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
|
return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long getstate(Window w) {
|
||||||
getstate(Window w)
|
|
||||||
{
|
|
||||||
int format;
|
int format;
|
||||||
long result = -1;
|
long result = -1;
|
||||||
unsigned char *p = NULL;
|
unsigned char *p = NULL;
|
||||||
@@ -779,9 +719,7 @@ getstate(Window w)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int gettextprop(Window w, Atom atom, char *text, unsigned int size) {
|
||||||
gettextprop(Window w, Atom atom, char *text, unsigned int size)
|
|
||||||
{
|
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
int n;
|
int n;
|
||||||
XTextProperty name;
|
XTextProperty name;
|
||||||
@@ -802,10 +740,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void grabkeys(void) {
|
||||||
grabkeys(void)
|
|
||||||
{
|
|
||||||
updatenumlockmask();
|
|
||||||
{
|
{
|
||||||
unsigned int i, j, k;
|
unsigned int i, j, k;
|
||||||
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
||||||
@@ -830,9 +765,7 @@ grabkeys(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void keypress(XEvent *e) {
|
||||||
keypress(XEvent *e)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
XKeyEvent *ev;
|
XKeyEvent *ev;
|
||||||
@@ -846,9 +779,7 @@ keypress(XEvent *e)
|
|||||||
keys[i].func(&(keys[i].arg));
|
keys[i].func(&(keys[i].arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void killclient(const Arg *arg) {
|
||||||
killclient(const Arg *arg)
|
|
||||||
{
|
|
||||||
if (!selmon->sel)
|
if (!selmon->sel)
|
||||||
return;
|
return;
|
||||||
if (!sendevent(selmon->sel, wmatom[WMDelete])) {
|
if (!sendevent(selmon->sel, wmatom[WMDelete])) {
|
||||||
@@ -862,9 +793,7 @@ killclient(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void manage(Window w, XWindowAttributes *wa) {
|
||||||
manage(Window w, XWindowAttributes *wa)
|
|
||||||
{
|
|
||||||
Client *c, *t = NULL;
|
Client *c, *t = NULL;
|
||||||
Window trans = None;
|
Window trans = None;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
@@ -921,9 +850,7 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void mappingnotify(XEvent *e) {
|
||||||
mappingnotify(XEvent *e)
|
|
||||||
{
|
|
||||||
XMappingEvent *ev = &e->xmapping;
|
XMappingEvent *ev = &e->xmapping;
|
||||||
|
|
||||||
XRefreshKeyboardMapping(ev);
|
XRefreshKeyboardMapping(ev);
|
||||||
@@ -931,9 +858,7 @@ mappingnotify(XEvent *e)
|
|||||||
grabkeys();
|
grabkeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void maprequest(XEvent *e) {
|
||||||
maprequest(XEvent *e)
|
|
||||||
{
|
|
||||||
static XWindowAttributes wa;
|
static XWindowAttributes wa;
|
||||||
XMapRequestEvent *ev = &e->xmaprequest;
|
XMapRequestEvent *ev = &e->xmaprequest;
|
||||||
|
|
||||||
@@ -943,9 +868,7 @@ maprequest(XEvent *e)
|
|||||||
manage(ev->window, &wa);
|
manage(ev->window, &wa);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void motionnotify(XEvent *e) {
|
||||||
motionnotify(XEvent *e)
|
|
||||||
{
|
|
||||||
static Monitor *mon = NULL;
|
static Monitor *mon = NULL;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XMotionEvent *ev = &e->xmotion;
|
XMotionEvent *ev = &e->xmotion;
|
||||||
@@ -960,25 +883,19 @@ motionnotify(XEvent *e)
|
|||||||
mon = m;
|
mon = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client * nexttiled(Client *c) {
|
||||||
nexttiled(Client *c)
|
|
||||||
{
|
|
||||||
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void pop(Client *c) {
|
||||||
pop(Client *c)
|
|
||||||
{
|
|
||||||
detach(c);
|
detach(c);
|
||||||
attach(c);
|
attach(c);
|
||||||
focus(c);
|
focus(c);
|
||||||
arrange(c->mon);
|
arrange(c->mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void propertynotify(XEvent *e) {
|
||||||
propertynotify(XEvent *e)
|
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
Window trans;
|
Window trans;
|
||||||
XPropertyEvent *ev = &e->xproperty;
|
XPropertyEvent *ev = &e->xproperty;
|
||||||
@@ -1013,9 +930,7 @@ propertynotify(XEvent *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Monitor *
|
Monitor * recttomon(int x, int y, int w, int h) {
|
||||||
recttomon(int x, int y, int w, int h)
|
|
||||||
{
|
|
||||||
Monitor *m, *r = selmon;
|
Monitor *m, *r = selmon;
|
||||||
int a, area = 0;
|
int a, area = 0;
|
||||||
|
|
||||||
@@ -1027,16 +942,12 @@ recttomon(int x, int y, int w, int h)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void resize(Client *c, int x, int y, int w, int h, int interact) {
|
||||||
resize(Client *c, int x, int y, int w, int h, int interact)
|
|
||||||
{
|
|
||||||
if (applysizehints(c, &x, &y, &w, &h, interact))
|
if (applysizehints(c, &x, &y, &w, &h, interact))
|
||||||
resizeclient(c, x, y, w, h);
|
resizeclient(c, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void resizeclient(Client *c, int x, int y, int w, int h) {
|
||||||
resizeclient(Client *c, int x, int y, int w, int h)
|
|
||||||
{
|
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
c->oldx = c->x; c->x = wc.x = x;
|
c->oldx = c->x; c->x = wc.x = x;
|
||||||
@@ -1049,9 +960,7 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
|||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void restack(Monitor *m) {
|
||||||
restack(Monitor *m)
|
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
@@ -1074,9 +983,7 @@ restack(Monitor *m)
|
|||||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void run(void) {
|
||||||
run(void)
|
|
||||||
{
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
/* main event loop */
|
/* main event loop */
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@@ -1085,9 +992,7 @@ run(void)
|
|||||||
handler[ev.type](&ev); /* call handler */
|
handler[ev.type](&ev); /* call handler */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void scan(void) {
|
||||||
scan(void)
|
|
||||||
{
|
|
||||||
unsigned int i, num;
|
unsigned int i, num;
|
||||||
Window d1, d2, *wins = NULL;
|
Window d1, d2, *wins = NULL;
|
||||||
XWindowAttributes wa;
|
XWindowAttributes wa;
|
||||||
@@ -1112,18 +1017,14 @@ scan(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void setclientstate(Client *c, long state) {
|
||||||
setclientstate(Client *c, long state)
|
|
||||||
{
|
|
||||||
long data[] = { state, None };
|
long data[] = { state, None };
|
||||||
|
|
||||||
XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
|
XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
|
||||||
PropModeReplace, (unsigned char *)data, 2);
|
PropModeReplace, (unsigned char *)data, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int sendevent(Client *c, Atom proto) {
|
||||||
sendevent(Client *c, Atom proto)
|
|
||||||
{
|
|
||||||
int n;
|
int n;
|
||||||
Atom *protocols;
|
Atom *protocols;
|
||||||
int exists = 0;
|
int exists = 0;
|
||||||
@@ -1146,9 +1047,7 @@ sendevent(Client *c, Atom proto)
|
|||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void setfocus(Client *c) {
|
||||||
setfocus(Client *c)
|
|
||||||
{
|
|
||||||
if (!c->neverfocus) {
|
if (!c->neverfocus) {
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
XChangeProperty(dpy, root, netatom[NetActiveWindow],
|
XChangeProperty(dpy, root, netatom[NetActiveWindow],
|
||||||
@@ -1158,9 +1057,7 @@ setfocus(Client *c)
|
|||||||
sendevent(c, wmatom[WMTakeFocus]);
|
sendevent(c, wmatom[WMTakeFocus]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void setfullscreen(Client *c, int fullscreen) {
|
||||||
setfullscreen(Client *c, int fullscreen)
|
|
||||||
{
|
|
||||||
if (fullscreen && !c->isfullscreen) {
|
if (fullscreen && !c->isfullscreen) {
|
||||||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||||
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
|
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
|
||||||
@@ -1187,9 +1084,7 @@ setfullscreen(Client *c, int fullscreen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* arg > 1.0 will set mfact absolutely */
|
/* arg > 1.0 will set mfact absolutely */
|
||||||
void
|
void setmfact(const Arg *arg) {
|
||||||
setmfact(const Arg *arg)
|
|
||||||
{
|
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
if (!arg || !selmon->lt[selmon->sellt]->arrange)
|
if (!arg || !selmon->lt[selmon->sellt]->arrange)
|
||||||
@@ -1201,9 +1096,7 @@ setmfact(const Arg *arg)
|
|||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void setup(void) {
|
||||||
setup(void)
|
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
Atom utf8string;
|
Atom utf8string;
|
||||||
@@ -1278,9 +1171,7 @@ setup(void)
|
|||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void seturgent(Client *c, int urg) {
|
||||||
seturgent(Client *c, int urg)
|
|
||||||
{
|
|
||||||
XWMHints *wmh;
|
XWMHints *wmh;
|
||||||
|
|
||||||
c->isurgent = urg;
|
c->isurgent = urg;
|
||||||
@@ -1291,9 +1182,7 @@ seturgent(Client *c, int urg)
|
|||||||
XFree(wmh);
|
XFree(wmh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void showhide(Client *c) {
|
||||||
showhide(Client *c)
|
|
||||||
{
|
|
||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return;
|
||||||
if (ISVISIBLE(c)) {
|
if (ISVISIBLE(c)) {
|
||||||
@@ -1309,9 +1198,7 @@ showhide(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void spawn(const Arg *arg) {
|
||||||
spawn(const Arg *arg)
|
|
||||||
{
|
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
@@ -1329,9 +1216,7 @@ spawn(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void tag(const Arg *arg) {
|
||||||
tag(const Arg *arg)
|
|
||||||
{
|
|
||||||
if (selmon->sel && arg->ui & TAGMASK) {
|
if (selmon->sel && arg->ui & TAGMASK) {
|
||||||
selmon->sel->tags = arg->ui & TAGMASK;
|
selmon->sel->tags = arg->ui & TAGMASK;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
@@ -1339,9 +1224,7 @@ tag(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void tile(Monitor *m) {
|
||||||
tile(Monitor *m)
|
|
||||||
{
|
|
||||||
unsigned int i, n, h, g = 0, mw, my, ty;
|
unsigned int i, n, h, g = 0, mw, my, ty;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
@@ -1369,9 +1252,7 @@ tile(Monitor *m)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void toggletag(const Arg *arg) {
|
||||||
toggletag(const Arg *arg)
|
|
||||||
{
|
|
||||||
unsigned int newtags;
|
unsigned int newtags;
|
||||||
|
|
||||||
if (!selmon->sel)
|
if (!selmon->sel)
|
||||||
@@ -1384,9 +1265,7 @@ toggletag(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void toggleview(const Arg *arg) {
|
||||||
toggleview(const Arg *arg)
|
|
||||||
{
|
|
||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||||
|
|
||||||
if (newtagset) {
|
if (newtagset) {
|
||||||
@@ -1396,9 +1275,7 @@ toggleview(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void unfocus(Client *c, int setfocus) {
|
||||||
unfocus(Client *c, int setfocus)
|
|
||||||
{
|
|
||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return;
|
||||||
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
|
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
|
||||||
@@ -1408,9 +1285,7 @@ unfocus(Client *c, int setfocus)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void unmanage(Client *c, int destroyed) {
|
||||||
unmanage(Client *c, int destroyed)
|
|
||||||
{
|
|
||||||
Monitor *m = c->mon;
|
Monitor *m = c->mon;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
@@ -1440,9 +1315,7 @@ unmanage(Client *c, int destroyed)
|
|||||||
arrange(m);
|
arrange(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void unmapnotify(XEvent *e) {
|
||||||
unmapnotify(XEvent *e)
|
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XUnmapEvent *ev = &e->xunmap;
|
XUnmapEvent *ev = &e->xunmap;
|
||||||
|
|
||||||
@@ -1454,9 +1327,7 @@ unmapnotify(XEvent *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void updatebars(void) {
|
||||||
updatebars(void)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XSetWindowAttributes wa = {
|
XSetWindowAttributes wa = {
|
||||||
.override_redirect = True,
|
.override_redirect = True,
|
||||||
@@ -1477,9 +1348,7 @@ updatebars(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int updategeom(void) {
|
||||||
updategeom(void)
|
|
||||||
{
|
|
||||||
int dirty = 0;
|
int dirty = 0;
|
||||||
|
|
||||||
{ /* default monitor setup */
|
{ /* default monitor setup */
|
||||||
@@ -1497,7 +1366,6 @@ updategeom(void)
|
|||||||
mons->wy = mons->topbar ? mons->wy + bh : mons->wy;
|
mons->wy = mons->topbar ? mons->wy + bh : mons->wy;
|
||||||
} else
|
} else
|
||||||
mons->by = -bh;
|
mons->by = -bh;
|
||||||
// updatebarpos(mons);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
@@ -1507,25 +1375,8 @@ updategeom(void)
|
|||||||
return dirty;
|
return dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
updatenumlockmask(void)
|
|
||||||
{
|
|
||||||
unsigned int i, j;
|
|
||||||
XModifierKeymap *modmap;
|
|
||||||
|
|
||||||
numlockmask = 0;
|
void updatesizehints(Client *c) {
|
||||||
modmap = XGetModifierMapping(dpy);
|
|
||||||
for (i = 0; i < 8; i++)
|
|
||||||
for (j = 0; j < modmap->max_keypermod; j++)
|
|
||||||
if (modmap->modifiermap[i * modmap->max_keypermod + j]
|
|
||||||
== XKeysymToKeycode(dpy, XK_Num_Lock))
|
|
||||||
numlockmask = (1 << i);
|
|
||||||
XFreeModifiermap(modmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
updatesizehints(Client *c)
|
|
||||||
{
|
|
||||||
long msize;
|
long msize;
|
||||||
XSizeHints size;
|
XSizeHints size;
|
||||||
|
|
||||||
@@ -1572,26 +1423,20 @@ updatesizehints(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void updatestatus(void) {
|
||||||
updatestatus(void)
|
|
||||||
{
|
|
||||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||||
strcpy(stext, " dwm ");
|
strcpy(stext, " dwm ");
|
||||||
drawbar(selmon);
|
drawbar(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void updatetitle(Client *c) {
|
||||||
updatetitle(Client *c)
|
|
||||||
{
|
|
||||||
if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
|
if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
|
||||||
gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
|
gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
|
||||||
if (c->name[0] == '\0') /* hack to mark broken clients */
|
if (c->name[0] == '\0') /* hack to mark broken clients */
|
||||||
strcpy(c->name, broken);
|
strcpy(c->name, broken);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void updatewindowtype(Client *c) {
|
||||||
updatewindowtype(Client *c)
|
|
||||||
{
|
|
||||||
Atom state = getatomprop(c, netatom[NetWMState]);
|
Atom state = getatomprop(c, netatom[NetWMState]);
|
||||||
Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
|
Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
|
||||||
|
|
||||||
@@ -1601,9 +1446,7 @@ updatewindowtype(Client *c)
|
|||||||
c->isfloating = 1;
|
c->isfloating = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void updatewmhints(Client *c) {
|
||||||
updatewmhints(Client *c)
|
|
||||||
{
|
|
||||||
XWMHints *wmh;
|
XWMHints *wmh;
|
||||||
|
|
||||||
if ((wmh = XGetWMHints(dpy, c->win))) {
|
if ((wmh = XGetWMHints(dpy, c->win))) {
|
||||||
@@ -1619,9 +1462,7 @@ updatewmhints(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void view(const Arg *arg) {
|
||||||
view(const Arg *arg)
|
|
||||||
{
|
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
return;
|
return;
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
@@ -1631,9 +1472,7 @@ view(const Arg *arg)
|
|||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client * wintoclient(Window w) {
|
||||||
wintoclient(Window w)
|
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
|
||||||
@@ -1644,9 +1483,7 @@ wintoclient(Window w)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Monitor *
|
Monitor * wintomon(Window w) {
|
||||||
wintomon(Window w)
|
|
||||||
{
|
|
||||||
int x, y;
|
int x, y;
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
@@ -1664,9 +1501,7 @@ wintomon(Window w)
|
|||||||
/* There's no way to check accesses to destroyed windows, thus those cases are
|
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||||
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||||
* default error handler, which may call exit. */
|
* default error handler, which may call exit. */
|
||||||
int
|
int xerror(Display *dpy, XErrorEvent *ee) {
|
||||||
xerror(Display *dpy, XErrorEvent *ee)
|
|
||||||
{
|
|
||||||
if (ee->error_code == BadWindow
|
if (ee->error_code == BadWindow
|
||||||
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|
||||||
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|
||||||
@@ -1682,15 +1517,11 @@ xerror(Display *dpy, XErrorEvent *ee)
|
|||||||
return xerrorxlib(dpy, ee); /* may call exit */
|
return xerrorxlib(dpy, ee); /* may call exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int xerrordummy(Display *dpy, XErrorEvent *ee) {
|
||||||
xerrordummy(Display *dpy, XErrorEvent *ee)
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zoom(const Arg *arg) {
|
||||||
zoom(const Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c = selmon->sel;
|
Client *c = selmon->sel;
|
||||||
|
|
||||||
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
|
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
|
||||||
@@ -1700,9 +1531,7 @@ zoom(const Arg *arg)
|
|||||||
pop(c);
|
pop(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int main(int argc, char *argv[]) {
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
if (!(dpy = XOpenDisplay(NULL)))
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
die("dwm: cannot open display");
|
die("dwm: cannot open display");
|
||||||
setup();
|
setup();
|
||||||
|
|||||||
Reference in New Issue
Block a user