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_AURA_WINDOW_TREE_HOST_X11_H_ | 5 #ifndef UI_AURA_WINDOW_TREE_HOST_X11_H_ |
6 #define UI_AURA_WINDOW_TREE_HOST_X11_H_ | 6 #define UI_AURA_WINDOW_TREE_HOST_X11_H_ |
7 | 7 |
8 #include <X11/Xlib.h> | |
9 | |
10 #include <vector> | |
11 | |
12 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | |
13 #undef RootWindow | |
14 | |
15 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
16 #include "ui/aura/aura_export.h" | 9 #include "ui/aura/aura_export.h" |
17 #include "ui/aura/env_observer.h" | |
18 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
19 #include "ui/base/x/x11_util.h" | |
20 #include "ui/events/event_source.h" | 11 #include "ui/events/event_source.h" |
21 #include "ui/events/platform/platform_event_dispatcher.h" | 12 #include "ui/events/platform/platform_event_dispatcher.h" |
22 #include "ui/gfx/insets.h" | 13 #include "ui/gfx/insets.h" |
23 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
24 #include "ui/gfx/x/x11_atom_cache.h" | 15 #include "ui/gfx/x/x11_atom_cache.h" |
25 | 16 |
| 17 // X forward decls to avoid including Xlib.h in a header file. |
| 18 typedef struct _XDisplay XDisplay; |
| 19 typedef unsigned long XID; |
| 20 typedef XID Window; |
| 21 |
26 namespace ui { | 22 namespace ui { |
27 class MouseEvent; | 23 class MouseEvent; |
28 } | 24 } |
29 | 25 |
30 namespace aura { | 26 namespace aura { |
31 | 27 |
32 namespace internal { | 28 namespace internal { |
33 class TouchEventCalibrate; | 29 class TouchEventCalibrate; |
34 } | 30 } |
35 | 31 |
36 class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost, | 32 class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost, |
37 public ui::EventSource, | 33 public ui::EventSource, |
38 public ui::PlatformEventDispatcher, | 34 public ui::PlatformEventDispatcher { |
39 public EnvObserver { | 35 |
40 public: | 36 public: |
41 explicit WindowTreeHostX11(const gfx::Rect& bounds); | 37 explicit WindowTreeHostX11(const gfx::Rect& bounds); |
42 virtual ~WindowTreeHostX11(); | 38 virtual ~WindowTreeHostX11(); |
43 | 39 |
44 // ui::PlatformEventDispatcher: | 40 // ui::PlatformEventDispatcher: |
45 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; | 41 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; |
46 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; | 42 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; |
47 | 43 |
48 // WindowTreeHost: | 44 // WindowTreeHost: |
49 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; | 45 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
50 virtual void Show() OVERRIDE; | 46 virtual void Show() OVERRIDE; |
51 virtual void Hide() OVERRIDE; | 47 virtual void Hide() OVERRIDE; |
52 virtual void ToggleFullScreen() OVERRIDE; | |
53 virtual gfx::Rect GetBounds() const OVERRIDE; | 48 virtual gfx::Rect GetBounds() const OVERRIDE; |
54 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 49 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
55 virtual gfx::Insets GetInsets() const OVERRIDE; | |
56 virtual void SetInsets(const gfx::Insets& insets) OVERRIDE; | |
57 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; | 50 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; |
58 virtual void SetCapture() OVERRIDE; | 51 virtual void SetCapture() OVERRIDE; |
59 virtual void ReleaseCapture() OVERRIDE; | 52 virtual void ReleaseCapture() OVERRIDE; |
60 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; | 53 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; |
61 virtual bool ConfineCursorToRootWindow() OVERRIDE; | |
62 virtual void UnConfineCursor() OVERRIDE; | |
63 virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; | 54 virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; |
64 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | 55 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; |
65 virtual void SetCursorNative(gfx::NativeCursor cursor_type) OVERRIDE; | 56 virtual void SetCursorNative(gfx::NativeCursor cursor_type) OVERRIDE; |
66 virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE; | 57 virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE; |
67 virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE; | 58 virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE; |
68 | 59 |
69 // EnvObserver overrides. | |
70 virtual void OnWindowInitialized(Window* window) OVERRIDE; | |
71 virtual void OnHostInitialized(WindowTreeHost* host) OVERRIDE; | |
72 | |
73 // ui::EventSource overrides. | 60 // ui::EventSource overrides. |
74 virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; | 61 virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; |
75 | 62 |
| 63 protected: |
| 64 // Called when X Configure Notify event is recevied. |
| 65 virtual void OnConfigureNotify(); |
| 66 |
| 67 // Translates the native mouse location into screen coordinates and and |
| 68 // dispatches the event via WindowEventDispatcher. |
| 69 virtual void TranslateAndDispatchLocatedEvent(ui::LocatedEvent* event); |
| 70 |
| 71 ::Window x_root_window() { return x_root_window_; } |
| 72 XDisplay* xdisplay() { return xdisplay_; } |
| 73 const gfx::Rect bounds() const { return bounds_; } |
| 74 ui::X11AtomCache* atom_cache() { return &atom_cache_; } |
| 75 |
76 private: | 76 private: |
77 // Dispatches XI2 events. Note that some events targetted for the X root | 77 // Dispatches XI2 events. Note that some events targetted for the X root |
78 // window are dispatched to the aura root window (e.g. touch events after | 78 // window are dispatched to the aura root window (e.g. touch events after |
79 // calibration). | 79 // calibration). |
80 void DispatchXI2Event(const base::NativeEvent& event); | 80 void DispatchXI2Event(const base::NativeEvent& event); |
81 | 81 |
82 // Returns true if there's an X window manager present... in most cases. Some | 82 // Returns true if there's an X window manager present... in most cases. Some |
83 // window managers (notably, ion3) don't implement enough of ICCCM for us to | 83 // window managers (notably, ion3) don't implement enough of ICCCM for us to |
84 // detect that they're there. | 84 // detect that they're there. |
85 bool IsWindowManagerPresent(); | 85 bool IsWindowManagerPresent(); |
86 | 86 |
87 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update | 87 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update |
88 // |current_cursor_|. | 88 // |current_cursor_|. |
89 void SetCursorInternal(gfx::NativeCursor cursor); | 89 void SetCursorInternal(gfx::NativeCursor cursor); |
90 | 90 |
91 // Translates the native mouse location into screen coordinates and and | |
92 // dispatches the event via WindowEventDispatcher. | |
93 void TranslateAndDispatchMouseEvent(ui::MouseEvent* event); | |
94 | |
95 // Update is_internal_display_ based on delegate_ state | |
96 void UpdateIsInternalDisplay(); | |
97 | |
98 // Set the CrOS touchpad "tap paused" property. It is used to temporarily | |
99 // turn off the Tap-to-click feature when the mouse pointer is invisible. | |
100 void SetCrOSTapPaused(bool state); | |
101 | |
102 // The display and the native X window hosting the root window. | 91 // The display and the native X window hosting the root window. |
103 XDisplay* xdisplay_; | 92 XDisplay* xdisplay_; |
104 ::Window xwindow_; | 93 ::Window xwindow_; |
105 | 94 |
106 // The native root window. | 95 // The native root window. |
107 ::Window x_root_window_; | 96 ::Window x_root_window_; |
108 | 97 |
109 // Current Aura cursor. | 98 // Current Aura cursor. |
110 gfx::NativeCursor current_cursor_; | 99 gfx::NativeCursor current_cursor_; |
111 | 100 |
112 // Is the window mapped to the screen? | 101 // Is the window mapped to the screen? |
113 bool window_mapped_; | 102 bool window_mapped_; |
114 | 103 |
115 // The bounds of |xwindow_|. | 104 // The bounds of |xwindow_|. |
116 gfx::Rect bounds_; | 105 gfx::Rect bounds_; |
117 | 106 |
118 // The insets that specifies the effective area within the |window_|. | |
119 gfx::Insets insets_; | |
120 | |
121 // True if the root host resides on the internal display | |
122 bool is_internal_display_; | |
123 | |
124 scoped_ptr<XID[]> pointer_barriers_; | |
125 | |
126 scoped_ptr<internal::TouchEventCalibrate> touch_calibrate_; | |
127 | |
128 ui::X11AtomCache atom_cache_; | 107 ui::X11AtomCache atom_cache_; |
129 | 108 |
130 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11); | 109 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11); |
131 }; | 110 }; |
132 | 111 |
133 namespace test { | 112 namespace test { |
134 | 113 |
135 // Set the default value of the override redirect flag used to | 114 // Set the default value of the override redirect flag used to |
136 // create a X window for WindowTreeHostX11. | 115 // create a X window for WindowTreeHostX11. |
137 AURA_EXPORT void SetUseOverrideRedirectWindowByDefault(bool override_redirect); | 116 AURA_EXPORT void SetUseOverrideRedirectWindowByDefault(bool override_redirect); |
138 | 117 |
139 } // namespace test | 118 } // namespace test |
140 } // namespace aura | 119 } // namespace aura |
141 | 120 |
142 #endif // UI_AURA_WINDOW_TREE_HOST_X11_H_ | 121 #endif // UI_AURA_WINDOW_TREE_HOST_X11_H_ |
OLD | NEW |