From d8ae1087d3d6adc34a896be50ecbbdf58a58c773 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 27 Jun 2018 15:20:16 +0200 Subject: [PATCH 1/6] RDA support: Make MATE panel aware of being run inside a remote desktop technology. --- configure.ac | 7 ++++++ mate-panel/Makefile.am | 2 ++ mate-panel/panel-action-button.c | 37 ++++++++++++++++++++++++++++++ mate-panel/panel-enums-gsettings.h | 1 + mate-panel/panel-icon-names.h | 5 ++++ mate-panel/panel-menu-items.c | 25 ++++++++++++++++++++ 6 files changed, 77 insertions(+) diff --git a/configure.ac b/configure.ac index bfa9afc24..8db576013 100644 --- a/configure.ac +++ b/configure.ac @@ -243,6 +243,13 @@ if test "x$have_randr" = "xyes"; then AC_DEFINE(HAVE_RANDR, 1, [Have the Xrandr extension library]) fi +dnl Remote Desktop Awareness + +PKG_CHECK_MODULES(RDA, rda, have_rda=yes, have_rda=no) +if test "x$have_rda" = "xyes"; then + AC_DEFINE(HAVE_RDA, 1, [Have the Remote Desktop Awareness library]) +fi + dnl Modules dir AC_SUBST([modulesdir],"\$(libdir)/mate-panel/modules") diff --git a/mate-panel/Makefile.am b/mate-panel/Makefile.am index f2f04d27b..b588bad36 100644 --- a/mate-panel/Makefile.am +++ b/mate-panel/Makefile.am @@ -142,6 +142,7 @@ mate_panel_SOURCES = \ mate_panel_CPPFLAGS = \ $(AM_CPPFLAGS) \ $(XRANDR_CFLAGS) \ + $(RDA_CFLAGS) \ -DPANEL_MODULES_DIR=\"$(modulesdir)\" \ -DMATEMENU_I_KNOW_THIS_IS_UNSTABLE @@ -157,6 +158,7 @@ mate_panel_LDADD = \ $(PANEL_LIBS) \ $(DCONF_LIBS) \ $(XRANDR_LIBS) \ + $(RDA_LIBS) \ $(X_LIBS) \ $(WAYLAND_LIBS) diff --git a/mate-panel/panel-action-button.c b/mate-panel/panel-action-button.c index 7d5bdefaa..87b67cd51 100644 --- a/mate-panel/panel-action-button.c +++ b/mate-panel/panel-action-button.c @@ -34,6 +34,10 @@ #include #include +#ifdef HAVE_RDA +#include +#endif + #define MATE_DESKTOP_USE_UNSTABLE_API #include #include @@ -86,6 +90,9 @@ static const char *panel_action_type [PANEL_ACTION_LAST] = { [PANEL_ACTION_NONE] = "none", [PANEL_ACTION_LOCK] = "lock", [PANEL_ACTION_LOGOUT] = "logout", +#ifdef HAVE_RDA + [PANEL_ACTION_SUSPEND] = "suspend", +#endif [PANEL_ACTION_RUN] = "run", [PANEL_ACTION_SEARCH] = "search", [PANEL_ACTION_FORCE_QUIT] = "force-quit", @@ -213,6 +220,24 @@ panel_action_logout (GtkWidget *widget) PANEL_SESSION_MANAGER_LOGOUT_MODE_NORMAL); } +#ifdef HAVE_RDA +/* Suspend Remote Session + */ +static void +panel_action_suspend (GtkWidget *widget) +{ + + rda_session_suspend(); + +} + +static gboolean +panel_action_suspend_not_supported(void) +{ + return (!rda_session_can_be_suspended()); +} +#endif /* HAVE_RDA */ + static void panel_action_shutdown (GtkWidget *widget) { @@ -361,6 +386,18 @@ static PanelAction actions [PANEL_ACTION_LAST] = { panel_action_logout, NULL, NULL, panel_lockdown_get_disable_log_out }, +#ifdef HAVE_RDA + [PANEL_ACTION_SUSPEND] = { + PANEL_ACTION_SUSPEND, + PANEL_ICON_SUSPEND, + N_("Suspend Session..."), + N_("Suspend the Remote Session and Resume later"), + "gospanel-20", + "ACTION:suspend:NEW", + panel_action_suspend, NULL, NULL, + panel_action_suspend_not_supported + }, +#endif /* HAVE_RDA */ [PANEL_ACTION_RUN] = { PANEL_ACTION_RUN, PANEL_ICON_RUN, diff --git a/mate-panel/panel-enums-gsettings.h b/mate-panel/panel-enums-gsettings.h index 89e8f7e1c..ad75d533b 100644 --- a/mate-panel/panel-enums-gsettings.h +++ b/mate-panel/panel-enums-gsettings.h @@ -70,6 +70,7 @@ typedef enum { PANEL_ACTION_NONE = 0, PANEL_ACTION_LOCK, PANEL_ACTION_LOGOUT, + PANEL_ACTION_SUSPEND, PANEL_ACTION_RUN, PANEL_ACTION_SEARCH, PANEL_ACTION_FORCE_QUIT, diff --git a/mate-panel/panel-icon-names.h b/mate-panel/panel-icon-names.h index 4c948b761..b50f685ac 100644 --- a/mate-panel/panel-icon-names.h +++ b/mate-panel/panel-icon-names.h @@ -1,3 +1,5 @@ +#include + #ifndef PANEL_ICON_NAMES_H #define PANEL_ICON_NAMES_H @@ -21,6 +23,9 @@ #define PANEL_ICON_LAUNCHER "mate-panel-launcher" #define PANEL_ICON_LOCKSCREEN "system-lock-screen" #define PANEL_ICON_LOGOUT "system-log-out" +#ifdef HAVE_RDA +#define PANEL_ICON_SUSPEND "stock_media-pause" +#endif #define PANEL_ICON_MAIN_MENU "start-here" #define PANEL_ICON_NETWORK "network-workgroup" #define PANEL_ICON_NETWORK_SERVER "network-server" diff --git a/mate-panel/panel-menu-items.c b/mate-panel/panel-menu-items.c index aa4c5d1f8..60555401f 100644 --- a/mate-panel/panel-menu-items.c +++ b/mate-panel/panel-menu-items.c @@ -40,6 +40,9 @@ #include #include #include +#ifdef HAVE_RDA +#include +#endif #include #include @@ -1543,6 +1546,28 @@ panel_menu_items_append_lock_logout (GtkWidget *menu) } g_list_free (children); +#ifdef HAVE_RDA + if (rda_session_can_be_suspended()) + { + + label = g_strdup_printf (_("Suspend %s Session..."), + rda_get_remote_technology_name()); + tooltip = g_strdup_printf (_("Suspend this %s session and resume it later..."), + rda_get_remote_technology_name()); + item = panel_menu_items_create_action_item_full (PANEL_ACTION_SUSPEND, + label, tooltip); + g_free (label); + g_free (tooltip); + + if (item != NULL) { + /* this separator will always be inserted */ + add_menu_separator (menu); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + } + + } +#endif /* HAVE_RDA */ + if (panel_lock_screen_action_available("lock")) { item = panel_menu_items_create_action_item(PANEL_ACTION_LOCK); From 7398bb9f5c5119afa76cb94154e7b65306baa4e4 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 21 Jun 2023 08:46:23 +0200 Subject: [PATCH 2/6] mate-panel/panel-menu-items.c: Only offer Shutdown button, if not running remotely (with HAVE_RDA defined). --- mate-panel/panel-menu-items.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mate-panel/panel-menu-items.c b/mate-panel/panel-menu-items.c index 60555401f..8eb9fd08b 100644 --- a/mate-panel/panel-menu-items.c +++ b/mate-panel/panel-menu-items.c @@ -1630,6 +1630,9 @@ panel_menu_items_append_lock_logout (GtkWidget *menu) gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); } +#ifdef HAVE_RDA + if (rda_session_is_local()) { +#endif /* HAVE_RDA */ item = panel_menu_items_create_action_item (PANEL_ACTION_SHUTDOWN); if (item != NULL) { if (!separator_inserted) @@ -1637,6 +1640,9 @@ panel_menu_items_append_lock_logout (GtkWidget *menu) gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); } +#ifdef HAVE_RDA + } +#endif /* HAVE_RDA */ } void From df45ed4d0f679e6dc9fc54d2e38925b00d0d6a1e Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 28 Jun 2018 15:39:47 +0200 Subject: [PATCH 3/6] configure.ac: Report RDA support status in configuration summary. --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 8db576013..e7e394b1d 100644 --- a/configure.ac +++ b/configure.ac @@ -388,6 +388,7 @@ echo " Wayland support: ${have_wayland} X11 support: ${have_x11} XRandr support: ${have_randr} + RDA support: ${have_rda} Build introspection support: ${found_introspection} Build gtk-doc documentation: ${enable_gtk_doc} From b8eedf0e8bf95ce5ed6692fe2209714771644209 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Sat, 19 Jan 2019 23:10:12 +0100 Subject: [PATCH 4/6] configure.ac: Explicitly require in RDA >= 0.0.3. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e7e394b1d..3b60dfe49 100644 --- a/configure.ac +++ b/configure.ac @@ -64,6 +64,7 @@ GTK_REQUIRED=3.22.0 LIBWNCK_REQUIRED=3.4.6 LIBWNCK_PREVIEWS_OPTIONAL=3.32.0 WEATHER_REQUIRED=1.17.0 +RDA_REQUIRED=0.0.3 dnl pkg-config dependency checks @@ -245,7 +246,7 @@ fi dnl Remote Desktop Awareness -PKG_CHECK_MODULES(RDA, rda, have_rda=yes, have_rda=no) +PKG_CHECK_MODULES(RDA, rda >= $RDA_REQUIRED, have_rda=yes, have_rda=no) if test "x$have_rda" = "xyes"; then AC_DEFINE(HAVE_RDA, 1, [Have the Remote Desktop Awareness library]) fi From b9dc42a1bb07621f8e43cef600b296b1149ec27b Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 21 Jun 2023 08:27:55 +0200 Subject: [PATCH 5/6] configure.ac: Make RDA enablement controllable via configure argument '--enable-rda'. --- configure.ac | 23 ++++++++++++++++++++++- mate-panel/Makefile.am | 12 ++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3b60dfe49..4748f9b7d 100644 --- a/configure.ac +++ b/configure.ac @@ -246,11 +246,32 @@ fi dnl Remote Desktop Awareness -PKG_CHECK_MODULES(RDA, rda >= $RDA_REQUIRED, have_rda=yes, have_rda=no) +AC_ARG_ENABLE(rda, + [AS_HELP_STRING([--enable-rda], + [Enable RDA (Remote Desktop Awareness, + default is to enable only if RDA development library is detected)])],, + [enable_rda=$enableval], + [enable_rda=auto]) + +# Check if we have librda installed, and thus should build with Wayland support +have_rda=no +if test "x$enable_rda" != "xno"; then + PKG_CHECK_MODULES(RDA, rda >= $RDA_REQUIRED, have_rda=yes, [ + if test "x$enable_rda" = "xyes"; then + AC_MSG_ERROR([Remote Desktop Awareness enabled but RDA library not found]) + fi + ]) +fi + +AM_CONDITIONAL(ENABLE_RDA, [test "x$have_rda" = "xyes"]) + if test "x$have_rda" = "xyes"; then AC_DEFINE(HAVE_RDA, 1, [Have the Remote Desktop Awareness library]) fi +AC_SUBST(RDA_CFLAGS) +AC_SUBST(RDA_LIBS) + dnl Modules dir AC_SUBST([modulesdir],"\$(libdir)/mate-panel/modules") diff --git a/mate-panel/Makefile.am b/mate-panel/Makefile.am index b588bad36..7fda7e6f5 100644 --- a/mate-panel/Makefile.am +++ b/mate-panel/Makefile.am @@ -142,10 +142,14 @@ mate_panel_SOURCES = \ mate_panel_CPPFLAGS = \ $(AM_CPPFLAGS) \ $(XRANDR_CFLAGS) \ - $(RDA_CFLAGS) \ -DPANEL_MODULES_DIR=\"$(modulesdir)\" \ -DMATEMENU_I_KNOW_THIS_IS_UNSTABLE +if ENABLE_RDA +mate_panel_CPPFLAGS += \ + $(RDA_CFLAGS) +endif + if ENABLE_WAYLAND mate_panel_CPPFLAGS += \ $(WAYLAND_CFLAGS) @@ -158,10 +162,14 @@ mate_panel_LDADD = \ $(PANEL_LIBS) \ $(DCONF_LIBS) \ $(XRANDR_LIBS) \ - $(RDA_LIBS) \ $(X_LIBS) \ $(WAYLAND_LIBS) +if ENABLE_RDA +mate_panel_LDADD += \ + $(RDA_LIBS) +endif + if ENABLE_WAYLAND mate_panel_LDADD += \ $(WAYLAND_LIBS) From 1289f2730edc1a284358802817bff9c71b576724 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 21 Jun 2023 08:32:29 +0200 Subject: [PATCH 6/6] mate-panel/Makefile.am: Cleanup WAYLAND_CFLAGS and WAYLAND_LIBS usage. --- mate-panel/Makefile.am | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mate-panel/Makefile.am b/mate-panel/Makefile.am index 7fda7e6f5..8a1358c92 100644 --- a/mate-panel/Makefile.am +++ b/mate-panel/Makefile.am @@ -15,8 +15,7 @@ AM_CPPFLAGS = \ -I$(top_builddir)/mate-panel/libpanel-util \ -DMATELOCALEDIR=\""$(datadir)/locale"\" \ -DPANELDATADIR=\""$(datadir)/mate-panel"\" \ - $(DISABLE_DEPRECATED_CFLAGS) \ - $(WAYLAND_CFLAGS) + $(DISABLE_DEPRECATED_CFLAGS) AM_CFLAGS = $(WARN_CFLAGS) @@ -162,8 +161,7 @@ mate_panel_LDADD = \ $(PANEL_LIBS) \ $(DCONF_LIBS) \ $(XRANDR_LIBS) \ - $(X_LIBS) \ - $(WAYLAND_LIBS) + $(X_LIBS) if ENABLE_RDA mate_panel_LDADD += \