/** * get_app_id_from_title: * * Use a window's "title" property to determine an application ID. * This is a temporary crutch for a few applications until we get * them correctly setting their WM_CLASS. */ static const char * get_app_id_from_title (MetaWindow *window) { static gboolean patterns_initialized = FALSE; const char *title; int i; title = meta_window_get_title (window); if (!patterns_initialized) /* Generate match patterns once for all */ { patterns_initialized = TRUE; for (i = 0; title_patterns[i].app_id; i++) { title_patterns[i].regex = g_regex_new (title_patterns[i].pattern, 0, 0, NULL); } } /* Match window title patterns to identifiers for non-standard apps */ if (title) { for (i = 0; title_patterns[i].app_id; i++) { if (g_regex_match (title_patterns[i].regex, title, 0, NULL)) { /* Matched, return the app id we want */ return title_patterns[i].app_id; } } } return NULL; }
static void ntf_wm_update_notification (NtfNotification *ntf, MetaWindow *window) { ClutterActor *src_icon; ClutterActor *button; NtfSource *src; const gchar *title; const gchar *summary; const gchar *body; g_return_if_fail (ntf && window); src = ntf_notification_get_source (ntf); if ((src_icon = ntf_source_get_icon (src))) { ClutterActor *icon = clutter_clone_new (src_icon) ; ntf_notification_set_icon (ntf, icon); } title = meta_window_get_title (window); if (title) summary = title; else summary = _("Unknown window"); ntf_notification_set_summary (ntf, summary); body = _("is asking for your attention."); ntf_notification_set_body (ntf, body); ntf_notification_remove_all_buttons (ntf); button = mx_button_new (); mx_button_set_label (MX_BUTTON (button), _("Activate")); g_signal_connect (button, "clicked", G_CALLBACK (ntf_wm_activate_cb), window); ntf_notification_add_button (ntf, button, 0); }
/** * shell_window_tracker_is_window_interesting: * * The ShellWindowTracker associates certain kinds of windows with * applications; however, others we don't want to * appear in places where we want to give a list of windows * for an application, such as the alt-tab dialog. * * An example of a window we don't want to show is the root * desktop window. We skip all override-redirect types, and also * exclude other window types like tooltip explicitly, though generally * most of these should be override-redirect. * Side component windows are considered interesting so they can be handled * by the window manager. * * Returns: %TRUE iff a window is "interesting" */ gboolean shell_window_tracker_is_window_interesting (MetaWindow *window) { if (g_strcmp0 (meta_window_get_role (window), SIDE_COMPONENT_ROLE) == 0) return TRUE; if (meta_window_is_skip_taskbar (window)) return FALSE; /* HACK: see https://github.com/endlessm/eos-shell/issues/548 and * https://github.com/linuxmint/Cinnamon/issues/728 */ if (g_strcmp0 (meta_window_get_title (window), "JavaEmbeddedFrame") == 0) return FALSE; return TRUE; }
static void _add_app(MetaSwitcher* self, MetaWindow* app, gint* x, gint* y) { MetaSwitcherPrivate* priv = self->priv; if (!priv->icons) priv->icons = g_hash_table_new(NULL, NULL); // container ClutterActor* actor = clutter_actor_new(); WindowPrivate* win_priv = get_window_private(actor); win_priv->window = app; win_priv->highlight = FALSE; g_hash_table_insert(priv->icons, app, actor); gint w = APP_ACTOR_WIDTH, h = APP_ACTOR_HEIGHT, screen_width, screen_height; /* TODO: @sonald scale app actor width */ MetaScreen *screen = meta_plugin_get_screen(priv->plugin); meta_screen_get_size(screen, &screen_width, &screen_height); if (priv->apps->len) w = (screen_width - priv->apps->len * APP_ICON_PADDING) / priv->apps->len; if (w > APP_ACTOR_WIDTH) w = APP_ACTOR_WIDTH; // add children ClutterContent* canvas = clutter_canvas_new(); g_signal_connect(canvas, "draw", G_CALLBACK(on_icon_background_draw), actor); clutter_canvas_set_size(CLUTTER_CANVAS(canvas), w, h); ClutterActor* bg = clutter_actor_new(); clutter_actor_set_name(bg, "bg"); clutter_actor_set_content(bg, canvas); g_object_unref(canvas); clutter_actor_set_size(bg, w, h); g_object_set(bg, "x-expand", TRUE, "y-expand", TRUE, "x-align", CLUTTER_ACTOR_ALIGN_FILL, "y-align", CLUTTER_ACTOR_ALIGN_FILL, NULL); clutter_actor_add_child(actor, bg); ClutterActor* icon = load_icon_for_window(self, app); if (icon) clutter_actor_add_child(actor, icon); ClutterActor* label = clutter_text_new(); clutter_actor_add_child(actor, label); clutter_text_set_text(CLUTTER_TEXT(label), meta_window_get_title(app)); clutter_text_set_font_name(CLUTTER_TEXT(label), "Sans 10"); ClutterColor clr = {0xff, 0xff, 0xff, 0xff}; clutter_text_set_color(CLUTTER_TEXT(label), &clr); clutter_text_set_ellipsize(CLUTTER_TEXT(label), PANGO_ELLIPSIZE_END); g_object_set(label, "x-align", CLUTTER_ACTOR_ALIGN_CENTER, "y-align", CLUTTER_ACTOR_ALIGN_CENTER, NULL); gfloat pref_width = clutter_actor_get_width(label); if (pref_width > w - 10) { pref_width = w - 10; clutter_actor_set_width(label, pref_width); } /* TODO: @sonald adjust app title position */ clutter_actor_set_position(label, (w - pref_width) / 2, APP_ICON_SIZE + 2); g_debug("%s: size: %d, %d", __func__, w, h); clutter_actor_show(actor); clutter_actor_add_child(priv->top, actor); *x += w; }