Commit 5b7209f6 authored by ben@chromium.org's avatar ben@chromium.org

Revert 151762.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151771 0039d316-1c4b-4281-b951-d872f2087c98
parent 6bf3373d
...@@ -321,9 +321,6 @@ ...@@ -321,9 +321,6 @@
'widget/drop_helper.h', 'widget/drop_helper.h',
'widget/drop_target_win.cc', 'widget/drop_target_win.cc',
'widget/drop_target_win.h', 'widget/drop_target_win.h',
'widget/hwnd_message_handler.cc',
'widget/hwnd_message_handler.h',
'widget/hwnd_message_handler_delegate.h',
'widget/root_view.cc', 'widget/root_view.cc',
'widget/root_view.h', 'widget/root_view.h',
'widget/tooltip_manager_aura.cc', 'widget/tooltip_manager_aura.cc',
...@@ -449,9 +446,6 @@ ...@@ -449,9 +446,6 @@
}], }],
['OS!="win"', { ['OS!="win"', {
'sources!': [ 'sources!': [
'widget/hwnd_message_handler.cc',
'widget/hwnd_message_handler.h',
'widget/hwnd_message_handler_delegate.h',
'widget/widget_hwnd_utils.cc', 'widget/widget_hwnd_utils.cc',
'widget/widget_hwnd_utils.h', 'widget/widget_hwnd_utils.h',
], ],
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/widget/hwnd_message_handler.h"
#include "ui/views/widget/hwnd_message_handler_delegate.h"
#include "ui/views/widget/native_widget_win.h"
namespace views {
////////////////////////////////////////////////////////////////////////////////
// HWNDMessageHandler, public:
HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate)
: delegate_(delegate),
remove_standard_frame_(false) {
}
HWNDMessageHandler::~HWNDMessageHandler() {
}
void HWNDMessageHandler::OnActivate(UINT action, BOOL minimized, HWND window) {
SetMsgHandled(FALSE);
}
void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) {
if (delegate_->IsWidgetWindow() && !active &&
thread_id != GetCurrentThreadId()) {
delegate_->HandleAppDeactivated();
// Also update the native frame if it is rendering the non-client area.
if (!remove_standard_frame_ &&
!delegate_->IsUsingCustomFrame() &&
delegate_->AsNativeWidgetWin()) {
delegate_->AsNativeWidgetWin()->DefWindowProcWithRedrawLock(
WM_NCACTIVATE, FALSE, 0);
}
}
}
BOOL HWNDMessageHandler::OnAppCommand(HWND window,
short command,
WORD device,
int keystate) {
BOOL handled = !!delegate_->HandleAppCommand(command);
SetMsgHandled(handled);
// Make sure to return TRUE if the event was handled or in some cases the
// system will execute the default handler which can cause bugs like going
// forward or back two pages instead of one.
return handled;
}
void HWNDMessageHandler::OnCancelMode() {
SetMsgHandled(FALSE);
}
void HWNDMessageHandler::OnCaptureChanged(HWND window) {
delegate_->HandleCaptureLost();
}
void HWNDMessageHandler::OnClose() {
delegate_->HandleClose();
}
void HWNDMessageHandler::OnCommand(UINT notification_code,
int command,
HWND window) {
// If the notification code is > 1 it means it is control specific and we
// should ignore it.
if (notification_code > 1 || delegate_->HandleAppCommand(command))
SetMsgHandled(FALSE);
}
void HWNDMessageHandler::OnDestroy() {
delegate_->HandleDestroy();
}
void HWNDMessageHandler::OnDisplayChange(UINT bits_per_pixel,
const CSize& screen_size) {
delegate_->HandleDisplayChange();
}
void HWNDMessageHandler::OnDwmCompositionChanged(UINT msg,
WPARAM w_param,
LPARAM l_param) {
if (!delegate_->IsWidgetWindow()) {
SetMsgHandled(FALSE);
return;
}
delegate_->HandleGlassModeChange();
}
void HWNDMessageHandler::OnEndSession(BOOL ending, UINT logoff) {
SetMsgHandled(FALSE);
}
void HWNDMessageHandler::OnEnterSizeMove() {
delegate_->HandleBeginWMSizeMove();
SetMsgHandled(FALSE);
}
LRESULT HWNDMessageHandler::OnEraseBkgnd(HDC dc) {
// Needed to prevent resize flicker.
return 1;
}
void HWNDMessageHandler::OnExitMenuLoop(BOOL is_track_popup_menu) {
SetMsgHandled(FALSE);
}
void HWNDMessageHandler::OnExitSizeMove() {
delegate_->HandleEndWMSizeMove();
SetMsgHandled(FALSE);
}
////////////////////////////////////////////////////////////////////////////////
// HWNDMessageHandler, private:
void HWNDMessageHandler::SetMsgHandled(BOOL handled) {
delegate_->AsNativeWidgetWin()->SetMsgHandled(handled);
}
} // namespace views
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_HWND_MESSAGE_HANDLER_H_
#define UI_VIEWS_WIDGET_HWND_MESSAGE_HANDLER_H_
#include <atlbase.h>
#include <atlapp.h>
#include <atlmisc.h>
#include <windows.h>
#include "base/basictypes.h"
#include "ui/views/views_export.h"
namespace views {
class HWNDMessageHandlerDelegate;
// An object that handles messages for a HWND that implements the views
// "Custom Frame" look. The purpose of this class is to isolate the windows-
// specific message handling from the code that wraps it. It is intended to be
// used by both a views::NativeWidget and an aura::RootWindowHost
// implementation.
// TODO(beng): This object should eventually *become* the WindowImpl.
class VIEWS_EXPORT HWNDMessageHandler {
public:
explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate);
~HWNDMessageHandler();
// Message Handlers.
void OnActivate(UINT action, BOOL minimized, HWND window);
// TODO(beng): Once this object becomes the WindowImpl, these methods can
// be made private.
void OnActivateApp(BOOL active, DWORD thread_id);
// TODO(beng): return BOOL is temporary until this object becomes a
// WindowImpl.
BOOL OnAppCommand(HWND window, short command, WORD device, int keystate);
void OnCancelMode();
void OnCaptureChanged(HWND window);
void OnClose();
void OnCommand(UINT notification_code, int command, HWND window);
void OnDestroy();
void OnDisplayChange(UINT bits_per_pixel, const CSize& screen_size);
void OnDwmCompositionChanged(UINT msg, WPARAM w_param, LPARAM l_param);
void OnEndSession(BOOL ending, UINT logoff);
void OnEnterSizeMove();
LRESULT OnEraseBkgnd(HDC dc);
void OnExitMenuLoop(BOOL is_track_popup_menu);
void OnExitSizeMove();
// TODO(beng): Can be removed once this object becomes the WindowImpl.
bool remove_standard_frame() const { return remove_standard_frame_; }
void set_remove_standard_frame(bool remove_standard_frame) {
remove_standard_frame_ = remove_standard_frame;
}
private:
// TODO(beng): Remove once this class becomes the WindowImpl.
void SetMsgHandled(BOOL handled);
HWNDMessageHandlerDelegate* delegate_;
bool remove_standard_frame_;
DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler);
};
} // namespace views
#endif // UI_VIEWS_WIDGET_HWND_MESSAGE_HANDLER_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_HWND_MESSAGE_HANDLER_DELEGATE_H_
#define UI_VIEWS_WIDGET_HWND_MESSAGE_HANDLER_DELEGATE_H_
#include "ui/views/views_export.h"
namespace views {
class NativeWidgetWin;
// Implemented by the object that uses the HWNDMessageHandler to handle
// notifications from the underlying HWND and service requests for data.
class VIEWS_EXPORT HWNDMessageHandlerDelegate {
public:
virtual bool IsWidgetWindow() const = 0;
// TODO(beng): resolve this more satisfactorily vis-a-vis ShouldUseNativeFrame
// to avoid confusion.
virtual bool IsUsingCustomFrame() const = 0;
// TODO(beng): Investigate migrating these methods to On* prefixes once
// HWNDMessageHandler is the WindowImpl.
// Called when another app was activated.
virtual void HandleAppDeactivated() = 0;
// Called when a well known "app command" from the system was performed.
// Returns true if the command was handled.
virtual bool HandleAppCommand(short command) = 0;
// Called when the window has lost mouse capture.
virtual void HandleCaptureLost() = 0;
// Called when the user tried to close the window.
virtual void HandleClose() = 0;
// Called when a command defined by the application was performed. Returns
// true if the command was handled.
virtual bool HandleCommand(int command) = 0;
// Called when the HWND is destroyed.
virtual void HandleDestroy() = 0;
// Called when display settings are adjusted on the system.
virtual void HandleDisplayChange() = 0;
// Called when the system changes from glass to non-glass or vice versa.
virtual void HandleGlassModeChange() = 0;
// Called when the user begins or ends a size/move operation using the window
// manager.
virtual void HandleBeginWMSizeMove() = 0;
virtual void HandleEndWMSizeMove() = 0;
// This is provided for methods that need to call private methods on NWW.
// TODO(beng): should be removed once HWNDMessageHandler is the WindowImpl.
virtual NativeWidgetWin* AsNativeWidgetWin() = 0;
protected:
virtual ~HWNDMessageHandlerDelegate() {}
};
} // namespace views
#endif // UI_VIEWS_WIDGET_HWND_MESSAGE_HANDLER_DELEGATE_H_
This diff is collapsed.
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "ui/base/win/window_impl.h" #include "ui/base/win/window_impl.h"
#include "ui/views/focus/focus_manager.h" #include "ui/views/focus/focus_manager.h"
#include "ui/views/layout/layout_manager.h" #include "ui/views/layout/layout_manager.h"
#include "ui/views/widget/hwnd_message_handler_delegate.h"
#include "ui/views/widget/native_widget_private.h" #include "ui/views/widget/native_widget_private.h"
namespace ui { namespace ui {
...@@ -41,7 +40,6 @@ class Rect; ...@@ -41,7 +40,6 @@ class Rect;
namespace views { namespace views {
class DropTargetWin; class DropTargetWin;
class HWNDMessageHandler;
class RootView; class RootView;
class TooltipManagerWin; class TooltipManagerWin;
...@@ -71,8 +69,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF; ...@@ -71,8 +69,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
public MessageLoopForUI::Observer, public MessageLoopForUI::Observer,
public internal::NativeWidgetPrivate, public internal::NativeWidgetPrivate {
public HWNDMessageHandlerDelegate {
public: public:
explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate); explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate);
virtual ~NativeWidgetWin(); virtual ~NativeWidgetWin();
...@@ -486,25 +483,6 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, ...@@ -486,25 +483,6 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
typedef ScopedVector<ui::ViewProp> ViewProps; typedef ScopedVector<ui::ViewProp> ViewProps;
typedef std::set<DWORD> TouchIDs; typedef std::set<DWORD> TouchIDs;
// TODO(beng): This friendship can be removed once all methods relating to
// this object being a WindowImpl are moved to HWNDMessageHandler.
friend HWNDMessageHandler;
// Overridden from HWNDMessageHandlerDelegate:
virtual bool IsWidgetWindow() const OVERRIDE;
virtual bool IsUsingCustomFrame() const OVERRIDE;
virtual void HandleAppDeactivated() OVERRIDE;
virtual bool HandleAppCommand(short command) OVERRIDE;
virtual void HandleCaptureLost() OVERRIDE;
virtual void HandleClose() OVERRIDE;
virtual bool HandleCommand(int command) OVERRIDE;
virtual void HandleDestroy() OVERRIDE;
virtual void HandleDisplayChange() OVERRIDE;
virtual void HandleGlassModeChange() OVERRIDE;
virtual void HandleBeginWMSizeMove() OVERRIDE;
virtual void HandleEndWMSizeMove() OVERRIDE;
virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE;
// Called after the WM_ACTIVATE message has been processed by the default // Called after the WM_ACTIVATE message has been processed by the default
// windows procedure. // windows procedure.
static void PostProcessActivateMessage(NativeWidgetWin* widget, static void PostProcessActivateMessage(NativeWidgetWin* widget,
...@@ -699,11 +677,11 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, ...@@ -699,11 +677,11 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
// Init time, before the Widget has created the NonClientView. // Init time, before the Widget has created the NonClientView.
bool has_non_client_view_; bool has_non_client_view_;
bool remove_standard_frame_;
// The set of touch devices currently down. // The set of touch devices currently down.
TouchIDs touch_ids_; TouchIDs touch_ids_;
scoped_ptr<HWNDMessageHandler> message_handler_;
DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment