[Xfce4-commits] [apps/xfdashboard] 01/01: Add signal and access function to get window manager name

noreply at xfce.org noreply at xfce.org
Wed May 10 11:09:26 CEST 2017


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit c1ec759379d37b099afd8318c4716fd81beb2484
Author: Stephan Haller <nomad at froevel.de>
Date:   Wed May 10 11:09:05 2017 +0200

    Add signal and access function to get window manager name
---
 libxfdashboard/window-tracker.c         | 33 +++++++++++++++++++++++++++
 libxfdashboard/window-tracker.h         |  6 +++++
 libxfdashboard/x11/window-tracker-x11.c | 40 +++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)

diff --git a/libxfdashboard/window-tracker.c b/libxfdashboard/window-tracker.c
index ed7f42a..508f879 100644
--- a/libxfdashboard/window-tracker.c
+++ b/libxfdashboard/window-tracker.c
@@ -70,6 +70,8 @@ enum
 	SIGNAL_MONITOR_GEOMETRY_CHANGED,
 	SIGNAL_SCREEN_SIZE_CHANGED,
 
+	SIGNAL_WINDOW_MANAGER_CHANGED,
+
 	SIGNAL_LAST
 };
 
@@ -366,6 +368,17 @@ void xfdashboard_window_tracker_default_init(XfdashboardWindowTrackerInterface *
 							G_TYPE_INT,
 							G_TYPE_INT);
 
+		XfdashboardWindowTrackerSignals[SIGNAL_WINDOW_MANAGER_CHANGED]=
+			g_signal_new("window-manager-changed",
+							G_TYPE_FROM_INTERFACE(iface),
+							G_SIGNAL_RUN_LAST,
+							G_STRUCT_OFFSET(XfdashboardWindowTrackerInterface, window_manager_changed),
+							NULL,
+							NULL,
+							g_cclosure_marshal_VOID__VOID,
+							G_TYPE_NONE,
+							0);
+
 		/* Set flag that base initialization was done for this interface */
 		initialized=TRUE;
 	}
@@ -682,6 +695,26 @@ void xfdashboard_window_tracker_get_screen_size(XfdashboardWindowTracker *self,
 	XFDASHBOARD_WINDOWS_TRACKER_WARN_NOT_IMPLEMENTED(self, "get_screen_width");
 }
 
+/* Get name of window manager managing windows, workspace etc. of desktop environment */
+const gchar* xfdashboard_window_tracker_get_window_manager_name(XfdashboardWindowTracker *self)
+{
+	XfdashboardWindowTrackerInterface		*iface;
+
+	g_return_val_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER(self), NULL);
+
+	iface=XFDASHBOARD_WINDOW_TRACKER_GET_IFACE(self);
+
+	/* Call virtual function */
+	if(iface->get_window_manager_name)
+	{
+		return(iface->get_window_manager_name(self));
+	}
+
+	/* If we get here the virtual function was not overridden */
+	XFDASHBOARD_WINDOWS_TRACKER_WARN_NOT_IMPLEMENTED(self, "get_window_manager_name");
+	return(NULL);
+}
+
 /* Get root (desktop) window */
 XfdashboardWindowTrackerWindow* xfdashboard_window_tracker_get_root_window(XfdashboardWindowTracker *self)
 {
diff --git a/libxfdashboard/window-tracker.h b/libxfdashboard/window-tracker.h
index ae79f3f..e93a47a 100644
--- a/libxfdashboard/window-tracker.h
+++ b/libxfdashboard/window-tracker.h
@@ -71,6 +71,8 @@ struct _XfdashboardWindowTrackerInterface
 
 	void (*get_screen_size)(XfdashboardWindowTracker *self, gint *outWidth, gint *outHeight);
 
+	const gchar* (*get_window_manager_name)(XfdashboardWindowTracker *self);
+
 	XfdashboardWindowTrackerWindow* (*get_root_window)(XfdashboardWindowTracker *self);
 	XfdashboardWindowTrackerWindow* (*get_stage_window)(XfdashboardWindowTracker *self, ClutterStage *inStage);
 
@@ -110,6 +112,8 @@ struct _XfdashboardWindowTrackerInterface
 	void (*monitor_geometry_changed)(XfdashboardWindowTracker *self, XfdashboardWindowTrackerMonitor *inMonitor);
 
 	void (*screen_size_changed)(XfdashboardWindowTracker *self, gint inWidth, gint inHeight);
+
+	void (*window_manager_changed)(XfdashboardWindowTracker *self);
 };
 
 /* Public API */
@@ -141,6 +145,8 @@ void xfdashboard_window_tracker_get_screen_size(XfdashboardWindowTracker *self,
 													gint *outWidth,
 													gint *outHeight);
 
+const gchar* xfdashboard_window_tracker_get_window_manager_name(XfdashboardWindowTracker *self);
+
 XfdashboardWindowTrackerWindow* xfdashboard_window_tracker_get_root_window(XfdashboardWindowTracker *self);
 XfdashboardWindowTrackerWindow* xfdashboard_window_tracker_get_stage_window(XfdashboardWindowTracker *self,
 																			ClutterStage *inStage);
diff --git a/libxfdashboard/x11/window-tracker-x11.c b/libxfdashboard/x11/window-tracker-x11.c
index 38aeaa3..f0d73e9 100644
--- a/libxfdashboard/x11/window-tracker-x11.c
+++ b/libxfdashboard/x11/window-tracker-x11.c
@@ -1090,6 +1090,23 @@ static void _xfdashboard_window_tracker_x11_on_screen_size_changed(XfdashboardWi
 	g_signal_emit_by_name(self, "screen-size-changed", w, h);
 }
 
+/* Window manager has changed */
+static void _xfdashboard_window_tracker_x11_on_window_manager_changed(XfdashboardWindowTrackerX11 *self,
+																		gpointer inUserData)
+{
+	XfdashboardWindowTrackerX11Private		*priv;
+
+	g_return_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER(self));
+
+	priv=self->priv;
+
+	/* Emit signal to tell that window manager has changed */
+	XFDASHBOARD_DEBUG(self, WINDOWS,
+						"Window manager changed to %s",
+						wnck_screen_get_window_manager_name(priv->screen));
+	g_signal_emit_by_name(self, "window-manager-changed");
+}
+
 /* Suspension state of application changed */
 static void _xfdashboard_window_tracker_x11_on_application_suspended_changed(XfdashboardWindowTrackerX11 *self,
 																				GParamSpec *inSpec,
@@ -1464,6 +1481,22 @@ static void _xfdashboard_window_tracker_x11_window_tracker_get_screen_size(Xfdas
 	if(outHeight) *outHeight=height;
 }
 
+/* Get window manager name managing desktop environment */
+static const gchar* _xfdashboard_window_tracker_x11_window_tracker_get_window_manager_name(XfdashboardWindowTracker *inWindowTracker)
+{
+	XfdashboardWindowTrackerX11				*self;
+	XfdashboardWindowTrackerX11Private		*priv;
+
+	g_return_val_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER_X11(inWindowTracker), NULL);
+
+	self=XFDASHBOARD_WINDOW_TRACKER_X11(inWindowTracker);
+	priv=self->priv;
+
+	/* Get window manager name from libwnck and return */
+	return(wnck_screen_get_window_manager_name(priv->screen));
+
+}
+
 /* Get root (desktop) window */
 static XfdashboardWindowTrackerWindow* _xfdashboard_window_tracker_x11_window_tracker_get_root_window(XfdashboardWindowTracker *inWindowTracker)
 {
@@ -1591,6 +1624,8 @@ static void _xfdashboard_window_tracker_x11_window_tracker_iface_init(Xfdashboar
 
 	iface->get_screen_size=_xfdashboard_window_tracker_x11_window_tracker_get_screen_size;
 
+	iface->get_window_manager_name=_xfdashboard_window_tracker_x11_window_tracker_get_window_manager_name;
+
 	iface->get_root_window=_xfdashboard_window_tracker_x11_window_tracker_get_root_window;
 	iface->get_stage_window=_xfdashboard_window_tracker_x11_window_tracker_get_stage_window;
 }
@@ -1882,6 +1917,11 @@ void xfdashboard_window_tracker_x11_init(XfdashboardWindowTrackerX11 *self)
 								G_CALLBACK(_xfdashboard_window_tracker_x11_on_screen_size_changed),
 								self);
 
+	g_signal_connect_swapped(priv->screen,
+								"window-manager-changed",
+								G_CALLBACK(_xfdashboard_window_tracker_x11_on_window_manager_changed),
+								self);
+
 #ifdef HAVE_XINERAMA
 	/* Check if multiple monitors are supported */
 	if(XineramaIsActive(GDK_SCREEN_XDISPLAY(priv->gdkScreen)))

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list