static void TooltipRealize(ToolTip * tt) { int i, wh; EObj *eo; for (i = 0; i < 5; i++) { if (!tt->iclass[i]) continue; wh = (i + 1) * 8; eo = EobjWindowCreate(EOBJ_TYPE_MISC, -50, -100, wh, wh, 1, tt->name); eo->fade = eo->shadow = 1; EobjChangeOpacity(eo, OpacityFromPercent(Conf.opacity.tooltips)); tt->win[i] = eo; } tt->iwin = ECreateWindow(EobjGetWin(tt->TTWIN), 0, 0, 1, 1, 0); }
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 _CoordsShow(EWin * ewin, int mode) { TextClass *tc; ImageClass *ic; char s[256]; int md; int x, y; unsigned int w, h; int cx, cy, cw, ch; EObj *eo = coord_eo; EImageBorder *pad; int bl, br, bt, bb; if (!Conf.movres.mode_info) return; if (!ewin || !ewin->state.show_coords) return; tc = TextclassFind("COORDS", 1); ic = ImageclassFind("COORDS", 1); if ((!ic) || (!tc)) return; cx = cy = cw = ch = 0; x = ewin->shape_x; y = ewin->shape_y; w = (ewin->state.shaded) ? ewin->client.w : ewin->shape_w; h = (ewin->state.shaded) ? ewin->client.h : ewin->shape_h; ICCCM_GetIncrementalSize(ewin, w, h, &w, &h); switch (mode) { default: case 0: Esnprintf(s, sizeof(s), "%i x %i (%i, %i)", w, h, x, y); break; case 1: Esnprintf(s, sizeof(s), _("Focused/unfocused opacity: %d/%d %%"), OpacityToPercent(ewin->props.focused_opacity), OpacityToPercent(ewin->ewmh.opacity)); break; } TextSize(tc, 0, 0, 0, s, &cw, &ch, 17); pad = ImageclassGetPadding(ic); cw += pad->left + pad->right; ch += pad->top + pad->bottom; /* Width hysteresis (hack - assuming horizontal text) */ cw += 8; if (eo && abs(EobjGetW(eo) - cw) < 8) cw = EobjGetW(eo); if (Mode.mode == MODE_MOVE) md = Conf.movres.mode_move; else md = Conf.movres.mode_resize; if ((md == 0) || ((cw < ewin->shape_w - 2) && (ch < ewin->shape_h - 2))) { if (Conf.movres.mode_info == 1) { switch (md) { case 0: case 1: case 2: EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); w = (ewin->state.shaded) ? EoGetW(ewin) : ewin->shape_w + bl + br; h = (ewin->state.shaded) ? EoGetH(ewin) : ewin->shape_h + bt + bb; cx = x + (w - cw) / 2 + EoGetX(EoGetDesk(ewin)); cy = y + (h - ch) / 2 + EoGetY(EoGetDesk(ewin)); break; } } } if (!eo) { eo = EobjWindowCreate(EOBJ_TYPE_MISC, 0, 0, 1, 1, 2, "Coord"); if (!eo) return; coord_eo = eo; eo->fade = eo->shadow = 1; /* Center text (override theme) */ TextclassSetJustification(tc, 512); } #define TEST_COORD_REPARENT_TO_FRAME 0 #if TEST_COORD_REPARENT_TO_FRAME cx -= x; cy -= y; #endif md = cw != EobjGetW(eo) || ch != EobjGetH(eo); /* md is change size flag */ EobjMoveResize(eo, cx, cy, cw, ch); if (!eo->shown) { #if TEST_COORD_REPARENT_TO_FRAME EobjReparent(eo, EoObj(ewin), cx, cy); #endif EobjMap(eo, 0); } ITApply(EobjGetWin(eo), ic, NULL, STATE_NORMAL, 1, 0, ST_SOLID, tc, NULL, s, 1); if (md) /* Assuming that shape change only happens when size changes too */ EobjShapeUpdate(eo, 0); EFlush(); }
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); }
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(); }