diff --git a/modules/plugin/test/testplugin/Makefile.in b/modules/plugin/test/testplugin/Makefile.in index 92ae9e30fec..47e50fff2ce 100644 --- a/modules/plugin/test/testplugin/Makefile.in +++ b/modules/plugin/test/testplugin/Makefile.in @@ -87,7 +87,7 @@ include $(topsrcdir)/config/rules.mk ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2) CXXFLAGS += $(MOZ_GTK2_CFLAGS) CFLAGS += $(MOZ_GTK2_CFLAGS) -EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS) +EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS) endif install-plugin: $(SHARED_LIBRARY) diff --git a/modules/plugin/test/testplugin/nptest_gtk2.cpp b/modules/plugin/test/testplugin/nptest_gtk2.cpp index ab1dc55fe44..aed28cbc190 100644 --- a/modules/plugin/test/testplugin/nptest_gtk2.cpp +++ b/modules/plugin/test/testplugin/nptest_gtk2.cpp @@ -38,6 +38,7 @@ #include #ifdef MOZ_X11 #include +#include #endif #include @@ -334,6 +335,34 @@ int32_t pluginGetEdge(InstanceData* instanceData, RectEdge edge) return NPTEST_INT32_ERROR; } +#ifdef MOZ_X11 +static void intersectWithShapeRects(Display* display, Window window, + int kind, GdkRegion* region) +{ + int count, order; + XRectangle* shapeRects = + XShapeGetRectangles(display, window, kind, &count, &order); + if (!shapeRects) + return; + + GdkRegion* shapeRegion = gdk_region_new(); + if (!shapeRegion) { + XFree(shapeRects); + return; + } + + for (int i = 0; i < count; ++i) { + XRectangle* r = &shapeRects[i]; + GdkRectangle rect = { r->x, r->y, r->width, r->height }; + gdk_region_union_with_rect(shapeRegion, &rect); + } + XFree(shapeRects); + + gdk_region_intersect(region, shapeRegion); + gdk_region_destroy(shapeRegion); +} +#endif + static GdkRegion* computeClipRegion(InstanceData* instanceData) { if (!instanceData->hasWidget) @@ -374,13 +403,15 @@ static GdkRegion* computeClipRegion(InstanceData* instanceData) return 0; } - GdkRectangle windowRect = { -pluginX, -pluginY, width, height }; + GdkRectangle windowRect = { 0, 0, width, height }; GdkRegion* windowRgn = gdk_region_rectangle(&windowRect); if (!windowRgn) { gdk_region_destroy(region); return 0; } - gdk_region_intersect(region, windowRgn); + intersectWithShapeRects(display, window, ShapeBounding, windowRgn); + intersectWithShapeRects(display, window, ShapeClip, windowRgn); + gdk_region_offset(windowRgn, -pluginX, -pluginY); gdk_region_destroy(windowRgn); // Stop now if we've reached the toplevel. Stopping here means