void do_draw_technical(EX_Drawable dr, GC gc, int a, int b, int c, int d, int bl, int br, int bt, int bb) { if (!font) font = XLoadFont(disp, "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*"); XSetFont(disp, gc, font); if (c < 3) c = 3; if (d < 3) d = 3; draw_h_arrow(dr, gc, a + bl, a + bl + c - 1, b + bt + d - 16); draw_h_arrow(dr, gc, 0, a - 1, b + bt + (d / 2)); draw_h_arrow(dr, gc, a + c + bl + br, WinGetW(VROOT) - 1, b + bt + (d / 2)); draw_v_arrow(dr, gc, b + bt, b + bt + d - 1, a + bl + 16); draw_v_arrow(dr, gc, 0, b - 1, a + bl + (c / 2)); draw_v_arrow(dr, gc, b + d + bt + bb, WinGetH(VROOT) - 1, a + bl + (c / 2)); XDrawLine(disp, dr, gc, a, 0, a, WinGetH(VROOT)); XDrawLine(disp, dr, gc, a + c + bl + br - 1, 0, a + c + bl + br - 1, WinGetH(VROOT)); XDrawLine(disp, dr, gc, 0, b, WinGetW(VROOT), b); XDrawLine(disp, dr, gc, 0, b + d + bt + bb - 1, WinGetW(VROOT), b + d + bt + bb - 1); XDrawRectangle(disp, dr, gc, a + bl + 1, b + bt + 1, c - 3, d - 3); }
static Container * SelectIconboxForEwin(EWin * ewin) { /* find the appropriate iconbox from all available ones for this app */ /* if it is to be iconified, or if it is alreayd return which iconbox */ /* it's in */ Container *ct, *ib_sel = NULL; if (!ewin) return NULL; if (ewin->state.iconified) { /* find the iconbox this window got iconifed into */ ib_sel = ContainersIterate(IconboxFindEwin, IB_TYPE_ICONBOX, ewin); } else { /* pick the closest iconbox physically on screen to put it in */ int min_dist; int dx, dy, dist; int i, num; Container **lst; lst = ContainersGetList(&num); min_dist = 0x7fffffff; for (i = 0; i < num; i++) { ct = lst[i]; if (!ct->ewin || ct->type != IB_TYPE_ICONBOX) continue; dx = (EoGetX(ct->ewin) + (EoGetW(ct->ewin) / 2)) - (EoGetX(ewin) + (EoGetW(ewin) / 2)); dy = (EoGetY(ct->ewin) + (EoGetH(ct->ewin) / 2)) - (EoGetY(ewin) + (EoGetH(ewin) / 2)); dist = (dx * dx) + (dy * dy); if ((!EoIsSticky(ct->ewin)) && (EoGetDesk(ct->ewin) != EoGetDesk(ewin))) dist += (WinGetW(VROOT) * WinGetW(VROOT)) + (WinGetH(VROOT) * WinGetH(VROOT)); if (dist < min_dist) { min_dist = dist; ib_sel = ct; } } Efree(lst); } return ib_sel; }
static EImage * pt_get_bg_image(Win win, int w, int h, int use_root) { EImage *ii = NULL; Win cr; Drawable bg; int xx, yy; bg = DeskGetBackgroundPixmap(DesksGetCurrent()); if (use_root || bg == None) { cr = VROOT; bg = WinGetXwin(VROOT); } else { cr = EoGetWin(DesksGetCurrent()); } ETranslateCoordinates(win, cr, 0, 0, &xx, &yy, NULL); #if 0 Eprintf("pt_get_bg_image %#lx %d %d %d %d\n", win, xx, yy, w, h); #endif if (xx < WinGetW(VROOT) && yy < WinGetH(VROOT) && xx + w >= 0 && yy + h >= 0) { /* Create the background base image */ ii = EImageGrabDrawable(bg, None, xx, yy, w, h, !EServerIsGrabbed()); } return ii; }
static void IPC_Screen(const char *params) { char param[1024]; int l; const char *p; param[0] = '\0'; p = params; if (p) { l = 0; sscanf(p, "%1000s %n", param, &l); p += l; } if (!p || !strncmp(param, "list", 2)) { ScreenShowInfo(p); } else if (!strncmp(param, "size", 2)) { IpcPrintf("Screen %d size %dx%d\n", Dpy.screen, WinGetW(VROOT), WinGetH(VROOT)); } else if (!strcmp(param, "split")) { unsigned int nx, ny; nx = 2; ny = 1; sscanf(p, "%u %u\n", &nx, &ny); ScreenSplit(nx, ny); } }
static void EdgeWindowShow(int which, int on) { EObj *eo; int x, y, w, h; x = y = 0; w = h = 1; switch (which) { default: case 1: /* Left */ eo = w1; h = WinGetH(VROOT); break; case 2: /* Right */ eo = w2; x = WinGetW(VROOT) - 1; h = WinGetH(VROOT); break; case 3: /* Top */ eo = w3; w = WinGetW(VROOT); break; case 4: /* Bottom */ eo = w4; y = WinGetH(VROOT) - 1; w = WinGetW(VROOT); break; } if (on) { EobjMoveResize(eo, x, y, w, h); EobjMap(eo, 0); } else { EobjUnmap(eo); } }
void EdgeWindowsShow(void) { int ax, ay, cx, cy; if (Conf.desks.edge_flip_mode == EDGE_FLIP_OFF) { EdgeWindowsHide(); return; } if (!w1) { w1 = EobjWindowCreate(EOBJ_TYPE_EVENT, 0, 0, 1, WinGetH(VROOT), 0, "Edge-L"); w2 = EobjWindowCreate(EOBJ_TYPE_EVENT, WinGetW(VROOT) - 1, 0, 1, WinGetH(VROOT), 0, "Edge-R"); w3 = EobjWindowCreate(EOBJ_TYPE_EVENT, 0, 0, WinGetW(VROOT), 1, 0, "Edge-T"); w4 = EobjWindowCreate(EOBJ_TYPE_EVENT, 0, WinGetH(VROOT) - 1, WinGetW(VROOT), 1, 0, "Edge-B"); ESelectInput(EobjGetWin(w1), EnterWindowMask | LeaveWindowMask); ESelectInput(EobjGetWin(w2), EnterWindowMask | LeaveWindowMask); ESelectInput(EobjGetWin(w3), EnterWindowMask | LeaveWindowMask); ESelectInput(EobjGetWin(w4), EnterWindowMask | LeaveWindowMask); EventCallbackRegister(EobjGetWin(w1), EdgeHandleEvents, (void *)0); EventCallbackRegister(EobjGetWin(w2), EdgeHandleEvents, (void *)1); EventCallbackRegister(EobjGetWin(w3), EdgeHandleEvents, (void *)2); EventCallbackRegister(EobjGetWin(w4), EdgeHandleEvents, (void *)3); } DeskCurrentGetArea(&cx, &cy); DesksGetAreaSize(&ax, &ay); EdgeWindowShow(1, cx != 0 || Conf.desks.areas_wraparound); EdgeWindowShow(2, cx != (ax - 1) || Conf.desks.areas_wraparound); EdgeWindowShow(3, cy != 0 || Conf.desks.areas_wraparound); EdgeWindowShow(4, cy != (ay - 1) || Conf.desks.areas_wraparound); }
static void MagwinShow(void) { if (MagWin) goto done; MagWin = MagwinCreate(_("Magnifier"), WinGetW(VROOT) / 4, WinGetH(VROOT) / 4); if (!MagWin) return; done: EwinShow(MagWin->ewin); }
static void _SnapUpdateEwinLocation(Snapshot * sn, const EWin * ewin) { int ax, ay; sn->x = EoGetX(ewin); sn->y = EoGetY(ewin); sn->area_x = ewin->area_x; sn->area_y = ewin->area_y; if (!EoIsSticky(ewin)) { DeskGetArea(EoGetDesk(ewin), &ax, &ay); sn->x += ((ax - sn->area_x) * WinGetW(VROOT)); sn->y += ((ay - sn->area_y) * WinGetH(VROOT)); } }
void EdgeCheckMotion(int x, int y) { int dir; if (x == 0) dir = 0; else if (x == WinGetW(VROOT) - 1) dir = 1; else if (y == 0) dir = 2; else if (y == WinGetH(VROOT) - 1) dir = 3; else dir = -1; EdgeEvent(dir); }
static void SetPanning(XRRScreenResources * xsr, RRCrtc crtc, int on) { XRRPanning *xpa; xpa = XRRGetPanning(disp, xsr, crtc); if (!xpa) return; Dprintf("Panning-A: %d,%d %dx%d trk: %d,%d %dx%d bdr: %d,%d,%d,%d\n", xpa->left, xpa->top, xpa->width, xpa->height, xpa->track_left, xpa->track_top, xpa->track_width, xpa->track_height, xpa->border_left, xpa->border_top, xpa->border_right, xpa->border_bottom); xpa->timestamp = EGetTimestamp(); xpa->left = xpa->top = 0; if (on) { xpa->width = WinGetW(VROOT); xpa->height = WinGetH(VROOT); xpa->track_width = xpa->track_height = 1; } else { xpa->width = xpa->height = 0; xpa->track_width = xpa->track_height = 0; } xpa->track_left = xpa->track_top = 0; xpa->border_left = xpa->border_top = 0; xpa->border_right = xpa->border_bottom = 0; Dprintf("Panning-B: %d,%d %dx%d trk: %d,%d %dx%d bdr: %d,%d,%d,%d\n", xpa->left, xpa->top, xpa->width, xpa->height, xpa->track_left, xpa->track_top, xpa->track_width, xpa->track_height, xpa->border_left, xpa->border_top, xpa->border_right, xpa->border_bottom); XRRSetPanning(disp, xsr, crtc, xpa); XRRFreePanning(xpa); }
static int MagwinKeyPress(MagWindow * mw, KeySym key) { switch (key) { case XK_q: /* Quit */ case XK_Escape: return 1; case XK_g: /* Toggle grabs */ if (mw->grabbing) _MagwinGrabRelease(mw); else _MagwinGrabSet(mw); break; case XK_t: /* Toggle text */ mw->disable_text = !mw->disable_text; break; case XK_u: /* Toggle update always */ mw->update_always = !mw->update_always; break; case XK_f: /* Toggle filter */ mw->filter += 1; mw->filter %= 2; break; case XK_i: /* Zoom in */ case XK_Page_Up: mw->scale += 1; break; case XK_o: /* Zoom out */ case XK_Page_Down: mw->scale -= 1; if (mw->scale < -20) mw->scale = -20; break; case XK_Left: mw->cx -= mw->step; if (mw->cx < mw->sw / 2) mw->cx = mw->sw / 2; break; case XK_Right: mw->cx += mw->step; if (mw->cx > WinGetW(VROOT) - mw->sw / 2) mw->cx = WinGetW(VROOT) - mw->sw / 2; break; case XK_Up: mw->cy -= mw->step; if (mw->cy < mw->sh / 2) mw->cy = mw->sh / 2; break; case XK_Down: mw->cy += mw->step; if (mw->cy > WinGetH(VROOT) - mw->sh / 2) mw->cy = WinGetH(VROOT) - mw->sh / 2; break; case XK_r: /* Switch render mode */ Conf.testing.use_render_for_scaling = !Conf.testing.use_render_for_scaling; break; case XK_s: /* x/y move step size */ mw->step = (mw->step == 1) ? 4 : 1; break; } return 0; }
void ITApply(Win win, ImageClass * ic, ImageState * is, int state, int active, int sticky, int image_type, TextClass * tc, TextState * ts, const char *text, int flags) { int w, h; if (!win || !ic) return; w = WinGetW(win); h = WinGetH(win); if (w <= 0 || h <= 0) return; if (!is) is = ImageclassGetImageState(ic, state, active, sticky); if (!is) return; if (tc && text) { if (!ts) ts = TextclassGetTextState(tc, state, active, sticky); } if (!is->im) ImagestateRealize(is); /* Imlib2 will not render pixmaps with dimensions > 8192 */ if (is->im && w <= 8192 && h <= 8192) { PmapMask pmm; ImagestateMakePmapMask(is, win, &pmm, IC_FLAG_MAKE_MASK, w, h, image_type); if (pmm.pmap) { Pixmap pmap = pmm.pmap; if ((ts && text) || (is->bevelstyle != BEVEL_NONE) || (flags & ITA_BGPMAP)) { if (pmm.type != 0) { pmap = EGetWindowBackgroundPixmap(win); EXCopyAreaTiled(pmm.pmap, None, pmap, 0, 0, w, h, 0, 0); } if (is->bevelstyle != BEVEL_NONE) { GC gc; gc = EXCreateGC(WinGetXwin(win), 0, NULL); ImagestateDrawBevel(is, pmap, gc, 0, 0, w, h); EXFreeGC(gc); } if (ts && text) TextstateTextDraw(ts, win, pmap, text, 0, 0, w, h, &(ic->padding), 0, TextclassGetJustification(tc), flags & ITA_JUSTV); } /* Set window pixmap */ if (pmap == pmm.pmap) { ESetWindowBackgroundPixmap(win, pmap); EFreeWindowBackgroundPixmap(win); } if (pmm.w == w && pmm.h == h) EShapeSetMask(win, 0, 0, pmm.mask); else if (pmm.mask) EShapeSetMaskTiled(win, 0, 0, pmm.mask, w, h); } PmapMaskFree(&pmm); if ((is->unloadable) || (Conf.memory_paranoia)) { EImageFree(is->im); is->im = NULL; } } else { ImagestateColorsAlloc(is); if (is->bevelstyle == BEVEL_NONE && !text) { ESetWindowBackground(win, is->bg_pixel); } else { Pixmap pmap; pmap = EGetWindowBackgroundPixmap(win); ImagestateDrawNoImg(is, pmap, 0, 0, w, h); if (ts && text) TextstateTextDraw(ts, win, pmap, text, 0, 0, w, h, &(ic->padding), 0, TextclassGetJustification(tc), flags & ITA_JUSTV); } } EClearWindow(win); }
static Window ExtInitWinMain(void) { int i, loop, err; Ecore_X_Window win; XGCValues gcv; GC gc; Pixmap pmap; Atom a; EiwData eiwd; EiwLoopFunc *eiwc_loop_func; if (EDebug(EDBUG_TYPE_SESSION)) Eprintf("ExtInitWinMain enter\n"); err = EDisplayOpen(NULL, -1); if (err) return None; EGrabServer(); EImageInit(); eiwd.attr.backing_store = NotUseful; eiwd.attr.override_redirect = True; eiwd.attr.colormap = WinGetCmap(VROOT); eiwd.attr.border_pixel = 0; eiwd.attr.background_pixel = 0; eiwd.attr.save_under = True; win = XCreateWindow(disp, WinGetXwin(VROOT), 0, 0, WinGetW(VROOT), WinGetH(VROOT), 0, CopyFromParent, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap | CWBackPixel | CWBorderPixel, &eiwd.attr); pmap = XCreatePixmap(disp, win, WinGetW(VROOT), WinGetH(VROOT), WinGetDepth(VROOT)); gcv.subwindow_mode = IncludeInferiors; gc = XCreateGC(disp, win, GCSubwindowMode, &gcv); XCopyArea(disp, WinGetXwin(VROOT), pmap, gc, 0, 0, WinGetW(VROOT), WinGetH(VROOT), 0, 0); XSetWindowBackgroundPixmap(disp, win, pmap); XMapRaised(disp, win); XFreePixmap(disp, pmap); XFreeGC(disp, gc); a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN"); ecore_x_window_prop_window_set(WinGetXwin(VROOT), a, &win, 1); XSelectInput(disp, win, StructureNotifyMask); EUngrabServer(); ESync(0); #if USE_EIWC_WINDOW && USE_EIWC_RENDER eiwc_loop_func = _eiw_render_init(win, &eiwd); if (!eiwc_loop_func) eiwc_loop_func = _eiw_window_init(win, &eiwd); #elif USE_EIWC_RENDER eiwc_loop_func = _eiw_render_init(win, &eiwd); #elif USE_EIWC_WINDOW eiwc_loop_func = _eiw_window_init(win, &eiwd); #endif if (!eiwc_loop_func) return None; { XWindowAttributes xwa; char s[1024]; EImage *im; for (i = loop = 1;; i++, loop++) { if (i > 12) i = 1; /* If we get unmapped we are done */ XGetWindowAttributes(disp, win, &xwa); if (xwa.map_state == IsUnmapped) break; Esnprintf(s, sizeof(s), "pix/wait%i.png", i); if (EDebug(EDBUG_TYPE_SESSION) > 1) Eprintf("ExtInitWinCreate - child %s\n", s); im = ThemeImageLoad(s); if (im) { eiwc_loop_func(win, im, &eiwd); EImageFree(im); } ESync(0); usleep(50000); /* If we still are here after 5 sec something is wrong. */ if (loop > 100) break; } } if (EDebug(EDBUG_TYPE_SESSION)) Eprintf("ExtInitWinMain exit\n"); EDisplayClose(); exit(0); }
static int EdgeTimeout(void *data) { int val; int ax, ay, aw, ah, dx, dy, dax, day; EWin *ewin; if (MenusActive()) goto done; if (Conf.desks.edge_flip_mode == EDGE_FLIP_OFF) goto done; /* Quit if pointer has left screen */ if (!EQueryPointer(NULL, NULL, NULL, NULL, NULL)) goto done; /* Quit if in fullscreen window */ ewin = GetEwinPointerInClient(); if (ewin && ewin->state.fullscreen) goto done; DeskCurrentGetArea(&ax, &ay); DesksGetAreaSize(&aw, &ah); val = PTR2INT(data); dx = 0; dy = 0; dax = 0; day = 0; switch (val) { case 0: if (ax == 0 && !Conf.desks.areas_wraparound) goto done; dx = WinGetW(VROOT) - 2; dax = -1; break; case 1: if (ax == (aw - 1) && !Conf.desks.areas_wraparound) goto done; dx = -(WinGetW(VROOT) - 2); dax = 1; break; case 2: if (ay == 0 && !Conf.desks.areas_wraparound) goto done; dy = WinGetH(VROOT) - 2; day = -1; break; case 3: if (ay == (ah - 1) && !Conf.desks.areas_wraparound) goto done; dy = -(WinGetH(VROOT) - 2); day = 1; break; default: break; } if (aw == 1) dx = 0; if (ah == 1) dy = 0; Mode.events.px = Mode.events.mx; Mode.events.py = Mode.events.my; Mode.events.mx = Mode.events.cx += dx; Mode.events.my = Mode.events.cy += dy; EWarpPointer(VROOT, Mode.events.mx, Mode.events.my); DeskCurrentMoveAreaBy(dax, day); Mode.events.px = Mode.events.mx; Mode.events.py = Mode.events.my; done: edge_timer = NULL; return 0; }
void StartupWindowsCreate(void) { Win w1, w2, win1, win2, b1, b2; Background *bg; ImageClass *ic; int x, y, bx, by, bw, bh, dbw; EObj *eo; /* Acting only as boolean? */ if (BackgroundFind("STARTUP_BACKGROUND_SIDEWAYS")) bg_sideways = 1; ic = ImageclassFind("STARTUP_BAR", 0); if (!ic) ic = ImageclassFind("DESKTOP_DRAGBUTTON_HORIZ", 0); bg = BackgroundFind("STARTUP_BACKGROUND"); if (!ic || !bg) return; dbw = Conf.desks.dragbar_width; if (dbw <= 0) dbw = 16; if (bg_sideways) { x = WinGetW(VROOT) / 2; y = 0; bx = WinGetW(VROOT) - dbw; by = 0; bw = dbw; bh = WinGetH(VROOT); } else { x = 0; y = WinGetH(VROOT) / 2; bx = 0; by = WinGetH(VROOT) - dbw; bw = WinGetW(VROOT); bh = dbw; } eo = EobjWindowCreate(EOBJ_TYPE_MISC, -x, -y, WinGetW(VROOT), WinGetH(VROOT), 1, "Init-1"); if (!eo) return; init_win1 = eo; w1 = EobjGetWin(eo); win1 = ECreateWindow(w1, x, y, WinGetW(VROOT), WinGetH(VROOT), 0); eo = EobjWindowCreate(EOBJ_TYPE_MISC, x, y, WinGetW(VROOT), WinGetH(VROOT), 1, "Init-2"); if (!eo) return; init_win2 = eo; w2 = EobjGetWin(eo); win2 = ECreateWindow(w2, -x, -y, WinGetW(VROOT), WinGetH(VROOT), 0); EMapWindow(win1); EMapWindow(win2); if (bw > 0 && bh > 0) { b1 = ECreateWindow(w1, bx, by, bw, bh, 0); b2 = ECreateWindow(w2, 0, 0, bw, bh, 0); EMapRaised(b1); EMapRaised(b2); ImageclassApply(ic, b1, 0, 0, 0, ST_SOLID); ImageclassApply(ic, b2, 0, 0, 0, ST_SOLID); } BackgroundSet(bg, win1, WinGetW(VROOT), WinGetH(VROOT)); BackgroundSet(bg, win2, WinGetW(VROOT), WinGetH(VROOT)); StartupBackgroundsDestroy(); EobjMap(init_win1, 0); EobjMap(init_win2, 0); EobjsRepaint(); }
static void MenuRealize(Menu * m) { int i, maxh, maxw, nmaxy; int maxx1, maxx2, w, h, x, y, r, mmw, mmh; EImage *im; EImageBorder *pad, *pad_item, *pad_sub; char has_i, has_s; if (m->num <= 0) return; if (!m->style) { MenuSetStyle(m, NULL); if (!m->style) return; } if (!m->win) { m->win = ECreateClientWindow(VROOT, 0, 0, 1, 1); EventCallbackRegister(m->win, MenuHandleEvents, m); } maxh = maxw = 0; maxx1 = 0; maxx2 = 0; has_i = 0; has_s = 0; for (i = 0; i < m->num; i++) { m->items[i]->menu = m; if (m->items[i]->child) has_s = 1; else has_i = 1; m->items[i]->win = ECreateWindow(m->win, 0, 0, 1, 1, 0); EventCallbackRegister(m->items[i]->win, MenuItemHandleEvents, m->items[i]); ESelectInput(m->items[i]->win, MENU_ITEM_EVENT_MASK); EMapWindow(m->items[i]->win); if ((m->style->tclass) && (m->items[i]->text)) { TextSize(m->style->tclass, 0, 0, 0, _(m->items[i]->text), &w, &h, 17); if (h > maxh) maxh = h; if (w > maxx1) maxx1 = w; m->items[i]->text_w = w; m->items[i]->text_h = h; } if (m->items[i]->icon_iclass && Conf.menus.show_icons) { im = ImageclassGetImage(m->items[i]->icon_iclass, 0, 0, 0); if (im) { w = h = 0; if (m->icon_size > 0) w = h = m->icon_size; else if (m->icon_size == 0) w = h = Conf.menus.icon_size; if (w <= 0 || h <= 0) EImageGetSize(im, &w, &h); m->items[i]->icon_w = w; m->items[i]->icon_h = h; m->items[i]->icon_win = ECreateWindow(m->items[i]->win, 0, 0, w, h, 0); EMapWindow(m->items[i]->icon_win); if (h > maxh) maxh = h; if (w > maxx2) maxx2 = w; EImageFree(im); } else m->items[i]->icon_iclass = NULL; } } pad = ImageclassGetPadding(m->style->bg_iclass); pad_item = ImageclassGetPadding(m->style->item_iclass); pad_sub = ImageclassGetPadding(m->style->sub_iclass); if (((has_i) && (has_s)) || ((!has_i) && (!has_s))) { if (pad_item->top > pad_sub->top) maxh += pad_item->top; else maxh += pad_sub->top; if (pad_item->bottom > pad_sub->bottom) maxh += pad_item->bottom; else maxh += pad_sub->bottom; maxw = maxx1 + maxx2; if (pad_item->left > pad_sub->left) maxw += pad_item->left; else maxw += pad_sub->left; if (pad_item->right > pad_sub->right) maxw += pad_item->right; else maxw += pad_sub->right; } else if (has_i) { maxh += pad_item->top; maxh += pad_item->bottom; maxw = maxx1 + maxx2; maxw += pad_item->left; maxw += pad_item->right; } else if (has_s) { maxh += pad_sub->top; maxh += pad_sub->bottom; maxw = maxx1 + maxx2; maxw += pad_sub->left; maxw += pad_sub->right; } mmw = 0; mmh = 0; nmaxy = 3 * WinGetH(VROOT) / (4 * maxh + 1); if (m->style->maxy && nmaxy > m->style->maxy) nmaxy = m->style->maxy; r = 0; x = 0; y = 0; for (i = 0; i < m->num; i++) { if (r == 0 && (m->style->bg_iclass) && (!m->style->use_item_bg)) { x += pad->left; y += pad->top; } EMoveResizeWindow(m->items[i]->win, x, y, maxw, maxh); if (m->style->iconpos == ICON_LEFT) { m->items[i]->text_x = pad_item->left + maxx2; m->items[i]->text_w = maxx1; m->items[i]->text_y = (maxh - m->items[i]->text_h) / 2; if (m->items[i]->icon_win) EMoveWindow(m->items[i]->icon_win, pad_item->left + ((maxx2 - m->items[i]->icon_w) / 2), ((maxh - m->items[i]->icon_h) / 2)); } else { m->items[i]->text_x = pad_item->left; m->items[i]->text_w = maxx1; m->items[i]->text_y = (maxh - m->items[i]->text_h) / 2; if (m->items[i]->icon_win) EMoveWindow(m->items[i]->icon_win, maxw - pad_item->right - maxx2 + ((maxx2 - m->items[i]->icon_w) / 2), ((maxh - m->items[i]->icon_h) / 2)); } if (m->items[i]->icon_iclass && Conf.menus.show_icons) { ImageclassApply(m->items[i]->icon_iclass, m->items[i]->icon_win, 0, 0, STATE_NORMAL, ST_MENU_ITEM); } if (x + maxw > mmw) mmw = x + maxw; if (y + maxh > mmh) mmh = y + maxh; if ((m->style->maxx) || (nmaxy)) { if (nmaxy) { y += maxh; r++; if (r >= nmaxy) { r = 0; x += maxw; y = 0; } } else { x += maxw; r++; if (r >= m->style->maxx) { r = 0; y += maxh; x = 0; } } } else y += maxh; } if ((m->style->bg_iclass) && (!m->style->use_item_bg)) { mmw += pad->right; mmh += pad->bottom; } m->redraw = 1; m->w = mmw; m->h = mmh; EResizeWindow(m->win, mmw, mmh); }
static void MagwinRedraw(MagWindow * mw, int paint) { int ww, wh; int sx, sy, sw, sh; double scale; int zoom_res; Drawable draw; char buf[128]; int px, py; int qx, qy; int out; unsigned int len; ww = mw->ewin->client.w; wh = mw->ewin->client.h; zoom_res = Conf.magwin.zoom_res; if (mw->scale < -6 * zoom_res) mw->scale = -6 * zoom_res; else if (mw->scale > 6 * zoom_res) mw->scale = 6 * zoom_res; scale = pow(2., (double)(mw->scale) / zoom_res); sw = (int)((ww + .999 * scale) / scale); if (sw > WinGetW(VROOT)) scale = (double)ww / (double)WinGetW(VROOT); sh = (int)((wh + .999 * scale) / scale); if (sh > WinGetH(VROOT) && scale < (double)wh / (double)WinGetH(VROOT)) scale = (double)wh / (double)WinGetH(VROOT); sw = (int)((ww + .999 * scale) / scale); sh = (int)((wh + .999 * scale) / scale); sx = mw->cx - sw / 2; sy = mw->cy - sh / 2; if (sx < 0) sx = 0; else if (sx + sw > WinGetW(VROOT)) sx = WinGetW(VROOT) - sw; if (sy < 0) sy = 0; else if (sy + sh > WinGetH(VROOT)) sy = WinGetH(VROOT) - sh; mw->sx = sx; mw->sy = sy; mw->sw = sw; mw->sh = sh; if (paint) { int dw, dh; dw = (int)(sw * scale + .5); dh = (int)(sh * scale + .5); draw = ECompMgrGetRootBuffer(); ScaleRect(VROOT, draw, EwinGetClientWin(mw->ewin), EwinGetClientXwin(mw->ewin), sx, sy, sw, sh, 0, 0, dw, dh, (mw->filter) ? EIMAGE_ANTI_ALIAS : 0); } if (mw->disable_text) return; /* Check if pointer is in magnifier window */ EQueryPointer(EwinGetClientWin(mw->ewin), &px, &py, NULL, NULL); out = px < 0 || px >= mw->ewin->client.w || py < 0 || py >= mw->ewin->client.h; /* Show magnified area coordinates */ len = Esnprintf(buf, sizeof(buf), "x%.2f: %d,%d %dx%d", scale, sx, sy, sw, sh); if (out) goto done; /* Show info about pixel at cursor (if in magnifier) */ qx = (int)(px / scale); qy = (int)(py / scale); if (qx > WinGetW(VROOT) - 1) qx = WinGetW(VROOT) - 1; if (qy > WinGetH(VROOT) - 1) qy = WinGetH(VROOT) - 1; Esnprintf(buf + len, sizeof(buf) - len, "\n%d,%d: pixel=%#08x", sx + qx, sy + qy, MagwinGetPixel(EwinGetClientXwin(mw->ewin), px, py)); done: MagwinDrawText(mw, 10, 10, buf); }
static int SwitchRes(char inout, int x, int y, int w, int h, int *dw, int *dh) { static int vp_x, vp_y; XF86VidModeModeInfo *mode; int scr; scr = Dpy.screen; if (inout) { XF86VidModeModeLine curmode; int dotclock; int rx, ry; if (!XF86VidModeGetModeLine(disp, scr, &dotclock, &curmode)) return 0; XF86VidModeGetViewPort(disp, scr, &vp_x, &vp_y); mode = FindMode(w, h); if (mode) { #if USE_XRANDR int vw, vh; vw = WinGetW(VROOT); vh = WinGetH(VROOT); /* x and y relative to unrotated display */ if (Mode.screen.rotation == RR_Rotate_90) { rx = y; ry = vw - mode->vdisplay - x; } else if (Mode.screen.rotation == RR_Rotate_270) { rx = vh - mode->hdisplay - y; ry = x; } else if (Mode.screen.rotation == RR_Rotate_180) { rx = vw - mode->hdisplay - x; ry = vh - mode->vdisplay - y; } else #endif { rx = x; ry = y; } #if USE_XRANDR if ((Mode.screen.rotation == RR_Rotate_90) || (Mode.screen.rotation == RR_Rotate_270)) { *dw = mode->vdisplay; *dh = mode->hdisplay; } else #endif { *dw = mode->hdisplay; *dh = mode->vdisplay; } XF86VidModeLockModeSwitch(disp, scr, 0); std_vid_mode_cur = GetModeIndex(dotclock, &curmode); XF86VidModeSwitchToMode(disp, scr, mode); XF86VidModeSetViewPort(disp, scr, rx, ry); XF86VidModeLockModeSwitch(disp, scr, 1); return 1; } } else { mode = std_vid_modes[std_vid_mode_cur]; XF86VidModeLockModeSwitch(disp, scr, 0); XF86VidModeSwitchToMode(disp, scr, mode); XF86VidModeSetViewPort(disp, scr, vp_x, vp_y); #if 0 /* No, don't lock or we can't switch resolution */ XF86VidModeLockModeSwitch(disp, scr, 1); #endif } return 0; }
void TooltipShow(ToolTip * tt, const char *text, ActionClass * ac, int x, int y) { int i, w, h, ix, iy, iw, ih, dx, dy, xx, yy; int ww, hh, adx, ady, dist; int headline_h = 0, headline_w = 0, icons_width = 0, labels_width = 0, double_w = 0; EImage *im; int *heights = NULL; ImageClass *ic; EImageBorder *pad; int cols[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int num, modifiers; Action *aa; const char *tts; EObj *eo; if (!tt || Mode.mode != MODE_NONE) return; if (!tt->TTWIN) { TooltipRealize(tt); if (!tt->TTWIN) return; } /* if we get an actionclass, look for tooltip action texts */ h = 0; if (ac) { num = ActionclassGetActionCount(ac); heights = EMALLOC(int, num); for (i = 0; i < num; i++) { int temp_w, temp_h; temp_w = 0; temp_h = 0; aa = ActionclassGetAction(ac, i); if (!aa) continue; tts = ActionGetTooltipString(aa); if (!tts) continue; tts = _(tts); TextSize(tt->tclass, 0, 0, STATE_NORMAL, tts, &temp_w, &temp_h, 17); if (temp_w > labels_width) labels_width = temp_w; temp_w = 0; if (ActionGetEvent(aa) == EVENT_DOUBLE_DOWN) { TextSize(tt->tclass, 0, 0, STATE_NORMAL, "2x", &double_w, &temp_h, 17); if (cols[0] < double_w) cols[0] = double_w; } if (ActionGetAnybutton(aa)) { TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_ANY", "pix/mouse_any.png", &cols[1], &temp_h); } else switch (ActionGetButton(aa)) { case 1: TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_1", "pix/mouse_1.png", &cols[1], &temp_h); break; case 2: TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_2", "pix/mouse_2.png", &cols[1], &temp_h); break; case 3: TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_3", "pix/mouse_3.png", &cols[1], &temp_h); break; case 4: TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_4", "pix/mouse_4.png", &cols[1], &temp_h); break; case 5: TooltipCreateIclass("TOOLTIP_MOUSEBUTTON_5", "pix/mouse_5.png", &cols[1], &temp_h); break; case 0: default: break; } modifiers = ActionGetModifiers(aa); if (modifiers) { if (modifiers & ShiftMask) TooltipCreateIclass("TOOLTIP_KEY_SHIFT", "pix/key_shift.png", &cols[2], &temp_h); if (modifiers & LockMask) TooltipCreateIclass("TOOLTIP_KEY_LOCK", "pix/key_lock.png", &cols[3], &temp_h); if (modifiers & ControlMask) TooltipCreateIclass("TOOLTIP_KEY_CTRL", "pix/key_ctrl.png", &cols[4], &temp_h); if (modifiers & Mod1Mask) TooltipCreateIclass("TOOLTIP_KEY_MOD1", "pix/key_mod1.png", &cols[5], &temp_h); if (modifiers & Mod2Mask) TooltipCreateIclass("TOOLTIP_KEY_MOD2", "pix/key_mod2.png", &cols[6], &temp_h); if (modifiers & Mod3Mask) TooltipCreateIclass("TOOLTIP_KEY_MOD3", "pix/key_mod3.png", &cols[7], &temp_h); if (modifiers & Mod4Mask) TooltipCreateIclass("TOOLTIP_KEY_MOD4", "pix/key_mod4.png", &cols[8], &temp_h); if (modifiers & Mod5Mask) TooltipCreateIclass("TOOLTIP_KEY_MOD5", "pix/key_mod5.png", &cols[9], &temp_h); } temp_w = cols[0] + cols[1] + cols[2] + cols[3] + cols[4] + cols[5] + cols[6] + cols[7] + cols[8] + cols[9]; if (temp_w > icons_width) icons_width = temp_w; heights[i] = temp_h; h += temp_h; } } TextSize(tt->tclass, 0, 0, STATE_NORMAL, text, &headline_w, &headline_h, 17); if (headline_w < icons_width + labels_width) w = icons_width + labels_width; else w = headline_w; h += headline_h; ic = tt->TTICL; pad = ImageclassGetPadding(ic); iw = 0; ih = 0; if (tt->tooltippic) { im = ImageclassGetImage(tt->tooltippic, 0, 0, 0); if (im) { EImageGetSize(im, &iw, &ih); EImageFree(im); } w += iw; if (h < ih) h = ih; } w += pad->left + pad->right; h += pad->top + pad->bottom; if ((tt->tooltippic) && (iw > 0) && (ih > 0)) { ix = pad->left; iy = (h - ih) / 2; EMoveResizeWindow(tt->iwin, ix, iy, iw, ih); EMapWindow(tt->iwin); ImageclassApply(tt->tooltippic, tt->iwin, 0, 0, STATE_NORMAL, ST_SOLID); } else EUnmapWindow(tt->iwin); dx = x - WinGetW(VROOT) / 2; dy = y - WinGetH(VROOT) / 2; if ((dy == 0) && (dx == 0)) dy = -1; adx = dx; if (adx < 0) adx = -adx; ady = dy; if (ady < 0) ady = -ady; if (adx < ady) /* +-------+ */ /* |\#####/| */ /* | \###/ | */ /* | \#/ | */ /* | /#\ | */ /* | /###\ | */ /* |/#####\| */ /* +-------+ */ { if (dy == 0) { dy = 1; ady = 1; } dist = tt->dist; ady = ady / dy; if (tt->win[0]) { yy = y - ((ady * 10 * dist) / 100); xx = x - (dist * 10 * dx) / (100 * WinGetW(VROOT) / 2); EobjMove(tt->win[0], xx - 4, yy - 4); } if (tt->win[1]) { yy = y - ((ady * 30 * dist) / 100); xx = x - (dist * 30 * dx) / (100 * WinGetW(VROOT) / 2); EobjMove(tt->win[1], xx - 8, yy - 8); } if (tt->win[2]) { yy = y - ((ady * 50 * dist) / 100); xx = x - (dist * 50 * dx) / (100 * WinGetW(VROOT) / 2); EobjMove(tt->win[2], xx - 12, yy - 12); } if (tt->win[3]) { yy = y - ((ady * 80 * dist) / 100); xx = x - (dist * 80 * dx) / (100 * WinGetW(VROOT) / 2); EobjMove(tt->win[3], xx - 16, yy - 16); } yy = y - ((ady * 100 * dist) / 100); xx = x - (dist * 100 * dx) / (100 * WinGetW(VROOT) / 2); if (ady < 0) hh = 0; else hh = h; ww = (w / 2) + ((dx * w) / (WinGetW(VROOT) / 2)); } else /* +-------+ */ /* |\ /| */ /* |#\ /#| */ /* |##\ /##| */ /* |##/ \##| */ /* |#/ \#| */ /* |/ \| */ /* +-------+ */ { if (dx == 0) { dx = 1; adx = 1; } dist = tt->dist; adx = adx / dx; if (tt->win[0]) { xx = x - ((adx * 10 * dist) / 100); yy = y - (dist * 10 * dy) / (100 * WinGetH(VROOT) / 2); EobjMove(tt->win[0], xx - 4, yy - 4); } if (tt->win[1]) { xx = x - ((adx * 30 * dist) / 100); yy = y - (dist * 30 * dy) / (100 * WinGetH(VROOT) / 2); EobjMove(tt->win[1], xx - 8, yy - 8); } if (tt->win[2]) { xx = x - ((adx * 50 * dist) / 100); yy = y - (dist * 50 * dy) / (100 * WinGetH(VROOT) / 2); EobjMove(tt->win[2], xx - 12, yy - 12); } if (tt->win[3]) { xx = x - ((adx * 80 * dist) / 100); yy = y - (dist * 80 * dy) / (100 * WinGetH(VROOT) / 2); EobjMove(tt->win[3], xx - 16, yy - 16); } xx = x - ((adx * 100 * dist) / 100); yy = y - (dist * 100 * dy) / (100 * WinGetH(VROOT) / 2); if (adx < 0) ww = 0; else ww = w; hh = (h / 2) + ((dy * h) / (WinGetH(VROOT) / 2)); } EobjMoveResize(tt->TTWIN, xx - ww, yy - hh, w, h); for (i = 0; i < 5; i++) { eo = tt->win[i]; if (!eo) continue; ImageclassApply(tt->iclass[i], EobjGetWin(eo), 0, 0, STATE_NORMAL, ST_TOOLTIP); EobjShapeUpdate(eo, 0); EobjMap(eo, 0); } xx = pad->left + iw; /* draw the ordinary tooltip text */ TextDraw(tt->tclass, EobjGetWin(tt->TTWIN), None, 0, 0, STATE_NORMAL, text, xx, pad->top, headline_w, headline_h, 17, 512); /* draw the icons and labels, if any */ if (ac) { num = ActionclassGetActionCount(ac); y = pad->top + headline_h; xx = pad->left + double_w; for (i = 0; i < num; i++) { x = xx + iw; aa = ActionclassGetAction(ac, i); if (!aa) continue; tts = ActionGetTooltipString(aa); if (!tts) continue; tts = _(tts); if (ActionGetEvent(aa) == EVENT_DOUBLE_DOWN) { TextDraw(tt->tclass, EobjGetWin(tt->TTWIN), None, 0, 0, STATE_NORMAL, "2x", xx + iw - double_w, y, double_w, heights[i], 17, 0); } if (ActionGetAnybutton(aa)) { TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_ANY", x, y, &x); } else switch (ActionGetButton(aa)) { case 1: TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_1", x, y, &x); break; case 2: TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_2", x, y, &x); break; case 3: TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_3", x, y, &x); break; case 4: TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_4", x, y, &x); break; case 5: TooltipIclassPaste(tt, "TOOLTIP_MOUSEBUTTON_5", x, y, &x); break; default: break; } modifiers = ActionGetModifiers(aa); if (modifiers) { if (modifiers & ShiftMask) TooltipIclassPaste(tt, "TOOLTIP_KEY_SHIFT", x, y, &x); if (modifiers & LockMask) TooltipIclassPaste(tt, "TOOLTIP_KEY_LOCK", x, y, &x); if (modifiers & ControlMask) TooltipIclassPaste(tt, "TOOLTIP_KEY_CTRL", x, y, &x); if (modifiers & Mod1Mask) TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD1", x, y, &x); if (modifiers & Mod2Mask) TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD2", x, y, &x); if (modifiers & Mod3Mask) TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD3", x, y, &x); if (modifiers & Mod4Mask) TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD4", x, y, &x); if (modifiers & Mod5Mask) TooltipIclassPaste(tt, "TOOLTIP_KEY_MOD5", x, y, &x); } TextDraw(tt->tclass, EobjGetWin(tt->TTWIN), None, 0, 0, STATE_NORMAL, tts, pad->left + icons_width + iw, y, labels_width, heights[i], 17, 0); y += heights[i]; } } Efree(heights); }