1245
1257
/* initialize the X11 device driver data structures. */
1247
1259
if (!displayOpen) {
1260
/* Bill Dunlap sees an error when tunneling to a non-existent
1261
X11 connection that BDR cannot reproduce. We leave a handler set
1262
if we get an error, but that is rare.
1265
strncpy(dspname, p, 101);
1266
dspname[100] = '\0';
1267
old = XSetIOErrorHandler(R_X11IOErrSimple);
1248
1268
if ((display = XOpenDisplay(p)) == NULL) {
1269
XSetIOErrorHandler(old);
1249
1270
warning(_("unable to open connection to X11 display '%s'"), p);
1273
XSetIOErrorHandler(old);
1252
1274
DisplayOpened = TRUE;
1253
1275
Rf_setX11Display(display, gamma_fac, colormodel, maxcube, TRUE);
1254
1276
displayOpen = TRUE;
1255
1277
if(xd->handleOwnEvents == FALSE)
1256
1278
addInputHandler(R_InputHandlers, ConnectionNumber(display),
1257
1279
R_ProcessX11Events, XActivity);
1280
} else if(strcmp(p, dspname))
1281
warning(_("ignoring 'display' argument as an X11 device is already open"));
1259
1282
whitepixel = GetX11Pixel(R_RED(canvascolor), R_GREEN(canvascolor),
1260
1283
R_BLUE(canvascolor));
1261
1284
blackpixel = GetX11Pixel(0, 0, 0);
1326
1349
app_con = XtCreateApplicationContext();
1327
1350
XtAppSetFallbackResources(app_con, x_fallback_resources);
1328
xtdpy = XtOpenDisplay(app_con, dsp, "r_x11", "R_x11",
1351
xtdpy = XtOpenDisplay(app_con, dspname, "r_x11", "R_x11",
1329
1352
NULL, 0, &zero, NULL);
1330
toplevel = XtAppCreateShell(NULL, "R_x11",
1331
applicationShellWidgetClass,
1333
XtGetApplicationResources(toplevel, (XtPointer) &xdev,
1337
if (xdev.geometry != NULL) {
1341
sprintf(gstr, "%dx%d+%d+%d", hint->width,
1342
hint->height, hint->x, hint->y);
1343
bitmask = XWMGeometry(display, DefaultScreen(display),
1344
xdev.geometry, gstr,
1348
&hint->width, &hint->height,
1349
&hint->win_gravity);
1351
if (bitmask & (XValue | YValue))
1352
hint->flags |= USPosition;
1353
if (bitmask & (WidthValue | HeightValue))
1354
hint->flags |= USSize;
1355
/* Restore user-specified settings */
1356
if(xpos != NA_INTEGER)
1357
hint->x = (xpos >= 0) ? xpos :
1358
DisplayWidth(display, screen) - iw + xpos;
1359
if(ypos != NA_INTEGER)
1360
hint->y = (ypos >= 0)? ypos :
1361
DisplayHeight(display, screen) - iw - ypos;
1362
if(!ISNA(w)) hint->width = iw;
1363
if(!ISNA(h)) hint->height = ih;
1354
toplevel = XtAppCreateShell(NULL, "R_x11",
1355
applicationShellWidgetClass,
1357
XtGetApplicationResources(toplevel, (XtPointer) &xdev,
1361
if (xdev.geometry != NULL) {
1365
sprintf(gstr, "%dx%d+%d+%d", hint->width,
1366
hint->height, hint->x, hint->y);
1367
bitmask = XWMGeometry(display, DefaultScreen(display),
1368
xdev.geometry, gstr,
1372
&hint->width, &hint->height,
1373
&hint->win_gravity);
1375
if (bitmask & (XValue | YValue))
1376
hint->flags |= USPosition;
1377
if (bitmask & (WidthValue | HeightValue))
1378
hint->flags |= USSize;
1379
/* Restore user-specified settings */
1380
if(xpos != NA_INTEGER)
1381
hint->x = (xpos >= 0) ? xpos :
1382
DisplayWidth(display, screen) - iw + xpos;
1383
if(ypos != NA_INTEGER)
1384
hint->y = (ypos >= 0)? ypos :
1385
DisplayHeight(display, screen) - iw - ypos;
1386
if(!ISNA(w)) hint->width = iw;
1387
if(!ISNA(h)) hint->height = ih;
1389
XtDestroyWidget(toplevel);
1390
XtCloseDisplay(xtdpy);
1392
warning(_("unable to obtain information on display '%s'"),
1365
XtDestroyWidget(toplevel);
1366
XtCloseDisplay(xtdpy);
1367
1395
XtDestroyApplicationContext(app_con);
2526
2554
R_CheckDeviceAvailable();
2527
2555
BEGIN_SUSPEND_INTERRUPTS {
2528
2556
/* Allocate and initialize the device driver data */
2529
if (!(dev = (pDevDesc) calloc(1, sizeof(NewDevDesc)))) return;
2557
if (!(dev = (pDevDesc) calloc(1, sizeof(DevDesc)))) return;
2530
2558
if (!X11DeviceDriver(dev, display, width, height,
2531
2559
ps, gamma, colormodel, maxcubesize,
2532
2560
bgcolor, canvascolor, sfonts, res,
3135
3169
BEGIN_SUSPEND_INTERRUPTS {
3137
3171
/* Allocate and initialize the device driver data */
3138
if (!(dev = (pDevDesc) calloc(1, sizeof(NewDevDesc)))) return 0;
3172
if (!(dev = (pDevDesc) calloc(1, sizeof(DevDesc)))) return 0;
3139
3173
if (!BMDeviceDriver(dev, devtable[type].gtype, filename, quality,
3140
3174
width, height, pointsize,
3141
3175
bgcolor, res, antialias)) {