event.c
author Anselm R. Garbe <arg@suckless.org>
Tue, 13 Feb 2007 22:53:58 +0100
changeset 755 887d74605df8
parent 753 db484aa5c2cf
child 756 df3ea2f76f54
permissions -rw-r--r--
I didn't knew of c->isfixed, that should fix Jukkas issue with gkrellm ;)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
644
1ed8c40dde36 corrections
arg@mig29
parents: 643
diff changeset
     1
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     2
 * See LICENSE file for license details.
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     3
 */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
     4
#include "dwm.h"
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     5
#include <stdlib.h>
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     6
#include <X11/keysym.h>
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
     7
#include <X11/Xatom.h>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     8
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
     9
/* static */
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    10
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    11
typedef struct {
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    12
	unsigned long mod;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    13
	KeySym keysym;
589
732c58a3d92d returning to old Key struct
arg@mig29
parents: 586
diff changeset
    14
	void (*func)(Arg *arg);
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    15
	Arg arg;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    16
} Key;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
    17
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
    18
KEYS
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
    19
291
8e6e0aa5e2ae removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents: 288
diff changeset
    20
#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
    21
#define MOUSEMASK		(BUTTONMASK | PointerMotionMask)
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
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
    24
movemouse(Client *c) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    25
	int x1, y1, ocx, ocy, di;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    26
	unsigned int dui;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    27
	Window dummy;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    28
	XEvent ev;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    29
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
    30
	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
    31
	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
    32
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    33
			None, cursor[CurMove], CurrentTime) != GrabSuccess)
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    34
		return;
482
acb1fc729a8c ismax toggling on mouse based action
arg@mmvi
parents: 478
diff changeset
    35
	c->ismax = False;
77
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(;;) {
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    38
		XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    39
		switch (ev.type) {
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    40
		case ButtonRelease:
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    41
			resize(c, True);
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    42
			XUngrabPointer(dpy, CurrentTime);
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    43
			return;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    44
		case ConfigureRequest:
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    45
		case Expose:
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    46
		case MapRequest:
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    47
			handler[ev.type](&ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    48
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    49
		case MotionNotify:
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
    50
			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
    51
			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
    52
			c->y = ocy + (ev.xmotion.y - y1);
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 556
diff changeset
    53
			if(abs(wax + c->x) < SNAP)
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 556
diff changeset
    54
				c->x = wax;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    55
			else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP)
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    56
				c->x = wax + waw - c->w - 2 * c->border;
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 556
diff changeset
    57
			if(abs(way - c->y) < SNAP)
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 556
diff changeset
    58
				c->y = way;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    59
			else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP)
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    60
				c->y = way + wah - c->h - 2 * c->border;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    61
			resize(c, False);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    62
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    63
		}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    64
	}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    65
}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    66
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    67
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
    68
resizemouse(Client *c) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    69
	int ocx, ocy;
268
a47b3b0d7bf4 applied Sanders LD and resize patches
Anselm R.Garbe <arg@10ksloc.org>
parents: 267
diff changeset
    70
	int nw, nh;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
    71
	XEvent ev;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    72
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
    73
	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
    74
	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
    75
	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
    76
			None, cursor[CurResize], CurrentTime) != GrabSuccess)
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    77
		return;
482
acb1fc729a8c ismax toggling on mouse based action
arg@mmvi
parents: 478
diff changeset
    78
	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
    79
	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
    80
	for(;;) {
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    81
		XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    82
		switch(ev.type) {
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    83
		case ButtonRelease:
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    84
			resize(c, True);
745
cf432071e646 added pointer warp on drop in resize
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
    85
			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
    86
					c->w + c->border - 1, c->h + c->border - 1);
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    87
			XUngrabPointer(dpy, CurrentTime);
746
54e12eb664fc removing all EnterNotifys after resize
Anselm R. Garbe <arg@suckless.org>
parents: 745
diff changeset
    88
			while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
    89
			return;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    90
		case ConfigureRequest:
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    91
		case Expose:
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    92
		case MapRequest:
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    93
			handler[ev.type](&ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    94
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
    95
		case MotionNotify:
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
    96
			XSync(dpy, False);
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    97
			nw = ev.xmotion.x - ocx - 2 * c->border + 1;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    98
			c->w = nw > 0 ? nw : 1;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
    99
			nh = ev.xmotion.y - ocy - 2 * c->border + 1;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
   100
			c->h = nh > 0 ? nh : 1;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
   101
			resize(c, True);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   102
			break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   103
		}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   104
	}
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   105
}
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   106
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   107
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
   108
buttonpress(XEvent *e) {
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   109
	int x;
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   110
	Arg a;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   111
	Client *c;
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   112
	XButtonPressedEvent *ev = &e->xbutton;
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   113
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   114
	if(barwin == ev->window) {
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
   115
		x = 0;
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
   116
		for(a.i = 0; a.i < ntags; a.i++) {
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
   117
			x += textw(tags[a.i]);
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
   118
			if(ev->x < x) {
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   119
				if(ev->button == Button1) {
398
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   120
					if(ev->state & MODKEY)
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   121
						tag(&a);
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   122
					else
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   123
						view(&a);
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   124
				}
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   125
				else if(ev->button == Button3) {
398
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   126
					if(ev->state & MODKEY)
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   127
						toggletag(&a);
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   128
					else
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
   129
						toggleview(&a);
394
1da9a6b94ca9 implemented Button2 press on tags for toggletag on the focused client
Anselm R. Garbe <arg@10kloc.org>
parents: 387
diff changeset
   130
				}
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
   131
				return;
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   132
			}
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   133
		}
676
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   134
		if(ev->x < x + bmw)
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   135
			switch(ev->button) {
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   136
			case Button1:
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   137
				togglemode(NULL);
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   138
				break;
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   139
			case Button4:
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   140
				a.i = 1;
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   141
				incnmaster(&a);
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   142
				break;
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   143
			case Button5:
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   144
				a.i = -1;
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   145
				incnmaster(&a);
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   146
				break;
7672a1041218 added comment to %u in config.default.h, added Button{4.5} support on mode label
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   147
			}
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
   148
	}
58
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 55
diff changeset
   149
	else if((c = getclient(ev->window))) {
143
36cabfe408cd applied Sanders patches
arg@10ksloc.org
parents: 139
diff changeset
   150
		focus(c);
473
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 466
diff changeset
   151
		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
   152
			return;
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 399
diff changeset
   153
		if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
   154
			restack();
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   155
			movemouse(c);
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   156
		}
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   157
		else if(ev->button == Button2)
248
1227c21588e2 applied Sanders zoom_update patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 239
diff changeset
   158
			zoom(NULL);
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
   159
		else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)
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
   160
				&& !c->isfixed)
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
   161
		{
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
   162
			restack();
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
   163
			resizemouse(c);
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   164
		}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   165
	}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   166
}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   167
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   168
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
   169
configurerequest(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   170
	Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   171
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   172
	XWindowChanges wc;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   173
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   174
	if((c = getclient(ev->window))) {
488
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
   175
		c->ismax = False;
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
   176
		c->border = (ev->value_mask & CWBorderWidth) ? ev->border_width : c->border;
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
   177
		if(c->isfixed || c->isfloat || (arrange == dofloat)) {
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
   178
			c->x = (ev->value_mask & CWX) ? ev->x : c->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
   179
			c->y = (ev->value_mask & CWY) ? ev->y : c->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
   180
			c->w = (ev->value_mask & CWWidth) ? ev->width : c->w;
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
   181
			c->h = (ev->value_mask & CWHeight) ? ev->height : c->h;
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
   182
			if((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight)))
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);
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
   184
			resize(c, False);
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
   185
			if(!isvisible(c))
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
   186
				XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 500
diff changeset
   187
		}
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
		else
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
   189
			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
   190
	}
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
   191
	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
   192
		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
   193
		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
   194
		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
   195
		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
   196
		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
   197
		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
   198
		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
   199
		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
   200
	}
752
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 750
diff changeset
   201
	XSync(dpy, False);
5
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
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   204
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
   205
destroynotify(XEvent *e) {
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   206
	Client *c;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   207
	XDestroyWindowEvent *ev = &e->xdestroywindow;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   208
11
ea9c08ec4b48 added gridsel to gridwm
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   209
	if((c = getclient(ev->window)))
ea9c08ec4b48 added gridsel to gridwm
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   210
		unmanage(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   211
}
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
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
   214
enternotify(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   215
	Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   216
	XCrossingEvent *ev = &e->xcrossing;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   217
232
98e9901b1dbb disallow zoom on maximized clients
Anselm R.Garbe <arg@10ksloc.org>
parents: 231
diff changeset
   218
	if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   219
		return;
687
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 676
diff changeset
   220
	if((c = getclient(ev->window)) && isvisible(c))
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   221
		focus(c);
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
   222
	else if(ev->window == root) {
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
   223
		selscreen = True;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
   224
		for(c = stack; c && !isvisible(c); c = c->snext);
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 707
diff changeset
   225
		focus(c);
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
   226
	}
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   227
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   228
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   229
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
   230
expose(XEvent *e) {
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   231
	XExposeEvent *ev = &e->xexpose;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   232
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   233
	if(ev->count == 0) {
70
e5fff8249705 draw bar on exposure ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 63
diff changeset
   234
		if(barwin == ev->window)
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
   235
			drawstatus();
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   236
	}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   237
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   238
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   239
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
   240
keypress(XEvent *e) {
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 565
diff changeset
   241
	static unsigned int len = sizeof key / sizeof key[0];
589
732c58a3d92d returning to old Key struct
arg@mig29
parents: 586
diff changeset
   242
	unsigned int i;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   243
	KeySym keysym;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   244
	XKeyEvent *ev = &e->xkey;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   245
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   246
	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
   247
	for(i = 0; i < len; i++) {
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
   248
		if(keysym == key[i].keysym
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
   249
			&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
   250
		{
589
732c58a3d92d returning to old Key struct
arg@mig29
parents: 586
diff changeset
   251
			if(key[i].func)
732c58a3d92d returning to old Key struct
arg@mig29
parents: 586
diff changeset
   252
				key[i].func(&key[i].arg);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   253
		}
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
   254
	}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   255
}
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
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
   258
leavenotify(XEvent *e) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   259
	XCrossingEvent *ev = &e->xcrossing;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   260
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
   261
	if((ev->window == root) && !ev->same_screen) {
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
   262
		selscreen = False;
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   263
		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
   264
	}
76
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
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
   268
mappingnotify(XEvent *e) {
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   269
	XMappingEvent *ev = &e->xmapping;
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   270
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   271
	XRefreshKeyboardMapping(ev);
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   272
	if(ev->request == MappingKeyboard)
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   273
		grabkeys();
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   274
}
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   275
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   276
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
   277
maprequest(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   278
	static XWindowAttributes wa;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   279
	XMapRequestEvent *ev = &e->xmaprequest;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   280
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   281
	if(!XGetWindowAttributes(dpy, ev->window, &wa))
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   282
		return;
750
154b5d4b4a26 I don't see any reason why we should select for input on override-redirect windows?
Anselm R. Garbe <arg@suckless.org>
parents: 746
diff changeset
   283
	if(wa.override_redirect)
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   284
		return;
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   285
	if(!getclient(ev->window))
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   286
		manage(ev->window, &wa);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   287
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   288
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
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
propertynotify(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   291
	Client *c;
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
   292
	Window trans;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
   293
	XPropertyEvent *ev = &e->xproperty;
5
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
	if(ev->state == PropertyDelete)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   296
		return; /* ignore */
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   297
	if((c = getclient(ev->window))) {
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   298
		switch (ev->atom) {
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   299
			default: break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   300
			case XA_WM_TRANSIENT_FOR:
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
   301
				XGetTransientForHint(dpy, c->win, &trans);
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   302
				if(!c->isfloat && (c->isfloat = (trans != 0)))
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
   303
					arrange();
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   304
				break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   305
			case XA_WM_NORMAL_HINTS:
639
226ef912c093 renamed updatesize into updatesizehints (thx to Sander for this hint)
arg@mig29
parents: 630
diff changeset
   306
				updatesizehints(c);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   307
				break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   308
		}
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   309
		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
   310
			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
   311
			if(c == sel)
399f08187c27 removed drawclient and drawall (they performed useless operations/consumed useless cpu cycles)
Anselm R. Garbe <arg@suckless.org>
parents: 687
diff changeset
   312
				drawstatus();
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   313
		}
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
   314
	}
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   315
}
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   316
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   317
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
   318
unmapnotify(XEvent *e) {
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   319
	Client *c;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   320
	XUnmapEvent *ev = &e->xunmap;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   321
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   322
	if((c = getclient(ev->window)))
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   323
		unmanage(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   324
}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   325
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 80
diff changeset
   326
/* extern */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   327
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   328
void (*handler[LASTEvent]) (XEvent *) = {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   329
	[ButtonPress] = buttonpress,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   330
	[ConfigureRequest] = configurerequest,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   331
	[DestroyNotify] = destroynotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   332
	[EnterNotify] = enternotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   333
	[LeaveNotify] = leavenotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   334
	[Expose] = expose,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   335
	[KeyPress] = keypress,
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   336
	[MappingNotify] = mappingnotify,
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   337
	[MapRequest] = maprequest,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   338
	[PropertyNotify] = propertynotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   339
	[UnmapNotify] = unmapnotify
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
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   342
void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
   343
grabkeys(void) {
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 565
diff changeset
   344
	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
   345
	unsigned int i;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   346
	KeyCode code;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   347
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
   348
	XUngrabKey(dpy, AnyKey, AnyModifier, root);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   349
	for(i = 0; i < len; i++) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   350
		code = XKeysymToKeycode(dpy, key[i].keysym);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   351
		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
   352
				GrabModeAsync, GrabModeAsync);
160
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
   353
		XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
   354
				GrabModeAsync, GrabModeAsync);
291
8e6e0aa5e2ae removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents: 288
diff changeset
   355
		XGrabKey(dpy, code, key[i].mod | numlockmask, root, True,
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
   356
				GrabModeAsync, GrabModeAsync);
291
8e6e0aa5e2ae removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents: 288
diff changeset
   357
		XGrabKey(dpy, code, key[i].mod | numlockmask | LockMask, root, True,
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
   358
				GrabModeAsync, GrabModeAsync);
76
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
}
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   361
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   362
void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
   363
procevent(void) {
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   364
	XEvent ev;
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   365
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   366
	while(XPending(dpy)) {
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   367
		XNextEvent(dpy, &ev);
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   368
		if(handler[ev.type])
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   369
			(handler[ev.type])(&ev); /* call handler */
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   370
	}
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
   371
}