summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/cancel_mode.cc22
-rw-r--r--ash/cancel_mode.h15
-rw-r--r--ash/launcher/launcher_tooltip_manager.cc17
-rw-r--r--ash/launcher/launcher_tooltip_manager.h9
-rw-r--r--ash/tooltips/tooltip_controller.cc16
-rw-r--r--ash/tooltips/tooltip_controller.h9
-rw-r--r--ash/wm/session_state_controller_impl.cc5
-rw-r--r--ash/wm/session_state_controller_impl2.cc3
-rw-r--r--ui/aura/root_window.cc6
-rw-r--r--ui/aura/root_window.h1
-rw-r--r--ui/aura/root_window_host_delegate.h2
-rw-r--r--ui/base/events/event.cc12
-rw-r--r--ui/base/events/event.h6
-rw-r--r--ui/base/events/event_constants.h4
-rw-r--r--ui/base/events/event_handler.cc5
-rw-r--r--ui/base/events/event_handler.h3
-rw-r--r--ui/views/widget/desktop_aura/desktop_root_window_host_win.cc4
-rw-r--r--ui/views/widget/desktop_aura/desktop_root_window_host_win.h1
-rw-r--r--ui/views/widget/native_widget_win.cc3
-rw-r--r--ui/views/widget/native_widget_win.h1
-rw-r--r--ui/views/win/hwnd_message_handler.cc6
-rw-r--r--ui/views/win/hwnd_message_handler.h2
-rw-r--r--ui/views/win/hwnd_message_handler_delegate.h3
24 files changed, 117 insertions, 40 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 7330065..dd22c5b 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -62,6 +62,8 @@
'ash_constants.h',
'ash_switches.cc',
'ash_switches.h',
+ 'cancel_mode.cc',
+ 'cancel_mode.h',
'caps_lock_delegate.h',
'caps_lock_delegate_stub.cc',
'caps_lock_delegate_stub.h',
diff --git a/ash/cancel_mode.cc b/ash/cancel_mode.cc
new file mode 100644
index 0000000..92f0543
--- /dev/null
+++ b/ash/cancel_mode.cc
@@ -0,0 +1,22 @@
+// Copyright (c) 2013 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 "ash/cancel_mode.h"
+
+#include "ash/root_window_controller.h"
+#include "ash/shell.h"
+#include "ui/aura/root_window.h"
+
+namespace ash {
+
+void DispatchCancelMode() {
+ Shell::RootWindowControllerList controllers(
+ Shell::GetAllRootWindowControllers());
+ for (Shell::RootWindowControllerList::const_iterator i = controllers.begin();
+ i != controllers.end(); ++i) {
+ (*i)->root_window()->AsRootWindowHostDelegate()->OnHostCancelMode();
+ }
+}
+
+} // namespace ash
diff --git a/ash/cancel_mode.h b/ash/cancel_mode.h
new file mode 100644
index 0000000..915fe43
--- /dev/null
+++ b/ash/cancel_mode.h
@@ -0,0 +1,15 @@
+// Copyright (c) 2013 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 ASH_CANCEL_MODE_H_
+#define ASH_CANCEL_MODE_H_
+
+namespace ash {
+
+// Sends OnHostCancelMode() to all RootWindows.
+void DispatchCancelMode();
+
+} // namespace ash
+
+#endif // ASH_CANCEL_MODE_H_
diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc
index ba5bf48..5d5e230 100644
--- a/ash/launcher/launcher_tooltip_manager.cc
+++ b/ash/launcher/launcher_tooltip_manager.cc
@@ -7,8 +7,6 @@
#include "ash/launcher/launcher_view.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
-#include "ash/wm/session_state_controller.h"
-#include "ash/wm/session_state_observer.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_animations.h"
#include "base/bind.h"
@@ -137,10 +135,8 @@ LauncherTooltipManager::LauncherTooltipManager(
launcher_view_(launcher_view) {
if (shelf_layout_manager)
shelf_layout_manager->AddObserver(this);
- if (Shell::HasInstance()) {
+ if (Shell::HasInstance())
Shell::GetInstance()->AddPreTargetHandler(this);
- Shell::GetInstance()->session_state_controller()->AddObserver(this);
- }
}
LauncherTooltipManager::~LauncherTooltipManager() {
@@ -148,10 +144,8 @@ LauncherTooltipManager::~LauncherTooltipManager() {
Close();
if (shelf_layout_manager_)
shelf_layout_manager_->RemoveObserver(this);
- if (Shell::HasInstance()) {
+ if (Shell::HasInstance())
Shell::GetInstance()->RemovePreTargetHandler(this);
- Shell::GetInstance()->session_state_controller()->RemoveObserver(this);
- }
}
void LauncherTooltipManager::ShowDelayed(views::View* anchor,
@@ -290,11 +284,8 @@ void LauncherTooltipManager::OnGestureEvent(ui::GestureEvent* event) {
}
}
-void LauncherTooltipManager::OnSessionStateEvent(
- SessionStateObserver::EventType event) {
- if (event == SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED ||
- event == SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED)
- Close();
+void LauncherTooltipManager::OnCancelMode(ui::CancelModeEvent* event) {
+ Close();
}
void LauncherTooltipManager::WillDeleteShelf() {
diff --git a/ash/launcher/launcher_tooltip_manager.h b/ash/launcher/launcher_tooltip_manager.h
index efe27f9..edd48bb 100644
--- a/ash/launcher/launcher_tooltip_manager.h
+++ b/ash/launcher/launcher_tooltip_manager.h
@@ -7,7 +7,6 @@
#include "ash/ash_export.h"
#include "ash/shelf_types.h"
-#include "ash/wm/session_state_observer.h"
#include "ash/wm/shelf_layout_manager.h"
#include "base/basictypes.h"
#include "base/string16.h"
@@ -37,8 +36,7 @@ class LauncherView;
// LauncherTooltipManager manages the tooltip balloon poping up on launcher
// items.
class ASH_EXPORT LauncherTooltipManager : public ui::EventHandler,
- public ShelfLayoutManager::Observer,
- public SessionStateObserver {
+ public ShelfLayoutManager::Observer {
public:
LauncherTooltipManager(ShelfLayoutManager* shelf_layout_manager,
LauncherView* launcher_view);
@@ -79,10 +77,7 @@ protected:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
-
- // SessionStateObserver override:
- virtual void OnSessionStateEvent(SessionStateObserver::EventType event)
- OVERRIDE;
+ virtual void OnCancelMode(ui::CancelModeEvent* event) OVERRIDE;
// ShelfLayoutManager::Observer overrides:
virtual void WillDeleteShelf() OVERRIDE;
diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc
index 8c187b6..c8bde19 100644
--- a/ash/tooltips/tooltip_controller.cc
+++ b/ash/tooltips/tooltip_controller.cc
@@ -10,8 +10,6 @@
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/cursor_manager.h"
-#include "ash/wm/session_state_controller.h"
-#include "ash/wm/session_state_observer.h"
#include "base/command_line.h"
#include "base/location.h"
#include "base/string_split.h"
@@ -214,15 +212,11 @@ TooltipController::TooltipController(
base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
this, &TooltipController::TooltipTimerFired);
DCHECK(drag_drop_client_);
- if (Shell::GetInstance())
- Shell::GetInstance()->session_state_controller()->AddObserver(this);
}
TooltipController::~TooltipController() {
if (tooltip_window_)
tooltip_window_->RemoveObserver(this);
- if (Shell::GetInstance())
- Shell::GetInstance()->session_state_controller()->RemoveObserver(this);
}
void TooltipController::UpdateTooltip(aura::Window* target) {
@@ -311,13 +305,9 @@ void TooltipController::OnTouchEvent(ui::TouchEvent* event) {
tooltip_window_ = NULL;
}
-void TooltipController::OnSessionStateEvent(
- SessionStateObserver::EventType event) {
- if (event == SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED ||
- event == SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED) {
- if (tooltip_.get() && tooltip_->IsVisible())
- tooltip_->Hide();
- }
+void TooltipController::OnCancelMode(ui::CancelModeEvent* event) {
+ if (tooltip_.get() && tooltip_->IsVisible())
+ tooltip_->Hide();
}
void TooltipController::OnWindowDestroyed(aura::Window* window) {
diff --git a/ash/tooltips/tooltip_controller.h b/ash/tooltips/tooltip_controller.h
index 5f2215a..3022aee 100644
--- a/ash/tooltips/tooltip_controller.h
+++ b/ash/tooltips/tooltip_controller.h
@@ -6,7 +6,6 @@
#define ASH_TOOLTIPS_TOOLTIP_CONTROLLER_H_
#include "ash/ash_export.h"
-#include "ash/wm/session_state_observer.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "base/timer.h"
@@ -33,8 +32,7 @@ namespace internal {
// TooltipController provides tooltip functionality for aura shell.
class ASH_EXPORT TooltipController : public aura::client::TooltipClient,
public ui::EventHandler,
- public aura::WindowObserver,
- public SessionStateObserver {
+ public aura::WindowObserver {
public:
explicit TooltipController(aura::client::DragDropClient* drag_drop_client);
virtual ~TooltipController();
@@ -47,10 +45,7 @@ class ASH_EXPORT TooltipController : public aura::client::TooltipClient,
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
-
- // Overridden from SessionStateController.
- virtual void OnSessionStateEvent(SessionStateObserver::EventType event)
- OVERRIDE;
+ virtual void OnCancelMode(ui::CancelModeEvent* event) OVERRIDE;
// Overridden from aura::WindowObserver.
virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
diff --git a/ash/wm/session_state_controller_impl.cc b/ash/wm/session_state_controller_impl.cc
index 7a54f35..0469b6b 100644
--- a/ash/wm/session_state_controller_impl.cc
+++ b/ash/wm/session_state_controller_impl.cc
@@ -5,6 +5,7 @@
#include "ash/wm/session_state_controller_impl.h"
#include "ash/ash_switches.h"
+#include "ash/cancel_mode.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
@@ -71,6 +72,7 @@ void SessionStateControllerImpl::OnLockStateChanged(bool locked) {
internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
internal::SessionStateAnimator::ANIMATION_FADE_IN,
internal::SessionStateAnimator::ANIMATION_SPEED_SHOW_LOCK_SCREEN);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(
SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
@@ -105,6 +107,7 @@ void SessionStateControllerImpl::OnStartingLock() {
internal::SessionStateAnimator::ANIMATION_FULL_CLOSE,
internal::SessionStateAnimator::ANIMATION_SPEED_FAST);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
@@ -120,6 +123,7 @@ void SessionStateControllerImpl::StartLockAnimationAndLockImmediately() {
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE,
internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
OnLockTimeout();
@@ -132,6 +136,7 @@ void SessionStateControllerImpl::StartLockAnimation(bool shutdown_after_lock) {
internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE,
internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(
SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
diff --git a/ash/wm/session_state_controller_impl2.cc b/ash/wm/session_state_controller_impl2.cc
index 2a386a3..2084e00 100644
--- a/ash/wm/session_state_controller_impl2.cc
+++ b/ash/wm/session_state_controller_impl2.cc
@@ -5,6 +5,7 @@
#include "ash/wm/session_state_controller_impl2.h"
#include "ash/ash_switches.h"
+#include "ash/cancel_mode.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
@@ -450,6 +451,7 @@ void SessionStateControllerImpl2::StartImmediatePreLockAnimation(
observer->Unpause();
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
}
@@ -485,6 +487,7 @@ void SessionStateControllerImpl2::StartCancellablePreLockAnimation() {
internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE,
observer);
+ DispatchCancelMode();
FOR_EACH_OBSERVER(SessionStateObserver, observers_,
OnSessionStateEvent(
SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 7ea9013..4013173 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -876,6 +876,12 @@ bool RootWindow::OnHostTouchEvent(ui::TouchEvent* event) {
return ProcessGestures(gestures.get()) ? true : handled;
}
+void RootWindow::OnHostCancelMode() {
+ ui::CancelModeEvent event;
+ Window* focused_window = client::GetFocusClient(this)->GetFocusedWindow();
+ ProcessEvent(focused_window ? focused_window : this, &event);
+}
+
void RootWindow::OnHostActivated() {
Env::GetInstance()->RootWindowActivated(this);
}
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index d506692..0a54f1a 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -331,6 +331,7 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
virtual bool OnHostMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual bool OnHostScrollEvent(ui::ScrollEvent* event) OVERRIDE;
virtual bool OnHostTouchEvent(ui::TouchEvent* event) OVERRIDE;
+ virtual void OnHostCancelMode() OVERRIDE;
virtual void OnHostActivated() OVERRIDE;
virtual void OnHostLostWindowCapture() OVERRIDE;
virtual void OnHostLostMouseGrab() OVERRIDE;
diff --git a/ui/aura/root_window_host_delegate.h b/ui/aura/root_window_host_delegate.h
index f45c0fb..ee33be8 100644
--- a/ui/aura/root_window_host_delegate.h
+++ b/ui/aura/root_window_host_delegate.h
@@ -13,6 +13,7 @@ class Size;
}
namespace ui {
+class Event;
class KeyEvent;
class MouseEvent;
class ScrollEvent;
@@ -31,6 +32,7 @@ class AURA_EXPORT RootWindowHostDelegate {
virtual bool OnHostMouseEvent(ui::MouseEvent* event) = 0;
virtual bool OnHostScrollEvent(ui::ScrollEvent* event) = 0;
virtual bool OnHostTouchEvent(ui::TouchEvent* event) = 0;
+ virtual void OnHostCancelMode() = 0;
// Called when the windowing system activates the window.
virtual void OnHostActivated() = 0;
diff --git a/ui/base/events/event.cc b/ui/base/events/event.cc
index 7383579e..50c265b 100644
--- a/ui/base/events/event.cc
+++ b/ui/base/events/event.cc
@@ -95,6 +95,7 @@ std::string EventTypeName(ui::EventType type) {
CASE_TYPE(ET_SCROLL);
CASE_TYPE(ET_SCROLL_FLING_START);
CASE_TYPE(ET_SCROLL_FLING_CANCEL);
+ CASE_TYPE(ET_CANCEL_MODE);
case ui::ET_LAST: NOTREACHED(); return std::string();
// Don't include default, so that we get an error when new type is added.
}
@@ -229,6 +230,17 @@ void Event::InitWithNativeEvent(const base::NativeEvent& native_event) {
}
////////////////////////////////////////////////////////////////////////////////
+// CancelModeEvent
+
+CancelModeEvent::CancelModeEvent()
+ : Event(ui::ET_CANCEL_MODE, base::TimeDelta(), 0) {
+ set_cancelable(false);
+}
+
+CancelModeEvent::~CancelModeEvent() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
// LocatedEvent
LocatedEvent::~LocatedEvent() {
diff --git a/ui/base/events/event.h b/ui/base/events/event.h
index 91a1ac8..a50823a 100644
--- a/ui/base/events/event.h
+++ b/ui/base/events/event.h
@@ -228,6 +228,12 @@ class UI_EXPORT Event {
EventResult result_;
};
+class UI_EXPORT CancelModeEvent : public Event {
+ public:
+ CancelModeEvent();
+ virtual ~CancelModeEvent();
+};
+
class UI_EXPORT LocatedEvent : public Event {
public:
// For testing.
diff --git a/ui/base/events/event_constants.h b/ui/base/events/event_constants.h
index 984b790..bb7706d 100644
--- a/ui/base/events/event_constants.h
+++ b/ui/base/events/event_constants.h
@@ -55,6 +55,10 @@ enum EventType {
ET_SCROLL_FLING_START,
ET_SCROLL_FLING_CANCEL,
+ // Sent by the system to indicate any modal type operations, such as drag and
+ // drop or menus, should stop.
+ ET_CANCEL_MODE,
+
// Must always be last. User namespace starts above this value.
// See ui::RegisterCustomEventType().
ET_LAST
diff --git a/ui/base/events/event_handler.cc b/ui/base/events/event_handler.cc
index e36a01f..99295b15 100644
--- a/ui/base/events/event_handler.cc
+++ b/ui/base/events/event_handler.cc
@@ -31,6 +31,8 @@ void EventHandler::OnEvent(Event* event) {
OnTouchEvent(static_cast<TouchEvent*>(event));
else if (event->IsGestureEvent())
OnGestureEvent(static_cast<GestureEvent*>(event));
+ else if (event->type() == ET_CANCEL_MODE)
+ OnCancelMode(static_cast<CancelModeEvent*>(event));
}
void EventHandler::OnKeyEvent(KeyEvent* event) {
@@ -48,4 +50,7 @@ void EventHandler::OnTouchEvent(TouchEvent* event) {
void EventHandler::OnGestureEvent(GestureEvent* event) {
}
+void EventHandler::OnCancelMode(CancelModeEvent* event) {
+}
+
} // namespace ui
diff --git a/ui/base/events/event_handler.h b/ui/base/events/event_handler.h
index 92d164a..6ecc389 100644
--- a/ui/base/events/event_handler.h
+++ b/ui/base/events/event_handler.h
@@ -14,6 +14,7 @@
namespace ui {
+class CancelModeEvent;
class Event;
class EventDispatcher;
class EventTarget;
@@ -46,6 +47,8 @@ class UI_EXPORT EventHandler {
virtual void OnGestureEvent(GestureEvent* event);
+ virtual void OnCancelMode(CancelModeEvent* event);
+
private:
friend class EventDispatcher;
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc
index 315769a..1f3e799 100644
--- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc
+++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc
@@ -581,6 +581,10 @@ bool DesktopRootWindowHostWin::HandleAppCommand(short command) {
GetWidget()->widget_delegate()->ExecuteWindowsCommand(command);
}
+void DesktopRootWindowHostWin::HandleCancelMode() {
+ root_window_host_delegate_->OnHostCancelMode();
+}
+
void DesktopRootWindowHostWin::HandleCaptureLost() {
native_widget_delegate_->OnMouseCaptureLost();
}
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h
index a62b1b4..a173220 100644
--- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h
+++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h
@@ -152,6 +152,7 @@ class VIEWS_EXPORT DesktopRootWindowHostWin
virtual void HandleAppDeactivated() OVERRIDE;
virtual void HandleActivationChanged(bool active) OVERRIDE;
virtual bool HandleAppCommand(short command) OVERRIDE;
+ virtual void HandleCancelMode() OVERRIDE;
virtual void HandleCaptureLost() OVERRIDE;
virtual void HandleClose() OVERRIDE;
virtual bool HandleCommand(int command) OVERRIDE;
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index 35d9b17..d1ea5c0 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -656,6 +656,9 @@ bool NativeWidgetWin::HandleAppCommand(short command) {
GetWidget()->widget_delegate()->ExecuteWindowsCommand(command);
}
+void NativeWidgetWin::HandleCancelMode() {
+}
+
void NativeWidgetWin::HandleCaptureLost() {
delegate_->OnMouseCaptureLost();
}
diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h
index e963c9b..006a249a 100644
--- a/ui/views/widget/native_widget_win.h
+++ b/ui/views/widget/native_widget_win.h
@@ -210,6 +210,7 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate,
virtual void HandleAppDeactivated() OVERRIDE;
virtual void HandleActivationChanged(bool active) OVERRIDE;
virtual bool HandleAppCommand(short command) OVERRIDE;
+ virtual void HandleCancelMode() OVERRIDE;
virtual void HandleCaptureLost() OVERRIDE;
virtual void HandleClose() OVERRIDE;
virtual bool HandleCommand(int command) OVERRIDE;
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index b250c96..d1c8534 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -1247,6 +1247,12 @@ BOOL HWNDMessageHandler::OnAppCommand(HWND window,
return handled;
}
+void HWNDMessageHandler::OnCancelMode() {
+ delegate_->HandleCancelMode();
+ // Need default handling, otherwise capture and other things aren't canceled.
+ SetMsgHandled(FALSE);
+}
+
void HWNDMessageHandler::OnCaptureChanged(HWND window) {
delegate_->HandleCaptureLost();
}
diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h
index 7185c89..f69979f 100644
--- a/ui/views/win/hwnd_message_handler.h
+++ b/ui/views/win/hwnd_message_handler.h
@@ -274,6 +274,7 @@ class VIEWS_EXPORT HWNDMessageHandler : public ui::WindowImpl,
// This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU.
MSG_WM_ACTIVATEAPP(OnActivateApp)
MSG_WM_APPCOMMAND(OnAppCommand)
+ MSG_WM_CANCELMODE(OnCancelMode)
MSG_WM_CAPTURECHANGED(OnCaptureChanged)
MSG_WM_CLOSE(OnClose)
MSG_WM_COMMAND(OnCommand)
@@ -315,6 +316,7 @@ class VIEWS_EXPORT HWNDMessageHandler : public ui::WindowImpl,
// 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);
diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h
index 53235dc..ac7c865 100644
--- a/ui/views/win/hwnd_message_handler_delegate.h
+++ b/ui/views/win/hwnd_message_handler_delegate.h
@@ -101,6 +101,9 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate {
// Returns true if the command was handled.
virtual bool HandleAppCommand(short command) = 0;
+ // Called from WM_CANCELMODE.
+ virtual void HandleCancelMode() = 0;
+
// Called when the window has lost mouse capture.
virtual void HandleCaptureLost() = 0;