before major changes to monitor support

This commit is contained in:
DarthMooMancer
2025-10-12 15:51:15 -04:00
parent d879d3b026
commit a2b0a3fa72
2 changed files with 104 additions and 269 deletions
-3
View File
@@ -20,7 +20,6 @@ static const float mfact = 0.55;
static const int nmaster = 1; static const int nmaster = 1;
static const int resizehints = 1; static const int resizehints = 1;
static const int lockfullscreen = 1; static const int lockfullscreen = 1;
static const int refreshrate = 120;
static const Layout layouts[] = { static const Layout layouts[] = {
{ "T", tile }, { "T", tile },
@@ -35,8 +34,6 @@ static const Layout layouts[] = {
#include "X11/XF86keysym.h" #include "X11/XF86keysym.h"
static const Key keys[] = { static const Key keys[] = {
{ MODKEY, XK_h, focusstack, {.i = +1 } },
{ MODKEY, XK_l, focusstack, {.i = -1 } },
{ MODKEY, XK_q, killclient, {0} }, { MODKEY, XK_q, killclient, {0} },
{ MODKEY, XK_Return, spawn, SHCMD("ghostty -e tmux a") }, { MODKEY, XK_Return, spawn, SHCMD("ghostty -e tmux a") },
{ MODKEY, XK_f, spawn, SHCMD("librewolf") }, { MODKEY, XK_f, spawn, SHCMD("librewolf") },
+80 -242
View File
@@ -136,7 +136,6 @@ static void enternotify(XEvent *e);
static void expose(XEvent *e); static void expose(XEvent *e);
static void focus(Client *c); static void focus(Client *c);
static void focusin(XEvent *e); static void focusin(XEvent *e);
static void focusstack(const Arg *arg);
static Atom getatomprop(Client *c, Atom prop); static Atom getatomprop(Client *c, Atom prop);
static int getrootptr(int *x, int *y); static int getrootptr(int *x, int *y);
static long getstate(Window w); static long getstate(Window w);
@@ -225,9 +224,7 @@ 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;
@@ -261,9 +258,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;
@@ -329,9 +324,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)
@@ -343,31 +336,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;
@@ -393,9 +378,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)
@@ -409,9 +392,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);
@@ -428,9 +409,7 @@ clientmessage(XEvent *e)
} }
} }
void void configure(Client *c) {
configure(Client *c)
{
XConfigureEvent ce; XConfigureEvent ce;
ce.type = ConfigureNotify; ce.type = ConfigureNotify;
@@ -447,9 +426,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;
@@ -475,9 +452,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;
@@ -527,9 +502,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));
@@ -545,9 +518,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;
@@ -555,18 +526,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);
@@ -578,9 +545,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;
@@ -633,18 +598,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;
@@ -661,9 +622,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;
@@ -671,9 +630,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)
@@ -696,44 +653,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 Atom getatomprop(Client *c, Atom prop) {
focusstack(const Arg *arg)
{
Client *c = NULL, *i;
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
return;
if (arg->i > 0) {
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
if (!c)
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
} else {
for (i = selmon->clients; i != selmon->sel; i = i->next)
if (ISVISIBLE(i))
c = i;
if (!c)
for (; i; i = i->next)
if (ISVISIBLE(i))
c = i;
}
if (c) {
focus(c);
restack(selmon);
}
}
Atom
getatomprop(Client *c, Atom prop)
{
int di; int di;
unsigned long dl; unsigned long dl;
unsigned char *p = NULL; unsigned char *p = NULL;
@@ -747,9 +674,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;
@@ -757,9 +682,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;
@@ -775,9 +698,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;
@@ -798,9 +719,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
return 1; return 1;
} }
void void grabkeys(void) {
grabkeys(void)
{
updatenumlockmask(); updatenumlockmask();
{ {
unsigned int i, j, k; unsigned int i, j, k;
@@ -826,9 +745,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;
@@ -842,9 +759,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])) {
@@ -858,9 +773,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;
@@ -917,9 +830,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);
@@ -927,9 +838,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;
@@ -939,9 +848,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;
@@ -956,16 +863,12 @@ 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 propertynotify(XEvent *e) {
propertynotify(XEvent *e)
{
Client *c; Client *c;
Window trans; Window trans;
XPropertyEvent *ev = &e->xproperty; XPropertyEvent *ev = &e->xproperty;
@@ -1000,9 +903,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;
@@ -1014,16 +915,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;
@@ -1036,9 +933,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;
@@ -1061,9 +956,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);
@@ -1072,9 +965,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;
@@ -1099,18 +990,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;
@@ -1133,9 +1020,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],
@@ -1145,9 +1030,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);
@@ -1173,9 +1056,7 @@ setfullscreen(Client *c, int fullscreen)
} }
} }
void void setup(void) {
setup(void)
{
int i; int i;
XSetWindowAttributes wa; XSetWindowAttributes wa;
Atom utf8string; Atom utf8string;
@@ -1250,9 +1131,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;
@@ -1263,9 +1142,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)) {
@@ -1281,9 +1158,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) {
@@ -1301,9 +1176,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);
@@ -1311,9 +1184,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;
@@ -1341,9 +1212,7 @@ tile(Monitor *m)
} }
} }
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);
@@ -1353,9 +1222,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;
@@ -1379,9 +1246,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;
@@ -1393,9 +1258,7 @@ unmapnotify(XEvent *e)
} }
} }
void void updatebars(void) {
updatebars(void)
{
Monitor *m; Monitor *m;
XSetWindowAttributes wa = { XSetWindowAttributes wa = {
.override_redirect = True, .override_redirect = True,
@@ -1415,9 +1278,7 @@ updatebars(void)
} }
} }
void void updatebarpos(Monitor *m) {
updatebarpos(Monitor *m)
{
m->wy = m->my; m->wy = m->my;
m->wh = m->mh; m->wh = m->mh;
if (m->showbar) { if (m->showbar) {
@@ -1428,9 +1289,7 @@ updatebarpos(Monitor *m)
m->by = -bh; m->by = -bh;
} }
void void updateclientlist(void) {
updateclientlist(void)
{
Client *c; Client *c;
Monitor *m; Monitor *m;
@@ -1442,9 +1301,7 @@ updateclientlist(void)
(unsigned char *) &(c->win), 1); (unsigned char *) &(c->win), 1);
} }
int int updategeom(void) {
updategeom(void)
{
int dirty = 0; int dirty = 0;
{ /* default monitor setup */ { /* default monitor setup */
@@ -1464,9 +1321,7 @@ updategeom(void)
return dirty; return dirty;
} }
void void updatenumlockmask(void) {
updatenumlockmask(void)
{
unsigned int i, j; unsigned int i, j;
XModifierKeymap *modmap; XModifierKeymap *modmap;
@@ -1480,9 +1335,7 @@ updatenumlockmask(void)
XFreeModifiermap(modmap); XFreeModifiermap(modmap);
} }
void void updatesizehints(Client *c) {
updatesizehints(Client *c)
{
long msize; long msize;
XSizeHints size; XSizeHints size;
@@ -1500,12 +1353,12 @@ updatesizehints(Client *c)
if (size.flags & PResizeInc) { if (size.flags & PResizeInc) {
c->incw = size.width_inc; c->incw = size.width_inc;
c->inch = size.height_inc; c->inch = size.height_inc;
} else } else {
c->incw = c->inch = 0; c->incw = c->inch = 0;
if (size.flags & PMaxSize) { if (size.flags & PMaxSize) {
c->maxw = size.max_width; c->maxw = size.max_width;
c->maxh = size.max_height; c->maxh = size.max_height;
} else } else {
c->maxw = c->maxh = 0; c->maxw = c->maxh = 0;
if (size.flags & PMinSize) { if (size.flags & PMinSize) {
c->minw = size.min_width; c->minw = size.min_width;
@@ -1513,37 +1366,35 @@ updatesizehints(Client *c)
} else if (size.flags & PBaseSize) { } else if (size.flags & PBaseSize) {
c->minw = size.base_width; c->minw = size.base_width;
c->minh = size.base_height; c->minh = size.base_height;
} else } else {
c->minw = c->minh = 0; c->minw = c->minh = 0;
if (size.flags & PAspect) { if (size.flags & PAspect) {
c->mina = (float)size.min_aspect.y / size.min_aspect.x; c->mina = (float)size.min_aspect.y / size.min_aspect.x;
c->maxa = (float)size.max_aspect.x / size.max_aspect.y; c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
} else } else {
c->maxa = c->mina = 0.0; c->maxa = c->mina = 0.0;
c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh); c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh);
c->hintsvalid = 1; c->hintsvalid = 1;
}
}
}
}
} }
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]);
@@ -1553,16 +1404,14 @@ 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))) {
if (c == selmon->sel && wmh->flags & XUrgencyHint) { if (c == selmon->sel && wmh->flags & XUrgencyHint) {
wmh->flags &= ~XUrgencyHint; wmh->flags &= ~XUrgencyHint;
XSetWMHints(dpy, c->win, wmh); XSetWMHints(dpy, c->win, wmh);
} else } else {
c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0; c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0;
if (wmh->flags & InputHint) if (wmh->flags & InputHint)
c->neverfocus = !wmh->input; c->neverfocus = !wmh->input;
@@ -1570,11 +1419,10 @@ updatewmhints(Client *c)
c->neverfocus = 0; c->neverfocus = 0;
XFree(wmh); XFree(wmh);
} }
}
} }
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 */
@@ -1584,9 +1432,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;
@@ -1597,9 +1443,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;
@@ -1617,9 +1461,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)
@@ -1635,15 +1477,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;
} }
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();