コード例 #1
0
ファイル: workspace.c プロジェクト: Frenzie/smartswitcher
static gboolean
on_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
{
  SSWorkspace *workspace;
  SSScreen *screen;
  SSDragAndDrop *dnd;
  gboolean shifted;
  gboolean ctrled;
  GList *i;
  SSWindow *window;

  workspace = (SSWorkspace *) data;
  screen = workspace->screen;
  dnd = screen->drag_and_drop;

  shifted = ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK);
  ctrled  = ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK);

  if (dnd->is_dragging) {
    if (dnd->drag_workspace != NULL) {
      // This simple if clause is to avoid unnecessary work.
      if (dnd->drag_workspace != workspace) {
        for (i = workspace->windows; i; i = i->next) {
          // TODO - something weird is going on when dragging a workspace with
          // multiple windows - only the first one is being moved. Perhaps we're
          // modifying the list whilst iterating over it?
          window = (SSWindow *) i->data;
          ss_window_move_to_workspace (window, dnd->drag_workspace);
        }
      }
      if (window_manager_uses_viewports) {
        wnck_screen_move_viewport (screen->wnck_screen, screen->screen_width * dnd->drag_workspace->viewport, 0);
      } else {
        wnck_workspace_activate (dnd->drag_workspace->wnck_workspace, event->time);
      }
    }
  } else {
    // It's a plain old click, not a drag.
    ss_screen_change_active_workspace_to (workspace->screen,
      workspace->wnck_workspace, workspace->viewport, shifted, ctrled, event->time);
  }

  ss_draganddrop_on_release (dnd);
  return TRUE;
}
コード例 #2
0
/* FIXME: this will not work with wm using large desktops and viewports
   to implement their workspaces.*/
bool WorkspacesInfo::changeCurrent(int newWorkspace)
{
    WnckScreen *screen = wnck_screen_get_default();
    WnckWorkspace *workspace = wnck_screen_get_workspace(screen, newWorkspace);
    if (workspace == NULL) {
        UQ_WARNING << "Requested activation workspace" << newWorkspace << " but it does not exist.";
        return false;
    }

    if (newWorkspace == current()) {
        return true;
    }

    /* This function will ask the WM to change workspace. However we have no way to know
       if it succeeds or fails. To know that we can only wait to be notified of the workspace
       to actually change, or decide we waited too much and proceed anyway */
    wnck_workspace_activate(workspace, CurrentTime);
    return SignalWaiter().waitForSignal(this, SIGNAL(currentChanged(int)), 50);
}
コード例 #3
0
ファイル: selector.c プロジェクト: Distrotech/libwnck
static void
wnck_selector_activate_window (WnckWindow *window)
{
  WnckWorkspace *workspace;
  guint32 timestamp;

  /* We're in an activate callback, so gtk_get_current_time() works... */
  timestamp = gtk_get_current_event_time ();

  /* FIXME: THIS IS SICK AND WRONG AND BUGGY.  See the end of
   * http://mail.gnome.org/archives/wm-spec-list/2005-July/msg00032.html
   * There should only be *one* activate call.
   */
  workspace = wnck_window_get_workspace (window);
  if (workspace)
    wnck_workspace_activate (workspace, timestamp);

  wnck_window_activate (window, timestamp);
}
コード例 #4
0
static void
window_item_activated (GtkWidget * widget,
                       WnckWindow* window)
{
  WnckWorkspace* workspace = wnck_window_get_workspace (window);

  if (workspace && wnck_screen_get_active_workspace (wnck_window_get_screen (window)) != workspace)
    {
      wnck_workspace_activate (workspace, gtk_get_current_event_time ());
    }

  if (wnck_screen_get_active_window (wnck_window_get_screen (window)) == window)
    {
      wnck_window_minimize (window);
    }
  else
    {
      wnck_window_activate_transient (window, gtk_get_current_event_time ());
    }
}
コード例 #5
0
ファイル: script_functions.c プロジェクト: kba/devilspie2
/**
 * Makes a workspace the active one
 */
int c_change_workspace(lua_State *lua)
{
	int top = lua_gettop(lua);
	GTimeVal timestamp;

	if (top != 1) {
		luaL_error(lua,"change_workspace: %s", one_indata_expected_error);
		return 0;
	}

	int type = lua_type(lua, 1);

	if (type!=LUA_TNUMBER) {
		luaL_error(lua,"change_workspace: %s", number_expected_as_indata_error);
		return 0;
	}

	int number = lua_tonumber(lua, 1);

	WnckWindow *window = get_current_window();
	if (window) {
		WnckScreen *screen;
		WnckWorkspace *workspace;

		screen = wnck_window_get_screen(window);
		workspace = wnck_screen_get_workspace(screen, number-1);

		if (!workspace) {
			g_warning(_("Workspace number %d does not exist!"), number);
		}

		g_get_current_time(&timestamp);
		if (!devilspie2_emulate) {
			wnck_workspace_activate(workspace, timestamp.tv_sec);
		}
	}

	lua_pushboolean(lua, TRUE);

	return 1;
}
コード例 #6
0
ファイル: task-item.c プロジェクト: Tecmie/mate-netbook
static gboolean 
on_task_item_button_released (GtkWidget      *widget, 
                              GdkEventButton *event,
                              TaskItem       *item)
{
  WnckWindow *window;
  WnckScreen *screen;
  WnckWorkspace *workspace;
  TaskItemPrivate *priv;
  
  g_return_val_if_fail (TASK_IS_ITEM (item), TRUE);
  
  priv = item->priv;
  window = priv->window;
  
  g_return_val_if_fail (WNCK_IS_WINDOW (window), TRUE);
  
  screen = priv->screen;
  workspace = wnck_window_get_workspace (window);
  
  if (event->button == 1)
  {
  
    if (WNCK_IS_WORKSPACE (workspace) && workspace != wnck_screen_get_active_workspace (screen))
    {
      wnck_workspace_activate (workspace, GDK_CURRENT_TIME);
    }
    if (wnck_window_is_active (window))
    {
      wnck_window_minimize (window);
    }
    else
    {
      wnck_window_activate (window, GDK_CURRENT_TIME);
    }
  }
  return TRUE;
}
コード例 #7
0
static gboolean
applet_scroll (PanelApplet    *applet,
               GdkEventScroll *event,
               PagerData      *pager)
{
	WnckScreen *screen;
	int         index;
	int         n_workspaces;
	int         n_columns;
	int         in_last_row;
	
	if (event->type != GDK_SCROLL)
		return FALSE;

	screen         = wncklet_get_screen (GTK_WIDGET (applet));
	index          = wnck_workspace_get_number (wnck_screen_get_active_workspace (screen));
	n_workspaces   = wnck_screen_get_workspace_count (screen);
	n_columns      = n_workspaces / pager->n_rows;
	if (n_workspaces % pager->n_rows != 0)
		n_columns++;
	in_last_row    = n_workspaces % n_columns;
	
	switch (event->direction) {
	case GDK_SCROLL_DOWN:
		if (index + n_columns < n_workspaces)
			index += n_columns;
		else if ((index < n_workspaces - 1
			  && index + in_last_row != n_workspaces - 1) ||
			 (index == n_workspaces - 1
			  && in_last_row != 0))
			index = (index % n_columns) + 1;
		break;
		
	case GDK_SCROLL_RIGHT:
		if (index < n_workspaces - 1)
			index++;
		break;
		
	case GDK_SCROLL_UP:
		if (index - n_columns >= 0)
			index -= n_columns;
		else if (index > 0)
			index = ((pager->n_rows - 1) * n_columns) + (index % n_columns) - 1;
			if (index >= n_workspaces)
				index -= n_columns;
		break;

	case GDK_SCROLL_LEFT:
		if (index > 0)
			index--;
		break;
	default:
		g_assert_not_reached ();
		break;
	}

	wnck_workspace_activate (wnck_screen_get_workspace (screen, index),
				 event->time);
	
	return TRUE;
}
コード例 #8
0
static gboolean applet_scroll(MatePanelApplet* applet, GdkEventScroll* event, PagerData* pager)
{
	GdkScrollDirection absolute_direction;
	int index;
	int n_workspaces;
	int n_columns;
	int in_last_row;

	if (event->type != GDK_SCROLL)
		return FALSE;

	index = wnck_workspace_get_number(wnck_screen_get_active_workspace(pager->screen));
	n_workspaces = wnck_screen_get_workspace_count(pager->screen);
	n_columns = n_workspaces / pager->n_rows;

	if (n_workspaces % pager->n_rows != 0)
		n_columns++;

	in_last_row    = n_workspaces % n_columns;

	absolute_direction = event->direction;

	if (gtk_widget_get_direction(GTK_WIDGET(applet)) == GTK_TEXT_DIR_RTL)
	{
		switch (event->direction)
		{
			case GDK_SCROLL_DOWN:
			case GDK_SCROLL_UP:
				break;
			case GDK_SCROLL_RIGHT:
				absolute_direction = GDK_SCROLL_LEFT;
				break;
			case GDK_SCROLL_LEFT:
				absolute_direction = GDK_SCROLL_RIGHT;
				break;
		}
	}

	switch (absolute_direction)
	{
		case GDK_SCROLL_DOWN:
			if (index + n_columns < n_workspaces)
			{
				index += n_columns;
			}
			else if (pager->wrap_workspaces && index == n_workspaces - 1)
			{
				index = 0;
			}
			else if ((index < n_workspaces - 1 && index + in_last_row != n_workspaces - 1) || (index == n_workspaces - 1 && in_last_row != 0))
			{
				index = (index % n_columns) + 1;
			}
			break;

		case GDK_SCROLL_RIGHT:
			if (index < n_workspaces - 1)
			{
				index++;
			}
			else if (pager->wrap_workspaces)
			{
			        index = 0;
			}
			break;

		case GDK_SCROLL_UP:
			if (index - n_columns >= 0)
			{
				index -= n_columns;
			}
			else if (index > 0)
			{
				index = ((pager->n_rows - 1) * n_columns) + (index % n_columns) - 1;
			}
			else if (pager->wrap_workspaces)
			{
				index = n_workspaces - 1;
			}

			if (index >= n_workspaces)
				index -= n_columns;
			break;

		case GDK_SCROLL_LEFT:
			if (index > 0)
			{
				index--;
			}
			else if (pager->wrap_workspaces)
			{
				index = n_workspaces - 1;
			}
			break;
		default:
			g_assert_not_reached();
			break;
	}

	wnck_workspace_activate(wnck_screen_get_workspace(pager->screen, index), event->time);

	return TRUE;
}