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.
5 #ifndef APP_ACTIVE_WINDOW_WATCHER_X_H_
6 #define APP_ACTIVE_WINDOW_WATCHER_X_H_
10 #include "base/basictypes.h"
11 #include "base/observer_list.h"
12 #include "base/singleton.h"
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
17 class ActiveWindowWatcherX
{
21 // |active_window| will be NULL if the active window isn't one of Chrome's.
22 virtual void ActiveWindowChanged(GdkWindow
* active_window
) = 0;
25 static void AddObserver(Observer
* observer
);
26 static void RemoveObserver(Observer
* observer
);
29 friend struct DefaultSingletonTraits
<ActiveWindowWatcherX
>;
31 ActiveWindowWatcherX();
35 // Sends a notification out through the NotificationService that the active
36 // window has changed.
37 void NotifyActiveWindowChanged();
39 // Callback for PropertyChange XEvents.
40 static GdkFilterReturn
OnWindowXEvent(GdkXEvent
* xevent
,
42 gpointer window_watcher
);
44 ObserverList
<Observer
> observers_
;
46 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX
);
49 #endif // APP_ACTIVE_WINDOW_WATCHER_X_H_