@@ -611,6 +611,93 @@ void setXorgClassHint(const video::SExposedVideoData &video_data,
611
611
#endif
612
612
}
613
613
614
+ bool setXorgWindowIcon (IrrlichtDevice *device,
615
+ const std::string &icon_file)
616
+ {
617
+ #ifdef XORG_USED
618
+
619
+ video::IVideoDriver *v_driver = device->getVideoDriver ();
620
+
621
+ video::IImageLoader *image_loader = NULL ;
622
+ for (u32 i = v_driver->getImageLoaderCount () - 1 ; i >= 0 ; i--) {
623
+ if (v_driver->getImageLoader (i)->isALoadableFileExtension (icon_file.c_str ())) {
624
+ image_loader = v_driver->getImageLoader (i);
625
+ break ;
626
+ }
627
+ }
628
+
629
+ if (!image_loader) {
630
+ warningstream << " Could not find image loader for file '"
631
+ << icon_file << " '" << std::endl;
632
+ return false ;
633
+ }
634
+
635
+ io::IReadFile *icon_f = device->getFileSystem ()->createAndOpenFile (icon_file.c_str ());
636
+
637
+ if (!icon_f) {
638
+ warningstream << " Could not load icon file '"
639
+ << icon_file << " '" << std::endl;
640
+ return false ;
641
+ }
642
+
643
+ video::IImage *img = image_loader->loadImage (icon_f);
644
+
645
+ if (!img) {
646
+ warningstream << " Could not load icon file '"
647
+ << icon_file << " '" << std::endl;
648
+ icon_f->drop ();
649
+ return false ;
650
+ }
651
+
652
+ u32 height = img->getDimension ().Height ;
653
+ u32 width = img->getDimension ().Width ;
654
+
655
+ size_t icon_buffer_len = 2 + height * width;
656
+ long *icon_buffer = new long [icon_buffer_len];
657
+
658
+ icon_buffer[0 ] = width;
659
+ icon_buffer[1 ] = height;
660
+
661
+ for (u32 x = 0 ; x < width; x++) {
662
+ for (u32 y = 0 ; y < height; y++) {
663
+ video::SColor col = img->getPixel (x, y);
664
+ long pixel_val = 0 ;
665
+ pixel_val |= (u8)col.getAlpha () << 24 ;
666
+ pixel_val |= (u8)col.getRed () << 16 ;
667
+ pixel_val |= (u8)col.getGreen () << 8 ;
668
+ pixel_val |= (u8)col.getBlue ();
669
+ icon_buffer[2 + x + y * width] = pixel_val;
670
+ }
671
+ }
672
+
673
+ img->drop ();
674
+ icon_f->drop ();
675
+
676
+ const video::SExposedVideoData &video_data = v_driver->getExposedVideoData ();
677
+
678
+ Display *x11_dpl = (Display *)video_data.OpenGLLinux .X11Display ;
679
+
680
+ if (x11_dpl == NULL ) {
681
+ warningstream << " Could not find x11 display for setting its icon."
682
+ << std::endl;
683
+ delete [] icon_buffer;
684
+ return false ;
685
+ }
686
+
687
+ Window x11_win = (Window)video_data.OpenGLLinux .X11Window ;
688
+
689
+ Atom net_wm_icon = XInternAtom (x11_dpl, " _NET_WM_ICON" , False);
690
+ Atom cardinal = XInternAtom (x11_dpl, " CARDINAL" , False);
691
+ XChangeProperty (x11_dpl, x11_win,
692
+ net_wm_icon, cardinal, 32 ,
693
+ PropModeReplace, (const unsigned char *)icon_buffer,
694
+ icon_buffer_len);
695
+
696
+ delete [] icon_buffer;
697
+
698
+ return true ;
699
+ #endif
700
+ }
614
701
615
702
// //
616
703
// // Video/Display Information (Client-only)
1 commit comments
est31 commentedon Jul 16, 2016
No, i think its a bug I've missed with this commit. See #4323