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 10 matching lines...) Expand all Loading... |
21 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
22 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
24 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
25 #include "ui/base/clipboard/clipboard_monitor.h" | 25 #include "ui/base/clipboard/clipboard_monitor.h" |
26 #include "ui/base/clipboard/custom_data_helper.h" | 26 #include "ui/base/clipboard/custom_data_helper.h" |
27 #include "ui/base/x/selection_owner.h" | 27 #include "ui/base/x/selection_owner.h" |
28 #include "ui/base/x/selection_requestor.h" | 28 #include "ui/base/x/selection_requestor.h" |
29 #include "ui/base/x/selection_utils.h" | 29 #include "ui/base/x/selection_utils.h" |
30 #include "ui/base/x/x11_util.h" | 30 #include "ui/base/x/x11_util.h" |
| 31 #include "ui/base/x/x11_window_event_manager.h" |
31 #include "ui/events/platform/platform_event_dispatcher.h" | 32 #include "ui/events/platform/platform_event_dispatcher.h" |
32 #include "ui/events/platform/platform_event_observer.h" | 33 #include "ui/events/platform/platform_event_observer.h" |
33 #include "ui/events/platform/platform_event_source.h" | 34 #include "ui/events/platform/platform_event_source.h" |
34 #include "ui/gfx/codec/png_codec.h" | 35 #include "ui/gfx/codec/png_codec.h" |
35 #include "ui/gfx/geometry/size.h" | 36 #include "ui/gfx/geometry/size.h" |
36 #include "ui/gfx/x/x11_atom_cache.h" | 37 #include "ui/gfx/x/x11_atom_cache.h" |
37 | 38 |
38 namespace ui { | 39 namespace ui { |
39 | 40 |
40 namespace { | 41 namespace { |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 bool CanDispatchEvent(const PlatformEvent& event) override; | 295 bool CanDispatchEvent(const PlatformEvent& event) override; |
295 uint32_t DispatchEvent(const PlatformEvent& event) override; | 296 uint32_t DispatchEvent(const PlatformEvent& event) override; |
296 | 297 |
297 // Our X11 state. | 298 // Our X11 state. |
298 Display* x_display_; | 299 Display* x_display_; |
299 ::Window x_root_window_; | 300 ::Window x_root_window_; |
300 | 301 |
301 // Input-only window used as a selection owner. | 302 // Input-only window used as a selection owner. |
302 ::Window x_window_; | 303 ::Window x_window_; |
303 | 304 |
| 305 // Events selected on |x_window_|. |
| 306 std::unique_ptr<XScopedEventSelector> x_window_events_; |
| 307 |
304 X11AtomCache atom_cache_; | 308 X11AtomCache atom_cache_; |
305 | 309 |
306 // Object which requests and receives selection data. | 310 // Object which requests and receives selection data. |
307 SelectionRequestor selection_requestor_; | 311 SelectionRequestor selection_requestor_; |
308 | 312 |
309 // Temporary target map that we write to during DispatchObects. | 313 // Temporary target map that we write to during DispatchObects. |
310 SelectionFormatMap clipboard_data_; | 314 SelectionFormatMap clipboard_data_; |
311 | 315 |
312 // Objects which offer selection data to other windows. | 316 // Objects which offer selection data to other windows. |
313 SelectionOwner clipboard_owner_; | 317 SelectionOwner clipboard_owner_; |
(...skipping 18 matching lines...) Expand all Loading... |
332 0, | 336 0, |
333 NULL)), | 337 NULL)), |
334 atom_cache_(x_display_, kAtomsToCache), | 338 atom_cache_(x_display_, kAtomsToCache), |
335 selection_requestor_(x_display_, x_window_, this), | 339 selection_requestor_(x_display_, x_window_, this), |
336 clipboard_owner_(x_display_, x_window_, atom_cache_.GetAtom(kClipboard)), | 340 clipboard_owner_(x_display_, x_window_, atom_cache_.GetAtom(kClipboard)), |
337 primary_owner_(x_display_, x_window_, XA_PRIMARY) { | 341 primary_owner_(x_display_, x_window_, XA_PRIMARY) { |
338 // We don't know all possible MIME types at compile time. | 342 // We don't know all possible MIME types at compile time. |
339 atom_cache_.allow_uncached_atoms(); | 343 atom_cache_.allow_uncached_atoms(); |
340 | 344 |
341 XStoreName(x_display_, x_window_, "Chromium clipboard"); | 345 XStoreName(x_display_, x_window_, "Chromium clipboard"); |
342 XSelectInput(x_display_, x_window_, PropertyChangeMask); | 346 x_window_events_.reset( |
| 347 new XScopedEventSelector(x_window_, PropertyChangeMask)); |
343 | 348 |
344 if (PlatformEventSource::GetInstance()) | 349 if (PlatformEventSource::GetInstance()) |
345 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 350 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
346 } | 351 } |
347 | 352 |
348 ClipboardAuraX11::AuraX11Details::~AuraX11Details() { | 353 ClipboardAuraX11::AuraX11Details::~AuraX11Details() { |
349 if (PlatformEventSource::GetInstance()) | 354 if (PlatformEventSource::GetInstance()) |
350 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | 355 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
351 | 356 |
352 XDestroyWindow(x_display_, x_window_); | 357 XDestroyWindow(x_display_, x_window_); |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 if (format.Equals(GetBitmapFormatType())) | 942 if (format.Equals(GetBitmapFormatType())) |
938 return; | 943 return; |
939 | 944 |
940 std::vector<unsigned char> bytes(data_data, data_data + data_len); | 945 std::vector<unsigned char> bytes(data_data, data_data + data_len); |
941 scoped_refptr<base::RefCountedMemory> mem( | 946 scoped_refptr<base::RefCountedMemory> mem( |
942 base::RefCountedBytes::TakeVector(&bytes)); | 947 base::RefCountedBytes::TakeVector(&bytes)); |
943 aurax11_details_->InsertMapping(format.ToString(), mem); | 948 aurax11_details_->InsertMapping(format.ToString(), mem); |
944 } | 949 } |
945 | 950 |
946 } // namespace ui | 951 } // namespace ui |
OLD | NEW |