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

Side by Side Diff: ui/aura/window_tree_host_win.cc

Issue 1390883003: aura: Unify WindowTreeHost for some platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win build Created 5 years, 2 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/aura/window_tree_host_win.h ('k') | ui/platform_window/win/win_window.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 (c) 2012 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/aura/window_tree_host_win.h"
6
7 #include <windows.h>
8
9 #include <algorithm>
10
11 #include "base/message_loop/message_loop.h"
12 #include "ui/aura/client/cursor_client.h"
13 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/base/cursor/cursor_loader_win.h"
15 #include "ui/base/view_prop.h"
16 #include "ui/compositor/compositor.h"
17 #include "ui/events/event.h"
18 #include "ui/gfx/display.h"
19 #include "ui/gfx/geometry/insets.h"
20 #include "ui/gfx/native_widget_types.h"
21 #include "ui/gfx/screen.h"
22 #include "ui/platform_window/win/win_window.h"
23
24 using std::max;
25 using std::min;
26
27 namespace aura {
28
29 // static
30 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
31 return new WindowTreeHostWin(bounds);
32 }
33
34 WindowTreeHostWin::WindowTreeHostWin(const gfx::Rect& bounds)
35 : has_capture_(false),
36 widget_(gfx::kNullAcceleratedWidget),
37 window_(new ui::WinWindow(this, bounds)) {
38 }
39
40 WindowTreeHostWin::~WindowTreeHostWin() {
41 DestroyCompositor();
42 DestroyDispatcher();
43 window_.reset();
44 }
45
46 ui::EventSource* WindowTreeHostWin::GetEventSource() {
47 return this;
48 }
49
50 gfx::AcceleratedWidget WindowTreeHostWin::GetAcceleratedWidget() {
51 return widget_;
52 }
53
54 void WindowTreeHostWin::ShowImpl() {
55 window_->Show();
56 }
57
58 void WindowTreeHostWin::HideImpl() {
59 window_->Hide();
60 }
61
62 gfx::Rect WindowTreeHostWin::GetBounds() const {
63 return window_->GetBounds();
64 }
65
66 void WindowTreeHostWin::SetBounds(const gfx::Rect& bounds) {
67 window_->SetBounds(bounds);
68 }
69
70 gfx::Point WindowTreeHostWin::GetLocationOnNativeScreen() const {
71 return window_->GetBounds().origin();
72 }
73
74 void WindowTreeHostWin::SetCapture() {
75 if (!has_capture_) {
76 has_capture_ = true;
77 window_->SetCapture();
78 }
79 }
80
81 void WindowTreeHostWin::ReleaseCapture() {
82 if (has_capture_)
83 window_->ReleaseCapture();
84 }
85
86 void WindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) {
87 // Custom web cursors are handled directly.
88 if (native_cursor == ui::kCursorCustom)
89 return;
90
91 ui::CursorLoaderWin cursor_loader;
92 cursor_loader.SetPlatformCursor(&native_cursor);
93 ::SetCursor(native_cursor.platform());
94 }
95
96 void WindowTreeHostWin::MoveCursorToNative(const gfx::Point& location) {
97 // Deliberately not implemented.
98 }
99
100 void WindowTreeHostWin::OnCursorVisibilityChangedNative(bool show) {
101 NOTIMPLEMENTED();
102 }
103
104 void WindowTreeHostWin::OnBoundsChanged(const gfx::Rect& new_bounds) {
105 gfx::Rect old_bounds = bounds_;
106 bounds_ = new_bounds;
107 if (bounds_.origin() != old_bounds.origin())
108 OnHostMoved(bounds_.origin());
109 if (bounds_.size() != old_bounds.size())
110 OnHostResized(bounds_.size());
111 }
112
113 void WindowTreeHostWin::OnDamageRect(const gfx::Rect& damage_rect) {
114 compositor()->ScheduleRedrawRect(damage_rect);
115 }
116
117 void WindowTreeHostWin::DispatchEvent(ui::Event* event) {
118 ui::EventDispatchDetails details = SendEventToProcessor(event);
119 if (details.dispatcher_destroyed)
120 event->SetHandled();
121 }
122
123 void WindowTreeHostWin::OnCloseRequest() {
124 // TODO: this obviously shouldn't be here.
125 base::MessageLoopForUI::current()->QuitWhenIdle();
126 }
127
128 void WindowTreeHostWin::OnClosed() {
129 }
130
131 void WindowTreeHostWin::OnWindowStateChanged(
132 ui::PlatformWindowState new_state) {
133 }
134
135 void WindowTreeHostWin::OnLostCapture() {
136 if (has_capture_) {
137 has_capture_ = false;
138 OnHostLostWindowCapture();
139 }
140 }
141
142 void WindowTreeHostWin::OnAcceleratedWidgetAvailable(
143 gfx::AcceleratedWidget widget,
144 float device_pixel_ratio) {
145 widget_ = widget;
146 CreateCompositor();
147 WindowTreeHost::OnAcceleratedWidgetAvailable();
148 }
149
150 void WindowTreeHostWin::OnActivationChanged(bool active) {
151 if (active)
152 OnHostActivated();
153 }
154
155 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host_win.h ('k') | ui/platform_window/win/win_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698