< prev index next >

src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c

Print this page




 736 SplashScreenThread(void *param) {
 737     Splash *splash = (Splash *) param;
 738 //    pthread_key_t key;
 739 
 740 //    pthread_key_create(&key, SplashPThreadDestructor);
 741 //    pthread_setspecific(key, splash);
 742 
 743     SplashLock(splash);
 744     pipe(splash->controlpipe);
 745     fcntl(splash->controlpipe[0], F_SETFL,
 746         fcntl(splash->controlpipe[0], F_GETFL, 0) | O_NONBLOCK);
 747     splash->time = SplashTime();
 748     SplashCreateWindow(splash);
 749     fflush(stdout);
 750     if (splash->window) {
 751         SplashRemoveDecoration(splash);
 752         XStoreName(splash->display, splash->window, "Java");
 753         XMapRaised(splash->display, splash->window);
 754         SplashUpdateShape(splash);
 755         SplashRedrawWindow(splash);



 756         SplashEventLoop(splash);
 757     }
 758     SplashUnlock(splash);
 759     SplashDone(splash);
 760 
 761     splash->isVisible=-1;
 762     return 0;
 763 }
 764 
 765 void
 766 SplashCreateThread(Splash * splash) {
 767     pthread_t thr;
 768     pthread_attr_t attr;
 769     int rc;
 770 
 771     pthread_attr_init(&attr);
 772     rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash);
 773 }
 774 
 775 void


 789 
 790 void
 791 SplashUpdate(Splash * splash) {
 792     sendctl(splash, SPLASHCTL_UPDATE);
 793 }
 794 
 795 void
 796 SplashReconfigure(Splash * splash) {
 797     sendctl(splash, SPLASHCTL_RECONFIGURE);
 798 }
 799 
 800 SPLASHEXPORT jboolean
 801 SplashGetScaledImageName(const char* jarName, const char* fileName,
 802                            float *scaleFactor, char *scaledImgName,
 803                            const size_t scaledImageNameLength)
 804 {
 805     *scaleFactor = 1;
 806 #ifndef __linux__
 807     return JNI_FALSE;
 808 #endif
 809     *scaleFactor = getNativeScaleFactor();
 810     if (*scaleFactor == 2.0) {
 811         size_t length = 0;
 812         char *stringToAppend = ".java-scale2x";
 813         char *dupFileName = strdup(fileName);
 814         char *fileExtension = strrchr(dupFileName, '.');
 815         if (fileExtension == NULL) {
 816             length = strlen(dupFileName) + strlen(stringToAppend) + 1;
 817             if (length > scaledImageNameLength) {
 818                 *scaleFactor = 1;
 819                 free(dupFileName);
 820                 return JNI_FALSE;
 821             }
 822             int retVal = snprintf(scaledImgName, length, "%s%s",
 823                 dupFileName, stringToAppend);
 824             if (retVal < 0 || (retVal != length - 1)) {
 825                 free(dupFileName);
 826                 *scaleFactor = 1;
 827                 return JNI_FALSE;
 828             }
 829         } else {
 830             int length_without_ext = fileExtension - dupFileName;
 831             length = length_without_ext +
 832                 strlen(stringToAppend) + strlen(fileExtension) + 1;
 833             if (length > scaledImageNameLength) {
 834                 *scaleFactor = 1;
 835                 free(dupFileName);
 836                 return JNI_FALSE;
 837             }
 838             int retVal = snprintf(scaledImgName, length, "%.*s%s%s",
 839                 length_without_ext, dupFileName, stringToAppend, fileExtension);
 840             if (retVal < 0 || retVal != length - 1) {
 841                 free(dupFileName);
 842                 *scaleFactor = 1;
 843                 return JNI_FALSE;
 844             }
 845         }
 846         free(dupFileName);
 847         FILE *fp;
 848         if (!(fp = fopen(scaledImgName, "r"))) {
 849             *scaleFactor = 1;
 850             return JNI_FALSE;
 851         }
 852         fclose(fp);
 853         return JNI_TRUE;
 854     }
 855     return JNI_FALSE;
 856 }


 736 SplashScreenThread(void *param) {
 737     Splash *splash = (Splash *) param;
 738 //    pthread_key_t key;
 739 
 740 //    pthread_key_create(&key, SplashPThreadDestructor);
 741 //    pthread_setspecific(key, splash);
 742 
 743     SplashLock(splash);
 744     pipe(splash->controlpipe);
 745     fcntl(splash->controlpipe[0], F_SETFL,
 746         fcntl(splash->controlpipe[0], F_GETFL, 0) | O_NONBLOCK);
 747     splash->time = SplashTime();
 748     SplashCreateWindow(splash);
 749     fflush(stdout);
 750     if (splash->window) {
 751         SplashRemoveDecoration(splash);
 752         XStoreName(splash->display, splash->window, "Java");
 753         XMapRaised(splash->display, splash->window);
 754         SplashUpdateShape(splash);
 755         SplashRedrawWindow(splash);
 756         //map the splash co-ordinates as per system scale
 757         splash->x /= splash->scaleFactor;
 758         splash->y /= splash->scaleFactor;
 759         SplashEventLoop(splash);
 760     }
 761     SplashUnlock(splash);
 762     SplashDone(splash);
 763 
 764     splash->isVisible=-1;
 765     return 0;
 766 }
 767 
 768 void
 769 SplashCreateThread(Splash * splash) {
 770     pthread_t thr;
 771     pthread_attr_t attr;
 772     int rc;
 773 
 774     pthread_attr_init(&attr);
 775     rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash);
 776 }
 777 
 778 void


 792 
 793 void
 794 SplashUpdate(Splash * splash) {
 795     sendctl(splash, SPLASHCTL_UPDATE);
 796 }
 797 
 798 void
 799 SplashReconfigure(Splash * splash) {
 800     sendctl(splash, SPLASHCTL_RECONFIGURE);
 801 }
 802 
 803 SPLASHEXPORT jboolean
 804 SplashGetScaledImageName(const char* jarName, const char* fileName,
 805                            float *scaleFactor, char *scaledImgName,
 806                            const size_t scaledImageNameLength)
 807 {
 808     *scaleFactor = 1;
 809 #ifndef __linux__
 810     return JNI_FALSE;
 811 #endif
 812     *scaleFactor = getNativeScaleFactor(NULL);
 813     return GetScaledImageName(fileName, scaledImgName, scaleFactor, scaledImageNameLength);













































 814 }
< prev index next >