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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc

Issue 659883002: Enable hidpi on Linux, refactor a bit on Windows to share Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: constants Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/widget/desktop_aura/desktop_window_tree_host_win.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
6 6
7 #include "base/win/metro.h" 7 #include "base/win/metro.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "third_party/skia/include/core/SkRegion.h" 9 #include "third_party/skia/include/core/SkRegion.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/client/cursor_client.h" 11 #include "ui/aura/client/cursor_client.h"
12 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/window_event_dispatcher.h" 13 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/aura/window_property.h" 14 #include "ui/aura/window_property.h"
15 #include "ui/base/cursor/cursor_loader_win.h" 15 #include "ui/base/cursor/cursor_loader_win.h"
16 #include "ui/base/ime/input_method.h" 16 #include "ui/base/ime/input_method.h"
17 #include "ui/base/win/shell.h" 17 #include "ui/base/win/shell.h"
18 #include "ui/compositor/compositor_constants.h" 18 #include "ui/compositor/compositor_constants.h"
19 #include "ui/gfx/dpi.h"
19 #include "ui/gfx/insets.h" 20 #include "ui/gfx/insets.h"
20 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
21 #include "ui/gfx/path.h" 22 #include "ui/gfx/path.h"
22 #include "ui/gfx/path_win.h" 23 #include "ui/gfx/path_win.h"
23 #include "ui/gfx/vector2d.h" 24 #include "ui/gfx/vector2d.h"
24 #include "ui/gfx/win/dpi.h"
25 #include "ui/native_theme/native_theme_aura.h" 25 #include "ui/native_theme/native_theme_aura.h"
26 #include "ui/native_theme/native_theme_win.h" 26 #include "ui/native_theme/native_theme_win.h"
27 #include "ui/views/corewm/tooltip_win.h" 27 #include "ui/views/corewm/tooltip_win.h"
28 #include "ui/views/ime/input_method_bridge.h" 28 #include "ui/views/ime/input_method_bridge.h"
29 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" 29 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h"
30 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" 30 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h"
31 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" 31 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
32 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 32 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
33 #include "ui/views/widget/root_view.h" 33 #include "ui/views/widget/root_view.h"
34 #include "ui/views/widget/widget_delegate.h" 34 #include "ui/views/widget/widget_delegate.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 native_widget_delegate_); 131 native_widget_delegate_);
132 132
133 HWND parent_hwnd = NULL; 133 HWND parent_hwnd = NULL;
134 if (params.parent && params.parent->GetHost()) 134 if (params.parent && params.parent->GetHost())
135 parent_hwnd = params.parent->GetHost()->GetAcceleratedWidget(); 135 parent_hwnd = params.parent->GetHost()->GetAcceleratedWidget();
136 136
137 message_handler_->set_remove_standard_frame(params.remove_standard_frame); 137 message_handler_->set_remove_standard_frame(params.remove_standard_frame);
138 138
139 has_non_client_view_ = Widget::RequiresNonClientView(params.type); 139 has_non_client_view_ = Widget::RequiresNonClientView(params.type);
140 140
141 gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(params.bounds); 141 gfx::Rect pixel_bounds = gfx::DIPToScreenRect(params.bounds);
142 message_handler_->Init(parent_hwnd, pixel_bounds); 142 message_handler_->Init(parent_hwnd, pixel_bounds);
143 if (params.type == Widget::InitParams::TYPE_MENU) { 143 if (params.type == Widget::InitParams::TYPE_MENU) {
144 ::SetProp(GetAcceleratedWidget(), 144 ::SetProp(GetAcceleratedWidget(),
145 kForceSoftwareCompositor, 145 kForceSoftwareCompositor,
146 reinterpret_cast<HANDLE>(true)); 146 reinterpret_cast<HANDLE>(true));
147 } 147 }
148 CreateCompositor(GetAcceleratedWidget()); 148 CreateCompositor(GetAcceleratedWidget());
149 } 149 }
150 150
151 void DesktopWindowTreeHostWin::OnNativeWidgetCreated( 151 void DesktopWindowTreeHostWin::OnNativeWidgetCreated(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return this; 204 return this;
205 } 205 }
206 206
207 void DesktopWindowTreeHostWin::ShowWindowWithState( 207 void DesktopWindowTreeHostWin::ShowWindowWithState(
208 ui::WindowShowState show_state) { 208 ui::WindowShowState show_state) {
209 message_handler_->ShowWindowWithState(show_state); 209 message_handler_->ShowWindowWithState(show_state);
210 } 210 }
211 211
212 void DesktopWindowTreeHostWin::ShowMaximizedWithBounds( 212 void DesktopWindowTreeHostWin::ShowMaximizedWithBounds(
213 const gfx::Rect& restored_bounds) { 213 const gfx::Rect& restored_bounds) {
214 gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(restored_bounds); 214 gfx::Rect pixel_bounds = gfx::DIPToScreenRect(restored_bounds);
215 message_handler_->ShowMaximizedWithBounds(pixel_bounds); 215 message_handler_->ShowMaximizedWithBounds(pixel_bounds);
216 } 216 }
217 217
218 bool DesktopWindowTreeHostWin::IsVisible() const { 218 bool DesktopWindowTreeHostWin::IsVisible() const {
219 return message_handler_->IsVisible(); 219 return message_handler_->IsVisible();
220 } 220 }
221 221
222 void DesktopWindowTreeHostWin::SetSize(const gfx::Size& size) { 222 void DesktopWindowTreeHostWin::SetSize(const gfx::Size& size) {
223 gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(size); 223 gfx::Size size_in_pixels = gfx::DIPToScreenSize(size);
224 gfx::Size expanded = GetExpandedWindowSize( 224 gfx::Size expanded = GetExpandedWindowSize(
225 message_handler_->window_ex_style(), size_in_pixels); 225 message_handler_->window_ex_style(), size_in_pixels);
226 window_enlargement_ = 226 window_enlargement_ =
227 gfx::Vector2d(expanded.width() - size_in_pixels.width(), 227 gfx::Vector2d(expanded.width() - size_in_pixels.width(),
228 expanded.height() - size_in_pixels.height()); 228 expanded.height() - size_in_pixels.height());
229 message_handler_->SetSize(expanded); 229 message_handler_->SetSize(expanded);
230 } 230 }
231 231
232 void DesktopWindowTreeHostWin::StackAtTop() { 232 void DesktopWindowTreeHostWin::StackAtTop() {
233 message_handler_->StackAtTop(); 233 message_handler_->StackAtTop();
234 } 234 }
235 235
236 void DesktopWindowTreeHostWin::CenterWindow(const gfx::Size& size) { 236 void DesktopWindowTreeHostWin::CenterWindow(const gfx::Size& size) {
237 gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(size); 237 gfx::Size size_in_pixels = gfx::DIPToScreenSize(size);
238 gfx::Size expanded_size; 238 gfx::Size expanded_size;
239 expanded_size = GetExpandedWindowSize(message_handler_->window_ex_style(), 239 expanded_size = GetExpandedWindowSize(message_handler_->window_ex_style(),
240 size_in_pixels); 240 size_in_pixels);
241 window_enlargement_ = 241 window_enlargement_ =
242 gfx::Vector2d(expanded_size.width() - size_in_pixels.width(), 242 gfx::Vector2d(expanded_size.width() - size_in_pixels.width(),
243 expanded_size.height() - size_in_pixels.height()); 243 expanded_size.height() - size_in_pixels.height());
244 message_handler_->CenterWindow(expanded_size); 244 message_handler_->CenterWindow(expanded_size);
245 } 245 }
246 246
247 void DesktopWindowTreeHostWin::GetWindowPlacement( 247 void DesktopWindowTreeHostWin::GetWindowPlacement(
248 gfx::Rect* bounds, 248 gfx::Rect* bounds,
249 ui::WindowShowState* show_state) const { 249 ui::WindowShowState* show_state) const {
250 message_handler_->GetWindowPlacement(bounds, show_state); 250 message_handler_->GetWindowPlacement(bounds, show_state);
251 InsetBottomRight(bounds, window_enlargement_); 251 InsetBottomRight(bounds, window_enlargement_);
252 *bounds = gfx::win::ScreenToDIPRect(*bounds); 252 *bounds = gfx::ScreenToDIPRect(*bounds);
253 } 253 }
254 254
255 gfx::Rect DesktopWindowTreeHostWin::GetWindowBoundsInScreen() const { 255 gfx::Rect DesktopWindowTreeHostWin::GetWindowBoundsInScreen() const {
256 gfx::Rect pixel_bounds = message_handler_->GetWindowBoundsInScreen(); 256 gfx::Rect pixel_bounds = message_handler_->GetWindowBoundsInScreen();
257 InsetBottomRight(&pixel_bounds, window_enlargement_); 257 InsetBottomRight(&pixel_bounds, window_enlargement_);
258 return gfx::win::ScreenToDIPRect(pixel_bounds); 258 return gfx::ScreenToDIPRect(pixel_bounds);
259 } 259 }
260 260
261 gfx::Rect DesktopWindowTreeHostWin::GetClientAreaBoundsInScreen() const { 261 gfx::Rect DesktopWindowTreeHostWin::GetClientAreaBoundsInScreen() const {
262 gfx::Rect pixel_bounds = message_handler_->GetClientAreaBoundsInScreen(); 262 gfx::Rect pixel_bounds = message_handler_->GetClientAreaBoundsInScreen();
263 InsetBottomRight(&pixel_bounds, window_enlargement_); 263 InsetBottomRight(&pixel_bounds, window_enlargement_);
264 return gfx::win::ScreenToDIPRect(pixel_bounds); 264 return gfx::ScreenToDIPRect(pixel_bounds);
265 } 265 }
266 266
267 gfx::Rect DesktopWindowTreeHostWin::GetRestoredBounds() const { 267 gfx::Rect DesktopWindowTreeHostWin::GetRestoredBounds() const {
268 gfx::Rect pixel_bounds = message_handler_->GetRestoredBounds(); 268 gfx::Rect pixel_bounds = message_handler_->GetRestoredBounds();
269 InsetBottomRight(&pixel_bounds, window_enlargement_); 269 InsetBottomRight(&pixel_bounds, window_enlargement_);
270 return gfx::win::ScreenToDIPRect(pixel_bounds); 270 return gfx::ScreenToDIPRect(pixel_bounds);
271 } 271 }
272 272
273 gfx::Rect DesktopWindowTreeHostWin::GetWorkAreaBoundsInScreen() const { 273 gfx::Rect DesktopWindowTreeHostWin::GetWorkAreaBoundsInScreen() const {
274 MONITORINFO monitor_info; 274 MONITORINFO monitor_info;
275 monitor_info.cbSize = sizeof(monitor_info); 275 monitor_info.cbSize = sizeof(monitor_info);
276 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(), 276 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(),
277 MONITOR_DEFAULTTONEAREST), 277 MONITOR_DEFAULTTONEAREST),
278 &monitor_info); 278 &monitor_info);
279 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork); 279 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork);
280 return gfx::win::ScreenToDIPRect(pixel_bounds); 280 return gfx::ScreenToDIPRect(pixel_bounds);
281 } 281 }
282 282
283 void DesktopWindowTreeHostWin::SetShape(gfx::NativeRegion native_region) { 283 void DesktopWindowTreeHostWin::SetShape(gfx::NativeRegion native_region) {
284 if (native_region) { 284 if (native_region) {
285 // TODO(wez): This would be a lot simpler if we were passed an SkPath. 285 // TODO(wez): This would be a lot simpler if we were passed an SkPath.
286 // See crbug.com/410593. 286 // See crbug.com/410593.
287 gfx::NativeRegion shape = native_region; 287 gfx::NativeRegion shape = native_region;
288 SkRegion device_region; 288 SkRegion device_region;
289 if (gfx::IsInHighDPIMode()) { 289 if (gfx::IsInHighDPIMode()) {
290 shape = &device_region; 290 shape = &device_region;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 int DesktopWindowTreeHostWin::GetInitialShowState() const { 633 int DesktopWindowTreeHostWin::GetInitialShowState() const {
634 return CanActivate() ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE; 634 return CanActivate() ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE;
635 } 635 }
636 636
637 bool DesktopWindowTreeHostWin::WillProcessWorkAreaChange() const { 637 bool DesktopWindowTreeHostWin::WillProcessWorkAreaChange() const {
638 return GetWidget()->widget_delegate()->WillProcessWorkAreaChange(); 638 return GetWidget()->widget_delegate()->WillProcessWorkAreaChange();
639 } 639 }
640 640
641 int DesktopWindowTreeHostWin::GetNonClientComponent( 641 int DesktopWindowTreeHostWin::GetNonClientComponent(
642 const gfx::Point& point) const { 642 const gfx::Point& point) const {
643 gfx::Point dip_position = gfx::win::ScreenToDIPPoint(point); 643 gfx::Point dip_position = gfx::ScreenToDIPPoint(point);
644 return native_widget_delegate_->GetNonClientComponent(dip_position); 644 return native_widget_delegate_->GetNonClientComponent(dip_position);
645 } 645 }
646 646
647 void DesktopWindowTreeHostWin::GetWindowMask(const gfx::Size& size, 647 void DesktopWindowTreeHostWin::GetWindowMask(const gfx::Size& size,
648 gfx::Path* path) { 648 gfx::Path* path) {
649 if (GetWidget()->non_client_view()) { 649 if (GetWidget()->non_client_view()) {
650 GetWidget()->non_client_view()->GetWindowMask(size, path); 650 GetWidget()->non_client_view()->GetWindowMask(size, path);
651 } else if (!window_enlargement_.IsZero()) { 651 } else if (!window_enlargement_.IsZero()) {
652 gfx::Rect bounds(WidgetSizeIsClientSize() 652 gfx::Rect bounds(WidgetSizeIsClientSize()
653 ? message_handler_->GetClientAreaBoundsInScreen() 653 ? message_handler_->GetClientAreaBoundsInScreen()
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 999
1000 // static 1000 // static
1001 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 1001 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
1002 internal::NativeWidgetDelegate* native_widget_delegate, 1002 internal::NativeWidgetDelegate* native_widget_delegate,
1003 DesktopNativeWidgetAura* desktop_native_widget_aura) { 1003 DesktopNativeWidgetAura* desktop_native_widget_aura) {
1004 return new DesktopWindowTreeHostWin(native_widget_delegate, 1004 return new DesktopWindowTreeHostWin(native_widget_delegate,
1005 desktop_native_widget_aura); 1005 desktop_native_widget_aura);
1006 } 1006 }
1007 1007
1008 } // namespace views 1008 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698