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

Side by Side Diff: remoting/host/linux/x_server_clipboard.cc

Issue 17513003: Chromoting Host: Don't listen for PRIMARY selection changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | no next file » | 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) 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 "remoting/host/linux/x_server_clipboard.h" 5 #include "remoting/host/linux/x_server_clipboard.h"
6 6
7 #include <X11/extensions/Xfixes.h> 7 #include <X11/extensions/Xfixes.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 large_selection_atom_ = atoms[1]; 74 large_selection_atom_ = atoms[1];
75 selection_string_atom_ = atoms[2]; 75 selection_string_atom_ = atoms[2];
76 targets_atom_ = atoms[3]; 76 targets_atom_ = atoms[3];
77 timestamp_atom_ = atoms[4]; 77 timestamp_atom_ = atoms[4];
78 utf8_string_atom_ = atoms[5]; 78 utf8_string_atom_ = atoms[5];
79 COMPILE_ASSERT(kNumAtomNames >= 6, kAtomNames_too_small); 79 COMPILE_ASSERT(kNumAtomNames >= 6, kAtomNames_too_small);
80 } else { 80 } else {
81 LOG(ERROR) << "XInternAtoms failed"; 81 LOG(ERROR) << "XInternAtoms failed";
82 } 82 }
83 83
84 XFixesSelectSelectionInput(display_, clipboard_window_, XA_PRIMARY,
85 XFixesSetSelectionOwnerNotifyMask);
86 XFixesSelectSelectionInput(display_, clipboard_window_, clipboard_atom_, 84 XFixesSelectSelectionInput(display_, clipboard_window_, clipboard_atom_,
87 XFixesSetSelectionOwnerNotifyMask); 85 XFixesSetSelectionOwnerNotifyMask);
88 } 86 }
89 87
90 void XServerClipboard::SetClipboard(const std::string& mime_type, 88 void XServerClipboard::SetClipboard(const std::string& mime_type,
91 const std::string& data) { 89 const std::string& data) {
92 DCHECK(display_); 90 DCHECK(display_);
93 91
94 if (clipboard_window_ == BadValue) 92 if (clipboard_window_ == BadValue)
95 return; 93 return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // quickly to our requests. 145 // quickly to our requests.
148 if (!get_selections_time_.is_null() && 146 if (!get_selections_time_.is_null() &&
149 (base::TimeTicks::Now() - get_selections_time_) < 147 (base::TimeTicks::Now() - get_selections_time_) <
150 base::TimeDelta::FromSeconds(5)) { 148 base::TimeDelta::FromSeconds(5)) {
151 // TODO(lambroslambrou): Instead of ignoring this notification, cancel any 149 // TODO(lambroslambrou): Instead of ignoring this notification, cancel any
152 // pending request operations and ignore the resulting events, before 150 // pending request operations and ignore the resulting events, before
153 // dispatching new requests here. 151 // dispatching new requests here.
154 return; 152 return;
155 } 153 }
156 154
157 // Only process PRIMARY and CLIPBOARD selections. 155 // Only process CLIPBOARD selections.
158 if (selection != clipboard_atom_ && selection != XA_PRIMARY) 156 if (selection != clipboard_atom_)
159 return; 157 return;
160 158
161 // If we own the selection, don't request details for it. 159 // If we own the selection, don't request details for it.
162 if (IsSelectionOwner(selection)) 160 if (IsSelectionOwner(selection))
163 return; 161 return;
164 162
165 get_selections_time_ = base::TimeTicks::Now(); 163 get_selections_time_ = base::TimeTicks::Now();
166 164
167 // Before getting the value of the chosen selection, request the list of 165 // Before getting the value of the chosen selection, request the list of
168 // target formats it supports. 166 // target formats it supports.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } else { 366 } else {
369 LOG(ERROR) << "XSetSelectionOwner failed for selection " << selection; 367 LOG(ERROR) << "XSetSelectionOwner failed for selection " << selection;
370 } 368 }
371 } 369 }
372 370
373 bool XServerClipboard::IsSelectionOwner(Atom selection) { 371 bool XServerClipboard::IsSelectionOwner(Atom selection) {
374 return selections_owned_.find(selection) != selections_owned_.end(); 372 return selections_owned_.find(selection) != selections_owned_.end();
375 } 373 }
376 374
377 } // namespace remoting 375 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698