static void _ZoomEwinRestore(EWin * ewin) { EwinBorderSetTo(ewin, ewin->normal_border); ewin->state.zoomed = 0; EwinMoveResize(ewin, ewin->save_fs.x, ewin->save_fs.y, ewin->client.w, ewin->client.h, 0); }
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; }
/* outstanding BUG: zooming on shaped windows leaves stuff exposed beneath them..... */ void Zoom(EWin * ewin, int on) { if (Mode.wm.window) return; if (!ewin) ewin = zoom_last_ewin; if (!ewin) return; if (zoom_can == 0) ZoomInit(); if (zoom_can <= 0) return; Dprintf("%s: on=%d\n", __func__, on); if (!on) { /* Unzoom */ if (ewin != zoom_last_ewin) return; _ZoomEwinRestore(ewin); SwitchRes(0, 0, 0, 0, 0, NULL, NULL); zw = zh = 0; zoom_last_ewin = NULL; } else if (ewin == zoom_last_ewin) { /* Already zoomed */ return; } else { /* Zoom */ if (ewin->state.fullscreen) return; if (!zoom_last_ewin) /* first zoom */ { on = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h, &zw, &zh); } else /* we are zoomed in on another window already.... */ { _ZoomEwinRestore(zoom_last_ewin); if ((ewin->client.w <= zw) && (ewin->client.h <= zh) && ((ewin->client.w >= zw / 2) || (ewin->client.h >= zh / 2))) { /* YAY no need to change resolution :-D */ } else { /* SwitchRes only tracks the LAST mode, so we have to switch back to * the original mode before switching to new target mode * so that we can restore the original vid mode when we zoom * out of the last window ;( */ SwitchRes(0, 0, 0, 0, 0, NULL, NULL); on = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h, &zw, &zh); } } Dprintf("%s: SwitchRes=%d - client size %dx%d -> screen %dx%d\n", __func__, on, ewin->client.w, ewin->client.h, zw, zh); if (!on) return; ewin->save_fs.x = EoGetX(ewin); ewin->save_fs.y = EoGetY(ewin); EwinRaise(ewin); EwinBorderSetTo(ewin, BorderCreateFiller(ewin->client.w, ewin->client.h, zw, zh)); EwinMoveResize(ewin, 0, 0, ewin->client.w, ewin->client.h, 0); ewin->state.zoomed = 1; FocusToEWin(ewin, FOCUS_SET); zoom_last_ewin = ewin; } EwinWarpTo(ewin, 1); ESync(0); EwinStateUpdate(ewin); HintsSetWindowState(ewin); }