OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/gl/gl_surface_glx_x11.h" |
| 6 |
| 7 #include <X11/Xlib.h> |
| 8 |
| 9 #include "ui/events/platform/platform_event_source.h" |
| 10 #include "ui/gfx/x/x11_types.h" |
| 11 |
| 12 namespace gl { |
| 13 |
| 14 GLSurfaceGLXX11::GLSurfaceGLXX11(gfx::AcceleratedWidget window) |
| 15 : NativeViewGLSurfaceGLX(window) {} |
| 16 |
| 17 GLSurfaceGLXX11::~GLSurfaceGLXX11() { |
| 18 Destroy(); |
| 19 } |
| 20 |
| 21 void GLSurfaceGLXX11::RegisterEvents() { |
| 22 auto* event_source = ui::PlatformEventSource::GetInstance(); |
| 23 // Can be null in tests, when we don't care about Exposes. |
| 24 if (event_source) { |
| 25 XSelectInput(gfx::GetXDisplay(), window(), ExposureMask); |
| 26 event_source->AddPlatformEventDispatcher(this); |
| 27 } |
| 28 } |
| 29 |
| 30 void GLSurfaceGLXX11::UnregisterEvents() { |
| 31 auto* event_source = ui::PlatformEventSource::GetInstance(); |
| 32 if (event_source) |
| 33 event_source->RemovePlatformEventDispatcher(this); |
| 34 } |
| 35 |
| 36 bool GLSurfaceGLXX11::CanDispatchEvent(const ui::PlatformEvent& event) { |
| 37 return CanHandleEvent(event); |
| 38 } |
| 39 |
| 40 uint32_t GLSurfaceGLXX11::DispatchEvent(const ui::PlatformEvent& event) { |
| 41 ForwardExposeEvent(event); |
| 42 return ui::POST_DISPATCH_STOP_PROPAGATION; |
| 43 } |
| 44 |
| 45 } // namespace gl |
OLD | NEW |