diff --git a/src/E.h b/src/E.h index d1196d53..4e40e751 100644 --- a/src/E.h +++ b/src/E.h @@ -252,16 +252,19 @@ int Esnprintf(va_alist); * Types */ -struct _imageclass; -struct _imagestate; -struct _textclass; -struct _textstate; +struct _border; typedef struct _ewin EWin; typedef struct _ecursor ECursor; typedef struct _client Client; +typedef struct _constraints +{ + int min, max; +} +Constraints; + typedef struct { void (*func) (const char *line, Client * c); @@ -294,74 +297,6 @@ typedef struct } VirtRoot; -typedef struct _constraints -{ - int min, max; -} -Constraints; - -typedef struct _winpoint -{ - int originbox; - struct - { - int percent; - int absolute; - } - x , y; -} -WinPoint; - -typedef struct _geometry -{ - Constraints width, height; - WinPoint topleft, bottomright; -} -Geometry; - -typedef struct _winpart -{ - Geometry geom; - struct _imageclass *iclass; - struct _actionclass *aclass; - struct _textclass *tclass; - ECursor *ec; - signed char ontop; - int flags; - char keep_for_shade; -} -WinPart; - -typedef struct _border -{ - char *name; - char *group_border_name; - Imlib_Border border; - int num_winparts; - WinPart *part; - char changes_shape; - char shadedir; - char throwaway; - unsigned int ref_count; - struct _actionclass *aclass; -} -Border; - -typedef struct _ewinbit -{ - EWin *ewin; /* Belongs to */ - Window win; - int x, y, w, h; - int cx, cy, cw, ch; - int state; - char expose; - char no_expose; - char left; - struct _imagestate *is; - struct _textstate *ts; -} -EWinBit; - /* Configuration parameters */ typedef struct { @@ -690,27 +625,6 @@ void ArrangeEwinXY(EWin * ewin, int *px, int *py); void ArrangeEwinCenteredXY(EWin * ewin, int *px, int *py); void ArrangeEwins(const char *params); -/* borders.c */ -void BorderIncRefcount(const Border * b); -void BorderDecRefcount(const Border * b); -const char *BorderGetName(const Border * b); -int BorderConfigLoad(FILE * fs); -void EwinBorderSelect(EWin * ewin); -void EwinBorderDetach(EWin * ewin); -void EwinBorderSetTo(EWin * ewin, const Border * b); -void EwinBorderDraw(EWin * ewin, int do_shape, int do_paint); -void EwinBorderCalcSizes(EWin * ewin, int propagate); -void EwinBorderMinShadeSize(EWin * ewin, int *mw, int *mh); -void EwinBorderUpdateInfo(EWin * ewin); -void EwinBorderUpdateState(EWin * ewin); -void EwinBorderEventsConfigure(EWin * ewin, int mode); -void EwinSetBorder(EWin * ewin, const Border * b, int apply); -void EwinSetBorderByName(EWin * ewin, const char *name); -int BorderWinpartIndex(EWin * ewin, Window win); -Border *BorderCreateFiller(int left, int right, int top, - int bottom); -void BordersSetupFallback(void); - /* comms.c */ void CommsInit(void); void CommsSend(Client * c, const char *s); @@ -1084,7 +998,7 @@ void WarpFocus(int delta); /* windowmatch.c */ int WindowMatchConfigLoad(FILE * fs); -Border *WindowMatchEwinBorder(const EWin * ewin); +struct _border *WindowMatchEwinBorder(const EWin * ewin); const char *WindowMatchEwinIcon(const EWin * ewin); void WindowMatchEwinOps(EWin * ewin); diff --git a/src/Makefile.am b/src/Makefile.am index 8c8ff60a..fc1cd998 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,6 +23,7 @@ e16_SOURCES = \ backgrounds.c \ backgrounds.h \ borders.c \ + borders.h \ buttons.c \ buttons.h \ cmclass.c \ diff --git a/src/borders.c b/src/borders.c index 12499a39..23f8c7fe 100644 --- a/src/borders.c +++ b/src/borders.c @@ -23,6 +23,7 @@ */ #include "E.h" #include "aclass.h" +#include "borders.h" #include "ewins.h" #include "hints.h" #include "iclass.h" @@ -41,12 +42,6 @@ static void BorderDestroy(Border * b); static void BorderWinpartHandleEvents(XEvent * ev, void *prm); static void BorderFrameHandleEvents(XEvent * ev, void *prm); -void -EwinBorderUpdateState(EWin * ewin) -{ - EwinBorderDraw(ewin, 0, 0); -} - static void BorderWinpartRealise(EWin * ewin, int i) { diff --git a/src/borders.h b/src/borders.h new file mode 100644 index 00000000..0fb55df3 --- /dev/null +++ b/src/borders.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2000-2005 Carsten Haitzler, Geoff Harrison, + * and various contributors + * Copyright (C) 2004-2005 Kim Woelders + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef _BORDERS_H_ +#define _BORDERS_H_ + +typedef struct _winpoint +{ + int originbox; + struct + { + int percent; + int absolute; + } + x , y; +} +WinPoint; + +typedef struct _geometry +{ + Constraints width, height; + WinPoint topleft, bottomright; +} +Geometry; + +typedef struct _winpart +{ + Geometry geom; + struct _imageclass *iclass; + struct _actionclass *aclass; + struct _textclass *tclass; + ECursor *ec; + signed char ontop; + int flags; + char keep_for_shade; +} +WinPart; + +typedef struct _border +{ + char *name; + char *group_border_name; + Imlib_Border border; + int num_winparts; + WinPart *part; + char changes_shape; + char shadedir; + char throwaway; + unsigned int ref_count; + struct _actionclass *aclass; +} +Border; + +typedef struct _ewinbit +{ + EWin *ewin; /* Belongs to */ + Window win; + int x, y, w, h; + int cx, cy, cw, ch; + int state; + char expose; + char no_expose; + char left; + struct _imagestate *is; + struct _textstate *ts; +} +EWinBit; + +/* borders.c */ +void BorderIncRefcount(const Border * b); +void BorderDecRefcount(const Border * b); +const char *BorderGetName(const Border * b); +int BorderConfigLoad(FILE * fs); +void EwinBorderSelect(EWin * ewin); +void EwinBorderDetach(EWin * ewin); +void EwinBorderSetTo(EWin * ewin, const Border * b); +void EwinBorderDraw(EWin * ewin, int do_shape, int do_paint); +void EwinBorderCalcSizes(EWin * ewin, int propagate); +void EwinBorderMinShadeSize(EWin * ewin, int *mw, int *mh); +void EwinBorderUpdateInfo(EWin * ewin); +void EwinBorderEventsConfigure(EWin * ewin, int mode); +void EwinSetBorder(EWin * ewin, const Border * b, int apply); +void EwinSetBorderByName(EWin * ewin, const char *name); +int BorderWinpartIndex(EWin * ewin, Window win); +Border *BorderCreateFiller(int left, int right, int top, + int bottom); +void BordersSetupFallback(void); + +#endif /* _BORDERS_H_ */ diff --git a/src/config.c b/src/config.c index 2bd26da6..5ee179c8 100644 --- a/src/config.c +++ b/src/config.c @@ -24,6 +24,7 @@ #include "E.h" #include "aclass.h" #include "backgrounds.h" +#include "borders.h" #include "buttons.h" #include "conf.h" #include "iclass.h" diff --git a/src/coords.c b/src/coords.c index 66bcc7d1..32c269f4 100644 --- a/src/coords.c +++ b/src/coords.c @@ -43,6 +43,7 @@ CoordsShow(EWin * ewin) int cx, cy, cw, ch; EObj *eo = coord_eo; Imlib_Border *pad; + int bl, br, bt, bb; if (!Conf.movres.mode_info) return; @@ -85,13 +86,10 @@ CoordsShow(EWin * ewin) case 0: case 1: case 2: - cx = - x + (ewin->shape_w + ewin->border->border.left + - ewin->border->border.right - cw) / 2 + + EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); + cx = x + (ewin->shape_w + bl + br - cw) / 2 + EoGetX(EoGetDesk(ewin)); - cy = - y + (ewin->shape_h + ewin->border->border.top + - ewin->border->border.bottom - ch) / 2 + + cy = y + (ewin->shape_h + bt + bb - ch) / 2 + EoGetY(EoGetDesk(ewin)); break; } diff --git a/src/dialog.h b/src/dialog.h index 92f6c64a..98d792a7 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -48,6 +48,9 @@ #define DLG_OAC 7 #define DLG_OC 5 +struct _imageclass; +struct _textclass; + typedef struct _dialog Dialog; typedef struct _ditem DItem; typedef void (DialogCallbackFunc) (Dialog * d, int val, void *data); diff --git a/src/draw.c b/src/draw.c index 4c178bce..1f9e4ff2 100644 --- a/src/draw.c +++ b/src/draw.c @@ -628,6 +628,7 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast) static Font font = 0; Window root = VRoot.win; int x1, y1, w1, h1, i, j, dx, dy; + int bl, br, bt, bb; char str[32]; switch (md) @@ -686,6 +687,8 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast) w = ewin->shape_w; h = ewin->shape_h; + EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); + if (!gc) { XGCValues gcv; @@ -726,94 +729,50 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast) Esnprintf(str, sizeof(str), "%i", (y2) - (y1) + 1); \ XDrawString(disp, root, gc, (x1) + 10, ((y1) + (y2)) / 2, str, strlen(str)); \ } -#define DO_DRAW_MODE_1(aa, bb, cc, dd) \ +#define DO_DRAW_MODE_1(_a, _b, _c, _d) \ if (!font) \ font = XLoadFont(disp, "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*"); \ XSetFont(disp, gc, font); \ - if (cc < 3) cc = 3; \ - if (dd < 3) dd = 3; \ - DRAW_H_ARROW(aa + ewin->border->border.left, \ - aa + ewin->border->border.left + cc - 1, \ - bb + ewin->border->border.top + dd - 16); \ - DRAW_H_ARROW(0, \ - aa - 1, \ - bb + ewin->border->border.top + (dd / 2)); \ - DRAW_H_ARROW(aa + cc + ewin->border->border.left + ewin->border->border.right, \ - VRoot.w - 1, \ - bb + ewin->border->border.top + (dd / 2)); \ - DRAW_V_ARROW(bb + ewin->border->border.top, \ - bb + ewin->border->border.top + dd - 1, \ - aa + ewin->border->border.left + 16); \ - DRAW_V_ARROW(0, \ - bb - 1, \ - aa + ewin->border->border.left + (cc / 2)); \ - DRAW_V_ARROW(bb + dd + ewin->border->border.top + ewin->border->border.bottom, \ - VRoot.h - 1, \ - aa + ewin->border->border.left + (cc / 2)); \ - XDrawLine(disp, root, gc, aa, 0, aa, VRoot.h); \ - XDrawLine(disp, root, gc, \ - aa + cc + ewin->border->border.left + \ - ewin->border->border.right - 1, 0, \ - aa + cc + ewin->border->border.left + \ - ewin->border->border.right - 1, VRoot.h); \ - XDrawLine(disp, root, gc, 0, bb, VRoot.w, bb); \ - XDrawLine(disp, root, gc, 0, \ - bb + dd + ewin->border->border.top + \ - ewin->border->border.bottom - 1, VRoot.w, \ - bb + dd + ewin->border->border.top + \ - ewin->border->border.bottom - 1); \ - XDrawRectangle(disp, root, gc, aa + ewin->border->border.left + 1, \ - bb + ewin->border->border.top + 1, cc - 3, dd - 3); + if (_c < 3) _c = 3; \ + if (_d < 3) _d = 3; \ + DRAW_H_ARROW(_a + bl, _a + bl + _c - 1, _b + bt + _d - 16); \ + DRAW_H_ARROW(0, _a - 1, _b + bt + (_d / 2)); \ + DRAW_H_ARROW(_a + _c + bl + br, VRoot.w - 1, _b + bt + (_d / 2)); \ + DRAW_V_ARROW(_b + bt, _b + bt + _d - 1, _a + bl + 16); \ + DRAW_V_ARROW(0, _b - 1, _a + bl + (_c / 2)); \ + DRAW_V_ARROW(_b + _d + bt + bb, VRoot.h - 1, _a + bl + (_c / 2)); \ + XDrawLine(disp, root, gc, _a, 0, _a, VRoot.h); \ + XDrawLine(disp, root, gc, _a + _c + bl + br - 1, 0, _a + _c + bl + br - 1, VRoot.h); \ + XDrawLine(disp, root, gc, 0, _b, VRoot.w, _b); \ + XDrawLine(disp, root, gc, 0, _b + _d + bt + bb - 1, VRoot.w, _b + _d + bt + bb - 1); \ + XDrawRectangle(disp, root, gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 3); -#define DO_DRAW_MODE_2(aa, bb, cc, dd) \ - if (cc < 3) cc = 3; \ - if (dd < 3) dd = 3; \ - XDrawRectangle(disp, root, gc, aa, bb, \ - cc + ewin->border->border.left + \ - ewin->border->border.right - 1, \ - dd + ewin->border->border.top + \ - ewin->border->border.bottom - 1); \ - XDrawRectangle(disp, root, gc, aa + ewin->border->border.left + 1, \ - bb + ewin->border->border.top + 1, cc - 3, dd - 3); +#define DO_DRAW_MODE_2(_a, _b, _c, _d) \ + if (_c < 3) _c = 3; \ + if (_d < 3) _d = 3; \ + XDrawRectangle(disp, root, gc, _a, _b, _c + bl + br - 1, _d + bt + bb - 1); \ + XDrawRectangle(disp, root, gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 3); -#define DO_DRAW_MODE_3(aa, bb, cc, dd) \ +#define DO_DRAW_MODE_3(_a, _b, _c, _d) \ XSetFillStyle(disp, gc, FillStippled); \ XSetStipple(disp, gc, b2); \ - if ((cc + ewin->border->border.left + ewin->border->border.right > 0) && \ - (ewin->border->border.top > 0)) \ - XFillRectangle(disp, root, gc, aa, bb, \ - cc + ewin->border->border.left + \ - ewin->border->border.right, \ - ewin->border->border.top); \ - if ((cc + ewin->border->border.left + ewin->border->border.right > 0) && \ - (ewin->border->border.bottom > 0)) \ - XFillRectangle(disp, root, gc, aa, bb + dd + \ - ewin->border->border.top, \ - cc + ewin->border->border.left + \ - ewin->border->border.right, \ - ewin->border->border.bottom); \ - if ((dd > 0) && (ewin->border->border.left > 0)) \ - XFillRectangle(disp, root, gc, aa, bb + ewin->border->border.top, \ - ewin->border->border.left, \ - dd); \ - if ((dd > 0) && (ewin->border->border.right > 0)) \ - XFillRectangle(disp, root, gc, aa + cc + ewin->border->border.left, \ - bb + ewin->border->border.top, \ - ewin->border->border.right, \ - dd); \ + if ((_c + bl + br > 0) && (bt > 0)) \ + XFillRectangle(disp, root, gc, _a, _b, _c + bl + br, bt); \ + if ((_c + bl + br > 0) && (bb > 0)) \ + XFillRectangle(disp, root, gc, _a, _b + _d + bt, _c + bl + br, bb); \ + if ((_d > 0) && (bl > 0)) \ + XFillRectangle(disp, root, gc, _a, _b + bt, bl, _d); \ + if ((_d > 0) && (br > 0)) \ + XFillRectangle(disp, root, gc, _a + _c + bl, _b + bt, br, _d); \ XSetStipple(disp, gc, b3); \ - if ((cc > 0) && (dd > 0)) \ - XFillRectangle(disp, root, gc, aa + ewin->border->border.left + 1, \ - bb + ewin->border->border.top + 1, cc - 3, dd - 3); + if ((_c > 0) && (_d > 0)) \ + XFillRectangle(disp, root, gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 3); -#define DO_DRAW_MODE_4(aa, bb, cc, dd) \ +#define DO_DRAW_MODE_4(_a, _b, _c, _d) \ XSetFillStyle(disp, gc, FillStippled); \ XSetStipple(disp, gc, b2); \ - XFillRectangle(disp, root, gc, aa, bb, \ - cc + ewin->border->border.left + \ - ewin->border->border.right, \ - dd + ewin->border->border.top + \ - ewin->border->border.bottom); + XFillRectangle(disp, root, gc, _a, _b, _c + bl + br, _d + bt + bb); + if (md == 1) { if (firstlast > 0) diff --git a/src/ewin-ops.c b/src/ewin-ops.c index 85d050ca..cb9e144d 100644 --- a/src/ewin-ops.c +++ b/src/ewin-ops.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "borders.h" #include "desktops.h" #include "emodule.h" #include "eobj.h" diff --git a/src/ewins.c b/src/ewins.c index ef127f37..d25dfa28 100644 --- a/src/ewins.c +++ b/src/ewins.c @@ -23,6 +23,7 @@ */ #include "E.h" #include "aclass.h" +#include "borders.h" #include "desktops.h" #include "ecompmgr.h" #include "emodule.h" @@ -1471,6 +1472,35 @@ EwinGetIconName(const EWin * ewin) return (name && strlen(name)) ? name : NULL; } +const char * +EwinBorderGetName(const EWin * ewin) +{ + return (ewin->border) ? BorderGetName(ewin->border) : "?"; +} + +void +EwinBorderGetSize(const EWin * ewin, int *bl, int *br, int *bt, int *bb) +{ + const Border *b = ewin->border; + + if (!b) + { + *bl = *br = *bt = *bb = 0; + return; + } + + *bl = b->border.left; + *br = b->border.right; + *bt = b->border.top; + *bb = b->border.bottom; +} + +void +EwinBorderUpdateState(EWin * ewin) +{ + EwinBorderDraw(ewin, 0, 0); +} + int EwinIsOnScreen(const EWin * ewin) { diff --git a/src/ewins.h b/src/ewins.h index 3194ed0d..effce77a 100644 --- a/src/ewins.h +++ b/src/ewins.h @@ -27,6 +27,8 @@ #include "eobj.h" #include "xwin.h" +struct _border; +struct _ewinbit; struct _desk; struct _group; struct _snapshot; @@ -68,10 +70,10 @@ struct _ewin char type; Window win_container; - const Border *border; - const Border *normal_border; - const Border *previous_border; - EWinBit *bits; + const struct _border *border; + const struct _border *normal_border; + const struct _border *previous_border; + struct _ewinbit *bits; struct { @@ -300,6 +302,10 @@ void EwinReparent(EWin * ewin, Window parent); Window EwinGetClientWin(const EWin * ewin); const char *EwinGetName(const EWin * ewin); const char *EwinGetIconName(const EWin * ewin); +const char *EwinBorderGetName(const EWin * ewin); +void EwinBorderGetSize(const EWin * ewin, int *bl, int *br, + int *bt, int *bb); +void EwinBorderUpdateState(EWin * ewin); int EwinIsOnScreen(const EWin * ewin); void EwinRememberPositionSet(EWin * ewin); void EwinRememberPositionGet(EWin * ewin, struct _desk *dsk, diff --git a/src/ewmh.c b/src/ewmh.c index fed8bcef..9625a1cb 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -424,10 +424,13 @@ EWMH_SetWindowBorder(const EWin * ewin) if (ewin->border) { - val[0] = ewin->border->border.left; - val[1] = ewin->border->border.right; - val[2] = ewin->border->border.top; - val[3] = ewin->border->border.bottom; + int bl, br, bt, bb; + + EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); + val[0] = (unsigned int)bl; + val[1] = (unsigned int)br; + val[2] = (unsigned int)bt; + val[3] = (unsigned int)bb; } else val[0] = val[1] = val[2] = val[3] = 0; @@ -579,7 +582,7 @@ EWMH_GetWindowType(EWin * ewin) EwinInhSetUser(ewin, move, 1); EwinInhSetUser(ewin, size, 1); ewin->props.donthide = 1; - EwinSetBorderByName(ewin, "BORDERLESS"); + ewin->props.no_border = 1; } else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK) { diff --git a/src/finders.c b/src/finders.c index cf1a9074..a1ffa9aa 100644 --- a/src/finders.c +++ b/src/finders.c @@ -21,6 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "borders.h" #include "ewins.h" #include "groups.h" diff --git a/src/groups.c b/src/groups.c index 9d927ab0..325cdc22 100644 --- a/src/groups.c +++ b/src/groups.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "borders.h" #include "dialog.h" #include "emodule.h" #include "ewins.h" diff --git a/src/hints.c b/src/hints.c index 028bd891..fc200881 100644 --- a/src/hints.c +++ b/src/hints.c @@ -24,7 +24,8 @@ * Feeble attempt to collect hint stuff in one place */ #include "E.h" -#include "desktops.h" /* Should not be here */ +#include "borders.h" /* FIXME - Should not be here */ +#include "desktops.h" /* FIXME - Should not be here */ #include "ecore-e16.h" #include "ewins.h" #include "hints.h" diff --git a/src/iconify.c b/src/iconify.c index 8ec9ed00..77b0fb83 100644 --- a/src/iconify.c +++ b/src/iconify.c @@ -1517,26 +1517,24 @@ IconboxLayout(Iconbox * ib, int *px, int *py, int *pw, int *ph) if (ib->auto_resize) { int add = 0; + int bl, br, bt, bb; + + EwinBorderGetSize(ib->ewin, &bl, &br, &bt, &bb); if (ib->orientation) { add = ib->max; if (ib->ewin->border) { - if ((ib->ewin->border->border.top + - ib->ewin->border->border.bottom + add) > VRoot.h) - add = - VRoot.h - (ib->ewin->border->border.top + - ib->ewin->border->border.bottom); + if ((bt + bb + add) > VRoot.h) + add = VRoot.h - (bt + bb); } y += (((ib->ewin->client.h - add) * ib->auto_resize_anchor) >> 10); h = add; if (ib->ewin->border) { - if ((EoGetY(ib->ewin) + ib->ewin->border->border.top + - ib->ewin->border->border.bottom + add) > VRoot.h) - y = VRoot.h - (ib->ewin->border->border.top + - ib->ewin->border->border.bottom + add); + if ((EoGetY(ib->ewin) + bt + bb + add) > VRoot.h) + y = VRoot.h - (bt + bb + add); } } else @@ -1544,20 +1542,15 @@ IconboxLayout(Iconbox * ib, int *px, int *py, int *pw, int *ph) add = ib->max; if (ib->ewin->border) { - if ((ib->ewin->border->border.left + - ib->ewin->border->border.right + add) > VRoot.w) - add = - VRoot.w - (ib->ewin->border->border.left + - ib->ewin->border->border.right); + if ((bl + br + add) > VRoot.w) + add = VRoot.w - (bl + br); } x += (((ib->ewin->client.w - add) * ib->auto_resize_anchor) >> 10); w = add; if (ib->ewin->border) { - if ((EoGetX(ib->ewin) + ib->ewin->border->border.left + - ib->ewin->border->border.right + add) > VRoot.w) - x = VRoot.w - (ib->ewin->border->border.left + - ib->ewin->border->border.right + add); + if ((EoGetX(ib->ewin) + bl + br + add) > VRoot.w) + x = VRoot.w - (bl + br + add); } } } diff --git a/src/ipc.c b/src/ipc.c index 5cdf6e36..3e56437c 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -23,6 +23,7 @@ */ #include "E.h" #include "aclass.h" +#include "borders.h" /* FIXME - Should not be here */ #include "desktops.h" #include "emodule.h" #include "eobj.h" @@ -964,15 +965,9 @@ IPC_Show(const char *params, Client * c __UNUSED__) static void EwinShowInfo(const EWin * ewin) { - Border NoBorder; - const Border *border; + int bl, br, bt, bb; - border = ewin->border; - if (border == NULL) - { - border = &NoBorder; - memset(&NoBorder, 0, sizeof(Border)); - } + EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); IpcPrintf("WM_NAME %s\n" "WM_ICON_NAME %s\n" @@ -1021,8 +1016,7 @@ EwinShowInfo(const EWin * ewin) #if USE_COMPOSITE EoGetPixmap(ewin), #endif - border->name, border->border.left, border->border.right, - border->border.top, border->border.bottom, + EwinBorderGetName(ewin), bl, br, bt, bb, ewin->icccm.icon_win, ewin->icccm.icon_pmap, ewin->icccm.icon_mask, EwinIsWindowGroupLeader(ewin), EwinGetWindowGroup(ewin), diff --git a/src/menus-misc.c b/src/menus-misc.c index dfb47ebc..1daa0d54 100644 --- a/src/menus-misc.c +++ b/src/menus-misc.c @@ -23,6 +23,7 @@ */ #include "E.h" #include "backgrounds.h" +#include "borders.h" #include "desktops.h" #include "ewins.h" #include "groups.h" @@ -576,7 +577,7 @@ static int BorderNameCompare(void *b1, void *b2) { if (b1 && b2) - return strcmp(((Border *) b1)->name, ((Border *) b2)->name); + return strcmp(BorderGetName(b1), BorderGetName(b2)); return 0; } diff --git a/src/menus.c b/src/menus.c index e6b1a0dd..c954b148 100644 --- a/src/menus.c +++ b/src/menus.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "borders.h" #include "dialog.h" #include "emodule.h" #include "eobj.h" @@ -1439,6 +1440,8 @@ SubmenuShowTimeout(int val __UNUSED__, void *dat) MenuItem *mi; EWin *ewin2, *ewin; struct _mdata *data; + int bl1, br1, bt1, bb1; + int bl2, br2, bt2, bb2; data = (struct _mdata *)dat; if (!data) @@ -1476,8 +1479,10 @@ SubmenuShowTimeout(int val __UNUSED__, void *dat) NULL); /* Sub-menu offsets relative to parent menu origin */ - xo = ewin->border->border.left + mx + mw; - yo = ewin->border->border.top + my - (ewin2->border->border.top + my2); + EwinBorderGetSize(ewin, &bl1, &br1, &bt1, &bb1); + EwinBorderGetSize(ewin2, &bl2, &br2, &bt2, &bb2); + xo = bl1 + mx + mw; + yo = bt1 + my - (bt2 + my2); if (Conf.menus.onscreen) { @@ -1487,10 +1492,8 @@ SubmenuShowTimeout(int val __UNUSED__, void *dat) int xdist = 0, ydist = 0; /* Size of new submenu (may be shaded atm.) */ - ww = mi->child->w + ewin2->border->border.left + - ewin2->border->border.right; - hh = mi->child->h + ewin2->border->border.top + - ewin2->border->border.bottom; + ww = mi->child->w + bl2 + br2; + hh = mi->child->h + bt2 + bb2; if (EoGetX(ewin) + xo + ww > VRoot.w) xdist = VRoot.w - (EoGetX(ewin) + xo + ww); @@ -1739,7 +1742,7 @@ MenuStyleConfigLoad(FILE * ConfigFile) b = FindItem(ms->border_name, 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER); if (b) - b->ref_count++; + BorderIncRefcount(b); } break; default: diff --git a/src/moveresize.c b/src/moveresize.c index d2b2e951..65831c9f 100644 --- a/src/moveresize.c +++ b/src/moveresize.c @@ -42,14 +42,16 @@ static struct void EwinShapeSet(EWin * ewin) { + int bl, br, bt, bb; + ewin->shape_x = EoGetX(ewin); ewin->shape_y = EoGetY(ewin); + if (ewin->state.shaded) { - ewin->shape_w = EoGetW(ewin) - - (ewin->border->border.left + ewin->border->border.right); - ewin->shape_h = EoGetH(ewin) - - (ewin->border->border.top + ewin->border->border.bottom); + EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); + ewin->shape_w = EoGetW(ewin) - (bl + br); + ewin->shape_h = EoGetH(ewin) - (bt + bb); } else { diff --git a/src/size.c b/src/size.c index cba7bd50..5d41e015 100644 --- a/src/size.c +++ b/src/size.c @@ -36,7 +36,7 @@ static void MaxSizeHV(EWin * ewin, const char *resize_type, int direction) { - int x, y, w, h, x1, x2, y1, y2, type; + int x, y, w, h, x1, x2, y1, y2, type, bl, br, bt, bb; EWin *const *lst, *pe; int i, num; @@ -77,6 +77,7 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) x = EoGetX(ewin); h = ewin->client.h; w = ewin->client.w; + EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); switch (type) { @@ -84,14 +85,12 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) if (direction & MAX_HOR) { x = 0; - w = VRoot.w - ewin->border->border.left - - ewin->border->border.right; + w = VRoot.w - bl - br; } if (direction & MAX_VER) { y = 0; - h = VRoot.h - ewin->border->border.top - - ewin->border->border.bottom; + h = VRoot.h - bt - bb; } break; @@ -134,8 +133,7 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) y2 = EoGetY(pe); } y = y1; - h = y2 - y1 - (ewin->border->border.top + - ewin->border->border.bottom); + h = y2 - y1 - (bt + bb); ewin->state.maximized_vert = 1; } @@ -161,8 +159,7 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) x2 = EoGetX(pe); } x = x1; - w = x2 - x1 - (ewin->border->border.left + - ewin->border->border.right); + w = x2 - x1 - (bl + br); ewin->state.maximized_horz = 1; } diff --git a/src/slideout.c b/src/slideout.c index 41fefbcf..34a66687 100644 --- a/src/slideout.c +++ b/src/slideout.c @@ -23,6 +23,7 @@ */ #include "E.h" #include "aclass.h" +#include "borders.h" #include "buttons.h" #include "desktops.h" #include "emodule.h" diff --git a/src/snaps.c b/src/snaps.c index 81737ef7..27c1dd2c 100644 --- a/src/snaps.c +++ b/src/snaps.c @@ -23,6 +23,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "borders.h" #include "desktops.h" #include "dialog.h" #include "ewins.h" @@ -301,9 +302,9 @@ SnapEwinBorder(Snapshot * sn, const EWin * ewin) Efree(sn->border_name); sn->border_name = NULL; if (ewin->previous_border) - sn->border_name = Estrdup(ewin->previous_border->name); + sn->border_name = Estrdup(BorderGetName(ewin->previous_border)); else if (ewin->normal_border) - sn->border_name = Estrdup(ewin->normal_border->name); + sn->border_name = Estrdup(BorderGetName(ewin->normal_border)); } static void diff --git a/src/windowmatch.c b/src/windowmatch.c index b1941773..9805891d 100644 --- a/src/windowmatch.c +++ b/src/windowmatch.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "borders.h" #include "conf.h" #include "desktops.h" #include "emodule.h" diff --git a/src/zoom.c b/src/zoom.c index 624a9d0b..766d8043 100644 --- a/src/zoom.c +++ b/src/zoom.c @@ -229,7 +229,7 @@ Zoom(EWin * ewin) mode = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h); if (mode) { - int x1, y1, x2, y2; + int x1, y1, x2, y2, bl, br, bt, bb; zoom_last_ewin = ewin; zoom_last_x = EoGetX(ewin); @@ -247,8 +247,8 @@ Zoom(EWin * ewin) if (y2 < 0) y2 = 0; RaiseEwin(ewin); - EwinMove(ewin, -ewin->border->border.left + x1, - -ewin->border->border.top + y1); + EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); + EwinMove(ewin, -bl + x1, -bt + y1); FocusToEWin(ewin, FOCUS_SET); EWarpPointer(_EwinGetClientWin(ewin), ewin->client.w / 2, ewin->client.h / 2);