event.c
author Anselm R.Garbe <arg@10ksloc.org>
Tue, 08 Aug 2006 18:12:18 +0200
changeset 230 b92bbc2487c9
parent 229 f4f5d000ce7a
child 231 f7e87c894b5e
permissions -rw-r--r--
removed NET_ACTIVE_WINDOW handling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     1
/*
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     2
 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     3
 * See LICENSE file for license details.
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     4
 */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
     5
#include "dwm.h"
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     6
#include <stdlib.h>
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     7
#include <X11/keysym.h>
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
     8
#include <X11/Xatom.h>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     9
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
    10
/* static */
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    11
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    12
typedef struct {
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    13
	unsigned long mod;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    14
	KeySym keysym;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    15
	void (*func)(Arg *arg);
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    16
	Arg arg;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    17
} Key;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    18
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
    19
KEYS
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
    20
160
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
    21
#define CLEANMASK(mask) (mask & ~(NUMLOCKMASK | LockMask))
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
    22
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    23
static void
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    24
movemouse(Client *c)
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    25
{
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    26
	int x1, y1, ocx, ocy, di;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    27
	unsigned int dui;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    28
	Window dummy;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    29
	XEvent ev;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    30
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    31
	ocx = c->x;
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    32
	ocy = c->y;
148
5267e1204367 uppercasing all define'd values (uppercase-prefixed should only be enum field qualifiers)
arg@10ksloc.org
parents: 146
diff changeset
    33
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    34
			None, cursor[CurMove], CurrentTime) != GrabSuccess)
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    35
		return;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    36
	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    37
	for(;;) {
148
5267e1204367 uppercasing all define'd values (uppercase-prefixed should only be enum field qualifiers)
arg@10ksloc.org
parents: 146
diff changeset
    38
		XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    39
		switch (ev.type) {
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    40
		default: break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    41
		case Expose:
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    42
			handler[Expose](&ev);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    43
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    44
		case MotionNotify:
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
    45
			XSync(dpy, False);
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    46
			c->x = ocx + (ev.xmotion.x - x1);
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    47
			c->y = ocy + (ev.xmotion.y - y1);
99
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
    48
			resize(c, False, TopLeft);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    49
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    50
		case ButtonRelease:
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    51
			XUngrabPointer(dpy, CurrentTime);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    52
			return;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    53
		}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    54
	}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    55
}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    56
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    57
static void
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    58
resizemouse(Client *c)
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    59
{
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    60
	int ocx, ocy;
99
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
    61
	Corner sticky;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    62
	XEvent ev;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    63
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    64
	ocx = c->x;
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    65
	ocy = c->y;
148
5267e1204367 uppercasing all define'd values (uppercase-prefixed should only be enum field qualifiers)
arg@10ksloc.org
parents: 146
diff changeset
    66
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    67
				None, cursor[CurResize], CurrentTime) != GrabSuccess)
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    68
		return;
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    69
	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    70
	for(;;) {
148
5267e1204367 uppercasing all define'd values (uppercase-prefixed should only be enum field qualifiers)
arg@10ksloc.org
parents: 146
diff changeset
    71
		XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    72
		switch(ev.type) {
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    73
		default: break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    74
		case Expose:
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    75
			handler[Expose](&ev);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    76
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    77
		case MotionNotify:
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
    78
			XSync(dpy, False);
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    79
			c->w = abs(ocx - ev.xmotion.x);
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    80
			c->h = abs(ocy - ev.xmotion.y);
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    81
			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
    82
			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
105
3e74cc981e9b refactored Sanders code somewhat
arg@10ksloc.org
parents: 99
diff changeset
    83
			if(ocx <= ev.xmotion.x)
3e74cc981e9b refactored Sanders code somewhat
arg@10ksloc.org
parents: 99
diff changeset
    84
				sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
3e74cc981e9b refactored Sanders code somewhat
arg@10ksloc.org
parents: 99
diff changeset
    85
			else
3e74cc981e9b refactored Sanders code somewhat
arg@10ksloc.org
parents: 99
diff changeset
    86
				sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
99
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
    87
			resize(c, True, sticky);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    88
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    89
		case ButtonRelease:
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    90
			XUngrabPointer(dpy, CurrentTime);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    91
			return;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    92
		}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    93
	}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    94
}
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
    95
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
    96
static void
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
    97
buttonpress(XEvent *e)
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
    98
{
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
    99
	int x;
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   100
	Arg a;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   101
	Client *c;
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   102
	XButtonPressedEvent *ev = &e->xbutton;
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   103
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   104
	if(barwin == ev->window) {
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   105
		switch(ev->button) {
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   106
		default:
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   107
			x = 0;
178
e848966a1ac6 removed TLast tag enum, now tags is simple defined as char *[] array, the rest is calculated correctly, rules take an int array for the tags
arg@10ksloc.org
parents: 164
diff changeset
   108
			for(a.i = 0; a.i < ntags; a.i++) {
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   109
				x += textw(tags[a.i]);
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   110
				if(ev->x < x) {
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   111
					view(&a);
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   112
					break;
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   113
				}
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   114
			}
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   115
			break;
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   116
		case Button4:
149
332fcc6d4f88 saved 2LOC
arg@10ksloc.org
parents: 148
diff changeset
   117
			viewnext(&a);
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   118
			break;
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   119
		case Button5:
149
332fcc6d4f88 saved 2LOC
arg@10ksloc.org
parents: 148
diff changeset
   120
			viewprev(&a);
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   121
			break;
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   122
		}
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   123
	}
58
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 55
diff changeset
   124
	else if((c = getclient(ev->window))) {
143
36cabfe408cd applied Sanders patches
arg@10ksloc.org
parents: 139
diff changeset
   125
		focus(c);
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   126
		switch(ev->button) {
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   127
		default:
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   128
			break;
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   129
		case Button1:
133
467ad2d3a6fa applied sanders maxfix patch
arg@10ksloc.org
parents: 130
diff changeset
   130
			if(!c->ismax && (arrange == dofloat || c->isfloat)) {
99
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
   131
				higher(c);
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
   132
				movemouse(c);
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
   133
			}
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   134
			break;
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   135
		case Button2:
26
e8f627998d6f simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents: 25
diff changeset
   136
			lower(c);
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   137
			break;
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   138
		case Button3:
133
467ad2d3a6fa applied sanders maxfix patch
arg@10ksloc.org
parents: 130
diff changeset
   139
			if(!c->ismax && (arrange == dofloat || c->isfloat)) {
99
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
   140
				higher(c);
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
   141
				resizemouse(c);
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
   142
			}
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   143
			break;
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   144
		}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   145
	}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   146
}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   147
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   148
static void
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   149
configurerequest(XEvent *e)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   150
{
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   151
	Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   152
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   153
	XEvent synev;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   154
	XWindowChanges wc;
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   155
	unsigned long newmask;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   156
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   157
	if((c = getclient(ev->window))) {
29
8ad86d0a6a53 added gravity stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
   158
		gravitate(c, True);
195
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   159
		if(ev->value_mask & CWX)
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   160
			c->x = ev->x;
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   161
		if(ev->value_mask & CWY)
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   162
			c->y = ev->y;
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   163
		if(ev->value_mask & CWWidth)
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   164
			c->w = ev->width;
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   165
		if(ev->value_mask & CWHeight)
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   166
			c->h = ev->height;
29
8ad86d0a6a53 added gravity stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
   167
		if(ev->value_mask & CWBorderWidth)
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   168
			c->border = ev->border_width;
29
8ad86d0a6a53 added gravity stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
   169
		gravitate(c, False);
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   170
		wc.x = c->x;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   171
		wc.y = c->y;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   172
		wc.width = c->w;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   173
		wc.height = c->h;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   174
		newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   175
		if(newmask)
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   176
			XConfigureWindow(dpy, c->win, newmask, &wc);
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   177
		else {
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   178
			synev.type = ConfigureNotify;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   179
			synev.xconfigure.display = dpy;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   180
			synev.xconfigure.event = c->win;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   181
			synev.xconfigure.window = c->win;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   182
			synev.xconfigure.x = c->x;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   183
			synev.xconfigure.y = c->y;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   184
			synev.xconfigure.width = c->w;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   185
			synev.xconfigure.height = c->h;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   186
			synev.xconfigure.border_width = c->border;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   187
			synev.xconfigure.above = None;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   188
			/* Send synthetic ConfigureNotify */
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   189
			XSendEvent(dpy, c->win, True, NoEventMask, &synev);
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   190
		}
195
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   191
		XSync(dpy, False);
196
d560e796f7fe small performance tweak ;)
arg@10ksloc.org
parents: 195
diff changeset
   192
		if(c->isfloat)
d560e796f7fe small performance tweak ;)
arg@10ksloc.org
parents: 195
diff changeset
   193
			resize(c, False, TopLeft);
d560e796f7fe small performance tweak ;)
arg@10ksloc.org
parents: 195
diff changeset
   194
		else
d560e796f7fe small performance tweak ;)
arg@10ksloc.org
parents: 195
diff changeset
   195
			arrange(NULL);
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   196
	}
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   197
	else {
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   198
		wc.x = ev->x;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   199
		wc.y = ev->y;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   200
		wc.width = ev->width;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   201
		wc.height = ev->height;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   202
		wc.border_width = ev->border_width;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   203
		wc.sibling = ev->above;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   204
		wc.stack_mode = ev->detail;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   205
		XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
195
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
   206
		XSync(dpy, False);
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
   207
	}
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   208
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   209
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   210
static void
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   211
destroynotify(XEvent *e)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   212
{
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   213
	Client *c;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   214
	XDestroyWindowEvent *ev = &e->xdestroywindow;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   215
11
ea9c08ec4b48 added gridsel to gridwm
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   216
	if((c = getclient(ev->window)))
ea9c08ec4b48 added gridsel to gridwm
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   217
		unmanage(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   218
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   219
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   220
static void
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   221
enternotify(XEvent *e)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   222
{
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   223
	Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   224
	XCrossingEvent *ev = &e->xcrossing;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   225
143
36cabfe408cd applied Sanders patches
arg@10ksloc.org
parents: 139
diff changeset
   226
	if(ev->detail == NotifyInferior)
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   227
		return;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   228
161
f381e34158d9 implemented focus on enterwindow on titlebars
arg@10ksloc.org
parents: 160
diff changeset
   229
	if((c = getclient(ev->window)) || (c = getctitle(ev->window)))
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   230
		focus(c);
26
e8f627998d6f simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents: 25
diff changeset
   231
	else if(ev->window == root)
31
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 30
diff changeset
   232
		issel = True;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   233
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   234
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   235
static void
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   236
expose(XEvent *e)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   237
{
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   238
	Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   239
	XExposeEvent *ev = &e->xexpose;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   240
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   241
	if(ev->count == 0) {
70
e5fff8249705 draw bar on exposure ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 63
diff changeset
   242
		if(barwin == ev->window)
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
   243
			drawstatus();
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
   244
		else if((c = getctitle(ev->window)))
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
   245
			drawtitle(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   246
	}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   247
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   248
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   249
static void
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   250
keypress(XEvent *e)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   251
{
138
c1185dc7a36e some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents: 137
diff changeset
   252
	static unsigned int len = sizeof(key) / sizeof(key[0]);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   253
	unsigned int i;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   254
	KeySym keysym;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   255
	XKeyEvent *ev = &e->xkey;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   256
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   257
	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   258
	for(i = 0; i < len; i++)
160
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
   259
		if(keysym == key[i].keysym &&
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
   260
				CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   261
			if(key[i].func)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   262
				key[i].func(&key[i].arg);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   263
			return;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   264
		}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   265
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   266
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   267
static void
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   268
leavenotify(XEvent *e)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   269
{
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   270
	XCrossingEvent *ev = &e->xcrossing;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   271
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   272
	if((ev->window == root) && !ev->same_screen)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   273
		issel = True;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   274
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   275
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   276
static void
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   277
maprequest(XEvent *e)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   278
{
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   279
	static XWindowAttributes wa;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   280
	XMapRequestEvent *ev = &e->xmaprequest;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   281
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   282
	if(!XGetWindowAttributes(dpy, ev->window, &wa))
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   283
		return;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   284
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   285
	if(wa.override_redirect) {
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   286
		XSelectInput(dpy, ev->window,
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   287
				(StructureNotifyMask | PropertyChangeMask));
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   288
		return;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   289
	}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   290
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   291
	if(!getclient(ev->window))
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   292
		manage(ev->window, &wa);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   293
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   294
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   295
static void
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   296
propertynotify(XEvent *e)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   297
{
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   298
	Client *c;
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
   299
	Window trans;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   300
	XPropertyEvent *ev = &e->xproperty;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   301
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   302
	if(ev->state == PropertyDelete)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   303
		return; /* ignore */
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   304
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   305
	if((c = getclient(ev->window))) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   306
		if(ev->atom == wmatom[WMProtocols]) {
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
   307
			c->proto = getproto(c->win);
30
2e0fb4130bfb new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
   308
			return;
2e0fb4130bfb new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
   309
		}
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   310
		switch (ev->atom) {
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   311
			default: break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   312
			case XA_WM_TRANSIENT_FOR:
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
   313
				XGetTransientForHint(dpy, c->win, &trans);
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   314
				if(!c->isfloat && (c->isfloat = (trans != 0)))
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
   315
					arrange(NULL);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   316
				break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   317
			case XA_WM_NORMAL_HINTS:
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
   318
				setsize(c);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   319
				break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   320
		}
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   321
		if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
   322
			settitle(c);
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
   323
			drawtitle(c);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   324
		}
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   325
	}
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   326
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   327
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   328
static void
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   329
unmapnotify(XEvent *e)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   330
{
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   331
	Client *c;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   332
	XUnmapEvent *ev = &e->xunmap;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   333
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   334
	if((c = getclient(ev->window)))
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   335
		unmanage(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   336
}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   337
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 80
diff changeset
   338
/* extern */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   339
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   340
void (*handler[LASTEvent]) (XEvent *) = {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   341
	[ButtonPress] = buttonpress,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   342
	[ConfigureRequest] = configurerequest,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   343
	[DestroyNotify] = destroynotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   344
	[EnterNotify] = enternotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   345
	[LeaveNotify] = leavenotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   346
	[Expose] = expose,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   347
	[KeyPress] = keypress,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   348
	[MapRequest] = maprequest,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   349
	[PropertyNotify] = propertynotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   350
	[UnmapNotify] = unmapnotify
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   351
};
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   352
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   353
void
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   354
grabkeys()
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   355
{
138
c1185dc7a36e some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents: 137
diff changeset
   356
	static unsigned int len = sizeof(key) / sizeof(key[0]);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   357
	unsigned int i;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   358
	KeyCode code;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   359
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   360
	for(i = 0; i < len; i++) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   361
		code = XKeysymToKeycode(dpy, key[i].keysym);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   362
		XGrabKey(dpy, code, key[i].mod, root, True,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   363
				GrabModeAsync, GrabModeAsync);
160
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
   364
		XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
   365
				GrabModeAsync, GrabModeAsync);
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
   366
		XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root, True,
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
   367
				GrabModeAsync, GrabModeAsync);
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
   368
		XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root, True,
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
   369
				GrabModeAsync, GrabModeAsync);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   370
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   371
}