< prev index next >

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

Print this page




 188             jio_fprintf(stderr, "X connection to %s host broken (explicit kill or server shutdown)\n", XDisplayName(NULL));
 189         }
 190         /*SignalError(lockedee->lastpc, lockedee, "fp/ade/gui/GUIException", "I/O error"); */
 191     }
 192     return 0;
 193 }
 194 
 195 static AwtGraphicsConfigDataPtr
 196 findWithTemplate(XVisualInfo *vinfo,
 197                  long mask)
 198 {
 199 
 200     XVisualInfo *visualList;
 201     XColor color;
 202     AwtGraphicsConfigDataPtr defaultConfig;
 203     int visualsMatched, i;
 204 
 205     visualList = XGetVisualInfo(awt_display,
 206                                 mask, vinfo, &visualsMatched);
 207     if (visualList) {


 208         defaultConfig = ZALLOC(_AwtGraphicsConfigData);
 209         for (i = 0; i < visualsMatched; i++) {
 210             memcpy(&defaultConfig->awt_visInfo, &visualList[i], sizeof(XVisualInfo));
 211             defaultConfig->awt_depth = visualList[i].depth;
 212 
 213             /* we can't use awtJNI_CreateColorData here, because it'll pull,
 214                SystemColor, which in turn will cause toolkit to be reinitialized */
 215             if (awtCreateX11Colormap(defaultConfig)) {












 216                 /* Allocate white and black pixels for this visual */
 217                 color.flags = DoRed | DoGreen | DoBlue;
 218                 color.red = color.green = color.blue = 0x0000;
 219                 XAllocColor(awt_display, defaultConfig->awt_cmap, &color);
 220                 x11Screens[visualList[i].screen].blackpixel = color.pixel;
 221                 color.flags = DoRed | DoGreen | DoBlue;
 222                 color.red = color.green = color.blue = 0xffff;
 223                 XAllocColor(awt_display, defaultConfig->awt_cmap, &color);
 224                 x11Screens[visualList[i].screen].whitepixel = color.pixel;
 225 
 226                 XFree(visualList);
 227                 return defaultConfig;
 228             }
 229         }
 230         XFree(visualList);
 231         free((void *)defaultConfig);
 232     }
 233     return NULL;
 234 }
 235 
 236 /* default config is based on X11 screen.  All Xinerama screens of that X11
 237    screen will have the same default config */
 238 /* Need more notes about which fields of the structure are based on the X
 239    screen, and which are based on the Xinerama screen */
 240 static AwtGraphicsConfigDataPtr
 241 makeDefaultConfig(JNIEnv *env, int screen) {
 242 
 243     AwtGraphicsConfigDataPtr defaultConfig;
 244     int xinawareScreen = 0;
 245     VisualID forcedVisualID = 0, defaultVisualID;
 246     char *forcedVisualStr;
 247     XVisualInfo vinfo;
 248     long mask;




 188             jio_fprintf(stderr, "X connection to %s host broken (explicit kill or server shutdown)\n", XDisplayName(NULL));
 189         }
 190         /*SignalError(lockedee->lastpc, lockedee, "fp/ade/gui/GUIException", "I/O error"); */
 191     }
 192     return 0;
 193 }
 194 
 195 static AwtGraphicsConfigDataPtr
 196 findWithTemplate(XVisualInfo *vinfo,
 197                  long mask)
 198 {
 199 
 200     XVisualInfo *visualList;
 201     XColor color;
 202     AwtGraphicsConfigDataPtr defaultConfig;
 203     int visualsMatched, i;
 204 
 205     visualList = XGetVisualInfo(awt_display,
 206                                 mask, vinfo, &visualsMatched);
 207     if (visualList) {
 208         int id = -1;
 209         VisualID defaultVisual = XVisualIDFromVisual(DefaultVisual(awt_display, vinfo->screen));
 210         defaultConfig = ZALLOC(_AwtGraphicsConfigData);
 211         for (i = 0; i < visualsMatched; i++) {
 212             memcpy(&defaultConfig->awt_visInfo, &visualList[i], sizeof(XVisualInfo));
 213             defaultConfig->awt_depth = visualList[i].depth;
 214 
 215             /* we can't use awtJNI_CreateColorData here, because it'll pull,
 216                SystemColor, which in turn will cause toolkit to be reinitialized */
 217             if (awtCreateX11Colormap(defaultConfig)) {
 218                 if (visualList[i].visualid == defaultVisual) {
 219                     id = i;
 220                     break;
 221                 } else if (-1 == id) {
 222                     // Keep 1st match for fallback
 223                     id = i;
 224                 }
 225             }
 226         }
 227         if (-1 != id) {
 228             memcpy(&defaultConfig->awt_visInfo, &visualList[id], sizeof(XVisualInfo));
 229             defaultConfig->awt_depth = visualList[id].depth;
 230             /* Allocate white and black pixels for this visual */
 231             color.flags = DoRed | DoGreen | DoBlue;
 232             color.red = color.green = color.blue = 0x0000;
 233             XAllocColor(awt_display, defaultConfig->awt_cmap, &color);
 234             x11Screens[visualList[id].screen].blackpixel = color.pixel;
 235             color.flags = DoRed | DoGreen | DoBlue;
 236             color.red = color.green = color.blue = 0xffff;
 237             XAllocColor(awt_display, defaultConfig->awt_cmap, &color);
 238             x11Screens[visualList[id].screen].whitepixel = color.pixel;
 239 
 240             XFree(visualList);
 241             return defaultConfig;

 242         }
 243         XFree(visualList);
 244         free((void *)defaultConfig);
 245     }
 246     return NULL;
 247 }
 248 
 249 /* default config is based on X11 screen.  All Xinerama screens of that X11
 250    screen will have the same default config */
 251 /* Need more notes about which fields of the structure are based on the X
 252    screen, and which are based on the Xinerama screen */
 253 static AwtGraphicsConfigDataPtr
 254 makeDefaultConfig(JNIEnv *env, int screen) {
 255 
 256     AwtGraphicsConfigDataPtr defaultConfig;
 257     int xinawareScreen = 0;
 258     VisualID forcedVisualID = 0, defaultVisualID;
 259     char *forcedVisualStr;
 260     XVisualInfo vinfo;
 261     long mask;


< prev index next >