1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Make window border size configurable.

Use the new preference FrameBorderWidth to configure the width of frame
window borders.
This commit is contained in:
Iain Patterson
2013-03-26 07:01:08 +00:00
committed by Carlos R. Mafra
parent dee30d06ac
commit 2affd6d484
13 changed files with 44 additions and 33 deletions

View File

@@ -362,7 +362,7 @@ void wMaximizeWindow(WWindow *wwin, int directions)
has_border = 0; has_border = 0;
/* the size to adjust the geometry */ /* the size to adjust the geometry */
adj_size = FRAME_BORDER_WIDTH * 2 * has_border; adj_size = wwin->screen_ptr->frame_border_width * 2 * has_border;
/* save old coordinates before we change the current values /* save old coordinates before we change the current values
* always if the window is not currently maximized at all * always if the window is not currently maximized at all
@@ -626,7 +626,7 @@ static void find_Maximus_geometry(WWindow *wwin, WArea usableArea, int *new_x, i
if (HAS_RESIZEBAR(wwin)) if (HAS_RESIZEBAR(wwin))
rbar_height_0 = RESIZEBAR_HEIGHT; rbar_height_0 = RESIZEBAR_HEIGHT;
if (HAS_BORDER(wwin)) if (HAS_BORDER(wwin))
bd_width_0 = FRAME_BORDER_WIDTH; bd_width_0 = wwin->screen_ptr->frame_border_width;
/* the length to be subtracted if the window has titlebar, etc */ /* the length to be subtracted if the window has titlebar, etc */
adjust_height = tbar_height_0 + 2 * bd_width_0 + rbar_height_0; adjust_height = tbar_height_0 + 2 * bd_width_0 + rbar_height_0;
@@ -1871,7 +1871,7 @@ void wSelectWindow(WWindow *wwin, Bool flag)
XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel); XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel);
if (!HAS_BORDER(wwin)) { if (!HAS_BORDER(wwin)) {
XSetWindowBorderWidth(dpy, wwin->frame->core->window, FRAME_BORDER_WIDTH); XSetWindowBorderWidth(dpy, wwin->frame->core->window, wwin->screen_ptr->frame_border_width);
} }
if (!scr->selected_windows) if (!scr->selected_windows)

View File

@@ -75,8 +75,8 @@ void wClientRestore(WWindow * wwin)
wClientGetGravityOffsets(wwin, &gx, &gy); wClientGetGravityOffsets(wwin, &gx, &gy);
/* set the position of the frame on screen */ /* set the position of the frame on screen */
wwin->frame_x -= gx * FRAME_BORDER_WIDTH; wwin->frame_x -= gx * wwin->screen_ptr->frame_border_width;
wwin->frame_y -= gy * FRAME_BORDER_WIDTH; wwin->frame_y -= gy * wwin->screen_ptr->frame_border_width;
/* if gravity is to the south, account for the border sizes */ /* if gravity is to the south, account for the border sizes */
if (gy > 0) if (gy > 0)
wwin->frame_y += (wwin->frame->top_width + wwin->frame->bottom_width); wwin->frame_y += (wwin->frame->top_width + wwin->frame->bottom_width);
@@ -224,7 +224,7 @@ void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre)
nx = xcre->x; nx = xcre->x;
/* Subtracting the border makes the window shift by 1 pixel -Dan */ /* Subtracting the border makes the window shift by 1 pixel -Dan */
/*if (HAS_BORDER(wwin)) { /*if (HAS_BORDER(wwin)) {
nx -= FRAME_BORDER_WIDTH; nx -= wwin->screen_ptr->frame_border_width;
} */ } */
} else { } else {
nx = wwin->frame_x; nx = wwin->frame_x;
@@ -234,7 +234,7 @@ void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre)
ny = xcre->y - ((ofs_y < 0) ? 0 : wwin->frame->top_width); ny = xcre->y - ((ofs_y < 0) ? 0 : wwin->frame->top_width);
/* Subtracting the border makes the window shift by 1 pixel -Dan */ /* Subtracting the border makes the window shift by 1 pixel -Dan */
/*if (HAS_BORDER(wwin)) { /*if (HAS_BORDER(wwin)) {
ny -= FRAME_BORDER_WIDTH; ny -= wwin->screen_ptr->frame_border_width;
} */ } */
} else { } else {
ny = wwin->frame_y; ny = wwin->frame_y;

View File

@@ -122,6 +122,7 @@ static int setMenuTextFont();
static int setIconTitleFont(); static int setIconTitleFont();
static int setIconTitleColor(); static int setIconTitleColor();
static int setIconTitleBack(); static int setIconTitleBack();
static int setFrameBorderWidth();
static int setFrameBorderColor(); static int setFrameBorderColor();
static int setFrameSelectedBorderColor(); static int setFrameSelectedBorderColor();
static int setLargeDisplayFont(); static int setLargeDisplayFont();
@@ -542,6 +543,8 @@ WDefaultEntry optionList[] = {
NULL, getPropList, setSwPOptions, NULL, NULL}, NULL, getPropList, setSwPOptions, NULL, NULL},
{"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences, {"ModifierKeyLabels", "(\"Shift+\", \"Ctrl+\", \"Mod1+\", \"Mod2+\", \"Mod3+\", \"Mod4+\", \"Mod5+\")", &wPreferences,
NULL, getPropList, setModifierKeyLabels, NULL, NULL}, NULL, getPropList, setModifierKeyLabels, NULL, NULL},
{"FrameBorderWidth", "1", NULL,
NULL, getInt, setFrameBorderWidth, NULL, NULL},
{"FrameBorderColor", "black", NULL, {"FrameBorderColor", "black", NULL,
NULL, getColor, setFrameBorderColor, NULL, NULL}, NULL, getColor, setFrameBorderColor, NULL, NULL},
{"FrameSelectedBorderColor", "white", NULL, {"FrameSelectedBorderColor", "white", NULL,
@@ -2584,6 +2587,13 @@ static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, XColor * color
return REFRESH_ICON_TITLE_BACK; return REFRESH_ICON_TITLE_BACK;
} }
static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, int * value, void *foo)
{
scr->frame_border_width = *value;
return REFRESH_FRAME_BORDER;
}
static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo) static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, XColor * color, void *foo)
{ {
if (scr->frame_border_color) if (scr->frame_border_color)

View File

@@ -106,7 +106,7 @@ WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y,
fwin->colormap = colormap; fwin->colormap = colormap;
fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, (flags & WFF_BORDER) fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, (flags & WFF_BORDER)
? FRAME_BORDER_WIDTH : 0, fwin->depth, fwin->visual, fwin->colormap, scr->frame_border_pixel); ? scr->frame_border_width : 0, fwin->depth, fwin->visual, fwin->colormap, scr->frame_border_pixel);
/* setup stacking information */ /* setup stacking information */
fwin->core->stacking = wmalloc(sizeof(WStacking)); fwin->core->stacking = wmalloc(sizeof(WStacking));
@@ -369,7 +369,7 @@ void wFrameWindowUpdateBorders(WFrameWindow * fwin, int flags)
wFrameWindowResize(fwin, width, height + fwin->top_width + fwin->bottom_width); wFrameWindowResize(fwin, width, height + fwin->top_width + fwin->bottom_width);
if (flags & WFF_BORDER) if (flags & WFF_BORDER)
XSetWindowBorderWidth(dpy, fwin->core->window, FRAME_BORDER_WIDTH); XSetWindowBorderWidth(dpy, fwin->core->window, scr->frame_border_width);
else else
XSetWindowBorderWidth(dpy, fwin->core->window, 0); XSetWindowBorderWidth(dpy, fwin->core->window, 0);

View File

@@ -57,8 +57,8 @@ extern WPreferences wPreferences;
#define MENU_SCROLL_STEP menuScrollParameters[(int)wPreferences.menu_scroll_speed].steps #define MENU_SCROLL_STEP menuScrollParameters[(int)wPreferences.menu_scroll_speed].steps
#define MENU_SCROLL_DELAY menuScrollParameters[(int)wPreferences.menu_scroll_speed].delay #define MENU_SCROLL_DELAY menuScrollParameters[(int)wPreferences.menu_scroll_speed].delay
#define MENUW(m) ((m)->frame->core->width+2*FRAME_BORDER_WIDTH) #define MENUW(m) ((m)->frame->core->width+2*(m)->frame->screen_ptr->frame_border_width)
#define MENUH(m) ((m)->frame->core->height+2*FRAME_BORDER_WIDTH) #define MENUH(m) ((m)->frame->core->height+2*(m)->frame->screen_ptr->frame_border_width)
/***** Local Stuff ******/ /***** Local Stuff ******/

View File

@@ -228,10 +228,10 @@ static void showGeometry(WWindow * wwin, int x1, int y1, int x2, int y2, int dir
x2--; x2--;
if (HAS_BORDER_WITH_SELECT(wwin)) { if (HAS_BORDER_WITH_SELECT(wwin)) {
x1 += FRAME_BORDER_WIDTH; x1 += scr->frame_border_width;
x2 += FRAME_BORDER_WIDTH; x2 += scr->frame_border_width;
y1 += FRAME_BORDER_WIDTH; y1 += scr->frame_border_width;
y2 += FRAME_BORDER_WIDTH; y2 += scr->frame_border_width;
} }
ty = y1 + wwin->frame->top_width; ty = y1 + wwin->frame->top_width;
@@ -463,8 +463,8 @@ static void drawTransparentFrame(WWindow * wwin, int x, int y, int width, int he
int bottom = 0; int bottom = 0;
if (HAS_BORDER_WITH_SELECT(wwin)) { if (HAS_BORDER_WITH_SELECT(wwin)) {
x += FRAME_BORDER_WIDTH; x += wwin->screen_ptr->frame_border_width;
y += FRAME_BORDER_WIDTH; y += wwin->screen_ptr->frame_border_width;
} }
if (HAS_TITLEBAR(wwin) && !wwin->flags.shaded) { if (HAS_TITLEBAR(wwin) && !wwin->flags.shaded) {
@@ -596,9 +596,9 @@ typedef struct {
#define WTOP(w) (w)->frame_y #define WTOP(w) (w)->frame_y
#define WLEFT(w) (w)->frame_x #define WLEFT(w) (w)->frame_x
#define WRIGHT(w) ((w)->frame_x + (int)(w)->frame->core->width - 1 + \ #define WRIGHT(w) ((w)->frame_x + (int)(w)->frame->core->width - 1 + \
(HAS_BORDER_WITH_SELECT(w) ? 2*FRAME_BORDER_WIDTH : 0)) (HAS_BORDER_WITH_SELECT(w) ? 2*(w)->screen_ptr->frame_border_width : 0))
#define WBOTTOM(w) ((w)->frame_y + (int)(w)->frame->core->height - 1 + \ #define WBOTTOM(w) ((w)->frame_y + (int)(w)->frame->core->height - 1 + \
(HAS_BORDER_WITH_SELECT(w) ? 2*FRAME_BORDER_WIDTH : 0)) (HAS_BORDER_WITH_SELECT(w) ? 2*(w)->screen_ptr->frame_border_width : 0))
static int compareWTop(const void *a, const void *b) static int compareWTop(const void *a, const void *b)
{ {
@@ -830,8 +830,8 @@ static void initMoveData(WWindow * wwin, MoveData * data)
data->calcX = wwin->frame_x; data->calcX = wwin->frame_x;
data->calcY = wwin->frame_y; data->calcY = wwin->frame_y;
data->winWidth = wwin->frame->core->width + (HAS_BORDER_WITH_SELECT(wwin) ? 2 * FRAME_BORDER_WIDTH : 0); data->winWidth = wwin->frame->core->width + (HAS_BORDER_WITH_SELECT(wwin) ? 2 * wwin->screen_ptr->frame_border_width : 0);
data->winHeight = wwin->frame->core->height + (HAS_BORDER_WITH_SELECT(wwin) ? 2 * FRAME_BORDER_WIDTH : 0); data->winHeight = wwin->frame->core->height + (HAS_BORDER_WITH_SELECT(wwin) ? 2 * wwin->screen_ptr->frame_border_width : 0);
} }
static Bool checkWorkspaceChange(WWindow * wwin, MoveData * data, Bool opaqueMove) static Bool checkWorkspaceChange(WWindow * wwin, MoveData * data, Bool opaqueMove)

View File

@@ -294,8 +294,8 @@ static void set_width_height(WWindow *wwin, unsigned int *width, unsigned int *h
*height += RESIZEBAR_HEIGHT; *height += RESIZEBAR_HEIGHT;
} }
if (HAS_BORDER(wwin)) { if (HAS_BORDER(wwin)) {
*height += 2 * FRAME_BORDER_WIDTH; *height += 2 * wwin->screen_ptr->frame_border_width;
*width += 2 * FRAME_BORDER_WIDTH; *width += 2 * wwin->screen_ptr->frame_border_width;
} }
} }

View File

@@ -167,6 +167,7 @@ typedef struct _WScreen {
WMColor *mtext_color; /* menu item text */ WMColor *mtext_color; /* menu item text */
WMColor *dtext_color; /* disabled menu item text */ WMColor *dtext_color; /* disabled menu item text */
int frame_border_width;
WMColor *frame_border_color; WMColor *frame_border_color;
WMColor *frame_selected_border_color; WMColor *frame_selected_border_color;

View File

@@ -876,7 +876,7 @@ static void manageAllWindows(WScreen * scr, int crashRecovery)
if (crashRecovery) { if (crashRecovery) {
int border; int border;
border = (!HAS_BORDER(wwin) ? 0 : FRAME_BORDER_WIDTH); border = (!HAS_BORDER(wwin) ? 0 : scr->frame_border_width);
wWindowMove(wwin, wwin->frame_x - border, wWindowMove(wwin, wwin->frame_x - border,
wwin->frame_y - border - wwin->frame_y - border -

View File

@@ -355,7 +355,6 @@
#define MIN_TITLEFONT_HEIGHT(h) ((h)>14 ? (h) : 14) #define MIN_TITLEFONT_HEIGHT(h) ((h)>14 ? (h) : 14)
#define TITLEBAR_HEIGHT 18 /* window's titlebar height */ #define TITLEBAR_HEIGHT 18 /* window's titlebar height */
#define RESIZEBAR_HEIGHT 8 /* height of the resizebar */ #define RESIZEBAR_HEIGHT 8 /* height of the resizebar */
#define FRAME_BORDER_WIDTH 1 /* width of window border for frames */
#define RESIZEBAR_MIN_WIDTH 20 /* min width of handles-corner_width */ #define RESIZEBAR_MIN_WIDTH 20 /* min width of handles-corner_width */
#define RESIZEBAR_CORNER_WIDTH 28 /* width of the corner of resizebars */ #define RESIZEBAR_CORNER_WIDTH 28 /* width of the corner of resizebars */
#define MENU_INDICATOR_SPACE 12 #define MENU_INDICATOR_SPACE 12

View File

@@ -2021,8 +2021,8 @@ void wWindowConfigure(WWindow *wwin, int req_x, int req_y, int req_width, int re
wwin->frame_x = req_x; wwin->frame_x = req_x;
wwin->frame_y = req_y; wwin->frame_y = req_y;
if (HAS_BORDER(wwin)) { if (HAS_BORDER(wwin)) {
wwin->client.x += FRAME_BORDER_WIDTH; wwin->client.x += wwin->screen_ptr->frame_border_width;
wwin->client.y += FRAME_BORDER_WIDTH; wwin->client.y += wwin->screen_ptr->frame_border_width;
} }
#ifdef SHAPE #ifdef SHAPE
if (wShapeSupported && wwin->flags.shaped && resize) if (wShapeSupported && wwin->flags.shaped && resize)
@@ -2058,8 +2058,8 @@ void wWindowMove(WWindow *wwin, int req_x, int req_y)
wwin->client.x = req_x; wwin->client.x = req_x;
wwin->client.y = req_y + wwin->frame->top_width; wwin->client.y = req_y + wwin->frame->top_width;
if (HAS_BORDER(wwin)) { if (HAS_BORDER(wwin)) {
wwin->client.x += FRAME_BORDER_WIDTH; wwin->client.x += wwin->screen_ptr->frame_border_width;
wwin->client.y += FRAME_BORDER_WIDTH; wwin->client.y += wwin->screen_ptr->frame_border_width;
} }
XMoveWindow(dpy, wwin->frame->core->window, req_x, req_y); XMoveWindow(dpy, wwin->frame->core->window, req_x, req_y);

View File

@@ -1608,10 +1608,10 @@ void wNETFrameExtents(WWindow *wwin)
if (wwin->frame->resizebar) if (wwin->frame->resizebar)
extents[3] = wwin->frame->resizebar->height; extents[3] = wwin->frame->resizebar->height;
if (HAS_BORDER(wwin)) { if (HAS_BORDER(wwin)) {
extents[0] += FRAME_BORDER_WIDTH; extents[0] += wwin->screen_ptr->frame_border_width;
extents[1] += FRAME_BORDER_WIDTH; extents[1] += wwin->screen_ptr->frame_border_width;
extents[2] += FRAME_BORDER_WIDTH; extents[2] += wwin->screen_ptr->frame_border_width;
extents[3] += FRAME_BORDER_WIDTH; extents[3] += wwin->screen_ptr->frame_border_width;
} }
XChangeProperty(dpy, wwin->client_win, net_frame_extents, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) extents, 4); XChangeProperty(dpy, wwin->client_win, net_frame_extents, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) extents, 4);

View File

@@ -86,6 +86,7 @@ static char *options[] = {
"IconBack", "IconBack",
"IconTitleColor", "IconTitleColor",
"IconTitleBack", "IconTitleBack",
"FrameBorderWidth",
"FrameBorderColor", "FrameBorderColor",
"FrameSelectedBorderColor", "FrameSelectedBorderColor",
"MenuStyle", "MenuStyle",