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

Side by Side Diff: ui/views/widget/native_widget_win.cc

Issue 6756043: Consolidate Widget Event code, other cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge. Created 9 years, 8 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 | « ui/views/widget/native_widget_win.h ('k') | ui/views/widget/widget.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "ui/base/system_monitor/system_monitor.h" 8 #include "ui/base/system_monitor/system_monitor.h"
9 #include "ui/base/view_prop.h" 9 #include "ui/base/view_prop.h"
10 #include "ui/base/win/hwnd_util.h" 10 #include "ui/base/win/hwnd_util.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 SetMsgHandled(FALSE); 342 SetMsgHandled(FALSE);
343 } 343 }
344 344
345 void NativeWidgetWin::OnInitMenuPopup(HMENU menu, UINT position, 345 void NativeWidgetWin::OnInitMenuPopup(HMENU menu, UINT position,
346 BOOL is_system_menu) { 346 BOOL is_system_menu) {
347 SetMsgHandled(FALSE); 347 SetMsgHandled(FALSE);
348 } 348 }
349 349
350 LRESULT NativeWidgetWin::OnKeyDown(UINT message, WPARAM w_param, 350 LRESULT NativeWidgetWin::OnKeyDown(UINT message, WPARAM w_param,
351 LPARAM l_param) { 351 LPARAM l_param) {
352 MSG msg; 352 MSG msg = { message, w_param, l_param };
353 MakeMSG(&msg, message, w_param, l_param);
354 SetMsgHandled(listener_->OnKeyEvent(KeyEvent(msg))); 353 SetMsgHandled(listener_->OnKeyEvent(KeyEvent(msg)));
355 return 0; 354 return 0;
356 } 355 }
357 356
358 LRESULT NativeWidgetWin::OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param) { 357 LRESULT NativeWidgetWin::OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param) {
359 MSG msg; 358 MSG msg = { message, w_param, l_param };
360 MakeMSG(&msg, message, w_param, l_param);
361 SetMsgHandled(listener_->OnKeyEvent(KeyEvent(msg))); 359 SetMsgHandled(listener_->OnKeyEvent(KeyEvent(msg)));
362 return 0; 360 return 0;
363 } 361 }
364 362
365 void NativeWidgetWin::OnKillFocus(HWND focused_window) { 363 void NativeWidgetWin::OnKillFocus(HWND focused_window) {
366 listener_->OnNativeBlur(focused_window); 364 listener_->OnNativeBlur(focused_window);
367 SetMsgHandled(FALSE); 365 SetMsgHandled(FALSE);
368 } 366 }
369 367
370 LRESULT NativeWidgetWin::OnMouseActivate(HWND window, UINT hittest_code, 368 LRESULT NativeWidgetWin::OnMouseActivate(HWND window, UINT hittest_code,
371 UINT message) { 369 UINT message) {
372 SetMsgHandled(FALSE); 370 SetMsgHandled(FALSE);
373 return MA_ACTIVATE; 371 return MA_ACTIVATE;
374 } 372 }
375 373
376 LRESULT NativeWidgetWin::OnMouseLeave(UINT message, WPARAM w_param, 374 LRESULT NativeWidgetWin::OnMouseLeave(UINT message, WPARAM w_param,
377 LPARAM l_param) { 375 LPARAM l_param) {
378 // TODO(beng): tooltip 376 // TODO(beng): tooltip
379 MSG msg; 377 MSG msg = { message, w_param, l_param };
380 MakeMSG(&msg, message, w_param, l_param);
381 SetMsgHandled(listener_->OnMouseEvent(MouseEvent(msg))); 378 SetMsgHandled(listener_->OnMouseEvent(MouseEvent(msg)));
382 379
383 // Reset our tracking flag so that future mouse movement over this WidgetWin 380 // Reset our tracking flag so that future mouse movement over this WidgetWin
384 // results in a new tracking session. 381 // results in a new tracking session.
385 active_mouse_tracking_flags_ = 0; 382 active_mouse_tracking_flags_ = 0;
386 383
387 return 0; 384 return 0;
388 } 385 }
389 386
390 void NativeWidgetWin::OnMove(const CPoint& point) { 387 void NativeWidgetWin::OnMove(const CPoint& point) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 tme.dwHoverTime = 0; 584 tme.dwHoverTime = 0;
588 TrackMouseEvent(&tme); 585 TrackMouseEvent(&tme);
589 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { 586 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) {
590 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); 587 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL);
591 TrackMouseEvents(mouse_tracking_flags); 588 TrackMouseEvents(mouse_tracking_flags);
592 } 589 }
593 } 590 }
594 591
595 bool NativeWidgetWin::ProcessMouseRange(UINT message, WPARAM w_param, 592 bool NativeWidgetWin::ProcessMouseRange(UINT message, WPARAM w_param,
596 LPARAM l_param, bool non_client) { 593 LPARAM l_param, bool non_client) {
597 MSG msg; 594 MSG msg = { message, w_param, l_param };
598 MakeMSG(&msg, message, w_param, l_param);
599 if (message == WM_MOUSEWHEEL) { 595 if (message == WM_MOUSEWHEEL) {
600 // Reroute the mouse-wheel to the window under the mouse pointer if 596 // Reroute the mouse-wheel to the window under the mouse pointer if
601 // applicable. 597 // applicable.
602 // TODO(beng): 598 // TODO(beng):
603 //if (views::RerouteMouseWheel(hwnd(), w_param, l_param)) 599 //if (views::RerouteMouseWheel(hwnd(), w_param, l_param))
604 // return 0; 600 // return 0;
605 return listener_->OnMouseWheelEvent(MouseWheelEvent(msg)); 601 return listener_->OnMouseWheelEvent(MouseWheelEvent(msg));
606 } 602 }
607 // Windows only fires WM_MOUSELEAVE events if the application begins 603 // Windows only fires WM_MOUSELEAVE events if the application begins
608 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. 604 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events.
609 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. 605 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE.
610 if (!has_capture_) 606 if (!has_capture_)
611 TrackMouseEvents(non_client ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE); 607 TrackMouseEvents(non_client ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE);
612 return listener_->OnMouseEvent(MouseEvent(msg)); 608 return listener_->OnMouseEvent(MouseEvent(msg));
613 } 609 }
614 610
615 void NativeWidgetWin::MakeMSG(MSG* msg, UINT message, WPARAM w_param,
616 LPARAM l_param, DWORD time, LONG x, LONG y) const {
617 msg->hwnd = hwnd();
618 msg->message = message;
619 msg->wParam = w_param;
620 msg->lParam = l_param;
621 msg->time = time;
622 msg->pt.x = x;
623 msg->pt.y = y;
624 }
625
626 void NativeWidgetWin::CloseNow() { 611 void NativeWidgetWin::CloseNow() {
627 DestroyWindow(hwnd()); 612 DestroyWindow(hwnd());
628 } 613 }
629 614
630 bool NativeWidgetWin::IsLayeredWindow() const { 615 bool NativeWidgetWin::IsLayeredWindow() const {
631 return !!(window_ex_style() & WS_EX_LAYERED); 616 return !!(window_ex_style() & WS_EX_LAYERED);
632 } 617 }
633 618
634 } // namespace internal 619 } // namespace internal
635 620
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 if (parent_widget) { 662 if (parent_widget) {
678 widget = parent_widget; 663 widget = parent_widget;
679 parent_hwnd = ::GetAncestor(parent_hwnd, GA_PARENT); 664 parent_hwnd = ::GetAncestor(parent_hwnd, GA_PARENT);
680 } 665 }
681 } while (parent_hwnd != NULL && parent_widget != NULL); 666 } while (parent_hwnd != NULL && parent_widget != NULL);
682 667
683 return widget; 668 return widget;
684 } 669 }
685 670
686 } // namespace ui 671 } // namespace ui
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_win.h ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698