Alexandre Julliard : winex11: Set the NET_WM_ICON hint for 32-bpp icons.

Alexandre Julliard julliard at winehq.org
Fri Apr 16 10:56:04 CDT 2010


Module: wine
Branch: master
Commit: ea1d71c7a4f8001df0221e67855d07744b14560d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ea1d71c7a4f8001df0221e67855d07744b14560d

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Apr 16 16:23:33 2010 +0200

winex11: Set the NET_WM_ICON hint for 32-bpp icons.

---

 dlls/winex11.drv/window.c      |   44 ++++++++++++++++++++++++++++++++++++---
 dlls/winex11.drv/x11drv.h      |    1 +
 dlls/winex11.drv/x11drv_main.c |    1 +
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index a9a3769..559f1d8 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -835,22 +835,58 @@ static void set_icon_hints( Display *display, struct x11drv_win_data *data, HICO
     {
         HBITMAP hbmOrig;
         RECT rcMask;
-        BITMAP bmMask;
+        BITMAP bm;
         ICONINFO ii;
         HDC hDC;
 
         GetIconInfo(hIcon, &ii);
 
-        GetObjectA(ii.hbmMask, sizeof(bmMask), &bmMask);
+        GetObjectW(ii.hbmMask, sizeof(bm), &bm);
         rcMask.top    = 0;
         rcMask.left   = 0;
-        rcMask.right  = bmMask.bmWidth;
-        rcMask.bottom = bmMask.bmHeight;
+        rcMask.right  = bm.bmWidth;
+        rcMask.bottom = bm.bmHeight;
 
         hDC = CreateCompatibleDC(0);
         hbmOrig = SelectObject(hDC, ii.hbmMask);
         InvertRect(hDC, &rcMask);
         SelectObject(hDC, ii.hbmColor);  /* force the color bitmap to x11drv mode too */
+
+        GetObjectW(ii.hbmColor, sizeof(bm), &bm);
+        if (bm.bmBitsPixel == 32)  /* FIXME: do this for other depths too */
+        {
+            BITMAPINFO info;
+            unsigned int size, *bits;
+
+            info.bmiHeader.biSize = sizeof(info);
+            info.bmiHeader.biWidth = bm.bmWidth;
+            info.bmiHeader.biHeight = -bm.bmHeight;
+            info.bmiHeader.biPlanes = 1;
+            info.bmiHeader.biBitCount = 32;
+            info.bmiHeader.biCompression = BI_RGB;
+            info.bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4;
+            info.bmiHeader.biXPelsPerMeter = 0;
+            info.bmiHeader.biYPelsPerMeter = 0;
+            info.bmiHeader.biClrUsed = 0;
+            info.bmiHeader.biClrImportant = 0;
+            size = bm.bmWidth * bm.bmHeight + 2;
+            bits = HeapAlloc( GetProcessHeap(), 0, size * sizeof(long) );
+            if (bits && GetDIBits( hDC, ii.hbmColor, 0, bm.bmHeight, bits + 2, &info, DIB_RGB_COLORS ))
+            {
+                bits[0] = bm.bmWidth;
+                bits[1] = bm.bmHeight;
+                if (sizeof(long) > sizeof(int))  /* convert to array of longs */
+                {
+                    int i = size;
+                    while (--i >= 0) ((unsigned long *)bits)[i] = bits[i];
+                }
+                wine_tsx11_lock();
+                XChangeProperty( display, data->whole_window, x11drv_atom(_NET_WM_ICON),
+                                 XA_CARDINAL, 32, PropModeReplace, (unsigned char *)bits, size );
+                wine_tsx11_unlock();
+            }
+            HeapFree( GetProcessHeap(), 0, bits );
+        }
         SelectObject(hDC, hbmOrig);
         DeleteDC(hDC);
 
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index ed6d3e0..a062e92 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -641,6 +641,7 @@ enum x11drv_atoms
     XATOM__NET_SUPPORTED,
     XATOM__NET_SYSTEM_TRAY_OPCODE,
     XATOM__NET_SYSTEM_TRAY_S0,
+    XATOM__NET_WM_ICON,
     XATOM__NET_WM_MOVERESIZE,
     XATOM__NET_WM_NAME,
     XATOM__NET_WM_PID,
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index a7f7ae0..7b4fb58 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -138,6 +138,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
     "_NET_SUPPORTED",
     "_NET_SYSTEM_TRAY_OPCODE",
     "_NET_SYSTEM_TRAY_S0",
+    "_NET_WM_ICON",
     "_NET_WM_MOVERESIZE",
     "_NET_WM_NAME",
     "_NET_WM_PID",




More information about the wine-cvs mailing list