[Xfce4-commits] [apps/xfdashboard] 02/04: Implement option to show only those windows in a XfdashboardLiveWorkspace for the monitor where it is placed on
noreply at xfce.org
noreply at xfce.org
Thu Jun 4 19:53:24 CEST 2015
This is an automated email from the git hooks/post-receive script.
nomad pushed a commit to branch master
in repository apps/xfdashboard.
commit 46346a7b4f880076e0776b3a172a31d46a115c1c
Author: Stephan Haller <nomad at froevel.de>
Date: Thu Jun 4 19:43:46 2015 +0200
Implement option to show only those windows in a XfdashboardLiveWorkspace for the monitor where it is placed on
This option is themable via property "show-current-monitor-only" at object instaces of class XfdashboardWorkspaceSelector.
This commit addresses issue GH #87
---
xfdashboard/live-workspace.c | 215 ++++++++++++++++++++++++++++++++++----
xfdashboard/live-workspace.h | 4 +
xfdashboard/workspace-selector.c | 121 +++++++++++++++++++--
xfdashboard/workspace-selector.h | 3 +
4 files changed, 312 insertions(+), 31 deletions(-)
diff --git a/xfdashboard/live-workspace.c b/xfdashboard/live-workspace.c
index 5f42004..48bf858 100644
--- a/xfdashboard/live-workspace.c
+++ b/xfdashboard/live-workspace.c
@@ -54,6 +54,7 @@ struct _XfdashboardLiveWorkspacePrivate
{
/* Properties related */
XfdashboardWindowTrackerWorkspace *workspace;
+ XfdashboardWindowTrackerMonitor *monitor;
gboolean showWindowContent;
XfdashboardStageBackgroundImageType backgroundType;
@@ -68,6 +69,7 @@ enum
PROP_0,
PROP_WORKSPACE,
+ PROP_MONITOR,
PROP_SHOW_WINDOW_CONTENT,
PROP_BACKGROUND_IMAGE_TYPE,
@@ -366,6 +368,17 @@ static void _xfdashboard_live_workspace_on_window_workspace_changed(XfdashboardL
}
}
+/* A monitor's position and/or size has changed */
+static void _xfdashboard_live_workspace_on_monitor_geometry_changed(XfdashboardLiveWorkspace *self,
+ gpointer inUserData)
+{
+ g_return_if_fail(XFDASHBOARD_IS_LIVE_WORKSPACE(self));
+ g_return_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER_MONITOR(inUserData));
+
+ /* Actor's allocation may change because of new geometry so relayout */
+ clutter_actor_queue_relayout(CLUTTER_ACTOR(self));
+}
+
/* A window was created
* Check if window opened is desktop background window
*/
@@ -416,8 +429,16 @@ static void _xfdashboard_live_workspace_get_preferred_height(ClutterActor *self,
/* Determine size of workspace if available (should usually be the largest actor) */
if(priv->workspace)
{
- childWidth=(gfloat)xfdashboard_window_tracker_workspace_get_width(priv->workspace);
- childHeight=(gfloat)xfdashboard_window_tracker_workspace_get_height(priv->workspace);
+ if(priv->monitor)
+ {
+ childWidth=(gfloat)xfdashboard_window_tracker_monitor_get_width(priv->monitor);
+ childHeight=(gfloat)xfdashboard_window_tracker_monitor_get_height(priv->monitor);
+ }
+ else
+ {
+ childWidth=(gfloat)xfdashboard_window_tracker_workspace_get_width(priv->workspace);
+ childHeight=(gfloat)xfdashboard_window_tracker_workspace_get_height(priv->workspace);
+ }
if(inForWidth<0.0f) naturalHeight=childHeight;
else naturalHeight=(childHeight/childWidth)*inForWidth;
@@ -442,8 +463,16 @@ static void _xfdashboard_live_workspace_get_preferred_width(ClutterActor *self,
/* Determine size of workspace if available (should usually be the largest actor) */
if(priv->workspace)
{
- childWidth=(gfloat)xfdashboard_window_tracker_workspace_get_width(priv->workspace);
- childHeight=(gfloat)xfdashboard_window_tracker_workspace_get_height(priv->workspace);
+ if(priv->monitor)
+ {
+ childWidth=(gfloat)xfdashboard_window_tracker_monitor_get_width(priv->monitor);
+ childHeight=(gfloat)xfdashboard_window_tracker_monitor_get_height(priv->monitor);
+ }
+ else
+ {
+ childWidth=(gfloat)xfdashboard_window_tracker_workspace_get_width(priv->workspace);
+ childHeight=(gfloat)xfdashboard_window_tracker_workspace_get_height(priv->workspace);
+ }
if(inForHeight<0.0f) naturalWidth=childWidth;
else naturalWidth=(childWidth/childHeight)*inForHeight;
@@ -455,41 +484,102 @@ static void _xfdashboard_live_workspace_get_preferred_width(ClutterActor *self,
}
/* Allocate position and size of actor and its children */
+static void _xfdashboard_live_workspace_transform_allocation(ClutterActorBox *ioBox,
+ const ClutterActorBox *inTotalArea,
+ const ClutterActorBox *inVisibleArea,
+ const ClutterActorBox *inAllocation)
+{
+ ClutterActorBox result;
+ gfloat totalWidth, totalHeight;
+ gfloat visibleWidth, visibleHeight;
+ gfloat allocationWidth, allocationHeight;
+
+ /* Get sizes */
+ totalWidth=clutter_actor_box_get_width(inTotalArea);
+ totalHeight=clutter_actor_box_get_height(inTotalArea);
+
+ visibleWidth=clutter_actor_box_get_width(inVisibleArea);
+ visibleHeight=clutter_actor_box_get_height(inVisibleArea);
+
+ allocationWidth=clutter_actor_box_get_width(inAllocation);
+ allocationHeight=clutter_actor_box_get_height(inAllocation);
+
+ /* Transform positions */
+ result.x1=((ioBox->x1/totalWidth)*allocationWidth)*(totalWidth/visibleWidth);
+ result.x2=((ioBox->x2/totalWidth)*allocationWidth)*(totalWidth/visibleWidth);
+
+ result.y1=((ioBox->y1/totalHeight)*allocationHeight)*(totalHeight/visibleHeight);
+ result.y2=((ioBox->y2/totalHeight)*allocationHeight)*(totalHeight/visibleHeight);
+
+ /* Set result */
+ ioBox->x1=result.x1;
+ ioBox->y1=result.y1;
+ ioBox->x2=result.x2;
+ ioBox->y2=result.y2;
+}
+
static void _xfdashboard_live_workspace_allocate(ClutterActor *self,
const ClutterActorBox *inBox,
ClutterAllocationFlags inFlags)
{
XfdashboardLiveWorkspacePrivate *priv=XFDASHBOARD_LIVE_WORKSPACE(self)->priv;
- gfloat availableWidth, availableHeight;
- gfloat workspaceWidth, workspaceHeight;
XfdashboardWindowTrackerWindow *window;
gint x, y, w, h;
ClutterActor *child;
ClutterActorIter iter;
ClutterActorBox childAllocation={ 0, };
+ ClutterActorBox visibleArea={ 0, };
+ ClutterActorBox workspaceArea={ 0, };
/* Chain up to store the allocation of the actor */
CLUTTER_ACTOR_CLASS(xfdashboard_live_workspace_parent_class)->allocate(self, inBox, inFlags);
- /* Get size of this allocation */
- clutter_actor_box_get_size(inBox, &availableWidth, &availableHeight);
+ /* Get size of workspace as it is needed to calculate translated position
+ * and size but fallback to size of screen if no workspace is set.
+ */
+ if(priv->workspace)
+ {
+ workspaceArea.x1=0.0f;
+ workspaceArea.y1=0.0f;
+ workspaceArea.x2=xfdashboard_window_tracker_workspace_get_width(priv->workspace);
+ workspaceArea.y2=xfdashboard_window_tracker_workspace_get_height(priv->workspace);
+ }
+ else
+ {
+ workspaceArea.x1=0.0f;
+ workspaceArea.y1=0.0f;
+ workspaceArea.x2=xfdashboard_window_tracker_get_screen_width(priv->windowTracker);
+ workspaceArea.y2=xfdashboard_window_tracker_get_screen_height(priv->windowTracker);
+ }
+
+ /* Get visible area of workspace */
+ if(priv->monitor)
+ {
+ xfdashboard_window_tracker_monitor_get_geometry(priv->monitor, &x, &y, &w, &h);
+ visibleArea.x1=x;
+ visibleArea.x2=x+w;
+ visibleArea.y1=y;
+ visibleArea.y2=y+h;
+ }
+ else
+ {
+ visibleArea.x1=0;
+ visibleArea.y1=0;
+ visibleArea.x2=clutter_actor_box_get_width(&workspaceArea);
+ visibleArea.y2=clutter_actor_box_get_height(&workspaceArea);
+ }
/* Resize background image layer to allocation even if it is hidden */
- childAllocation.x1=0.0f;
- childAllocation.y1=0.0f;
- childAllocation.x2=availableWidth;
- childAllocation.y2=availableHeight;
+ childAllocation.x1=-visibleArea.x1;
+ childAllocation.y1=-visibleArea.y1;
+ childAllocation.x2=childAllocation.x1+clutter_actor_box_get_width(&workspaceArea);
+ childAllocation.y2=childAllocation.y1+clutter_actor_box_get_height(&workspaceArea);
+ _xfdashboard_live_workspace_transform_allocation(&childAllocation, &workspaceArea, &visibleArea, inBox);
clutter_actor_allocate(priv->backgroundImageLayer, &childAllocation, inFlags);
/* If we handle no workspace to not set allocation of children */
if(!priv->workspace) return;
- /* Get size of workspace as it is needed to calculate translated
- * position and size
- */
- workspaceWidth=(gfloat)xfdashboard_window_tracker_workspace_get_width(priv->workspace);
- workspaceHeight=(gfloat)xfdashboard_window_tracker_workspace_get_height(priv->workspace);
-
/* Iterate through window actors, calculate translated allocation of
* position and size to available size of this actor
*/
@@ -507,14 +597,29 @@ static void _xfdashboard_live_workspace_allocate(ClutterActor *self,
xfdashboard_window_tracker_window_get_position_size(window, &x, &y, &w, &h);
/* Calculate translated position and size of child */
- childAllocation.x1=ceil((x/workspaceWidth)*availableWidth);
- childAllocation.y1=ceil((y/workspaceHeight)*availableHeight);
- childAllocation.x2=childAllocation.x1+ceil((w/workspaceWidth)*availableWidth);
- childAllocation.y2=childAllocation.y1+ceil((h/workspaceHeight)*availableHeight);
+ childAllocation.x1=x-visibleArea.x1;
+ childAllocation.x2=childAllocation.x1+w;
+ childAllocation.y1=y-visibleArea.y1;
+ childAllocation.y2=childAllocation.y1+h;
+ _xfdashboard_live_workspace_transform_allocation(&childAllocation, &workspaceArea, &visibleArea, inBox);
/* Set allocation of child */
clutter_actor_allocate(child, &childAllocation, inFlags);
}
+
+ /* Set clip if a specific monitor should be shown only otherwise remove clip */
+ if(priv->monitor)
+ {
+ clutter_actor_set_clip(self,
+ 0.0f,
+ 0.0f,
+ clutter_actor_box_get_width(inBox),
+ clutter_actor_box_get_height(inBox));
+ }
+ else
+ {
+ clutter_actor_remove_clip(self);
+ }
}
/* IMPLEMENTATION: GObject */
@@ -541,6 +646,12 @@ static void _xfdashboard_live_workspace_dispose(GObject *inObject)
priv->windowTracker=NULL;
}
+ if(priv->monitor)
+ {
+ g_signal_handlers_disconnect_by_data(priv->monitor, self);
+ priv->monitor=NULL;
+ }
+
if(priv->workspace)
{
g_signal_handlers_disconnect_by_data(priv->workspace, self);
@@ -565,6 +676,10 @@ static void _xfdashboard_live_workspace_set_property(GObject *inObject,
xfdashboard_live_workspace_set_workspace(self, g_value_get_object(inValue));
break;
+ case PROP_MONITOR:
+ xfdashboard_live_workspace_set_monitor(self, g_value_get_object(inValue));
+ break;
+
case PROP_SHOW_WINDOW_CONTENT:
xfdashboard_live_workspace_set_show_window_content(self, g_value_get_boolean(inValue));
break;
@@ -592,6 +707,10 @@ static void _xfdashboard_live_workspace_get_property(GObject *inObject,
g_value_set_object(outValue, self->priv->workspace);
break;
+ case PROP_MONITOR:
+ g_value_set_object(outValue, self->priv->monitor);
+ break;
+
case PROP_SHOW_WINDOW_CONTENT:
g_value_set_boolean(outValue, self->priv->showWindowContent);
break;
@@ -636,6 +755,13 @@ static void xfdashboard_live_workspace_class_init(XfdashboardLiveWorkspaceClass
XFDASHBOARD_TYPE_WINDOW_TRACKER_WORKSPACE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ XfdashboardLiveWorkspaceProperties[PROP_MONITOR]=
+ g_param_spec_object("monitor",
+ _("Monitor"),
+ _("The monitor whose window to show only"),
+ XFDASHBOARD_TYPE_WINDOW_TRACKER_MONITOR,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
XfdashboardLiveWorkspaceProperties[PROP_SHOW_WINDOW_CONTENT]=
g_param_spec_boolean("show-window-content",
_("show-window-content"),
@@ -685,6 +811,7 @@ static void xfdashboard_live_workspace_init(XfdashboardLiveWorkspace *self)
priv->workspace=NULL;
priv->showWindowContent=TRUE;
priv->backgroundType=XFDASHBOARD_STAGE_BACKGROUND_IMAGE_TYPE_NONE;
+ priv->monitor=NULL;
/* Set up this actor */
clutter_actor_set_reactive(CLUTTER_ACTOR(self), TRUE);
@@ -820,6 +947,50 @@ void xfdashboard_live_workspace_set_workspace(XfdashboardLiveWorkspace *self, Xf
g_object_notify_by_pspec(G_OBJECT(self), XfdashboardLiveWorkspaceProperties[PROP_WORKSPACE]);
}
+/* Get/set monitor whose window to show only */
+XfdashboardWindowTrackerMonitor* xfdashboard_live_workspace_get_monitor(XfdashboardLiveWorkspace *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_LIVE_WORKSPACE(self), NULL);
+
+ return(self->priv->monitor);
+}
+
+void xfdashboard_live_workspace_set_monitor(XfdashboardLiveWorkspace *self, XfdashboardWindowTrackerMonitor *inMonitor)
+{
+ XfdashboardLiveWorkspacePrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_LIVE_WORKSPACE(self));
+ g_return_if_fail(!inMonitor || XFDASHBOARD_IS_WINDOW_TRACKER_MONITOR(inMonitor));
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->monitor!=inMonitor)
+ {
+ /* Set value */
+ if(priv->monitor)
+ {
+ g_signal_handlers_disconnect_by_data(priv->monitor, self);
+ priv->monitor=NULL;
+ }
+
+ if(inMonitor)
+ {
+ priv->monitor=inMonitor;
+ g_signal_connect_swapped(priv->monitor,
+ "geometry-changed",
+ G_CALLBACK(_xfdashboard_live_workspace_on_monitor_geometry_changed),
+ self);
+ }
+
+ /* Force a relayout of this actor to update appearance */
+ clutter_actor_queue_relayout(CLUTTER_ACTOR(self));
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardLiveWorkspaceProperties[PROP_MONITOR]);
+ }
+}
+
/* Get/set if the window content should be shown or the window's icon */
gboolean xfdashboard_live_workspace_get_show_window_content(XfdashboardLiveWorkspace *self)
{
diff --git a/xfdashboard/live-workspace.h b/xfdashboard/live-workspace.h
index bfac478..c8e195d 100644
--- a/xfdashboard/live-workspace.h
+++ b/xfdashboard/live-workspace.h
@@ -29,6 +29,7 @@
#include "background.h"
#include "window-tracker-workspace.h"
+#include "window-tracker-monitor.h"
G_BEGIN_DECLS
@@ -72,6 +73,9 @@ ClutterActor* xfdashboard_live_workspace_new_for_workspace(XfdashboardWindowTrac
XfdashboardWindowTrackerWorkspace* xfdashboard_live_workspace_get_workspace(XfdashboardLiveWorkspace *self);
void xfdashboard_live_workspace_set_workspace(XfdashboardLiveWorkspace *self, XfdashboardWindowTrackerWorkspace *inWorkspace);
+XfdashboardWindowTrackerMonitor* xfdashboard_live_workspace_get_monitor(XfdashboardLiveWorkspace *self);
+void xfdashboard_live_workspace_set_monitor(XfdashboardLiveWorkspace *self, XfdashboardWindowTrackerMonitor *inMonitor);
+
gboolean xfdashboard_live_workspace_get_show_window_content(XfdashboardLiveWorkspace *self);
void xfdashboard_live_workspace_set_show_window_content(XfdashboardLiveWorkspace *self, gboolean inShowWindowContent);
diff --git a/xfdashboard/workspace-selector.c b/xfdashboard/workspace-selector.c
index 8c478be..f244b90 100644
--- a/xfdashboard/workspace-selector.c
+++ b/xfdashboard/workspace-selector.c
@@ -63,6 +63,7 @@ struct _XfdashboardWorkspaceSelectorPrivate
gfloat maxSize;
gfloat maxFraction;
gboolean usingFraction;
+ gboolean showCurrentMonitorOnly;
/* Instance related */
XfdashboardWindowTracker *windowTracker;
@@ -82,6 +83,8 @@ enum
PROP_MAX_FRACTION,
PROP_USING_FRACTION,
+ PROP_SHOW_CURRENT_MONITOR_ONLY,
+
PROP_LAST
};
@@ -93,11 +96,30 @@ static GParamSpec* XfdashboardWorkspaceSelectorProperties[PROP_LAST]={ 0, };
#define DEFAULT_USING_FRACTION TRUE
#define DEFAULT_ORIENTATION CLUTTER_ORIENTATION_VERTICAL
+/* Find stage interface whose child this actor is */
+static XfdashboardStageInterface* _xfdashboard_workspace_selector_get_stage_interface(XfdashboardWorkspaceSelector *self)
+{
+ ClutterActor *stageInterface;
+
+ g_return_val_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(self), NULL);
+
+ /* Find parent stage interface */
+ stageInterface=clutter_actor_get_parent(CLUTTER_ACTOR(self));
+ while(stageInterface && !XFDASHBOARD_IS_STAGE_INTERFACE(stageInterface))
+ {
+ stageInterface=clutter_actor_get_parent(stageInterface);
+ }
+ if(stageInterface) return(XFDASHBOARD_STAGE_INTERFACE(stageInterface));
+
+ /* If we get here we did not find parent stage interface */
+ return(NULL);
+}
+
/* Get maximum (horizontal or vertical) size either by static size or fraction */
static gfloat _xfdashboard_workspace_selector_get_max_size_internal(XfdashboardWorkspaceSelector *self)
{
XfdashboardWorkspaceSelectorPrivate *priv;
- ClutterActor *stageInterface;
+ XfdashboardStageInterface *stageInterface;
gfloat w, h;
gfloat size, fraction;
@@ -109,11 +131,7 @@ static gfloat _xfdashboard_workspace_selector_get_max_size_internal(XfdashboardW
* to determine maximum size by fraction or to update maximum size or
* fraction and send notifications.
*/
- stageInterface=clutter_actor_get_parent(CLUTTER_ACTOR(self));
- while(stageInterface && !XFDASHBOARD_IS_STAGE_INTERFACE(stageInterface))
- {
- stageInterface=clutter_actor_get_parent(stageInterface);
- }
+ stageInterface=_xfdashboard_workspace_selector_get_stage_interface(self);
if(!stageInterface) return(0.0f);
clutter_actor_get_size(CLUTTER_ACTOR(stageInterface), &w, &h);
@@ -406,18 +424,36 @@ static void _xfdashboard_workspace_selector_on_workspace_added(XfdashboardWorksp
XfdashboardWindowTrackerWorkspace *inWorkspace,
gpointer inUserData)
{
- ClutterActor *actor;
- gint index;
- ClutterAction *action;
+ XfdashboardWorkspaceSelectorPrivate *priv;
+ ClutterActor *actor;
+ gint index;
+ ClutterAction *action;
g_return_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(self));
g_return_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER_WORKSPACE(inWorkspace));
+ priv=self->priv;
+
/* Get index of workspace for insertion */
index=xfdashboard_window_tracker_workspace_get_number(inWorkspace);
/* Create new live workspace actor and insert at index */
actor=xfdashboard_live_workspace_new_for_workspace(inWorkspace);
+ if(priv->showCurrentMonitorOnly)
+ {
+ XfdashboardStageInterface *stageInterface;
+ XfdashboardWindowTrackerMonitor *monitor;
+
+ /* Get parent stage interface */
+ stageInterface=_xfdashboard_workspace_selector_get_stage_interface(self);
+
+ /* Get monitor of stage interface if available */
+ monitor=NULL;
+ if(stageInterface) monitor=xfdashboard_stage_interface_get_monitor(stageInterface);
+
+ /* Set monitor at newly created live workspace actor */
+ xfdashboard_live_workspace_set_monitor(XFDASHBOARD_LIVE_WORKSPACE(actor), monitor);
+ }
g_signal_connect_swapped(actor, "clicked", G_CALLBACK(_xfdashboard_workspace_selector_on_workspace_clicked), self);
clutter_actor_insert_child_at_index(CLUTTER_ACTOR(self), actor, index);
@@ -1144,6 +1180,10 @@ static void _xfdashboard_workspace_selector_set_property(GObject *inObject,
xfdashboard_workspace_selector_set_maximum_fraction(self, g_value_get_float(inValue));
break;
+ case PROP_SHOW_CURRENT_MONITOR_ONLY:
+ xfdashboard_workspace_selector_set_show_current_monitor_only(self, g_value_get_boolean(inValue));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
break;
@@ -1180,6 +1220,10 @@ static void _xfdashboard_workspace_selector_get_property(GObject *inObject,
g_value_set_boolean(outValue, priv->usingFraction);
break;
+ case PROP_SHOW_CURRENT_MONITOR_ONLY:
+ g_value_set_boolean(outValue, priv->showCurrentMonitorOnly);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
break;
@@ -1248,6 +1292,13 @@ static void xfdashboard_workspace_selector_class_init(XfdashboardWorkspaceSelect
DEFAULT_USING_FRACTION,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ XfdashboardWorkspaceSelectorProperties[PROP_SHOW_CURRENT_MONITOR_ONLY]=
+ g_param_spec_boolean("show-current-monitor-only",
+ _("Show current monitor only"),
+ _("Show only windows of the monitor where this actor is placed"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardWorkspaceSelectorProperties);
/* Define stylable properties */
@@ -1255,6 +1306,7 @@ static void xfdashboard_workspace_selector_class_init(XfdashboardWorkspaceSelect
xfdashboard_actor_install_stylable_property(actorClass, XfdashboardWorkspaceSelectorProperties[PROP_ORIENTATION]);
xfdashboard_actor_install_stylable_property(actorClass, XfdashboardWorkspaceSelectorProperties[PROP_MAX_SIZE]);
xfdashboard_actor_install_stylable_property(actorClass, XfdashboardWorkspaceSelectorProperties[PROP_MAX_FRACTION]);
+ xfdashboard_actor_install_stylable_property(actorClass, XfdashboardWorkspaceSelectorProperties[PROP_SHOW_CURRENT_MONITOR_ONLY]);
}
/* Object initialization
@@ -1277,6 +1329,7 @@ static void xfdashboard_workspace_selector_init(XfdashboardWorkspaceSelector *se
priv->maxSize=DEFAULT_MAX_SIZE;
priv->maxFraction=DEFAULT_MAX_FRACTION;
priv->usingFraction=DEFAULT_USING_FRACTION;
+ priv->showCurrentMonitorOnly=FALSE;
/* Set up this actor */
clutter_actor_set_reactive(CLUTTER_ACTOR(self), TRUE);
@@ -1512,3 +1565,53 @@ gboolean xfdashboard_workspace_selector_is_using_fraction(XfdashboardWorkspaceSe
return(self->priv->usingFraction);
}
+
+/* Get/set orientation */
+gboolean xfdashboard_workspace_selector_get_show_current_monitor_only(XfdashboardWorkspaceSelector *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(self), FALSE);
+
+ return(self->priv->showCurrentMonitorOnly);
+}
+
+void xfdashboard_workspace_selector_set_show_current_monitor_only(XfdashboardWorkspaceSelector *self, gboolean inShowCurrentMonitorOnly)
+{
+ XfdashboardWorkspaceSelectorPrivate *priv;
+ ClutterActorIter iter;
+ ClutterActor *child;
+ XfdashboardStageInterface *stageInterface;
+ XfdashboardWindowTrackerMonitor *monitor;
+
+ g_return_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(self));
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->showCurrentMonitorOnly!=inShowCurrentMonitorOnly)
+ {
+ /* Set value */
+ priv->showCurrentMonitorOnly=inShowCurrentMonitorOnly;
+
+ /* Get parent stage interface */
+ stageInterface=_xfdashboard_workspace_selector_get_stage_interface(self);
+
+ /* Get monitor of stage interface if available and if only windows
+ * of current monitor should be shown.
+ */
+ monitor=NULL;
+ if(stageInterface && priv->showCurrentMonitorOnly) monitor=xfdashboard_stage_interface_get_monitor(stageInterface);
+
+ /* Iterate through workspace actors and update monitor */
+ clutter_actor_iter_init(&iter, CLUTTER_ACTOR(self));
+ while(clutter_actor_iter_next(&iter, &child))
+ {
+ if(XFDASHBOARD_IS_LIVE_WORKSPACE(child))
+ {
+ xfdashboard_live_workspace_set_monitor(XFDASHBOARD_LIVE_WORKSPACE(child), monitor);
+ }
+ }
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardWorkspaceSelectorProperties[PROP_SHOW_CURRENT_MONITOR_ONLY]);
+ }
+}
diff --git a/xfdashboard/workspace-selector.h b/xfdashboard/workspace-selector.h
index e6d5685..fe87326 100644
--- a/xfdashboard/workspace-selector.h
+++ b/xfdashboard/workspace-selector.h
@@ -78,6 +78,9 @@ void xfdashboard_workspace_selector_set_maximum_fraction(XfdashboardWorkspaceSel
gboolean xfdashboard_workspace_selector_is_using_fraction(XfdashboardWorkspaceSelector *self);
+gboolean xfdashboard_workspace_selector_get_show_current_monitor_only(XfdashboardWorkspaceSelector *self);
+void xfdashboard_workspace_selector_set_show_current_monitor_only(XfdashboardWorkspaceSelector *self, gboolean inShowCurrentMonitorOnly);
+
G_END_DECLS
#endif /* __XFDASHBOARD_WORKSPACE_SELECTOR__ */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list