2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2009 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.
25 #include "backgrounds.h"
28 #include "e16-ecore_list.h"
45 #define Dprintf(fmt...) if(EDebug(EDBUG_TYPE_PAGER))Eprintf(fmt)
47 #define Dprintf(fmt...)
50 #define USE_PAGER_BACKGROUND_CACHE 1
51 #define HIQ ((Conf_pagers.hiq) ? 0x200 : 0x100)
53 #define PAGER_MODE_SIMPLE 0
54 #define PAGER_MODE_SNAP 1
55 #define PAGER_MODE_LIVE 2
57 #define PAGER_UPD_EWIN_GEOM 0
58 #define PAGER_UPD_EWIN_GONE 1
59 #define PAGER_UPD_EWIN_DAMAGE 2
61 #define EwinGetVX(ew) (ew->vx)
62 #define EwinGetVY(ew) (ew->vy)
63 #define EwinGetVX2(ew) (ew->vx + EoGetW(ew))
64 #define EwinGetVY2(ew) (ew->vy + EoGetH(ew))
93 int screen_w, screen_h;
107 static void PagerScanCancel(Pager * p);
108 static int PagerScanTimeout(void *data);
109 static void PagerCheckUpdate(Pager * p, void *prm);
110 static void PagerUpdateEwinsFromPager(Pager * p);
111 static void PagerHiwinHide(void);
112 static void PagerEvent(Win win, XEvent * ev, void *prm);
113 static void PagerHiwinEvent(Win win, XEvent * ev, void *prm);
115 static Ecore_List *pager_list = NULL;
117 static Hiwin *hiwin = NULL;
122 int mode = Conf_pagers.mode;
124 if (mode == PAGER_MODE_LIVE && !ECompMgrIsActive())
125 mode = PAGER_MODE_SNAP;
135 if (!Conf_pagers.enable)
138 p = ECALLOC(Pager, 1);
143 pager_list = ecore_list_new();
144 ecore_list_append(pager_list, p);
147 p->win = ECreateClientWindow(VROOT, 0, 0, 1, 1);
148 EventCallbackRegister(p->win, 0, PagerEvent, p);
149 p->sel_win = ECreateWindow(p->win, 0, 0, 1, 1, 0);
155 PagerDestroy(Pager * p)
157 ecore_list_node_remove(pager_list, p);
162 if (p->bgpmap != None)
163 EFreePixmap(p->bgpmap);
169 PagerScanTrig(Pager * p)
171 if (p->scan_timer || Conf_pagers.scanspeed <= 0)
174 TIMER_ADD(p->scan_timer, 1 / ((double)Conf_pagers.scanspeed),
175 PagerScanTimeout, p);
179 PagerScanCancel(Pager * p)
181 TIMER_DEL(p->scan_timer);
185 PagerScanTimeout(void *data)
189 int y, y2, phase, cx, cy, ww, hh, xx, yy;
190 static int offsets[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
191 int pager_mode = PagersGetMode();
195 if (pager_mode != PAGER_MODE_SNAP)
199 if (!ewin || !EoIsShown(ewin))
201 if (p->dsk != DesksGetCurrent())
203 if (ewin->state.visibility == VisibilityFullyObscured)
206 if (Conf_pagers.scanspeed <= 0)
209 if (Mode.mode != MODE_NONE)
212 DeskCurrentGetArea(&cx, &cy);
217 phase = p->update_phase;
218 if (ww <= 0 || hh <= 0)
222 /* Due to a bug in imlib2 <= 1.2.0 we have to scan left->right in stead
223 * of top->bottom, at least for now. */
224 y = ((phase & 0xfffffff8) + offsets[phase % 8]) % hh;
225 y2 = (y * WinGetH(VROOT)) / hh;
227 ScaleRect(VROOT, WinGetXwin(VROOT), p->win, WinGetPmap(p->win), 0,
228 y2, WinGetW(VROOT), WinGetH(VROOT) / hh, xx, yy + y, ww, 1, HIQ);
229 EClearArea(p->win, xx, yy + y, ww, 1);
232 y = ((phase & 0xfffffff8) + offsets[phase % 8]) % ww;
233 y2 = (y * WinGetW(VROOT)) / ww;
235 ScaleRect(VROOT, WinGetXwin(VROOT), p->win, WinGetPmap(p->win), y2,
236 0, WinGetW(VROOT) / ww, WinGetH(VROOT), xx + y, yy, 1, hh, HIQ);
237 EClearArea(p->win, xx + y, yy, 1, hh);
241 if (p->update_phase >= y2)
243 PagerUpdateEwinsFromPager(p);
247 TimerSetInterval(p->scan_timer, 1 / ((double)Conf_pagers.scanspeed));
251 p->scan_timer = NULL;
255 #if 0 /* FIXME - Remove? */
257 PagerHiwinUpdate(Hiwin * phi, Pager * p __UNUSED__, EWin * ewin)
261 if (!EoIsShown(phi) || !ewin->mini_pmm.pmap)
264 im = EImageGrabDrawable(ewin->mini_pmm.pmap, None, 0, 0,
265 ewin->mini_w, ewin->mini_h, 0);
266 EImageRenderOnDrawable(im, EoGetWin(phi), 0, 0, 0, EoGetW(phi), EoGetH(phi));
272 PagerEwinUpdateMini(Pager * p, EWin * ewin)
274 int w, h, update, use_iclass, serdif;
276 int pager_mode = PagersGetMode();
278 w = (EoGetW(ewin) * p->dw) / WinGetW(VROOT);
279 h = (EoGetH(ewin) * p->dh) / WinGetH(VROOT);
286 serdif = EoGetSerial(ewin) - p->serial;
289 if (!ewin->mini_pmm.pmap)
291 if (ewin->mini_w != w || ewin->mini_h != h)
294 if (serdif > 0 && ewin->type != EWIN_TYPE_PAGER &&
295 pager_mode == PAGER_MODE_LIVE && Mode.mode == 0)
297 if (serdif > p->serdif)
303 Dprintf("PagerEwinUpdateMini %#lx/%#lx wxh=%dx%d ser=%#x/%#x dif=%d: %s\n",
304 EwinGetClientXwin(ewin), EoGetXwin(ewin), w, h,
305 EoGetSerial(ewin), p->serial, serdif, EwinGetTitle(ewin));
309 FreePmapMask(&ewin->mini_pmm);
313 ewin->mini_pmm.type = 0;
314 ewin->mini_pmm.pmap = ECreatePixmap(p->win, w, h, 0);
317 if (pager_mode != PAGER_MODE_SIMPLE)
319 draw = EoGetPixmap(ewin);
320 if (draw == None && EwinIsOnScreen(ewin))
321 draw = EoGetXwin(ewin);
323 use_iclass = draw == None;
329 ic = ImageclassFind("PAGER_WIN", 1);
330 ImageclassApplySimple(ic, p->win, ewin->mini_pmm.pmap,
331 STATE_NORMAL, 0, 0, w, h);
332 Dprintf("Use Iclass, pmap=%#lx\n", ewin->mini_pmm.pmap);
336 ScaleRect(EoGetWin(ewin), draw, p->win, ewin->mini_pmm.pmap,
337 0, 0, EoGetW(ewin), EoGetH(ewin), 0, 0, w, h, HIQ);
338 Dprintf("Grab scaled, pmap=%#lx\n", ewin->mini_pmm.pmap);
341 #if 0 /* FIXME - Remove? */
342 if (hiwin && ewin == hiwin->ewin)
343 PagerHiwinUpdate(hiwin, p, ewin);
348 doPagerUpdate(Pager * p)
350 int x, y, ax, ay, cx, cy, vx, vy;
353 int i, num, update_screen_included, update_screen_only;
354 int pager_mode = PagersGetMode();
358 DesksGetAreaSize(&ax, &ay);
359 DeskGetArea(p->dsk, &cx, &cy);
360 vx = cx * WinGetW(VROOT);
361 vy = cy * WinGetH(VROOT);
363 update_screen_included = update_screen_only = 0;
364 if (pager_mode == PAGER_MODE_SNAP && p->dsk == DesksGetCurrent()
367 /* Update from screen unless update area is entirely off-screen */
368 if (!(p->x2 <= vx || p->y2 <= vy ||
369 p->x1 >= vx + WinGetW(VROOT) || p->y1 >= vy + WinGetH(VROOT)))
370 update_screen_included = 1;
372 /* Check if update area is entirely on-screen */
373 if (p->x1 >= vx && p->y1 >= vy &&
374 p->x2 <= vx + WinGetW(VROOT) && p->y2 <= vy + WinGetH(VROOT))
375 update_screen_only = 1;
377 p->x1 = p->y1 = 99999;
378 p->x2 = p->y2 = -99999;
380 pmap = EGetWindowBackgroundPixmap(p->win);
382 if (update_screen_only)
383 goto do_screen_update;
385 lst = EwinListGetForDesk(&num, p->dsk);
386 for (i = num - 1; i >= 0; i--)
391 if (!EoIsShown(ewin))
394 PagerEwinUpdateMini(p, ewin);
397 p->serial += p->serdif;
404 gc = EXCreateGC(pmap, 0, NULL);
408 Dprintf("doPagerUpdate %d: Repaint\n", p->dsk->num);
409 for (y = 0; y < ay; y++)
411 for (x = 0; x < ax; x++)
414 if (update_screen_included && x == cx && y == cy)
417 XCopyArea(disp, p->bgpmap, pmap, gc, 0, 0, p->dw, p->dh,
418 x * p->dw, y * p->dh);
422 for (i = num - 1; i >= 0; i--)
428 if (!EoIsShown(ewin))
431 wx = (EwinGetVX(ewin) * p->dw) / WinGetW(VROOT);
432 wy = (EwinGetVY(ewin) * p->dh) / WinGetH(VROOT);
433 ww = (EoGetW(ewin) * p->dw) / WinGetW(VROOT);
434 wh = (EoGetH(ewin) * p->dh) / WinGetH(VROOT);
436 if (ewin->mini_pmm.pmap)
438 if (ewin->mini_pmm.mask)
440 XSetClipMask(disp, gc, ewin->mini_pmm.mask);
441 XSetClipOrigin(disp, gc, wx, wy);
443 XCopyArea(disp, ewin->mini_pmm.pmap, pmap, gc, 0, 0,
445 if (ewin->mini_pmm.mask)
446 XSetClipMask(disp, gc, None);
450 XSetForeground(disp, gc, Dpy.pixel_black);
451 XDrawRectangle(disp, pmap, gc, wx - 1, wy - 1, ww + 1, wh + 1);
452 XSetForeground(disp, gc, Dpy.pixel_white);
453 XFillRectangle(disp, pmap, gc, wx, wy, ww, wh);
457 if (!update_screen_included)
459 EClearWindow(p->win);
464 Dprintf("doPagerUpdate %d: Snap screen\n", p->dsk->num);
465 /* Update pager area by snapshotting entire screen */
466 ScaleRect(VROOT, WinGetXwin(VROOT), p->win, pmap, 0, 0,
467 WinGetW(VROOT), WinGetH(VROOT), cx * p->dw, cy * p->dh,
470 EClearWindow(p->win);
472 /* Update ewin snapshots */
473 PagerUpdateEwinsFromPager(p);
481 PagerUpdate(Pager * p, int why, int x1, int y1, int x2, int y2)
483 if (!Conf_pagers.enable)
496 Mode_pagers.update_pending |= 1 << why;
500 PagerReconfigure(Pager * p, int apply)
502 int ax, ay, w, h, dx, dy;
505 DesksGetAreaSize(&ax, &ay);
507 aspect = ((double)WinGetW(VROOT)) / ((double)WinGetH(VROOT));
524 ICCCM_SetSizeConstraints(p->ewin,
525 WinGetW(VROOT) / 64 * ax,
526 WinGetH(VROOT) / 64 * ay,
527 WinGetW(VROOT) / 4 * ax,
528 WinGetH(VROOT) / 4 * ay, 0, 0, dx * ax, dy * ay,
529 aspect * ((double)ax / (double)ay),
530 aspect * ((double)ax / (double)ay));
534 w = (int)((double)ax * (double)WinGetW(VROOT) / (double)p->scale + .5);
535 h = (int)((double)ay * (double)WinGetH(VROOT) / (double)p->scale + .5);
536 EwinResize(p->ewin, w + (dx * ax) / 2, h + (dy * ay) / 2);
537 EwinReposition(p->ewin);
542 PagerUpdateBg(Pager * p)
548 int pager_mode = PagersGetMode();
551 p->x2 = p->y2 = 99999;
556 pmap = p->bgpmap = ECreatePixmap(p->win, p->dw, p->dh, 0);
558 bg = DeskBackgroundGet(p->dsk);
559 if (pager_mode != PAGER_MODE_SIMPLE && bg)
561 #if USE_PAGER_BACKGROUND_CACHE
566 uniq = BackgroundGetUniqueString(bg);
567 Esnprintf(s, sizeof(s), "%s/cached/pager/%s.%i.%i.%s.png",
568 EDirUserCache(), BackgroundGetName(bg), p->dw, p->dh, uniq);
574 EImageRenderOnDrawable(im, p->win, pmap, 0, 0, 0, p->dw, p->dh);
580 BackgroundApplyPmap(bg, p->win, pmap, p->dw, p->dh);
581 #if USE_PAGER_BACKGROUND_CACHE
582 im = EImageGrabDrawable(pmap, None, 0, 0, p->dw, p->dh, 0);
590 if (pager_mode != PAGER_MODE_SIMPLE && p->dsk->bg.pmap)
592 ScaleTile(VROOT, p->dsk->bg.pmap, p->win, pmap,
593 0, 0, p->dw, p->dh, HIQ);
597 ic = ImageclassFind("PAGER_BACKGROUND", 1);
600 ImageclassApplySimple(ic, p->win, pmap, STATE_NORMAL,
605 gc = EXCreateGC(pmap, 0, NULL);
609 XSetForeground(disp, gc, Dpy.pixel_black);
610 XDrawRectangle(disp, pmap, gc, 0, 0, p->dw, p->dh);
611 XSetForeground(disp, gc, Dpy.pixel_white);
612 XFillRectangle(disp, pmap, gc, 1, 1, p->dw - 2, p->dh - 2);
618 _PagerEwinInit(EWin * ewin)
620 Pager *p = (Pager *) ewin->data;
623 Esnprintf(s, sizeof(s), "Pager-%i", p->dsk->num);
624 EwinSetTitle(ewin, s);
625 Esnprintf(s, sizeof(s), "%i", p->dsk->num);
626 EwinSetClass(ewin, s, "Enlightenment_Pager");
628 ewin->props.skip_ext_task = 1;
629 ewin->props.skip_ext_pager = 1;
630 ewin->props.skip_focuslist = 1;
631 ewin->props.skip_winlist = 1;
632 EwinInhSetWM(ewin, focus, 1);
633 ewin->props.autosave = 1;
635 EoSetSticky(ewin, 1);
639 _PagerEwinMoveResize(EWin * ewin, int resize __UNUSED__)
641 Pager *p = (Pager *) ewin->data;
646 if (!Conf_pagers.enable || !p || Mode.mode != MODE_NONE)
651 if ((w == p->w && h == p->h) || w <= 1 || h <= 1)
654 DesksGetAreaSize(&ax, &ay);
661 if (p->scale <= 0. || Mode.op_source == OPSRC_USER)
662 p->scale = ((float)WinGetW(VROOT) / p->dw +
663 (float)WinGetH(VROOT) / p->dh) / 2;
666 PagerCheckUpdate(p, NULL);
668 ic = ImageclassFind("PAGER_SEL", 0);
671 DeskGetArea(p->dsk, &cx, &cy);
672 EMoveResizeWindow(p->sel_win, cx * p->dw, cy * p->dh, p->dw, p->dh);
673 ImageclassApply(ic, p->sel_win, 0, 0, STATE_NORMAL, ST_PAGER);
678 _PagerEwinClose(EWin * ewin)
680 PagerDestroy((Pager *) ewin->data);
684 static const EWinOps _PagerEwinOps = {
687 _PagerEwinMoveResize,
697 if (!Conf_pagers.enable)
706 ewin = AddInternalToFamily(p->win, "PAGER", EWIN_TYPE_PAGER,
712 p->screen_w = WinGetW(VROOT);
713 p->screen_h = WinGetH(VROOT);
715 PagerReconfigure(p, 0);
717 ewin->client.event_mask |=
718 ButtonPressMask | ButtonReleaseMask |
719 EnterWindowMask | LeaveWindowMask | PointerMotionMask;
720 ESelectInput(p->win, ewin->client.event_mask);
725 EwinMoveToDesktop(ewin, EoGetDesk(ewin));
726 if (ewin->state.placed)
728 EwinMoveResize(ewin, EoGetX(ewin), EoGetY(ewin), w, h);
732 /* no snapshots ? first time ? make a row on the bottom left up */
735 DesksGetAreaSize(&ax, &ay);
736 w = ((48 * WinGetW(VROOT)) / WinGetH(VROOT)) * ax;
738 EwinResize(ewin, w, h); /* Does layout */
739 EwinMove(ewin, 0, WinGetH(VROOT) -
740 (DesksGetNumber() - p->dsk->num) * EoGetH(ewin));
748 void (*func) (Pager * p, void *prm);
750 } pager_foreach_data;
753 _PagersForeachFunc(void *item, void *prm)
755 Pager *p = (Pager *) item;
756 pager_foreach_data *data = (pager_foreach_data *) prm;
758 if (data->dsk && data->dsk != p->dsk)
760 data->func(p, data->prm);
764 PagersForeach(Desk * dsk, void (*func) (Pager * p, void *prm), void *prm)
766 pager_foreach_data data;
771 ecore_list_for_each(pager_list, _PagersForeachFunc, &data);
780 _PagerUpdate(Pager * p, void *prm)
782 pager_update_data *pud = (pager_update_data *) prm;
784 PagerUpdate(p, pud->why, pud->x1, pud->y1, pud->x2, pud->y2);
788 PagersUpdate(Desk * dsk, int why, int x1, int y1, int x2, int y2)
790 pager_update_data pud;
792 if (ecore_list_count(pager_list) <= 0)
800 PagersForeach(dsk, _PagerUpdate, &pud);
804 PagerCheckUpdate(Pager * p, void *prm __UNUSED__)
815 p->do_newbg = p->do_update = 0;
819 _PagersUpdateTimeout(void *data __UNUSED__)
821 Mode_pagers.timer_pending = 0;
827 PagersCheckUpdate(void)
829 static double tlast = 0.;
831 Timer *pager_update_timer;
833 if (!Mode_pagers.update_pending || !Conf_pagers.enable)
836 if (Mode_pagers.update_pending == (1 << PAGER_UPD_EWIN_DAMAGE))
839 dt = (Conf_pagers.scanspeed > 0) ? 1. / Conf_pagers.scanspeed : .1;
842 /* The purpose of this timer is to trigger the idler */
843 if (!Mode_pagers.timer_pending)
844 TIMER_ADD(pager_update_timer, dt, _PagersUpdateTimeout, NULL);
845 Mode_pagers.timer_pending = 1;
851 PagersForeach(NULL, PagerCheckUpdate, NULL);
853 Mode_pagers.update_pending = 0;
857 _PagersIdler(void *data __UNUSED__)
863 PagerEwinUpdateFromPager(Pager * p, EWin * ewin)
868 if (!EoIsShown(ewin) || !EwinIsOnScreen(ewin))
871 Dprintf("PagerEwinUpdateFromPager %d\n", p->dsk->num);
877 x = (x * p->dw) / WinGetW(VROOT);
878 y = (y * p->dh) / WinGetH(VROOT);
879 w = (w * p->dw) / WinGetW(VROOT);
880 h = (h * p->dh) / WinGetH(VROOT);
887 gc = EXCreateGC(WinGetPmap(p->win), 0, NULL);
889 /* NB! If the pixmap/mask was created by imlib, free it. Due to imlibs */
890 /* image/pixmap cache it may be in use elsewhere. */
891 if (ewin->mini_pmm.pmap &&
892 ((ewin->mini_pmm.type) || (ewin->mini_w != w) || (ewin->mini_h != h)))
893 FreePmapMask(&ewin->mini_pmm);
895 if (!ewin->mini_pmm.pmap)
899 ewin->mini_pmm.type = 0;
900 ewin->mini_pmm.pmap = ECreatePixmap(p->win, w, h, 0);
901 ewin->mini_pmm.mask = None;
904 if (!ewin->mini_pmm.pmap)
907 XCopyArea(disp, WinGetPmap(p->win), ewin->mini_pmm.pmap, gc, x, y, w, h, 0,
910 #if 0 /* FIXME - Remove? */
911 if (hiwin && ewin == hiwin->ewin)
912 PagerHiwinUpdate(hiwin, p, ewin);
917 PagerUpdateEwinsFromPager(Pager * p)
922 lst = EwinListGetForDesk(&num, p->dsk);
923 for (i = 0; i < num; i++)
924 PagerEwinUpdateFromPager(p, lst[i]);
928 PagersUpdateEwin(EWin * ewin, int why)
932 if (!Conf_pagers.enable)
937 case PAGER_UPD_EWIN_GEOM:
938 if (!EoIsShown(ewin) || ewin->state.animated)
942 case PAGER_UPD_EWIN_GONE:
943 if (ewin == HiwinGetEwin(hiwin, 0))
947 case PAGER_UPD_EWIN_DAMAGE:
948 if (ewin->type == EWIN_TYPE_PAGER)
950 if (PagersGetMode() != PAGER_MODE_LIVE)
955 dsk = (EoIsFloating(ewin)) ? DesksGetCurrent() : EoGetDesk(ewin);
956 PagersUpdate(dsk, why, EwinGetVX(ewin), EwinGetVY(ewin),
957 EwinGetVX2(ewin), EwinGetVY2(ewin));
961 EwinInPagerAt(Pager * p, int px, int py)
963 EWin *const *lst, *ewin;
964 int i, num, x, y, w, h;
966 if (!Conf_pagers.enable)
969 lst = EwinListGetForDesk(&num, p->dsk);
970 for (i = 0; i < num; i++)
973 if (!EoIsShown(ewin))
976 x = (EwinGetVX(ewin) * p->dw) / WinGetW(VROOT);
977 y = (EwinGetVY(ewin) * p->dh) / WinGetH(VROOT);
978 w = (EoGetW(ewin) * p->dw) / WinGetW(VROOT);
979 h = (EoGetH(ewin) * p->dh) / WinGetH(VROOT);
981 if (px >= x && py >= y && px < (x + w) && py < (y + h))
989 PagerMenuShow(Pager * p, int x, int y)
991 static Menu *p_menu = NULL, *pw_menu = NULL;
996 if (!Conf_pagers.enable)
999 ewin = EwinInPagerAt(p, x, y);
1003 MenuDestroy(pw_menu);
1006 MenuCreate("__DESK_WIN_MENU", _("Window Options"), NULL, NULL);
1008 Esnprintf(s, sizeof(s), "wop %#lx ic", EwinGetClientXwin(ewin));
1009 mi = MenuItemCreate(_("Iconify"), NULL, s, NULL);
1010 MenuAddItem(pw_menu, mi);
1012 Esnprintf(s, sizeof(s), "wop %#lx close", EwinGetClientXwin(ewin));
1013 mi = MenuItemCreate(_("Close"), NULL, s, NULL);
1014 MenuAddItem(pw_menu, mi);
1016 Esnprintf(s, sizeof(s), "wop %#lx kill", EwinGetClientXwin(ewin));
1017 mi = MenuItemCreate(_("Annihilate"), NULL, s, NULL);
1018 MenuAddItem(pw_menu, mi);
1020 Esnprintf(s, sizeof(s), "wop %#lx st", EwinGetClientXwin(ewin));
1021 mi = MenuItemCreate(_("Stick / Unstick"), NULL, s, NULL);
1022 MenuAddItem(pw_menu, mi);
1024 EFunc(NULL, "menus show __DESK_WIN_MENU");
1029 MenuDestroy(p_menu);
1030 p_menu = MenuCreate("__DESK_MENU", _("Desktop Options"), NULL, NULL);
1032 mi = MenuItemCreate(_("Pager Settings..."), NULL, "cfg pagers", NULL);
1033 MenuAddItem(p_menu, mi);
1035 if (PagersGetMode() != PAGER_MODE_SIMPLE)
1037 mi = MenuItemCreate(_("Snapshotting Off"), NULL, "pg mode simp", NULL);
1038 MenuAddItem(p_menu, mi);
1040 if (Conf_pagers.hiq)
1041 mi = MenuItemCreate(_("High Quality Off"), NULL, "pg hiq off", NULL);
1043 mi = MenuItemCreate(_("High Quality On"), NULL, "pg hiq on", NULL);
1044 MenuAddItem(p_menu, mi);
1048 mi = MenuItemCreate(_("Snapshotting On"), NULL, "pg mode live", NULL);
1049 MenuAddItem(p_menu, mi);
1051 if (Conf_pagers.zoom)
1052 mi = MenuItemCreate(_("Zoom Off"), NULL, "pg zoom off", NULL);
1054 mi = MenuItemCreate(_("Zoom On"), NULL, "pg zoom on", NULL);
1055 MenuAddItem(p_menu, mi);
1057 EFunc(NULL, "menus show __DESK_MENU");
1061 PagerClose(Pager * p)
1067 _PagerUpdateSel(Pager * p, void *prm __UNUSED__)
1072 if (p->dsk != DesksGetCurrent())
1073 EUnmapWindow(p->sel_win);
1076 DeskGetArea(p->dsk, &cx, &cy);
1077 EMoveWindow(p->sel_win, cx * p->dw, cy * p->dh);
1078 EMapWindow(p->sel_win);
1079 ic = ImageclassFind("PAGER_SEL", 0);
1081 ImageclassApply(ic, p->sel_win, 0, 0, STATE_NORMAL, ST_PAGER);
1086 UpdatePagerSel(void)
1088 if (!Conf_pagers.enable)
1091 PagersForeach(NULL, _PagerUpdateSel, NULL);
1095 PagerShowTt(EWin * ewin)
1097 static EWin *tt_ewin = NULL;
1100 Dprintf("PagerShowTt %s\n", (ewin) ? EwinGetIconName(ewin) : NULL);
1102 if (!Conf_pagers.title || (ewin == tt_ewin))
1105 if (MenusActive()) /* Don't show Tooltip when menu is up */
1108 tt = TooltipFind("PAGER");
1112 TooltipShow(tt, EwinGetIconName(ewin), NULL, Mode.events.cx,
1122 PagerHiwinInit(Pager * p, EWin * ewin)
1125 int wx, wy, ww, wh, px, py;
1129 phi = HiwinCreate();
1135 wx = (EwinGetVX(ewin) * p->dw) / WinGetW(VROOT);
1136 wy = (EwinGetVY(ewin) * p->dh) / WinGetH(VROOT);
1137 ww = (EoGetW(ewin) * p->dw) / WinGetW(VROOT);
1138 wh = (EoGetH(ewin) * p->dh) / WinGetH(VROOT);
1139 ETranslateCoordinates(p->win, VROOT, 0, 0, &px, &py, NULL);
1141 HiwinInit(phi, ewin);
1142 HiwinSetGeom(phi, px + wx, py + wy, ww, wh);
1143 HiwinSetCallback(phi, PagerHiwinEvent, p);
1147 PagerHiwinHide(void)
1149 Dprintf("PagerHiwinHide\n");
1155 PagerHiwinShow(Pager * p, EWin * ewin, int zoom, int confine)
1159 if (MenusActive()) /* Don't show HiWin when menu is up */
1164 PagerHiwinInit(p, ewin);
1170 HiwinShow(phi, ewin, zoom, confine);
1174 PagerZoomChange(Pager * p, int delta)
1176 Dprintf("PagerZoomChange delta=%d\n", delta);
1183 if (!ECompMgrIsActive() && Mode_pagers.zoom >= 2)
1185 if (Mode_pagers.zoom >= 8)
1191 if (Mode_pagers.zoom <= 2)
1195 PagerHiwinShow(p, NULL, Mode_pagers.zoom, 0);
1199 PagerHandleMotion(Pager * p, int x, int y)
1204 if (!Conf_pagers.enable)
1207 on_screen = EQueryPointer(p->win, &x, &y, NULL, NULL);
1209 if (on_screen && x >= 0 && x < p->w && y >= 0 && y < p->h)
1210 ewin = EwinInPagerAt(p, x, y);
1214 if (!Conf_pagers.zoom)
1220 if (!ewin || EoGetLayer(ewin) <= 0)
1224 else if (!hiwin || ewin != HiwinGetEwin(hiwin, 0))
1226 if (Mode_pagers.zoom < 2)
1227 Mode_pagers.zoom = 2;
1228 PagerHiwinShow(p, ewin, Mode_pagers.zoom, 0);
1230 if (Mode_pagers.zoom <= 2)
1235 NewPagerForDesktop(Desk * dsk)
1248 _PagerUpdateBackground(Pager * p, void *prm __UNUSED__)
1254 PagersUpdateBackground(Desk * dsk)
1256 PagersForeach(dsk, _PagerUpdateBackground, NULL);
1258 Mode_pagers.update_pending = 1;
1262 PagerSetHiQ(char onoff)
1267 Conf_pagers.hiq = onoff;
1269 lst = EwinListGetAll(&num);
1270 for (i = 0; i < num; i++)
1276 PagersUpdateBackground(NULL);
1282 _PagerSetSnap(Pager * p, void *prm __UNUSED__)
1288 PagersSetMode(int mode)
1293 if (mode == Conf_pagers.mode)
1295 Conf_pagers.mode = mode;
1297 lst = EwinListGetAll(&num);
1298 for (i = 0; i < num; i++)
1304 PagersUpdateBackground(NULL);
1306 if (Conf_pagers.mode == PAGER_MODE_SNAP && Conf_pagers.scanspeed > 0)
1307 PagersForeach(DesksGetCurrent(), _PagerSetSnap, NULL);
1313 * Pager event handlers
1316 static int *gwin_px, *gwin_py;
1319 PagerEwinGroupSet(void)
1322 EWin *ewin, **gwins;
1324 ewin = HiwinGetEwin(hiwin, 0);
1325 gwins = ListWinGroupMembersForEwin(ewin, GROUP_ACTION_MOVE,
1326 Mode.nogroup, &num);
1330 gwin_px = EMALLOC(int, num);
1331 gwin_py = EMALLOC(int, num);
1333 for (i = 0; i < num; i++)
1335 gwin_px[i] = EoGetX(gwins[i]);
1336 gwin_py[i] = EoGetY(gwins[i]);
1343 PagerEwinGroupUnset(void)
1350 PagerEventUnmap(Pager * p __UNUSED__)
1356 EwinGroupMove(EWin * ewin, Desk * dsk, int x, int y)
1358 int i, num, dx, dy, newdesk;
1364 /* Move all group members */
1365 newdesk = dsk != EoGetDesk(ewin);
1366 dx = x - EoGetX(ewin);
1367 dy = y - EoGetY(ewin);
1369 ListWinGroupMembersForEwin(ewin, GROUP_ACTION_MOVE, Mode.nogroup, &num);
1370 for (i = 0; i < num; i++)
1372 if (gwins[i]->type == EWIN_TYPE_PAGER)
1376 EwinOpMoveToDesktopAt(gwins[i], OPSRC_USER, dsk,
1377 EoGetX(gwins[i]) + dx, EoGetY(gwins[i]) + dy);
1379 EwinOpMove(gwins[i], OPSRC_USER, EoGetX(gwins[i]) + dx,
1380 EoGetY(gwins[i]) + dy);
1386 PagerEwinMove(Pager * p __UNUSED__, Pager * pd, EWin * ewin)
1388 int x, y, dx, dy, px, py;
1392 /* Delta in pager coords */
1393 dx = Mode.events.mx - Mode.events.px;
1394 dy = Mode.events.my - Mode.events.py;
1396 if (dx == 0 && dy == 0 && p == pd)
1399 /* Move mini window */
1400 HiwinGetXY(phi, &x, &y);
1401 HiwinMove(phi, x + dx, y + dy);
1403 /* Find real window position */
1404 ETranslateCoordinates(VROOT, pd->win, x, y, &px, &py, NULL);
1405 DeskGetArea(pd->dsk, &cx, &cy);
1406 x = (px * WinGetW(VROOT)) / pd->dw - cx * WinGetW(VROOT);
1407 y = (py * WinGetH(VROOT)) / pd->dh - cy * WinGetH(VROOT);
1409 /* Move all group members */
1410 EwinGroupMove(ewin, pd->dsk, x, y);
1414 PagerHandleMouseDown(Pager * p, int px, int py, int button)
1419 in_pager = (px >= 0 && py >= 0 && px < p->w && py < p->h);
1423 if (button == Conf_pagers.menu_button)
1426 PagerMenuShow(p, px, py);
1428 else if (button == Conf_pagers.win_button)
1430 ewin = EwinInPagerAt(p, px, py);
1431 if (ewin && ewin->type != EWIN_TYPE_PAGER && !ewin->state.inhibit_move)
1433 PagerHiwinShow(p, ewin, 1, !Mode.wm.window);
1434 Mode.mode = MODE_PAGER_DRAG_PENDING;
1435 PagerEwinGroupSet();
1441 PagerHiwinHandleMouseDown(Pager * p, int px, int py, int button)
1443 PagerHandleMouseDown(p, px, py, button);
1447 PagerHandleMouseUp(Pager * p, int px, int py, int button)
1452 in_pager = (px >= 0 && py >= 0 && px < p->w && py < p->h);
1456 if (button == Conf_pagers.sel_button)
1459 if (p->dsk != DesksGetCurrent())
1460 SoundPlay(SOUND_DESKTOP_SHUT);
1461 DeskCurrentGotoArea(px / p->dw, py / p->dh);
1463 else if (button == Conf_pagers.win_button)
1466 DeskCurrentGotoArea(px / p->dw, py / p->dh);
1467 ewin = EwinInPagerAt(p, px, py);
1471 FocusToEWin(ewin, FOCUS_SET);
1477 PagerHiwinHandleMouseUp(Pager * p, int px, int py, int button)
1479 int i, num, in_vroot;
1480 EWin *ewin, *ewin2, **gwins;
1483 Dprintf("PagerHiwinHandleMouseUp m=%d d=%d x,y=%d,%d\n", Mode.mode,
1484 p->dsk->num, px, py);
1486 if (Mode.mode != MODE_PAGER_DRAG)
1488 if (Mode.mode == MODE_PAGER_DRAG_PENDING)
1489 Mode.mode = MODE_NONE;
1491 PagerHandleMouseUp(p, px, py, button);
1495 Mode.mode = MODE_NONE;
1497 ewin = HiwinGetEwin(hiwin, 1);
1501 in_vroot = (Mode.events.cx >= 0 && Mode.events.cx < WinGetW(VROOT) &&
1502 Mode.events.cy >= 0 && Mode.events.cy < WinGetH(VROOT));
1504 if (button == Conf_pagers.win_button)
1506 /* Find which pager or iconbox we are in (if any) */
1507 ewin2 = GetEwinPointerInClient();
1508 if ((ewin2) && (ewin2->type == EWIN_TYPE_PAGER))
1510 PagerEwinMove(p, (Pager *) ewin2->data, ewin);
1512 else if ((ewin2) && (ewin2->type == EWIN_TYPE_ICONBOX))
1514 /* Pointer is in iconbox */
1516 /* Iconify after moving back to pre-drag position */
1517 gwins = ListWinGroupMembersForEwin(ewin, GROUP_ACTION_MOVE,
1518 Mode.nogroup, &num);
1519 for (i = 0; i < num; i++)
1521 if (gwins[i]->type != EWIN_TYPE_PAGER)
1523 EwinMove(gwins[i], gwin_px[i], gwin_py[i]);
1524 EwinIconify(gwins[i]);
1529 else if (ewin2 && ewin2->props.vroot)
1531 /* Dropping onto virtual root */
1532 EwinReparent(ewin, EwinGetClientWin(ewin2));
1536 /* Move back to real root */
1537 EwinReparent(ewin, RROOT);
1541 /* Pointer is not in pager or iconbox */
1542 /* Move window(s) to pointer location */
1543 x = Mode.events.cx - EoGetW(ewin) / 2;
1544 y = Mode.events.cy - EoGetH(ewin) / 2;
1545 EwinGroupMove(ewin, DesksGetCurrent(), x, y);
1552 /* unallocate the space that was holding the old positions of the */
1554 PagerEwinGroupUnset();
1558 PagerEvent(Win win __UNUSED__, XEvent * ev, void *prm)
1560 Pager *p = (Pager *) prm;
1562 Dprintf("PagerEvent ev=%d\n", ev->type);
1567 PagerHandleMouseDown(p, ev->xbutton.x, ev->xbutton.y,
1568 (int)ev->xbutton.button);
1571 if (ev->xbutton.window != Mode.events.last_bpress)
1573 PagerHandleMouseUp(p, ev->xbutton.x, ev->xbutton.y,
1574 (int)ev->xbutton.button);
1578 PagerHandleMotion(p, ev->xmotion.x, ev->xmotion.y);
1591 case VisibilityNotify:
1592 if (ev->xvisibility.state != VisibilityFullyObscured)
1599 PagerHiwinEvent(Win win, XEvent * ev, void *prm)
1601 Pager *p = (Pager *) prm;
1608 Dprintf("PagerHiwinEvent ev=%d\n", ev->type);
1613 switch (ev->xbutton.button)
1616 if (Mode.mode != MODE_NONE)
1618 PagerZoomChange(p, 1);
1621 if (Mode.mode != MODE_NONE)
1623 PagerZoomChange(p, -1);
1626 /* Translate x,y to pager window coordinates */
1627 ETranslateCoordinates(win, p->win,
1628 ev->xbutton.x, ev->xbutton.y, &px, &py,
1630 PagerHiwinHandleMouseDown(p, px, py, (int)ev->xbutton.button);
1636 switch (ev->xbutton.button)
1642 /* Translate x,y to pager window coordinates */
1643 ETranslateCoordinates(win, p->win,
1644 ev->xbutton.x, ev->xbutton.y, &px, &py,
1646 PagerHiwinHandleMouseUp(p, px, py, (int)ev->xbutton.button);
1655 PagerHandleMotion(p, ev->xmotion.x, ev->xmotion.y);
1658 case MODE_PAGER_DRAG_PENDING:
1659 case MODE_PAGER_DRAG:
1660 ewin = HiwinGetEwin(hiwin, 1);
1661 if (!ewin || ewin->type == EWIN_TYPE_PAGER)
1663 Mode.mode = MODE_NONE;
1667 Mode.mode = MODE_PAGER_DRAG;
1668 PagerEwinMove(p, p, ewin);
1684 PagersForDesktopCount(Desk * dsk)
1689 ECORE_LIST_FOR_EACH(pager_list, p)
1699 _PagerClose(Pager * p, void *prm __UNUSED__)
1705 PagersForDesktopEnable(Desk * dsk)
1707 if (PagersForDesktopCount(dsk) <= 0)
1708 NewPagerForDesktop(dsk);
1712 PagersForDesktopDisable(Desk * dsk)
1714 PagersForeach(dsk, _PagerClose, NULL);
1718 PagersShow(int enable)
1722 if (enable && !Conf_pagers.enable)
1724 Conf_pagers.enable = 1;
1725 for (i = 0; i < DesksGetNumber(); i++)
1726 PagersForDesktopEnable(DeskGet(i));
1728 Mode_pagers.idler = IdlerAdd(_PagersIdler, NULL);
1730 else if (!enable && Conf_pagers.enable)
1732 for (i = 0; i < DesksGetNumber(); i++)
1733 PagersForDesktopDisable(DeskGet(i));
1734 Conf_pagers.enable = 0;
1735 IdlerDel(Mode_pagers.idler);
1736 Mode_pagers.idler = NULL;
1741 _PagerReconfigure(Pager * p, void *prm __UNUSED__)
1743 PagerReconfigure(p, 1);
1747 _PagersReconfigureTimeout(void *data __UNUSED__)
1749 PagersForeach(NULL, _PagerReconfigure, NULL);
1755 PagersReconfigure(void)
1757 Timer *pg_timer_cfg;
1759 if (!Conf_pagers.enable)
1762 TIMER_ADD(pg_timer_cfg, .5, _PagersReconfigureTimeout, NULL);
1767 * Configuration dialog
1769 static char tmp_show_pagers;
1770 static char tmp_pager_hiq;
1771 static int tmp_pager_mode;
1772 static char tmp_pager_zoom;
1773 static char tmp_pager_title;
1774 static char tmp_pager_do_scan;
1775 static int tmp_pager_scan_speed;
1776 static int tmp_pager_sel_button;
1777 static int tmp_pager_win_button;
1778 static int tmp_pager_menu_button;
1779 static DItem *pager_scan_speed_label = NULL;
1782 CB_ConfigurePager(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
1786 PagersShow(tmp_show_pagers);
1787 if (Conf_pagers.hiq != tmp_pager_hiq)
1788 PagerSetHiQ(tmp_pager_hiq);
1789 Conf_pagers.zoom = tmp_pager_zoom;
1790 Conf_pagers.title = tmp_pager_title;
1791 Conf_pagers.sel_button = tmp_pager_sel_button;
1792 Conf_pagers.win_button = tmp_pager_win_button;
1793 Conf_pagers.menu_button = tmp_pager_menu_button;
1794 if ((Conf_pagers.scanspeed != tmp_pager_scan_speed)
1795 || ((!tmp_pager_do_scan) && (Conf_pagers.scanspeed > 0))
1796 || ((tmp_pager_do_scan) && (Conf_pagers.scanspeed == 0)))
1798 if (tmp_pager_do_scan)
1799 Conf_pagers.scanspeed = tmp_pager_scan_speed;
1801 Conf_pagers.scanspeed = 0;
1803 PagersSetMode(tmp_pager_mode);
1809 CB_PagerScanSlide(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
1813 Esnprintf(s, sizeof(s), "%s %03i %s", _("Pager scanning speed:"),
1814 tmp_pager_scan_speed, _("lines per second"));
1815 DialogItemSetText(pager_scan_speed_label, s);
1816 DialogDrawItems(d, pager_scan_speed_label, 0, 0, 99999, 99999);
1820 _DlgFillPagers(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
1825 tmp_show_pagers = Conf_pagers.enable;
1826 tmp_pager_hiq = Conf_pagers.hiq;
1827 tmp_pager_mode = Conf_pagers.mode;
1828 tmp_pager_zoom = Conf_pagers.zoom;
1829 tmp_pager_title = Conf_pagers.title;
1830 tmp_pager_sel_button = Conf_pagers.sel_button;
1831 tmp_pager_win_button = Conf_pagers.win_button;
1832 tmp_pager_menu_button = Conf_pagers.menu_button;
1833 if (Conf_pagers.scanspeed == 0)
1834 tmp_pager_do_scan = 0;
1836 tmp_pager_do_scan = 1;
1837 tmp_pager_scan_speed = Conf_pagers.scanspeed;
1839 DialogItemTableSetOptions(table, 2, 0, 0, 0);
1841 di = DialogAddItem(table, DITEM_CHECKBUTTON);
1842 DialogItemSetColSpan(di, 2);
1843 DialogItemSetText(di, _("Enable pager display"));
1844 DialogItemCheckButtonSetPtr(di, &tmp_show_pagers);
1846 di = DialogAddItem(table, DITEM_SEPARATOR);
1847 DialogItemSetColSpan(di, 2);
1849 di = DialogAddItem(table, DITEM_TEXT);
1850 DialogItemSetColSpan(di, 2);
1851 DialogItemSetFill(di, 0, 0);
1852 DialogItemSetAlign(di, 0, 512);
1853 DialogItemSetText(di, _("Pager Mode:"));
1855 radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
1856 DialogItemSetColSpan(di, 2);
1857 DialogItemSetText(di, _("Simple"));
1858 DialogItemRadioButtonSetFirst(di, radio);
1859 DialogItemRadioButtonGroupSetVal(di, 0);
1861 di = DialogAddItem(table, DITEM_RADIOBUTTON);
1862 DialogItemSetColSpan(di, 2);
1863 DialogItemSetText(di, _("Make miniature snapshots of the screen"));
1864 DialogItemRadioButtonSetFirst(di, radio);
1865 DialogItemRadioButtonGroupSetVal(di, 1);
1868 di = DialogAddItem(table, DITEM_RADIOBUTTON);
1869 DialogItemSetColSpan(di, 2);
1870 DialogItemSetText(di, _("Live Update"));
1871 DialogItemRadioButtonSetFirst(di, radio);
1872 DialogItemRadioButtonGroupSetVal(di, 2);
1874 DialogItemRadioButtonGroupSetValPtr(radio, &tmp_pager_mode);
1876 di = DialogAddItem(table, DITEM_SEPARATOR);
1877 DialogItemSetColSpan(di, 2);
1879 di = DialogAddItem(table, DITEM_CHECKBUTTON);
1880 DialogItemSetColSpan(di, 2);
1881 DialogItemSetText(di, _("Smooth high quality snapshots in snapshot mode"));
1882 DialogItemCheckButtonSetPtr(di, &tmp_pager_hiq);
1884 di = DialogAddItem(table, DITEM_CHECKBUTTON);
1885 DialogItemSetColSpan(di, 2);
1886 DialogItemSetText(di, _("Zoom in on pager windows when mouse is over them"));
1887 DialogItemCheckButtonSetPtr(di, &tmp_pager_zoom);
1889 di = DialogAddItem(table, DITEM_CHECKBUTTON);
1890 DialogItemSetColSpan(di, 2);
1891 DialogItemSetText(di,
1892 _("Pop up window title when mouse is over the window"));
1893 DialogItemCheckButtonSetPtr(di, &tmp_pager_title);
1895 di = DialogAddItem(table, DITEM_CHECKBUTTON);
1896 DialogItemSetColSpan(di, 2);
1897 DialogItemSetText(di, _("Continuously scan screen to update pager"));
1898 DialogItemCheckButtonSetPtr(di, &tmp_pager_do_scan);
1900 di = pager_scan_speed_label = DialogAddItem(table, DITEM_TEXT);
1901 DialogItemSetColSpan(di, 2);
1902 DialogItemSetFill(di, 0, 0);
1903 DialogItemSetAlign(di, 0, 512);
1904 Esnprintf(s, sizeof(s), "%s %03i %s", _("Pager scanning speed:"),
1905 tmp_pager_scan_speed, _("lines per second"));
1906 DialogItemSetText(di, s);
1908 di = DialogAddItem(table, DITEM_SLIDER);
1909 DialogItemSliderSetBounds(di, 1, 256);
1910 DialogItemSliderSetUnits(di, 1);
1911 DialogItemSliderSetJump(di, 1);
1912 DialogItemSetColSpan(di, 2);
1913 DialogItemSliderSetValPtr(di, &tmp_pager_scan_speed);
1914 DialogItemSetCallback(di, CB_PagerScanSlide, 0, NULL);
1916 di = DialogAddItem(table, DITEM_TEXT);
1917 DialogItemSetColSpan(di, 2);
1918 DialogItemSetFill(di, 0, 0);
1919 DialogItemSetAlign(di, 0, 512);
1920 DialogItemSetText(di, _("Mouse button to select and drag windows:"));
1922 radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
1923 DialogItemSetColSpan(di, 2);
1924 DialogItemSetText(di, _("Left"));
1925 DialogItemRadioButtonSetFirst(di, radio);
1926 DialogItemRadioButtonGroupSetVal(di, 1);
1928 di = DialogAddItem(table, DITEM_RADIOBUTTON);
1929 DialogItemSetColSpan(di, 2);
1930 DialogItemSetText(di, _("Middle"));
1931 DialogItemRadioButtonSetFirst(di, radio);
1932 DialogItemRadioButtonGroupSetVal(di, 2);
1934 di = DialogAddItem(table, DITEM_RADIOBUTTON);
1935 DialogItemSetColSpan(di, 2);
1936 DialogItemSetText(di, _("Right"));
1937 DialogItemRadioButtonSetFirst(di, radio);
1938 DialogItemRadioButtonGroupSetVal(di, 3);
1939 DialogItemRadioButtonGroupSetValPtr(radio, &tmp_pager_win_button);
1941 di = DialogAddItem(table, DITEM_TEXT);
1942 DialogItemSetColSpan(di, 2);
1943 DialogItemSetFill(di, 0, 0);
1944 DialogItemSetAlign(di, 0, 512);
1945 DialogItemSetText(di, _("Mouse button to select desktops:"));
1947 radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
1948 DialogItemSetColSpan(di, 2);
1949 DialogItemSetText(di, _("Left"));
1950 DialogItemRadioButtonSetFirst(di, radio);
1951 DialogItemRadioButtonGroupSetVal(di, 1);
1953 di = DialogAddItem(table, DITEM_RADIOBUTTON);
1954 DialogItemSetColSpan(di, 2);
1955 DialogItemSetText(di, _("Middle"));
1956 DialogItemRadioButtonSetFirst(di, radio);
1957 DialogItemRadioButtonGroupSetVal(di, 2);
1959 di = DialogAddItem(table, DITEM_RADIOBUTTON);
1960 DialogItemSetColSpan(di, 2);
1961 DialogItemSetText(di, _("Right"));
1962 DialogItemRadioButtonSetFirst(di, radio);
1963 DialogItemRadioButtonGroupSetVal(di, 3);
1964 DialogItemRadioButtonGroupSetValPtr(radio, &tmp_pager_sel_button);
1966 di = DialogAddItem(table, DITEM_TEXT);
1967 DialogItemSetColSpan(di, 2);
1968 DialogItemSetFill(di, 0, 0);
1969 DialogItemSetAlign(di, 0, 512);
1970 DialogItemSetText(di, _("Mouse button to display pager menu:"));
1972 radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
1973 DialogItemSetColSpan(di, 2);
1974 DialogItemSetText(di, _("Left"));
1975 DialogItemRadioButtonSetFirst(di, radio);
1976 DialogItemRadioButtonGroupSetVal(di, 1);
1978 di = DialogAddItem(table, DITEM_RADIOBUTTON);
1979 DialogItemSetColSpan(di, 2);
1980 DialogItemSetText(di, _("Middle"));
1981 DialogItemRadioButtonSetFirst(di, radio);
1982 DialogItemRadioButtonGroupSetVal(di, 2);
1984 di = DialogAddItem(table, DITEM_RADIOBUTTON);
1985 DialogItemSetColSpan(di, 2);
1986 DialogItemSetText(di, _("Right"));
1987 DialogItemRadioButtonSetFirst(di, radio);
1988 DialogItemRadioButtonGroupSetVal(di, 3);
1989 DialogItemRadioButtonGroupSetValPtr(radio, &tmp_pager_menu_button);
1992 const DialogDef DlgPagers = {
1995 N_("Pager Settings"),
1996 SOUND_SETTINGS_PAGER,
1998 N_("Enlightenment Desktop & Area\n" "Pager Settings Dialog\n"),
2000 DLG_OAC, CB_ConfigurePager,
2002 #endif /* ENABLE_DIALOGS */
2009 PagersSighan(int sig, void *prm)
2014 memset(&Mode_pagers, 0, sizeof(Mode_pagers));
2015 EDirMake(EDirUserCache(), "cached/pager");
2017 case ESIGNAL_CONFIGURE:
2020 if (!Conf_pagers.enable)
2022 Conf_pagers.enable = 0;
2026 case ESIGNAL_AREA_CONFIGURED:
2027 PagersReconfigure();
2029 case ESIGNAL_AREA_SWITCH_START:
2032 case ESIGNAL_AREA_SWITCH_DONE:
2033 PagersUpdate(DesksGetCurrent(), PAGER_UPD_EWIN_GEOM,
2034 0, 0, 99999, 99999);
2038 case ESIGNAL_DESK_ADDED:
2039 if (Mode.wm.startup)
2041 NewPagerForDesktop((Desk *) prm);
2043 case ESIGNAL_DESK_REMOVED:
2044 PagersForDesktopDisable((Desk *) prm);
2046 case ESIGNAL_DESK_SWITCH_START:
2049 case ESIGNAL_DESK_SWITCH_DONE:
2052 case ESIGNAL_DESK_RESIZE:
2053 PagersReconfigure();
2056 case ESIGNAL_BACKGROUND_CHANGE:
2057 PagersUpdateBackground((Desk *) prm);
2060 case ESIGNAL_EWIN_UNMAP:
2061 PagersUpdateEwin((EWin *) prm, PAGER_UPD_EWIN_GONE);
2063 case ESIGNAL_EWIN_CHANGE:
2064 PagersUpdateEwin((EWin *) prm, PAGER_UPD_EWIN_GEOM);
2066 case ESIGNAL_EWIN_DAMAGE:
2067 PagersUpdateEwin((EWin *) prm, PAGER_UPD_EWIN_DAMAGE);
2073 IPC_Pager(const char *params)
2075 const char *p = params;
2085 sscanf(p, "%100s %n", prm1, &len);
2088 if (!strcmp(prm1, "on"))
2092 else if (!strcmp(prm1, "off"))
2096 else if (!strcmp(prm1, "desk"))
2100 sscanf(p, "%d %100s", &desk, prm1);
2101 dsk = DeskGet(desk);
2107 else if (!strcmp(prm1, "on"))
2109 PagersForDesktopEnable(dsk);
2111 else if (!strcmp(prm1, "new"))
2113 NewPagerForDesktop(dsk);
2115 else if (!strcmp(prm1, "off"))
2117 PagersForDesktopDisable(dsk);
2120 else if (!strcmp(prm1, "hiq"))
2122 if (!strcmp(p, "on"))
2124 else if (!strcmp(p, "off"))
2127 else if (!strcmp(prm1, "mode"))
2129 if (!strncmp(p, "si", 2))
2130 PagersSetMode(PAGER_MODE_SIMPLE);
2131 else if (!strncmp(p, "sn", 2))
2132 PagersSetMode(PAGER_MODE_SNAP);
2133 else if (!strncmp(p, "li", 2))
2134 PagersSetMode(PAGER_MODE_LIVE);
2136 else if (!strcmp(prm1, "zoom"))
2138 if (!strcmp(p, "on"))
2139 Conf_pagers.zoom = 1;
2140 else if (!strcmp(p, "off"))
2141 Conf_pagers.zoom = 0;
2145 static const IpcItem PagersIpcArray[] = {
2149 "Toggle the status of the Pager and various pager settings",
2150 "use \"pager <on/off>\" to set the current mode\nuse \"pager ?\" "
2151 "to get the current mode\n"
2152 " pager <#> <on/off/?> Toggle or test any desktop's pager\n"
2153 " pager hiq <on/off> Toggle high quality pager\n"
2154 " pager scanrate <#> Toggle number of line updates per second\n"
2155 " pager mode <mode> Set pager mode (simple/snapshot/live)\n"
2156 " pager title <on/off> Toggle title display in the pager\n"
2157 " pager zoom <on/off> Toggle zooming in the pager\n"}
2160 #define N_IPC_FUNCS (sizeof(PagersIpcArray)/sizeof(IpcItem))
2163 * Configuration items
2165 static const CfgItem PagersCfgItems[] = {
2166 CFG_ITEM_BOOL(Conf_pagers, enable, 1),
2167 CFG_ITEM_BOOL(Conf_pagers, zoom, 1),
2168 CFG_ITEM_BOOL(Conf_pagers, title, 1),
2169 CFG_ITEM_BOOL(Conf_pagers, hiq, 1),
2170 CFG_ITEM_INT(Conf_pagers, mode, PAGER_MODE_LIVE),
2171 CFG_ITEM_INT(Conf_pagers, scanspeed, 10),
2172 CFG_ITEM_INT(Conf_pagers, sel_button, 2),
2173 CFG_ITEM_INT(Conf_pagers, win_button, 1),
2174 CFG_ITEM_INT(Conf_pagers, menu_button, 3),
2176 #define N_CFG_ITEMS (sizeof(PagersCfgItems)/sizeof(CfgItem))
2181 extern const EModule ModPagers;
2182 const EModule ModPagers = {
2185 {N_IPC_FUNCS, PagersIpcArray},
2186 {N_CFG_ITEMS, PagersCfgItems}