[XPbOwner initialize] switched the usage of PRIMARY and CLIPBOARD.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@17454 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2003-08-08 10:32:18 +00:00
parent 5a7a2109c2
commit b4c621a255

View file

@ -23,6 +23,7 @@
*/ */
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
#include <Foundation/NSUserDefaults.h>
#include <AppKit/NSPasteboard.h> #include <AppKit/NSPasteboard.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
@ -56,6 +57,7 @@ static char* atom_names[] = {
"TEXT", "TEXT",
"NULL", "NULL",
"FILE_NAME", "FILE_NAME",
"CLIPBOARD",
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
"UTF8_STRING" "UTF8_STRING"
#endif #endif
@ -81,8 +83,9 @@ static Atom atoms[sizeof(atom_names)/sizeof(char*)];
#define XG_TEXT atoms[12] #define XG_TEXT atoms[12]
#define XG_NULL atoms[13] #define XG_NULL atoms[13]
#define XG_FILE_NAME atoms[14] #define XG_FILE_NAME atoms[14]
#define XA_CLIPBOARD atoms[15]
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
#define XG_UTF8_STRING atoms[15] #define XG_UTF8_STRING atoms[16]
#endif #endif
@ -254,7 +257,7 @@ static NSString *xWaitMode = @"XPasteboardWaitMode";
{ {
XPbOwner *o; XPbOwner *o;
NSPasteboard *p; NSPasteboard *p;
Atom XA_CLIPBOARD; Atom generalPb, selectionPb;
ownByO = NSCreateMapTable(NSObjectMapKeyCallBacks, ownByO = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 0); NSNonOwnedPointerMapValueCallBacks, 0);
@ -307,31 +310,35 @@ static NSString *xWaitMode = @"XPasteboardWaitMode";
} }
/* /*
* According to the new open desktop specification these * According to the new open desktop specification
* two pasteboards should be switched around. That is, * http://www.freedesktop.org/standards/clipboards-spec/clipboards.txt
* general should be XA_CLIPBOARD and selection * these two pasteboards should be switched around. That is,
* XA_PRIMARY. The problem is that most X programs still * general should be XA_CLIPBOARD and selection XA_PRIMARY.
* use the old way. So we do the same for now. * The problem is that most X programs still use the old way.
* For these environments we offer a switch to the old mode.
*/ */
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"GSOldClipboard"])
{
generalPb = XA_PRIMARY;
selectionPb = XA_CLIPBOARD;
}
else
{
generalPb = XA_CLIPBOARD;
selectionPb = XA_PRIMARY;
}
/* /*
* For the general pasteboard we establish an initial owner that is the * For the general and the selection pasteboard we establish an initial
* X selection system. In this way, any X window selection already * owner that is the X selection system. In this way, any X window
* active will be available to the GNUstep system. * selection already active will be available to the GNUstep system.
* This object is not released! * These objects are not released!
*/ */
p = [NSPasteboard generalPasteboard]; p = [NSPasteboard generalPasteboard];
o = [[XPbOwner alloc] initWithXPb: XA_PRIMARY osPb: p]; o = [[XPbOwner alloc] initWithXPb: generalPb osPb: p];
[o xSelectionClear]; [o xSelectionClear];
/*
* For the selection pasteboard we establish an initial owner that is the
* X selection system. In this way, any X window selection already
* active will be available to the GNUstep system.
* This object is not released!
*/
XA_CLIPBOARD = XInternAtom(xDisplay, "CLIPBOARD", False);
p = [NSPasteboard pasteboardWithName: @"Selection"]; p = [NSPasteboard pasteboardWithName: @"Selection"];
o = [[XPbOwner alloc] initWithXPb: XA_CLIPBOARD osPb: p]; o = [[XPbOwner alloc] initWithXPb: selectionPb osPb: p];
[o xSelectionClear]; [o xSelectionClear];
// Call this to get the class initialisation // Call this to get the class initialisation