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

Unified Diff: ui/aura_shell/desktop_event_filter.cc

Issue 8450018: First shot at implementing drag&drop for Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor changes Created 9 years, 1 month 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/aura_shell/desktop_event_filter.cc
diff --git a/ui/aura_shell/desktop_event_filter.cc b/ui/aura_shell/desktop_event_filter.cc
index d69ead118f5b8531c642c99d7b192ad33f9c0c13..a9ab7e36ade8ccdf9451637cf68ed2685f11a296 100644
--- a/ui/aura_shell/desktop_event_filter.cc
+++ b/ui/aura_shell/desktop_event_filter.cc
@@ -4,6 +4,8 @@
#include "ui/aura_shell/desktop_event_filter.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/desktop.h"
#include "ui/aura/event.h"
#include "ui/aura/focus_manager.h"
@@ -15,6 +17,30 @@
namespace aura_shell {
namespace internal {
+bool HandleDragDrop(aura::Window* target, aura::MouseEvent* event) {
+ aura::DragDropClient* drag_drop_client = static_cast<aura::DragDropClient*>(
+ aura::Desktop::GetInstance()->GetProperty(
+ aura::kDesktopDragDropClientKey));
+ if (drag_drop_client && drag_drop_client->IsDragAndDropInProgress()) {
+ switch (event->type()) {
+ case ui::ET_MOUSE_DRAGGED:
+ drag_drop_client->DragUpdate(target, *event);
+ break;
+ case ui::ET_MOUSE_RELEASED:
+ drag_drop_client->Drop(target, *event);
+ break;
+ case ui::ET_MOUSE_EXITED:
+ drag_drop_client->DragCancel();
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ return true;
+ }
+ return false;
+}
+
// Returns the default cursor for a window component.
gfx::NativeCursor CursorForWindowComponent(int window_component) {
switch (window_component) {
@@ -70,6 +96,11 @@ bool DesktopEventFilter::PreHandleKeyEvent(aura::Window* target,
bool DesktopEventFilter::PreHandleMouseEvent(aura::Window* target,
aura::MouseEvent* event) {
+
+ // Give all events to the drag/drop controller is a drag/drop is in progress.
+ if (HandleDragDrop(target, event))
Ben Goodger (Google) 2011/11/16 00:13:20 Now that we support addtl event filters... just mo
varunjain 2011/11/16 20:30:15 Done.
+ return true;
+
if (FilterMouseEvent(target, event))
return true;

Powered by Google App Engine
This is Rietveld 408576698