Index: ui/ozone/platform/x11/gl_surface_glx_ozone.cc |
diff --git a/ui/ozone/platform/x11/gl_surface_glx_ozone.cc b/ui/ozone/platform/x11/gl_surface_glx_ozone.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..74ad75f9fbd99281fc21558b11acdecbb8b71367 |
--- /dev/null |
+++ b/ui/ozone/platform/x11/gl_surface_glx_ozone.cc |
@@ -0,0 +1,41 @@ |
+// 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/ozone/platform/x11/gl_surface_glx_ozone.h" |
+ |
+#include <X11/Xlib.h> |
+ |
+namespace ui { |
+ |
+GLSurfaceGLXOzone::GLSurfaceGLXOzone(gfx::AcceleratedWidget window) |
+ : NativeViewGLSurfaceGLX(window) {} |
+ |
+GLSurfaceGLXOzone::~GLSurfaceGLXOzone() { |
+ Destroy(); |
+} |
+ |
+void GLSurfaceGLXOzone::RegisterEvents() { |
+ auto* event_source = X11EventSourceLibevent::GetInstance(); |
+ // Can be null in tests, when we don't care about Exposes. |
+ if (event_source) { |
+ XSelectInput(gfx::GetXDisplay(), window(), ExposureMask); |
+ event_source->AddXEventDispatcher(this); |
+ } |
+} |
+ |
+void GLSurfaceGLXOzone::UnregisterEvents() { |
+ auto* event_source = X11EventSourceLibevent::GetInstance(); |
+ if (event_source) |
+ event_source->RemoveXEventDispatcher(this); |
+} |
+ |
+bool GLSurfaceGLXOzone::DispatchXEvent(XEvent* event) { |
+ if (!CanHandleEvent(event)) |
+ return false; |
+ |
+ ForwardExposeEvent(event); |
+ return true; |
+} |
+ |
+} // namespace ui |