| Index: ui/gl/gl_surface_glx.cc
|
| diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc
|
| index 8b705dfbe93751c899daa05752cc585d64229097..89bb09fbce2a33d3207a62456bbb903849ea9800 100644
|
| --- a/ui/gl/gl_surface_glx.cc
|
| +++ b/ui/gl/gl_surface_glx.cc
|
| @@ -14,6 +14,7 @@ extern "C" {
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/message_loop/message_loop.h"
|
| +#include "base/message_loop/message_pump_x11.h"
|
| #include "base/synchronization/cancellation_flag.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/threading/non_thread_safe.h"
|
| @@ -315,7 +316,10 @@ bool GLSurfaceGLX::InitializeOneOff() {
|
| // it's own thread.
|
| XInitThreads();
|
|
|
| - g_display = base::MessagePumpForUI::GetDefaultXDisplay();
|
| + // XXX -- base::MessagePumpForUI is returning Gtk here -- we need to
|
| + // make this *not* be a compile-time decision.
|
| + g_display = //base::MessagePumpForUI::GetDefaultXDisplay();
|
| + base::MessagePumpX11::GetDefaultXDisplay();
|
| if (!g_display) {
|
| LOG(ERROR) << "XOpenDisplay failed.";
|
| return false;
|
| @@ -388,31 +392,84 @@ void* GLSurfaceGLX::GetDisplay() {
|
|
|
| GLSurfaceGLX::~GLSurfaceGLX() {}
|
|
|
| +// XXX - we should just have 1 of these, not 1 per GLSurfaceGLX
|
| +class NativeViewXExposeEventForwarder : public base::MessageLoop::Observer {
|
| + public:
|
| + NativeViewXExposeEventForwarder(gfx::AcceleratedWidget parent_window,
|
| + gfx::AcceleratedWidget child_window)
|
| + : child_window_(child_window), parent_window_(parent_window) {
|
| + base::MessageLoopForUI::current()->AddObserver(this);
|
| + }
|
| + ~NativeViewXExposeEventForwarder() {
|
| + base::MessageLoopForUI::current()->RemoveObserver(this);
|
| + }
|
| +
|
| + virtual base::EventStatus WillProcessEvent(
|
| + const base::NativeEvent& xevent) OVERRIDE {
|
| + if (xevent->type == Expose &&
|
| + xevent->xexpose.window == child_window_) {
|
| + XEvent forwarded_event = *xevent;
|
| + forwarded_event.xexpose.window = parent_window_;
|
| + XSendEvent(
|
| + g_display, parent_window_, False, ExposureMask, &forwarded_event);
|
| + }
|
| + return base::EVENT_CONTINUE;
|
| + }
|
| + virtual void DidProcessEvent(const base::NativeEvent&) OVERRIDE {
|
| + }
|
| +
|
| + private:
|
| + gfx::AcceleratedWidget child_window_;
|
| + gfx::AcceleratedWidget parent_window_;
|
| +};
|
| +
|
| NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window)
|
| - : window_(window),
|
| + : parent_window_(window),
|
| + window_(0),
|
| config_(NULL) {
|
| }
|
|
|
| bool NativeViewGLSurfaceGLX::Initialize() {
|
| XWindowAttributes attributes;
|
| - if (!XGetWindowAttributes(g_display, window_, &attributes)) {
|
| - LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << ".";
|
| + if (!XGetWindowAttributes(g_display, parent_window_, &attributes)) {
|
| + LOG(ERROR) << "XGetWindowAttributes failed for window "
|
| + << parent_window_ << ".";
|
| return false;
|
| }
|
| size_ = gfx::Size(attributes.width, attributes.height);
|
|
|
| + XSetWindowAttributes set_attributes = {0};
|
| + set_attributes.event_mask = ExposureMask;
|
| + window_= XCreateWindow(
|
| + g_display, parent_window_, 0, 0, attributes.width, attributes.height, 0,
|
| + attributes.depth, InputOutput, attributes.visual, CWEventMask,
|
| + &set_attributes);
|
| + XMapWindow(g_display, window_);
|
| + XFlush(g_display);
|
| +
|
| if (g_glx_oml_sync_control_supported)
|
| vsync_provider_.reset(new OMLSyncControlVSyncProvider(window_));
|
| else if (g_glx_sgi_video_sync_supported)
|
| vsync_provider_.reset(new SGIVideoSyncVSyncProvider(window_));
|
|
|
| + event_forwarder_.reset(
|
| + new NativeViewXExposeEventForwarder(parent_window_, window_));
|
| +
|
| return true;
|
| }
|
|
|
| void NativeViewGLSurfaceGLX::Destroy() {
|
| + event_forwarder_.reset();
|
| + if (window_) {
|
| + XDestroyWindow(g_display, window_);
|
| + XFlush(g_display);
|
| + window_ = 0;
|
| + }
|
| }
|
|
|
| bool NativeViewGLSurfaceGLX::Resize(const gfx::Size& size) {
|
| + XResizeWindow(g_display, window_, size.width(), size.height());
|
| + XFlush(g_display);
|
| size_ = size;
|
| return true;
|
| }
|
| @@ -516,7 +573,8 @@ VSyncProvider* NativeViewGLSurfaceGLX::GetVSyncProvider() {
|
| }
|
|
|
| NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX()
|
| - : window_(0),
|
| + : parent_window_(0),
|
| + window_(0),
|
| config_(NULL) {
|
| }
|
|
|
|
|