event.c
author Anselm R. Garbe <garbeam@gmail.com>
Sat, 15 Sep 2007 12:36:42 +0200
changeset 987 ea0cef59c3a3
parent 971 b2a0dfa22b1d
permissions -rw-r--r--
renamed drawstatus into drawbar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
910
c13cb8c6b7a5 referred to LICENSE file
Anselm R. Garbe <arg@suckless.org>
parents: 909
diff changeset
     1
/* See LICENSE file for copyright and license details. */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
     2
#include "dwm.h"
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     3
#include <stdlib.h>
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     4
#include <X11/keysym.h>
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
     5
#include <X11/Xatom.h>
953
Anselm R. Garbe <garbeam@gmail.com>
parents: 946
diff changeset
     6
#include <X11/Xutil.h>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     7
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
     8
/* static */
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
     9
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    10
typedef struct {
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    11
	unsigned long mod;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    12
	KeySym keysym;
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 821
diff changeset
    13
	void (*func)(const char *arg);
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 821
diff changeset
    14
	const char *arg;
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    15
} Key;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    16
926
6f9cf0cfe278 removed shiftview(), if you scroll the views in the tag area, you can also use Button1 instead
Anselm R. Garbe <garbeam@gmail.com>
parents: 925
diff changeset
    17
#define CLEANMASK(mask)		(mask & ~(numlockmask | LockMask))
538
00ccae001069 moved MOUSEMASK into event.c (not used in other places)
Anselm R. Garbe <arg@10kloc.org>
parents: 533
diff changeset
    18
#define MOUSEMASK		(BUTTONMASK | PointerMotionMask)
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
    19
777
469dc170f833 draw.c is useless (belongs to main.c now)
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
    20
static Client *
469dc170f833 draw.c is useless (belongs to main.c now)
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
    21
getclient(Window w) {
469dc170f833 draw.c is useless (belongs to main.c now)
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
    22
	Client *c;
469dc170f833 draw.c is useless (belongs to main.c now)
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
    23
469dc170f833 draw.c is useless (belongs to main.c now)
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
    24
	for(c = clients; c && c->win != w; c = c->next);
469dc170f833 draw.c is useless (belongs to main.c now)
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
    25
	return c;
469dc170f833 draw.c is useless (belongs to main.c now)
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
    26
}
469dc170f833 draw.c is useless (belongs to main.c now)
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
    27
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    28
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
    29
movemouse(Client *c) {
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    30
	int x1, y1, ocx, ocy, di, nx, ny;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    31
	unsigned int dui;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    32
	Window dummy;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    33
	XEvent ev;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    34
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    35
	ocx = nx = c->x;
764
759a5fbbd8b7 removed useless space
Anselm R. Garbe <arg@suckless.org>
parents: 762
diff changeset
    36
	ocy = ny = c->y;
148
5267e1204367 uppercasing all define'd values (uppercase-prefixed should only be enum field qualifiers)
arg@10ksloc.org
parents: 146
diff changeset
    37
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    38
			None, cursor[CurMove], CurrentTime) != GrabSuccess)
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    39
		return;
482
acb1fc729a8c ismax toggling on mouse based action
arg@mmvi
parents: 478
diff changeset
    40
	c->ismax = False;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    41
	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    42
	for(;;) {
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    43
		XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    44
		switch (ev.type) {
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    45
		case ButtonRelease:
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    46
			XUngrabPointer(dpy, CurrentTime);
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    47
			return;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    48
		case ConfigureRequest:
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    49
		case Expose:
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    50
		case MapRequest:
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    51
			handler[ev.type](&ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    52
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    53
		case MotionNotify:
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
    54
			XSync(dpy, False);
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    55
			nx = ocx + (ev.xmotion.x - x1);
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    56
			ny = ocy + (ev.xmotion.y - y1);
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    57
			if(abs(wax + nx) < SNAP)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    58
				nx = wax;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    59
			else if(abs((wax + waw) - (nx + c->w + 2 * c->border)) < SNAP)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    60
				nx = wax + waw - c->w - 2 * c->border;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    61
			if(abs(way - ny) < SNAP)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    62
				ny = way;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    63
			else if(abs((way + wah) - (ny + c->h + 2 * c->border)) < SNAP)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    64
				ny = way + wah - c->h - 2 * c->border;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
    65
			resize(c, nx, ny, c->w, c->h, False);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    66
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    67
		}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    68
	}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    69
}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    70
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    71
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
    72
resizemouse(Client *c) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    73
	int ocx, ocy;
268
a47b3b0d7bf4 applied Sanders LD and resize patches
Anselm R.Garbe <arg@10ksloc.org>
parents: 267
diff changeset
    74
	int nw, nh;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    75
	XEvent ev;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    76
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
    77
	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
    78
	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
    79
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
    80
			None, cursor[CurResize], CurrentTime) != GrabSuccess)
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    81
		return;
482
acb1fc729a8c ismax toggling on mouse based action
arg@mmvi
parents: 478
diff changeset
    82
	c->ismax = False;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    83
	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    84
	for(;;) {
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    85
		XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    86
		switch(ev.type) {
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    87
		case ButtonRelease:
745
cf432071e646 added pointer warp on drop in resize
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
    88
			XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
cf432071e646 added pointer warp on drop in resize
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
    89
					c->w + c->border - 1, c->h + c->border - 1);
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    90
			XUngrabPointer(dpy, CurrentTime);
746
54e12eb664fc removing all EnterNotifys after resize
Anselm R. Garbe <arg@suckless.org>
parents: 745
diff changeset
    91
			while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    92
			return;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    93
		case ConfigureRequest:
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    94
		case Expose:
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    95
		case MapRequest:
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    96
			handler[ev.type](&ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    97
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    98
		case MotionNotify:
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
    99
			XSync(dpy, False);
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   100
			if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   101
				nw = 1;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   102
			if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   103
				nh = 1;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   104
			resize(c, c->x, c->y, nw, nh, True);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   105
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   106
		}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   107
	}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   108
}
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   109
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   110
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   111
buttonpress(XEvent *e) {
825
bef1854ce739 fixed some issues due to the Arg->const char * transition
Anselm R. Garbe <arg@suckless.org>
parents: 823
diff changeset
   112
	unsigned int i, x;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   113
	Client *c;
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   114
	XButtonPressedEvent *ev = &e->xbutton;
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   115
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   116
	if(barwin == ev->window) {
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
   117
		x = 0;
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 821
diff changeset
   118
		for(i = 0; i < ntags; i++) {
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 821
diff changeset
   119
			x += textw(tags[i]);
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
   120
			if(ev->x < x) {
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   121
				if(ev->button == Button1) {
398
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   122
					if(ev->state & MODKEY)
956
484245788760 made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   123
						tag(tags[i]);
398
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   124
					else
956
484245788760 made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   125
						view(tags[i]);
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   126
				}
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   127
				else if(ev->button == Button3) {
398
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   128
					if(ev->state & MODKEY)
956
484245788760 made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   129
						toggletag(tags[i]);
398
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   130
					else
956
484245788760 made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   131
						toggleview(tags[i]);
394
1da9a6b94ca9 implemented Button2 press on tags for toggletag on the focused client
Anselm R. Garbe <arg@10kloc.org>
parents: 387
diff changeset
   132
				}
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
   133
				return;
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   134
			}
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   135
		}
926
6f9cf0cfe278 removed shiftview(), if you scroll the views in the tag area, you can also use Button1 instead
Anselm R. Garbe <garbeam@gmail.com>
parents: 925
diff changeset
   136
		if((ev->x < x + blw) && ev->button == Button1)
925
10df275327ce applied Jeroen's {clean,spell}.diff patches, thanks Jeroen!
Anselm R. Garbe <garbeam@gmail.com>
parents: 924
diff changeset
   137
			setlayout(NULL);
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   138
	}
58
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 55
diff changeset
   139
	else if((c = getclient(ev->window))) {
143
36cabfe408cd applied Sanders patches
arg@10ksloc.org
parents: 139
diff changeset
   140
		focus(c);
473
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 466
diff changeset
   141
		if(CLEANMASK(ev->state) != MODKEY)
318
1b45d6f14fca applied Sanders focus_* patches, removed the unnecessary clean-prefix from the new function names
Anselm R.Garbe <arg@10ksloc.org>
parents: 292
diff changeset
   142
			return;
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   143
		if(ev->button == Button1 && (isfloating() || c->isfloating)) {
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
   144
			restack();
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   145
			movemouse(c);
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   146
		}
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   147
		else if(ev->button == Button2)
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 821
diff changeset
   148
			zoom(NULL);
757
22dfaeb82491 made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 756
diff changeset
   149
		else if(ev->button == Button3
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   150
		&& (isfloating() || c->isfloating) && !c->isfixed)
755
887d74605df8 I didn't knew of c->isfixed, that should fix Jukkas issue with gkrellm ;)
Anselm R. Garbe <arg@suckless.org>
parents: 753
diff changeset
   151
		{
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
   152
			restack();
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   153
			resizemouse(c);
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   154
		}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   155
	}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   156
}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   157
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   158
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   159
configurerequest(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   160
	Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   161
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   162
	XWindowChanges wc;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   163
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   164
	if((c = getclient(ev->window))) {
488
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
   165
		c->ismax = False;
860
9d9fd4575591 changing order of c->border restorage
Anselm R. Garbe <arg@suckless.org>
parents: 858
diff changeset
   166
		if(ev->value_mask & CWBorderWidth)
9d9fd4575591 changing order of c->border restorage
Anselm R. Garbe <arg@suckless.org>
parents: 858
diff changeset
   167
			c->border = ev->border_width;
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   168
		if(c->isfixed || c->isfloating || isfloating()) {
767
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   169
			if(ev->value_mask & CWX)
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   170
				c->x = ev->x;
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   171
			if(ev->value_mask & CWY)
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   172
				c->y = ev->y;
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   173
			if(ev->value_mask & CWWidth)
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   174
				c->w = ev->width;
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   175
			if(ev->value_mask & CWHeight)
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   176
				c->h = ev->height;
872
c7b4661e8902 applied Maarten Maathuis recenter-patch for floating clients only requesting new width and height exceeding the screen space
Anselm R. Garbe <arg@suckless.org>
parents: 869
diff changeset
   177
			if((c->x + c->w) > sw && c->isfloating)
c7b4661e8902 applied Maarten Maathuis recenter-patch for floating clients only requesting new width and height exceeding the screen space
Anselm R. Garbe <arg@suckless.org>
parents: 869
diff changeset
   178
				c->x = sw / 2 - c->w / 2; /* center in x direction */
c7b4661e8902 applied Maarten Maathuis recenter-patch for floating clients only requesting new width and height exceeding the screen space
Anselm R. Garbe <arg@suckless.org>
parents: 869
diff changeset
   179
			if((c->y + c->h) > sh && c->isfloating)
c7b4661e8902 applied Maarten Maathuis recenter-patch for floating clients only requesting new width and height exceeding the screen space
Anselm R. Garbe <arg@suckless.org>
parents: 869
diff changeset
   180
				c->y = sh / 2 - c->h / 2; /* center in y direction */
757
22dfaeb82491 made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 756
diff changeset
   181
			if((ev->value_mask & (CWX | CWY))
22dfaeb82491 made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 756
diff changeset
   182
			&& !(ev->value_mask & (CWWidth | CWHeight)))
755
887d74605df8 I didn't knew of c->isfixed, that should fix Jukkas issue with gkrellm ;)
Anselm R. Garbe <arg@suckless.org>
parents: 753
diff changeset
   183
				configure(c);
768
b1dbe65d3e84 simplified configurerequest to a bare minimum, removed wrong ban() calls
Anselm R. Garbe <arg@suckless.org>
parents: 767
diff changeset
   184
			if(isvisible(c))
767
074537180053 fixed configurerequest according to Jukkas complains
Anselm R. Garbe <arg@suckless.org>
parents: 766
diff changeset
   185
				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 500
diff changeset
   186
		}
861
55691060ffa3 changed border handling
Anselm R. Garbe <arg@suckless.org>
parents: 860
diff changeset
   187
		else
755
887d74605df8 I didn't knew of c->isfixed, that should fix Jukkas issue with gkrellm ;)
Anselm R. Garbe <arg@suckless.org>
parents: 753
diff changeset
   188
			configure(c);
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
   189
	}
753
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   190
	else {
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   191
		wc.x = ev->x;
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   192
		wc.y = ev->y;
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   193
		wc.width = ev->width;
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   194
		wc.height = ev->height;
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   195
		wc.border_width = ev->border_width;
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   196
		wc.sibling = ev->above;
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   197
		wc.stack_mode = ev->detail;
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   198
		XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
db484aa5c2cf stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   199
	}
752
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 750
diff changeset
   200
	XSync(dpy, False);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   201
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   202
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   203
static void
867
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   204
configurenotify(XEvent *e) {
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   205
	XConfigureEvent *ev = &e->xconfigure;
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   206
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   207
	if (ev->window == root && (ev->width != sw || ev->height != sh)) {
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   208
		sw = ev->width;
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   209
		sh = ev->height;
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   210
		XFreePixmap(dpy, dc.drawable);
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   211
		dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   212
		XResizeWindow(dpy, barwin, sw, bh);
897
0a78c9e46e24 fixed issue reported by Christian Garbs
Anselm R. Garbe <arg@suckless.org>
parents: 875
diff changeset
   213
		updatebarpos();
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   214
		arrange();
867
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   215
	}
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   216
}
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   217
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   218
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   219
destroynotify(XEvent *e) {
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   220
	Client *c;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   221
	XDestroyWindowEvent *ev = &e->xdestroywindow;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   222
11
ea9c08ec4b48 added gridsel to gridwm
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   223
	if((c = getclient(ev->window)))
971
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 958
diff changeset
   224
		unmanage(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   225
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   226
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   227
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   228
enternotify(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   229
	Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   230
	XCrossingEvent *ev = &e->xcrossing;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   231
232
98e9901b1dbb disallow zoom on maximized clients
Anselm R.Garbe <arg@10ksloc.org>
parents: 231
diff changeset
   232
	if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   233
		return;
908
2f27c51332ed applied Jukkas patch
Anselm R. Garbe <arg@suckless.org>
parents: 906
diff changeset
   234
	if((c = getclient(ev->window)))
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   235
		focus(c);
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
   236
	else if(ev->window == root) {
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
   237
		selscreen = True;
904
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 897
diff changeset
   238
		focus(NULL);
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
   239
	}
5
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
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   242
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   243
expose(XEvent *e) {
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   244
	XExposeEvent *ev = &e->xexpose;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   245
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   246
	if(ev->count == 0) {
70
e5fff8249705 draw bar on exposure ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 63
diff changeset
   247
		if(barwin == ev->window)
987
ea0cef59c3a3 renamed drawstatus into drawbar
Anselm R. Garbe <garbeam@gmail.com>
parents: 971
diff changeset
   248
			drawbar();
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   249
	}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   250
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   251
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   252
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   253
keypress(XEvent *e) {
956
484245788760 made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   254
	KEYS
958
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   255
	unsigned int len = sizeof keys / sizeof keys[0];
589
732c58a3d92d returning to old Key struct
arg@mig29
parents: 586
diff changeset
   256
	unsigned int i;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   257
	KeySym keysym;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   258
	XKeyEvent *ev = &e->xkey;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   259
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   260
	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
757
22dfaeb82491 made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 756
diff changeset
   261
	for(i = 0; i < len; i++)
958
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   262
		if(keysym == keys[i].keysym
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   263
		&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state))
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
   264
		{
958
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   265
			if(keys[i].func)
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   266
				keys[i].func(keys[i].arg);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   267
		}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   268
}
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
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   271
leavenotify(XEvent *e) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   272
	XCrossingEvent *ev = &e->xcrossing;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   273
701
fc5b982778df applied a modified version of Christof Musik's multihead patch (though this is not sure if it works in all cases, have to wait for an ACK by Christof)
Anselm R. Garbe <arg@suckless.org>
parents: 692
diff changeset
   274
	if((ev->window == root) && !ev->same_screen) {
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
   275
		selscreen = False;
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   276
		focus(NULL);
701
fc5b982778df applied a modified version of Christof Musik's multihead patch (though this is not sure if it works in all cases, have to wait for an ACK by Christof)
Anselm R. Garbe <arg@suckless.org>
parents: 692
diff changeset
   277
	}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   278
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   279
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   280
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   281
mappingnotify(XEvent *e) {
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   282
	XMappingEvent *ev = &e->xmapping;
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   283
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   284
	XRefreshKeyboardMapping(ev);
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   285
	if(ev->request == MappingKeyboard)
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   286
		grabkeys();
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   287
}
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   288
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   289
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   290
maprequest(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   291
	static XWindowAttributes wa;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   292
	XMapRequestEvent *ev = &e->xmaprequest;
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
	if(!XGetWindowAttributes(dpy, ev->window, &wa))
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   295
		return;
921
e0ec0d5d8b1e restoring tip to be a working dwm again (switching FONT to terminus in config.arg.h)
arg@f00b4r
parents: 920
diff changeset
   296
	if(wa.override_redirect)
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   297
		return;
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   298
	if(!getclient(ev->window))
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   299
		manage(ev->window, &wa);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   300
}
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
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   303
propertynotify(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   304
	Client *c;
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
   305
	Window trans;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   306
	XPropertyEvent *ev = &e->xproperty;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   307
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   308
	if(ev->state == PropertyDelete)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   309
		return; /* ignore */
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   310
	if((c = getclient(ev->window))) {
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   311
		switch (ev->atom) {
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   312
			default: break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   313
			case XA_WM_TRANSIENT_FOR:
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
   314
				XGetTransientForHint(dpy, c->win, &trans);
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   315
				if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   316
					arrange();
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   317
				break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   318
			case XA_WM_NORMAL_HINTS:
639
226ef912c093 renamed updatesize into updatesizehints (thx to Sander for this hint)
arg@mig29
parents: 630
diff changeset
   319
				updatesizehints(c);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   320
				break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   321
		}
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   322
		if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
454
ffb462fb7903 small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents: 400
diff changeset
   323
			updatetitle(c);
690
399f08187c27 removed drawclient and drawall (they performed useless operations/consumed useless cpu cycles)
Anselm R. Garbe <arg@suckless.org>
parents: 687
diff changeset
   324
			if(c == sel)
987
ea0cef59c3a3 renamed drawstatus into drawbar
Anselm R. Garbe <garbeam@gmail.com>
parents: 971
diff changeset
   325
				drawbar();
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   326
		}
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   327
	}
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   328
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   329
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   330
static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
   331
unmapnotify(XEvent *e) {
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   332
	Client *c;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   333
	XUnmapEvent *ev = &e->xunmap;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   334
971
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 958
diff changeset
   335
	if((c = getclient(ev->window)))
b2a0dfa22b1d removed the _DWM_PROPERTIES handling, reverted ban/unban to XMoveWindow(), and changed argument of setlayout to layout[N].symbol check
Anselm R. Garbe <garbeam@gmail.com>
parents: 958
diff changeset
   336
		unmanage(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   337
}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   338
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 80
diff changeset
   339
/* extern */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   340
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   341
void (*handler[LASTEvent]) (XEvent *) = {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   342
	[ButtonPress] = buttonpress,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   343
	[ConfigureRequest] = configurerequest,
867
067a7784150e applied patch of Paul Liu to allow onthefly resizing due to xrandr changes
Anselm R. Garbe <arg@suckless.org>
parents: 861
diff changeset
   344
	[ConfigureNotify] = configurenotify,
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   345
	[DestroyNotify] = destroynotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   346
	[EnterNotify] = enternotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   347
	[LeaveNotify] = leavenotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   348
	[Expose] = expose,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   349
	[KeyPress] = keypress,
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   350
	[MappingNotify] = mappingnotify,
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   351
	[MapRequest] = maprequest,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   352
	[PropertyNotify] = propertynotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   353
	[UnmapNotify] = unmapnotify
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   354
};
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   355
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   356
void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
   357
grabkeys(void) {
956
484245788760 made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   358
	KEYS
958
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   359
	unsigned int len = sizeof keys / sizeof keys[0];
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   360
	unsigned int i;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   361
	KeyCode code;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   362
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   363
	XUngrabKey(dpy, AnyKey, AnyModifier, root);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   364
	for(i = 0; i < len; i++) {
958
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   365
		code = XKeysymToKeycode(dpy, keys[i].keysym);
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   366
		XGrabKey(dpy, code, keys[i].mod, root, True,
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   367
				GrabModeAsync, GrabModeAsync);
958
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   368
		XGrabKey(dpy, code, keys[i].mod | LockMask, root, True,
160
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
   369
				GrabModeAsync, GrabModeAsync);
958
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   370
		XGrabKey(dpy, code, keys[i].mod | numlockmask, root, True,
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
   371
				GrabModeAsync, GrabModeAsync);
958
8b502be8b8e0 made plural arrays
Anselm R. Garbe <garbeam@gmail.com>
parents: 956
diff changeset
   372
		XGrabKey(dpy, code, keys[i].mod | numlockmask | LockMask, root, True,
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
   373
				GrabModeAsync, GrabModeAsync);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   374
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   375
}