Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: views/events/event_wayland.cc

Issue 7942004: Consolidate/cleanup event cracking code; single out GdkEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge removal of compact nav. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/events/event_utils_win.cc ('k') | views/events/event_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/events/event_wayland.cc
diff --git a/views/events/event_wayland.cc b/views/events/event_wayland.cc
index 92b54829ab8b53ef24c1c492670bde30acb2d5e5..95d564f8b65ad8064054d8ec56fe3f8d25020a81 100644
--- a/views/events/event_wayland.cc
+++ b/views/events/event_wayland.cc
@@ -4,191 +4,13 @@
#include "views/events/event.h"
-#include <X11/Xlib.h>
-
#include "base/logging.h"
-#include "ui/base/keycodes/keyboard_code_conversion_x.h"
-#include "ui/wayland/events/wayland_event.h"
namespace views {
-namespace {
-
-static int kWheelScrollAmount = 53;
-
-ui::EventType EventTypeFromNative(NativeEvent native_event) {
- switch (native_event->type) {
- case ui::WAYLAND_BUTTON:
- switch (native_event->button.button) {
- case ui::LEFT_BUTTON:
- case ui::RIGHT_BUTTON:
- case ui::MIDDLE_BUTTON:
- return native_event->button.state ? ui::ET_MOUSE_PRESSED
- : ui::ET_MOUSE_RELEASED;
- case ui::SCROLL_UP:
- case ui::SCROLL_DOWN:
- return ui::ET_MOUSEWHEEL;
- default:
- break;
- }
- break;
- case ui::WAYLAND_KEY:
- return native_event->key.state ? ui::ET_KEY_PRESSED
- : ui::ET_KEY_RELEASED;
- case ui::WAYLAND_MOTION:
- return ui::ET_MOUSE_MOVED;
- case ui::WAYLAND_POINTER_FOCUS:
- return native_event->pointer_focus.state ? ui::ET_MOUSE_ENTERED
- : ui::ET_MOUSE_EXITED;
- case ui::WAYLAND_KEYBOARD_FOCUS:
- return ui::ET_UNKNOWN;
- default:
- break;
- }
- return ui::ET_UNKNOWN;
-}
-
-gfx::Point GetMouseEventLocation(NativeEvent native_event) {
- switch (native_event->type) {
- case ui::WAYLAND_BUTTON:
- return gfx::Point(native_event->button.x, native_event->button.y);
- case ui::WAYLAND_MOTION:
- return gfx::Point(native_event->motion.x, native_event->motion.y);
- case ui::WAYLAND_POINTER_FOCUS:
- return gfx::Point(native_event->pointer_focus.x,
- native_event->pointer_focus.y);
- default:
- return gfx::Point(0, 0);
- }
-}
-
-int GetEventFlagsFromState(unsigned int state) {
- int flags = 0;
- if (state & ControlMask)
- flags |= ui::EF_CONTROL_DOWN;
- if (state & ShiftMask)
- flags |= ui::EF_SHIFT_DOWN;
- if (state & Mod1Mask)
- flags |= ui::EF_ALT_DOWN;
- if (state & LockMask)
- flags |= ui::EF_CAPS_LOCK_DOWN;
- if (state & Button1Mask)
- flags |= ui::EF_LEFT_BUTTON_DOWN;
- if (state & Button2Mask)
- flags |= ui::EF_MIDDLE_BUTTON_DOWN;
- if (state & Button3Mask)
- flags |= ui::EF_RIGHT_BUTTON_DOWN;
-
- return flags;
-}
-
-int GetButtonEventFlagsFromNativeEvent(NativeEvent native_event) {
- // TODO(dnicoara): Need to add double click.
- int flags = 0;
- switch (native_event->button.button) {
- case ui::LEFT_BUTTON:
- return flags | ui::EF_LEFT_BUTTON_DOWN;
- case ui::MIDDLE_BUTTON:
- return flags | ui::EF_MIDDLE_BUTTON_DOWN;
- case ui::RIGHT_BUTTON:
- return flags | ui::EF_RIGHT_BUTTON_DOWN;
- }
- return flags;
-}
-
-int GetEventFlagsFromNativeEvent(NativeEvent native_event) {
- switch (native_event->type) {
- case ui::WAYLAND_BUTTON:
- return GetButtonEventFlagsFromNativeEvent(native_event) |
- GetEventFlagsFromState(native_event->button.modifiers);
- case ui::WAYLAND_KEY:
- return GetEventFlagsFromState(native_event->key.modifiers);
- case ui::WAYLAND_MOTION:
- return GetEventFlagsFromState(native_event->motion.modifiers);
- case ui::WAYLAND_KEYBOARD_FOCUS:
- return GetEventFlagsFromState(native_event->keyboard_focus.modifiers);
- default:
- return 0;
- }
-}
-
-int GetMouseWheelOffset(NativeEvent native_event) {
- if (native_event->button.button == ui::SCROLL_UP) {
- return kWheelScrollAmount;
- } else {
- return -kWheelScrollAmount;
- }
-}
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// Event, private:
-
-void Event::Init() {
- native_event_ = NULL;
- native_event_2_ = NULL;
-}
-
-void Event::InitWithNativeEvent(NativeEvent native_event) {
- native_event_ = native_event;
- // TODO(dnicoara): Remove once we rid views of Gtk/Gdk.
- native_event_2_ = NULL;
-}
-
-void Event::InitWithNativeEvent2(NativeEvent2 native_event_2,
- FromNativeEvent2) {
- native_event_2_ = NULL;
- // TODO(dnicoara): Remove once we rid views of Gtk/Gdk.
- native_event_2_ = native_event_2;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// MouseEvent, public:
-
-MouseEvent::MouseEvent(NativeEvent native_event)
- : LocatedEvent(native_event) {
-}
-
-MouseEvent::MouseEvent(NativeEvent2 native_event_2,
- FromNativeEvent2 from_native)
- : LocatedEvent(native_event_2, from_native) {
- // TODO(dnicoara): Remove once we rid views of Gtk/Gdk.
- NOTREACHED();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// LocatedEvent, protected:
-
-LocatedEvent::LocatedEvent(NativeEvent native_event)
- : Event(native_event, EventTypeFromNative(native_event),
- GetEventFlagsFromNativeEvent(native_event)),
- location_(GetMouseEventLocation(native_event)) {
-}
-
-LocatedEvent::LocatedEvent(NativeEvent2 native_event_2,
- FromNativeEvent2 from_native)
- : Event(native_event_2, ui::ET_UNKNOWN, 0, from_native) {
- // TODO(dnicoara) Remove once we rid views of Gtk.
- NOTREACHED();
-}
-
//////////////////////////////////////////////////////////////////////////////
// KeyEvent, public:
-
-KeyEvent::KeyEvent(NativeEvent native_event)
- : Event(native_event, EventTypeFromNative(native_event),
- GetEventFlagsFromNativeEvent(native_event)),
- key_code_(ui::KeyboardCodeFromXKeysym(native_event->key.sym)) {
-}
-
-KeyEvent::KeyEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native)
- : Event(native_event_2, ui::ET_UNKNOWN, 0, from_native) {
- // TODO(dnicoara) Remove once we rid views of Gtk.
- NOTREACHED();
-}
-
uint16 KeyEvent::GetCharacter() const {
return GetCharacterFromKeyCode(key_code_, flags());
}
@@ -197,19 +19,4 @@ uint16 KeyEvent::GetUnmodifiedCharacter() const {
return GetCharacterFromKeyCode(key_code_, flags() & ui::EF_SHIFT_DOWN);
}
-//////////////////////////////////////////////////////////////////////////////
-// MouseWheelEvent, public:
-
-MouseWheelEvent::MouseWheelEvent(NativeEvent native_event)
- : MouseEvent(native_event),
- offset_(GetMouseWheelOffset(native_event)) {
-}
-
-MouseWheelEvent::MouseWheelEvent(NativeEvent2 native_event_2,
- FromNativeEvent2 from_native)
- : MouseEvent(native_event_2, from_native) {
- // TODO(dnicoara) Remove once we rid views of Gtk.
- NOTREACHED();
-}
-
} // namespace views
« no previous file with comments | « views/events/event_utils_win.cc ('k') | views/events/event_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698