| OLD | NEW |
| 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/window/window_win.h" | 5 #include "views/window/window_win.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 303 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
| 304 return gfx::Font(caption_font); | 304 return gfx::Font(caption_font); |
| 305 } | 305 } |
| 306 | 306 |
| 307 /////////////////////////////////////////////////////////////////////////////// | 307 /////////////////////////////////////////////////////////////////////////////// |
| 308 // WindowWin, protected: | 308 // WindowWin, protected: |
| 309 | 309 |
| 310 gfx::Insets WindowWin::GetClientAreaInsets() const { | 310 gfx::Insets WindowWin::GetClientAreaInsets() const { |
| 311 // Returning an empty Insets object causes the default handling in | 311 // Returning an empty Insets object causes the default handling in |
| 312 // WidgetWin::OnNCCalcSize() to be invoked. | 312 // WidgetWin::OnNCCalcSize() to be invoked. |
| 313 if (delegate_->IsUsingNativeFrame()) | 313 if (GetWindow()->ShouldUseNativeFrame()) |
| 314 return gfx::Insets(); | 314 return gfx::Insets(); |
| 315 | 315 |
| 316 if (IsMaximized()) { | 316 if (IsMaximized()) { |
| 317 // Windows automatically adds a standard width border to all sides when a | 317 // Windows automatically adds a standard width border to all sides when a |
| 318 // window is maximized. | 318 // window is maximized. |
| 319 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); | 319 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
| 320 return gfx::Insets(border_thickness, border_thickness, border_thickness, | 320 return gfx::Insets(border_thickness, border_thickness, border_thickness, |
| 321 border_thickness); | 321 border_thickness); |
| 322 } | 322 } |
| 323 // This is weird, but highly essential. If we don't offset the bottom edge | 323 // This is weird, but highly essential. If we don't offset the bottom edge |
| 324 // of the client rect, the window client area and window area will match, | 324 // of the client rect, the window client area and window area will match, |
| 325 // and when returning to glass rendering mode from non-glass, the client | 325 // and when returning to glass rendering mode from non-glass, the client |
| 326 // area will not paint black as transparent. This is because (and I don't | 326 // area will not paint black as transparent. This is because (and I don't |
| 327 // know why) the client area goes from matching the window rect to being | 327 // know why) the client area goes from matching the window rect to being |
| 328 // something else. If the client area is not the window rect in both | 328 // something else. If the client area is not the window rect in both |
| 329 // modes, the blackness doesn't occur. Because of this, we need to tell | 329 // modes, the blackness doesn't occur. Because of this, we need to tell |
| 330 // the RootView to lay out to fit the window rect, rather than the client | 330 // the RootView to lay out to fit the window rect, rather than the client |
| 331 // rect when using the opaque frame. | 331 // rect when using the opaque frame. |
| 332 // Note: this is only required for non-fullscreen windows. Note that | 332 // Note: this is only required for non-fullscreen windows. Note that |
| 333 // fullscreen windows are in restored state, not maximized. | 333 // fullscreen windows are in restored state, not maximized. |
| 334 return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 0); | 334 return gfx::Insets(0, 0, 0, 0); |
| 335 } | 335 } |
| 336 | 336 |
| 337 int WindowWin::GetShowState() const { | 337 int WindowWin::GetShowState() const { |
| 338 return SW_SHOWNORMAL; | 338 return SW_SHOWNORMAL; |
| 339 } | 339 } |
| 340 | 340 |
| 341 /////////////////////////////////////////////////////////////////////////////// | 341 /////////////////////////////////////////////////////////////////////////////// |
| 342 // WindowWin, WidgetWin overrides: | 342 // WindowWin, WidgetWin overrides: |
| 343 | 343 |
| 344 void WindowWin::InitNativeWidget(const Widget::InitParams& params) { | 344 void WindowWin::InitNativeWidget(const Widget::InitParams& params) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 is_in_size_move_ = true; | 407 is_in_size_move_ = true; |
| 408 WidgetWin::OnEnterSizeMove(); | 408 WidgetWin::OnEnterSizeMove(); |
| 409 delegate_->OnNativeWindowBeginUserBoundsChange(); | 409 delegate_->OnNativeWindowBeginUserBoundsChange(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void WindowWin::OnExitSizeMove() { | 412 void WindowWin::OnExitSizeMove() { |
| 413 is_in_size_move_ = false; | 413 is_in_size_move_ = false; |
| 414 WidgetWin::OnExitSizeMove(); | 414 WidgetWin::OnExitSizeMove(); |
| 415 delegate_->OnNativeWindowEndUserBoundsChange(); | 415 delegate_->OnNativeWindowEndUserBoundsChange(); |
| 416 | 416 |
| 417 if (!ShouldUseNativeFrame()) { | 417 if (!GetWindow()->ShouldUseNativeFrame()) { |
| 418 // Sending SWP_FRAMECHANGED forces a non-client repaint, which fixes the | 418 // Sending SWP_FRAMECHANGED forces a non-client repaint, which fixes the |
| 419 // glitch in rendering the bottom pixel of the window caused by us | 419 // glitch in rendering the bottom pixel of the window caused by us |
| 420 // offsetting the client rect there (See comment in GetClientAreaInsets()). | 420 // offsetting the client rect there (See comment in GetClientAreaInsets()). |
| 421 SetWindowPos(NULL, 0, 0, 0, 0, | 421 SetWindowPos(NULL, 0, 0, 0, 0, |
| 422 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER); | 422 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER); |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 | 425 |
| 426 void WindowWin::OnFinalMessage(HWND window) { | 426 void WindowWin::OnFinalMessage(HWND window) { |
| 427 delegate_->OnNativeWindowDestroyed(); | 427 delegate_->OnNativeWindowDestroyed(); |
| 428 WidgetWin::OnFinalMessage(window); | 428 WidgetWin::OnFinalMessage(window); |
| 429 } | 429 } |
| 430 | 430 |
| 431 void WindowWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) { | 431 void WindowWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) { |
| 432 gfx::Size min_window_size(delegate_->GetMinimumSize()); | 432 gfx::Size min_window_size(delegate_->GetMinimumSize()); |
| 433 minmax_info->ptMinTrackSize.x = min_window_size.width(); | 433 minmax_info->ptMinTrackSize.x = min_window_size.width(); |
| 434 minmax_info->ptMinTrackSize.y = min_window_size.height(); | 434 minmax_info->ptMinTrackSize.y = min_window_size.height(); |
| 435 WidgetWin::OnGetMinMaxInfo(minmax_info); | 435 WidgetWin::OnGetMinMaxInfo(minmax_info); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void WindowWin::OnInitMenu(HMENU menu) { | 438 void WindowWin::OnInitMenu(HMENU menu) { |
| 439 // We only need to manually enable the system menu if we're not using a native | 439 // We only need to manually enable the system menu if we're not using a native |
| 440 // frame. | 440 // frame. |
| 441 if (delegate_->IsUsingNativeFrame()) | 441 if (GetWindow()->ShouldUseNativeFrame()) |
| 442 WidgetWin::OnInitMenu(menu); | 442 WidgetWin::OnInitMenu(menu); |
| 443 | 443 |
| 444 bool is_fullscreen = IsFullscreen(); | 444 bool is_fullscreen = IsFullscreen(); |
| 445 bool is_minimized = IsMinimized(); | 445 bool is_minimized = IsMinimized(); |
| 446 bool is_maximized = IsMaximized(); | 446 bool is_maximized = IsMaximized(); |
| 447 bool is_restored = !is_fullscreen && !is_minimized && !is_maximized; | 447 bool is_restored = !is_fullscreen && !is_minimized && !is_maximized; |
| 448 | 448 |
| 449 ScopedRedrawLock lock(this); | 449 ScopedRedrawLock lock(this); |
| 450 EnableMenuItem(menu, SC_RESTORE, is_minimized || is_maximized); | 450 EnableMenuItem(menu, SC_RESTORE, is_minimized || is_maximized); |
| 451 EnableMenuItem(menu, SC_MOVE, is_restored); | 451 EnableMenuItem(menu, SC_MOVE, is_restored); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 477 if (w_param == HTCAPTION || w_param == HTSYSMENU) { | 477 if (w_param == HTCAPTION || w_param == HTSYSMENU) { |
| 478 UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD; | 478 UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD; |
| 479 if (base::i18n::IsRTL()) | 479 if (base::i18n::IsRTL()) |
| 480 flags |= TPM_RIGHTALIGN; | 480 flags |= TPM_RIGHTALIGN; |
| 481 HMENU system_menu = GetSystemMenu(GetNativeView(), FALSE); | 481 HMENU system_menu = GetSystemMenu(GetNativeView(), FALSE); |
| 482 int id = TrackPopupMenu(system_menu, flags, screen_point.x, | 482 int id = TrackPopupMenu(system_menu, flags, screen_point.x, |
| 483 screen_point.y, 0, GetNativeView(), NULL); | 483 screen_point.y, 0, GetNativeView(), NULL); |
| 484 ExecuteSystemMenuCommand(id); | 484 ExecuteSystemMenuCommand(id); |
| 485 return 0; | 485 return 0; |
| 486 } | 486 } |
| 487 } else if (message == WM_NCLBUTTONDOWN && !delegate_->IsUsingNativeFrame()) { | 487 } else if (message == WM_NCLBUTTONDOWN && |
| 488 !GetWindow()->ShouldUseNativeFrame()) { |
| 488 switch (w_param) { | 489 switch (w_param) { |
| 489 case HTCLOSE: | 490 case HTCLOSE: |
| 490 case HTMINBUTTON: | 491 case HTMINBUTTON: |
| 491 case HTMAXBUTTON: { | 492 case HTMAXBUTTON: { |
| 492 // When the mouse is pressed down in these specific non-client areas, | 493 // When the mouse is pressed down in these specific non-client areas, |
| 493 // we need to tell the RootView to send the mouse pressed event (which | 494 // we need to tell the RootView to send the mouse pressed event (which |
| 494 // sets capture, allowing subsequent WM_LBUTTONUP (note, _not_ | 495 // sets capture, allowing subsequent WM_LBUTTONUP (note, _not_ |
| 495 // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be | 496 // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be |
| 496 // sent by the applicable button's ButtonListener. We _have_ to do this | 497 // sent by the applicable button's ButtonListener. We _have_ to do this |
| 497 // way rather than letting Windows just send the syscommand itself (as | 498 // way rather than letting Windows just send the syscommand itself (as |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 550 |
| 550 is_active_ = !!active; | 551 is_active_ = !!active; |
| 551 delegate_->OnNativeWindowActivationChanged(is_active_); | 552 delegate_->OnNativeWindowActivationChanged(is_active_); |
| 552 | 553 |
| 553 // The frame may need to redraw as a result of the activation change. | 554 // The frame may need to redraw as a result of the activation change. |
| 554 // We can get WM_NCACTIVATE before we're actually visible. If we're not | 555 // We can get WM_NCACTIVATE before we're actually visible. If we're not |
| 555 // visible, no need to paint. | 556 // visible, no need to paint. |
| 556 if (IsVisible()) | 557 if (IsVisible()) |
| 557 GetWindow()->non_client_view()->SchedulePaint(); | 558 GetWindow()->non_client_view()->SchedulePaint(); |
| 558 | 559 |
| 559 if (!ShouldUseNativeFrame()) { | 560 if (!GetWindow()->ShouldUseNativeFrame()) { |
| 560 // TODO(beng, et al): Hack to redraw this window and child windows | 561 // TODO(beng, et al): Hack to redraw this window and child windows |
| 561 // synchronously upon activation. Not all child windows are redrawing | 562 // synchronously upon activation. Not all child windows are redrawing |
| 562 // themselves leading to issues like http://crbug.com/74604 | 563 // themselves leading to issues like http://crbug.com/74604 |
| 563 // We redraw out-of-process HWNDs asynchronously to avoid hanging the | 564 // We redraw out-of-process HWNDs asynchronously to avoid hanging the |
| 564 // whole app if a child HWND belonging to a hung plugin is encountered. | 565 // whole app if a child HWND belonging to a hung plugin is encountered. |
| 565 RedrawWindow(GetNativeView(), NULL, NULL, | 566 RedrawWindow(GetNativeView(), NULL, NULL, |
| 566 RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW); | 567 RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW); |
| 567 EnumChildWindows(GetNativeView(), EnumChildWindowsForRedraw, NULL); | 568 EnumChildWindows(GetNativeView(), EnumChildWindowsForRedraw, NULL); |
| 568 } | 569 } |
| 569 | 570 |
| 570 // If we're active again, we should be allowed to render as inactive, so | 571 // If we're active again, we should be allowed to render as inactive, so |
| 571 // tell the non-client view. | 572 // tell the non-client view. |
| 572 bool inactive_rendering_disabled = delegate_->IsInactiveRenderingDisabled(); | 573 bool inactive_rendering_disabled = delegate_->IsInactiveRenderingDisabled(); |
| 573 if (IsActive()) | 574 if (IsActive()) |
| 574 delegate_->EnableInactiveRendering(); | 575 delegate_->EnableInactiveRendering(); |
| 575 | 576 |
| 576 return CallDefaultNCActivateHandler(inactive_rendering_disabled || active); | 577 return CallDefaultNCActivateHandler(inactive_rendering_disabled || active); |
| 577 } | 578 } |
| 578 | 579 |
| 579 LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { | 580 LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { |
| 581 //return 0; |
| 580 // We only override the default handling if we need to specify a custom | 582 // We only override the default handling if we need to specify a custom |
| 581 // non-client edge width. Note that in most cases "no insets" means no | 583 // non-client edge width. Note that in most cases "no insets" means no |
| 582 // custom width, but in fullscreen mode we want a custom width of 0. | 584 // custom width, but in fullscreen mode we want a custom width of 0. |
| 583 gfx::Insets insets = GetClientAreaInsets(); | 585 gfx::Insets insets = GetClientAreaInsets(); |
| 584 if (insets.empty() && !IsFullscreen()) | 586 if (insets.empty() && !IsFullscreen()) |
| 585 return WidgetWin::OnNCCalcSize(mode, l_param); | 587 return WidgetWin::OnNCCalcSize(mode, l_param); |
| 586 | 588 |
| 587 RECT* client_rect = mode ? | 589 RECT* client_rect = mode ? |
| 588 &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] : | 590 &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] : |
| 589 reinterpret_cast<RECT*>(l_param); | 591 reinterpret_cast<RECT*>(l_param); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 611 if (!monitor) { | 613 if (!monitor) { |
| 612 // This is probably an extreme case that we won't hit, but if we don't | 614 // This is probably an extreme case that we won't hit, but if we don't |
| 613 // intersect any monitor, let us not adjust the client rect since our | 615 // intersect any monitor, let us not adjust the client rect since our |
| 614 // window will not be visible anyway. | 616 // window will not be visible anyway. |
| 615 return 0; | 617 return 0; |
| 616 } | 618 } |
| 617 } | 619 } |
| 618 if (EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor)) | 620 if (EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor)) |
| 619 client_rect->left += kAutoHideTaskbarThicknessPx; | 621 client_rect->left += kAutoHideTaskbarThicknessPx; |
| 620 if (EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) { | 622 if (EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) { |
| 621 if (delegate_->IsUsingNativeFrame()) { | 623 if (GetWindow()->ShouldUseNativeFrame()) { |
| 622 // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of | 624 // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of |
| 623 // WM_NCHITTEST, having any nonclient area atop the window causes the | 625 // WM_NCHITTEST, having any nonclient area atop the window causes the |
| 624 // caption buttons to draw onscreen but not respond to mouse | 626 // caption buttons to draw onscreen but not respond to mouse |
| 625 // hover/clicks. | 627 // hover/clicks. |
| 626 // So for a taskbar at the screen top, we can't push the | 628 // So for a taskbar at the screen top, we can't push the |
| 627 // client_rect->top down; instead, we move the bottom up by one pixel, | 629 // client_rect->top down; instead, we move the bottom up by one pixel, |
| 628 // which is the smallest change we can make and still get a client area | 630 // which is the smallest change we can make and still get a client area |
| 629 // less than the screen size. This is visibly ugly, but there seems to | 631 // less than the screen size. This is visibly ugly, but there seems to |
| 630 // be no better solution. | 632 // be no better solution. |
| 631 --client_rect->bottom; | 633 --client_rect->bottom; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 652 // actually require another repaint to correct the layout after glass gets | 654 // actually require another repaint to correct the layout after glass gets |
| 653 // turned on and off. | 655 // turned on and off. |
| 654 if (insets.left() == 0 || insets.top() == 0) | 656 if (insets.left() == 0 || insets.top() == 0) |
| 655 return 0; | 657 return 0; |
| 656 return mode ? WVR_REDRAW : 0; | 658 return mode ? WVR_REDRAW : 0; |
| 657 } | 659 } |
| 658 | 660 |
| 659 LRESULT WindowWin::OnNCHitTest(const CPoint& point) { | 661 LRESULT WindowWin::OnNCHitTest(const CPoint& point) { |
| 660 // If the DWM is rendering the window controls, we need to give the DWM's | 662 // If the DWM is rendering the window controls, we need to give the DWM's |
| 661 // default window procedure first chance to handle hit testing. | 663 // default window procedure first chance to handle hit testing. |
| 662 if (ShouldUseNativeFrame()) { | 664 if (GetWindow()->ShouldUseNativeFrame()) { |
| 663 LRESULT result; | 665 LRESULT result; |
| 664 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, | 666 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, |
| 665 MAKELPARAM(point.x, point.y), &result)) { | 667 MAKELPARAM(point.x, point.y), &result)) { |
| 666 return result; | 668 return result; |
| 667 } | 669 } |
| 668 } | 670 } |
| 669 | 671 |
| 670 // First, give the NonClientView a chance to test the point to see if it | 672 // First, give the NonClientView a chance to test the point to see if it |
| 671 // provides any of the non-client area. | 673 // provides any of the non-client area. |
| 672 POINT temp = point; | 674 POINT temp = point; |
| 673 MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); | 675 MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); |
| 674 int component = delegate_->GetNonClientComponent(gfx::Point(temp)); | 676 int component = delegate_->GetNonClientComponent(gfx::Point(temp)); |
| 675 if (component != HTNOWHERE) | 677 if (component != HTNOWHERE) |
| 676 return component; | 678 return component; |
| 677 | 679 |
| 678 // Otherwise, we let Windows do all the native frame non-client handling for | 680 // Otherwise, we let Windows do all the native frame non-client handling for |
| 679 // us. | 681 // us. |
| 680 return WidgetWin::OnNCHitTest(point); | 682 return WidgetWin::OnNCHitTest(point); |
| 681 } | 683 } |
| 682 | 684 |
| 683 void WindowWin::OnNCPaint(HRGN rgn) { | 685 void WindowWin::OnNCPaint(HRGN rgn) { |
| 684 // When using a custom frame, we want to avoid calling DefWindowProc() since | 686 // When using a custom frame, we want to avoid calling DefWindowProc() since |
| 685 // that may render artifacts. | 687 // that may render artifacts. |
| 686 SetMsgHandled((!IsActive() || is_in_size_move_) && | 688 SetMsgHandled((!IsActive() || is_in_size_move_) && |
| 687 !delegate_->IsUsingNativeFrame()); | 689 !GetWindow()->ShouldUseNativeFrame()); |
| 688 } | 690 } |
| 689 | 691 |
| 690 LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param, | 692 LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param, |
| 691 LPARAM l_param) { | 693 LPARAM l_param) { |
| 692 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for | 694 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for |
| 693 // an explanation about why we need to handle this message. | 695 // an explanation about why we need to handle this message. |
| 694 SetMsgHandled(!delegate_->IsUsingNativeFrame()); | 696 SetMsgHandled(!GetWindow()->ShouldUseNativeFrame()); |
| 695 return 0; | 697 return 0; |
| 696 } | 698 } |
| 697 | 699 |
| 698 LRESULT WindowWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, | 700 LRESULT WindowWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, |
| 699 LPARAM l_param) { | 701 LPARAM l_param) { |
| 700 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for | 702 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for |
| 701 // an explanation about why we need to handle this message. | 703 // an explanation about why we need to handle this message. |
| 702 SetMsgHandled(!delegate_->IsUsingNativeFrame()); | 704 SetMsgHandled(!GetWindow()->ShouldUseNativeFrame()); |
| 703 return 0; | 705 return 0; |
| 704 } | 706 } |
| 705 | 707 |
| 706 LRESULT WindowWin::OnSetCursor(UINT msg, | 708 LRESULT WindowWin::OnSetCursor(UINT msg, |
| 707 WPARAM w_param, | 709 WPARAM w_param, |
| 708 LPARAM l_param) { | 710 LPARAM l_param) { |
| 709 // This shouldn't hurt even if we're using the native frame. | 711 // This shouldn't hurt even if we're using the native frame. |
| 710 ScopedRedrawLock lock(this); | 712 ScopedRedrawLock lock(this); |
| 711 return DefWindowProc(GetNativeView(), msg, w_param, l_param); | 713 return DefWindowProc(GetNativeView(), msg, w_param, l_param); |
| 712 } | 714 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 void WindowWin::OnSysCommand(UINT notification_code, CPoint click) { | 751 void WindowWin::OnSysCommand(UINT notification_code, CPoint click) { |
| 750 // Windows uses the 4 lower order bits of |notification_code| for type- | 752 // Windows uses the 4 lower order bits of |notification_code| for type- |
| 751 // specific information so we must exclude this when comparing. | 753 // specific information so we must exclude this when comparing. |
| 752 static const int sc_mask = 0xFFF0; | 754 static const int sc_mask = 0xFFF0; |
| 753 // Ignore size/move/maximize in fullscreen mode. | 755 // Ignore size/move/maximize in fullscreen mode. |
| 754 if (IsFullscreen() && | 756 if (IsFullscreen() && |
| 755 (((notification_code & sc_mask) == SC_SIZE) || | 757 (((notification_code & sc_mask) == SC_SIZE) || |
| 756 ((notification_code & sc_mask) == SC_MOVE) || | 758 ((notification_code & sc_mask) == SC_MOVE) || |
| 757 ((notification_code & sc_mask) == SC_MAXIMIZE))) | 759 ((notification_code & sc_mask) == SC_MAXIMIZE))) |
| 758 return; | 760 return; |
| 759 if (!delegate_->IsUsingNativeFrame()) { | 761 if (!GetWindow()->ShouldUseNativeFrame()) { |
| 760 if ((notification_code & sc_mask) == SC_MINIMIZE || | 762 if ((notification_code & sc_mask) == SC_MINIMIZE || |
| 761 (notification_code & sc_mask) == SC_MAXIMIZE || | 763 (notification_code & sc_mask) == SC_MAXIMIZE || |
| 762 (notification_code & sc_mask) == SC_RESTORE) { | 764 (notification_code & sc_mask) == SC_RESTORE) { |
| 763 GetWindow()->non_client_view()->ResetWindowControls(); | 765 GetWindow()->non_client_view()->ResetWindowControls(); |
| 764 } else if ((notification_code & sc_mask) == SC_MOVE || | 766 } else if ((notification_code & sc_mask) == SC_MOVE || |
| 765 (notification_code & sc_mask) == SC_SIZE) { | 767 (notification_code & sc_mask) == SC_SIZE) { |
| 766 if (lock_updates_) { | 768 if (lock_updates_) { |
| 767 // We were locked, before entering a resize or move modal loop. Now that | 769 // We were locked, before entering a resize or move modal loop. Now that |
| 768 // we've begun to move the window, we need to unlock updates so that the | 770 // we've begun to move the window, we need to unlock updates so that the |
| 769 // sizing/moving feedback can be continuous. | 771 // sizing/moving feedback can be continuous. |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION); | 1194 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION); |
| 1193 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF), | 1195 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF), |
| 1194 kDragFrameWindowAlpha, LWA_ALPHA); | 1196 kDragFrameWindowAlpha, LWA_ALPHA); |
| 1195 } else { | 1197 } else { |
| 1196 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_); | 1198 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_); |
| 1197 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_); | 1199 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_); |
| 1198 } | 1200 } |
| 1199 } | 1201 } |
| 1200 | 1202 |
| 1201 NonClientFrameView* WindowWin::CreateFrameViewForWindow() { | 1203 NonClientFrameView* WindowWin::CreateFrameViewForWindow() { |
| 1202 if (ShouldUseNativeFrame()) | 1204 if (GetWindow()->ShouldUseNativeFrame()) |
| 1203 return new NativeFrameView(GetWindow()); | 1205 return new NativeFrameView(GetWindow()); |
| 1204 return new CustomFrameView(GetWindow()); | 1206 return new CustomFrameView(GetWindow()); |
| 1205 } | 1207 } |
| 1206 | 1208 |
| 1207 void WindowWin::UpdateFrameAfterFrameChange() { | 1209 void WindowWin::UpdateFrameAfterFrameChange() { |
| 1208 // We've either gained or lost a custom window region, so reset it now. | 1210 // We've either gained or lost a custom window region, so reset it now. |
| 1209 ResetWindowRegion(true); | 1211 ResetWindowRegion(true); |
| 1210 } | 1212 } |
| 1211 | 1213 |
| 1212 gfx::NativeWindow WindowWin::GetNativeWindow() const { | 1214 gfx::NativeWindow WindowWin::GetNativeWindow() const { |
| 1213 return GetNativeView(); | 1215 return GetNativeView(); |
| 1214 } | 1216 } |
| 1215 | 1217 |
| 1216 bool WindowWin::ShouldUseNativeFrame() const { | 1218 bool WindowWin::ShouldUseNativeFrame() const { |
| 1217 return WidgetWin::IsAeroGlassEnabled(); | 1219 return WidgetWin::IsAeroGlassEnabled(); |
| 1218 } | 1220 } |
| 1219 | 1221 |
| 1220 void WindowWin::FrameTypeChanged() { | 1222 void WindowWin::FrameTypeChanged() { |
| 1221 // Called when the frame type could possibly be changing (theme change or | 1223 // Called when the frame type could possibly be changing (theme change or |
| 1222 // DWM composition change). | 1224 // DWM composition change). |
| 1223 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 1225 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 1224 // We need to toggle the rendering policy of the DWM/glass frame as we | 1226 // We need to toggle the rendering policy of the DWM/glass frame as we |
| 1225 // change from opaque to glass. "Non client rendering enabled" means that | 1227 // change from opaque to glass. "Non client rendering enabled" means that |
| 1226 // the DWM's glass non-client rendering is enabled, which is why | 1228 // the DWM's glass non-client rendering is enabled, which is why |
| 1227 // DWMNCRP_ENABLED is used for the native frame case. _DISABLED means the | 1229 // DWMNCRP_ENABLED is used for the native frame case. _DISABLED means the |
| 1228 // DWM doesn't render glass, and so is used in the custom frame case. | 1230 // DWM doesn't render glass, and so is used in the custom frame case. |
| 1229 DWMNCRENDERINGPOLICY policy = | 1231 DWMNCRENDERINGPOLICY policy = GetWindow()->ShouldUseNativeFrame() ? |
| 1230 delegate_->IsUsingNativeFrame() ? DWMNCRP_ENABLED : DWMNCRP_DISABLED; | 1232 DWMNCRP_ENABLED : DWMNCRP_DISABLED; |
| 1231 DwmSetWindowAttribute(GetNativeView(), DWMWA_NCRENDERING_POLICY, | 1233 DwmSetWindowAttribute(GetNativeView(), DWMWA_NCRENDERING_POLICY, |
| 1232 &policy, sizeof(DWMNCRENDERINGPOLICY)); | 1234 &policy, sizeof(DWMNCRENDERINGPOLICY)); |
| 1233 } | 1235 } |
| 1234 | 1236 |
| 1235 // Send a frame change notification, since the non-client metrics have | 1237 // Send a frame change notification, since the non-client metrics have |
| 1236 // changed. | 1238 // changed. |
| 1237 SendFrameChanged(GetNativeView()); | 1239 SendFrameChanged(GetNativeView()); |
| 1238 | 1240 |
| 1239 // Update the non-client view with the correct frame view for the active frame | 1241 // Update the non-client view with the correct frame view for the active frame |
| 1240 // type. | 1242 // type. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 } | 1296 } |
| 1295 | 1297 |
| 1296 void WindowWin::UnlockUpdates() { | 1298 void WindowWin::UnlockUpdates() { |
| 1297 SetWindowLong(GWL_STYLE, saved_window_style_); | 1299 SetWindowLong(GWL_STYLE, saved_window_style_); |
| 1298 lock_updates_ = false; | 1300 lock_updates_ = false; |
| 1299 } | 1301 } |
| 1300 | 1302 |
| 1301 void WindowWin::ResetWindowRegion(bool force) { | 1303 void WindowWin::ResetWindowRegion(bool force) { |
| 1302 // A native frame uses the native window region, and we don't want to mess | 1304 // A native frame uses the native window region, and we don't want to mess |
| 1303 // with it. | 1305 // with it. |
| 1304 if (delegate_->IsUsingNativeFrame()) { | 1306 if (GetWindow()->ShouldUseNativeFrame()) { |
| 1305 if (force) | 1307 if (force) |
| 1306 SetWindowRgn(NULL, TRUE); | 1308 SetWindowRgn(NULL, TRUE); |
| 1307 return; | 1309 return; |
| 1308 } | 1310 } |
| 1309 | 1311 |
| 1310 // Changing the window region is going to force a paint. Only change the | 1312 // Changing the window region is going to force a paint. Only change the |
| 1311 // window region if the region really differs. | 1313 // window region if the region really differs. |
| 1312 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); | 1314 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); |
| 1313 int current_rgn_result = GetWindowRgn(GetNativeView(), current_rgn); | 1315 int current_rgn_result = GetWindowRgn(GetNativeView(), current_rgn); |
| 1314 | 1316 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 //////////////////////////////////////////////////////////////////////////////// | 1359 //////////////////////////////////////////////////////////////////////////////// |
| 1358 // NativeWindow, public: | 1360 // NativeWindow, public: |
| 1359 | 1361 |
| 1360 // static | 1362 // static |
| 1361 NativeWindow* NativeWindow::CreateNativeWindow( | 1363 NativeWindow* NativeWindow::CreateNativeWindow( |
| 1362 internal::NativeWindowDelegate* delegate) { | 1364 internal::NativeWindowDelegate* delegate) { |
| 1363 return new WindowWin(delegate); | 1365 return new WindowWin(delegate); |
| 1364 } | 1366 } |
| 1365 | 1367 |
| 1366 } // namespace views | 1368 } // namespace views |
| OLD | NEW |