client.c
author Anselm R. Garbe <arg@suckless.org>
Mon, 19 Feb 2007 15:57:08 +0100
changeset 779 e4382ee39888
parent 777 469dc170f833
child 781 dde5852bf151
permissions -rw-r--r--
bugfix of transient handling
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
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    13
attachstack(Client *c) {
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    14
	c->snext = stack;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    15
	stack = c;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    16
}
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    17
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    18
static void
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    19
detachstack(Client *c) {
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    20
	Client **tc;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    21
	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    22
	*tc = c->snext;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    23
}
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    24
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    25
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
    26
grabbuttons(Client *c, Bool focused) {
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    27
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    28
452
026aba558fdf added some comments
Anselm R. Garbe <arg@10kloc.org>
parents: 450
diff changeset
    29
	if(focused) {
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    30
		XGrabButton(dpy, Button1, MODKEY, 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
		XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    33
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    34
		XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    35
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    36
		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
    37
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    38
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    39
		XGrabButton(dpy, Button2, MODKEY, 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
		XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    42
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    43
		XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    44
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    45
		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
    46
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    47
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    48
		XGrabButton(dpy, Button3, MODKEY, 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
		XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    51
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    52
		XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    53
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    54
		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
    55
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    56
	}
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    57
	else
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    58
		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    59
				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
    60
}
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
    61
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    62
static Bool
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    63
isprotodel(Client *c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    64
	int i, n;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    65
	Atom *protocols;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    66
	Bool ret = False;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    67
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    68
	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    69
		for(i = 0; !ret && i < n; i++)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    70
			if(protocols[i] == wmatom[WMDelete])
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    71
				ret = True;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    72
		XFree(protocols);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    73
	}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    74
	return ret;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    75
}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    76
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
    77
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
    78
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
    79
	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
    80
	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
    81
			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
    82
}
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
    83
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    84
static void
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    85
togglemax(Client *c) {
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    86
	XEvent ev;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    87
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    88
	if(c->isfixed)
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    89
		return;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    90
	if((c->ismax = !c->ismax)) {
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    91
		c->rx = c->x;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    92
		c->ry = c->y;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    93
		c->rw = c->w;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    94
		c->rh = c->h;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    95
		resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    96
	}
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    97
	else
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    98
		resize(c, c->rx, c->ry, c->rw, c->rh, True);
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    99
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   100
}
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   101
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   102
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
   103
xerrordummy(Display *dsply, XErrorEvent *ee) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   104
	return 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   105
}
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   106
730
8997e28553a8 made some changes more concistent
Anselm R. Garbe <arg@suckless.org>
parents: 725
diff changeset
   107
/* extern */
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   108
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   109
void
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   110
attach(Client *c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   111
	if(clients)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   112
		clients->prev = c;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   113
	c->next = clients;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   114
	clients = c;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   115
}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   116
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   117
void
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   118
configure(Client *c) {
752
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   119
	XConfigureEvent ce;
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   120
752
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   121
	ce.type = ConfigureNotify;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   122
	ce.display = dpy;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   123
	ce.event = c->win;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   124
	ce.window = c->win;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   125
	ce.x = c->x;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   126
	ce.y = c->y;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   127
	ce.width = c->w;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   128
	ce.height = c->h;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   129
	ce.border_width = c->border;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   130
	ce.above = None;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   131
	ce.override_redirect = False;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   132
	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   133
}
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   134
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   135
void
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   136
detach(Client *c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   137
	if(c->prev)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   138
		c->prev->next = c->next;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   139
	if(c->next)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   140
		c->next->prev = c->prev;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   141
	if(c == clients)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   142
		clients = c->next;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   143
	c->next = c->prev = NULL;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   144
}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   145
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   146
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
   147
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
   148
	if(c && !isvisible(c))
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 232
diff changeset
   149
		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
   150
	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
   151
		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
   152
		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
   153
	}
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   154
	if(c) {
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   155
		detachstack(c);
771
05946fa53085 added some new convenience functions
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
   156
		attachstack(c);
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   157
		grabbuttons(c, True);
714
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   158
	}
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   159
	sel = c;
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   160
	drawstatus();
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 715
diff changeset
   161
	if(!selscreen)
714
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   162
		return;
715
5b3e4cdb6674 implemented Sanders remarks
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
   163
	if(c) {
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   164
		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
   165
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   166
	}
712
b288b57d81f8 this version should also work with cornercases (like unmanage during !issel, etc.)
Anselm R. Garbe <arg@suckless.org>
parents: 711
diff changeset
   167
	else
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   168
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   169
}
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   170
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   171
void
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   172
focusnext(Arg *arg) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   173
	Client *c;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   174
   
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   175
	if(!sel)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   176
		return;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   177
	for(c = sel->next; c && !isvisible(c); c = c->next);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   178
	if(!c)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   179
		for(c = clients; c && !isvisible(c); c = c->next);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   180
	if(c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   181
		focus(c);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   182
		restack();
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   183
	}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   184
}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   185
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   186
void
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   187
focusprev(Arg *arg) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   188
	Client *c;
734
6283adb1fcf2 replaced getproto with a saner function, now old-school artifacts of WM times in the early 90s completely disappeared, no punned pointer warning anymore ;)
Anselm R. Garbe <arg@suckless.org>
parents: 733
diff changeset
   189
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   190
	if(!sel)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   191
		return;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   192
	for(c = sel->prev; c && !isvisible(c); c = c->prev);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   193
	if(!c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   194
		for(c = clients; c && c->next; c = c->next);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   195
		for(; c && !isvisible(c); c = c->prev);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   196
	}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   197
	if(c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   198
		focus(c);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   199
		restack();
734
6283adb1fcf2 replaced getproto with a saner function, now old-school artifacts of WM times in the early 90s completely disappeared, no punned pointer warning anymore ;)
Anselm R. Garbe <arg@suckless.org>
parents: 733
diff changeset
   200
	}
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   201
}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   202
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   203
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
   204
killclient(Arg *arg) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   205
	if(!sel)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   206
		return;
734
6283adb1fcf2 replaced getproto with a saner function, now old-school artifacts of WM times in the early 90s completely disappeared, no punned pointer warning anymore ;)
Anselm R. Garbe <arg@suckless.org>
parents: 733
diff changeset
   207
	if(isprotodel(sel))
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   208
		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
   209
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   210
		XKillClient(dpy, sel->win);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   211
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   212
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   213
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
manage(Window w, XWindowAttributes *wa) {
754
65ac12761a04 making it more sure that transient checks will work in any case
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   215
	Client *c, *t;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   216
	Window trans;
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   217
	XWindowChanges wc;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   218
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   219
	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
   220
	c->tags = emallocz(ntags * sizeof(Bool));
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   221
	c->win = w;
687
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   222
	c->x = wa->x;
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   223
	c->y = wa->y;
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   224
	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
   225
	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
   226
	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
   227
		c->border = 0;
517
2b4bd49fc155 applied ality's hardcode-0 patches
Anselm R. Garbe <arg@10kloc.org>
parents: 502
diff changeset
   228
		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
   229
		c->y = sy;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   230
	}
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   231
	else {
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   232
		c->border = BORDERPX;
718
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   233
		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
   234
			c->x = wax + waw - c->w - 2 * c->border;
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   235
		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
   236
			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
   237
		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
   238
			c->x = wax;
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 < way)
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   240
			c->y = way;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   241
	}
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   242
	updatesizehints(c);
779
e4382ee39888 bugfix of transient handling
Anselm R. Garbe <arg@suckless.org>
parents: 777
diff changeset
   243
	XSelectInput(dpy, w,
127
1480e19f6377 using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents: 124
diff changeset
   244
		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
779
e4382ee39888 bugfix of transient handling
Anselm R. Garbe <arg@suckless.org>
parents: 777
diff changeset
   245
	XGetTransientForHint(dpy, w, &trans);
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
   246
	grabbuttons(c, False);
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   247
	wc.border_width = c->border;
779
e4382ee39888 bugfix of transient handling
Anselm R. Garbe <arg@suckless.org>
parents: 777
diff changeset
   248
	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
e4382ee39888 bugfix of transient handling
Anselm R. Garbe <arg@suckless.org>
parents: 777
diff changeset
   249
	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   250
	configure(c); /* propagates border_width, if size doesn't change */
500
d5ad819f2a66 fixing the settags issue, preparing 1.7.1
Anselm R. Garbe <arg@10kloc.org>
parents: 491
diff changeset
   251
	updatetitle(c);
779
e4382ee39888 bugfix of transient handling
Anselm R. Garbe <arg@suckless.org>
parents: 777
diff changeset
   252
	for(t = clients; t && t->win != trans; t = t->next);
754
65ac12761a04 making it more sure that transient checks will work in any case
Anselm R. Garbe <arg@suckless.org>
parents: 752
diff changeset
   253
	settags(c, t);
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
   254
	if(!c->isfloat)
779
e4382ee39888 bugfix of transient handling
Anselm R. Garbe <arg@suckless.org>
parents: 777
diff changeset
   255
		c->isfloat = (t != NULL) || c->isfixed;
771
05946fa53085 added some new convenience functions
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
   256
	attach(c);
05946fa53085 added some new convenience functions
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
   257
	attachstack(c);
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   258
	c->isbanned = True;
779
e4382ee39888 bugfix of transient handling
Anselm R. Garbe <arg@suckless.org>
parents: 777
diff changeset
   259
	XMoveWindow(dpy, w, c->x + 2 * sw, c->y);
e4382ee39888 bugfix of transient handling
Anselm R. Garbe <arg@suckless.org>
parents: 777
diff changeset
   260
	XMapWindow(dpy, w);
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
   261
	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
   262
	if(isvisible(c))
51
035617ee18d1 new stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 50
diff changeset
   263
		focus(c);
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
   264
	arrange();
94
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   265
}
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   266
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   267
Client *
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   268
nexttiled(Client *c) {
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   269
	for(; c && (c->isfloat || !isvisible(c)); c = c->next);
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   270
	return c;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   271
}
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   272
94
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   273
void
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   274
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
733
1950833a5614 yet another fix
Anselm R. Garbe <arg@suckless.org>
parents: 732
diff changeset
   275
	float actual, dx, dy, max, min;
163
e2e1de08341d new stuff
arg@10ksloc.org
parents: 161
diff changeset
   276
	XWindowChanges wc;
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   277
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   278
	if(w <= 0 || h <= 0)
721
d3876aa79292 prepared yet another hotfix release
Anselm R. Garbe <arg@suckless.org>
parents: 718
diff changeset
   279
		return;
129
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   280
	if(sizehints) {
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   281
		if(c->minw && w < c->minw)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   282
			w = c->minw;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   283
		if(c->minh && h < c->minh)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   284
			h = c->minh;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   285
		if(c->maxw && w > c->maxw)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   286
			w = c->maxw;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   287
		if(c->maxh && h > c->maxh)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   288
			h = c->maxh;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   289
		/* inspired by algorithm from fluxbox */
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   290
		if(c->minay > 0 && c->maxay && (h - c->baseh) > 0) {
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   291
			dx = (float)(w - c->basew);
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   292
			dy = (float)(h - c->baseh);
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   293
			min = (float)(c->minax) / (float)(c->minay);
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   294
			max = (float)(c->maxax) / (float)(c->maxay);
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   295
			actual = dx / dy;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   296
			if(max > 0 && min > 0 && actual > 0) {
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   297
				if(actual < min) {
732
a642068c4834 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 731
diff changeset
   298
					dy = (dx * min + dy) / (min * min + 1);
a642068c4834 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 731
diff changeset
   299
					dx = dy * min;
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   300
					w = (int)dx + c->basew;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   301
					h = (int)dy + c->baseh;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   302
				}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   303
				else if(actual > max) {
732
a642068c4834 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 731
diff changeset
   304
					dy = (dx * min + dy) / (max * max + 1);
a642068c4834 simplification
Anselm R. Garbe <arg@suckless.org>
parents: 731
diff changeset
   305
					dx = dy * min;
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   306
					w = (int)dx + c->basew;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   307
					h = (int)dy + c->baseh;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   308
				}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   309
			}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   310
		}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   311
		if(c->incw)
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   312
			w -= (w - c->basew) % c->incw;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   313
		if(c->inch)
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   314
			h -= (h - c->baseh) % c->inch;
52
d18f6dd0cf23 fixed several things, nearly feature complete
Anselm R. Garbe <garbeam@wmii.de>
parents: 51
diff changeset
   315
	}
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   316
	if(w == sw && h == sh)
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   317
		c->border = 0;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   318
	else
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   319
		c->border = BORDERPX;
465
590575d080fe offscreen client appearance fixes
arg@mmvi
parents: 464
diff changeset
   320
	/* offscreen appearance fixes */
762
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   321
	if(x > sw)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   322
		x = sw - w - 2 * c->border;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   323
	if(y > sh)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   324
		y = sh - h - 2 * c->border;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   325
	if(x + w + 2 * c->border < sx)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   326
		x = sx;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   327
	if(y + h + 2 * c->border < sy)
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   328
		y = sy;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   329
	if(c->x != x || c->y != y || c->w != w || c->h != h) {
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   330
		c->x = wc.x = x;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   331
		c->y = wc.y = y;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   332
		c->w = wc.width = w;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   333
		c->h = wc.height = h;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   334
		wc.border_width = c->border;
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   335
		XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   336
		configure(c);
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   337
		XSync(dpy, False);
140bcd4782d8 removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents: 760
diff changeset
   338
	}
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   339
}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   340
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   341
void
639
226ef912c093 renamed updatesize into updatesizehints (thx to Sander for this hint)
arg@mig29
parents: 631
diff changeset
   342
updatesizehints(Client *c) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   343
	long msize;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   344
	XSizeHints size;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   345
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   346
	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
   347
		size.flags = PSize;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   348
	c->flags = size.flags;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   349
	if(c->flags & PBaseSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   350
		c->basew = size.base_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   351
		c->baseh = size.base_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   352
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   353
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   354
		c->basew = c->baseh = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   355
	if(c->flags & PResizeInc) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   356
		c->incw = size.width_inc;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   357
		c->inch = size.height_inc;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   358
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   359
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   360
		c->incw = c->inch = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   361
	if(c->flags & PMaxSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   362
		c->maxw = size.max_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   363
		c->maxh = size.max_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   364
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   365
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   366
		c->maxw = c->maxh = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   367
	if(c->flags & PMinSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   368
		c->minw = size.min_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   369
		c->minh = size.min_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   370
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   371
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   372
		c->minw = c->minh = 0;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   373
	if(c->flags & PAspect) {
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   374
		c->minax = size.min_aspect.x;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   375
		c->minay = size.min_aspect.y;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   376
		c->maxax = size.max_aspect.x;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   377
		c->maxay = size.max_aspect.y;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   378
	}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   379
	else
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   380
		c->minax = c->minay = c->maxax = c->maxay = 0;
757
22dfaeb82491 made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 754
diff changeset
   381
	c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
22dfaeb82491 made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 754
diff changeset
   382
			&& 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
   383
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   384
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   385
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
   386
updatetitle(Client *c) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   387
	char **list = NULL;
377
b1159a638d0a removed crappy variables
Anselm R. Garbe <arg@10kloc.org>
parents: 372
diff changeset
   388
	int n;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   389
	XTextProperty name;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   390
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   391
	name.nitems = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   392
	c->name[0] = 0;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   393
	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
   394
	if(!name.nitems)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   395
		XGetWMName(dpy, c->win, &name);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   396
	if(!name.nitems)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   397
		return;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   398
	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
   399
		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
   400
	else {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   401
		if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
757
22dfaeb82491 made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 754
diff changeset
   402
		&& n > 0 && *list)
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   403
		{
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
   404
			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
   405
			XFreeStringList(list);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   406
		}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   407
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   408
	XFree(name.value);
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   409
}
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   410
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   411
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
   412
unmanage(Client *c) {
450
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 448
diff changeset
   413
	Client *nc;
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 448
diff changeset
   414
472
298be2d65d2e reviewed client.c
arg@mmvi
parents: 465
diff changeset
   415
	/* The server grab construct avoids race conditions. */
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   416
	XGrabServer(dpy);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
   417
	XSetErrorHandler(xerrordummy);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   418
	detach(c);
448
Anselm R. Garbe <arg@10kloc.org>
parents: 447
diff changeset
   419
	detachstack(c);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   420
	if(sel == c) {
450
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 448
diff changeset
   421
		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
   422
		focus(nc);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   423
	}
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   424
	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
   425
	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
   426
	free(c->tags);
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   427
	free(c);
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 77
diff changeset
   428
	XSync(dpy, False);
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
   429
	XSetErrorHandler(xerror);
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   430
	XUngrabServer(dpy);
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
   431
	arrange();
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   432
}
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   433
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   434
void
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   435
zoom(Arg *arg) {
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   436
	unsigned int n;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   437
	Client *c;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   438
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   439
	if(!sel)
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   440
		return;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   441
	if(sel->isfloat || (arrange == dofloat)) {
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   442
		togglemax(sel);
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   443
		return;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   444
	}
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   445
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   446
		n++;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   447
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   448
	if((c = sel) == nexttiled(clients))
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   449
		if(!(c = nexttiled(c->next)))
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   450
			return;
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   451
	detach(c);
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   452
	attach(c);
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   453
	focus(c);
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   454
	arrange();
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
   455
}