dwm-meillo

annotate client.c @ 5:e5018cae273f

added several other stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Mon, 10 Jul 2006 22:16:48 +0200
parents
children 49e2fc9fb94f
rev   line source
garbeam@5 1 /*
garbeam@5 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
garbeam@5 3 * See LICENSE file for license details.
garbeam@5 4 */
garbeam@5 5
garbeam@5 6 #include <string.h>
garbeam@5 7 #include <X11/Xatom.h>
garbeam@5 8
garbeam@5 9 #include "util.h"
garbeam@5 10 #include "wm.h"
garbeam@5 11
garbeam@5 12 static void
garbeam@5 13 update_client_name(Client *c)
garbeam@5 14 {
garbeam@5 15 XTextProperty name;
garbeam@5 16 int n;
garbeam@5 17 char **list = 0;
garbeam@5 18
garbeam@5 19 name.nitems = 0;
garbeam@5 20 c->name[0] = 0;
garbeam@5 21 XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]);
garbeam@5 22 if(!name.nitems)
garbeam@5 23 XGetWMName(dpy, c->win, &name);
garbeam@5 24 if(!name.nitems)
garbeam@5 25 return;
garbeam@5 26 if(name.encoding == XA_STRING)
garbeam@5 27 strncpy(c->name, (char *)name.value, sizeof(c->name));
garbeam@5 28 else {
garbeam@5 29 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
garbeam@5 30 && n > 0 && *list)
garbeam@5 31 {
garbeam@5 32 strncpy(c->name, *list, sizeof(c->name));
garbeam@5 33 XFreeStringList(list);
garbeam@5 34 }
garbeam@5 35 }
garbeam@5 36 XFree(name.value);
garbeam@5 37 }
garbeam@5 38
garbeam@5 39 Client *
garbeam@5 40 create_client(Window w, XWindowAttributes *wa)
garbeam@5 41 {
garbeam@5 42 Client *c;
garbeam@5 43 XSetWindowAttributes twa;
garbeam@5 44 long msize;
garbeam@5 45
garbeam@5 46 c = emallocz(sizeof(Client));
garbeam@5 47 c->win = w;
garbeam@5 48 c->r[RFloat].x = wa->x;
garbeam@5 49 c->r[RFloat].y = wa->y;
garbeam@5 50 c->r[RFloat].width = wa->width;
garbeam@5 51 c->r[RFloat].height = wa->height;
garbeam@5 52 c->border = wa->border_width;
garbeam@5 53 XSetWindowBorderWidth(dpy, c->win, 0);
garbeam@5 54 c->proto = win_proto(c->win);
garbeam@5 55 XGetTransientForHint(dpy, c->win, &c->trans);
garbeam@5 56 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
garbeam@5 57 c->size.flags = PSize;
garbeam@5 58 c->fixedsize =
garbeam@5 59 (c->size.flags & PMinSize && c->size.flags & PMaxSize
garbeam@5 60 && c->size.min_width == c->size.max_width
garbeam@5 61 && c->size.min_height == c->size.max_height);
garbeam@5 62 XAddToSaveSet(dpy, c->win);
garbeam@5 63 update_client_name(c);
garbeam@5 64 twa.override_redirect = 1;
garbeam@5 65 twa.background_pixmap = ParentRelative;
garbeam@5 66 twa.event_mask = ExposureMask;
garbeam@5 67
garbeam@5 68 c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y,
garbeam@5 69 c->r[RFloat].width, barrect.height, 0,
garbeam@5 70 DefaultDepth(dpy, screen), CopyFromParent,
garbeam@5 71 DefaultVisual(dpy, screen),
garbeam@5 72 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
garbeam@5 73 XFlush(dpy);
garbeam@5 74
garbeam@5 75 #if 0
garbeam@5 76 for(t=&client, i=0; *t; t=&(*t)->next, i++);
garbeam@5 77 c->next = *t; /* *t == nil */
garbeam@5 78 *t = c;
garbeam@5 79 #endif
garbeam@5 80 return c;
garbeam@5 81 }
garbeam@5 82
garbeam@5 83 void
garbeam@5 84 manage(Client *c)
garbeam@5 85 {
garbeam@5 86 XMapRaised(dpy, c->win);
garbeam@5 87 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
garbeam@5 88 XFlush(dpy);
garbeam@5 89 }