diff options
Diffstat (limited to 'WebKit/gtk/WebCoreSupport/DragClientGtk.cpp')
-rw-r--r-- | WebKit/gtk/WebCoreSupport/DragClientGtk.cpp | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp index cc75d36..b850cec 100644 --- a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) Igalia S.L. + * Copyright (C) 2009, 2010 Igalia S.L. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -41,23 +41,38 @@ using namespace WebCore; namespace WebKit { -static gboolean dragIconWindowExposeEventCallback(GtkWidget* widget, GdkEventExpose* event, DragClient* client) +#ifdef GTK_API_VERSION_2 +static gboolean dragIconWindowDrawEventCallback(GtkWidget* widget, GdkEventExpose* event, DragClient* client) { - client->dragIconWindowExposeEvent(widget, event); + PlatformRefPtr<cairo_t> context = adoptPlatformRef(gdk_cairo_create(event->window)); + client->drawDragIconWindow(widget, context.get()); return TRUE; } +#else +static gboolean dragIconWindowDrawEventCallback(GtkWidget* widget, cairo_t* context, DragClient* client) +{ + if (!gdk_cairo_get_clip_rectangle(context, 0)) + return FALSE; + client->drawDragIconWindow(widget, context); + return TRUE; +} +#endif // GTK_API_VERSION_2 DragClient::DragClient(WebKitWebView* webView) : m_webView(webView) , m_startPos(0, 0) , m_dragIconWindow(gtk_window_new(GTK_WINDOW_POPUP)) { - g_signal_connect(m_dragIconWindow.get(), "expose-event", G_CALLBACK(dragIconWindowExposeEventCallback), this); +#ifdef GTK_API_VERSION_2 + g_signal_connect(m_dragIconWindow.get(), "expose-event", G_CALLBACK(dragIconWindowDrawEventCallback), this); +#else + g_signal_connect(m_dragIconWindow.get(), "draw", G_CALLBACK(dragIconWindowDrawEventCallback), this); +#endif } DragClient::~DragClient() { - g_signal_handlers_disconnect_by_func(m_dragIconWindow.get(), (gpointer) dragIconWindowExposeEventCallback, this); + g_signal_handlers_disconnect_by_func(m_dragIconWindow.get(), (gpointer) dragIconWindowDrawEventCallback, this); } void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*) @@ -106,9 +121,16 @@ void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, if (!gtk_widget_get_realized(m_dragIconWindow.get())) { GdkScreen* screen = gtk_widget_get_screen(m_dragIconWindow.get()); +#ifdef GTK_API_VERSION_2 GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen); if (rgba) gtk_widget_set_colormap(m_dragIconWindow.get(), rgba); +#else + GdkVisual* visual = gdk_screen_get_rgba_visual(screen); + if (!visual) + visual = gdk_screen_get_system_visual(screen); + gtk_widget_set_visual(m_dragIconWindow.get(), visual); +#endif // GTK_API_VERSION_2 } IntSize origin = eventPos - dragImageOrigin; @@ -118,15 +140,14 @@ void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, gtk_drag_set_icon_default(context); } -void DragClient::dragIconWindowExposeEvent(GtkWidget* widget, GdkEventExpose* event) +void DragClient::drawDragIconWindow(GtkWidget* widget, cairo_t* context) { - PlatformRefPtr<cairo_t> context = adoptPlatformRef(gdk_cairo_create(event->window)); - cairo_rectangle(context.get(), 0, 0, + cairo_rectangle(context, 0, 0, cairo_image_surface_get_width(m_dragImage.get()), cairo_image_surface_get_height(m_dragImage.get())); - cairo_set_operator(context.get(), CAIRO_OPERATOR_SOURCE); - cairo_set_source_surface(context.get(), m_dragImage.get(), 0, 0); - cairo_fill(context.get()); + cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(context, m_dragImage.get(), 0, 0); + cairo_fill(context); } DragImageRef DragClient::createDragImageForLink(KURL&, const String&, Frame*) |