Bug 167512

Summary: mouse over icon (open in new window) shows as a black shadow
Product: [Applications] konqueror Reporter: Kishore <kitts.mailinglists>
Component: khtmlAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: christophe
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: shows a back shape when there should have been an icon

Description Kishore 2008-07-27 08:09:07 UTC
Version:            (using 4.1.60 (KDE 4.1.60 (KDE 4.2 >= 20080709)), compiled sources)
Compiler:          gcc
OS:                Linux (x86_64) release 2.6.24-20-generic

In recent times there was a feature introduced where an icon would be shown when hovering over a link that would open in a new window. From recent builds from SVN this icon only shows as a black area of the shape of the icon. This is the case even with mailto:links
Comment 1 Kishore 2008-07-27 08:10:08 UTC
Created attachment 26427 [details]
shows a back shape when there should have been an icon
Comment 2 Christophe Marin 2008-07-27 10:09:00 UTC
Confirmed (rev. 838173)
Comment 3 Maksim Orlovich 2008-07-28 01:49:34 UTC
It seems like Qt no longer handles the background texture brush. If I just use QLabel instead, if fixes the blackness, but the mask is messed up!
Comment 4 Maksim Orlovich 2008-07-28 02:07:59 UTC
Well, this gets it to work:
+++ khtmlview.cpp       (working copy)                             
@@ -410,7 +410,7 @@
     bool accessKeysPreActivate;
     CompletedState emitCompletedAfterRepaint;

-    QWidget* cursor_icon_widget;
+    QLabel* cursor_icon_widget;

     // scrolling activated by MMB
     short m_mouseScroll_byX;
@@ -1459,22 +1459,20 @@

         if( !d->cursor_icon_widget ) {
 #ifdef Q_WS_X11
-            d->cursor_icon_widget = new QWidget( 0, Qt::X11BypassWindowManagerHint );
+            d->cursor_icon_widget = new QLabel( 0, Qt::X11BypassWindowManagerHint );
             XSetWindowAttributes attr;
             attr.save_under = True;
             XChangeWindowAttributes( QX11Info::display(), d->cursor_icon_widget->winId(), CWSaveUnder, &attr );
 #else
-            d->cursor_icon_widget = new QWidget( NULL, NULL );
+            d->cursor_icon_widget = new QLabel( NULL, NULL );
             //TODO
 #endif
             d->cursor_icon_widget->resize( icon_pixmap.width(), icon_pixmap.height());
             if( !icon_pixmap.mask().isNull() )
-                d->cursor_icon_widget->setMask( icon_pixmap.mask());
+                d->cursor_icon_widget->setMask( icon_pixmap.createMaskFromColor(Qt::transparent));
             else
                 d->cursor_icon_widget->clearMask();
-            QPalette palette;
-            palette.setBrush( d->cursor_icon_widget->backgroundRole(), QBrush( icon_pixmap ) );
-            d->cursor_icon_widget->setPalette( palette );
+            d->cursor_icon_widget->setPixmap( icon_pixmap);
             d->cursor_icon_widget->update();
         }
         QPoint c_pos = QCursor::pos();

... But it's inefficient. The reason ::mask doesn't work is that the boundary buffers are semi-transparent, so they get clipped away.. Will improve performance and commit..
Comment 5 Maksim Orlovich 2008-07-28 02:52:08 UTC
SVN commit 838505 by orlovich:

Fix a bunch of issues with sub-cursor link type indicator:
1) Don't make it all black --- seems like Qt doesn't like texture brushes anymore.
2) Fix mask setting --- default mask constructions cuts away all pixels with non-0xff alpha.
And no, this isn't less efficient --- ::mask recomputes all the time anyway.
3) Actually change the icon when needed. As a bonus, we don't bug kiconloader all the time while the cursor is wiggling 
over a link

Also, be evil, and sanify the variable name. 
BUG: 167512  


 M  +41 -48    khtmlview.cpp  
 M  +1 -1      khtmlview.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=838505
Comment 6 Kishore 2008-07-30 17:05:12 UTC
Wonderful. Looks fine now. Thanks!