From bc8ccee72f78d163fd16caf6386f14ed9e6ae53d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Amadeusz=20S=C5=82awi=C5=84ski?= Date: Mon, 19 May 2014 22:27:22 +0200 Subject: [PATCH] Allow setting separate border color for focused windows MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch adds "FrameFocusedBorderColor" option for theming, It should allow having borders better matching titlebar colors. By default it's set to black. Signed-off-by: Amadeusz Sławiński --- src/actions.c | 15 +++++++++++---- src/defaults.c | 20 ++++++++++++++++++++ src/framewin.c | 17 +++++++++++++++-- src/framewin.h | 1 + src/screen.c | 2 ++ src/screen.h | 2 ++ util/getstyle.c | 1 + 7 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/actions.c b/src/actions.c index 13dffec6..a767072f 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1874,10 +1874,17 @@ void wSelectWindow(WWindow *wwin, Bool flag) WMAddToArray(scr->selected_windows, wwin); } else { wwin->flags.selected = 0; - if (wwin->frame->border_pixel) - XSetWindowBorder(dpy, wwin->frame->core->window, *wwin->frame->border_pixel); - else - XSetWindowBorder(dpy, wwin->frame->core->window, scr->frame_border_pixel); + if (wwin->flags.focused) { + if (wwin->frame->focused_border_pixel) + XSetWindowBorder(dpy, wwin->frame->core->window, *wwin->frame->focused_border_pixel); + else + XSetWindowBorder(dpy, wwin->frame->core->window, scr->frame_focused_border_pixel); + } else { + if (wwin->frame->border_pixel) + XSetWindowBorder(dpy, wwin->frame->core->window, *wwin->frame->border_pixel); + else + XSetWindowBorder(dpy, wwin->frame->core->window, scr->frame_border_pixel); + } if (!HAS_BORDER(wwin)) { XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0); diff --git a/src/defaults.c b/src/defaults.c index 7d66372e..436cb203 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -126,6 +126,7 @@ static WDECallbackUpdate setIconTitleColor; static WDECallbackUpdate setIconTitleBack; static WDECallbackUpdate setFrameBorderWidth; static WDECallbackUpdate setFrameBorderColor; +static WDECallbackUpdate setFrameFocusedBorderColor; static WDECallbackUpdate setFrameSelectedBorderColor; static WDECallbackUpdate setLargeDisplayFont; static WDECallbackUpdate setWTitleColor; @@ -568,6 +569,8 @@ WDefaultEntry optionList[] = { NULL, getInt, setFrameBorderWidth, NULL, NULL}, {"FrameBorderColor", "black", NULL, NULL, getColor, setFrameBorderColor, NULL, NULL}, + {"FrameFocusedBorderColor", "black", NULL, + NULL, getColor, setFrameFocusedBorderColor, NULL, NULL}, {"FrameSelectedBorderColor", "white", NULL, NULL, getColor, setFrameSelectedBorderColor, NULL, NULL}, @@ -2891,6 +2894,23 @@ static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata return REFRESH_FRAME_BORDER; } +static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo) +{ + XColor *color = tdata; + + /* Parameter not used, but tell the compiler that it is ok */ + (void) entry; + (void) foo; + + if (scr->frame_focused_border_color) + WMReleaseColor(scr->frame_focused_border_color); + scr->frame_focused_border_color = WMCreateRGBColor(scr->wmscreen, color->red, color->green, color->blue, True); + + wFreeColor(scr, color->pixel); + + return REFRESH_FRAME_BORDER; +} + static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { XColor *color = tdata; diff --git a/src/framewin.c b/src/framewin.c index 68a1b740..13fe1e09 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -415,6 +415,7 @@ void wFrameWindowUpdateBorders(WFrameWindow * fwin, int flags) checkTitleSize(fwin); allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_border_color), &fwin->border_pixel); + allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_focused_border_color), &fwin->focused_border_pixel); allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_selected_border_color), &fwin->selected_border_pixel); if (flags & WFF_SELECTED) { @@ -422,8 +423,13 @@ void wFrameWindowUpdateBorders(WFrameWindow * fwin, int flags) XSetWindowBorder(dpy, fwin->core->window, *fwin->selected_border_pixel); } else { - if (fwin->border_pixel) - XSetWindowBorder(dpy, fwin->core->window, *fwin->border_pixel); + if (fwin->flags.state == WS_FOCUSED) { + if (fwin->focused_border_pixel) + XSetWindowBorder(dpy, fwin->core->window, *fwin->focused_border_pixel); + } else { + if (fwin->border_pixel) + XSetWindowBorder(dpy, fwin->core->window, *fwin->border_pixel); + } } } @@ -477,6 +483,13 @@ void wFrameWindowChangeState(WFrameWindow * fwin, int state) fwin->flags.state = state; fwin->flags.need_texture_change = 1; + if (fwin->flags.state == WS_FOCUSED) { + if (fwin->focused_border_pixel) + XSetWindowBorder(dpy, fwin->core->window, *fwin->focused_border_pixel); + } else { + if (fwin->border_pixel) + XSetWindowBorder(dpy, fwin->core->window, *fwin->border_pixel); + } wFrameWindowPaint(fwin); } diff --git a/src/framewin.h b/src/framewin.h index 22e0edfd..8b0a53ca 100644 --- a/src/framewin.h +++ b/src/framewin.h @@ -152,6 +152,7 @@ typedef struct WFrameWindow { Visual *visual; Colormap colormap; unsigned long *border_pixel; + unsigned long *focused_border_pixel; unsigned long *selected_border_pixel; } WFrameWindow; diff --git a/src/screen.c b/src/screen.c index 91ef63bc..afc9d17d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -622,6 +622,8 @@ WScreen *wScreenInit(int screen_number) /* frame boder color */ wGetColor(scr, WMGetColorRGBDescription(scr->frame_border_color), &xcol); scr->frame_border_pixel = xcol.pixel; + wGetColor(scr, WMGetColorRGBDescription(scr->frame_focused_border_color), &xcol); + scr->frame_focused_border_pixel = xcol.pixel; wGetColor(scr, WMGetColorRGBDescription(scr->frame_selected_border_color), &xcol); scr->frame_selected_border_pixel = xcol.pixel; } diff --git a/src/screen.h b/src/screen.h index 97e2e48a..b9b5d78b 100644 --- a/src/screen.h +++ b/src/screen.h @@ -160,10 +160,12 @@ typedef struct _WScreen { int frame_border_width; WMColor *frame_border_color; + WMColor *frame_focused_border_color; WMColor *frame_selected_border_color; WMPixel line_pixel; WMPixel frame_border_pixel; /* frame border */ + WMPixel frame_focused_border_pixel; /* frame border */ WMPixel frame_selected_border_pixel;/* frame border */ diff --git a/util/getstyle.c b/util/getstyle.c index dfb739c6..079b7d40 100644 --- a/util/getstyle.c +++ b/util/getstyle.c @@ -92,6 +92,7 @@ static char *options[] = { "IconTitleBack", "FrameBorderWidth", "FrameBorderColor", + "FrameFocusedBorderColor", "FrameSelectedBorderColor", "MenuStyle", "WindowTitleExtendSpace", -- 2.11.4.GIT