import CS xdg-desktop-portal-gnome-41.2-3.el9

This commit is contained in:
eabdullin 2024-03-28 12:02:19 +00:00
parent 36c25554e2
commit c2fa37d6ec
15 changed files with 3679 additions and 1 deletions

View File

@ -0,0 +1,638 @@
From d9c897c8b91165f95f011d44f2fea731b4b7eb16 Mon Sep 17 00:00:00 2001
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Date: Wed, 10 Nov 2021 15:32:18 -0300
Subject: [PATCH] screencast: Trivial style cleanups
Move some code around, and cleanup some of the styling.
It's getting increasingly harder to follow these files,
so start this series of cleanups with them.
---
src/screencast.c | 30 ++--
src/screencastdialog.c | 62 +++----
src/screencastdialog.h | 2 +-
src/screencastwidget.c | 356 +++++++++++++++++++++--------------------
src/screencastwidget.h | 10 +-
5 files changed, 238 insertions(+), 222 deletions(-)
diff --git a/src/gnomescreencast.c b/src/gnomescreencast.c
index fd80ca7..abf5b53 100644
--- a/src/gnomescreencast.c
+++ b/src/gnomescreencast.c
@@ -473,6 +473,7 @@ gnome_screen_cast_session_record_selections (GnomeScreenCastSession *gnome_scree
select,
error))
return FALSE;
+ break;
}
}
diff --git a/src/screencast.c b/src/screencast.c
index 27d8946..38d1d05 100644
--- a/src/screencast.c
+++ b/src/screencast.c
@@ -572,21 +572,6 @@ on_gnome_screen_cast_disabled (GDBusConnection *connection,
}
}
-gboolean
-screen_cast_init (GDBusConnection *connection,
- GError **error)
-{
- impl_connection = connection;
- gnome_screen_cast = gnome_screen_cast_new (connection);
-
- g_signal_connect (gnome_screen_cast, "enabled",
- G_CALLBACK (on_gnome_screen_cast_enabled), NULL);
- g_signal_connect (gnome_screen_cast, "disabled",
- G_CALLBACK (on_gnome_screen_cast_disabled), NULL);
-
- return TRUE;
-}
-
static void
screen_cast_session_close (Session *session)
{
@@ -636,3 +621,18 @@ screen_cast_session_class_init (ScreenCastSessionClass *klass)
session_class = (SessionClass *)klass;
session_class->close = screen_cast_session_close;
}
+
+gboolean
+screen_cast_init (GDBusConnection *connection,
+ GError **error)
+{
+ impl_connection = connection;
+ gnome_screen_cast = gnome_screen_cast_new (connection);
+
+ g_signal_connect (gnome_screen_cast, "enabled",
+ G_CALLBACK (on_gnome_screen_cast_enabled), NULL);
+ g_signal_connect (gnome_screen_cast, "disabled",
+ G_CALLBACK (on_gnome_screen_cast_disabled), NULL);
+
+ return TRUE;
+}
diff --git a/src/screencastdialog.c b/src/screencastdialog.c
index 306992d..56d4d49 100644
--- a/src/screencastdialog.c
+++ b/src/screencastdialog.c
@@ -51,6 +51,10 @@ static guint signals[N_SIGNALS];
G_DEFINE_TYPE (ScreenCastDialog, screen_cast_dialog, GTK_TYPE_WINDOW)
+/*
+ * Callbacks
+ */
+
static void
button_clicked (GtkWidget *button,
ScreenCastDialog *dialog)
@@ -84,7 +88,7 @@ button_clicked (GtkWidget *button,
static void
on_has_selection_changed (ScreenCastWidget *screen_cast_widget,
- gboolean has_selection,
+ gboolean has_selection,
ScreenCastDialog *dialog)
{
if (has_selection)
@@ -93,32 +97,9 @@ on_has_selection_changed (ScreenCastWidget *screen_cast_widget,
gtk_widget_set_sensitive (dialog->accept_button, FALSE);
}
-ScreenCastDialog *
-screen_cast_dialog_new (const char *app_id,
- ScreenCastSelection *select)
-{
- ScreenCastDialog *dialog;
- ScreenCastWidget *screen_cast_widget;
-
- dialog = g_object_new (SCREEN_CAST_TYPE_DIALOG, NULL);
- screen_cast_widget = SCREEN_CAST_WIDGET (dialog->screen_cast_widget);
- screen_cast_widget_set_app_id (screen_cast_widget, app_id);
- screen_cast_widget_set_allow_multiple (screen_cast_widget, select->multiple);
- screen_cast_widget_set_source_types (screen_cast_widget,
- select->source_types);
-
- return dialog;
-}
-
-static void
-screen_cast_dialog_init (ScreenCastDialog *dialog)
-{
- gtk_widget_init_template (GTK_WIDGET (dialog));
-
- g_signal_connect (dialog->screen_cast_widget, "has-selection-changed",
- G_CALLBACK (on_has_selection_changed), dialog);
- gtk_widget_show (dialog->screen_cast_widget);
-}
+/*
+ * GtkWindow overrides
+ */
static gboolean
screen_cast_dialog_close_request (GtkWindow *dialog)
@@ -155,3 +136,30 @@ screen_cast_dialog_class_init (ScreenCastDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, ScreenCastDialog, screen_cast_widget);
gtk_widget_class_bind_template_callback (widget_class, button_clicked);
}
+
+static void
+screen_cast_dialog_init (ScreenCastDialog *dialog)
+{
+ gtk_widget_init_template (GTK_WIDGET (dialog));
+
+ g_signal_connect (dialog->screen_cast_widget, "has-selection-changed",
+ G_CALLBACK (on_has_selection_changed), dialog);
+ gtk_widget_show (dialog->screen_cast_widget);
+}
+
+ScreenCastDialog *
+screen_cast_dialog_new (const char *app_id,
+ ScreenCastSelection *select)
+{
+ ScreenCastDialog *dialog;
+ ScreenCastWidget *screen_cast_widget;
+
+ dialog = g_object_new (SCREEN_CAST_TYPE_DIALOG, NULL);
+ screen_cast_widget = SCREEN_CAST_WIDGET (dialog->screen_cast_widget);
+ screen_cast_widget_set_app_id (screen_cast_widget, app_id);
+ screen_cast_widget_set_allow_multiple (screen_cast_widget, select->multiple);
+ screen_cast_widget_set_source_types (screen_cast_widget,
+ select->source_types);
+
+ return dialog;
+}
diff --git a/src/screencastdialog.h b/src/screencastdialog.h
index 247d93b..1fca470 100644
--- a/src/screencastdialog.h
+++ b/src/screencastdialog.h
@@ -26,5 +26,5 @@
G_DECLARE_FINAL_TYPE (ScreenCastDialog, screen_cast_dialog,
SCREEN_CAST, DIALOG, GtkWindow)
-ScreenCastDialog * screen_cast_dialog_new (const char *app_id,
+ScreenCastDialog * screen_cast_dialog_new (const char *app_id,
ScreenCastSelection *select);
diff --git a/src/screencastwidget.c b/src/screencastwidget.c
index cdd57dc..454c93e 100644
--- a/src/screencastwidget.c
+++ b/src/screencastwidget.c
@@ -65,6 +65,55 @@ static GQuark quark_window_widget_data;
G_DEFINE_TYPE (ScreenCastWidget, screen_cast_widget, GTK_TYPE_BOX)
+/*
+ * Auxiliary methods
+ */
+
+static gboolean
+add_selections (ScreenCastWidget *widget,
+ GVariantBuilder *source_selections_builder)
+{
+ GList *selected_monitor_rows;
+ GList *selected_window_rows;
+ GList *l;
+
+ selected_monitor_rows =
+ gtk_list_box_get_selected_rows (GTK_LIST_BOX (widget->monitor_list));
+ selected_window_rows =
+ gtk_list_box_get_selected_rows (GTK_LIST_BOX (widget->window_list));
+ if (!selected_monitor_rows && !selected_window_rows)
+ return FALSE;
+
+ for (l = selected_monitor_rows; l; l = l->next)
+ {
+ GtkWidget *monitor_widget = gtk_list_box_row_get_child (l->data);
+ Monitor *monitor;
+
+ monitor = g_object_get_qdata (G_OBJECT (monitor_widget),
+ quark_monitor_widget_data);
+
+ g_variant_builder_add (source_selections_builder, "(us)",
+ SCREEN_CAST_SOURCE_TYPE_MONITOR,
+ monitor_get_connector (monitor));
+ }
+ g_list_free (selected_monitor_rows);
+ for (l = selected_window_rows; l; l = l->next)
+ {
+ GtkWidget *window_widget = gtk_list_box_row_get_child (l->data);
+ Window *window;
+
+ window = g_object_get_qdata (G_OBJECT (window_widget),
+ quark_window_widget_data);
+
+ g_variant_builder_add (source_selections_builder, "(ut)",
+ SCREEN_CAST_SOURCE_TYPE_WINDOW,
+ window_get_id (window));
+ }
+ g_list_free (selected_window_rows);
+
+ return TRUE;
+}
+
static GtkWidget *
create_window_widget (Window *window)
{
@@ -131,7 +180,7 @@ create_monitor_widget (LogicalMonitor *logical_monitor)
}
static gboolean
-should_skip_window (Window *window,
+should_skip_window (Window *window,
GtkWindow *toplevel)
{
g_autofree char *processed_app_id = NULL;
@@ -254,7 +303,7 @@ unselect_rows (GtkListBox *listbox)
}
static void
-on_windows_changed (ShellIntrospect *shell_introspect,
+on_windows_changed (ShellIntrospect *shell_introspect,
ScreenCastWidget *widget)
{
update_windows_list (widget);
@@ -283,9 +332,9 @@ disconnect_windows_changed_listener (ScreenCastWidget *widget)
}
static void
-on_stack_switch (GtkStack *stack,
+on_stack_switch (GtkStack *stack,
GParamSpec *pspec,
- gpointer *data)
+ gpointer *data)
{
ScreenCastWidget *widget = (ScreenCastWidget *)data;
GtkWidget *visible_child;
@@ -307,9 +356,9 @@ on_stack_switch (GtkStack *stack,
}
static void
-on_row_activated (GtkListBox *box,
+on_row_activated (GtkListBox *box,
GtkListBoxRow *row,
- gpointer *data)
+ gpointer *data)
{
if (!row)
return;
@@ -378,7 +427,7 @@ schedule_selection_change (ScreenCastWidget *widget)
}
static void
-on_selected_rows_changed (GtkListBox *box,
+on_selected_rows_changed (GtkListBox *box,
ScreenCastWidget *widget)
{
/* GtkListBox activates rows after selecting them, which prevents
@@ -403,59 +452,128 @@ update_list_box_header (GtkListBoxRow *row,
static void
on_monitors_changed (DisplayStateTracker *display_state_tracker,
- ScreenCastWidget *widget)
+ ScreenCastWidget *widget)
{
update_monitors_list (widget);
}
-static gboolean
-add_selections (ScreenCastWidget *widget,
- GVariantBuilder *source_selections_builder)
+/*
+ * GObject overrides
+ */
+
+static void
+screen_cast_widget_finalize (GObject *object)
{
- GList *selected_monitor_rows;
- GList *selected_window_rows;
- GList *l;
+ ScreenCastWidget *widget = SCREEN_CAST_WIDGET (object);
- selected_monitor_rows =
- gtk_list_box_get_selected_rows (GTK_LIST_BOX (widget->monitor_list));
- selected_window_rows =
- gtk_list_box_get_selected_rows (GTK_LIST_BOX (widget->window_list));
- if (!selected_monitor_rows && !selected_window_rows)
- return FALSE;
+ g_signal_handler_disconnect (widget->display_state_tracker,
+ widget->monitors_changed_handler_id);
- for (l = selected_monitor_rows; l; l = l->next)
+ if (widget->windows_changed_handler_id)
+ disconnect_windows_changed_listener (widget);
+
+ if (widget->selection_changed_timeout_id > 0)
{
- GtkWidget *monitor_widget = gtk_list_box_row_get_child (l->data);
- Monitor *monitor;
+ g_source_remove (widget->selection_changed_timeout_id);
+ widget->selection_changed_timeout_id = 0;
+ }
- monitor = g_object_get_qdata (G_OBJECT (monitor_widget),
- quark_monitor_widget_data);
+ G_OBJECT_CLASS (screen_cast_widget_parent_class)->finalize (object);
+}
- g_variant_builder_add (source_selections_builder, "(us)",
- SCREEN_CAST_SOURCE_TYPE_MONITOR,
- monitor_get_connector (monitor));
- }
- g_list_free (selected_monitor_rows);
- for (l = selected_window_rows; l; l = l->next)
- {
- GtkWidget *window_widget = gtk_list_box_row_get_child (l->data);
- Window *window;
+static void
+screen_cast_widget_class_init (ScreenCastWidgetClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- window = g_object_get_qdata (G_OBJECT (window_widget),
- quark_window_widget_data);
+ object_class->finalize = screen_cast_widget_finalize;
- g_variant_builder_add (source_selections_builder, "(ut)",
- SCREEN_CAST_SOURCE_TYPE_WINDOW,
- window_get_id (window));
- }
- g_list_free (selected_window_rows);
+ signals[HAS_SELECTION_CHANGED] = g_signal_new ("has-selection-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_BOOLEAN);
- return TRUE;
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/portal/desktop/gnome/screencastwidget.ui");
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, source_type_switcher);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, source_type);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_selection);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_selection);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_heading);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_list);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_heading);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_list);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_list_scrolled);
+
+ quark_monitor_widget_data = g_quark_from_static_string ("-monitor-widget-connector-quark");
+ quark_window_widget_data = g_quark_from_static_string ("-window-widget-connector-quark");
+}
+
+static void
+screen_cast_widget_init (ScreenCastWidget *widget)
+{
+ GtkScrolledWindow *scrolled_window;
+ GtkAdjustment *vadjustment;
+
+ gtk_widget_init_template (GTK_WIDGET (widget));
+
+ screen_cast_widget_set_app_id (widget, NULL);
+ screen_cast_widget_set_allow_multiple (widget, FALSE);
+
+ gtk_list_box_set_header_func (GTK_LIST_BOX (widget->monitor_list),
+ update_list_box_header,
+ NULL, NULL);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (widget->window_list),
+ update_list_box_header,
+ NULL, NULL);
+ scrolled_window = GTK_SCROLLED_WINDOW (widget->window_list_scrolled);
+ vadjustment = gtk_scrolled_window_get_vadjustment (scrolled_window);
+ gtk_list_box_set_adjustment (GTK_LIST_BOX (widget->window_list), vadjustment);
+
+ g_signal_connect (widget->source_type, "notify::visible-child",
+ G_CALLBACK (on_stack_switch),
+ widget);
+ g_signal_connect (widget->monitor_list, "row-activated",
+ G_CALLBACK (on_row_activated),
+ NULL);
+ g_signal_connect (widget->window_list, "row-activated",
+ G_CALLBACK (on_row_activated),
+ NULL);
+ g_signal_connect (widget->monitor_list, "selected-rows-changed",
+ G_CALLBACK (on_selected_rows_changed),
+ widget);
+ g_signal_connect (widget->window_list, "selected-rows-changed",
+ G_CALLBACK (on_selected_rows_changed),
+ widget);
+
+ widget->display_state_tracker = display_state_tracker_get ();
+ widget->monitors_changed_handler_id =
+ g_signal_connect (widget->display_state_tracker,
+ "monitors-changed",
+ G_CALLBACK (on_monitors_changed),
+ widget);
+ widget->shell_introspect = shell_introspect_get ();
+
+ update_monitors_list (widget);
+ update_windows_list (widget);
+
+ gtk_widget_show (widget->monitor_list);
+ gtk_widget_show (widget->window_list);
+}
+
+void
+init_screen_cast_widget (void)
+{
+ g_type_ensure (screen_cast_widget_get_type ());
}
void
screen_cast_widget_add_selections (ScreenCastWidget *widget,
- GVariantBuilder *selections_builder)
+ GVariantBuilder *selections_builder)
{
GVariantBuilder source_selections_builder;
@@ -474,7 +592,7 @@ screen_cast_widget_add_selections (ScreenCastWidget *widget,
void
screen_cast_widget_set_app_id (ScreenCastWidget *widget,
- const char *app_id)
+ const char *app_id)
{
g_autofree char *monitor_heading = NULL;
g_autofree char *window_heading = NULL;
@@ -508,7 +626,7 @@ screen_cast_widget_set_app_id (ScreenCastWidget *widget,
void
screen_cast_widget_set_allow_multiple (ScreenCastWidget *widget,
- gboolean multiple)
+ gboolean multiple)
{
gtk_list_box_set_selection_mode (GTK_LIST_BOX (widget->monitor_list),
multiple ? GTK_SELECTION_MULTIPLE
@@ -519,8 +637,8 @@ screen_cast_widget_set_allow_multiple (ScreenCastWidget *widget,
}
void
-screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
- ScreenCastSourceType source_types)
+screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
+ ScreenCastSourceType source_types)
{
if (source_types & SCREEN_CAST_SOURCE_TYPE_MONITOR)
gtk_widget_show (screen_cast_widget->monitor_selection);
@@ -531,113 +649,3 @@ screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
if (__builtin_popcount (source_types) > 1)
gtk_widget_show (screen_cast_widget->source_type_switcher);
}
-
-static void
-screen_cast_widget_finalize (GObject *object)
-{
- ScreenCastWidget *widget = SCREEN_CAST_WIDGET (object);
-
- g_signal_handler_disconnect (widget->display_state_tracker,
- widget->monitors_changed_handler_id);
-
- if (widget->windows_changed_handler_id)
- disconnect_windows_changed_listener (widget);
-
- if (widget->selection_changed_timeout_id > 0)
- {
- g_source_remove (widget->selection_changed_timeout_id);
- widget->selection_changed_timeout_id = 0;
- }
-
- G_OBJECT_CLASS (screen_cast_widget_parent_class)->finalize (object);
-}
-
-static void
-screen_cast_widget_init (ScreenCastWidget *widget)
-{
- GtkScrolledWindow *scrolled_window;
- GtkAdjustment *vadjustment;
-
- gtk_widget_init_template (GTK_WIDGET (widget));
-
- screen_cast_widget_set_app_id (widget, NULL);
- screen_cast_widget_set_allow_multiple (widget, FALSE);
-
- gtk_list_box_set_header_func (GTK_LIST_BOX (widget->monitor_list),
- update_list_box_header,
- NULL, NULL);
- gtk_list_box_set_header_func (GTK_LIST_BOX (widget->window_list),
- update_list_box_header,
- NULL, NULL);
- scrolled_window = GTK_SCROLLED_WINDOW (widget->window_list_scrolled);
- vadjustment = gtk_scrolled_window_get_vadjustment (scrolled_window);
- gtk_list_box_set_adjustment (GTK_LIST_BOX (widget->window_list), vadjustment);
-
- g_signal_connect (widget->source_type, "notify::visible-child",
- G_CALLBACK (on_stack_switch),
- widget);
- g_signal_connect (widget->monitor_list, "row-activated",
- G_CALLBACK (on_row_activated),
- NULL);
- g_signal_connect (widget->window_list, "row-activated",
- G_CALLBACK (on_row_activated),
- NULL);
- g_signal_connect (widget->monitor_list, "selected-rows-changed",
- G_CALLBACK (on_selected_rows_changed),
- widget);
- g_signal_connect (widget->window_list, "selected-rows-changed",
- G_CALLBACK (on_selected_rows_changed),
- widget);
-
- widget->display_state_tracker = display_state_tracker_get ();
- widget->monitors_changed_handler_id =
- g_signal_connect (widget->display_state_tracker,
- "monitors-changed",
- G_CALLBACK (on_monitors_changed),
- widget);
- widget->shell_introspect = shell_introspect_get ();
-
- update_monitors_list (widget);
- update_windows_list (widget);
-
- gtk_widget_show (widget->monitor_list);
- gtk_widget_show (widget->window_list);
-}
-
-static void
-screen_cast_widget_class_init (ScreenCastWidgetClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->finalize = screen_cast_widget_finalize;
-
- signals[HAS_SELECTION_CHANGED] = g_signal_new ("has-selection-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- NULL,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-
- gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/portal/desktop/gnome/screencastwidget.ui");
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, source_type_switcher);
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, source_type);
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_selection);
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_selection);
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_heading);
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_list);
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_heading);
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_list);
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_list_scrolled);
-
- quark_monitor_widget_data = g_quark_from_static_string ("-monitor-widget-connector-quark");
- quark_window_widget_data = g_quark_from_static_string ("-window-widget-connector-quark");
-}
-
-void
-init_screen_cast_widget (void)
-{
- g_type_ensure (screen_cast_widget_get_type ());
-}
diff --git a/src/screencastwidget.h b/src/screencastwidget.h
index 3a1ebd2..34360a3 100644
--- a/src/screencastwidget.h
+++ b/src/screencastwidget.h
@@ -31,13 +31,13 @@ G_DECLARE_FINAL_TYPE (ScreenCastWidget, screen_cast_widget,
void init_screen_cast_widget (void);
void screen_cast_widget_set_app_id (ScreenCastWidget *widget,
- const char *app_id);
+ const char *app_id);
void screen_cast_widget_set_allow_multiple (ScreenCastWidget *widget,
- gboolean multiple);
+ gboolean multiple);
-void screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
- ScreenCastSourceType source_types);
+void screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
+ ScreenCastSourceType source_types);
void screen_cast_widget_add_selections (ScreenCastWidget *widget,
- GVariantBuilder *selections_builder);
+ GVariantBuilder *selections_builder);
diff --git a/src/screencastwidget.ui b/src/screencastwidget.ui
index 2417ca5..fb83b94 100644
--- a/src/screencastwidget.ui
+++ b/src/screencastwidget.ui
@@ -19,6 +19,7 @@
<child>
<object class="GtkStack" id="source_type">
<property name="transition-type">crossfade</property>
+ <!-- Window selection page -->
<child>
<object class="GtkStackPage">
<property name="name">windows_page</property>
@@ -80,6 +81,8 @@
</property>
</object>
</child>
+
+ <!-- Physical monitor selection page -->
<child>
<object class="GtkStackPage">
<property name="name">monitors_page</property>

View File

@ -0,0 +1,223 @@
diff --git a/src/displaystatetracker.c b/src/displaystatetracker.c
index fc9109e..ebe1105 100644
--- a/src/displaystatetracker.c
+++ b/src/displaystatetracker.c
@@ -62,7 +62,7 @@ G_DEFINE_TYPE (DisplayStateTracker, display_state_tracker, G_TYPE_OBJECT)
static DisplayStateTracker *_display_state_tracker;
-static void
+void
monitor_free (Monitor *monitor)
{
g_free (monitor->connector);
@@ -71,6 +71,19 @@ monitor_free (Monitor *monitor)
g_free (monitor);
}
+Monitor *
+monitor_dup (Monitor *monitor)
+{
+ Monitor *new_monitor;
+
+ new_monitor = g_new0 (Monitor, 1);
+ new_monitor->connector = g_strdup (monitor->connector);
+ new_monitor->match_string = g_strdup (monitor->match_string);
+ new_monitor->display_name = g_strdup (monitor->display_name);
+
+ return new_monitor;
+}
+
const char *
monitor_get_connector (Monitor *monitor)
{
diff --git a/src/displaystatetracker.h b/src/displaystatetracker.h
index 1c3a7dc..e438dda 100644
--- a/src/displaystatetracker.h
+++ b/src/displaystatetracker.h
@@ -26,6 +26,10 @@ typedef struct _LogicalMonitor LogicalMonitor;
G_DECLARE_FINAL_TYPE (DisplayStateTracker, display_state_tracker,
DISPLAY, STATE_TRACKER, GObject)
+void monitor_free (Monitor *monitor);
+
+Monitor * monitor_dup (Monitor *monitor);
+
const char * monitor_get_connector (Monitor *monitor);
const char * monitor_get_match_string (Monitor *monitor);
diff --git a/src/screencast.c b/src/screencast.c
index 0a15033..724ffc9 100644
--- a/src/screencast.c
+++ b/src/screencast.c
@@ -469,6 +469,22 @@ find_best_window_by_app_id_and_title (const char *app_id,
return best_match;
}
+void
+screen_cast_stream_info_free (ScreenCastStreamInfo *info)
+{
+ switch (info->type)
+ {
+ case SCREEN_CAST_SOURCE_TYPE_MONITOR:
+ g_clear_pointer (&info->data.monitor, monitor_free);
+ break;
+ case SCREEN_CAST_SOURCE_TYPE_WINDOW:
+ g_clear_pointer (&info->data.window, window_free);
+ break;
+ }
+
+ g_free (info);
+}
+
static gboolean
restore_stream_from_data (ScreenCastSession *screen_cast_session)
@@ -486,7 +502,8 @@ restore_stream_from_data (ScreenCastSession *screen_cast_session)
if (!screen_cast_session->restored.data)
return FALSE;
- streams = g_ptr_array_new_with_free_func (g_free);
+ streams =
+ g_ptr_array_new_with_free_func ((GDestroyNotify) screen_cast_stream_info_free);
g_variant_get (screen_cast_session->restored.data,
RESTORE_VARIANT_TYPE,
@@ -512,7 +529,7 @@ restore_stream_from_data (ScreenCastSession *screen_cast_session)
info = g_new0 (ScreenCastStreamInfo, 1);
info->type = SCREEN_CAST_SOURCE_TYPE_MONITOR;
- info->data.monitor = monitor;
+ info->data.monitor = monitor_dup (monitor);
info->id = id;
g_ptr_array_add (streams, info);
}
@@ -537,7 +554,7 @@ restore_stream_from_data (ScreenCastSession *screen_cast_session)
info = g_new0 (ScreenCastStreamInfo, 1);
info->type = SCREEN_CAST_SOURCE_TYPE_WINDOW;
- info->data.window = window;
+ info->data.window = window_dup (window);
info->id = id;
g_ptr_array_add (streams, info);
}
diff --git a/src/screencast.h b/src/screencast.h
index 3d64b4a..ae8988d 100644
--- a/src/screencast.h
+++ b/src/screencast.h
@@ -64,3 +64,5 @@ typedef struct
gboolean screen_cast_init (GDBusConnection *connection,
GError **error);
+
+void screen_cast_stream_info_free (ScreenCastStreamInfo *info);
diff --git a/src/screencastwidget.c b/src/screencastwidget.c
index 11743f7..a40c824 100644
--- a/src/screencastwidget.c
+++ b/src/screencastwidget.c
@@ -101,9 +101,10 @@ create_window_widget (Window *window)
gtk_widget_set_margin_bottom (window_label, 12);
gtk_box_append (GTK_BOX (window_widget), window_label);
- g_object_set_qdata (G_OBJECT (window_widget),
- quark_window_widget_data,
- window);
+ g_object_set_qdata_full (G_OBJECT (window_widget),
+ quark_window_widget_data,
+ window_dup (window),
+ (GDestroyNotify) window_free);
return window_widget;
}
@@ -123,9 +124,12 @@ create_monitor_widget (LogicalMonitor *logical_monitor)
GtkWidget *monitor_label;
if (!l->prev)
- g_object_set_qdata (G_OBJECT (monitor_widget),
- quark_monitor_widget_data,
- monitor);
+ {
+ g_object_set_qdata_full (G_OBJECT (monitor_widget),
+ quark_monitor_widget_data,
+ monitor_dup (monitor),
+ (GDestroyNotify) monitor_free);
+ }
monitor_label = gtk_label_new (monitor_get_display_name (monitor));
gtk_widget_set_margin_top (monitor_label, 12);
@@ -599,7 +603,8 @@ screen_cast_widget_get_selected_streams (ScreenCastWidget *self)
uint32_t id = 0;
GList *l;
- streams = g_ptr_array_new_with_free_func (g_free);
+ streams =
+ g_ptr_array_new_with_free_func ((GDestroyNotify) screen_cast_stream_info_free);
selected_monitor_rows =
gtk_list_box_get_selected_rows (GTK_LIST_BOX (self->monitor_list));
@@ -619,7 +624,7 @@ screen_cast_widget_get_selected_streams (ScreenCastWidget *self)
info = g_new0 (ScreenCastStreamInfo, 1);
info->type = SCREEN_CAST_SOURCE_TYPE_MONITOR;
- info->data.monitor = monitor;
+ info->data.monitor = monitor_dup (monitor);
info->id = id++;
g_ptr_array_add (streams, info);
}
@@ -634,7 +639,7 @@ screen_cast_widget_get_selected_streams (ScreenCastWidget *self)
info = g_new0 (ScreenCastStreamInfo, 1);
info->type = SCREEN_CAST_SOURCE_TYPE_WINDOW;
- info->data.window = window;
+ info->data.window = window_dup (window);
info->id = id++;
g_ptr_array_add (streams, info);
}
diff --git a/src/shellintrospect.c b/src/shellintrospect.c
index 8a81086..d1bcc8c 100644
--- a/src/shellintrospect.c
+++ b/src/shellintrospect.c
@@ -62,7 +62,7 @@ static guint signals[N_SIGNALS];
static ShellIntrospect *_shell_introspect;
-static void
+void
window_free (Window *window)
{
g_free (window->title);
@@ -70,6 +70,19 @@ window_free (Window *window)
g_free (window);
}
+Window *
+window_dup (Window *window)
+{
+ Window *new_window;
+
+ new_window = g_new0 (Window, 1);
+ new_window->id = window->id;
+ new_window->title = g_strdup (window->title);
+ new_window->app_id = g_strdup (window->app_id);
+
+ return new_window;
+}
+
static void
get_windows_cb (GObject *source_object,
GAsyncResult *res,
diff --git a/src/shellintrospect.h b/src/shellintrospect.h
index f63ecee..ea4188f 100644
--- a/src/shellintrospect.h
+++ b/src/shellintrospect.h
@@ -34,6 +34,10 @@ void shell_introspect_ref_listeners (ShellIntrospect *shell_introspect);
void shell_introspect_unref_listeners (ShellIntrospect *shell_introspect);
+void window_free (Window *window);
+
+Window * window_dup (Window *window);
+
const char * window_get_app_id (Window *window);
const char * window_get_title (Window *window);

View File

@ -0,0 +1,23 @@
From a7c03eb9642a244f5623bf5bbe0e29f759554567 Mon Sep 17 00:00:00 2001
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Date: Wed, 10 Nov 2021 15:52:37 -0300
Subject: [PATCH] screencast: Cleanup unnecessary forward declaration
---
src/screencast.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/screencast.c b/src/screencast.c
index 38d1d05..98390ab 100644
--- a/src/screencast.c
+++ b/src/screencast.c
@@ -77,9 +77,6 @@ static GnomeScreenCast *gnome_screen_cast;
GType screen_cast_session_get_type (void);
G_DEFINE_TYPE (ScreenCastSession, screen_cast_session, session_get_type ())
-static void
-start_done (ScreenCastSession *session);
-
static gboolean
start_session (ScreenCastSession *session,
GVariant *selections,

View File

@ -0,0 +1,452 @@
From 367f05b980ab780ae3b3380164f2135ce4f487fa Mon Sep 17 00:00:00 2001
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Date: Wed, 10 Nov 2021 16:04:59 -0300
Subject: [PATCH] screencast: More code shuffling and cleanups
No funcional changes.
---
src/screencast.c | 350 +++++++++++++++++++++++------------------------
1 file changed, 168 insertions(+), 182 deletions(-)
diff --git a/src/screencast.c b/src/screencast.c
index 98390ab..4ba67aa 100644
--- a/src/screencast.c
+++ b/src/screencast.c
@@ -82,10 +82,6 @@ start_session (ScreenCastSession *session,
GVariant *selections,
GError **error);
-static void
-cancel_start_session (ScreenCastSession *session,
- int response);
-
static gboolean
is_screen_cast_session (Session *session)
{
@@ -108,10 +104,23 @@ screen_cast_dialog_handle_close (ScreenCastDialogHandle *dialog_handle)
screen_cast_dialog_handle_free (dialog_handle);
}
+static void
+cancel_start_session (ScreenCastSession *screen_cast_session,
+ int response)
+{
+ GVariantBuilder results_builder;
+
+ g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT);
+ xdp_impl_screen_cast_complete_start (XDP_IMPL_SCREEN_CAST (impl),
+ screen_cast_session->start_invocation,
+ response,
+ g_variant_builder_end (&results_builder));
+}
+
static gboolean
-handle_close (XdpImplRequest *object,
- GDBusMethodInvocation *invocation,
- ScreenCastDialogHandle *dialog_handle)
+on_request_handle_close_cb (XdpImplRequest *object,
+ GDBusMethodInvocation *invocation,
+ ScreenCastDialogHandle *dialog_handle)
{
cancel_start_session (dialog_handle->session, 2);
@@ -121,10 +130,10 @@ handle_close (XdpImplRequest *object,
}
static void
-screen_cast_dialog_done (GtkWidget *widget,
- int dialog_response,
- GVariant *selections,
- ScreenCastDialogHandle *dialog_handle)
+on_screen_cast_dialog_done_cb (GtkWidget *widget,
+ int dialog_response,
+ GVariant *selections,
+ ScreenCastDialogHandle *dialog_handle)
{
int response;
@@ -165,10 +174,10 @@ screen_cast_dialog_done (GtkWidget *widget,
}
static ScreenCastDialogHandle *
-create_screen_cast_dialog (ScreenCastSession *session,
+create_screen_cast_dialog (ScreenCastSession *session,
GDBusMethodInvocation *invocation,
- Request *request,
- const char *parent_window)
+ Request *request,
+ const char *parent_window)
{
ScreenCastDialogHandle *dialog_handle;
ExternalWindow *external_parent;
@@ -210,10 +219,9 @@ create_screen_cast_dialog (ScreenCastSession *session,
dialog_handle->dialog = dialog;
g_signal_connect (request, "handle-close",
- G_CALLBACK (handle_close), dialog_handle);
-
+ G_CALLBACK (on_request_handle_close_cb), dialog_handle);
g_signal_connect (dialog, "done",
- G_CALLBACK (screen_cast_dialog_done), dialog_handle);
+ G_CALLBACK (on_screen_cast_dialog_done_cb), dialog_handle);
gtk_widget_realize (dialog);
@@ -226,145 +234,6 @@ create_screen_cast_dialog (ScreenCastSession *session,
return dialog_handle;
}
-static ScreenCastSession *
-screen_cast_session_new (const char *app_id,
- const char *session_handle)
-{
- ScreenCastSession *screen_cast_session;
-
- screen_cast_session = g_object_new (screen_cast_session_get_type (),
- "id", session_handle,
- NULL);
-
- return screen_cast_session;
-}
-
-static gboolean
-handle_create_session (XdpImplScreenCast *object,
- GDBusMethodInvocation *invocation,
- const char *arg_handle,
- const char *arg_session_handle,
- const char *arg_app_id,
- GVariant *arg_options)
-{
- g_autoptr(GError) error = NULL;
- int response;
- Session *session;
- GVariantBuilder results_builder;
-
- session = (Session *)screen_cast_session_new (arg_app_id,
- arg_session_handle);
-
- if (!session_export (session,
- g_dbus_method_invocation_get_connection (invocation),
- &error))
- {
- g_clear_object (&session);
- g_warning ("Failed to create screen cast session: %s", error->message);
- response = 2;
- goto out;
- }
-
- response = 0;
-
-out:
- g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT);
- xdp_impl_screen_cast_complete_create_session (object,
- invocation,
- response,
- g_variant_builder_end (&results_builder));
-
- return TRUE;
-}
-
-static gboolean
-handle_select_sources (XdpImplScreenCast *object,
- GDBusMethodInvocation *invocation,
- const char *arg_handle,
- const char *arg_session_handle,
- const char *arg_app_id,
- GVariant *arg_options)
-{
- Session *session;
- int response;
- uint32_t types;
- gboolean multiple;
- ScreenCastCursorMode cursor_mode;
- ScreenCastSelection select;
- GVariantBuilder results_builder;
- GVariant *results;
-
- session = lookup_session (arg_session_handle);
- if (!session)
- {
- g_warning ("Tried to select sources on non-existing %s", arg_session_handle);
- response = 2;
- goto out;
- }
-
- if (!g_variant_lookup (arg_options, "multiple", "b", &multiple))
- multiple = FALSE;
-
- if (!g_variant_lookup (arg_options, "types", "u", &types))
- types = SCREEN_CAST_SOURCE_TYPE_MONITOR;
-
- if (!(types & (SCREEN_CAST_SOURCE_TYPE_MONITOR |
- SCREEN_CAST_SOURCE_TYPE_WINDOW)))
- {
- g_warning ("Unknown screen cast source type");
- response = 2;
- goto out;
- }
-
- if (!g_variant_lookup (arg_options, "cursor_mode", "u", &cursor_mode))
- cursor_mode = SCREEN_CAST_CURSOR_MODE_HIDDEN;
-
- switch (cursor_mode)
- {
- case SCREEN_CAST_CURSOR_MODE_HIDDEN:
- case SCREEN_CAST_CURSOR_MODE_EMBEDDED:
- case SCREEN_CAST_CURSOR_MODE_METADATA:
- break;
- default:
- g_warning ("Unknown screen cast cursor mode");
- response = 2;
- goto out;
- }
-
- select.multiple = multiple;
- select.source_types = types;
- select.cursor_mode = cursor_mode;
-
- if (is_screen_cast_session (session))
- {
- ScreenCastSession *screen_cast_session = (ScreenCastSession *)session;
-
- screen_cast_session->select = select;
- response = 0;
- }
- else if (is_remote_desktop_session (session))
- {
- RemoteDesktopSession *remote_desktop_session =
- (RemoteDesktopSession *)session;
-
- remote_desktop_session_sources_selected (remote_desktop_session, &select);
- response = 0;
- }
- else
- {
- g_warning ("Tried to select sources on invalid session type");
- response = 2;
- }
-
-out:
- g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT);
- results = g_variant_builder_end (&results_builder);
- xdp_impl_screen_cast_complete_select_sources (object, invocation,
- response, results);
-
- return TRUE;
-}
-
static void
start_done (ScreenCastSession *screen_cast_session)
{
@@ -391,14 +260,14 @@ start_done (ScreenCastSession *screen_cast_session)
static void
on_gnome_screen_cast_session_ready (GnomeScreenCastSession *gnome_screen_cast_session,
- ScreenCastSession *screen_cast_session)
+ ScreenCastSession *screen_cast_session)
{
start_done (screen_cast_session);
}
static void
on_gnome_screen_cast_session_closed (GnomeScreenCastSession *gnome_screen_cast_session,
- ScreenCastSession *screen_cast_session)
+ ScreenCastSession *screen_cast_session)
{
session_close ((Session *)screen_cast_session);
}
@@ -441,27 +310,14 @@ start_session (ScreenCastSession *screen_cast_session,
return TRUE;
}
-static void
-cancel_start_session (ScreenCastSession *screen_cast_session,
- int response)
-{
- GVariantBuilder results_builder;
-
- g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT);
- xdp_impl_screen_cast_complete_start (XDP_IMPL_SCREEN_CAST (impl),
- screen_cast_session->start_invocation,
- response,
- g_variant_builder_end (&results_builder));
-}
-
static gboolean
-handle_start (XdpImplScreenCast *object,
+handle_start (XdpImplScreenCast *object,
GDBusMethodInvocation *invocation,
- const char *arg_handle,
- const char *arg_session_handle,
- const char *arg_app_id,
- const char *arg_parent_window,
- GVariant *arg_options)
+ const char *arg_handle,
+ const char *arg_session_handle,
+ const char *arg_app_id,
+ const char *arg_parent_window,
+ GVariant *arg_options)
{
const char *sender;
g_autoptr(Request) request = NULL;
@@ -507,6 +363,133 @@ err:
return TRUE;
}
+static gboolean
+handle_select_sources (XdpImplScreenCast *object,
+ GDBusMethodInvocation *invocation,
+ const char *arg_handle,
+ const char *arg_session_handle,
+ const char *arg_app_id,
+ GVariant *arg_options)
+{
+ Session *session;
+ int response;
+ uint32_t types;
+ gboolean multiple;
+ ScreenCastCursorMode cursor_mode;
+ ScreenCastSelection select;
+ GVariantBuilder results_builder;
+ GVariant *results;
+
+ session = lookup_session (arg_session_handle);
+ if (!session)
+ {
+ g_warning ("Tried to select sources on non-existing %s", arg_session_handle);
+ response = 2;
+ goto out;
+ }
+
+ if (!g_variant_lookup (arg_options, "multiple", "b", &multiple))
+ multiple = FALSE;
+
+ if (!g_variant_lookup (arg_options, "types", "u", &types))
+ types = SCREEN_CAST_SOURCE_TYPE_MONITOR;
+
+ if (!(types & (SCREEN_CAST_SOURCE_TYPE_MONITOR |
+ SCREEN_CAST_SOURCE_TYPE_WINDOW)))
+ {
+ g_warning ("Unknown screen cast source type");
+ response = 2;
+ goto out;
+ }
+
+ if (!g_variant_lookup (arg_options, "cursor_mode", "u", &cursor_mode))
+ cursor_mode = SCREEN_CAST_CURSOR_MODE_HIDDEN;
+
+ switch (cursor_mode)
+ {
+ case SCREEN_CAST_CURSOR_MODE_HIDDEN:
+ case SCREEN_CAST_CURSOR_MODE_EMBEDDED:
+ case SCREEN_CAST_CURSOR_MODE_METADATA:
+ break;
+ default:
+ g_warning ("Unknown screen cast cursor mode");
+ response = 2;
+ goto out;
+ }
+
+ select.multiple = multiple;
+ select.source_types = types;
+ select.cursor_mode = cursor_mode;
+
+ if (is_screen_cast_session (session))
+ {
+ ScreenCastSession *screen_cast_session = (ScreenCastSession *)session;
+
+ screen_cast_session->select = select;
+ response = 0;
+ }
+ else if (is_remote_desktop_session (session))
+ {
+ RemoteDesktopSession *remote_desktop_session =
+ (RemoteDesktopSession *)session;
+
+ remote_desktop_session_sources_selected (remote_desktop_session, &select);
+ response = 0;
+ }
+ else
+ {
+ g_warning ("Tried to select sources on invalid session type");
+ response = 2;
+ }
+
+out:
+ g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT);
+ results = g_variant_builder_end (&results_builder);
+ xdp_impl_screen_cast_complete_select_sources (object, invocation,
+ response, results);
+
+ return TRUE;
+}
+
+static gboolean
+handle_create_session (XdpImplScreenCast *object,
+ GDBusMethodInvocation *invocation,
+ const char *arg_handle,
+ const char *arg_session_handle,
+ const char *arg_app_id,
+ GVariant *arg_options)
+{
+ g_autoptr(GError) error = NULL;
+ int response;
+ Session *session;
+ GVariantBuilder results_builder;
+
+ session = g_object_new (screen_cast_session_get_type (),
+ "id", arg_session_handle,
+ NULL);
+
+ if (!session_export (session,
+ g_dbus_method_invocation_get_connection (invocation),
+ &error))
+ {
+ g_clear_object (&session);
+ g_warning ("Failed to create screen cast session: %s", error->message);
+ response = 2;
+ goto out;
+ }
+
+ response = 0;
+
+out:
+ g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT);
+ xdp_impl_screen_cast_complete_create_session (object,
+ invocation,
+ response,
+ g_variant_builder_end (&results_builder));
+
+ return TRUE;
+}
+
static void
on_gnome_screen_cast_enabled (GnomeScreenCast *gnome_screen_cast)
{
@@ -535,9 +518,12 @@ on_gnome_screen_cast_enabled (GnomeScreenCast *gnome_screen_cast)
available_cursor_modes = SCREEN_CAST_CURSOR_MODE_NONE;
if (gnome_api_version >= 2)
- available_cursor_modes |= (SCREEN_CAST_CURSOR_MODE_HIDDEN |
- SCREEN_CAST_CURSOR_MODE_EMBEDDED |
- SCREEN_CAST_CURSOR_MODE_METADATA);
+ {
+ available_cursor_modes |= SCREEN_CAST_CURSOR_MODE_HIDDEN |
+ SCREEN_CAST_CURSOR_MODE_EMBEDDED |
+ SCREEN_CAST_CURSOR_MODE_METADATA;
+ }
+
g_object_set (G_OBJECT (impl),
"available-cursor-modes", available_cursor_modes,
NULL);
@@ -620,8 +606,8 @@ screen_cast_session_class_init (ScreenCastSessionClass *klass)
}
gboolean
-screen_cast_init (GDBusConnection *connection,
- GError **error)
+screen_cast_init (GDBusConnection *connection,
+ GError **error)
{
impl_connection = connection;
gnome_screen_cast = gnome_screen_cast_new (connection);

View File

@ -0,0 +1,744 @@
From 0f6957254e32ab6dc1c132c0f7623bbac31309f6 Mon Sep 17 00:00:00 2001
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Date: Wed, 10 Nov 2021 19:54:39 -0300
Subject: [PATCH] screencastwidget: Rework selection APIs
Instead of passing data around using GVariants, add
properly types variables and structures all around.
This will vastly simplify future commits introducing
screencast stream restore.
---
src/gnomescreencast.c | 51 ++++++-------
src/gnomescreencast.h | 8 +-
src/remotedesktop.c | 40 +++++-----
src/remotedesktopdialog.c | 35 ++++-----
src/screencast.c | 151 +++++++++++++++++---------------------
src/screencast.h | 12 +++
src/screencastdialog.c | 15 ++--
src/screencastwidget.c | 132 +++++++++++++++------------------
src/screencastwidget.h | 3 +-
9 files changed, 203 insertions(+), 244 deletions(-)
diff --git a/src/gnomescreencast.c b/src/gnomescreencast.c
index abf5b53..3f8539c 100644
--- a/src/gnomescreencast.c
+++ b/src/gnomescreencast.c
@@ -274,10 +274,10 @@ cursor_mode_to_gnome_cursor_mode (ScreenCastCursorMode cursor_mode)
}
static gboolean
-gnome_screen_cast_session_record_window (GnomeScreenCastSession *gnome_screen_cast_session,
- const guint64 id,
- ScreenCastSelection *select,
- GError **error)
+gnome_screen_cast_session_record_window (GnomeScreenCastSession *gnome_screen_cast_session,
+ Window *window,
+ ScreenCastSelection *select,
+ GError **error)
{
OrgGnomeMutterScreenCastSession *session_proxy =
gnome_screen_cast_session->proxy;
@@ -292,7 +292,7 @@ gnome_screen_cast_session_record_window (GnomeScreenCastSession *gnome_screen_ca
g_variant_builder_init (&properties_builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&properties_builder, "{sv}",
"window-id",
- g_variant_new_uint64 (id));
+ g_variant_new_uint64 (window_get_id (window)));
if (select->cursor_mode)
{
uint32_t gnome_cursor_mode;
@@ -356,10 +356,10 @@ gnome_screen_cast_session_record_window (GnomeScreenCastSession *gnome_screen_ca
}
static gboolean
-gnome_screen_cast_session_record_monitor (GnomeScreenCastSession *gnome_screen_cast_session,
- const char *connector,
- ScreenCastSelection *select,
- GError **error)
+gnome_screen_cast_session_record_monitor (GnomeScreenCastSession *gnome_screen_cast_session,
+ Monitor *monitor,
+ ScreenCastSelection *select,
+ GError **error)
{
OrgGnomeMutterScreenCastSession *session_proxy =
gnome_screen_cast_session->proxy;
@@ -370,6 +370,7 @@ gnome_screen_cast_session_record_monitor (GnomeScreenCastSession *gnome_screen_c
OrgGnomeMutterScreenCastStream *stream_proxy;
GnomeScreenCastStream *stream;
GVariant *parameters;
+ const char *connector;
g_variant_builder_init (&properties_builder, G_VARIANT_TYPE_VARDICT);
if (select->cursor_mode)
@@ -383,6 +384,7 @@ gnome_screen_cast_session_record_monitor (GnomeScreenCastSession *gnome_screen_c
}
properties = g_variant_builder_end (&properties_builder);
+ connector = monitor_get_connector (monitor);
if (!org_gnome_mutter_screen_cast_session_call_record_monitor_sync (session_proxy,
connector,
properties,
@@ -436,40 +438,29 @@ gnome_screen_cast_session_record_monitor (GnomeScreenCastSession *gnome_screen_c
}
gboolean
-gnome_screen_cast_session_record_selections (GnomeScreenCastSession *gnome_screen_cast_session,
- GVariant *selections,
- ScreenCastSelection *select,
- GError **error)
+gnome_screen_cast_session_record_selections (GnomeScreenCastSession *gnome_screen_cast_session,
+ GPtrArray *streams,
+ ScreenCastSelection *select,
+ GError **error)
{
- GVariantIter selections_iter;
- GVariant *selection;
+ guint i;
- g_variant_iter_init (&selections_iter, selections);
- while ((selection = g_variant_iter_next_value (&selections_iter)))
+ for (i = 0; i < streams->len; i++)
{
- ScreenCastSourceType source_type;
- g_autofree char *key = NULL;
- g_autoptr(GVariant) variant = NULL;
- guint64 id;
+ ScreenCastStreamInfo *info = g_ptr_array_index (streams, i);
- g_variant_get (selection, "(u?)",
- &source_type,
- &variant);
-
- switch (source_type)
+ switch (info->type)
{
case SCREEN_CAST_SOURCE_TYPE_MONITOR:
- key = g_variant_dup_string (variant, NULL);
if (!gnome_screen_cast_session_record_monitor (gnome_screen_cast_session,
- key,
+ info->data.monitor,
select,
error))
return FALSE;
break;
case SCREEN_CAST_SOURCE_TYPE_WINDOW:
- id = g_variant_get_uint64 (variant);
if (!gnome_screen_cast_session_record_window (gnome_screen_cast_session,
- id,
+ info->data.window,
select,
error))
return FALSE;
diff --git a/src/gnomescreencast.h b/src/gnomescreencast.h
index 06e4e1e..748cf7d 100644
--- a/src/gnomescreencast.h
+++ b/src/gnomescreencast.h
@@ -34,10 +34,10 @@ const char * gnome_screen_cast_session_get_stream_path_from_id (GnomeScreenCastS
void gnome_screen_cast_session_add_stream_properties (GnomeScreenCastSession *gnome_screen_cast_session,
GVariantBuilder *streams_builder);
-gboolean gnome_screen_cast_session_record_selections (GnomeScreenCastSession *gnome_screen_cast_session,
- GVariant *selections,
- ScreenCastSelection *select,
- GError **error);
+gboolean gnome_screen_cast_session_record_selections (GnomeScreenCastSession *gnome_screen_cast_session,
+ GPtrArray *streams,
+ ScreenCastSelection *select,
+ GError **error);
gboolean gnome_screen_cast_session_stop (GnomeScreenCastSession *gnome_screen_cast_session,
GError **error);
diff --git a/src/remotedesktop.c b/src/remotedesktop.c
index a1c688a..46d1dcc 100644
--- a/src/remotedesktop.c
+++ b/src/remotedesktop.c
@@ -104,9 +104,10 @@ static void
start_done (RemoteDesktopSession *session);
static gboolean
-start_session (RemoteDesktopSession *session,
- GVariant *selections,
- GError **error);
+start_session (RemoteDesktopSession *session,
+ RemoteDesktopDeviceType device_types,
+ GPtrArray *streams,
+ GError **error);
static void
cancel_start_session (RemoteDesktopSession *session,
@@ -155,9 +156,10 @@ handle_close (XdpImplRequest *object,
}
static void
-remote_desktop_dialog_done (GtkWidget *widget,
- int dialog_response,
- GVariant *selections,
+remote_desktop_dialog_done (GtkWidget *widget,
+ int dialog_response,
+ RemoteDesktopDeviceType device_types,
+ GPtrArray *streams,
RemoteDesktopDialogHandle *dialog_handle)
{
int response;
@@ -184,7 +186,7 @@ remote_desktop_dialog_done (GtkWidget *widget,
{
g_autoptr(GError) error = NULL;
- if (!start_session (dialog_handle->session, selections, &error))
+ if (!start_session (dialog_handle->session, device_types, streams, &error))
{
g_warning ("Failed to start session: %s", error->message);
response = 2;
@@ -453,9 +455,9 @@ on_gnome_screen_cast_session_ready (GnomeScreenCastSession *gnome_screen_cast_se
}
static gboolean
-open_screen_cast_session (RemoteDesktopSession *remote_desktop_session,
- GVariant *source_selections,
- GError **error)
+open_screen_cast_session (RemoteDesktopSession *remote_desktop_session,
+ GPtrArray *streams,
+ GError **error)
{
OrgGnomeMutterRemoteDesktopSession *session_proxy =
remote_desktop_session->mutter_session_proxy;
@@ -478,7 +480,7 @@ open_screen_cast_session (RemoteDesktopSession *remote_desktop_session,
remote_desktop_session);
if (!gnome_screen_cast_session_record_selections (gnome_screen_cast_session,
- source_selections,
+ streams,
&remote_desktop_session->select.screen_cast,
error))
return FALSE;
@@ -487,23 +489,19 @@ open_screen_cast_session (RemoteDesktopSession *remote_desktop_session,
}
static gboolean
-start_session (RemoteDesktopSession *remote_desktop_session,
- GVariant *selections,
- GError **error)
+start_session (RemoteDesktopSession *remote_desktop_session,
+ RemoteDesktopDeviceType device_types,
+ GPtrArray *streams,
+ GError **error)
{
OrgGnomeMutterRemoteDesktopSession *session_proxy;
- RemoteDesktopDeviceType device_types = 0;
- g_autoptr(GVariant) source_selections = NULL;
gboolean need_streams;
- g_variant_lookup (selections, "selected_device_types", "u", &device_types);
remote_desktop_session->shared.device_types = device_types;
- if (g_variant_lookup (selections, "selected_screen_cast_sources", "@a(us)",
- &source_selections))
+ if (streams)
{
- if (!open_screen_cast_session (remote_desktop_session,
- source_selections, error))
+ if (!open_screen_cast_session (remote_desktop_session, streams, error))
return FALSE;
need_streams = TRUE;
diff --git a/src/remotedesktopdialog.c b/src/remotedesktopdialog.c
index a21b008..bae7678 100644
--- a/src/remotedesktopdialog.c
+++ b/src/remotedesktopdialog.c
@@ -61,9 +61,8 @@ static GQuark quark_device_widget_data;
G_DEFINE_TYPE (RemoteDesktopDialog, remote_desktop_dialog, GTK_TYPE_WINDOW)
-static void
-add_device_type_selections (RemoteDesktopDialog *dialog,
- GVariantBuilder *selections_builder)
+static RemoteDesktopDeviceType
+get_selected_device_types (RemoteDesktopDialog *dialog)
{
GList *selected_rows;
GList *l;
@@ -81,43 +80,36 @@ add_device_type_selections (RemoteDesktopDialog *dialog,
}
g_list_free (selected_rows);
- g_variant_builder_add (selections_builder, "{sv}",
- "selected_device_types",
- g_variant_new_uint32 (selected_device_types));
+ return selected_device_types;
}
static void
button_clicked (GtkWidget *button,
RemoteDesktopDialog *dialog)
{
+ RemoteDesktopDeviceType device_types = 0;
+ g_autoptr(GPtrArray) streams = NULL;
int response;
- GVariant *selections;
gtk_widget_hide (GTK_WIDGET (dialog));
if (button == dialog->accept_button)
{
- GVariantBuilder selections_builder;
ScreenCastWidget *screen_cast_widget =
SCREEN_CAST_WIDGET (dialog->screen_cast_widget);
response = GTK_RESPONSE_OK;
-
- g_variant_builder_init (&selections_builder, G_VARIANT_TYPE_VARDICT);
-
- add_device_type_selections (dialog, &selections_builder);
- if (dialog->screen_cast_enable)
- screen_cast_widget_add_selections (screen_cast_widget,
- &selections_builder);
- selections = g_variant_builder_end (&selections_builder);
+ device_types = get_selected_device_types (dialog);
+ streams = screen_cast_widget_get_selected_streams (screen_cast_widget);
}
else
{
response = GTK_RESPONSE_CANCEL;
- selections = NULL;
+ device_types = 0;
+ streams = NULL;
}
- g_signal_emit (dialog, signals[DONE], 0, response, selections);
+ g_signal_emit (dialog, signals[DONE], 0, response, device_types, streams);
}
static void
@@ -356,7 +348,7 @@ remote_desktop_dialog_close_request (GtkWindow *dialog)
{
gtk_widget_hide (GTK_WIDGET (dialog));
- g_signal_emit (dialog, signals[DONE], 0, GTK_RESPONSE_CANCEL, NULL);
+ g_signal_emit (dialog, signals[DONE], 0, GTK_RESPONSE_CANCEL, 0, NULL);
return TRUE;
}
@@ -375,9 +367,10 @@ remote_desktop_dialog_class_init (RemoteDesktopDialogClass *klass)
0,
NULL, NULL,
NULL,
- G_TYPE_NONE, 2,
+ G_TYPE_NONE, 3,
+ G_TYPE_INT,
G_TYPE_INT,
- G_TYPE_VARIANT);
+ G_TYPE_PTR_ARRAY);
init_screen_cast_widget ();
diff --git a/src/screencast.c b/src/screencast.c
index 4ba67aa..2713d26 100644
--- a/src/screencast.c
+++ b/src/screencast.c
@@ -77,11 +77,6 @@ static GnomeScreenCast *gnome_screen_cast;
GType screen_cast_session_get_type (void);
G_DEFINE_TYPE (ScreenCastSession, screen_cast_session, session_get_type ())
-static gboolean
-start_session (ScreenCastSession *session,
- GVariant *selections,
- GError **error);
-
static gboolean
is_screen_cast_session (Session *session)
{
@@ -129,10 +124,76 @@ on_request_handle_close_cb (XdpImplRequest *object,
return FALSE;
}
+static void
+on_gnome_screen_cast_session_ready (GnomeScreenCastSession *gnome_screen_cast_session,
+ ScreenCastSession *screen_cast_session)
+{
+ GVariantBuilder streams_builder;
+ GVariantBuilder results_builder;
+
+ g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_init (&streams_builder, G_VARIANT_TYPE ("a(ua{sv})"));
+
+ gnome_screen_cast_session = screen_cast_session->gnome_screen_cast_session;
+ gnome_screen_cast_session_add_stream_properties (gnome_screen_cast_session,
+ &streams_builder);
+
+ g_variant_builder_add (&results_builder, "{sv}",
+ "streams",
+ g_variant_builder_end (&streams_builder));
+
+ xdp_impl_screen_cast_complete_start (XDP_IMPL_SCREEN_CAST (impl),
+ screen_cast_session->start_invocation, 0,
+ g_variant_builder_end (&results_builder));
+ screen_cast_session->start_invocation = NULL;
+}
+
+static void
+on_gnome_screen_cast_session_closed (GnomeScreenCastSession *gnome_screen_cast_session,
+ ScreenCastSession *screen_cast_session)
+{
+ session_close ((Session *)screen_cast_session);
+}
+
+static gboolean
+start_session (ScreenCastSession *screen_cast_session,
+ GPtrArray *streams,
+ GError **error)
+{
+ GnomeScreenCastSession *gnome_screen_cast_session;
+
+ gnome_screen_cast_session =
+ gnome_screen_cast_create_session (gnome_screen_cast, NULL, error);
+ if (!gnome_screen_cast_session)
+ return FALSE;
+
+ screen_cast_session->gnome_screen_cast_session = gnome_screen_cast_session;
+
+ screen_cast_session->session_ready_handler_id =
+ g_signal_connect (gnome_screen_cast_session, "ready",
+ G_CALLBACK (on_gnome_screen_cast_session_ready),
+ screen_cast_session);
+ screen_cast_session->session_closed_handler_id =
+ g_signal_connect (gnome_screen_cast_session, "closed",
+ G_CALLBACK (on_gnome_screen_cast_session_closed),
+ screen_cast_session);
+
+ if (!gnome_screen_cast_session_record_selections (gnome_screen_cast_session,
+ streams,
+ &screen_cast_session->select,
+ error))
+ return FALSE;
+
+ if (!gnome_screen_cast_session_start (gnome_screen_cast_session, error))
+ return FALSE;
+
+ return TRUE;
+}
+
static void
on_screen_cast_dialog_done_cb (GtkWidget *widget,
int dialog_response,
- GVariant *selections,
+ GPtrArray *streams,
ScreenCastDialogHandle *dialog_handle)
{
int response;
@@ -159,7 +220,7 @@ on_screen_cast_dialog_done_cb (GtkWidget *widget,
{
g_autoptr(GError) error = NULL;
- if (!start_session (dialog_handle->session, selections, &error))
+ if (!start_session (dialog_handle->session, streams, &error))
{
g_warning ("Failed to start session: %s", error->message);
response = 2;
@@ -234,82 +295,6 @@ create_screen_cast_dialog (ScreenCastSession *session,
return dialog_handle;
}
-static void
-start_done (ScreenCastSession *screen_cast_session)
-{
- GnomeScreenCastSession *gnome_screen_cast_session;
- GVariantBuilder streams_builder;
- GVariantBuilder results_builder;
-
- g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT);
- g_variant_builder_init (&streams_builder, G_VARIANT_TYPE ("a(ua{sv})"));
-
- gnome_screen_cast_session = screen_cast_session->gnome_screen_cast_session;
- gnome_screen_cast_session_add_stream_properties (gnome_screen_cast_session,
- &streams_builder);
-
- g_variant_builder_add (&results_builder, "{sv}",
- "streams",