summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 01:13:11 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 01:13:11 +0000
commit8fa18a33d2dee21f748139ef503d08ebb4b706af (patch)
treeeb69b882d33b06f9a82fd0d90ffcc29a8a2884f8 /chrome/browser/gtk
parent7cebf25a2c487e8a2428142b260f443bf6107fcf (diff)
downloadchromium_src-8fa18a33d2dee21f748139ef503d08ebb4b706af.zip
chromium_src-8fa18a33d2dee21f748139ef503d08ebb4b706af.tar.gz
chromium_src-8fa18a33d2dee21f748139ef503d08ebb4b706af.tar.bz2
Basic DragImage implementation.
Only the chromium part is for review. The webkit part shows how that will look when I create the patch for webkit later. This can be landed without the change to webkit. TODO later: - use the image on windows, mac - implement the other DragImageRef functions TEST=drag an image from the render view in GTK BUG=11457 Review URL: http://codereview.chromium.org/668125 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/notifications/balloon_view_host_gtk.h4
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.cc15
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.h11
3 files changed, 27 insertions, 3 deletions
diff --git a/chrome/browser/gtk/notifications/balloon_view_host_gtk.h b/chrome/browser/gtk/notifications/balloon_view_host_gtk.h
index 0c40864..4bcd5b4 100644
--- a/chrome/browser/gtk/notifications/balloon_view_host_gtk.h
+++ b/chrome/browser/gtk/notifications/balloon_view_host_gtk.h
@@ -79,7 +79,9 @@ class BalloonViewHost : public RenderViewHostDelegate,
const gfx::Rect& initial_pos) {}
virtual void ShowContextMenu(const ContextMenuParams& params) {}
virtual void StartDragging(const WebDropData& drop_data,
- WebKit::WebDragOperationsMask allowed_ops) {}
+ WebKit::WebDragOperationsMask allowed_ops,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) {}
virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {}
virtual void GotFocus() {}
virtual void TakeFocus(bool reverse) {}
diff --git a/chrome/browser/gtk/tab_contents_drag_source.cc b/chrome/browser/gtk/tab_contents_drag_source.cc
index 85ebe0c..45f0f1f 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.cc
+++ b/chrome/browser/gtk/tab_contents_drag_source.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "app/gfx/gtk_util.h"
#include "app/gtk_dnd_util.h"
#include "base/file_util.h"
#include "base/mime_util.h"
@@ -69,7 +70,9 @@ TabContents* TabContentsDragSource::tab_contents() const {
}
void TabContentsDragSource::StartDragging(const WebDropData& drop_data,
- GdkEventButton* last_mouse_down) {
+ GdkEventButton* last_mouse_down,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) {
int targets_mask = 0;
if (!drop_data.plain_text.empty())
@@ -98,6 +101,8 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data,
}
drop_data_.reset(new WebDropData(drop_data));
+ drag_image_ = image;
+ image_offset_ = image_offset;
GtkTargetList* list = gtk_dnd_util::GetTargetListFromCodeMask(targets_mask);
if (targets_mask & gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS) {
@@ -303,6 +308,14 @@ void TabContentsDragSource::OnDragBegin(GdkDragContext* drag_context) {
generated_download_file_name.value().c_str()),
generated_download_file_name.value().length());
}
+
+ if (!drag_image_.isNull()) {
+ GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&drag_image_);
+ gtk_drag_set_icon_pixbuf(drag_context, pixbuf,
+ image_offset_.x(), image_offset_.y());
+ // Let the drag take ownership.
+ g_object_unref(pixbuf);
+ }
}
void TabContentsDragSource::OnDragEnd(GdkDragContext* drag_context,
diff --git a/chrome/browser/gtk/tab_contents_drag_source.h b/chrome/browser/gtk/tab_contents_drag_source.h
index edef7ad..35693e9 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.h
+++ b/chrome/browser/gtk/tab_contents_drag_source.h
@@ -10,9 +10,11 @@
#include "app/gfx/native_widget_types.h"
#include "base/basictypes.h"
#include "base/file_path.h"
+#include "base/gfx/point.h"
#include "base/message_loop.h"
#include "base/string16.h"
#include "googleurl/src/gurl.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h"
class TabContents;
@@ -31,7 +33,9 @@ class TabContentsDragSource : public MessageLoopForUI::Observer {
// Starts a drag for the tab contents this TabContentsDragSource was
// created for.
void StartDragging(const WebDropData& drop_data,
- GdkEventButton* last_mouse_down);
+ GdkEventButton* last_mouse_down,
+ const SkBitmap& image,
+ const gfx::Point& image_offset);
// MessageLoop::Observer implementation:
virtual void WillProcessEvent(GdkEvent* event);
@@ -79,6 +83,11 @@ class TabContentsDragSource : public MessageLoopForUI::Observer {
// view). Non-NULL iff there is a current drag.
scoped_ptr<WebDropData> drop_data_;
+ // The image used for depicting the drag, and the offset between the cursor
+ // and the top left pixel.
+ SkBitmap drag_image_;
+ gfx::Point image_offset_;
+
// The mime type for the file contents of the current drag (if any).
GdkAtom drag_file_mime_type_;