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

Unified Diff: ui/views/widget/native_widget_win.cc

Issue 10867096: Make HWNDMessageHandler subclass WindowImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/native_widget_win.cc
===================================================================
--- ui/views/widget/native_widget_win.cc (revision 153552)
+++ ui/views/widget/native_widget_win.cc (working copy)
@@ -147,11 +147,7 @@
void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) {
SetInitParams(params);
-
- message_handler_->Init(params.bounds);
-
- // Create the window.
- WindowImpl::Init(params.GetParent(), params.bounds);
+ message_handler_->Init(params.GetParent(), params.bounds);
}
NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() {
@@ -181,11 +177,11 @@
}
gfx::NativeView NativeWidgetWin::GetNativeView() const {
- return WindowImpl::hwnd();
+ return message_handler_->hwnd();
}
gfx::NativeWindow NativeWidgetWin::GetNativeWindow() const {
- return WindowImpl::hwnd();
+ return message_handler_->hwnd();
}
Widget* NativeWidgetWin::GetTopLevelWidget() {
@@ -223,11 +219,11 @@
}
if (value)
- props_.push_back(new ViewProp(hwnd(), name, value));
+ props_.push_back(new ViewProp(GetNativeView(), name, value));
}
void* NativeWidgetWin::GetNativeWindowProperty(const char* name) const {
- return ViewProp::GetValue(hwnd(), name);
+ return ViewProp::GetValue(GetNativeView(), name);
}
TooltipManager* NativeWidgetWin::GetTooltipManager() const {
@@ -429,18 +425,21 @@
void NativeWidgetWin::SetUseDragFrame(bool use_drag_frame) {
if (use_drag_frame) {
// Make the frame slightly transparent during the drag operation.
- drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE);
- drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE);
- SetWindowLong(GWL_EXSTYLE,
+ drag_frame_saved_window_style_ = GetWindowLong(GetNativeView(), GWL_STYLE);
+ drag_frame_saved_window_ex_style_ =
+ GetWindowLong(GetNativeView(), GWL_EXSTYLE);
+ SetWindowLong(GetNativeView(), GWL_EXSTYLE,
drag_frame_saved_window_ex_style_ | WS_EX_LAYERED);
// Remove the captions tyle so the window doesn't have window controls for a
// more "transparent" look.
- SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION);
+ SetWindowLong(GetNativeView(), GWL_STYLE,
+ drag_frame_saved_window_style_ & ~WS_CAPTION);
SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF),
kDragFrameWindowAlpha, LWA_ALPHA);
} else {
- SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_);
- SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_);
+ SetWindowLong(GetNativeView(), GWL_STYLE, drag_frame_saved_window_style_);
+ SetWindowLong(GetNativeView(), GWL_EXSTYLE,
+ drag_frame_saved_window_ex_style_);
}
}
@@ -497,273 +496,8 @@
}
////////////////////////////////////////////////////////////////////////////////
-// NativeWidgetWin, MessageLoop::Observer implementation:
-
-base::EventStatus NativeWidgetWin::WillProcessEvent(
- const base::NativeEvent& event) {
- return base::EVENT_CONTINUE;
-}
-
-void NativeWidgetWin::DidProcessEvent(const base::NativeEvent& event) {
- message_handler_->RedrawInvalidRect();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWidgetWin, WindowImpl overrides:
-
-HICON NativeWidgetWin::GetDefaultWindowIcon() const {
- return message_handler_->GetDefaultWindowIcon();
-}
-
-LRESULT NativeWidgetWin::OnWndProc(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnWndProc(message, w_param, l_param);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// NativeWidgetWin, protected:
-// Message handlers ------------------------------------------------------------
-
-void NativeWidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) {
- message_handler_->OnActivate(action, minimized, window);
-}
-
-void NativeWidgetWin::OnActivateApp(BOOL active, DWORD thread_id) {
- message_handler_->OnActivateApp(active, thread_id);
-}
-
-LRESULT NativeWidgetWin::OnAppCommand(HWND window,
- short app_command,
- WORD device,
- int keystate) {
- return message_handler_->OnAppCommand(window, app_command, device, keystate);
-}
-
-void NativeWidgetWin::OnCancelMode() {
- message_handler_->OnCancelMode();
-}
-
-void NativeWidgetWin::OnCaptureChanged(HWND hwnd) {
- message_handler_->OnCaptureChanged(hwnd);
-}
-
-void NativeWidgetWin::OnClose() {
- message_handler_->OnClose();
-}
-
-void NativeWidgetWin::OnCommand(UINT notification_code,
- int command_id,
- HWND window) {
- message_handler_->OnCommand(notification_code, command_id, window);
-}
-
-LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) {
- return message_handler_->OnCreate(create_struct);
-}
-
-void NativeWidgetWin::OnDestroy() {
- message_handler_->OnDestroy();
-}
-
-void NativeWidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) {
- message_handler_->OnDisplayChange(bits_per_pixel, screen_size);
-}
-
-LRESULT NativeWidgetWin::OnDwmCompositionChanged(UINT msg,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnDwmCompositionChanged(msg, w_param, l_param);
-}
-
-void NativeWidgetWin::OnEndSession(BOOL ending, UINT logoff) {
- message_handler_->OnEndSession(ending, logoff);
-}
-
-void NativeWidgetWin::OnEnterSizeMove() {
- message_handler_->OnEnterSizeMove();
-}
-
-LRESULT NativeWidgetWin::OnEraseBkgnd(HDC dc) {
- return message_handler_->OnEraseBkgnd(dc);
-}
-
-void NativeWidgetWin::OnExitMenuLoop(BOOL is_track_popup_menu) {
- message_handler_->OnExitMenuLoop(is_track_popup_menu);
-}
-
-void NativeWidgetWin::OnExitSizeMove() {
- message_handler_->OnExitSizeMove();
-}
-
-LRESULT NativeWidgetWin::OnGetObject(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnGetObject(message, w_param, l_param);
-}
-
-void NativeWidgetWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) {
- message_handler_->OnGetMinMaxInfo(minmax_info);
-}
-
-void NativeWidgetWin::OnHScroll(int scroll_type,
- short position,
- HWND scrollbar) {
- message_handler_->OnHScroll(scroll_type, position, scrollbar);
-}
-
-LRESULT NativeWidgetWin::OnImeMessages(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnImeMessages(message, w_param, l_param);
-}
-
-void NativeWidgetWin::OnInitMenu(HMENU menu) {
- message_handler_->OnInitMenu(menu);
-}
-
-void NativeWidgetWin::OnInitMenuPopup(HMENU menu,
- UINT position,
- BOOL is_system_menu) {
- message_handler_->OnInitMenuPopup();
-}
-
-void NativeWidgetWin::OnInputLangChange(DWORD character_set,
- HKL input_language_id) {
- message_handler_->OnInputLangChange(character_set, input_language_id);
-}
-
-LRESULT NativeWidgetWin::OnKeyEvent(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnKeyEvent(message, w_param, l_param);
-}
-
-void NativeWidgetWin::OnKillFocus(HWND focused_window) {
- message_handler_->OnKillFocus(focused_window);
-}
-
-LRESULT NativeWidgetWin::OnMouseActivate(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnMouseActivate(message, w_param, l_param);
-}
-
-LRESULT NativeWidgetWin::OnMouseRange(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnMouseRange(message, w_param, l_param);
-}
-
-void NativeWidgetWin::OnMove(const CPoint& point) {
- message_handler_->OnMove(point);
-}
-
-void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
- message_handler_->OnMoving(param, new_bounds);
-}
-
-LRESULT NativeWidgetWin::OnNCActivate(BOOL active) {
- return message_handler_->OnNCActivate(active);
-}
-
-LRESULT NativeWidgetWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
- return message_handler_->OnNCCalcSize(mode, l_param);
-}
-
-LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) {
- return message_handler_->OnNCHitTest(point);
-}
-
-void NativeWidgetWin::OnNCPaint(HRGN rgn) {
- message_handler_->OnNCPaint(rgn);
-}
-
-LRESULT NativeWidgetWin::OnNCUAHDrawCaption(UINT msg,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnNCUAHDrawCaption(msg, w_param, l_param);
-}
-
-LRESULT NativeWidgetWin::OnNCUAHDrawFrame(UINT msg,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnNCUAHDrawFrame(msg, w_param, l_param);
-}
-
-LRESULT NativeWidgetWin::OnNotify(int w_param, NMHDR* l_param) {
- return message_handler_->OnNotify(w_param, l_param);
-}
-
-void NativeWidgetWin::OnPaint(HDC dc) {
- message_handler_->OnPaint(dc);
-}
-
-LRESULT NativeWidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) {
- return message_handler_->OnPowerBroadcast(power_event, data);
-}
-
-LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnReflectedMessage(msg, w_param, l_param);
-}
-
-LRESULT NativeWidgetWin::OnSetCursor(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnSetCursor(message, w_param, l_param);
-}
-
-void NativeWidgetWin::OnSetFocus(HWND old_focused_window) {
- message_handler_->OnSetFocus(old_focused_window);
-}
-
-LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) {
- return message_handler_->OnSetIcon(size_type, new_icon);
-}
-
-LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) {
- return message_handler_->OnSetText(text);
-}
-
-void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
- message_handler_->OnSettingChange(flags, section);
-}
-
-void NativeWidgetWin::OnSize(UINT param, const CSize& size) {
- message_handler_->OnSize(param, size);
-}
-
-void NativeWidgetWin::OnSysCommand(UINT notification_code, CPoint click) {
- message_handler_->OnSysCommand(notification_code, click);
-}
-
-void NativeWidgetWin::OnThemeChanged() {
- message_handler_->OnThemeChanged();
-}
-
-LRESULT NativeWidgetWin::OnTouchEvent(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return message_handler_->OnTouchEvent(message, w_param, l_param);
-}
-
-void NativeWidgetWin::OnVScroll(int scroll_type,
- short position,
- HWND scrollbar) {
- message_handler_->OnVScroll(scroll_type, position, scrollbar);
-}
-
-void NativeWidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
- message_handler_->OnWindowPosChanging(window_pos);
-}
-
-void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
- message_handler_->OnWindowPosChanged(window_pos);
-}
-
void NativeWidgetWin::OnFinalMessage(HWND window) {
// We don't destroy props in WM_DESTROY as we may still get messages after
// WM_DESTROY that assume the properties are still valid (such as WM_CLOSE).
@@ -780,6 +514,10 @@
screen_reader_active_ = true;
}
+HWNDMessageHandler* NativeWidgetWin::GetMessageHandler() {
+ return message_handler_.get();
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetWin, HWNDMessageHandlerDelegate implementation:
@@ -817,6 +555,11 @@
return delegate_->CanActivate();
}
+bool NativeWidgetWin::WidgetSizeIsClientSize() const {
+ const Widget* widget = GetWidget()->GetTopLevelWidget();
+ return IsMaximized() || (widget && widget->ShouldUseNativeFrame());
+}
+
bool NativeWidgetWin::CanSaveFocus() const {
return GetWidget()->is_top_level();
}
@@ -908,6 +651,9 @@
delegate_->OnNativeWidgetActivationChanged(active);
}
+void NativeWidgetWin::HandleMouseActivate(int hittest_code) {
+}
+
bool NativeWidgetWin::HandleAppCommand(short command) {
// We treat APPCOMMAND ids as an extension of our command namespace, and just
// let the delegate figure out what to do...
@@ -935,19 +681,13 @@
// TODO(beng): much of this could/should maybe move to HWNDMessageHandler.
SetNativeWindowProperty(kNativeWidgetKey, this);
- CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd()));
+ CHECK_EQ(this, GetNativeWidgetForNativeView(GetNativeView()));
- props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(hwnd()));
+ props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(GetNativeView()));
drop_target_ = new DropTargetWin(
static_cast<internal::RootView*>(GetWidget()->GetRootView()));
- // We need to add ourselves as a message loop observer so that we can repaint
- // aggressively if the contents of our window become invalid. Unfortunately
- // WM_PAINT messages are starved and we get flickery redrawing when resizing
- // if we do not do this.
- MessageLoopForUI::current()->AddObserver(this);
-
// Windows special DWM window frame requires a special tooltip manager so
// that window controls in Chrome windows don't flicker when you move your
// mouse over them. See comment in aero_tooltip_manager.h.
@@ -970,14 +710,13 @@
void NativeWidgetWin::HandleDestroying() {
delegate_->OnNativeWidgetDestroying();
if (drop_target_.get()) {
- RevokeDragDrop(hwnd());
+ RevokeDragDrop(GetNativeView());
drop_target_ = NULL;
}
}
void NativeWidgetWin::HandleDestroyed() {
- MessageLoopForUI::current()->RemoveObserver(this);
- OnFinalMessage(hwnd());
+ OnFinalMessage(GetNativeView());
}
bool NativeWidgetWin::HandleInitialFocus() {
@@ -1072,10 +811,22 @@
tooltip_manager_->OnMouse(message, w_param, l_param);
}
-NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() {
- return this;
+void NativeWidgetWin::HandleEndSession() {
}
+void NativeWidgetWin::HandleInitMenuPopup() {
+}
+
+void NativeWidgetWin::HandleFrameChanged() {
+}
+
+bool NativeWidgetWin::HandleMSG(UINT message,
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT* result) {
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetWin, private:
@@ -1160,19 +911,16 @@
NOTREACHED();
}
- set_initial_class_style(class_style);
- set_window_style(window_style() | style);
- set_window_ex_style(window_ex_style() | ex_style);
+ message_handler_->set_initial_class_style(class_style);
+ message_handler_->set_window_style(
+ message_handler_->window_style() | style);
+ message_handler_->set_window_ex_style(
+ message_handler_->window_ex_style() | ex_style);
has_non_client_view_ = Widget::RequiresNonClientView(params.type);
message_handler_->set_remove_standard_frame(params.remove_standard_frame);
}
-bool NativeWidgetWin::WidgetSizeIsClientSize() const {
- const Widget* widget = GetWidget()->GetTopLevelWidget();
- return IsZoomed() || (widget && widget->ShouldUseNativeFrame());
-}
-
////////////////////////////////////////////////////////////////////////////////
// Widget, public:

Powered by Google App Engine
This is Rietveld 408576698