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

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

Issue 304007: Make sure the RootView is sized to the correct bounds when the opaque frame i... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/widget_win.h" 5 #include "views/widget/widget_win.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/native_theme_win.h" 8 #include "app/gfx/native_theme_win.h"
9 #include "app/gfx/path.h" 9 #include "app/gfx/path.h"
10 #include "app/l10n_util_win.h" 10 #include "app/l10n_util_win.h"
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 } 827 }
828 828
829 void WidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) { 829 void WidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
830 SetMsgHandled(FALSE); 830 SetMsgHandled(FALSE);
831 } 831 }
832 832
833 void WidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) { 833 void WidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
834 SetMsgHandled(FALSE); 834 SetMsgHandled(FALSE);
835 } 835 }
836 836
837 gfx::Size WidgetWin::GetRootViewSize() const {
838 CRect rect;
839 if (use_layered_buffer_)
840 GetWindowRect(&rect);
841 else
842 GetClientRect(&rect);
843
844 return gfx::Size(rect.Width(), rect.Height());
845 }
846
837 /////////////////////////////////////////////////////////////////////////////// 847 ///////////////////////////////////////////////////////////////////////////////
838 // WidgetWin, protected: 848 // WidgetWin, protected:
839 849
840 void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) { 850 void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) {
841 // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE 851 // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE
842 // when the user moves the mouse outside this HWND's bounds. 852 // when the user moves the mouse outside this HWND's bounds.
843 if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) { 853 if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) {
844 if (mouse_tracking_flags & TME_CANCEL) { 854 if (mouse_tracking_flags & TME_CANCEL) {
845 // We're about to cancel active mouse tracking, so empty out the stored 855 // We're about to cancel active mouse tracking, so empty out the stored
846 // state. 856 // state.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 953
944 void WidgetWin::ProcessMouseExited() { 954 void WidgetWin::ProcessMouseExited() {
945 last_mouse_event_was_move_ = false; 955 last_mouse_event_was_move_ = false;
946 root_view_->ProcessOnMouseExited(); 956 root_view_->ProcessOnMouseExited();
947 // Reset our tracking flag so that future mouse movement over this WidgetWin 957 // Reset our tracking flag so that future mouse movement over this WidgetWin
948 // results in a new tracking session. 958 // results in a new tracking session.
949 active_mouse_tracking_flags_ = 0; 959 active_mouse_tracking_flags_ = 0;
950 } 960 }
951 961
952 void WidgetWin::LayoutRootView() { 962 void WidgetWin::LayoutRootView() {
953 CRect rect; 963 gfx::Size size = GetRootViewSize();
Peter Kasting 2009/10/23 05:09:31 Nit: Constructor style?
954 if (SizeRootViewToWindowRect() || use_layered_buffer_) {
955 GetWindowRect(&rect);
956 } else {
957 GetClientRect(&rect);
958 }
959 964
960 if (use_layered_buffer_) 965 if (use_layered_buffer_)
961 SizeContents(rect); 966 SizeContents(size);
962 967
963 // Resizing changes the size of the view hierarchy and thus forces a 968 // Resizing changes the size of the view hierarchy and thus forces a
964 // complete relayout. 969 // complete relayout.
965 root_view_->SetBounds(0, 0, rect.Width(), rect.Height()); 970 root_view_->SetBounds(0, 0, size.width(), size.height());
966 root_view_->SchedulePaint(); 971 root_view_->SchedulePaint();
967 972
968 if (use_layered_buffer_) 973 if (use_layered_buffer_)
969 PaintNow(gfx::Rect(rect)); 974 PaintNow(gfx::Rect(0, 0, size.width(), size.height()));
970 } 975 }
971 976
972 bool WidgetWin::ReleaseCaptureOnMouseReleased() { 977 bool WidgetWin::ReleaseCaptureOnMouseReleased() {
973 return true; 978 return true;
974 } 979 }
975 980
976 RootView* WidgetWin::CreateRootView() { 981 RootView* WidgetWin::CreateRootView() {
977 return new RootView(this); 982 return new RootView(this);
978 } 983 }
979 984
980 /////////////////////////////////////////////////////////////////////////////// 985 ///////////////////////////////////////////////////////////////////////////////
981 // WidgetWin, private: 986 // WidgetWin, private:
982 987
983 // static 988 // static
984 Window* WidgetWin::GetWindowImpl(HWND hwnd) { 989 Window* WidgetWin::GetWindowImpl(HWND hwnd) {
985 // NOTE: we can't use GetAncestor here as constrained windows are a Window, 990 // NOTE: we can't use GetAncestor here as constrained windows are a Window,
986 // but not a top level window. 991 // but not a top level window.
987 HWND parent = hwnd; 992 HWND parent = hwnd;
988 while (parent) { 993 while (parent) {
989 WidgetWin* widget = 994 WidgetWin* widget =
990 reinterpret_cast<WidgetWin*>(win_util::GetWindowUserData(parent)); 995 reinterpret_cast<WidgetWin*>(win_util::GetWindowUserData(parent));
991 if (widget && widget->is_window_) 996 if (widget && widget->is_window_)
992 return static_cast<WindowWin*>(widget); 997 return static_cast<WindowWin*>(widget);
993 parent = ::GetParent(parent); 998 parent = ::GetParent(parent);
994 } 999 }
995 return NULL; 1000 return NULL;
996 } 1001 }
997 1002
998 void WidgetWin::SizeContents(const CRect& window_rect) { 1003 void WidgetWin::SizeContents(const gfx::Size& window_size) {
999 contents_.reset(new gfx::Canvas(window_rect.Width(), 1004 contents_.reset(new gfx::Canvas(window_size.width(),
1000 window_rect.Height(), 1005 window_size.height(),
1001 false)); 1006 false));
1002 } 1007 }
1003 1008
1004 void WidgetWin::PaintLayeredWindow() { 1009 void WidgetWin::PaintLayeredWindow() {
1005 // Painting monkeys with our cliprect, so we need to save it so that the 1010 // Painting monkeys with our cliprect, so we need to save it so that the
1006 // call to UpdateLayeredWindow updates the entire window, not just the 1011 // call to UpdateLayeredWindow updates the entire window, not just the
1007 // cliprect. 1012 // cliprect.
1008 contents_->save(SkCanvas::kClip_SaveFlag); 1013 contents_->save(SkCanvas::kClip_SaveFlag);
1009 gfx::Rect dirty_rect = root_view_->GetScheduledPaintRect(); 1014 gfx::Rect dirty_rect = root_view_->GetScheduledPaintRect();
1010 contents_->ClipRectInt(dirty_rect.x(), dirty_rect.y(), dirty_rect.width(), 1015 contents_->ClipRectInt(dirty_rect.x(), dirty_rect.y(), dirty_rect.width(),
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 WidgetWin* popup = new WidgetWin; 1159 WidgetWin* popup = new WidgetWin;
1155 popup->set_window_style(WS_POPUP); 1160 popup->set_window_style(WS_POPUP);
1156 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | 1161 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
1157 WS_EX_TRANSPARENT | 1162 WS_EX_TRANSPARENT |
1158 l10n_util::GetExtendedTooltipStyles()); 1163 l10n_util::GetExtendedTooltipStyles());
1159 popup->set_delete_on_destroy(delete_on_destroy); 1164 popup->set_delete_on_destroy(delete_on_destroy);
1160 return popup; 1165 return popup;
1161 } 1166 }
1162 1167
1163 } // namespace views 1168 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698