OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ |
6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
11 #undef RootWindow | 11 #undef RootWindow |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/observer_list.h" |
16 #include "ui/aura/env_observer.h" | 17 #include "ui/aura/env_observer.h" |
17 #include "ui/events/platform/platform_event_dispatcher.h" | 18 #include "ui/events/platform/platform_event_dispatcher.h" |
18 #include "ui/events/platform/x11/x11_event_source.h" | 19 #include "ui/events/platform/x11/x11_event_source.h" |
19 #include "ui/gfx/x/x11_atom_cache.h" | 20 #include "ui/gfx/x/x11_atom_cache.h" |
20 #include "ui/gfx/x/x11_types.h" | 21 #include "ui/gfx/x/x11_types.h" |
21 #include "ui/views/views_export.h" | 22 #include "ui/views/views_export.h" |
| 23 #include "ui/views/widget/desktop_aura/x11_desktop_handler_observer.h" |
22 | 24 |
23 namespace base { | 25 namespace base { |
24 template <typename T> struct DefaultSingletonTraits; | 26 template <typename T> struct DefaultSingletonTraits; |
25 } | 27 } |
26 | 28 |
27 namespace views { | 29 namespace views { |
28 | 30 |
29 // A singleton that owns global objects related to the desktop and listens for | 31 // A singleton that owns global objects related to the desktop and listens for |
30 // X11 events on the X11 root window. Destroys itself when aura::Env is | 32 // X11 events on the X11 root window. Destroys itself when aura::Env is |
31 // deleted. | 33 // deleted. |
32 class VIEWS_EXPORT X11DesktopHandler : public ui::PlatformEventDispatcher, | 34 class VIEWS_EXPORT X11DesktopHandler : public ui::PlatformEventDispatcher, |
33 public aura::EnvObserver { | 35 public aura::EnvObserver { |
34 public: | 36 public: |
35 // Returns the singleton handler. | 37 // Returns the singleton handler. |
36 static X11DesktopHandler* get(); | 38 static X11DesktopHandler* get(); |
37 | 39 |
| 40 // Adds/removes X11DesktopHandlerObservers. |
| 41 void AddObserver(X11DesktopHandlerObserver* observer); |
| 42 void RemoveObserver(X11DesktopHandlerObserver* observer); |
| 43 |
38 // Gets/sets the X11 server time of the most recent mouse click, touch or | 44 // Gets/sets the X11 server time of the most recent mouse click, touch or |
39 // key press on a Chrome window. | 45 // key press on a Chrome window. |
40 int wm_user_time_ms() const { return wm_user_time_ms_; } | 46 int wm_user_time_ms() const { return wm_user_time_ms_; } |
41 void set_wm_user_time_ms(Time time_ms); | 47 void set_wm_user_time_ms(Time time_ms); |
42 | 48 |
43 // Sends a request to the window manager to activate |window|. | 49 // Sends a request to the window manager to activate |window|. |
44 // This method should only be called if the window is already mapped. | 50 // This method should only be called if the window is already mapped. |
45 void ActivateWindow(::Window window); | 51 void ActivateWindow(::Window window); |
46 | 52 |
47 // Attempts to get the window manager to deactivate |window| by moving it to | 53 // Attempts to get the window manager to deactivate |window| by moving it to |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 ::Window current_window_; | 104 ::Window current_window_; |
99 | 105 |
100 // Whether we should treat |current_window_| as active. In particular, we | 106 // Whether we should treat |current_window_| as active. In particular, we |
101 // pretend that a window is deactivated after a call to DeactivateWindow(). | 107 // pretend that a window is deactivated after a call to DeactivateWindow(). |
102 ActiveState current_window_active_state_; | 108 ActiveState current_window_active_state_; |
103 | 109 |
104 ui::X11AtomCache atom_cache_; | 110 ui::X11AtomCache atom_cache_; |
105 | 111 |
106 bool wm_supports_active_window_; | 112 bool wm_supports_active_window_; |
107 | 113 |
| 114 base::ObserverList<X11DesktopHandlerObserver> observers_; |
| 115 |
108 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler); | 116 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler); |
109 }; | 117 }; |
110 | 118 |
111 } // namespace views | 119 } // namespace views |
112 | 120 |
113 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ | 121 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ |
OLD | NEW |