From 7c77a4b5ae8bc596c5e3b7d0497ce1420e67311a Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Wed, 12 Nov 2008 18:55:27 +0100 Subject: [PATCH] frame: Fix window border shadow, will be improved with the configuration file. --- src/frame.c | 33 ++++++++++++++++++++++++--------- src/layout.c | 11 +---------- src/util.c | 17 +++++++++++++++++ src/wmfs.h | 6 ++++-- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/frame.c b/src/frame.c index d21f5fc..42ef6ba 100644 --- a/src/frame.c +++ b/src/frame.c @@ -70,10 +70,10 @@ frame_create(Client *c) { CWIN(c->titlebar, c->frame, 0, 0, c->frame_geo.width, - (TBARH - SHADH*2) + BORDH, + (TBARH + SHADH/2) + BORDH, 1, CWEventMask|CWBackPixel, c->colors.frame, &at); - XSetWindowBorder(dpy, c->titlebar, 0x212121); + XSetWindowBorder(dpy, c->titlebar, SHADC); } /* Titlebar buttons */ at.event_mask &= ~(EnterWindowMask | LeaveWindowMask); /* <- Delete useless mask */ @@ -88,13 +88,18 @@ frame_create(Client *c) CWEventMask|CWBackPixel|CWCursor, c->colors.resizecorner, &at); /* Border (for shadow) */ - CWIN(c->left, c->frame, 0, 0, SHADH, c->frame_geo.height, 0, CWBackPixel, 0x585858, &at); - CWIN(c->top, c->frame, 0, 0, c->frame_geo.width, SHADH, 0, CWBackPixel, 0x585858, &at); - CWIN(c->bottom, c->frame, 0, c->frame_geo.height, c->frame_geo.width, SHADH, 0, CWBackPixel, 0x212121, &at); - CWIN(c->right, c->frame, c->frame_geo.width - SHADH, 0, SHADH, c->frame_geo.height, 0, CWBackPixel, 0x212121, &at); + CWIN(c->left, c->frame, 0, 0, SHADH, c->frame_geo.height, 0, + CWBackPixel, color_enlight(c->colors.frame), &at); + CWIN(c->top, c->frame, 0, 0, c->frame_geo.width, SHADH, 0, + CWBackPixel, color_enlight(c->colors.frame), &at); + CWIN(c->bottom, c->frame, 0, c->frame_geo.height, c->frame_geo.width, SHADH, 0, + CWBackPixel, SHADC, &at); + CWIN(c->right, c->frame, c->frame_geo.width - SHADH, 0, SHADH, c->frame_geo.height, 0, + CWBackPixel, SHADC, &at); /* Reparent window with the frame */ XReparentWindow(dpy, c->win, c->frame, BORDH, BORDH + TBARH); + return; } @@ -133,7 +138,8 @@ frame_moveresize(Client *c, XRectangle geo) return; } -/** Update a frame +/** Update the client frame; Set the new color + * and the title ---> refresh all * \param c Client pointer */ void @@ -142,13 +148,22 @@ frame_update(Client *c) if(TBARH) { XSetWindowBackground(dpy, c->titlebar, c->colors.frame); + XSetWindowBorder(dpy, c->titlebar, SHADC); XClearWindow(dpy, c->titlebar); } - - XSetWindowBackground(dpy, c->frame, c->colors.frame); + XSetWindowBackground(dpy, c->frame, c->colors.frame); XSetWindowBackground(dpy, c->resize, c->colors.resizecorner); + XSetWindowBackground(dpy, c->left, color_enlight(c->colors.frame)); + XSetWindowBackground(dpy, c->top, color_enlight(c->colors.frame)); + XSetWindowBackground(dpy, c->right, SHADC); + XSetWindowBackground(dpy, c->bottom, SHADC); + XClearWindow(dpy, c->resize); XClearWindow(dpy, c->frame); + XClearWindow(dpy, c->left); + XClearWindow(dpy, c->top); + XClearWindow(dpy, c->right); + XClearWindow(dpy, c->bottom); if((TBARH + BORDH + 1) > font->height) draw_text(c->titlebar, diff --git a/src/layout.c b/src/layout.c index cea83af..8adf90e 100644 --- a/src/layout.c +++ b/src/layout.c @@ -499,16 +499,7 @@ uicb_togglefree(uicb_t cmd) sel->tile = False; sel->max = False; sel->lmax = False; - if(sel->free) - { - sel->geo.x = sel->ogeo.x; - sel->geo.y = sel->ogeo.y; - sel->geo.width = sel->ogeo.width; - sel->geo.height = sel->ogeo.height; - client_moveresize(sel, sel->geo, True); - } - - client_raise(sel); + client_moveresize(sel, sel->ogeo, True); arrange(); diff --git a/src/util.c b/src/util.c index 122100f..7632710 100644 --- a/src/util.c +++ b/src/util.c @@ -74,6 +74,23 @@ getcolor(char *color) return xcolor.pixel; } +/** Enlight an hexadecimal color + * \param col Color + * \return The clarified color +*/ +ulong +color_enlight(ulong col) +{ + ulong ret = col; + + if((col + 0x330000) < 0xffffff + && (col + 0x003300) < 0xffffff + && (col + 0x000033) < 0xffffff) + ret += 0x333333; + + return ret; +} + /** Get a Window WM State * \param win Window * \return The state diff --git a/src/wmfs.h b/src/wmfs.h index 89860a9..2093c3b 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -68,18 +68,19 @@ #define MAXW DisplayWidth(dpy, screen) #define SHADH 1 +#define SHADC 0x000000 #define BORDH conf.client.borderheight #define TBARH conf.titlebar.height #define FRAMEW(w) w + BORDH * 2 #define FRAMEH(h) h + (BORDH * 2) + TBARH -/* To checking if wmfs can create and use the titlebar buttons */ +/* To checking if wmfs can create + * and use the titlebar buttons */ #define CTBAR TBARH - BORDH > 1 #define BUTHW (BORDH + TBARH) - 6 #define BUTX(b) (b + 0.5) * BUTHW + BORDH + 1 #define RESHW 5 * BORDH - #define CHECK(x) if(!x) return #define ITOA(p ,n) sprintf(p, "%d", n) #define deb(p) fprintf(stderr, "debug: %d\n", p) @@ -166,6 +167,7 @@ void uicb_mouse_move(uicb_t cmd); void uicb_mouse_resize(uicb_t cmd); /* util.c */ +ulong color_enlight(ulong col); void *emalloc(uint element, uint size); void efree(void *ptr); ulong getcolor(char *color);