diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-05 15:24:03 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-05 15:24:03 +0000 |
commit | 9a2e75dde876521fdd1f39c9646902aade1f8c89 (patch) | |
tree | eb35e3f9c005694a7e929fbe8b8bbb3b7f3976d6 /ash/accelerators/accelerator_dispatcher_win.cc | |
parent | b390cd8541458f9c87053de63873860f72566a52 (diff) | |
download | chromium_src-9a2e75dde876521fdd1f39c9646902aade1f8c89.zip chromium_src-9a2e75dde876521fdd1f39c9646902aade1f8c89.tar.gz chromium_src-9a2e75dde876521fdd1f39c9646902aade1f8c89.tar.bz2 |
x11: Move X event handling out of the message-pump.
This change moves the X11 event handling out of the X11 message-pump, and uses
the X11 event dispatch code from X11EventSource instead. Overview of the changes:
* Remove all X event handling code from the message-pump. The X11 message-pump
only opens the connection to the X11 server. This too will be moved out of
here in subsequent patches.
* The X11EventSource sends an XEvent it receives from the X11 server back to
the X11 message-pump, which triggers the MessagePumpObservers, before sending
the event to the dispatchers. This is a short-term workaround until the
message-pump observers are converted into PlatformEventObservers.
* The MessagePumpDispatcher implementations that deal with X11 events are
converted into PlatformEventDispatchers.
* Remove support for starting a nested message-loop with a custom dispatcher
on non-Windows.
Changes in components:
//ash:
* Split AcceleratorDispatcher into platform-specific AcceleratorDispatcherWin,
which remains a MessagePumpDispatcher, and AcceleratorDispatcherLinux, which
is a PlatformEventDispatcher. It may be possible to do some cleanup in this,
depending on the outcome of http://crbug.com/357777 and http://crbug.com/357733.
//base:
* Remove support for providing a custom MessagePumpDispatcher when starting a
nested message-loop on non-Windows platforms.
* Remove most of the event-dispatch code from MessagePumpX11. The only remaining
bits are for triggering MessagePumpObservers, which will be replaced by the newer
PlatformEventObservers in subsequent patches.
//chrome, //content, //mojo, //ui/aura, //ui/base, //ui/wm:
* Convert MessagePumpDispatchers that deal with X11 events into
PlatformEventDispatchers.
//ui/events:
* Allow creating a 'default' PlatformEventSource. On X11, it creates X11EventSource,
and on other platforms, it doesn't create an event-source.
* A temporary measure in X11EventSource to send the event to the message-pump so
that the message-pump observers can be triggered. This will be removed once the
MessagePumpObservers that deal with X11 events are turned into
PlatformEventObservers.
//ui/views:
* Remove the linux implementation of MenuMessagePumpDispatcher, and replace it with
MenuEventDispatcherLinux.
* Platform specific implementation for MenuController::RunMessageLoop(): the Windows
implementation uses the MessagePumpDispatcher, and the non-windows implementation
uses the PlatformEventDispatcher. This is somewhat unfortunate, and I am going to
look for something better for this. But the code duplication here is relatively
small, I don't want to make this patch any larger.
BUG=354062
R=darin@chromium.org, sky@chromium.org
Review URL: https://codereview.chromium.org/219743002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/accelerators/accelerator_dispatcher_win.cc')
-rw-r--r-- | ash/accelerators/accelerator_dispatcher_win.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/ash/accelerators/accelerator_dispatcher_win.cc b/ash/accelerators/accelerator_dispatcher_win.cc new file mode 100644 index 0000000..35005f3 --- /dev/null +++ b/ash/accelerators/accelerator_dispatcher_win.cc @@ -0,0 +1,64 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/accelerators/accelerator_dispatcher.h" + +#include "base/memory/scoped_ptr.h" +#include "base/message_loop/message_pump_dispatcher.h" +#include "base/run_loop.h" +#include "ui/events/event.h" + +using base::MessagePumpDispatcher; + +namespace ash { + +namespace { + +bool IsKeyEvent(const MSG& msg) { + return msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN || + msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP; +} + +} // namespace + +class AcceleratorDispatcherWin : public AcceleratorDispatcher, + public MessagePumpDispatcher { + public: + explicit AcceleratorDispatcherWin(MessagePumpDispatcher* nested) + : nested_dispatcher_(nested) {} + virtual ~AcceleratorDispatcherWin() {} + + private: + // AcceleratorDispatcher: + virtual scoped_ptr<base::RunLoop> CreateRunLoop() OVERRIDE { + return scoped_ptr<base::RunLoop>(new base::RunLoop(this)); + } + + // MessagePumpDispatcher: + virtual uint32_t Dispatch(const MSG& event) OVERRIDE { + if (IsKeyEvent(event)) { + ui::KeyEvent key_event(event, false); + if (MenuClosedForPossibleAccelerator(key_event)) + return POST_DISPATCH_QUIT_LOOP; + + if (AcceleratorProcessedForKeyEvent(key_event)) + return POST_DISPATCH_NONE; + } + + return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event) + : POST_DISPATCH_PERFORM_DEFAULT; + } + + MessagePumpDispatcher* nested_dispatcher_; + + DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcherWin); +}; + +scoped_ptr<AcceleratorDispatcher> AcceleratorDispatcher::Create( + MessagePumpDispatcher* nested_dispatcher) { + return scoped_ptr<AcceleratorDispatcher>( + new AcceleratorDispatcherWin(nested_dispatcher)); +} + +} // namespace ash |