static MagWindow * MagwinCreate(const char *title, int width, int height) { MagWindow *mw; Win win; int x, y, w, h; mw = ECALLOC(MagWindow, 1); if (!mw) return NULL; win = VROOT; w = width; h = height; x = (win->w - w) / 2; y = (win->h - h) / 2; win = ECreateClientWindow(VROOT, x, y, w, h); mw->title = title; mw->ewin = AddInternalToFamily(win, NULL, EWIN_TYPE_MISC, &_MagEwinOps, mw); if (!mw->ewin) { Efree(mw); return NULL; } mw->filter = 1; mw->disable_text = 1; mw->ewin->o.ghost = 1; EoSetLayer(mw->ewin, 10); EwinMoveResize(mw->ewin, EoGetX(mw->ewin), EoGetY(mw->ewin), mw->ewin->client.w, mw->ewin->client.h); mw->ewin->client.event_mask |= KeyPressMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask; ESelectInput(win, mw->ewin->client.event_mask); EventCallbackRegister(win, MagwinEvent, mw); EQueryPointer(VROOT, &mw->cx, &mw->cy, NULL, NULL); mw->scale = Conf.magwin.zoom_res; mw->step = 4; return mw; }
static void MenuShow(Menu * m, char noshow) { EWin *ewin; int x, y, w, h; int wx, wy, mw, mh; int head_num = 0; if (m->shown) return; if (MenuLoad(m) || m->redraw) MenuRealize(m); if (m->num <= 0) return; if (!m->win || !m->items[0]->win) MenuRealize(m); if (!m->style) return; ewin = m->ewin; if (ewin) { #if 0 /* ??? */ EwinRaise(ewin); EwinShow(ewin); return; #else MenuHide(m); #endif } EGetGeometry(m->items[0]->win, NULL, &x, &y, &w, &h, NULL, NULL); mw = m->w; mh = m->h; EQueryPointer(NULL, &wx, &wy, NULL, NULL); wx -= EoGetX(DesksGetCurrent()) + x + (w / 2); wy -= EoGetY(DesksGetCurrent()) + y + (h / 2); if (Conf.menus.onscreen) { Border *b; b = BorderFind(m->style->border_name); if (b) { int sx, sy, sw, sh; head_num = ScreenGetGeometryByPointer(&sx, &sy, &sw, &sh); if (wx > sx + sw - mw - b->border.right) wx = sx + sw - mw - b->border.right; if (wx < sx + b->border.left) wx = sx + b->border.left; if (wy > sy + sh - mh - b->border.bottom) wy = sy + sh - mh - b->border.bottom; if (wy < sy + b->border.top) wy = sy + b->border.top; } } EMoveWindow(m->win, wx, wy); ewin = AddInternalToFamily(m->win, m->style->border_name, EWIN_TYPE_MENU, &_MenuEwinOps, m); if (ewin) { ewin->client.event_mask |= KeyPressMask; ESelectInput(m->win, ewin->client.event_mask); ewin->head = head_num; EwinResize(ewin, ewin->client.w, ewin->client.h, 0); if (Conf.menus.animate) EwinInstantShade(ewin, 0); if (!noshow) { ICCCM_Cmap(NULL); EwinOpFloatAt(ewin, OPSRC_NA, EoGetX(ewin), EoGetY(ewin)); EwinShow(ewin); if (Conf.menus.animate) EwinUnShade(ewin); } } m->shown = 1; m->last_access = time(0); Mode_menus.just_shown = 1; if (!Mode_menus.first) { Mode_menus.context_ewin = GetContextEwin(); #if 0 Eprintf("Mode_menus.context_ewin set %s\n", EwinGetTitle(Mode_menus.context_ewin)); #endif ESync(ESYNC_MENUS); Mode_menus.first = m; MenuShowMasker(m); TooltipsEnable(0); GrabKeyboardSet(m->win); } m->ref_count++; }