diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 22:53:37 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 22:53:37 +0000 |
commit | 148d105e27c7c8c2cda0c81292690b9edafcae1f (patch) | |
tree | e278052fc84a6e5399aec5bd0d423162aecb6d16 /base/message_pump_glib.h | |
parent | dc75d4823b598a9b9b313728a06f6b47d6a73929 (diff) | |
download | chromium_src-148d105e27c7c8c2cda0c81292690b9edafcae1f.zip chromium_src-148d105e27c7c8c2cda0c81292690b9edafcae1f.tar.gz chromium_src-148d105e27c7c8c2cda0c81292690b9edafcae1f.tar.bz2 |
This CL adds accelerators to the Linux toolkit views.
The MessageLoop had to be modified to support Dispatchers on Linux.
BUG=None
TEST=On Windows and Linux, make sure the accelerators still work as expected. On Linux toolkit views, build and run the unit-tests.
Review URL: http://codereview.chromium.org/159046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22210 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_glib.h')
-rw-r--r-- | base/message_pump_glib.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/base/message_pump_glib.h b/base/message_pump_glib.h index e8288a8..08e1964 100644 --- a/base/message_pump_glib.h +++ b/base/message_pump_glib.h @@ -31,10 +31,29 @@ class MessagePumpForUI : public MessagePump { virtual void DidProcessEvent(GdkEvent* event) = 0; }; + // Dispatcher is used during a nested invocation of Run to dispatch events. + // If Run is invoked with a non-NULL Dispatcher, MessageLoop does not + // dispatch events (or invoke gtk_main_do_event), rather every event is + // passed to Dispatcher's Dispatch method for dispatch. It is up to the + // Dispatcher to dispatch, or not, the event. + // + // The nested loop is exited by either posting a quit, or returning false + // from Dispatch. + class Dispatcher { + public: + virtual ~Dispatcher() {} + // Dispatches the event. If true is returned processing continues as + // normal. If false is returned, the nested loop exits immediately. + virtual bool Dispatch(GdkEvent* event) = 0; + }; + MessagePumpForUI(); - ~MessagePumpForUI(); + virtual ~MessagePumpForUI(); + + // Like MessagePump::Run, but GdkEvent objects are routed through dispatcher. + virtual void RunWithDispatcher(Delegate* delegate, Dispatcher* dispatcher); - virtual void Run(Delegate* delegate); + virtual void Run(Delegate* delegate) { RunWithDispatcher(delegate, NULL); } virtual void Quit(); virtual void ScheduleWork(); virtual void ScheduleDelayedWork(const Time& delayed_work_time); @@ -49,10 +68,10 @@ class MessagePumpForUI : public MessagePump { bool HandleCheck(); void HandleDispatch(); - // Add an Observer, which will start receiving notifications immediately. + // Adds an Observer, which will start receiving notifications immediately. void AddObserver(Observer* observer); - // Remove an Observer. It is safe to call this method while an Observer is + // Removes an Observer. It is safe to call this method while an Observer is // receiving a notification callback. void RemoveObserver(Observer* observer); @@ -61,6 +80,7 @@ class MessagePumpForUI : public MessagePump { // separate between them in this structure type. struct RunState { Delegate* delegate; + Dispatcher* dispatcher; // Used to flag that the current Run() invocation should return ASAP. bool should_quit; |