OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ | 5 #ifndef UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ |
6 #define UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ | 6 #define UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gdk/gdk.h> | |
10 | |
11 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
12 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
13 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
14 #include "ui/base/gtk/gtk_signal.h" | 12 #include "ui/base/gtk/gtk_signal.h" |
15 #include "ui/base/ui_export.h" | 13 #include "ui/base/ui_export.h" |
16 | 14 |
| 15 #if defined(TOOLKIT_USES_GTK) |
| 16 #include <gdk/gdk.h> |
| 17 #endif |
| 18 |
17 namespace ui { | 19 namespace ui { |
18 | 20 |
19 // This is a helper class that is used to keep track of which window the X | 21 // This is a helper class that is used to keep track of which window the X |
20 // window manager thinks is active. Add an Observer to listener for changes to | 22 // window manager thinks is active. Add an Observer to listener for changes to |
21 // the active window. | 23 // the active window. |
22 class UI_EXPORT ActiveWindowWatcherX { | 24 class UI_EXPORT ActiveWindowWatcherX { |
23 public: | 25 public: |
24 class Observer { | 26 class Observer { |
25 public: | 27 public: |
| 28 #if defined(TOOLKIT_USES_GTK) |
26 // |active_window| will be NULL if the active window isn't one of Chrome's. | 29 // |active_window| will be NULL if the active window isn't one of Chrome's. |
27 virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; | 30 virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; |
| 31 #endif |
28 | 32 |
29 protected: | 33 protected: |
30 virtual ~Observer() {} | 34 virtual ~Observer() {} |
31 }; | 35 }; |
32 | 36 |
33 static ActiveWindowWatcherX* GetInstance(); | 37 static ActiveWindowWatcherX* GetInstance(); |
34 | 38 |
35 static void AddObserver(Observer* observer); | 39 static void AddObserver(Observer* observer); |
36 static void RemoveObserver(Observer* observer); | 40 static void RemoveObserver(Observer* observer); |
37 | 41 |
38 // Checks if the WM supports the active window property. Note that the return | 42 // Checks if the WM supports the active window property. Note that the return |
39 // value can change, especially during system startup. | 43 // value can change, especially during system startup. |
40 static bool WMSupportsActivation(); | 44 static bool WMSupportsActivation(); |
41 | 45 |
42 private: | 46 private: |
43 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; | 47 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; |
44 | 48 |
45 ActiveWindowWatcherX(); | 49 ActiveWindowWatcherX(); |
46 virtual ~ActiveWindowWatcherX(); | 50 virtual ~ActiveWindowWatcherX(); |
47 | 51 |
48 void Init(); | 52 void Init(); |
49 | 53 |
50 // Sends a notification out through the NotificationService that the active | 54 // Sends a notification out through the NotificationService that the active |
51 // window has changed. | 55 // window has changed. |
52 void NotifyActiveWindowChanged(); | 56 void NotifyActiveWindowChanged(); |
53 | 57 |
| 58 #if defined(TOOLKIT_USES_GTK) |
54 // Callback for PropertyChange XEvents. | 59 // Callback for PropertyChange XEvents. |
55 CHROMEG_CALLBACK_1(ActiveWindowWatcherX, GdkFilterReturn, | 60 CHROMEG_CALLBACK_1(ActiveWindowWatcherX, GdkFilterReturn, |
56 OnWindowXEvent, GdkXEvent*, GdkEvent*); | 61 OnWindowXEvent, GdkXEvent*, GdkEvent*); |
| 62 #endif |
57 | 63 |
58 ObserverList<Observer> observers_; | 64 ObserverList<Observer> observers_; |
59 | 65 |
60 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); | 66 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); |
61 }; | 67 }; |
62 | 68 |
63 } // namespace ui | 69 } // namespace ui |
64 | 70 |
65 #endif // UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ | 71 #endif // UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ |
OLD | NEW |