예제 #1
0
파일: magwin.c 프로젝트: gzorin/e17
static void
_MagwinGrabSet(MagWindow * mw)
{
   GrabPointerSet(EwinGetClientWin(mw->ewin), ECSR_GRAB, 0);
   GrabKeyboardSet(EwinGetClientWin(mw->ewin));
   mw->grabbing = 1;
   mw->grab_time = Mode.events.time;
}
예제 #2
0
파일: focus.c 프로젝트: burzumishi/e16
static void
doFocusToEwin(EWin * ewin, int why)
{
   int                 do_focus = 0;
   int                 do_raise = 0, do_warp = 0;

   if (focus_inhibit)
      return;

   if (EDebug(EDBUG_TYPE_FOCUS))
      Eprintf("%s: %#x %s why=%d\n", __func__,
	      (ewin) ? EwinGetClientXwin(ewin) : 0,
	      (ewin) ? EwinGetTitle(ewin) : "None", why);

   switch (why)
     {
     case FOCUS_NEXT:
     case FOCUS_PREV:
	if (Conf.focus.raise_on_next)
	   do_raise = 1;
	if (Conf.focus.warp_on_next)
	   do_warp = 1;
	/* Fall thru */
     default:
     case FOCUS_SET:
     case FOCUS_ENTER:
     case FOCUS_LEAVE:		/* Unused */
     case FOCUS_CLICK:
	if (ewin && ewin == Mode.focuswin)
	   return;
	if (!ewin)		/* Unfocus */
	   break;
	if (!FocusEwinValid(ewin, 1, why == FOCUS_CLICK, 0))
	   return;
	break;

     case FOCUS_INIT:
     case FOCUS_DESK_ENTER:
	ewin = FocusEwinSelect();
	break;

     case FOCUS_DESK_LEAVE:
	focus_is_set = 0;
	/* FALLTHROUGH */
     case FOCUS_NONE:
	ewin = NULL;
	if (ewin == Mode.focuswin)
	   return;
	break;

     case FOCUS_EWIN_UNMAP:
	if (Mode.focuswin)
	   return;
	ewin = FocusEwinSelect();
	if (ewin == Mode.focuswin)
	   ewin = NULL;
	break;

     case FOCUS_EWIN_NEW:
	if (Conf.focus.all_new_windows_get_focus)
	   goto check_focus_new;

	if (Mode.place.doing_manual)
	   goto check_focus_new;

	if (ewin->props.focus_when_mapped)
	   goto check_focus_new;

	if (Conf.focus.new_windows_get_focus_if_group_focused && Mode.focuswin)
	  {
	     if (EwinGetWindowGroup(ewin) == EwinGetWindowGroup(Mode.focuswin))
		goto check_focus_new;
	  }

	if (EwinIsTransient(ewin))
	  {
	     if (Conf.focus.new_transients_get_focus)
	       {
		  do_focus = 1;
	       }
	     else if (Conf.focus.new_transients_get_focus_if_group_focused &&
		      Mode.focuswin)
	       {
		  if ((EwinGetTransientFor(ewin) ==
		       EwinGetClientXwin(Mode.focuswin)) ||
		      (EwinGetWindowGroup(ewin) ==
		       EwinGetWindowGroup(Mode.focuswin)))
		     do_focus = 1;
	       }

	     if (!do_focus)
		return;
	     DeskGotoByEwin(ewin);
	     goto check_focus_new;
	  }

	return;

      check_focus_new:
	if (!FocusEwinValid(ewin, 1, 0, 0))
	   return;
	break;
     }

   if (ewin == Mode.focuswin && focus_is_set)
      return;

   /* Check if ewin is a valid focus window target */

   if (!ewin)
      goto done;

   /* NB! ewin != NULL */

   if (why != FOCUS_CLICK && ewin->props.focusclick)
      return;

   if (Conf.autoraise.enable)
     {
	TIMER_DEL(focus_timer_autoraise);

	if (Conf.focus.mode != MODE_FOCUS_CLICK)
	   TIMER_ADD(focus_timer_autoraise, Conf.autoraise.delay,
		     AutoraiseTimeout, ewin);
     }

   if (do_raise)
      EwinRaise(ewin);

   if (Conf.focus.warp_always)
      do_warp = 1;
   if (do_warp)
      EwinWarpTo(ewin, 0);

   switch (why)
     {
     case FOCUS_PREV:
     case FOCUS_NEXT:
	GrabKeyboardSet(VROOT);	/* Causes idler to be called on KeyRelease */
	focus_pending_raise = ewin;
	break;
     case FOCUS_DESK_ENTER:
	if (Conf.focus.mode == MODE_FOCUS_CLICK)
	   break;
	/* FALLTHROUGH */
     default:
     case FOCUS_INIT:
	EwinListFocusRaise(ewin);
	break;
     }

   SoundPlay(SOUND_FOCUS_SET);
 done:

   ClickGrabsUpdate();

   /* Unset old focus window (if any) highlighting */
   if (Mode.focuswin)
      FocusEwinSetActive(Mode.focuswin, 0);
   ICCCM_Cmap(ewin);

   /* Quit if pointer is not on our screen */

   if (!Mode.events.on_screen)
     {
	Mode.focuswin = NULL;
	return;
     }

   /* Set new focus window (if any) highlighting */
   Mode.focuswin = ewin;
   if (Mode.focuswin)
      FocusEwinSetActive(Mode.focuswin, 1);

   if (why == FOCUS_DESK_LEAVE)
      return;

   ICCCM_Focus(ewin);
   focus_is_set = 1;
}
예제 #3
0
파일: warp.c 프로젝트: Limsik/e17
static void
WarpFocusWinShow(WarpFocusWin * fw)
{
   WarplistItem       *wi;
   EImageBorder       *pad;
   EWin               *ewin;
   int                 i, x, y, w, h, ww, hh;
   char                s[1024], ss[32];
   const char         *fmt;

   w = 0;
   h = 0;
   pad = ImageclassGetPadding(fw->ic);

   for (i = 0; i < warplist_num; i++)
     {
	wi = warplist + i;
	wi->win = ECreateWindow(EoGetWin(fw), 0, 0, 1, 1, 0);
	EMapWindow(wi->win);

	ewin = wi->ewin;
	if (ewin->state.iconified)
	   fmt = "%s[%s]";
	else if (ewin->state.shaded)
	   fmt = "%s=%s=";
	else
	   fmt = "%s%s";
	ss[0] = '\0';
	if (Conf.warplist.showalldesks)
	  {
	     if (EoIsSticky(ewin) || ewin->state.iconified)
		strcpy(ss, "[-] ");
	     else
		Esnprintf(ss, sizeof(ss), "[%d] ", EoGetDeskNum(ewin));
	  }
	Esnprintf(s, sizeof(s), fmt, ss, EwinGetTitle(ewin));
	wi->txt = strdup(s);
	TextSize(fw->tc, 0, 0, 0, wi->txt, &ww, &hh, 17);
	if (ww > w)
	   w = ww;
	if (hh > h)
	   h = hh;
     }

   fw->tw = w;			/* Text size */
   fw->th = h;
   w += pad->left + pad->right;
   h += pad->top + pad->bottom;
   if (Conf.warplist.icon_mode != 0)
     {
	if (Conf.warplist.icon_mode != EWIN_ICON_MODE_APP_IMG &&
	    Conf.warplist.icon_mode != EWIN_ICON_MODE_IMG_APP)
	   Conf.warplist.icon_mode = EWIN_ICON_MODE_APP_IMG;
	w += h;
     }
   fw->mw = w;			/* Focus list item size */
   fw->mh = h;

   /* Reset shape */
   EShapeSetMask(EoGetWin(fw), 0, 0, None);

   ScreenGetAvailableAreaByPointer(&x, &y, &ww, &hh, Conf.place.ignore_struts);
   x += (ww - w) / 2;
   y += (hh - h * warplist_num) / 2;
   EoMoveResize(fw, x, y, w, h * warplist_num);

   for (i = 0; i < warplist_num; i++)
      EMoveResizeWindow(warplist[i].win, 0, (h * i), fw->mw, fw->mh);

   EoMap(fw, 0);

   /*
    * Grab the keyboard. The grab is automatically released when
    * WarpFocusHide unmaps warpFocusWindow.
    */
   GrabKeyboardSet(EoGetWin(fw));
   GrabPointerSet(EoGetWin(fw), None, 0);

   TooltipsEnable(0);
}
예제 #4
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++;
}