[mutter] workspace: Add a "workspace-index" property to MetaWorkspace



commit 19795c16811c186139125776d251a2efd43b6e9e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Aug 16 08:03:10 2014 -0400

    workspace: Add a "workspace-index" property to MetaWorkspace
    
    This will be used to replace some of the hooks that are used to call
    into window.c, so that the workspace index property is properly kept up
    to date.
    
    We can't name the property "index" since it causes conflicts with the
    meta_workspace_index method. This should really be called
    meta_workspace_get_index, but oh well.

 src/core/screen.c            |    2 +-
 src/core/workspace-private.h |    2 ++
 src/core/workspace.c         |   13 ++++++++++++-
 src/meta/workspace.h         |    1 -
 4 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/core/screen.c b/src/core/screen.c
index 545050c..6051c5c 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1122,7 +1122,7 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
   for (l = next; l != NULL; l = l->next)
     {
       MetaWorkspace *w = l->data;
-      meta_workspace_update_window_hints (w);
+      meta_workspace_index_changed (w);
     }
 
   meta_screen_queue_workarea_recalc (screen);
diff --git a/src/core/workspace-private.h b/src/core/workspace-private.h
index 34f498f..e75c926 100644
--- a/src/core/workspace-private.h
+++ b/src/core/workspace-private.h
@@ -94,4 +94,6 @@ void meta_workspace_focus_default_window (MetaWorkspace *workspace,
 
 const char* meta_workspace_get_name (MetaWorkspace *workspace);
 
+void meta_workspace_index_changed (MetaWorkspace *workspace);
+
 #endif
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 59b950a..fe94c37 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -60,6 +60,7 @@ enum {
   PROP_0,
 
   PROP_N_WINDOWS,
+  PROP_WORKSPACE_INDEX,
 
   LAST_PROP,
 };
@@ -114,6 +115,9 @@ meta_workspace_get_property (GObject      *object,
        */
       g_value_set_uint (value, g_list_length (ws->windows));
       break;
+    case PROP_WORKSPACE_INDEX:
+      g_value_set_uint (value, meta_workspace_index (ws));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -148,6 +152,11 @@ meta_workspace_class_init (MetaWorkspaceClass *klass)
                                                  "Number of windows",
                                                  0, G_MAXUINT, 0,
                                                  G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+  obj_props[PROP_WORKSPACE_INDEX] = g_param_spec_uint ("workspace-index",
+                                                       "Workspace index",
+                                                       "The workspace's index",
+                                                       0, G_MAXUINT, 0,
+                                                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
 
   g_object_class_install_properties (object_class, LAST_PROP, obj_props);
 }
@@ -691,7 +700,7 @@ meta_workspace_index (MetaWorkspace *workspace)
 }
 
 void
-meta_workspace_update_window_hints (MetaWorkspace *workspace)
+meta_workspace_index_changed (MetaWorkspace *workspace)
 {
   GList *l;
   for (l = workspace->windows; l != NULL; l = l->next)
@@ -699,6 +708,8 @@ meta_workspace_update_window_hints (MetaWorkspace *workspace)
       MetaWindow *win = l->data;
       meta_window_current_workspace_changed (win);
     }
+
+  g_object_notify_by_pspec (G_OBJECT (workspace), obj_props[PROP_WORKSPACE_INDEX]);
 }
 
 /**
diff --git a/src/meta/workspace.h b/src/meta/workspace.h
index 54b3858..9cce118 100644
--- a/src/meta/workspace.h
+++ b/src/meta/workspace.h
@@ -49,7 +49,6 @@ void meta_workspace_activate_with_focus (MetaWorkspace *workspace,
                                          MetaWindow    *focus_this,
                                          guint32        timestamp);
 
-void meta_workspace_update_window_hints (MetaWorkspace *workspace);
 void meta_workspace_set_builtin_struts (MetaWorkspace *workspace,
                                         GSList        *struts);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]