Ejemplo n.º 1
0
/* returns the icon geometry (unexpanded title plus pixmap) if it is visible */
Bool get_visible_icon_geometry(
	FvwmWindow *fw, rectangle *ret_g)
{
	if (IS_ICON_UNMAPPED(fw) || !IS_ICONIFIED(fw))
	{
		memset(ret_g, 0, sizeof(*ret_g));
		return False;
	}
	if (fw->icon_g.picture_w_g.width > 0)
	{
		*ret_g = fw->icon_g.picture_w_g;
		if (!HAS_NO_ICON_TITLE(fw))
		{
			ret_g->height += fw->icon_g.title_w_g.height;
		}
	}
	else if (!HAS_NO_ICON_TITLE(fw))
	{
		*ret_g = fw->icon_g.title_w_g;
	}
	else
	{
		memset(ret_g, 0, sizeof(*ret_g));
		return False;
	}

	return True;
}
Ejemplo n.º 2
0
Archivo: focus.c Proyecto: fvwmorg/fvwm
static Bool focus_query_grab_buttons(FvwmWindow *fw, Bool client_entered)
{
	Bool flag;
	Bool is_focused;

	if (fw->Desk != Scr.CurrentDesk || IS_ICONIFIED(fw))
	{
		return False;
	}
	is_focused = focus_is_focused(fw);
	if (!is_focused && FP_DO_FOCUS_CLICK_CLIENT(FW_FOCUS_POLICY(fw)))
	{
		return True;
	}
	if (is_on_top_of_layer_and_above_unmanaged(fw))
	{
		return False;
	}
	if (is_focused)
	{
		flag = FP_DO_RAISE_FOCUSED_CLIENT_CLICK(FW_FOCUS_POLICY(fw));
	}
	else
	{
		flag = FP_DO_RAISE_UNFOCUSED_CLIENT_CLICK(FW_FOCUS_POLICY(fw));
	}

	return (flag) ? True : False;
}
Ejemplo n.º 3
0
/**************************************************************************
 *
 * Moves focus to specified window
 *
 *************************************************************************/
void FocusOn(FvwmWindow *t, Bool FocusByMouse, char *action)
{
  int dx,dy;
  int cx,cy;
  Bool do_not_warp;

  if (t == NULL || HAS_NEVER_FOCUS(t))
  {
    UngrabEm(GRAB_NORMAL);
    if (t)
    {
      /* give the window a chance to take the focus itself */
      MoveFocus(t->w, t, FocusByMouse, 1, 0);
    }
    return;
  }

  if (!(do_not_warp = StrEquals(PeekToken(action, NULL), "NoWarp")))
  {
    if (t->Desk != Scr.CurrentDesk)
    {
      goto_desk(t->Desk);
    }

    if (IS_ICONIFIED(t))
    {
      cx = t->icon_xl_loc + t->icon_g.width/2;
      cy = t->icon_g.y + t->icon_p_height + ICON_HEIGHT(t) / 2;
    }
    else
    {
      cx = t->frame_g.x + t->frame_g.width/2;
      cy = t->frame_g.y + t->frame_g.height/2;
    }
    dx = (cx + Scr.Vx)/Scr.MyDisplayWidth*Scr.MyDisplayWidth;
    dy = (cy +Scr.Vy)/Scr.MyDisplayHeight*Scr.MyDisplayHeight;
    MoveViewport(dx,dy,True);

    /* If the window is still not visible, make it visible! */
    if (((t->frame_g.x + t->frame_g.height)< 0)||
	(t->frame_g.y + t->frame_g.width < 0)||
	(t->frame_g.x >Scr.MyDisplayWidth)||(t->frame_g.y>Scr.MyDisplayHeight))
    {
      SetupFrame(t, 0, 0, t->frame_g.width, t->frame_g.height, False);
      if (HAS_MOUSE_FOCUS(t) || HAS_SLOPPY_FOCUS(t))
      {
	XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, 2,2);
      }
    }
  }

  UngrabEm(GRAB_NORMAL);
  if (t->Desk == Scr.CurrentDesk)
  {
    MoveFocus(t->w, t, FocusByMouse, do_not_warp, 0);
  }

  return;
}
Ejemplo n.º 4
0
/* When a window is unmapped (or destroyed) this function takes care of
 * adjusting the focus window appropriately. */
void restore_focus_after_unmap(
  FvwmWindow *tmp_win, Bool do_skip_marked_transients)
{
  extern FvwmWindow *colormap_win;
  FvwmWindow *t = NULL;
  FvwmWindow *set_focus_to = NULL;

  if (tmp_win == get_focus_window())
  {
    if (tmp_win->transientfor != None && tmp_win->transientfor != Scr.Root)
    {
      for (t = Scr.FvwmRoot.next; t != NULL; t = t->next)
      {
	if (t->w == tmp_win->transientfor &&
	    t->Desk == tmp_win->Desk &&
	    (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t)))
	{
	  set_focus_to = t;
	  break;
	}
      }
    }
    if (!set_focus_to &&
	(HAS_CLICK_FOCUS(tmp_win) || HAS_SLOPPY_FOCUS(tmp_win)))
    {
      for (t = tmp_win->next; t != NULL; t = t->next)
      {
	if (t->Desk == tmp_win->Desk && !DO_SKIP_CIRCULATE(t) &&
	    !(IS_ICONIFIED(t) && (
		      DO_SKIP_ICON_CIRCULATE(t) || IS_ICON_SUPPRESSED(t))) &&
	    (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t)))
	{
	  /* If it is on a different desk we have to look for another window */
	  set_focus_to = t;
	  break;
	}
      }
    }
    if (set_focus_to && set_focus_to != tmp_win &&
	set_focus_to->Desk == tmp_win->Desk)
    {
      /* Don't transfer focus to windows on other desks */
      SetFocusWindow(set_focus_to, 1);
    }
    if (tmp_win == get_focus_window())
    {
      DeleteFocus(1);
    }
  }
  if (tmp_win == Scr.pushed_window)
    Scr.pushed_window = NULL;
  if (tmp_win == colormap_win)
  {
    InstallWindowColormaps(set_focus_to);
  }

  return;
}
Ejemplo n.º 5
0
Archivo: FvwmPager.c Proyecto: att/uwin
/***********************************************************************
 *
 *  Procedure:
 *	list_add - displays packet contents to stderr
 *
 ***********************************************************************/
void list_add(unsigned long *body)
{
  PagerWindow *t,**prev;
  int i=0;
  struct ConfigWinPacket  *cfgpacket = (void *) body;

  t = Start;
  prev = &Start;

  while(t!= NULL)
    {
      if (t->w == cfgpacket->w)
      {
	/* it's already there, do nothing */
	return;
      }
      prev = &(t->next);
      t = t->next;
      i++;
    }
  *prev = (PagerWindow *)safemalloc(sizeof(PagerWindow));
  memset(*prev, 0, sizeof(PagerWindow));
  (*prev)->w = cfgpacket->w;
  (*prev)->frame = cfgpacket->frame;
  (*prev)->t = (char *) cfgpacket->fvwmwin;
  (*prev)->x = cfgpacket->frame_x;
  (*prev)->y = cfgpacket->frame_y;
  (*prev)->width = cfgpacket->frame_width;
  (*prev)->height = cfgpacket->frame_height;
  (*prev)->desk = cfgpacket->desk;
  memcpy(&((*prev)->flags), &(cfgpacket->flags), sizeof(cfgpacket->flags));
  (*prev)->title_height = cfgpacket->title_height;
  (*prev)->border_width = cfgpacket->border_width;
  (*prev)->icon_w = cfgpacket->icon_w;
  (*prev)->icon_pixmap_w = cfgpacket->icon_pixmap_w;
  if (IS_ICONIFIED(*prev))
  {
    (*prev)->icon_x = 0;
    (*prev)->icon_y = 0;
    (*prev)->icon_width = 0;
    (*prev)->icon_height = 0;
  }

  if (win_pix_set)
  {
    (*prev)->text = win_fore_pix;
    (*prev)->back = win_back_pix;
  }
  else
  {
    (*prev)->text = cfgpacket->TextPixel;
    (*prev)->back = cfgpacket->BackPixel;
  }
  AddNewWindow(*prev);
}
Ejemplo n.º 6
0
/* Returns the visible geometry of a window or icon.  This can be used to test
 * if this region overlaps other windows. */
Bool get_visible_window_or_icon_geometry(
	FvwmWindow *fw, rectangle *ret_g)
{
	if (IS_ICONIFIED(fw))
	{
		return get_visible_icon_geometry(fw, ret_g);
	}
	*ret_g = fw->g.frame;

	return True;
}
Ejemplo n.º 7
0
/* returns the icon title geometry if it is visible */
Bool get_visible_icon_title_geometry(
	FvwmWindow *fw, rectangle *ret_g)
{
	if (HAS_NO_ICON_TITLE(fw) || IS_ICON_UNMAPPED(fw) ||
	    !IS_ICONIFIED(fw))
	{
		memset(ret_g, 0, sizeof(*ret_g));
		return False;
	}
	*ret_g = fw->icon_g.title_w_g;

	return True;
}
Ejemplo n.º 8
0
/* returns the icon picture geometry if it is visible */
Bool get_visible_icon_picture_geometry(
	FvwmWindow *fw, rectangle *ret_g)
{
	if (fw->icon_g.picture_w_g.width == 0 ||
	    IS_ICON_UNMAPPED(fw) || !IS_ICONIFIED(fw))
	{
		memset(ret_g, 0, sizeof(*ret_g));
		return False;
	}
	*ret_g = fw->icon_g.picture_w_g;

	return True;
}
Ejemplo n.º 9
0
Archivo: focus.c Proyecto: fvwmorg/fvwm
static FvwmWindow *__restore_focus_after_unmap(
	const FvwmWindow *fw, Bool do_skip_marked_transients)
{
	FvwmWindow *t = NULL;
	FvwmWindow *set_focus_to = NULL;

	t = get_transientfor_fvwmwindow(fw);
	if (t != NULL &&
	    FP_DO_RELEASE_FOCUS_TRANSIENT(FW_FOCUS_POLICY(fw)) &&
	    !FP_DO_OVERRIDE_RELEASE_FOCUS(FW_FOCUS_POLICY(t)) &&
	    t->Desk == fw->Desk &&
	    (!do_skip_marked_transients || !IS_IN_TRANSIENT_SUBTREE(t)))
	{
		set_focus_to = t;
	}
	else if (t == NULL && FP_DO_RELEASE_FOCUS(FW_FOCUS_POLICY(fw)))
	{
		for (t = fw->next; t != NULL && set_focus_to == NULL;
		     t = t->next)
		{
			if (!FP_DO_OVERRIDE_RELEASE_FOCUS(
				    FW_FOCUS_POLICY(t)) &&
			    t->Desk == fw->Desk && !DO_SKIP_CIRCULATE(t) &&
			    !(IS_ICONIFIED(t) && (DO_SKIP_ICON_CIRCULATE(t) ||
			      IS_ICON_SUPPRESSED(t))) &&
			    (!do_skip_marked_transients ||
			     !IS_IN_TRANSIENT_SUBTREE(t)))
			{
				/* If it is on a different desk we have to look
				 * for another window */
				set_focus_to = t;
			}
		}
	}
	if (set_focus_to && set_focus_to != fw &&
	    set_focus_to->Desk == fw->Desk)
	{
		/* Don't transfer focus to windows on other desks */
		SetFocusWindow(set_focus_to, True, FOCUS_SET_FORCE);
	}
	if (focus_is_focused(fw))
	{
		DeleteFocus(True);
	}

	return set_focus_to;
}
Ejemplo n.º 10
0
int is_suitable_window(unsigned long *body)
{
  XWindowAttributes xwa;
  struct ConfigWinPacket  *cfgpacket = (void *) body;

  if ((DO_SKIP_WINDOW_LIST(cfgpacket)) && !all)
    return 0;

  if ((IS_MAXIMIZED(cfgpacket)) && !maximized)
    return 0;

  if ((IS_STICKY_ACROSS_PAGES(cfgpacket)) && !sticky_page)
    return 0;

  if ((IS_STICKY_ACROSS_DESKS(cfgpacket)) && !sticky_desk)
    return 0;

  if (!XGetWindowAttributes(dpy, cfgpacket->w, &xwa))
    return 0;

  if (xwa.map_state != IsViewable)
    return 0;

  if (!(IS_MAPPED(cfgpacket)))
    return 0;

  if (IS_ICONIFIED(cfgpacket))
    return 0;

  if (!desk)
  {
    int x = (int)cfgpacket->frame_x, y = (int)cfgpacket->frame_y;
    int w = (int)cfgpacket->frame_width, h = (int)cfgpacket->frame_height;
    if (x >= dx + dwidth || y >= dy + dheight || x + w <= dx || y + h <= dy)
      return 0;
  }

  if (!(HAS_TITLE(cfgpacket)) && !untitled)
    return 0;

  if ((IS_TRANSIENT(cfgpacket)) && !transients)
    return 0;

  return 1;
}
Ejemplo n.º 11
0
void list_configure(unsigned long *body)
{
  struct ConfigWinPacket *cfgpacket = (void *)body;
  char *grav;

  printf( "0x%08lx %-20s x %ld, y %ld, width %ld, height %ld\n",
	  cfgpacket->w, "frame", cfgpacket->frame_x, cfgpacket->frame_y,
	  cfgpacket->frame_width, cfgpacket->frame_height );
  printf( "0x%08lx %-20s %ld\n" ,cfgpacket->w, "desktop", cfgpacket->desk);

  /* Oooh, you asked for it... */
  if (Opt_flags == 2)
  {
    printf( "Packet flags\n" );
    printf( "is_sticky_across_pages: %d\n",
	    IS_STICKY_ACROSS_PAGES( cfgpacket ) );
    printf( "is_sticky_across_desks: %d\n",
	    IS_STICKY_ACROSS_DESKS( cfgpacket ) );
    printf( "has_icon_font: %d\n",
	    HAS_ICON_FONT( cfgpacket ) );
    printf( "has_window_font: %d\n",
	    HAS_WINDOW_FONT( cfgpacket ) );
    printf( "do_circulate_skip: %d\n",
	    DO_SKIP_CIRCULATE( cfgpacket ) );
    printf( "do_circulate_skip_icon: %d\n",
	    DO_SKIP_ICON_CIRCULATE( cfgpacket ) );
    printf( "do_circulate_skip_shaded: %d\n",
	    DO_SKIP_SHADED_CIRCULATE( cfgpacket ) );
    printf( "do_grab_focus_when_created: %d\n",
	    FP_DO_GRAB_FOCUS( FW_FOCUS_POLICY(cfgpacket) ) );
    printf( "do_grab_focus_when_transient_created: %d\n",
	    FP_DO_GRAB_FOCUS_TRANSIENT( FW_FOCUS_POLICY(cfgpacket) ) );
    printf( "do_ignore_restack: %d\n",
	    DO_IGNORE_RESTACK( cfgpacket ) );
    printf( "do_lower_transient: %d\n",
	    DO_LOWER_TRANSIENT( cfgpacket ) );
    printf( "do_not_show_on_map: %d\n",
	    DO_NOT_SHOW_ON_MAP( cfgpacket ) );
    printf( "do_not_pass_click_focus_click: %d\n",
	    FP_DO_PASS_FOCUS_CLICK( FW_FOCUS_POLICY(cfgpacket) ) );
    printf( "do_raise_transient: %d\n",
	    DO_RAISE_TRANSIENT( cfgpacket ) );
    printf( "do_resize_opaque: %d\n",
	    DO_RESIZE_OPAQUE( cfgpacket ) );
    printf( "do_shrink_windowshade: %d\n",
	    DO_SHRINK_WINDOWSHADE( cfgpacket ) );
    printf( "do_stack_transient_parent: %d\n",
	    DO_STACK_TRANSIENT_PARENT( cfgpacket ) );
    printf( "do_window_list_skip: %d\n",
	    DO_SKIP_WINDOW_LIST( cfgpacket ) );
    printf( "has_depressable_border: %d\n",
	    HAS_DEPRESSABLE_BORDER( cfgpacket ) );
    printf( "has_mwm_border: %d\n",
	    HAS_MWM_BORDER( cfgpacket ) );
    printf( "has_mwm_buttons: %d\n",
	    HAS_MWM_BUTTONS( cfgpacket ) );
    printf( "has_mwm_override: %d\n",
	    HAS_MWM_OVERRIDE_HINTS( cfgpacket ) );
    printf( "has_no_icon_title: %d\n",
	    HAS_NO_ICON_TITLE( cfgpacket ) );
    printf( "has_override_size: %d\n",
	    HAS_OVERRIDE_SIZE_HINTS( cfgpacket ) );
    printf( "has_stippled_title: %d\n",
	    HAS_STIPPLED_TITLE( cfgpacket ) );
    printf( "is_fixed: %d\n",
	    IS_FIXED( cfgpacket ) );
    printf( "is_icon_sticky_across_pages: %d\n",
	    IS_ICON_STICKY_ACROSS_PAGES( cfgpacket ) );
    printf( "is_icon_sticky_across_desks: %d\n",
	    IS_ICON_STICKY_ACROSS_DESKS( cfgpacket ) );
    printf( "is_icon_suppressed: %d\n",
	    IS_ICON_SUPPRESSED( cfgpacket ) );
    printf( "is_lenient: %d\n",
	    FP_IS_LENIENT( FW_FOCUS_POLICY(cfgpacket) ) );
    printf( "does_wm_delete_window: %d\n",
	    WM_DELETES_WINDOW( cfgpacket ) );
    printf( "does_wm_take_focus: %d\n",
	    WM_TAKES_FOCUS( cfgpacket ) );
    printf( "do_iconify_after_map: %d\n",
	    DO_ICONIFY_AFTER_MAP( cfgpacket ) );
    printf( "do_reuse_destroyed: %d\n",
	    DO_REUSE_DESTROYED( cfgpacket ) );
    printf( "has_border: %d\n",
	    !HAS_NO_BORDER( cfgpacket ) );
    printf( "has_title: %d\n",
	    HAS_TITLE( cfgpacket ) );
    printf( "is_iconify_pending: %d\n",
	    IS_ICONIFY_PENDING( cfgpacket ) );
    printf( "is_fully_visible: %d\n",
	    IS_FULLY_VISIBLE( cfgpacket ) );
    printf( "is_iconified: %d\n",
	    IS_ICONIFIED( cfgpacket ) );
    printf( "is_iconfied_by_parent: %d\n",
	    IS_ICONIFIED_BY_PARENT( cfgpacket ) );
    printf( "is_icon_entered: %d\n",
	    IS_ICON_ENTERED( cfgpacket ) );
    printf( "is_icon_font_loaded: %d\n",
	    IS_ICON_FONT_LOADED( cfgpacket ) );
    printf( "is_icon_moved: %d\n",
	    IS_ICON_MOVED( cfgpacket ) );
    printf( "is_icon_ours: %d\n",
	    IS_ICON_OURS( cfgpacket ) );
    printf( "is_icon_shaped: %d\n",
	    IS_ICON_SHAPED( cfgpacket ) );
    printf( "is_icon_unmapped: %d\n",
	    IS_ICON_UNMAPPED( cfgpacket ) );
    printf( "is_mapped: %d\n",
	    IS_MAPPED( cfgpacket ) );
    printf( "is_map_pending: %d\n",
	    IS_MAP_PENDING( cfgpacket ) );
    printf( "is_maximized: %d\n",
	    IS_MAXIMIZED( cfgpacket ) );
    printf( "is_name_changed: %d\n",
	    IS_NAME_CHANGED( cfgpacket ) );
    printf( "is_partially_visible: %d\n",
	    IS_PARTIALLY_VISIBLE( cfgpacket ) );
    printf( "is_pixmap_ours: %d\n",
	    IS_PIXMAP_OURS( cfgpacket ) );
    printf( "is_size_inc_set: %d\n",
	    IS_SIZE_INC_SET( cfgpacket ) );
    printf( "is_transient: %d\n",
	    IS_TRANSIENT( cfgpacket ) );
    printf( "is_window_drawn_once: %d\n",
	    cfgpacket->flags.is_window_drawn_once );
    printf( "is_viewport_moved: %d\n",
	    IS_VIEWPORT_MOVED( cfgpacket ) );
    printf( "is_window_being_moved_opaque: %d\n",
	    IS_WINDOW_BEING_MOVED_OPAQUE( cfgpacket ) );
    printf( "is_window_font_loaded: %d\n",
	    IS_WINDOW_FONT_LOADED( cfgpacket ) );
    printf( "is_window_shaded %d\n",
	    IS_SHADED( cfgpacket ) );
    printf( "title_dir: %d\n",
	    GET_TITLE_DIR( cfgpacket ) );
  }

  printf( "0x%08lx %-20s %hd\n",
	  cfgpacket->w, "title height", cfgpacket->title_height);
  printf( "0x%08lx %-20s %hd\n",
	  cfgpacket->w, "border width", cfgpacket->border_width);
  printf( "0x%08lx %-20s width %ld, height %ld\n", cfgpacket->w, "base size",
	  cfgpacket->hints_base_width, cfgpacket->hints_base_height);
  printf( "0x%08lx %-20s width %ld, height %ld\n", cfgpacket->w,
	  "size increment", cfgpacket->hints_width_inc,
	  cfgpacket->hints_height_inc);
  printf( "0x%08lx %-20s width %ld, height %ld\n", cfgpacket->w, "min size",
	  cfgpacket->hints_min_width, cfgpacket->hints_min_height);
  printf( "0x%08lx %-20s width %ld, height %ld\n", cfgpacket->w, "max size",
	  cfgpacket->hints_max_width, cfgpacket->hints_max_height);

  switch(cfgpacket->hints_win_gravity)
  {
  case ForgetGravity:
    grav = "Forget";
    break;
  case NorthWestGravity:
    grav = "NorthWest";
    break;
  case NorthGravity:
    grav = "North";
    break;
  case NorthEastGravity:
    grav = "NorthEast";
    break;
  case WestGravity:
    grav = "West";
    break;
  case CenterGravity:
    grav = "Center";
    break;
  case EastGravity:
    grav = "East";
    break;
  case SouthWestGravity:
    grav = "SouthWest";
    break;
  case SouthGravity:
    grav = "South";
    break;
  case SouthEastGravity:
    grav = "SouthEast";
    break;
  case StaticGravity:
    grav = "Static";
    break;
  default:
    grav = "Unknown";
    break;
  }
  printf( "0x%08lx %-20s %s\n", cfgpacket->w, "gravity", grav);
  printf( "0x%08lx %-20s text 0x%lx, back 0x%lx\n", cfgpacket->w, "pixel",
	  cfgpacket->TextPixel, cfgpacket->BackPixel);
}
Ejemplo n.º 12
0
Archivo: FvwmSave.c Proyecto: att/uwin
/***********************************************************************
 *
 *  Procedure:
 *	checks to see if we are supposed to take some action now,
 *      finds time for next action to be performed.
 *
 ***********************************************************************/
void do_save(void)
{
  struct list *t;
  char tname[200],loc[30];
  FILE *out;
  char **command_list;
  int dwidth,dheight,xtermline = 0;
  int x1,x2,y1,y2,i,command_count;
  long tVx, tVy;

  sprintf(tname, "%s/new.xinitrc", getenv( "HOME" ) );
  out = fopen( tname, "w+" );
  for (t = list_root; t != NULL; t = t->next)
  {
    tname[0]=0;

    x1 = t->frame_x;
    x2 = ScreenWidth - x1 - t->frame_width - 2;
    if(x2 < 0)
      x2 = 0;
    y1 = t->frame_y;
    y2 = ScreenHeight - y1 -  t->frame_height - 2;
    if(y2 < 0)
      y2 = 0;
    dheight = t->frame_height - t->title_height - 2*t->boundary_width;
    dwidth = t->frame_width - 2*t->boundary_width;
    dwidth -= t->base_width ;
    dheight -= t->base_height ;
    dwidth /= t->width_inc;
    dheight /= t->height_inc;

    if (IS_STICKY(t))
    {
      tVx = 0;
      tVy = 0;
    }
    else
    {
      tVx = Vx;
      tVy = Vy;
    }
    sprintf(tname,"%dx%d",dwidth,dheight);
    if ((t->gravity == EastGravity) ||
	(t->gravity == NorthEastGravity) ||
	(t->gravity == SouthEastGravity))
      sprintf(loc,"-%d",x2);
    else
      sprintf(loc,"+%d",x1+(int)tVx);
    strcat(tname, loc);

    if((t->gravity == SouthGravity)||
       (t->gravity == SouthEastGravity)||
       (t->gravity == SouthWestGravity))
      sprintf(loc,"-%d",y2);
    else
      sprintf(loc,"+%d",y1+(int)tVy);
    strcat(tname, loc);

    if ( XGetCommand( dpy, t->id, &command_list, &command_count ) )
    {
      for (i=0; i < command_count; i++)
      {
	if ( strncmp( "-geo", command_list[i], 4) == 0)
	{
	  i++;
	  continue;
	}
	if ( strncmp( "-ic", command_list[i], 3) == 0)
	  continue;
	if ( strncmp( "-display", command_list[i], 8) == 0)
	{
	  i++;
	  continue;
	}
	write_string(out,command_list[i]);
	if(strstr(command_list[i], "xterm"))
	{
	  fprintf( out, "-geometry %s ", tname );
	  if (IS_ICONIFIED(t))
	    fprintf(out, "-ic ");
	  xtermline = 1;
	}
      }
      if ( command_count > 0 )
      {
	if ( xtermline == 0 )
	{
	  if (IS_ICONIFIED(t))
	    fprintf(out, "-ic ");
	  fprintf( out, "-geometry %s &\n", tname );
	}
	else
	{
	  fprintf( out, "&\n");
	}
      }
      XFreeStringList( command_list );
      xtermline = 0;
    }
  }
  fprintf(out, "fvwm\n");
  fclose( out );
  exit(0);
}
Ejemplo n.º 13
0
Archivo: FvwmPager.c Proyecto: att/uwin
/***********************************************************************
 *
 *  Procedure:
 *	list_configure - displays packet contents to stderr
 *
 ***********************************************************************/
void list_configure(unsigned long *body)
{
  PagerWindow *t;
  Window target_w;
  struct ConfigWinPacket  *cfgpacket = (void *) body;

  target_w = cfgpacket->w;
  t = Start;
  while((t!= NULL)&&(t->w != target_w))
  {
    t = t->next;
  }
  if(t== NULL)
  {
    list_add(body);
    return;
  }

  t->t = (char *) cfgpacket->fvwmwin;
  t->frame = cfgpacket->frame;
  t->frame_x = cfgpacket->frame_x;
  t->frame_y = cfgpacket->frame_y;
  t->frame_width = cfgpacket->frame_width;
  t->frame_height = cfgpacket->frame_height;
  t->title_height = cfgpacket->title_height;
  t->border_width = cfgpacket->border_width;
  memcpy(&(t->flags), &(cfgpacket->flags), sizeof(cfgpacket->flags));
  t->icon_w = cfgpacket->icon_w;
  t->icon_pixmap_w = cfgpacket->icon_pixmap_w;

  if (win_pix_set)
  {
    t->text = win_fore_pix;
    t->back = win_back_pix;
  }
  else
  {
    t->text = cfgpacket->TextPixel;
    t->back = cfgpacket->BackPixel;
  }
  if(IS_ICONIFIED(t))
  {
    t->x = t->icon_x;
    t->y = t->icon_y;
    t->width = t->icon_width;
    t->height = t->icon_height;
    if(IS_ICON_SUPPRESSED(t) || t->width == 0 || t->height == 0)
    {
      t->x = -32768;
      t->y = -32768;
    }
  }
  else
  {
    t->x = t->frame_x;
    t->y = t->frame_y;
    t->width = t->frame_width;
    t->height = t->frame_height;
  }
  if(t->desk != cfgpacket->desk)
  {
    ChangeDeskForWindow(t, cfgpacket->desk);
  }
  else
    MoveResizePagerView(t, False);
}
Ejemplo n.º 14
0
/*
** seemed kind of silly to have check_allowed_function and
** check_allowed_function2 partially overlapping in their checks, so I
** combined them here and made them wrapper functions instead.
*/
Bool is_function_allowed(
	int function, char *action_string, const FvwmWindow *t,
	request_origin_t request_origin, Bool do_allow_override_mwm_hints)
{
	unsigned int functions;
	char *functionlist[] = {
		MOVE_STRING,
		RESIZE_STRING1,
		RESIZE_STRING2,
		MINIMIZE_STRING,
		MINIMIZE_STRING2,
		MAXIMIZE_STRING,
		CLOSE_STRING1,
		CLOSE_STRING2,
		CLOSE_STRING3,
		CLOSE_STRING4,
		NULL
	};

	if (t == NULL)
	{
		return True;  /* this logic come from animated menu */
	}
	if (do_allow_override_mwm_hints && HAS_MWM_OVERRIDE_HINTS(t))
	{
		/* allow everything */
		functions = ~0;
	}
	else
	{
		/* restrict by mwm hints */
		functions = t->functions;
	}

	/* Hate to do it, but for lack of a better idea, check based on the
	 * menu entry name */
	/* Complex functions are a little tricky, ignore them if no menu item*/
	if (function == F_FUNCTION && action_string != NULL)
	{
		int i;

		/* remap to regular actions */

		i = GetTokenIndex(action_string, functionlist, -1, NULL);
		switch (i)
		{
		case 0:
			function = F_MOVE;
			break;
		case 1:
			function = F_RESIZE;
			break;
		case 2:
			function = F_RESIZE;
			break;
		case 3:
			function = F_ICONIFY;
			break;
		case 4:
			function = F_ICONIFY;
			break;
		case 5:
			function = F_MAXIMIZE;
			break;
		case 6:
			function = F_CLOSE;
			break;
		case 7:
			function = F_DELETE;
			break;
		case 8:
			function = F_DESTROY;
			break;
		case 9:
			function = F_QUIT;
			break;
		default:
			break;
		}
	}
	/* now do the real checks */
	switch(function)
	{
	case F_DELETE:
	        if (IS_UNCLOSABLE(t))
		{
		        return False;
		}
		if (IS_TEAR_OFF_MENU(t))
		{
			/* always allow this on tear off menus */
			break;
		}
		if (!WM_DELETES_WINDOW(t))
		{
			return False;
		}
		/* fall through to close clause */
	case F_CLOSE:
	        if (IS_UNCLOSABLE(t))
		{
		        return False;
		}
		if (IS_TEAR_OFF_MENU(t))
		{
			/* always allow this on tear off menus */
			break;
		}
		if (!(functions & MWM_FUNC_CLOSE))
		{
			return False;
		}
		break;
	case F_DESTROY: /* shouldn't destroy always be allowed??? */
	        if (IS_UNCLOSABLE(t))
		{
		        return False;
		}
		if (IS_TEAR_OFF_MENU(t))
		{
			/* always allow this on tear off menus */
			break;
		}
		if (!(functions & MWM_FUNC_CLOSE))
		{
			return False;
		}
		break;
	case F_RESIZE:
	        if(!__is_resize_allowed(t, functions, request_origin))
		{
		        return False;
		}
		break;
	case F_ICONIFY:
		if ((!IS_ICONIFIED(t) && !(functions & MWM_FUNC_MINIMIZE)) ||
		    IS_UNICONIFIABLE(t))
		{
			return False;
		}
		break;
	case F_MAXIMIZE:
	        if (IS_MAXIMIZE_FIXED_SIZE_DISALLOWED(t) &&
		    !__is_resize_allowed(t, functions, request_origin))
		{
		       return False;
		}
		if ((request_origin && !(functions & MWM_FUNC_MAXIMIZE)) ||
		    IS_UNMAXIMIZABLE(t))
		{
			return False;
		}
		break;
	case F_MOVE:
		/* Move is a funny hint. Keeps it out of the menu, but you're
		 * still allowed to move. */
		if (request_origin && IS_FIXED(t))
		{
			return False;
		}
		else if (!request_origin && IS_FIXED_PPOS(t))
		{
			return False;
		}
		if (request_origin && !(functions & MWM_FUNC_MOVE))
		{
			return False;
		}
		break;
	case F_FUNCTION:
	default:
		break;
	} /* end of switch */

	/* if we fell through, just return True */
	return True;
}
Ejemplo n.º 15
0
Archivo: focus.c Proyecto: fvwmorg/fvwm
/*
 *
 * Moves pointer to specified window
 *
 */
static void warp_to_fvwm_window(
	const exec_context_t *exc, int warp_x, int x_unit, int warp_y,
	int y_unit, int do_raise)
{
	int dx,dy;
	int cx,cy;
	int x,y;
	FvwmWindow *t = exc->w.fw;

	if (t == (FvwmWindow *)0 ||
	    (IS_ICONIFIED(t) && FW_W_ICON_TITLE(t) == None))
	{
		return;
	}
	if (t->Desk != Scr.CurrentDesk)
	{
		goto_desk(t->Desk);
	}
	if (IS_ICONIFIED(t))
	{
		rectangle g;
		Bool rc;

		rc = get_visible_icon_title_geometry(t, &g);
		if (rc == False)
		{
			get_visible_icon_picture_geometry(t, &g);
		}
		cx = g.x + g.width / 2;
		cy = g.y + g.height / 2;
	}
	else
	{
		cx = t->g.frame.x + t->g.frame.width/2;
		cy = t->g.frame.y + t->g.frame.height/2;
	}
	dx = (cx + Scr.Vx) / Scr.MyDisplayWidth * Scr.MyDisplayWidth;
	dy = (cy + Scr.Vy) / Scr.MyDisplayHeight * Scr.MyDisplayHeight;
	if (dx != Scr.Vx || dy != Scr.Vy)
	{
		MoveViewport(dx, dy, True);
	}
	if (IS_ICONIFIED(t))
	{
		rectangle g;
		Bool rc;

		rc = get_visible_icon_title_geometry(t, &g);
		if (rc == False)
		{
			get_visible_icon_picture_geometry(t, &g);
		}
		x = g.x + g.width / 2;
		y = g.y + g.height / 2;
	}
	else
	{
		if (x_unit != Scr.MyDisplayWidth && warp_x >= 0)
		{
			x = t->g.frame.x + warp_x;
		}
		else if (x_unit != Scr.MyDisplayWidth)
		{
			x = t->g.frame.x + t->g.frame.width + warp_x;
		}
		else if (warp_x >= 0)
		{
			x = t->g.frame.x +
				(t->g.frame.width - 1) * warp_x / 100;
		}
		else
		{
			x = t->g.frame.x +
				(t->g.frame.width - 1) * (100 + warp_x) / 100;
		}

		if (y_unit != Scr.MyDisplayHeight && warp_y >= 0)
		{
			y = t->g.frame.y + warp_y;
		}
		else if (y_unit != Scr.MyDisplayHeight)
		{
			y = t->g.frame.y + t->g.frame.height + warp_y;
		}
		else if (warp_y >= 0)
		{
			y = t->g.frame.y +
				(t->g.frame.height - 1) * warp_y / 100;
		}
		else
		{
			y = t->g.frame.y +
				(t->g.frame.height - 1) * (100 + warp_y) / 100;
		}
	}
	FWarpPointerUpdateEvpos(
		exc->x.elast, dpy, None, Scr.Root, 0, 0, 0, 0, x, y);
	if (do_raise)
	{
		RaiseWindow(t, False);
	}
	/* If the window is still not visible, make it visible! */
	if (t->g.frame.x + t->g.frame.width  < 0 ||
	    t->g.frame.y + t->g.frame.height < 0 ||
	    t->g.frame.x >= Scr.MyDisplayWidth ||
	    t->g.frame.y >= Scr.MyDisplayHeight)
	{
		frame_setup_window(
			t, 0, 0, t->g.frame.width, t->g.frame.height, False);
		FWarpPointerUpdateEvpos(
			exc->x.elast, dpy, None, Scr.Root, 0, 0, 0, 0, 2, 2);
	}

	return;
}
Ejemplo n.º 16
0
Archivo: focus.c Proyecto: fvwmorg/fvwm
/*
 * Sets the input focus to the indicated window.
 */
static void __set_focus_to_fwin(
	Window w, FvwmWindow *fw, sftfwin_args_t *args)
{
	FvwmWindow *sf;

	if (__try_forbid_user_focus(w, fw) == True)
	{
		return;
	}
	__try_program_focus(w, fw);
	if (__check_allow_focus(w, fw, args->set_by) == False)
	{
		return;
	}
	__update_windowlist(fw, args->set_by, args->is_focus_by_flip_focus_cmd);
	if (__try_other_screen_focus(fw) == True)
	{
		return;
	}

	if (fw && !args->do_forbid_warp)
	{
		if (IS_ICONIFIED(fw))
		{
			rectangle r;
			Bool rc;

			rc = get_visible_icon_geometry(fw, &r);
			if (!rc || !IsRectangleOnThisPage(&r, fw->Desk))
			{
				fw = NULL;
				w = Scr.NoFocusWin;
			}
		}
		else if (!IsRectangleOnThisPage(&(fw->g.frame), fw->Desk))
		{
			fw = NULL;
			w = Scr.NoFocusWin;
		}
	}

	sf = get_focus_window();
	if (fw == NULL)
	{
		FOCUS_SET(Scr.NoFocusWin, NULL);
		set_focus_window(NULL);
		Scr.UnknownWinFocused = None;
		XFlush(dpy);
		return;
	}
	/* RBW - allow focus to go to a NoIconTitle icon window so
	 * auto-raise will work on it. */
	if (IS_ICONIFIED(fw))
	{
		Bool is_window_selected = False;

		if (FW_W_ICON_TITLE(fw))
		{
			w = FW_W_ICON_TITLE(fw);
			is_window_selected = True;
		}
		if ((!is_window_selected || WAS_ICON_HINT_PROVIDED(fw)) &&
		    FW_W_ICON_PIXMAP(fw))
		{
			w = FW_W_ICON_PIXMAP(fw);
		}
	}

	if (FP_IS_LENIENT(FW_FOCUS_POLICY(fw)))
	{
		FOCUS_SET(w, fw);
		set_focus_window(fw);
		if (args->do_allow_force_broadcast)
		{
			SET_FOCUS_CHANGE_BROADCAST_PENDING(fw, 1);
		}
		Scr.UnknownWinFocused = None;
	}
	else if (focus_does_accept_input_focus(fw))
	{
		/* Window will accept input focus */
		if (Scr.StolenFocusWin == w && Scr.UnknownWinFocused != None)
		{
			/* Without this FocusIn is not generated on the
			 * window if it was focuesed when the unmanaged
			 * window took focus. */
			FOCUS_SET(Scr.NoFocusWin, NULL);

		}
		FOCUS_SET(w, fw);
		set_focus_window(fw);
		if (fw)
		{
			if (args->do_allow_force_broadcast)
			{
				SET_FOCUS_CHANGE_BROADCAST_PENDING(fw, 1);
			}
		}
		Scr.UnknownWinFocused = None;
	}
	else if (sf && sf->Desk == Scr.CurrentDesk)
	{
		/* Window doesn't want focus. Leave focus alone */
	}
	else
	{
		FOCUS_SET(Scr.NoFocusWin, NULL);
		set_focus_window(NULL);
	}
	XFlush(dpy);

	return;
}
Ejemplo n.º 17
0
Archivo: focus.c Proyecto: fvwmorg/fvwm
/*
 *
 * Moves focus to specified window; only to be called bay Focus and FlipFocus
 *
 */
static void __activate_window_by_command(
	F_CMD_ARGS, int is_focus_by_flip_focus_cmd)
{
	int cx;
	int cy;
	Bool do_not_warp;
	sftfwin_args_t sf_args;
	FvwmWindow * const fw = exc->w.fw;

	memset(&sf_args, 0, sizeof(sf_args));
	sf_args.do_allow_force_broadcast = 1;
	sf_args.is_focus_by_flip_focus_cmd = is_focus_by_flip_focus_cmd;
	sf_args.set_by = FOCUS_SET_BY_FUNCTION;
        sf_args.client_entered = 0;
	if (fw == NULL || !FP_DO_FOCUS_BY_FUNCTION(FW_FOCUS_POLICY(fw)))
	{
		UngrabEm(GRAB_NORMAL);
		if (fw)
		{
			/* give the window a chance to take the focus itself */
			sf_args.do_forbid_warp = 1;
			sf_args.do_force = 0;
			set_focus_to_fwin(FW_W(fw), fw, &sf_args);
		}
		return;
	}

	do_not_warp = StrEquals(PeekToken(action, NULL), "NoWarp");
	if (!do_not_warp)
	{
		if (fw->Desk != Scr.CurrentDesk)
		{
			goto_desk(fw->Desk);
		}
		if (IS_ICONIFIED(fw))
		{
			rectangle g;
			Bool rc;

			rc = get_visible_icon_title_geometry(fw, &g);
			if (rc == False)
			{
				get_visible_icon_picture_geometry(fw, &g);
			}
			cx = g.x + g.width / 2;
			cy = g.y + g.height / 2;
		}
		else
		{
			cx = fw->g.frame.x + fw->g.frame.width/2;
			cy = fw->g.frame.y + fw->g.frame.height/2;
		}
		if (
			cx < 0 || cx >= Scr.MyDisplayWidth ||
			cy < 0 || cy >= Scr.MyDisplayHeight)
		{
			int dx;
			int dy;

			dx = ((cx + Scr.Vx) / Scr.MyDisplayWidth) *
				Scr.MyDisplayWidth;
			dy = ((cy + Scr.Vy) / Scr.MyDisplayHeight) *
				Scr.MyDisplayHeight;
			MoveViewport(dx, dy, True);
		}
#if 0 /* can not happen */
		/* If the window is still not visible, make it visible! */
		if (fw->g.frame.x + fw->g.frame.width < 0 ||
		    fw->g.frame.y + fw->g.frame.height < 0 ||
		    fw->g.frame.x >= Scr.MyDisplayWidth ||
		    fw->g.frame.y >= Scr.MyDisplayHeight)
		{
			frame_setup_window(
				fw, 0, 0, fw->g.frame.width,
				fw->g.frame.height, False);
			if (
				FP_DO_WARP_POINTER_ON_FOCUS_FUNC(
					FW_FOCUS_POLICY(fw)))
			{
				FWarpPointerUpdateEvpos(
					exc->x.elast, dpy, None, Scr.Root, 0,
					0, 0, 0, 2, 2);
			}
		}
#endif
	}
	UngrabEm(GRAB_NORMAL);

	if (fw->Desk == Scr.CurrentDesk)
	{
		FvwmWindow *sf;

		sf = get_focus_window();
		sf_args.do_forbid_warp = !!do_not_warp;
		sf_args.do_force = 0;
                sf_args.client_entered = 0;
		set_focus_to_fwin(FW_W(fw), fw, &sf_args);
		if (sf != get_focus_window())
		{
			/* Ignore EnterNotify event while we are waiting for
			 * this window to be focused. */
			Scr.focus_in_pending_window = sf;
		}
	}

	return;
}
Ejemplo n.º 18
0
/*
 * Change by PRB ([email protected]), 31/10/93.  Prepend a hot key
 * specifier to each item in the list.  This means allocating the
 * memory for each item (& freeing it) rather than just using the window
 * title directly. */
void CMD_WindowList(F_CMD_ARGS)
{
	struct MenuRoot *mr;
	struct MenuParameters mp;
	char* ret_action = NULL;
	FvwmWindow *t;
	FvwmWindow **windowList;
	FvwmWindow **iconifiedList = NULL;
	int numWindows;
	int ii;
	char tname[128];
	char loc[64];
	char *name=NULL;
	Bool free_name = False;
	int dwidth;
	int dheight;
	char *tlabel;
	int last_desk_done = INT_MIN;
	int last_desk_displayed = INT_MIN;
	int next_desk = 0;
	char *t_hot=NULL;             /* Menu label with hotkey added */
	char scut = '0';              /* Current short cut key */
	char *opts=NULL;
	char *tok=NULL;
	int desk = Scr.CurrentDesk;
	unsigned long flags = SHOW_DEFAULT;
	char *func = NULL;
	char *ffunc = NULL;
	char *tfunc = NULL;
	char *default_action = NULL;
	MenuReturn mret;
	MenuOptions mops;
	int low_layer = 0;  /* show all layers by default */
	int high_layer = INT_MAX;
	int max_label_width = 0;
	int skiplist_mode = 0; /* do not show skiplist by default */
	Bool use_hotkey = True;
	KeyCode old_sor_keycode;
	char sor_default_keyname[8] = { 'M', 'e', 't', 'a', '_', 'L' };
	char *sor_keyname = sor_default_keyname;
	/* Condition vars. */
	Bool use_condition = False;
	Bool current_at_end = False;
	Bool iconified_at_end = False;
	int ic = 0;
	int ij;
	WindowConditionMask mask;
	char *cond_flags;
	Bool first_desk = True;
	Bool empty_menu = True;
	Bool was_get_menu_opts_called = False;
	FvwmWindow * const fw = exc->w.fw;
	const Window w = exc->w.w;
	const exec_context_t *exc2;

	memset(&mops, 0, sizeof(mops));
	memset(&mret, 0, sizeof(MenuReturn));
	/* parse postitioning args - must call this even if no action is given
	 * because it sets the xinerama screen origin */
	if (action && *action)
	{
		/* Look for condition - CreateFlagString returns NULL if no '('
		 * or '[' */
		cond_flags = CreateFlagString(action, &action);
		if (cond_flags)
		{
			/* Create window mask */
			use_condition = True;
			DefaultConditionMask(&mask);

			/* override for Current [] */
			mask.my_flags.use_circulate_hit = 1;
			mask.my_flags.use_circulate_hit_icon = 1;

			CreateConditionMask(cond_flags, &mask);
			free(cond_flags);
		}
		opts = get_menu_options(
			action, w, fw, NULL, NULL, NULL, &mops);
		was_get_menu_opts_called = True;

		/* parse options */
		while (opts && *opts)
		{
			opts = GetNextSimpleOption(opts, &tok);
			if (!tok)
			{
				break;
			}

			if (StrEquals(tok,"NoHotkeys"))
			{
				use_hotkey = False;
			}
			else if (StrEquals(tok,"Function"))
			{
				opts = GetNextSimpleOption(opts, &func);
			}
			else if (StrEquals(tok,"Desk"))
			{
				free(tok);
				opts = GetNextSimpleOption(opts, &tok);
				if (tok)
				{
					desk = atoi(tok);
					flags &= ~SHOW_ALLDESKS;
				}
			}
			else if (StrEquals(tok,"CurrentDesk"))
			{
				desk = Scr.CurrentDesk;
				flags &= ~SHOW_ALLDESKS;
			}
			else if (StrEquals(tok,"NotAlphabetic"))
			{
				flags &= ~SHOW_ALPHABETIC;
			}
			else if (StrEquals(tok,"Alphabetic"))
			{
				flags |= SHOW_ALPHABETIC;
			}
			else if (StrEquals(tok,"SortByClass"))
			{
				flags |= SORT_BYCLASS;
			}
			else if (StrEquals(tok,"SortByResource"))
			{
				flags |= SORT_BYRESOURCE;
			}
			else if (StrEquals(tok,"ReverseOrder"))
			{
				flags |= SORT_REVERSE;
			}
			else if (StrEquals(tok,"CurrentAtEnd"))
			{
				current_at_end = True;
			}
			else if (StrEquals(tok,"IconifiedAtEnd"))
			{
				iconified_at_end = True;
			}
			else if (StrEquals(tok,"NoDeskSort"))
			{
				flags |= NO_DESK_SORT;
			}
			else if (StrEquals(tok,"ShowPage"))
			{
				flags |= SHOW_PAGE_X | SHOW_PAGE_Y;
			}
			else if (StrEquals(tok,"ShowPageX"))
			{
				flags |= SHOW_PAGE_X;
			}
			else if (StrEquals(tok,"ShowPageY"))
			{
				flags |= SHOW_PAGE_Y;
			}
			else if (StrEquals(tok,"ShowScreen"))
			{
				flags |= SHOW_SCREEN;
			}
			else if (StrEquals(tok,"UseIconName"))
			{
				flags |= SHOW_ICONNAME;
			}
			else if (StrEquals(tok,"NoGeometry"))
			{
				flags &= ~SHOW_GEOMETRY;
				flags &= ~SHOW_INFONOTGEO;
			}
			else if (StrEquals(tok,"NoGeometryWithInfo"))
			{
				flags &= ~SHOW_GEOMETRY;
				flags |= SHOW_INFONOTGEO;
			}
			else if (StrEquals(tok,"Geometry"))
			{
				flags |= SHOW_GEOMETRY;
				flags &= ~SHOW_INFONOTGEO;
			}
			else if (StrEquals(tok,"NoIcons"))
			{
				flags &= ~SHOW_ICONIC;
			}
			else if (StrEquals(tok,"Icons"))
			{
				flags |= SHOW_ICONIC;
			}
			else if (StrEquals(tok,"OnlyIcons"))
			{
				flags = SHOW_ICONIC;
			}
			else if (StrEquals(tok,"NoNormal"))
			{
				flags &= ~SHOW_NORMAL;
			}
			else if (StrEquals(tok,"Normal"))
			{
				flags |= SHOW_NORMAL;
			}
			else if (StrEquals(tok,"OnlyNormal"))
			{
				flags = SHOW_NORMAL;
			}
			else if (StrEquals(tok,"NoSticky"))
			{
				flags &= ~(SHOW_STICKY_ACROSS_PAGES);
				flags &= ~(SHOW_STICKY_ACROSS_DESKS);
			}
			else if (StrEquals(tok,"NoStickyPage"))
			{
				flags &= ~(SHOW_STICKY_ACROSS_PAGES);
			}
			else if (StrEquals(tok,"NoStickyDesk"))
			{
				flags &= ~(SHOW_STICKY_ACROSS_DESKS);
			}
			else if (StrEquals(tok,"Sticky"))
			{
				flags |= SHOW_STICKY_ACROSS_PAGES;
				flags |= SHOW_STICKY_ACROSS_DESKS;
			}
			else if (StrEquals(tok,"StickyPage"))
			{
				flags |= SHOW_STICKY_ACROSS_PAGES;
			}
			else if (StrEquals(tok,"StickyDesk"))
			{
				flags |= SHOW_STICKY_ACROSS_DESKS;
			}
			else if (StrEquals(tok,"OnlySticky"))
			{
				flags = SHOW_STICKY_ACROSS_PAGES;
				flags = SHOW_STICKY_ACROSS_DESKS;
			}
			else if (StrEquals(tok,"OnlyStickyPage"))
			{
				flags = SHOW_STICKY_ACROSS_PAGES;
			}
			else if (StrEquals(tok,"OnlyStickyDesk"))
			{
				flags = SHOW_STICKY_ACROSS_DESKS;
			}
			else if (StrEquals(tok,"UseListSkip"))
			{
				/* deprecated as of 02-May-2007 (SS) */
				fprintf(stderr, "UseListSkip is deprecated. Please use \"UseSkipList\".\n");
				skiplist_mode = 1;
			}
			else if (StrEquals(tok,"UseSkipList"))
			{
				skiplist_mode = 1;
			}
			else if (StrEquals(tok,"OnlyListSkip"))
			{
				/* deprecated as of 02-May-2007 (SS) */
				fprintf(stderr, "OnlyListSkip is deprecated. Please use \"OnlySkipList\".\n");
				skiplist_mode = 2;
			}
			else if (StrEquals(tok,"OnlySkipList"))
			{
				skiplist_mode = 2;
			}
			else if (StrEquals(tok,"NoDeskNum"))
			{
				flags |= NO_DESK_NUM;
			}
			else if (StrEquals(tok,"NoLayer"))
			{
				flags |= NO_LAYER;
			}
			else if (StrEquals(tok,"NoCurrentDeskTitle"))
			{
				flags |= NO_CURRENT_DESK_TITLE;
			}
			else if (StrEquals(tok,"TitleForAllDesks"))
			{
				flags |= TITLE_FOR_ALL_DESKS;
			}
			else if (StrEquals(tok,"NoNumInDeskTitle"))
			{
				flags |= NO_NUM_IN_DESK_TITLE;
			}
			/* these are a bit dubious, but we should keep the
			 * OnTop options for compatibility */
			else if (StrEquals(tok, "NoOnTop"))
			{
				if (high_layer >= Scr.TopLayer)
				{
					high_layer = Scr.TopLayer - 1;
				}
			}
			else if (StrEquals(tok, "OnTop"))
			{
				if (high_layer < Scr.TopLayer)
				{
					high_layer = Scr.TopLayer;
				}
			}
			else if (StrEquals(tok, "OnlyOnTop"))
			{
				high_layer = low_layer = Scr.TopLayer;
			}
			else if (StrEquals(tok, "NoOnBottom"))
			{
				if (low_layer <= Scr.BottomLayer)
				{
					low_layer = Scr.BottomLayer - 1;
				}
			}
			else if (StrEquals(tok, "OnBottom"))
			{
				if (low_layer > Scr.BottomLayer)
				{
					low_layer = Scr.BottomLayer;
				}
			}
			else if (StrEquals(tok, "OnlyOnBottom"))
			{
				high_layer = low_layer = Scr.BottomLayer;
			}
			else if (StrEquals(tok, "Layer"))
			{
				free(tok);
				opts = GetNextSimpleOption(opts, &tok);
				if (tok)
				{
					low_layer = high_layer = atoi(tok);
					free(tok);
					opts = GetNextSimpleOption(opts, &tok);
					if (tok)
					{
						high_layer = atoi(tok);
					}
				}
			}
			else if (StrEquals(tok, "SelectOnRelease"))
			{
				if (sor_keyname != sor_default_keyname)
				{
					free(sor_keyname);
				}
				sor_keyname = NULL;
				opts = GetNextSimpleOption(opts, &sor_keyname);
			}
			else if (StrEquals(tok, "MaxLabelWidth"))
			{
				char *wid;

				opts = GetNextSimpleOption(opts, &wid);
				if (wid)
				{
					max_label_width = atoi(wid);
					if (max_label_width < 1)
					{
						max_label_width = 1;
					}
					free(wid);
				}
			}
			else if (!opts || !*opts)
			{
				default_action = safestrdup(tok);
			}
			else
			{
				fvwm_msg(
					ERR, "WindowList","Unknown option '%s'",
					tok);
			}
			if (tok)
			{
				free(tok);
			}
		}
	}
	if (was_get_menu_opts_called == False)
	{
		opts = get_menu_options(
			action, w, fw, NULL, NULL, NULL, &mops);
	}

	tlabel = get_desk_title(desk, flags, True);
	mr = NewMenuRoot(tlabel);
	if (!(flags & NO_CURRENT_DESK_TITLE))
	{
		AddToMenu(mr, tlabel, "TITLE", False, False, False);
		empty_menu = False;
	}
	free(tlabel);

	numWindows = 0;
	for (t = Scr.FvwmRoot.next; t != NULL; t = t->next)
	{
		numWindows++;
	}
	windowList = malloc(numWindows*sizeof(t));
	if (windowList == NULL)
	{
		return;
	}
	if (iconified_at_end)
	{
		iconifiedList = malloc(numWindows*sizeof(t));
		if (iconifiedList == NULL)
		{
			free(windowList);
			return;
		}
	}
	/* get the windowlist starting from the current window (if any)*/
	t = get_focus_window();
	if (t == NULL)
	{
		t = Scr.FvwmRoot.next;
	}
	else if (current_at_end)
	{
		if (t->next)
		{
			t = t->next;
		}
		else
		{
			t = Scr.FvwmRoot.next;
		}
	}
	for (ii = 0; ii < numWindows; ii++)
	{
		if (flags & SORT_REVERSE)
		{
			windowList[numWindows - ii - 1] = t;
		}
		else if (iconified_at_end && IS_ICONIFIED(t))
		{
			iconifiedList[ic++] = t;
		}
		else
		{
			windowList[ii - ic] = t;
		}
		if (t->next)
		{
			t = t->next;
		}
		else
		{
			t = Scr.FvwmRoot.next;
		}
	}
	if (iconified_at_end && ic > 0)
	{
		if (current_at_end && ii > ic)
		{
			windowList[numWindows - 1] = windowList[--ii - ic];
		}
		for (ij = 0; ij < ic; ij++)
		{
			windowList[ij + (ii - ic)] = iconifiedList[ij];
		}
	}

	/* Do alphabetic sort */
	if (flags & (SHOW_ALPHABETIC | SORT_BYCLASS | SORT_BYRESOURCE))
	{
		/* This will be compare or compareReverse if a reverse order
		 * is selected. */
		int (*sort)(const FvwmWindow **a, const FvwmWindow **b);

		switch (flags & (SHOW_ALPHABETIC | SHOW_ICONNAME | \
			SORT_BYCLASS | SORT_BYRESOURCE))
		{
		case SHOW_ALPHABETIC:
			compare = visibleCompare;
			break;
		case SHOW_ALPHABETIC | SHOW_ICONNAME:
			compare = iconCompare;
			break;
		/* Sorting based on class name produces an alphabetic
		 * order so the keyword alphabetic is redundant. */
		case SORT_BYCLASS:
		case SORT_BYCLASS | SHOW_ALPHABETIC:
			compare = classCompare;
			break;
		case SORT_BYCLASS | SHOW_ICONNAME:
		case SORT_BYCLASS | SHOW_ICONNAME | SHOW_ALPHABETIC:
			compare = classIconCompare;
			break;
		case SORT_BYRESOURCE:
		case SORT_BYRESOURCE | SORT_BYCLASS:
		case SORT_BYRESOURCE | SORT_BYCLASS | SHOW_ALPHABETIC:
			compare = resourceCompare;
			break;
		case SORT_BYRESOURCE | SHOW_ICONNAME:
		case SORT_BYRESOURCE | SHOW_ICONNAME | SORT_BYCLASS:
		case SORT_BYRESOURCE | SHOW_ICONNAME | SORT_BYCLASS | \
		SHOW_ALPHABETIC:
			compare = resourceIconCompare;
			break;

		/* All current cases are covered, but if something
		 * changes in the future we leave compare valid even if
		 * it isn't what is expected. */
		default:
			compare = visibleCompare;
			break;
		}

		if ( flags & SORT_REVERSE )
		{
			sort = compareReverse;
		}
		else
		{
			sort = compare;
		}
		qsort(windowList, numWindows, sizeof(t),
		      (int(*)(const void*, const void*))sort);
	}

	while(next_desk != INT_MAX)
	{
		/* Sort window list by desktop number */
		if ((flags & SHOW_ALLDESKS) && !(flags & NO_DESK_SORT))
		{
			/* run through the windowlist finding the first desk
			 * not already processed */
			next_desk = INT_MAX;
			for (ii = 0; ii < numWindows; ii++)
			{
				t = windowList[ii];
				if (t->Desk >last_desk_done &&
				    t->Desk < next_desk)
				{
					next_desk = t->Desk;
				}
			}
		}
		if (!(flags & SHOW_ALLDESKS))
		{
			/* if only doing one desk and it hasn't been done */
			if (last_desk_done  == INT_MIN)
				next_desk = desk; /* select the desk */
			else
				next_desk = INT_MAX; /* flag completion */
		}
		if (flags & NO_DESK_SORT)
			next_desk = INT_MAX; /* only go through loop once */

		last_desk_done = next_desk;
		for (ii = 0; ii < numWindows; ii++)
		{
			t = windowList[ii];
			if (t->Desk != next_desk && !(flags & NO_DESK_SORT))
			{
				continue;
			}
			if (skiplist_mode == 0 && DO_SKIP_WINDOW_LIST(t))
			{
				/* don't want skiplist windows - skip */
				continue;
			}
			if (skiplist_mode == 2 && !DO_SKIP_WINDOW_LIST(t))
			{
				/* don't want no skiplist one - skip */
				continue;
			}
			if (use_condition && !MatchesConditionMask(t, &mask))
			{
				/* doesn't match specified condition */
				continue;
			}
			if (!(flags & SHOW_ICONIC) && (IS_ICONIFIED(t)))
			{
				/* don't want icons - skip */
				continue;
			}
			if (!(flags & SHOW_STICKY_ACROSS_PAGES) &&
			    (IS_STICKY_ACROSS_PAGES(t)))
			{
				/* don't want sticky ones - skip */
				continue;
			}
			if (!(flags & SHOW_STICKY_ACROSS_DESKS) &&
			    (IS_STICKY_ACROSS_DESKS(t)))
			{
				/* don't want sticky ones - skip */
				continue;
			}
			if (!(flags & SHOW_NORMAL) &&
			    !(IS_ICONIFIED(t) ||
			      IS_STICKY_ACROSS_PAGES(t) ||
			      IS_STICKY_ACROSS_DESKS(t)))
			{
				/* don't want "normal" ones - skip */
				continue;
			}
			if (get_layer(t) < low_layer ||
			    get_layer(t) > high_layer)
			{
				/* don't want this layer */
				continue;
			}

			empty_menu = False;
			/* add separator between desks when geometry
			 * shown but not at the top*/
			if (t->Desk != last_desk_displayed)
			{
				if (last_desk_displayed != INT_MIN)
				{
					if (((flags & SHOW_GEOMETRY) ||
					     (flags & SHOW_INFONOTGEO)) &&
					    !(flags & TITLE_FOR_ALL_DESKS))
					{
						AddToMenu(
							mr, NULL, NULL, False,
							False, False);
					}
					if (flags & TITLE_FOR_ALL_DESKS)
					{
						tlabel = get_desk_title(
							t->Desk, flags, False);
						AddToMenu(
							mr, tlabel, "TITLE",
							False, False, False);
						free(tlabel);
					}
				}
				last_desk_displayed = t->Desk;
			}
			if (first_desk && flags & TITLE_FOR_ALL_DESKS)
			{
				tlabel = get_desk_title(t->Desk, flags, False);
				AddToMenu(
					mr, tlabel, "TITLE", False, False,
					False);
				free(tlabel);
			}
			first_desk = False;

			if (flags & SHOW_ICONNAME)
			{
				name = t->visible_icon_name;
			}
			else
			{
				name = t->visible_name;
			}

			free_name = False;
			if (!name)
			{
				name = "NULL_NAME";
			}
			else if (max_label_width > 0 &&
				 strlen(name) > max_label_width)
			{
				name = strdup(name);
				name[max_label_width] = '\0';
				free_name = True;
			}

			t_hot = safemalloc(strlen(name) + 80);
			if (use_hotkey)
			{
				/* Generate label */
				sprintf(t_hot, "&%c. ", scut);
			}
			else
			{
				*t_hot = 0;
			}
			if (!(flags & SHOW_INFONOTGEO))
			{
				strcat(t_hot, name);
			}
			if (*t_hot == 0)
			{
				strcpy(t_hot, " ");
			}

			/* Next shortcut key */
			if (scut == '9')
			{
				scut = 'A';
			}
			else if (scut == 'Z')
			{
				scut = '0';
			}
			else
			{
				scut++;
			}

			if (flags & SHOW_INFONOTGEO)
			{
				tname[0]=0;
				if (!IS_ICONIFIED(t) &&
				    !(flags & NO_DESK_NUM))
				{
					sprintf(loc,"%d:", t->Desk);
					strcat(tname,loc);
				}
				if (IS_ICONIFIED(t))
				{
					strcat(tname, "(");
				}
				strcat(t_hot,"\t");
				strcat(t_hot,tname);
				strcat(t_hot, name);
				if (IS_ICONIFIED(t))
				{
					strcat(t_hot, ")");
				}
			}
			else if (flags & SHOW_GEOMETRY)
			{
				size_borders b;

				tname[0]=0;
				if (IS_ICONIFIED(t))
				{
					strcpy(tname, "(");
				}
				if (!(flags & NO_DESK_NUM))
				{
					sprintf(loc, "%d", t->Desk);
					strcat(tname, loc);
				}
				if (flags & SHOW_SCREEN)
				{
					fscreen_scr_arg fscr;
					int scr;

					fscr.xypos.x =
						Scr.Vx + t->g.frame.x +
						t->g.frame.width / 2;
					fscr.xypos.y =
						Scr.Vy + t->g.frame.y +
						t->g.frame.height / 2;
					scr = FScreenGetScrId(
						&fscr, FSCREEN_XYPOS);
					sprintf(loc, "@%d", scr);
					strcat(tname, loc);
				}
				if (flags & SHOW_PAGE_X)
				{
					sprintf(loc, "+%d",
						(Scr.Vx + t->g.frame.x +
						 t->g.frame.width / 2) /
						Scr.MyDisplayWidth);
					strcat(tname, loc);
				}
				if (flags & SHOW_PAGE_Y)
				{
					sprintf(loc, "+%d",
						(Scr.Vy + t->g.frame.y +
						 t->g.frame.height/2) /
						Scr.MyDisplayHeight);
					strcat(tname, loc);
				}
				if (!(flags & NO_LAYER))
				{
					sprintf(loc, "(%d)",
						(get_layer(t)));
					strcat(tname, loc);
				}
				strcat(tname, ":");
				get_window_borders(t, &b);
				dheight = t->g.frame.height -
					b.total_size.height;
				dwidth = t->g.frame.width -
					b.total_size.width;

				dwidth = (dwidth - t->hints.base_width)
					  /t->orig_hints.width_inc;
				dheight = (dheight - t->hints.base_height)
					  /t->orig_hints.height_inc;

				sprintf(loc,"%d",dwidth);
				strcat(tname, loc);
				sprintf(loc,"x%d",dheight);
				strcat(tname, loc);
				if (t->g.frame.x >=0)
				{
					sprintf(loc,"+%d",t->g.frame.x);
				}
				else
				{
					sprintf(loc,"%d",t->g.frame.x);
				}
				strcat(tname, loc);
				if (t->g.frame.y >=0)
				{
					sprintf(loc,"+%d",t->g.frame.y);
				}
				else
				{
					sprintf(loc,"%d",t->g.frame.y);
				}
				strcat(tname, loc);

				if (IS_STICKY_ACROSS_PAGES(t) ||
				    IS_STICKY_ACROSS_DESKS(t))
				{
					strcat(tname, " S");
				}
				if (IS_ICONIFIED(t))
				{
					strcat(tname, ")");
				}
				strcat(t_hot,"\t");
				strcat(t_hot,tname);
			}
			ffunc = func ? func : "WindowListFunc";
			tfunc = safemalloc(strlen(ffunc) + 36);
			/* support two ways for now: window context
			 * (new) and window id param (old) */
			sprintf(tfunc, "WindowId %lu %s %lu",
				FW_W(t), ffunc, FW_W(t));
			AddToMenu(
				mr, t_hot, tfunc, False, False, False);
			free(tfunc);
			/* Add the title pixmap */
			if (FMiniIconsSupported && t->mini_icon)
			{
				MI_MINI_ICON(MR_LAST_ITEM(mr))[0] =
					t->mini_icon;
				/* increase the cache count. Otherwise the
				 * pixmap will be eventually removed from the
				 * cache by DestroyMenu */
				t->mini_icon->count++;
			}
			if (t_hot)
			{
				free(t_hot);
			}
			if (free_name)
			{
				free(name);
			}
		}
	}

	if (empty_menu)
	{
		/* force current desk title */
		tlabel = get_desk_title(desk, flags, True);
		AddToMenu(mr, tlabel, "TITLE", False, False, False);
		free(tlabel);
	}

	if (func)
	{
		free(func);
	}
	free(windowList);
	if (iconified_at_end)
	{
		free(iconifiedList);
	}
	/* Use the WindowList menu style if there is one */
	change_mr_menu_style(mr, "WindowList");

	/* Activate select_on_release style */
	old_sor_keycode = MST_SELECT_ON_RELEASE_KEY(mr);
	if (sor_keyname &&
	    (!MST_SELECT_ON_RELEASE_KEY(mr) ||
	     sor_keyname != sor_default_keyname))
	{
		MST_SELECT_ON_RELEASE_KEY(mr) =
			XKeysymToKeycode(
				dpy, FvwmStringToKeysym(dpy, sor_keyname));
	}

	memset(&mp, 0, sizeof(mp));
	mp.menu = mr;
	exc2 = exc_clone_context(exc, NULL, 0);
	mp.pexc = &exc2;
	mp.flags.has_default_action = (default_action && *default_action != 0);
	mp.flags.is_sticky = 1;
	mp.flags.is_submenu = 0;
	mp.flags.is_already_mapped = 0;
	mp.flags.is_triggered_by_keypress =
		(!default_action && exc->x.etrigger->type == KeyPress);
	mp.pops = &mops;
	mp.ret_paction = &ret_action;
	do_menu(&mp, &mret);
	/* Restore old menu style */
	MST_SELECT_ON_RELEASE_KEY(mr) = old_sor_keycode;
	if (ret_action)
	{
		free(ret_action);
	}
	DestroyMenu(mr, False, False);
	if (mret.rc == MENU_DOUBLE_CLICKED &&
	    default_action && *default_action)
	{
		execute_function(cond_rc, exc2, default_action, 0);
	}
	if (default_action != NULL)
	{
		free(default_action);
	}
	if (use_condition)
	{
		FreeConditionMask(&mask);
	}
	if (sor_keyname && sor_keyname != sor_default_keyname)
	{
		free(sor_keyname);
	}
	exc_destroy_context(exc2);

	return;
}
Ejemplo n.º 19
0
/********************************************************************
 *
 * Sets the input focus to the indicated window.
 *
 **********************************************************************/
static void DoSetFocus(Window w, FvwmWindow *Fw, Bool FocusByMouse, Bool NoWarp)
{
  extern Time lastTimestamp;
  FvwmWindow *sf;

  if (Fw && WM_TAKES_FOCUS(Fw))
  {
    send_clientmessage(dpy, w, _XA_WM_TAKE_FOCUS, lastTimestamp);
  }
  if (Fw && HAS_NEVER_FOCUS(Fw))
  {
    if (WM_TAKES_FOCUS(Fw))
    {
      /* give it a chance to take the focus itself */
      XSync(dpy, 0);
    }
    else
    {
      /* make sure the window is not hilighted */
      DrawDecorations(Fw, DRAW_ALL, False, False, None);
    }
    return;
  }
  if (Fw && !IS_LENIENT(Fw) &&
      Fw->wmhints && (Fw->wmhints->flags & InputHint) && !Fw->wmhints->input &&
      (sf = get_focus_window()) && sf->Desk == Scr.CurrentDesk)
  {
    return;
  }
  /* ClickToFocus focus queue manipulation - only performed for
   * Focus-by-mouse type focus events */
  /* Watch out: Fw may not be on the windowlist and the windowlist may be
   * empty */
  if (Fw && Fw != get_focus_window() && Fw != &Scr.FvwmRoot &&
      !IS_SCHEDULED_FOR_DESTROY(Fw))
  {
    if (FocusByMouse) /* pluck window from list and deposit at top */
    {
      /* remove Fw from list */
      if (Fw->prev)
	Fw->prev->next = Fw->next;
      if (Fw->next)
	Fw->next->prev = Fw->prev;

      /* insert Fw at start */
      Fw->next = Scr.FvwmRoot.next;
      if (Scr.FvwmRoot.next)
	Scr.FvwmRoot.next->prev = Fw;
      Scr.FvwmRoot.next = Fw;
      Fw->prev = &Scr.FvwmRoot;
    }
    else
    {
      /* move the windowlist around so that Fw is at the top */
      FvwmWindow *tmp_win;

      /* find the window on the windowlist */
      tmp_win = &Scr.FvwmRoot;
      while (tmp_win && tmp_win != Fw)
        tmp_win = tmp_win->next;

      if (tmp_win) /* the window is on the (non-zero length) windowlist */
      {
        /* make tmp_win point to the last window on the list */
        while (tmp_win->next)
          tmp_win = tmp_win->next;

        /* close the ends of the windowlist */
        tmp_win->next = Scr.FvwmRoot.next;
        Scr.FvwmRoot.next->prev = tmp_win;

        /* make Fw the new start of the list */
        Scr.FvwmRoot.next = Fw;
        /* open the closed loop windowlist */
        Fw->prev->next = NULL;
        Fw->prev = &Scr.FvwmRoot;
      }
    }
  }
  lastFocusType = FocusByMouse;

  if (!Fw && !Scr.flags.is_pointer_on_this_screen)
  {
    focus_grab_buttons(Scr.Ungrabbed, False);
    set_focus_window(NULL);
    /* DV (25-Nov-2000): Don't give the Scr.NoFocusWin the focus here. This
     * would steal the focus from the other screen's root window again. */
    /* FOCUS_SET(Scr.NoFocusWin); */
    return;
  }

  if (Fw && !NoWarp)
  {
    if (IS_ICONIFIED(Fw))
    {
      rectangle r;

      r.x = Fw->icon_g.x;
      r.y = Fw->icon_g.y;
      r.width = Fw->icon_g.width;
      r.height = Fw->icon_p_height + Fw->icon_g.height;
      if (!IsRectangleOnThisPage(&r, Fw->Desk))
      {
        Fw = NULL;
        w = Scr.NoFocusWin;
      }
    }
    else if (!IsRectangleOnThisPage(&(Fw->frame_g),Fw->Desk))
    {
      Fw = NULL;
      w = Scr.NoFocusWin;
    }
  }

  /*
      RBW - 1999/12/08 - we have to re-grab the unfocused window here for the
      MouseFocusClickRaises case also, but we can't ungrab the newly focused
      window here, or we'll never catch the raise click. For this special case,
      the newly-focused window is ungrabbed in events.c (HandleButtonPress).
  */
  if (Scr.Ungrabbed != Fw)
  {
    /* need to grab all buttons for window that we are about to unfocus */
    focus_grab_buttons(Scr.Ungrabbed, False);
  }
  /* if we do click to focus, remove the grab on mouse events that
   * was made to detect the focus change */
  if (Fw && HAS_CLICK_FOCUS(Fw))
  {
    focus_grab_buttons(Fw, True);
  }
  /* RBW - allow focus to go to a NoIconTitle icon window so
   * auto-raise will work on it... */
  if (Fw && IS_ICONIFIED(Fw))
  {
    Bool is_window_selected = False;

    if (Fw->icon_w)
    {
      w = Fw->icon_w;
      is_window_selected = True;
    }
    if ((!is_window_selected || WAS_ICON_HINT_PROVIDED(Fw)) &&
	Fw->icon_pixmap_w)
    {
      w = Fw->icon_pixmap_w;
    }
  }

  if (Fw && IS_LENIENT(Fw))
  {
    FOCUS_SET(w);
    set_focus_window(Fw);
    SET_FOCUS_CHANGE_BROADCAST_PENDING(Fw, 1);
    Scr.UnknownWinFocused = None;
  }
  else if (!Fw || !(Fw->wmhints) || !(Fw->wmhints->flags & InputHint) ||
           Fw->wmhints->input != False)
  {
    /* Window will accept input focus */
    FOCUS_SET(w);
    set_focus_window(Fw);
    if (Fw)
    {
      SET_FOCUS_CHANGE_BROADCAST_PENDING(Fw, 1);
    }
    Scr.UnknownWinFocused = None;
  }
  else if ((sf = get_focus_window()) && sf->Desk == Scr.CurrentDesk)
  {
    /* Window doesn't want focus. Leave focus alone */
    /* FOCUS_SET(Scr.Hilite->w);*/
  }
  else
  {
    FOCUS_SET(Scr.NoFocusWin);
    set_focus_window(NULL);
  }
  XSync(dpy,0);

  return;
}
Ejemplo n.º 20
0
/**************************************************************************
 *
 * Moves pointer to specified window
 *
 *************************************************************************/
static void warp_to_fvwm_window(
  XEvent *eventp, FvwmWindow *t, int warp_x, int x_unit, int warp_y, int y_unit)
{
  int dx,dy;
  int cx,cy;
  int x,y;

  if(t == (FvwmWindow *)0 || (IS_ICONIFIED(t) && t->icon_w == None))
    return;

  if(t->Desk != Scr.CurrentDesk)
  {
    goto_desk(t->Desk);
  }

  if(IS_ICONIFIED(t))
  {
    cx = t->icon_xl_loc + t->icon_g.width/2;
    cy = t->icon_g.y + t->icon_p_height + ICON_HEIGHT(t) / 2;
  }
  else
  {
    cx = t->frame_g.x + t->frame_g.width/2;
    cy = t->frame_g.y + t->frame_g.height/2;
  }

  dx = (cx + Scr.Vx) / Scr.MyDisplayWidth * Scr.MyDisplayWidth;
  dy = (cy + Scr.Vy) / Scr.MyDisplayHeight * Scr.MyDisplayHeight;

  MoveViewport(dx,dy,True);

  if(IS_ICONIFIED(t))
  {
    x = t->icon_xl_loc + t->icon_g.width / 2;
    y = t->icon_g.y + t->icon_p_height + ICON_HEIGHT(t) / 2;
  }
  else
  {
    if (x_unit != Scr.MyDisplayWidth && warp_x >= 0)
      x = t->frame_g.x + warp_x;
    else if (x_unit != Scr.MyDisplayWidth)
      x = t->frame_g.x + t->frame_g.width + warp_x;
    else if (warp_x >= 0)
      x = t->frame_g.x + (t->frame_g.width - 1) * warp_x / 100;
    else
      x = t->frame_g.x + (t->frame_g.width - 1) * (100 + warp_x) / 100;

    if (y_unit != Scr.MyDisplayHeight && warp_y >= 0)
      y = t->frame_g.y + warp_y;
    else if (y_unit != Scr.MyDisplayHeight)
      y = t->frame_g.y + t->frame_g.height + warp_y;
    else if (warp_y >= 0)
      y = t->frame_g.y + (t->frame_g.height - 1) * warp_y / 100;
    else
      y = t->frame_g.y + (t->frame_g.height - 1) * (100 + warp_y) / 100;
  }
  XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, x, y);
  SetPointerEventPosition(eventp, x, y);
  RaiseWindow(t);

  /* If the window is still not visible, make it visible! */
  if (t->frame_g.x + t->frame_g.width  < 0 ||
      t->frame_g.y + t->frame_g.height < 0 ||
      t->frame_g.x >= Scr.MyDisplayWidth   ||
      t->frame_g.y >= Scr.MyDisplayHeight)
  {
    SetupFrame(t, 0, 0, t->frame_g.width, t->frame_g.height, False);
    XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, 2,2);
    SetPointerEventPosition(eventp, 2, 2);
  }
}
Ejemplo n.º 21
0
void do_save_command(FILE *out, struct list *t, int *curdesk,
                                int emit_wait, int *isfirstline)
{
  char tname[200],loc[30];
  char **command_list;
  int dwidth,dheight,xtermline = 0;
  int x1,x2,y1,y2,i,command_count;
  long tVx, tVy;

  tname[0]=0;

  x1 = t->frame_x;
  x2 = ScreenWidth - x1 - t->frame_width - 2;
  if(x2 < 0)
    x2 = 0;
  y1 = t->frame_y;
  y2 = ScreenHeight - y1 -  t->frame_height - 2;
  if(y2 < 0)
    y2 = 0;
  dheight = t->frame_height - t->title_height - 2*t->boundary_width;
  dwidth = t->frame_width - 2*t->boundary_width;
  dwidth -= t->base_width ;
  dheight -= t->base_height ;
  dwidth /= t->width_inc;
  dheight /= t->height_inc;

  if (IS_STICKY(t))
  {
    tVx = 0;
    tVy = 0;
  }
  else
  {
    tVx = Vx;
    tVy = Vy;
  }
  sprintf(tname,"%dx%d",dwidth,dheight);
  if ((t->gravity == EastGravity) ||
      (t->gravity == NorthEastGravity) ||
      (t->gravity == SouthEastGravity))
    sprintf(loc,"-%d",x2);
  else
    sprintf(loc,"+%d",x1+(int)tVx);
  strcat(tname, loc);

  if((t->gravity == SouthGravity)||
     (t->gravity == SouthEastGravity)||
     (t->gravity == SouthWestGravity))
    sprintf(loc,"-%d",y2);
  else
    sprintf(loc,"+%d",y1+(int)tVy);
  strcat(tname, loc);

  if ( XGetCommand( dpy, t->id, &command_list, &command_count ) )
  {
    if (*curdesk != t->desk)
    {
      fprintf( out, "%s\t\"I\" Desk 0 %ld\n", *isfirstline ? "" : "+",
	       t->desk);
      fflush ( out );
      if (*isfirstline) *isfirstline = 0;
      *curdesk = t->desk;
    }

    fprintf( out, "%s\t\t\"I\" Exec ",  *isfirstline ? "" : "+");
    if (*isfirstline) *isfirstline = 0;
    fflush ( out );
    for (i=0; i < command_count; i++)
    {
      if ( strncmp( "-geo", command_list[i], 4) == 0)
      {
	i++;
	continue;
      }
      if ( strncmp( "-ic", command_list[i], 3) == 0)
	continue;
      if ( strncmp( "-display", command_list[i], 8) == 0)
      {
	i++;
	continue;
      }
      write_string(out,command_list[i]);
      fflush ( out );
      if(strstr(command_list[i], "xterm"))
      {
	fprintf( out, "-geometry %s ", tname );
	if (IS_ICONIFIED(t))
	  fprintf(out, "-ic ");
	xtermline = 1;
	fflush ( out );
      }
    }
    if ( command_count > 0 )
    {
      if ( xtermline == 0 )
      {
	if (IS_ICONIFIED(t))
	  fprintf(out, "-ic ");
	fprintf( out, "-geometry %s &\n", tname);
      }
      else
      {
	fprintf( out, "&\n");
      }
    }
    if (emit_wait) {
      if (t->name)
	fprintf( out, "+\t\t\"I\" Wait %s\n", t->name);
      else fprintf( out, "+\t\t\"I\" Wait %s\n", command_list[0]);
      fflush( out );
    }
    XFreeStringList( command_list );
    xtermline = 0;
  }
}