| 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> |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 void NativeWidgetWin::ReleaseCapture() { | 243 void NativeWidgetWin::ReleaseCapture() { |
| 244 message_handler_->ReleaseCapture(); | 244 message_handler_->ReleaseCapture(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool NativeWidgetWin::HasCapture() const { | 247 bool NativeWidgetWin::HasCapture() const { |
| 248 return message_handler_->HasCapture(); | 248 return message_handler_->HasCapture(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 InputMethod* NativeWidgetWin::CreateInputMethod() { | 251 InputMethod* NativeWidgetWin::CreateInputMethod() { |
| 252 return message_handler_->CreateInputMethod(); | 252 #if !defined(USE_AURA) |
| 253 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 254 if (!command_line->HasSwitch(switches::kEnableViewsTextfield)) |
| 255 return NULL; |
| 256 #endif |
| 257 return new InputMethodWin(GetMessageHandler()); |
| 253 } | 258 } |
| 254 | 259 |
| 255 internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() { | 260 internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() { |
| 256 return message_handler_.get(); | 261 return message_handler_.get(); |
| 257 } | 262 } |
| 258 | 263 |
| 259 void NativeWidgetWin::CenterWindow(const gfx::Size& size) { | 264 void NativeWidgetWin::CenterWindow(const gfx::Size& size) { |
| 260 message_handler_->CenterWindow(size); | 265 message_handler_->CenterWindow(size); |
| 261 } | 266 } |
| 262 | 267 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 468 |
| 464 void NativeWidgetWin::ClearNativeFocus() { | 469 void NativeWidgetWin::ClearNativeFocus() { |
| 465 message_handler_->ClearNativeFocus(); | 470 message_handler_->ClearNativeFocus(); |
| 466 } | 471 } |
| 467 | 472 |
| 468 void NativeWidgetWin::FocusNativeView(gfx::NativeView native_view) { | 473 void NativeWidgetWin::FocusNativeView(gfx::NativeView native_view) { |
| 469 message_handler_->FocusHWND(native_view); | 474 message_handler_->FocusHWND(native_view); |
| 470 } | 475 } |
| 471 | 476 |
| 472 gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const { | 477 gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const { |
| 473 return message_handler_->GetWorkAreaBoundsInScreen(); | 478 return gfx::Screen::GetDisplayNearestWindow(GetNativeView()).work_area(); |
| 474 } | 479 } |
| 475 | 480 |
| 476 void NativeWidgetWin::SetInactiveRenderingDisabled(bool value) { | 481 void NativeWidgetWin::SetInactiveRenderingDisabled(bool value) { |
| 477 } | 482 } |
| 478 | 483 |
| 479 Widget::MoveLoopResult NativeWidgetWin::RunMoveLoop( | 484 Widget::MoveLoopResult NativeWidgetWin::RunMoveLoop( |
| 480 const gfx::Point& drag_offset) { | 485 const gfx::Point& drag_offset) { |
| 481 return message_handler_->RunMoveLoop(drag_offset) ? | 486 return message_handler_->RunMoveLoop(drag_offset) ? |
| 482 Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED; | 487 Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED; |
| 483 } | 488 } |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 void NativeWidgetWin::HandleClientSizeChanged(const gfx::Size& new_size) { | 744 void NativeWidgetWin::HandleClientSizeChanged(const gfx::Size& new_size) { |
| 740 delegate_->OnNativeWidgetSizeChanged(new_size); | 745 delegate_->OnNativeWidgetSizeChanged(new_size); |
| 741 } | 746 } |
| 742 | 747 |
| 743 void NativeWidgetWin::HandleFrameChanged() { | 748 void NativeWidgetWin::HandleFrameChanged() { |
| 744 GetWidget()->non_client_view()->UpdateFrame(); | 749 GetWidget()->non_client_view()->UpdateFrame(); |
| 745 } | 750 } |
| 746 | 751 |
| 747 void NativeWidgetWin::HandleNativeFocus(HWND last_focused_window) { | 752 void NativeWidgetWin::HandleNativeFocus(HWND last_focused_window) { |
| 748 delegate_->OnNativeFocus(last_focused_window); | 753 delegate_->OnNativeFocus(last_focused_window); |
| 754 InputMethod* input_method = GetInputMethod(); |
| 755 if (input_method) |
| 756 input_method->OnFocus(); |
| 749 } | 757 } |
| 750 | 758 |
| 751 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { | 759 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { |
| 752 delegate_->OnNativeBlur(focused_window); | 760 delegate_->OnNativeBlur(focused_window); |
| 761 InputMethod* input_method = GetInputMethod(); |
| 762 if (input_method) |
| 763 input_method->OnBlur(); |
| 753 } | 764 } |
| 754 | 765 |
| 755 bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { | 766 bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { |
| 756 return delegate_->OnMouseEvent(event); | 767 return delegate_->OnMouseEvent(event); |
| 757 } | 768 } |
| 758 | 769 |
| 759 bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { | 770 bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { |
| 760 return delegate_->OnKeyEvent(event); | 771 return delegate_->OnKeyEvent(event); |
| 761 } | 772 } |
| 762 | 773 |
| 774 bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { |
| 775 InputMethod* input_method = GetInputMethod(); |
| 776 if (input_method) |
| 777 input_method->DispatchKeyEvent(event); |
| 778 return !!input_method; |
| 779 } |
| 780 |
| 781 bool NativeWidgetWin::HandleIMEMessage(UINT message, |
| 782 WPARAM w_param, |
| 783 LPARAM l_param, |
| 784 LRESULT* result) { |
| 785 InputMethod* input_method = GetInputMethod(); |
| 786 if (!input_method || input_method->IsMock()) { |
| 787 *result = 0; |
| 788 return false; |
| 789 } |
| 790 |
| 791 InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method); |
| 792 BOOL handled = FALSE; |
| 793 *result = ime_win->OnImeMessages(message, w_param, l_param, &handled); |
| 794 return !!handled; |
| 795 } |
| 796 |
| 797 void NativeWidgetWin::HandleInputLanguageChange(DWORD character_set, |
| 798 HKL input_language_id) { |
| 799 InputMethod* input_method = GetInputMethod(); |
| 800 if (input_method && !input_method->IsMock()) { |
| 801 static_cast<InputMethodWin*>(input_method)->OnInputLangChange( |
| 802 character_set, input_language_id); |
| 803 } |
| 804 } |
| 805 |
| 763 bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) { | 806 bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) { |
| 764 return delegate_->OnNativeWidgetPaintAccelerated(gfx::Rect(invalid_rect)); | 807 return delegate_->OnNativeWidgetPaintAccelerated(gfx::Rect(invalid_rect)); |
| 765 } | 808 } |
| 766 | 809 |
| 767 void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) { | 810 void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) { |
| 768 delegate_->OnNativeWidgetPaint(canvas); | 811 delegate_->OnNativeWidgetPaint(canvas); |
| 769 } | 812 } |
| 770 | 813 |
| 771 void NativeWidgetWin::HandleScreenReaderDetected() { | 814 void NativeWidgetWin::HandleScreenReaderDetected() { |
| 772 // TODO(beng): just consolidate this with OnScreenReaderDetected. | 815 // TODO(beng): just consolidate this with OnScreenReaderDetected. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 // static | 1105 // static |
| 1063 bool NativeWidgetPrivate::IsTouchDown() { | 1106 bool NativeWidgetPrivate::IsTouchDown() { |
| 1064 // This currently isn't necessary because we're not generating touch events on | 1107 // This currently isn't necessary because we're not generating touch events on |
| 1065 // windows. When we do, this will need to be updated. | 1108 // windows. When we do, this will need to be updated. |
| 1066 return false; | 1109 return false; |
| 1067 } | 1110 } |
| 1068 | 1111 |
| 1069 } // namespace internal | 1112 } // namespace internal |
| 1070 | 1113 |
| 1071 } // namespace views | 1114 } // namespace views |
| OLD | NEW |