Chromium Code Reviews| 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/widget.h" | 5 #include "ui/views/widget/widget.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 disable_inactive_rendering_(false), | 166 disable_inactive_rendering_(false), |
| 167 widget_closed_(false), | 167 widget_closed_(false), |
| 168 saved_show_state_(ui::SHOW_STATE_DEFAULT), | 168 saved_show_state_(ui::SHOW_STATE_DEFAULT), |
| 169 focus_on_creation_(true), | 169 focus_on_creation_(true), |
| 170 is_top_level_(false), | 170 is_top_level_(false), |
| 171 native_widget_initialized_(false), | 171 native_widget_initialized_(false), |
| 172 native_widget_destroyed_(false), | 172 native_widget_destroyed_(false), |
| 173 is_mouse_button_pressed_(false), | 173 is_mouse_button_pressed_(false), |
| 174 is_touch_down_(false), | 174 is_touch_down_(false), |
| 175 last_mouse_event_was_move_(false), | 175 last_mouse_event_was_move_(false), |
| 176 capture_explicitly_set_(false), | |
| 176 root_layers_dirty_(false), | 177 root_layers_dirty_(false), |
| 177 movement_disabled_(false) { | 178 movement_disabled_(false) { |
| 178 } | 179 } |
| 179 | 180 |
| 180 Widget::~Widget() { | 181 Widget::~Widget() { |
| 181 DestroyRootView(); | 182 DestroyRootView(); |
| 182 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) { | 183 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) { |
| 183 delete native_widget_; | 184 delete native_widget_; |
| 184 } else { | 185 } else { |
| 185 DCHECK(native_widget_destroyed_) | 186 DCHECK(native_widget_destroyed_) |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 } | 911 } |
| 911 | 912 |
| 912 void Widget::SetCapture(View* view) { | 913 void Widget::SetCapture(View* view) { |
| 913 if (internal::NativeWidgetPrivate::IsMouseButtonDown()) | 914 if (internal::NativeWidgetPrivate::IsMouseButtonDown()) |
| 914 is_mouse_button_pressed_ = true; | 915 is_mouse_button_pressed_ = true; |
| 915 if (internal::NativeWidgetPrivate::IsTouchDown()) | 916 if (internal::NativeWidgetPrivate::IsTouchDown()) |
| 916 is_touch_down_ = true; | 917 is_touch_down_ = true; |
| 917 root_view_->SetMouseHandler(view); | 918 root_view_->SetMouseHandler(view); |
| 918 if (!native_widget_->HasCapture()) | 919 if (!native_widget_->HasCapture()) |
| 919 native_widget_->SetCapture(); | 920 native_widget_->SetCapture(); |
| 921 capture_explicitly_set_ = true; | |
|
sky
2013/09/04 14:10:15
Do you verify all callers of SetCapture are ok wit
Evan Stade
2013/09/04 23:00:38
You are quite right. Do you like this new approach
| |
| 920 } | 922 } |
| 921 | 923 |
| 922 void Widget::ReleaseCapture() { | 924 void Widget::ReleaseCapture() { |
| 923 if (native_widget_->HasCapture()) | 925 if (native_widget_->HasCapture()) |
| 924 native_widget_->ReleaseCapture(); | 926 native_widget_->ReleaseCapture(); |
| 927 capture_explicitly_set_ = false; | |
| 925 } | 928 } |
| 926 | 929 |
| 927 bool Widget::HasCapture() { | 930 bool Widget::HasCapture() { |
| 928 return native_widget_->HasCapture(); | 931 return native_widget_->HasCapture(); |
| 929 } | 932 } |
| 930 | 933 |
| 931 void Widget::TooltipTextChanged(View* view) { | 934 void Widget::TooltipTextChanged(View* view) { |
| 932 TooltipManager* manager = native_widget_private()->GetTooltipManager(); | 935 TooltipManager* manager = native_widget_private()->GetTooltipManager(); |
| 933 if (manager) | 936 if (manager) |
| 934 manager->TooltipTextChanged(view); | 937 manager->TooltipTextChanged(view); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1308 non_client_view_ = NULL; | 1311 non_client_view_ = NULL; |
| 1309 root_view_.reset(); | 1312 root_view_.reset(); |
| 1310 // Input method has to be destroyed before focus manager. | 1313 // Input method has to be destroyed before focus manager. |
| 1311 input_method_.reset(); | 1314 input_method_.reset(); |
| 1312 } | 1315 } |
| 1313 | 1316 |
| 1314 //////////////////////////////////////////////////////////////////////////////// | 1317 //////////////////////////////////////////////////////////////////////////////// |
| 1315 // Widget, private: | 1318 // Widget, private: |
| 1316 | 1319 |
| 1317 bool Widget::ShouldReleaseCaptureOnMouseReleased() const { | 1320 bool Widget::ShouldReleaseCaptureOnMouseReleased() const { |
| 1318 return true; | 1321 return !capture_explicitly_set_; |
| 1319 } | 1322 } |
| 1320 | 1323 |
| 1321 void Widget::SetInactiveRenderingDisabled(bool value) { | 1324 void Widget::SetInactiveRenderingDisabled(bool value) { |
| 1322 if (value == disable_inactive_rendering_) | 1325 if (value == disable_inactive_rendering_) |
| 1323 return; | 1326 return; |
| 1324 | 1327 |
| 1325 disable_inactive_rendering_ = value; | 1328 disable_inactive_rendering_ = value; |
| 1326 if (non_client_view_) | 1329 if (non_client_view_) |
| 1327 non_client_view_->SetInactiveRenderingDisabled(value); | 1330 non_client_view_->SetInactiveRenderingDisabled(value); |
| 1328 native_widget_->SetInactiveRenderingDisabled(value); | 1331 native_widget_->SetInactiveRenderingDisabled(value); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1427 | 1430 |
| 1428 //////////////////////////////////////////////////////////////////////////////// | 1431 //////////////////////////////////////////////////////////////////////////////// |
| 1429 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1432 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1430 | 1433 |
| 1431 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1434 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1432 return this; | 1435 return this; |
| 1433 } | 1436 } |
| 1434 | 1437 |
| 1435 } // namespace internal | 1438 } // namespace internal |
| 1436 } // namespace views | 1439 } // namespace views |
| OLD | NEW |