gl_surface_glx_x11.cc 1011 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. #include "ui/gl/gl_surface_glx_x11.h"
  5. #include "ui/gfx/x/future.h"
  6. namespace gl {
  7. GLSurfaceGLXX11::GLSurfaceGLXX11(gfx::AcceleratedWidget window)
  8. : NativeViewGLSurfaceGLX(window) {}
  9. GLSurfaceGLXX11::~GLSurfaceGLXX11() {
  10. Destroy();
  11. }
  12. void GLSurfaceGLXX11::RegisterEvents() {
  13. // Can be null in tests, when we don't care about Exposes.
  14. auto* connection = x11::Connection::Get();
  15. connection->ChangeWindowAttributes(x11::ChangeWindowAttributesRequest{
  16. .window = static_cast<x11::Window>(window()),
  17. .event_mask = x11::EventMask::Exposure});
  18. connection->AddEventObserver(this);
  19. }
  20. void GLSurfaceGLXX11::UnregisterEvents() {
  21. x11::Connection::Get()->RemoveEventObserver(this);
  22. }
  23. void GLSurfaceGLXX11::OnEvent(const x11::Event& event) {
  24. if (CanHandleEvent(event))
  25. ForwardExposeEvent(event);
  26. }
  27. } // namespace gl