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

Unified Diff: ui/platform_window/x11/x11_window_ozone.cc

Issue 1602173005: Add PlatformWindow/Event related code for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for comments. Created 4 years, 10 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
Index: ui/platform_window/x11/x11_window_ozone.cc
diff --git a/ui/platform_window/x11/x11_window_ozone.cc b/ui/platform_window/x11/x11_window_ozone.cc
new file mode 100644
index 0000000000000000000000000000000000000000..22363f9aa8c56dd99db927d7c3865bc4b7296f7d
--- /dev/null
+++ b/ui/platform_window/x11/x11_window_ozone.cc
@@ -0,0 +1,64 @@
+// 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.
+
+#include "ui/platform_window/x11/x11_window_ozone.h"
+
+#include "ui/events/event.h"
+#include "ui/events/ozone/events_ozone.h"
+#include "ui/events/platform/x11/x11_event_source.h"
+#include "ui/events/x/events_x_utils.h"
+#include "ui/gfx/geometry/point.h"
+
+namespace ui {
+
+X11WindowOzone::X11WindowOzone(PlatformWindowDelegate* delegate)
+ : X11WindowBase(delegate) {}
+
+X11WindowOzone::~X11WindowOzone() {
+ Destroy();
+}
+
+void X11WindowOzone::Create() {
+ X11EventSourceLibevent* event_source = X11EventSourceLibevent::GetInstance();
+ DCHECK(event_source);
+ event_source->AddPlatformEventDispatcher(this);
+ event_source->AddXEventDispatcher(this);
sadrul 2016/02/08 17:28:33 Is there a reason to not do this in the ctor?
kylechar 2016/02/08 19:08:10 Done.
+
+ X11WindowBase::Create();
+}
+
+void X11WindowOzone::Destroy() {
+ X11EventSourceLibevent* event_source = X11EventSourceLibevent::GetInstance();
+ event_source->RemovePlatformEventDispatcher(this);
+ event_source->RemoveXEventDispatcher(this);
+}
+
+void X11WindowOzone::Close() {
+ Destroy();
+ X11WindowBase::Destroy();
+}
+
+void X11WindowOzone::SetCursor(PlatformCursor cursor) {}
+
+bool X11WindowOzone::DispatchXEvent(XEvent* xev) {
+ if (XWindowFromXEvent(*xev) != xwindow())
+ return false;
+
+ ProcessXWindowEvent(xev);
+ return true;
+}
+
+bool X11WindowOzone::CanDispatchEvent(const PlatformEvent& event) {
+ // TODO(kylechar): This is broken, there is no way to include XID of XWindow
+ // in ui::Event. Fix or use similar hack to DrmWindowHost.
+ return true;
+}
+
+uint32_t X11WindowOzone::DispatchEvent(const PlatformEvent& platform_event) {
+ Event* event = static_cast<Event*>(platform_event);
+ delegate()->DispatchEvent(event);
+ return POST_DISPATCH_STOP_PROPAGATION;
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698