client.c
changeset 771 05946fa53085
parent 768 b1dbe65d3e84
child 772 a1dd3d977e25
equal deleted inserted replaced
770:5280cbb5bbd4 771:05946fa53085
     8 #include <X11/Xutil.h>
     8 #include <X11/Xutil.h>
     9 
     9 
    10 /* static */
    10 /* static */
    11 
    11 
    12 static void
    12 static void
    13 detachstack(Client *c) {
       
    14 	Client **tc;
       
    15 	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
       
    16 	*tc = c->snext;
       
    17 }
       
    18 
       
    19 static void
       
    20 grabbuttons(Client *c, Bool focused) {
    13 grabbuttons(Client *c, Bool focused) {
    21 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
    14 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
    22 
    15 
    23 	if(focused) {
    16 	if(focused) {
    24 		XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
    17 		XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
    64 xerrordummy(Display *dsply, XErrorEvent *ee) {
    57 xerrordummy(Display *dsply, XErrorEvent *ee) {
    65 	return 0;
    58 	return 0;
    66 }
    59 }
    67 
    60 
    68 /* extern */
    61 /* extern */
       
    62 
       
    63 void
       
    64 attach(Client *c) {
       
    65 	if(clients)
       
    66 		clients->prev = c;
       
    67 	c->next = clients;
       
    68 	clients = c;
       
    69 }
       
    70 
       
    71 void
       
    72 attachstack(Client *c) {
       
    73 	c->snext = stack;
       
    74 	stack = c;
       
    75 }
    69 
    76 
    70 void
    77 void
    71 configure(Client *c) {
    78 configure(Client *c) {
    72 	XConfigureEvent ce;
    79 	XConfigureEvent ce;
    73 
    80 
    84 	ce.override_redirect = False;
    91 	ce.override_redirect = False;
    85 	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
    92 	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
    86 }
    93 }
    87 
    94 
    88 void
    95 void
       
    96 detach(Client *c) {
       
    97 	if(c->prev)
       
    98 		c->prev->next = c->next;
       
    99 	if(c->next)
       
   100 		c->next->prev = c->prev;
       
   101 	if(c == clients)
       
   102 		clients = c->next;
       
   103 	c->next = c->prev = NULL;
       
   104 }
       
   105 
       
   106 void
       
   107 detachstack(Client *c) {
       
   108 	Client **tc;
       
   109 	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
       
   110 	*tc = c->snext;
       
   111 }
       
   112 
       
   113 void
    89 focus(Client *c) {
   114 focus(Client *c) {
    90 	if(c && !isvisible(c))
   115 	if(c && !isvisible(c))
    91 		return;
   116 		return;
    92 	if(sel && sel != c) {
   117 	if(sel && sel != c) {
    93 		grabbuttons(sel, False);
   118 		grabbuttons(sel, False);
    94 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
   119 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
    95 	}
   120 	}
    96 	if(c) {
   121 	if(c) {
    97 		detachstack(c);
   122 		detachstack(c);
    98 		c->snext = stack;
   123 		attachstack(c);
    99 		stack = c;
       
   100 		grabbuttons(c, True);
   124 		grabbuttons(c, True);
   101 	}
   125 	}
   102 	sel = c;
   126 	sel = c;
   103 	drawstatus();
   127 	drawstatus();
   104 	if(!selscreen)
   128 	if(!selscreen)
   187 	updatetitle(c);
   211 	updatetitle(c);
   188 	t = getclient(trans);
   212 	t = getclient(trans);
   189 	settags(c, t);
   213 	settags(c, t);
   190 	if(!c->isfloat)
   214 	if(!c->isfloat)
   191 		c->isfloat = (t != 0) || c->isfixed;
   215 		c->isfloat = (t != 0) || c->isfixed;
   192 	if(clients)
   216 	attach(c);
   193 		clients->prev = c;
   217 	attachstack(c);
   194 	c->next = clients;
       
   195 	c->snext = stack;
       
   196 	stack = clients = c;
       
   197 	c->isbanned = True;
   218 	c->isbanned = True;
   198 	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
   219 	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
   199 	XMapWindow(dpy, c->win);
   220 	XMapWindow(dpy, c->win);
   200 	setclientstate(c, NormalState);
   221 	setclientstate(c, NormalState);
   201 	if(isvisible(c))
   222 	if(isvisible(c))