mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 21:02:14 +00:00
screen-cast: Pass remote desktop session on construction
We already have the remote desktop session ID, and we'll soon need the actual remote desktop session in the screen cast session, so pass it on construction. The old screen cast type is set implicitly instead. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
This commit is contained in:
parent
f5e063ab57
commit
27b790d8c1
@ -62,6 +62,7 @@ typedef struct _MetaRenderer MetaRenderer;
|
||||
typedef struct _MetaRendererView MetaRendererView;
|
||||
|
||||
typedef struct _MetaRemoteDesktop MetaRemoteDesktop;
|
||||
typedef struct _MetaRemoteDesktopSession MetaRemoteDesktopSession;
|
||||
typedef struct _MetaScreenCast MetaScreenCast;
|
||||
typedef struct _MetaScreenCastSession MetaScreenCastSession;
|
||||
typedef struct _MetaScreenCastStream MetaScreenCastStream;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "backends/meta-dbus-session-manager.h"
|
||||
#include "backends/meta-dbus-session-watcher.h"
|
||||
#include "backends/meta-remote-access-controller-private.h"
|
||||
#include "backends/meta-remote-desktop-session.h"
|
||||
#include "backends/meta-screen-cast-area-stream.h"
|
||||
#include "backends/meta-screen-cast-monitor-stream.h"
|
||||
#include "backends/meta-screen-cast-stream.h"
|
||||
@ -41,7 +42,7 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_SESSION_TYPE,
|
||||
PROP_REMOTE_DESKTOP_SESSION,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
@ -66,6 +67,8 @@ struct _MetaScreenCastSession
|
||||
|
||||
gboolean is_active;
|
||||
gboolean disable_animations;
|
||||
|
||||
MetaRemoteDesktopSession *remote_desktop_session;
|
||||
};
|
||||
|
||||
static void initable_init_iface (GInitableIface *iface);
|
||||
@ -230,6 +233,12 @@ meta_screen_cast_session_get_session_type (MetaScreenCastSession *session)
|
||||
return session->session_type;
|
||||
}
|
||||
|
||||
MetaRemoteDesktopSession *
|
||||
meta_screen_cast_session_get_remote_desktop_session (MetaScreenCastSession *session)
|
||||
{
|
||||
return session->remote_desktop_session;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_permission (MetaScreenCastSession *session,
|
||||
GDBusMethodInvocation *invocation)
|
||||
@ -248,6 +257,14 @@ meta_screen_cast_session_initable_init (GInitable *initable,
|
||||
GDBusConnection *connection;
|
||||
static unsigned int global_session_number = 0;
|
||||
|
||||
if (session->remote_desktop_session)
|
||||
{
|
||||
if (!meta_remote_desktop_session_register_screen_cast (session->remote_desktop_session,
|
||||
session,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
session->object_path =
|
||||
g_strdup_printf (META_SCREEN_CAST_SESSION_DBUS_PATH "/u%u",
|
||||
++global_session_number);
|
||||
@ -799,8 +816,12 @@ meta_screen_cast_session_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SESSION_TYPE:
|
||||
session->session_type = g_value_get_enum (value);
|
||||
case PROP_REMOTE_DESKTOP_SESSION:
|
||||
session->remote_desktop_session = g_value_get_object (value);
|
||||
if (session->remote_desktop_session)
|
||||
session->session_type = META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP;
|
||||
else
|
||||
session->session_type = META_SCREEN_CAST_SESSION_TYPE_NORMAL;
|
||||
break;
|
||||
|
||||
case N_PROPS + META_DBUS_SESSION_PROP_SESSION_MANAGER:
|
||||
@ -828,8 +849,8 @@ meta_screen_cast_session_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SESSION_TYPE:
|
||||
g_value_set_enum (value, session->session_type);
|
||||
case PROP_REMOTE_DESKTOP_SESSION:
|
||||
g_value_set_object (value, session->remote_desktop_session);
|
||||
break;
|
||||
|
||||
case N_PROPS + META_DBUS_SESSION_PROP_SESSION_MANAGER:
|
||||
@ -861,10 +882,9 @@ meta_screen_cast_session_class_init (MetaScreenCastSessionClass *klass)
|
||||
object_class->set_property = meta_screen_cast_session_set_property;
|
||||
object_class->get_property = meta_screen_cast_session_get_property;
|
||||
|
||||
obj_props[PROP_SESSION_TYPE] =
|
||||
g_param_spec_enum ("session-type", NULL, NULL,
|
||||
META_TYPE_SCREEN_CAST_SESSION_TYPE,
|
||||
META_SCREEN_CAST_SESSION_TYPE_NORMAL,
|
||||
obj_props[PROP_REMOTE_DESKTOP_SESSION] =
|
||||
g_param_spec_object ("remote-desktop-session", NULL, NULL,
|
||||
META_TYPE_REMOTE_DESKTOP_SESSION,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "backends/meta-screen-cast.h"
|
||||
|
||||
#include "backends/meta-backend-types.h"
|
||||
#include "backends/meta-screen-cast-stream.h"
|
||||
#include "meta/meta-remote-access-controller.h"
|
||||
|
||||
@ -48,6 +49,8 @@ char * meta_screen_cast_session_get_peer_name (MetaScreenCastSession *session);
|
||||
|
||||
MetaScreenCastSessionType meta_screen_cast_session_get_session_type (MetaScreenCastSession *session);
|
||||
|
||||
MetaRemoteDesktopSession * meta_screen_cast_session_get_remote_desktop_session (MetaScreenCastSession *session);
|
||||
|
||||
gboolean meta_screen_cast_session_start (MetaScreenCastSession *session,
|
||||
GError **error);
|
||||
|
||||
|
@ -93,22 +93,17 @@ meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
||||
return dmabuf_handle;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
register_remote_desktop_screen_cast_session (MetaScreenCastSession *session,
|
||||
static MetaRemoteDesktopSession *
|
||||
find_remote_desktop_session (MetaDbusSessionManager *session_manager,
|
||||
const char *remote_desktop_session_id,
|
||||
GError **error)
|
||||
{
|
||||
MetaScreenCast *screen_cast =
|
||||
meta_screen_cast_session_get_screen_cast (session);
|
||||
MetaDbusSessionManager *session_manager =
|
||||
META_DBUS_SESSION_MANAGER (screen_cast);
|
||||
MetaBackend *backend =
|
||||
meta_dbus_session_manager_get_backend (session_manager);
|
||||
MetaRemoteDesktop *remote_desktop = meta_backend_get_remote_desktop (backend);
|
||||
MetaDbusSessionManager *remote_desktop_session_manager =
|
||||
META_DBUS_SESSION_MANAGER (remote_desktop);
|
||||
MetaDbusSession *remote_desktop_dbus_session;
|
||||
MetaRemoteDesktopSession *remote_desktop_session;
|
||||
|
||||
remote_desktop_dbus_session =
|
||||
meta_dbus_session_manager_get_session (remote_desktop_session_manager,
|
||||
@ -117,17 +112,10 @@ register_remote_desktop_screen_cast_session (MetaScreenCastSession *session,
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"No remote desktop session found");
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
remote_desktop_session =
|
||||
META_REMOTE_DESKTOP_SESSION (remote_desktop_dbus_session);
|
||||
if (!meta_remote_desktop_session_register_screen_cast (remote_desktop_session,
|
||||
session,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return META_REMOTE_DESKTOP_SESSION (remote_desktop_dbus_session);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -139,7 +127,7 @@ handle_create_session (MetaDBusScreenCast *skeleton,
|
||||
MetaDbusSessionManager *session_manager =
|
||||
META_DBUS_SESSION_MANAGER (screen_cast);
|
||||
char *remote_desktop_session_id = NULL;
|
||||
MetaScreenCastSessionType session_type;
|
||||
MetaRemoteDesktopSession *remote_desktop_session = NULL;
|
||||
MetaDbusSession *dbus_session;
|
||||
MetaScreenCastSession *session;
|
||||
g_autoptr (GError) error = NULL;
|
||||
@ -150,15 +138,24 @@ handle_create_session (MetaDBusScreenCast *skeleton,
|
||||
&remote_desktop_session_id);
|
||||
|
||||
if (remote_desktop_session_id)
|
||||
session_type = META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP;
|
||||
else
|
||||
session_type = META_SCREEN_CAST_SESSION_TYPE_NORMAL;
|
||||
{
|
||||
remote_desktop_session = find_remote_desktop_session (session_manager,
|
||||
remote_desktop_session_id,
|
||||
&error);
|
||||
if (!remote_desktop_session)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_FAILED,
|
||||
"%s", error->message);
|
||||
return G_DBUS_METHOD_INVOCATION_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
dbus_session =
|
||||
meta_dbus_session_manager_create_session (session_manager,
|
||||
invocation,
|
||||
&error,
|
||||
"session-type", session_type,
|
||||
"remote-desktop-session", remote_desktop_session,
|
||||
NULL);
|
||||
if (!dbus_session)
|
||||
{
|
||||
@ -169,20 +166,6 @@ handle_create_session (MetaDBusScreenCast *skeleton,
|
||||
}
|
||||
session = META_SCREEN_CAST_SESSION (dbus_session);
|
||||
|
||||
if (remote_desktop_session_id)
|
||||
{
|
||||
if (!register_remote_desktop_screen_cast_session (session,
|
||||
remote_desktop_session_id,
|
||||
&error))
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_FAILED,
|
||||
"%s", error->message);
|
||||
meta_dbus_session_close (dbus_session);
|
||||
return G_DBUS_METHOD_INVOCATION_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_variant_lookup (properties, "disable-animations", "b",
|
||||
&disable_animations))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user