Bug 71162 - When dragging a URL link with an image, the image is pasted and not the link URL
Summary: When dragging a URL link with an image, the image is pasted and not the link URL
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: unspecified
Platform: Mandrake RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-24 02:06 UTC by Manuel Mejia
Modified: 2004-03-17 14:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch-71162-1.diff (2.37 KB, text/x-diff)
2004-03-16 23:36 UTC, Dawit Alemayehu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Mejia 2003-12-24 02:06:01 UTC
Version:            (using KDE KDE 3.1.94)
Installed from:    Mandrake RPMs

In previous versions of Konqueror (pre 3.1.93), you could drag a link from one Konqueror window to a second Konqueror window and that link would open in the second window.  Now, if you that link is displaying an image, the image is opened instead of the underlying link. 

Example:

http://slashdot.org - Near the top there is an icon of a yellow Mandrake star.  The URL for the underlying link is http://slashdot.org/search.pl?topic=147 , and the URL for the icon is http://images.slashdot.org/topics/topicmandrake.gif.

I preferred the old behaviour where I could drag that icon into a new page and it would open up the URL "http://slashdot.org/search.pl?topic=147" and not the icon.

If this is new behaviour is intended, is there a workaround for dragging links between Konqueror windows?

I also notice this behaviour when dragging from Konqueror to Konsole.  I get a popup menu where the options are "paste", "cp", "mv".  However, what gets copied is URL for the icon.
Comment 1 Michael Rolf 2004-02-10 16:43:29 UTC
Due to this bug it's now impossible to download the linked data by dragging it to an DownloadManager like KGet or D4X  (gentoo and KDE 3.2.0).

For me it's a main feature that I can easily use a DownloadManager, so I wait for a khtml fix and switched in the meantime to Mozilla as default browser, because Mozilla still worked well with this.

Michael
Comment 2 edfardos 2004-02-10 21:01:51 UTC
ditto here - showed up in beta2 afaict - makes it (nearly) impossible to use
download managers like kget.  I should have mentioned it then - this 
behavior is still evident in kde3.2.

edfardos(@yahoo.com)
Comment 3 edfardos 2004-02-10 21:31:46 UTC
It's in khtml_part.cpp (kdelibs), line 5349, comment "// Image inside a link?".
That condition is never met, it's treated like a "// Normal image" (confirmed
with debugging printfs).

--edfardos
Comment 4 Wilbert Berendsen 2004-03-10 11:43:35 UTC
This bug causes also the grave bug #65553 in KMail!
Comment 5 Dawit Alemayehu 2004-03-16 23:36:26 UTC
Hi,

The attached patch is intended to address the regression with dragging links 
and images as described in these reports. Please test...



Created an attachment (id=5246)
patch-71162-1.diff
Comment 6 Steffen Schwientek 2004-03-17 01:33:33 UTC
After applying the patch, drag&drop is working properly here (actual cvs, gentoo distribution)

Steffen
Comment 7 Dawit Alemayehu 2004-03-17 14:17:36 UTC
CVS commit by adawit: 

Backport:
- Regression fix for BR# 71162 & BR# 65553.
- Set the suggested filename if available when prompting user to save files.

CCMAIL: 71162-done@bugs.kde.org
CCMAIL: 65553-done@bugs.kde.org


  M +19 -17    khtml_part.cpp   1.959.2.9


--- kdelibs/khtml/khtml_part.cpp  #1.959.2.8:1.959.2.9
@@ -3777,9 +3777,13 @@ bool KHTMLPart::processObjectRequest( kh
     if ( child->m_type != khtml::ChildFrame::Object )
     {
+      QString suggestedFilename;
+      if ( child->m_run )
+        suggestedFilename = child->m_run->suggestedFilename();
+
       KParts::BrowserRun::AskSaveResult res = KParts::BrowserRun::askEmbedOrSave(
-        url, mimetype/*, suggestedFilename */ );
+        url, mimetype, suggestedFilename  );
       switch( res ) {
       case KParts::BrowserRun::Save:
-        KHTMLPopupGUIClient::saveURL( widget(), i18n( "Save As" ), url, child->m_args.metaData(), QString::null, 0 /*, suggestedFilename */ );
+        KHTMLPopupGUIClient::saveURL( widget(), i18n( "Save As" ), url, child->m_args.metaData(), QString::null, 0, suggestedFilename);
         // fall-through
       case KParts::BrowserRun::Cancel:
@@ -5364,4 +5368,9 @@ void KHTMLPart::khtmlMouseMoveEvent( kht
     d->m_bRightMousePressed = false;
   }
+
+  DOM::DOMString url = event->url();
+  DOM::DOMString target = event->target();
+  DOM::Node innerNode = event->innerNode();
+
 #ifndef QT_NO_DRAGANDDROP
   if( d->m_bDnd && d->m_bMousePressed &&
@@ -5375,21 +5384,18 @@ void KHTMLPart::khtmlMouseMoveEvent( kht
     QDragObject *drag = 0;
     KURL u;
-    if ( d->m_mousePressNode.handle() && d->m_mousePressNode.handle()->id() == ID_IMG )
+
+    // qDebug("****************** Event URL: %s", url.string().latin1());
+    // qDebug("****************** Event Target: %s", target.string().latin1());
+
+    // Normal image...
+    if ( url.length() == 0 && innerNode.handle() && innerNode.handle()->id() == ID_IMG )
     {
-      // Normal image
-      img = static_cast<HTMLImageElementImpl *>(d->m_mousePressNode.handle());
+      img = static_cast<HTMLImageElementImpl *>(innerNode.handle());
       u = KURL( completeURL( khtml::parseURL(img->getAttribute(ATTR_SRC)).string() ) );
       pix = KMimeType::mimeType("image/png")->pixmap(KIcon::Desktop);
     }
-    else if ( event->innerNode().handle() && event->innerNode().handle()->id() == ID_IMG )
-    {
-      // Image inside a link?
-      img = static_cast<HTMLImageElementImpl *>(event->innerNode().handle());
-      u = completeURL( d->m_strSelectedURL );
-      pix = KMimeType::mimeType("image/png")->pixmap(KIcon::Desktop);
-    }
     else
     {
-      // Text link
+      // Text or image link...
       u = completeURL( d->m_strSelectedURL );
       pix = KMimeType::pixmapForURL(u, 0, KIcon::Desktop, KIcon::SizeMedium);
@@ -5423,8 +5429,4 @@ void KHTMLPart::khtmlMouseMoveEvent( kht
 #endif
 
-  DOM::DOMString url = event->url();
-  DOM::DOMString target = event->target();
-  DOM::Node innerNode = event->innerNode();
-
   // Not clicked -> mouse over stuff
   if ( !d->m_bMousePressed )