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