| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/ozone/platform/dri/dri_window.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "ui/events/event.h" | |
| 9 #include "ui/events/ozone/evdev/event_factory_evdev.h" | |
| 10 #include "ui/events/ozone/events_ozone.h" | |
| 11 #include "ui/events/platform/platform_event_source.h" | |
| 12 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | |
| 13 #include "ui/ozone/platform/dri/dri_cursor.h" | |
| 14 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" | |
| 15 #include "ui/ozone/platform/dri/dri_window_manager.h" | |
| 16 #include "ui/platform_window/platform_window_delegate.h" | |
| 17 | |
| 18 namespace ui { | |
| 19 | |
| 20 DriWindow::DriWindow(PlatformWindowDelegate* delegate, | |
| 21 const gfx::Rect& bounds, | |
| 22 DriGpuPlatformSupportHost* sender, | |
| 23 EventFactoryEvdev* event_factory, | |
| 24 DriWindowManager* window_manager) | |
| 25 : delegate_(delegate), | |
| 26 sender_(sender), | |
| 27 event_factory_(event_factory), | |
| 28 window_manager_(window_manager), | |
| 29 bounds_(bounds), | |
| 30 widget_(window_manager->NextAcceleratedWidget()) { | |
| 31 window_manager_->AddWindow(widget_, this); | |
| 32 } | |
| 33 | |
| 34 DriWindow::~DriWindow() { | |
| 35 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | |
| 36 window_manager_->RemoveWindow(widget_); | |
| 37 | |
| 38 sender_->RemoveChannelObserver(this); | |
| 39 if (!sender_->IsConnected()) | |
| 40 return; | |
| 41 | |
| 42 sender_->Send(new OzoneGpuMsg_DestroyWindowDelegate(widget_)); | |
| 43 } | |
| 44 | |
| 45 void DriWindow::Initialize() { | |
| 46 sender_->AddChannelObserver(this); | |
| 47 delegate_->OnAcceleratedWidgetAvailable(widget_); | |
| 48 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | |
| 49 } | |
| 50 | |
| 51 void DriWindow::Show() {} | |
| 52 | |
| 53 void DriWindow::Hide() {} | |
| 54 | |
| 55 void DriWindow::Close() {} | |
| 56 | |
| 57 void DriWindow::SetBounds(const gfx::Rect& bounds) { | |
| 58 bounds_ = bounds; | |
| 59 delegate_->OnBoundsChanged(bounds); | |
| 60 | |
| 61 if (!sender_->IsConnected()) | |
| 62 return; | |
| 63 | |
| 64 if (window_manager_->cursor()->GetCursorWindow() == widget_) | |
| 65 window_manager_->cursor()->HideCursor(); | |
| 66 | |
| 67 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds)); | |
| 68 | |
| 69 if (window_manager_->cursor()->GetCursorWindow() == widget_) | |
| 70 window_manager_->cursor()->ShowCursor(); | |
| 71 } | |
| 72 | |
| 73 gfx::Rect DriWindow::GetBounds() { | |
| 74 return bounds_; | |
| 75 } | |
| 76 | |
| 77 void DriWindow::SetCapture() {} | |
| 78 | |
| 79 void DriWindow::ReleaseCapture() {} | |
| 80 | |
| 81 void DriWindow::ToggleFullscreen() {} | |
| 82 | |
| 83 void DriWindow::Maximize() {} | |
| 84 | |
| 85 void DriWindow::Minimize() {} | |
| 86 | |
| 87 void DriWindow::Restore() {} | |
| 88 | |
| 89 void DriWindow::SetCursor(PlatformCursor cursor) { | |
| 90 window_manager_->cursor()->SetCursor(widget_, cursor); | |
| 91 } | |
| 92 | |
| 93 void DriWindow::MoveCursorTo(const gfx::Point& location) { | |
| 94 event_factory_->WarpCursorTo(widget_, location); | |
| 95 } | |
| 96 | |
| 97 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { | |
| 98 DCHECK(ne); | |
| 99 Event* event = static_cast<Event*>(ne); | |
| 100 if (event->IsMouseEvent() || event->IsScrollEvent()) | |
| 101 return window_manager_->cursor()->GetCursorWindow() == widget_; | |
| 102 | |
| 103 return true; | |
| 104 } | |
| 105 | |
| 106 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { | |
| 107 DispatchEventFromNativeUiEvent( | |
| 108 native_event, | |
| 109 base::Bind(&PlatformWindowDelegate::DispatchEvent, | |
| 110 base::Unretained(delegate_))); | |
| 111 return POST_DISPATCH_STOP_PROPAGATION; | |
| 112 } | |
| 113 | |
| 114 void DriWindow::OnChannelEstablished() { | |
| 115 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); | |
| 116 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | |
| 117 } | |
| 118 | |
| 119 void DriWindow::OnChannelDestroyed() { | |
| 120 } | |
| 121 | |
| 122 } // namespace ui | |
| OLD | NEW |