OLD | NEW |
---|---|
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/native_widget_win.h" | 5 #include "ui/views/widget/native_widget_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/win/scoped_gdi_object.h" | 14 #include "base/win/scoped_gdi_object.h" |
15 #include "base/win/win_util.h" | 15 #include "base/win/win_util.h" |
16 #include "base/win/windows_version.h" | 16 #include "base/win/windows_version.h" |
17 #include "ui/base/dragdrop/drag_drop_types.h" | 17 #include "ui/base/dragdrop/drag_drop_types.h" |
18 #include "ui/base/dragdrop/drag_source_win.h" | 18 #include "ui/base/dragdrop/drag_source_win.h" |
19 #include "ui/base/dragdrop/os_exchange_data.h" | 19 #include "ui/base/dragdrop/os_exchange_data.h" |
20 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 20 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
21 #include "ui/base/events/event.h" | 21 #include "ui/base/events/event.h" |
22 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 22 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
23 #include "ui/base/l10n/l10n_util_win.h" | 23 #include "ui/base/l10n/l10n_util_win.h" |
24 #include "ui/base/theme_provider.h" | 24 #include "ui/base/theme_provider.h" |
25 #include "ui/base/view_prop.h" | 25 #include "ui/base/view_prop.h" |
26 #include "ui/base/win/dpi.h" | |
26 #include "ui/base/win/hwnd_util.h" | 27 #include "ui/base/win/hwnd_util.h" |
27 #include "ui/base/win/mouse_wheel_util.h" | 28 #include "ui/base/win/mouse_wheel_util.h" |
28 #include "ui/base/win/shell.h" | 29 #include "ui/base/win/shell.h" |
29 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
30 #include "ui/gfx/canvas_paint.h" | 31 #include "ui/gfx/canvas_paint.h" |
31 #include "ui/gfx/canvas_skia_paint.h" | 32 #include "ui/gfx/canvas_skia_paint.h" |
32 #include "ui/gfx/path.h" | 33 #include "ui/gfx/path.h" |
34 #include "ui/gfx/point_conversions.h" | |
33 #include "ui/gfx/screen.h" | 35 #include "ui/gfx/screen.h" |
36 #include "ui/gfx/size_conversions.h" | |
34 #include "ui/native_theme/native_theme.h" | 37 #include "ui/native_theme/native_theme.h" |
35 #include "ui/views/controls/native_control_win.h" | 38 #include "ui/views/controls/native_control_win.h" |
36 #include "ui/views/controls/textfield/textfield.h" | 39 #include "ui/views/controls/textfield/textfield.h" |
37 #include "ui/views/drag_utils.h" | 40 #include "ui/views/drag_utils.h" |
38 #include "ui/views/focus/accelerator_handler.h" | 41 #include "ui/views/focus/accelerator_handler.h" |
39 #include "ui/views/focus/view_storage.h" | 42 #include "ui/views/focus/view_storage.h" |
40 #include "ui/views/focus/widget_focus_manager.h" | 43 #include "ui/views/focus/widget_focus_manager.h" |
41 #include "ui/views/ime/input_method_win.h" | 44 #include "ui/views/ime/input_method_win.h" |
42 #include "ui/views/widget/aero_tooltip_manager.h" | 45 #include "ui/views/widget/aero_tooltip_manager.h" |
43 #include "ui/views/widget/drop_target_win.h" | 46 #include "ui/views/widget/drop_target_win.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 NativeWidgetWin::~NativeWidgetWin() { | 93 NativeWidgetWin::~NativeWidgetWin() { |
91 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 94 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
92 delete delegate_; | 95 delete delegate_; |
93 else | 96 else |
94 CloseNow(); | 97 CloseNow(); |
95 message_handler_.reset(); | 98 message_handler_.reset(); |
96 } | 99 } |
97 | 100 |
98 // static | 101 // static |
99 gfx::Font NativeWidgetWin::GetWindowTitleFont() { | 102 gfx::Font NativeWidgetWin::GetWindowTitleFont() { |
103 // TODO: Consider scaling to screen dpi. | |
kevers
2013/04/19 20:31:42
AdjustUIFont should already be adjusting the size
| |
100 NONCLIENTMETRICS ncm; | 104 NONCLIENTMETRICS ncm; |
101 base::win::GetNonClientMetrics(&ncm); | 105 base::win::GetNonClientMetrics(&ncm); |
102 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 106 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
103 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 107 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
104 return gfx::Font(caption_font); | 108 return gfx::Font(caption_font); |
105 } | 109 } |
106 | 110 |
107 void NativeWidgetWin::Show(int show_state) { | 111 void NativeWidgetWin::Show(int show_state) { |
108 message_handler_->Show(show_state); | 112 message_handler_->Show(show_state); |
109 } | 113 } |
110 | 114 |
111 //////////////////////////////////////////////////////////////////////////////// | 115 //////////////////////////////////////////////////////////////////////////////// |
112 // NativeWidgetWin, NativeWidget implementation: | 116 // NativeWidgetWin, NativeWidget implementation: |
113 | 117 |
114 void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) { | 118 void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) { |
115 SetInitParams(params); | 119 gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(params.bounds); |
116 message_handler_->Init(params.parent, params.bounds); | 120 Widget::InitParams params_in_pixel(params); |
121 params_in_pixel.bounds = pixel_bounds; | |
122 SetInitParams(params_in_pixel); | |
123 message_handler_->Init(params.parent, pixel_bounds); | |
117 } | 124 } |
118 | 125 |
119 NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() { | 126 NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() { |
120 return GetWidget()->ShouldUseNativeFrame() ? | 127 return GetWidget()->ShouldUseNativeFrame() ? |
121 new NativeFrameView(GetWidget()) : NULL; | 128 new NativeFrameView(GetWidget()) : NULL; |
122 } | 129 } |
123 | 130 |
124 bool NativeWidgetWin::ShouldUseNativeFrame() const { | 131 bool NativeWidgetWin::ShouldUseNativeFrame() const { |
125 return ui::win::IsAeroGlassEnabled(); | 132 return ui::win::IsAeroGlassEnabled(); |
126 } | 133 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 | 210 |
204 InputMethod* NativeWidgetWin::CreateInputMethod() { | 211 InputMethod* NativeWidgetWin::CreateInputMethod() { |
205 return new InputMethodWin(GetMessageHandler(), GetNativeWindow(), NULL); | 212 return new InputMethodWin(GetMessageHandler(), GetNativeWindow(), NULL); |
206 } | 213 } |
207 | 214 |
208 internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() { | 215 internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() { |
209 return message_handler_.get(); | 216 return message_handler_.get(); |
210 } | 217 } |
211 | 218 |
212 void NativeWidgetWin::CenterWindow(const gfx::Size& size) { | 219 void NativeWidgetWin::CenterWindow(const gfx::Size& size) { |
213 message_handler_->CenterWindow(size); | 220 gfx::Size size_in_pixels = ui::win::DIPToScreenSize(size); |
221 message_handler_->CenterWindow(size_in_pixels); | |
214 } | 222 } |
215 | 223 |
216 void NativeWidgetWin::GetWindowPlacement( | 224 void NativeWidgetWin::GetWindowPlacement( |
217 gfx::Rect* bounds, | 225 gfx::Rect* bounds, |
218 ui::WindowShowState* show_state) const { | 226 ui::WindowShowState* show_state) const { |
219 message_handler_->GetWindowPlacement(bounds, show_state); | 227 message_handler_->GetWindowPlacement(bounds, show_state); |
220 } | 228 } |
221 | 229 |
222 void NativeWidgetWin::SetWindowTitle(const string16& title) { | 230 void NativeWidgetWin::SetWindowTitle(const string16& title) { |
223 message_handler_->SetTitle(title); | 231 message_handler_->SetTitle(title); |
(...skipping 14 matching lines...) Expand all Loading... | |
238 | 246 |
239 gfx::Rect NativeWidgetWin::GetClientAreaBoundsInScreen() const { | 247 gfx::Rect NativeWidgetWin::GetClientAreaBoundsInScreen() const { |
240 return message_handler_->GetClientAreaBoundsInScreen(); | 248 return message_handler_->GetClientAreaBoundsInScreen(); |
241 } | 249 } |
242 | 250 |
243 gfx::Rect NativeWidgetWin::GetRestoredBounds() const { | 251 gfx::Rect NativeWidgetWin::GetRestoredBounds() const { |
244 return message_handler_->GetRestoredBounds(); | 252 return message_handler_->GetRestoredBounds(); |
245 } | 253 } |
246 | 254 |
247 void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) { | 255 void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) { |
248 message_handler_->SetBounds(bounds); | 256 float scale = ui::win::GetDeviceScaleFactor(); |
257 gfx::Rect bounds_in_pixels( | |
258 gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)), | |
259 gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale))); | |
260 message_handler_->SetBounds(bounds_in_pixels); | |
249 } | 261 } |
250 | 262 |
251 void NativeWidgetWin::SetSize(const gfx::Size& size) { | 263 void NativeWidgetWin::SetSize(const gfx::Size& size) { |
252 message_handler_->SetSize(size); | 264 message_handler_->SetSize(size); |
253 } | 265 } |
254 | 266 |
255 void NativeWidgetWin::StackAbove(gfx::NativeView native_view) { | 267 void NativeWidgetWin::StackAbove(gfx::NativeView native_view) { |
256 message_handler_->StackAbove(native_view); | 268 message_handler_->StackAbove(native_view); |
257 } | 269 } |
258 | 270 |
(...skipping 20 matching lines...) Expand all Loading... | |
279 void NativeWidgetWin::Show() { | 291 void NativeWidgetWin::Show() { |
280 message_handler_->Show(); | 292 message_handler_->Show(); |
281 } | 293 } |
282 | 294 |
283 void NativeWidgetWin::Hide() { | 295 void NativeWidgetWin::Hide() { |
284 message_handler_->Hide(); | 296 message_handler_->Hide(); |
285 } | 297 } |
286 | 298 |
287 void NativeWidgetWin::ShowMaximizedWithBounds( | 299 void NativeWidgetWin::ShowMaximizedWithBounds( |
288 const gfx::Rect& restored_bounds) { | 300 const gfx::Rect& restored_bounds) { |
289 message_handler_->ShowMaximizedWithBounds(restored_bounds); | 301 gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(restored_bounds); |
302 message_handler_->ShowMaximizedWithBounds(pixel_bounds); | |
290 } | 303 } |
291 | 304 |
292 void NativeWidgetWin::ShowWithWindowState(ui::WindowShowState show_state) { | 305 void NativeWidgetWin::ShowWithWindowState(ui::WindowShowState show_state) { |
293 message_handler_->ShowWindowWithState(show_state); | 306 message_handler_->ShowWindowWithState(show_state); |
294 } | 307 } |
295 | 308 |
296 bool NativeWidgetWin::IsVisible() const { | 309 bool NativeWidgetWin::IsVisible() const { |
297 return message_handler_->IsVisible(); | 310 return message_handler_->IsVisible(); |
298 } | 311 } |
299 | 312 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 | 398 |
386 void NativeWidgetWin::RunShellDrag(View* view, | 399 void NativeWidgetWin::RunShellDrag(View* view, |
387 const ui::OSExchangeData& data, | 400 const ui::OSExchangeData& data, |
388 const gfx::Point& location, | 401 const gfx::Point& location, |
389 int operation, | 402 int operation, |
390 ui::DragDropTypes::DragEventSource source) { | 403 ui::DragDropTypes::DragEventSource source) { |
391 views::RunShellDrag(NULL, data, location, operation, source); | 404 views::RunShellDrag(NULL, data, location, operation, source); |
392 } | 405 } |
393 | 406 |
394 void NativeWidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { | 407 void NativeWidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { |
395 message_handler_->SchedulePaintInRect(rect); | 408 gfx::Rect pixel_rect = ui::win::DIPToScreenRect(rect); |
409 message_handler_->SchedulePaintInRect(pixel_rect); | |
396 } | 410 } |
397 | 411 |
398 void NativeWidgetWin::SetCursor(gfx::NativeCursor cursor) { | 412 void NativeWidgetWin::SetCursor(gfx::NativeCursor cursor) { |
399 message_handler_->SetCursor(cursor); | 413 message_handler_->SetCursor(cursor); |
400 } | 414 } |
401 | 415 |
402 void NativeWidgetWin::ClearNativeFocus() { | 416 void NativeWidgetWin::ClearNativeFocus() { |
403 message_handler_->ClearNativeFocus(); | 417 message_handler_->ClearNativeFocus(); |
404 } | 418 } |
405 | 419 |
406 gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const { | 420 gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const { |
407 return gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 421 return ui::win::ScreenToDIPRect( |
408 GetNativeView()).work_area(); | 422 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( |
423 GetNativeView()).work_area()); | |
409 } | 424 } |
410 | 425 |
411 void NativeWidgetWin::SetInactiveRenderingDisabled(bool value) { | 426 void NativeWidgetWin::SetInactiveRenderingDisabled(bool value) { |
412 } | 427 } |
413 | 428 |
414 Widget::MoveLoopResult NativeWidgetWin::RunMoveLoop( | 429 Widget::MoveLoopResult NativeWidgetWin::RunMoveLoop( |
415 const gfx::Vector2d& drag_offset, | 430 const gfx::Vector2d& drag_offset, |
416 Widget::MoveLoopSource source) { | 431 Widget::MoveLoopSource source) { |
417 return message_handler_->RunMoveLoop(drag_offset) ? | 432 return message_handler_->RunMoveLoop(drag_offset) ? |
418 Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED; | 433 Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 if (GetWidget()->non_client_view()) | 543 if (GetWidget()->non_client_view()) |
529 GetWidget()->non_client_view()->GetWindowMask(size, path); | 544 GetWidget()->non_client_view()->GetWindowMask(size, path); |
530 } | 545 } |
531 | 546 |
532 bool NativeWidgetWin::GetClientAreaInsets(gfx::Insets* insets) const { | 547 bool NativeWidgetWin::GetClientAreaInsets(gfx::Insets* insets) const { |
533 return false; | 548 return false; |
534 } | 549 } |
535 | 550 |
536 void NativeWidgetWin::GetMinMaxSize(gfx::Size* min_size, | 551 void NativeWidgetWin::GetMinMaxSize(gfx::Size* min_size, |
537 gfx::Size* max_size) const { | 552 gfx::Size* max_size) const { |
538 *min_size = delegate_->GetMinimumSize(); | 553 *min_size = ui::win::ScreenToDIPSize(delegate_->GetMinimumSize()); |
539 *max_size = delegate_->GetMaximumSize(); | 554 *max_size = ui::win::ScreenToDIPSize(delegate_->GetMaximumSize()); |
540 } | 555 } |
541 | 556 |
542 gfx::Size NativeWidgetWin::GetRootViewSize() const { | 557 gfx::Size NativeWidgetWin::GetRootViewSize() const { |
543 return GetWidget()->GetRootView()->size(); | 558 gfx::Size pixel_size = GetWidget()->GetRootView()->size(); |
559 return ui::win::ScreenToDIPSize(pixel_size); | |
544 } | 560 } |
545 | 561 |
546 void NativeWidgetWin::ResetWindowControls() { | 562 void NativeWidgetWin::ResetWindowControls() { |
547 GetWidget()->non_client_view()->ResetWindowControls(); | 563 GetWidget()->non_client_view()->ResetWindowControls(); |
548 } | 564 } |
549 | 565 |
550 void NativeWidgetWin::PaintLayeredWindow(gfx::Canvas* canvas) { | 566 void NativeWidgetWin::PaintLayeredWindow(gfx::Canvas* canvas) { |
551 GetWidget()->GetRootView()->Paint(canvas); | 567 GetWidget()->GetRootView()->Paint(canvas); |
552 } | 568 } |
553 | 569 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 | 684 |
669 void NativeWidgetWin::HandleWorkAreaChanged() { | 685 void NativeWidgetWin::HandleWorkAreaChanged() { |
670 GetWidget()->widget_delegate()->OnWorkAreaChanged(); | 686 GetWidget()->widget_delegate()->OnWorkAreaChanged(); |
671 } | 687 } |
672 | 688 |
673 void NativeWidgetWin::HandleVisibilityChanged(bool visible) { | 689 void NativeWidgetWin::HandleVisibilityChanged(bool visible) { |
674 delegate_->OnNativeWidgetVisibilityChanged(visible); | 690 delegate_->OnNativeWidgetVisibilityChanged(visible); |
675 } | 691 } |
676 | 692 |
677 void NativeWidgetWin::HandleClientSizeChanged(const gfx::Size& new_size) { | 693 void NativeWidgetWin::HandleClientSizeChanged(const gfx::Size& new_size) { |
678 delegate_->OnNativeWidgetSizeChanged(new_size); | 694 gfx::Size size_in_dip = ui::win::ScreenToDIPSize(new_size); |
695 delegate_->OnNativeWidgetSizeChanged(size_in_dip); | |
679 } | 696 } |
680 | 697 |
681 void NativeWidgetWin::HandleFrameChanged() { | 698 void NativeWidgetWin::HandleFrameChanged() { |
682 // Replace the frame and layout the contents. | 699 // Replace the frame and layout the contents. |
683 GetWidget()->non_client_view()->UpdateFrame(true); | 700 GetWidget()->non_client_view()->UpdateFrame(true); |
684 } | 701 } |
685 | 702 |
686 void NativeWidgetWin::HandleNativeFocus(HWND last_focused_window) { | 703 void NativeWidgetWin::HandleNativeFocus(HWND last_focused_window) { |
687 delegate_->OnNativeFocus(last_focused_window); | 704 delegate_->OnNativeFocus(last_focused_window); |
688 InputMethod* input_method = GetInputMethod(); | 705 InputMethod* input_method = GetInputMethod(); |
689 if (input_method) | 706 if (input_method) |
690 input_method->OnFocus(); | 707 input_method->OnFocus(); |
691 } | 708 } |
692 | 709 |
693 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { | 710 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { |
694 delegate_->OnNativeBlur(focused_window); | 711 delegate_->OnNativeBlur(focused_window); |
695 InputMethod* input_method = GetInputMethod(); | 712 InputMethod* input_method = GetInputMethod(); |
696 if (input_method) | 713 if (input_method) |
697 input_method->OnBlur(); | 714 input_method->OnBlur(); |
698 } | 715 } |
699 | 716 |
700 bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { | 717 bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { |
701 delegate_->OnMouseEvent(const_cast<ui::MouseEvent*>(&event)); | 718 ui::MouseEvent dpi_event(event); |
702 return event.handled(); | 719 dpi_event.set_location(ui::win::ScreenToDIPPoint(event.location())); |
720 delegate_->OnMouseEvent(&dpi_event); | |
721 return dpi_event.handled(); | |
703 } | 722 } |
704 | 723 |
705 bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { | 724 bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { |
706 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&event)); | 725 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&event)); |
707 return event.handled(); | 726 return event.handled(); |
708 } | 727 } |
709 | 728 |
710 bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { | 729 bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { |
711 InputMethod* input_method = GetInputMethod(); | 730 InputMethod* input_method = GetInputMethod(); |
712 if (input_method) | 731 if (input_method) |
(...skipping 25 matching lines...) Expand all Loading... | |
738 void NativeWidgetWin::HandleInputLanguageChange(DWORD character_set, | 757 void NativeWidgetWin::HandleInputLanguageChange(DWORD character_set, |
739 HKL input_language_id) { | 758 HKL input_language_id) { |
740 InputMethod* input_method = GetInputMethod(); | 759 InputMethod* input_method = GetInputMethod(); |
741 if (input_method && !input_method->IsMock()) { | 760 if (input_method && !input_method->IsMock()) { |
742 static_cast<InputMethodWin*>(input_method)->OnInputLangChange( | 761 static_cast<InputMethodWin*>(input_method)->OnInputLangChange( |
743 character_set, input_language_id); | 762 character_set, input_language_id); |
744 } | 763 } |
745 } | 764 } |
746 | 765 |
747 bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) { | 766 bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) { |
748 return delegate_->OnNativeWidgetPaintAccelerated(gfx::Rect(invalid_rect)); | 767 gfx::Rect dpi_rect = ui::win::ScreenToDIPRect(invalid_rect); |
768 return delegate_->OnNativeWidgetPaintAccelerated(dpi_rect); | |
749 } | 769 } |
750 | 770 |
751 void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) { | 771 void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) { |
752 delegate_->OnNativeWidgetPaint(canvas); | 772 delegate_->OnNativeWidgetPaint(canvas); |
753 } | 773 } |
754 | 774 |
755 bool NativeWidgetWin::HandleTooltipNotify(int w_param, | 775 bool NativeWidgetWin::HandleTooltipNotify(int w_param, |
756 NMHDR* l_param, | 776 NMHDR* l_param, |
757 LRESULT* l_result) { | 777 LRESULT* l_result) { |
758 // We can be sent this message before the tooltip manager is created, if a | 778 // We can be sent this message before the tooltip manager is created, if a |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 gfx::Rect* rect) { | 847 gfx::Rect* rect) { |
828 DCHECK(source); | 848 DCHECK(source); |
829 DCHECK(target); | 849 DCHECK(target); |
830 DCHECK(rect); | 850 DCHECK(rect); |
831 | 851 |
832 HWND source_hwnd = source->GetNativeView(); | 852 HWND source_hwnd = source->GetNativeView(); |
833 HWND target_hwnd = target->GetNativeView(); | 853 HWND target_hwnd = target->GetNativeView(); |
834 if (source_hwnd == target_hwnd) | 854 if (source_hwnd == target_hwnd) |
835 return true; | 855 return true; |
836 | 856 |
837 RECT win_rect = rect->ToRECT(); | 857 RECT win_rect = ui::win::DIPToScreenRect(*rect).ToRECT(); |
838 if (::MapWindowPoints(source_hwnd, target_hwnd, | 858 if (::MapWindowPoints(source_hwnd, target_hwnd, |
839 reinterpret_cast<LPPOINT>(&win_rect), | 859 reinterpret_cast<LPPOINT>(&win_rect), |
840 sizeof(RECT)/sizeof(POINT))) { | 860 sizeof(RECT)/sizeof(POINT))) { |
841 *rect = gfx::Rect(win_rect); | 861 *rect = ui::win::ScreenToDIPRect(gfx::Rect(win_rect)); |
842 return true; | 862 return true; |
843 } | 863 } |
844 return false; | 864 return false; |
845 } | 865 } |
846 | 866 |
847 namespace internal { | 867 namespace internal { |
848 | 868 |
849 //////////////////////////////////////////////////////////////////////////////// | 869 //////////////////////////////////////////////////////////////////////////////// |
850 // internal::NativeWidgetPrivate, public: | 870 // internal::NativeWidgetPrivate, public: |
851 | 871 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
963 // static | 983 // static |
964 bool NativeWidgetPrivate::IsTouchDown() { | 984 bool NativeWidgetPrivate::IsTouchDown() { |
965 // This currently isn't necessary because we're not generating touch events on | 985 // This currently isn't necessary because we're not generating touch events on |
966 // windows. When we do, this will need to be updated. | 986 // windows. When we do, this will need to be updated. |
967 return false; | 987 return false; |
968 } | 988 } |
969 | 989 |
970 } // namespace internal | 990 } // namespace internal |
971 | 991 |
972 } // namespace views | 992 } // namespace views |
OLD | NEW |