| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/menu/nested_dispatcher_gtk.h" | 5 #include "views/controls/menu/nested_dispatcher_gtk.h" |
| 6 | 6 |
| 7 #if defined(TOUCH_UI) |
| 8 #include "views/focus/accelerator_handler.h" |
| 9 #endif |
| 10 |
| 7 namespace views { | 11 namespace views { |
| 8 | 12 |
| 9 NestedDispatcherGtk::NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator, | 13 NestedDispatcherGtk::NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator, |
| 10 bool allow_nested_task) | 14 bool allow_nested_task) |
| 11 : creator_(creator), | 15 : creator_(creator), |
| 12 allow_nested_task_(allow_nested_task) { | 16 allow_nested_task_(allow_nested_task) { |
| 13 } | 17 } |
| 14 | 18 |
| 15 bool NestedDispatcherGtk::RunAndSelfDestruct() { | 19 bool NestedDispatcherGtk::RunAndSelfDestruct() { |
| 16 bool nestable = MessageLoopForUI::current()->NestableTasksAllowed(); | 20 bool nestable = MessageLoopForUI::current()->NestableTasksAllowed(); |
| 17 if (allow_nested_task_) | 21 if (allow_nested_task_) |
| 18 MessageLoopForUI::current()->SetNestableTasksAllowed(true); | 22 MessageLoopForUI::current()->SetNestableTasksAllowed(true); |
| 19 MessageLoopForUI::current()->Run(this); | 23 MessageLoopForUI::current()->Run(this); |
| 20 if (allow_nested_task_) | 24 if (allow_nested_task_) |
| 21 MessageLoopForUI::current()->SetNestableTasksAllowed(nestable); | 25 MessageLoopForUI::current()->SetNestableTasksAllowed(nestable); |
| 22 bool creator_is_deleted = creator_ == NULL; | 26 bool creator_is_deleted = creator_ == NULL; |
| 23 delete this; | 27 delete this; |
| 24 return creator_is_deleted; | 28 return creator_is_deleted; |
| 25 } | 29 } |
| 26 | 30 |
| 27 void NestedDispatcherGtk::CreatorDestroyed() { | 31 void NestedDispatcherGtk::CreatorDestroyed() { |
| 28 creator_ = NULL; | 32 creator_ = NULL; |
| 29 } | 33 } |
| 30 | 34 |
| 31 bool NestedDispatcherGtk::Dispatch(GdkEvent* event) { | 35 bool NestedDispatcherGtk::Dispatch(GdkEvent* event) { |
| 32 if (creator_ != NULL) { | 36 if (creator_ != NULL) { |
| 37 #if defined(TOUCH_UI) |
| 38 return static_cast<base::MessagePumpForUI::Dispatcher*> |
| 39 (creator_)->Dispatch(event); |
| 40 #else |
| 33 return creator_->Dispatch(event); | 41 return creator_->Dispatch(event); |
| 42 #endif |
| 34 } else { | 43 } else { |
| 35 return false; | 44 return false; |
| 36 } | 45 } |
| 37 } | 46 } |
| 38 | 47 |
| 48 #if defined(TOUCH_UI) |
| 49 bool NestedDispatcherGtk::Dispatch(XEvent* xevent) { |
| 50 return creator_ ? creator_->Dispatch(xevent) : false; |
| 51 } |
| 52 #endif |
| 53 |
| 39 } // namespace views | 54 } // namespace views |
| OLD | NEW |