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

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

Issue 7828038: Workaround windows classic theme caption rendering artifacts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use a ScopedRedrawLock and update |saved_window_style_| on WM_NCLBUTTONDOWN. Created 9 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 | « no previous file | no next file » | 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 "views/widget/native_widget_win.h" 5 #include "views/widget/native_widget_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 } 1494 }
1495 } else if (message == WM_NCRBUTTONDOWN && 1495 } else if (message == WM_NCRBUTTONDOWN &&
1496 (w_param == HTCAPTION || w_param == HTSYSMENU)) { 1496 (w_param == HTCAPTION || w_param == HTSYSMENU)) {
1497 is_right_mouse_pressed_on_caption_ = true; 1497 is_right_mouse_pressed_on_caption_ = true;
1498 // We SetMouseCapture() to ensure we only show the menu when the button 1498 // We SetMouseCapture() to ensure we only show the menu when the button
1499 // down and up are both on the caption. Note: this causes the button up to 1499 // down and up are both on the caption. Note: this causes the button up to
1500 // be WM_RBUTTONUP instead of WM_NCRBUTTONUP. 1500 // be WM_RBUTTONUP instead of WM_NCRBUTTONUP.
1501 SetMouseCapture(); 1501 SetMouseCapture();
1502 } 1502 }
1503 1503
1504 /*
1505 TODO(beng): This fixes some situations where the windows-classic appearance
1506 non-client area is rendered over our custom frame, however it
1507 causes mouse-releases to the non-client area to be eaten, so it
1508 can't be enabled.
1509 if (message == WM_NCLBUTTONDOWN) {
1510 // NativeWidgetWin::OnNCLButtonDown set the message as un-handled. This
1511 // normally means NativeWidgetWin::ProcessWindowMessage will pass it to
1512 // DefWindowProc. Sadly, DefWindowProc for WM_NCLBUTTONDOWN does weird
1513 // non-client painting, so we need to call it directly here inside a
1514 // scoped update lock.
1515 ScopedRedrawLock lock(this);
1516 NativeWidgetWin::OnMouseRange(message, w_param, l_param);
1517 DefWindowProc(GetNativeView(), WM_NCLBUTTONDOWN, w_param, l_param);
1518 SetMsgHandled(TRUE);
1519 }
1520 */
1521
1522 MSG msg = { hwnd(), message, w_param, l_param, 0, 1504 MSG msg = { hwnd(), message, w_param, l_param, 0,
1523 { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } }; 1505 { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } };
1524 MouseEvent event(msg); 1506 MouseEvent event(msg);
1525 1507
1526 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) 1508 if (!(event.flags() & ui::EF_IS_NON_CLIENT))
1527 if (tooltip_manager_.get()) 1509 if (tooltip_manager_.get())
1528 tooltip_manager_->OnMouse(message, w_param, l_param); 1510 tooltip_manager_->OnMouse(message, w_param, l_param);
1529 1511
1530 if (event.type() == ui::ET_MOUSE_MOVED && !HasMouseCapture()) { 1512 if (event.type() == ui::ET_MOUSE_MOVED && !HasMouseCapture()) {
1531 // Windows only fires WM_MOUSELEAVE events if the application begins 1513 // Windows only fires WM_MOUSELEAVE events if the application begins
1532 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. 1514 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events.
1533 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. 1515 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE.
1534 TrackMouseEvents((message == WM_NCMOUSEMOVE) ? 1516 TrackMouseEvents((message == WM_NCMOUSEMOVE) ?
1535 TME_NONCLIENT | TME_LEAVE : TME_LEAVE); 1517 TME_NONCLIENT | TME_LEAVE : TME_LEAVE);
1536 } else if (event.type() == ui::ET_MOUSE_EXITED) { 1518 } else if (event.type() == ui::ET_MOUSE_EXITED) {
1537 // Reset our tracking flags so future mouse movement over this 1519 // Reset our tracking flags so future mouse movement over this
1538 // NativeWidgetWin results in a new tracking session. Fall through for 1520 // NativeWidgetWin results in a new tracking session. Fall through for
1539 // OnMouseEvent. 1521 // OnMouseEvent.
1540 active_mouse_tracking_flags_ = 0; 1522 active_mouse_tracking_flags_ = 0;
1541 } else if (event.type() == ui::ET_MOUSEWHEEL) { 1523 } else if (event.type() == ui::ET_MOUSEWHEEL) {
1542 // Reroute the mouse wheel to the window under the pointer if applicable. 1524 // Reroute the mouse wheel to the window under the pointer if applicable.
1543 return (ui::RerouteMouseWheel(hwnd(), w_param, l_param) || 1525 return (ui::RerouteMouseWheel(hwnd(), w_param, l_param) ||
1544 delegate_->OnMouseEvent(MouseWheelEvent(msg))) ? 0 : 1; 1526 delegate_->OnMouseEvent(MouseWheelEvent(msg))) ? 0 : 1;
1545 } 1527 }
1546 1528
1547 SetMsgHandled(delegate_->OnMouseEvent(event)); 1529 bool handled = delegate_->OnMouseEvent(event);
1530
1531 if (!handled && message == WM_NCLBUTTONDOWN) {
1532 // TODO(msw): Eliminate undesired painting, or re-evaluate this workaround.
1533 // DefWindowProc for WM_NCLBUTTONDOWN does weird non-client painting, so we
1534 // need to call it directly here inside a ScopedRedrawLock. This may cause
1535 // other negative side-effects (ex/ stifling non-client mouse releases).
1536 ScopedRedrawLock lock(this);
1537 DefWindowProc(GetNativeView(), message, w_param, l_param);
1538 // Update the saved window style, which may change (maximized to restored).
1539 saved_window_style_ = GetWindowLong(GWL_STYLE);
1540 handled = true;
1541 }
1542
1543 SetMsgHandled(handled);
1548 return 0; 1544 return 0;
1549 } 1545 }
1550 1546
1551 void NativeWidgetWin::OnMove(const CPoint& point) { 1547 void NativeWidgetWin::OnMove(const CPoint& point) {
1552 // TODO(beng): move to Widget. 1548 // TODO(beng): move to Widget.
1553 GetWidget()->widget_delegate()->OnWidgetMove(); 1549 GetWidget()->widget_delegate()->OnWidgetMove();
1554 SetMsgHandled(FALSE); 1550 SetMsgHandled(FALSE);
1555 } 1551 }
1556 1552
1557 void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { 1553 void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2533 return (GetKeyState(VK_LBUTTON) & 0x80) || 2529 return (GetKeyState(VK_LBUTTON) & 0x80) ||
2534 (GetKeyState(VK_RBUTTON) & 0x80) || 2530 (GetKeyState(VK_RBUTTON) & 0x80) ||
2535 (GetKeyState(VK_MBUTTON) & 0x80) || 2531 (GetKeyState(VK_MBUTTON) & 0x80) ||
2536 (GetKeyState(VK_XBUTTON1) & 0x80) || 2532 (GetKeyState(VK_XBUTTON1) & 0x80) ||
2537 (GetKeyState(VK_XBUTTON2) & 0x80); 2533 (GetKeyState(VK_XBUTTON2) & 0x80);
2538 } 2534 }
2539 2535
2540 } // namespace internal 2536 } // namespace internal
2541 2537
2542 } // namespace views 2538 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698