comparison client.c @ 20:4560e0882c1d

made code more readable
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 22:49:09 +0200
parents b5510d0c6d43
children 3ef108a5ca0a
comparison
equal deleted inserted replaced
19:b5510d0c6d43 20:4560e0882c1d
42 else 42 else
43 draw_client(c); 43 draw_client(c);
44 } 44 }
45 45
46 void 46 void
47 update_size(Client *c)
48 {
49 XSizeHints size;
50 long msize;
51 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
52 size.flags = PSize;
53 c->flags = size.flags;
54 c->basew = size.base_width;
55 c->baseh = size.base_height;
56 c->incw = size.width_inc;
57 c->inch = size.height_inc;
58 c->maxw = size.max_width;
59 c->maxh = size.max_height;
60 c->minw = size.min_width;
61 c->minh = size.min_height;
62 }
63
64 void
47 focus(Client *c) 65 focus(Client *c)
48 { 66 {
49 Client **l; 67 Client **l;
50 for(l=&stack; *l && *l != c; l=&(*l)->snext); 68 for(l=&stack; *l && *l != c; l=&(*l)->snext);
51 eassert(*l == c); 69 eassert(*l == c);
60 void 78 void
61 manage(Window w, XWindowAttributes *wa) 79 manage(Window w, XWindowAttributes *wa)
62 { 80 {
63 Client *c, **l; 81 Client *c, **l;
64 XSetWindowAttributes twa; 82 XSetWindowAttributes twa;
65 long msize;
66 83
67 c = emallocz(sizeof(Client)); 84 c = emallocz(sizeof(Client));
68 c->win = w; 85 c->win = w;
69 c->r[RFloat].x = wa->x; 86 c->x = wa->x;
70 c->r[RFloat].y = wa->y; 87 c->y = wa->y;
71 c->r[RFloat].width = wa->width; 88 c->w = wa->width;
72 c->r[RFloat].height = wa->height; 89 c->h = wa->height;
90 update_size(c);
73 XSetWindowBorderWidth(dpy, c->win, 1); 91 XSetWindowBorderWidth(dpy, c->win, 1);
74 XSelectInput(dpy, c->win, CLIENT_MASK); 92 XSelectInput(dpy, c->win, CLIENT_MASK);
75 XGetTransientForHint(dpy, c->win, &c->trans); 93 XGetTransientForHint(dpy, c->win, &c->trans);
76 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
77 c->size.flags = PSize;
78 c->fixedsize =
79 (c->size.flags & PMinSize && c->size.flags & PMaxSize
80 && c->size.min_width == c->size.max_width
81 && c->size.min_height == c->size.max_height);
82 update_name(c); 94 update_name(c);
83 twa.override_redirect = 1; 95 twa.override_redirect = 1;
84 twa.background_pixmap = ParentRelative; 96 twa.background_pixmap = ParentRelative;
85 twa.event_mask = ExposureMask; 97 twa.event_mask = ExposureMask;
86 98
87 c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y, 99 c->title = XCreateWindow(dpy, root, c->x, c->y, c->w, barrect.height,
88 c->r[RFloat].width, barrect.height, 0, 100 0, DefaultDepth(dpy, screen), CopyFromParent,
89 DefaultDepth(dpy, screen), CopyFromParent,
90 DefaultVisual(dpy, screen), 101 DefaultVisual(dpy, screen),
91 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 102 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
92 103
93 for(l=&clients; *l; l=&(*l)->next); 104 for(l=&clients; *l; l=&(*l)->next);
94 c->next = *l; /* *l == nil */ 105 c->next = *l; /* *l == nil */
108 void 119 void
109 resize(Client *c) 120 resize(Client *c)
110 { 121 {
111 XConfigureEvent e; 122 XConfigureEvent e;
112 123
113 XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y, 124 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
114 c->r[RFloat].width, c->r[RFloat].height);
115 e.type = ConfigureNotify; 125 e.type = ConfigureNotify;
116 e.event = c->win; 126 e.event = c->win;
117 e.window = c->win; 127 e.window = c->win;
118 e.x = c->r[RFloat].x; 128 e.x = c->x;
119 e.y = c->r[RFloat].y; 129 e.y = c->y;
120 e.width = c->r[RFloat].width; 130 e.width = c->w;
121 e.height = c->r[RFloat].height; 131 e.height = c->h;
122 e.border_width = 0; 132 e.border_width = 0;
123 e.above = None; 133 e.above = None;
124 e.override_redirect = False; 134 e.override_redirect = False;
125 XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask); 135 XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
126 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e); 136 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);