summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 15:24:41 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 15:24:41 +0000
commitc27ae599b03a7c30a65c843a8aed99a9e94d284e (patch)
treedd7a3413fbd5d46b3d9e102b2249c817ef2f9b9a /chrome/browser/gtk
parentb490de133b26e30f8fc5429ff666107cdfdcc117 (diff)
downloadchromium_src-c27ae599b03a7c30a65c843a8aed99a9e94d284e.zip
chromium_src-c27ae599b03a7c30a65c843a8aed99a9e94d284e.tar.gz
chromium_src-c27ae599b03a7c30a65c843a8aed99a9e94d284e.tar.bz2
Retry r41799:
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 The problem was an incorrect method signature in RenderView. Review URL: http://codereview.chromium.org/1037008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41953 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.cc14
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.h11
3 files changed, 26 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 22e8cda..de71a41 100644
--- a/chrome/browser/gtk/notifications/balloon_view_host_gtk.h
+++ b/chrome/browser/gtk/notifications/balloon_view_host_gtk.h
@@ -80,7 +80,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 081feb5..6d9ca4c 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.cc
+++ b/chrome/browser/gtk/tab_contents_drag_source.cc
@@ -70,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())
@@ -99,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) {
@@ -304,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 aa0216e..7740ee6 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.h
+++ b/chrome/browser/gtk/tab_contents_drag_source.h
@@ -9,10 +9,12 @@
#include "base/basictypes.h"
#include "base/file_path.h"
+#include "base/gfx/point.h"
#include "base/message_loop.h"
#include "base/string16.h"
#include "gfx/native_widget_types.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_;