Exemple #1
0
int
EventsUpdateXY(int *px, int *py)
{
   int                 ss;

   ss = EQueryPointer(NULL, &Mode.events.cx, &Mode.events.cy, NULL, NULL);
   if (px)
      *px = Mode.events.cx;
   if (py)
      *py = Mode.events.cy;

   return ss;
}
Exemple #2
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;
}
Exemple #3
0
static void
FocusRaisePending(void)
{
   EWin               *ewin = focus_pending_raise;
   unsigned int        mask;

   /* The focusing cycle ends when no more modifiers are depressed */
   mask = 0;
   EQueryPointer(NULL, NULL, NULL, NULL, &mask);
   if ((mask & Mode.masks.mod_key_mask) != 0)
      return;

   if (EwinFindByPtr(ewin))	/* May be gone */
      EwinListFocusRaise(ewin);

   GrabKeyboardRelease();

   focus_pending_raise = NULL;
}
Exemple #4
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;
}
Exemple #5
0
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++;
}
Exemple #6
0
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);
}