mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
x11: Set icon issue fix
Signed-off-by: Vinzenz Feenstra <evilissimo@gmail.com>
This commit is contained in:
parent
c12a8e922f
commit
bfafcb4664
@ -1210,20 +1210,17 @@ void OS_X11::swap_buffers() {
|
|||||||
|
|
||||||
|
|
||||||
void OS_X11::set_icon(const Image& p_icon) {
|
void OS_X11::set_icon(const Image& p_icon) {
|
||||||
|
|
||||||
//does not work, if anyone knows why, please fix
|
|
||||||
if (!p_icon.empty()) {
|
if (!p_icon.empty()) {
|
||||||
|
|
||||||
Image img=p_icon;
|
Image img=p_icon;
|
||||||
img.convert(Image::FORMAT_RGBA);
|
img.convert(Image::FORMAT_RGBA);
|
||||||
|
|
||||||
|
|
||||||
int w = img.get_width();
|
int w = img.get_width();
|
||||||
int h = img.get_height();
|
int h = img.get_height();
|
||||||
|
|
||||||
Vector<long> pd;
|
// We're using size_t to have wordsize (32Bit build -> 32 Bits, 64 Bit build -> 64 Bits
|
||||||
|
Vector<size_t> pd;
|
||||||
|
|
||||||
pd.resize((2+w*h)*sizeof(long));
|
pd.resize(2+w*h);
|
||||||
|
|
||||||
print_line("***** SET ICON ***** "+itos(w)+" "+itos(h));
|
print_line("***** SET ICON ***** "+itos(w)+" "+itos(h));
|
||||||
|
|
||||||
@ -1232,23 +1229,17 @@ void OS_X11::set_icon(const Image& p_icon) {
|
|||||||
|
|
||||||
DVector<uint8_t>::Read r = img.get_data().read();
|
DVector<uint8_t>::Read r = img.get_data().read();
|
||||||
|
|
||||||
long *wr=(long*)&pd[2];
|
size_t * wr = &pd[2];
|
||||||
|
uint8_t const * pr = r.ptr();
|
||||||
|
|
||||||
for(int i=0;i<w*h;i++) {
|
for(int i=0;i<w*h;i++) {
|
||||||
|
size_t v=0;
|
||||||
uint32_t v=0;
|
// A R G B
|
||||||
v|=r[i*4+3];
|
v|=pr[3] << 24 | pr[0] << 16 | pr[1] << 8 | pr[2];
|
||||||
v<<=8;
|
*wr++=v;
|
||||||
v|=r[i*4+0];
|
pr += 4;
|
||||||
v<<=8;
|
|
||||||
v|=r[i*4+1];
|
|
||||||
v<<=8;
|
|
||||||
v|=r[i*4+2];
|
|
||||||
wr[i]=v;
|
|
||||||
}
|
}
|
||||||
|
XChangeProperty(x11_display, x11_window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (uint8_t*) pd.ptr(), pd.size());
|
||||||
XChangeProperty(x11_display, x11_window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) pd.ptr(),
|
|
||||||
(2+w*h));
|
|
||||||
} else {
|
} else {
|
||||||
XDeleteProperty(x11_display, x11_window, net_wm_icon);
|
XDeleteProperty(x11_display, x11_window, net_wm_icon);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user