Commit 0f83a23a authored by sadrul@chromium.org's avatar sadrul@chromium.org

aura: Add back XInputHierarchyChangedEventListener for aura and remove stubs.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/8623005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111099 0039d316-1c4b-4281-b951-d872f2087c98
parent 6d33da17
......@@ -79,46 +79,6 @@ std::string SystemNotification::Delegate::id() const {
return id_;
}
////////////////////////////////////////////////////////////////////////////////
// XInputHierarchyChangedEventListener
// static
XInputHierarchyChangedEventListener*
XInputHierarchyChangedEventListener::GetInstance() {
NOTIMPLEMENTED();
return new XInputHierarchyChangedEventListener();
}
XInputHierarchyChangedEventListener::XInputHierarchyChangedEventListener()
: stopped_(false),
xiopcode_(0) {
NOTIMPLEMENTED();
}
XInputHierarchyChangedEventListener::~XInputHierarchyChangedEventListener() {
NOTIMPLEMENTED();
}
void XInputHierarchyChangedEventListener::Stop() {
NOTIMPLEMENTED();
}
base::EventStatus XInputHierarchyChangedEventListener::WillProcessEvent(
const base::NativeEvent& event) {
NOTIMPLEMENTED();
return base::EVENT_HANDLED;
}
void XInputHierarchyChangedEventListener::DidProcessEvent(
const base::NativeEvent& event) {
NOTIMPLEMENTED();
}
bool XInputHierarchyChangedEventListener::ProcessedXEvent(XEvent* xevent) {
NOTIMPLEMENTED();
return true;
}
//////////////////////////////////////////////////////////////////////////////
// ScreenLocker
......
......@@ -4,7 +4,6 @@
#include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>
......@@ -76,12 +75,7 @@ XInputHierarchyChangedEventListener::XInputHierarchyChangedEventListener()
: stopped_(false),
xiopcode_(GetXInputOpCode()) {
SelectXInputEvents();
#if defined(TOUCH_UI) || !defined(TOOLKIT_USES_GTK)
MessageLoopForUI::current()->AddObserver(this);
#else
gdk_window_add_filter(NULL, GdkEventFilter, this);
#endif
Init();
}
XInputHierarchyChangedEventListener::~XInputHierarchyChangedEventListener() {
......@@ -92,60 +86,21 @@ void XInputHierarchyChangedEventListener::Stop() {
if (stopped_)
return;
#if defined(TOUCH_UI) || !defined(TOOLKIT_USES_GTK)
MessageLoopForUI::current()->RemoveObserver(this);
#else
gdk_window_remove_filter(NULL, GdkEventFilter, this);
#endif
StopImpl();
stopped_ = true;
xiopcode_ = -1;
}
#if defined(TOUCH_UI) || !defined(TOOLKIT_USES_GTK)
base::EventStatus XInputHierarchyChangedEventListener::WillProcessEvent(
const base::NativeEvent& event) {
// There may be multiple listeners for the XI_HierarchyChanged event. So
// always return EVENT_CONTINUE to make sure all the listeners receive the
// event.
ProcessedXEvent(event);
return base::EVENT_CONTINUE;
}
void XInputHierarchyChangedEventListener::DidProcessEvent(
const base::NativeEvent& event) {
}
#else // defined(TOUCH_UI) || !defined(TOOLKIT_USES_GTK)
// static
GdkFilterReturn XInputHierarchyChangedEventListener::GdkEventFilter(
GdkXEvent* gxevent, GdkEvent* gevent, gpointer data) {
XInputHierarchyChangedEventListener* listener =
static_cast<XInputHierarchyChangedEventListener*>(data);
XEvent* xevent = static_cast<XEvent*>(gxevent);
return listener->ProcessedXEvent(xevent) ? GDK_FILTER_REMOVE
: GDK_FILTER_CONTINUE;
}
#endif // defined(TOUCH_UI) || !defined(TOOLKIT_USES_GTK)
bool XInputHierarchyChangedEventListener::ProcessedXEvent(XEvent* xevent) {
if ((xevent->xcookie.type != GenericEvent) ||
(xevent->xcookie.extension != xiopcode_)) {
return false;
}
#if !defined(TOUCH_UI)
if (!XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) {
VLOG(1) << "XGetEventData failed";
return false;
}
#endif
XGenericEventCookie* cookie = &(xevent->xcookie);
const bool should_consume = (cookie->evtype == XI_HierarchyChanged);
if (should_consume)
HandleHierarchyChangedEvent(static_cast<XIHierarchyEvent*>(cookie->data));
#if !defined(TOUCH_UI)
XFreeEventData(xevent->xgeneric.display, cookie);
#endif
return should_consume;
}
......
......@@ -35,15 +35,13 @@ class XInputHierarchyChangedEventListener : public MessageLoopForUI::Observer {
XInputHierarchyChangedEventListener();
virtual ~XInputHierarchyChangedEventListener();
#if defined(TOUCH_UI) || !defined(TOOLKIT_USES_GTK)
// MessageLoopForUI::Observer overrides.
virtual base::EventStatus WillProcessEvent(
const base::NativeEvent& event) OVERRIDE;
virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
#else
// When TOUCH_UI is not defined, WillProcessXEvent() will not be called
// automatically. We have to call the function manually by adding the Gdk
// event filter.
void Init();
void StopImpl();
#if defined(TOOLKIT_USES_GTK)
// When GTK events are processed, WillProcessXEvent() is not called
// automatically. It is necessary to call the function manually by adding the
// Gdk event filter.
static GdkFilterReturn GdkEventFilter(GdkXEvent* gxevent,
GdkEvent* gevent,
gpointer data);
......@@ -51,6 +49,11 @@ class XInputHierarchyChangedEventListener : public MessageLoopForUI::Observer {
// MessageLoopForUI::Observer overrides.
virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {}
virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {}
#else
// MessageLoopForUI::Observer overrides.
virtual base::EventStatus WillProcessEvent(
const base::NativeEvent& event) OVERRIDE;
virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
#endif
// Returns true if the event was processed, false otherwise.
......
// 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.
#include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
namespace chromeos {
void XInputHierarchyChangedEventListener::Init() {
MessageLoopForUI::current()->AddObserver(this);
}
void XInputHierarchyChangedEventListener::StopImpl() {
MessageLoopForUI::current()->RemoveObserver(this);
}
base::EventStatus XInputHierarchyChangedEventListener::WillProcessEvent(
const base::NativeEvent& event) {
// There may be multiple listeners for the XI_HierarchyChanged event. So
// always return EVENT_CONTINUE to make sure all the listeners receive the
// event.
ProcessedXEvent(event);
return base::EVENT_CONTINUE;
}
void XInputHierarchyChangedEventListener::DidProcessEvent(
const base::NativeEvent& event) {
}
} // namespace chromeos
// 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.
#include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>
namespace chromeos {
void XInputHierarchyChangedEventListener::Init() {
gdk_window_add_filter(NULL, GdkEventFilter, this);
}
void XInputHierarchyChangedEventListener::StopImpl() {
gdk_window_remove_filter(NULL, GdkEventFilter, this);
}
// static
GdkFilterReturn XInputHierarchyChangedEventListener::GdkEventFilter(
GdkXEvent* gxevent, GdkEvent* gevent, gpointer data) {
XInputHierarchyChangedEventListener* listener =
static_cast<XInputHierarchyChangedEventListener*>(data);
XEvent* xevent = static_cast<XEvent*>(gxevent);
if (xevent->xcookie.type != GenericEvent)
return GDK_FILTER_CONTINUE;
if (!XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) {
VLOG(1) << "XGetEventData failed";
return GDK_FILTER_CONTINUE;
}
bool processed = listener->ProcessedXEvent(xevent);
XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
return processed ? GDK_FILTER_REMOVE : GDK_FILTER_CONTINUE;
}
} // namespace chromeos
......@@ -808,6 +808,8 @@
'browser/chromeos/web_socket_proxy_controller.h',
'browser/chromeos/xinput_hierarchy_changed_event_listener.cc',
'browser/chromeos/xinput_hierarchy_changed_event_listener.h',
'browser/chromeos/xinput_hierarchy_changed_event_listener_aura.cc',
'browser/chromeos/xinput_hierarchy_changed_event_listener_gtk.cc',
'browser/command_updater.cc',
'browser/command_updater.h',
'browser/component_updater/component_updater_configurator.cc',
......@@ -5194,7 +5196,6 @@
['exclude', '^browser/chromeos/login/webui_screen_locker.cc'],
['exclude', '^browser/chromeos/login/wizard_in_process_browser_test.cc'],
['exclude', '^browser/chromeos/notifications/'],
['exclude', '^browser/chromeos/xinput_hierarchy_changed_event_listener.cc'],
['include', '^browser/ui/views/handle_web_keyboard_event_aura.cc'],
['include', '^browser/ui/views/handle_web_keyboard_event.h'],
],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment