diff options
Diffstat (limited to 'WebCore/plugins/gtk')
-rw-r--r-- | WebCore/plugins/gtk/PluginViewGtk.cpp | 108 | ||||
-rw-r--r-- | WebCore/plugins/gtk/gtk2xtbin.c | 24 |
2 files changed, 55 insertions, 77 deletions
diff --git a/WebCore/plugins/gtk/PluginViewGtk.cpp b/WebCore/plugins/gtk/PluginViewGtk.cpp index bee7821..6954af3 100644 --- a/WebCore/plugins/gtk/PluginViewGtk.cpp +++ b/WebCore/plugins/gtk/PluginViewGtk.cpp @@ -137,13 +137,14 @@ void PluginView::updatePluginWidget() #if defined(XP_UNIX) if (!m_isWindowed) { + Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); if (m_drawable) - XFreePixmap(GDK_DISPLAY(), m_drawable); + XFreePixmap(display, m_drawable); - m_drawable = XCreatePixmap(GDK_DISPLAY(), getRootWindow(m_parentFrame.get()), + m_drawable = XCreatePixmap(display, getRootWindow(m_parentFrame.get()), m_windowRect.width(), m_windowRect.height(), ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth); - XSync(GDK_DISPLAY(), false); // make sure that the server knows about the Drawable + XSync(display, false); // make sure that the server knows about the Drawable } #endif @@ -187,75 +188,48 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) if (!m_drawable) return; - const bool syncX = m_pluginDisplay && m_pluginDisplay != GDK_DISPLAY(); + Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); + const bool syncX = m_pluginDisplay && m_pluginDisplay != display; IntRect exposedRect(rect); exposedRect.intersect(frameRect()); exposedRect.move(-frameRect().x(), -frameRect().y()); - Window dummyW; - int dummyI; - unsigned int dummyUI, actualDepth = 0; - XGetGeometry(GDK_DISPLAY(), m_drawable, &dummyW, &dummyI, &dummyI, - &dummyUI, &dummyUI, &dummyUI, &actualDepth); - - const unsigned int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth; - ASSERT(drawableDepth == actualDepth); - - cairo_surface_t* drawableSurface = cairo_xlib_surface_create(GDK_DISPLAY(), - m_drawable, - m_visual, - m_windowRect.width(), - m_windowRect.height()); - - if (m_isTransparent && drawableDepth != 32) { - // Attempt to fake it when we don't have an alpha channel on our - // pixmap. If that's not possible, at least clear the window to - // avoid drawing artifacts. - GtkWidget* widget = m_parentFrame->view()->hostWindow()->platformPageClient(); - GdkDrawable* gdkBackingStore = 0; - gint xoff = 0, yoff = 0; - - gdk_window_get_internal_paint_info(gtk_widget_get_window(widget), &gdkBackingStore, &xoff, &yoff); - - GC gc = XDefaultGC(GDK_DISPLAY(), gdk_screen_get_number(gdk_screen_get_default())); - if (gdkBackingStore) { - XCopyArea(GDK_DISPLAY(), GDK_DRAWABLE_XID(gdkBackingStore), m_drawable, gc, - m_windowRect.x() + exposedRect.x() - xoff, - m_windowRect.y() + exposedRect.y() - yoff, - exposedRect.width(), exposedRect.height(), - exposedRect.x(), exposedRect.y()); - } else { - // no valid backing store; clear to the background color - XFillRectangle(GDK_DISPLAY(), m_drawable, gc, - exposedRect.x(), exposedRect.y(), - exposedRect.width(), exposedRect.height()); - } - } else if (m_isTransparent) { + PlatformRefPtr<cairo_surface_t> drawableSurface = adoptPlatformRef(cairo_xlib_surface_create(display, + m_drawable, + m_visual, + m_windowRect.width(), + m_windowRect.height())); + + if (m_isTransparent) { // If we have a 32 bit drawable and the plugin wants transparency, // we'll clear the exposed area to transparent first. Otherwise, // we'd end up with junk in there from the last paint, or, worse, // uninitialized data. - cairo_t* crFill = cairo_create(drawableSurface); + PlatformRefPtr<cairo_t> cr = adoptPlatformRef(cairo_create(drawableSurface.get())); - cairo_set_operator(crFill, CAIRO_OPERATOR_SOURCE); - cairo_pattern_t* fill = cairo_pattern_create_rgba(0., 0., 0., 0.); - cairo_set_source(crFill, fill); + if (!(cairo_surface_get_content(drawableSurface.get()) & CAIRO_CONTENT_ALPHA)) { + // Attempt to fake it when we don't have an alpha channel on our + // pixmap. If that's not possible, at least clear the window to + // avoid drawing artifacts. - cairo_rectangle(crFill, exposedRect.x(), exposedRect.y(), - exposedRect.width(), exposedRect.height()); - cairo_clip(crFill); - cairo_paint(crFill); + // This Would not work without double buffering, but we always use it. + cairo_set_source_surface(cr.get(), cairo_get_group_target(context->platformContext()), + -m_windowRect.x(), -m_windowRect.y()); + cairo_set_operator(cr.get(), CAIRO_OPERATOR_SOURCE); + } else + cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR); - cairo_destroy(crFill); - cairo_pattern_destroy(fill); + cairo_rectangle(cr.get(), exposedRect.x(), exposedRect.y(), + exposedRect.width(), exposedRect.height()); + cairo_fill(cr.get()); } XEvent xevent; memset(&xevent, 0, sizeof(XEvent)); XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose; exposeEvent.type = GraphicsExpose; - exposeEvent.display = GDK_DISPLAY(); + exposeEvent.display = display; exposeEvent.drawable = m_drawable; exposeEvent.x = exposedRect.x(); exposeEvent.y = exposedRect.y(); @@ -270,7 +244,7 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) cairo_t* cr = context->platformContext(); cairo_save(cr); - cairo_set_source_surface(cr, drawableSurface, frameRect().x(), frameRect().y()); + cairo_set_source_surface(cr, drawableSurface.get(), frameRect().x(), frameRect().y()); cairo_rectangle(cr, frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y(), @@ -284,7 +258,6 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) cairo_paint(cr); cairo_restore(cr); - cairo_surface_destroy(drawableSurface); #endif // defined(XP_UNIX) } @@ -346,7 +319,7 @@ void PluginView::initXEvent(XEvent* xEvent) xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server xEvent->xany.send_event = false; - xEvent->xany.display = GDK_DISPLAY(); + xEvent->xany.display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); // NOTE: event->xany.window doesn't always correspond to the .window property of other XEvent's // but does in the case of KeyPress, KeyRelease, ButtonPress, ButtonRelease, and MotionNotify // events; thus, this is right: @@ -637,7 +610,7 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re case NPNVxDisplay: #if defined(XP_UNIX) if (m_needsXEmbed) - *(void **)value = (void *)GDK_DISPLAY(); + *(void **)value = (void *)GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); else *(void **)value = (void *)GTK_XTBIN(platformPluginWidget())->xtclient.xtdisplay; *result = NPERR_NO_ERROR; @@ -732,8 +705,9 @@ static void getVisualAndColormap(int depth, Visual** visual, Colormap* colormap) *visual = 0; *colormap = 0; + Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); int rmaj, rmin; - if (depth == 32 && (!XRenderQueryVersion(GDK_DISPLAY(), &rmaj, &rmin) || (rmaj == 0 && rmin < 5))) + if (depth == 32 && (!XRenderQueryVersion(display, &rmaj, &rmin) || (rmaj == 0 && rmin < 5))) return; XVisualInfo templ; @@ -741,14 +715,14 @@ static void getVisualAndColormap(int depth, Visual** visual, Colormap* colormap) templ.depth = depth; templ.c_class = TrueColor; int nVisuals; - XVisualInfo* visualInfo = XGetVisualInfo(GDK_DISPLAY(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nVisuals); + XVisualInfo* visualInfo = XGetVisualInfo(display, VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nVisuals); if (!nVisuals) return; if (depth == 32) { for (int idx = 0; idx < nVisuals; ++idx) { - XRenderPictFormat* format = XRenderFindVisualFormat(GDK_DISPLAY(), visualInfo[idx].visual); + XRenderPictFormat* format = XRenderFindVisualFormat(display, visualInfo[idx].visual); if (format->type == PictTypeDirect && format->direct.alphaMask) { *visual = visualInfo[idx].visual; break; @@ -760,7 +734,7 @@ static void getVisualAndColormap(int depth, Visual** visual, Colormap* colormap) XFree(visualInfo); if (*visual) - *colormap = XCreateColormap(GDK_DISPLAY(), GDK_ROOT_WINDOW(), *visual, AllocNone); + *colormap = XCreateColormap(display, GDK_ROOT_WINDOW(), *visual, AllocNone); } #endif @@ -842,9 +816,9 @@ bool PluginView::platformStart() m_npWindow.window = (void*)gtk_socket_get_id(GTK_SOCKET(platformPluginWidget())); GdkWindow* window = gtk_widget_get_window(widget); ws->display = GDK_WINDOW_XDISPLAY(window); - ws->visual = GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(GDK_DRAWABLE(window))); - ws->depth = gdk_visual_get_depth(gdk_drawable_get_visual(GDK_DRAWABLE(window))); - ws->colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(GDK_DRAWABLE(window))); + ws->visual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window)); + ws->depth = gdk_visual_get_depth(gdk_window_get_visual(window)); + ws->colormap = XCreateColormap(ws->display, GDK_ROOT_WINDOW(), ws->visual, AllocNone); } else { m_npWindow.window = (void*)GTK_XTBIN(platformPluginWidget())->xtwindow; ws->display = GTK_XTBIN(platformPluginWidget())->xtdisplay; @@ -874,7 +848,7 @@ bool PluginView::platformStart() ws->depth = gdk_visual_get_depth(gvisual); } - ws->display = GDK_DISPLAY(); + ws->display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); ws->visual = m_visual; ws->colormap = m_colormap; @@ -904,7 +878,7 @@ void PluginView::platformDestroy() { #if defined(XP_UNIX) if (m_drawable) { - XFreePixmap(GDK_DISPLAY(), m_drawable); + XFreePixmap(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), m_drawable); m_drawable = 0; } #endif diff --git a/WebCore/plugins/gtk/gtk2xtbin.c b/WebCore/plugins/gtk/gtk2xtbin.c index a0808d9..31c564f 100644 --- a/WebCore/plugins/gtk/gtk2xtbin.c +++ b/WebCore/plugins/gtk/gtk2xtbin.c @@ -72,7 +72,7 @@ static void gtk_xtbin_class_init (GtkXtBinClass *klass); static void gtk_xtbin_init (GtkXtBin *xtbin); static void gtk_xtbin_realize (GtkWidget *widget); static void gtk_xtbin_unrealize (GtkWidget *widget); -static void gtk_xtbin_destroy (GtkObject *object); +static void gtk_xtbin_dispose (GObject *object); /* Xt aware XEmbed */ static void xt_client_init (XtClient * xtclient, @@ -244,7 +244,7 @@ static void gtk_xtbin_class_init (GtkXtBinClass *klass) { GtkWidgetClass *widget_class; - GtkObjectClass *object_class; + GObjectClass *object_class; parent_class = g_type_class_peek_parent (klass); @@ -252,8 +252,8 @@ gtk_xtbin_class_init (GtkXtBinClass *klass) widget_class->realize = gtk_xtbin_realize; widget_class->unrealize = gtk_xtbin_unrealize; - object_class = GTK_OBJECT_CLASS (klass); - object_class->destroy = gtk_xtbin_destroy; + object_class = G_OBJECT_CLASS (klass); + object_class->dispose = gtk_xtbin_dispose; } static void @@ -326,8 +326,9 @@ gtk_xtbin_new (GdkWindow *parent_window, String * f) { GtkXtBin *xtbin; gpointer user_data; + GdkScreen *screen; GdkVisual* visual; - GdkColormap* colormap; + Colormap colormap; assert(parent_window != NULL); xtbin = g_object_new (GTK_TYPE_XTBIN, NULL); @@ -341,12 +342,15 @@ gtk_xtbin_new (GdkWindow *parent_window, String * f) /* Initialize the Xt toolkit */ xtbin->parent_window = parent_window; - visual = gtk_widget_get_default_visual(); - colormap = gtk_widget_get_default_colormap(); + screen = gtk_widget_get_screen(GTK_WIDGET(parent_window)); + visual = gdk_screen_get_system_visual(screen); + colormap = XCreateColormap(GDK_DISPLAY_XDISPLAY(gdk_screen_get_display(screen)), + GDK_WINDOW_XWINDOW(gdk_screen_get_root_window(screen)), + GDK_VISUAL_XVISUAL(visual), AllocNone); xt_client_init(&(xtbin->xtclient), GDK_VISUAL_XVISUAL(visual), - GDK_COLORMAP_XCOLORMAP(colormap), + colormap, gdk_visual_get_depth(visual)); if (!xtbin->xtclient.xtdisplay) { @@ -480,7 +484,7 @@ gtk_xtbin_unrealize (GtkWidget *object) } static void -gtk_xtbin_destroy (GtkObject *object) +gtk_xtbin_dispose (GObject *object) { GtkXtBin *xtbin; @@ -514,7 +518,7 @@ gtk_xtbin_destroy (GtkObject *object) } } - GTK_OBJECT_CLASS(parent_class)->destroy(object); + G_OBJECT_CLASS(parent_class)->dispose(object); } /* |