| 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/base/clipboard/clipboard_aurax11.h" | 5 #include "ui/base/clipboard/clipboard_aurax11.h" |
| 6 | 6 |
| 7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
| 8 #include <X11/extensions/Xfixes.h> | 8 #include <X11/extensions/Xfixes.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 // Moves the temporary |clipboard_data_| to the long term data storage for | 259 // Moves the temporary |clipboard_data_| to the long term data storage for |
| 260 // |type|. | 260 // |type|. |
| 261 void TakeOwnershipOfSelection(ClipboardType type); | 261 void TakeOwnershipOfSelection(ClipboardType type); |
| 262 | 262 |
| 263 // Returns the first of |types| offered by the current selection holder in | 263 // Returns the first of |types| offered by the current selection holder in |
| 264 // |data_out|, or returns NULL if none of those types are available. | 264 // |data_out|, or returns NULL if none of those types are available. |
| 265 // | 265 // |
| 266 // If the selection holder is us, this call is synchronous and we pull | 266 // If the selection holder is us, this call is synchronous and we pull |
| 267 // the data out of |clipboard_selection_| or |primary_selection_|. If the | 267 // the data out of |clipboard_selection_| or |primary_selection_|. If the |
| 268 // selection holder is some other window, we spin up a nested message loop | 268 // selection holder is some other window, we spin up a nested run loop |
| 269 // and do the asynchronous dance with whatever application is holding the | 269 // and do the asynchronous dance with whatever application is holding the |
| 270 // selection. | 270 // selection. |
| 271 ui::SelectionData RequestAndWaitForTypes(ClipboardType type, | 271 ui::SelectionData RequestAndWaitForTypes(ClipboardType type, |
| 272 const std::vector< ::Atom>& types); | 272 const std::vector< ::Atom>& types); |
| 273 | 273 |
| 274 // Retrieves the list of possible data types the current clipboard owner has. | 274 // Retrieves the list of possible data types the current clipboard owner has. |
| 275 // | 275 // |
| 276 // If the selection holder is us, this is synchronous, otherwise this runs a | 276 // If the selection holder is us, this is synchronous, otherwise this runs a |
| 277 // blocking message loop. | 277 // blocking message loop. |
| 278 TargetList WaitAndGetTargetsList(ClipboardType type); | 278 TargetList WaitAndGetTargetsList(ClipboardType type); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 return clipboard_owner_.TakeOwnershipOfSelection(clipboard_data_); | 395 return clipboard_owner_.TakeOwnershipOfSelection(clipboard_data_); |
| 396 else | 396 else |
| 397 return primary_owner_.TakeOwnershipOfSelection(clipboard_data_); | 397 return primary_owner_.TakeOwnershipOfSelection(clipboard_data_); |
| 398 } | 398 } |
| 399 | 399 |
| 400 SelectionData ClipboardAuraX11::AuraX11Details::RequestAndWaitForTypes( | 400 SelectionData ClipboardAuraX11::AuraX11Details::RequestAndWaitForTypes( |
| 401 ClipboardType type, | 401 ClipboardType type, |
| 402 const std::vector<::Atom>& types) { | 402 const std::vector<::Atom>& types) { |
| 403 ::Atom selection_name = LookupSelectionForClipboardType(type); | 403 ::Atom selection_name = LookupSelectionForClipboardType(type); |
| 404 if (XGetSelectionOwner(x_display_, selection_name) == x_window_) { | 404 if (XGetSelectionOwner(x_display_, selection_name) == x_window_) { |
| 405 // We can local fastpath instead of playing the nested message loop game | 405 // We can local fastpath instead of playing the nested run loop game |
| 406 // with the X server. | 406 // with the X server. |
| 407 const SelectionFormatMap& format_map = LookupStorageForAtom(selection_name); | 407 const SelectionFormatMap& format_map = LookupStorageForAtom(selection_name); |
| 408 | 408 |
| 409 for (std::vector< ::Atom>::const_iterator it = types.begin(); | 409 for (std::vector< ::Atom>::const_iterator it = types.begin(); |
| 410 it != types.end(); ++it) { | 410 it != types.end(); ++it) { |
| 411 SelectionFormatMap::const_iterator format_map_it = format_map.find(*it); | 411 SelectionFormatMap::const_iterator format_map_it = format_map.find(*it); |
| 412 if (format_map_it != format_map.end()) | 412 if (format_map_it != format_map.end()) |
| 413 return SelectionData(format_map_it->first, format_map_it->second); | 413 return SelectionData(format_map_it->first, format_map_it->second); |
| 414 } | 414 } |
| 415 } else { | 415 } else { |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 if (format.Equals(GetBitmapFormatType())) | 945 if (format.Equals(GetBitmapFormatType())) |
| 946 return; | 946 return; |
| 947 | 947 |
| 948 std::vector<unsigned char> bytes(data_data, data_data + data_len); | 948 std::vector<unsigned char> bytes(data_data, data_data + data_len); |
| 949 scoped_refptr<base::RefCountedMemory> mem( | 949 scoped_refptr<base::RefCountedMemory> mem( |
| 950 base::RefCountedBytes::TakeVector(&bytes)); | 950 base::RefCountedBytes::TakeVector(&bytes)); |
| 951 aurax11_details_->InsertMapping(format.ToString(), mem); | 951 aurax11_details_->InsertMapping(format.ToString(), mem); |
| 952 } | 952 } |
| 953 | 953 |
| 954 } // namespace ui | 954 } // namespace ui |
| OLD | NEW |