| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" |
| 6 | 6 |
| 7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
| 8 | 8 |
| 9 #include "base/event_types.h" | 9 #include "base/event_types.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 398 } |
| 399 | 399 |
| 400 /////////////////////////////////////////////////////////////////////////////// | 400 /////////////////////////////////////////////////////////////////////////////// |
| 401 | 401 |
| 402 DesktopDragDropClientAuraX11::DesktopDragDropClientAuraX11( | 402 DesktopDragDropClientAuraX11::DesktopDragDropClientAuraX11( |
| 403 aura::Window* root_window, | 403 aura::Window* root_window, |
| 404 views::DesktopNativeCursorManager* cursor_manager, | 404 views::DesktopNativeCursorManager* cursor_manager, |
| 405 Display* xdisplay, | 405 Display* xdisplay, |
| 406 ::Window xwindow) | 406 ::Window xwindow) |
| 407 : root_window_(root_window), | 407 : root_window_(root_window), |
| 408 cursor_manager_(cursor_manager), |
| 408 xdisplay_(xdisplay), | 409 xdisplay_(xdisplay), |
| 409 xwindow_(xwindow), | 410 xwindow_(xwindow), |
| 410 atom_cache_(xdisplay_, kAtomsToCache), | 411 atom_cache_(xdisplay_, kAtomsToCache), |
| 411 current_modifier_state_(ui::EF_NONE), | 412 current_modifier_state_(ui::EF_NONE), |
| 412 target_window_(NULL), | 413 target_window_(NULL), |
| 413 waiting_on_status_(false), | 414 waiting_on_status_(false), |
| 414 status_received_since_enter_(false), | 415 status_received_since_enter_(false), |
| 415 source_provider_(NULL), | 416 source_provider_(NULL), |
| 416 source_current_window_(None), | 417 source_current_window_(None), |
| 417 source_state_(SOURCE_STATE_OTHER), | 418 source_state_(SOURCE_STATE_OTHER), |
| 418 drag_operation_(0), | 419 drag_operation_(0), |
| 419 negotiated_operation_(ui::DragDropTypes::DRAG_NONE), | 420 negotiated_operation_(ui::DragDropTypes::DRAG_NONE), |
| 420 grab_cursor_(cursor_manager->GetInitializedCursor(ui::kCursorGrabbing)), | |
| 421 copy_grab_cursor_(cursor_manager->GetInitializedCursor(ui::kCursorCopy)), | |
| 422 move_grab_cursor_(cursor_manager->GetInitializedCursor(ui::kCursorMove)), | |
| 423 weak_ptr_factory_(this) { | 421 weak_ptr_factory_(this) { |
| 424 // Some tests change the DesktopDragDropClientAuraX11 associated with an | 422 // Some tests change the DesktopDragDropClientAuraX11 associated with an |
| 425 // |xwindow|. | 423 // |xwindow|. |
| 426 g_live_client_map.Get()[xwindow] = this; | 424 g_live_client_map.Get()[xwindow] = this; |
| 427 | 425 |
| 428 // Mark that we are aware of drag and drop concepts. | 426 // Mark that we are aware of drag and drop concepts. |
| 429 unsigned long xdnd_version = kMinXdndVersion; | 427 unsigned long xdnd_version = kMinXdndVersion; |
| 430 XChangeProperty(xdisplay_, xwindow_, atom_cache_.GetAtom("XdndAware"), | 428 XChangeProperty(xdisplay_, xwindow_, atom_cache_.GetAtom("XdndAware"), |
| 431 XA_ATOM, 32, PropModeReplace, | 429 XA_ATOM, 32, PropModeReplace, |
| 432 reinterpret_cast<unsigned char*>(&xdnd_version), 1); | 430 reinterpret_cast<unsigned char*>(&xdnd_version), 1); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 // We were waiting on the status message so we could send the XdndDrop. | 529 // We were waiting on the status message so we could send the XdndDrop. |
| 532 if (negotiated_operation_ == ui::DragDropTypes::DRAG_NONE) { | 530 if (negotiated_operation_ == ui::DragDropTypes::DRAG_NONE) { |
| 533 move_loop_->EndMoveLoop(); | 531 move_loop_->EndMoveLoop(); |
| 534 return; | 532 return; |
| 535 } | 533 } |
| 536 source_state_ = SOURCE_STATE_DROPPED; | 534 source_state_ = SOURCE_STATE_DROPPED; |
| 537 SendXdndDrop(source_window); | 535 SendXdndDrop(source_window); |
| 538 return; | 536 return; |
| 539 } | 537 } |
| 540 | 538 |
| 539 int cursor_type = ui::kCursorNull; |
| 541 switch (negotiated_operation_) { | 540 switch (negotiated_operation_) { |
| 542 case ui::DragDropTypes::DRAG_COPY: | 541 case ui::DragDropTypes::DRAG_COPY: |
| 543 move_loop_->UpdateCursor(copy_grab_cursor_); | 542 cursor_type = ui::kCursorCopy; |
| 544 break; | 543 break; |
| 545 case ui::DragDropTypes::DRAG_MOVE: | 544 case ui::DragDropTypes::DRAG_MOVE: |
| 546 move_loop_->UpdateCursor(move_grab_cursor_); | 545 cursor_type = ui::kCursorMove; |
| 547 break; | 546 break; |
| 548 default: | 547 default: |
| 549 move_loop_->UpdateCursor(grab_cursor_); | 548 cursor_type = ui::kCursorGrabbing; |
| 550 break; | 549 break; |
| 551 } | 550 } |
| 551 move_loop_->UpdateCursor(cursor_manager_->GetInitializedCursor(cursor_type)); |
| 552 | 552 |
| 553 // Note: event.data.[2,3] specify a rectangle. It is a request by the other | 553 // Note: event.data.[2,3] specify a rectangle. It is a request by the other |
| 554 // window to not send further XdndPosition messages while the cursor is | 554 // window to not send further XdndPosition messages while the cursor is |
| 555 // within it. However, it is considered advisory and (at least according to | 555 // within it. However, it is considered advisory and (at least according to |
| 556 // the spec) the other side must handle further position messages within | 556 // the spec) the other side must handle further position messages within |
| 557 // it. GTK+ doesn't bother with this, so neither should we. | 557 // it. GTK+ doesn't bother with this, so neither should we. |
| 558 | 558 |
| 559 if (next_position_message_.get()) { | 559 if (next_position_message_.get()) { |
| 560 // We were waiting on the status message so we could send off the next | 560 // We were waiting on the status message so we could send off the next |
| 561 // position message we queued up. | 561 // position message we queued up. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 | 686 |
| 687 // It is possible for the DesktopWindowTreeHostX11 to be destroyed during the | 687 // It is possible for the DesktopWindowTreeHostX11 to be destroyed during the |
| 688 // move loop, which would also destroy this drag-client. So keep track of | 688 // move loop, which would also destroy this drag-client. So keep track of |
| 689 // whether it is alive after the drag ends. | 689 // whether it is alive after the drag ends. |
| 690 base::WeakPtr<DesktopDragDropClientAuraX11> alive( | 690 base::WeakPtr<DesktopDragDropClientAuraX11> alive( |
| 691 weak_ptr_factory_.GetWeakPtr()); | 691 weak_ptr_factory_.GetWeakPtr()); |
| 692 | 692 |
| 693 // Windows has a specific method, DoDragDrop(), which performs the entire | 693 // Windows has a specific method, DoDragDrop(), which performs the entire |
| 694 // drag. We have to emulate this, so we spin off a nested runloop which will | 694 // drag. We have to emulate this, so we spin off a nested runloop which will |
| 695 // track all cursor movement and reroute events to a specific handler. | 695 // track all cursor movement and reroute events to a specific handler. |
| 696 move_loop_->RunMoveLoop(source_window, grab_cursor_); | 696 move_loop_->RunMoveLoop( |
| 697 source_window, |
| 698 cursor_manager_->GetInitializedCursor(ui::kCursorGrabbing)); |
| 697 | 699 |
| 698 if (alive) { | 700 if (alive) { |
| 699 drag_widget_.reset(); | 701 drag_widget_.reset(); |
| 700 | 702 |
| 701 source_provider_ = NULL; | 703 source_provider_ = NULL; |
| 702 g_current_drag_drop_client = NULL; | 704 g_current_drag_drop_client = NULL; |
| 703 drag_operation_ = 0; | 705 drag_operation_ = 0; |
| 704 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom("XdndActionList")); | 706 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom("XdndActionList")); |
| 705 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom(kXdndDirectSave0)); | 707 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom(kXdndDirectSave0)); |
| 706 | 708 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 for (int x = 0; x < in_bitmap->width(); ++x) { | 1191 for (int x = 0; x < in_bitmap->width(); ++x) { |
| 1190 if (SkColorGetA(in_row[x]) > kMinAlpha) | 1192 if (SkColorGetA(in_row[x]) > kMinAlpha) |
| 1191 return true; | 1193 return true; |
| 1192 } | 1194 } |
| 1193 } | 1195 } |
| 1194 | 1196 |
| 1195 return false; | 1197 return false; |
| 1196 } | 1198 } |
| 1197 | 1199 |
| 1198 } // namespace views | 1200 } // namespace views |
| OLD | NEW |