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 <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 9 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
10 #undef RootWindow | 10 #undef RootWindow |
11 | 11 |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/message_loop/message_pump_dispatcher.h" | |
15 #include "ui/aura/env_observer.h" | 14 #include "ui/aura/env_observer.h" |
| 15 #include "ui/events/platform/platform_event_dispatcher.h" |
16 #include "ui/gfx/x/x11_atom_cache.h" | 16 #include "ui/gfx/x/x11_atom_cache.h" |
17 #include "ui/gfx/x/x11_types.h" | 17 #include "ui/gfx/x/x11_types.h" |
18 #include "ui/views/views_export.h" | 18 #include "ui/views/views_export.h" |
19 | 19 |
20 template <typename T> struct DefaultSingletonTraits; | 20 template <typename T> struct DefaultSingletonTraits; |
21 | 21 |
22 namespace views { | 22 namespace views { |
23 | 23 |
24 // A singleton that owns global objects related to the desktop and listens for | 24 // A singleton that owns global objects related to the desktop and listens for |
25 // X11 events on the X11 root window. Destroys itself when aura::Env is | 25 // X11 events on the X11 root window. Destroys itself when aura::Env is |
26 // deleted. | 26 // deleted. |
27 class VIEWS_EXPORT X11DesktopHandler : public base::MessagePumpDispatcher, | 27 class VIEWS_EXPORT X11DesktopHandler : public ui::PlatformEventDispatcher, |
28 public aura::EnvObserver { | 28 public aura::EnvObserver { |
29 public: | 29 public: |
30 // Returns the singleton handler. | 30 // Returns the singleton handler. |
31 static X11DesktopHandler* get(); | 31 static X11DesktopHandler* get(); |
32 | 32 |
33 // Sends a request to the window manager to activate |window|. | 33 // Sends a request to the window manager to activate |window|. |
34 // This method should only be called if the window is already mapped. | 34 // This method should only be called if the window is already mapped. |
35 void ActivateWindow(::Window window); | 35 void ActivateWindow(::Window window); |
36 | 36 |
37 // Checks if the current active window is |window|. | 37 // Checks if the current active window is |window|. |
38 bool IsActiveWindow(::Window window) const; | 38 bool IsActiveWindow(::Window window) const; |
39 | 39 |
40 // Processes activation/focus related events. Some of these events are | 40 // Processes activation/focus related events. Some of these events are |
41 // dispatched to the X11 window dispatcher, and not to the X11 root-window | 41 // dispatched to the X11 window dispatcher, and not to the X11 root-window |
42 // dispatcher. The window dispatcher sends these events to here. | 42 // dispatcher. The window dispatcher sends these events to here. |
43 void ProcessXEvent(const base::NativeEvent& event); | 43 void ProcessXEvent(XEvent* event); |
44 | 44 |
45 // Overridden from MessagePumpDispatcher: | 45 // ui::PlatformEventDispatcher |
46 virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; | 46 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; |
| 47 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; |
47 | 48 |
48 // Overridden from aura::EnvObserver: | 49 // Overridden from aura::EnvObserver: |
49 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; | 50 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; |
50 virtual void OnWillDestroyEnv() OVERRIDE; | 51 virtual void OnWillDestroyEnv() OVERRIDE; |
51 | 52 |
52 private: | 53 private: |
53 explicit X11DesktopHandler(); | 54 explicit X11DesktopHandler(); |
54 virtual ~X11DesktopHandler(); | 55 virtual ~X11DesktopHandler(); |
55 | 56 |
56 // Handles changes in activation. | 57 // Handles changes in activation. |
(...skipping 11 matching lines...) Expand all Loading... |
68 ui::X11AtomCache atom_cache_; | 69 ui::X11AtomCache atom_cache_; |
69 | 70 |
70 bool wm_supports_active_window_; | 71 bool wm_supports_active_window_; |
71 | 72 |
72 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler); | 73 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler); |
73 }; | 74 }; |
74 | 75 |
75 } // namespace views | 76 } // namespace views |
76 | 77 |
77 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ | 78 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ |
OLD | NEW |