Chromium Code Reviews| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "ui/aura/aura_export.h" | 13 #include "ui/aura/aura_export.h" |
| 14 #include "ui/aura/window_tree_host.h" | 14 #include "ui/aura/window_tree_host.h" |
| 15 #include "ui/events/platform/platform_event_dispatcher.h" | 15 #include "ui/events/platform/platform_event_dispatcher.h" |
| 16 #include "ui/gfx/geometry/insets.h" | 16 #include "ui/gfx/geometry/insets.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/gfx/x/x11_atom_cache.h" | 18 #include "ui/gfx/x/x11_atom_cache.h" |
| 19 | 19 |
| 20 // X forward decls to avoid including Xlib.h in a header file. | 20 // X forward decls to avoid including Xlib.h in a header file. |
| 21 typedef struct _XDisplay XDisplay; | 21 typedef struct _XDisplay XDisplay; |
| 22 typedef unsigned long XID; | 22 typedef unsigned long XID; |
| 23 typedef XID Window; | 23 typedef XID Window; |
| 24 | 24 |
| 25 namespace ui { | 25 namespace ui { |
| 26 class MouseEvent; | 26 class MouseEvent; |
| 27 class XScopedEventSelector; | |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace aura { | 30 namespace aura { |
| 30 | 31 |
| 31 class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost, | 32 class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost, |
| 32 public ui::PlatformEventDispatcher { | 33 public ui::PlatformEventDispatcher { |
| 33 public: | 34 public: |
| 34 explicit WindowTreeHostX11(const gfx::Rect& bounds); | 35 explicit WindowTreeHostX11(const gfx::Rect& bounds); |
| 35 ~WindowTreeHostX11() override; | 36 ~WindowTreeHostX11() override; |
| 36 | 37 |
| 37 // ui::PlatformEventDispatcher: | 38 // ui::PlatformEventDispatcher: |
| 38 bool CanDispatchEvent(const ui::PlatformEvent& event) override; | 39 bool CanDispatchEvent(const ui::PlatformEvent& event) override; |
| 39 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; | 40 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; |
| 40 | 41 |
| 41 // WindowTreeHost: | 42 // WindowTreeHost: |
| 42 ui::EventSource* GetEventSource() override; | 43 ui::EventSource* GetEventSource() override; |
| 43 gfx::AcceleratedWidget GetAcceleratedWidget() override; | 44 gfx::AcceleratedWidget GetAcceleratedWidget() override; |
| 44 void ShowImpl() override; | 45 void ShowImpl() override; |
| 45 void HideImpl() override; | 46 void HideImpl() override; |
| 46 gfx::Rect GetBounds() const override; | 47 gfx::Rect GetBounds() const override; |
| 47 void SetBounds(const gfx::Rect& bounds) override; | 48 void SetBounds(const gfx::Rect& bounds) override; |
| 48 gfx::Point GetLocationOnNativeScreen() const override; | 49 gfx::Point GetLocationOnNativeScreen() const override; |
| 49 void SetCapture() override; | 50 void SetCapture() override; |
| 50 void ReleaseCapture() override; | 51 void ReleaseCapture() override; |
| 51 void SetCursorNative(gfx::NativeCursor cursor_type) override; | 52 void SetCursorNative(gfx::NativeCursor cursor_type) override; |
| 52 void MoveCursorToNative(const gfx::Point& location) override; | 53 void MoveCursorToNative(const gfx::Point& location) override; |
| 53 void OnCursorVisibilityChangedNative(bool show) override; | 54 void OnCursorVisibilityChangedNative(bool show) override; |
| 54 | 55 |
| 56 void DisableInput(); | |
|
Daniel Erat
2016/09/07 22:58:36
nit: please add a brief comment describing what th
Tom (Use chromium acct)
2016/09/07 23:31:16
Done.
| |
| 57 | |
| 55 protected: | 58 protected: |
| 56 // Called when X Configure Notify event is recevied. | 59 // Called when X Configure Notify event is recevied. |
| 57 virtual void OnConfigureNotify(); | 60 virtual void OnConfigureNotify(); |
| 58 | 61 |
| 59 // Translates the native mouse location into screen coordinates and | 62 // Translates the native mouse location into screen coordinates and |
| 60 // dispatches the event via WindowEventDispatcher. | 63 // dispatches the event via WindowEventDispatcher. |
| 61 virtual void TranslateAndDispatchLocatedEvent(ui::LocatedEvent* event); | 64 virtual void TranslateAndDispatchLocatedEvent(ui::LocatedEvent* event); |
| 62 | 65 |
| 63 ::Window x_root_window() { return x_root_window_; } | 66 ::Window x_root_window() { return x_root_window_; } |
| 64 XDisplay* xdisplay() { return xdisplay_; } | 67 XDisplay* xdisplay() { return xdisplay_; } |
| 65 const gfx::Rect& bounds() const { return bounds_; } | 68 const gfx::Rect& bounds() const { return bounds_; } |
| 66 ui::X11AtomCache* atom_cache() { return &atom_cache_; } | 69 ui::X11AtomCache* atom_cache() { return &atom_cache_; } |
| 67 | 70 |
| 68 private: | 71 private: |
| 69 // Dispatches XI2 events. Note that some events targetted for the X root | 72 // Dispatches XI2 events. Note that some events targetted for the X root |
| 70 // window are dispatched to the aura root window (e.g. touch events after | 73 // window are dispatched to the aura root window (e.g. touch events after |
| 71 // calibration). | 74 // calibration). |
| 72 void DispatchXI2Event(const base::NativeEvent& event); | 75 void DispatchXI2Event(const base::NativeEvent& event); |
| 73 | 76 |
| 74 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update | 77 // Sets the cursor on |xwindow_| to |cursor|. Does not check or update |
| 75 // |current_cursor_|. | 78 // |current_cursor_|. |
| 76 void SetCursorInternal(gfx::NativeCursor cursor); | 79 void SetCursorInternal(gfx::NativeCursor cursor); |
| 77 | 80 |
| 78 // The display and the native X window hosting the root window. | 81 // The display and the native X window hosting the root window. |
| 79 XDisplay* xdisplay_; | 82 XDisplay* xdisplay_; |
| 80 ::Window xwindow_; | 83 ::Window xwindow_; |
| 81 | 84 |
| 85 // Events selected on |xwindow_|. | |
| 86 std::unique_ptr<ui::XScopedEventSelector> xwindow_events_; | |
| 87 | |
| 82 // The native root window. | 88 // The native root window. |
| 83 ::Window x_root_window_; | 89 ::Window x_root_window_; |
| 84 | 90 |
| 85 // Current Aura cursor. | 91 // Current Aura cursor. |
| 86 gfx::NativeCursor current_cursor_; | 92 gfx::NativeCursor current_cursor_; |
| 87 | 93 |
| 88 // Is the window mapped to the screen? | 94 // Is the window mapped to the screen? |
| 89 bool window_mapped_; | 95 bool window_mapped_; |
| 90 | 96 |
| 91 // The bounds of |xwindow_|. | 97 // The bounds of |xwindow_|. |
| 92 gfx::Rect bounds_; | 98 gfx::Rect bounds_; |
| 93 | 99 |
| 94 ui::X11AtomCache atom_cache_; | 100 ui::X11AtomCache atom_cache_; |
| 95 | 101 |
| 96 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11); | 102 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostX11); |
| 97 }; | 103 }; |
| 98 | 104 |
| 99 namespace test { | 105 namespace test { |
| 100 | 106 |
| 101 // Set the default value of the override redirect flag used to | 107 // Set the default value of the override redirect flag used to |
| 102 // create a X window for WindowTreeHostX11. | 108 // create a X window for WindowTreeHostX11. |
| 103 AURA_EXPORT void SetUseOverrideRedirectWindowByDefault(bool override_redirect); | 109 AURA_EXPORT void SetUseOverrideRedirectWindowByDefault(bool override_redirect); |
| 104 | 110 |
| 105 } // namespace test | 111 } // namespace test |
| 106 } // namespace aura | 112 } // namespace aura |
| 107 | 113 |
| 108 #endif // UI_AURA_WINDOW_TREE_HOST_X11_H_ | 114 #endif // UI_AURA_WINDOW_TREE_HOST_X11_H_ |
| OLD | NEW |