| OLD | NEW | 
|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef APP_ACTIVE_WINDOW_WATCHER_X_H_ | 5 #ifndef APP_ACTIVE_WINDOW_WATCHER_X_H_ | 
| 6 #define APP_ACTIVE_WINDOW_WATCHER_X_H_ | 6 #define APP_ACTIVE_WINDOW_WATCHER_X_H_ | 
| 7 #pragma once | 7 #pragma once | 
| 8 | 8 | 
| 9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> | 
| 10 | 10 | 
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" | 
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" | 
| 13 #include "base/singleton.h" | 13 #include "base/singleton.h" | 
| 14 | 14 | 
| 15 // This is a helper class that is used to keep track of which window the X | 15 // This is a helper class that is used to keep track of which window the X | 
| 16 // window manager thinks is active. Add an Observer to listener for changes to | 16 // window manager thinks is active. Add an Observer to listener for changes to | 
| 17 // the active window. | 17 // the active window. | 
| 18 class ActiveWindowWatcherX { | 18 class ActiveWindowWatcherX { | 
| 19  public: | 19  public: | 
| 20   class Observer { | 20   class Observer { | 
| 21    public: | 21    public: | 
| 22     // |active_window| will be NULL if the active window isn't one of Chrome's. | 22     // |active_window| will be NULL if the active window isn't one of Chrome's. | 
| 23     virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; | 23     virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; | 
| 24 | 24 | 
| 25    protected: | 25    protected: | 
| 26     virtual ~Observer() {} | 26     virtual ~Observer() {} | 
| 27   }; | 27   }; | 
| 28 | 28 | 
|  | 29   static ActiveWindowWatcherX* GetInstance(); | 
|  | 30 | 
| 29   static void AddObserver(Observer* observer); | 31   static void AddObserver(Observer* observer); | 
| 30   static void RemoveObserver(Observer* observer); | 32   static void RemoveObserver(Observer* observer); | 
| 31 | 33 | 
| 32  private: | 34  private: | 
| 33   friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; | 35   friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; | 
| 34 | 36 | 
| 35   ActiveWindowWatcherX(); | 37   ActiveWindowWatcherX(); | 
| 36   ~ActiveWindowWatcherX(); | 38   ~ActiveWindowWatcherX(); | 
| 37 | 39 | 
| 38   static ActiveWindowWatcherX* GetInstance(); |  | 
| 39 |  | 
| 40   void Init(); | 40   void Init(); | 
| 41 | 41 | 
| 42   // Sends a notification out through the NotificationService that the active | 42   // Sends a notification out through the NotificationService that the active | 
| 43   // window has changed. | 43   // window has changed. | 
| 44   void NotifyActiveWindowChanged(); | 44   void NotifyActiveWindowChanged(); | 
| 45 | 45 | 
| 46   // Callback for PropertyChange XEvents. | 46   // Callback for PropertyChange XEvents. | 
| 47   static GdkFilterReturn OnWindowXEvent(GdkXEvent* xevent, | 47   static GdkFilterReturn OnWindowXEvent(GdkXEvent* xevent, | 
| 48                                         GdkEvent* event, | 48                                         GdkEvent* event, | 
| 49                                         gpointer window_watcher); | 49                                         gpointer window_watcher); | 
| 50 | 50 | 
| 51   ObserverList<Observer> observers_; | 51   ObserverList<Observer> observers_; | 
| 52 | 52 | 
| 53   DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); | 53   DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); | 
| 54 }; | 54 }; | 
| 55 | 55 | 
| 56 #endif  // APP_ACTIVE_WINDOW_WATCHER_X_H_ | 56 #endif  // APP_ACTIVE_WINDOW_WATCHER_X_H_ | 
| OLD | NEW | 
|---|