| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/hwnd_view.h" | 5 #include "chrome/views/hwnd_view.h" |
| 6 | 6 |
| 7 #include "chrome/common/gfx/chrome_canvas.h" | 7 #include "chrome/common/gfx/chrome_canvas.h" |
| 8 #include "chrome/common/win_util.h" | 8 #include "chrome/common/win_util.h" |
| 9 #include "chrome/views/focus_manager.h" | 9 #include "chrome/views/focus_manager.h" |
| 10 #include "chrome/views/scroll_view.h" | 10 #include "chrome/views/scroll_view.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 void HWNDView::UpdateHWNDBounds() { | 66 void HWNDView::UpdateHWNDBounds() { |
| 67 if (!hwnd_) | 67 if (!hwnd_) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 // Since HWNDs know nothing about the View hierarchy (they are direct children | 70 // Since HWNDs know nothing about the View hierarchy (they are direct children |
| 71 // of the ViewContainer that hosts our View hierarchy) they need to be | 71 // of the ViewContainer that hosts our View hierarchy) they need to be |
| 72 // positioned in the coordinate system of the ViewContainer, not the current | 72 // positioned in the coordinate system of the ViewContainer, not the current |
| 73 // view. | 73 // view. |
| 74 CPoint top_left; | 74 gfx::Point top_left; |
| 75 | |
| 76 top_left.x = top_left.y = 0; | |
| 77 ConvertPointToViewContainer(this, &top_left); | 75 ConvertPointToViewContainer(this, &top_left); |
| 78 | 76 |
| 79 gfx::Rect vis_bounds = GetVisibleBounds(); | 77 gfx::Rect vis_bounds = GetVisibleBounds(); |
| 80 bool visible = !vis_bounds.IsEmpty(); | 78 bool visible = !vis_bounds.IsEmpty(); |
| 81 | 79 |
| 82 if (visible && !fast_resize_) { | 80 if (visible && !fast_resize_) { |
| 83 if (vis_bounds.width() != bounds_.Width() || | 81 if (vis_bounds.width() != bounds_.Width() || |
| 84 vis_bounds.height() != bounds_.Height()) { | 82 vis_bounds.height() != bounds_.Height()) { |
| 85 // Only a portion of the HWND is really visible. | 83 // Only a portion of the HWND is really visible. |
| 86 int x = vis_bounds.x(); | 84 int x = vis_bounds.x(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 107 SWP_NOOWNERZORDER | | 105 SWP_NOOWNERZORDER | |
| 108 SWP_NOZORDER; | 106 SWP_NOZORDER; |
| 109 // Only send the SHOWWINDOW flag if we're invisible, to avoid flashing. | 107 // Only send the SHOWWINDOW flag if we're invisible, to avoid flashing. |
| 110 if (!::IsWindowVisible(hwnd_)) | 108 if (!::IsWindowVisible(hwnd_)) |
| 111 swp_flags = (swp_flags | SWP_SHOWWINDOW) & ~SWP_NOREDRAW; | 109 swp_flags = (swp_flags | SWP_SHOWWINDOW) & ~SWP_NOREDRAW; |
| 112 | 110 |
| 113 if (fast_resize_) { | 111 if (fast_resize_) { |
| 114 // In a fast resize, we move the window and clip it with SetWindowRgn. | 112 // In a fast resize, we move the window and clip it with SetWindowRgn. |
| 115 CRect rect; | 113 CRect rect; |
| 116 GetWindowRect(hwnd_, &rect); | 114 GetWindowRect(hwnd_, &rect); |
| 117 ::SetWindowPos(hwnd_, 0, top_left.x, top_left.y, rect.Width(), | 115 ::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), rect.Width(), |
| 118 rect.Height(), swp_flags); | 116 rect.Height(), swp_flags); |
| 119 | 117 |
| 120 HRGN clip_region = CreateRectRgn(0, 0, | 118 HRGN clip_region = CreateRectRgn(0, 0, |
| 121 bounds_.Width(), | 119 bounds_.Width(), |
| 122 bounds_.Height()); | 120 bounds_.Height()); |
| 123 SetWindowRgn(hwnd_, clip_region, FALSE); | 121 SetWindowRgn(hwnd_, clip_region, FALSE); |
| 124 installed_clip_ = true; | 122 installed_clip_ = true; |
| 125 } else { | 123 } else { |
| 126 ::SetWindowPos(hwnd_, 0, top_left.x, top_left.y, bounds_.Width(), | 124 ::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), bounds_.Width(), |
| 127 bounds_.Height(), swp_flags); | 125 bounds_.Height(), swp_flags); |
| 128 } | 126 } |
| 129 } else if (::IsWindowVisible(hwnd_)) { | 127 } else if (::IsWindowVisible(hwnd_)) { |
| 130 // The window is currently visible, but its clipped by another view. Hide | 128 // The window is currently visible, but its clipped by another view. Hide |
| 131 // it. | 129 // it. |
| 132 ::SetWindowPos(hwnd_, 0, 0, 0, 0, 0, | 130 ::SetWindowPos(hwnd_, 0, 0, 0, 0, 0, |
| 133 SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | | 131 SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | |
| 134 SWP_NOREDRAW | SWP_NOOWNERZORDER ); | 132 SWP_NOREDRAW | SWP_NOOWNERZORDER ); |
| 135 } | 133 } |
| 136 } | 134 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0, | 192 canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0, |
| 195 bounds_.Width(), bounds_.Height()); | 193 bounds_.Width(), bounds_.Height()); |
| 196 } | 194 } |
| 197 | 195 |
| 198 std::string HWNDView::GetClassName() const { | 196 std::string HWNDView::GetClassName() const { |
| 199 return kViewClassName; | 197 return kViewClassName; |
| 200 } | 198 } |
| 201 | 199 |
| 202 } | 200 } |
| 203 | 201 |
| OLD | NEW |