kwo pushed a commit to branch master. http://git.enlightenment.org/e16/e16.git/commit/?id=bf1095d107583d6adc2cbda73487b8c8325e1ad9
commit bf1095d107583d6adc2cbda73487b8c8325e1ad9 Author: Kim Woelders <k...@woelders.dk> Date: Thu Jun 6 22:26:28 2013 +0200 Hide Border struct internals --- src/borders.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/borders.h | 64 +++++------------------------------------ src/ewin-ops.c | 91 ++++++++++++++++++++++++++++++---------------------------- src/ewins.c | 48 +++++++++++++++++-------------- src/groups.c | 2 +- src/menus.c | 19 ++++++------ 6 files changed, 171 insertions(+), 132 deletions(-) diff --git a/src/borders.c b/src/borders.c index c69ff181..f33f0a9c 100644 --- a/src/borders.c +++ b/src/borders.c @@ -49,6 +49,61 @@ #define EWIN_BORDER_TITLE_EVENT_MASK \ (EWIN_BORDER_PART_EVENT_MASK) +typedef struct { + int min, max; +} WinLimit; + +typedef struct { + int originbox; + struct { + int percent; + int absolute; + } x , y; +} WinPoint; + +typedef struct { + WinLimit width, height; + WinPoint topleft, bottomright; +} Geometry; + +typedef struct { + Geometry geom; + ImageClass *iclass; + ActionClass *aclass; + TextClass *tclass; + ECursor *ec; + signed char ontop; + int flags; + char keep_for_shade; +} WinPart; + +struct _border { + dlist_t list; + char *name; + char *group_border_name; + EImageBorder border; + int num_winparts; + WinPart *part; + char no_extent; + char changes_shape; + char shadedir; + char throwaway; + unsigned int ref_count; + ActionClass *aclass; +}; + +struct _ewinbit { + EWin *ewin; /* Belongs to */ + Win win; + int x, y, w, h; + int cx, cy, cw, ch; + char state; + char expose; + char left; + ImageState *is; + TextState *ts; +}; + static LIST_HEAD(border_list); static void _BorderDestroy(Border * b); @@ -485,6 +540,24 @@ BorderCanShade(const Border * b) return !b->no_extent; } +const EImageBorder * +BorderGetSize(const Border * b) +{ + return &b->border; +} + +int +BorderGetShadedir(const Border * b) +{ + return b->shadedir; +} + +ActionClass * +BorderGetAclass(const Border * b) +{ + return b->aclass; +} + void EwinBorderSelect(EWin * ewin) { @@ -670,6 +743,12 @@ EwinBorderSetInitially(EWin * ewin, const char *name) _EwinBorderAssign(ewin, BorderFind(name)); } +const Border * +EwinBorderGetGroupBorder(const EWin * ewin) +{ + return BorderFind(ewin->border->group_border_name); +} + static Border * _BorderCreate(const char *name) { diff --git a/src/borders.h b/src/borders.h index f7a9eeab..27f86795 100644 --- a/src/borders.h +++ b/src/borders.h @@ -26,69 +26,17 @@ #include "eimage.h" #include "etypes.h" -#include "list.h" #include "xtypes.h" -typedef struct { - int min, max; -} WinLimit; - -typedef struct { - int originbox; - struct { - int percent; - int absolute; - } x , y; -} WinPoint; - -typedef struct { - WinLimit width, height; - WinPoint topleft, bottomright; -} Geometry; - -typedef struct { - Geometry geom; - ImageClass *iclass; - ActionClass *aclass; - TextClass *tclass; - ECursor *ec; - signed char ontop; - int flags; - char keep_for_shade; -} WinPart; - -struct _border { - dlist_t list; - char *name; - char *group_border_name; - EImageBorder border; - int num_winparts; - WinPart *part; - char no_extent; - char changes_shape; - char shadedir; - char throwaway; - unsigned int ref_count; - ActionClass *aclass; -}; - -struct _ewinbit { - EWin *ewin; /* Belongs to */ - Win win; - int x, y, w, h; - int cx, cy, cw, ch; - char state; - char expose; - char left; - ImageState *is; - TextState *ts; -}; - -/* borders.c */ Border *BorderFind(const char *name); const char *BorderGetName(const Border * b); int BorderCanShade(const Border * b); +const EImageBorder *BorderGetSize(const Border * b); +int BorderGetShadedir(const Border * b); +ActionClass *BorderGetAclass(const Border * b); + int BorderConfigLoad(FILE * fs); + void EwinBorderSelect(EWin * ewin); void EwinBorderDetach(EWin * ewin); void EwinBorderSetTo(EWin * ewin, const Border * b); @@ -98,8 +46,10 @@ void EwinBorderMinShadeSize(const EWin * ewin, int *mw, int *mh); void EwinBorderUpdateInfo(EWin * ewin); void EwinBorderChange(EWin * ewin, const Border * b, int normal); void EwinBorderSetInitially(EWin * ewin, const char *name); +const Border *EwinBorderGetGroupBorder(const EWin * ewin); int BorderWinpartIndex(EWin * ewin, Win win); void BorderCheckState(EWin * ewin, XEvent * ev); + Border *BorderCreateFiller(int w, int h, int sw, int sh); Border **BordersGetList(int *pnum); diff --git a/src/ewin-ops.c b/src/ewin-ops.c index 689d9e7d..ddf77751 100644 --- a/src/ewin-ops.c +++ b/src/ewin-ops.c @@ -174,6 +174,7 @@ doEwinMoveResize(EWin * ewin, Desk * dsk, int x, int y, int w, int h, int flags) EWin **lst; int i, num; Desk *pdesk; + const EImageBorder *pad; if (ewin->state.zoomed) return; @@ -191,6 +192,8 @@ doEwinMoveResize(EWin * ewin, Desk * dsk, int x, int y, int w, int h, int flags) reparent = move = resize = raise = 0; floating = EoIsFloating(ewin); + pad = BorderGetSize(ewin->border); + if (flags & MRF_FLOAT) { if (floating == 0) @@ -310,10 +313,8 @@ doEwinMoveResize(EWin * ewin, Desk * dsk, int x, int y, int w, int h, int flags) } else { - w = ewin->client.w + ewin->border->border.left + - ewin->border->border.right; - h = ewin->client.h + ewin->border->border.top + - ewin->border->border.bottom; + w = ewin->client.w + pad->left + pad->right; + h = ewin->client.h + pad->top + pad->bottom; } } @@ -321,8 +322,8 @@ doEwinMoveResize(EWin * ewin, Desk * dsk, int x, int y, int w, int h, int flags) dy = y - EoGetY(ewin); if ((dx != 0) || (dy != 0)) move = 1; - ewin->client.x = x + ewin->border->border.left; - ewin->client.y = y + ewin->border->border.top; + ewin->client.x = x + pad->left; + ewin->client.y = y + pad->top; #if 0 Eprintf("repa=%d float=%d raise=%d move=%d resz=%d\n", @@ -355,9 +356,7 @@ doEwinMoveResize(EWin * ewin, Desk * dsk, int x, int y, int w, int h, int flags) if (flags & MRF_RESIZE) { if (!ewin->state.shaded) - EMoveResizeWindow(EwinGetClientConWin(ewin), - ewin->border->border.left, - ewin->border->border.top, + EMoveResizeWindow(EwinGetClientConWin(ewin), pad->left, pad->top, ewin->client.w, ewin->client.h); #if USE_CONTAINER_WIN EMoveResizeWindow(EwinGetClientWin(ewin), 0, 0, ewin->client.w, @@ -764,7 +763,7 @@ EwinInstantShade(EWin * ewin, int force) EwinBorderMinShadeSize(ewin, &minw, &minh); - switch (ewin->border->shadedir) + switch (BorderGetShadedir(ewin->border)) { default: case SHADE_LEFT: @@ -802,6 +801,7 @@ EwinInstantUnShade(EWin * ewin) { XSetWindowAttributes att; int x, y, w, h; + const EImageBorder *pad; if (ewin->state.zoomed) return; @@ -811,18 +811,18 @@ EwinInstantUnShade(EWin * ewin) x = EoGetX(ewin); y = EoGetY(ewin); - switch (ewin->border->shadedir) + pad = BorderGetSize(ewin->border); + + switch (BorderGetShadedir(ewin->border)) { default: break; case SHADE_RIGHT: - w = ewin->client.w + ewin->border->border.left + - ewin->border->border.right; + w = ewin->client.w + pad->left + pad->right; x = x + EoGetW(ewin) - w; break; case SHADE_DOWN: - h = ewin->client.h + ewin->border->border.top + - ewin->border->border.bottom; + h = ewin->client.h + pad->top + pad->bottom; y = y + EoGetH(ewin) - h; break; } @@ -871,6 +871,7 @@ _EwinShadeStart(_ewin_shade_data * esd) EWin *ewin = esd->ewin; int minw, minh; XSetWindowAttributes att; + const EImageBorder *pad; esd->start.x = EoGetX(ewin); esd->start.y = EoGetY(ewin); @@ -883,19 +884,21 @@ _EwinShadeStart(_ewin_shade_data * esd) EwinBorderMinShadeSize(ewin, &minw, &minh); - switch (ewin->border->shadedir) + pad = BorderGetSize(ewin->border); + + switch (BorderGetShadedir(ewin->border)) { default: case SHADE_LEFT: att.win_gravity = EastGravity; esd->a = esd->start.w; - esd->b = ewin->border->border.left + ewin->border->border.right; + esd->b = pad->left + pad->right; esd->final.w = minw; break; case SHADE_RIGHT: att.win_gravity = WestGravity; esd->a = esd->start.w; - esd->b = ewin->border->border.left + ewin->border->border.right; + esd->b = pad->left + pad->right; esd->c = esd->start.x + esd->start.w; esd->final.x = esd->c - minw; esd->final.w = minw; @@ -903,13 +906,13 @@ _EwinShadeStart(_ewin_shade_data * esd) case SHADE_UP: att.win_gravity = SouthGravity; esd->a = esd->start.h; - esd->b = ewin->border->border.top + ewin->border->border.bottom; + esd->b = pad->top + pad->bottom; esd->final.h = minh; break; case SHADE_DOWN: att.win_gravity = SouthGravity; esd->a = esd->start.h; - esd->b = ewin->border->border.top + ewin->border->border.bottom; + esd->b = pad->top + pad->bottom; esd->c = esd->start.y + esd->start.h; esd->final.y = esd->c - minh; esd->final.h = minh; @@ -981,6 +984,7 @@ _EwinUnshadeStart(_ewin_shade_data * esd) EWin *ewin = esd->ewin; int cow __UNUSED__, coh __UNUSED__, clx, cly; XSetWindowAttributes att; + const EImageBorder *pad; esd->start.x = EoGetX(ewin); esd->start.y = EoGetY(ewin); @@ -997,12 +1001,14 @@ _EwinUnshadeStart(_ewin_shade_data * esd) clx = cly = 0; - switch (ewin->border->shadedir) + pad = BorderGetSize(ewin->border); + + switch (BorderGetShadedir(ewin->border)) { default: case SHADE_LEFT: att.win_gravity = NorthEastGravity; - esd->a = ewin->border->border.left + ewin->border->border.right; + esd->a = pad->left + pad->right; esd->b = ewin->client.w + esd->a; esd->c = 0; /* Not used */ esd->final.w = esd->b; @@ -1011,7 +1017,7 @@ _EwinUnshadeStart(_ewin_shade_data * esd) break; case SHADE_RIGHT: att.win_gravity = NorthWestGravity; - esd->a = ewin->border->border.left + ewin->border->border.right; + esd->a = pad->left + pad->right; esd->b = ewin->client.w + esd->a; esd->c = esd->start.x + esd->start.w; /* NB! w != a is possible */ esd->final.x = esd->c - esd->b; @@ -1020,7 +1026,7 @@ _EwinUnshadeStart(_ewin_shade_data * esd) break; case SHADE_UP: att.win_gravity = SouthEastGravity; - esd->a = ewin->border->border.top + ewin->border->border.bottom; + esd->a = pad->top + pad->bottom; esd->b = ewin->client.h + esd->a; esd->c = 0; /* Not used */ esd->final.h = esd->b; @@ -1029,7 +1035,7 @@ _EwinUnshadeStart(_ewin_shade_data * esd) break; case SHADE_DOWN: att.win_gravity = SouthEastGravity; - esd->a = ewin->border->border.top + ewin->border->border.bottom; + esd->a = pad->top + pad->bottom; esd->b = ewin->client.h + esd->a; esd->c = esd->start.y + esd->start.h; /* NB! h != a is possible */ esd->final.y = esd->c - esd->b; @@ -1042,15 +1048,11 @@ _EwinUnshadeStart(_ewin_shade_data * esd) EChangeWindowAttributes(EwinGetClientWin(ewin), CWWinGravity, &att); EWindowSync(EwinGetClientWin(ewin)); /* Gravity - recache */ #if USE_CONTAINER_WIN - EMoveResizeWindow(ewin->win_container, - ewin->border->border.left, ewin->border->border.top, - cow, coh); + EMoveResizeWindow(ewin->win_container, pad->left, pad->top, cow, coh); EMoveResizeWindow(EwinGetClientWin(ewin), clx, cly, ewin->client.w, ewin->client.h); #else - EMoveResizeWindow(EwinGetClientWin(ewin), - ewin->border->border.left + clx, - ewin->border->border.top + cly, + EMoveResizeWindow(EwinGetClientWin(ewin), pad->left + clx, pad->top + cly, ewin->client.w, ewin->client.h); #endif } @@ -1060,6 +1062,9 @@ _EwinUnshadeEnd(_ewin_shade_data * esd) { EWin *ewin = esd->ewin; XSetWindowAttributes att; +#if USE_CONTAINER_WIN + const EImageBorder *pad = BorderGetSize(ewin->border); +#endif EoMoveResize(ewin, esd->final.x, esd->final.y, esd->final.w, esd->final.h); @@ -1070,8 +1075,7 @@ _EwinUnshadeEnd(_ewin_shade_data * esd) #if USE_CONTAINER_WIN EMoveResizeWindow(EwinGetClientWin(ewin), 0, 0, ewin->client.w, ewin->client.h); - EMoveResizeWindow(ewin->win_container, - ewin->border->border.left, ewin->border->border.top, + EMoveResizeWindow(ewin->win_container, pad->left, pad->top, ewin->client.w, ewin->client.h); #else EWindowSync(EwinGetClientWin(ewin)); /* Gravity - recache */ @@ -1097,6 +1101,7 @@ _EwinShadeRun(EObj * eobj, int remaining, void *state) EWin *ewin = (EWin *) eobj; int k, x, y, w, h, ww, hh; int cow __UNUSED__, coh __UNUSED__, shx, shy; + const EImageBorder *pad; k = 1024 - remaining; @@ -1110,14 +1115,16 @@ _EwinShadeRun(EObj * eobj, int remaining, void *state) shx = shy = 0; - switch (ewin->border->shadedir) + pad = BorderGetSize(ewin->border); + + switch (BorderGetShadedir(ewin->border)) { default: case SHADE_LEFT: w = ((esd->a * (1024 - k)) + (esd->b * k)) >> 10; if (w <= 0) w = 1; - ww = w - (ewin->border->border.left + ewin->border->border.right); + ww = w - (pad->left + pad->right); if (ww <= 0) ww = 1; cow = ww; @@ -1128,7 +1135,7 @@ _EwinShadeRun(EObj * eobj, int remaining, void *state) if (w <= 0) w = 1; x = esd->c - w; - ww = w - (ewin->border->border.left + ewin->border->border.right); + ww = w - (pad->left + pad->right); if (ww <= 0) ww = 1; cow = ww; @@ -1137,7 +1144,7 @@ _EwinShadeRun(EObj * eobj, int remaining, void *state) h = ((esd->a * (1024 - k)) + (esd->b * k)) >> 10; if (h <= 0) h = 1; - hh = h - (ewin->border->border.top + ewin->border->border.bottom); + hh = h - (pad->top + pad->bottom); if (hh <= 0) hh = 1; coh = hh; @@ -1148,7 +1155,7 @@ _EwinShadeRun(EObj * eobj, int remaining, void *state) if (h <= 0) h = 1; y = esd->c - h; - hh = h - (ewin->border->border.top + ewin->border->border.bottom); + hh = h - (pad->top + pad->bottom); if (hh <= 0) hh = 1; coh = hh; @@ -1156,13 +1163,9 @@ _EwinShadeRun(EObj * eobj, int remaining, void *state) break; } #if USE_CONTAINER_WIN - EMoveResizeWindow(ewin->win_container, - ewin->border->border.left, - ewin->border->border.top, cow, coh); + EMoveResizeWindow(ewin->win_container, pad->left, pad->top, cow, coh); #else - EMoveResizeWindow(EwinGetClientWin(ewin), - ewin->border->border.left + shx, - ewin->border->border.top + shy, + EMoveResizeWindow(EwinGetClientWin(ewin), pad->left + shx, pad->top + shy, ewin->client.w, ewin->client.h); #endif if (ewin->state.shaped) diff --git a/src/ewins.c b/src/ewins.c index 1c848a3e..c40c1cb4 100644 --- a/src/ewins.c +++ b/src/ewins.c @@ -313,22 +313,22 @@ EwinManage(EWin * ewin) static void EwinSetGeometry(EWin * ewin) { - int x, y, l, r, t, b; + int x, y; int grav; + const EImageBorder *pad; grav = (ewin->state.identified) ? StaticGravity : ewin->icccm.grav; EwinGetPosition(ewin, ewin->client.x, ewin->client.y, grav, &x, &y); - l = ewin->border->border.left; - r = ewin->border->border.right; - t = ewin->border->border.top; - b = ewin->border->border.bottom; + pad = BorderGetSize(ewin->border); - ewin->client.x = x + l; - ewin->client.y = y + t; + ewin->client.x = x + pad->left; + ewin->client.y = y + pad->top; - EoMoveResize(ewin, x, y, ewin->client.w + l + r, ewin->client.h + t + b); + EoMoveResize(ewin, x, y, + ewin->client.w + pad->left + pad->right, + ewin->client.h + pad->top + pad->bottom); } static void @@ -570,10 +570,13 @@ void EwinGetPosition(const EWin * ewin, int x, int y, int grav, int *px, int *py) { int bw, bd_lr, bd_tb; + const EImageBorder *pad; bw = ewin->client.bw; - bd_lr = ewin->border->border.left + ewin->border->border.right; - bd_tb = ewin->border->border.top + ewin->border->border.bottom; + + pad = BorderGetSize(ewin->border); + bd_lr = pad->left + pad->right; + bd_tb = pad->top + pad->bottom; if (grav == 0) grav = ewin->icccm.grav; @@ -596,7 +599,7 @@ EwinGetPosition(const EWin * ewin, int x, int y, int grav, int *px, int *py) x -= bd_lr - bw; break; case StaticGravity: - x -= ewin->border->border.left; + x -= pad->left; break; default: break; @@ -620,7 +623,7 @@ EwinGetPosition(const EWin * ewin, int x, int y, int grav, int *px, int *py) y -= bd_tb - bw; break; case StaticGravity: - y -= ewin->border->border.top; + y -= pad->top; break; default: break; @@ -1116,12 +1119,13 @@ EwinWithdraw(EWin * ewin, Win to) if (xwin == EwinGetContainerXwin(ewin)) { + const EImageBorder *pad = BorderGetSize(ewin->border); + /* Park the client window on the new root */ x = ewin->client.x; y = ewin->client.y; ETranslateCoordinates(EwinGetClientWin(ewin), VROOT, - -ewin->border->border.left, - -ewin->border->border.top, &x, &y, NULL); + -pad->left, -pad->top, &x, &y, NULL); EReparentWindow(EwinGetClientWin(ewin), to, x, y); HintsDelWindowHints(ewin); } @@ -1659,18 +1663,18 @@ EwinBorderGetName(const EWin * ewin) void EwinBorderGetSize(const EWin * ewin, int *bl, int *br, int *bt, int *bb) { - const Border *b = ewin->border; + const EImageBorder *pad = BorderGetSize(ewin->border); - if (!b) + if (!pad) { *bl = *br = *bt = *bb = 0; return; } - *bl = b->border.left; - *br = b->border.right; - *bt = b->border.top; - *bb = b->border.bottom; + *bl = pad->left; + *br = pad->right; + *bt = pad->top; + *bb = pad->bottom; } void @@ -2523,8 +2527,8 @@ EwinHandleEventsClient(Win win __UNUSED__, XEvent * ev, void *prm) case FocusOut: if (ev->xfocus.detail == NotifyInferior) break; - if (ewin->border->aclass) - ActionclassEvent(ewin->border->aclass, ev, ewin); + if (BorderGetAclass(ewin->border)) + ActionclassEvent(BorderGetAclass(ewin->border), ev, ewin); FocusHandleChange(ewin, ev); break; diff --git a/src/groups.c b/src/groups.c index 37e06d33..f272babf 100644 --- a/src/groups.c +++ b/src/groups.c @@ -535,7 +535,7 @@ _EwinGroupsShowHide(EWin * ewin, int group_index, char onoff) for (i = 0; i < num; i++) { if (onoff == SET_ON) - b = BorderFind(gwins[i]->border->group_border_name); + b = EwinBorderGetGroupBorder(gwins[i]); else b = gwins[i]->normal_border; diff --git a/src/menus.c b/src/menus.c index 359801c4..703dbc23 100644 --- a/src/menus.c +++ b/src/menus.c @@ -336,18 +336,21 @@ MenuShow(Menu * m, char noshow) if (b) { int sx, sy, sw, sh; + const EImageBorder *pad; + + pad = BorderGetSize(b); head_num = ScreenGetGeometryByPointer(&sx, &sy, &sw, &sh); - if (wx > sx + sw - mw - b->border.right) - wx = sx + sw - mw - b->border.right; - if (wx < sx + b->border.left) - wx = sx + b->border.left; + if (wx > sx + sw - mw - pad->right) + wx = sx + sw - mw - pad->right; + if (wx < sx + pad->left) + wx = sx + pad->left; - if (wy > sy + sh - mh - b->border.bottom) - wy = sy + sh - mh - b->border.bottom; - if (wy < sy + b->border.top) - wy = sy + b->border.top; + if (wy > sy + sh - mh - pad->bottom) + wy = sy + sh - mh - pad->bottom; + if (wy < sy + pad->top) + wy = sy + pad->top; } } --