| 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/strings/string_util.h" | 13 #include "base/strings/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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 107 } |
| 105 | 108 |
| 106 void NativeWidgetWin::Show(int show_state) { | 109 void NativeWidgetWin::Show(int show_state) { |
| 107 message_handler_->Show(show_state); | 110 message_handler_->Show(show_state); |
| 108 } | 111 } |
| 109 | 112 |
| 110 //////////////////////////////////////////////////////////////////////////////// | 113 //////////////////////////////////////////////////////////////////////////////// |
| 111 // NativeWidgetWin, NativeWidget implementation: | 114 // NativeWidgetWin, NativeWidget implementation: |
| 112 | 115 |
| 113 void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) { | 116 void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) { |
| 114 SetInitParams(params); | 117 gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(params.bounds); |
| 115 message_handler_->Init(params.parent, params.bounds); | 118 Widget::InitParams params_in_pixel(params); |
| 119 params_in_pixel.bounds = pixel_bounds; |
| 120 SetInitParams(params_in_pixel); |
| 121 message_handler_->Init(params.parent, pixel_bounds); |
| 116 } | 122 } |
| 117 | 123 |
| 118 NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() { | 124 NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() { |
| 119 return GetWidget()->ShouldUseNativeFrame() ? | 125 return GetWidget()->ShouldUseNativeFrame() ? |
| 120 new NativeFrameView(GetWidget()) : NULL; | 126 new NativeFrameView(GetWidget()) : NULL; |
| 121 } | 127 } |
| 122 | 128 |
| 123 bool NativeWidgetWin::ShouldUseNativeFrame() const { | 129 bool NativeWidgetWin::ShouldUseNativeFrame() const { |
| 124 return ui::win::IsAeroGlassEnabled(); | 130 return ui::win::IsAeroGlassEnabled(); |
| 125 } | 131 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 210 |
| 205 InputMethod* NativeWidgetWin::CreateInputMethod() { | 211 InputMethod* NativeWidgetWin::CreateInputMethod() { |
| 206 return new InputMethodWin(GetMessageHandler(), GetNativeWindow(), NULL); | 212 return new InputMethodWin(GetMessageHandler(), GetNativeWindow(), NULL); |
| 207 } | 213 } |
| 208 | 214 |
| 209 internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() { | 215 internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() { |
| 210 return message_handler_.get(); | 216 return message_handler_.get(); |
| 211 } | 217 } |
| 212 | 218 |
| 213 void NativeWidgetWin::CenterWindow(const gfx::Size& size) { | 219 void NativeWidgetWin::CenterWindow(const gfx::Size& size) { |
| 214 message_handler_->CenterWindow(size); | 220 gfx::Size size_in_pixels = ui::win::DIPToScreenSize(size); |
| 221 message_handler_->CenterWindow(size_in_pixels); |
| 215 } | 222 } |
| 216 | 223 |
| 217 void NativeWidgetWin::GetWindowPlacement( | 224 void NativeWidgetWin::GetWindowPlacement( |
| 218 gfx::Rect* bounds, | 225 gfx::Rect* bounds, |
| 219 ui::WindowShowState* show_state) const { | 226 ui::WindowShowState* show_state) const { |
| 220 message_handler_->GetWindowPlacement(bounds, show_state); | 227 message_handler_->GetWindowPlacement(bounds, show_state); |
| 228 *bounds = ui::win::ScreenToDIPRect(*bounds); |
| 221 } | 229 } |
| 222 | 230 |
| 223 void NativeWidgetWin::SetWindowTitle(const string16& title) { | 231 void NativeWidgetWin::SetWindowTitle(const string16& title) { |
| 224 message_handler_->SetTitle(title); | 232 message_handler_->SetTitle(title); |
| 225 } | 233 } |
| 226 | 234 |
| 227 void NativeWidgetWin::SetWindowIcons(const gfx::ImageSkia& window_icon, | 235 void NativeWidgetWin::SetWindowIcons(const gfx::ImageSkia& window_icon, |
| 228 const gfx::ImageSkia& app_icon) { | 236 const gfx::ImageSkia& app_icon) { |
| 229 message_handler_->SetWindowIcons(window_icon, app_icon); | 237 message_handler_->SetWindowIcons(window_icon, app_icon); |
| 230 } | 238 } |
| 231 | 239 |
| 232 void NativeWidgetWin::InitModalType(ui::ModalType modal_type) { | 240 void NativeWidgetWin::InitModalType(ui::ModalType modal_type) { |
| 233 message_handler_->InitModalType(modal_type); | 241 message_handler_->InitModalType(modal_type); |
| 234 } | 242 } |
| 235 | 243 |
| 236 gfx::Rect NativeWidgetWin::GetWindowBoundsInScreen() const { | 244 gfx::Rect NativeWidgetWin::GetWindowBoundsInScreen() const { |
| 237 return message_handler_->GetWindowBoundsInScreen(); | 245 gfx::Rect bounds_in_pixels = message_handler_->GetWindowBoundsInScreen(); |
| 246 return ui::win::ScreenToDIPRect(bounds_in_pixels); |
| 238 } | 247 } |
| 239 | 248 |
| 240 gfx::Rect NativeWidgetWin::GetClientAreaBoundsInScreen() const { | 249 gfx::Rect NativeWidgetWin::GetClientAreaBoundsInScreen() const { |
| 241 return message_handler_->GetClientAreaBoundsInScreen(); | 250 gfx::Rect bounds_in_pixels = message_handler_->GetClientAreaBoundsInScreen(); |
| 251 return ui::win::ScreenToDIPRect(bounds_in_pixels); |
| 242 } | 252 } |
| 243 | 253 |
| 244 gfx::Rect NativeWidgetWin::GetRestoredBounds() const { | 254 gfx::Rect NativeWidgetWin::GetRestoredBounds() const { |
| 245 return message_handler_->GetRestoredBounds(); | 255 gfx::Rect bounds_in_pixels = message_handler_->GetRestoredBounds(); |
| 256 return ui::win::ScreenToDIPRect(bounds_in_pixels); |
| 246 } | 257 } |
| 247 | 258 |
| 248 void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) { | 259 void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) { |
| 249 message_handler_->SetBounds(bounds); | 260 float scale = ui::win::GetDeviceScaleFactor(); |
| 261 gfx::Rect bounds_in_pixels( |
| 262 gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)), |
| 263 gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale))); |
| 264 message_handler_->SetBounds(bounds_in_pixels); |
| 250 } | 265 } |
| 251 | 266 |
| 252 void NativeWidgetWin::SetSize(const gfx::Size& size) { | 267 void NativeWidgetWin::SetSize(const gfx::Size& size) { |
| 253 message_handler_->SetSize(size); | 268 message_handler_->SetSize(size); |
| 254 } | 269 } |
| 255 | 270 |
| 256 void NativeWidgetWin::StackAbove(gfx::NativeView native_view) { | 271 void NativeWidgetWin::StackAbove(gfx::NativeView native_view) { |
| 257 message_handler_->StackAbove(native_view); | 272 message_handler_->StackAbove(native_view); |
| 258 } | 273 } |
| 259 | 274 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 280 void NativeWidgetWin::Show() { | 295 void NativeWidgetWin::Show() { |
| 281 message_handler_->Show(); | 296 message_handler_->Show(); |
| 282 } | 297 } |
| 283 | 298 |
| 284 void NativeWidgetWin::Hide() { | 299 void NativeWidgetWin::Hide() { |
| 285 message_handler_->Hide(); | 300 message_handler_->Hide(); |
| 286 } | 301 } |
| 287 | 302 |
| 288 void NativeWidgetWin::ShowMaximizedWithBounds( | 303 void NativeWidgetWin::ShowMaximizedWithBounds( |
| 289 const gfx::Rect& restored_bounds) { | 304 const gfx::Rect& restored_bounds) { |
| 290 message_handler_->ShowMaximizedWithBounds(restored_bounds); | 305 gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(restored_bounds); |
| 306 message_handler_->ShowMaximizedWithBounds(pixel_bounds); |
| 291 } | 307 } |
| 292 | 308 |
| 293 void NativeWidgetWin::ShowWithWindowState(ui::WindowShowState show_state) { | 309 void NativeWidgetWin::ShowWithWindowState(ui::WindowShowState show_state) { |
| 294 message_handler_->ShowWindowWithState(show_state); | 310 message_handler_->ShowWindowWithState(show_state); |
| 295 } | 311 } |
| 296 | 312 |
| 297 bool NativeWidgetWin::IsVisible() const { | 313 bool NativeWidgetWin::IsVisible() const { |
| 298 return message_handler_->IsVisible(); | 314 return message_handler_->IsVisible(); |
| 299 } | 315 } |
| 300 | 316 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 | 402 |
| 387 void NativeWidgetWin::RunShellDrag(View* view, | 403 void NativeWidgetWin::RunShellDrag(View* view, |
| 388 const ui::OSExchangeData& data, | 404 const ui::OSExchangeData& data, |
| 389 const gfx::Point& location, | 405 const gfx::Point& location, |
| 390 int operation, | 406 int operation, |
| 391 ui::DragDropTypes::DragEventSource source) { | 407 ui::DragDropTypes::DragEventSource source) { |
| 392 views::RunShellDrag(NULL, data, location, operation, source); | 408 views::RunShellDrag(NULL, data, location, operation, source); |
| 393 } | 409 } |
| 394 | 410 |
| 395 void NativeWidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { | 411 void NativeWidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { |
| 396 message_handler_->SchedulePaintInRect(rect); | 412 gfx::Rect pixel_rect = ui::win::DIPToScreenRect(rect); |
| 413 message_handler_->SchedulePaintInRect(pixel_rect); |
| 397 } | 414 } |
| 398 | 415 |
| 399 void NativeWidgetWin::SetCursor(gfx::NativeCursor cursor) { | 416 void NativeWidgetWin::SetCursor(gfx::NativeCursor cursor) { |
| 400 message_handler_->SetCursor(cursor); | 417 message_handler_->SetCursor(cursor); |
| 401 } | 418 } |
| 402 | 419 |
| 403 void NativeWidgetWin::ClearNativeFocus() { | 420 void NativeWidgetWin::ClearNativeFocus() { |
| 404 message_handler_->ClearNativeFocus(); | 421 message_handler_->ClearNativeFocus(); |
| 405 } | 422 } |
| 406 | 423 |
| 407 gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const { | 424 gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const { |
| 408 return gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( | 425 return ui::win::ScreenToDIPRect( |
| 409 GetNativeView()).work_area(); | 426 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( |
| 427 GetNativeView()).work_area()); |
| 410 } | 428 } |
| 411 | 429 |
| 412 void NativeWidgetWin::SetInactiveRenderingDisabled(bool value) { | 430 void NativeWidgetWin::SetInactiveRenderingDisabled(bool value) { |
| 413 } | 431 } |
| 414 | 432 |
| 415 Widget::MoveLoopResult NativeWidgetWin::RunMoveLoop( | 433 Widget::MoveLoopResult NativeWidgetWin::RunMoveLoop( |
| 416 const gfx::Vector2d& drag_offset, | 434 const gfx::Vector2d& drag_offset, |
| 417 Widget::MoveLoopSource source) { | 435 Widget::MoveLoopSource source) { |
| 418 return message_handler_->RunMoveLoop(drag_offset) ? | 436 return message_handler_->RunMoveLoop(drag_offset) ? |
| 419 Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED; | 437 Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 544 |
| 527 int NativeWidgetWin::GetInitialShowState() const { | 545 int NativeWidgetWin::GetInitialShowState() const { |
| 528 return SW_SHOWNORMAL; | 546 return SW_SHOWNORMAL; |
| 529 } | 547 } |
| 530 | 548 |
| 531 bool NativeWidgetWin::WillProcessWorkAreaChange() const { | 549 bool NativeWidgetWin::WillProcessWorkAreaChange() const { |
| 532 return GetWidget()->widget_delegate()->WillProcessWorkAreaChange(); | 550 return GetWidget()->widget_delegate()->WillProcessWorkAreaChange(); |
| 533 } | 551 } |
| 534 | 552 |
| 535 int NativeWidgetWin::GetNonClientComponent(const gfx::Point& point) const { | 553 int NativeWidgetWin::GetNonClientComponent(const gfx::Point& point) const { |
| 536 return delegate_->GetNonClientComponent(point); | 554 gfx::Point point_in_dip = ui::win::ScreenToDIPPoint(point); |
| 555 return delegate_->GetNonClientComponent(point_in_dip); |
| 537 } | 556 } |
| 538 | 557 |
| 539 void NativeWidgetWin::GetWindowMask(const gfx::Size& size, gfx::Path* path) { | 558 void NativeWidgetWin::GetWindowMask(const gfx::Size& size, gfx::Path* path) { |
| 540 if (GetWidget()->non_client_view()) | 559 if (GetWidget()->non_client_view()) |
| 541 GetWidget()->non_client_view()->GetWindowMask(size, path); | 560 GetWidget()->non_client_view()->GetWindowMask(size, path); |
| 542 } | 561 } |
| 543 | 562 |
| 544 bool NativeWidgetWin::GetClientAreaInsets(gfx::Insets* insets) const { | 563 bool NativeWidgetWin::GetClientAreaInsets(gfx::Insets* insets) const { |
| 545 return false; | 564 return false; |
| 546 } | 565 } |
| 547 | 566 |
| 548 void NativeWidgetWin::GetMinMaxSize(gfx::Size* min_size, | 567 void NativeWidgetWin::GetMinMaxSize(gfx::Size* min_size, |
| 549 gfx::Size* max_size) const { | 568 gfx::Size* max_size) const { |
| 550 *min_size = delegate_->GetMinimumSize(); | 569 *min_size = ui::win::ScreenToDIPSize(delegate_->GetMinimumSize()); |
| 551 *max_size = delegate_->GetMaximumSize(); | 570 *max_size = ui::win::ScreenToDIPSize(delegate_->GetMaximumSize()); |
| 552 } | 571 } |
| 553 | 572 |
| 554 gfx::Size NativeWidgetWin::GetRootViewSize() const { | 573 gfx::Size NativeWidgetWin::GetRootViewSize() const { |
| 555 return GetWidget()->GetRootView()->size(); | 574 gfx::Size pixel_size = GetWidget()->GetRootView()->size(); |
| 575 return ui::win::ScreenToDIPSize(pixel_size); |
| 556 } | 576 } |
| 557 | 577 |
| 558 void NativeWidgetWin::ResetWindowControls() { | 578 void NativeWidgetWin::ResetWindowControls() { |
| 559 GetWidget()->non_client_view()->ResetWindowControls(); | 579 GetWidget()->non_client_view()->ResetWindowControls(); |
| 560 } | 580 } |
| 561 | 581 |
| 562 void NativeWidgetWin::PaintLayeredWindow(gfx::Canvas* canvas) { | 582 void NativeWidgetWin::PaintLayeredWindow(gfx::Canvas* canvas) { |
| 563 GetWidget()->GetRootView()->Paint(canvas); | 583 GetWidget()->GetRootView()->Paint(canvas); |
| 564 } | 584 } |
| 565 | 585 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 700 |
| 681 void NativeWidgetWin::HandleWorkAreaChanged() { | 701 void NativeWidgetWin::HandleWorkAreaChanged() { |
| 682 GetWidget()->widget_delegate()->OnWorkAreaChanged(); | 702 GetWidget()->widget_delegate()->OnWorkAreaChanged(); |
| 683 } | 703 } |
| 684 | 704 |
| 685 void NativeWidgetWin::HandleVisibilityChanged(bool visible) { | 705 void NativeWidgetWin::HandleVisibilityChanged(bool visible) { |
| 686 delegate_->OnNativeWidgetVisibilityChanged(visible); | 706 delegate_->OnNativeWidgetVisibilityChanged(visible); |
| 687 } | 707 } |
| 688 | 708 |
| 689 void NativeWidgetWin::HandleClientSizeChanged(const gfx::Size& new_size) { | 709 void NativeWidgetWin::HandleClientSizeChanged(const gfx::Size& new_size) { |
| 690 delegate_->OnNativeWidgetSizeChanged(new_size); | 710 gfx::Size size_in_dip = ui::win::ScreenToDIPSize(new_size); |
| 711 delegate_->OnNativeWidgetSizeChanged(size_in_dip); |
| 691 } | 712 } |
| 692 | 713 |
| 693 void NativeWidgetWin::HandleFrameChanged() { | 714 void NativeWidgetWin::HandleFrameChanged() { |
| 694 // Replace the frame and layout the contents. | 715 // Replace the frame and layout the contents. |
| 695 GetWidget()->non_client_view()->UpdateFrame(true); | 716 GetWidget()->non_client_view()->UpdateFrame(true); |
| 696 } | 717 } |
| 697 | 718 |
| 698 void NativeWidgetWin::HandleNativeFocus(HWND last_focused_window) { | 719 void NativeWidgetWin::HandleNativeFocus(HWND last_focused_window) { |
| 699 delegate_->OnNativeFocus(last_focused_window); | 720 delegate_->OnNativeFocus(last_focused_window); |
| 700 InputMethod* input_method = GetInputMethod(); | 721 InputMethod* input_method = GetInputMethod(); |
| 701 if (input_method) | 722 if (input_method) |
| 702 input_method->OnFocus(); | 723 input_method->OnFocus(); |
| 703 } | 724 } |
| 704 | 725 |
| 705 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { | 726 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { |
| 706 delegate_->OnNativeBlur(focused_window); | 727 delegate_->OnNativeBlur(focused_window); |
| 707 InputMethod* input_method = GetInputMethod(); | 728 InputMethod* input_method = GetInputMethod(); |
| 708 if (input_method) | 729 if (input_method) |
| 709 input_method->OnBlur(); | 730 input_method->OnBlur(); |
| 710 } | 731 } |
| 711 | 732 |
| 712 bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { | 733 bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { |
| 713 delegate_->OnMouseEvent(const_cast<ui::MouseEvent*>(&event)); | 734 ui::MouseEvent dpi_event(event); |
| 714 return event.handled(); | 735 dpi_event.set_location(ui::win::ScreenToDIPPoint(event.location())); |
| 736 dpi_event.set_root_location(ui::win::ScreenToDIPPoint(event.location())); |
| 737 delegate_->OnMouseEvent(&dpi_event); |
| 738 return dpi_event.handled(); |
| 715 } | 739 } |
| 716 | 740 |
| 717 bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { | 741 bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { |
| 718 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&event)); | 742 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&event)); |
| 719 return event.handled(); | 743 return event.handled(); |
| 720 } | 744 } |
| 721 | 745 |
| 722 bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { | 746 bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { |
| 723 InputMethod* input_method = GetInputMethod(); | 747 InputMethod* input_method = GetInputMethod(); |
| 724 if (input_method) | 748 if (input_method) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 750 void NativeWidgetWin::HandleInputLanguageChange(DWORD character_set, | 774 void NativeWidgetWin::HandleInputLanguageChange(DWORD character_set, |
| 751 HKL input_language_id) { | 775 HKL input_language_id) { |
| 752 InputMethod* input_method = GetInputMethod(); | 776 InputMethod* input_method = GetInputMethod(); |
| 753 if (input_method && !input_method->IsMock()) { | 777 if (input_method && !input_method->IsMock()) { |
| 754 static_cast<InputMethodWin*>(input_method)->OnInputLangChange( | 778 static_cast<InputMethodWin*>(input_method)->OnInputLangChange( |
| 755 character_set, input_language_id); | 779 character_set, input_language_id); |
| 756 } | 780 } |
| 757 } | 781 } |
| 758 | 782 |
| 759 bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) { | 783 bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) { |
| 760 return delegate_->OnNativeWidgetPaintAccelerated(gfx::Rect(invalid_rect)); | 784 gfx::Rect dpi_rect = ui::win::ScreenToDIPRect(invalid_rect); |
| 785 return delegate_->OnNativeWidgetPaintAccelerated(dpi_rect); |
| 761 } | 786 } |
| 762 | 787 |
| 763 void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) { | 788 void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) { |
| 764 delegate_->OnNativeWidgetPaint(canvas); | 789 delegate_->OnNativeWidgetPaint(canvas); |
| 765 } | 790 } |
| 766 | 791 |
| 767 bool NativeWidgetWin::HandleTooltipNotify(int w_param, | 792 bool NativeWidgetWin::HandleTooltipNotify(int w_param, |
| 768 NMHDR* l_param, | 793 NMHDR* l_param, |
| 769 LRESULT* l_result) { | 794 LRESULT* l_result) { |
| 770 // We can be sent this message before the tooltip manager is created, if a | 795 // 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... |
| 839 gfx::Rect* rect) { | 864 gfx::Rect* rect) { |
| 840 DCHECK(source); | 865 DCHECK(source); |
| 841 DCHECK(target); | 866 DCHECK(target); |
| 842 DCHECK(rect); | 867 DCHECK(rect); |
| 843 | 868 |
| 844 HWND source_hwnd = source->GetNativeView(); | 869 HWND source_hwnd = source->GetNativeView(); |
| 845 HWND target_hwnd = target->GetNativeView(); | 870 HWND target_hwnd = target->GetNativeView(); |
| 846 if (source_hwnd == target_hwnd) | 871 if (source_hwnd == target_hwnd) |
| 847 return true; | 872 return true; |
| 848 | 873 |
| 849 RECT win_rect = rect->ToRECT(); | 874 RECT win_rect = ui::win::DIPToScreenRect(*rect).ToRECT(); |
| 850 if (::MapWindowPoints(source_hwnd, target_hwnd, | 875 if (::MapWindowPoints(source_hwnd, target_hwnd, |
| 851 reinterpret_cast<LPPOINT>(&win_rect), | 876 reinterpret_cast<LPPOINT>(&win_rect), |
| 852 sizeof(RECT)/sizeof(POINT))) { | 877 sizeof(RECT)/sizeof(POINT))) { |
| 853 *rect = gfx::Rect(win_rect); | 878 *rect = ui::win::ScreenToDIPRect(gfx::Rect(win_rect)); |
| 854 return true; | 879 return true; |
| 855 } | 880 } |
| 856 return false; | 881 return false; |
| 857 } | 882 } |
| 858 | 883 |
| 859 namespace internal { | 884 namespace internal { |
| 860 | 885 |
| 861 //////////////////////////////////////////////////////////////////////////////// | 886 //////////////////////////////////////////////////////////////////////////////// |
| 862 // internal::NativeWidgetPrivate, public: | 887 // internal::NativeWidgetPrivate, public: |
| 863 | 888 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 // static | 1000 // static |
| 976 bool NativeWidgetPrivate::IsTouchDown() { | 1001 bool NativeWidgetPrivate::IsTouchDown() { |
| 977 // This currently isn't necessary because we're not generating touch events on | 1002 // This currently isn't necessary because we're not generating touch events on |
| 978 // windows. When we do, this will need to be updated. | 1003 // windows. When we do, this will need to be updated. |
| 979 return false; | 1004 return false; |
| 980 } | 1005 } |
| 981 | 1006 |
| 982 } // namespace internal | 1007 } // namespace internal |
| 983 | 1008 |
| 984 } // namespace views | 1009 } // namespace views |
| OLD | NEW |