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 | 7 |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
13 | 13 |
14 // This is a helper class that is used to keep track of which window the X | 14 // This is a helper class that is used to keep track of which window the X |
15 // window manager thinks is active. Add an Observer to listener for changes to | 15 // window manager thinks is active. Add an Observer to listener for changes to |
16 // the active window. | 16 // the active window. |
17 class ActiveWindowWatcherX { | 17 class ActiveWindowWatcherX { |
18 public: | 18 public: |
19 class Observer { | 19 class Observer { |
20 public: | 20 public: |
21 // |active_window| will be NULL if the active window isn't one of Chrome's. | 21 // |active_window| will be NULL if the active window isn't one of Chrome's. |
22 virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; | 22 virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; |
| 23 |
| 24 protected: |
| 25 virtual ~Observer() {} |
23 }; | 26 }; |
24 | 27 |
25 static void AddObserver(Observer* observer); | 28 static void AddObserver(Observer* observer); |
26 static void RemoveObserver(Observer* observer); | 29 static void RemoveObserver(Observer* observer); |
27 | 30 |
28 private: | 31 private: |
29 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; | 32 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; |
30 | 33 |
31 ActiveWindowWatcherX(); | 34 ActiveWindowWatcherX(); |
32 | 35 |
33 void Init(); | 36 void Init(); |
34 | 37 |
35 // Sends a notification out through the NotificationService that the active | 38 // Sends a notification out through the NotificationService that the active |
36 // window has changed. | 39 // window has changed. |
37 void NotifyActiveWindowChanged(); | 40 void NotifyActiveWindowChanged(); |
38 | 41 |
39 // Callback for PropertyChange XEvents. | 42 // Callback for PropertyChange XEvents. |
40 static GdkFilterReturn OnWindowXEvent(GdkXEvent* xevent, | 43 static GdkFilterReturn OnWindowXEvent(GdkXEvent* xevent, |
41 GdkEvent* event, | 44 GdkEvent* event, |
42 gpointer window_watcher); | 45 gpointer window_watcher); |
43 | 46 |
44 ObserverList<Observer> observers_; | 47 ObserverList<Observer> observers_; |
45 | 48 |
46 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); | 49 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); |
47 }; | 50 }; |
48 | 51 |
49 #endif // APP_ACTIVE_WINDOW_WATCHER_X_H_ | 52 #endif // APP_ACTIVE_WINDOW_WATCHER_X_H_ |
OLD | NEW |