|
From: Bert F. <be...@us...> - 2002-04-11 21:50:31
|
Update of /cvsroot/squeak/squeak/platforms/unix/vm
In directory usw-pr-cvs1:/tmp/cvs-serv1066
Modified Files:
sqXWindow.c
Log Message:
Clipboard handling fix by Ned Konz:
Make clipboard text *from* Squeak be available as both PRIMARY and
CLIPBOARD, and copy only the PRIMARY *to* Squeak.
Index: sqXWindow.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/unix/vm/sqXWindow.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** sqXWindow.c 12 Mar 2002 04:09:33 -0000 1.29
--- sqXWindow.c 11 Apr 2002 21:50:25 -0000 1.30
***************
*** 207,211 ****
char *stEmptySelection= ""; /* immutable "empty string" value */
int stPrimarySelectionSize;/* size of buffer holding selection */
! int stOwnsSelection= 0; /* true if we own the X selection */
XColor stColorBlack; /* black pixel value in stColormap */
XColor stColorWhite; /* white pixel value in stColormap */
--- 207,212 ----
char *stEmptySelection= ""; /* immutable "empty string" value */
int stPrimarySelectionSize;/* size of buffer holding selection */
! int stOwnsSelection= 0; /* true if we own the X PRIMARY selection */
! int stOwnsClipboard= 0; /* true if we own the X CLIPBOARD selection */
XColor stColorBlack; /* black pixel value in stColormap */
XColor stColorWhite; /* white pixel value in stColormap */
***************
*** 234,237 ****
--- 235,240 ----
int browserPipes[]= {-1, -1}; /* read/write fd for communication with browser */
int headless= 0;
+ Atom clipboardAtom= 0;
+ Atom primaryAtom= 0;
#define inBrowser\
***************
*** 641,645 ****
case SelectionClear:
! stOwnsSelection= 0;
break;
--- 644,651 ----
case SelectionClear:
! if (((XSelectionClearEvent *)theEvent)->selection == clipboardAtom)
! stOwnsClipboard= 0;
! else if (((XSelectionClearEvent *)theEvent)->selection == primaryAtom)
! stOwnsSelection= 0;
break;
***************
*** 688,692 ****
{
case SelectionClear:
! stOwnsSelection= 0;
break;
case SelectionRequest:
--- 694,701 ----
{
case SelectionClear:
! if (((XSelectionClearEvent*)&theEvent)->selection == clipboardAtom)
! stOwnsClipboard= 0;
! else if (((XSelectionClearEvent*)&theEvent)->selection == primaryAtom)
! stOwnsSelection= 0;
break;
case SelectionRequest:
***************
*** 752,758 ****
void claimSelection(void)
{
! XSetSelectionOwner(stDisplay, XA_PRIMARY, stWindow, lastKeystrokeTime);
XFlush(stDisplay);
! stOwnsSelection= (XGetSelectionOwner(stDisplay, XA_PRIMARY) == stWindow);
}
--- 761,769 ----
void claimSelection(void)
{
! XSetSelectionOwner(stDisplay, clipboardAtom, stWindow, lastKeystrokeTime);
! XSetSelectionOwner(stDisplay, primaryAtom, stWindow, lastKeystrokeTime);
XFlush(stDisplay);
! stOwnsClipboard= (XGetSelectionOwner(stDisplay, clipboardAtom) == stWindow);
! stOwnsSelection= (XGetSelectionOwner(stDisplay, primaryAtom) == stWindow);
}
***************
*** 805,810 ****
char *data;
! /* request the selection */
! XConvertSelection(stDisplay, XA_PRIMARY, XA_STRING, XA_STRING, stWindow, CurrentTime);
/* wait for selection notification, ignoring (most) other events. */
--- 816,821 ----
char *data;
! /* request the PRIMARY selection, since this should be the same as the CLIPBOARD */
! XConvertSelection(stDisplay, primaryAtom, XA_STRING, XA_STRING, stWindow, CurrentTime);
/* wait for selection notification, ignoring (most) other events. */
***************
*** 1606,1609 ****
--- 1617,1623 ----
completionType= XShmGetEventBase(stDisplay) + ShmCompletion;
# endif
+
+ clipboardAtom = XInternAtom(stDisplay, "CLIPBOARD", False);
+ primaryAtom = XInternAtom(stDisplay, "PRIMARY", False);
}
***************
*** 3749,3752 ****
--- 3763,3767 ----
stPrimarySelectionSize= 0;
stOwnsSelection= 0;
+ stOwnsClipboard= 0;
}
#endif
***************
*** 3755,3759 ****
{
#ifndef HEADLESS
! if (stOwnsSelection)
return stPrimarySelection ? strlen(stPrimarySelection) : 0;
return strlen(getSelection());
--- 3770,3774 ----
{
#ifndef HEADLESS
! if (stOwnsSelection || stOwnsClipboard)
return stPrimarySelection ? strlen(stPrimarySelection) : 0;
return strlen(getSelection());
***************
*** 3815,3819 ****
return 0;
! if (!stOwnsSelection)
{
char *newSelection;
--- 3830,3834 ----
return 0;
! if (!stOwnsSelection && !stOwnsClipboard)
{
char *newSelection;
|