shell: Use MetaStartupNotification

This is "API compatible" with ShellStartupNotification, so only
C changes are necessary.
This commit is contained in:
Carlos Garnacho 2018-08-23 00:00:36 +02:00
parent 4d2dce2c52
commit 10b3671a99
4 changed files with 28 additions and 84 deletions

View File

@ -5,9 +5,6 @@
#include "shell-app.h"
#include "shell-app-system.h"
#define SN_API_NOT_YET_FROZEN 1
#include <libsn/sn.h>
G_BEGIN_DECLS
ShellApp* _shell_app_new_for_window (MetaWindow *window);
@ -16,7 +13,7 @@ ShellApp* _shell_app_new (GDesktopAppInfo *info);
void _shell_app_set_app_info (ShellApp *app, GDesktopAppInfo *info);
void _shell_app_handle_startup_sequence (ShellApp *app, SnStartupSequence *sequence);
void _shell_app_handle_startup_sequence (ShellApp *app, MetaStartupSequence *sequence);
void _shell_app_add_window (ShellApp *app, MetaWindow *window);

View File

@ -1143,9 +1143,9 @@ shell_app_get_pids (ShellApp *app)
void
_shell_app_handle_startup_sequence (ShellApp *app,
SnStartupSequence *sequence)
MetaStartupSequence *sequence)
{
gboolean starting = !sn_startup_sequence_get_completed (sequence);
gboolean starting = !meta_startup_sequence_get_completed (sequence);
/* The Shell design calls for on application launch, the app title
* appears at top, and no X window is focused. So when we get
@ -1160,8 +1160,8 @@ _shell_app_handle_startup_sequence (ShellApp *app,
shell_app_state_transition (app, SHELL_APP_STATE_STARTING);
meta_x11_display_focus_the_no_focus_window (x11_display,
sn_startup_sequence_get_timestamp (sequence));
app->started_on_workspace = sn_startup_sequence_get_workspace (sequence);
meta_startup_sequence_get_timestamp (sequence));
app->started_on_workspace = meta_startup_sequence_get_workspace (sequence);
}
if (!starting)

View File

@ -14,9 +14,7 @@
#include <meta/util.h>
#include <meta/window.h>
#include <meta/meta-workspace-manager.h>
#define SN_API_NOT_YET_FROZEN 1
#include <libsn/sn.h>
#include <meta/meta-startup-notification.h>
#include "shell-window-tracker-private.h"
#include "shell-app-private.h"
@ -115,7 +113,7 @@ shell_window_tracker_class_init (ShellWindowTrackerClass *klass)
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1, SHELL_TYPE_STARTUP_SEQUENCE);
G_TYPE_NONE, 1, META_TYPE_STARTUP_SEQUENCE);
signals[TRACKED_WINDOWS_CHANGED] = g_signal_new ("tracked-windows-changed",
SHELL_TYPE_WINDOW_TRACKER,
G_SIGNAL_RUN_LAST,
@ -430,8 +428,8 @@ get_app_for_window (ShellWindowTracker *tracker,
sequences = shell_window_tracker_get_startup_sequences (tracker);
for (iter = sequences; iter; iter = iter->next)
{
ShellStartupSequence *sequence = iter->data;
const char *id = shell_startup_sequence_get_id (sequence);
MetaStartupSequence *sequence = iter->data;
const char *id = meta_startup_sequence_get_id (sequence);
if (strcmp (id, startup_id) != 0)
continue;
@ -653,13 +651,13 @@ init_window_tracking (ShellWindowTracker *self)
}
static void
on_startup_sequence_changed (MetaDisplay *display,
SnStartupSequence *sequence,
on_startup_sequence_changed (MetaStartupNotification *sn,
MetaStartupSequence *sequence,
ShellWindowTracker *self)
{
ShellApp *app;
app = shell_startup_sequence_get_app ((ShellStartupSequence*)sequence);
app = shell_startup_sequence_get_app (sequence);
if (app)
_shell_app_handle_startup_sequence (app, sequence);
@ -670,12 +668,13 @@ static void
shell_window_tracker_init (ShellWindowTracker *self)
{
MetaDisplay *display = shell_global_get_display (shell_global_get ());
MetaStartupNotification *sn = meta_display_get_startup_notification (display);
self->window_to_app = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, (GDestroyNotify) g_object_unref);
g_signal_connect (display, "startup-sequence-changed",
g_signal_connect (sn, "changed",
G_CALLBACK (on_startup_sequence_changed), self);
load_initial_windows (self);
@ -786,60 +785,33 @@ on_focus_window_changed (MetaDisplay *display,
* shell_window_tracker_get_startup_sequences:
* @tracker:
*
* Returns: (transfer none) (element-type ShellStartupSequence): Currently active startup sequences
* Returns: (transfer none) (element-type MetaStartupSequence): Currently active startup sequences
*/
GSList *
shell_window_tracker_get_startup_sequences (ShellWindowTracker *self)
{
ShellGlobal *global = shell_global_get ();
MetaDisplay *display = shell_global_get_display (global);
MetaStartupNotification *sn = meta_display_get_startup_notification (display);
return meta_display_get_startup_sequences (display);
}
/* sn_startup_sequence_ref returns void, so make a
* wrapper which returns self */
static SnStartupSequence *
sequence_ref (SnStartupSequence *sequence)
{
sn_startup_sequence_ref (sequence);
return sequence;
}
GType
shell_startup_sequence_get_type (void)
{
static GType gtype = G_TYPE_INVALID;
if (gtype == G_TYPE_INVALID)
{
gtype = g_boxed_type_register_static ("ShellStartupSequence",
(GBoxedCopyFunc)sequence_ref,
(GBoxedFreeFunc)sn_startup_sequence_unref);
}
return gtype;
}
const char *
shell_startup_sequence_get_id (ShellStartupSequence *sequence)
{
return sn_startup_sequence_get_id ((SnStartupSequence*)sequence);
return meta_startup_notification_get_sequences (sn);
}
/**
* shell_startup_sequence_get_app:
* @sequence: A #ShellStartupSequence
* @sequence: A #MetaStartupSequence
*
* Returns: (transfer none): The application being launched, or %NULL if unknown.
*/
ShellApp *
shell_startup_sequence_get_app (ShellStartupSequence *sequence)
shell_startup_sequence_get_app (MetaStartupSequence *sequence)
{
const char *appid;
char *basename;
ShellAppSystem *appsys;
ShellApp *app;
appid = sn_startup_sequence_get_application_id ((SnStartupSequence*)sequence);
appid = meta_startup_sequence_get_application_id (sequence);
if (!appid)
return NULL;
@ -850,24 +822,6 @@ shell_startup_sequence_get_app (ShellStartupSequence *sequence)
return app;
}
const char *
shell_startup_sequence_get_name (ShellStartupSequence *sequence)
{
return sn_startup_sequence_get_name ((SnStartupSequence*)sequence);
}
gboolean
shell_startup_sequence_get_completed (ShellStartupSequence *sequence)
{
return sn_startup_sequence_get_completed ((SnStartupSequence*)sequence);
}
int
shell_startup_sequence_get_workspace (ShellStartupSequence *sequence)
{
return sn_startup_sequence_get_workspace ((SnStartupSequence*)sequence);
}
/**
* shell_startup_sequence_create_icon:
* @sequence:
@ -876,7 +830,8 @@ shell_startup_sequence_get_workspace (ShellStartupSequence *sequence)
* Returns: (transfer none): A new #ClutterTexture containing an icon for the sequence
*/
ClutterActor *
shell_startup_sequence_create_icon (ShellStartupSequence *sequence, guint size)
shell_startup_sequence_create_icon (MetaStartupSequence *sequence,
guint size)
{
GIcon *themed;
const char *icon_name;
@ -889,7 +844,7 @@ shell_startup_sequence_create_icon (ShellStartupSequence *sequence, guint size)
context = st_theme_context_get_for_stage (shell_global_get_stage (global));
g_object_get (context, "scale-factor", &scale, NULL);
icon_name = sn_startup_sequence_get_icon_name ((SnStartupSequence*)sequence);
icon_name = meta_startup_sequence_get_icon_name (sequence);
if (!icon_name)
{
texture = clutter_texture_new ();

View File

@ -5,6 +5,7 @@
#include <glib-object.h>
#include <glib.h>
#include <meta/window.h>
#include <meta/meta-startup-notification.h>
#include "shell-app.h"
#include "shell-app-system.h"
@ -23,17 +24,8 @@ ShellApp *shell_window_tracker_get_app_from_pid (ShellWindowTracker *tracker, in
GSList *shell_window_tracker_get_startup_sequences (ShellWindowTracker *tracker);
/* Hidden typedef for SnStartupSequence */
typedef struct _ShellStartupSequence ShellStartupSequence;
#define SHELL_TYPE_STARTUP_SEQUENCE (shell_startup_sequence_get_type ())
GType shell_startup_sequence_get_type (void);
const char *shell_startup_sequence_get_id (ShellStartupSequence *sequence);
ShellApp *shell_startup_sequence_get_app (ShellStartupSequence *sequence);
const char *shell_startup_sequence_get_name (ShellStartupSequence *sequence);
gboolean shell_startup_sequence_get_completed (ShellStartupSequence *sequence);
int shell_startup_sequence_get_workspace (ShellStartupSequence *sequence);
ClutterActor *shell_startup_sequence_create_icon (ShellStartupSequence *sequence, guint size);
ShellApp *shell_startup_sequence_get_app (MetaStartupSequence *sequence);
ClutterActor *shell_startup_sequence_create_icon (MetaStartupSequence *sequence, guint size);
G_END_DECLS