diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-12 19:29:06 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-12 19:29:06 +0000 |
commit | ed8b1b805203b6ccdb5517d0c30cc689dde65e98 (patch) | |
tree | 88b8d0c2e552f291fbb01e8aa660806597e9d3fc /chrome/views | |
parent | 71994cd0877f3528079b1154d46d90801e515292 (diff) | |
download | chromium_src-ed8b1b805203b6ccdb5517d0c30cc689dde65e98.zip chromium_src-ed8b1b805203b6ccdb5517d0c30cc689dde65e98.tar.gz chromium_src-ed8b1b805203b6ccdb5517d0c30cc689dde65e98.tar.bz2 |
Make Widget return a gfx::NativeView instead of a HWND.
Review URL: http://codereview.chromium.org/43124
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11562 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r-- | chrome/views/accessibility/view_accessibility.cc | 4 | ||||
-rw-r--r-- | chrome/views/bitmap_scroll_bar.cc | 2 | ||||
-rw-r--r-- | chrome/views/button_dropdown.cc | 8 | ||||
-rw-r--r-- | chrome/views/chrome_menu.cc | 6 | ||||
-rw-r--r-- | chrome/views/focus_manager.cc | 2 | ||||
-rw-r--r-- | chrome/views/focus_manager_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/views/hwnd_view.cc | 4 | ||||
-rw-r--r-- | chrome/views/menu_button.cc | 4 | ||||
-rw-r--r-- | chrome/views/native_control.cc | 2 | ||||
-rw-r--r-- | chrome/views/native_frame_view.cc | 2 | ||||
-rw-r--r-- | chrome/views/native_scroll_bar.cc | 4 | ||||
-rw-r--r-- | chrome/views/non_client_view.cc | 6 | ||||
-rw-r--r-- | chrome/views/root_view.cc | 6 | ||||
-rw-r--r-- | chrome/views/root_view_drop_target.cc | 2 | ||||
-rw-r--r-- | chrome/views/text_field.cc | 2 | ||||
-rw-r--r-- | chrome/views/tree_view.cc | 2 | ||||
-rw-r--r-- | chrome/views/view_win.cc | 4 | ||||
-rw-r--r-- | chrome/views/widget.h | 11 | ||||
-rw-r--r-- | chrome/views/widget_win.cc | 26 | ||||
-rw-r--r-- | chrome/views/widget_win.h | 40 | ||||
-rw-r--r-- | chrome/views/window.cc | 93 |
21 files changed, 116 insertions, 120 deletions
diff --git a/chrome/views/accessibility/view_accessibility.cc b/chrome/views/accessibility/view_accessibility.cc index 555009e..35ab3e1 100644 --- a/chrome/views/accessibility/view_accessibility.cc +++ b/chrome/views/accessibility/view_accessibility.cc @@ -84,7 +84,7 @@ STDMETHODIMP ViewAccessibility::get_accParent(IDispatch** disp_parent) { if (!parent_view) { // This function can get called during teardown of WidetWin so we // should bail out if we fail to get the HWND. - if (!view_->GetWidget() || !view_->GetWidget()->GetHWND()) { + if (!view_->GetWidget() || !view_->GetWidget()->GetNativeView()) { *disp_parent = NULL; return S_FALSE; } @@ -93,7 +93,7 @@ STDMETHODIMP ViewAccessibility::get_accParent(IDispatch** disp_parent) { // the default implementation, to interface with Windows' hierarchy and to // support calls from e.g. WindowFromAccessibleObject. HRESULT hr = - ::AccessibleObjectFromWindow(view_->GetWidget()->GetHWND(), + ::AccessibleObjectFromWindow(view_->GetWidget()->GetNativeView(), OBJID_WINDOW, IID_IAccessible, reinterpret_cast<void**>(disp_parent)); diff --git a/chrome/views/bitmap_scroll_bar.cc b/chrome/views/bitmap_scroll_bar.cc index 686954d..98ad4ad 100644 --- a/chrome/views/bitmap_scroll_bar.cc +++ b/chrome/views/bitmap_scroll_bar.cc @@ -538,7 +538,7 @@ void BitmapScrollBar::ShowContextMenu(View* source, View::ConvertPointFromWidget(this, &temp_pt); context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); - Menu menu(this, Menu::TOPLEFT, GetWidget()->GetHWND()); + Menu menu(this, Menu::TOPLEFT, GetWidget()->GetNativeView()); menu.AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); menu.AppendSeparator(); menu.AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); diff --git a/chrome/views/button_dropdown.cc b/chrome/views/button_dropdown.cc index 6c587ae..6428598 100644 --- a/chrome/views/button_dropdown.cc +++ b/chrome/views/button_dropdown.cc @@ -48,7 +48,7 @@ bool ButtonDropDown::OnMousePressed(const MouseEvent& e) { // Schedule a task that will show the menu. MessageLoop::current()->PostDelayedTask(FROM_HERE, show_menu_factory_.NewRunnableMethod(&ButtonDropDown::ShowDropDownMenu, - GetWidget()->GetHWND()), + GetWidget()->GetNativeView()), kMenuTimerDelay); } @@ -72,7 +72,7 @@ void ButtonDropDown::OnMouseReleased(const MouseEvent& e, bool canceled) { // update the appearance synchronously. SetState(BS_PUSHED); PaintNow(); - ShowDropDownMenu(GetWidget()->GetHWND()); + ShowDropDownMenu(GetWidget()->GetNativeView()); } } @@ -90,7 +90,7 @@ bool ButtonDropDown::OnMouseDragged(const MouseEvent& e) { // it immediately. if (e.y() > y_position_on_lbuttondown_ + dragging_threshold) { show_menu_factory_.RevokeAll(); - ShowDropDownMenu(GetWidget()->GetHWND()); + ShowDropDownMenu(GetWidget()->GetNativeView()); } } @@ -111,7 +111,7 @@ void ButtonDropDown::ShowContextMenu(int x, int y, bool is_mouse_gesture) { // update the appearance synchronously. SetState(BS_PUSHED); PaintNow(); - ShowDropDownMenu(GetWidget()->GetHWND()); + ShowDropDownMenu(GetWidget()->GetNativeView()); SetState(BS_HOT); } diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc index ef33e6a..c8df05e 100644 --- a/chrome/views/chrome_menu.cc +++ b/chrome/views/chrome_menu.cc @@ -2661,7 +2661,7 @@ bool MenuController::IsMenuWindow(MenuItemView* item, HWND window) { if (!item) return false; return ((item->HasSubmenu() && item->GetSubmenu()->IsShowing() && - item->GetSubmenu()->GetWidget()->GetHWND() == window) || + item->GetSubmenu()->GetWidget()->GetNativeView() == window) || IsMenuWindow(item->GetParentMenuItem(), window)); } @@ -2739,8 +2739,8 @@ void MenuController::RepostEvent(SubmenuView* source, SubmenuView* submenu = state_.item->GetRootMenuItem()->GetSubmenu(); submenu->ReleaseCapture(); - if (submenu->host() && submenu->host()->GetHWND() && - GetWindowThreadProcessId(submenu->host()->GetHWND(), NULL) != + if (submenu->host() && submenu->host()->GetNativeView() && + GetWindowThreadProcessId(submenu->host()->GetNativeView(), NULL) != GetWindowThreadProcessId(window, NULL)) { // Even though we have mouse capture, windows generates a mouse event // if the other window is in a separate thread. Don't generate an event in diff --git a/chrome/views/focus_manager.cc b/chrome/views/focus_manager.cc index 093b0a4..8924f5e 100644 --- a/chrome/views/focus_manager.cc +++ b/chrome/views/focus_manager.cc @@ -471,7 +471,7 @@ bool FocusManager::ContainsView(View* view) { if (!widget) return false; - HWND window = widget->GetHWND(); + HWND window = widget->GetNativeView(); while (window) { if (window == root_) return true; diff --git a/chrome/views/focus_manager_unittest.cc b/chrome/views/focus_manager_unittest.cc index 1207bbb..736fcbe 100644 --- a/chrome/views/focus_manager_unittest.cc +++ b/chrome/views/focus_manager_unittest.cc @@ -517,7 +517,7 @@ void FocusManagerTest::SetUp() { OleInitialize(NULL); test_window_ = new TestViewWindow(this); test_window_->Init(); - ShowWindow(test_window_->GetHWND(), SW_SHOW); + ShowWindow(test_window_->GetNativeView(), SW_SHOW); } void FocusManagerTest::TearDown() { @@ -550,7 +550,7 @@ TEST_F(FocusManagerTest, NormalTraversal) { // MessageLoop::current()->Run(new views::AcceleratorHandler()); views::FocusManager* focus_manager = - views::FocusManager::GetFocusManager(test_window_->GetHWND()); + views::FocusManager::GetFocusManager(test_window_->GetNativeView()); // Let's traverse the whole focus hierarchy (several times, to make sure it // loops OK). focus_manager->SetFocusedView(NULL); @@ -627,7 +627,7 @@ TEST_F(FocusManagerTest, TraversalWithNonEnabledViews) { views::FocusManager* focus_manager = - views::FocusManager::GetFocusManager(test_window_->GetHWND()); + views::FocusManager::GetFocusManager(test_window_->GetNativeView()); views::View* focused_view; // Let's do one traversal (several times, to make sure it loops ok). for (int i = 0; i < 3;++i) { diff --git a/chrome/views/hwnd_view.cc b/chrome/views/hwnd_view.cc index 4df2b42..a89e5f9 100644 --- a/chrome/views/hwnd_view.cc +++ b/chrome/views/hwnd_view.cc @@ -40,7 +40,7 @@ void HWNDView::Attach(HWND hwnd) { ShowWindow(hwnd_, SW_HIDE); // Need to set the HWND's parent before changing its size to avoid flashing. - ::SetParent(hwnd_, GetWidget()->GetHWND()); + ::SetParent(hwnd_, GetWidget()->GetNativeView()); UpdateHWNDBounds(); // Register with the focus manager so the associated view is focused when the @@ -151,7 +151,7 @@ void HWNDView::ViewHierarchyChanged(bool is_add, View *parent, View *child) { Widget* widget = GetWidget(); if (is_add && widget) { HWND parent = ::GetParent(hwnd_); - HWND widget_hwnd = widget->GetHWND(); + HWND widget_hwnd = widget->GetNativeView(); if (parent != widget_hwnd) { ::SetParent(hwnd_, widget_hwnd); } diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc index ad8ace1..09a9318 100644 --- a/chrome/views/menu_button.cc +++ b/chrome/views/menu_button.cc @@ -111,7 +111,7 @@ int MenuButton::GetMaximumScreenXCoordinate() { return 0; } - HWND hwnd = widget->GetHWND(); + HWND hwnd = widget->GetNativeView(); CRect t; ::GetWindowRect(hwnd, &t); @@ -157,7 +157,7 @@ bool MenuButton::Activate() { menu_visible_ = true; menu_delegate_->RunMenu(this, menu_position.ToPOINT(), - GetWidget()->GetHWND()); + GetWidget()->GetNativeView()); menu_visible_ = false; menu_closed_time_ = Time::Now(); diff --git a/chrome/views/native_control.cc b/chrome/views/native_control.cc index 884af0e..ba7bc5d 100644 --- a/chrome/views/native_control.cc +++ b/chrome/views/native_control.cc @@ -38,7 +38,7 @@ class NativeControlContainer : public CWindowImpl<NativeControlContainer, explicit NativeControlContainer(NativeControl* parent) : parent_(parent), control_(NULL) { - Create(parent->GetWidget()->GetHWND()); + Create(parent->GetWidget()->GetNativeView()); ::ShowWindow(m_hWnd, SW_SHOW); } diff --git a/chrome/views/native_frame_view.cc b/chrome/views/native_frame_view.cc index 20b6f13..ee8eea2 100644 --- a/chrome/views/native_frame_view.cc +++ b/chrome/views/native_frame_view.cc @@ -36,7 +36,7 @@ gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds( gfx::Point NativeFrameView::GetSystemMenuPoint() const { POINT temp = {0, -kFrameShadowThickness }; - MapWindowPoints(frame_->GetHWND(), HWND_DESKTOP, &temp, 1); + MapWindowPoints(frame_->GetNativeView(), HWND_DESKTOP, &temp, 1); return gfx::Point(temp); } diff --git a/chrome/views/native_scroll_bar.cc b/chrome/views/native_scroll_bar.cc index 3bc2c7f..c789130 100644 --- a/chrome/views/native_scroll_bar.cc +++ b/chrome/views/native_scroll_bar.cc @@ -30,7 +30,7 @@ class ScrollBarContainer : public CWindowImpl<ScrollBarContainer, public: ScrollBarContainer(ScrollBar* parent) : parent_(parent), scrollbar_(NULL) { - Create(parent->GetWidget()->GetHWND()); + Create(parent->GetWidget()->GetNativeView()); ::ShowWindow(m_hWnd, SW_SHOW); } @@ -127,7 +127,7 @@ class ScrollBarContainer : public CWindowImpl<ScrollBarContainer, // component focused so we actually get mousewheel events. if (source != NULL) { Widget* widget = parent_->GetWidget(); - if (widget && widget->GetHWND() != GetFocus()) { + if (widget && widget->GetNativeView() != GetFocus()) { parent_->RequestFocus(); } } diff --git a/chrome/views/non_client_view.cc b/chrome/views/non_client_view.cc index 18e90b7..46bea84 100644 --- a/chrome/views/non_client_view.cc +++ b/chrome/views/non_client_view.cc @@ -63,21 +63,21 @@ void NonClientView::SystemThemeChanged() { // everything has settled down. WINDOWPLACEMENT saved_window_placement; saved_window_placement.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(frame_->GetHWND(), &saved_window_placement); + GetWindowPlacement(frame_->GetNativeView(), &saved_window_placement); frame_->Hide(); // Important step: restore the window first, since our hiding hack doesn't // work for maximized windows! We tell the frame not to allow itself to be // made visible though, which removes the brief flicker. frame_->set_force_hidden(true); - ShowWindow(frame_->GetHWND(), SW_RESTORE); + ShowWindow(frame_->GetNativeView(), SW_RESTORE); frame_->set_force_hidden(false); SetUseNativeFrame(win_util::ShouldUseVistaFrame()); // Now that we've updated the frame, we'll want to restore our saved placement // since the display should have settled down and we can be properly rendered. - SetWindowPlacement(frame_->GetHWND(), &saved_window_placement); + SetWindowPlacement(frame_->GetNativeView(), &saved_window_placement); } void NonClientView::SetUseNativeFrame(bool use_native_frame) { diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc index 3fa5956..861d3c9 100644 --- a/chrome/views/root_view.cc +++ b/chrome/views/root_view.cc @@ -325,7 +325,7 @@ bool RootView::OnMousePressed(const MouseEvent& e) { if (focus_on_mouse_pressed_) { #if defined(OS_WIN) - HWND hwnd = GetWidget()->GetHWND(); + HWND hwnd = GetWidget()->GetNativeView(); if (::GetFocus() != hwnd) { ::SetFocus(hwnd); } @@ -480,7 +480,7 @@ void RootView::OnWidgetCreated() { void RootView::OnWidgetDestroyed() { #if defined(OS_WIN) if (drop_target_.get()) { - RevokeDragDrop(GetWidget()->GetHWND()); + RevokeDragDrop(GetWidget()->GetNativeView()); drop_target_ = NULL; } #else @@ -508,7 +508,7 @@ void RootView::FocusView(View* view) { #if defined(OS_WIN) FocusManager* focus_manager = GetFocusManager(); DCHECK(focus_manager) << "No Focus Manager for Window " << - (GetWidget() ? GetWidget()->GetHWND() : 0); + (GetWidget() ? GetWidget()->GetNativeView() : 0); if (!focus_manager) return; diff --git a/chrome/views/root_view_drop_target.cc b/chrome/views/root_view_drop_target.cc index 8ce79c2..83e301f 100644 --- a/chrome/views/root_view_drop_target.cc +++ b/chrome/views/root_view_drop_target.cc @@ -13,7 +13,7 @@ namespace views { RootViewDropTarget::RootViewDropTarget(RootView* root_view) - : BaseDropTarget(root_view->GetWidget()->GetHWND()), + : BaseDropTarget(root_view->GetWidget()->GetNativeView()), root_view_(root_view), target_view_(NULL), deepest_view_(NULL) { diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc index 10a154c..1c62b14 100644 --- a/chrome/views/text_field.cc +++ b/chrome/views/text_field.cc @@ -272,7 +272,7 @@ TextField::Edit::Edit(TextField* parent, bool draw_border) DWORD ex_style = l10n_util::GetExtendedStyles(); RECT r = {0, 0, parent_->width(), parent_->height()}; - Create(parent_->GetWidget()->GetHWND(), r, NULL, style, ex_style); + Create(parent_->GetWidget()->GetNativeView(), r, NULL, style, ex_style); if (parent->GetStyle() & TextField::STYLE_LOWERCASE) { DCHECK((parent->GetStyle() & TextField::STYLE_PASSWORD) == 0); diff --git a/chrome/views/tree_view.cc b/chrome/views/tree_view.cc index 7166a31..764d6c7 100644 --- a/chrome/views/tree_view.cc +++ b/chrome/views/tree_view.cc @@ -466,7 +466,7 @@ bool TreeView::OnKeyDown(int virtual_key_code) { } else if (virtual_key_code == VK_RETURN && !process_enter_) { Widget* widget = GetWidget(); DCHECK(widget); - FocusManager* fm = FocusManager::GetFocusManager(widget->GetHWND()); + FocusManager* fm = FocusManager::GetFocusManager(widget->GetNativeView()); DCHECK(fm); Accelerator accelerator(Accelerator(static_cast<int>(virtual_key_code), win_util::IsShiftPressed(), diff --git a/chrome/views/view_win.cc b/chrome/views/view_win.cc index 190d21f..a69bf77 100644 --- a/chrome/views/view_win.cc +++ b/chrome/views/view_win.cc @@ -21,7 +21,7 @@ FocusManager* View::GetFocusManager() { if (!widget) return NULL; - HWND hwnd = widget->GetHWND(); + HWND hwnd = widget->GetNativeView(); if (!hwnd) return NULL; @@ -71,7 +71,7 @@ void View::Focus() { // messages. FocusManager* focus_manager = GetFocusManager(); if (focus_manager) - focus_manager->FocusHWND(GetRootView()->GetWidget()->GetHWND()); + focus_manager->FocusHWND(GetRootView()->GetWidget()->GetNativeView()); } int View::GetHorizontalDragThreshold() { diff --git a/chrome/views/widget.h b/chrome/views/widget.h index d3c4e08..46aa754 100644 --- a/chrome/views/widget.h +++ b/chrome/views/widget.h @@ -5,10 +5,7 @@ #ifndef CHROME_VIEWS_WIDGET_H_ #define CHROME_VIEWS_WIDGET_H_ -#if defined(OS_WIN) -// TODO(maruel): Remove once HWND is abstracted. -#include <windows.h> -#endif +#include "base/gfx/native_widget_types.h" namespace gfx { class Rect; @@ -51,10 +48,8 @@ class Widget { // the window should also become the active window. virtual void MoveToFront(bool should_activate) = 0; -#if defined(OS_WIN) - // Returns the Window HWND associated with this Widget. - virtual HWND GetHWND() const = 0; -#endif + // Returns the gfx::NativeView associated with this Widget. + virtual gfx::NativeView GetNativeView() const = 0; // Forces a paint of a specified rectangle immediately. virtual void PaintNow(const gfx::Rect& update_rect) = 0; diff --git a/chrome/views/widget_win.cc b/chrome/views/widget_win.cc index 29c04a5..e5a8891 100644 --- a/chrome/views/widget_win.cc +++ b/chrome/views/widget_win.cc @@ -186,21 +186,21 @@ void WidgetWin::Init(HWND parent, const gfx::Rect& bounds, // that window controls in Chrome windows don't flicker when you move your // mouse over them. See comment in aero_tooltip_manager.h. if (win_util::ShouldUseVistaFrame()) { - tooltip_manager_.reset(new AeroTooltipManager(this, GetHWND())); + tooltip_manager_.reset(new AeroTooltipManager(this, GetNativeView())); } else { - tooltip_manager_.reset(new TooltipManager(this, GetHWND())); + tooltip_manager_.reset(new TooltipManager(this, GetNativeView())); } // This message initializes the window so that focus border are shown for // windows. - ::SendMessage(GetHWND(), + ::SendMessage(GetNativeView(), WM_CHANGEUISTATE, MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0); // Bug 964884: detach the IME attached to this window. // We should attach IMEs only when we need to input CJK strings. - ::ImmAssociateContextEx(GetHWND(), NULL, 0); + ::ImmAssociateContextEx(GetNativeView(), NULL, 0); } void WidgetWin::SetContentsView(View* view) { @@ -245,12 +245,12 @@ void WidgetWin::MoveToFront(bool should_activate) { // Keep the window topmost if it was already topmost. WINDOWINFO wi; wi.cbSize = sizeof WINDOWINFO; - GetWindowInfo(GetHWND(), &wi); + GetWindowInfo(GetNativeView(), &wi); SetWindowPos((wi.dwExStyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, flags); } -HWND WidgetWin::GetHWND() const { +gfx::NativeView WidgetWin::GetNativeView() const { return hwnd_; } @@ -292,11 +292,11 @@ RootView* WidgetWin::GetRootView() { } bool WidgetWin::IsVisible() { - return !!::IsWindowVisible(GetHWND()); + return !!::IsWindowVisible(GetNativeView()); } bool WidgetWin::IsActive() { - return win_util::IsWindowActive(GetHWND()); + return win_util::IsWindowActive(GetNativeView()); } TooltipManager* WidgetWin::GetTooltipManager() { @@ -510,7 +510,7 @@ LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) { } // Notify that an instance of IAccessible was allocated for m_hWnd - ::NotifyWinEvent(EVENT_OBJECT_CREATE, GetHWND(), OBJID_CLIENT, + ::NotifyWinEvent(EVENT_OBJECT_CREATE, GetNativeView(), OBJID_CLIENT, CHILDID_SELF); } @@ -619,7 +619,7 @@ LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) { // NC points are in screen coordinates. CPoint temp = point; - MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); + MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); ProcessMouseMoved(temp, 0, true); // We need to process this message to stop Windows from drawing the window @@ -655,7 +655,7 @@ LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) { } void WidgetWin::OnPaint(HDC dc) { - root_view_->OnPaint(GetHWND()); + root_view_->OnPaint(GetNativeView()); } void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { @@ -709,7 +709,7 @@ void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(tme); tme.dwFlags = mouse_tracking_flags; - tme.hwndTrack = GetHWND(); + tme.hwndTrack = GetNativeView(); tme.dwHoverTime = 0; TrackMouseEvent(&tme); } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { @@ -821,7 +821,7 @@ void WidgetWin::AdjustWindowToFitScreenSize() { gfx::Rect new_window_rect = window_rect.AdjustToFit(monitor_rect); if (!new_window_rect.Equals(window_rect)) { // New position differs from last, resize window. - ::SetWindowPos(GetHWND(), + ::SetWindowPos(GetNativeView(), 0, new_window_rect.x(), new_window_rect.y(), diff --git a/chrome/views/widget_win.h b/chrome/views/widget_win.h index cf2274e..f13051c 100644 --- a/chrome/views/widget_win.h +++ b/chrome/views/widget_win.h @@ -251,7 +251,7 @@ class WidgetWin : public Widget, // Overridden from Widget: virtual void GetBounds(gfx::Rect* out, bool including_frame) const; virtual void MoveToFront(bool should_activate); - virtual HWND GetHWND() const; + virtual gfx::NativeView GetNativeView() const; virtual void PaintNow(const gfx::Rect& update_rect); virtual RootView* GetRootView(); virtual bool IsVisible(); @@ -285,35 +285,35 @@ class WidgetWin : public Widget, } BOOL IsWindow() const { - return ::IsWindow(GetHWND()); + return ::IsWindow(GetNativeView()); } BOOL ShowWindow(int command) { - DCHECK(::IsWindow(GetHWND())); - return ::ShowWindow(GetHWND(), command); + DCHECK(::IsWindow(GetNativeView())); + return ::ShowWindow(GetNativeView(), command); } HWND SetCapture() { - DCHECK(::IsWindow(GetHWND())); - return ::SetCapture(GetHWND()); + DCHECK(::IsWindow(GetNativeView())); + return ::SetCapture(GetNativeView()); } HWND GetParent() const { - return ::GetParent(GetHWND()); + return ::GetParent(GetNativeView()); } BOOL GetWindowRect(RECT* rect) const { - return ::GetWindowRect(GetHWND(), rect); + return ::GetWindowRect(GetNativeView(), rect); } BOOL SetWindowPos(HWND hwnd_after, int x, int y, int cx, int cy, UINT flags) { - DCHECK(::IsWindow(GetHWND())); - return ::SetWindowPos(GetHWND(), hwnd_after, x, y, cx, cy, flags); + DCHECK(::IsWindow(GetNativeView())); + return ::SetWindowPos(GetNativeView(), hwnd_after, x, y, cx, cy, flags); } BOOL IsZoomed() const { - DCHECK(::IsWindow(GetHWND())); - return ::IsZoomed(GetHWND()); + DCHECK(::IsWindow(GetNativeView())); + return ::IsZoomed(GetNativeView()); } BOOL MoveWindow(int x, int y, int width, int height) { @@ -321,26 +321,26 @@ class WidgetWin : public Widget, } BOOL MoveWindow(int x, int y, int width, int height, BOOL repaint) { - DCHECK(::IsWindow(GetHWND())); - return ::MoveWindow(GetHWND(), x, y, width, height, repaint); + DCHECK(::IsWindow(GetNativeView())); + return ::MoveWindow(GetNativeView(), x, y, width, height, repaint); } int SetWindowRgn(HRGN region, BOOL redraw) { - DCHECK(::IsWindow(GetHWND())); - return ::SetWindowRgn(GetHWND(), region, redraw); + DCHECK(::IsWindow(GetNativeView())); + return ::SetWindowRgn(GetNativeView(), region, redraw); } BOOL GetClientRect(RECT* rect) const { - DCHECK(::IsWindow(GetHWND())); - return ::GetClientRect(GetHWND(), rect); + DCHECK(::IsWindow(GetNativeView())); + return ::GetClientRect(GetNativeView(), rect); } protected: // Call close instead of this to Destroy the window. BOOL DestroyWindow() { - DCHECK(::IsWindow(GetHWND())); - return ::DestroyWindow(GetHWND()); + DCHECK(::IsWindow(GetNativeView())); + return ::DestroyWindow(GetNativeView()); } // Message Handlers diff --git a/chrome/views/window.cc b/chrome/views/window.cc index 0548fa4..4bf24ee 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -95,16 +95,16 @@ gfx::Size Window::CalculateMaximumSize() const { // rect of the display the window is on, less padding. If this is a child // (constrained) window, the maximum size of this Window are the bounds of the // parent window, less padding. - DCHECK(GetHWND()) << "Cannot calculate maximum size before Init() is called"; + DCHECK(GetNativeView()) << "Cannot calculate maximum size before Init() is called"; gfx::Rect working_rect; - HWND parent_hwnd = ::GetParent(GetHWND()); + HWND parent_hwnd = ::GetParent(GetNativeView()); if (parent_hwnd) { RECT parent_rect; ::GetClientRect(parent_hwnd, &parent_rect); working_rect = parent_rect; } else { HMONITOR current_monitor = - ::MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST); + ::MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST); MONITORINFO mi; mi.cbSize = sizeof(mi); ::GetMonitorInfo(current_monitor, &mi); @@ -150,9 +150,9 @@ int Window::GetShowState() const { void Window::Activate() { if (IsMinimized()) - ::ShowWindow(GetHWND(), SW_RESTORE); - ::SetWindowPos(GetHWND(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); - SetForegroundWindow(GetHWND()); + ::ShowWindow(GetNativeView(), SW_RESTORE); + ::SetWindowPos(GetNativeView(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + SetForegroundWindow(GetNativeView()); } void Window::SetBounds(const gfx::Rect& bounds) { @@ -160,7 +160,7 @@ void Window::SetBounds(const gfx::Rect& bounds) { } void Window::SetBounds(const gfx::Rect& bounds, HWND other_hwnd) { - win_util::SetChildBounds(GetHWND(), GetParent(), other_hwnd, bounds, + win_util::SetChildBounds(GetNativeView(), GetParent(), other_hwnd, bounds, kMonitorEdgePadding, 0); } @@ -181,7 +181,7 @@ void Window::Close() { // closes us, we want our owner to gain activation. But only if the owner // is visible. If we don't manually force that here, the other app will // regain activation instead. - if (owning_hwnd_ && GetHWND() == GetForegroundWindow() && + if (owning_hwnd_ && GetNativeView() == GetForegroundWindow() && IsWindowVisible(owning_hwnd_)) { SetForegroundWindow(owning_hwnd_); } @@ -190,11 +190,11 @@ void Window::Close() { } bool Window::IsMaximized() const { - return !!::IsZoomed(GetHWND()); + return !!::IsZoomed(GetNativeView()); } bool Window::IsMinimized() const { - return !!::IsIconic(GetHWND()); + return !!::IsIconic(GetNativeView()); } void Window::EnableClose(bool enable) { @@ -203,7 +203,7 @@ void Window::EnableClose(bool enable) { // Disable the native frame's close button regardless of whether or not the // native frame is in use, since this also affects the system menu. - EnableMenuItem(GetSystemMenu(GetHWND(), false), + EnableMenuItem(GetSystemMenu(GetNativeView(), false), SC_CLOSE, enable ? MF_ENABLED : MF_GRAYED); // Let the window know the frame changed. @@ -229,7 +229,7 @@ void Window::UpdateWindowTitle() { std::wstring localized_text; if (l10n_util::AdjustStringForLocaleDirection(window_title, &localized_text)) window_title.assign(localized_text); - SetWindowText(GetHWND(), window_title.c_str()); + SetWindowText(GetNativeView(), window_title.c_str()); } void Window::UpdateWindowIcon() { @@ -245,12 +245,12 @@ void Window::UpdateWindowIcon() { // We need to make sure to destroy the previous icon, otherwise we'll leak // these GDI objects until we crash! HICON old_icon = reinterpret_cast<HICON>( - SendMessage(GetHWND(), WM_SETICON, ICON_SMALL, + SendMessage(GetNativeView(), WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(windows_icon))); if (old_icon) DestroyIcon(old_icon); old_icon = reinterpret_cast<HICON>( - SendMessage(GetHWND(), WM_SETICON, ICON_BIG, + SendMessage(GetNativeView(), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(windows_icon))); if (old_icon) DestroyIcon(old_icon); @@ -259,7 +259,7 @@ void Window::UpdateWindowIcon() { void Window::ExecuteSystemMenuCommand(int command) { if (command) - SendMessage(GetHWND(), WM_SYSCOMMAND, command, 0); + SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0); } gfx::Rect Window::GetWindowBoundsForClientBounds( @@ -353,7 +353,7 @@ void Window::Init(HWND parent, const gfx::Rect& bounds) { set_window_ex_style(CalculateWindowExStyle()); WidgetWin::Init(parent, bounds, true); - win_util::SetWindowUserData(GetHWND(), this); + win_util::SetWindowUserData(GetNativeView(), this); // Create the ClientView, add it to the NonClientView and add the // NonClientView to the RootView. This will cause everything to be parented. @@ -387,7 +387,7 @@ void Window::UpdateFrameAfterFrameChange() { } void Window::SizeWindowToDefault() { - win_util::CenterAndSizeWindow(owning_window(), GetHWND(), + win_util::CenterAndSizeWindow(owning_window(), GetNativeView(), non_client_view_->GetPreferredSize().ToSIZE(), false); } @@ -397,11 +397,11 @@ void Window::RunSystemMenu(const gfx::Point& point) { // We need to call this otherwise there's a small chance that we aren't going // to get a system menu. We also can't take the return value of this // function. We need to call it *again* to get a valid HMENU. - //::GetSystemMenu(GetHWND(), TRUE); - HMENU system_menu = ::GetSystemMenu(GetHWND(), FALSE); + //::GetSystemMenu(GetNativeView(), TRUE); + HMENU system_menu = ::GetSystemMenu(GetNativeView(), FALSE); int id = ::TrackPopupMenu(system_menu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, - point.x(), point.y(), 0, GetHWND(), NULL); + point.x(), point.y(), 0, GetNativeView(), NULL); ExecuteSystemMenuCommand(id); } @@ -466,7 +466,7 @@ LRESULT Window::OnDwmCompositionChanged(UINT msg, WPARAM w_param, // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want // to notify our children too, since we can have MDI child windows who need to // update their appearance. - EnumChildWindows(GetHWND(), &SendDwmCompositionChanged, NULL); + EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL); return 0; } @@ -517,7 +517,7 @@ void Window::OnMouseLeave() { POINT pt; if (GetCursorPos(&pt)) { LRESULT ht_component = - ::SendMessage(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y)); + ::SendMessage(GetNativeView(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y)); if (ht_component != HTNOWHERE) { // If the mouse moved into a part of the window's non-client area, then // don't send a mouse exited event since the mouse is still within the @@ -541,7 +541,7 @@ LRESULT Window::OnNCActivate(BOOL active) { if (!non_client_view_->UseNativeFrame()) { // We can get WM_NCACTIVATE before we're actually visible. If we're not // visible, no need to paint. - if (IsWindowVisible(GetHWND())) { + if (IsWindowVisible(GetNativeView())) { non_client_view_->SchedulePaint(); // We need to force a paint now, as a user dragging a window will block // painting operations while the move is in progress. @@ -583,7 +583,8 @@ LRESULT Window::OnNCCalcSize(BOOL mode, LPARAM l_param) { // thickness of the auto-hide taskbar on each such edge, so the window isn't // treated as a "fullscreen app", which would cause the taskbars to // disappear. - HMONITOR monitor = MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST); + HMONITOR monitor = MonitorFromWindow(GetNativeView(), + MONITOR_DEFAULTTONEAREST); if (win_util::EdgeHasAutoHideTaskbar(ABE_LEFT, monitor)) client_rect->left += win_util::kAutoHideTaskbarThicknessPx; if (win_util::EdgeHasAutoHideTaskbar(ABE_TOP, monitor)) @@ -610,7 +611,7 @@ LRESULT Window::OnNCHitTest(const CPoint& point) { // First, give the NonClientView a chance to test the point to see if it // provides any of the non-client area. CPoint temp = point; - MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); + MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); int component = non_client_view_->NonClientHitTest(gfx::Point(temp)); if (component != HTNOWHERE) return component; @@ -691,13 +692,13 @@ void Window::OnNCPaint(HRGN rgn) { // In particular the docs mentiond DCX_CLIPCHILDREN, but as far as I can tell // it doesn't work at all. So, instead we get the DC for the window then // manually clip out the children. - HDC dc = GetWindowDC(GetHWND()); + HDC dc = GetWindowDC(GetNativeView()); ClipState clip_state; clip_state.x = window_rect.left; clip_state.y = window_rect.top; - clip_state.parent = GetHWND(); + clip_state.parent = GetNativeView(); clip_state.dc = dc; - EnumChildWindows(GetHWND(), &ClipDCToChild, + EnumChildWindows(GetNativeView(), &ClipDCToChild, reinterpret_cast<LPARAM>(&clip_state)); RootView* root_view = GetRootView(); @@ -722,7 +723,7 @@ void Window::OnNCPaint(HRGN rgn) { root_view->ProcessPaint(&canvas); } - ReleaseDC(GetHWND(), dc); + ReleaseDC(GetNativeView(), dc); } void Window::OnNCLButtonDown(UINT ht_component, const CPoint& point) { @@ -770,7 +771,7 @@ void Window::OnNCLButtonDown(UINT ht_component, const CPoint& point) { // non-client painting, so we need to call it directly here inside a // scoped update lock. ScopedRedrawLock lock(this); - DefWindowProc(GetHWND(), WM_NCLBUTTONDOWN, ht_component, + DefWindowProc(GetNativeView(), WM_NCLBUTTONDOWN, ht_component, MAKELPARAM(point.x, point.y)); SetMsgHandled(TRUE); } @@ -811,7 +812,7 @@ LRESULT Window::OnSetCursor(HWND window, UINT hittest_code, UINT message) { // This is annoying because they then have to move all the foreground windows // out of the way to be able to activate said window. I love how on Windows, // the answer isn't always logical. - if (!IsWindowEnabled(GetHWND())) + if (!IsWindowEnabled(GetNativeView())) return WidgetWin::OnSetCursor(window, hittest_code, message); int index = RC_NORMAL; @@ -844,14 +845,14 @@ LRESULT Window::OnSetCursor(HWND window, UINT hittest_code, UINT message) { LRESULT Window::OnSetIcon(UINT size_type, HICON new_icon) { // This shouldn't hurt even if we're using the native frame. ScopedRedrawLock lock(this); - return DefWindowProc(GetHWND(), WM_SETICON, size_type, + return DefWindowProc(GetNativeView(), WM_SETICON, size_type, reinterpret_cast<LPARAM>(new_icon)); } LRESULT Window::OnSetText(const wchar_t* text) { // This shouldn't hurt even if we're using the native frame. ScopedRedrawLock lock(this); - return DefWindowProc(GetHWND(), WM_SETTEXT, NULL, + return DefWindowProc(GetNativeView(), WM_SETTEXT, NULL, reinterpret_cast<LPARAM>(text)); } @@ -861,7 +862,7 @@ void Window::OnSize(UINT size_param, const CSize& new_size) { // layout differently when maximized). SaveWindowPosition(); ChangeSize(size_param, new_size); - RedrawWindow(GetHWND(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); + RedrawWindow(GetNativeView(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've // invoked OnSize we ensure the RootView has been laid out. @@ -896,7 +897,7 @@ void Window::OnSysCommand(UINT notification_code, CPoint click) { is_always_on_top_ = !is_always_on_top_; // Change the menu check state. - HMENU system_menu = GetSystemMenu(GetHWND(), FALSE); + HMENU system_menu = GetSystemMenu(GetNativeView(), FALSE); MENUITEMINFO menu_info; memset(&menu_info, 0, sizeof(MENUITEMINFO)); menu_info.cbSize = sizeof(MENUITEMINFO); @@ -915,7 +916,7 @@ void Window::OnSysCommand(UINT notification_code, CPoint click) { RunSystemMenu(non_client_view_->GetSystemMenuPoint()); } else { // Use the default implementation for any other command. - DefWindowProc(GetHWND(), WM_SYSCOMMAND, notification_code, + DefWindowProc(GetNativeView(), WM_SYSCOMMAND, notification_code, MAKELPARAM(click.y, click.x)); } } @@ -954,7 +955,7 @@ void Window::SetInitialFocus() { } else { // The window does not get keyboard messages unless we focus it, not sure // why. - SetFocus(GetHWND()); + SetFocus(GetNativeView()); } } @@ -1019,7 +1020,7 @@ void Window::AddAlwaysOnTopSystemMenuItem() { always_on_top_menu_text_ = l10n_util::GetString(IDS_ALWAYS_ON_TOP); // Let's insert a menu to the window. - HMENU system_menu = ::GetSystemMenu(GetHWND(), FALSE); + HMENU system_menu = ::GetSystemMenu(GetNativeView(), FALSE); int index = ::GetMenuItemCount(system_menu) - 1; if (index < 0) { // Paranoia check. @@ -1059,7 +1060,7 @@ void Window::RestoreEnabledIfNecessary() { } void Window::AlwaysOnTopChanged() { - ::SetWindowPos(GetHWND(), + ::SetWindowPos(GetNativeView(), is_always_on_top_ ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); @@ -1106,7 +1107,7 @@ void Window::SaveWindowPosition() { WINDOWPLACEMENT win_placement = { 0 }; win_placement.length = sizeof(WINDOWPLACEMENT); - BOOL r = GetWindowPlacement(GetHWND(), &win_placement); + BOOL r = GetWindowPlacement(GetNativeView(), &win_placement); DCHECK(r); bool maximized = (win_placement.showCmd == SW_SHOWMAXIMIZED); @@ -1117,12 +1118,12 @@ void Window::SaveWindowPosition() { void Window::LockUpdates() { lock_updates_ = true; - saved_window_style_ = GetWindowLong(GetHWND(), GWL_STYLE); - SetWindowLong(GetHWND(), GWL_STYLE, saved_window_style_ & ~WS_VISIBLE); + saved_window_style_ = GetWindowLong(GetNativeView(), GWL_STYLE); + SetWindowLong(GetNativeView(), GWL_STYLE, saved_window_style_ & ~WS_VISIBLE); } void Window::UnlockUpdates() { - SetWindowLong(GetHWND(), GWL_STYLE, saved_window_style_); + SetWindowLong(GetNativeView(), GWL_STYLE, saved_window_style_); lock_updates_ = false; } @@ -1138,7 +1139,7 @@ void Window::ResetWindowRegion(bool force) { // Changing the window region is going to force a paint. Only change the // window region if the region really differs. HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); - int current_rgn_result = GetWindowRgn(GetHWND(), current_rgn); + int current_rgn_result = GetWindowRgn(GetNativeView(), current_rgn); CRect window_rect; GetWindowRect(&window_rect); @@ -1160,7 +1161,7 @@ void Window::ResetWindowRegion(bool force) { void Window::ProcessNCMousePress(const CPoint& point, int flags) { CPoint temp = point; - MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); + MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); UINT message_flags = 0; if ((GetKeyState(VK_CONTROL) & 0x80) == 0x80) message_flags |= MK_CONTROL; @@ -1175,7 +1176,7 @@ LRESULT Window::CallDefaultNCActivateHandler(BOOL active) { // window title bar directly, so we need to use a redraw lock here to prevent // it from doing so. ScopedRedrawLock lock(this); - return DefWindowProc(GetHWND(), WM_NCACTIVATE, active, 0); + return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0); } void Window::InitClass() { |