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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 | 931 |
932 const NativeWidget* Widget::native_widget() const { | 932 const NativeWidget* Widget::native_widget() const { |
933 return native_widget_; | 933 return native_widget_; |
934 } | 934 } |
935 | 935 |
936 NativeWidget* Widget::native_widget() { | 936 NativeWidget* Widget::native_widget() { |
937 return native_widget_; | 937 return native_widget_; |
938 } | 938 } |
939 | 939 |
940 void Widget::SetCapture(View* view) { | 940 void Widget::SetCapture(View* view) { |
| 941 if (!native_widget_->HasCapture()) { |
| 942 native_widget_->SetCapture(); |
| 943 |
| 944 // Early return if setting capture was unsuccessful. |
| 945 if (!native_widget_->HasCapture()) |
| 946 return; |
| 947 } |
| 948 |
941 if (internal::NativeWidgetPrivate::IsMouseButtonDown()) | 949 if (internal::NativeWidgetPrivate::IsMouseButtonDown()) |
942 is_mouse_button_pressed_ = true; | 950 is_mouse_button_pressed_ = true; |
943 root_view_->SetMouseHandler(view); | 951 root_view_->SetMouseHandler(view); |
944 if (!native_widget_->HasCapture()) | |
945 native_widget_->SetCapture(); | |
946 } | 952 } |
947 | 953 |
948 void Widget::ReleaseCapture() { | 954 void Widget::ReleaseCapture() { |
949 if (native_widget_->HasCapture()) | 955 if (native_widget_->HasCapture()) |
950 native_widget_->ReleaseCapture(); | 956 native_widget_->ReleaseCapture(); |
951 } | 957 } |
952 | 958 |
953 bool Widget::HasCapture() { | 959 bool Widget::HasCapture() { |
954 return native_widget_->HasCapture(); | 960 return native_widget_->HasCapture(); |
955 } | 961 } |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 | 1499 |
1494 //////////////////////////////////////////////////////////////////////////////// | 1500 //////////////////////////////////////////////////////////////////////////////// |
1495 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1501 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1496 | 1502 |
1497 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1503 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1498 return this; | 1504 return this; |
1499 } | 1505 } |
1500 | 1506 |
1501 } // namespace internal | 1507 } // namespace internal |
1502 } // namespace views | 1508 } // namespace views |
OLD | NEW |