summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/render_widget_host_hwnd.cc33
-rw-r--r--chrome/browser/render_widget_host_hwnd.h7
-rw-r--r--chrome/browser/web_contents.cc81
-rw-r--r--chrome/browser/web_contents.h4
-rw-r--r--chrome/views/focus_manager.cc3
5 files changed, 66 insertions, 62 deletions
diff --git a/chrome/browser/render_widget_host_hwnd.cc b/chrome/browser/render_widget_host_hwnd.cc
index 346b050..8ca727c 100644
--- a/chrome/browser/render_widget_host_hwnd.cc
+++ b/chrome/browser/render_widget_host_hwnd.cc
@@ -724,39 +724,6 @@ LRESULT RenderWidgetHostHWND::OnWheelEvent(UINT message, WPARAM wparam,
return 0;
}
-LRESULT RenderWidgetHostHWND::OnNcCalcSize(UINT message, WPARAM w_param,
- LPARAM l_param, BOOL& handled) {
- // Handle WM_NCCALCSIZE and make scrollbar size to 0.
- // Here we indicate that the entire window area is our
- // client area. The assumption is that we won't have a border
- // or any other non-client widget.
- return 0;
-}
-
-LRESULT RenderWidgetHostHWND::OnSize(UINT message, WPARAM w_param,
- LPARAM l_param, BOOL& handled) {
- // Set arbitrary but valid scroll information so that
- // our window will get WS_VSCROLL and WS_HSCROLL style.
-
- // TODO(joshia): The correct thing to do here is to get
- // the correct scroll information from the renderer and
- // set it here.
- SCROLLINFO si = {0};
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL;
-
- si.nMin = 1;
- si.nMax = 100;
- si.nPage = 10;
- si.nTrackPos = 50;
-
- SetScrollInfo(SB_HORZ, &si, FALSE);
- SetScrollInfo(SB_VERT, &si, FALSE);
-
- handled = FALSE;
- return 0;
-}
-
LRESULT RenderWidgetHostHWND::OnMouseActivate(UINT, WPARAM, LPARAM,
BOOL& handled) {
// We handle WM_MOUSEACTIVATE to set focus to the underlying plugin
diff --git a/chrome/browser/render_widget_host_hwnd.h b/chrome/browser/render_widget_host_hwnd.h
index 5f245cb..bc16c6d 100644
--- a/chrome/browser/render_widget_host_hwnd.h
+++ b/chrome/browser/render_widget_host_hwnd.h
@@ -106,8 +106,6 @@ class RenderWidgetHostHWND :
MESSAGE_HANDLER(WM_CHAR, OnKeyEvent)
MESSAGE_HANDLER(WM_SYSCHAR, OnKeyEvent)
MESSAGE_HANDLER(WM_IME_CHAR, OnKeyEvent)
- MESSAGE_HANDLER(WM_NCCALCSIZE, OnNcCalcSize)
- MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate)
END_MSG_MAP()
@@ -165,11 +163,6 @@ class RenderWidgetHostHWND :
UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled);
LRESULT OnWheelEvent(
UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled);
- // Handle WM_NCCALCSIZE and supress scrollbars
- LRESULT OnNcCalcSize(UINT, WPARAM, LPARAM, BOOL& handled);
- // Handle WM_SIZE and indicate that we have a valid scroll info
- // so that windows will give us the WS_HSCROLL and WS_VSCROLL style.
- LRESULT OnSize(UINT, WPARAM, LPARAM, BOOL& handled);
LRESULT OnMouseActivate(UINT, WPARAM, LPARAM, BOOL& handled);
// Handle vertical scrolling
LRESULT OnVScroll(int code, short position, HWND scrollbar_control);
diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc
index 7084bd8..3a9fd3a 100644
--- a/chrome/browser/web_contents.cc
+++ b/chrome/browser/web_contents.cc
@@ -376,13 +376,6 @@ void WebContents::OnPaint(HDC junk_dc) {
SetMsgHandled(FALSE);
}
-void WebContents::OnHScroll(int scroll_type, short position, HWND scrollbar) {
- // This window can receive scroll events as a result of the ThinkPad's
- // trackpad scroll wheel emulation.
- if (!ScrollZoom(scroll_type))
- SetMsgHandled(FALSE);
-}
-
LRESULT WebContents::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) {
switch (msg) {
case WM_LBUTTONDOWN:
@@ -398,12 +391,7 @@ LRESULT WebContents::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) {
if (delegate())
delegate()->ContentsMouseEvent(this, WM_MOUSEMOVE);
break;
- case WM_MOUSEWHEEL:
- // This message is reflected from the view() to this window.
- if (GET_KEYSTATE_WPARAM(w_param) & MK_CONTROL) {
- WheelZoom(GET_WHEEL_DELTA_WPARAM(w_param));
- return 1;
- }
+ default:
break;
}
@@ -418,23 +406,74 @@ void WebContents::OnMouseLeave() {
SetMsgHandled(FALSE);
}
+// A message is reflected here from view().
+// Return non-zero to indicate that it is handled here.
+// Return 0 to allow view() to further process it.
LRESULT WebContents::OnReflectedMessage(UINT msg, WPARAM w_param,
LPARAM l_param) {
MSG* message = reinterpret_cast<MSG*>(l_param);
- LRESULT ret = 0;
- if (message) {
- ProcessWindowMessage(message->hwnd, message->message, message->wParam,
- message->lParam, ret);
+ switch (message->message) {
+ case WM_MOUSEWHEEL:
+ // This message is reflected from the view() to this window.
+ if (GET_KEYSTATE_WPARAM(message->wParam) & MK_CONTROL) {
+ WheelZoom(GET_WHEEL_DELTA_WPARAM(message->wParam));
+ return 1;
+ }
+ break;
+ case WM_HSCROLL:
+ case WM_VSCROLL:
+ if (ScrollZoom(LOWORD(message->wParam)))
+ return 1;
+ default:
+ break;
}
- return ret;
+ return 0;
+}
+
+void WebContents::OnSize(UINT param, const CSize& size) {
+ HWNDViewContainer::OnSize(param, size);
+
+ // Hack for thinkpad touchpad driver.
+ // Set fake scrollbars so that we can get scroll messages,
+ SCROLLINFO si = {0};
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+
+ si.nMin = 1;
+ si.nMax = 100;
+ si.nPage = 10;
+ si.nTrackPos = 50;
+
+ ::SetScrollInfo(GetHWND(), SB_HORZ, &si, FALSE);
+ ::SetScrollInfo(GetHWND(), SB_VERT, &si, FALSE);
+}
+
+LRESULT WebContents::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
+ // Hack for thinkpad mouse wheel driver. We have set the fake scroll bars
+ // to receive scroll messages from thinkpad touchpad driver. Suppress
+ // painting of scrollbars by returning 0 size for them.
+ return 0;
+}
+
+void WebContents::OnHScroll(int scroll_type, short position, HWND scrollbar) {
+ ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar);
}
void WebContents::OnVScroll(int scroll_type, short position, HWND scrollbar) {
+ ScrollCommon(WM_VSCROLL, scroll_type, position, scrollbar);
+}
+
+void WebContents::ScrollCommon(UINT message, int scroll_type, short position,
+ HWND scrollbar) {
// This window can receive scroll events as a result of the ThinkPad's
- // TrackPad scroll wheel emulation.
- if (!ScrollZoom(scroll_type))
- SetMsgHandled(FALSE);
+ // Trackpad scroll wheel emulation.
+ if (!ScrollZoom(scroll_type)) {
+ // Reflect scroll message to the view() to give it a chance
+ // to process scrolling.
+ SendMessage(GetContentHWND(), message, MAKELONG(scroll_type, position),
+ (LPARAM) scrollbar);
+ }
}
bool WebContents::ScrollZoom(int scroll_type) {
diff --git a/chrome/browser/web_contents.h b/chrome/browser/web_contents.h
index 866862a..30b4c2f 100644
--- a/chrome/browser/web_contents.h
+++ b/chrome/browser/web_contents.h
@@ -493,6 +493,8 @@ class WebContents : public TabContents,
GearsCreateShortcutCallbackFunctor* callback_functor;
};
+ void ScrollCommon(UINT message, int scroll_type, short position,
+ HWND scrollbar);
bool ScrollZoom(int scroll_type);
void WheelZoom(int distance);
@@ -511,6 +513,8 @@ class WebContents : public TabContents,
virtual void OnSetFocus(HWND window);
virtual void OnVScroll(int scroll_type, short position, HWND scrollbar);
virtual void OnWindowPosChanged(WINDOWPOS* window_pos);
+ virtual void OnSize(UINT param, const CSize& size);
+ virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param);
// Callback from HistoryService for our request for a favicon.
void OnFavIconData(HistoryService::Handle handle,
diff --git a/chrome/views/focus_manager.cc b/chrome/views/focus_manager.cc
index 8b47faf..bd1b429 100644
--- a/chrome/views/focus_manager.cc
+++ b/chrome/views/focus_manager.cc
@@ -47,7 +47,8 @@ static bool CanRedirectMouseWheelFrom(HWND window) {
// pointer. Detect if we are dealing with this window. In this case we
// don't need to do anything as the Thinkpad mouse driver will send
// mouse wheel messages to the right window.
- if (class_name == L"Syn Visual Class")
+ if ((class_name == L"Syn Visual Class") ||
+ (class_name == L"SynTrackCursorWindowClass"))
return false;
return true;