aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2012-09-14 04:22:05 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2012-09-20 13:03:11 +0300
commit69f34fc03d44daa5feeae5b853192a9526d3f7ee (patch)
treeb2c0dc03ec21f79f4be75d2b43ea564204ac4c23
parente80860e74a22d41698cc6c9db90a900222da54a5 (diff)
squash Desktop/Client declarations
-rw-r--r--monsterwm.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/monsterwm.c b/monsterwm.c
index 2f00afc..26dd19a 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -234,11 +234,10 @@ Client* addwindow(Window w, Desktop *d) {
* call the appropriate handler
*/
void buttonpress(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
+ Bool w = wintoclient(e->xbutton.window, &c, &d);
- if (wintoclient(e->xbutton.window, &c, &d) && CLICK_TO_FOCUS &&
- c != d->curr && e->xbutton.button == FOCUS_BUTTON) focus(c, d);
+ if (w && CLICK_TO_FOCUS && c != d->curr && e->xbutton.button == FOCUS_BUTTON) focus(c, d);
for (unsigned int i = 0; i < LENGTH(buttons); i++)
if (CLEANMASK(buttons[i].mask) == CLEANMASK(e->xbutton.state) &&
@@ -327,9 +326,7 @@ void client_to_desktop(const Arg *arg) {
* on its desktop.
*/
void clientmessage(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
-
+ Desktop *d = NULL; Client *c = NULL;
if (!wintoclient(e->xclient.window, &c, &d)) return;
if (e->xclient.message_type == netatoms[NET_WM_STATE] && (
@@ -423,8 +420,7 @@ void desktopinfo(void) {
* on receival, remove the client that held that window
*/
void destroynotify(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
if (wintoclient(e->xdestroywindow.window, &c, &d)) removeclient(c, d);
}
@@ -435,8 +431,7 @@ void destroynotify(XEvent *e) {
* and will get focus if FOLLOW_MOUSE is set in the config.
*/
void enternotify(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
if (FOLLOW_MOUSE && wintoclient(e->xcrossing.window, &c, &d) && e->xcrossing.mode == NotifyNormal
&& e->xcrossing.detail != NotifyInferior && e->xcrossing.window != d->curr->win) focus(c, d);
@@ -551,9 +546,7 @@ void focus(Client *c, Desktop *d) {
* client, by the user, through the wm.
*/
void focusin(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
-
+ Desktop *d = NULL; Client *c = NULL;
if (wintoclient(e->xfocus.window, &c, &d) && d->curr &&
e->xfocus.window != d->curr->win) focus(d->curr, d);
}
@@ -665,16 +658,15 @@ void killclient(void) {
* then display/map the window, else, if follow is set, focus the new desktop.
*/
void maprequest(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
Window w = e->xmaprequest.window;
XWindowAttributes wa = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ if (wintoclient(w, &c, &d) || (XGetWindowAttributes(dis, w, &wa) && wa.override_redirect)) return;
+
XClassHint ch = {0, 0};
Bool follow = False, floating = False;
int newdsk = currdeskidx;
- if (wintoclient(w, &c, &d) || (XGetWindowAttributes(dis, w, &wa) && wa.override_redirect)) return;
-
if (XGetClassHint(dis, w, &ch)) for (unsigned int i = 0; i < LENGTH(rules); i++)
if (strstr(ch.res_class, rules[i].class) || strstr(ch.res_name, rules[i].class)) {
if (rules[i].desktop >= 0 && rules[i].desktop < DESKTOPS) newdsk = rules[i].desktop;
@@ -880,11 +872,12 @@ void prev_win(void) {
* set unrgent hint for a window
*/
void propertynotify(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
if (e->xproperty.atom != XA_WM_HINTS || !wintoclient(e->xproperty.window, &c, &d)) return;
+
XWMHints *wmh = XGetWMHints(dis, c->win);
c->isurgn = (c != desktops[currdeskidx].curr && wmh && (wmh->flags & XUrgencyHint));
+
if (wmh) XFree(wmh);
desktopinfo();
}
@@ -1092,8 +1085,7 @@ void tile(Desktop *d) {
* client, so invisible windows do not exist on screen
*/
void unmapnotify(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
if (e->xunmap.send_event && wintoclient(e->xunmap.window, &c, &d)) removeclient(c, d);
}