Chromium Code Reviews| 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> | 9 #include <gdk/gdk.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 13 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 14 #include "ui/base/gtk/gtk_signal.h" | |
| 15 #include "ui/base/ui_export.h" | 13 #include "ui/base/ui_export.h" |
| 14 #include "ui/base/x/x11_util.h" | |
| 16 | 15 |
| 17 namespace ui { | 16 namespace ui { |
| 18 | 17 |
| 19 // This is a helper class that is used to keep track of which window the X | 18 // 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 | 19 // window manager thinks is active. Add an Observer to listen for changes to |
| 21 // the active window. | 20 // the active window. |
| 22 class UI_EXPORT ActiveWindowWatcherX { | 21 class UI_EXPORT ActiveWindowWatcherX { |
| 23 public: | 22 public: |
| 24 class Observer { | 23 class Observer { |
| 25 public: | 24 public: |
| 26 // |active_window| will be NULL if the active window isn't one of Chrome's. | 25 // |active_window| will be NULL if the active window isn't one of Chrome's. |
| 27 virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; | 26 virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; |
| 28 | 27 |
| 29 protected: | 28 protected: |
| 30 virtual ~Observer() {} | 29 virtual ~Observer() {} |
| 31 }; | 30 }; |
| 32 | 31 |
| 33 static ActiveWindowWatcherX* GetInstance(); | 32 static ActiveWindowWatcherX* GetInstance(); |
| 34 | |
| 35 static void AddObserver(Observer* observer); | 33 static void AddObserver(Observer* observer); |
| 36 static void RemoveObserver(Observer* observer); | 34 static void RemoveObserver(Observer* observer); |
| 35 static Atom GetPropertyAtom(); | |
|
sky
2011/11/18 17:54:22
Add a description.
prasadt
2011/11/18 22:31:42
Done.
| |
| 36 | |
| 37 // Sends a notification out through the NotificationService that the active | |
| 38 // window has changed. | |
| 39 static void Notify(); | |
|
sky
2011/11/18 17:54:22
This doesn't notify through the NOtificationServic
prasadt
2011/11/18 22:31:42
I did consider that option. Didn't do it for a few
sky
2011/11/18 22:44:58
I'm ok with it as long as you make RootWindowPrope
prasadt
2011/11/21 23:36:49
Done.
| |
| 37 | 40 |
| 38 // Checks if the WM supports the active window property. Note that the return | 41 // Checks if the WM supports the active window property. Note that the return |
| 39 // value can change, especially during system startup. | 42 // value can change, especially during system startup. |
| 40 static bool WMSupportsActivation(); | 43 static bool WMSupportsActivation(); |
| 41 | 44 |
| 42 private: | 45 private: |
| 43 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; | 46 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; |
| 44 | 47 |
| 45 ActiveWindowWatcherX(); | 48 ActiveWindowWatcherX() {} |
|
sky
2011/11/18 17:54:22
Don't inline these.
prasadt
2011/11/18 22:31:42
Done.
Curious though why this is discouraged.
sky
2011/11/18 22:44:58
See threads from erg on this. Your class is probab
sky
2011/11/18 22:46:39
Ha. I was just asked to review a change that cause
| |
| 46 ~ActiveWindowWatcherX(); | 49 ~ActiveWindowWatcherX() {} |
| 47 | |
| 48 void Init(); | |
| 49 | |
| 50 // Sends a notification out through the NotificationService that the active | |
| 51 // window has changed. | |
| 52 void NotifyActiveWindowChanged(); | 50 void NotifyActiveWindowChanged(); |
| 53 | 51 |
| 54 // Callback for PropertyChange XEvents. | |
| 55 CHROMEG_CALLBACK_1(ActiveWindowWatcherX, GdkFilterReturn, | |
| 56 OnWindowXEvent, GdkXEvent*, GdkEvent*); | |
| 57 | |
| 58 ObserverList<Observer> observers_; | 52 ObserverList<Observer> observers_; |
| 59 | 53 |
| 60 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); | 54 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); |
| 61 }; | 55 }; |
| 62 | 56 |
| 63 } // namespace ui | 57 } // namespace ui |
| 64 | 58 |
| 65 #endif // UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ | 59 #endif // UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ |
| OLD | NEW |