| 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 (GetWindow()->ShouldUseNativeFrame()) | 313 if (delegate_->IsUsingNativeFrame()) |
| 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, 0, 0); | 334 return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 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 (!GetWindow()->ShouldUseNativeFrame()) { | 417 if (!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 (GetWindow()->ShouldUseNativeFrame()) | 441 if (delegate_->IsUsingNativeFrame()) |
| 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 && | 487 } else if (message == WM_NCLBUTTONDOWN && !delegate_->IsUsingNativeFrame()) { |
| 488 !GetWindow()->ShouldUseNativeFrame()) { | |
| 489 switch (w_param) { | 488 switch (w_param) { |
| 490 case HTCLOSE: | 489 case HTCLOSE: |
| 491 case HTMINBUTTON: | 490 case HTMINBUTTON: |
| 492 case HTMAXBUTTON: { | 491 case HTMAXBUTTON: { |
| 493 // When the mouse is pressed down in these specific non-client areas, | 492 // When the mouse is pressed down in these specific non-client areas, |
| 494 // we need to tell the RootView to send the mouse pressed event (which | 493 // we need to tell the RootView to send the mouse pressed event (which |
| 495 // sets capture, allowing subsequent WM_LBUTTONUP (note, _not_ | 494 // sets capture, allowing subsequent WM_LBUTTONUP (note, _not_ |
| 496 // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be | 495 // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be |
| 497 // sent by the applicable button's ButtonListener. We _have_ to do this | 496 // sent by the applicable button's ButtonListener. We _have_ to do this |
| 498 // way rather than letting Windows just send the syscommand itself (as | 497 // way rather than letting Windows just send the syscommand itself (as |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 | 555 |
| 557 is_active_ = !!active; | 556 is_active_ = !!active; |
| 558 delegate_->OnNativeWindowActivationChanged(is_active_); | 557 delegate_->OnNativeWindowActivationChanged(is_active_); |
| 559 | 558 |
| 560 // The frame may need to redraw as a result of the activation change. | 559 // The frame may need to redraw as a result of the activation change. |
| 561 // We can get WM_NCACTIVATE before we're actually visible. If we're not | 560 // We can get WM_NCACTIVATE before we're actually visible. If we're not |
| 562 // visible, no need to paint. | 561 // visible, no need to paint. |
| 563 if (IsVisible()) | 562 if (IsVisible()) |
| 564 GetWindow()->non_client_view()->SchedulePaint(); | 563 GetWindow()->non_client_view()->SchedulePaint(); |
| 565 | 564 |
| 566 if (!GetWindow()->ShouldUseNativeFrame()) { | 565 if (!ShouldUseNativeFrame()) { |
| 567 // TODO(beng, et al): Hack to redraw this window and child windows | 566 // TODO(beng, et al): Hack to redraw this window and child windows |
| 568 // synchronously upon activation. Not all child windows are redrawing | 567 // synchronously upon activation. Not all child windows are redrawing |
| 569 // themselves leading to issues like http://crbug.com/74604 | 568 // themselves leading to issues like http://crbug.com/74604 |
| 570 // We redraw out-of-process HWNDs asynchronously to avoid hanging the | 569 // We redraw out-of-process HWNDs asynchronously to avoid hanging the |
| 571 // whole app if a child HWND belonging to a hung plugin is encountered. | 570 // whole app if a child HWND belonging to a hung plugin is encountered. |
| 572 RedrawWindow(GetNativeView(), NULL, NULL, | 571 RedrawWindow(GetNativeView(), NULL, NULL, |
| 573 RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW); | 572 RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW); |
| 574 EnumChildWindows(GetNativeView(), EnumChildWindowsForRedraw, NULL); | 573 EnumChildWindows(GetNativeView(), EnumChildWindowsForRedraw, NULL); |
| 575 } | 574 } |
| 576 | 575 |
| 577 // If we're active again, we should be allowed to render as inactive, so | 576 // If we're active again, we should be allowed to render as inactive, so |
| 578 // tell the non-client view. | 577 // tell the non-client view. |
| 579 bool inactive_rendering_disabled = delegate_->IsInactiveRenderingDisabled(); | 578 bool inactive_rendering_disabled = delegate_->IsInactiveRenderingDisabled(); |
| 580 if (IsActive()) | 579 if (IsActive()) |
| 581 delegate_->EnableInactiveRendering(); | 580 delegate_->EnableInactiveRendering(); |
| 582 | 581 |
| 583 return CallDefaultNCActivateHandler(inactive_rendering_disabled || active); | 582 return CallDefaultNCActivateHandler(inactive_rendering_disabled || active); |
| 584 } | 583 } |
| 585 | 584 |
| 586 LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { | 585 LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { |
| 587 //return 0; | |
| 588 // We only override the default handling if we need to specify a custom | 586 // We only override the default handling if we need to specify a custom |
| 589 // non-client edge width. Note that in most cases "no insets" means no | 587 // non-client edge width. Note that in most cases "no insets" means no |
| 590 // custom width, but in fullscreen mode we want a custom width of 0. | 588 // custom width, but in fullscreen mode we want a custom width of 0. |
| 591 gfx::Insets insets = GetClientAreaInsets(); | 589 gfx::Insets insets = GetClientAreaInsets(); |
| 592 if (insets.empty() && !IsFullscreen()) | 590 if (insets.empty() && !IsFullscreen()) |
| 593 return WidgetWin::OnNCCalcSize(mode, l_param); | 591 return WidgetWin::OnNCCalcSize(mode, l_param); |
| 594 | 592 |
| 595 RECT* client_rect = mode ? | 593 RECT* client_rect = mode ? |
| 596 &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] : | 594 &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] : |
| 597 reinterpret_cast<RECT*>(l_param); | 595 reinterpret_cast<RECT*>(l_param); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 619 if (!monitor) { | 617 if (!monitor) { |
| 620 // This is probably an extreme case that we won't hit, but if we don't | 618 // This is probably an extreme case that we won't hit, but if we don't |
| 621 // intersect any monitor, let us not adjust the client rect since our | 619 // intersect any monitor, let us not adjust the client rect since our |
| 622 // window will not be visible anyway. | 620 // window will not be visible anyway. |
| 623 return 0; | 621 return 0; |
| 624 } | 622 } |
| 625 } | 623 } |
| 626 if (EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor)) | 624 if (EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor)) |
| 627 client_rect->left += kAutoHideTaskbarThicknessPx; | 625 client_rect->left += kAutoHideTaskbarThicknessPx; |
| 628 if (EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) { | 626 if (EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) { |
| 629 if (GetWindow()->ShouldUseNativeFrame()) { | 627 if (delegate_->IsUsingNativeFrame()) { |
| 630 // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of | 628 // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of |
| 631 // WM_NCHITTEST, having any nonclient area atop the window causes the | 629 // WM_NCHITTEST, having any nonclient area atop the window causes the |
| 632 // caption buttons to draw onscreen but not respond to mouse | 630 // caption buttons to draw onscreen but not respond to mouse |
| 633 // hover/clicks. | 631 // hover/clicks. |
| 634 // So for a taskbar at the screen top, we can't push the | 632 // So for a taskbar at the screen top, we can't push the |
| 635 // client_rect->top down; instead, we move the bottom up by one pixel, | 633 // client_rect->top down; instead, we move the bottom up by one pixel, |
| 636 // which is the smallest change we can make and still get a client area | 634 // which is the smallest change we can make and still get a client area |
| 637 // less than the screen size. This is visibly ugly, but there seems to | 635 // less than the screen size. This is visibly ugly, but there seems to |
| 638 // be no better solution. | 636 // be no better solution. |
| 639 --client_rect->bottom; | 637 --client_rect->bottom; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 660 // actually require another repaint to correct the layout after glass gets | 658 // actually require another repaint to correct the layout after glass gets |
| 661 // turned on and off. | 659 // turned on and off. |
| 662 if (insets.left() == 0 || insets.top() == 0) | 660 if (insets.left() == 0 || insets.top() == 0) |
| 663 return 0; | 661 return 0; |
| 664 return mode ? WVR_REDRAW : 0; | 662 return mode ? WVR_REDRAW : 0; |
| 665 } | 663 } |
| 666 | 664 |
| 667 LRESULT WindowWin::OnNCHitTest(const CPoint& point) { | 665 LRESULT WindowWin::OnNCHitTest(const CPoint& point) { |
| 668 // If the DWM is rendering the window controls, we need to give the DWM's | 666 // If the DWM is rendering the window controls, we need to give the DWM's |
| 669 // default window procedure first chance to handle hit testing. | 667 // default window procedure first chance to handle hit testing. |
| 670 if (GetWindow()->ShouldUseNativeFrame()) { | 668 if (ShouldUseNativeFrame()) { |
| 671 LRESULT result; | 669 LRESULT result; |
| 672 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, | 670 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, |
| 673 MAKELPARAM(point.x, point.y), &result)) { | 671 MAKELPARAM(point.x, point.y), &result)) { |
| 674 return result; | 672 return result; |
| 675 } | 673 } |
| 676 } | 674 } |
| 677 | 675 |
| 678 // First, give the NonClientView a chance to test the point to see if it | 676 // First, give the NonClientView a chance to test the point to see if it |
| 679 // provides any of the non-client area. | 677 // provides any of the non-client area. |
| 680 POINT temp = point; | 678 POINT temp = point; |
| 681 MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); | 679 MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); |
| 682 int component = delegate_->GetNonClientComponent(gfx::Point(temp)); | 680 int component = delegate_->GetNonClientComponent(gfx::Point(temp)); |
| 683 if (component != HTNOWHERE) | 681 if (component != HTNOWHERE) |
| 684 return component; | 682 return component; |
| 685 | 683 |
| 686 // Otherwise, we let Windows do all the native frame non-client handling for | 684 // Otherwise, we let Windows do all the native frame non-client handling for |
| 687 // us. | 685 // us. |
| 688 return WidgetWin::OnNCHitTest(point); | 686 return WidgetWin::OnNCHitTest(point); |
| 689 } | 687 } |
| 690 | 688 |
| 691 void WindowWin::OnNCPaint(HRGN rgn) { | 689 void WindowWin::OnNCPaint(HRGN rgn) { |
| 692 // When using a custom frame, we want to avoid calling DefWindowProc() since | 690 // When using a custom frame, we want to avoid calling DefWindowProc() since |
| 693 // that may render artifacts. | 691 // that may render artifacts. |
| 694 SetMsgHandled((!IsActive() || is_in_size_move_) && | 692 SetMsgHandled((!IsActive() || is_in_size_move_) && |
| 695 !GetWindow()->ShouldUseNativeFrame()); | 693 !delegate_->IsUsingNativeFrame()); |
| 696 } | 694 } |
| 697 | 695 |
| 698 LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param, | 696 LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param, |
| 699 LPARAM l_param) { | 697 LPARAM l_param) { |
| 700 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for | 698 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for |
| 701 // an explanation about why we need to handle this message. | 699 // an explanation about why we need to handle this message. |
| 702 SetMsgHandled(!GetWindow()->ShouldUseNativeFrame()); | 700 SetMsgHandled(!delegate_->IsUsingNativeFrame()); |
| 703 return 0; | 701 return 0; |
| 704 } | 702 } |
| 705 | 703 |
| 706 LRESULT WindowWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, | 704 LRESULT WindowWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, |
| 707 LPARAM l_param) { | 705 LPARAM l_param) { |
| 708 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for | 706 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for |
| 709 // an explanation about why we need to handle this message. | 707 // an explanation about why we need to handle this message. |
| 710 SetMsgHandled(!GetWindow()->ShouldUseNativeFrame()); | 708 SetMsgHandled(!delegate_->IsUsingNativeFrame()); |
| 711 return 0; | 709 return 0; |
| 712 } | 710 } |
| 713 | 711 |
| 714 LRESULT WindowWin::OnSetCursor(UINT msg, | 712 LRESULT WindowWin::OnSetCursor(UINT msg, |
| 715 WPARAM w_param, | 713 WPARAM w_param, |
| 716 LPARAM l_param) { | 714 LPARAM l_param) { |
| 717 // This shouldn't hurt even if we're using the native frame. | 715 // This shouldn't hurt even if we're using the native frame. |
| 718 ScopedRedrawLock lock(this); | 716 ScopedRedrawLock lock(this); |
| 719 return DefWindowProc(GetNativeView(), msg, w_param, l_param); | 717 return DefWindowProc(GetNativeView(), msg, w_param, l_param); |
| 720 } | 718 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 void WindowWin::OnSysCommand(UINT notification_code, CPoint click) { | 755 void WindowWin::OnSysCommand(UINT notification_code, CPoint click) { |
| 758 // Windows uses the 4 lower order bits of |notification_code| for type- | 756 // Windows uses the 4 lower order bits of |notification_code| for type- |
| 759 // specific information so we must exclude this when comparing. | 757 // specific information so we must exclude this when comparing. |
| 760 static const int sc_mask = 0xFFF0; | 758 static const int sc_mask = 0xFFF0; |
| 761 // Ignore size/move/maximize in fullscreen mode. | 759 // Ignore size/move/maximize in fullscreen mode. |
| 762 if (IsFullscreen() && | 760 if (IsFullscreen() && |
| 763 (((notification_code & sc_mask) == SC_SIZE) || | 761 (((notification_code & sc_mask) == SC_SIZE) || |
| 764 ((notification_code & sc_mask) == SC_MOVE) || | 762 ((notification_code & sc_mask) == SC_MOVE) || |
| 765 ((notification_code & sc_mask) == SC_MAXIMIZE))) | 763 ((notification_code & sc_mask) == SC_MAXIMIZE))) |
| 766 return; | 764 return; |
| 767 if (!GetWindow()->ShouldUseNativeFrame()) { | 765 if (!delegate_->IsUsingNativeFrame()) { |
| 768 if ((notification_code & sc_mask) == SC_MINIMIZE || | 766 if ((notification_code & sc_mask) == SC_MINIMIZE || |
| 769 (notification_code & sc_mask) == SC_MAXIMIZE || | 767 (notification_code & sc_mask) == SC_MAXIMIZE || |
| 770 (notification_code & sc_mask) == SC_RESTORE) { | 768 (notification_code & sc_mask) == SC_RESTORE) { |
| 771 GetWindow()->non_client_view()->ResetWindowControls(); | 769 GetWindow()->non_client_view()->ResetWindowControls(); |
| 772 } else if ((notification_code & sc_mask) == SC_MOVE || | 770 } else if ((notification_code & sc_mask) == SC_MOVE || |
| 773 (notification_code & sc_mask) == SC_SIZE) { | 771 (notification_code & sc_mask) == SC_SIZE) { |
| 774 if (lock_updates_) { | 772 if (lock_updates_) { |
| 775 // We were locked, before entering a resize or move modal loop. Now that | 773 // We were locked, before entering a resize or move modal loop. Now that |
| 776 // we've begun to move the window, we need to unlock updates so that the | 774 // we've begun to move the window, we need to unlock updates so that the |
| 777 // sizing/moving feedback can be continuous. | 775 // sizing/moving feedback can be continuous. |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION); | 1198 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION); |
| 1201 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF), | 1199 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF), |
| 1202 kDragFrameWindowAlpha, LWA_ALPHA); | 1200 kDragFrameWindowAlpha, LWA_ALPHA); |
| 1203 } else { | 1201 } else { |
| 1204 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_); | 1202 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_); |
| 1205 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_); | 1203 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_); |
| 1206 } | 1204 } |
| 1207 } | 1205 } |
| 1208 | 1206 |
| 1209 NonClientFrameView* WindowWin::CreateFrameViewForWindow() { | 1207 NonClientFrameView* WindowWin::CreateFrameViewForWindow() { |
| 1210 if (GetWindow()->ShouldUseNativeFrame()) | 1208 if (ShouldUseNativeFrame()) |
| 1211 return new NativeFrameView(GetWindow()); | 1209 return new NativeFrameView(GetWindow()); |
| 1212 return new CustomFrameView(GetWindow()); | 1210 return new CustomFrameView(GetWindow()); |
| 1213 } | 1211 } |
| 1214 | 1212 |
| 1215 void WindowWin::UpdateFrameAfterFrameChange() { | 1213 void WindowWin::UpdateFrameAfterFrameChange() { |
| 1216 // We've either gained or lost a custom window region, so reset it now. | 1214 // We've either gained or lost a custom window region, so reset it now. |
| 1217 ResetWindowRegion(true); | 1215 ResetWindowRegion(true); |
| 1218 } | 1216 } |
| 1219 | 1217 |
| 1220 gfx::NativeWindow WindowWin::GetNativeWindow() const { | 1218 gfx::NativeWindow WindowWin::GetNativeWindow() const { |
| 1221 return GetNativeView(); | 1219 return GetNativeView(); |
| 1222 } | 1220 } |
| 1223 | 1221 |
| 1224 bool WindowWin::ShouldUseNativeFrame() const { | 1222 bool WindowWin::ShouldUseNativeFrame() const { |
| 1225 return WidgetWin::IsAeroGlassEnabled(); | 1223 return WidgetWin::IsAeroGlassEnabled(); |
| 1226 } | 1224 } |
| 1227 | 1225 |
| 1228 void WindowWin::FrameTypeChanged() { | 1226 void WindowWin::FrameTypeChanged() { |
| 1229 // Called when the frame type could possibly be changing (theme change or | 1227 // Called when the frame type could possibly be changing (theme change or |
| 1230 // DWM composition change). | 1228 // DWM composition change). |
| 1231 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 1229 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 1232 // We need to toggle the rendering policy of the DWM/glass frame as we | 1230 // We need to toggle the rendering policy of the DWM/glass frame as we |
| 1233 // change from opaque to glass. "Non client rendering enabled" means that | 1231 // change from opaque to glass. "Non client rendering enabled" means that |
| 1234 // the DWM's glass non-client rendering is enabled, which is why | 1232 // the DWM's glass non-client rendering is enabled, which is why |
| 1235 // DWMNCRP_ENABLED is used for the native frame case. _DISABLED means the | 1233 // DWMNCRP_ENABLED is used for the native frame case. _DISABLED means the |
| 1236 // DWM doesn't render glass, and so is used in the custom frame case. | 1234 // DWM doesn't render glass, and so is used in the custom frame case. |
| 1237 DWMNCRENDERINGPOLICY policy = GetWindow()->ShouldUseNativeFrame() ? | 1235 DWMNCRENDERINGPOLICY policy = |
| 1238 DWMNCRP_ENABLED : DWMNCRP_DISABLED; | 1236 delegate_->IsUsingNativeFrame() ? DWMNCRP_ENABLED : DWMNCRP_DISABLED; |
| 1239 DwmSetWindowAttribute(GetNativeView(), DWMWA_NCRENDERING_POLICY, | 1237 DwmSetWindowAttribute(GetNativeView(), DWMWA_NCRENDERING_POLICY, |
| 1240 &policy, sizeof(DWMNCRENDERINGPOLICY)); | 1238 &policy, sizeof(DWMNCRENDERINGPOLICY)); |
| 1241 } | 1239 } |
| 1242 | 1240 |
| 1243 // Send a frame change notification, since the non-client metrics have | 1241 // Send a frame change notification, since the non-client metrics have |
| 1244 // changed. | 1242 // changed. |
| 1245 SendFrameChanged(GetNativeView()); | 1243 SendFrameChanged(GetNativeView()); |
| 1246 | 1244 |
| 1247 // Update the non-client view with the correct frame view for the active frame | 1245 // Update the non-client view with the correct frame view for the active frame |
| 1248 // type. | 1246 // type. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 } | 1300 } |
| 1303 | 1301 |
| 1304 void WindowWin::UnlockUpdates() { | 1302 void WindowWin::UnlockUpdates() { |
| 1305 SetWindowLong(GWL_STYLE, saved_window_style_); | 1303 SetWindowLong(GWL_STYLE, saved_window_style_); |
| 1306 lock_updates_ = false; | 1304 lock_updates_ = false; |
| 1307 } | 1305 } |
| 1308 | 1306 |
| 1309 void WindowWin::ResetWindowRegion(bool force) { | 1307 void WindowWin::ResetWindowRegion(bool force) { |
| 1310 // A native frame uses the native window region, and we don't want to mess | 1308 // A native frame uses the native window region, and we don't want to mess |
| 1311 // with it. | 1309 // with it. |
| 1312 if (GetWindow()->ShouldUseNativeFrame()) { | 1310 if (delegate_->IsUsingNativeFrame()) { |
| 1313 if (force) | 1311 if (force) |
| 1314 SetWindowRgn(NULL, TRUE); | 1312 SetWindowRgn(NULL, TRUE); |
| 1315 return; | 1313 return; |
| 1316 } | 1314 } |
| 1317 | 1315 |
| 1318 // Changing the window region is going to force a paint. Only change the | 1316 // Changing the window region is going to force a paint. Only change the |
| 1319 // window region if the region really differs. | 1317 // window region if the region really differs. |
| 1320 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); | 1318 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); |
| 1321 int current_rgn_result = GetWindowRgn(GetNativeView(), current_rgn); | 1319 int current_rgn_result = GetWindowRgn(GetNativeView(), current_rgn); |
| 1322 | 1320 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 //////////////////////////////////////////////////////////////////////////////// | 1363 //////////////////////////////////////////////////////////////////////////////// |
| 1366 // NativeWindow, public: | 1364 // NativeWindow, public: |
| 1367 | 1365 |
| 1368 // static | 1366 // static |
| 1369 NativeWindow* NativeWindow::CreateNativeWindow( | 1367 NativeWindow* NativeWindow::CreateNativeWindow( |
| 1370 internal::NativeWindowDelegate* delegate) { | 1368 internal::NativeWindowDelegate* delegate) { |
| 1371 return new WindowWin(delegate); | 1369 return new WindowWin(delegate); |
| 1372 } | 1370 } |
| 1373 | 1371 |
| 1374 } // namespace views | 1372 } // namespace views |
| OLD | NEW |