| 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 #include "ui/ozone/platform/wayland/wayland_window.h" | 5 #include "ui/ozone/platform/wayland/wayland_window.h" |
| 6 | 6 |
| 7 #include <xdg-shell-unstable-v5-client-protocol.h> | 7 #include <xdg-shell-unstable-v5-client-protocol.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/ozone/platform/wayland/wayland_display.h" | 10 #include "ui/ozone/platform/wayland/wayland_display.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 return false; | 34 return false; |
| 35 } | 35 } |
| 36 wl_surface_set_user_data(surface_.get(), this); | 36 wl_surface_set_user_data(surface_.get(), this); |
| 37 xdg_surface_.reset( | 37 xdg_surface_.reset( |
| 38 xdg_shell_get_xdg_surface(display_->shell(), surface_.get())); | 38 xdg_shell_get_xdg_surface(display_->shell(), surface_.get())); |
| 39 if (!xdg_surface_) { | 39 if (!xdg_surface_) { |
| 40 LOG(ERROR) << "Failed to create xdg_surface"; | 40 LOG(ERROR) << "Failed to create xdg_surface"; |
| 41 return false; | 41 return false; |
| 42 } | 42 } |
| 43 xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this); | 43 xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this); |
| 44 display_->ScheduleFlush(); |
| 44 | 45 |
| 45 display_->AddWindow(surface_.id(), this); | 46 display_->AddWindow(surface_.id(), this); |
| 46 delegate_->OnAcceleratedWidgetAvailable(surface_.id(), 1.f); | 47 delegate_->OnAcceleratedWidgetAvailable(surface_.id(), 1.f); |
| 47 | 48 |
| 48 return true; | 49 return true; |
| 49 } | 50 } |
| 50 | 51 |
| 51 void WaylandWindow::ApplyPendingBounds() { | 52 void WaylandWindow::ApplyPendingBounds() { |
| 52 if (pending_bounds_.IsEmpty()) | 53 if (pending_bounds_.IsEmpty()) |
| 53 return; | 54 return; |
| 54 | 55 |
| 55 SetBounds(pending_bounds_); | 56 SetBounds(pending_bounds_); |
| 56 DCHECK(xdg_surface_); | 57 DCHECK(xdg_surface_); |
| 57 xdg_surface_ack_configure(xdg_surface_.get(), pending_configure_serial_); | 58 xdg_surface_ack_configure(xdg_surface_.get(), pending_configure_serial_); |
| 58 pending_bounds_ = gfx::Rect(); | 59 pending_bounds_ = gfx::Rect(); |
| 60 display_->ScheduleFlush(); |
| 59 } | 61 } |
| 60 | 62 |
| 61 void WaylandWindow::Show() {} | 63 void WaylandWindow::Show() {} |
| 62 | 64 |
| 63 void WaylandWindow::Hide() { | 65 void WaylandWindow::Hide() { |
| 64 NOTIMPLEMENTED(); | 66 NOTIMPLEMENTED(); |
| 65 } | 67 } |
| 66 | 68 |
| 67 void WaylandWindow::Close() { | 69 void WaylandWindow::Close() { |
| 68 NOTIMPLEMENTED(); | 70 NOTIMPLEMENTED(); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void WaylandWindow::SetBounds(const gfx::Rect& bounds) { | 73 void WaylandWindow::SetBounds(const gfx::Rect& bounds) { |
| 72 if (bounds == bounds_) | 74 if (bounds == bounds_) |
| 73 return; | 75 return; |
| 74 bounds_ = bounds; | 76 bounds_ = bounds; |
| 75 delegate_->OnBoundsChanged(bounds); | 77 delegate_->OnBoundsChanged(bounds); |
| 76 } | 78 } |
| 77 | 79 |
| 78 gfx::Rect WaylandWindow::GetBounds() { | 80 gfx::Rect WaylandWindow::GetBounds() { |
| 79 return bounds_; | 81 return bounds_; |
| 80 } | 82 } |
| 81 | 83 |
| 82 void WaylandWindow::SetTitle(const base::string16& title) { | 84 void WaylandWindow::SetTitle(const base::string16& title) { |
| 83 DCHECK(xdg_surface_); | 85 DCHECK(xdg_surface_); |
| 84 xdg_surface_set_title(xdg_surface_.get(), UTF16ToUTF8(title).c_str()); | 86 xdg_surface_set_title(xdg_surface_.get(), UTF16ToUTF8(title).c_str()); |
| 87 display_->ScheduleFlush(); |
| 85 } | 88 } |
| 86 | 89 |
| 87 void WaylandWindow::SetCapture() { | 90 void WaylandWindow::SetCapture() { |
| 88 NOTIMPLEMENTED(); | 91 NOTIMPLEMENTED(); |
| 89 } | 92 } |
| 90 | 93 |
| 91 void WaylandWindow::ReleaseCapture() { | 94 void WaylandWindow::ReleaseCapture() { |
| 92 NOTIMPLEMENTED(); | 95 NOTIMPLEMENTED(); |
| 93 } | 96 } |
| 94 | 97 |
| 95 void WaylandWindow::ToggleFullscreen() { | 98 void WaylandWindow::ToggleFullscreen() { |
| 96 NOTIMPLEMENTED(); | 99 NOTIMPLEMENTED(); |
| 97 } | 100 } |
| 98 | 101 |
| 99 void WaylandWindow::Maximize() { | 102 void WaylandWindow::Maximize() { |
| 100 DCHECK(xdg_surface_); | 103 DCHECK(xdg_surface_); |
| 101 xdg_surface_set_maximized(xdg_surface_.get()); | 104 xdg_surface_set_maximized(xdg_surface_.get()); |
| 105 display_->ScheduleFlush(); |
| 102 } | 106 } |
| 103 | 107 |
| 104 void WaylandWindow::Minimize() { | 108 void WaylandWindow::Minimize() { |
| 105 DCHECK(xdg_surface_); | 109 DCHECK(xdg_surface_); |
| 106 xdg_surface_set_minimized(xdg_surface_.get()); | 110 xdg_surface_set_minimized(xdg_surface_.get()); |
| 111 display_->ScheduleFlush(); |
| 107 } | 112 } |
| 108 | 113 |
| 109 void WaylandWindow::Restore() { | 114 void WaylandWindow::Restore() { |
| 110 DCHECK(xdg_surface_); | 115 DCHECK(xdg_surface_); |
| 111 xdg_surface_unset_maximized(xdg_surface_.get()); | 116 xdg_surface_unset_maximized(xdg_surface_.get()); |
| 117 display_->ScheduleFlush(); |
| 112 } | 118 } |
| 113 | 119 |
| 114 void WaylandWindow::SetCursor(PlatformCursor cursor) { | 120 void WaylandWindow::SetCursor(PlatformCursor cursor) { |
| 115 NOTIMPLEMENTED(); | 121 NOTIMPLEMENTED(); |
| 116 } | 122 } |
| 117 | 123 |
| 118 void WaylandWindow::MoveCursorTo(const gfx::Point& location) { | 124 void WaylandWindow::MoveCursorTo(const gfx::Point& location) { |
| 119 NOTIMPLEMENTED(); | 125 NOTIMPLEMENTED(); |
| 120 } | 126 } |
| 121 | 127 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 142 // during an interactive resize, and only the last one matters. | 148 // during an interactive resize, and only the last one matters. |
| 143 window->pending_bounds_ = gfx::Rect(0, 0, width, height); | 149 window->pending_bounds_ = gfx::Rect(0, 0, width, height); |
| 144 window->pending_configure_serial_ = serial; | 150 window->pending_configure_serial_ = serial; |
| 145 } | 151 } |
| 146 | 152 |
| 147 void WaylandWindow::Close(void* data, xdg_surface* obj) { | 153 void WaylandWindow::Close(void* data, xdg_surface* obj) { |
| 148 NOTIMPLEMENTED(); | 154 NOTIMPLEMENTED(); |
| 149 } | 155 } |
| 150 | 156 |
| 151 } // namespace ui | 157 } // namespace ui |
| OLD | NEW |