| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/base/x/selection_owner.h" | 5 #include "ui/base/x/selection_owner.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
| 10 | 10 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 void SelectionOwner::RetrieveTargets(std::vector<XAtom>* targets) { | 112 void SelectionOwner::RetrieveTargets(std::vector<XAtom>* targets) { |
| 113 for (SelectionFormatMap::const_iterator it = format_map_.begin(); | 113 for (SelectionFormatMap::const_iterator it = format_map_.begin(); |
| 114 it != format_map_.end(); ++it) { | 114 it != format_map_.end(); ++it) { |
| 115 targets->push_back(it->first); | 115 targets->push_back(it->first); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 void SelectionOwner::TakeOwnershipOfSelection( | 119 void SelectionOwner::TakeOwnershipOfSelection( |
| 120 const SelectionFormatMap& data) { | 120 const SelectionFormatMap& data) { |
| 121 // Save the last server timestamp seen from X, to satisfy requests for the | 121 acquired_selection_timestamp_ = X11EventSource::GetInstance()->GetTimestamp(); |
| 122 // TIMESTAMP target later… | 122 XSetSelectionOwner(x_display_, selection_name_, x_window_, |
| 123 acquired_selection_timestamp_ = | 123 acquired_selection_timestamp_); |
| 124 X11EventSource::GetInstance()->last_seen_server_time(); | |
| 125 // …but always pass CurrentTime to XSetSelectionOwner to increase the chances | |
| 126 // of this succeeding. | |
| 127 XSetSelectionOwner(x_display_, selection_name_, x_window_, CurrentTime); | |
| 128 | 124 |
| 129 if (XGetSelectionOwner(x_display_, selection_name_) == x_window_) { | 125 if (XGetSelectionOwner(x_display_, selection_name_) == x_window_) { |
| 130 // The X server agrees that we are the selection owner. Commit our data. | 126 // The X server agrees that we are the selection owner. Commit our data. |
| 131 format_map_ = data; | 127 format_map_ = data; |
| 132 } | 128 } |
| 133 } | 129 } |
| 134 | 130 |
| 135 void SelectionOwner::ClearSelectionOwner() { | 131 void SelectionOwner::ClearSelectionOwner() { |
| 136 XSetSelectionOwner(x_display_, selection_name_, None, CurrentTime); | 132 XSetSelectionOwner(x_display_, selection_name_, None, CurrentTime); |
| 137 format_map_ = SelectionFormatMap(); | 133 format_map_ = SelectionFormatMap(); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 foreign_window_manager_id(foreign_window_manager_id) { | 384 foreign_window_manager_id(foreign_window_manager_id) { |
| 389 } | 385 } |
| 390 | 386 |
| 391 SelectionOwner::IncrementalTransfer::IncrementalTransfer( | 387 SelectionOwner::IncrementalTransfer::IncrementalTransfer( |
| 392 const IncrementalTransfer& other) = default; | 388 const IncrementalTransfer& other) = default; |
| 393 | 389 |
| 394 SelectionOwner::IncrementalTransfer::~IncrementalTransfer() { | 390 SelectionOwner::IncrementalTransfer::~IncrementalTransfer() { |
| 395 } | 391 } |
| 396 | 392 |
| 397 } // namespace ui | 393 } // namespace ui |
| OLD | NEW |