示例#1
0
/**
 * ww_filter_user_windows
 * @windows: List of %WnckWindow<!-- -->s to filter
 * @current_workspace: Only use windows on this workspace. %NULL indicates
 *                     that all windows should be used
 *
 * Extract the user controlled visible windows from a %GList of
 * %WnckWindows.
 *
 * Return value: A newly allocated list containing only windows that are 
 * not minimized, shaded, or wnck_window_skip_task_list() on the current
 * workspace.
 */
GList*
ww_filter_user_windows (GList * windows, WnckWorkspace *current_workspace)
{
	GList       *next;
	GList       *result;
	WnckWindow  *win;
	WnckWorkspace *win_ws;

	result = NULL;    
	
	for (next = windows; next; next = next->next)
	{
		win = WNCK_WINDOW(next->data);
		if (!wnck_window_is_skip_tasklist (win) &&
			!wnck_window_is_minimized (win) &&
			!wnck_window_is_maximized (win) &&
			!wnck_window_is_shaded (win))
		{
			win_ws = wnck_window_get_workspace (win);
			
			if (current_workspace == NULL
			    || (win_ws == current_workspace
			        && wnck_window_is_in_viewport(win, current_workspace))
			    || win_ws == NULL)	
				result = g_list_append (result, win);
				
		}
	}
	
	return result;
}
示例#2
0
static GtkWidget *
wnck_selector_create_window (WnckSelector *selector, WnckWindow *window)
{
  GtkWidget *item;
  GtkWidget *image;
  char *name;

  name = _wnck_window_get_name_for_display (window, FALSE, TRUE);

  item = wnck_selector_item_new (selector, name, window);

  g_free (name);

  image = gtk_image_new ();

  wnck_selector_set_window_icon (selector, image, window, TRUE);

  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
                                 GTK_WIDGET (image));
  gtk_widget_show (image);

  g_signal_connect_swapped (item, "activate",
                            G_CALLBACK (wnck_selector_activate_window),
                            window);

  if (!wnck_window_is_skip_tasklist (window))
    gtk_widget_show (item);

  g_object_set_data (G_OBJECT (item), "wnck-selector-window", window);

  return item;
}
示例#3
0
static void
wnck_selector_window_state_changed (WnckWindow *window,
                                    WnckWindowState changed_mask,
                                    WnckWindowState new_state,
                                    WnckSelector *selector)
{
  window_hash_item *item;
  char *window_name;

  if (!
      (changed_mask &
       (WNCK_WINDOW_STATE_MINIMIZED | WNCK_WINDOW_STATE_SHADED |
        WNCK_WINDOW_STATE_SKIP_TASKLIST |
        WNCK_WINDOW_STATE_DEMANDS_ATTENTION |
        WNCK_WINDOW_STATE_URGENT)))
    return;

  item = NULL;
  window_name = NULL;

  if (!selector->priv->window_hash)
	  return;

  item = g_hash_table_lookup (selector->priv->window_hash, window);
  if (item == NULL)
    return;

  if (changed_mask & WNCK_WINDOW_STATE_SKIP_TASKLIST)
    {
      if (wnck_window_is_skip_tasklist (window))
        gtk_widget_hide (item->item);
      else
        gtk_widget_show (item->item);

      wnck_selector_make_menu_consistent (selector);

      gtk_menu_reposition (GTK_MENU (selector->priv->menu));
    }

  if (changed_mask &
      (WNCK_WINDOW_STATE_DEMANDS_ATTENTION | WNCK_WINDOW_STATE_URGENT))
    {
      if (wnck_window_or_transient_needs_attention (window))
	_make_gtk_label_bold (GTK_LABEL (item->label));
      else
	_make_gtk_label_normal (GTK_LABEL (item->label));
    }

  if (changed_mask &
      (WNCK_WINDOW_STATE_MINIMIZED | WNCK_WINDOW_STATE_SHADED))
    {
      window_name = _wnck_window_get_name_for_display (window, FALSE, TRUE);
      gtk_label_set_text (GTK_LABEL (item->label), window_name);
      g_free (window_name);
    }
}
示例#4
0
static void
task_item_set_visibility (TaskItem *item)
{
  WnckScreen *screen;
  WnckWindow *window;
  WnckWorkspace *workspace;

  g_return_if_fail (TASK_IS_ITEM (item));
  
  TaskItemPrivate *priv = item->priv;
  
  if (!WNCK_IS_WINDOW (priv->window))
  {
    gtk_widget_hide (GTK_WIDGET (item));
    return;
  }
  
  window = priv->window;
  
  screen = priv->screen;
  workspace = wnck_screen_get_active_workspace (screen);
  
  gboolean show_all = task_list_get_show_all_windows (TASK_LIST (task_list_get_default ()));
  gboolean show_window = FALSE;
  
  if (!wnck_window_is_skip_tasklist (window))
  {
    if (wnck_workspace_is_virtual (workspace))
    {
      show_window = wnck_window_is_in_viewport (window, workspace);
    }
    else
    {
      show_window = wnck_window_is_on_workspace (window, workspace);
    }
    show_window = show_window || show_all;
  }
  
  if (show_window)
  {
    gtk_widget_show (GTK_WIDGET (item));
  }
  else
  {
    gtk_widget_hide (GTK_WIDGET (item));
  }
}
示例#5
0
static gboolean
wnck_selector_scroll_event (GtkWidget      *widget,
                            GdkEventScroll *event)
{
  WnckSelector *selector;
  WnckScreen *screen;
  WnckWorkspace *workspace;
  GList *windows_list;
  GList *l;
  WnckWindow *window;
  WnckWindow *previous_window;
  gboolean should_activate_next_window;

  selector = WNCK_SELECTOR (widget);

  screen = wnck_selector_get_screen (selector);
  workspace = wnck_screen_get_active_workspace (screen);
  windows_list = wnck_screen_get_windows (screen);
  windows_list = g_list_sort (windows_list, wnck_selector_windows_compare);

  /* Walk through the list of windows until we find the active one
   * (considering only those windows on the same workspace).
   * Then, depending on whether we're scrolling up or down, activate the next
   * window in the list (if it exists), or the previous one.
   */
  previous_window = NULL;
  should_activate_next_window = FALSE;
  for (l = windows_list; l; l = l->next)
    {
      window = WNCK_WINDOW (l->data);

      if (wnck_window_is_skip_tasklist (window))
        continue;

      if (workspace && !wnck_window_is_pinned (window) &&
          wnck_window_get_workspace (window) != workspace)
        continue;

      if (should_activate_next_window)
        {
          wnck_window_activate_transient (window, event->time);
          return TRUE;
        }

      if (wnck_window_is_active (window))
        {
          switch (event->direction)
            {
              case GDK_SCROLL_UP:
                if (previous_window != NULL)
                  {
                    wnck_window_activate_transient (previous_window,
                                                    event->time);
                    return TRUE;
                  }
              break;

              case GDK_SCROLL_DOWN:
                should_activate_next_window = TRUE;
              break;

              case GDK_SCROLL_LEFT:
              case GDK_SCROLL_RIGHT:
                /* We ignore LEFT and RIGHT scroll events. */
              break;

              case GDK_SCROLL_SMOOTH:
              break;

              default:
                g_assert_not_reached ();
            }
        }

      previous_window = window;
    }

  return TRUE;
}
示例#6
0
static void
on_active_window_changed (WnckScreen *screen,
                          WnckWindow *old_window,
                          TaskTitle  *title)
{
    g_return_if_fail (TASK_IS_TITLE (title));
    WnckWindow *act_window = wnck_screen_get_active_window (screen);
    WnckWindowType type = WNCK_WINDOW_NORMAL;
    TaskTitlePrivate *priv = title->priv;

    if (act_window)
        type = wnck_window_get_window_type (act_window);

    disconnect_window (title);
    // Depending on the type and state of the window we adjust the title
    if(WNCK_IS_WINDOW(act_window)) {
        if(type == WNCK_WINDOW_DESKTOP) {
            /* The current window is the desktop so we show the home title if
             *  the user has configured this, otherwise we hide the title */
            if (window_picker_applet_get_show_home_title (priv->windowPickerApplet)) {
                show_home_title(title);
            } else {
                hide_title (title);
            }
        } else if(wnck_window_is_skip_tasklist (act_window)
            && type != WNCK_WINDOW_DESKTOP)
        {
            /* The current window is not in the task list, we dont change the
             * current title. */
            return;
        } else if(type == WNCK_WINDOW_DOCK
            || type == WNCK_WINDOW_SPLASHSCREEN
            || type == WNCK_WINDOW_MENU)
        {
            return;
        } else { //for all other types
            if(wnck_window_is_maximized (act_window) && window_picker_applet_get_show_application_title (priv->windowPickerApplet)) {
                //show normal title of window
                gtk_label_set_text (GTK_LABEL (priv->label),
                    wnck_window_get_name (act_window));
                gtk_image_set_from_icon_name (GTK_IMAGE (priv->button_image),
                        "window-close", GTK_ICON_SIZE_MENU);
                gtk_widget_set_tooltip_text (GTK_WIDGET (title),
                     wnck_window_get_name (act_window));
                gtk_widget_set_tooltip_text (priv->button, _("Close window"));
                g_signal_connect (act_window, "name-changed",
                    G_CALLBACK (on_name_changed), title);
                g_signal_connect_after (act_window, "state-changed",
                    G_CALLBACK (on_state_changed), title);
                gtk_widget_show (priv->grid);
                priv->window = act_window;
            } else {
                hide_title (title); //only show the title for maximized windows
            }
        }
    } else { //its not a window
        if (task_list_get_desktop_visible (TASK_LIST (window_picker_applet_get_tasks (priv->windowPickerApplet)))
                && window_picker_applet_get_show_home_title (priv->windowPickerApplet))
        {
            show_home_title(title);
        } else { //reset the task title and hide it
            hide_title (title);
        }
    }

    gtk_widget_queue_draw (GTK_WIDGET (title));
}
示例#7
0
/**
 * ww_find_neighbour
 * @screen:
 * @windows:
 * @active:
 * @direction:
 *
 * Return value: The neighbouring window from @windows in the given direction
 *               or %NULL in case no window is found or @active is %NULL
 */
WnckWindow*
ww_find_neighbour (WnckScreen	*screen,
                   GList		*windows,
                   WnckWindow	*active,
                   WwDirection	direction)
{
	WnckWindow	*neighbour;
	GList		*next;
	int			ax, ay, aw, ah; /* active window geometry */
	int			wx, wy; /* geometry for currently checked window */ 
	int			nx, ny; /* geometry of neighbour */
	double		wdist, ndist; /* distance to active window */

	neighbour = NULL;
	
	g_return_val_if_fail (WNCK_IS_SCREEN(screen), NULL);
	
	if (g_list_length(windows) == 0)
    {
		return NULL;
    }
	
	/* If there is no active window, do nothing */
	if (active == NULL
		|| wnck_window_is_skip_tasklist (active)) {
		g_debug ("No active window");
		return NULL;
	}

	nx = ny = 0;
	ndist = 100000;

	wnck_window_get_geometry (active, &ax, &ay, &aw, &ah);
	g_debug("Active window '%s' (%d, %d) @ %d x %d",
	        wnck_window_get_name (active), ax, ay, aw, ah);

	/* Set ax and ay to the center of grav. for active */
	ww_window_center (active, &ax, &ay);
	
	if ( direction == LEFT )
	{
		for ( next = windows; next; next = next->next )
		{
			ww_window_center (WNCK_WINDOW (next->data), &wx, &wy);
			wdist = ww_y_weighted_distance (wx, wy, ax, ay);
			if ( wx < ax )
			{
				if ( wdist < ndist )
				{
					neighbour = WNCK_WINDOW (next->data);
					ndist = wdist;
				}
			} 
		}
	}
	else if ( direction == RIGHT )
	{
		for ( next = windows; next; next = next->next )
		{
			ww_window_center (WNCK_WINDOW (next->data), &wx, &wy);
			wdist = ww_y_weighted_distance (wx, wy, ax, ay);
			if ( wx > ax )
			{
				if ( wdist < ndist )
				{
					neighbour = WNCK_WINDOW (next->data);
					ndist = wdist;
				}
			}
		}
	}
	else if ( direction == DOWN )
	{
		for ( next = windows; next; next = next->next )
		{
			ww_window_center (WNCK_WINDOW (next->data), &wx, &wy);
			wdist = ww_x_weighted_distance (wx, wy, ax, ay);
			if ( wy > ay )
			{
				if ( wdist < ndist )
				{
					neighbour = WNCK_WINDOW (next->data);
					ndist = wdist;
				}
			}
		}
	}
	else if ( direction == UP )
	{
		for ( next = windows; next; next = next->next )
		{
			ww_window_center (WNCK_WINDOW (next->data), &wx, &wy);
			wdist = ww_x_weighted_distance (wx, wy, ax, ay);
			if ( wy < ay )
			{
				if ( wdist < ndist )
				{
					neighbour = WNCK_WINDOW (next->data);
					ndist = wdist;
				}
			}
		}
	}

	if (neighbour)
		g_debug ("Found neighbour '%s'",
		         wnck_window_get_name (neighbour));
	
	return neighbour; 
}