Commit c093918c authored by piman@chromium.org's avatar piman@chromium.org

glx: forward Expose event from child window to parent

r272290 added a child window to GLSurfaceGLX, but it needs to forward
Expose events to the parent.

BUG=326995
R=ccameron@chromium.org, sadrul@chromium.org

Review URL: https://codereview.chromium.org/299143002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272648 0039d316-1c4b-4281-b951-d872f2087c98
parent 5f967259
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/config/gpu_info_collector.h" #include "gpu/config/gpu_info_collector.h"
#include "gpu/config/gpu_util.h" #include "gpu/config/gpu_util.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/gl/gl_switches.h" #include "ui/gl/gl_switches.h"
...@@ -144,6 +145,12 @@ int GpuMain(const MainFunctionParams& parameters) { ...@@ -144,6 +145,12 @@ int GpuMain(const MainFunctionParams& parameters) {
message_loop_type = base::MessageLoop::TYPE_UI; message_loop_type = base::MessageLoop::TYPE_UI;
} }
base::MessageLoop main_message_loop(message_loop_type); base::MessageLoop main_message_loop(message_loop_type);
#elif defined(OS_LINUX) && defined(USE_X11)
// We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX
// and https://crbug.com/326995.
base::MessageLoop main_message_loop(base::MessageLoop::TYPE_UI);
scoped_ptr<ui::PlatformEventSource> event_source =
ui::PlatformEventSource::CreateDefault();
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
base::MessageLoop main_message_loop(base::MessageLoop::TYPE_DEFAULT); base::MessageLoop main_message_loop(base::MessageLoop::TYPE_DEFAULT);
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
......
...@@ -2,6 +2,7 @@ include_rules = [ ...@@ -2,6 +2,7 @@ include_rules = [
"+third_party/khronos", "+third_party/khronos",
"+third_party/mesa/src/include", "+third_party/mesa/src/include",
"+third_party/skia", "+third_party/skia",
"+ui/events",
"+ui/gfx", "+ui/gfx",
"+ui/ozone", "+ui/ozone",
] ]
...@@ -222,6 +222,7 @@ ...@@ -222,6 +222,7 @@
'<(DEPTH)/build/linux/system.gyp:x11', '<(DEPTH)/build/linux/system.gyp:x11',
'<(DEPTH)/build/linux/system.gyp:xcomposite', '<(DEPTH)/build/linux/system.gyp:xcomposite',
'<(DEPTH)/build/linux/system.gyp:xext', '<(DEPTH)/build/linux/system.gyp:xext',
'<(DEPTH)/ui/events/platform/events_platform.gyp:events_platform',
'<(DEPTH)/ui/gfx/x/gfx_x11.gyp:gfx_x11', '<(DEPTH)/ui/gfx/x/gfx_x11.gyp:gfx_x11',
], ],
}], }],
......
...@@ -21,6 +21,7 @@ extern "C" { ...@@ -21,6 +21,7 @@ extern "C" {
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "third_party/mesa/src/include/GL/osmesa.h" #include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/x/x11_connection.h" #include "ui/gfx/x/x11_connection.h"
#include "ui/gfx/x/x11_types.h" #include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
...@@ -425,6 +426,15 @@ bool NativeViewGLSurfaceGLX::Initialize() { ...@@ -425,6 +426,15 @@ bool NativeViewGLSurfaceGLX::Initialize() {
NULL); NULL);
XMapWindow(g_display, window_); XMapWindow(g_display, window_);
ui::PlatformEventSource* event_source =
ui::PlatformEventSource::GetInstance();
// Can be NULL in tests, when we don't care about Exposes.
if (event_source) {
XSelectInput(g_display, window_, ExposureMask);
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
}
XFlush(g_display);
gfx::AcceleratedWidget window_for_vsync = window_; gfx::AcceleratedWidget window_for_vsync = window_;
if (g_glx_oml_sync_control_supported) if (g_glx_oml_sync_control_supported)
...@@ -437,11 +447,28 @@ bool NativeViewGLSurfaceGLX::Initialize() { ...@@ -437,11 +447,28 @@ bool NativeViewGLSurfaceGLX::Initialize() {
void NativeViewGLSurfaceGLX::Destroy() { void NativeViewGLSurfaceGLX::Destroy() {
if (window_) { if (window_) {
ui::PlatformEventSource* event_source =
ui::PlatformEventSource::GetInstance();
if (event_source)
event_source->RemovePlatformEventDispatcher(this);
XDestroyWindow(g_display, window_); XDestroyWindow(g_display, window_);
XFlush(g_display); XFlush(g_display);
} }
} }
bool NativeViewGLSurfaceGLX::CanDispatchEvent(const ui::PlatformEvent& event) {
return event->type == Expose && event->xexpose.window == window_;
}
uint32_t NativeViewGLSurfaceGLX::DispatchEvent(const ui::PlatformEvent& event) {
XEvent forwarded_event = *event;
forwarded_event.xexpose.window = parent_window_;
XSendEvent(g_display, parent_window_, False, ExposureMask,
&forwarded_event);
XFlush(g_display);
return ui::POST_DISPATCH_STOP_PROPAGATION;
}
bool NativeViewGLSurfaceGLX::Resize(const gfx::Size& size) { bool NativeViewGLSurfaceGLX::Resize(const gfx::Size& size) {
size_ = size; size_ = size;
glXWaitGL(); glXWaitGL();
...@@ -547,12 +574,6 @@ VSyncProvider* NativeViewGLSurfaceGLX::GetVSyncProvider() { ...@@ -547,12 +574,6 @@ VSyncProvider* NativeViewGLSurfaceGLX::GetVSyncProvider() {
return vsync_provider_.get(); return vsync_provider_.get();
} }
NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX()
: parent_window_(0),
window_(0),
config_(NULL) {
}
NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() {
Destroy(); Destroy();
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string> #include <string>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
#include "ui/gfx/vsync_provider.h" #include "ui/gfx/vsync_provider.h"
...@@ -48,7 +49,8 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface { ...@@ -48,7 +49,8 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface {
}; };
// A surface used to render to a view. // A surface used to render to a view.
class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX,
public ui::PlatformEventDispatcher {
public: public:
explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window); explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window);
...@@ -66,13 +68,16 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { ...@@ -66,13 +68,16 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX {
virtual VSyncProvider* GetVSyncProvider() OVERRIDE; virtual VSyncProvider* GetVSyncProvider() OVERRIDE;
protected: protected:
NativeViewGLSurfaceGLX();
virtual ~NativeViewGLSurfaceGLX(); virtual ~NativeViewGLSurfaceGLX();
private: private:
// The handle for the drawable to make current or swap. // The handle for the drawable to make current or swap.
gfx::AcceleratedWidget GetDrawableHandle() const; gfx::AcceleratedWidget GetDrawableHandle() const;
// PlatformEventDispatcher implementation
virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
// Window passed in at creation. Always valid. // Window passed in at creation. Always valid.
gfx::AcceleratedWidget parent_window_; gfx::AcceleratedWidget parent_window_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment