mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
launcher: Use gnome.gdbusgen and add prefix to generated API
This is more in line with how generated D-Bus boilerplate work, lets stay consistent. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
This commit is contained in:
parent
ad1bffc002
commit
8867b11e19
@ -47,8 +47,8 @@
|
|||||||
|
|
||||||
struct _MetaLauncher
|
struct _MetaLauncher
|
||||||
{
|
{
|
||||||
Login1Session *session_proxy;
|
MetaDbusLogin1Session *session_proxy;
|
||||||
Login1Seat *seat_proxy;
|
MetaDbusLogin1Seat *seat_proxy;
|
||||||
char *seat_id;
|
char *seat_id;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -224,14 +224,15 @@ find_systemd_session (gchar **session_id,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Login1Session *
|
static MetaDbusLogin1Session *
|
||||||
get_session_proxy (GCancellable *cancellable,
|
get_session_proxy (GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_autofree char *proxy_path = NULL;
|
g_autofree char *proxy_path = NULL;
|
||||||
g_autofree char *session_id = NULL;
|
g_autofree char *session_id = NULL;
|
||||||
g_autoptr (GError) local_error = NULL;
|
g_autoptr (GError) local_error = NULL;
|
||||||
Login1Session *session_proxy;
|
GDBusProxyFlags flags;
|
||||||
|
MetaDbusLogin1Session *session_proxy;
|
||||||
|
|
||||||
if (!find_systemd_session (&session_id, &local_error))
|
if (!find_systemd_session (&session_id, &local_error))
|
||||||
{
|
{
|
||||||
@ -243,28 +244,35 @@ get_session_proxy (GCancellable *cancellable,
|
|||||||
|
|
||||||
proxy_path = get_escaped_dbus_path ("/org/freedesktop/login1/session", session_id);
|
proxy_path = get_escaped_dbus_path ("/org/freedesktop/login1/session", session_id);
|
||||||
|
|
||||||
session_proxy = login1_session_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
flags = G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START;
|
||||||
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
session_proxy =
|
||||||
"org.freedesktop.login1",
|
meta_dbus_login1_session_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
||||||
proxy_path,
|
flags,
|
||||||
cancellable, error);
|
"org.freedesktop.login1",
|
||||||
|
proxy_path,
|
||||||
|
cancellable, error);
|
||||||
if (!session_proxy)
|
if (!session_proxy)
|
||||||
g_prefix_error(error, "Could not get session proxy: ");
|
g_prefix_error(error, "Could not get session proxy: ");
|
||||||
|
|
||||||
return session_proxy;
|
return session_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Login1Seat *
|
static MetaDbusLogin1Seat *
|
||||||
get_seat_proxy (gchar *seat_id,
|
get_seat_proxy (gchar *seat_id,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_autofree char *seat_proxy_path = get_escaped_dbus_path ("/org/freedesktop/login1/seat", seat_id);
|
g_autofree char *seat_proxy_path = get_escaped_dbus_path ("/org/freedesktop/login1/seat", seat_id);
|
||||||
Login1Seat *seat = login1_seat_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
GDBusProxyFlags flags;
|
||||||
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
MetaDbusLogin1Seat *seat;
|
||||||
"org.freedesktop.login1",
|
|
||||||
seat_proxy_path,
|
flags = G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START;
|
||||||
cancellable, error);
|
seat =
|
||||||
|
meta_dbus_login1_seat_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
||||||
|
flags,
|
||||||
|
"org.freedesktop.login1",
|
||||||
|
seat_proxy_path,
|
||||||
|
cancellable, error);
|
||||||
if (!seat)
|
if (!seat)
|
||||||
g_prefix_error(error, "Could not get seat proxy: ");
|
g_prefix_error(error, "Could not get seat proxy: ");
|
||||||
|
|
||||||
@ -272,26 +280,26 @@ get_seat_proxy (gchar *seat_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
take_device (Login1Session *session_proxy,
|
take_device (MetaDbusLogin1Session *session_proxy,
|
||||||
int dev_major,
|
int dev_major,
|
||||||
int dev_minor,
|
int dev_minor,
|
||||||
int *out_fd,
|
int *out_fd,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr (GVariant) fd_variant = NULL;
|
g_autoptr (GVariant) fd_variant = NULL;
|
||||||
g_autoptr (GUnixFDList) fd_list = NULL;
|
g_autoptr (GUnixFDList) fd_list = NULL;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
if (!login1_session_call_take_device_sync (session_proxy,
|
if (!meta_dbus_login1_session_call_take_device_sync (session_proxy,
|
||||||
dev_major,
|
dev_major,
|
||||||
dev_minor,
|
dev_minor,
|
||||||
NULL,
|
NULL,
|
||||||
&fd_variant,
|
&fd_variant,
|
||||||
NULL, /* paused */
|
NULL, /* paused */
|
||||||
&fd_list,
|
&fd_list,
|
||||||
cancellable,
|
cancellable,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
fd = g_unix_fd_list_get (fd_list, g_variant_get_handle (fd_variant), error);
|
fd = g_unix_fd_list_get (fd_list, g_variant_get_handle (fd_variant), error);
|
||||||
@ -363,6 +371,7 @@ void
|
|||||||
meta_launcher_close_restricted (MetaLauncher *launcher,
|
meta_launcher_close_restricted (MetaLauncher *launcher,
|
||||||
int fd)
|
int fd)
|
||||||
{
|
{
|
||||||
|
MetaDbusLogin1Session *session_proxy = launcher->session_proxy;
|
||||||
int major, minor;
|
int major, minor;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
@ -372,9 +381,9 @@ meta_launcher_close_restricted (MetaLauncher *launcher,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!login1_session_call_release_device_sync (launcher->session_proxy,
|
if (!meta_dbus_login1_session_call_release_device_sync (session_proxy,
|
||||||
major, minor,
|
major, minor,
|
||||||
NULL, &error))
|
NULL, &error))
|
||||||
{
|
{
|
||||||
g_warning ("Could not release device (%d,%d): %s",
|
g_warning ("Could not release device (%d,%d): %s",
|
||||||
major, minor, error->message);
|
major, minor, error->message);
|
||||||
@ -441,8 +450,10 @@ sync_active (MetaLauncher *self)
|
|||||||
{
|
{
|
||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
||||||
gboolean active = login1_session_get_active (LOGIN1_SESSION (self->session_proxy));
|
MetaDbusLogin1Session *session_proxy = self->session_proxy;
|
||||||
|
gboolean active;
|
||||||
|
|
||||||
|
active = meta_dbus_login1_session_get_active (session_proxy);
|
||||||
if (active == self->session_active)
|
if (active == self->session_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -455,9 +466,9 @@ sync_active (MetaLauncher *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_active_changed (Login1Session *session,
|
on_active_changed (MetaDbusLogin1Session *session,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MetaLauncher *self = user_data;
|
MetaLauncher *self = user_data;
|
||||||
sync_active (self);
|
sync_active (self);
|
||||||
@ -496,8 +507,8 @@ MetaLauncher *
|
|||||||
meta_launcher_new (GError **error)
|
meta_launcher_new (GError **error)
|
||||||
{
|
{
|
||||||
MetaLauncher *self = NULL;
|
MetaLauncher *self = NULL;
|
||||||
g_autoptr (Login1Session) session_proxy = NULL;
|
g_autoptr (MetaDbusLogin1Session) session_proxy = NULL;
|
||||||
g_autoptr (Login1Seat) seat_proxy = NULL;
|
g_autoptr (MetaDbusLogin1Seat) seat_proxy = NULL;
|
||||||
g_autofree char *seat_id = NULL;
|
g_autofree char *seat_id = NULL;
|
||||||
gboolean have_control = FALSE;
|
gboolean have_control = FALSE;
|
||||||
|
|
||||||
@ -505,7 +516,10 @@ meta_launcher_new (GError **error)
|
|||||||
if (!session_proxy)
|
if (!session_proxy)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!login1_session_call_take_control_sync (session_proxy, FALSE, NULL, error))
|
if (!meta_dbus_login1_session_call_take_control_sync (session_proxy,
|
||||||
|
FALSE,
|
||||||
|
NULL,
|
||||||
|
error))
|
||||||
{
|
{
|
||||||
g_prefix_error (error, "Could not take control: ");
|
g_prefix_error (error, "Could not take control: ");
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -538,7 +552,10 @@ meta_launcher_new (GError **error)
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (have_control)
|
if (have_control)
|
||||||
login1_session_call_release_control_sync (session_proxy, NULL, NULL);
|
{
|
||||||
|
meta_dbus_login1_session_call_release_control_sync (session_proxy,
|
||||||
|
NULL, NULL);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,5 +575,6 @@ meta_launcher_activate_vt (MetaLauncher *launcher,
|
|||||||
signed char vt,
|
signed char vt,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
return login1_seat_call_switch_to_sync (launcher->seat_proxy, vt, NULL, error);
|
return meta_dbus_login1_seat_call_switch_to_sync (launcher->seat_proxy, vt,
|
||||||
|
NULL, error);
|
||||||
}
|
}
|
||||||
|
@ -833,22 +833,10 @@ if have_native_backend
|
|||||||
)
|
)
|
||||||
mutter_built_sources += default_modes_h
|
mutter_built_sources += default_modes_h
|
||||||
|
|
||||||
gdbus_codegen = find_program('gdbus-codegen')
|
dbus_login1_built_sources = gnome.gdbus_codegen('meta-dbus-login1',
|
||||||
dbus_login1_built_sources = custom_target('meta-dbus-login1',
|
'org.freedesktop.login1.xml',
|
||||||
input: 'org.freedesktop.login1.xml',
|
interface_prefix: 'org.freedesktop.login1.',
|
||||||
output: [
|
namespace: 'MetaDbusLogin1',
|
||||||
'meta-dbus-login1.c',
|
|
||||||
'meta-dbus-login1.h',
|
|
||||||
],
|
|
||||||
command: [
|
|
||||||
gdbus_codegen,
|
|
||||||
'--interface-prefix', 'org.freedesktop.login1',
|
|
||||||
'--c-namespace', 'Login1',
|
|
||||||
'--generate-c-code', 'meta-dbus-login1',
|
|
||||||
'--output-directory', meson.current_build_dir(),
|
|
||||||
'--c-generate-autocleanup', 'all',
|
|
||||||
'@INPUT@',
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
mutter_built_sources += dbus_login1_built_sources
|
mutter_built_sources += dbus_login1_built_sources
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user