static void MagwinHide(void) { if (!MagWin) return; EwinHide(MagWin->ewin); }
static void MenuHide(Menu * m) { EWin *ewin; if (!m || !m->shown) return; if (m->sel_item) MenuDrawItem(m, m->sel_item, 1, STATE_NORMAL); m->sel_item = NULL; ewin = m->ewin; if (ewin) { EUnmapWindow(m->win); EReparentWindow(m->win, VROOT, ewin->client.x, ewin->client.y); EwinHide(ewin); } m->ewin = NULL; m->shown = 0; m->parent = NULL; m->last_access = time(0); if (m->child) { MenuHide(m->child); m->child = NULL; } if (m->dynamic) MenuEmpty(m, 0); m->ref_count--; }
static void MagwinEvent(Win win __UNUSED__, XEvent * ev, void *prm) { MagWindow *mw = (MagWindow *) prm; KeySym key; int done = 0; switch (ev->type) { default: break; case KeyPress: key = XLookupKeysym(&ev->xkey, 0); done = MagwinKeyPress(mw, key); mw->update = 1; break; case ButtonPress: switch (ev->xbutton.button) { default: break; case 1: if (!mw->grabbing) _MagwinGrabSet(mw); mw->stroke_mx = Mode.events.mx; mw->stroke_my = Mode.events.my; mw->stroke_cx = mw->cx; mw->stroke_cy = mw->cy; mw->btn_down = 1; break; case 3: MagwinKeyPress(mw, XK_f); break; case 4: MagwinKeyPress(mw, XK_i); break; case 5: MagwinKeyPress(mw, XK_o); break; } mw->update = 1; break; case ButtonRelease: switch (ev->xbutton.button) { default: break; case 1: if (mw->grabbing && (ev->xbutton.time - mw->grab_time > 250)) _MagwinGrabRelease(mw); mw->btn_down = 0; mw->stroke = 0; } break; case MotionNotify: if (mw->btn_down) { int dx, dy; double scale; dx = Mode.events.mx - mw->stroke_mx; dy = Mode.events.my - mw->stroke_my; if ((abs(dx) > 10) || (abs(dy) > 10)) mw->stroke = 1; if (!mw->stroke) break; scale = pow(2., (double)(mw->scale) / Conf.magwin.zoom_res); mw->cx = mw->stroke_cx - (int)(dx / scale); mw->cy = mw->stroke_cy - (int)(dy / scale); mw->update = 1; } else if (mw->grabbing) { mw->cx = Mode.events.mx; mw->cy = Mode.events.my; mw->update = 1; } else { mw->update = 1; } break; case MapNotify: mw->update = 1; if (mw->configured) break; mw->configured = 1; _MagwinGrabSet(mw); #if USE_TIMER TIMER_ADD(mw->timer, 50, _MagwinTimeout, 0, mw); #elif USE_ANIMATOR AnimatorAdd(_MagwinAnimator, mw); #endif break; } if (done) EwinHide(mw->ewin); }