Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: services/native_viewport/platform_viewport_ozone.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/native_viewport/BUILD.gn ('k') | skia/ext/platform_canvas_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "services/native_viewport/platform_viewport.h"
6
7 #include "mojo/converters/geometry/geometry_type_converters.h"
8 #include "ui/events/event.h"
9 #include "ui/events/platform/platform_event_dispatcher.h"
10 #include "ui/events/platform/platform_event_source.h"
11 #include "ui/ozone/public/cursor_factory_ozone.h"
12 #include "ui/ozone/public/ozone_platform.h"
13 #include "ui/ozone/public/surface_factory_ozone.h"
14 #include "ui/platform_window/platform_window.h"
15 #include "ui/platform_window/platform_window_delegate.h"
16
17 namespace native_viewport {
18
19 // TODO(spang): Deduplicate with PlatformViewportX11.. but there's a hack
20 // in there that prevents this.
21 class PlatformViewportOzone : public PlatformViewport,
22 public ui::PlatformWindowDelegate {
23 public:
24 explicit PlatformViewportOzone(Delegate* delegate) : delegate_(delegate) {
25 ui::OzonePlatform::InitializeForUI();
26 }
27
28 virtual ~PlatformViewportOzone() {
29 // Destroy the platform-window while |this| is still alive.
30 platform_window_.reset();
31 }
32
33 private:
34 // Overridden from PlatformViewport:
35 virtual void Init(const gfx::Rect& bounds) override {
36 platform_window_ =
37 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds);
38 }
39
40 virtual void Show() override { platform_window_->Show(); }
41
42 virtual void Hide() override { platform_window_->Hide(); }
43
44 virtual void Close() override { platform_window_->Close(); }
45
46 virtual gfx::Size GetSize() override {
47 return platform_window_->GetBounds().size();
48 }
49
50 virtual void SetBounds(const gfx::Rect& bounds) override {
51 platform_window_->SetBounds(bounds);
52 }
53
54 virtual void SetCapture() override { platform_window_->SetCapture(); }
55
56 virtual void ReleaseCapture() override { platform_window_->ReleaseCapture(); }
57
58 // ui::PlatformWindowDelegate:
59 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) override {
60 mojo::ViewportMetricsPtr metrics = mojo::ViewportMetrics::New();
61 metrics->size = new_bounds.size();
62 delegate_->OnMetricsChanged(metrics.Pass());
63 }
64
65 virtual void OnDamageRect(const gfx::Rect& damaged_region) override {}
66
67 virtual void DispatchEvent(ui::Event* event) override {
68 delegate_->OnEvent(event);
69 }
70
71 virtual void OnCloseRequest() override { platform_window_->Close(); }
72
73 virtual void OnClosed() override { delegate_->OnDestroyed(); }
74
75 virtual void OnWindowStateChanged(ui::PlatformWindowState state) override {}
76
77 virtual void OnLostCapture() override {}
78
79 virtual void OnAcceleratedWidgetAvailable(
80 gfx::AcceleratedWidget widget) override {
81 delegate_->OnAcceleratedWidgetAvailable(widget);
82 }
83
84 virtual void OnActivationChanged(bool active) override {}
85
86 scoped_ptr<ui::PlatformWindow> platform_window_;
87 Delegate* delegate_;
88
89 DISALLOW_COPY_AND_ASSIGN(PlatformViewportOzone);
90 };
91
92 // static
93 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) {
94 return make_scoped_ptr(new PlatformViewportOzone(delegate));
95 }
96
97 } // namespace native_viewport
OLDNEW
« no previous file with comments | « services/native_viewport/BUILD.gn ('k') | skia/ext/platform_canvas_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698