Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1521)

Side by Side Diff: chrome/browser/web_contents.cc

Issue 2878: Touchpad support for laptops... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/web_contents.h ('k') | chrome/views/focus_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/web_contents.h" 5 #include "chrome/browser/web_contents.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_version_info.h" 8 #include "base/file_version_info.h"
9 #include "chrome/app/locales/locale_settings.h" 9 #include "chrome/app/locales/locale_settings.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 return; 369 return;
370 } 370 }
371 371
372 // We need to do this to validate the dirty area so we don't end up in a 372 // We need to do this to validate the dirty area so we don't end up in a
373 // WM_PAINTstorm that causes other mysterious bugs (such as WM_TIMERs not 373 // WM_PAINTstorm that causes other mysterious bugs (such as WM_TIMERs not
374 // firing etc). It doesn't matter that we don't have any non-clipped area. 374 // firing etc). It doesn't matter that we don't have any non-clipped area.
375 CPaintDC dc(GetHWND()); 375 CPaintDC dc(GetHWND());
376 SetMsgHandled(FALSE); 376 SetMsgHandled(FALSE);
377 } 377 }
378 378
379 void WebContents::OnHScroll(int scroll_type, short position, HWND scrollbar) {
380 // This window can receive scroll events as a result of the ThinkPad's
381 // trackpad scroll wheel emulation.
382 if (!ScrollZoom(scroll_type))
383 SetMsgHandled(FALSE);
384 }
385
386 LRESULT WebContents::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { 379 LRESULT WebContents::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) {
387 switch (msg) { 380 switch (msg) {
388 case WM_LBUTTONDOWN: 381 case WM_LBUTTONDOWN:
389 case WM_MBUTTONDOWN: 382 case WM_MBUTTONDOWN:
390 case WM_RBUTTONDOWN: 383 case WM_RBUTTONDOWN:
391 // Make sure this TabContents is activated when it is clicked on. 384 // Make sure this TabContents is activated when it is clicked on.
392 if (delegate()) 385 if (delegate())
393 delegate()->ActivateContents(this); 386 delegate()->ActivateContents(this);
394 break; 387 break;
395 case WM_MOUSEMOVE: 388 case WM_MOUSEMOVE:
396 // Let our delegate know that the mouse moved (useful for resetting status 389 // Let our delegate know that the mouse moved (useful for resetting status
397 // bubble state). 390 // bubble state).
398 if (delegate()) 391 if (delegate())
399 delegate()->ContentsMouseEvent(this, WM_MOUSEMOVE); 392 delegate()->ContentsMouseEvent(this, WM_MOUSEMOVE);
400 break; 393 break;
401 case WM_MOUSEWHEEL: 394 default:
402 // This message is reflected from the view() to this window.
403 if (GET_KEYSTATE_WPARAM(w_param) & MK_CONTROL) {
404 WheelZoom(GET_WHEEL_DELTA_WPARAM(w_param));
405 return 1;
406 }
407 break; 395 break;
408 } 396 }
409 397
410 return 0; 398 return 0;
411 } 399 }
412 400
413 void WebContents::OnMouseLeave() { 401 void WebContents::OnMouseLeave() {
414 // Let our delegate know that the mouse moved (useful for resetting status 402 // Let our delegate know that the mouse moved (useful for resetting status
415 // bubble state). 403 // bubble state).
416 if (delegate()) 404 if (delegate())
417 delegate()->ContentsMouseEvent(this, WM_MOUSELEAVE); 405 delegate()->ContentsMouseEvent(this, WM_MOUSELEAVE);
418 SetMsgHandled(FALSE); 406 SetMsgHandled(FALSE);
419 } 407 }
420 408
409 // A message is reflected here from view().
410 // Return non-zero to indicate that it is handled here.
411 // Return 0 to allow view() to further process it.
421 LRESULT WebContents::OnReflectedMessage(UINT msg, WPARAM w_param, 412 LRESULT WebContents::OnReflectedMessage(UINT msg, WPARAM w_param,
422 LPARAM l_param) { 413 LPARAM l_param) {
423 MSG* message = reinterpret_cast<MSG*>(l_param); 414 MSG* message = reinterpret_cast<MSG*>(l_param);
424 LRESULT ret = 0; 415 switch (message->message) {
425 if (message) { 416 case WM_MOUSEWHEEL:
426 ProcessWindowMessage(message->hwnd, message->message, message->wParam, 417 // This message is reflected from the view() to this window.
427 message->lParam, ret); 418 if (GET_KEYSTATE_WPARAM(message->wParam) & MK_CONTROL) {
419 WheelZoom(GET_WHEEL_DELTA_WPARAM(message->wParam));
420 return 1;
421 }
422 break;
423 case WM_HSCROLL:
424 case WM_VSCROLL:
425 if (ScrollZoom(LOWORD(message->wParam)))
426 return 1;
427 default:
428 break;
428 } 429 }
429 430
430 return ret; 431 return 0;
432 }
433
434 void WebContents::OnSize(UINT param, const CSize& size) {
435 HWNDViewContainer::OnSize(param, size);
436
437 // Hack for thinkpad touchpad driver.
438 // Set fake scrollbars so that we can get scroll messages,
439 SCROLLINFO si = {0};
440 si.cbSize = sizeof(si);
441 si.fMask = SIF_ALL;
442
443 si.nMin = 1;
444 si.nMax = 100;
445 si.nPage = 10;
446 si.nTrackPos = 50;
447
448 ::SetScrollInfo(GetHWND(), SB_HORZ, &si, FALSE);
449 ::SetScrollInfo(GetHWND(), SB_VERT, &si, FALSE);
450 }
451
452 LRESULT WebContents::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
453 // Hack for thinkpad mouse wheel driver. We have set the fake scroll bars
454 // to receive scroll messages from thinkpad touchpad driver. Suppress
455 // painting of scrollbars by returning 0 size for them.
456 return 0;
457 }
458
459 void WebContents::OnHScroll(int scroll_type, short position, HWND scrollbar) {
460 ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar);
431 } 461 }
432 462
433 void WebContents::OnVScroll(int scroll_type, short position, HWND scrollbar) { 463 void WebContents::OnVScroll(int scroll_type, short position, HWND scrollbar) {
464 ScrollCommon(WM_VSCROLL, scroll_type, position, scrollbar);
465 }
466
467 void WebContents::ScrollCommon(UINT message, int scroll_type, short position,
468 HWND scrollbar) {
434 // This window can receive scroll events as a result of the ThinkPad's 469 // This window can receive scroll events as a result of the ThinkPad's
435 // TrackPad scroll wheel emulation. 470 // Trackpad scroll wheel emulation.
436 if (!ScrollZoom(scroll_type)) 471 if (!ScrollZoom(scroll_type)) {
437 SetMsgHandled(FALSE); 472 // Reflect scroll message to the view() to give it a chance
473 // to process scrolling.
474 SendMessage(GetContentHWND(), message, MAKELONG(scroll_type, position),
475 (LPARAM) scrollbar);
476 }
438 } 477 }
439 478
440 bool WebContents::ScrollZoom(int scroll_type) { 479 bool WebContents::ScrollZoom(int scroll_type) {
441 // If ctrl is held, zoom the UI. There are three issues with this: 480 // If ctrl is held, zoom the UI. There are three issues with this:
442 // 1) Should the event be eaten or forwarded to content? We eat the event, 481 // 1) Should the event be eaten or forwarded to content? We eat the event,
443 // which is like Firefox and unlike IE. 482 // which is like Firefox and unlike IE.
444 // 2) Should wheel up zoom in or out? We zoom in (increase font size), which 483 // 2) Should wheel up zoom in or out? We zoom in (increase font size), which
445 // is like IE and Google maps, but unlike Firefox. 484 // is like IE and Google maps, but unlike Firefox.
446 // 3) Should the mouse have to be over the content area? We zoom as long as 485 // 3) Should the mouse have to be over the content area? We zoom as long as
447 // content has focus, although FF and IE require that the mouse is over 486 // content has focus, although FF and IE require that the mouse is over
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 } 2477 }
2439 2478
2440 BOOL WebContents::EnumPluginWindowsCallback(HWND window, LPARAM) { 2479 BOOL WebContents::EnumPluginWindowsCallback(HWND window, LPARAM) {
2441 if (WebPluginDelegateImpl::IsPluginDelegateWindow(window)) { 2480 if (WebPluginDelegateImpl::IsPluginDelegateWindow(window)) {
2442 ::ShowWindow(window, SW_HIDE); 2481 ::ShowWindow(window, SW_HIDE);
2443 SetParent(window, NULL); 2482 SetParent(window, NULL);
2444 } 2483 }
2445 2484
2446 return TRUE; 2485 return TRUE;
2447 } 2486 }
OLDNEW
« no previous file with comments | « chrome/browser/web_contents.h ('k') | chrome/views/focus_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698