Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: ui/base/x/active_window_watcher_x.h

Issue 8595003: Have panels respond to changes in work area on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move observers into their own header files. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
15 #include "ui/base/ui_export.h" 12 #include "ui/base/ui_export.h"
13 #include "ui/base/x/x11_util.h"
16 14
17 namespace ui { 15 namespace ui {
18 16
17 class ActiveWindowWatcherXObserver;
18
19 namespace internal {
20
sky 2011/11/21 23:50:32 nit: generally we don't use newlines for namespace
prasadt 2011/11/22 00:46:34 Done.
21 class RootWindowPropertyWatcherX;
22
23 }
24
19 // This is a helper class that is used to keep track of which window the X 25 // 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 26 // window manager thinks is active. Add an Observer to listen for changes to
21 // the active window. 27 // the active window.
22 class UI_EXPORT ActiveWindowWatcherX { 28 class UI_EXPORT ActiveWindowWatcherX {
23 public: 29 public:
24 class Observer { 30 static ActiveWindowWatcherX* GetInstance();
25 public: 31 static void AddObserver(ActiveWindowWatcherXObserver* observer);
26 // |active_window| will be NULL if the active window isn't one of Chrome's. 32 static void RemoveObserver(ActiveWindowWatcherXObserver* observer);
27 virtual void ActiveWindowChanged(GdkWindow* active_window) = 0;
28 33
29 protected: 34 // Gets the atom for the default display for the property this class is
30 virtual ~Observer() {} 35 // watching for.
31 }; 36 static Atom GetPropertyAtom();
sky 2011/11/21 23:50:32 Can this be private too?
prasadt 2011/11/22 00:46:34 Done.
32
33 static ActiveWindowWatcherX* GetInstance();
34
35 static void AddObserver(Observer* observer);
36 static void RemoveObserver(Observer* observer);
37 37
38 // Checks if the WM supports the active window property. Note that the return 38 // Checks if the WM supports the active window property. Note that the return
39 // value can change, especially during system startup. 39 // value can change, especially during system startup.
40 static bool WMSupportsActivation(); 40 static bool WMSupportsActivation();
41 41
42 private: 42 private:
43 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>; 43 friend struct DefaultSingletonTraits<ActiveWindowWatcherX>;
44 friend class ui::internal::RootWindowPropertyWatcherX;
45
46 // Notify observers that the active window has changed.
47 static void Notify();
44 48
45 ActiveWindowWatcherX(); 49 ActiveWindowWatcherX();
sky 2011/11/21 23:50:32 constructor/destructor before other methods.
prasadt 2011/11/22 00:46:34 Done.
46 ~ActiveWindowWatcherX(); 50 ~ActiveWindowWatcherX();
47
48 void Init();
49
50 // Sends a notification out through the NotificationService that the active
51 // window has changed.
52 void NotifyActiveWindowChanged(); 51 void NotifyActiveWindowChanged();
53 52
54 // Callback for PropertyChange XEvents. 53 ObserverList<ActiveWindowWatcherXObserver> observers_;
55 CHROMEG_CALLBACK_1(ActiveWindowWatcherX, GdkFilterReturn,
56 OnWindowXEvent, GdkXEvent*, GdkEvent*);
57
58 ObserverList<Observer> observers_;
59 54
60 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX); 55 DISALLOW_COPY_AND_ASSIGN(ActiveWindowWatcherX);
61 }; 56 };
62 57
63 } // namespace ui 58 } // namespace ui
64 59
65 #endif // UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_ 60 #endif // UI_BASE_X_ACTIVE_WINDOW_WATCHER_X_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698