summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wold <[email protected]>2019-06-17 22:33:59 +0000
committerraveit65 <[email protected]>2019-06-23 10:12:24 +0200
commit49942432f1d908d801d8ec353887eee2d110e5e2 (patch)
tree8bd11c5958ef60aea61b879b53398ca7f4307fc2
parent6ceac636cc2f96702707a560b73975391506c630 (diff)
downloadmate-panel-49942432f1d908d801d8ec353887eee2d110e5e2.tar.bz2
mate-panel-49942432f1d908d801d8ec353887eee2d110e5e2.tar.xz
Wayland support for panel-applet-container.c
-rw-r--r--mate-panel/libmate-panel-applet-private/panel-applet-container.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/mate-panel/libmate-panel-applet-private/panel-applet-container.c b/mate-panel/libmate-panel-applet-private/panel-applet-container.c
index 04ee799b..f6e0f94c 100644
--- a/mate-panel/libmate-panel-applet-private/panel-applet-container.c
+++ b/mate-panel/libmate-panel-applet-private/panel-applet-container.c
@@ -20,9 +20,15 @@
*
*/
+#include <config.h>
#include <string.h>
+
#include <gtk/gtk.h>
+
+#ifdef HAVE_X11
#include <gtk/gtkx.h>
+#endif
+
#include <panel-applets-manager.h>
#include "panel-applet-container.h"
#include "panel-marshal.h"
@@ -74,7 +80,9 @@ static const AppletPropertyInfo applet_properties [] = {
#define MATE_PANEL_APPLET_FACTORY_OBJECT_PATH "/org/mate/panel/applet/%s"
#define MATE_PANEL_APPLET_INTERFACE "org.mate.panel.applet.Applet"
+#ifdef HAVE_X11
static gboolean mate_panel_applet_container_plug_removed (MatePanelAppletContainer *container);
+#endif
G_DEFINE_TYPE_WITH_PRIVATE (MatePanelAppletContainer, mate_panel_applet_container, GTK_TYPE_EVENT_BOX);
@@ -97,15 +105,23 @@ static void
panel_applet_container_setup (MatePanelAppletContainer *container)
{
if (container->priv->out_of_process) {
- container->priv->socket = gtk_socket_new ();
-
- g_signal_connect_swapped (container->priv->socket,
- "plug-removed",
- G_CALLBACK (mate_panel_applet_container_plug_removed),
- container);
-
- gtk_container_add (GTK_CONTAINER (container), container->priv->socket);
- gtk_widget_show (container->priv->socket);
+#ifdef HAVE_X11
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+ container->priv->socket = gtk_socket_new ();
+
+ g_signal_connect_swapped (container->priv->socket,
+ "plug-removed",
+ G_CALLBACK (mate_panel_applet_container_plug_removed),
+ container);
+
+ gtk_container_add (GTK_CONTAINER (container), container->priv->socket);
+ gtk_widget_show (container->priv->socket);
+ } else
+#endif
+ { // Not using X11
+ g_warning("%s requested out-of-process container, which is only supported on X11",
+ container->priv->iid);
+ }
} else {
GtkWidget *applet;
@@ -253,9 +269,12 @@ mate_panel_applet_container_new (void)
return container;
}
+#ifdef HAVE_X11
static gboolean
mate_panel_applet_container_plug_removed (MatePanelAppletContainer *container)
{
+ g_return_val_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (container))), FALSE);
+
if (!container->priv->applet_proxy)
return FALSE;
@@ -276,6 +295,7 @@ mate_panel_applet_container_plug_removed (MatePanelAppletContainer *container)
*/
return FALSE;
}
+#endif // HAVE_X11
static void
mate_panel_applet_container_child_signal (GDBusProxy *proxy,
@@ -368,10 +388,13 @@ on_proxy_appeared (GObject *source_object,
panel_applet_container_setup (container);
+#ifdef HAVE_X11
+ // xid always <= 0 when not using X11
if (container->priv->xid > 0) {
gtk_socket_add_id (GTK_SOCKET (container->priv->socket),
container->priv->xid);
}
+#endif
/* g_async_result_get_source_object returns new ref */
g_object_unref (container);
@@ -505,7 +528,14 @@ mate_panel_applet_container_get_applet (MatePanelAppletContainer *container,
/* we can't use the screen of the container widget since it's not in a
* widget hierarchy yet */
- screen_number = gdk_x11_screen_get_screen_number (screen);
+#ifdef HAVE_X11
+ if (GDK_IS_X11_DISPLAY (gdk_screen_get_display (screen))) {
+ screen_number = gdk_x11_screen_get_screen_number (screen);
+ } else
+#endif
+ { // Not using X11
+ screen_number = 0;
+ }
data = g_new (AppletFactoryData, 1);
data->result = result;