jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c
changeset 41793 7b9c71553d63
parent 41107 567f832618d7
child 44150 022f5ba40098
equal deleted inserted replaced
41792:8b032394d44e 41793:7b9c71553d63
  1665 typedef XRROutputInfo * (*XRRGetOutputInfoType)(Display *dpy,
  1665 typedef XRROutputInfo * (*XRRGetOutputInfoType)(Display *dpy,
  1666                                 XRRScreenResources *resources, RROutput output);
  1666                                 XRRScreenResources *resources, RROutput output);
  1667 
  1667 
  1668 typedef void (*XRRFreeOutputInfoType)(XRROutputInfo *outputInfo);
  1668 typedef void (*XRRFreeOutputInfoType)(XRROutputInfo *outputInfo);
  1669 
  1669 
       
  1670 typedef XRRCrtcInfo* (*XRRGetCrtcInfoType)(Display *dpy,
       
  1671                                     XRRScreenResources *resources, RRCrtc crtc);
       
  1672 
       
  1673 typedef void (*XRRFreeCrtcInfoType)(XRRCrtcInfo *crtcInfo);
       
  1674 
  1670 static XRRQueryVersionType               awt_XRRQueryVersion;
  1675 static XRRQueryVersionType               awt_XRRQueryVersion;
  1671 static XRRGetScreenInfoType              awt_XRRGetScreenInfo;
  1676 static XRRGetScreenInfoType              awt_XRRGetScreenInfo;
  1672 static XRRFreeScreenConfigInfoType       awt_XRRFreeScreenConfigInfo;
  1677 static XRRFreeScreenConfigInfoType       awt_XRRFreeScreenConfigInfo;
  1673 static XRRConfigRatesType                awt_XRRConfigRates;
  1678 static XRRConfigRatesType                awt_XRRConfigRates;
  1674 static XRRConfigCurrentRateType          awt_XRRConfigCurrentRate;
  1679 static XRRConfigCurrentRateType          awt_XRRConfigCurrentRate;
  1678 static XRRConfigRotationsType            awt_XRRConfigRotations;
  1683 static XRRConfigRotationsType            awt_XRRConfigRotations;
  1679 static XRRGetScreenResourcesType         awt_XRRGetScreenResources;
  1684 static XRRGetScreenResourcesType         awt_XRRGetScreenResources;
  1680 static XRRFreeScreenResourcesType        awt_XRRFreeScreenResources;
  1685 static XRRFreeScreenResourcesType        awt_XRRFreeScreenResources;
  1681 static XRRGetOutputInfoType              awt_XRRGetOutputInfo;
  1686 static XRRGetOutputInfoType              awt_XRRGetOutputInfo;
  1682 static XRRFreeOutputInfoType             awt_XRRFreeOutputInfo;
  1687 static XRRFreeOutputInfoType             awt_XRRFreeOutputInfo;
       
  1688 static XRRGetCrtcInfoType                awt_XRRGetCrtcInfo;
       
  1689 static XRRFreeCrtcInfoType               awt_XRRFreeCrtcInfo;
  1683 
  1690 
  1684 #define LOAD_XRANDR_FUNC(f) \
  1691 #define LOAD_XRANDR_FUNC(f) \
  1685     do { \
  1692     do { \
  1686         awt_##f = (f##Type)dlsym(pLibRandR, #f); \
  1693         awt_##f = (f##Type)dlsym(pLibRandR, #f); \
  1687         if (awt_##f == NULL) { \
  1694         if (awt_##f == NULL) { \
  1753     LOAD_XRANDR_FUNC(XRRConfigRotations);
  1760     LOAD_XRANDR_FUNC(XRRConfigRotations);
  1754     LOAD_XRANDR_FUNC(XRRGetScreenResources);
  1761     LOAD_XRANDR_FUNC(XRRGetScreenResources);
  1755     LOAD_XRANDR_FUNC(XRRFreeScreenResources);
  1762     LOAD_XRANDR_FUNC(XRRFreeScreenResources);
  1756     LOAD_XRANDR_FUNC(XRRGetOutputInfo);
  1763     LOAD_XRANDR_FUNC(XRRGetOutputInfo);
  1757     LOAD_XRANDR_FUNC(XRRFreeOutputInfo);
  1764     LOAD_XRANDR_FUNC(XRRFreeOutputInfo);
       
  1765     LOAD_XRANDR_FUNC(XRRGetCrtcInfo);
       
  1766     LOAD_XRANDR_FUNC(XRRFreeCrtcInfo);
  1758 
  1767 
  1759     return JNI_TRUE;
  1768     return JNI_TRUE;
  1760 }
  1769 }
  1761 
  1770 
  1762 static jobject
  1771 static jobject
  1893     XRRScreenConfiguration *config;
  1902     XRRScreenConfiguration *config;
  1894     jobject displayMode = NULL;
  1903     jobject displayMode = NULL;
  1895 
  1904 
  1896     AWT_LOCK();
  1905     AWT_LOCK();
  1897 
  1906 
  1898     if (screen < ScreenCount(awt_display)) {
  1907     if (usingXinerama && XScreenCount(awt_display) > 0) {
       
  1908         XRRScreenResources *res = awt_XRRGetScreenResources(awt_display,
       
  1909                                                     RootWindow(awt_display, 0));
       
  1910         if (res) {
       
  1911             if (res->noutput > screen) {
       
  1912                 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
       
  1913                                                      res, res->outputs[screen]);
       
  1914                 if (output_info) {
       
  1915                     if (output_info->crtc) {
       
  1916                         XRRCrtcInfo *crtc_info =
       
  1917                                     awt_XRRGetCrtcInfo (awt_display, res,
       
  1918                                                         output_info->crtc);
       
  1919                         if (crtc_info) {
       
  1920                             if (crtc_info->mode) {
       
  1921                                 int i;
       
  1922                                 for (i = 0; i < res->nmode; i++) {
       
  1923                                     XRRModeInfo *mode = &res->modes[i];
       
  1924                                     if (mode->id == crtc_info->mode) {
       
  1925                                         float rate = 0;
       
  1926                                         if (mode->hTotal && mode->vTotal) {
       
  1927                                              rate = ((float)mode->dotClock /
       
  1928                                                     ((float)mode->hTotal *
       
  1929                                                     (float)mode->vTotal));
       
  1930                                         }
       
  1931                                         displayMode = X11GD_CreateDisplayMode(
       
  1932                                                            env,
       
  1933                                                            mode->width,
       
  1934                                                            mode->height,
       
  1935                                                            BIT_DEPTH_MULTI,
       
  1936                                                            (int)(rate +.2));
       
  1937                                         break;
       
  1938                                     }
       
  1939                                 }
       
  1940                             }
       
  1941                             awt_XRRFreeCrtcInfo(crtc_info);
       
  1942                         }
       
  1943                     }
       
  1944                     awt_XRRFreeOutputInfo(output_info);
       
  1945                 }
       
  1946             }
       
  1947             awt_XRRFreeScreenResources(res);
       
  1948         }
       
  1949     } else {
  1899 
  1950 
  1900         config = awt_XRRGetScreenInfo(awt_display,
  1951         config = awt_XRRGetScreenInfo(awt_display,
  1901                                       RootWindow(awt_display, screen));
  1952                                       RootWindow(awt_display, screen));
  1902         if (config != NULL) {
  1953         if (config != NULL) {
  1903             Rotation rotation;
  1954             Rotation rotation;
  1952            if (res->noutput > screen) {
  2003            if (res->noutput > screen) {
  1953                 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
  2004                 XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display,
  1954                                                      res, res->outputs[screen]);
  2005                                                      res, res->outputs[screen]);
  1955                 if (output_info) {
  2006                 if (output_info) {
  1956                     int i;
  2007                     int i;
  1957                     for (i = 0; i < res->nmode; i++) {
  2008                     for (i = 0; i < output_info->nmode; i++) {
  1958                         RRMode m = output_info->modes[i];
  2009                         RRMode m = output_info->modes[i];
  1959                         int j;
  2010                         int j;
  1960                         XRRModeInfo *mode;
  2011                         XRRModeInfo *mode;
  1961                         for (j = 0; j < res->nmode; j++) {
  2012                         for (j = 0; j < res->nmode; j++) {
  1962                             mode = &res->modes[j];
  2013                             mode = &res->modes[j];