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

Unified Diff: ui/aura_shell/default_container_event_filter.cc

Issue 8381015: Add workspace to desktop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: temporarily exlucde tests failing on win Created 9 years, 2 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
« no previous file with comments | « ui/aura_shell/default_container_event_filter.h ('k') | ui/aura_shell/default_container_layout_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/default_container_event_filter.cc
diff --git a/ui/aura_shell/default_container_event_filter.cc b/ui/aura_shell/default_container_event_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c54e39176a6edfb8c50e65f3ac620d27a2035a16
--- /dev/null
+++ b/ui/aura_shell/default_container_event_filter.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2011 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/aura_shell/default_container_event_filter.h"
+
+#include "ui/aura/event.h"
+#include "ui/aura/hit_test.h"
+#include "ui/aura/window.h"
+#include "ui/aura_shell/default_container_layout_manager.h"
+
+namespace aura_shell {
+namespace internal {
+
+DefaultContainerEventFilter::DefaultContainerEventFilter(aura::Window* owner)
+ : ToplevelWindowEventFilter(owner),
+ drag_state_(DRAG_NONE) {
+}
+
+DefaultContainerEventFilter::~DefaultContainerEventFilter() {
+}
+
+bool DefaultContainerEventFilter::OnMouseEvent(aura::Window* target,
+ aura::MouseEvent* event) {
+ DefaultContainerLayoutManager* layout_manager =
+ static_cast<DefaultContainerLayoutManager*>(owner()->layout_manager());
+ DCHECK(layout_manager);
+
+ // Notify layout manager that drag event may move/resize the target wnidow.
+ if (event->type() == ui::ET_MOUSE_DRAGGED && drag_state_ == DRAG_NONE)
+ layout_manager->PrepareForMoveOrResize(target, event);
+
+ bool handled = ToplevelWindowEventFilter::OnMouseEvent(target, event);
+
+ switch (event->type()) {
+ case ui::ET_MOUSE_DRAGGED:
+ // Cancel move/resize if the event wasn't handled, or
+ // drag_state_ didn't move to MOVE or RESIZE.
+ if (!handled || (drag_state_ == DRAG_NONE && !UpdateDragState()))
+ layout_manager->CancelMoveOrResize(target, event);
+ break;
+ case ui::ET_MOUSE_RELEASED:
+ if (drag_state_ == DRAG_MOVE)
+ layout_manager->EndMove(target, event);
+ else if (drag_state_ == DRAG_RESIZE)
+ layout_manager->EndResize(target, event);
+
+ drag_state_ = DRAG_NONE;
+ break;
+ default:
+ break;
+ }
+ return handled;
+}
+
+bool DefaultContainerEventFilter::UpdateDragState() {
+ DCHECK_EQ(DRAG_NONE, drag_state_);
+ switch (window_component()) {
+ case HTCAPTION:
+ drag_state_ = DRAG_MOVE;
+ break;
+ case HTTOP:
+ case HTTOPRIGHT:
+ case HTRIGHT:
+ case HTBOTTOMRIGHT:
+ case HTBOTTOM:
+ case HTBOTTOMLEFT:
+ case HTLEFT:
+ case HTTOPLEFT:
+ case HTGROWBOX:
+ drag_state_ = DRAG_RESIZE;
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+} // internal
+} // aura_shell
« no previous file with comments | « ui/aura_shell/default_container_event_filter.h ('k') | ui/aura_shell/default_container_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698