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

Side by Side Diff: ui/views/widget/widget.cc

Issue 10479010: Gesture related changes for views: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« ui/views/widget/root_view.cc ('K') | « ui/views/widget/widget.h ('k') | 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 "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "ui/base/hit_test.h" 10 #include "ui/base/hit_test.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 is_secondary_widget_(true), 162 is_secondary_widget_(true),
163 frame_type_(FRAME_TYPE_DEFAULT), 163 frame_type_(FRAME_TYPE_DEFAULT),
164 disable_inactive_rendering_(false), 164 disable_inactive_rendering_(false),
165 widget_closed_(false), 165 widget_closed_(false),
166 saved_show_state_(ui::SHOW_STATE_DEFAULT), 166 saved_show_state_(ui::SHOW_STATE_DEFAULT),
167 focus_on_creation_(true), 167 focus_on_creation_(true),
168 is_top_level_(false), 168 is_top_level_(false),
169 native_widget_initialized_(false), 169 native_widget_initialized_(false),
170 native_widget_destroyed_(false), 170 native_widget_destroyed_(false),
171 is_mouse_button_pressed_(false), 171 is_mouse_button_pressed_(false),
172 is_touch_down_(false),
172 last_mouse_event_was_move_(false) { 173 last_mouse_event_was_move_(false) {
173 } 174 }
174 175
175 Widget::~Widget() { 176 Widget::~Widget() {
176 while (!event_stack_.empty()) { 177 while (!event_stack_.empty()) {
177 event_stack_.top()->reset(); 178 event_stack_.top()->reset();
178 event_stack_.pop(); 179 event_stack_.pop();
179 } 180 }
180 181
181 DestroyRootView(); 182 DestroyRootView();
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 818 }
818 819
819 const NativeWidget* Widget::native_widget() const { 820 const NativeWidget* Widget::native_widget() const {
820 return native_widget_; 821 return native_widget_;
821 } 822 }
822 823
823 NativeWidget* Widget::native_widget() { 824 NativeWidget* Widget::native_widget() {
824 return native_widget_; 825 return native_widget_;
825 } 826 }
826 827
827 void Widget::SetMouseCapture(views::View* view) { 828 void Widget::SetCapture(views::View* view) {
828 is_mouse_button_pressed_ = true; 829 if (internal::NativeWidgetPrivate::IsMouseButtonDown())
830 is_mouse_button_pressed_ = true;
831 if (internal::NativeWidgetPrivate::IsTouchDown())
832 is_touch_down_ = true;
829 root_view_->SetMouseHandler(view); 833 root_view_->SetMouseHandler(view);
830 if (!native_widget_->HasCapture()) 834 if (!native_widget_->HasCapture())
831 native_widget_->SetCapture(); 835 native_widget_->SetCapture();
832 } 836 }
833 837
834 void Widget::ReleaseMouseCapture() { 838 void Widget::ReleaseCapture() {
835 if (native_widget_->HasCapture()) 839 if (native_widget_->HasCapture())
836 native_widget_->ReleaseCapture(); 840 native_widget_->ReleaseCapture();
837 } 841 }
838 842
839 const Event* Widget::GetCurrentEvent() { 843 const Event* Widget::GetCurrentEvent() {
840 return event_stack_.empty() ? NULL : event_stack_.top()->event(); 844 return event_stack_.empty() ? NULL : event_stack_.top()->event();
841 } 845 }
842 846
843 void Widget::TooltipTextChanged(View* view) { 847 void Widget::TooltipTextChanged(View* view) {
844 TooltipManager* manager = native_widget_private()->GetTooltipManager(); 848 TooltipManager* manager = native_widget_private()->GetTooltipManager();
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 case ui::ET_MOUSEWHEEL: 1084 case ui::ET_MOUSEWHEEL:
1081 return GetRootView()->OnMouseWheel( 1085 return GetRootView()->OnMouseWheel(
1082 reinterpret_cast<const MouseWheelEvent&>(event)); 1086 reinterpret_cast<const MouseWheelEvent&>(event));
1083 default: 1087 default:
1084 return false; 1088 return false;
1085 } 1089 }
1086 return true; 1090 return true;
1087 } 1091 }
1088 1092
1089 void Widget::OnMouseCaptureLost() { 1093 void Widget::OnMouseCaptureLost() {
1090 if (is_mouse_button_pressed_) 1094 if (is_mouse_button_pressed_ || is_touch_down_)
1091 GetRootView()->OnMouseCaptureLost(); 1095 GetRootView()->OnMouseCaptureLost();
1096 is_touch_down_ = false;
1092 is_mouse_button_pressed_ = false; 1097 is_mouse_button_pressed_ = false;
1093 } 1098 }
1094 1099
1095 ui::TouchStatus Widget::OnTouchEvent(const TouchEvent& event) { 1100 ui::TouchStatus Widget::OnTouchEvent(const TouchEvent& event) {
1096 ScopedEvent scoped(this, event); 1101 ScopedEvent scoped(this, event);
1097 return GetRootView()->OnTouchEvent(event); 1102 return GetRootView()->OnTouchEvent(event);
1098 } 1103 }
1099 1104
1100 ui::GestureStatus Widget::OnGestureEvent(const GestureEvent& event) { 1105 ui::GestureStatus Widget::OnGestureEvent(const GestureEvent& event) {
1101 ScopedEvent scoped(this, event); 1106 ScopedEvent scoped(this, event);
1107 switch (event.type()) {
1108 case ui::ET_GESTURE_TAP_DOWN:
1109 is_touch_down_ = true;
1110 // We explicitly don't capture here. Not capturing enables multiple
1111 // widgets to get tap events at the same time. Views (such as tab
1112 // dragging) may explicitly capture.
1113 break;
1114
1115 case ui::ET_GESTURE_TAP_UP:
1116 is_touch_down_ = false;
1117 ReleaseCapture();
1118 break;
1119
1120 default:
1121 break;
1122 }
1102 return GetRootView()->OnGestureEvent(event); 1123 return GetRootView()->OnGestureEvent(event);
1103 } 1124 }
1104 1125
1105 bool Widget::ExecuteCommand(int command_id) { 1126 bool Widget::ExecuteCommand(int command_id) {
1106 return widget_delegate_->ExecuteWindowsCommand(command_id); 1127 return widget_delegate_->ExecuteWindowsCommand(command_id);
1107 } 1128 }
1108 1129
1109 InputMethod* Widget::GetInputMethodDirect() { 1130 InputMethod* Widget::GetInputMethodDirect() {
1110 return input_method_.get(); 1131 return input_method_.get();
1111 } 1132 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 1282
1262 //////////////////////////////////////////////////////////////////////////////// 1283 ////////////////////////////////////////////////////////////////////////////////
1263 // internal::NativeWidgetPrivate, NativeWidget implementation: 1284 // internal::NativeWidgetPrivate, NativeWidget implementation:
1264 1285
1265 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1286 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1266 return this; 1287 return this;
1267 } 1288 }
1268 1289
1269 } // namespace internal 1290 } // namespace internal
1270 } // namespace views 1291 } // namespace views
OLDNEW
« ui/views/widget/root_view.cc ('K') | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698