/* The active workspace has changed */ static void _xfdashboard_workspace_selector_on_active_workspace_changed(XfdashboardWorkspaceSelector *self, XfdashboardWindowTrackerWorkspace *inPrevWorkspace, gpointer inUserData) { XfdashboardWorkspaceSelectorPrivate *priv; XfdashboardLiveWorkspace *liveWorkspace; XfdashboardWindowTrackerWorkspace *workspace; g_return_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(self)); priv=self->priv; /* Unmark previous workspace */ if(inPrevWorkspace) { liveWorkspace=_xfdashboard_workspace_selector_find_actor_for_workspace(self, inPrevWorkspace); if(liveWorkspace) xfdashboard_stylable_remove_pseudo_class(XFDASHBOARD_STYLABLE(liveWorkspace), "active"); priv->activeWorkspace=NULL; } /* Mark new active workspace */ workspace=xfdashboard_window_tracker_get_active_workspace(priv->windowTracker); if(workspace) { priv->activeWorkspace=workspace; liveWorkspace=_xfdashboard_workspace_selector_find_actor_for_workspace(self, priv->activeWorkspace); if(liveWorkspace) xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(liveWorkspace), "active"); } }
/** * xfdashboard_create_app_context: * @inWorkspace: The workspace where to place application windows on or %NULL * * Returns a #GAppLaunchContext suitable for launching applications on the * given display and workspace by GIO. * * If @inWorkspace is specified it sets workspace on which applications will * be launched when using this context when running under a window manager * that supports multiple workspaces. * * When the workspace is not specified it is up to the window manager to pick * one, typically it will be the current workspace. * * Return value: (transfer full): the newly created #GAppLaunchContext or %NULL * in case of an error. Use g_object_unref() to free return value. */ GAppLaunchContext* xfdashboard_create_app_context(XfdashboardWindowTrackerWorkspace *inWorkspace) { GdkAppLaunchContext *context; const ClutterEvent *event; XfdashboardWindowTracker *tracker; g_return_val_if_fail(inWorkspace==NULL || XFDASHBOARD_IS_WINDOW_TRACKER_WORKSPACE(inWorkspace), NULL); /* Get last event for timestamp */ event=clutter_get_current_event(); /* Get active workspace if not specified */ if(!inWorkspace) { tracker=xfdashboard_window_tracker_get_default(); inWorkspace=xfdashboard_window_tracker_get_active_workspace(tracker); g_object_unref(tracker); } /* Create and set up application context to use either the workspace specified * or otherwise current active workspace. We will even set the current active * explicitly to launch the application on current workspace even if user changes * workspace in the time between launching application and showing first window. */ context=gdk_display_get_app_launch_context(gdk_display_get_default()); if(event) gdk_app_launch_context_set_timestamp(context, clutter_event_get_time(event)); gdk_app_launch_context_set_desktop(context, xfdashboard_window_tracker_workspace_get_number(inWorkspace)); /* Return application context */ return(G_APP_LAUNCH_CONTEXT(context)); }
/* Object initialization * Create private structure and set up default values */ static void xfdashboard_workspace_selector_init(XfdashboardWorkspaceSelector *self) { XfdashboardWorkspaceSelectorPrivate *priv; ClutterRequestMode requestMode; GList *workspaces; XfdashboardWindowTrackerWorkspace *workspace; priv=self->priv=XFDASHBOARD_WORKSPACE_SELECTOR_GET_PRIVATE(self); /* Set up default values */ priv->windowTracker=xfdashboard_window_tracker_get_default(); priv->activeWorkspace=NULL; priv->spacing=0.0f; priv->orientation=DEFAULT_ORIENTATION; priv->maxSize=DEFAULT_MAX_SIZE; priv->maxFraction=DEFAULT_MAX_FRACTION; priv->usingFraction=DEFAULT_USING_FRACTION; /* Set up this actor */ clutter_actor_set_reactive(CLUTTER_ACTOR(self), TRUE); requestMode=(priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL ? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH : CLUTTER_REQUEST_WIDTH_FOR_HEIGHT); clutter_actor_set_request_mode(CLUTTER_ACTOR(self), requestMode); /* Connect signals */ g_signal_connect(self, "scroll-event", G_CALLBACK(_xfdashboard_workspace_selector_on_scroll_event), NULL); g_signal_connect_swapped(priv->windowTracker, "workspace-added", G_CALLBACK(_xfdashboard_workspace_selector_on_workspace_added), self); g_signal_connect_swapped(priv->windowTracker, "workspace-removed", G_CALLBACK(_xfdashboard_workspace_selector_on_workspace_removed), self); g_signal_connect_swapped(priv->windowTracker, "active-workspace-changed", G_CALLBACK(_xfdashboard_workspace_selector_on_active_workspace_changed), self); /* If we there are already workspace known add them to this actor */ workspaces=xfdashboard_window_tracker_get_workspaces(priv->windowTracker); if(workspaces) { for(; workspaces; workspaces=g_list_next(workspaces)) { workspace=(XfdashboardWindowTrackerWorkspace*)workspaces->data; _xfdashboard_workspace_selector_on_workspace_added(self, workspace, NULL); } } /* If active workspace is already available then set it in this actor */ workspace=xfdashboard_window_tracker_get_active_workspace(priv->windowTracker); if(workspace) { _xfdashboard_workspace_selector_on_active_workspace_changed(self, NULL, NULL); } }