diff options
author | msb@chromium.org <msb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-14 19:23:46 +0000 |
---|---|---|
committer | msb@chromium.org <msb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-14 19:23:46 +0000 |
commit | 43ddf9ade38d89fa12017122cd07085c93da397b (patch) | |
tree | 831a2c4b93ae5ebd14033eb833e89a7ecdf99ee4 /ui | |
parent | df9167beda5d69796316c3c862c849c73433c78a (diff) | |
download | chromium_src-43ddf9ade38d89fa12017122cd07085c93da397b.zip chromium_src-43ddf9ade38d89fa12017122cd07085c93da397b.tar.gz chromium_src-43ddf9ade38d89fa12017122cd07085c93da397b.tar.bz2 |
wayland: define base:NativeEvent for Wayland
Fixes the use_wayland build which was broken by this commit:
http://codereview.chromium.org/8113028
Similar to win, we create a wayland namespace inside base
and define WaylandEvent there.
Historical note:
Wayland does not have a "native" event structure. Instead, the client
is made aware of events via a callback executed in the context
of display_run():
http://git.chromium.org/gitweb/?p=chromiumos/third_party/wayland-demos.git;a=blob;f=clients/window.c
So we create WaylandEvent structure which takes the parameters from
the callback and wraps them into a structure. For details, see:
src/ui/wayland/events/wayland_event.h
BUG=chromium:102903
TEST=Compiles but doesn't yet link with this change plus a series of
others I'm working on.
R=msw@chromium.org,oshima@chromium.org,mark@chromium.org
Review URL: http://codereview.chromium.org/8378005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/wayland/events_wayland.cc | 22 | ||||
-rw-r--r-- | ui/wayland/events/wayland_event.h | 127 | ||||
-rw-r--r-- | ui/wayland/wayland.gyp | 1 | ||||
-rw-r--r-- | ui/wayland/wayland_input_device.cc | 4 | ||||
-rw-r--r-- | ui/wayland/wayland_widget.h | 18 | ||||
-rw-r--r-- | ui/wayland/wayland_window.cc | 4 |
6 files changed, 37 insertions, 139 deletions
diff --git a/ui/base/wayland/events_wayland.cc b/ui/base/wayland/events_wayland.cc index df6ffac..a52a93b 100644 --- a/ui/base/wayland/events_wayland.cc +++ b/ui/base/wayland/events_wayland.cc @@ -4,13 +4,31 @@ #include "ui/base/events.h" +#include <linux/input.h> #include <X11/extensions/XInput2.h> +#include "base/event_types.h" #include "base/logging.h" #include "ui/base/keycodes/keyboard_code_conversion_x.h" -#include "ui/wayland/events/wayland_event.h" #include "ui/gfx/point.h" +using namespace base::wayland; + +namespace ui { + +// These are the mouse events expected. The event type Wayland sends is an +// evdev event. The following is the correct mapping from evdev to expected +// events type. +enum WaylandEventButtonType { + LEFT_BUTTON = BTN_LEFT, + MIDDLE_BUTTON = BTN_RIGHT, + RIGHT_BUTTON = BTN_MIDDLE, + SCROLL_UP = BTN_SIDE, + SCROLL_DOWN = BTN_EXTRA, +}; + +} // namespace ui + namespace { // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. @@ -126,7 +144,7 @@ bool IsMouseEvent(const base::NativeEvent& native_event) { } int GetMouseWheelOffset(const base::NativeEvent& native_event) { - return native_event->button.button == ui::SCROLL_UP ? + return native_event->button.button == SCROLL_UP ? kWheelScrollAmount : -kWheelScrollAmount; } diff --git a/ui/wayland/events/wayland_event.h b/ui/wayland/events/wayland_event.h deleted file mode 100644 index 0c20361..0000000 --- a/ui/wayland/events/wayland_event.h +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef UI_WAYLAND_EVENTS_WAYLAND_EVENT_H_ -#define UI_WAYLAND_EVENTS_WAYLAND_EVENT_H_ - -#include <linux/input.h> -#include <stdint.h> - -// Wayland event information is being passed in as arguments to the callbacks. -// (See wayland_input_device.{h,cc} for information on the callbacks and how -// events are processed.) -// In order to provide a more generic look for events we wrap these arguments -// in specific event structs. Then define a WaylandEvent as a union of all -// types of events that Wayland will send. -// -// The following fields are common for most event types and their use is -// similar: -// - time: -// The time of the event. This should be monotonically increasing. -// - state: -// The value of the button event as given by evdev. This is 0 if button -// isn't pressed. -// - modifiers: -// Stores all the keyboard modifiers (Ctrl, Alt, Shift, ...) currently -// active. The modifiers are values as defined by xkbcommon. - -namespace ui { - -// Types of events Wayland will send -enum WaylandEventType { - WAYLAND_BUTTON, - WAYLAND_KEY, - WAYLAND_MOTION, - WAYLAND_POINTER_FOCUS, - WAYLAND_KEYBOARD_FOCUS, - WAYLAND_GEOMETRY_CHANGE, -}; - -// These are the mouse events expected. The event type Wayland sends is an -// evdev event. The following is the correct mapping from evdev to expected -// events type. -enum WaylandEventButtonType { - LEFT_BUTTON = BTN_LEFT, - MIDDLE_BUTTON = BTN_RIGHT, - RIGHT_BUTTON = BTN_MIDDLE, - SCROLL_UP = BTN_SIDE, - SCROLL_DOWN = BTN_EXTRA, -}; - -struct WaylandEventButton { - WaylandEventType type; - uint32_t time; - // WaylandEventButtonType defines some of the values button can take - uint32_t button; - uint32_t state; - uint32_t modifiers; - int32_t x; - int32_t y; -}; - -struct WaylandEventKey { - WaylandEventType type; - uint32_t time; - // The raw key value that evdev returns. - uint32_t key; - // The key symbol returned by processing the raw key using the xkbcommon - // library. - uint32_t sym; - uint32_t state; - uint32_t modifiers; -}; - -// Triggered when there is a motion event. The motion event is triggered -// only if there is a window under focus. -struct WaylandEventMotion { - WaylandEventType type; - uint32_t time; - uint32_t modifiers; - int32_t x; - int32_t y; -}; - -// Triggered when a window enters/exits pointer focus. The state tells us -// if the window lost focus (state == 0) or gained focus (state != 0). -struct WaylandEventPointerFocus { - WaylandEventType type; - uint32_t time; - uint32_t state; - int32_t x; - int32_t y; -}; - -// Triggered when a window enters/exits keyboard focus. The state tells us -// if the window lost focus (state == 0) or gained focus (state != 0). -struct WaylandEventKeyboardFocus { - WaylandEventType type; - uint32_t time; - uint32_t state; - uint32_t modifiers; -}; - -// Event triggered when a window's geometry changes. The event contains the -// position and dimensions of the window. -struct WaylandEventGeometryChange { - WaylandEventType type; - uint32_t time; - int32_t x; - int32_t y; - int32_t width; - int32_t height; -}; - -union WaylandEvent { - WaylandEventType type; - WaylandEventButton button; - WaylandEventKey key; - WaylandEventMotion motion; - WaylandEventPointerFocus pointer_focus; - WaylandEventKeyboardFocus keyboard_focus; - WaylandEventGeometryChange geometry_change; -}; - -} // namespace ui - -#endif // UI_WAYLAND_EVENTS_WAYLAND_EVENT_H_ diff --git a/ui/wayland/wayland.gyp b/ui/wayland/wayland.gyp index 72e456e..3953e2c 100644 --- a/ui/wayland/wayland.gyp +++ b/ui/wayland/wayland.gyp @@ -18,7 +18,6 @@ 'events', ], 'sources': [ - 'events/wayland_event.h', 'wayland_buffer.cc', 'wayland_buffer.h', 'wayland_cursor.cc', diff --git a/ui/wayland/wayland_input_device.cc b/ui/wayland/wayland_input_device.cc index 100e19d..034b4a1 100644 --- a/ui/wayland/wayland_input_device.cc +++ b/ui/wayland/wayland_input_device.cc @@ -7,10 +7,12 @@ #include <X11/extensions/XKBcommon.h> #include <wayland-client.h> -#include "ui/wayland/events/wayland_event.h" +#include "base/wayland/wayland_event.h" #include "ui/wayland/wayland_widget.h" #include "ui/wayland/wayland_window.h" +using namespace base::wayland; + namespace ui { WaylandInputDevice::WaylandInputDevice( diff --git a/ui/wayland/wayland_widget.h b/ui/wayland/wayland_widget.h index f274141..1c4e40d 100644 --- a/ui/wayland/wayland_widget.h +++ b/ui/wayland/wayland_widget.h @@ -5,7 +5,11 @@ #ifndef UI_WAYLAND_WAYLAND_WIDGET_H_ #define UI_WAYLAND_WAYLAND_WIDGET_H_ -#include "ui/wayland/events/wayland_event.h" +namespace base { +namespace wayland { +union WaylandEvent; +} +} namespace ui { @@ -14,13 +18,13 @@ class WaylandWidget { public: virtual ~WaylandWidget() {} - virtual void OnMotionNotify(WaylandEvent event) = 0; - virtual void OnButtonNotify(WaylandEvent event) = 0; - virtual void OnKeyNotify(WaylandEvent event) = 0; - virtual void OnPointerFocus(WaylandEvent event) = 0; - virtual void OnKeyboardFocus(WaylandEvent event) = 0; + virtual void OnMotionNotify(base::wayland::WaylandEvent event) = 0; + virtual void OnButtonNotify(base::wayland::WaylandEvent event) = 0; + virtual void OnKeyNotify(base::wayland::WaylandEvent event) = 0; + virtual void OnPointerFocus(base::wayland::WaylandEvent event) = 0; + virtual void OnKeyboardFocus(base::wayland::WaylandEvent event) = 0; - virtual void OnGeometryChange(WaylandEvent event) = 0; + virtual void OnGeometryChange(base::wayland::WaylandEvent event) = 0; }; } // namespace ui diff --git a/ui/wayland/wayland_window.cc b/ui/wayland/wayland_window.cc index 7199494..cd84a45 100644 --- a/ui/wayland/wayland_window.cc +++ b/ui/wayland/wayland_window.cc @@ -6,10 +6,12 @@ #include <wayland-egl.h> -#include "ui/wayland/events/wayland_event.h" +#include "base/wayland/wayland_event.h" #include "ui/wayland/wayland_display.h" #include "ui/wayland/wayland_widget.h" +using base::wayland::WaylandEvent; + namespace ui { WaylandWindow::WaylandWindow(WaylandWidget* widget, WaylandDisplay* display) |