client.c
author Anselm R. Garbe <garbeam@gmail.com>
Sat, 18 Aug 2007 14:20:56 +0200
changeset 964 777a9d9ce70b
parent 963 7416c26a14db
child 966 3ad7903c9e83
permissions -rw-r--r--
hmm I doubt the usefulness of storing this information...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
910
c13cb8c6b7a5 referred to LICENSE file
Anselm R. Garbe <arg@suckless.org>
parents: 909
diff changeset
     1
/* See LICENSE file for copyright and license details. */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
     2
#include "dwm.h"
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
     3
#include <stdlib.h>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     4
#include <string.h>
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     5
#include <X11/Xatom.h>
32
082c75b937b5 removed unnecessary crap
Anselm R. Garbe <garbeam@wmii.de>
parents: 31
diff changeset
     6
#include <X11/Xutil.h>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     7
730
8997e28553a8 made some changes more concistent
Anselm R. Garbe <arg@suckless.org>
parents: 725
diff changeset
     8
/* static */
50
148f25ed0ad7 several other additions/fixes, dwm is quite usable already
Anselm R. Garbe <garbeam@wmii.de>
parents: 49
diff changeset
     9
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
    10
static char prop[128];
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
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;
781
dde5852bf151 some more code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 779
diff changeset
    21
776
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    22
	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
    23
	*tc = c->snext;
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
be103ae46dbc renamed view.c into screen.c
Anselm R. Garbe <arg@suckless.org>
parents: 775
diff changeset
    26
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
    27
grabbuttons(Client *c, Bool focused) {
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    28
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    29
452
026aba558fdf added some comments
Anselm R. Garbe <arg@10kloc.org>
parents: 450
diff changeset
    30
	if(focused) {
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    31
		XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    32
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    33
		XGrabButton(dpy, Button1, MODKEY | LockMask, 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, Button1, MODKEY | numlockmask, 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, Button1, MODKEY | numlockmask | LockMask, 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
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    40
		XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    41
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    42
		XGrabButton(dpy, Button2, MODKEY | LockMask, 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, Button2, MODKEY | numlockmask, 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, Button2, MODKEY | numlockmask | LockMask, 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
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    49
		XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    50
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    51
		XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    52
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    53
		XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    54
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    55
		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
    56
				GrabModeAsync, GrabModeSync, None, None);
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    57
	}
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    58
	else
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    59
		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
    60
				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
    61
}
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
    62
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    63
static Bool
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    64
isprotodel(Client *c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    65
	int i, n;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    66
	Atom *protocols;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    67
	Bool ret = False;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    68
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    69
	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    70
		for(i = 0; !ret && i < n; i++)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    71
			if(protocols[i] == wmatom[WMDelete])
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    72
				ret = True;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    73
		XFree(protocols);
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    74
	}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    75
	return ret;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    76
}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    77
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
    78
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
    79
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
    80
	long data[] = {state, None};
781
dde5852bf151 some more code polishing
Anselm R. Garbe <arg@suckless.org>
parents: 779
diff changeset
    81
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
    82
	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
    83
			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
    84
}
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
    85
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    86
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
    87
xerrordummy(Display *dsply, XErrorEvent *ee) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    88
	return 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
    89
}
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    90
730
8997e28553a8 made some changes more concistent
Anselm R. Garbe <arg@suckless.org>
parents: 725
diff changeset
    91
/* extern */
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    92
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
    93
void
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    94
attach(Client *c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    95
	if(clients)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    96
		clients->prev = c;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    97
	c->next = clients;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    98
	clients = c;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
    99
}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   100
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   101
void
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   102
ban(Client *c) {
927
60d5a92ce85c changed ban/unban implementation to not move the windows anymore, but map/unmap them instead - PLEASE TEST THIS
Anselm R. Garbe <garbeam@gmail.com>
parents: 915
diff changeset
   103
	if(c->isbanned)
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   104
		return;
927
60d5a92ce85c changed ban/unban implementation to not move the windows anymore, but map/unmap them instead - PLEASE TEST THIS
Anselm R. Garbe <garbeam@gmail.com>
parents: 915
diff changeset
   105
	XUnmapWindow(dpy, c->win);
60d5a92ce85c changed ban/unban implementation to not move the windows anymore, but map/unmap them instead - PLEASE TEST THIS
Anselm R. Garbe <garbeam@gmail.com>
parents: 915
diff changeset
   106
	setclientstate(c, IconicState);
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   107
	c->isbanned = True;
927
60d5a92ce85c changed ban/unban implementation to not move the windows anymore, but map/unmap them instead - PLEASE TEST THIS
Anselm R. Garbe <garbeam@gmail.com>
parents: 915
diff changeset
   108
	c->unmapped++;
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   109
}
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   110
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   111
void
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   112
configure(Client *c) {
752
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   113
	XConfigureEvent ce;
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   114
752
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   115
	ce.type = ConfigureNotify;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   116
	ce.display = dpy;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   117
	ce.event = c->win;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   118
	ce.window = c->win;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   119
	ce.x = c->x;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   120
	ce.y = c->y;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   121
	ce.width = c->w;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   122
	ce.height = c->h;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   123
	ce.border_width = c->border;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   124
	ce.above = None;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   125
	ce.override_redirect = False;
9fe042b02e18 simplified configurerequest
Anselm R. Garbe <arg@suckless.org>
parents: 734
diff changeset
   126
	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
   127
}
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   128
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 479
diff changeset
   129
void
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   130
detach(Client *c) {
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   131
	if(c->prev)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   132
		c->prev->next = c->next;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   133
	if(c->next)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   134
		c->next->prev = c->prev;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   135
	if(c == clients)
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   136
		clients = c->next;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   137
	c->next = c->prev = NULL;
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   138
}
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   139
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   140
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
   141
focus(Client *c) {
927
60d5a92ce85c changed ban/unban implementation to not move the windows anymore, but map/unmap them instead - PLEASE TEST THIS
Anselm R. Garbe <garbeam@gmail.com>
parents: 915
diff changeset
   142
	if((!c && selscreen) || (c && !isvisible(c)))
904
2dfd50e4cfde applied anydot's 3 minor patches, thank you anydot
Anselm R. Garbe <arg@suckless.org>
parents: 903
diff changeset
   143
		for(c = stack; c && !isvisible(c); c = c->snext);
712
b288b57d81f8 this version should also work with cornercases (like unmanage during !issel, etc.)
Anselm R. Garbe <arg@suckless.org>
parents: 711
diff changeset
   144
	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
   145
		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
   146
		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
   147
	}
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   148
	if(c) {
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   149
		detachstack(c);
771
05946fa53085 added some new convenience functions
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
   150
		attachstack(c);
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   151
		grabbuttons(c, True);
714
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   152
	}
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   153
	sel = c;
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   154
	drawstatus();
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 715
diff changeset
   155
	if(!selscreen)
714
7034ee0f48d6 small changes
Anselm R. Garbe <arg@suckless.org>
parents: 713
diff changeset
   156
		return;
715
5b3e4cdb6674 implemented Sanders remarks
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
   157
	if(c) {
711
b40134b93de3 I think this is the best solution of multihead support
Anselm R. Garbe <arg@suckless.org>
parents: 709
diff changeset
   158
		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
   159
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   160
	}
712
b288b57d81f8 this version should also work with cornercases (like unmanage during !issel, etc.)
Anselm R. Garbe <arg@suckless.org>
parents: 711
diff changeset
   161
	else
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
   162
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   163
}
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
   164
775
920b51271fc8 renamed manage.c to view.c
Anselm R. Garbe <arg@suckless.org>
parents: 772
diff changeset
   165
void
823
fb5cbf0bd923 replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents: 813
diff changeset
   166
killclient(const char *arg) {
848
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   167
	XEvent ev;
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   168
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   169
	if(!sel)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   170
		return;
848
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   171
	if(isprotodel(sel)) {
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   172
		ev.type = ClientMessage;
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   173
		ev.xclient.window = sel->win;
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   174
		ev.xclient.message_type = wmatom[WMProtocols];
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   175
		ev.xclient.format = 32;
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   176
		ev.xclient.data.l[0] = wmatom[WMDelete];
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   177
		ev.xclient.data.l[1] = CurrentTime;
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   178
		XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
944739ec944a removed sendevent
Anselm R. Garbe <arg@suckless.org>
parents: 837
diff changeset
   179
	}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   180
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   181
		XKillClient(dpy, sel->win);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   182
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   183
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   184
Bool
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   185
loadprops(Client *c) {
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   186
	unsigned int i;
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   187
	Bool result = False;
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   188
	XTextProperty name;
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   189
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   190
	/* check if window has set a property */
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   191
	name.nitems = 0;
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   192
	XGetTextProperty(dpy, c->win, &name, dwmprops);
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   193
	if(name.nitems && name.encoding == XA_STRING) {
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   194
		strncpy(prop, (char *)name.value, sizeof prop - 1);
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   195
		prop[sizeof prop - 1] = '\0';
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   196
		XFree(name.value);
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   197
		for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   198
			if((c->tags[i] = prop[i] == '1'))
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   199
				result = True;
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   200
		if(i < sizeof prop - 1 && prop[i] != '\0')
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   201
			c->isfloating = prop[i] == '1';
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   202
	}
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   203
	return result;
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   204
}
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   205
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   206
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
   207
manage(Window w, XWindowAttributes *wa) {
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   208
	unsigned int i;
855
1a5538340315 make also transients floating when we do not know the main window
Anselm R. Garbe <arg@suckless.org>
parents: 852
diff changeset
   209
	Client *c, *t = NULL;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   210
	Window trans;
855
1a5538340315 make also transients floating when we do not know the main window
Anselm R. Garbe <arg@suckless.org>
parents: 852
diff changeset
   211
	Status rettrans;
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
   212
	XWindowChanges wc;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   213
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   214
	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
   215
	c->tags = emallocz(ntags * sizeof(Bool));
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
   216
	c->win = w;
687
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   217
	c->x = wa->x;
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   218
	c->y = wa->y;
a76799907854 removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents: 647
diff changeset
   219
	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
   220
	c->h = wa->height;
865
018c38468422 fixed the border issue for mplayer, ff is definately broken when using F11 (fullscreen mode)
Anselm R. Garbe <arg@suckless.org>
parents: 864
diff changeset
   221
	c->oldborder = wa->border_width;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   222
	if(c->w == sw && c->h == sh) {
517
2b4bd49fc155 applied ality's hardcode-0 patches
Anselm R. Garbe <arg@10kloc.org>
parents: 502
diff changeset
   223
		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
   224
		c->y = sy;
865
018c38468422 fixed the border issue for mplayer, ff is definately broken when using F11 (fullscreen mode)
Anselm R. Garbe <arg@suckless.org>
parents: 864
diff changeset
   225
		c->border = wa->border_width;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   226
	}
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   227
	else {
718
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   228
		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
   229
			c->x = wax + waw - c->w - 2 * c->border;
09452e717bfd applied offscreen appearance hotfix
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
   230
		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
   231
			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
   232
		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
   233
			c->x = wax;
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   234
		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
   235
			c->y = way;
865
018c38468422 fixed the border issue for mplayer, ff is definately broken when using F11 (fullscreen mode)
Anselm R. Garbe <arg@suckless.org>
parents: 864
diff changeset
   236
		c->border = BORDERPX;
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 690
diff changeset
   237
	}
865
018c38468422 fixed the border issue for mplayer, ff is definately broken when using F11 (fullscreen mode)
Anselm R. Garbe <arg@suckless.org>
parents: 864
diff changeset
   238
	wc.border_width = c->border;
018c38468422 fixed the border issue for mplayer, ff is definately broken when using F11 (fullscreen mode)
Anselm R. Garbe <arg@suckless.org>
parents: 864
diff changeset
   239
	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
018c38468422 fixed the border issue for mplayer, ff is definately broken when using F11 (fullscreen mode)
Anselm R. Garbe <arg@suckless.org>
parents: 864
diff changeset
   240
	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
018c38468422 fixed the border issue for mplayer, ff is definately broken when using F11 (fullscreen mode)
Anselm R. Garbe <arg@suckless.org>
parents: 864
diff changeset
   241
	configure(c); /* propagates border_width, if size doesn't change */
708
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);
372
a9b4077ec058 applied sanders focus_ patches
Anselm R. Garbe <arg@10kloc.org>
parents: 342
diff changeset
   245
	grabbuttons(c, False);
500
d5ad819f2a66 fixing the settags issue, preparing 1.7.1
Anselm R. Garbe <arg@10kloc.org>
parents: 491
diff changeset
   246
	updatetitle(c);
855
1a5538340315 make also transients floating when we do not know the main window
Anselm R. Garbe <arg@suckless.org>
parents: 852
diff changeset
   247
	if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
1a5538340315 make also transients floating when we do not know the main window
Anselm R. Garbe <arg@suckless.org>
parents: 852
diff changeset
   248
		for(t = clients; t && t->win != trans; t = t->next);
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   249
	if(t)
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   250
		for(i = 0; i < ntags; i++)
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   251
			c->tags[i] = t->tags[i];
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   252
	if(!loadprops(c))
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   253
		applyrules(c);
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   254
	if(!c->isfloating)
855
1a5538340315 make also transients floating when we do not know the main window
Anselm R. Garbe <arg@suckless.org>
parents: 852
diff changeset
   255
		c->isfloating = (rettrans == Success) || c->isfixed;
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   256
	saveprops(c);
771
05946fa53085 added some new convenience functions
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
   257
	attach(c);
05946fa53085 added some new convenience functions
Anselm R. Garbe <arg@suckless.org>
parents: 768
diff changeset
   258
	attachstack(c);
930
33e5eecb3311 changed the fix of yesterday, the resize should only be necessary at manage() time, not on any unban()
Anselm R. Garbe <garbeam@gmail.com>
parents: 929
diff changeset
   259
	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
957
e61ca30d9474 fixed the issue observed by various people, that clients appeared on empty tags
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   260
	ban(c);
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 945
diff changeset
   261
	arrange();
94
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   262
}
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   263
6efe82c775c9 pop on heretag
Anselm R. Garbe <garbeam@wmii.de>
parents: 93
diff changeset
   264
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
   265
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
945
89ea2acd2646 made resize more precise
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   266
	double dx, dy, max, min, ratio;
89ea2acd2646 made resize more precise
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   267
	XWindowChanges wc; 
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 945
diff changeset
   268
129
c478383db7c9 applied sanders no_sizehints for tiled mode patch (thx!)
arg@10ksloc.org
parents: 128
diff changeset
   269
	if(sizehints) {
945
89ea2acd2646 made resize more precise
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   270
		if(c->minay > 0 && c->maxay > 0 && (h - c->baseh) > 0 && (w - c->basew) > 0) {
89ea2acd2646 made resize more precise
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   271
			dx = (double)(w - c->basew);
89ea2acd2646 made resize more precise
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   272
			dy = (double)(h - c->baseh);
89ea2acd2646 made resize more precise
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   273
			min = (double)(c->minax) / (double)(c->minay);
89ea2acd2646 made resize more precise
Anselm R. Garbe <garbeam@gmail.com>
parents: 941
diff changeset
   274
			max = (double)(c->maxax) / (double)(c->maxay);
849
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   275
			ratio = dx / dy;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   276
			if(max > 0 && min > 0 && ratio > 0) {
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   277
				if(ratio < min) {
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   278
					dy = (dx * min + dy) / (min * min + 1);
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   279
					dx = dy * min;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   280
					w = (int)dx + c->basew;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   281
					h = (int)dy + c->baseh;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   282
				}
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   283
				else if(ratio > max) {
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   284
					dy = (dx * min + dy) / (max * max + 1);
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   285
					dx = dy * min;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   286
					w = (int)dx + c->basew;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   287
					h = (int)dy + c->baseh;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   288
				}
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   289
			}
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   290
		}
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
   291
		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
   292
			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
   293
		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
   294
			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
   295
		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
   296
			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
   297
		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
   298
			h = c->maxh;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   299
		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
   300
			w -= (w - c->basew) % c->incw;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   301
		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
   302
			h -= (h - c->baseh) % c->inch;
52
d18f6dd0cf23 fixed several things, nearly feature complete
Anselm R. Garbe <garbeam@wmii.de>
parents: 51
diff changeset
   303
	}
952
4f66942cc63b fix of resize (thanks Sander for the hint!)
Anselm R. Garbe <garbeam@gmail.com>
parents: 946
diff changeset
   304
	if(w <= 0 || h <= 0)
4f66942cc63b fix of resize (thanks Sander for the hint!)
Anselm R. Garbe <garbeam@gmail.com>
parents: 946
diff changeset
   305
		return;
465
590575d080fe offscreen client appearance fixes
arg@mmvi
parents: 464
diff changeset
   306
	/* 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
   307
	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
   308
		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
   309
	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
   310
		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
   311
	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
   312
		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
   313
	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
   314
		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
   315
	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
   316
		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
   317
		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
   318
		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
   319
		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
   320
		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
   321
		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
   322
		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
   323
		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
   324
	}
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   325
}
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
   326
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   327
void
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   328
saveprops(Client *c) {
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   329
	unsigned int i;
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   330
964
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   331
	for(i = 0; i < ntags && i < sizeof prop - 1; i++)
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   332
		prop[i] = c->tags[i] ? '1' : '0';
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   333
	if(i < sizeof prop - 1)
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   334
		prop[i++] = c->isfloating ? '1' : '0';
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   335
	prop[i] = '\0';
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   336
	XChangeProperty(dpy, c->win, dwmprops, XA_STRING, 8,
777a9d9ce70b hmm I doubt the usefulness of storing this information...
Anselm R. Garbe <garbeam@gmail.com>
parents: 963
diff changeset
   337
			PropModeReplace, (unsigned char *)prop, i);
963
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   338
}
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   339
7416c26a14db cleaned up settags-handling
Anselm R. Garbe <garbeam@gmail.com>
parents: 957
diff changeset
   340
void
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   341
unban(Client *c) {
927
60d5a92ce85c changed ban/unban implementation to not move the windows anymore, but map/unmap them instead - PLEASE TEST THIS
Anselm R. Garbe <garbeam@gmail.com>
parents: 915
diff changeset
   342
	if(!c->isbanned)
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   343
		return;
927
60d5a92ce85c changed ban/unban implementation to not move the windows anymore, but map/unmap them instead - PLEASE TEST THIS
Anselm R. Garbe <garbeam@gmail.com>
parents: 915
diff changeset
   344
	XMapWindow(dpy, c->win);
60d5a92ce85c changed ban/unban implementation to not move the windows anymore, but map/unmap them instead - PLEASE TEST THIS
Anselm R. Garbe <garbeam@gmail.com>
parents: 915
diff changeset
   345
	setclientstate(c, NormalState);
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   346
	c->isbanned = False;
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   347
}
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   348
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   349
void
953
Anselm R. Garbe <garbeam@gmail.com>
parents: 952
diff changeset
   350
unmanage(Client *c, long state) {
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   351
	XWindowChanges wc;
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   352
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   353
	wc.border_width = c->oldborder;
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   354
	/* The server grab construct avoids race conditions. */
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   355
	XGrabServer(dpy);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   356
	XSetErrorHandler(xerrordummy);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   357
	XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   358
	detach(c);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   359
	detachstack(c);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   360
	if(sel == c)
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   361
		focus(NULL);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   362
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
953
Anselm R. Garbe <garbeam@gmail.com>
parents: 952
diff changeset
   363
	setclientstate(c, state);
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   364
	free(c->tags);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   365
	free(c);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   366
	XSync(dpy, False);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   367
	XSetErrorHandler(xerror);
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   368
	XUngrabServer(dpy);
957
e61ca30d9474 fixed the issue observed by various people, that clients appeared on empty tags
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   369
	if(state != NormalState)
e61ca30d9474 fixed the issue observed by various people, that clients appeared on empty tags
Anselm R. Garbe <garbeam@gmail.com>
parents: 953
diff changeset
   370
		arrange();
915
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   371
}
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   372
67104d329f06 added an creatnotify event handler
Anselm R. Garbe <arg@suckless.org>
parents: 914
diff changeset
   373
void
639
226ef912c093 renamed updatesize into updatesizehints (thx to Sander for this hint)
arg@mig29
parents: 631
diff changeset
   374
updatesizehints(Client *c) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   375
	long msize;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   376
	XSizeHints size;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   377
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   378
	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
   379
		size.flags = PSize;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   380
	c->flags = size.flags;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   381
	if(c->flags & PBaseSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   382
		c->basew = size.base_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   383
		c->baseh = size.base_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   384
	}
849
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   385
	else if(c->flags & PMinSize) {
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   386
		c->basew = size.min_width;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   387
		c->baseh = size.min_height;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   388
	}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   389
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   390
		c->basew = c->baseh = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   391
	if(c->flags & PResizeInc) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   392
		c->incw = size.width_inc;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   393
		c->inch = size.height_inc;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   394
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   395
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   396
		c->incw = c->inch = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   397
	if(c->flags & PMaxSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   398
		c->maxw = size.max_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   399
		c->maxh = size.max_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   400
	}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   401
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   402
		c->maxw = c->maxh = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   403
	if(c->flags & PMinSize) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   404
		c->minw = size.min_width;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   405
		c->minh = size.min_height;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   406
	}
849
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   407
	else if(c->flags & PBaseSize) {
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   408
		c->minw = size.base_width;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   409
		c->minh = size.base_height;
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   410
	}
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   411
	else
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   412
		c->minw = c->minh = 0;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   413
	if(c->flags & PAspect) {
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   414
		c->minax = size.min_aspect.x;
849
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   415
		c->maxax = size.max_aspect.x;
731
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   416
		c->minay = size.min_aspect.y;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   417
		c->maxay = size.max_aspect.y;
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   418
	}
29c9b557ed95 implemented aspect ratio support of windows
Anselm R. Garbe <arg@suckless.org>
parents: 730
diff changeset
   419
	else
849
4f1ff9e068d3 some changes to updatesizehints, I don't change the aspect ratio algorithm now - I can't think, it is a mess
Anselm R. Garbe <arg@suckless.org>
parents: 848
diff changeset
   420
		c->minax = c->maxax = c->minay = 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
   421
	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
   422
			&& 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
   423
}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   424
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   425
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
   426
updatetitle(Client *c) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   427
	char **list = NULL;
377
b1159a638d0a removed crappy variables
Anselm R. Garbe <arg@10kloc.org>
parents: 372
diff changeset
   428
	int n;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 115
diff changeset
   429
	XTextProperty name;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   430
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   431
	name.nitems = 0;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   432
	c->name[0] = 0;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
   433
	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
   434
	if(!name.nitems)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   435
		XGetWMName(dpy, c->win, &name);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   436
	if(!name.nitems)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   437
		return;
874
e42bdee29c92 small fix of fix
Anselm R. Garbe <arg@suckless.org>
parents: 873
diff changeset
   438
	if(name.encoding == XA_STRING)
873
e1af8e712b35 fixed a potential security flaw
Anselm R. Garbe <arg@suckless.org>
parents: 865
diff changeset
   439
		strncpy(c->name, (char *)name.value, sizeof c->name - 1);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   440
	else {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   441
		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
   442
		&& n > 0 && *list)
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   443
		{
873
e1af8e712b35 fixed a potential security flaw
Anselm R. Garbe <arg@suckless.org>
parents: 865
diff changeset
   444
			strncpy(c->name, *list, sizeof c->name - 1);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   445
			XFreeStringList(list);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   446
		}
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   447
	}
873
e1af8e712b35 fixed a potential security flaw
Anselm R. Garbe <arg@suckless.org>
parents: 865
diff changeset
   448
	c->name[sizeof c->name - 1] = '\0';
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
   449
	XFree(name.value);
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
   450
}