Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2377

Icon in system tray looks ugly if ARGB is used

XMLWordPrintable

      Changing "templ.depth" (variable in the code below) to 16 or 24 works fine.
      To reproduce, create an icon called some "someicon.png" and run the following code:

      #include <QtGui>
      #include <X11/extensions/Xrender.h>
      
      int main( int argc, char * argv[] )
      {
          Colormap colormap = 0;
          Visual * visual = 0;
          int eventBase, errorBase;
          Display * dpy = XOpenDisplay( 0 );
          int screen = DefaultScreen( dpy );
      
          if ( XRenderQueryExtension( dpy, & eventBase, & errorBase) )
          {
              int nvi;
              XVisualInfo templ;
              templ.screen  = screen;
              templ.depth   = 32; // CHANGE TO 16 OR 24 IN ORDER TO WORK WELL
              templ.c_class = TrueColor;
              XVisualInfo * xvi
                  = XGetVisualInfo( dpy, VisualScreenMask | VisualDepthMask
                                         | VisualClassMask, & templ, & nvi );
      
            for ( int i = 0; i < nvi; ++i )
            {
                XRenderPictFormat * format
                    = XRenderFindVisualFormat( dpy, xvi[i].visual );
                if ( format->type == PictTypeDirect && format->direct.alphaMask )
                {
                    visual = xvi[i].visual;
                    colormap = XCreateColormap( dpy, RootWindow( dpy, screen ),
                                                visual, AllocNone);
                    break;
                }
            }
          }
      
          QApplication app( dpy, argc, argv,
                            Qt::HANDLE( visual ), Qt::HANDLE( colormap ) );
          QSystemTrayIcon tray;
          tray.setIcon( QPixmap( "someicon.png") );
          tray.show();
          return app.exec();
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            dzyubenk Denis Dzyubenko (Inactive)
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes