예제 #1
0
파일: focus.c 프로젝트: burzumishi/e16
static void
ClickGrabsSet(EWin * ewin)
{
   int                 set = 0;

   if ((Conf.focus.clickraises && !EwinListStackIsRaised(ewin)) ||
       (!ewin->state.active && !ewin->state.inhibit_focus))
      set = 1;

   if (set)
     {
	if (!ewin->state.click_grab_isset)
	  {
	     GrabButtonSet(AnyButton, AnyModifier, EwinGetClientConWin(ewin),
			   ButtonPressMask, ECSR_PGRAB, 1);
	     if (EDebug(EDBUG_TYPE_GRABS))
		Eprintf("%s: %#x set %s\n", __func__,
			EwinGetClientXwin(ewin), EwinGetTitle(ewin));
	     ewin->state.click_grab_isset = 1;
	  }
     }
   else
     {
	if (ewin->state.click_grab_isset)
	  {
	     GrabButtonRelease(AnyButton, AnyModifier,
			       EwinGetClientConWin(ewin));
	     if (EDebug(EDBUG_TYPE_GRABS))
		Eprintf("%s: %#x unset %s\n", __func__,
			EwinGetClientXwin(ewin), EwinGetTitle(ewin));
	     ewin->state.click_grab_isset = 0;
	  }
     }
}
예제 #2
0
파일: focus.c 프로젝트: burzumishi/e16
/*
 * Return !0 if it is OK to focus ewin.
 */
static int
FocusEwinValid(EWin * ewin, int want_on_screen, int click, int want_visible)
{
   if (!ewin)
      return 0;

#if 0
   Eprintf("%s: %#x %s: st=%d sh=%d inh=%d cl=%d(%d) vis=%d(%d)\n", __func__,
	   EwinGetClientXwin(ewin), EwinGetTitle(ewin),
	   ewin->state.state, EoIsShown(ewin), ewin->state.inhibit_focus,
	   click, ewin->props.focusclick, want_visible, ewin->state.visibility);
#endif

   if (ewin->state.inhibit_focus)
      return 0;

   if (!EoIsMapped(ewin) || !EoIsShown(ewin) ||
       ewin->state.state != EWIN_STATE_MAPPED)
      return 0;

   if (ewin->props.focusclick && !click)
      return 0;

   if (want_visible && ewin->state.visibility == VisibilityFullyObscured)
      return 0;

   return !want_on_screen || EwinIsOnScreen(ewin);
}
예제 #3
0
파일: focus.c 프로젝트: burzumishi/e16
void
FocusToEWin(EWin * ewin, int why)
{
   if (EDebug(EDBUG_TYPE_FOCUS))
      Eprintf("%s(%d) %#x %s why=%d\n", __func__, focus_inhibit,
	      (ewin) ? EwinGetClientXwin(ewin) : 0,
	      (ewin) ? EwinGetTitle(ewin) : "None", why);

   switch (why)
     {
     case FOCUS_EWIN_NEW:
	if (!Conf.focus.all_new_windows_get_focus)
	   return;
	if (!FocusEwinValid(ewin, 0, 0, 0))
	   break;
	focus_pending_new = ewin;
	focus_pending_why = why;
	focus_pending_ewin = ewin;
	break;

     default:
	if (ewin && !FocusEwinValid(ewin, 0, why == FOCUS_CLICK, 0))
	   break;
	focus_pending_why = why;
	focus_pending_ewin = ewin;
	break;

     case FOCUS_EWIN_UNMAP:
	focus_pending_why = why;
	focus_pending_ewin = NULL;
	if (ewin == Mode.focuswin)
	  {
	     Mode.focuswin = NULL;
	     focus_is_set = 0;
	     if (!EoIsGone(ewin))
		FocusEwinSetActive(ewin, 0);
	  }
	if (ewin == focus_pending_new)
	   focus_pending_new = NULL;
	break;
     }
   focus_request = (int)NextRequest(disp) - 1;
}
예제 #4
0
파일: snaps.c 프로젝트: burzumishi/e16
static int
_SnapEwinMatch(const Snapshot * sn, const EWin * ewin)
{
   char                buf[256], *s;

   /* Don't allow matching anything */
   if (!sn->match_flags)
      return 0;

   if (ewin->state.identified)
      return sn->win == EwinGetClientXwin(ewin);

   if (sn->startup_id && !sn->cmd)
      return 0;

   if (sn->match_flags & SNAP_MATCH_TITLE
       && !SEQ(sn->win_title, EwinGetIcccmName(ewin)))
      return 0;

   if (sn->match_flags & SNAP_MATCH_NAME
       && !SEQ(sn->win_name, EwinGetIcccmCName(ewin)))
      return 0;

   if (sn->match_flags & SNAP_MATCH_CLASS
       && !SEQ(sn->win_class, EwinGetIcccmClass(ewin)))
      return 0;

   if (sn->match_flags & SNAP_MATCH_ROLE)
     {
	s = _ParseRole(ewin->icccm.wm_role, buf, sizeof(buf));
	if (!SEQ(sn->win_role, s))
	   return 0;
     }

   /* Match! */
   return 1;
}
예제 #5
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;
}
예제 #6
0
파일: magwin.c 프로젝트: gzorin/e17
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);
}