4746 self setLastCopyBuffer:(self getCopyBuffer). |
4746 self setLastCopyBuffer:(self getCopyBuffer). |
4747 self setCopyBuffer:nil |
4747 self setCopyBuffer:nil |
4748 |
4748 |
4749 "/ noone is interested in that ... |
4749 "/ noone is interested in that ... |
4750 "/ aView selectionClear:selectionID |
4750 "/ aView selectionClear:selectionID |
|
4751 |
|
4752 ! |
|
4753 |
|
4754 selectionClear:aView selection:selectionID time:time |
|
4755 "sent when another X-client has created a selection. |
|
4756 This is a very X-specific mechanism." |
|
4757 |
|
4758 "/ |
|
4759 "/ workaround a bug in olvwm: it clears selections |
|
4760 "/ on window raise. |
|
4761 "/ In this case, keep my last own selection. |
|
4762 "/ |
|
4763 |
|
4764 self setLastCopyBuffer:(self getCopyBuffer). |
|
4765 self setCopyBuffer:nil |
|
4766 |
|
4767 "/ noone is interested in that ... |
|
4768 "/ aView selectionClear:selectionID |
|
4769 ! |
|
4770 |
|
4771 selectionClear:selectionID view:aView |
|
4772 "OBSOLETE - this will vanish" |
|
4773 |
|
4774 "sent when another X-client has created a selection. |
|
4775 This is a very X-specific mechanism." |
|
4776 |
|
4777 "/ |
|
4778 "/ workaround a bug in olvwm: it clears selections |
|
4779 "/ on window raise. |
|
4780 "/ In this case, keep my last own selection. |
|
4781 "/ |
|
4782 |
|
4783 self setLastCopyBuffer:(self getCopyBuffer). |
|
4784 self setCopyBuffer:nil |
|
4785 |
|
4786 "/ noone is interested in that ... |
|
4787 "/ aView selectionClear:selectionID |
|
4788 ! |
|
4789 |
|
4790 selectionNotify:aView selection:selectionID target:targetID property:propertyID requestor:requestorID time:time |
|
4791 "sent when the server returns an answer from a request for a selection. |
|
4792 This is a very X-specific mechanism." |
|
4793 |
|
4794 |s sensor| |
|
4795 |
|
4796 propertyID == 0 ifTrue:[ |
|
4797 "invalid olvwm behavior" |
|
4798 s := self getLastCopyBuffer |
|
4799 ] ifFalse:[ |
|
4800 targetID == self atomIDOfSTRING ifTrue:[ |
|
4801 " |
|
4802 a returned string |
|
4803 " |
|
4804 s := self getTextProperty:propertyID from:requestorID. |
|
4805 s notNil ifTrue:[ |
|
4806 (s endsWith:Character cr) ifTrue:[ |
|
4807 s := s asStringCollection copyWith:'' |
|
4808 ] |
|
4809 ] |
|
4810 ] ifFalse:[ |
|
4811 " |
|
4812 a returned object |
|
4813 " |
|
4814 s := self getObjectProperty:propertyID from:requestorID. |
|
4815 ]. |
|
4816 ]. |
|
4817 |
|
4818 s notNil ifTrue:[ |
|
4819 (sensor := aView sensor) notNil ifTrue:[ |
|
4820 sensor pasteFromClipBoard:s view:aView |
|
4821 ] ifFalse:[ |
|
4822 " |
|
4823 if there is no sensor ... |
|
4824 " |
|
4825 aView pasteFromClipBoard:s |
|
4826 ] |
|
4827 ] |
4751 ! |
4828 ! |
4752 |
4829 |
4753 selectionNotify:propertyID target:targetID selection:selectionID from:requestorID view:aView |
4830 selectionNotify:propertyID target:targetID selection:selectionID from:requestorID view:aView |
4754 "sent when the server returns an answer from a request for a selection. |
4831 "sent when the server returns an answer from a request for a selection. |
4755 This is a very X-specific mechanism." |
4832 This is a very X-specific mechanism." |
4786 if there is no sensor ... |
4863 if there is no sensor ... |
4787 " |
4864 " |
4788 aView pasteFromClipBoard:s |
4865 aView pasteFromClipBoard:s |
4789 ] |
4866 ] |
4790 ] |
4867 ] |
|
4868 ! |
|
4869 |
|
4870 selectionRequest:aView requestor:requestorID selection:selectionID target:targetID property:propertyID time:time |
|
4871 "sent by some other X-client to ask for the selection. |
|
4872 This is a very X-specific mechanism." |
|
4873 |
|
4874 |o s stream| |
|
4875 |
|
4876 "/targetID printCR. |
|
4877 |
|
4878 targetID == (self atomIDOfLENGTH) ifTrue:[ |
|
4879 "/ |
|
4880 "/ the other one wants to know the size of our selection ... |
|
4881 "/ |
|
4882 s := self selectionAsString. |
|
4883 self |
|
4884 setLengthProperty:propertyID |
|
4885 value:s size |
|
4886 for:requestorID. |
|
4887 |
|
4888 self |
|
4889 sendSelectionNotifySelection:selectionID |
|
4890 property:propertyID |
|
4891 target:targetID |
|
4892 time:time |
|
4893 from:aView id |
|
4894 to:requestorID. |
|
4895 ^ self |
|
4896 ]. |
|
4897 |
|
4898 (targetID == self atomIDOfSTRING or:[ |
|
4899 targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[ |
|
4900 "/ |
|
4901 "/ the other view wants the selection as string |
|
4902 "/ |
|
4903 s := self selectionAsString. |
|
4904 |
|
4905 self |
|
4906 sendSelection:s |
|
4907 selection:primaryAtom |
|
4908 property:propertyID |
|
4909 target:self atomIDOfSTRING "/ targetID, once I can provide compountText as well |
|
4910 time:time |
|
4911 from:requestorID |
|
4912 to:requestorID. |
|
4913 ^ self |
|
4914 ]. |
|
4915 |
|
4916 "/ (targetID == (self atomIDOf:'TARGETS')) ifTrue:[ |
|
4917 "/"/ TODO: implement this to avoid netscape paste-delay. |
|
4918 "/"/ |
|
4919 "/ ^ self |
|
4920 "/ ]. |
|
4921 |
|
4922 (targetID == (self atomIDOf:'ST_OBJECT')) ifTrue:[ |
|
4923 "/ |
|
4924 "/ send the selection in binaryStore format |
|
4925 "/ (assuming, that the other view knows how to handle it) |
|
4926 "/ |
|
4927 o := self getCopyBuffer. |
|
4928 stream := WriteStream on:(ByteArray new:200). |
|
4929 o storeBinaryOn:stream. |
|
4930 |
|
4931 ^ self |
|
4932 sendSelection:(stream contents) |
|
4933 selection:primaryAtom |
|
4934 property:propertyID |
|
4935 target:targetID |
|
4936 time:time |
|
4937 from:aView id |
|
4938 to:requestorID |
|
4939 ]. |
|
4940 |
4791 ! |
4941 ! |
4792 |
4942 |
4793 selectionRequest:propertyID target:targetID selection:selectionID time:t from:windowID view:aView |
4943 selectionRequest:propertyID target:targetID selection:selectionID time:t from:windowID view:aView |
4794 "sent by some other X-client to ask for the selection. |
4944 "sent by some other X-client to ask for the selection. |
4795 This is a very X-specific mechanism." |
4945 This is a very X-specific mechanism." |
5221 |
5371 |
5222 case SelectionNotify: |
5372 case SelectionNotify: |
5223 /* |
5373 /* |
5224 * returned selection value (answer from SelectionRequest) |
5374 * returned selection value (answer from SelectionRequest) |
5225 */ |
5375 */ |
5226 __ArrayInstPtr(eventArr)->a_element[2] = @symbol(selectionNotify:selection:target:property:time:); |
5376 __ArrayInstPtr(eventArr)->a_element[2] = @symbol(selectionNotify:selection:target:property:requestor:time:); |
5227 __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(ev->xselectionrequest.selection); __STORE(eventArr, t); |
5377 __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(ev->xselection.selection); __STORE(eventArr, t); |
5228 __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(ev->xselectionrequest.target); __STORE(eventArr, t); |
5378 __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(ev->xselection.target); __STORE(eventArr, t); |
5229 __ArrayInstPtr(eventArr)->a_element[5] = t = __MKUINT(ev->xselectionrequest.property); __STORE(eventArr, t); |
5379 __ArrayInstPtr(eventArr)->a_element[5] = t = __MKUINT(ev->xselection.property); __STORE(eventArr, t); |
5230 __ArrayInstPtr(eventArr)->a_element[6] = t = __MKUINT(ev->xselectionrequest.time); __STORE(eventArr, t); |
5380 __ArrayInstPtr(eventArr)->a_element[6] = t = __MKEXTERNALADDRESS(ev->xselection.requestor); __STORE(eventArr, t); |
|
5381 __ArrayInstPtr(eventArr)->a_element[7] = t = __MKUINT(ev->xselection.time); __STORE(eventArr, t); |
|
5382 |
5231 RETURN (true); |
5383 RETURN (true); |
5232 |
5384 |
5233 case ColormapNotify: |
5385 case ColormapNotify: |
5234 __ArrayInstPtr(eventArr)->a_element[2] = @symbol(colormapNotify:state:); |
5386 __ArrayInstPtr(eventArr)->a_element[2] = @symbol(colormapNotify:state:); |
5235 __ArrayInstPtr(eventArr)->a_element[3] = cme->state == ColormapInstalled ? true : false; |
5387 __ArrayInstPtr(eventArr)->a_element[3] = cme->state == ColormapInstalled ? true : false; |
9590 %{ /* UNLIMITEDSTACK */ |
9737 %{ /* UNLIMITEDSTACK */ |
9591 if (__isAtomID(propertyID) |
9738 if (__isAtomID(propertyID) |
9592 && __isAtomID(typeID) |
9739 && __isAtomID(typeID) |
9593 && ISCONNECTED |
9740 && ISCONNECTED |
9594 && (__isString(anObject) |
9741 && (__isString(anObject) |
9595 || __isSmallInteger(anObject) |
9742 || __isSmallInteger(anObject) |
9596 || __isSymbol(anObject) |
9743 || __isSymbol(anObject) |
9597 || __isByteArray(anObject) |
9744 || __isByteArray(anObject) |
9598 || __isWords(anObject))) { |
9745 || __isWords(anObject))) { |
9599 |
9746 |
9600 Display *dpy = myDpy; |
9747 Display *dpy = myDpy; |
9601 Atom prop, type; |
9748 Atom prop, type; |
9602 Window window; |
9749 Window window; |
9603 unsigned INT value; |
9750 unsigned INT value; |
9604 |
9751 |
9605 prop = _AtomVal(propertyID); |
9752 prop = _AtomVal(propertyID); |
9606 type = _AtomVal(typeID); |
9753 type = _AtomVal(typeID); |
9607 |
9754 |
9608 if (__isExternalAddress(aWindowID)) { |
9755 if (__isExternalAddress(aWindowID)) { |
9609 window = _WindowVal(aWindowID); |
9756 window = _WindowVal(aWindowID); |
9610 } else { |
9757 } else if (__isSmallInteger(aWindowID)) { |
9611 window = DefaultRootWindow(dpy); |
9758 window = (Window)__smallIntegerVal(aWindowID); |
9612 } |
9759 } else if (aWindowID == nil) { |
9613 |
9760 window = DefaultRootWindow(dpy); |
9614 if (__isSmallInteger(anObject)) { |
9761 } else { |
9615 value = __intVal(anObject); |
9762 window = (Window)__unsignedLongIntVal(aWindowID); |
9616 XChangeProperty(dpy, window, prop, type, 32, |
9763 } |
9617 PropModeReplace, |
9764 |
9618 (unsigned char *)(&value), sizeof(unsigned int)); |
9765 if (__isSmallInteger(anObject)) { |
9619 } else { |
9766 value = __intVal(anObject); |
9620 if (__isByteArray(anObject)) { |
9767 XChangeProperty(dpy, window, prop, type, 32, |
9621 XChangeProperty(dpy, window, prop, type, 8, |
9768 PropModeReplace, |
9622 PropModeReplace, |
9769 (unsigned char *)(&value), sizeof(unsigned int)); |
9623 __ByteArrayInstPtr(anObject)->ba_element, |
9770 } else { |
9624 __byteArraySize(anObject)); |
9771 if (__isByteArray(anObject)) { |
9625 } else { |
9772 XChangeProperty(dpy, window, prop, type, 8, |
9626 /* string or symbol or wordArray-like (16bit-string) object */ |
9773 PropModeReplace, |
9627 if (__isWords(__qClass(anObject))) { |
9774 __ByteArrayInstPtr(anObject)->ba_element, |
9628 XChangeProperty(dpy, window, prop, type, 16, |
9775 __byteArraySize(anObject)); |
9629 PropModeReplace, |
9776 } else { |
9630 __stringVal(anObject), |
9777 /* string or symbol or wordArray-like (16bit-string) object */ |
9631 __wordArraySize(anObject)); |
9778 if (__isWords(__qClass(anObject))) { |
9632 } else { |
9779 XChangeProperty(dpy, window, prop, type, 16, |
9633 /* must be string or symbol */ |
9780 PropModeReplace, |
9634 XChangeProperty(dpy, window, prop, type, 8, |
9781 __stringVal(anObject), |
9635 PropModeReplace, |
9782 __wordArraySize(anObject)); |
9636 __stringVal(anObject), |
9783 } else { |
9637 __stringSize(anObject)); |
9784 /* must be string or symbol */ |
9638 } |
9785 XChangeProperty(dpy, window, prop, type, 8, |
9639 } |
9786 PropModeReplace, |
9640 } |
9787 __stringVal(anObject), |
9641 DPRINTF(("changeProp win=%x prop=%x type=%x\n", window, prop, type)); |
9788 __stringSize(anObject)); |
9642 RETURN (true); |
9789 } |
|
9790 } |
|
9791 } |
|
9792 DPRINTF(("changeProp win=%x prop=%x type=%x\n", window, prop, type)); |
|
9793 RETURN (true); |
9643 } |
9794 } |
9644 %}. |
9795 %}. |
9645 ^ false |
9796 ^ false |
9646 ! |
9797 ! |
9647 |
9798 |
10148 sendSelectionNotifySelection:selectionID property:propertyID target:targetID time:t from:windowID to:requestorID |
10299 sendSelectionNotifySelection:selectionID property:propertyID target:targetID time:t from:windowID to:requestorID |
10149 "send a selectionNotify back from a SelectionRequest" |
10300 "send a selectionNotify back from a SelectionRequest" |
10150 |
10301 |
10151 %{ /* NOCONTEXT */ |
10302 %{ /* NOCONTEXT */ |
10152 if (__isAtomID(propertyID) |
10303 if (__isAtomID(propertyID) |
10153 && __isExternalAddress(requestorID) |
|
10154 && ISCONNECTED |
10304 && ISCONNECTED |
10155 && __isAtomID(targetID) |
10305 && __isAtomID(targetID) |
10156 && __isAtomID(selectionID)) { |
10306 && __isAtomID(selectionID)) { |
10157 Display *dpy = myDpy; |
10307 Display *dpy = myDpy; |
10158 XEvent ev; |
10308 XEvent ev; |
10159 Window requestor = _WindowVal(requestorID); |
10309 Window requestor, originator; |
10160 Atom property = _AtomVal(propertyID); |
10310 Atom property = _AtomVal(propertyID); |
10161 Atom target = _AtomVal(targetID); |
10311 Atom target = _AtomVal(targetID); |
10162 Atom selection = _AtomVal(selectionID); |
10312 Atom selection = _AtomVal(selectionID); |
10163 Status result; |
10313 Status result; |
10164 |
10314 |
10165 ev.xselection.type = SelectionNotify; |
10315 if (__isExternalAddress(requestorID)) { |
10166 ev.xselection.display = dpy; |
10316 requestor = _WindowVal(requestorID); |
10167 ev.xselection.selection = selection; |
10317 } else if (__isSmallInteger(requestorID)) { |
10168 ev.xselection.target = target; |
10318 requestor = (Window)__smallIntegerVal(requestorID); |
10169 if (__isExternalAddress(windowID)) |
10319 } else if (requestorID == nil) { |
10170 ev.xselection.requestor = _WindowVal(windowID); |
10320 requestor = DefaultRootWindow(dpy); |
10171 else |
10321 } else { |
10172 ev.xselection.requestor = DefaultRootWindow(dpy); |
10322 requestor = (Window)__unsignedLongIntVal(requestorID); |
10173 if (__isExternalAddress(t)) { |
10323 } |
10174 ev.xselection.time = (INT)(__externalAddressVal(t)); |
10324 if (__isExternalAddress(windowID)) { |
10175 } else { |
10325 originator = _WindowVal(windowID); |
10176 ev.xselection.time = CurrentTime; |
10326 } else if (__isSmallInteger(windowID)) { |
10177 } |
10327 originator = (Window)__smallIntegerVal(windowID); |
10178 if (property == None) |
10328 } else if (windowID == nil) { |
10179 ev.xselection.property = target; |
10329 originator = DefaultRootWindow(dpy); |
10180 else |
10330 } else { |
10181 ev.xselection.property = property; |
10331 originator = (Window)__unsignedLongIntVal(windowID); |
10182 |
10332 } |
10183 DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
10333 |
10184 ev.xselection.selection, |
10334 ev.xselection.type = SelectionNotify; |
10185 ev.xselection.property, |
10335 ev.xselection.display = dpy; |
10186 ev.xselection.target, |
10336 ev.xselection.selection = selection; |
10187 ev.xselection.requestor, |
10337 ev.xselection.target = target; |
10188 requestor)); |
10338 ev.xselection.requestor = originator; |
10189 |
10339 |
10190 ENTER_XLIB(); |
10340 if (__isExternalAddress(t)) { |
10191 result = XSendEvent(dpy, requestor, False, 0 , &ev); |
10341 ev.xselection.time = (INT)(__externalAddressVal(t)); |
10192 LEAVE_XLIB(); |
10342 } else if (__isSmallInteger(t)) { |
10193 |
10343 ev.xselection.time = __smallIntegerVal(t); |
10194 if ((result == BadValue) || (result == BadWindow)) { |
10344 } else if (t == nil) { |
10195 DPRINTF(("bad status\n")); |
10345 ev.xselection.time = CurrentTime; |
10196 RETURN (false); |
10346 } else { |
10197 } |
10347 ev.xselection.time = (INT)__unsignedLongIntVal(t); |
10198 ENTER_XLIB(); |
10348 } |
10199 XFlush(dpy); |
10349 #if 0 |
10200 LEAVE_XLIB(); |
10350 printf("ev.xselection.selection: %x\n", ev.xselection.selection); |
10201 RETURN (true) |
10351 printf("ev.xselection.target: %x\n", ev.xselection.target); |
|
10352 printf("ev.xselection.requestor: %x\n", ev.xselection.requestor); |
|
10353 printf("ev.xselection.time: %x\n", ev.xselection.time); |
|
10354 printf("requestor: %x\n", requestor); |
|
10355 #endif |
|
10356 if (property == None) |
|
10357 ev.xselection.property = target; |
|
10358 else |
|
10359 ev.xselection.property = property; |
|
10360 |
|
10361 DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
10362 ev.xselection.selection, |
|
10363 ev.xselection.property, |
|
10364 ev.xselection.target, |
|
10365 ev.xselection.requestor, |
|
10366 requestor)); |
|
10367 |
|
10368 ENTER_XLIB(); |
|
10369 result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
10370 LEAVE_XLIB(); |
|
10371 |
|
10372 if ((result == BadValue) || (result == BadWindow)) { |
|
10373 DPRINTF(("bad status\n")); |
|
10374 RETURN (false); |
|
10375 } |
|
10376 ENTER_XLIB(); |
|
10377 XFlush(dpy); |
|
10378 LEAVE_XLIB(); |
|
10379 RETURN (true) |
10202 } |
10380 } |
10203 %}. |
10381 %}. |
10204 self primitiveFailed. |
10382 self primitiveFailed. |
10205 ^ false |
10383 ^ false |
10206 |
10384 |