Commit 957d3972 authored by ben@chromium.org's avatar ben@chromium.org

Move more message handlers from NativeWidgetWin to HWNDMessageHandler.

Buildbots (not trybots) were giving grief on past iteration of this CL:
http://codereview.chromium.org/10832345/
... so I am splitting it into smaller pieces to help identify what piece was the cause.

http://crbug.com/142962
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10827422

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152370 0039d316-1c4b-4281-b951-d872f2087c98
parent 73a56652
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "ui/views/widget/hwnd_message_handler.h" #include "ui/views/widget/hwnd_message_handler.h"
#include "base/system_monitor/system_monitor.h"
#include "ui/base/native_theme/native_theme_win.h"
#include "ui/views/ime/input_method_win.h"
#include "ui/views/widget/hwnd_message_handler_delegate.h" #include "ui/views/widget/hwnd_message_handler_delegate.h"
#include "ui/views/widget/native_widget_win.h" #include "ui/views/widget/native_widget_win.h"
...@@ -113,9 +116,91 @@ void HWNDMessageHandler::OnExitSizeMove() { ...@@ -113,9 +116,91 @@ void HWNDMessageHandler::OnExitSizeMove() {
SetMsgHandled(FALSE); SetMsgHandled(FALSE);
} }
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);
return result;
}
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);
}
}
void HWNDMessageHandler::OnMove(const CPoint& point) {
delegate_->HandleMove();
SetMsgHandled(FALSE);
}
void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) {
delegate_->HandleMove();
}
LRESULT HWNDMessageHandler::OnNCUAHDrawCaption(UINT message,
WPARAM w_param,
LPARAM l_param) {
// See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
// an explanation about why we need to handle this message.
SetMsgHandled(delegate_->IsUsingCustomFrame());
return 0;
}
LRESULT HWNDMessageHandler::OnNCUAHDrawFrame(UINT message,
WPARAM w_param,
LPARAM l_param) {
// See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
// an explanation about why we need to handle this message.
SetMsgHandled(delegate_->IsUsingCustomFrame());
return 0;
}
LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) {
base::SystemMonitor* monitor = base::SystemMonitor::Get();
if (monitor)
monitor->ProcessWmPowerBroadcastMessage(power_event);
SetMsgHandled(FALSE);
return 0;
}
void HWNDMessageHandler::OnThemeChanged() {
ui::NativeThemeWin::instance()->CloseHandles();
}
void HWNDMessageHandler::OnVScroll(int scroll_type,
short position,
HWND scrollbar) {
SetMsgHandled(FALSE);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// HWNDMessageHandler, private: // HWNDMessageHandler, private:
HWND HWNDMessageHandler::hwnd() {
return delegate_->AsNativeWidgetWin()->hwnd();
}
LRESULT HWNDMessageHandler::DefWindowProcWithRedrawLock(UINT message,
WPARAM w_param,
LPARAM l_param) {
return delegate_->AsNativeWidgetWin()->DefWindowProcWithRedrawLock(message,
w_param,
l_param);
}
void HWNDMessageHandler::SetMsgHandled(BOOL handled) { void HWNDMessageHandler::SetMsgHandled(BOOL handled) {
delegate_->AsNativeWidgetWin()->SetMsgHandled(handled); delegate_->AsNativeWidgetWin()->SetMsgHandled(handled);
} }
......
...@@ -48,6 +48,15 @@ class VIEWS_EXPORT HWNDMessageHandler { ...@@ -48,6 +48,15 @@ class VIEWS_EXPORT HWNDMessageHandler {
LRESULT OnEraseBkgnd(HDC dc); LRESULT OnEraseBkgnd(HDC dc);
void OnExitMenuLoop(BOOL is_track_popup_menu); void OnExitMenuLoop(BOOL is_track_popup_menu);
void OnExitSizeMove(); void OnExitSizeMove();
LRESULT OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param);
void OnInputLangChange(DWORD character_set, HKL input_language_id);
void OnMove(const CPoint& point);
void OnMoving(UINT param, const RECT* new_bounds);
LRESULT OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param);
LRESULT OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param);
LRESULT OnPowerBroadcast(DWORD power_event, DWORD data);
void OnThemeChanged();
void OnVScroll(int scroll_type, short position, HWND scrollbar);
// TODO(beng): Can be removed once this object becomes the WindowImpl. // TODO(beng): Can be removed once this object becomes the WindowImpl.
bool remove_standard_frame() const { return remove_standard_frame_; } bool remove_standard_frame() const { return remove_standard_frame_; }
...@@ -56,6 +65,15 @@ class VIEWS_EXPORT HWNDMessageHandler { ...@@ -56,6 +65,15 @@ class VIEWS_EXPORT HWNDMessageHandler {
} }
private: private:
// TODO(beng): This won't be a style violation once this object becomes the
// WindowImpl.
HWND hwnd();
// TODO(beng): Remove once this class becomes the WindowImpl.
LRESULT DefWindowProcWithRedrawLock(UINT message,
WPARAM w_param,
LPARAM l_param);
// TODO(beng): Remove once this class becomes the WindowImpl. // TODO(beng): Remove once this class becomes the WindowImpl.
void SetMsgHandled(BOOL handled); void SetMsgHandled(BOOL handled);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
namespace views { namespace views {
class InputMethod;
class NativeWidgetWin; class NativeWidgetWin;
// Implemented by the object that uses the HWNDMessageHandler to handle // Implemented by the object that uses the HWNDMessageHandler to handle
...@@ -21,6 +22,8 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { ...@@ -21,6 +22,8 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate {
// to avoid confusion. // to avoid confusion.
virtual bool IsUsingCustomFrame() const = 0; virtual bool IsUsingCustomFrame() const = 0;
virtual InputMethod* GetInputMethod() = 0;
// TODO(beng): Investigate migrating these methods to On* prefixes once // TODO(beng): Investigate migrating these methods to On* prefixes once
// HWNDMessageHandler is the WindowImpl. // HWNDMessageHandler is the WindowImpl.
...@@ -55,6 +58,9 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { ...@@ -55,6 +58,9 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate {
virtual void HandleBeginWMSizeMove() = 0; virtual void HandleBeginWMSizeMove() = 0;
virtual void HandleEndWMSizeMove() = 0; virtual void HandleEndWMSizeMove() = 0;
// Called when the window's position changed.
virtual void HandleMove() = 0;
// This is provided for methods that need to call private methods on NWW. // This is provided for methods that need to call private methods on NWW.
// TODO(beng): should be removed once HWNDMessageHandler is the WindowImpl. // TODO(beng): should be removed once HWNDMessageHandler is the WindowImpl.
virtual NativeWidgetWin* AsNativeWidgetWin() = 0; virtual NativeWidgetWin* AsNativeWidgetWin() = 0;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/system_monitor/system_monitor.h"
#include "base/win/scoped_gdi_object.h" #include "base/win/scoped_gdi_object.h"
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
...@@ -22,7 +21,6 @@ ...@@ -22,7 +21,6 @@
#include "ui/base/event.h" #include "ui/base/event.h"
#include "ui/base/keycodes/keyboard_code_conversion_win.h" #include "ui/base/keycodes/keyboard_code_conversion_win.h"
#include "ui/base/l10n/l10n_util_win.h" #include "ui/base/l10n/l10n_util_win.h"
#include "ui/base/native_theme/native_theme_win.h"
#include "ui/base/theme_provider.h" #include "ui/base/theme_provider.h"
#include "ui/base/view_prop.h" #include "ui/base/view_prop.h"
#include "ui/base/win/hwnd_util.h" #include "ui/base/win/hwnd_util.h"
...@@ -1459,18 +1457,7 @@ void NativeWidgetWin::OnHScroll(int scroll_type, ...@@ -1459,18 +1457,7 @@ void NativeWidgetWin::OnHScroll(int scroll_type,
LRESULT NativeWidgetWin::OnImeMessages(UINT message, LRESULT NativeWidgetWin::OnImeMessages(UINT message,
WPARAM w_param, WPARAM w_param,
LPARAM l_param) { LPARAM l_param) {
InputMethod* input_method = GetWidget()->GetInputMethodDirect(); return message_handler_->OnImeMessages(message, w_param, l_param);
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);
return result;
} }
void NativeWidgetWin::OnInitMenu(HMENU menu) { void NativeWidgetWin::OnInitMenu(HMENU menu) {
...@@ -1500,12 +1487,7 @@ void NativeWidgetWin::OnInitMenuPopup(HMENU menu, ...@@ -1500,12 +1487,7 @@ void NativeWidgetWin::OnInitMenuPopup(HMENU menu,
void NativeWidgetWin::OnInputLangChange(DWORD character_set, void NativeWidgetWin::OnInputLangChange(DWORD character_set,
HKL input_language_id) { HKL input_language_id) {
InputMethod* input_method = GetWidget()->GetInputMethodDirect(); message_handler_->OnInputLangChange(character_set, input_language_id);
if (input_method && !input_method->IsMock()) {
static_cast<InputMethodWin*>(input_method)->OnInputLangChange(
character_set, input_language_id);
}
} }
LRESULT NativeWidgetWin::OnKeyEvent(UINT message, LRESULT NativeWidgetWin::OnKeyEvent(UINT message,
...@@ -1634,12 +1616,11 @@ LRESULT NativeWidgetWin::OnMouseRange(UINT message, ...@@ -1634,12 +1616,11 @@ LRESULT NativeWidgetWin::OnMouseRange(UINT message,
} }
void NativeWidgetWin::OnMove(const CPoint& point) { void NativeWidgetWin::OnMove(const CPoint& point) {
delegate_->OnNativeWidgetMove(); message_handler_->OnMove(point);
SetMsgHandled(FALSE);
} }
void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
delegate_->OnNativeWidgetMove(); message_handler_->OnMoving(param, new_bounds);
} }
LRESULT NativeWidgetWin::OnNCActivate(BOOL active) { LRESULT NativeWidgetWin::OnNCActivate(BOOL active) {
...@@ -1889,19 +1870,13 @@ void NativeWidgetWin::OnNCPaint(HRGN rgn) { ...@@ -1889,19 +1870,13 @@ void NativeWidgetWin::OnNCPaint(HRGN rgn) {
LRESULT NativeWidgetWin::OnNCUAHDrawCaption(UINT msg, LRESULT NativeWidgetWin::OnNCUAHDrawCaption(UINT msg,
WPARAM w_param, WPARAM w_param,
LPARAM l_param) { LPARAM l_param) {
// See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for return message_handler_->OnNCUAHDrawCaption(msg, w_param, l_param);
// an explanation about why we need to handle this message.
SetMsgHandled(!GetWidget()->ShouldUseNativeFrame());
return 0;
} }
LRESULT NativeWidgetWin::OnNCUAHDrawFrame(UINT msg, LRESULT NativeWidgetWin::OnNCUAHDrawFrame(UINT msg,
WPARAM w_param, WPARAM w_param,
LPARAM l_param) { LPARAM l_param) {
// See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for return message_handler_->OnNCUAHDrawFrame(msg, w_param, l_param);
// an explanation about why we need to handle this message.
SetMsgHandled(!GetWidget()->ShouldUseNativeFrame());
return 0;
} }
LRESULT NativeWidgetWin::OnNotify(int w_param, NMHDR* l_param) { LRESULT NativeWidgetWin::OnNotify(int w_param, NMHDR* l_param) {
...@@ -1939,11 +1914,7 @@ void NativeWidgetWin::OnPaint(HDC dc) { ...@@ -1939,11 +1914,7 @@ void NativeWidgetWin::OnPaint(HDC dc) {
} }
LRESULT NativeWidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) { LRESULT NativeWidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) {
base::SystemMonitor* monitor = base::SystemMonitor::Get(); return message_handler_->OnPowerBroadcast(power_event, data);
if (monitor)
monitor->ProcessWmPowerBroadcastMessage(power_event);
SetMsgHandled(FALSE);
return 0;
} }
LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg, LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg,
...@@ -2059,8 +2030,7 @@ void NativeWidgetWin::OnSysCommand(UINT notification_code, CPoint click) { ...@@ -2059,8 +2030,7 @@ void NativeWidgetWin::OnSysCommand(UINT notification_code, CPoint click) {
} }
void NativeWidgetWin::OnThemeChanged() { void NativeWidgetWin::OnThemeChanged() {
// Notify NativeThemeWin. message_handler_->OnThemeChanged();
ui::NativeThemeWin::instance()->CloseHandles();
} }
LRESULT NativeWidgetWin::OnTouchEvent(UINT message, LRESULT NativeWidgetWin::OnTouchEvent(UINT message,
...@@ -2085,7 +2055,7 @@ LRESULT NativeWidgetWin::OnTouchEvent(UINT message, ...@@ -2085,7 +2055,7 @@ LRESULT NativeWidgetWin::OnTouchEvent(UINT message,
void NativeWidgetWin::OnVScroll(int scroll_type, void NativeWidgetWin::OnVScroll(int scroll_type,
short position, short position,
HWND scrollbar) { HWND scrollbar) {
SetMsgHandled(FALSE); message_handler_->OnVScroll(scroll_type, position, scrollbar);
} }
void NativeWidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) { void NativeWidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
...@@ -2291,6 +2261,10 @@ bool NativeWidgetWin::IsUsingCustomFrame() const { ...@@ -2291,6 +2261,10 @@ bool NativeWidgetWin::IsUsingCustomFrame() const {
return GetWidget()->ShouldUseNativeFrame(); return GetWidget()->ShouldUseNativeFrame();
} }
InputMethod* NativeWidgetWin::GetInputMethod() {
return GetWidget()->GetInputMethodDirect();
}
void NativeWidgetWin::HandleAppDeactivated() { void NativeWidgetWin::HandleAppDeactivated() {
// Another application was activated, we should reset any state that // Another application was activated, we should reset any state that
// disables inactive rendering now. // disables inactive rendering now.
...@@ -2346,6 +2320,10 @@ void NativeWidgetWin::HandleEndWMSizeMove() { ...@@ -2346,6 +2320,10 @@ void NativeWidgetWin::HandleEndWMSizeMove() {
delegate_->OnNativeWidgetEndUserBoundsChange(); delegate_->OnNativeWidgetEndUserBoundsChange();
} }
void NativeWidgetWin::HandleMove() {
delegate_->OnNativeWidgetMove();
}
NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() { NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() {
return this; return this;
} }
......
...@@ -494,6 +494,7 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, ...@@ -494,6 +494,7 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
// Overridden from HWNDMessageHandlerDelegate: // Overridden from HWNDMessageHandlerDelegate:
virtual bool IsWidgetWindow() const OVERRIDE; virtual bool IsWidgetWindow() const OVERRIDE;
virtual bool IsUsingCustomFrame() const OVERRIDE; virtual bool IsUsingCustomFrame() const OVERRIDE;
virtual InputMethod* GetInputMethod() OVERRIDE;
virtual void HandleAppDeactivated() OVERRIDE; virtual void HandleAppDeactivated() OVERRIDE;
virtual bool HandleAppCommand(short command) OVERRIDE; virtual bool HandleAppCommand(short command) OVERRIDE;
virtual void HandleCaptureLost() OVERRIDE; virtual void HandleCaptureLost() OVERRIDE;
...@@ -504,6 +505,7 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, ...@@ -504,6 +505,7 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
virtual void HandleGlassModeChange() OVERRIDE; virtual void HandleGlassModeChange() OVERRIDE;
virtual void HandleBeginWMSizeMove() OVERRIDE; virtual void HandleBeginWMSizeMove() OVERRIDE;
virtual void HandleEndWMSizeMove() OVERRIDE; virtual void HandleEndWMSizeMove() OVERRIDE;
virtual void HandleMove() OVERRIDE;
virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE; virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE;
// Called after the WM_ACTIVATE message has been processed by the default // Called after the WM_ACTIVATE message has been processed by the default
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment