[mutter] Add focus-window property to MetaDisplay



commit df90187e06066f0fff4a8208ccc55b9b6b0e8a34
Author: Colin Walters <walters verbum org>
Date:   Thu Jul 30 17:33:11 2009 -0400

    Add focus-window property to MetaDisplay
    
    Useful mainly for notify::focus-window.

 src/core/display.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/core/window.c  |    8 +++++-
 2 files changed, 61 insertions(+), 3 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index fd3b2ee..121c1aa 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -128,9 +128,16 @@ G_DEFINE_TYPE(MetaDisplay, meta_display, G_TYPE_OBJECT);
 enum
 {
   OVERLAY_KEY,
+  FOCUS_WINDOW,
   LAST_SIGNAL
 };
 
+enum {
+  PROP_0,
+
+  PROP_FOCUS_WINDOW
+};
+
 static guint display_signals [LAST_SIGNAL] = { 0 };
 
 /**
@@ -170,8 +177,46 @@ static void    sanity_check_timestamps   (MetaDisplay *display,
 MetaGroup*     get_focussed_group (MetaDisplay *display);
 
 static void
+meta_display_get_property(GObject         *object,
+                          guint            prop_id,
+                          GValue          *value,
+                          GParamSpec      *pspec)
+{
+  MetaDisplay *display = META_DISPLAY (object);
+
+  switch (prop_id)
+    {
+    case PROP_FOCUS_WINDOW:
+      g_value_set_object (value, display->focus_window);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+meta_display_set_property(GObject         *object,
+                          guint            prop_id,
+                          const GValue    *value,
+                          GParamSpec      *pspec)
+{
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
 meta_display_class_init (MetaDisplayClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->get_property = meta_display_get_property;
+  object_class->set_property = meta_display_set_property;
+
   display_signals[OVERLAY_KEY] =
     g_signal_new ("overlay-key",
                   G_TYPE_FROM_CLASS (klass),
@@ -179,9 +224,18 @@ meta_display_class_init (MetaDisplayClass *klass)
                   0,
                   NULL, NULL,
                   g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE, 0);  
+                  G_TYPE_NONE, 0);
+
+  g_object_class_install_property (object_class,
+                                   PROP_FOCUS_WINDOW,
+                                   g_param_spec_object ("focus-window",
+                                                        "Focus window",
+                                                        "Currently focused window",
+                                                        META_TYPE_WINDOW,
+                                                        G_PARAM_READABLE));
 }
 
+
 /**
  * Destructor for MetaPingData structs. Will destroy the
  * event source for the struct as well.
diff --git a/src/core/window.c b/src/core/window.c
index b677cee..0e9bbe2 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1289,7 +1289,10 @@ meta_window_unmanage (MetaWindow  *window,
   g_assert (window->display->grab_window != window);
 
   if (window->display->focus_window == window)
-    window->display->focus_window = NULL;
+    {
+      window->display->focus_window = NULL;
+      g_object_notify (window->display, "focus-window");
+    }
 
   if (window->maximized_horizontally || window->maximized_vertically)
     unmaximize_window_before_freeing (window);
@@ -5747,7 +5750,7 @@ meta_window_notify_focus (MetaWindow *window,
             meta_display_ungrab_focus_window_button (window->display, window);
 
           g_signal_emit (window, window_signals[FOCUS], 0);
-
+          g_object_notify (window->display, "focus-window");
         }
     }
   else if (event->type == FocusOut ||
@@ -5773,6 +5776,7 @@ meta_window_notify_focus (MetaWindow *window,
                       "* Focus --> NULL (was %s)\n", window->desc);
 
           window->display->focus_window = NULL;
+          g_object_notify (window->display, "focus-window");
           window->has_focus = FALSE;
           if (window->frame)
             meta_frame_queue_draw (window->frame);



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