OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef APP_ACTIVE_WINDOW_WATCHER_X_H_ | |
6 #define APP_ACTIVE_WINDOW_WATCHER_X_H_ | |
7 #pragma once | |
8 | |
9 #include <gdk/gdk.h> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/observer_list.h" | |
13 #include "base/singleton.h" | |
14 | |
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 | |
17 // the active window. | |
18 class ActiveWindowWatcherX { | |
19 public: | |
20 class Observer { | |
21 public: | |
22 // |active_window| will be NULL if the active window isn't one of Chrome's. | |
23 virtual void ActiveWindowChanged(GdkWindow* active_window) = 0; | |
24 | |
25 protected: | |
26 virtual ~Observer() {} | |
27 }; | |
28 | |
29 static ActiveWindowWatcherX* GetInstance(); | |
30 | |
31 static void AddObserver(Observer* observer); | |
32 static void RemoveObserver(Observer* observer); | |
33 | |
34 private: | |
35 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; | |
36 | |
37 ActiveWindowWatcherX(); | |
38 ~ActiveWindowWatcherX(); | |
39 | |
40 void Init(); | |
41 | |
42 // Sends a notification out through the NotificationService that the active | |
43 // window has changed. | |
44 void NotifyActiveWindowChanged(); | |
45 | |
46 // Callback for PropertyChange XEvents. | |
47 static GdkFilterReturn OnWindowXEvent(GdkXEvent* xevent, | |
48 GdkEvent* event, | |
49 gpointer window_watcher); | |
50 | |
51 ObserverList<Observer> observers_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); | |
54 }; | |
55 | |
56 #endif // APP_ACTIVE_WINDOW_WATCHER_X_H_ | |
OLD | NEW |