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

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

Issue 2611773002: Removes code using mus client lib (Closed)
Patch Set: dont run on linux Created 3 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 | « ui/views/mus/window_tree_host_mus.h ('k') | ui/views/test/native_widget_factory_mus.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 2015 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/views/mus/window_tree_host_mus.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "services/ui/public/cpp/window.h"
9 #include "ui/aura/env.h"
10 #include "ui/aura/window.h"
11 #include "ui/aura/window_event_dispatcher.h"
12 #include "ui/events/event.h"
13 #include "ui/gfx/geometry/dip_util.h"
14 #include "ui/platform_window/stub/stub_window.h"
15 #include "ui/views/mus/input_method_mus.h"
16 #include "ui/views/mus/native_widget_mus.h"
17
18 namespace views {
19
20 namespace {
21 static uint32_t accelerated_widget_count = 1;
22
23 bool IsUsingTestContext() {
24 return aura::Env::GetInstance()->context_factory()->DoesCreateTestContexts();
25 }
26
27 } // namespace
28
29 ////////////////////////////////////////////////////////////////////////////////
30 // WindowTreeHostMus, public:
31
32 WindowTreeHostMus::WindowTreeHostMus(NativeWidgetMus* native_widget,
33 ui::Window* window)
34 : native_widget_(native_widget) {
35 CreateCompositor();
36 gfx::AcceleratedWidget accelerated_widget;
37 if (IsUsingTestContext()) {
38 accelerated_widget = gfx::kNullAcceleratedWidget;
39 } else {
40 // We need accelerated widget numbers to be different for each
41 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
42 // has this property.
43 #if defined(OS_WIN) || defined(OS_ANDROID)
44 accelerated_widget =
45 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
46 #else
47 accelerated_widget =
48 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
49 #endif
50 }
51 // TODO(markdittmer): Use correct device-scale-factor from |window|.
52 OnAcceleratedWidgetAvailable(accelerated_widget, 1.f);
53
54 SetPlatformWindow(base::MakeUnique<ui::StubWindow>(
55 this,
56 false)); // Do not advertise accelerated widget; already set manually.
57
58 compositor()->SetWindow(window);
59
60 // Initialize the stub platform window bounds to those of the ui::Window.
61 platform_window()->SetBounds(gfx::ConvertRectToPixel(
62 compositor()->device_scale_factor(), window->bounds()));
63
64 compositor()->SetHostHasTransparentBackground(true);
65 }
66
67 WindowTreeHostMus::~WindowTreeHostMus() {
68 DestroyCompositor();
69 DestroyDispatcher();
70 }
71
72 void WindowTreeHostMus::DispatchEvent(ui::Event* event) {
73 // Key events are sent to InputMethodMus directly from NativeWidgetMus.
74 DCHECK(!event->IsKeyEvent());
75 WindowTreeHostPlatform::DispatchEvent(event);
76 }
77
78 void WindowTreeHostMus::OnClosed() {
79 if (native_widget_)
80 native_widget_->OnPlatformWindowClosed();
81 }
82
83 void WindowTreeHostMus::OnActivationChanged(bool active) {
84 if (active)
85 GetInputMethod()->OnFocus();
86 else
87 GetInputMethod()->OnBlur();
88 if (native_widget_)
89 native_widget_->OnActivationChanged(active);
90 WindowTreeHostPlatform::OnActivationChanged(active);
91 }
92
93 void WindowTreeHostMus::OnCloseRequest() {
94 OnHostCloseRequested();
95 }
96
97 gfx::ICCProfile WindowTreeHostMus::GetICCProfileForCurrentDisplay() {
98 // TODO: This should read the profile from mus. crbug.com/647510
99 return gfx::ICCProfile();
100 }
101
102 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_tree_host_mus.h ('k') | ui/views/test/native_widget_factory_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698