Chromium Code Reviews| 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_requestor.h" | 5 #include "ui/base/x/selection_requestor.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_pump_x11.h" | 7 #include "base/message_loop/message_pump_x11.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "ui/base/x/selection_utils.h" | 9 #include "ui/base/x/selection_utils.h" |
| 10 #include "ui/base/x/x11_util.h" | 10 #include "ui/base/x/x11_util.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 run_loop.QuitClosure(), | 62 run_loop.QuitClosure(), |
| 63 base::TimeDelta::FromMilliseconds(kMaxWaitTimeForClipboardResponse)); | 63 base::TimeDelta::FromMilliseconds(kMaxWaitTimeForClipboardResponse)); |
| 64 | 64 |
| 65 PendingRequest pending_request(target, run_loop.QuitClosure()); | 65 PendingRequest pending_request(target, run_loop.QuitClosure()); |
| 66 pending_requests_.push_back(&pending_request); | 66 pending_requests_.push_back(&pending_request); |
| 67 run_loop.Run(); | 67 run_loop.Run(); |
| 68 DCHECK(!pending_requests_.empty()); | 68 DCHECK(!pending_requests_.empty()); |
| 69 DCHECK_EQ(&pending_request, pending_requests_.back()); | 69 DCHECK_EQ(&pending_request, pending_requests_.back()); |
| 70 pending_requests_.pop_back(); | 70 pending_requests_.pop_back(); |
| 71 | 71 |
| 72 if (pending_request.returned_property != property_to_set) | 72 bool success = false; |
| 73 return false; | 73 if (pending_request.returned_property == property_to_set) { |
| 74 | 74 success = ui::GetRawBytesOfProperty(x_window_, |
| 75 return ui::GetRawBytesOfProperty(x_window_, pending_request.returned_property, | 75 pending_request.returned_property, |
| 76 out_data, out_data_bytes, out_data_items, | 76 out_data, out_data_bytes, |
| 77 out_type); | 77 out_data_items, out_type); |
| 78 } | |
| 79 XDeleteProperty(x_display_, x_window_, pending_request.returned_property); | |
|
sadrul
2014/04/15 16:20:15
Should this be inside the if? and/or, should this
pkotwicz
2014/04/15 16:57:55
I checked and XDeleteProperty() does not do anythi
sadrul
2014/04/15 18:04:30
The man page claims XDeleteProperty can generate B
| |
| 80 return success; | |
| 78 } | 81 } |
| 79 | 82 |
| 80 SelectionData SelectionRequestor::RequestAndWaitForTypes( | 83 SelectionData SelectionRequestor::RequestAndWaitForTypes( |
| 81 const std::vector< ::Atom>& types) { | 84 const std::vector< ::Atom>& types) { |
| 82 for (std::vector< ::Atom>::const_iterator it = types.begin(); | 85 for (std::vector< ::Atom>::const_iterator it = types.begin(); |
| 83 it != types.end(); ++it) { | 86 it != types.end(); ++it) { |
| 84 scoped_refptr<base::RefCountedMemory> data; | 87 scoped_refptr<base::RefCountedMemory> data; |
| 85 size_t data_bytes = 0; | 88 size_t data_bytes = 0; |
| 86 ::Atom type = None; | 89 ::Atom type = None; |
| 87 if (PerformBlockingConvertSelection(*it, | 90 if (PerformBlockingConvertSelection(*it, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 111 if (request->target != event.target) | 114 if (request->target != event.target) |
| 112 continue; | 115 continue; |
| 113 request_notified = request; | 116 request_notified = request; |
| 114 break; | 117 break; |
| 115 } | 118 } |
| 116 } | 119 } |
| 117 | 120 |
| 118 // This event doesn't correspond to any XConvertSelection calls that we | 121 // This event doesn't correspond to any XConvertSelection calls that we |
| 119 // issued in PerformBlockingConvertSelection. This shouldn't happen, but any | 122 // issued in PerformBlockingConvertSelection. This shouldn't happen, but any |
| 120 // client can send any message, so it can happen. | 123 // client can send any message, so it can happen. |
| 121 if (!request_notified) | 124 if (!request_notified) { |
| 125 // ICCCM requires us to delete the property passed into SelectionNotify. If | |
| 126 // |request_notified| is true, the property will be deleted when the run | |
| 127 // loop has quit. | |
| 128 XDeleteProperty(x_display_, x_window_, event.property); | |
| 122 return; | 129 return; |
| 130 } | |
| 123 | 131 |
| 124 request_notified->returned_property = event.property; | 132 request_notified->returned_property = event.property; |
| 125 request_notified->returned = true; | 133 request_notified->returned = true; |
| 126 request_notified->quit_closure.Run(); | 134 request_notified->quit_closure.Run(); |
| 127 } | 135 } |
| 128 | 136 |
| 129 SelectionRequestor::PendingRequest::PendingRequest(Atom target, | 137 SelectionRequestor::PendingRequest::PendingRequest(Atom target, |
| 130 base::Closure quit_closure) | 138 base::Closure quit_closure) |
| 131 : target(target), | 139 : target(target), |
| 132 quit_closure(quit_closure), | 140 quit_closure(quit_closure), |
| 133 returned_property(None), | 141 returned_property(None), |
| 134 returned(false) { | 142 returned(false) { |
| 135 } | 143 } |
| 136 | 144 |
| 137 SelectionRequestor::PendingRequest::~PendingRequest() { | 145 SelectionRequestor::PendingRequest::~PendingRequest() { |
| 138 } | 146 } |
| 139 | 147 |
| 140 } // namespace ui | 148 } // namespace ui |
| OLD | NEW |