OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_drop_target_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_drop_target_win.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/win/win_util.h" | 8 #include "base/win/win_util.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 target_window_ = NULL; | 87 target_window_ = NULL; |
88 } | 88 } |
89 return ui::DragDropTypes::DragOperationToDropEffect(drag_operation); | 89 return ui::DragDropTypes::DragOperationToDropEffect(drag_operation); |
90 } | 90 } |
91 | 91 |
92 void DesktopDropTargetWin::OnWindowDestroyed(aura::Window* window) { | 92 void DesktopDropTargetWin::OnWindowDestroyed(aura::Window* window) { |
93 DCHECK(window == target_window_); | 93 DCHECK(window == target_window_); |
94 target_window_ = NULL; | 94 target_window_ = NULL; |
95 } | 95 } |
96 | 96 |
97 static int ConvertKeyStateToAuraEventFlags(DWORD key_state) | |
Avi (use Gerrit)
2015/03/10 03:14:07
Why are you putting this function in the middle of
zino
2015/03/10 08:47:23
Done.
| |
98 { | |
99 int flags = 0; | |
100 | |
101 if (key_state & MK_CONTROL) | |
102 flags |= ui::EF_CONTROL_DOWN; | |
103 if (key_state & MK_ALT) | |
104 flags |= ui::EF_ALT_DOWN; | |
105 if (key_state & MK_SHIFT) | |
106 flags |= ui::EF_SHIFT_DOWN; | |
107 if (key_state & MK_LBUTTON) | |
108 flags |= ui::EF_LEFT_MOUSE_BUTTON; | |
109 if (key_state & MK_MBUTTON) | |
110 flags |= ui::EF_MIDDLE_MOUSE_BUTTON; | |
111 if (key_state & MK_RBUTTON) | |
112 flags |= ui::EF_RIGHT_MOUSE_BUTTON; | |
113 | |
114 return flags; | |
115 } | |
116 | |
97 void DesktopDropTargetWin::Translate( | 117 void DesktopDropTargetWin::Translate( |
98 IDataObject* data_object, | 118 IDataObject* data_object, |
99 DWORD key_state, | 119 DWORD key_state, |
100 POINT position, | 120 POINT position, |
101 DWORD effect, | 121 DWORD effect, |
102 scoped_ptr<OSExchangeData>* data, | 122 scoped_ptr<OSExchangeData>* data, |
103 scoped_ptr<ui::DropTargetEvent>* event, | 123 scoped_ptr<ui::DropTargetEvent>* event, |
104 DragDropDelegate** delegate) { | 124 DragDropDelegate** delegate) { |
105 gfx::Point location(position.x, position.y); | 125 gfx::Point location(position.x, position.y); |
106 gfx::Point root_location = location; | 126 gfx::Point root_location = location; |
(...skipping 18 matching lines...) Expand all Loading... | |
125 return; | 145 return; |
126 | 146 |
127 data->reset(new OSExchangeData(new OSExchangeDataProviderWin(data_object))); | 147 data->reset(new OSExchangeData(new OSExchangeDataProviderWin(data_object))); |
128 location = root_location; | 148 location = root_location; |
129 aura::Window::ConvertPointToTarget(root_window_, target_window_, &location); | 149 aura::Window::ConvertPointToTarget(root_window_, target_window_, &location); |
130 event->reset(new ui::DropTargetEvent( | 150 event->reset(new ui::DropTargetEvent( |
131 *(data->get()), | 151 *(data->get()), |
132 location, | 152 location, |
133 root_location, | 153 root_location, |
134 ui::DragDropTypes::DropEffectToDragOperation(effect))); | 154 ui::DragDropTypes::DropEffectToDragOperation(effect))); |
135 int flags = 0; | 155 (*event)->set_flags(ConvertKeyStateToAuraEventFlags(key_state)); |
136 flags |= base::win::IsAltPressed() ? ui::EF_ALT_DOWN : ui::EF_NONE; | |
137 flags |= base::win::IsShiftPressed() ? ui::EF_SHIFT_DOWN : ui::EF_NONE; | |
138 flags |= base::win::IsCtrlPressed() ? ui::EF_CONTROL_DOWN : ui::EF_NONE; | |
139 (*event)->set_flags(flags); | |
140 if (target_window_changed) | 156 if (target_window_changed) |
141 (*delegate)->OnDragEntered(*event->get()); | 157 (*delegate)->OnDragEntered(*event->get()); |
142 } | 158 } |
143 | 159 |
144 void DesktopDropTargetWin::NotifyDragLeave() { | 160 void DesktopDropTargetWin::NotifyDragLeave() { |
145 if (!target_window_) | 161 if (!target_window_) |
146 return; | 162 return; |
147 DragDropDelegate* delegate = | 163 DragDropDelegate* delegate = |
148 aura::client::GetDragDropDelegate(target_window_); | 164 aura::client::GetDragDropDelegate(target_window_); |
149 if (delegate) | 165 if (delegate) |
150 delegate->OnDragExited(); | 166 delegate->OnDragExited(); |
151 target_window_->RemoveObserver(this); | 167 target_window_->RemoveObserver(this); |
152 target_window_ = NULL; | 168 target_window_ = NULL; |
153 } | 169 } |
154 | 170 |
155 } // namespace views | 171 } // namespace views |
OLD | NEW |