Upstream version 7.35.139.0
[platform/framework/web/crosswalk.git] / src / ui / views / widget / desktop_aura / desktop_drag_drop_client_aurax11.cc
index c56a3ce..4ea28c6 100644 (file)
@@ -70,7 +70,7 @@ const char* kAtomsToCache[] = {
 
 // The time to wait for the target to respond after the user has released the
 // mouse button before ending the move loop.
-const int kEndMoveLoopTimeoutMs = 30000;
+const int kEndMoveLoopTimeoutMs = 1000;
 
 static base::LazyInstance<
     std::map< ::Window, views::DesktopDragDropClientAuraX11*> >::Leaky
@@ -335,7 +335,11 @@ void DesktopDragDropClientAuraX11::X11DragContext::RequestNextTarget() {
 
 void DesktopDragDropClientAuraX11::X11DragContext::OnSelectionNotify(
     const XSelectionEvent& event) {
-  DCHECK(waiting_to_handle_position_);
+  if (!waiting_to_handle_position_) {
+    // A misbehaved window may send SelectionNotify without us requesting data
+    // via XConvertSelection().
+    return;
+  }
   DCHECK(drag_drop_client_);
   DCHECK_EQ(event.property, atom_cache_->GetAtom(kChromiumDragReciever));
 
@@ -609,12 +613,12 @@ void DesktopDragDropClientAuraX11::OnXdndDrop(
 
 void DesktopDragDropClientAuraX11::OnSelectionNotify(
     const XSelectionEvent& xselection) {
-  if (!target_current_context_) {
-    NOTIMPLEMENTED();
-    return;
-  }
+  if (target_current_context_)
+    target_current_context_->OnSelectionNotify(xselection);
 
-  target_current_context_->OnSelectionNotify(xselection);
+  // ICCCM requires us to delete the property passed into SelectionNotify.
+  if (xselection.property != None)
+    XDeleteProperty(xdisplay_, xwindow_, xselection.property);
 }
 
 int DesktopDragDropClientAuraX11::StartDragAndDrop(
@@ -734,6 +738,13 @@ void DesktopDragDropClientAuraX11::OnMouseMovement(XMotionEvent* event) {
 }
 
 void DesktopDragDropClientAuraX11::OnMouseReleased() {
+  if (source_state_ != SOURCE_STATE_OTHER) {
+    // The user has previously released the mouse and is clicking in
+    // frustration.
+    move_loop_.EndMoveLoop();
+    return;
+  }
+
   if (source_current_window_ != None) {
     if (ContainsKey(waiting_on_status_, source_current_window_)) {
       // If we are waiting for an XdndStatus message, we need to wait for it to