[vlc-commits] commit: skins2(X11): add icon to vlc (Erwan Tulou )

git at videolan.org git at videolan.org
Wed Oct 6 15:57:22 CEST 2010


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Wed Oct  6 10:51:31 2010 +0200| [7e7ead5d37667ea3016bc2d355b57958d9ef93e2] | committer: Erwan Tulou 

skins2(X11): add icon to vlc

this should fix https://bugs.launchpad.net/ubuntu/+source/vlc/+bug/521850
Tested successfully with compiz and metacity

Todo: adapt configure.ac to ensure XPM is available for skins2 (as done with mozilla)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7e7ead5d37667ea3016bc2d355b57958d9ef93e2
---

 configure.ac                           |    2 +-
 modules/gui/skins2/x11/x11_display.cpp |   26 +++++++++++++++++++++++++-
 modules/gui/skins2/x11/x11_window.cpp  |    8 ++++++++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9525a30..c719676 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3688,7 +3688,7 @@ if test "${enable_skins2}" = "yes" ||
     ALIASES="${ALIASES} svlc"
     VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 ${X_CFLAGS} -DX11_SKINS])
     VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
-    VLC_ADD_LIBS([skins2],[${X_LIBS} ${X_PRE_LIBS} -lXext -lX11])
+    VLC_ADD_LIBS([skins2],[${X_LIBS} ${X_PRE_LIBS} -lXext -lXpm -lX11])
     need_xid_provider="no"
   fi fi fi
 fi
diff --git a/modules/gui/skins2/x11/x11_display.cpp b/modules/gui/skins2/x11/x11_display.cpp
index 84b0305..1b489e6 100644
--- a/modules/gui/skins2/x11/x11_display.cpp
+++ b/modules/gui/skins2/x11/x11_display.cpp
@@ -26,11 +26,14 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#include <X11/xpm.h>
 #include <X11/extensions/shape.h>
 
 #include "x11_display.hpp"
 #include "../src/logger.hpp"
 
+#include "../../../share/icons/32x32/vlc.xpm"
+
 template<class type> type X11Display::putPixel(type r, type g, type b) const
 {
     return ( (r >> m_redRightShift)   << m_redLeftShift   ) |
@@ -237,6 +240,28 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
         // Change the window title
         XStoreName( m_pDisplay, m_mainWindow, "VLC Media Player" );
 
+        // Add an icon
+        Pixmap icon_pixmap, shape_pixmap;
+        int ret = XpmCreatePixmapFromData( m_pDisplay, root, (char**)vlc_xpm,
+                                           &icon_pixmap, &shape_pixmap, NULL );
+        if( ret == XpmSuccess )
+        {
+            XWMHints *wm = XAllocWMHints();
+            if( wm )
+            {
+                wm->icon_pixmap = icon_pixmap;
+                wm->icon_mask = shape_pixmap;
+                wm->flags = (IconPixmapHint|IconMaskHint);
+
+                XSetWMHints( m_pDisplay, m_mainWindow, wm );
+                XFree( wm );
+            }
+        }
+        else
+        {
+            msg_Err( getIntf(), "icon failed to be loaded (err=%i)", ret );
+        }
+
         // Receive map notify events
         XSelectInput( m_pDisplay, m_mainWindow, StructureNotifyMask );
 
@@ -461,5 +486,4 @@ unsigned long X11Display::getPixelValue( uint8_t r, uint8_t g, uint8_t b )
     return m_pixelSize==1 ? 255 - value : value;
 }
 
-
 #endif
diff --git a/modules/gui/skins2/x11/x11_window.cpp b/modules/gui/skins2/x11/x11_window.cpp
index 64fa4ae..bc2c6eb 100644
--- a/modules/gui/skins2/x11/x11_window.cpp
+++ b/modules/gui/skins2/x11/x11_window.cpp
@@ -165,6 +165,14 @@ X11Window::X11Window( intf_thread_t *pIntf, GenericWindow &rWindow,
     classhint.res_class = (char*) "Vlc";
     XSetClassHint( XDISPLAY, m_wnd, &classhint );
 
+    // copies WM_HINTS from the main window
+    XWMHints *wm = XGetWMHints( XDISPLAY, m_rDisplay.getMainWindow() );
+    if( wm )
+    {
+        XSetWMHints( XDISPLAY, m_wnd, wm );
+        XFree( wm );
+    }
+
     // initialize WM_CLIENT_MACHINE
     char* hostname = NULL;
     long host_name_max = sysconf( _SC_HOST_NAME_MAX );



More information about the vlc-commits mailing list