2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2008 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #include "e16-ecore_list.h"
37 #define SLIDEOUT_EVENT_MASK \
38 (KeyPressMask | KeyReleaseMask | \
39 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | \
48 unsigned int ref_count;
52 static void SlideoutCalcSize(Slideout * s);
54 static Ecore_List *slideout_list = NULL;
62 static void SlideoutHandleEvent(Win win, XEvent * ev, void *prm);
65 SlideoutCreate(const char *name, char dir)
69 s = ECALLOC(Slideout, 1);
73 s->name = Estrdup(name);
76 EoInit(s, EOBJ_TYPE_MISC, None, -10, -10, 1, 1, 1, name);
78 ESelectInput(EoGetWin(s), SLIDEOUT_EVENT_MASK);
79 EventCallbackRegister(EoGetWin(s), 0, SlideoutHandleEvent, s);
85 SlideoutShow(Slideout * s, EWin * ewin, Win win)
87 int x, y, i, xx, yy, sw, sh;
89 XSetWindowAttributes att;
93 /* Don't ever show more than one slideout */
94 if (Mode_slideouts.active)
98 EGetGeometry(win, NULL, NULL, NULL, &w, &h, NULL, NULL);
99 ETranslateCoordinates(win, VROOT, 0, 0, &x, &y, NULL);
105 switch (s->direction)
108 xx = x + ((w - sw) >> 1);
110 if ((yy < 0) && (sh < WinGetH(VROOT)))
114 SlideoutShow(s, ewin, win);
120 xx = x + ((w - sw) >> 1);
122 if (((yy + sh) > WinGetH(VROOT)) && (sh < WinGetH(VROOT)))
126 SlideoutShow(s, ewin, win);
133 yy = y + ((h - sh) >> 1);
134 if ((xx < 0) && (sw < WinGetW(VROOT)))
138 SlideoutShow(s, ewin, win);
145 yy = y + ((h - sh) >> 1);
146 if (((xx + sw) > WinGetW(VROOT)) && (sw < WinGetW(VROOT)))
150 SlideoutShow(s, ewin, win);
161 /* If the slideout is associated with an ewin,
162 * put it on the same virtual desktop. */
163 dsk = EoGetDesk(ewin);
164 if (BorderWinpartIndex(ewin, win) >= 0 &&
165 !EoIsFloating(ewin) /* && !ewin->sticky */ )
170 EoSetLayer(s, EoGetLayer(ewin));
178 EoReparent(s, EoObj(dsk), xx, yy);
180 switch (s->direction)
183 att.win_gravity = SouthEastGravity;
184 EChangeWindowAttributes(EoGetWin(s), CWWinGravity, &att);
185 att.win_gravity = NorthWestGravity;
186 for (i = 0; i < s->num_objs; i++)
187 EChangeWindowAttributes(EobjGetWin(s->objs[i]), CWWinGravity, &att);
188 EoMoveResize(s, xx, yy, 1, 1);
189 ESync(ESYNC_SLIDEOUT);
191 EobjSlideSizeTo(EoObj(s), xx + sw, yy, xx, yy, 1, sh, sw, sh,
192 Conf.place.slidespeedmap);
195 att.win_gravity = NorthWestGravity;
196 EChangeWindowAttributes(EoGetWin(s), CWWinGravity, &att);
197 att.win_gravity = SouthEastGravity;
198 for (i = 0; i < s->num_objs; i++)
199 EChangeWindowAttributes(EobjGetWin(s->objs[i]), CWWinGravity, &att);
200 EoMoveResize(s, xx, yy, 1, 1);
201 ESync(ESYNC_SLIDEOUT);
203 EobjSlideSizeTo(EoObj(s), xx, yy, xx, yy, 1, sh, sw, sh,
204 Conf.place.slidespeedmap);
207 att.win_gravity = SouthEastGravity;
208 EChangeWindowAttributes(EoGetWin(s), CWWinGravity, &att);
209 att.win_gravity = NorthWestGravity;
210 for (i = 0; i < s->num_objs; i++)
211 EChangeWindowAttributes(EobjGetWin(s->objs[i]), CWWinGravity, &att);
212 EoMoveResize(s, xx, yy, 1, 1);
213 ESync(ESYNC_SLIDEOUT);
215 EobjSlideSizeTo(EoObj(s), xx, yy + sh, xx, yy, sw, 1, sw, sh,
216 Conf.place.slidespeedmap);
219 att.win_gravity = NorthWestGravity;
220 EChangeWindowAttributes(EoGetWin(s), CWWinGravity, &att);
221 att.win_gravity = SouthEastGravity;
222 for (i = 0; i < s->num_objs; i++)
223 EChangeWindowAttributes(EobjGetWin(s->objs[i]), CWWinGravity, &att);
224 EoMoveResize(s, xx, yy, 1, 1);
225 ESync(ESYNC_SLIDEOUT);
227 EobjSlideSizeTo(EoObj(s), xx, yy, xx, yy, sw, 1, sw, sh,
228 Conf.place.slidespeedmap);
234 s->context_ewin = ewin;
236 GrabPointerSet(EoGetWin(s), ECSR_ROOT, 0);
238 Mode_slideouts.active = s;
242 SlideoutHide(Slideout * s)
247 GrabPointerRelease();
249 s->context_ewin = NULL;
251 Mode_slideouts.active = NULL;
255 SlideoutCalcSize(Slideout * s)
267 for (i = 0; i < s->num_objs; i++)
269 bw = EobjGetW(s->objs[i]);
270 bh = EobjGetH(s->objs[i]);
272 switch (s->direction)
293 for (i = 0; i < s->num_objs; i++)
295 bw = EobjGetW(s->objs[i]);
296 bh = EobjGetH(s->objs[i]);
298 switch (s->direction)
302 EMoveWindow(EobjGetWin(s->objs[i]), (sw - bw) >> 1, sh - y);
305 EMoveWindow(EobjGetWin(s->objs[i]), (sw - bw) >> 1, y);
310 EMoveWindow(EobjGetWin(s->objs[i]), sw - x, (sh - bh) >> 1);
313 EMoveWindow(EobjGetWin(s->objs[i]), x, (sh - bh) >> 1);
319 EShapePropagate(EoGetWin(s));
323 SlideoutButtonCallback(EObj * seo, XEvent * ev, ActionClass * ac)
325 Slideout *s = (Slideout *) seo;
326 EWin *ewin = s->context_ewin;
328 if (ev->type == ButtonRelease)
332 ActionclassEvent(ac, ev, ewin);
336 SlideoutAddButton(Slideout * s, Button * b)
338 EObj *eob = (EObj *) b;
344 s->objs = EREALLOC(EObj *, s->objs, s->num_objs);
345 s->objs[s->num_objs - 1] = eob;
346 ButtonSwallowInto(b, EoObj(s));
347 ButtonSetCallback(b, SlideoutButtonCallback, EoObj(s));
353 SlideoutRemoveButton(Slideout * s, Button * b)
361 SlideoutHandleEvent(Win win __UNUSED__, XEvent * ev, void *prm)
363 Slideout *s = (Slideout *) prm;
377 if (ev->xcrossing.mode != NotifyGrab)
378 GrabPointerRelease();
381 if (ev->xcrossing.mode != NotifyUngrab)
382 GrabPointerSet(EoGetWin(s), ECSR_ROOT, 0);
390 if (Mode_slideouts.active)
391 SlideoutHide(Mode_slideouts.active);
395 * Configuration load/save
400 SlideoutsConfigLoad(FILE * fs)
403 Slideout *slideout = 0;
405 char s[FILEPATH_LEN_MAX];
406 char s2[FILEPATH_LEN_MAX];
407 char name[FILEPATH_LEN_MAX];
410 slideout_list = ecore_list_new();
414 while (GetLine(s, sizeof(s), fs))
416 i1 = ConfigParseline1(s, s2, NULL, NULL);
421 ecore_list_prepend(slideout_list, slideout);
423 case CONFIG_CLASSNAME:
426 case SLIDEOUT_DIRECTION:
427 slideout = SlideoutCreate(name, (char)atoi(s2));
430 SlideoutAddButton(slideout, ButtonFind(s2));
433 ConfigParseError("Slideout", s);
448 SlideoutsSighan(int sig, void *prm)
452 case ESIGNAL_AREA_SWITCH_START:
453 case ESIGNAL_DESK_SWITCH_START:
457 case ESIGNAL_EWIN_UNMAP:
458 if (Mode_slideouts.active
459 && Mode_slideouts.active->context_ewin == (EWin *) prm)
466 _SlideoutMatchName(const void *data, const void *match)
468 return strcmp(((const Slideout *)data)->name, (const char *)match);
472 SlideoutFind(const char *name)
474 return (Slideout *) ecore_list_find(slideout_list, _SlideoutMatchName, name);
478 IPC_Slideout(const char *params)
485 s = SlideoutFind(params);
489 SoundPlay(SOUND_SLIDEOUT_SHOW);
490 SlideoutShow(s, GetContextEwin(), Mode.context_win);
493 static const IpcItem SlideoutsIpcArray[] = {
495 IPC_Slideout, "slideout", NULL, "Show slideout", NULL},
497 #define N_IPC_FUNCS (sizeof(SlideoutsIpcArray)/sizeof(IpcItem))
502 extern const EModule ModSlideouts;
503 const EModule ModSlideouts = {
504 "slideouts", "slideout",
506 {N_IPC_FUNCS, SlideoutsIpcArray},