Unified · Split
| @@ -12,8 +12,6 @@ · 11 unmodified lines | |||
| 12 | 12 | ||
| 13 | #include <termios.h> | 13 | #include <termios.h> |
| 14 | 14 | ||
| 15 | #define argv0 "drawterm" | ||
| 16 | |||
| 17 | typedef struct Cursor Cursor; | 15 | typedef struct Cursor Cursor; |
| 18 | 16 | ||
| 19 | #undef long | 17 | #undef long |
| @@ -327,7 +325,6 @@ xinitscreen(void) · 307 unmodified lines | |||
| 327 | Memimage *gscreen; | 325 | Memimage *gscreen; |
| 328 | int i, xsize, ysize; | 326 | int i, xsize, ysize; |
| 329 | char *argv[2]; | 327 | char *argv[2]; |
| 330 | char *disp_val; | ||
| 331 | Window rootwin; | 328 | Window rootwin; |
| 332 | Rectangle r; | 329 | Rectangle r; |
| 333 | XWMHints hints; | 330 | XWMHints hints; |
| @@ -346,11 +343,8 @@ xinitscreen(void) · 12 unmodified lines | |||
| 346 | xdrawable = 0; | 343 | xdrawable = 0; |
| 347 | 344 | ||
| 348 | xdisplay = XOpenDisplay(NULL); | 345 | xdisplay = XOpenDisplay(NULL); |
| 349 | if(xdisplay == 0){ | 346 | if(xdisplay == 0) |
| 350 | iprint("xinitscreen: XOpenDisplay: %r [DISPLAY=%s]\n", | 347 | panic("XOpenDisplay: %r [DISPLAY=%s]", getenv("DISPLAY")); |
| 351 | getenv("DISPLAY")); | ||
| 352 | exit(0); | ||
| 353 | } | ||
| 354 | 348 | ||
| 355 | XSetErrorHandler(shutup); | 349 | XSetErrorHandler(shutup); |
| 356 | XSetIOErrorHandler(panicshutup); | 350 | XSetIOErrorHandler(panicshutup); |
| @@ -373,13 +367,13 @@ xinitscreen(void) · 16 unmodified lines | |||
| 373 | else if(XMatchVisualInfo(xdisplay, rootscreennum, 8, PseudoColor, &xvi) | 367 | else if(XMatchVisualInfo(xdisplay, rootscreennum, 8, PseudoColor, &xvi) |
| 374 | || XMatchVisualInfo(xdisplay, rootscreennum, 8, StaticColor, &xvi)){ | 368 | || XMatchVisualInfo(xdisplay, rootscreennum, 8, StaticColor, &xvi)){ |
| 375 | if(xscreendepth > 8) | 369 | if(xscreendepth > 8) |
| 376 | panic("drawterm: can't deal with colormapped depth %d screens\n", xscreendepth); | 370 | panic("can't deal with colormapped depth %d screens", xscreendepth); |
| 377 | xvis = xvi.visual; | 371 | xvis = xvi.visual; |
| 378 | xscreendepth = 8; | 372 | xscreendepth = 8; |
| 379 | } | 373 | } |
| 380 | else{ | 374 | else{ |
| 381 | if(xscreendepth != 8) | 375 | if(xscreendepth != 8) |
| 382 | panic("drawterm: can't deal with depth %d screens\n", xscreendepth); | 376 | panic("can't deal with depth %d screens", xscreendepth); |
| 383 | xvis = DefaultVisual(xdisplay, rootscreennum); | 377 | xvis = DefaultVisual(xdisplay, rootscreennum); |
| 384 | } | 378 | } |
| 385 | 379 | ||
| @@ -418,7 +412,7 @@ xinitscreen(void) · 32 unmodified lines | |||
| 418 | } | 412 | } |
| 419 | } | 413 | } |
| 420 | if(xscreenchan == 0) | 414 | if(xscreenchan == 0) |
| 421 | panic("drawterm: unknown screen pixel format\n"); | 415 | panic("unknown screen pixel format"); |
| 422 | 416 | ||
| 423 | screen = DefaultScreenOfDisplay(xdisplay); | 417 | screen = DefaultScreenOfDisplay(xdisplay); |
| 424 | xcmap = DefaultColormapOfScreen(screen); | 418 | xcmap = DefaultColormapOfScreen(screen); |
| @@ -489,23 +483,13 @@ xinitscreen(void) · 64 unmodified lines | |||
| 489 | xgccopy = creategc(xscreenid); | 483 | xgccopy = creategc(xscreenid); |
| 490 | 484 | ||
| 491 | xkmcon = XOpenDisplay(NULL); | 485 | xkmcon = XOpenDisplay(NULL); |
| 492 | if(xkmcon == 0){ | 486 | if(xkmcon == 0) |
| 493 | disp_val = getenv("DISPLAY"); | 487 | panic("XOpenDisplay: %r [DISPLAY=%s]", getenv("DISPLAY")); |
| 494 | if(disp_val == 0) | ||
| 495 | disp_val = "not set"; | ||
| 496 | iprint("drawterm: open %r, DISPLAY is %s\n", disp_val); | ||
| 497 | exit(0); | ||
| 498 | } | ||
| 499 | XkbSetDetectableAutoRepeat(xkmcon, True, NULL); | 488 | XkbSetDetectableAutoRepeat(xkmcon, True, NULL); |
| 500 | 489 | ||
| 501 | xsnarfcon = XOpenDisplay(NULL); | 490 | xsnarfcon = XOpenDisplay(NULL); |
| 502 | if(xsnarfcon == 0){ | 491 | if(xsnarfcon == 0) |
| 503 | disp_val = getenv("DISPLAY"); | 492 | panic("XOpenDisplay: %r [DISPLAY=%s]", getenv("DISPLAY")); |
| 504 | if(disp_val == 0) | ||
| 505 | disp_val = "not set"; | ||
| 506 | iprint("drawterm: open %r, DISPLAY is %s\n", disp_val); | ||
| 507 | exit(0); | ||
| 508 | } | ||
| 509 | 493 | ||
| 510 | clipboard = XInternAtom(xkmcon, "CLIPBOARD", False); | 494 | clipboard = XInternAtom(xkmcon, "CLIPBOARD", False); |
| 511 | utf8string = XInternAtom(xkmcon, "UTF8_STRING", False); | 495 | utf8string = XInternAtom(xkmcon, "UTF8_STRING", False); |
| @@ -607,7 +591,7 @@ initmap(Window w) · 95 unmodified lines | |||
| 607 | c = map[19]; | 591 | c = map[19]; |
| 608 | /* find out index into colormap for our RGB */ | 592 | /* find out index into colormap for our RGB */ |
| 609 | if(!XAllocColor(xdisplay, xcmap, &c)) | 593 | if(!XAllocColor(xdisplay, xcmap, &c)) |
| 610 | panic("drawterm: screen-x11 can't alloc color"); | 594 | panic("screen-x11 can't alloc color"); |
| 611 | 595 | ||
| 612 | p = c.pixel; | 596 | p = c.pixel; |
| 613 | pp = rgb2cmap((p>>16)&0xff,(p>>8)&0xff,p&0xff); | 597 | pp = rgb2cmap((p>>16)&0xff,(p>>8)&0xff,p&0xff); |
| @@ -642,10 +626,8 @@ initmap(Window w) · 28 unmodified lines | |||
| 642 | else { | 626 | else { |
| 643 | for(i = 0; i < 128; i++) { | 627 | for(i = 0; i < 128; i++) { |
| 644 | c = map7[i]; | 628 | c = map7[i]; |
| 645 | if(!XAllocColor(xdisplay, xcmap, &c)) { | 629 | if(!XAllocColor(xdisplay, xcmap, &c)) |
| 646 | iprint("drawterm: can't alloc colors in default map, don't use -7\n"); | 630 | panic("can't alloc colors in default map, don't use -7"); |
| 647 | exit(0); | ||
| 648 | } | ||
| 649 | plan9tox11[map7to8[i][0]] = c.pixel; | 631 | plan9tox11[map7to8[i][0]] = c.pixel; |
| 650 | plan9tox11[map7to8[i][1]] = c.pixel; | 632 | plan9tox11[map7to8[i][1]] = c.pixel; |
| 651 | x11toplan9[c.pixel] = map7to8[i][0]; | 633 | x11toplan9[c.pixel] = map7to8[i][0]; |
| @@ -653,7 +635,7 @@ initmap(Window w) · 1 unmodified line | |||
| 653 | } | 635 | } |
| 654 | } | 636 | } |
| 655 | else | 637 | else |
| 656 | panic("drawterm: unsupported visual class %d\n", xvis->class); | 638 | panic("unsupported visual class %d", xvis->class); |
| 657 | } | 639 | } |
| 658 | 640 | ||
| 659 | static void | 641 | static void |
| @@ -1163,7 +1145,7 @@ if(0) iprint("xselect target=%d requestor=%d property=%d selection=%d\n", · 503 unmodified lines | |||
| 1163 | }else if(strcmp(name, "text/plain") == 0 || strcmp(name, "text/plain;charset=UTF-8") == 0){ | 1145 | }else if(strcmp(name, "text/plain") == 0 || strcmp(name, "text/plain;charset=UTF-8") == 0){ |
| 1164 | goto text; | 1146 | goto text; |
| 1165 | }else | 1147 | }else |
| 1166 | iprint("%s: cannot handle selection request for '%s' (%d)\n", argv0, name, (int)xe->target); | 1148 | iprint("cannot handle selection request for '%s' (%d)\n", name, (int)xe->target); |
| 1167 | } | 1149 | } |
| 1168 | r.xselection.property = None; | 1150 | r.xselection.property = None; |
| 1169 | } | 1151 | } |