Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PLATFORM_WINDOW_X11_X11_WINDOW_H_ | 5 #ifndef UI_OZONE_PLATFORM_X11_X11_WINDOW_HOST_H_ |
| 6 #define UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ | 6 #define UI_OZONE_PLATFORM_X11_X11_WINDOW_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/macros.h" | |
| 11 #include "ui/events/platform/platform_event_dispatcher.h" | 10 #include "ui/events/platform/platform_event_dispatcher.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/gfx/x/x11_atom_cache.h" | 12 #include "ui/gfx/x/x11_atom_cache.h" |
| 13 #include "ui/ozone/platform/x11/x11_window_host_manager.h" | |
| 14 #include "ui/platform_window/platform_window.h" | 14 #include "ui/platform_window/platform_window.h" |
| 15 #include "ui/platform_window/platform_window_delegate.h" | |
| 16 #include "ui/platform_window/x11/x11_window_export.h" | |
| 17 | 15 |
| 18 typedef struct _XDisplay XDisplay; | 16 typedef struct _XDisplay XDisplay; |
| 19 typedef unsigned long XID; | 17 typedef unsigned long XID; |
| 18 typedef union _XEvent XEvent; | |
| 20 | 19 |
| 21 namespace ui { | 20 namespace ui { |
| 22 | 21 |
| 23 class X11_WINDOW_EXPORT X11Window : public PlatformWindow, | 22 // Manages one XWindow and handles events for that window. |
| 24 public PlatformEventDispatcher { | 23 class X11WindowHost : public PlatformWindow, public PlatformEventDispatcher { |
|
spang
2016/01/20 19:53:31
Suggest calling it X11WindowOzone, the "host" thin
kylechar
2016/01/20 21:46:16
Done.
| |
| 25 public: | 24 public: |
| 26 explicit X11Window(PlatformWindowDelegate* delegate); | 25 explicit X11WindowHost(PlatformWindowDelegate* delegate, |
| 27 ~X11Window() override; | 26 WindowStatusCallback on_create_callback, |
| 27 WindowStatusCallback on_destroy_callback); | |
| 28 ~X11WindowHost() override; | |
| 28 | 29 |
| 29 private: | 30 // Creates new underlying XWindow. Does not map XWindow. |
| 30 void Destroy(); | 31 void Create(); |
| 31 | 32 |
| 32 void ProcessXInput2Event(XEvent* xevent); | 33 // Processes an XEvent that can't be converted into an equivalent ui::Event |
| 34 // and handled by normal event loop. | |
| 35 void ProcessXEvent(const XEvent& xev); | |
| 33 | 36 |
| 34 // PlatformWindow: | 37 // PlatformWindow: |
| 35 void Show() override; | 38 void Show() override; |
| 36 void Hide() override; | 39 void Hide() override; |
| 37 void Close() override; | 40 void Close() override; |
| 38 void SetBounds(const gfx::Rect& bounds) override; | 41 void SetBounds(const gfx::Rect& bounds) override; |
| 39 gfx::Rect GetBounds() override; | 42 gfx::Rect GetBounds() override; |
| 40 void SetTitle(const base::string16& title) override; | 43 void SetTitle(const base::string16& title) override; |
| 41 void SetCapture() override; | 44 void SetCapture() override; |
| 42 void ReleaseCapture() override; | 45 void ReleaseCapture() override; |
| 43 void ToggleFullscreen() override; | 46 void ToggleFullscreen() override; |
| 44 void Maximize() override; | 47 void Maximize() override; |
| 45 void Minimize() override; | 48 void Minimize() override; |
| 46 void Restore() override; | 49 void Restore() override; |
| 47 void SetCursor(PlatformCursor cursor) override; | 50 void SetCursor(PlatformCursor cursor) override; |
| 48 void MoveCursorTo(const gfx::Point& location) override; | 51 void MoveCursorTo(const gfx::Point& location) override; |
| 49 void ConfineCursorToBounds(const gfx::Rect& bounds) override; | 52 void ConfineCursorToBounds(const gfx::Rect& bounds) override; |
| 50 PlatformImeController* GetPlatformImeController() override; | 53 PlatformImeController* GetPlatformImeController() override; |
| 51 | 54 |
| 55 private: | |
| 56 void Destroy(); | |
| 57 | |
| 52 // PlatformEventDispatcher: | 58 // PlatformEventDispatcher: |
| 53 bool CanDispatchEvent(const PlatformEvent& event) override; | 59 bool CanDispatchEvent(const PlatformEvent& event) override; |
| 54 uint32_t DispatchEvent(const PlatformEvent& event) override; | 60 uint32_t DispatchEvent(const PlatformEvent& event) override; |
| 55 | 61 |
| 56 PlatformWindowDelegate* delegate_; | 62 PlatformWindowDelegate* delegate_; |
| 57 | 63 |
| 64 WindowStatusCallback on_create_callback_; | |
| 65 WindowStatusCallback on_destroy_callback_; | |
| 66 | |
| 58 XDisplay* xdisplay_; | 67 XDisplay* xdisplay_; |
| 59 XID xwindow_; | 68 XID xwindow_; |
| 60 XID xroot_window_; | 69 XID xroot_window_; |
| 61 X11AtomCache atom_cache_; | 70 X11AtomCache atom_cache_; |
| 62 | 71 |
| 63 base::string16 window_title_; | 72 base::string16 window_title_; |
| 64 | 73 |
| 65 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_| | 74 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_| |
| 66 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is | 75 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is |
| 67 // the bounds the X11 server has set on the window. | 76 // the bounds the X11 server has set on the window. |
| 68 gfx::Rect requested_bounds_; | 77 gfx::Rect requested_bounds_; |
| 69 gfx::Rect confirmed_bounds_; | 78 gfx::Rect confirmed_bounds_; |
| 70 | 79 |
| 71 bool window_mapped_; | 80 bool window_mapped_ = false; |
| 72 | 81 |
| 73 DISALLOW_COPY_AND_ASSIGN(X11Window); | 82 DISALLOW_COPY_AND_ASSIGN(X11WindowHost); |
| 74 }; | 83 }; |
| 75 | 84 |
| 76 namespace test { | |
| 77 | |
| 78 // Sets the value of the |override_redirect| flag when creating an X11 window. | |
| 79 // It is necessary to set this flag on for various tests, otherwise the call to | |
| 80 // X11Window::Show() blocks because it never receives the MapNotify event. It is | |
| 81 // unclear why this is necessary, but might be related to calls to | |
| 82 // XInitThreads(). | |
| 83 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault( | |
| 84 bool override_redirect); | |
| 85 | |
| 86 } // namespace test | |
| 87 | |
| 88 } // namespace ui | 85 } // namespace ui |
| 89 | 86 |
| 90 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ | 87 #endif // UI_OZONE_PLATFORM_X11_X11_WINDOW_HOST_H_ |
| OLD | NEW |