summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-03 18:23:18 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-03 18:23:18 +0000
commit2a3197bb6a8a4c6f3a7affadce28cda638906131 (patch)
tree3269ee97d0c0e180d7529169178571f0c56060eb /ash
parent820de97b4820ef0da82d9ee74f3009dc88d3c93e (diff)
downloadchromium_src-2a3197bb6a8a4c6f3a7affadce28cda638906131.zip
chromium_src-2a3197bb6a8a4c6f3a7affadce28cda638906131.tar.gz
chromium_src-2a3197bb6a8a4c6f3a7affadce28cda638906131.tar.bz2
Adds some widget methods I'm going to need for dragging real browsers:
. RunMoveLoop/EndMoveLoop. The new TabDragController will invoke this to start dragging a window. . SetMouseCapture/ReleaseMouseCapture - I have to futz with mouse capture during tab dragging. . SetVisibilityChangedAnimationsEnabled - so that I can disable the aero show/hide effect when showing a new browser. BUG=98345 TEST=none R=ben@chromium.org Review URL: http://codereview.chromium.org/9022039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/toplevel_window_event_filter.cc43
-rw-r--r--ash/wm/toplevel_window_event_filter.h21
2 files changed, 53 insertions, 11 deletions
diff --git a/ash/wm/toplevel_window_event_filter.cc b/ash/wm/toplevel_window_event_filter.cc
index c4d0695..c173ce7 100644
--- a/ash/wm/toplevel_window_event_filter.cc
+++ b/ash/wm/toplevel_window_event_filter.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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 "ash/wm/toplevel_window_event_filter.h"
#include "ash/wm/window_util.h"
+#include "base/message_loop.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/cursor.h"
#include "ui/aura/event.h"
@@ -13,6 +14,7 @@
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
#include "ui/base/ui_base_types.h"
+#include "ui/gfx/screen.h"
namespace ash {
@@ -135,7 +137,9 @@ void ToggleMaximizedState(aura::Window* window) {
ToplevelWindowEventFilter::ToplevelWindowEventFilter(aura::Window* owner)
: EventFilter(owner),
+ in_move_loop_(false),
window_component_(HTNOWHERE) {
+ aura::client::SetWindowMoveClient(owner, this);
}
ToplevelWindowEventFilter::~ToplevelWindowEventFilter() {
@@ -163,13 +167,17 @@ bool ToplevelWindowEventFilter::PreHandleMouseEvent(aura::Window* target,
event->flags() & ui::EF_IS_DOUBLE_CLICK) {
ToggleMaximizedState(target);
}
- UpdateLocationFromEvent(target, event);
+ UpdateMouseDownLocation(target, event->location());
return GetBoundsChangeForWindowComponent(window_component_) !=
kBoundsChange_None;
case ui::ET_MOUSE_DRAGGED:
return HandleDrag(target, event);
case ui::ET_MOUSE_RELEASED:
window_component_ = HTNOWHERE;
+ if (in_move_loop_) {
+ MessageLoop::current()->Quit();
+ in_move_loop_ = false;
+ }
break;
default:
break;
@@ -191,7 +199,7 @@ ui::TouchStatus ToplevelWindowEventFilter::PreHandleTouchEvent(
// Handle touch move by simulate mouse drag with single touch.
switch (event->type()) {
case ui::ET_TOUCH_PRESSED:
- UpdateLocationFromEvent(target, event);
+ UpdateMouseDownLocation(target, event->location());
pressed_touch_ids_.insert(event->touch_id());
if (pressed_touch_ids_.size() == 1)
return ui::TOUCH_STATUS_START;
@@ -215,6 +223,29 @@ ui::TouchStatus ToplevelWindowEventFilter::PreHandleTouchEvent(
return ui::TOUCH_STATUS_UNKNOWN;
}
+void ToplevelWindowEventFilter::RunMoveLoop(aura::Window* source) {
+ DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
+ in_move_loop_ = true;
+ window_component_ = HTCAPTION;
+ gfx::Point source_mouse_location(gfx::Screen::GetCursorScreenPoint());
+ aura::Window::ConvertPointToWindow(
+ aura::RootWindow::GetInstance(), source, &source_mouse_location);
+ UpdateMouseDownLocation(source, source_mouse_location);
+ MessageLoopForUI::current()->RunWithDispatcher(
+ aura::RootWindow::GetInstance()->GetDispatcher());
+ in_move_loop_ = false;
+}
+
+void ToplevelWindowEventFilter::EndMoveLoop() {
+ if (!in_move_loop_)
+ return;
+
+ in_move_loop_ = false;
+ window_component_ = HTNOWHERE;
+ MessageLoopForUI::current()->Quit();
+ aura::RootWindow::GetInstance()->PostNativeEvent(ui::CreateNoopEvent());
+}
+
void ToplevelWindowEventFilter::MoveWindowToFront(aura::Window* target) {
aura::Window* parent = target->parent();
aura::Window* child = target;
@@ -263,11 +294,11 @@ bool ToplevelWindowEventFilter::HandleDrag(aura::Window* target,
return true;
}
-void ToplevelWindowEventFilter::UpdateLocationFromEvent(
+void ToplevelWindowEventFilter::UpdateMouseDownLocation(
aura::Window* target,
- aura::LocatedEvent* event) {
+ const gfx::Point& location) {
mouse_down_bounds_ = target->bounds();
- mouse_down_offset_in_parent_ = event->location();
+ mouse_down_offset_in_parent_ = location;
aura::Window::ConvertPointToWindow(target, target->parent(),
&mouse_down_offset_in_parent_);
}
diff --git a/ash/wm/toplevel_window_event_filter.h b/ash/wm/toplevel_window_event_filter.h
index b548289..ea3661d 100644
--- a/ash/wm/toplevel_window_event_filter.h
+++ b/ash/wm/toplevel_window_event_filter.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -9,6 +9,7 @@
#include <set>
#include "base/compiler_specific.h"
+#include "ui/aura/client/window_move_client.h"
#include "ui/aura/event_filter.h"
#include "ash/ash_export.h"
#include "ui/gfx/point.h"
@@ -22,7 +23,9 @@ class Window;
namespace ash {
-class ASH_EXPORT ToplevelWindowEventFilter : public aura::EventFilter {
+class ASH_EXPORT ToplevelWindowEventFilter :
+ public aura::EventFilter,
+ public aura::client::WindowMoveClient {
public:
explicit ToplevelWindowEventFilter(aura::Window* owner);
virtual ~ToplevelWindowEventFilter();
@@ -35,6 +38,10 @@ class ASH_EXPORT ToplevelWindowEventFilter : public aura::EventFilter {
virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target,
aura::TouchEvent* event) OVERRIDE;
+ // Overridden form aura::client::WindowMoveClient:
+ virtual void RunMoveLoop(aura::Window* source) OVERRIDE;
+ virtual void EndMoveLoop() OVERRIDE;
+
protected:
// Returns the |window_component_|. See the variable definition below for
// more details.
@@ -50,9 +57,10 @@ class ASH_EXPORT ToplevelWindowEventFilter : public aura::EventFilter {
// The return value is returned by OnMouseEvent() above.
bool HandleDrag(aura::Window* target, aura::LocatedEvent* event);
- // Updates the event location to window.
- void UpdateLocationFromEvent(aura::Window* target,
- aura::LocatedEvent* event);
+ // Updates |mouse_down_offset_in_parent_| and |mouse_down_bounds_| from
+ // |location|.
+ void UpdateMouseDownLocation(aura::Window* target,
+ const gfx::Point& location);
// Updates the |window_component_| using the |event|'s location.
void UpdateWindowComponentForEvent(aura::Window* window,
@@ -91,6 +99,9 @@ class ASH_EXPORT ToplevelWindowEventFilter : public aura::EventFilter {
// The bounds of the target window when the mouse was pressed.
gfx::Rect mouse_down_bounds_;
+ // Are we running a nested message loop from RunMoveLoop().
+ bool in_move_loop_;
+
// The window component (hit-test code) the mouse is currently over.
int window_component_;