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/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 | 8 |
9 #include "base/event_types.h" | 9 #include "base/event_types.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 unfetched_targets_.push_back(event.data.l[2+i]); | 229 unfetched_targets_.push_back(event.data.l[2+i]); |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 DesktopDragDropClientAuraX11* client = | 234 DesktopDragDropClientAuraX11* client = |
235 DesktopDragDropClientAuraX11::GetForWindow(source_window_); | 235 DesktopDragDropClientAuraX11::GetForWindow(source_window_); |
236 if (!client) { | 236 if (!client) { |
237 // The window doesn't have a DesktopDragDropClientAuraX11, that means it's | 237 // The window doesn't have a DesktopDragDropClientAuraX11, that means it's |
238 // created by some other process. Listen for messages on it. | 238 // created by some other process. Listen for messages on it. |
239 base::MessagePumpAuraX11::Current()->AddDispatcherForWindow( | 239 base::MessagePumpX11::Current()->AddDispatcherForWindow( |
240 this, source_window_); | 240 this, source_window_); |
241 XSelectInput(base::MessagePumpAuraX11::GetDefaultXDisplay(), | 241 XSelectInput(base::MessagePumpX11::GetDefaultXDisplay(), |
242 source_window_, PropertyChangeMask); | 242 source_window_, PropertyChangeMask); |
243 | 243 |
244 // We must perform a full sync here because we could be racing | 244 // We must perform a full sync here because we could be racing |
245 // |source_window_|. | 245 // |source_window_|. |
246 XSync(base::MessagePumpAuraX11::GetDefaultXDisplay(), False); | 246 XSync(base::MessagePumpX11::GetDefaultXDisplay(), False); |
247 } else { | 247 } else { |
248 // This drag originates from an aura window within our process. This means | 248 // This drag originates from an aura window within our process. This means |
249 // that we can shortcut the X11 server and ask the owning SelectionOwner | 249 // that we can shortcut the X11 server and ask the owning SelectionOwner |
250 // for the data it's offering. | 250 // for the data it's offering. |
251 fetched_targets_ = client->GetFormatMap(); | 251 fetched_targets_ = client->GetFormatMap(); |
252 unfetched_targets_.clear(); | 252 unfetched_targets_.clear(); |
253 } | 253 } |
254 | 254 |
255 ReadActions(); | 255 ReadActions(); |
256 } | 256 } |
257 | 257 |
258 DesktopDragDropClientAuraX11::X11DragContext::~X11DragContext() { | 258 DesktopDragDropClientAuraX11::X11DragContext::~X11DragContext() { |
259 DesktopDragDropClientAuraX11* client = | 259 DesktopDragDropClientAuraX11* client = |
260 DesktopDragDropClientAuraX11::GetForWindow(source_window_); | 260 DesktopDragDropClientAuraX11::GetForWindow(source_window_); |
261 if (!client) { | 261 if (!client) { |
262 // Unsubscribe from message events. | 262 // Unsubscribe from message events. |
263 base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow( | 263 base::MessagePumpX11::Current()->RemoveDispatcherForWindow( |
264 source_window_); | 264 source_window_); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 void DesktopDragDropClientAuraX11::X11DragContext::OnStartXdndPositionMessage( | 268 void DesktopDragDropClientAuraX11::X11DragContext::OnStartXdndPositionMessage( |
269 DesktopDragDropClientAuraX11* client, | 269 DesktopDragDropClientAuraX11* client, |
270 ::Window source_window, | 270 ::Window source_window, |
271 const gfx::Point& screen_point) { | 271 const gfx::Point& screen_point) { |
272 DCHECK_EQ(source_window_, source_window); | 272 DCHECK_EQ(source_window_, source_window); |
273 | 273 |
274 if (!unfetched_targets_.empty()) { | 274 if (!unfetched_targets_.empty()) { |
275 // We have unfetched targets. That means we need to pause the handling of | 275 // We have unfetched targets. That means we need to pause the handling of |
276 // the position message and ask the other window for its data. | 276 // the position message and ask the other window for its data. |
277 screen_point_ = screen_point; | 277 screen_point_ = screen_point; |
278 drag_drop_client_ = client; | 278 drag_drop_client_ = client; |
279 waiting_to_handle_position_ = true; | 279 waiting_to_handle_position_ = true; |
280 | 280 |
281 fetched_targets_ = ui::SelectionFormatMap(); | 281 fetched_targets_ = ui::SelectionFormatMap(); |
282 RequestNextTarget(); | 282 RequestNextTarget(); |
283 } else { | 283 } else { |
284 client->CompleteXdndPosition(source_window, screen_point); | 284 client->CompleteXdndPosition(source_window, screen_point); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 void DesktopDragDropClientAuraX11::X11DragContext::RequestNextTarget() { | 288 void DesktopDragDropClientAuraX11::X11DragContext::RequestNextTarget() { |
289 ::Atom target = unfetched_targets_.back(); | 289 ::Atom target = unfetched_targets_.back(); |
290 unfetched_targets_.pop_back(); | 290 unfetched_targets_.pop_back(); |
291 | 291 |
292 XConvertSelection(base::MessagePumpAuraX11::GetDefaultXDisplay(), | 292 XConvertSelection(base::MessagePumpX11::GetDefaultXDisplay(), |
293 atom_cache_->GetAtom(kXdndSelection), | 293 atom_cache_->GetAtom(kXdndSelection), |
294 target, | 294 target, |
295 atom_cache_->GetAtom(kChromiumDragReciever), | 295 atom_cache_->GetAtom(kChromiumDragReciever), |
296 local_window_, | 296 local_window_, |
297 CurrentTime); | 297 CurrentTime); |
298 } | 298 } |
299 | 299 |
300 void DesktopDragDropClientAuraX11::X11DragContext::OnSelectionNotify( | 300 void DesktopDragDropClientAuraX11::X11DragContext::OnSelectionNotify( |
301 const XSelectionEvent& event) { | 301 const XSelectionEvent& event) { |
302 DCHECK(waiting_to_handle_position_); | 302 DCHECK(waiting_to_handle_position_); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 // GdkEvent about the failed drag. (And sending this message doesn't appear | 914 // GdkEvent about the failed drag. (And sending this message doesn't appear |
915 // to go through normal xlib machinery, but instead passes through the low | 915 // to go through normal xlib machinery, but instead passes through the low |
916 // level xProto (the x11 wire format) that I don't understand. | 916 // level xProto (the x11 wire format) that I don't understand. |
917 // | 917 // |
918 // I'm unsure if I have to jump through those hoops, or if XSendEvent is | 918 // I'm unsure if I have to jump through those hoops, or if XSendEvent is |
919 // sufficient. | 919 // sufficient. |
920 XSendEvent(xdisplay_, xid, False, 0, xev); | 920 XSendEvent(xdisplay_, xid, False, 0, xev); |
921 } | 921 } |
922 | 922 |
923 } // namespace views | 923 } // namespace views |
OLD | NEW |