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