client.c
author Anselm R. Garbe <arg@suckless.org>
Tue, 06 Feb 2007 15:29:19 +0100
changeset 733 1950833a5614
parent 732 a642068c4834
child 734 6283adb1fcf2
permissions -rw-r--r--
yet another fix
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"
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
     5
#include <stdlib.h>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     6
#include <string.h>
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     7
#include <X11/Xatom.h>
32
082c75b937b5 removed unnecessary crap
Anselm R. Garbe <garbeam@wmii.de>
parents: 31
diff changeset
     8
#include <X11/Xutil.h>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     9
730
8997e28553a8 made some changes more concistent
Anselm R. Garbe <arg@suckless.org>
parents: 725
diff changeset
    10
/* static */
50
148f25ed0ad7 several other additions/fixes, dwm is quite usable already
Anselm R. Garbe <garbeam@wmii.de>
parents: 49
diff changeset
    11
26
e8f627998d6f simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents: 23
diff changeset
    12
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
    13
detachstack(Client *c) {
446
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
    14
	Client **tc;
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
    15
	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
    16
	*tc = c->snext;
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
    17
}
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
    18
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
    19
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
    20
grabbuttons(Client *c, Bool focused) {
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    21
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    22
452
026aba558fdf added some comments
Anselm R. Garbe <arg@10kloc.org>
parents: 450
diff changeset
    23
	if(focused) {
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    24
		XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    25
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    26
		XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    27
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    28
		XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    29
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    30
		XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    31
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    32
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    33
		XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    34
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    35
		XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    36
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    37
		XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    38
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    39
		XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    40
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    41
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    42
		XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    43
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    44
		XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    45
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    46
		XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    47
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    48
		XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    49
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    50
	}
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    51
	else
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    52
		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    53
				GrabModeAsync, GrabModeSync, None, None);
318
1b45d6f14fca applied Sanders focus_* patches, removed the unnecessary clean-prefix from the new function names
Anselm R.Garbe <arg@10ksloc.org>
parents: 315
diff changeset
    54
}
1b45d6f14fca applied Sanders focus_* patches, removed the unnecessary clean-prefix from the new function names
Anselm R.Garbe <arg@10ksloc.org>
parents: 315
diff changeset
    55
725
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
    56
static void
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
    57
setclientstate(Client *c, long state) {
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
    58
	long data[] = {state, None};
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
    59
	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
    60
			PropModeReplace, (unsigned char *)data, 2);
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
    61
}
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
    62
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    63
static int
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
    64
xerrordummy(Display *dsply, XErrorEvent *ee) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    65
	return 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    66
}
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    67
730
8997e28553a8 made some changes more concistent
Anselm R. Garbe <arg@suckless.org>
parents: 725
diff changeset
    68
/* extern */
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    69
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
    70
void
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    71
configure(Client *c) {
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    72
	XEvent synev;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    73
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    74
	synev.type = ConfigureNotify;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    75
	synev.xconfigure.display = dpy;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    76
	synev.xconfigure.event = c->win;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    77
	synev.xconfigure.window = c->win;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    78
	synev.xconfigure.x = c->x;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    79
	synev.xconfigure.y = c->y;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    80
	synev.xconfigure.width = c->w;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    81
	synev.xconfigure.height = c->h;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    82
	synev.xconfigure.border_width = c->border;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    83
	synev.xconfigure.above = None;
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    84
	XSendEvent(dpy, c->win, True, NoEventMask, &synev);
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    85
}
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    86
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
    87
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
    88
focus(Client *c) {
709
6c2fcf88dd9f this variant is known to work, but focus() is ugly - we need in general a better way to handle multihead, this issel-stuff looks awkward (maybe it might be a good idea to set sel to NULL but to introduce a Client *revert which is set if a screen is unfocused, have to think about it further).
Anselm R. Garbe <arg@suckless.org>
parents: 708
diff changeset
    89
	if(c && !isvisible(c))
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 232
diff changeset
    90
		return;
712
b288b57d81f8 this version should also work with cornercases (like unmanage during !issel, etc.)
Anselm R. Garbe <arg@suckless.org>
parents: 711
diff changeset
    91
	if(sel && sel != c) {
b288b57d81f8 this version should also work with cornercases (like unmanage during !issel, etc.)
Anselm R. Garbe <arg@suckless.org>
parents: 711
diff changeset
    92
		grabbuttons(sel, False);
b288b57d81f8 this version should also work with cornercases (like unmanage during !issel, etc.)
Anselm R. Garbe <arg@suckless.org>
parents: 711
diff changeset
    93
		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
318
1b45d6f14fca applied Sanders focus_* patches, removed the unnecessary clean-prefix from the new function names
Anselm R.Garbe <arg@10ksloc.org>
parents: 315
diff changeset
    94
	}
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
    95
	if(c) {
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
    96
		detachstack(c);
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
    97
		c->snext = stack;
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
    98
		stack = c;
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
    99
		grabbuttons(c, True);
714
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   100
	}
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   101
	sel = c;
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   102
	drawstatus();
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 715
diff changeset
   103
	if(!selscreen)
714
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   104
		return;
715
5b3e4cdb6674 implemented Sanders remarks
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
   105
	if(c) {
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   106
		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   107
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   108
	}
712
b288b57d81f8 this version should also work with cornercases (like unmanage during !issel, etc.)
Anselm R. Garbe <arg@suckless.org>
parents: 711
diff changeset
   109
	else
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   110
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   111
}
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   112
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   113
Client *
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
   114
getclient(Window w) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   115
	Client *c;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   116
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   117
	for(c = clients; c; c = c->next)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   118
		if(c->win == w)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   119
			return c;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   120
	return NULL;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   121
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   122
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   123
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
   124
killclient(Arg *arg) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   125
	if(!sel)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   126
		return;
157
93012e947eae renamed WM_PROTOCOL_DELWIN into PROTODELWIN
arg@10ksloc.org
parents: 151
diff changeset
   127
	if(sel->proto & PROTODELWIN)
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   128
		sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   129
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   130
		XKillClient(dpy, sel->win);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   131
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   132
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   133
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
   134
manage(Window w, XWindowAttributes *wa) {
431
a230e4432bb7 moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents: 430
diff changeset
   135
	Client *c;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   136
	Window trans;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   137
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   138
	c = emallocz(sizeof(Client));
178
e848966a1ac6 removed TLast tag enum, now tags is simple defined as char *[] array, the rest is calculated correctly, rules take an int array for the tags
arg@10ksloc.org
parents: 173
diff changeset
   139
	c->tags = emallocz(ntags * sizeof(Bool));
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   140
	c->win = w;
687
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   141
	c->x = wa->x;
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   142
	c->y = wa->y;
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   143
	c->w = wa->width;
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
   144
	c->h = wa->height;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   145
	if(c->w == sw && c->h == sh) {
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   146
		c->border = 0;
517
2b4bd49fc155 applied ality's hardcode-0 patches
Anselm R. Garbe <arg@10kloc.org>
parents: 502
diff changeset
   147
		c->x = sx;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   148
		c->y = sy;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   149
	}
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   150
	else {
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   151
		c->border = BORDERPX;
718
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   152
		if(c->x + c->w + 2 * c->border > wax + waw)
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   153
			c->x = wax + waw - c->w - 2 * c->border;
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   154
		if(c->y + c->h + 2 * c->border > way + wah)
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   155
			c->y = way + wah - c->h - 2 * c->border;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   156
		if(c->x < wax)
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   157
			c->x = wax;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   158
		if(c->y < way)
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   159
			c->y = way;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   160
	}
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   161
	updatesizehints(c);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
   162
	c->proto = getproto(c->win);
26
e8f627998d6f simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents: 23
diff changeset
   163
	XSelectInput(dpy, c->win,
127
1480e19f6377 using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents: 124
diff changeset
   164
		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 52
diff changeset
   165
	XGetTransientForHint(dpy, c->win, &trans);
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
   166
	grabbuttons(c, False);
715
5b3e4cdb6674 implemented Sanders remarks
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
   167
	XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
500
d5ad819f2a66 fixing the settags issue, preparing 1.7.1
Anselm R. Garbe <arg@10kloc.org>
parents: 491
diff changeset
   168
	updatetitle(c);
431
a230e4432bb7 moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents: 430
diff changeset
   169
	settags(c, getclient(trans));
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   170
	if(!c->isfloat)
549
fd1061442711 applied sanders try2 patch
arg@mig29
parents: 548
diff changeset
   171
		c->isfloat = trans || c->isfixed;
381
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
   172
	if(clients)
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
   173
		clients->prev = c;
b00cc483d13b still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
   174
	c->next = clients;
446
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
   175
	c->snext = stack;
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 442
diff changeset
   176
	stack = clients = c;
687
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   177
	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
270
dacd3f3c5823 implemented restack behavior (floats are on top in tiled mode)
Anselm R.Garbe <arg@10ksloc.org>
parents: 261
diff changeset
   178
	XMapWindow(dpy, c->win);
725
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
   179
	setclientstate(c, NormalState);
261
d6fd632d861c implement multi-tag selection through button3 click on the specific tag
Anselm R.Garbe <arg@10ksloc.org>
parents: 254
diff changeset
   180
	if(isvisible(c))
51
035617ee18d1 new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 50
diff changeset
   181
		focus(c);
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
   182
	arrange();
94
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   183
}
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   184
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   185
void
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   186
resize(Client *c, Bool sizehints) {
733
1950833a5614 yet another fix
Anselm R. Garbe <arg@suckless.org>
parents: 732
diff changeset
   187
	float actual, dx, dy, max, min;
163
e2e1de08341d new stuff
arg@10ksloc.org
parents: 161
diff changeset
   188
	XWindowChanges wc;
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   189
721
d3876aa79292 prepared yet another hotfix release
Anselm R. Garbe <arg@suckless.org>
parents: 718
diff changeset
   190
	if(c->w <= 0 || c->h <= 0)
d3876aa79292 prepared yet another hotfix release
Anselm R. Garbe <arg@suckless.org>
parents: 718
diff changeset
   191
		return;
129
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   192
	if(sizehints) {
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   193
		if(c->minw && c->w < c->minw)
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   194
			c->w = c->minw;
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   195
		if(c->minh && c->h < c->minh)
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   196
			c->h = c->minh;
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   197
		if(c->maxw && c->w > c->maxw)
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   198
			c->w = c->maxw;
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   199
		if(c->maxh && c->h > c->maxh)
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   200
			c->h = c->maxh;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   201
		/* inspired by algorithm from fluxbox */
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   202
		if(c->minay > 0 && c->maxay && (c->h - c->baseh) > 0) {
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   203
			dx = (float)(c->w - c->basew);
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   204
			dy = (float)(c->h - c->baseh);
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   205
			min = (float)(c->minax) / (float)(c->minay);
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   206
			max = (float)(c->maxax) / (float)(c->maxay);
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   207
			actual = dx / dy;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   208
			if(max > 0 && min > 0 && actual > 0) {
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   209
				if(actual < min) {
732
a642068c4834 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 731
diff changeset
   210
					dy = (dx * min + dy) / (min * min + 1);
a642068c4834 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 731
diff changeset
   211
					dx = dy * min;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   212
					c->w = (int)dx + c->basew;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   213
					c->h = (int)dy + c->baseh;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   214
				}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   215
				else if(actual > max) {
732
a642068c4834 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 731
diff changeset
   216
					dy = (dx * min + dy) / (max * max + 1);
a642068c4834 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 731
diff changeset
   217
					dx = dy * min;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   218
					c->w = (int)dx + c->basew;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   219
					c->h = (int)dy + c->baseh;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   220
				}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   221
			}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   222
		}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   223
		if(c->incw)
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   224
			c->w -= (c->w - c->basew) % c->incw;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   225
		if(c->inch)
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   226
			c->h -= (c->h - c->baseh) % c->inch;
52
d18f6dd0cf23 fixed several things, nearly feature complete
Anselm R. Garbe <garbeam@wmii.de>
parents: 51
diff changeset
   227
	}
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   228
	if(c->w == sw && c->h == sh)
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   229
		c->border = 0;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   230
	else
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   231
		c->border = BORDERPX;
465
590575d080fe offscreen client appearance fixes
arg@mmvi
parents: 464
diff changeset
   232
	/* offscreen appearance fixes */
718
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   233
	if(c->x > sw)
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   234
		c->x = sw - c->w - 2 * c->border;
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   235
	if(c->y > sh)
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   236
		c->y = sh - c->h - 2 * c->border;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   237
	if(c->x + c->w + 2 * c->border < sx)
517
2b4bd49fc155 applied ality's hardcode-0 patches
Anselm R. Garbe <arg@10kloc.org>
parents: 502
diff changeset
   238
		c->x = sx;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   239
	if(c->y + c->h + 2 * c->border < sy)
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   240
		c->y = sy;
163
e2e1de08341d new stuff
arg@10ksloc.org
parents: 161
diff changeset
   241
	wc.x = c->x;
e2e1de08341d new stuff
arg@10ksloc.org
parents: 161
diff changeset
   242
	wc.y = c->y;
e2e1de08341d new stuff
arg@10ksloc.org
parents: 161
diff changeset
   243
	wc.width = c->w;
e2e1de08341d new stuff
arg@10ksloc.org
parents: 161
diff changeset
   244
	wc.height = c->h;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   245
	wc.border_width = c->border;
452
026aba558fdf added some comments
Anselm R. Garbe <arg@10kloc.org>
parents: 450
diff changeset
   246
	XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
630
264f02dd2ad0 removed gravitate for the moment
arg@mig29
parents: 629
diff changeset
   247
	configure(c);
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 77
diff changeset
   248
	XSync(dpy, False);
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   249
}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   250
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   251
void
639
226ef912c093 renamed updatesize into updatesizehints (thx to Sander for this hint)
arg@mig29
parents: 631
diff changeset
   252
updatesizehints(Client *c) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   253
	long msize;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   254
	XSizeHints size;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   255
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   256
	if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   257
		size.flags = PSize;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   258
	c->flags = size.flags;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   259
	if(c->flags & PBaseSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   260
		c->basew = size.base_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   261
		c->baseh = size.base_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   262
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   263
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   264
		c->basew = c->baseh = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   265
	if(c->flags & PResizeInc) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   266
		c->incw = size.width_inc;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   267
		c->inch = size.height_inc;
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
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   270
		c->incw = c->inch = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   271
	if(c->flags & PMaxSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   272
		c->maxw = size.max_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   273
		c->maxh = size.max_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   274
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   275
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   276
		c->maxw = c->maxh = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   277
	if(c->flags & PMinSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   278
		c->minw = size.min_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   279
		c->minh = size.min_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   280
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   281
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   282
		c->minw = c->minh = 0;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   283
	if(c->flags & PAspect) {
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   284
		c->minax = size.min_aspect.x;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   285
		c->minay = size.min_aspect.y;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   286
		c->maxax = size.max_aspect.x;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   287
		c->maxay = size.max_aspect.y;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   288
	}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   289
	else
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   290
		c->minax = c->minay = c->maxax = c->maxay = 0;
550
787f6ae02f29 and another fix
arg@mig29
parents: 549
diff changeset
   291
	c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
787f6ae02f29 and another fix
arg@mig29
parents: 549
diff changeset
   292
				c->maxw == c->minw && c->maxh == c->minh);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   293
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   294
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   295
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
   296
updatetitle(Client *c) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   297
	char **list = NULL;
377
b1159a638d0a removed crappy variables
Anselm R. Garbe <arg@10kloc.org>
parents: 372
diff changeset
   298
	int n;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   299
	XTextProperty name;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   300
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   301
	name.nitems = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   302
	c->name[0] = 0;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   303
	XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   304
	if(!name.nitems)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   305
		XGetWMName(dpy, c->win, &name);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   306
	if(!name.nitems)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   307
		return;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   308
	if(name.encoding == XA_STRING)
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 550
diff changeset
   309
		strncpy(c->name, (char *)name.value, sizeof c->name);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   310
	else {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   311
		if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   312
				&& n > 0 && *list)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   313
		{
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 550
diff changeset
   314
			strncpy(c->name, *list, sizeof c->name);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   315
			XFreeStringList(list);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   316
		}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   317
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   318
	XFree(name.value);
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   319
}
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   320
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   321
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
   322
unmanage(Client *c) {
450
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 448
diff changeset
   323
	Client *nc;
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 448
diff changeset
   324
472
298be2d65d2e reviewed client.c
arg@mmvi
parents: 465
diff changeset
   325
	/* The server grab construct avoids race conditions. */
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   326
	XGrabServer(dpy);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
   327
	XSetErrorHandler(xerrordummy);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   328
	detach(c);
448
Anselm R. Garbe <arg@10kloc.org>
parents: 447
diff changeset
   329
	detachstack(c);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   330
	if(sel == c) {
450
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 448
diff changeset
   331
		for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 448
diff changeset
   332
		focus(nc);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   333
	}
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   334
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
725
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 721
diff changeset
   335
	setclientstate(c, WithdrawnState);
178
e848966a1ac6 removed TLast tag enum, now tags is simple defined as char *[] array, the rest is calculated correctly, rules take an int array for the tags
arg@10ksloc.org
parents: 173
diff changeset
   336
	free(c->tags);
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   337
	free(c);
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 77
diff changeset
   338
	XSync(dpy, False);
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
   339
	XSetErrorHandler(xerror);
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   340
	XUngrabServer(dpy);
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
   341
	arrange();
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   342
}