diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-31 20:40:03 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-31 20:40:03 +0000 |
commit | 55a13c949c4857dedbdfcc190fe7996ed29b3b7d (patch) | |
tree | e5b663806b1eb4efc33afcbdfed0476bdb991a21 /ui | |
parent | 8562e13f99371ad1dacbb3393e2957b3a4098cc9 (diff) | |
download | chromium_src-55a13c949c4857dedbdfcc190fe7996ed29b3b7d.zip chromium_src-55a13c949c4857dedbdfcc190fe7996ed29b3b7d.tar.gz chromium_src-55a13c949c4857dedbdfcc190fe7996ed29b3b7d.tar.bz2 |
Make HWNDMessageHandler build with use_aura==1
http://crbug.com/142962
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10918015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.gyp | 2 | ||||
-rw-r--r-- | ui/views/views.gyp | 11 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 47 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.h | 7 | ||||
-rw-r--r-- | ui/views/win/DEPS | 1 | ||||
-rw-r--r-- | ui/views/win/hwnd_message_handler.cc | 82 | ||||
-rw-r--r-- | ui/views/win/hwnd_message_handler.h | 3 | ||||
-rw-r--r-- | ui/views/win/hwnd_message_handler_delegate.h | 20 |
8 files changed, 108 insertions, 65 deletions
@@ -519,8 +519,6 @@ ['exclude', 'base/dialogs/select_file_dialog_mac.mm'], ['exclude', 'base/dialogs/select_file_dialog_win.cc'], ['exclude', 'base/dragdrop/drag_utils_win.cc'], - ['exclude', 'base/win/mouse_wheel_util.cc'], - ['exclude', 'base/win/mouse_wheel_util.h'], ['exclude', 'base/work_area_watcher_observer.h'], ['exclude', 'base/x/active_window_watcher_x.cc'], ['exclude', 'base/x/active_window_watcher_x.h'], diff --git a/ui/views/views.gyp b/ui/views/views.gyp index 20f49ce..12f7551 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -453,17 +453,6 @@ 'widget/widget_message_filter.h', ], }], - ['use_aura==1 or OS!="win"', { - 'sources!': [ - 'win/fullscreen_handler.cc', - 'win/fullscreen_handler.h', - 'win/hwnd_message_handler.cc', - 'win/hwnd_message_handler.h', - 'win/hwnd_message_handler_delegate.h', - 'win/scoped_fullscreen_visibility.cc', - 'win/scoped_fullscreen_visibility.h', - ], - }], ['OS!="win"', { 'sources!': [ 'win/fullscreen_handler.cc', diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 190e10c..fbb62fa 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -249,7 +249,12 @@ bool NativeWidgetWin::HasCapture() const { } InputMethod* NativeWidgetWin::CreateInputMethod() { - return message_handler_->CreateInputMethod(); +#if !defined(USE_AURA) + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (!command_line->HasSwitch(switches::kEnableViewsTextfield)) + return NULL; +#endif + return new InputMethodWin(GetMessageHandler()); } internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() { @@ -470,7 +475,7 @@ void NativeWidgetWin::FocusNativeView(gfx::NativeView native_view) { } gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const { - return message_handler_->GetWorkAreaBoundsInScreen(); + return gfx::Screen::GetDisplayNearestWindow(GetNativeView()).work_area(); } void NativeWidgetWin::SetInactiveRenderingDisabled(bool value) { @@ -746,10 +751,16 @@ void NativeWidgetWin::HandleFrameChanged() { void NativeWidgetWin::HandleNativeFocus(HWND last_focused_window) { delegate_->OnNativeFocus(last_focused_window); + InputMethod* input_method = GetInputMethod(); + if (input_method) + input_method->OnFocus(); } void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { delegate_->OnNativeBlur(focused_window); + InputMethod* input_method = GetInputMethod(); + if (input_method) + input_method->OnBlur(); } bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { @@ -760,6 +771,38 @@ bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { return delegate_->OnKeyEvent(event); } +bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { + InputMethod* input_method = GetInputMethod(); + if (input_method) + input_method->DispatchKeyEvent(event); + return !!input_method; +} + +bool NativeWidgetWin::HandleIMEMessage(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) { + InputMethod* input_method = GetInputMethod(); + if (!input_method || input_method->IsMock()) { + *result = 0; + return false; + } + + InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method); + BOOL handled = FALSE; + *result = ime_win->OnImeMessages(message, w_param, l_param, &handled); + return !!handled; +} + +void NativeWidgetWin::HandleInputLanguageChange(DWORD character_set, + HKL input_language_id) { + InputMethod* input_method = GetInputMethod(); + if (input_method && !input_method->IsMock()) { + static_cast<InputMethodWin*>(input_method)->OnInputLangChange( + character_set, input_language_id); + } +} + bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) { return delegate_->OnNativeWidgetPaintAccelerated(gfx::Rect(invalid_rect)); } diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h index a8baf32..bb65868 100644 --- a/ui/views/widget/native_widget_win.h +++ b/ui/views/widget/native_widget_win.h @@ -229,6 +229,13 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, virtual void HandleNativeBlur(HWND focused_window) OVERRIDE; virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE; virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; + virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) OVERRIDE; + virtual bool HandleIMEMessage(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) OVERRIDE; + virtual void HandleInputLanguageChange(DWORD character_set, + HKL input_language_id) OVERRIDE; virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) OVERRIDE; virtual void HandlePaint(gfx::Canvas* canvas) OVERRIDE; virtual void HandleScreenReaderDetected() OVERRIDE; diff --git a/ui/views/win/DEPS b/ui/views/win/DEPS index b3efd79..01bf1a1 100644 --- a/ui/views/win/DEPS +++ b/ui/views/win/DEPS @@ -8,7 +8,6 @@ include_rules = [ "+ui/gfx", "+ui/views/accessibility/native_view_accessibility_win.h", "+ui/views/ime/input_method_delegate.h", - "+ui/views/ime/input_method_win.h", "+ui/views/views_delegate.h", "+ui/views/views_export.h", "+ui/views/widget/child_window_message_processor.h", diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index 86bc878..f606669 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -23,10 +23,7 @@ #include "ui/gfx/insets.h" #include "ui/gfx/path.h" #include "ui/gfx/screen.h" -#include "ui/views/accessibility/native_view_accessibility_win.h" -#include "ui/views/ime/input_method_win.h" #include "ui/views/views_delegate.h" -#include "ui/views/widget/child_window_message_processor.h" #include "ui/views/widget/monitor_win.h" #include "ui/views/widget/native_widget_win.h" #include "ui/views/widget/widget_hwnd_utils.h" @@ -35,8 +32,8 @@ #include "ui/views/win/scoped_fullscreen_visibility.h" #if !defined(USE_AURA) -#include "base/command_line.h" -#include "ui/base/ui_base_switches.h" +#include "ui/views/accessibility/native_view_accessibility_win.h" +#include "ui/views/widget/child_window_message_processor.h" #endif namespace views { @@ -189,12 +186,15 @@ struct FindOwnedWindowsData { }; BOOL CALLBACK FindOwnedWindowsCallback(HWND hwnd, LPARAM param) { + // TODO(beng): resolve wrt aura. +#if !defined(USE_AURA) FindOwnedWindowsData* data = reinterpret_cast<FindOwnedWindowsData*>(param); if (GetWindow(hwnd, GW_OWNER) == data->window) { Widget* widget = Widget::GetWidgetForNativeView(hwnd); if (widget) data->owned_widgets.push_back(widget); } +#endif return TRUE; } @@ -239,6 +239,8 @@ static BOOL CALLBACK ClipDCToChild(HWND window, LPARAM param) { return TRUE; } +#if !defined(USE_AURA) + // Get the source HWND of the specified message. Depending on the message, the // source HWND is encoded in either the WPARAM or the LPARAM value. HWND GetControlHWNDForMessage(UINT message, WPARAM w_param, LPARAM l_param) { @@ -283,6 +285,8 @@ bool ProcessChildWindowMessage(UINT message, return false; } +#endif + // A custom MSAA object id used to determine if a screen reader is actively // listening for MSAA events. const int kCustomObjectID = 1; @@ -507,10 +511,6 @@ void HWNDMessageHandler::GetWindowPlacement( } } -gfx::Rect HWNDMessageHandler::GetWorkAreaBoundsInScreen() const { - return gfx::Screen::GetDisplayNearestWindow(hwnd()).work_area(); -} - void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds) { LONG style = GetWindowLong(hwnd(), GWL_STYLE); if (style & WS_MAXIMIZE) @@ -734,30 +734,26 @@ void HWNDMessageHandler::SetVisibilityChangedAnimationsEnabled(bool enabled) { } } -InputMethod* HWNDMessageHandler::CreateInputMethod() { -#if !defined(USE_AURA) - CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (!command_line->HasSwitch(switches::kEnableViewsTextfield)) - return NULL; -#endif - return new InputMethodWin(this); -} - void HWNDMessageHandler::SetTitle(const string16& title) { SetWindowText(hwnd(), title.c_str()); SetAccessibleName(title); } void HWNDMessageHandler::SetAccessibleName(const string16& name) { + // TODO(beng): figure out vis-a-vis aura. +#if !defined(USE_AURA) base::win::ScopedComPtr<IAccPropServices> pAccPropServices; HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); if (SUCCEEDED(hr)) hr = pAccPropServices->SetHwndPropStr(hwnd(), OBJID_CLIENT, CHILDID_SELF, PROPID_ACC_NAME, name.c_str()); +#endif } void HWNDMessageHandler::SetAccessibleRole(ui::AccessibilityTypes::Role role) { + // TODO(beng): figure out vis-a-vis aura. +#if !defined(USE_AURA) base::win::ScopedComPtr<IAccPropServices> pAccPropServices; HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); @@ -770,10 +766,13 @@ void HWNDMessageHandler::SetAccessibleRole(ui::AccessibilityTypes::Role role) { PROPID_ACC_ROLE, var); } } +#endif } void HWNDMessageHandler::SetAccessibleState( ui::AccessibilityTypes::State state) { + // TODO(beng): figure out vis-a-vis aura. +#if !defined(USE_AURA) base::win::ScopedComPtr<IAccPropServices> pAccPropServices; HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); @@ -786,11 +785,14 @@ void HWNDMessageHandler::SetAccessibleState( PROPID_ACC_STATE, var); } } +#endif } void HWNDMessageHandler::SendNativeAccessibilityEvent( int id, ui::AccessibilityTypes::Event event_type) { + // TODO(beng): figure out vis-a-vis aura. +#if !defined(USE_AURA) // Now call the Windows-specific method to notify MSAA clients of this // event. The widget gives us a temporary unique child ID to associate // with this view so that clients can call get_accChild in @@ -798,6 +800,7 @@ void HWNDMessageHandler::SendNativeAccessibilityEvent( // with this view. ::NotifyWinEvent(NativeViewAccessibilityWin::MSAAEvent(event_type), hwnd(), OBJID_CLIENT, id); +#endif } void HWNDMessageHandler::SetCursor(HCURSOR cursor) { @@ -909,11 +912,13 @@ LRESULT HWNDMessageHandler::OnWndProc(UINT message, if (delegate_->PreHandleMSG(message, w_param, l_param, &result)) return result; +#if !defined(USE_AURA) // First allow messages sent by child controls to be processed directly by // their associated views. If such a view is present, it will handle the // message *instead of* this NativeWidgetWin. if (ProcessChildWindowMessage(message, w_param, l_param, &result)) return result; +#endif // Otherwise we handle everything else. if (!ProcessWindowMessage(window, message, w_param, l_param, result)) @@ -1114,7 +1119,10 @@ void HWNDMessageHandler::ResetWindowRegion(bool force) { gfx::Path window_mask; delegate_->GetWindowMask( gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask); + // TODO(beng): resolve wrt aura. +#if !defined(USE_AURA) new_region = window_mask.CreateNativeRegion(); +#endif } if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { @@ -1396,16 +1404,9 @@ LRESULT HWNDMessageHandler::OnGetObject(UINT message, LRESULT HWNDMessageHandler::OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param) { - InputMethod* input_method = delegate_->GetInputMethod(); - if (!input_method || input_method->IsMock()) { - SetMsgHandled(FALSE); - return 0; - } - - InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method); - BOOL handled = FALSE; - LRESULT result = ime_win->OnImeMessages(message, w_param, l_param, &handled); - SetMsgHandled(handled); + LRESULT result = 0; + SetMsgHandled(delegate_->HandleIMEMessage( + message, w_param, l_param, &result)); return result; } @@ -1427,32 +1428,22 @@ void HWNDMessageHandler::OnInitMenu(HMENU menu) { void HWNDMessageHandler::OnInputLangChange(DWORD character_set, HKL input_language_id) { - InputMethod* input_method = delegate_->GetInputMethod(); - if (input_method && !input_method->IsMock()) { - static_cast<InputMethodWin*>(input_method)->OnInputLangChange( - character_set, input_language_id); - } + delegate_->HandleInputLanguageChange(character_set, input_language_id); } LRESULT HWNDMessageHandler::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { + MSG msg = { hwnd(), message, w_param, l_param }; ui::KeyEvent key(msg, message == WM_CHAR); - InputMethod* input_method = delegate_->GetInputMethod(); - if (input_method) - input_method->DispatchKeyEvent(key); - else + if (!delegate_->HandleUntranslatedKeyEvent(key)) DispatchKeyEventPostIME(key); return 0; } void HWNDMessageHandler::OnKillFocus(HWND focused_window) { delegate_->HandleNativeBlur(focused_window); - - InputMethod* input_method = delegate_->GetInputMethod(); - if (input_method) - input_method->OnBlur(); SetMsgHandled(FALSE); } @@ -1839,9 +1830,12 @@ void HWNDMessageHandler::OnPaint(HDC dc) { if (delegate_->HandlePaintAccelerated(gfx::Rect(dirty_rect))) { ValidateRect(hwnd(), NULL); } else { + // TODO(beng): resolve vis-a-vis aura +#if !defined(USE_AURA) scoped_ptr<gfx::CanvasPaint> canvas( gfx::CanvasPaint::CreateCanvasPaint(hwnd())); delegate_->HandlePaint(canvas->AsCanvas()); +#endif } } else { // TODO(msw): Find a better solution for this crbug.com/93530 workaround. @@ -1878,9 +1872,6 @@ LRESULT HWNDMessageHandler::OnSetCursor(UINT message, void HWNDMessageHandler::OnSetFocus(HWND last_focused_window) { delegate_->HandleNativeFocus(last_focused_window); - InputMethod* input_method = delegate_->GetInputMethod(); - if (input_method) - input_method->OnFocus(); SetMsgHandled(FALSE); } @@ -1972,7 +1963,10 @@ void HWNDMessageHandler::OnSysCommand(UINT notification_code, } void HWNDMessageHandler::OnThemeChanged() { + // TODO(beng): resolve vis-a-vis aura. +#if !defined(USE_AURA) ui::NativeThemeWin::instance()->CloseHandles(); +#endif } LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h index 940bbf0..7f73b2b 100644 --- a/ui/views/win/hwnd_message_handler.h +++ b/ui/views/win/hwnd_message_handler.h @@ -75,7 +75,6 @@ class VIEWS_EXPORT HWNDMessageHandler : public ui::WindowImpl, gfx::Rect GetRestoredBounds() const; void GetWindowPlacement(gfx::Rect* bounds, ui::WindowShowState* show_state) const; - gfx::Rect GetWorkAreaBoundsInScreen() const; void SetBounds(const gfx::Rect& bounds); void SetSize(const gfx::Size& size); @@ -126,8 +125,6 @@ class VIEWS_EXPORT HWNDMessageHandler : public ui::WindowImpl, void SetVisibilityChangedAnimationsEnabled(bool enabled); - InputMethod* CreateInputMethod(); - void SetTitle(const string16& title); void SetAccessibleName(const string16& name); diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h index 9dddce5..6d3826e 100644 --- a/ui/views/win/hwnd_message_handler_delegate.h +++ b/ui/views/win/hwnd_message_handler_delegate.h @@ -156,10 +156,26 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { // handled by the delegate. virtual bool HandleMouseEvent(const ui::MouseEvent& event) = 0; - // Called when a key event is received. Returns true if the event was handled - // by the delegate. + // Called when a translated key event is received (i.e. post IME translation.) + // Returns true if the event was handled by the delegate. virtual bool HandleKeyEvent(const ui::KeyEvent& event) = 0; + // Called when an untranslated key event is received (i.e. pre-IME + // translation). Returns true if the event was sent to the input method. + virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) = 0; + + // Called when an IME message needs to be processed by the delegate. Returns + // true if the event was handled and no default processing should be + // performed. + virtual bool HandleIMEMessage(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) = 0; + + // Called when the system input language changes. + virtual void HandleInputLanguageChange(DWORD character_set, + HKL input_language_id) = 0; + // Called to compel the delegate to paint |invalid_rect| accelerated. Returns // true if accelerated painting was performed. virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) = 0; |