]>
git.saurik.com Git - wxWidgets.git/blob - src/unix/utilsx11.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/unix/utilsx11.cpp
3 // Purpose: Miscellaneous X11 functions
4 // Author: Mattia Barbon
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__WXX11__) || defined(__WXGTK__) || defined(__WXMOTIF__)
14 #include "wx/unix/utilsx11.h"
15 #include "wx/iconbndl.h"
20 #pragma message disable nosimpint
23 #include <X11/Xatom.h>
25 #pragma message enable nosimpint
28 void wxSetIconsX11( WXDisplay
* display
, WXWindow window
,
29 const wxIconBundle
& ib
)
33 size_t i
, max
= ib
.m_icons
.GetCount();
35 for( i
= 0; i
< max
; ++i
)
36 if( ib
.m_icons
[i
].Ok() )
37 size
+= 2 + ib
.m_icons
[i
].GetWidth() * ib
.m_icons
[i
].GetHeight();
39 Atom net_wm_icon
= XInternAtom( (Display
*)display
, "_NET_WM_ICON", 0 );
43 wxUint32
* data
= new wxUint32
[size
];
46 for( i
= 0; i
< max
; ++i
)
48 const wxImage image
= ib
.m_icons
[i
].ConvertToImage();
49 int width
= image
.GetWidth(), height
= image
.GetHeight();
50 unsigned char* imageData
= image
.GetData();
51 unsigned char* imageDataEnd
= imageData
+ ( width
* height
* 3 );
52 bool hasMask
= image
.HasMask();
53 unsigned char rMask
, gMask
, bMask
;
54 unsigned char r
, g
, b
, a
;
58 rMask
= image
.GetMaskRed();
59 gMask
= image
.GetMaskGreen();
60 bMask
= image
.GetMaskBlue();
62 else // no mask, but still init the variables to avoid warnings
72 while( imageData
< imageDataEnd
) {
76 if( hasMask
&& r
== rMask
&& g
== gMask
&& b
== bMask
)
81 *ptr
++ = ( a
<< 24 ) | ( r
<< 16 ) | ( g
<< 8 ) | b
;
87 XChangeProperty( (Display
*)display
,
92 (unsigned char*)data
, size
);
97 XDeleteProperty( (Display
*)display
,