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 #ifndef VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ |
6 #define VIEWS_CONTROLS_MENU_NATIVE_DISPATCHER_GTK_H_ | 6 #define VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 | 10 |
| 11 #if defined(TOUCH_UI) |
| 12 typedef union _XEvent XEvent; |
| 13 #endif |
| 14 |
11 namespace views { | 15 namespace views { |
12 | 16 |
13 // A nested dispatcher that can out-live the creator of this | 17 // A nested dispatcher that can out-live the creator of this |
14 // dispatcher. This is to deal with the scenario where a menu object | 18 // dispatcher. This is to deal with the scenario where a menu object |
15 // is deleted while it's handling the message loop. Note that | 19 // is deleted while it's handling the message loop. Note that |
16 // |RunAndSelfDestruct| method always delete itself regardless of | 20 // |RunAndSelfDestruct| method always delete itself regardless of |
17 // whether or not the menu object is deleted, so a menu object should | 21 // whether or not the menu object is deleted, so a menu object should |
18 // create a new instance for each open request. | 22 // create a new instance for each open request. |
19 // http://crosbug.com/7228, http://crosbug.com/7929 | 23 // http://crosbug.com/7228, http://crosbug.com/7929 |
20 class NestedDispatcherGtk : public MessageLoopForUI::Dispatcher { | 24 class NestedDispatcherGtk : public MessageLoopForUI::Dispatcher { |
21 public: | 25 public: |
22 NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator, | 26 NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator, |
23 bool allow_nested_task); | 27 bool allow_nested_task); |
24 | 28 |
25 // Run the messsage loop and returns if the menu has been | 29 // Run the messsage loop and returns if the menu has been |
26 // deleted in the nested loop. Returns true if the menu is | 30 // deleted in the nested loop. Returns true if the menu is |
27 // deleted, or false otherwise. | 31 // deleted, or false otherwise. |
28 bool RunAndSelfDestruct(); | 32 bool RunAndSelfDestruct(); |
29 | 33 |
30 // Tells the nested dispatcher that creator has been destroyed. | 34 // Tells the nested dispatcher that creator has been destroyed. |
31 void CreatorDestroyed(); | 35 void CreatorDestroyed(); |
32 | 36 |
33 private: | 37 private: |
34 virtual ~NestedDispatcherGtk() {} | 38 virtual ~NestedDispatcherGtk() {} |
35 | 39 |
36 // Overriden from MessageLoopForUI::Dispatcher: | 40 // Overriden from MessageLoopForUI::Dispatcher: |
37 virtual bool Dispatch(GdkEvent* event); | 41 virtual bool Dispatch(GdkEvent* event); |
38 | 42 |
| 43 #if defined(TOUCH_UI) |
| 44 virtual bool Dispatch(XEvent* xevent); |
| 45 #endif |
| 46 |
39 // Creator of the nested loop. | 47 // Creator of the nested loop. |
40 MessageLoopForUI::Dispatcher* creator_; | 48 MessageLoopForUI::Dispatcher* creator_; |
41 | 49 |
42 // True to allow nested task in the message loop. | 50 // True to allow nested task in the message loop. |
43 bool allow_nested_task_; | 51 bool allow_nested_task_; |
44 | 52 |
45 DISALLOW_COPY_AND_ASSIGN(NestedDispatcherGtk); | 53 DISALLOW_COPY_AND_ASSIGN(NestedDispatcherGtk); |
46 }; | 54 }; |
47 | 55 |
48 } // namespace views | 56 } // namespace views |
49 | 57 |
50 #endif // VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ | 58 #endif // VIEWS_CONTROLS_MENU_NESTED_DISPATCHER_GTK_H_ |
OLD | NEW |