10647 unsigned char *data; |
10649 unsigned char *data; |
10648 int ok = 1; |
10650 int ok = 1; |
10649 # define PROP_SIZE 2048 |
10651 # define PROP_SIZE 2048 |
10650 |
10652 |
10651 if (ISCONNECTED) { |
10653 if (ISCONNECTED) { |
10652 Display *dpy = myDpy; |
10654 Display *dpy = myDpy; |
10653 |
10655 |
10654 if (__isAtomID(propertyID)) { |
10656 if (__isAtomID(propertyID)) { |
10655 property = __AtomVal(propertyID); |
10657 property = __AtomVal(propertyID); |
10656 |
10658 |
10657 if (__isExternalAddress(windowID)) { |
10659 if (__isExternalAddress(windowID)) { |
10658 window = __WindowVal(windowID); |
10660 window = __WindowVal(windowID); |
10659 } else if (windowID == nil) { |
10661 } else if (windowID == nil) { |
10660 window = DefaultRootWindow(dpy); |
10662 window = DefaultRootWindow(dpy); |
10661 } else |
10663 } else |
10662 goto fail; |
10664 goto fail; |
10663 |
10665 |
10664 nread = 0; |
10666 nread = 0; |
10665 cp = 0; |
10667 cp = 0; |
10666 #ifdef PROPERTY_DEBUG |
10668 #ifdef PROPERTY_DEBUG |
10667 console_fprintf(stderr, "getProperty %x\n", property); |
10669 console_fprintf(stderr, "getProperty %x\n", property); |
10668 #endif |
10670 #endif |
10669 |
10671 |
10670 do { |
10672 do { |
10671 int retVal; |
10673 int retVal; |
10672 |
10674 |
10673 ENTER_XLIB(); |
10675 ENTER_XLIB(); |
10674 retVal = XGetWindowProperty(dpy, window, property, nread/4, PROP_SIZE, |
10676 retVal = XGetWindowProperty(dpy, window, property, nread/4, PROP_SIZE, |
10675 doDelete == true, |
10677 doDelete == true, |
10676 AnyPropertyType, &actual_type, &actual_format, |
10678 AnyPropertyType, &actual_type, &actual_format, |
10677 &nitems, &bytes_after, (unsigned char **)&data); |
10679 &nitems, &bytes_after, (unsigned char **)&data); |
10678 LEAVE_XLIB(); |
10680 LEAVE_XLIB(); |
10679 if (retVal != Success) { |
10681 if (retVal != Success) { |
10680 #ifdef PROPERTY_DEBUG |
10682 #ifdef PROPERTY_DEBUG |
10681 console_fprintf(stderr, "- no success\n"); |
10683 console_fprintf(stderr, "- no success\n"); |
10682 #endif |
10684 #endif |
10683 ok = 0; |
10685 ok = 0; |
10684 break; |
10686 break; |
10685 } |
10687 } |
10686 #ifdef PROPERTY_DEBUG |
10688 #ifdef PROPERTY_DEBUG |
10687 console_fprintf(stderr, "- type:%x\n", actual_type); |
10689 console_fprintf(stderr, "- type:%x\n", actual_type); |
10688 #endif |
10690 #endif |
10689 nitems *= (actual_format / 8); |
10691 nitems *= (actual_format / 8); |
10690 typeID = __MKATOMOBJ(actual_type); |
10692 typeID = __MKATOMOBJ(actual_type); |
10691 if (! cp) { |
10693 if (! cp) { |
10692 cp = cp2 = (char *)malloc(nitems+bytes_after); |
10694 cp = cp2 = (char *)malloc(nitems+bytes_after); |
10693 } else { |
10695 } else { |
10694 cp2 = cp + nread; |
10696 cp2 = cp + nread; |
10695 } |
10697 } |
10696 if (! cp) { |
10698 if (! cp) { |
10697 XFree(data); |
10699 XFree(data); |
10698 goto fail; |
10700 goto fail; |
10699 } |
10701 } |
10700 |
10702 |
10701 nread += nitems; |
10703 nread += nitems; |
10702 bcopy(data, cp2, nitems); |
10704 bcopy(data, cp2, nitems); |
10703 XFree(data); |
10705 XFree(data); |
10704 #ifdef PROPERTY_DEBUG |
10706 #ifdef PROPERTY_DEBUG |
10705 console_fprintf(stderr, "- <nitems:%d bytes_after:%d>\n", nitems, bytes_after); |
10707 console_fprintf(stderr, "- <nitems:%d bytes_after:%d>\n", nitems, bytes_after); |
10706 #endif |
10708 #endif |
10707 } while (bytes_after > 0); |
10709 } while (bytes_after > 0); |
10708 |
10710 |
10709 if (ok) { |
10711 if (ok) { |
10710 switch (actual_format) { |
10712 switch (actual_format) { |
10711 case 32: |
10713 case 32: |
10712 // bad design: even though it says "32", |
10714 // bad design: even though it says "32", |
10713 // what is really returned are longs. |
10715 // what is really returned are longs. |
10714 // this does make a difference on 64bit machines! |
10716 // this does make a difference on 64bit machines! |
10715 val = __stArrayFromCULongArray((unsigned long*)cp, nread/sizeof(long)); |
10717 val = __stArrayFromCULongArray((unsigned long*)cp, nread/sizeof(long)); |
10716 break; |
10718 break; |
10717 case 16: |
10719 case 16: |
10718 val = __stArrayFromCUShortArray((unsigned short*)cp, nread/2); |
10720 val = __stArrayFromCUShortArray((unsigned short*)cp, nread/2); |
10719 break; |
10721 break; |
10720 case 8: |
10722 case 8: |
10721 default: |
10723 default: |
10722 if (actual_type == XA_STRING) { |
10724 if (actual_type == XA_STRING) { |
10723 val = __MKSTRING_L(cp, nread); |
10725 val = __MKSTRING_L(cp, nread); |
10724 } else { |
10726 } else { |
10725 val = __MKBYTEARRAY(cp, nread); |
10727 val = __MKBYTEARRAY(cp, nread); |
10726 } |
10728 } |
10727 break; |
10729 break; |
10728 } |
10730 } |
10729 } |
10731 } |
10730 if (cp) |
10732 if (cp) |
10731 free(cp); |
10733 free(cp); |
10732 } |
10734 } |
10733 } |
10735 } |
10734 fail: ; |
10736 fail: ; |
10735 %}. |
10737 %}. |
10736 (typeID isNil or:[typeID == 0]) ifTrue:[ |
10738 (typeID isNil or:[typeID == 0]) ifTrue:[ |
10737 "typeID == 0 (None): The property does not exist in the specified window" |
10739 "typeID == 0 (None): The property does not exist in the specified window" |
10738 ^ nil |
10740 ^ nil |
10739 ]. |
10741 ]. |
10740 ^ typeID->val |
10742 ^ typeID->val |
10741 |
10743 |
10742 " |
10744 " |
10743 Display |
10745 Display |
10744 getProperty:#'_NET_WM_ICON_GEOMETRY' |
10746 getProperty:#'_NET_WM_ICON_GEOMETRY' |
10745 from:nil |
10747 from:nil |
10746 delete:false |
10748 delete:false |
10747 |
10749 |
10748 Display |
10750 Display |
10749 getProperty:#'_NET_SUPPORTED' |
10751 getProperty:#'_NET_SUPPORTED' |
10750 from:nil |
10752 from:nil |
10751 delete:false |
10753 delete:false |
10752 |
10754 |
10753 Transcript showCR:( |
10755 Transcript showCR:( |
10754 (Display |
10756 (Display |
10755 getProperty:#'_NET_SUPPORTED' |
10757 getProperty:#'_NET_SUPPORTED' |
10756 from:nil |
10758 from:nil |
10757 delete:false) |
10759 delete:false) |
10758 value |
10760 value |
10759 collect:[:eachID | Display atomName:eachID]) |
10761 collect:[:eachID | Display atomName:eachID]) |
10760 |
10762 |
10761 " |
10763 " |
10762 |
10764 |
10763 "Modified: / 31-08-2017 / 22:01:44 / cg" |
10765 "Modified: / 31-08-2017 / 22:01:44 / cg" |
10764 ! |
10766 ! |
10765 |
10767 |