dwm/dwm.c

2146 lines
52 KiB
C
Raw Normal View History

/* See LICENSE file for copyright and license details.
*
* dynamic window manager is designed like any other X client as well. It is
* driven through handling X events. In contrast to other X clients, a window
* manager selects for SubstructureRedirectMask on the root window, to receive
* events about window (dis-)appearance. Only one X connection at a time is
* allowed to select for this event mask.
*
* The event handlers of dwm are organized in an array which is accessed
* whenever a new event has been fetched. This allows event dispatching
* in O(1) time.
*
* Each child of the root window is called a client, except windows which have
* set the override_redirect flag. Clients are organized in a linked client
* list on each monitor, the focus history is remembered through a stack list
* on each monitor. Each client contains a bit array to indicate the tags of a
* client.
*
* Keys and tagging rules are organized as arrays and defined in config.h.
*
* To understand everything else, start reading main().
*/
2007-09-15 23:25:27 +03:00
#include <errno.h>
#include <locale.h>
#include <signal.h>
2015-11-08 21:38:00 +02:00
#include <stdarg.h>
2007-09-15 23:25:27 +03:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
2007-09-27 10:14:32 +03:00
#include <sys/types.h>
2007-09-15 23:25:27 +03:00
#include <sys/wait.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
2007-10-17 12:19:14 +03:00
#include <X11/Xlib.h>
2007-09-15 23:25:27 +03:00
#include <X11/Xproto.h>
#include <X11/Xutil.h>
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
#include <X11/Xft/Xft.h>
2007-09-15 23:25:27 +03:00
2013-04-17 22:21:47 +03:00
#include "drw.h"
#include "util.h"
2012-11-17 20:01:22 +02:00
2007-09-15 23:25:27 +03:00
/* macros */
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
2011-06-27 22:12:42 +03:00
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
2011-11-06 21:31:29 +02:00
#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)))
2009-06-23 19:20:33 +03:00
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
2011-11-02 14:01:28 +02:00
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
2008-06-20 18:52:07 +03:00
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
typedef union {
int i;
2008-07-16 20:17:42 +03:00
unsigned int ui;
float f;
const void *v;
} Arg;
typedef struct {
2008-07-16 20:17:42 +03:00
unsigned int click;
unsigned int mask;
unsigned int button;
void (*func)(const Arg *arg);
const Arg arg;
} Button;
2009-06-22 16:58:08 +03:00
typedef struct Monitor Monitor;
typedef struct Client Client;
struct Client {
char name[256];
2008-06-15 12:52:57 +03:00
float mina, maxa;
int x, y, w, h;
int oldx, oldy, oldw, oldh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
2008-05-22 13:50:18 +03:00
int bw, oldbw;
2008-07-16 20:17:42 +03:00
unsigned int tags;
2015-11-08 23:48:43 +02:00
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
Client *next;
Client *snext;
Monitor *mon;
Window win;
};
typedef struct {
2008-07-16 20:17:42 +03:00
unsigned int mod;
KeySym keysym;
2008-06-11 11:12:06 +03:00
void (*func)(const Arg *);
const Arg arg;
} Key;
typedef struct {
2009-06-22 16:58:08 +03:00
const char *symbol;
void (*arrange)(Monitor *);
} Layout;
struct Monitor {
char ltsymbol[16];
float mfact;
2011-10-25 22:40:46 +03:00
int nmaster;
int num;
2009-07-09 13:29:01 +03:00
int by; /* bar geometry */
2009-06-30 22:15:31 +03:00
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
2015-11-08 23:48:43 +02:00
int showbar;
int topbar;
Client *clients;
Client *sel;
Client *stack;
2009-06-22 16:58:08 +03:00
Monitor *next;
Window barwin;
const Layout *lt[2];
2009-06-22 16:58:08 +03:00
};
typedef struct {
2008-03-14 16:35:45 +02:00
const char *class;
const char *instance;
const char *title;
2008-07-16 20:17:42 +03:00
unsigned int tags;
2015-11-08 23:48:43 +02:00
int isfloating;
int monitor;
} Rule;
2007-10-18 18:02:19 +03:00
/* function declarations */
2008-06-11 11:12:06 +03:00
static void applyrules(Client *c);
2015-11-08 23:48:43 +02:00
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
2008-06-11 11:12:06 +03:00
static void attach(Client *c);
static void attachstack(Client *c);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
static void cleanup(void);
static void cleanupmon(Monitor *mon);
static void clientmessage(XEvent *e);
2008-06-11 11:12:06 +03:00
static void configure(Client *c);
static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e);
static Monitor *createmon(void);
2008-06-11 11:12:06 +03:00
static void destroynotify(XEvent *e);
static void detach(Client *c);
static void detachstack(Client *c);
static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m);
static void drawbars(void);
2008-06-11 11:12:06 +03:00
static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
static void focusin(XEvent *e);
2009-07-01 21:15:20 +03:00
static void focusmon(const Arg *arg);
2008-06-11 11:12:06 +03:00
static void focusstack(const Arg *arg);
2015-11-08 23:48:43 +02:00
static int getrootptr(int *x, int *y);
2008-06-11 11:12:06 +03:00
static long getstate(Window w);
2015-11-08 23:48:43 +02:00
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, int focused);
2008-06-11 11:12:06 +03:00
static void grabkeys(void);
2011-10-25 22:40:46 +03:00
static void incnmaster(const Arg *arg);
2008-06-11 11:12:06 +03:00
static void keypress(XEvent *e);
static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
static void monocle(Monitor *m);
2011-11-15 21:16:58 +02:00
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
2009-06-23 19:20:33 +03:00
static Client *nexttiled(Client *c);
2011-04-15 11:13:06 +03:00
static void pop(Client *);
2008-06-11 11:12:06 +03:00
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
2011-11-06 21:31:29 +02:00
static Monitor *recttomon(int x, int y, int w, int h);
2015-11-08 23:48:43 +02:00
static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
static void restack(Monitor *m);
2008-06-11 11:12:06 +03:00
static void run(void);
static void scan(void);
2015-11-08 23:48:43 +02:00
static int sendevent(Client *c, Atom proto);
static void sendmon(Client *c, Monitor *m);
2008-06-11 11:12:06 +03:00
static void setclientstate(Client *c, long state);
static void setfocus(Client *c);
2015-11-08 23:48:43 +02:00
static void setfullscreen(Client *c, int fullscreen);
2008-06-19 13:38:53 +03:00
static void setlayout(const Arg *arg);
2008-06-11 11:12:06 +03:00
static void setmfact(const Arg *arg);
static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
2009-08-13 12:45:59 +03:00
static void sigchld(int unused);
2008-06-11 11:12:06 +03:00
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
2009-07-01 21:15:20 +03:00
static void tagmon(const Arg *arg);
static void tile(Monitor *);
2008-06-11 11:12:06 +03:00
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
2015-11-08 23:48:43 +02:00
static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed);
2008-06-11 11:12:06 +03:00
static void unmapnotify(XEvent *e);
2015-11-08 23:48:43 +02:00
static int updategeom(void);
static void updatebarpos(Monitor *m);
2009-06-22 16:58:08 +03:00
static void updatebars(void);
static void updateclientlist(void);
static void updatenumlockmask(void);
2008-06-11 11:12:06 +03:00
static void updatesizehints(Client *c);
static void updatestatus(void);
2011-11-02 14:01:28 +02:00
static void updatewindowtype(Client *c);
2008-06-11 11:12:06 +03:00
static void updatetitle(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
2009-06-30 21:39:59 +03:00
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
2008-06-11 11:12:06 +03:00
static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
/* variables */
2009-07-13 00:49:06 +03:00
static const char broken[] = "broken";
static char stext[256];
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */
static int lrpad; /* sum of left and right padding for text */
2008-06-11 11:12:06 +03:00
static int (*xerrorxlib)(Display *, XErrorEvent *);
2008-07-16 20:17:42 +03:00
static unsigned int numlockmask = 0;
2008-06-11 11:12:06 +03:00
static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
[ClientMessage] = clientmessage,
[ConfigureRequest] = configurerequest,
[ConfigureNotify] = configurenotify,
[DestroyNotify] = destroynotify,
[EnterNotify] = enternotify,
[Expose] = expose,
[FocusIn] = focusin,
[KeyPress] = keypress,
[MappingNotify] = mappingnotify,
[MapRequest] = maprequest,
2011-11-15 21:16:58 +02:00
[MotionNotify] = motionnotify,
[PropertyNotify] = propertynotify,
[UnmapNotify] = unmapnotify
};
2008-06-11 11:12:06 +03:00
static Atom wmatom[WMLast], netatom[NetLast];
2015-11-08 23:48:43 +02:00
static int running = 1;
2013-06-16 16:20:29 +03:00
static Cur *cursor[CurLast];
static Clr **scheme;
2008-06-11 11:12:06 +03:00
static Display *dpy;
2013-06-16 16:20:29 +03:00
static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
2009-07-02 22:56:23 +03:00
/* configuration, allows nested code to access above variables */
#include "config.h"
2008-07-16 20:17:42 +03:00
/* compile-time check if all tags fit into an unsigned int bit array. */
2009-07-14 18:01:14 +03:00
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
2007-10-18 18:02:19 +03:00
/* function implementations */
void
2015-11-09 00:11:48 +02:00
applyrules(Client *c)
{
2009-07-13 00:49:06 +03:00
const char *class, *instance;
2008-07-16 20:17:42 +03:00
unsigned int i;
const Rule *r;
Monitor *m;
XClassHint ch = { NULL, NULL };
2007-09-15 23:25:27 +03:00
2007-09-16 12:53:14 +03:00
/* rule matching */
2015-11-08 23:48:43 +02:00
c->isfloating = 0;
c->tags = 0;
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
2015-11-09 00:11:48 +02:00
for (i = 0; i < LENGTH(rules); i++) {
r = &rules[i];
2015-11-09 00:11:48 +02:00
if ((!r->title || strstr(c->name, r->title))
&& (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance)))
{
c->isfloating = r->isfloating;
c->tags |= r->tags;
2015-11-09 00:11:48 +02:00
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
2007-09-16 12:53:14 +03:00
}
2008-02-27 00:51:23 +02:00
}
2015-11-09 00:11:48 +02:00
if (ch.res_class)
XFree(ch.res_class);
2015-11-09 00:11:48 +02:00
if (ch.res_name)
XFree(ch.res_name);
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
2007-09-15 23:25:27 +03:00
}
2015-11-08 23:48:43 +02:00
int
2015-11-09 00:11:48 +02:00
applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
{
2015-11-08 23:48:43 +02:00
int baseismin;
2009-06-30 22:15:31 +03:00
Monitor *m = c->mon;
/* set minimum possible */
*w = MAX(1, *w);
*h = MAX(1, *h);
2015-11-09 00:11:48 +02:00
if (interact) {
if (*x > sw)
*x = sw - WIDTH(c);
2015-11-09 00:11:48 +02:00
if (*y > sh)
*y = sh - HEIGHT(c);
2015-11-09 00:11:48 +02:00
if (*x + *w + 2 * c->bw < 0)
*x = 0;
2015-11-09 00:11:48 +02:00
if (*y + *h + 2 * c->bw < 0)
*y = 0;
2015-11-09 00:11:48 +02:00
} else {
if (*x >= m->wx + m->ww)
2011-11-04 21:02:35 +02:00
*x = m->wx + m->ww - WIDTH(c);
2015-11-09 00:11:48 +02:00
if (*y >= m->wy + m->wh)
2011-11-04 21:02:35 +02:00
*y = m->wy + m->wh - HEIGHT(c);
2015-11-09 00:11:48 +02:00
if (*x + *w + 2 * c->bw <= m->wx)
2011-11-04 21:02:35 +02:00
*x = m->wx;
2015-11-09 00:11:48 +02:00
if (*y + *h + 2 * c->bw <= m->wy)
2011-11-04 21:02:35 +02:00
*y = m->wy;
}
2015-11-09 00:11:48 +02:00
if (*h < bh)
*h = bh;
2015-11-09 00:11:48 +02:00
if (*w < bh)
*w = bh;
2015-11-09 00:11:48 +02:00
if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
/* see last two sentences in ICCCM 4.1.2.3 */
baseismin = c->basew == c->minw && c->baseh == c->minh;
2015-11-09 00:11:48 +02:00
if (!baseismin) { /* temporarily remove base dimensions */
*w -= c->basew;
*h -= c->baseh;
}
/* adjust for aspect limits */
2015-11-09 00:11:48 +02:00
if (c->mina > 0 && c->maxa > 0) {
if (c->maxa < (float)*w / *h)
2009-07-17 17:28:07 +03:00
*w = *h * c->maxa + 0.5;
2015-11-09 00:11:48 +02:00
else if (c->mina < (float)*h / *w)
2009-07-17 17:28:07 +03:00
*h = *w * c->mina + 0.5;
}
2015-11-09 00:11:48 +02:00
if (baseismin) { /* increment calculation requires this */
*w -= c->basew;
*h -= c->baseh;
}
/* adjust for increment value */
2015-11-09 00:11:48 +02:00
if (c->incw)
*w -= *w % c->incw;
2015-11-09 00:11:48 +02:00
if (c->inch)
*h -= *h % c->inch;
/* restore base dimensions */
*w = MAX(*w + c->basew, c->minw);
*h = MAX(*h + c->baseh, c->minh);
2015-11-09 00:11:48 +02:00
if (c->maxw)
*w = MIN(*w, c->maxw);
2015-11-09 00:11:48 +02:00
if (c->maxh)
*h = MIN(*h, c->maxh);
}
return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
}
void
2015-11-09 00:11:48 +02:00
arrange(Monitor *m)
{
if (m)
showhide(m->stack);
2015-11-09 00:11:48 +02:00
else for (m = mons; m; m = m->next)
showhide(m->stack);
2015-11-09 00:11:48 +02:00
if (m) {
arrangemon(m);
restack(m);
2015-11-09 00:11:48 +02:00
} else for (m = mons; m; m = m->next)
arrangemon(m);
}
void
2015-11-09 00:11:48 +02:00
arrangemon(Monitor *m)
{
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
2015-11-09 00:11:48 +02:00
if (m->lt[m->sellt]->arrange)
m->lt[m->sellt]->arrange(m);
2007-09-15 23:25:27 +03:00
}
void
2015-11-09 00:11:48 +02:00
attach(Client *c)
{
c->next = c->mon->clients;
c->mon->clients = c;
2007-09-15 23:25:27 +03:00
}
void
2015-11-09 00:11:48 +02:00
attachstack(Client *c)
{
c->snext = c->mon->stack;
c->mon->stack = c;
2007-09-15 23:25:27 +03:00
}
void
2015-11-09 00:11:48 +02:00
buttonpress(XEvent *e)
{
2008-07-16 20:17:42 +03:00
unsigned int i, x, click;
2008-06-20 18:52:07 +03:00
Arg arg = {0};
2007-09-16 12:53:14 +03:00
Client *c;
Monitor *m;
2007-09-16 12:53:14 +03:00
XButtonPressedEvent *ev = &e->xbutton;
2007-09-15 23:25:27 +03:00
2008-06-15 12:52:57 +03:00
click = ClkRootWin;
/* focus monitor if necessary */
2015-11-09 00:11:48 +02:00
if ((m = wintomon(ev->window)) && m != selmon) {
2015-11-08 23:48:43 +02:00
unfocus(selmon->sel, 1);
selmon = m;
focus(NULL);
}
2015-11-09 00:11:48 +02:00
if (ev->window == selmon->barwin) {
2009-07-09 13:29:01 +03:00
i = x = 0;
2011-07-27 20:59:10 +03:00
do
x += TEXTW(tags[i]);
2015-11-09 00:11:48 +02:00
while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
2008-06-20 18:52:07 +03:00
click = ClkTagBar;
arg.ui = 1 << i;
2015-11-09 00:11:48 +02:00
} else if (ev->x < x + blw)
click = ClkLtSymbol;
2015-11-09 00:11:48 +02:00
else if (ev->x > selmon->ww - TEXTW(stext))
click = ClkStatusText;
else
click = ClkWinTitle;
2015-11-09 00:11:48 +02:00
} else if ((c = wintoclient(ev->window))) {
2008-06-15 12:52:57 +03:00
focus(c);
restack(selmon);
XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin;
2008-06-15 12:52:57 +03:00
}
2015-11-09 00:11:48 +02:00
for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
2009-07-14 18:26:04 +03:00
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
2008-09-02 00:18:50 +03:00
buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
2007-09-15 23:25:27 +03:00
}
void
2015-11-09 00:11:48 +02:00
checkotherwm(void)
{
xerrorxlib = XSetErrorHandler(xerrorstart);
2007-09-16 13:34:08 +03:00
/* this causes an error if some other window manager is running */
XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
2007-09-16 13:34:08 +03:00
XSync(dpy, False);
XSetErrorHandler(xerror);
2007-09-16 13:34:08 +03:00
XSync(dpy, False);
}
void
2015-11-09 00:11:48 +02:00
cleanup(void)
{
2008-08-12 22:24:40 +03:00
Arg a = {.ui = ~0};
Layout foo = { "", NULL };
Monitor *m;
size_t i;
2008-06-11 11:12:06 +03:00
view(&a);
selmon->lt[selmon->sellt] = &foo;
2015-11-09 00:11:48 +02:00
for (m = mons; m; m = m->next)
while (m->stack)
2015-11-08 23:48:43 +02:00
unmanage(m->stack, 0);
2008-02-18 19:08:22 +02:00
XUngrabKey(dpy, AnyKey, AnyModifier, root);
2015-11-09 00:11:48 +02:00
while (mons)
cleanupmon(mons);
2015-11-09 00:11:48 +02:00
for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colors); i++)
free(scheme[i]);
XDestroyWindow(dpy, wmcheckwin);
2013-06-16 16:20:29 +03:00
drw_free(drw);
2008-02-18 19:08:22 +02:00
XSync(dpy, False);
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
2007-09-15 23:25:27 +03:00
}
2009-06-22 16:58:08 +03:00
void
2015-11-09 00:11:48 +02:00
cleanupmon(Monitor *mon)
{
2009-06-22 16:58:08 +03:00
Monitor *m;
2015-11-09 00:11:48 +02:00
if (mon == mons)
mons = mons->next;
else {
2015-11-09 00:11:48 +02:00
for (m = mons; m && m->next != mon; m = m->next);
m->next = mon->next;
2009-06-22 16:58:08 +03:00
}
XUnmapWindow(dpy, mon->barwin);
XDestroyWindow(dpy, mon->barwin);
free(mon);
2009-06-22 16:58:08 +03:00
}
void
2015-11-09 00:11:48 +02:00
clientmessage(XEvent *e)
{
XClientMessageEvent *cme = &e->xclient;
Client *c = wintoclient(cme->window);
2015-11-09 00:11:48 +02:00
if (!c)
return;
2015-11-09 00:11:48 +02:00
if (cme->message_type == netatom[NetWMState]) {
if (cme->data.l[1] == netatom[NetWMFullscreen]
|| cme->data.l[2] == netatom[NetWMFullscreen])
2011-11-06 21:30:06 +02:00
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
2015-11-09 00:11:48 +02:00
} else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent)
seturgent(c, 1);
}
}
void
2015-11-09 00:11:48 +02:00
configure(Client *c)
{
2007-09-16 12:53:14 +03:00
XConfigureEvent ce;
2007-09-15 23:25:27 +03:00
2007-09-16 12:53:14 +03:00
ce.type = ConfigureNotify;
ce.display = dpy;
ce.event = c->win;
ce.window = c->win;
ce.x = c->x;
ce.y = c->y;
ce.width = c->w;
ce.height = c->h;
ce.border_width = c->bw;
2007-09-16 12:53:14 +03:00
ce.above = None;
ce.override_redirect = False;
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
}
void
2015-11-09 00:11:48 +02:00
configurenotify(XEvent *e)
{
2009-06-22 16:58:08 +03:00
Monitor *m;