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

Side by Side Diff: ui/views/mus/window_tree_host_mus.cc

Issue 1999083002: Finish eliminating PlatformWindowMus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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 | « ui/views/mus/window_tree_host_mus.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/views/mus/window_tree_host_mus.h" 5 #include "ui/views/mus/window_tree_host_mus.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "components/bitmap_uploader/bitmap_uploader.h"
8 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
9 #include "ui/aura/window_event_dispatcher.h" 10 #include "ui/aura/window_event_dispatcher.h"
11 #include "ui/base/view_prop.h"
10 #include "ui/events/event.h" 12 #include "ui/events/event.h"
13 #include "ui/platform_window/stub/stub_window.h"
11 #include "ui/views/mus/input_method_mus.h" 14 #include "ui/views/mus/input_method_mus.h"
12 #include "ui/views/mus/native_widget_mus.h" 15 #include "ui/views/mus/native_widget_mus.h"
13 #include "ui/views/mus/platform_window_mus.h"
14 16
15 namespace views { 17 namespace views {
16 18
19 namespace {
20 static uint32_t accelerated_widget_count = 1;
21 }
22
17 //////////////////////////////////////////////////////////////////////////////// 23 ////////////////////////////////////////////////////////////////////////////////
18 // WindowTreeHostMus, public: 24 // WindowTreeHostMus, public:
19 25
20 WindowTreeHostMus::WindowTreeHostMus(shell::Connector* connector, 26 WindowTreeHostMus::WindowTreeHostMus(shell::Connector* connector,
21 NativeWidgetMus* native_widget, 27 NativeWidgetMus* native_widget,
22 mus::Window* window) 28 mus::Window* window)
23 : native_widget_(native_widget) { 29 : native_widget_(native_widget) {
24 SetPlatformWindow( 30 // We need accelerated widget numbers to be different for each
25 base::WrapUnique(new PlatformWindowMus(this, connector, window))); 31 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
32 // has this property.
33 #if defined(OS_WIN) || defined(OS_ANDROID)
34 gfx::AcceleratedWidget accelerated_widget =
35 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
36 #else
37 gfx::AcceleratedWidget accelerated_widget =
38 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
39 #endif
40
41 // TODO(markdittmer): StubWindow will call |OnAcceleratedWidgetAvailable| with
42 // device pixel ratio = 1. Really, this ratio should be consistent with that
43 // of |window|.
44 SetPlatformWindow(base::WrapUnique(
45 new ui::StubWindow(this, accelerated_widget)));
46
47 // If no connector was passed, then it's entirely possible that mojo has not
48 // been initialized and BitmapUploader will not work. This occurs, for
49 // example, in some unit test contexts.
50 if (connector) {
51 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(window));
52 bitmap_uploader_->Init(connector);
53 prop_.reset(new ui::ViewProp(
54 accelerated_widget,
55 bitmap_uploader::kBitmapUploaderForAcceleratedWidget,
56 bitmap_uploader_.get()));
57 }
58
26 // The location of events is already transformed, and there is no way to 59 // The location of events is already transformed, and there is no way to
27 // correctly determine the reverse transform. So, don't attempt to transform 60 // correctly determine the reverse transform. So, don't attempt to transform
28 // event locations, else the root location is wrong. 61 // event locations, else the root location is wrong.
29 // TODO(sky): we need to transform for device scale though. 62 // TODO(sky): we need to transform for device scale though.
30 dispatcher()->set_transform_events(false); 63 dispatcher()->set_transform_events(false);
31 compositor()->SetHostHasTransparentBackground(true); 64 compositor()->SetHostHasTransparentBackground(true);
32 65
33 input_method_.reset(new InputMethodMUS(this, window)); 66 input_method_.reset(new InputMethodMUS(this, window));
34 SetSharedInputMethod(input_method_.get()); 67 SetSharedInputMethod(input_method_.get());
35 } 68 }
36 69
37 WindowTreeHostMus::~WindowTreeHostMus() { 70 WindowTreeHostMus::~WindowTreeHostMus() {
38 DestroyCompositor(); 71 DestroyCompositor();
39 DestroyDispatcher(); 72 DestroyDispatcher();
40 } 73 }
41 74
42 PlatformWindowMus* WindowTreeHostMus::platform_window() {
43 return static_cast<PlatformWindowMus*>(
44 WindowTreeHostPlatform::platform_window());
45 }
46
47 void WindowTreeHostMus::DispatchEvent(ui::Event* event) { 75 void WindowTreeHostMus::DispatchEvent(ui::Event* event) {
48 if (event->IsKeyEvent() && GetInputMethod()) { 76 if (event->IsKeyEvent() && GetInputMethod()) {
49 GetInputMethod()->DispatchKeyEvent(event->AsKeyEvent()); 77 GetInputMethod()->DispatchKeyEvent(event->AsKeyEvent());
50 event->StopPropagation(); 78 event->StopPropagation();
51 return; 79 return;
52 } 80 }
53 WindowTreeHostPlatform::DispatchEvent(event); 81 WindowTreeHostPlatform::DispatchEvent(event);
54 } 82 }
55 83
56 void WindowTreeHostMus::OnClosed() { 84 void WindowTreeHostMus::OnClosed() {
57 if (native_widget_) 85 if (native_widget_)
58 native_widget_->OnPlatformWindowClosed(); 86 native_widget_->OnPlatformWindowClosed();
59 } 87 }
60 88
61 void WindowTreeHostMus::OnActivationChanged(bool active) { 89 void WindowTreeHostMus::OnActivationChanged(bool active) {
62 if (active) 90 if (active)
63 GetInputMethod()->OnFocus(); 91 GetInputMethod()->OnFocus();
64 else 92 else
65 GetInputMethod()->OnBlur(); 93 GetInputMethod()->OnBlur();
66 if (native_widget_) 94 if (native_widget_)
67 native_widget_->OnActivationChanged(active); 95 native_widget_->OnActivationChanged(active);
68 WindowTreeHostPlatform::OnActivationChanged(active); 96 WindowTreeHostPlatform::OnActivationChanged(active);
69 } 97 }
70 98
71 void WindowTreeHostMus::OnCloseRequest() { 99 void WindowTreeHostMus::OnCloseRequest() {
72 OnHostCloseRequested(); 100 OnHostCloseRequested();
73 } 101 }
74 102
75 } // namespace views 103 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_tree_host_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698