From 5c756e0076eab9298fd02ff37c6a9596f7ff9549 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sun, 21 Aug 2005 13:21:48 +0000 Subject: [PATCH] Button related cleanups. SVN revision: 16256 --- src/E.h | 38 +----------- src/Makefile.am | 1 + src/arrange.c | 1 + src/buttons.c | 156 ++++++++++++++++++++++-------------------------- src/buttons.h | 54 +++++++++++++++++ src/config.c | 1 + src/desktops.c | 124 ++++++++++---------------------------- src/eobj.h | 7 +++ src/ewins.c | 19 ++++++ src/ewins.h | 1 + src/menus.c | 7 --- src/slideout.c | 53 ++++++++-------- 12 files changed, 214 insertions(+), 248 deletions(-) create mode 100644 src/buttons.h diff --git a/src/E.h b/src/E.h index 1f668d97..f023cd8e 100644 --- a/src/E.h +++ b/src/E.h @@ -333,7 +333,6 @@ typedef struct _dialog Dialog; typedef struct _ditem DItem; typedef struct _snapshot Snapshot; typedef struct _group Group; -typedef struct _button Button; typedef struct _background Background; typedef struct _ecursor ECursor; typedef struct _efont Efont; @@ -485,6 +484,7 @@ struct _textclass unsigned int ref_count; }; +struct _button; typedef struct { EObj o; @@ -492,7 +492,7 @@ typedef struct char viewable; char dirty_stack; Background *bg; - Button *tag; + struct _button *tag; int current_area_x; int current_area_y; long event_mask; @@ -1035,39 +1035,6 @@ Border *BorderCreateFiller(int left, int right, int top, int bottom); void BordersSetupFallback(void); -/* buttons.c */ -int ButtonsConfigLoad(FILE * fs); -Button *ButtonCreate(const char *name, int id, ImageClass * ic, - ActionClass * aclass, TextClass * tclass, - const char *label, char ontop, int flags, - int minw, int maxw, int minh, int maxh, int xo, - int yo, int xa, int xr, int ya, int yr, - int xsr, int xsa, int ysr, int ysa, char simg, - int desk, char sticky); -void ButtonDestroy(Button * b); -void ButtonShow(Button * b); -void ButtonHide(Button * b); -void ButtonToggle(Button * b); -void ButtonDraw(Button * b); -void ButtonDrawWithState(Button * b, int state); -void ButtonMoveToDesktop(Button * b, int desk); -void ButtonMoveToCoord(Button * b, int x, int y); -void ButtonMoveRelative(Button * b, int dx, int dy); -void ButtonIncRefcount(Button * b); -void ButtonDecRefcount(Button * b); -void ButtonSwallowInto(Button * bi, EObj * eo); -int ButtonGetRefcount(const Button * b); -int ButtonGetDesk(const Button * b); -int ButtonGetInfo(const Button * b, RectBox * r, int desk); -Window ButtonGetWin(const Button * b); -int ButtonGetWidth(const Button * b); -int ButtonGetHeight(const Button * b); -int ButtonIsFixed(const Button * b); -int ButtonIsInternal(const Button * b); -int ButtonDoShowDefault(const Button * b); -int ButtonEmbedWindow(Button * ButtonToUse, - Window WindowToEmbed); - /* cmclass.c */ #if ENABLE_COLOR_MODIFIERS void CreateCurve(ModCurve * c); @@ -1558,7 +1525,6 @@ void ITApply(Window win, ImageClass * ic, ImageState * is, int w, /* ipc.c */ void __PRINTF__ IpcPrintf(const char *fmt, ...); int HandleIPC(const char *params, Client * c); -void ButtonIPC(int val, void *data); int EFunc(EWin * ewin, const char *params); /* lang.c */ diff --git a/src/Makefile.am b/src/Makefile.am index 69c203e0..66f81b27 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,7 @@ e16_SOURCES = \ backgrounds.c \ borders.c \ buttons.c \ + buttons.h \ cmclass.c \ comms.c \ conf.h \ diff --git a/src/arrange.c b/src/arrange.c index 5b71f997..1c43dd3b 100644 --- a/src/arrange.c +++ b/src/arrange.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "buttons.h" #include "ewins.h" static int diff --git a/src/buttons.c b/src/buttons.c index 36524096..bb983ffd 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "buttons.h" #include "emodule.h" #include "tooltips.h" #include "xwin.h" @@ -74,6 +75,30 @@ static struct static void ButtonHandleEvents(XEvent * ev, void *btn); +void +ButtonIncRefcount(Button * b) +{ + b->ref_count++; +} + +void +ButtonDecRefcount(Button * b) +{ + b->ref_count--; +} + +static int +ButtonIsFixed(const Button * b) +{ + return b->flags & FLAG_FIXED; +} + +static int +ButtonIsInternal(const Button * b) +{ + return b->internal; +} + Button * ButtonCreate(const char *name, int id, ImageClass * iclass, ActionClass * aclass, TextClass * tclass, const char *label, @@ -229,6 +254,22 @@ ButtonCalc(Button * b) EoMoveResize(b, x, y, w, h); } +static void +ButtonDraw(Button * b) +{ + ITApply(EoGetWin(b), b->iclass, NULL, EoGetW(b), EoGetH(b), + b->state, 0, 0, 0, ST_BUTTON, b->tclass, NULL, b->label); +} + +#if 0 /* Unused */ +void +ButtonDrawWithState(Button * b, int state) +{ + b->state = state; + ButtonDraw(b); +} +#endif + void ButtonShow(Button * b) { @@ -251,7 +292,7 @@ ButtonSwallowInto(Button * b, EObj * eo) EMapWindow(EoGetWin(b)); } -void +static void ButtonMoveToDesktop(Button * b, int desk) { Desk *d; @@ -273,7 +314,7 @@ ButtonHide(Button * b) EoUnmap(b); } -void +static void ButtonToggle(Button * b) { if (b->internal) @@ -285,26 +326,12 @@ ButtonToggle(Button * b) ButtonShow(b); } -void -ButtonDraw(Button * b) -{ - ITApply(EoGetWin(b), b->iclass, NULL, EoGetW(b), EoGetH(b), - b->state, 0, 0, 0, ST_BUTTON, b->tclass, NULL, b->label); -} - -void -ButtonDrawWithState(Button * b, int state) -{ - b->state = state; - ButtonDraw(b); -} - void ButtonMoveToCoord(Button * b, int x, int y) { int rx, ry, relx, rely, absx, absy; - if (b->flags & FLAG_FIXED) + if (ButtonIsFixed(b)) return; if ((x + (EoGetW(b) >> 1)) < (VRoot.w / 3)) @@ -345,40 +372,10 @@ ButtonMoveRelative(Button * b, int dx, int dy) ButtonMoveToCoord(b, EoGetX(b) + dx, EoGetY(b) + dy); } -void -ButtonIncRefcount(Button * b) -{ - b->ref_count++; -} - -void -ButtonDecRefcount(Button * b) -{ - b->ref_count--; -} - -static const char * -ButtonGetName(const Button * b) -{ - return EoGetName(b); -} - -int -ButtonGetRefcount(const Button * b) -{ - return b->ref_count; -} - -int -ButtonGetDesk(const Button * b) -{ - return EoGetDesk(b); -} - int ButtonGetInfo(const Button * b, RectBox * r, int desk) { - if (!EoIsShown(b) || b->internal) + if (!EoIsShown(b) || ButtonIsInternal(b)) return -1; if (!EoIsSticky(b) && EoGetDesk(b) != desk) return -1; @@ -393,36 +390,6 @@ ButtonGetInfo(const Button * b, RectBox * r, int desk) return 0; } -Window -ButtonGetWin(const Button * b) -{ - return EoGetWin(b); -} - -int -ButtonGetWidth(const Button * b) -{ - return EoGetW(b); -} - -int -ButtonGetHeight(const Button * b) -{ - return EoGetH(b); -} - -int -ButtonIsFixed(const Button * b) -{ - return b->flags & FLAG_FIXED; -} - -int -ButtonIsInternal(const Button * b) -{ - return b->internal; -} - int ButtonDoShowDefault(const Button * b) { @@ -487,6 +454,25 @@ ButtonDragEnd(Button * b) autosave(); } +void +ButtonsMoveStickyToDesk(int desk) +{ + Button **lst, *btn; + int i, num; + + lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); + for (i = 0; i < num; i++) + { + btn = lst[i]; + if (!EoIsSticky(btn) || ButtonIsInternal(btn)) + continue; + + ButtonMoveToDesktop(btn, desk); + } + if (lst) + Efree(lst); +} + /* * Button event handlers */ @@ -519,7 +505,7 @@ ButtonEventMouseDown(Button * b, XEvent * ev) b->state = STATE_CLICKED; ButtonDraw(b); - if (!b->internal) + if (!ButtonIsInternal(b)) { ActionClass *ac; @@ -1062,9 +1048,9 @@ doHideShowButton(const char *params) lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); for (i = 0; i < num; i++) { - if (matchregexp(ss, ButtonGetName(lst[i]))) + if (matchregexp(ss, EoGetName(lst[i]))) { - if (strcmp(ButtonGetName(lst[i]), + if (strcmp(EoGetName(lst[i]), "_DESKTOP_DESKRAY_DRAG_CONTROL")) ButtonToggle(lst[i]); } @@ -1081,9 +1067,9 @@ doHideShowButton(const char *params) lst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 0); for (i = 0; i < num; i++) { - if (!matchregexp(ss, ButtonGetName(lst[i]))) + if (!matchregexp(ss, EoGetName(lst[i]))) { - if (strcmp(ButtonGetName(lst[i]), + if (strcmp(EoGetName(lst[i]), "_DESKTOP_DESKRAY_DRAG_CONTROL")) ButtonToggle(lst[i]); } @@ -1096,7 +1082,7 @@ doHideShowButton(const char *params) lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); for (i = 0; i < num; i++) { - if (strcmp(ButtonGetName(lst[i]), "_DESKTOP_DESKRAY_DRAG_CONTROL")) + if (strcmp(EoGetName(lst[i]), "_DESKTOP_DESKRAY_DRAG_CONTROL")) ButtonToggle(lst[i]); } if (lst) @@ -1138,7 +1124,7 @@ ButtonsIpc(const char *params, Client * c __UNUSED__) IpcPrintf("%#lx %2d %2d %2d %5d+%5d %5dx%5d %s\n", EoGetWin(b), EoGetDesk(b), EoIsSticky(b), EoGetLayer(b), EoGetX(b), EoGetY(b), EoGetW(b), EoGetH(b), - ButtonGetName(lst[i])); + EoGetName(lst[i])); } if (lst) Efree(lst); diff --git a/src/buttons.h b/src/buttons.h new file mode 100644 index 00000000..4c616f7e --- /dev/null +++ b/src/buttons.h @@ -0,0 +1,54 @@ +/* + * 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 _BUTTONS_H_ +#define _BUTTONS_H_ + +typedef struct _button Button; + +/* buttons.c */ +Button *ButtonCreate(const char *name, int id, ImageClass * ic, + ActionClass * aclass, TextClass * tclass, + const char *label, char ontop, int flags, + int minw, int maxw, int minh, int maxh, int xo, + int yo, int xa, int xr, int ya, int yr, + int xsr, int xsa, int ysr, int ysa, char simg, + int desk, char sticky); +void ButtonDestroy(Button * b); +void ButtonShow(Button * b); +void ButtonHide(Button * b); +void ButtonMoveToCoord(Button * b, int x, int y); +void ButtonMoveRelative(Button * b, int dx, int dy); +void ButtonIncRefcount(Button * b); +void ButtonDecRefcount(Button * b); +void ButtonSwallowInto(Button * bi, EObj * eo); +int ButtonGetInfo(const Button * b, RectBox * r, int desk); +int ButtonDoShowDefault(const Button * b); +int ButtonEmbedWindow(Button * ButtonToUse, + Window WindowToEmbed); + +void ButtonsMoveStickyToDesk(int desk); +int ButtonsConfigLoad(FILE * fs); + +#endif /* _BUTTONS_H_ */ diff --git a/src/config.c b/src/config.c index b2acfacb..7fa3ad9c 100644 --- a/src/config.c +++ b/src/config.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "buttons.h" #include "conf.h" #include "tooltips.h" #include diff --git a/src/desktops.c b/src/desktops.c index a741febd..23509066 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -22,11 +22,12 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" -#include +#include "buttons.h" #include "emodule.h" #include "ewins.h" #include "tooltips.h" #include "xwin.h" +#include #define EDESK_EVENT_MASK \ (ButtonPressMask | ButtonReleaseMask | \ @@ -308,35 +309,35 @@ DeskControlsCreate(Desk * d) } static void -DeskControlsDestroy(Desk * d) +DeskControlsDestroy(Desk * d, int id) { Button **blst; int num, i; - blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 1); - if (blst) - { - for (i = 0; i < num; i++) - if (ButtonGetDesk(blst[i]) == d->num) - ButtonDestroy(blst[i]); - Efree(blst); - } + blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, id); + if (!blst) + return; + + for (i = 0; i < num; i++) + if (EobjGetDesk((EObj *) (blst[i])) == d->num) + ButtonDestroy(blst[i]); + Efree(blst); } static void -DeskControlsShow(Desk * d) +DeskControlsShow(Desk * d, int id) { Button **blst; int num, i; - blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 1); - if (blst) - { - for (i = 0; i < num; i++) - if (ButtonGetDesk(blst[i]) == d->num) - ButtonShow(blst[i]); - Efree(blst); - } + blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, id); + if (!blst) + return; + + for (i = 0; i < num; i++) + if (EobjGetDesk((EObj *) (blst[i])) == d->num) + ButtonShow(blst[i]); + Efree(blst); } static void @@ -372,7 +373,7 @@ DeskConfigure(Desk * d) unsigned int rnd; DeskControlsCreate(d); - DeskControlsShow(d); + DeskControlsShow(d, 1); bg = desks.bg[d->num]; if (bg) @@ -443,33 +444,12 @@ DeskCreate(int desk, int configure) static void DeskDestroy(Desk * d) { - Button **blst; - int num, i; - - if (d->num <= 0) - return; - ModulesSignal(ESIGNAL_DESK_REMOVED, ((void *)(long)(d->num))); EventCallbackUnregister(EoGetWin(d), 0, DesktopHandleEvents, d); - blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 1); - for (i = 0; i < num; i++) - { - if (ButtonGetDesk(blst[i]) == d->num) - ButtonDestroy(blst[i]); - } - if (blst) - Efree(blst); - - blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 2); - for (i = 0; i < num; i++) - { - if (ButtonGetDesk(blst[i]) == d->num) - ButtonDestroy(blst[i]); - } - if (blst) - Efree(blst); + DeskControlsDestroy(d, 1); + DeskControlsDestroy(d, 2); if (d->bg) BackgroundDecRefcount(d->bg); @@ -500,9 +480,9 @@ DeskResize(int desk, int w, int h) } BackgroundPixmapFree(d->bg); DeskRefresh(d->num); - DeskControlsDestroy(d); + DeskControlsDestroy(d, 1); DeskControlsCreate(d); - DeskControlsShow(d); + DeskControlsShow(d, 1); } Desk * @@ -712,7 +692,7 @@ DesksControlsDestroy(void) int i; for (i = 0; i < Conf.desks.num; i++) - DeskControlsDestroy(_DeskGet(i)); + DeskControlsDestroy(_DeskGet(i), 1); } static void @@ -721,7 +701,7 @@ DesksControlsShow(void) int i; for (i = 0; i < Conf.desks.num; i++) - DeskControlsShow(_DeskGet(i)); + DeskControlsShow(_DeskGet(i), 1); } static void @@ -920,48 +900,6 @@ DesktopAt(int x, int y) return 0; } -static void -MoveStickyWindowsToCurrentDesk(void) -{ - Desk *d; - EWin *const *lst, *ewin; - int i, num, desk; - - desk = DesksGetCurrent(); - d = _DeskGet(desk); - - lst = EwinListStackGet(&num); - for (i = 0; i < num; i++) - { - ewin = lst[i]; - if (!EoIsSticky(ewin) && !EoIsFloating(ewin)) - continue; - if (EwinIsTransientChild(ewin)) - continue; - - EwinMoveToDesktop(ewin, desk); - } -} - -static void -MoveStickyButtonsToCurrentDesk(void) -{ - Button **lst, *btn; - int i, num; - - lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); - for (i = 0; i < num; i++) - { - btn = lst[i]; - if (ButtonIsInternal(btn) || !EoIsSticky((EWin *) btn)) - continue; - - ButtonMoveToDesktop(btn, desks.current); - } - if (lst) - Efree(lst); -} - static void DesksStackingCheck(void) { @@ -1071,8 +1009,8 @@ DeskEnter(Desk * d) DeskHide(desks.order[i]); } - MoveStickyWindowsToCurrentDesk(); - MoveStickyButtonsToCurrentDesk(); + EwinsMoveStickyToDesk(d->num); + ButtonsMoveStickyToDesk(d->num); DesksStackingCheck(); HintsSetCurrentDesktop(); @@ -1215,8 +1153,8 @@ DeskLower(int desk) UncoverDesktop(desks.order[0]); DeskHide(desk); - MoveStickyWindowsToCurrentDesk(); - MoveStickyButtonsToCurrentDesk(); + EwinsMoveStickyToDesk(desks.current); + ButtonsMoveStickyToDesk(desks.current); DesksStackingCheck(); FocusNewDesk(); if (Mode.mode == MODE_NONE) diff --git a/src/eobj.h b/src/eobj.h index a5a43dfd..3da60907 100644 --- a/src/eobj.h +++ b/src/eobj.h @@ -55,6 +55,13 @@ struct _eobj #define EOBJ_TYPE_EVENT 4 #define EOBJ_TYPE_EXT 5 +#define EobjGetWin(eo) ((eo)->win) +#define EobjGetDesk(eo) ((eo)->desk) +#define EobjGetX(eo) ((eo)->x) +#define EobjGetY(eo) ((eo)->y) +#define EobjGetW(eo) ((eo)->w) +#define EobjGetH(eo) ((eo)->h) + #define EoObj(eo) (&((eo)->o)) #define EoGetWin(eo) ((eo)->o.win) #define EoGetName(eo) ((eo)->o.name) diff --git a/src/ewins.c b/src/ewins.c index dc5eb2ad..a669e57c 100644 --- a/src/ewins.c +++ b/src/ewins.c @@ -1619,6 +1619,25 @@ EwinsTouch(int desk) } } +void +EwinsMoveStickyToDesk(int desk) +{ + EWin *const *lst, *ewin; + int i, num; + + lst = EwinListStackGet(&num); + for (i = 0; i < num; i++) + { + ewin = lst[num - 1 - i]; + if (!EoIsSticky(ewin) && !EoIsFloating(ewin)) + continue; + if (EwinIsTransientChild(ewin)) + continue; + + EwinMoveToDesktop(ewin, desk); + } +} + void EwinsSetFree(void) { diff --git a/src/ewins.h b/src/ewins.h index d4e9c34b..8e5e36d0 100644 --- a/src/ewins.h +++ b/src/ewins.h @@ -263,6 +263,7 @@ void EwinChange(EWin * ewin, unsigned int flag); void EwinsEventsConfigure(int mode); void EwinsSetFree(void); void EwinsShowDesktop(int on); +void EwinsMoveStickyToDesk(int desk); /* ewin-ops.c */ void SlideEwinTo(EWin * ewin, int fx, int fy, int tx, int ty, diff --git a/src/menus.c b/src/menus.c index 2ba81389..9d685d70 100644 --- a/src/menus.c +++ b/src/menus.c @@ -217,13 +217,6 @@ MenuShow(Menu * m, char noshow) ewin = m->ewin; if (ewin) { -#if 0 /* FIXME - Why? */ - if ((Mode.button) && - FindItem(Mode.button, 0, LIST_FINDBY_POINTER, LIST_TYPE_BUTTON)) - { - ButtonDrawWithState(Mode.button, STATE_NORMAL); - } -#endif #if 0 /* ??? */ RaiseEwin(ewin); ShowEwin(ewin); diff --git a/src/slideout.c b/src/slideout.c index 0f1812b5..51dcd03e 100644 --- a/src/slideout.c +++ b/src/slideout.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "buttons.h" #include "emodule.h" #include "ewins.h" #include "xwin.h" @@ -35,8 +36,8 @@ typedef struct { EObj o; char direction; - int num_buttons; - Button **button; + int num_objs; + EObj **objs; unsigned int ref_count; EWin *context_ewin; } Slideout; @@ -170,9 +171,8 @@ SlideoutShow(Slideout * s, EWin * ewin, Window win) att.win_gravity = SouthEastGravity; EChangeWindowAttributes(EoGetWin(s), CWWinGravity, &att); att.win_gravity = NorthWestGravity; - for (i = 0; i < s->num_buttons; i++) - EChangeWindowAttributes(ButtonGetWin(s->button[i]), - CWWinGravity, &att); + for (i = 0; i < s->num_objs; i++) + EChangeWindowAttributes(EobjGetWin(s->objs[i]), CWWinGravity, &att); EoMoveResize(s, xx, yy, 1, 1); ESync(); EoMap(s, 2); @@ -183,9 +183,8 @@ SlideoutShow(Slideout * s, EWin * ewin, Window win) att.win_gravity = NorthWestGravity; EChangeWindowAttributes(EoGetWin(s), CWWinGravity, &att); att.win_gravity = SouthEastGravity; - for (i = 0; i < s->num_buttons; i++) - EChangeWindowAttributes(ButtonGetWin(s->button[i]), - CWWinGravity, &att); + for (i = 0; i < s->num_objs; i++) + EChangeWindowAttributes(EobjGetWin(s->objs[i]), CWWinGravity, &att); EoMoveResize(s, xx, yy, 1, 1); ESync(); EoMap(s, 2); @@ -196,9 +195,8 @@ SlideoutShow(Slideout * s, EWin * ewin, Window win) att.win_gravity = SouthEastGravity; EChangeWindowAttributes(EoGetWin(s), CWWinGravity, &att); att.win_gravity = NorthWestGravity; - for (i = 0; i < s->num_buttons; i++) - EChangeWindowAttributes(ButtonGetWin(s->button[i]), - CWWinGravity, &att); + for (i = 0; i < s->num_objs; i++) + EChangeWindowAttributes(EobjGetWin(s->objs[i]), CWWinGravity, &att); EoMoveResize(s, xx, yy, 1, 1); ESync(); EoMap(s, 2); @@ -209,9 +207,8 @@ SlideoutShow(Slideout * s, EWin * ewin, Window win) att.win_gravity = NorthWestGravity; EChangeWindowAttributes(EoGetWin(s), CWWinGravity, &att); att.win_gravity = SouthEastGravity; - for (i = 0; i < s->num_buttons; i++) - EChangeWindowAttributes(ButtonGetWin(s->button[i]), - CWWinGravity, &att); + for (i = 0; i < s->num_objs; i++) + EChangeWindowAttributes(EobjGetWin(s->objs[i]), CWWinGravity, &att); EoMoveResize(s, xx, yy, 1, 1); ESync(); EoMap(s, 2); @@ -255,10 +252,10 @@ SlideoutCalcSize(Slideout * s) sh = 0; x = 0; y = 0; - for (i = 0; i < s->num_buttons; i++) + for (i = 0; i < s->num_objs; i++) { - bw = ButtonGetWidth(s->button[i]); - bh = ButtonGetHeight(s->button[i]); + bw = EobjGetW(s->objs[i]); + bh = EobjGetH(s->objs[i]); switch (s->direction) { @@ -281,27 +278,27 @@ SlideoutCalcSize(Slideout * s) EoResize(s, sw, sh); - for (i = 0; i < s->num_buttons; i++) + for (i = 0; i < s->num_objs; i++) { - bw = ButtonGetWidth(s->button[i]); - bh = ButtonGetHeight(s->button[i]); + bw = EobjGetW(s->objs[i]); + bh = EobjGetH(s->objs[i]); switch (s->direction) { case 2: y += bh; - EMoveWindow(ButtonGetWin(s->button[i]), (sw - bw) >> 1, sh - y); + EMoveWindow(EobjGetWin(s->objs[i]), (sw - bw) >> 1, sh - y); break; case 3: - EMoveWindow(ButtonGetWin(s->button[i]), (sw - bw) >> 1, y); + EMoveWindow(EobjGetWin(s->objs[i]), (sw - bw) >> 1, y); y += bh; break; case 0: x += bw; - EMoveWindow(ButtonGetWin(s->button[i]), sw - x, (sh - bh) >> 1); + EMoveWindow(EobjGetWin(s->objs[i]), sw - x, (sh - bh) >> 1); break; case 1: - EMoveWindow(ButtonGetWin(s->button[i]), x, (sh - bh) >> 1); + EMoveWindow(EobjGetWin(s->objs[i]), x, (sh - bh) >> 1); x += bw; default: break; @@ -313,14 +310,16 @@ SlideoutCalcSize(Slideout * s) static void SlideoutAddButton(Slideout * s, Button * b) { + EObj *eob = (EObj *) b; + if (!b) return; if (!s) return; - s->num_buttons++; - s->button = Erealloc(s->button, sizeof(Button *) * s->num_buttons); - s->button[s->num_buttons - 1] = b; + s->num_objs++; + s->objs = Erealloc(s->objs, sizeof(EObj *) * s->num_objs); + s->objs[s->num_objs - 1] = eob; ButtonSwallowInto(b, EoObj(s)); SlideoutCalcSize(s); }