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

Side by Side Diff: ui/base/x/selection_requestor.cc

Issue 237583003: Delete the property returned by SelectionNotify as per ICCCM spec (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/run_loop.h" 7 #include "base/run_loop.h"
8 #include "ui/base/x/selection_utils.h" 8 #include "ui/base/x/selection_utils.h"
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 #include "ui/gfx/x/x11_types.h" 10 #include "ui/gfx/x/x11_types.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (pending_request.returned_property != None)
80 XDeleteProperty(x_display_, x_window_, pending_request.returned_property);
81 return success;
78 } 82 }
79 83
80 SelectionData SelectionRequestor::RequestAndWaitForTypes( 84 SelectionData SelectionRequestor::RequestAndWaitForTypes(
81 const std::vector< ::Atom>& types) { 85 const std::vector< ::Atom>& types) {
82 for (std::vector< ::Atom>::const_iterator it = types.begin(); 86 for (std::vector< ::Atom>::const_iterator it = types.begin();
83 it != types.end(); ++it) { 87 it != types.end(); ++it) {
84 scoped_refptr<base::RefCountedMemory> data; 88 scoped_refptr<base::RefCountedMemory> data;
85 size_t data_bytes = 0; 89 size_t data_bytes = 0;
86 ::Atom type = None; 90 ::Atom type = None;
87 if (PerformBlockingConvertSelection(*it, 91 if (PerformBlockingConvertSelection(*it,
(...skipping 23 matching lines...) Expand all
111 if (request->target != event.target) 115 if (request->target != event.target)
112 continue; 116 continue;
113 request_notified = request; 117 request_notified = request;
114 break; 118 break;
115 } 119 }
116 } 120 }
117 121
118 // This event doesn't correspond to any XConvertSelection calls that we 122 // This event doesn't correspond to any XConvertSelection calls that we
119 // issued in PerformBlockingConvertSelection. This shouldn't happen, but any 123 // issued in PerformBlockingConvertSelection. This shouldn't happen, but any
120 // client can send any message, so it can happen. 124 // client can send any message, so it can happen.
121 if (!request_notified) 125 if (!request_notified) {
126 // ICCCM requires us to delete the property passed into SelectionNotify. If
127 // |request_notified| is true, the property will be deleted when the run
128 // loop has quit.
129 if (event.property != None)
130 XDeleteProperty(x_display_, x_window_, event.property);
122 return; 131 return;
132 }
123 133
124 request_notified->returned_property = event.property; 134 request_notified->returned_property = event.property;
125 request_notified->returned = true; 135 request_notified->returned = true;
126 request_notified->quit_closure.Run(); 136 request_notified->quit_closure.Run();
127 } 137 }
128 138
129 SelectionRequestor::PendingRequest::PendingRequest(Atom target, 139 SelectionRequestor::PendingRequest::PendingRequest(Atom target,
130 base::Closure quit_closure) 140 base::Closure quit_closure)
131 : target(target), 141 : target(target),
132 quit_closure(quit_closure), 142 quit_closure(quit_closure),
133 returned_property(None), 143 returned_property(None),
134 returned(false) { 144 returned(false) {
135 } 145 }
136 146
137 SelectionRequestor::PendingRequest::~PendingRequest() { 147 SelectionRequestor::PendingRequest::~PendingRequest() {
138 } 148 }
139 149
140 } // namespace ui 150 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698