[hackers] [wmii] Allow alpha colors in the bar. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Mon, 19 Jul 2010 16:50:32 +0000 (UTC)

changeset: 2768:3c7a9658bc69
user: Kris Maglione <kris_AT_suckless.org>
date: Mon Jul 19 09:30:52 2010 -0400
files: cmd/wmii/bar.c cmd/wmii/fns.h cmd/wmii/main.c cmd/wmii/root.c lib/libstuff/x11/initdisplay.c
description:
Allow alpha colors in the bar.

diff -r 5b510b0c693e -r 3c7a9658bc69 cmd/wmii/bar.c
--- a/cmd/wmii/bar.c Mon Jul 19 09:30:11 2010 -0400
+++ b/cmd/wmii/bar.c Mon Jul 19 09:30:52 2010 -0400
@@ -11,16 +11,11 @@
                 for((b)=(s)->bar[__bar_n]; (b); (b)=(b)->next)
 
 void
-bar_init(WMScreen *s, bool force) {
+bar_init(WMScreen *s) {
         WinAttr wa;
 
- if(s->barwin)
- if(force)
- destroywindow(s->barwin);
- else {
- bar_resize(s);
- return;
- }
+ if(s->barwin && (s->barwin->depth == 32) == s->barwin_rgba)
+ return;
 
         s->brect = s->r;
         s->brect.min.y = s->brect.max.y - labelh(def.font);
@@ -182,12 +177,12 @@
                 width += tw * shrink;
         }
 
+ if(s->bar[BRight])
+ s->bar[BRight]->r.max.x += Dx(s->brect) - width;
         tb = nil;
         foreach_bar(s, b) {
                 if(tb)
                         b->r = rectaddpt(b->r, Pt(tb->r.max.x, 0));
- if(b == s->bar[BRight])
- b->r.max.x += Dx(s->brect) - width;
                 tb = b;
         }
 
@@ -206,7 +201,7 @@
         }
 
         if(s->barwin_rgba != (s->barwin->depth == 32))
- bar_init(s, true);
+ bar_init(s);
         copyimage(s->barwin, r, ibuf, ZP);
 }
 
diff -r 5b510b0c693e -r 3c7a9658bc69 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Mon Jul 19 09:30:11 2010 -0400
+++ b/cmd/wmii/fns.h Mon Jul 19 09:30:52 2010 -0400
@@ -68,7 +68,7 @@
 void bar_destroy(Bar**, Bar*);
 void bar_draw(WMScreen*);
 Bar* bar_find(Bar*, const char*);
-void bar_init(WMScreen*, bool);
+void bar_init(WMScreen*);
 void bar_resize(WMScreen*);
 void bar_sety(WMScreen*, int);
 void bar_setbounds(WMScreen*, int, int);
diff -r 5b510b0c693e -r 3c7a9658bc69 cmd/wmii/main.c
--- a/cmd/wmii/main.c Mon Jul 19 09:30:11 2010 -0400
+++ b/cmd/wmii/main.c Mon Jul 19 09:30:52 2010 -0400
@@ -210,7 +210,7 @@
                         for(v=view; v; v=v->next)
                                 view_init(v, i);
                 def.snap = Dy(screen->r) / 63;
- bar_init(screens[i], false);
+ bar_init(screens[i]);
         }
         screen = screens[0];
         if(selview)
diff -r 5b510b0c693e -r 3c7a9658bc69 cmd/wmii/root.c
--- a/cmd/wmii/root.c Mon Jul 19 09:30:11 2010 -0400
+++ b/cmd/wmii/root.c Mon Jul 19 09:30:52 2010 -0400
@@ -10,16 +10,15 @@
 root_init(void) {
         WinAttr wa;
 
+ wa.cursor = cursor[CurNormal];
         wa.event_mask = EnterWindowMask
                       | FocusChangeMask
                       | LeaveWindowMask
                       | PointerMotionMask
                       | SubstructureNotifyMask
                       | SubstructureRedirectMask;
- wa.cursor = cursor[CurNormal];
- setwinattr(&scr.root, &wa,
- CWEventMask
- | CWCursor);
+ setwinattr(&scr.root, &wa, CWCursor
+ | CWEventMask);
         sethandler(&scr.root, &handlers);
 }
 
@@ -50,16 +49,8 @@
 mapreq_event(Window *w, void *aux, XMapRequestEvent *e) {
         XWindowAttributes wa;
 
- if(!XGetWindowAttributes(display, e->window, &wa))
+ if(!XGetWindowAttributes(display, e->window, &wa) || wa.override_redirect)
                 return false;
- if(wa.override_redirect) {
- /* Do I really want these? */
- /* Probably not.
- XSelectInput(display, e->window,
- PropertyChangeMask | StructureNotifyMask);
- */
- return false;
- }
         if(!win2client(e->window))
                 client_create(e->window, &wa);
         return false;
diff -r 5b510b0c693e -r 3c7a9658bc69 lib/libstuff/x11/initdisplay.c
--- a/lib/libstuff/x11/initdisplay.c Mon Jul 19 09:30:11 2010 -0400
+++ b/lib/libstuff/x11/initdisplay.c Mon Jul 19 09:30:52 2010 -0400
@@ -22,7 +22,7 @@
 Lfmt(Fmt *f) {
         Color c;
 
-#define fix(c, m) (ushort)((c.alpha ? ((ulong)c.m * 0xffff) / c.alpha : 0) >> 8)
+#define fix(c, m) (ushort)((c.alpha ? (ulong)c.m * 0xffff / c.alpha : 0) >> 8)
         c = va_arg(f->args, Color);
         return fmtprint(f, c.alpha < 0xff00 ? "rgba:%02uhx/%02uhx/%02uhx/%02uhx"
                                             : "#%02uhx%02uhx%02uhx",
Received on Mon Jul 19 2010 - 18:50:32 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 19 2010 - 19:00:08 CEST