static int cinnamon_app_compare_windows (gconstpointer a, gconstpointer b, gpointer datap) { MetaWindow *win_a = (gpointer)a; MetaWindow *win_b = (gpointer)b; CompareWindowsData *data = datap; gboolean ws_a, ws_b; gboolean vis_a, vis_b; ws_a = meta_window_get_workspace (win_a) == data->active_workspace; ws_b = meta_window_get_workspace (win_b) == data->active_workspace; if (ws_a && !ws_b) return -1; else if (!ws_a && ws_b) return 1; vis_a = meta_window_showing_on_its_workspace (win_a); vis_b = meta_window_showing_on_its_workspace (win_b); if (vis_a && !vis_b) return -1; else if (!vis_a && vis_b) return 1; return meta_window_get_user_time (win_b) - meta_window_get_user_time (win_a); }
void mnb_zones_preview_add_window (MnbZonesPreview *preview, MetaWindow *window) { ClutterActor *clone; ClutterActor *group; MetaRectangle rect; MetaWorkspace *workspace; /* TODO: Determine if we need to add a weak reference on the window * in case it gets destroyed during the animation. * I'd have thought that the clone's reference on the texture * would be enough that this wouldn't be necessary. * * We do; while the clone's reference is enough to keep the texture about, * it is not enough to make it possible to map the clone once the texture * has been unparented. */ workspace = meta_window_get_workspace (window); group = mnb_zones_preview_get_workspace_group (preview, meta_workspace_index(workspace)); clone = clutter_clone_new (CLUTTER_ACTOR(window)); g_signal_connect (window, "destroy", G_CALLBACK (mnb_zones_preview_mcw_destroy_cb), clone); g_signal_connect (clone, "destroy", G_CALLBACK (mnb_zones_preview_clone_destroy_cb), window); meta_window_get_outer_rect (window, &rect); clutter_actor_set_position (clone, rect.x, rect.y); clutter_actor_add_child (CLUTTER_ACTOR (group), clone); }
void meta_stack_lower (MetaStack *stack, MetaWindow *window) { GList *l; int min_stack_position = window->stack_position; MetaWorkspace *workspace; stack_ensure_sorted (stack); workspace = meta_window_get_workspace (window); for (l = stack->sorted; l; l = l->next) { MetaWindow *w = (MetaWindow *) l->data; if (meta_window_located_on_workspace (w, workspace) && w->stack_position < min_stack_position) min_stack_position = w->stack_position; } if (min_stack_position == window->stack_position) return; meta_window_set_stack_position_no_sync (window, min_stack_position); stack_sync_to_xserver (stack); meta_stack_update_window_tile_matches (stack, window->screen->active_workspace); }
gboolean cinnamon_app_is_on_workspace (CinnamonApp *app, MetaWorkspace *workspace) { GSList *iter; if (cinnamon_app_get_state (app) == CINNAMON_APP_STATE_STARTING) { if (app->started_on_workspace == -1 || meta_workspace_index (workspace) == app->started_on_workspace) return TRUE; else return FALSE; } if (app->running_state == NULL) return FALSE; for (iter = app->running_state->windows; iter; iter = iter->next) { if (meta_window_get_workspace (iter->data) == workspace) return TRUE; } return FALSE; }
static gboolean collect_transients_on_workspace (MetaWindow *window, gpointer datap) { CollectTransientsData *data = datap; if (data->workspace && meta_window_get_workspace (window) != data->workspace) return TRUE; *data->transients = g_slist_prepend (*data->transients, window); return TRUE; }
/* The basic idea here is that when we're targeting a window, * if it has transients we want to pick the most recent one * the user interacted with. * This function makes raising GEdit with the file chooser * open work correctly. */ static MetaWindow * find_most_recent_transient_on_same_workspace (MetaDisplay *display, MetaWindow *reference) { GSList *transients, *transients_sorted, *iter; MetaWindow *result; CollectTransientsData data; transients = NULL; data.workspace = meta_window_get_workspace (reference); data.transients = &transients; meta_window_foreach_transient (reference, collect_transients_on_workspace, &data); transients_sorted = meta_display_sort_windows_by_stacking (display, transients); /* Reverse this so we're top-to-bottom (yes, we should probably change the order * returned from the sort_windows_by_stacking function) */ transients_sorted = g_slist_reverse (transients_sorted); g_slist_free (transients); transients = NULL; result = NULL; for (iter = transients_sorted; iter; iter = iter->next) { MetaWindow *window = iter->data; MetaWindowType wintype = meta_window_get_window_type (window); /* Don't want to focus UTILITY types, like the Gimp toolbars */ if (wintype == META_WINDOW_NORMAL || wintype == META_WINDOW_DIALOG) { result = window; break; } } g_slist_free (transients_sorted); return result; }
static void switch_workspace (MetaPlugin *plugin, gint from, gint to, MetaMotionDirection direction) { MetaScreen *screen; MetaDefaultPluginPrivate *priv = META_DEFAULT_PLUGIN (plugin)->priv; GList *l; ClutterActor *workspace0 = clutter_group_new (); ClutterActor *workspace1 = clutter_group_new (); ClutterActor *stage; int screen_width, screen_height; ClutterAnimation *animation; screen = meta_plugin_get_screen (plugin); stage = meta_get_stage_for_screen (screen); meta_screen_get_size (screen, &screen_width, &screen_height); clutter_actor_set_anchor_point (workspace1, screen_width, screen_height); clutter_actor_set_position (workspace1, screen_width, screen_height); clutter_actor_set_scale (workspace1, 0.0, 0.0); clutter_container_add_actor (CLUTTER_CONTAINER (stage), workspace1); clutter_container_add_actor (CLUTTER_CONTAINER (stage), workspace0); if (from == to) { meta_plugin_switch_workspace_completed (plugin); return; } l = g_list_last (meta_get_window_actors (screen)); while (l) { MetaWindowActor *window_actor = l->data; MetaWindow *window = meta_window_actor_get_meta_window (window_actor); MetaWorkspace *workspace; ActorPrivate *apriv = get_actor_private (window_actor); ClutterActor *actor = CLUTTER_ACTOR (window_actor); gint win_workspace; workspace = meta_window_get_workspace (window); win_workspace = meta_workspace_index (workspace); if (win_workspace == to || win_workspace == from) { apriv->orig_parent = clutter_actor_get_parent (actor); clutter_actor_reparent (actor, win_workspace == to ? workspace1 : workspace0); clutter_actor_show_all (actor); clutter_actor_raise_top (actor); } else if (win_workspace < 0) { /* Sticky window */ apriv->orig_parent = NULL; } else { /* Window on some other desktop */ clutter_actor_hide (actor); apriv->orig_parent = NULL; } l = l->prev; } priv->desktop1 = workspace0; priv->desktop2 = workspace1; animation = clutter_actor_animate (workspace0, CLUTTER_EASE_IN_SINE, SWITCH_TIMEOUT, "scale-x", 1.0, "scale-y", 1.0, NULL); priv->tml_switch_workspace1 = clutter_animation_get_timeline (animation); g_signal_connect (priv->tml_switch_workspace1, "completed", G_CALLBACK (on_switch_workspace_effect_complete), plugin); animation = clutter_actor_animate (workspace1, CLUTTER_EASE_IN_SINE, SWITCH_TIMEOUT, "scale-x", 0.0, "scale-y", 0.0, NULL); priv->tml_switch_workspace2 = clutter_animation_get_timeline (animation); }
/** * cinnamon_app_activate_window: * @app: a #CinnamonApp * @window: (allow-none): Window to be focused * @timestamp: Event timestamp * * Bring all windows for the given app to the foreground, * but ensure that @window is on top. If @window is %NULL, * the window with the most recent user time for the app * will be used. * * This function has no effect if @app is not currently running. */ void cinnamon_app_activate_window (CinnamonApp *app, MetaWindow *window, guint32 timestamp) { GSList *windows; if (cinnamon_app_get_state (app) != CINNAMON_APP_STATE_RUNNING) return; windows = cinnamon_app_get_windows (app); if (window == NULL && windows) window = windows->data; if (!g_slist_find (windows, window)) return; else { GSList *iter; CinnamonGlobal *global = cinnamon_global_get (); MetaScreen *screen = cinnamon_global_get_screen (global); MetaDisplay *display = meta_screen_get_display (screen); MetaWorkspace *active = meta_screen_get_active_workspace (screen); MetaWorkspace *workspace = meta_window_get_workspace (window); guint32 last_user_timestamp = meta_display_get_last_user_time (display); MetaWindow *most_recent_transient; if (meta_display_xserver_time_is_before (display, timestamp, last_user_timestamp)) { meta_window_set_demands_attention (window); return; } /* Now raise all the other windows for the app that are on * the same workspace, in reverse order to preserve the stacking. */ for (iter = windows; iter; iter = iter->next) { MetaWindow *other_window = iter->data; if (other_window != window) meta_window_raise (other_window); } /* If we have a transient that the user's interacted with more recently than * the window, pick that. */ most_recent_transient = find_most_recent_transient_on_same_workspace (display, window); if (most_recent_transient && meta_display_xserver_time_is_before (display, meta_window_get_user_time (window), meta_window_get_user_time (most_recent_transient))) window = most_recent_transient; if (!cinnamon_window_tracker_is_window_interesting (window)) { /* We won't get notify::user-time signals for uninteresting windows, * which means that an app's last_user_time won't get updated. * Update it here instead. */ app->running_state->last_user_time = timestamp; } if (active != workspace) meta_workspace_activate_with_focus (workspace, window, timestamp); else meta_window_activate (window, timestamp); } }