< prev index next >

src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c

Print this page




 121  * operation on both OSes.  Until then, some of the Xinerama-related code
 122  * is ifdef'd appropriately.  -bchristi, 7/12/01
 123  */
 124 
 125 #define MAXFRAMEBUFFERS 16
 126 #if defined(__linux__) || defined(MACOSX)
 127 typedef struct {
 128    int   screen_number;
 129    short x_org;
 130    short y_org;
 131    short width;
 132    short height;
 133 } XineramaScreenInfo;
 134 
 135 typedef XineramaScreenInfo* XineramaQueryScreensFunc(Display*, int*);
 136 
 137 #else /* SOLARIS */
 138 typedef Status XineramaGetInfoFunc(Display* display, int screen_number,
 139          XRectangle* framebuffer_rects, unsigned char* framebuffer_hints,
 140          int* num_framebuffers);
 141 typedef Status XineramaGetCenterHintFunc(Display* display, int screen_number,
 142                                          int* x, int* y);
 143 
 144 XineramaGetCenterHintFunc* XineramaSolarisCenterFunc = NULL;
 145 #endif
 146 
 147 Bool usingXinerama = False;
 148 XRectangle fbrects[MAXFRAMEBUFFERS];
 149 
 150 JNIEXPORT void JNICALL
 151 Java_sun_awt_X11GraphicsConfig_initIDs (JNIEnv *env, jclass cls)
 152 {
 153     x11GraphicsConfigIDs.aData = NULL;
 154     x11GraphicsConfigIDs.bitsPerPixel = NULL;
 155     x11GraphicsConfigIDs.screen = NULL;
 156 
 157     x11GraphicsConfigIDs.aData = (*env)->GetFieldID (env, cls, "aData", "J");
 158     CHECK_NULL(x11GraphicsConfigIDs.aData);
 159     x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I");
 160     CHECK_NULL(x11GraphicsConfigIDs.bitsPerPixel);
 161     x11GraphicsConfigIDs.screen = (*env)->GetFieldID (env, cls, "screen", "Lsun/awt/X11GraphicsDevice;");
 162     CHECK_NULL(x11GraphicsConfigIDs.screen);
 163 
 164     if (x11GraphicsConfigIDs.aData == NULL ||


 628             } else {
 629                 DTRACE_PRINTLN("calling XineramaQueryScreens didn't work");
 630             }
 631         } else {
 632             DTRACE_PRINTLN("couldn't load XineramaQueryScreens symbol");
 633         }
 634         dlclose(libHandle);
 635     } else {
 636         DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror());
 637     }
 638 }
 639 #endif
 640 #if !defined(__linux__) && !defined(MACOSX) /* Solaris */
 641 static void xinerama_init_solaris()
 642 {
 643     void* libHandle = NULL;
 644     unsigned char fbhints[MAXFRAMEBUFFERS];
 645     int32_t locNumScr = 0;
 646     /* load and run XineramaGetInfo */
 647     char* XineramaGetInfoName = "XineramaGetInfo";
 648     char* XineramaGetCenterHintName = "XineramaGetCenterHint";
 649     XineramaGetInfoFunc* XineramaSolarisFunc = NULL;
 650 
 651     /* load library */
 652     libHandle = dlopen(JNI_LIB_NAME("Xext"), RTLD_LAZY | RTLD_GLOBAL);
 653     if (libHandle != NULL) {
 654         XineramaSolarisFunc = (XineramaGetInfoFunc*)dlsym(libHandle, XineramaGetInfoName);
 655         XineramaSolarisCenterFunc =
 656             (XineramaGetCenterHintFunc*)dlsym(libHandle, XineramaGetCenterHintName);
 657 
 658         if (XineramaSolarisFunc != NULL) {
 659             DTRACE_PRINTLN("calling XineramaGetInfo func on Solaris");
 660             if ((*XineramaSolarisFunc)(awt_display, 0, &fbrects[0],
 661                                        &fbhints[0], &locNumScr) != 0 &&
 662                 locNumScr > XScreenCount(awt_display))
 663             {
 664                 DTRACE_PRINTLN("Enabling Xinerama support");
 665                 usingXinerama = True;
 666                 /* set global number of screens */
 667                 DTRACE_PRINTLN1(" num screens = %i\n", locNumScr);
 668                 awt_numScreens = locNumScr;
 669             } else {
 670                 DTRACE_PRINTLN("calling XineramaGetInfo didn't work");
 671             }
 672         } else {
 673             DTRACE_PRINTLN("couldn't load XineramaGetInfo symbol");
 674         }
 675         dlclose(libHandle);
 676     } else {
 677         DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror());


1572     }
1573 #endif /* !HEADLESS */
1574 }
1575 
1576 /*
1577  * Class:     sun_awt_X11GraphicsEnvironment
1578  * Method:    pRunningXinerama
1579  * Signature: ()Z
1580  */
1581 JNIEXPORT jboolean JNICALL
1582 Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama(JNIEnv *env,
1583     jobject this)
1584 {
1585 #ifdef HEADLESS
1586     return JNI_FALSE;
1587 #else
1588     return usingXinerama ? JNI_TRUE : JNI_FALSE;
1589 #endif /* HEADLESS */
1590 }
1591 
1592 /*
1593  * Can return NULL.
1594  *
1595  * Class:     sun_awt_X11GraphicsEnvironment
1596  * Method:    getXineramaCenterPoint
1597  * Signature: ()Ljava/awt/Point
1598  */
1599 JNIEXPORT jobject JNICALL
1600 Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint(JNIEnv *env,
1601     jobject this)
1602 {
1603     jobject point = NULL;
1604 #ifndef HEADLESS    /* return NULL in HEADLESS, Linux */
1605 #if !defined(__linux__) && !defined(MACOSX)
1606     int x,y;
1607 
1608     AWT_LOCK();
1609     DASSERT(usingXinerama);
1610     if (XineramaSolarisCenterFunc != NULL) {
1611         (XineramaSolarisCenterFunc)(awt_display, 0, &x, &y);
1612         point = JNU_NewObjectByName(env, "java/awt/Point","(II)V", x, y);
1613         DASSERT(point);
1614     } else {
1615         DTRACE_PRINTLN("unable to call XineramaSolarisCenterFunc: symbol is null");
1616     }
1617     AWT_FLUSH_UNLOCK();
1618 #endif /* __linux __ || MACOSX */
1619 #endif /* HEADLESS */
1620     return point;
1621 }
1622 
1623 
1624 /**
1625  * Begin DisplayMode/FullScreen support
1626  */
1627 
1628 #ifndef HEADLESS
1629 
1630 #ifndef NO_XRANDR
1631 
1632 #define BIT_DEPTH_MULTI java_awt_DisplayMode_BIT_DEPTH_MULTI
1633 #define REFRESH_RATE_UNKNOWN java_awt_DisplayMode_REFRESH_RATE_UNKNOWN
1634 
1635 typedef Status
1636     (*XRRQueryVersionType) (Display *dpy, int *major_versionp, int *minor_versionp);
1637 typedef XRRScreenConfiguration*
1638     (*XRRGetScreenInfoType)(Display *dpy, Drawable root);
1639 typedef void
1640     (*XRRFreeScreenConfigInfoType)(XRRScreenConfiguration *config);
1641 typedef short*
1642     (*XRRConfigRatesType)(XRRScreenConfiguration *config,
1643                           int sizeID, int *nrates);




 121  * operation on both OSes.  Until then, some of the Xinerama-related code
 122  * is ifdef'd appropriately.  -bchristi, 7/12/01
 123  */
 124 
 125 #define MAXFRAMEBUFFERS 16
 126 #if defined(__linux__) || defined(MACOSX)
 127 typedef struct {
 128    int   screen_number;
 129    short x_org;
 130    short y_org;
 131    short width;
 132    short height;
 133 } XineramaScreenInfo;
 134 
 135 typedef XineramaScreenInfo* XineramaQueryScreensFunc(Display*, int*);
 136 
 137 #else /* SOLARIS */
 138 typedef Status XineramaGetInfoFunc(Display* display, int screen_number,
 139          XRectangle* framebuffer_rects, unsigned char* framebuffer_hints,
 140          int* num_framebuffers);




 141 #endif
 142 
 143 Bool usingXinerama = False;
 144 XRectangle fbrects[MAXFRAMEBUFFERS];
 145 
 146 JNIEXPORT void JNICALL
 147 Java_sun_awt_X11GraphicsConfig_initIDs (JNIEnv *env, jclass cls)
 148 {
 149     x11GraphicsConfigIDs.aData = NULL;
 150     x11GraphicsConfigIDs.bitsPerPixel = NULL;
 151     x11GraphicsConfigIDs.screen = NULL;
 152 
 153     x11GraphicsConfigIDs.aData = (*env)->GetFieldID (env, cls, "aData", "J");
 154     CHECK_NULL(x11GraphicsConfigIDs.aData);
 155     x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I");
 156     CHECK_NULL(x11GraphicsConfigIDs.bitsPerPixel);
 157     x11GraphicsConfigIDs.screen = (*env)->GetFieldID (env, cls, "screen", "Lsun/awt/X11GraphicsDevice;");
 158     CHECK_NULL(x11GraphicsConfigIDs.screen);
 159 
 160     if (x11GraphicsConfigIDs.aData == NULL ||


 624             } else {
 625                 DTRACE_PRINTLN("calling XineramaQueryScreens didn't work");
 626             }
 627         } else {
 628             DTRACE_PRINTLN("couldn't load XineramaQueryScreens symbol");
 629         }
 630         dlclose(libHandle);
 631     } else {
 632         DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror());
 633     }
 634 }
 635 #endif
 636 #if !defined(__linux__) && !defined(MACOSX) /* Solaris */
 637 static void xinerama_init_solaris()
 638 {
 639     void* libHandle = NULL;
 640     unsigned char fbhints[MAXFRAMEBUFFERS];
 641     int32_t locNumScr = 0;
 642     /* load and run XineramaGetInfo */
 643     char* XineramaGetInfoName = "XineramaGetInfo";

 644     XineramaGetInfoFunc* XineramaSolarisFunc = NULL;
 645 
 646     /* load library */
 647     libHandle = dlopen(JNI_LIB_NAME("Xext"), RTLD_LAZY | RTLD_GLOBAL);
 648     if (libHandle != NULL) {
 649         XineramaSolarisFunc = (XineramaGetInfoFunc*)dlsym(libHandle, XineramaGetInfoName);



 650         if (XineramaSolarisFunc != NULL) {
 651             DTRACE_PRINTLN("calling XineramaGetInfo func on Solaris");
 652             if ((*XineramaSolarisFunc)(awt_display, 0, &fbrects[0],
 653                                        &fbhints[0], &locNumScr) != 0 &&
 654                 locNumScr > XScreenCount(awt_display))
 655             {
 656                 DTRACE_PRINTLN("Enabling Xinerama support");
 657                 usingXinerama = True;
 658                 /* set global number of screens */
 659                 DTRACE_PRINTLN1(" num screens = %i\n", locNumScr);
 660                 awt_numScreens = locNumScr;
 661             } else {
 662                 DTRACE_PRINTLN("calling XineramaGetInfo didn't work");
 663             }
 664         } else {
 665             DTRACE_PRINTLN("couldn't load XineramaGetInfo symbol");
 666         }
 667         dlclose(libHandle);
 668     } else {
 669         DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror());


1564     }
1565 #endif /* !HEADLESS */
1566 }
1567 
1568 /*
1569  * Class:     sun_awt_X11GraphicsEnvironment
1570  * Method:    pRunningXinerama
1571  * Signature: ()Z
1572  */
1573 JNIEXPORT jboolean JNICALL
1574 Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama(JNIEnv *env,
1575     jobject this)
1576 {
1577 #ifdef HEADLESS
1578     return JNI_FALSE;
1579 #else
1580     return usingXinerama ? JNI_TRUE : JNI_FALSE;
1581 #endif /* HEADLESS */
1582 }
1583 
































1584 /**
1585  * Begin DisplayMode/FullScreen support
1586  */
1587 
1588 #ifndef HEADLESS
1589 
1590 #ifndef NO_XRANDR
1591 
1592 #define BIT_DEPTH_MULTI java_awt_DisplayMode_BIT_DEPTH_MULTI
1593 #define REFRESH_RATE_UNKNOWN java_awt_DisplayMode_REFRESH_RATE_UNKNOWN
1594 
1595 typedef Status
1596     (*XRRQueryVersionType) (Display *dpy, int *major_versionp, int *minor_versionp);
1597 typedef XRRScreenConfiguration*
1598     (*XRRGetScreenInfoType)(Display *dpy, Drawable root);
1599 typedef void
1600     (*XRRFreeScreenConfigInfoType)(XRRScreenConfiguration *config);
1601 typedef short*
1602     (*XRRConfigRatesType)(XRRScreenConfiguration *config,
1603                           int sizeID, int *nrates);


< prev index next >