WebKit Update 61491:61498.
[chromium-blink-merge.git] / app / active_window_watcher_x.h
blob0934ad40cefb57369ae24e161cdbe830fb2d7b17
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_
8 #include <gdk/gdk.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
16 // the active window.
17 class ActiveWindowWatcherX {
18 public:
19 class Observer {
20 public:
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);
28 private:
29 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>;
31 ActiveWindowWatcherX();
33 void Init();
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,
41 GdkEvent* event,
42 gpointer window_watcher);
44 ObserverList<Observer> observers_;
46 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX);
49 #endif // APP_ACTIVE_WINDOW_WATCHER_X_H_