2385 Window win; |
2386 Window win; |
2386 int w, h, angle1, angle2; |
2387 int w, h, angle1, angle2; |
2387 double f; |
2388 double f; |
2388 |
2389 |
2389 if (__isSmallInteger(startAngle)) |
2390 if (__isSmallInteger(startAngle)) |
2390 angle1 = __intVal(startAngle) * 64; |
2391 angle1 = __intVal(startAngle) * 64; |
2391 else if (__isFloat(startAngle)) { |
2392 else if (__isFloat(startAngle)) { |
2392 f = __floatVal(startAngle); |
2393 f = __floatVal(startAngle); |
2393 angle1 = f * 64; |
2394 angle1 = f * 64; |
2394 } |
2395 } |
2395 if (__isSmallInteger(angle)) |
2396 if (__isSmallInteger(angle)) |
2396 angle2 = __intVal(angle) * 64; |
2397 angle2 = __intVal(angle) * 64; |
2397 else if (__isFloat(angle)) { |
2398 else if (__isFloat(angle)) { |
2398 f = __floatVal(angle); |
2399 f = __floatVal(angle); |
2399 angle2 = f * 64; |
2400 angle2 = f * 64; |
2400 } |
2401 } |
2401 if (__isExternalAddress(aGCId) |
2402 if (__isExternalAddress(aGCId) |
2402 && __isExternalAddress(aDrawableId) |
2403 && __isExternalAddress(aDrawableId) |
2403 && __bothSmallInteger(x, y) |
2404 && __bothSmallInteger(x, y) |
2404 && __bothSmallInteger(width, height)) { |
2405 && __bothSmallInteger(width, height)) { |
2405 win = _WindowVal(aDrawableId); |
2406 win = _WindowVal(aDrawableId); |
2406 gc = _GCVal(aGCId); |
2407 gc = _GCVal(aGCId); |
2407 w = __intVal(width); |
2408 w = __intVal(width); |
2408 h = __intVal(height); |
2409 h = __intVal(height); |
2409 /* |
2410 /* |
2410 * need this check here: some servers simply dump core with bad args |
2411 * need this check here: some servers simply dump core with bad args |
2411 */ |
2412 */ |
2412 if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
2413 if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
2413 XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
2414 XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
2414 w, h, angle1, angle2); |
2415 w, h, angle1, angle2); |
2415 } |
2416 } |
2416 RETURN ( self ); |
2417 RETURN ( self ); |
2417 } |
2418 } |
2418 %}. |
2419 %}. |
2419 "badGC, badDrawable or coordinates not integer" |
2420 "badGC, badDrawable or coordinates not integer" |
2420 self primitiveFailed |
2421 self primitiveFailed |
2421 ! |
2422 ! |
2569 if (__isExternalAddress(aGCId) |
2570 if (__isExternalAddress(aGCId) |
2570 && __isExternalAddress(aDrawableId) |
2571 && __isExternalAddress(aDrawableId) |
2571 && __isNonNilObject(aString) |
2572 && __isNonNilObject(aString) |
2572 && __bothSmallInteger(index1, index2) |
2573 && __bothSmallInteger(index1, index2) |
2573 && __bothSmallInteger(x, y)) { |
2574 && __bothSmallInteger(x, y)) { |
2574 gc = _GCVal(aGCId); |
2575 gc = _GCVal(aGCId); |
2575 win = _WindowVal(aDrawableId); |
2576 win = _WindowVal(aDrawableId); |
2576 cls = __qClass(aString); |
2577 cls = __qClass(aString); |
2577 |
2578 |
2578 i1 = __intVal(index1) - 1; |
2579 i1 = __intVal(index1) - 1; |
2579 if (i1 >= 0) { |
2580 if (i1 >= 0) { |
2580 i2 = __intVal(index2) - 1; |
2581 i2 = __intVal(index2) - 1; |
2581 if (i2 < i1) { |
2582 if (i2 < i1) { |
2582 RETURN (self); |
2583 RETURN (self); |
2583 } |
2584 } |
2584 |
2585 |
2585 cp = _stringVal(aString); |
2586 cp = _stringVal(aString); |
2586 l = i2 - i1 + 1; |
2587 l = i2 - i1 + 1; |
2587 |
2588 |
2588 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
2589 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
2589 n = _stringSize(aString); |
2590 n = _stringSize(aString); |
2590 if (i2 < n) { |
2591 if (i2 < n) { |
2591 cp += i1; |
2592 cp += i1; |
2592 if (l > 1000) l = 1000; |
2593 if (l > 1000) l = 1000; |
2593 if (opaque == true) |
2594 if (opaque == true) |
2594 XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
2595 XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
2595 else |
2596 else |
2596 XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
2597 XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
2597 RETURN ( self ); |
2598 RETURN ( self ); |
2598 } |
2599 } |
2599 } |
2600 } |
2600 |
2601 |
2601 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
2602 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
2602 cp += nInstBytes; |
2603 cp += nInstBytes; |
2603 |
2604 |
2604 if (__isBytes(aString)) { |
2605 if (__isBytes(aString)) { |
2605 n = __byteArraySize(aString) - nInstBytes - 1; |
2606 n = __byteArraySize(aString) - nInstBytes - 1; |
2606 |
2607 |
2607 if (i2 < n) { |
2608 if (i2 < n) { |
2608 cp += i1; |
2609 cp += i1; |
2609 if (l > 1000) l = 1000; |
2610 if (l > 1000) l = 1000; |
2610 if (opaque == true) |
2611 if (opaque == true) |
2611 XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
2612 XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
2612 else |
2613 else |
2613 XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
2614 XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
2614 RETURN ( self ); |
2615 RETURN ( self ); |
2615 } |
2616 } |
2616 } |
2617 } |
2617 |
2618 |
2618 /* TWOBYTESTRINGS */ |
2619 /* TWOBYTESTRINGS */ |
2619 if (__isWords(aString)) { |
2620 if (__isWords(aString)) { |
2620 n = (__byteArraySize(aString) - nInstBytes) / 2; |
2621 n = (__byteArraySize(aString) - nInstBytes) / 2; |
2621 |
2622 |
2622 if (i2 < n) { |
2623 if (i2 < n) { |
2623 union { |
2624 union { |
2624 char b[2]; |
2625 char b[2]; |
2625 unsigned short s; |
2626 unsigned short s; |
2626 } u; |
2627 } u; |
2627 int i; |
2628 int i; |
2628 XChar2b *cp2 = (XChar2b *)0; |
2629 XChar2b *cp2 = (XChar2b *)0; |
2629 int mustFree = 0; |
2630 int mustFree = 0; |
2630 |
2631 |
2631 cp += (i1 * 2); |
2632 cp += (i1 * 2); |
2632 if (l > 1000) l = 1000; |
2633 if (l > 1000) l = 1000; |
2633 |
2634 |
2634 /* |
2635 /* |
2635 * ST/X TwoByteStrings store the asciiValue in native byteOrder; |
2636 * ST/X TwoByteStrings store the asciiValue in native byteOrder; |
2636 * X expects them MSB first |
2637 * X expects them MSB first |
2637 * convert as required |
2638 * convert as required |
2638 */ |
2639 */ |
2639 |
2640 |
2640 u.s = 0x1234; |
2641 u.s = 0x1234; |
2641 if (u.b[0] != 0x12) { |
2642 if (u.b[0] != 0x12) { |
2642 if (l <= NLOCALBUFFER) { |
2643 if (l <= NLOCALBUFFER) { |
2643 cp2 = xlatebuffer; |
2644 cp2 = xlatebuffer; |
2644 } else { |
2645 } else { |
2645 cp2 = (XChar2b *)(malloc(l * 2)); |
2646 cp2 = (XChar2b *)(malloc(l * 2)); |
2646 mustFree = 1; |
2647 mustFree = 1; |
2647 } |
2648 } |
2648 for (i=0; i<l; i++) { |
2649 for (i=0; i<l; i++) { |
2649 cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
2650 cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
2650 cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
2651 cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
2651 } |
2652 } |
2652 cp = (char *) cp2; |
2653 cp = (char *) cp2; |
2653 } |
2654 } |
2654 |
2655 |
2655 if (opaque == true) |
2656 if (opaque == true) |
2656 XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
2657 XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
2657 else |
2658 else |
2658 XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
2659 XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
2659 |
2660 |
2660 if (mustFree) { |
2661 if (mustFree) { |
2661 free(cp2); |
2662 free(cp2); |
2662 } |
2663 } |
2663 |
2664 |
2664 RETURN ( self ); |
2665 RETURN ( self ); |
2665 } |
2666 } |
2666 } |
2667 } |
2667 } |
2668 } |
2668 } |
2669 } |
2669 #undef NLOCALBUFFER |
2670 #undef NLOCALBUFFER |
2670 %}. |
2671 %}. |
2671 "x/y not integer, badGC or drawable, or not a string" |
2672 "x/y not integer, badGC or drawable, or not a string" |
2672 self primitiveFailed |
2673 self primitiveFailed |
2690 |
2691 |
2691 if (__isExternalAddress(aGCId) |
2692 if (__isExternalAddress(aGCId) |
2692 && __isExternalAddress(aDrawableId) |
2693 && __isExternalAddress(aDrawableId) |
2693 && __isNonNilObject(aString) |
2694 && __isNonNilObject(aString) |
2694 && __bothSmallInteger(x, y)) { |
2695 && __bothSmallInteger(x, y)) { |
2695 gc = _GCVal(aGCId); |
2696 gc = _GCVal(aGCId); |
2696 win = _WindowVal(aDrawableId); |
2697 win = _WindowVal(aDrawableId); |
2697 cls = __qClass(aString); |
2698 cls = __qClass(aString); |
2698 |
2699 |
2699 cp = _stringVal(aString); |
2700 cp = _stringVal(aString); |
2700 |
2701 |
2701 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
2702 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
2702 n = _stringSize(aString); |
2703 n = _stringSize(aString); |
2703 if (n > 1000) n = 1000; |
2704 if (n > 1000) n = 1000; |
2704 if (opaque == true) |
2705 if (opaque == true) |
2705 XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
2706 XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
2706 else |
2707 else |
2707 XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
2708 XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
2708 RETURN ( self ); |
2709 RETURN ( self ); |
2709 } |
2710 } |
2710 |
2711 |
2711 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
2712 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
2712 cp += nInstBytes; |
2713 cp += nInstBytes; |
2713 |
2714 |
2714 if (__isBytes(aString)) { |
2715 if (__isBytes(aString)) { |
2715 n = __byteArraySize(aString) - nInstBytes - 1; |
2716 n = __byteArraySize(aString) - nInstBytes - 1; |
2716 |
2717 |
2717 if (n > 1000) n = 1000; |
2718 if (n > 1000) n = 1000; |
2718 if (opaque == true) |
2719 if (opaque == true) |
2719 XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
2720 XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
2720 else |
2721 else |
2721 XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
2722 XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
2722 RETURN ( self ); |
2723 RETURN ( self ); |
2723 } |
2724 } |
2724 |
2725 |
2725 /* TWOBYTESTRINGS */ |
2726 /* TWOBYTESTRINGS */ |
2726 if (__isWords(aString)) { |
2727 if (__isWords(aString)) { |
2727 union { |
2728 union { |
2728 char b[2]; |
2729 char b[2]; |
2729 unsigned short s; |
2730 unsigned short s; |
2730 } u; |
2731 } u; |
2731 int i; |
2732 int i; |
2732 XChar2b *cp2; |
2733 XChar2b *cp2; |
2733 int mustFree = 0; |
2734 int mustFree = 0; |
2734 |
2735 |
2735 n = (__byteArraySize(aString) - nInstBytes) / 2; |
2736 n = (__byteArraySize(aString) - nInstBytes) / 2; |
2736 if (n > 1000) n = 1000; |
2737 if (n > 1000) n = 1000; |
2737 |
2738 |
2738 /* |
2739 /* |
2739 * ST/X TwoByteStrings store the asciiValue in native byteOrder; |
2740 * ST/X TwoByteStrings store the asciiValue in native byteOrder; |
2740 * X expects them MSB first |
2741 * X expects them MSB first |
2741 * convert as required |
2742 * convert as required |
2742 */ |
2743 */ |
2743 |
2744 |
2744 u.s = 0x1234; |
2745 u.s = 0x1234; |
2745 if (u.b[0] != 0x12) { |
2746 if (u.b[0] != 0x12) { |
2746 if (n <= NLOCALBUFFER) { |
2747 if (n <= NLOCALBUFFER) { |
2747 cp2 = xlatebuffer; |
2748 cp2 = xlatebuffer; |
2748 } else { |
2749 } else { |
2749 cp2 = (XChar2b *)(malloc(n * 2)); |
2750 cp2 = (XChar2b *)(malloc(n * 2)); |
2750 mustFree = 1; |
2751 mustFree = 1; |
2751 } |
2752 } |
2752 |
2753 |
2753 for (i=0; i<n; i++) { |
2754 for (i=0; i<n; i++) { |
2754 cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
2755 cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
2755 cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
2756 cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
2756 } |
2757 } |
2757 cp = (char *) cp2; |
2758 cp = (char *) cp2; |
2758 } |
2759 } |
2759 |
2760 |
2760 if (opaque == true) |
2761 if (opaque == true) |
2761 XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
2762 XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
2762 else |
2763 else |
2763 XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
2764 XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
2764 |
2765 |
2765 |
2766 |
2766 if (mustFree) { |
2767 if (mustFree) { |
2767 free(cp2); |
2768 free(cp2); |
2768 } |
2769 } |
2769 |
2770 |
2770 RETURN ( self ); |
2771 RETURN ( self ); |
2771 } |
2772 } |
2772 } |
2773 } |
2773 #undef NLOCALBUFFER |
2774 #undef NLOCALBUFFER |
2774 %}. |
2775 %}. |
2775 "x/y not integer, badGC or drawable, or not a string" |
2776 "x/y not integer, badGC or drawable, or not a string" |
2776 self primitiveFailed |
2777 self primitiveFailed |
2850 Window win; |
2851 Window win; |
2851 int w, h, angle1, angle2; |
2852 int w, h, angle1, angle2; |
2852 double f; |
2853 double f; |
2853 |
2854 |
2854 if (__isSmallInteger(startAngle)) |
2855 if (__isSmallInteger(startAngle)) |
2855 angle1 = __intVal(startAngle) * 64; |
2856 angle1 = __intVal(startAngle) * 64; |
2856 else if (__isFloat(startAngle)) { |
2857 else if (__isFloat(startAngle)) { |
2857 f = __floatVal(startAngle); |
2858 f = __floatVal(startAngle); |
2858 angle1 = f * 64; |
2859 angle1 = f * 64; |
2859 } |
2860 } |
2860 if (__isSmallInteger(angle)) |
2861 if (__isSmallInteger(angle)) |
2861 angle2 = __intVal(angle) * 64; |
2862 angle2 = __intVal(angle) * 64; |
2862 else if (__isFloat(angle)) { |
2863 else if (__isFloat(angle)) { |
2863 f = __floatVal(angle); |
2864 f = __floatVal(angle); |
2864 angle2 = f * 64; |
2865 angle2 = f * 64; |
2865 } |
2866 } |
2866 if (__isExternalAddress(aGCId) |
2867 if (__isExternalAddress(aGCId) |
2867 && __isExternalAddress(aDrawableId) |
2868 && __isExternalAddress(aDrawableId) |
2868 && __bothSmallInteger(x, y) |
2869 && __bothSmallInteger(x, y) |
2869 && __bothSmallInteger(width, height)) { |
2870 && __bothSmallInteger(width, height)) { |
2870 gc = _GCVal(aGCId); |
2871 gc = _GCVal(aGCId); |
2871 win = _WindowVal(aDrawableId); |
2872 win = _WindowVal(aDrawableId); |
2872 w = __intVal(width); |
2873 w = __intVal(width); |
2873 h = __intVal(height); |
2874 h = __intVal(height); |
2874 /* |
2875 /* |
2875 * need this check here: some servers simply dump core with bad args |
2876 * need this check here: some servers simply dump core with bad args |
2876 */ |
2877 */ |
2877 if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
2878 if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
2878 XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
2879 XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
2879 w, h, angle1, angle2); |
2880 w, h, angle1, angle2); |
2880 } |
2881 } |
2881 RETURN ( self ); |
2882 RETURN ( self ); |
2882 } |
2883 } |
2883 %}. |
2884 %}. |
2884 "badGC, badDrawable or coordinates not integer" |
2885 "badGC, badDrawable or coordinates not integer" |
2885 self primitiveFailed |
2886 self primitiveFailed |
2886 ! |
2887 ! |
4114 simulateKeyboardInput:aCharacterOrString inViewId:viewId |
4115 simulateKeyboardInput:aCharacterOrString inViewId:viewId |
4115 "send input to some other view, by simulating keyPress/keyRelease |
4116 "send input to some other view, by simulating keyPress/keyRelease |
4116 events. |
4117 events. |
4117 Only a few control characters are supported. |
4118 Only a few control characters are supported. |
4118 Notice: not all alien views allow this kind of synthetic input; |
4119 Notice: not all alien views allow this kind of synthetic input; |
4119 some simply ignore it." |
4120 some simply ignore it." |
4120 |
4121 |
4121 |control code state| |
4122 |control code state| |
4122 |
4123 |
4123 aCharacterOrString isString ifTrue:[ |
4124 aCharacterOrString isString ifTrue:[ |
4124 aCharacterOrString do:[:char | |
4125 aCharacterOrString do:[:char | |
4125 self simulateKeyboardInput:char inViewId:viewId |
4126 self simulateKeyboardInput:char inViewId:viewId |
4126 ]. |
4127 ]. |
4127 ^ self |
4128 ^ self |
4128 ]. |
4129 ]. |
4129 |
4130 |
4130 control := false. |
4131 control := false. |
4131 code := aCharacterOrString asciiValue. |
4132 code := aCharacterOrString asciiValue. |
4132 |
4133 |
4133 (aCharacterOrString == Character cr) ifTrue:[ |
4134 (aCharacterOrString == Character cr) ifTrue:[ |
4134 code := #Return |
4135 code := #Return |
4135 ] ifFalse:[ |
4136 ] ifFalse:[ |
4136 (aCharacterOrString == Character tab) ifTrue:[ |
4137 (aCharacterOrString == Character tab) ifTrue:[ |
4137 code := #Tab |
4138 code := #Tab |
4138 ] ifFalse:[ |
4139 ] ifFalse:[ |
4139 (aCharacterOrString == Character esc) ifTrue:[ |
4140 (aCharacterOrString == Character esc) ifTrue:[ |
4140 code := #Escape |
4141 code := #Escape |
4141 ] |
4142 ] |
4142 ] |
4143 ] |
4143 ]. |
4144 ]. |
4144 |
4145 |
4145 control ifTrue:[ |
4146 control ifTrue:[ |
4146 state := self controlMask |
4147 state := self controlMask |
4147 ]. |
4148 ]. |
4148 |
4149 |
4149 |
4150 |
4150 "/ the stuff below should not be needed |
4151 "/ the stuff below should not be needed |
4151 "/ (sendKeyOrButtonevent should be able to figure out things itself) |
4152 "/ (sendKeyOrButtonevent should be able to figure out things itself) |
4152 "/ however, on some linux systems it seems to not work correctly. |
4153 "/ however, on some linux systems it seems to not work correctly. |
4153 "/ Hopefully, this is correct ... |
4154 "/ Hopefully, this is correct ... |
4154 |
4155 |
4155 code isNumber ifTrue:[ |
4156 code isNumber ifTrue:[ |
4156 code >= $A asciiValue ifTrue:[ |
4157 code >= $A asciiValue ifTrue:[ |
4157 code <= $Z asciiValue ifTrue:[ |
4158 code <= $Z asciiValue ifTrue:[ |
4158 state := self shiftMask |
4159 state := self shiftMask |
4159 ] |
4160 ] |
4160 ] |
4161 ] |
4161 ]. |
4162 ]. |
4162 |
4163 |
4163 self sendKeyOrButtonEvent:#keyPress x:0 y:0 keyOrButton:code state:state toViewId:viewId. |
4164 self sendKeyOrButtonEvent:#keyPress x:0 y:0 keyOrButton:code state:state toViewId:viewId. |
4164 self sendKeyOrButtonEvent:#keyRelease x:0 y:0 keyOrButton:code state:state toViewId:viewId |
4165 self sendKeyOrButtonEvent:#keyRelease x:0 y:0 keyOrButton:code state:state toViewId:viewId |
4165 |
4166 |
4378 encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True); |
4379 encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True); |
4379 charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True); |
4380 charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True); |
4380 fontAtom = XInternAtom(myDpy, "FONT", True); |
4381 fontAtom = XInternAtom(myDpy, "FONT", True); |
4381 |
4382 |
4382 if (ISCONNECTED) { |
4383 if (ISCONNECTED) { |
4383 if (__isExternalAddress(aFontId)) { |
4384 if (__isExternalAddress(aFontId)) { |
4384 |
4385 |
4385 f = _FontVal(aFontId); |
4386 f = _FontVal(aFontId); |
4386 if (f) { |
4387 if (f) { |
4387 n = f->n_properties; |
4388 n = f->n_properties; |
4388 prop = f->properties; |
4389 prop = f->properties; |
4389 if (prop) { |
4390 if (prop) { |
4390 while (n--) { |
4391 while (n--) { |
4391 cp = XGetAtomName(myDpy, prop->name); |
4392 cp = XGetAtomName(myDpy, prop->name); |
4392 #ifdef SUPERDEBUG |
4393 #ifdef SUPERDEBUG |
4393 printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
4394 printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
4394 #endif |
4395 #endif |
4395 if (prop->name == XA_FULL_NAME) { |
4396 if (prop->name == XA_FULL_NAME) { |
4396 cp = XGetAtomName(myDpy, prop->card32); |
4397 cp = XGetAtomName(myDpy, prop->card32); |
4397 if (cp) { |
4398 if (cp) { |
4398 fullName = __MKSTRING(cp COMMA_CON); |
4399 fullName = __MKSTRING(cp COMMA_CON); |
4399 #ifdef SUPERDEBUG |
4400 #ifdef SUPERDEBUG |
4400 printf(" FULL_NAME -> %s\n", cp); |
4401 printf(" FULL_NAME -> %s\n", cp); |
4401 #endif |
4402 #endif |
4402 } |
4403 } |
4403 } |
4404 } |
4404 if (prop->name == fontAtom) { |
4405 if (prop->name == fontAtom) { |
4405 cp = XGetAtomName(myDpy, prop->card32); |
4406 cp = XGetAtomName(myDpy, prop->card32); |
4406 if (cp) { |
4407 if (cp) { |
4407 fontName = __MKSTRING(cp COMMA_CON); |
4408 fontName = __MKSTRING(cp COMMA_CON); |
4408 #ifdef SUPERDEBUG |
4409 #ifdef SUPERDEBUG |
4409 printf(" FONT -> %s\n", cp); |
4410 printf(" FONT -> %s\n", cp); |
4410 #endif |
4411 #endif |
4411 } |
4412 } |
4412 } |
4413 } |
4413 if (prop->name == encodingAtom) { |
4414 if (prop->name == encodingAtom) { |
4414 cp = XGetAtomName(myDpy, prop->card32); |
4415 cp = XGetAtomName(myDpy, prop->card32); |
4415 if (cp) { |
4416 if (cp) { |
4416 encoding = __MKSTRING(cp COMMA_CON); |
4417 encoding = __MKSTRING(cp COMMA_CON); |
4417 #ifdef SUPERDEBUG |
4418 #ifdef SUPERDEBUG |
4418 printf(" ENCODING -> %s\n", cp); |
4419 printf(" ENCODING -> %s\n", cp); |
4419 #endif |
4420 #endif |
4420 } |
4421 } |
4421 } |
4422 } |
4422 if (prop->name == registryAtom) { |
4423 if (prop->name == registryAtom) { |
4423 cp = XGetAtomName(myDpy, prop->card32); |
4424 cp = XGetAtomName(myDpy, prop->card32); |
4424 if (cp) { |
4425 if (cp) { |
4425 registry = __MKSTRING(cp COMMA_CON); |
4426 registry = __MKSTRING(cp COMMA_CON); |
4426 #ifdef SUPERDEBUG |
4427 #ifdef SUPERDEBUG |
4427 printf(" REGISTRY -> %s\n", cp); |
4428 printf(" REGISTRY -> %s\n", cp); |
4428 #endif |
4429 #endif |
4429 } |
4430 } |
4430 } |
4431 } |
4431 if (prop->name == charSetCollAtom) { |
4432 if (prop->name == charSetCollAtom) { |
4432 cp = XGetAtomName(myDpy, prop->card32); |
4433 cp = XGetAtomName(myDpy, prop->card32); |
4433 if (cp) { |
4434 if (cp) { |
4434 charSetCollections = __MKSTRING(cp COMMA_CON); |
4435 charSetCollections = __MKSTRING(cp COMMA_CON); |
4435 #ifdef SUPERDEBUG |
4436 #ifdef SUPERDEBUG |
4436 printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
4437 printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
4437 #endif |
4438 #endif |
4438 } |
4439 } |
4439 } |
4440 } |
4440 prop++; |
4441 prop++; |
4441 } |
4442 } |
4442 } |
4443 } |
4443 } |
4444 } |
4444 } |
4445 } |
4445 } |
4446 } |
4446 %}. |
4447 %}. |
4447 ^ self |
4448 ^ self |
4448 extractEncodingFromRegistry:registry |
4449 extractEncodingFromRegistry:registry |
4449 encoding:encoding |
4450 encoding:encoding |
4450 charSetCollections:charSetCollections |
4451 charSetCollections:charSetCollections |
4451 ! |
4452 ! |
4452 |
4453 |
4453 extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
4454 extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
4454 "this is pure magic ..." |
4455 "this is pure magic ..." |
4455 |
4456 |
4456 |enc charSets| |
4457 |enc charSets| |
4457 |
4458 |
4458 (registry notNil and:[registry notEmpty]) ifTrue:[ |
4459 (registry notNil and:[registry notEmpty]) ifTrue:[ |
4459 enc := registry asLowercase asSymbol. |
4460 enc := registry asLowercase asSymbol. |
4460 ] ifFalse:[ |
4461 ] ifFalse:[ |
4461 (encoding notNil and:[encoding notEmpty]) ifTrue:[ |
4462 (encoding notNil and:[encoding notEmpty]) ifTrue:[ |
4462 enc := encoding asLowercase asSymbol |
4463 enc := encoding asLowercase asSymbol |
4463 ] ifFalse:[ |
4464 ] ifFalse:[ |
4464 charSets := charSetCollections. |
4465 charSets := charSetCollections. |
4465 (charSets notNil and:[charSets notEmpty]) ifTrue:[ |
4466 (charSets notNil and:[charSets notEmpty]) ifTrue:[ |
4466 charSets := charSets asUppercase asCollectionOfWords. |
4467 charSets := charSets asUppercase asCollectionOfWords. |
4467 (charSets includes:'ISO8859-1') ifTrue:[ |
4468 (charSets includes:'ISO8859-1') ifTrue:[ |
4468 enc := #iso8859 |
4469 enc := #iso8859 |
4469 ] ifFalse:[ |
4470 ] ifFalse:[ |
4470 (charSets includes:'ISO8859') ifTrue:[ |
4471 (charSets includes:'ISO8859') ifTrue:[ |
4471 enc := #iso8859 |
4472 enc := #iso8859 |
4472 ] ifFalse:[ |
4473 ] ifFalse:[ |
4473 (charSets includes:'ASCII') ifTrue:[ |
4474 (charSets includes:'ASCII') ifTrue:[ |
4474 enc := #ascii |
4475 enc := #ascii |
4475 ] ifFalse:[ |
4476 ] ifFalse:[ |
4476 (charSets includes:'ADOBE-STANDARD') ifTrue:[ |
4477 (charSets includes:'ADOBE-STANDARD') ifTrue:[ |
4477 enc := #iso8859 |
4478 enc := #iso8859 |
4478 ] |
4479 ] |
4479 ] |
4480 ] |
4480 ] |
4481 ] |
4481 ] |
4482 ] |
4482 ] |
4483 ] |
4483 ] |
4484 ] |
4484 ]. |
4485 ]. |
4485 ^ enc |
4486 ^ enc |
4486 |
4487 |
4487 "Created: 17.4.1996 / 14:57:06 / cg" |
4488 "Created: 17.4.1996 / 14:57:06 / cg" |
4488 "Modified: 17.4.1996 / 17:22:35 / cg" |
4489 "Modified: 17.4.1996 / 17:22:35 / cg" |
5020 # define NLOCALBUFFER 200 |
5021 # define NLOCALBUFFER 200 |
5021 XChar2b xlatebuffer[NLOCALBUFFER]; |
5022 XChar2b xlatebuffer[NLOCALBUFFER]; |
5022 int nInstBytes; |
5023 int nInstBytes; |
5023 |
5024 |
5024 if (ISCONNECTED) { |
5025 if (ISCONNECTED) { |
5025 if (__bothSmallInteger(index1, index2) |
5026 if (__bothSmallInteger(index1, index2) |
5026 && __isExternalAddress(aFontId) |
5027 && __isExternalAddress(aFontId) |
5027 && __isNonNilObject(aString)) { |
5028 && __isNonNilObject(aString)) { |
5028 f = _FontVal(aFontId); |
5029 f = _FontVal(aFontId); |
5029 i1 = __intVal(index1) - 1; |
5030 i1 = __intVal(index1) - 1; |
5030 cls = __qClass(aString); |
5031 cls = __qClass(aString); |
5031 |
5032 |
5032 if (i1 >= 0) { |
5033 if (i1 >= 0) { |
5033 i2 = __intVal(index2) - 1; |
5034 i2 = __intVal(index2) - 1; |
5034 if (i2 < i1) { |
5035 if (i2 < i1) { |
5035 RETURN (self); |
5036 RETURN (self); |
5036 } |
5037 } |
5037 |
5038 |
5038 cp = (char *) _stringVal(aString); |
5039 cp = (char *) _stringVal(aString); |
5039 l = i2 - i1 + 1; |
5040 l = i2 - i1 + 1; |
5040 |
5041 |
5041 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
5042 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
5042 n = _stringSize(aString); |
5043 n = _stringSize(aString); |
5043 if (i2 < n) { |
5044 if (i2 < n) { |
5044 cp += i1; |
5045 cp += i1; |
5045 BEGIN_INTERRUPTSBLOCKED |
5046 BEGIN_INTERRUPTSBLOCKED |
5046 len = XTextWidth(f, cp, l); |
5047 len = XTextWidth(f, cp, l); |
5047 END_INTERRUPTSBLOCKED |
5048 END_INTERRUPTSBLOCKED |
5048 RETURN ( __MKSMALLINT(len) ); |
5049 RETURN ( __MKSMALLINT(len) ); |
5049 } |
5050 } |
5050 } |
5051 } |
5051 |
5052 |
5052 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
5053 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
5053 cp += nInstBytes; |
5054 cp += nInstBytes; |
5054 |
5055 |
5055 if (__isBytes(aString)) { |
5056 if (__isBytes(aString)) { |
5056 n = __byteArraySize(aString) - nInstBytes; |
5057 n = __byteArraySize(aString) - nInstBytes; |
5057 if (i2 < n) { |
5058 if (i2 < n) { |
5058 cp += i1; |
5059 cp += i1; |
5059 BEGIN_INTERRUPTSBLOCKED |
5060 BEGIN_INTERRUPTSBLOCKED |
5060 len = XTextWidth(f, cp, l); |
5061 len = XTextWidth(f, cp, l); |
5061 END_INTERRUPTSBLOCKED |
5062 END_INTERRUPTSBLOCKED |
5062 RETURN ( __MKSMALLINT(len) ); |
5063 RETURN ( __MKSMALLINT(len) ); |
5063 } |
5064 } |
5064 } |
5065 } |
5065 |
5066 |
5066 /* TWOBYTESTRINGS */ |
5067 /* TWOBYTESTRINGS */ |
5067 if (__isWords(aString)) { |
5068 if (__isWords(aString)) { |
5068 n = (__byteArraySize(aString) - nInstBytes) / 2; |
5069 n = (__byteArraySize(aString) - nInstBytes) / 2; |
5069 |
5070 |
5070 if (i2 < n) { |
5071 if (i2 < n) { |
5071 union { |
5072 union { |
5072 char b[2]; |
5073 char b[2]; |
5073 unsigned short s; |
5074 unsigned short s; |
5074 } u; |
5075 } u; |
5075 int i; |
5076 int i; |
5076 XChar2b *cp2 = (XChar2b *)0; |
5077 XChar2b *cp2 = (XChar2b *)0; |
5077 int mustFree = 0; |
5078 int mustFree = 0; |
5078 |
5079 |
5079 cp += (i1 * 2); |
5080 cp += (i1 * 2); |
5080 if (l > 1000) l = 1000; |
5081 if (l > 1000) l = 1000; |
5081 |
5082 |
5082 /* |
5083 /* |
5083 * ST/X TwoByteStrings store the asciiValue in native byteOrder; |
5084 * ST/X TwoByteStrings store the asciiValue in native byteOrder; |
5084 * X expects them MSB first |
5085 * X expects them MSB first |
5085 * convert as required |
5086 * convert as required |
5086 */ |
5087 */ |
5087 |
5088 |
5088 u.s = 0x1234; |
5089 u.s = 0x1234; |
5089 if (u.b[0] != 0x12) { |
5090 if (u.b[0] != 0x12) { |
5090 if (l <= NLOCALBUFFER) { |
5091 if (l <= NLOCALBUFFER) { |
5091 cp2 = xlatebuffer; |
5092 cp2 = xlatebuffer; |
5092 } else { |
5093 } else { |
5093 cp2 = (XChar2b *)(malloc(l * 2)); |
5094 cp2 = (XChar2b *)(malloc(l * 2)); |
5094 mustFree = 1; |
5095 mustFree = 1; |
5095 } |
5096 } |
5096 for (i=0; i<l; i++) { |
5097 for (i=0; i<l; i++) { |
5097 cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
5098 cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
5098 cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
5099 cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
5099 } |
5100 } |
5100 cp = (char *) cp2; |
5101 cp = (char *) cp2; |
5101 } |
5102 } |
5102 BEGIN_INTERRUPTSBLOCKED |
5103 BEGIN_INTERRUPTSBLOCKED |
5103 len = XTextWidth16(f, (XChar2b *)cp, l); |
5104 len = XTextWidth16(f, (XChar2b *)cp, l); |
5104 END_INTERRUPTSBLOCKED |
5105 END_INTERRUPTSBLOCKED |
5105 |
5106 |
5106 if (mustFree) { |
5107 if (mustFree) { |
5107 free(cp2); |
5108 free(cp2); |
5108 } |
5109 } |
5109 |
5110 |
5110 RETURN ( __MKSMALLINT(len) ); |
5111 RETURN ( __MKSMALLINT(len) ); |
5111 } |
5112 } |
5112 } |
5113 } |
5113 } |
5114 } |
5114 } |
5115 } |
5115 } |
5116 } |
5116 #undef NLOCALBUFFER |
5117 #undef NLOCALBUFFER |
5117 %}. |
5118 %}. |
5118 self primitiveFailed. |
5119 self primitiveFailed. |
5119 ^ nil |
5120 ^ nil |
5130 # define NLOCALBUFFER 200 |
5131 # define NLOCALBUFFER 200 |
5131 XChar2b xlatebuffer[NLOCALBUFFER]; |
5132 XChar2b xlatebuffer[NLOCALBUFFER]; |
5132 int nInstBytes; |
5133 int nInstBytes; |
5133 |
5134 |
5134 if (ISCONNECTED) { |
5135 if (ISCONNECTED) { |
5135 if (__isExternalAddress(aFontId) |
5136 if (__isExternalAddress(aFontId) |
5136 && __isNonNilObject(aString)) { |
5137 && __isNonNilObject(aString)) { |
5137 f = _FontVal(aFontId); |
5138 f = _FontVal(aFontId); |
5138 cls = __qClass(aString); |
5139 cls = __qClass(aString); |
5139 |
5140 |
5140 cp = (char *)_stringVal(aString); |
5141 cp = (char *)_stringVal(aString); |
5141 |
5142 |
5142 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
5143 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
5143 n = _stringSize(aString); |
5144 n = _stringSize(aString); |
5144 BEGIN_INTERRUPTSBLOCKED |
5145 BEGIN_INTERRUPTSBLOCKED |
5145 len = XTextWidth(f, cp, n); |
5146 len = XTextWidth(f, cp, n); |
5146 END_INTERRUPTSBLOCKED |
5147 END_INTERRUPTSBLOCKED |
5147 RETURN ( __MKSMALLINT(len) ); |
5148 RETURN ( __MKSMALLINT(len) ); |
5148 } |
5149 } |
5149 |
5150 |
5150 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
5151 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
5151 cp += nInstBytes; |
5152 cp += nInstBytes; |
5152 |
5153 |
5153 if (__isBytes(aString)) { |
5154 if (__isBytes(aString)) { |
5154 n = __byteArraySize(aString) - nInstBytes; |
5155 n = __byteArraySize(aString) - nInstBytes; |
5155 |
5156 |
5156 BEGIN_INTERRUPTSBLOCKED |
5157 BEGIN_INTERRUPTSBLOCKED |
5157 len = XTextWidth(f, cp, n); |
5158 len = XTextWidth(f, cp, n); |
5158 END_INTERRUPTSBLOCKED |
5159 END_INTERRUPTSBLOCKED |
5159 RETURN ( __MKSMALLINT(len) ); |
5160 RETURN ( __MKSMALLINT(len) ); |
5160 } |
5161 } |
5161 |
5162 |
5162 /* TWOBYTESTRINGS */ |
5163 /* TWOBYTESTRINGS */ |
5163 if (__isWords(aString)) { |
5164 if (__isWords(aString)) { |
5164 union { |
5165 union { |
5165 char b[2]; |
5166 char b[2]; |
5166 unsigned short s; |
5167 unsigned short s; |
5167 } u; |
5168 } u; |
5168 int i; |
5169 int i; |
5169 XChar2b *cp2; |
5170 XChar2b *cp2; |
5170 int mustFree = 0; |
5171 int mustFree = 0; |
5171 |
5172 |
5172 n = (__byteArraySize(aString) - nInstBytes) / 2; |
5173 n = (__byteArraySize(aString) - nInstBytes) / 2; |
5173 if (n > 1000) n = 1000; |
5174 if (n > 1000) n = 1000; |
5174 |
5175 |
5175 /* |
5176 /* |
5176 * ST/X TwoByteStrings store the asciiValue in native byteOrder; |
5177 * ST/X TwoByteStrings store the asciiValue in native byteOrder; |
5177 * X expects them MSB first |
5178 * X expects them MSB first |
5178 * convert as required |
5179 * convert as required |
5179 */ |
5180 */ |
5180 |
5181 |
5181 u.s = 0x1234; |
5182 u.s = 0x1234; |
5182 if (u.b[0] != 0x12) { |
5183 if (u.b[0] != 0x12) { |
5183 if (n <= NLOCALBUFFER) { |
5184 if (n <= NLOCALBUFFER) { |
5184 cp2 = xlatebuffer; |
5185 cp2 = xlatebuffer; |
5185 } else { |
5186 } else { |
5186 cp2 = (XChar2b *)(malloc(n * 2)); |
5187 cp2 = (XChar2b *)(malloc(n * 2)); |
5187 mustFree = 1; |
5188 mustFree = 1; |
5188 } |
5189 } |
5189 |
5190 |
5190 for (i=0; i<n; i++) { |
5191 for (i=0; i<n; i++) { |
5191 cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
5192 cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
5192 cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
5193 cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
5193 } |
5194 } |
5194 cp = (char *) cp2; |
5195 cp = (char *) cp2; |
5195 } |
5196 } |
5196 |
5197 |
5197 BEGIN_INTERRUPTSBLOCKED |
5198 BEGIN_INTERRUPTSBLOCKED |
5198 len = XTextWidth16(f, (XChar2b *)cp, n); |
5199 len = XTextWidth16(f, (XChar2b *)cp, n); |
5199 END_INTERRUPTSBLOCKED |
5200 END_INTERRUPTSBLOCKED |
5200 |
5201 |
5201 if (mustFree) { |
5202 if (mustFree) { |
5202 free(cp2); |
5203 free(cp2); |
5203 } |
5204 } |
5204 |
5205 |
5205 RETURN ( __MKSMALLINT(len) ); |
5206 RETURN ( __MKSMALLINT(len) ); |
5206 } |
5207 } |
5207 } |
5208 } |
5208 } |
5209 } |
5209 #undef NLOCALBUFFER |
5210 #undef NLOCALBUFFER |
5210 %}. |
5211 %}. |
5211 self primitiveFailed. |
5212 self primitiveFailed. |
5212 ^ nil |
5213 ^ nil |
5969 char *type, *nm; |
5970 char *type, *nm; |
5970 int dummy; |
5971 int dummy; |
5971 int mask, shift, nBits; |
5972 int mask, shift, nBits; |
5972 |
5973 |
5973 if (ISCONNECTED) { |
5974 if (ISCONNECTED) { |
5974 __INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
5975 __INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
5975 __INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
5976 __INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
5976 |
5977 |
5977 BEGIN_INTERRUPTSBLOCKED |
5978 BEGIN_INTERRUPTSBLOCKED |
5978 |
5979 |
5979 __INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
5980 __INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
5980 __INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
5981 __INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
5981 __INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
5982 __INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
5982 __INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
5983 __INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
5983 __INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
5984 __INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
5984 __INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
5985 __INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
5985 __INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
5986 __INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
5986 __INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
5987 __INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
5987 __INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
5988 __INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
5988 |
5989 |
5989 #ifdef SHAPE |
5990 #ifdef SHAPE |
5990 if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
5991 if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
5991 __INST(hasShapeExtension) = true; |
5992 __INST(hasShapeExtension) = true; |
5992 else |
5993 else |
5993 #endif |
5994 #endif |
5994 __INST(hasShapeExtension) = false; |
5995 __INST(hasShapeExtension) = false; |
5995 |
5996 |
5996 #ifdef SHM |
5997 #ifdef SHM |
5997 if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
5998 if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
5998 __INST(hasShmExtension) = true; |
5999 __INST(hasShmExtension) = true; |
5999 else |
6000 else |
6000 #endif |
6001 #endif |
6001 __INST(hasShmExtension) = false; |
6002 __INST(hasShmExtension) = false; |
6002 |
6003 |
6003 #ifdef FAX |
6004 #ifdef FAX |
6004 if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase)) |
6005 if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase)) |
6005 __INST(hasFaxExtension) = true; |
6006 __INST(hasFaxExtension) = true; |
6006 else |
6007 else |
6007 #endif |
6008 #endif |
6008 __INST(hasFaxExtension) = false; |
6009 __INST(hasFaxExtension) = false; |
6009 |
6010 |
6010 #ifdef DPS |
6011 #ifdef DPS |
6011 if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6012 if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6012 __INST(hasDPSExtension) = true; |
6013 __INST(hasDPSExtension) = true; |
6013 else |
6014 else |
6014 #endif |
6015 #endif |
6015 __INST(hasDPSExtension) = false; |
6016 __INST(hasDPSExtension) = false; |
6016 |
6017 |
6017 #ifdef XVIDEO |
6018 #ifdef XVIDEO |
6018 if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
6019 if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
6019 __INST(hasXVideoExtension) = true; |
6020 __INST(hasXVideoExtension) = true; |
6020 else |
6021 else |
6021 #endif |
6022 #endif |
6022 __INST(hasXVideoExtension) = false; |
6023 __INST(hasXVideoExtension) = false; |
6023 |
6024 |
6024 #ifdef MBUF |
6025 #ifdef MBUF |
6025 if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
6026 if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
6026 __INST(hasMbufExtension) = true; |
6027 __INST(hasMbufExtension) = true; |
6027 else |
6028 else |
6028 #endif |
6029 #endif |
6029 __INST(hasMbufExtension) = false; |
6030 __INST(hasMbufExtension) = false; |
6030 |
6031 |
6031 #ifdef PEX5 |
6032 #ifdef PEX5 |
6032 if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
6033 if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
6033 __INST(hasPEXExtension) = true; |
6034 __INST(hasPEXExtension) = true; |
6034 else |
6035 else |
6035 #endif |
6036 #endif |
6036 __INST(hasPEXExtension) = false; |
6037 __INST(hasPEXExtension) = false; |
6037 |
6038 |
6038 #ifdef XIE |
6039 #ifdef XIE |
6039 if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
6040 if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
6040 __INST(hasImageExtension) = true; |
6041 __INST(hasImageExtension) = true; |
6041 else |
6042 else |
6042 #endif |
6043 #endif |
6043 __INST(hasImageExtension) = false; |
6044 __INST(hasImageExtension) = false; |
6044 |
6045 |
6045 #ifdef XI |
6046 #ifdef XI |
6046 if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
6047 if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
6047 __INST(hasInputExtension) = true; |
6048 __INST(hasInputExtension) = true; |
6048 else |
6049 else |
6049 #endif |
6050 #endif |
6050 __INST(hasInputExtension) = false; |
6051 __INST(hasInputExtension) = false; |
6051 |
6052 |
6052 /* |
6053 /* |
6053 * look for RGB visual |
6054 * look for RGB visual |
6054 */ |
6055 */ |
6055 nvi = 0; |
6056 nvi = 0; |
6056 viproto.screen = scr; |
6057 viproto.screen = scr; |
6057 vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
6058 vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
6058 maxRGBDepth = 0; |
6059 maxRGBDepth = 0; |
6059 for (i = 0; i < nvi; i++) { |
6060 for (i = 0; i < nvi; i++) { |
6060 switch (vip[i].class) { |
6061 switch (vip[i].class) { |
6061 case TrueColor: |
6062 case TrueColor: |
6062 if (vip[i].depth > maxRGBDepth) { |
6063 if (vip[i].depth > maxRGBDepth) { |
6063 maxRGBDepth = vip[i].depth; |
6064 maxRGBDepth = vip[i].depth; |
6064 rgbRedMask = vip[i].red_mask; |
6065 rgbRedMask = vip[i].red_mask; |
6065 rgbGreenMask = vip[i].green_mask; |
6066 rgbGreenMask = vip[i].green_mask; |
6066 rgbBlueMask = vip[i].blue_mask; |
6067 rgbBlueMask = vip[i].blue_mask; |
6067 rgbVisualID = vip[i].visualid; |
6068 rgbVisualID = vip[i].visualid; |
6068 } |
6069 } |
6069 break; |
6070 break; |
6070 } |
6071 } |
6071 } |
6072 } |
6072 if (vip) XFree ((char *) vip); |
6073 if (vip) XFree ((char *) vip); |
6073 |
6074 |
6074 if (maxRGBDepth) { |
6075 if (maxRGBDepth) { |
6075 __INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
6076 __INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
6076 } |
6077 } |
6077 |
6078 |
6078 visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
6079 visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
6079 __INST(monitorType) = @symbol(unknown); |
6080 __INST(monitorType) = @symbol(unknown); |
6080 __INST(hasColors) = true; |
6081 __INST(hasColors) = true; |
6081 __INST(hasGreyscales) = true; |
6082 __INST(hasGreyscales) = true; |
6082 switch (visual->class) { |
6083 switch (visual->class) { |
6083 case StaticGray: |
6084 case StaticGray: |
6084 __INST(visualType) = @symbol(StaticGray); |
6085 __INST(visualType) = @symbol(StaticGray); |
6085 __INST(hasColors) = false; |
6086 __INST(hasColors) = false; |
6086 __INST(monitorType) = @symbol(monochrome); |
6087 __INST(monitorType) = @symbol(monochrome); |
6087 break; |
6088 break; |
6088 case GrayScale: |
6089 case GrayScale: |
6089 __INST(visualType) = @symbol(GrayScale); |
6090 __INST(visualType) = @symbol(GrayScale); |
6090 __INST(hasColors) = false; |
6091 __INST(hasColors) = false; |
6091 __INST(monitorType) = @symbol(monochrome); |
6092 __INST(monitorType) = @symbol(monochrome); |
6092 break; |
6093 break; |
6093 case StaticColor: |
6094 case StaticColor: |
6094 __INST(visualType) = @symbol(StaticColor); |
6095 __INST(visualType) = @symbol(StaticColor); |
6095 break; |
6096 break; |
6096 case PseudoColor: |
6097 case PseudoColor: |
6097 __INST(visualType) = @symbol(PseudoColor); |
6098 __INST(visualType) = @symbol(PseudoColor); |
6098 break; |
6099 break; |
6099 case TrueColor: |
6100 case TrueColor: |
6100 __INST(visualType) = @symbol(TrueColor); |
6101 __INST(visualType) = @symbol(TrueColor); |
6101 break; |
6102 break; |
6102 case DirectColor: |
6103 case DirectColor: |
6103 __INST(visualType) = @symbol(DirectColor); |
6104 __INST(visualType) = @symbol(DirectColor); |
6104 break; |
6105 break; |
6105 } |
6106 } |
6106 if (DisplayCells(dpy, scr) == 2) { |
6107 if (DisplayCells(dpy, scr) == 2) { |
6107 __INST(hasColors) = false; |
6108 __INST(hasColors) = false; |
6108 __INST(hasGreyscales) = false; |
6109 __INST(hasGreyscales) = false; |
6109 __INST(monitorType) = @symbol(monochrome); |
6110 __INST(monitorType) = @symbol(monochrome); |
6110 } |
6111 } |
6111 __INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
6112 __INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
6112 __INST(redMask) = __MKSMALLINT(visual->red_mask); |
6113 __INST(redMask) = __MKSMALLINT(visual->red_mask); |
6113 __INST(greenMask) = __MKSMALLINT(visual->green_mask); |
6114 __INST(greenMask) = __MKSMALLINT(visual->green_mask); |
6114 __INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
6115 __INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
6115 switch (visual->class) { |
6116 switch (visual->class) { |
6116 case TrueColor: |
6117 case TrueColor: |
6117 /* extract number of bits and shift counts */ |
6118 /* extract number of bits and shift counts */ |
6118 mask = visual->red_mask; |
6119 mask = visual->red_mask; |
6119 shift = 0; |
6120 shift = 0; |
6120 while (mask && ((mask & 1) == 0)) { |
6121 while (mask && ((mask & 1) == 0)) { |
6121 mask >>= 1; |
6122 mask >>= 1; |
6122 shift++; |
6123 shift++; |
6123 } |
6124 } |
6124 __INST(redShift) = __MKSMALLINT(shift); |
6125 __INST(redShift) = __MKSMALLINT(shift); |
6125 nBits = 0; |
6126 nBits = 0; |
6126 while (mask) { |
6127 while (mask) { |
6127 mask >>= 1; |
6128 mask >>= 1; |
6128 nBits++; |
6129 nBits++; |
6129 } |
6130 } |
6130 __INST(bitsRed) = __MKSMALLINT(nBits); |
6131 __INST(bitsRed) = __MKSMALLINT(nBits); |
6131 |
6132 |
6132 mask = visual->green_mask; |
6133 mask = visual->green_mask; |
6133 shift = 0; |
6134 shift = 0; |
6134 while (mask && ((mask & 1) == 0)) { |
6135 while (mask && ((mask & 1) == 0)) { |
6135 mask >>= 1; |
6136 mask >>= 1; |
6136 shift++; |
6137 shift++; |
6137 } |
6138 } |
6138 __INST(greenShift) = __MKSMALLINT(shift); |
6139 __INST(greenShift) = __MKSMALLINT(shift); |
6139 nBits = 0; |
6140 nBits = 0; |
6140 while (mask) { |
6141 while (mask) { |
6141 mask >>= 1; |
6142 mask >>= 1; |
6142 nBits++; |
6143 nBits++; |
6143 } |
6144 } |
6144 __INST(bitsGreen) = __MKSMALLINT(nBits); |
6145 __INST(bitsGreen) = __MKSMALLINT(nBits); |
6145 |
6146 |
6146 mask = visual->blue_mask; |
6147 mask = visual->blue_mask; |
6147 shift = 0; |
6148 shift = 0; |
6148 while (mask && ((mask & 1) == 0)) { |
6149 while (mask && ((mask & 1) == 0)) { |
6149 mask >>= 1; |
6150 mask >>= 1; |
6150 shift++; |
6151 shift++; |
6151 } |
6152 } |
6152 __INST(blueShift) = __MKSMALLINT(shift); |
6153 __INST(blueShift) = __MKSMALLINT(shift); |
6153 nBits = 0; |
6154 nBits = 0; |
6154 while (mask) { |
6155 while (mask) { |
6155 mask >>= 1; |
6156 mask >>= 1; |
6156 nBits++; |
6157 nBits++; |
6157 } |
6158 } |
6158 __INST(bitsBlue) = __MKSMALLINT(nBits); |
6159 __INST(bitsBlue) = __MKSMALLINT(nBits); |
6159 break; |
6160 break; |
6160 } |
6161 } |
6161 |
6162 |
6162 #ifndef XA_PRIMARY |
6163 #ifndef XA_PRIMARY |
6163 __INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
6164 __INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
6164 #else |
6165 #else |
6165 __INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
6166 __INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
6166 #endif |
6167 #endif |
6167 #ifndef XA_SECONDARY |
6168 #ifndef XA_SECONDARY |
6168 __INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
6169 __INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
6169 #else |
6170 #else |
6170 __INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
6171 __INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
6171 #endif |
6172 #endif |
6172 #ifndef XA_CUT_BUFFER0 |
6173 #ifndef XA_CUT_BUFFER0 |
6173 __INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
6174 __INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
6174 #else |
6175 #else |
6175 __INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
6176 __INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
6176 #endif |
6177 #endif |
6177 #ifndef XA_STRING |
6178 #ifndef XA_STRING |
6178 __INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
6179 __INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
6179 #else |
6180 #else |
6180 __INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
6181 __INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
6181 #endif |
6182 #endif |
6182 #ifndef XA_LENGTH |
6183 #ifndef XA_LENGTH |
6183 __INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
6184 __INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
6184 #else |
6185 #else |
6185 __INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
6186 __INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
6186 #endif |
6187 #endif |
6187 |
6188 |
6188 END_INTERRUPTSBLOCKED |
6189 END_INTERRUPTSBLOCKED |
6189 } |
6190 } |
6190 %}. |
6191 %}. |
6191 ! |
6192 ! |
6192 |
6193 |
6193 initializeSpecialFlags |
6194 initializeSpecialFlags |