| OLD | NEW |
| 1 // Copyright 2016 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_OZONE_PLATFORM_WAYLAND_WAYLAND_WINDOW_H_ | 5 #ifndef UI_OZONE_PLATFORM_WAYLAND_WAYLAND_WINDOW_H_ |
| 6 #define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_WINDOW_H_ | 6 #define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_WINDOW_H_ |
| 7 | 7 |
| 8 #include "ui/events/platform/platform_event_dispatcher.h" |
| 8 #include "ui/gfx/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
| 9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 10 #include "ui/ozone/platform/wayland/wayland_object.h" | 11 #include "ui/ozone/platform/wayland/wayland_object.h" |
| 11 #include "ui/platform_window/platform_window.h" | 12 #include "ui/platform_window/platform_window.h" |
| 12 | 13 |
| 13 namespace ui { | 14 namespace ui { |
| 14 | 15 |
| 15 class WaylandDisplay; | 16 class WaylandDisplay; |
| 16 | 17 |
| 17 class WaylandWindow : public PlatformWindow { | 18 class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher { |
| 18 public: | 19 public: |
| 19 WaylandWindow(PlatformWindowDelegate* delegate, | 20 WaylandWindow(PlatformWindowDelegate* delegate, |
| 20 WaylandDisplay* display, | 21 WaylandDisplay* display, |
| 21 const gfx::Rect& bounds); | 22 const gfx::Rect& bounds); |
| 22 ~WaylandWindow() override; | 23 ~WaylandWindow() override; |
| 23 | 24 |
| 25 static WaylandWindow* FromSurface(wl_surface* surface); |
| 26 |
| 24 bool Initialize(); | 27 bool Initialize(); |
| 25 | 28 |
| 26 wl_surface* GetSurface(); | 29 wl_surface* GetSurface(); |
| 27 gfx::AcceleratedWidget GetWidget(); | 30 gfx::AcceleratedWidget GetWidget(); |
| 28 | 31 |
| 29 // Apply the bounds specified in the most recent configure event. This should | 32 // Apply the bounds specified in the most recent configure event. This should |
| 30 // be called after processing all pending events in the wayland connection. | 33 // be called after processing all pending events in the wayland connection. |
| 31 void ApplyPendingBounds(); | 34 void ApplyPendingBounds(); |
| 32 | 35 |
| 36 // Set whether this window has pointer focus and should dispatch mouse events. |
| 37 void set_pointer_focus(bool focus) { has_pointer_focus_ = focus; } |
| 38 |
| 33 // PlatformWindow | 39 // PlatformWindow |
| 34 void Show() override; | 40 void Show() override; |
| 35 void Hide() override; | 41 void Hide() override; |
| 36 void Close() override; | 42 void Close() override; |
| 37 void SetBounds(const gfx::Rect& bounds) override; | 43 void SetBounds(const gfx::Rect& bounds) override; |
| 38 gfx::Rect GetBounds() override; | 44 gfx::Rect GetBounds() override; |
| 39 void SetTitle(const base::string16& title) override; | 45 void SetTitle(const base::string16& title) override; |
| 40 void SetCapture() override; | 46 void SetCapture() override; |
| 41 void ReleaseCapture() override; | 47 void ReleaseCapture() override; |
| 42 void ToggleFullscreen() override; | 48 void ToggleFullscreen() override; |
| 43 void Maximize() override; | 49 void Maximize() override; |
| 44 void Minimize() override; | 50 void Minimize() override; |
| 45 void Restore() override; | 51 void Restore() override; |
| 46 void SetCursor(PlatformCursor cursor) override; | 52 void SetCursor(PlatformCursor cursor) override; |
| 47 void MoveCursorTo(const gfx::Point& location) override; | 53 void MoveCursorTo(const gfx::Point& location) override; |
| 48 void ConfineCursorToBounds(const gfx::Rect& bounds) override; | 54 void ConfineCursorToBounds(const gfx::Rect& bounds) override; |
| 49 PlatformImeController* GetPlatformImeController() override; | 55 PlatformImeController* GetPlatformImeController() override; |
| 50 | 56 |
| 57 // PlatformEventDispatcher |
| 58 bool CanDispatchEvent(const PlatformEvent& event) override; |
| 59 uint32_t DispatchEvent(const PlatformEvent& event) override; |
| 60 |
| 51 // xdg_surface_listener | 61 // xdg_surface_listener |
| 52 static void Configure(void* data, | 62 static void Configure(void* data, |
| 53 xdg_surface* obj, | 63 xdg_surface* obj, |
| 54 int32_t width, | 64 int32_t width, |
| 55 int32_t height, | 65 int32_t height, |
| 56 wl_array* states, | 66 wl_array* states, |
| 57 uint32_t serial); | 67 uint32_t serial); |
| 58 static void Close(void* data, xdg_surface* obj); | 68 static void Close(void* data, xdg_surface* obj); |
| 59 | 69 |
| 60 private: | 70 private: |
| 61 PlatformWindowDelegate* delegate_; | 71 PlatformWindowDelegate* delegate_; |
| 62 WaylandDisplay* display_; | 72 WaylandDisplay* display_; |
| 63 | 73 |
| 64 wl::Object<wl_surface> surface_; | 74 wl::Object<wl_surface> surface_; |
| 65 wl::Object<xdg_surface> xdg_surface_; | 75 wl::Object<xdg_surface> xdg_surface_; |
| 66 | 76 |
| 67 gfx::Rect bounds_; | 77 gfx::Rect bounds_; |
| 68 gfx::Rect pending_bounds_; | 78 gfx::Rect pending_bounds_; |
| 69 uint32_t pending_configure_serial_; | 79 uint32_t pending_configure_serial_; |
| 80 bool has_pointer_focus_ = false; |
| 70 | 81 |
| 71 DISALLOW_COPY_AND_ASSIGN(WaylandWindow); | 82 DISALLOW_COPY_AND_ASSIGN(WaylandWindow); |
| 72 }; | 83 }; |
| 73 | 84 |
| 74 } // namespace ui | 85 } // namespace ui |
| 75 | 86 |
| 76 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_WINDOW_H_ | 87 #endif // UI_OZONE_PLATFORM_WAYLAND_WAYLAND_WINDOW_H_ |
| OLD | NEW |