Index: ui/ozone/platform/x11/x11_event_factory.h |
diff --git a/ui/events/platform/x11/x11_event_source.h b/ui/ozone/platform/x11/x11_event_factory.h |
similarity index 59% |
copy from ui/events/platform/x11/x11_event_source.h |
copy to ui/ozone/platform/x11/x11_event_factory.h |
index 26d646016607273684183310df1a393d8e0d1558..5c73225a909475a465119818a605f6802a1a9b0f 100644 |
--- a/ui/events/platform/x11/x11_event_source.h |
+++ b/ui/ozone/platform/x11/x11_event_factory.h |
@@ -1,17 +1,20 @@ |
-// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Copyright 2016 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_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ |
-#define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ |
+#ifndef UI_OZONE_PLATFORM_X11_X11_EVENT_FACTORY_H_ |
+#define UI_OZONE_PLATFORM_X11_X11_EVENT_FACTORY_H_ |
#include <stdint.h> |
#include "base/macros.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/message_loop/message_loop.h" |
+#include "base/message_loop/message_pump_libevent.h" |
#include "ui/events/events_export.h" |
#include "ui/events/platform/platform_event_source.h" |
#include "ui/gfx/x/x11_types.h" |
+#include "ui/ozone/platform/x11/x11_window_manager_ozone.h" |
typedef struct _GPollFD GPollFD; |
typedef struct _GSource GSource; |
@@ -20,16 +23,17 @@ typedef unsigned long XID; |
namespace ui { |
-class X11HotplugEventHandler; |
- |
// A PlatformEventSource implementation for reading events from X11 server and |
// dispatching the events to the appropriate dispatcher. |
-class EVENTS_EXPORT X11EventSource : public PlatformEventSource { |
+class EVENTS_EXPORT X11EventFactory |
sadrul
2016/01/21 14:53:01
Why can't we use X11EventSourceLibevent instead?
kylechar
2016/01/21 15:13:35
Similar X11Window the existing X11EventSourceLibev
|
+ : public PlatformEventSource, |
+ public base::MessagePumpLibevent::Watcher { |
public: |
- explicit X11EventSource(XDisplay* display); |
- ~X11EventSource() override; |
+ explicit X11EventFactory(XDisplay* display, |
+ scoped_refptr<X11WindowManagerOzone> window_manager); |
+ ~X11EventFactory() override; |
- static X11EventSource* GetInstance(); |
+ static X11EventFactory* GetInstance(); |
// Called by the glib source dispatch function. Processes all (if any) |
// available X events. |
@@ -46,32 +50,40 @@ class EVENTS_EXPORT X11EventSource : public PlatformEventSource { |
// functions which require a mapped window. |
void BlockUntilWindowMapped(XID window); |
- protected: |
- XDisplay* display() { return display_; } |
- |
private: |
+ void AddEventWatcher(); |
+ |
// Extracts cookie data from |xevent| if it's of GenericType, and dispatches |
// the event. This function also frees up the cookie data after dispatch is |
// complete. |
uint32_t ExtractCookieDataDispatchEvent(XEvent* xevent); |
// PlatformEventSource: |
- uint32_t DispatchEvent(XEvent* xevent) override; |
+ uint32_t DispatchEvent(base::NativeEvent event) override; |
void StopCurrentEventStream() override; |
void OnDispatcherListChanged() override; |
+ // base::MessagePumpLibevent::Watcher: |
+ void OnFileCanReadWithoutBlocking(int fd) override; |
+ void OnFileCanWriteWithoutBlocking(int fd) override; |
+ |
+ // Dispatches a XEvent for a XWindow that can't be translated to a ui::Event. |
+ void DispatchXEventToXWindow(const XEvent& xevent); |
+ |
// The connection to the X11 server used to receive the events. |
XDisplay* display_; |
// Keeps track of whether this source should continue to dispatch all the |
// available events. |
- bool continue_stream_; |
+ bool continue_stream_ = true; |
- scoped_ptr<X11HotplugEventHandler> hotplug_event_handler_; |
+ scoped_refptr<X11WindowManagerOzone> window_manager_; |
+ base::MessagePumpLibevent::FileDescriptorWatcher watcher_controller_; |
+ bool initialized_ = false; |
- DISALLOW_COPY_AND_ASSIGN(X11EventSource); |
+ DISALLOW_COPY_AND_ASSIGN(X11EventFactory); |
}; |
} // namespace ui |
-#endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ |
+#endif // UI_OZONE_PLATFORM_X11_X11_EVENT_FACTORY_H_ |