static void disassociate_window (CinnamonWindowTracker *self, MetaWindow *window) { CinnamonApp *app; app = g_hash_table_lookup (self->window_to_app, window); if (!app) return; g_object_ref (app); g_hash_table_remove (self->window_to_app, window); if (cinnamon_window_tracker_is_window_interesting (self, window)) { _cinnamon_app_remove_window (app, window); g_signal_handlers_disconnect_by_func (window, G_CALLBACK(on_wm_class_changed), self); g_signal_handlers_disconnect_by_func (window, G_CALLBACK (on_gtk_application_id_changed), self); } g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0); g_object_unref (app); }
/** * cinnamon_app_request_quit: * @app: A #CinnamonApp * * Initiate an asynchronous request to quit this application. * The application may interact with the user, and the user * might cancel the quit request from the application UI. * * This operation may not be supported for all applications. * * Returns: %TRUE if a quit request is supported for this application */ gboolean cinnamon_app_request_quit (CinnamonApp *app) { GSList *iter; if (cinnamon_app_get_state (app) != CINNAMON_APP_STATE_RUNNING) return FALSE; /* TODO - check for an XSMP connection; we could probably use that */ for (iter = app->running_state->windows; iter; iter = iter->next) { MetaWindow *win = iter->data; if (!cinnamon_window_tracker_is_window_interesting (win)) continue; meta_window_delete (win, cinnamon_global_get_current_time (cinnamon_global_get ())); } return TRUE; }
static void track_window (CinnamonWindowTracker *self, MetaWindow *window) { CinnamonApp *app; if (!cinnamon_window_tracker_is_window_interesting (window)) return; app = get_app_for_window (self, window); if (!app) return; /* At this point we've stored the association from window -> application */ g_hash_table_insert (self->window_to_app, window, app); g_signal_connect (window, "notify::wm-class", G_CALLBACK (on_wm_class_changed), self); _cinnamon_app_add_window (app, window); g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0); }
/** * 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); } }