mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-23 16:10:52 +00:00
2004-09-04 23:59 Alexander Malmberg <alexander@malmberg.org>
* Tools/GNUmakefile.preamble: Compile with -Wall. * Tools/xpbs.m: Rename to +initializePasteboard. Return NO iff XOpenDisplay fails. * Tools/win32pbs.m (+initialize): Rename to +initializePasteboard. Return YES. * Tools/gpbs.m ([PasteboardServer -init]): Call +initializePasteboard instead of +class. Set xPbClass to nil if the call fails. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@19992 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
868cbc0b01
commit
b1d769a07f
5 changed files with 109 additions and 92 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2004-09-05 00:05 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Tools/GNUmakefile.preamble: Compile with -Wall.
|
||||
* Tools/xpbs.m: Rename to +initializePasteboard. Return NO iff
|
||||
XOpenDisplay fails.
|
||||
* Tools/win32pbs.m (+initialize): Rename to +initializePasteboard.
|
||||
Return YES.
|
||||
* Tools/gpbs.m ([PasteboardServer -init]): Call +initializePasteboard
|
||||
instead of +class. Set xPbClass to nil if the call fails.
|
||||
|
||||
2004-09-01 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* configure.ac: Prepend don't overwrite CFLAGS and LDFLAGS given
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#ADDITIONAL_CPPFLAGS +=
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
#ADDITIONAL_OBJCFLAGS +=
|
||||
ADDITIONAL_OBJCFLAGS += -Wall
|
||||
|
||||
# Additional flags to pass to the C compiler
|
||||
#ADDITIONAL_CFLAGS +=
|
||||
|
|
11
Tools/gpbs.m
11
Tools/gpbs.m
|
@ -107,6 +107,7 @@ gpbs_log (int prio)
|
|||
|
||||
@protocol XPb
|
||||
+ (id) ownerByOsPb: (NSString*)p;
|
||||
+ (BOOL) initializePasteboard;
|
||||
@end
|
||||
static Class xPbClass;
|
||||
|
||||
|
@ -1046,7 +1047,15 @@ NSMutableDictionary *pasteboards = nil;
|
|||
#else
|
||||
xPbClass = NSClassFromString(@"XPbOwner");
|
||||
#endif
|
||||
[xPbClass class];
|
||||
|
||||
/*
|
||||
If the OS pasteboard system fails to initialize, pretend that it isn't
|
||||
there. In practice, this happens if gpbs has been compiled with X
|
||||
support but is run on a display-less system. Note that
|
||||
+initializePasteboard will already have printed a warning in this case.
|
||||
*/
|
||||
if (xPbClass && ![xPbClass initializePasteboard])
|
||||
xPbClass = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
|||
|
||||
@implementation Win32PbOwner
|
||||
|
||||
+ (void) initialize
|
||||
+ (BOOL) initializePasteboard
|
||||
{
|
||||
if (self == [Win32PbOwner class])
|
||||
{
|
||||
|
@ -60,6 +60,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
|||
[NSPasteboard generalPasteboard]];
|
||||
[wpb clipboardHasData];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (id) ownerByOsPb: (NSString*)p
|
||||
|
|
175
Tools/xpbs.m
175
Tools/xpbs.m
|
@ -156,98 +156,95 @@ static NSString *xWaitMode = @"XPasteboardWaitMode";
|
|||
|
||||
@implementation XPbOwner
|
||||
|
||||
+ (void) initialize
|
||||
+ (BOOL) initializePasteboard
|
||||
{
|
||||
if (self == [XPbOwner class])
|
||||
XPbOwner *o;
|
||||
NSPasteboard *p;
|
||||
Atom generalPb, selectionPb;
|
||||
NSRunLoop *l = [NSRunLoop currentRunLoop];
|
||||
int desc;
|
||||
|
||||
ownByO = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
ownByX = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
|
||||
xDisplay = XOpenDisplay(NULL);
|
||||
if (xDisplay == 0)
|
||||
{
|
||||
XPbOwner *o;
|
||||
NSPasteboard *p;
|
||||
Atom generalPb, selectionPb;
|
||||
|
||||
ownByO = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
ownByX = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
|
||||
xDisplay = XOpenDisplay(NULL);
|
||||
if (xDisplay == 0)
|
||||
{
|
||||
NSLog(@"Unable to open X display - no X interoperation available");
|
||||
}
|
||||
else
|
||||
{
|
||||
NSRunLoop *l = [NSRunLoop currentRunLoop];
|
||||
int desc;
|
||||
|
||||
/*
|
||||
* Set up atoms for use in X selection mechanism.
|
||||
*/
|
||||
XInternAtoms(xDisplay, atom_names, sizeof(atom_names)/sizeof(char*),
|
||||
False, atoms);
|
||||
|
||||
xRootWin = RootWindow(xDisplay, DefaultScreen(xDisplay));
|
||||
xAppWin = XCreateSimpleWindow(xDisplay, xRootWin,
|
||||
0, 0, 100, 100, 1, 1, 0L);
|
||||
/*
|
||||
* Add the X descriptor to the run loop so we get callbacks when
|
||||
* X events arrive.
|
||||
*/
|
||||
desc = XConnectionNumber(xDisplay);
|
||||
|
||||
[l addEvent: (void*)(gsaddr)desc
|
||||
type: ET_RDESC
|
||||
watcher: (id<RunLoopEvents>)self
|
||||
forMode: NSDefaultRunLoopMode];
|
||||
|
||||
[l addEvent: (void*)(gsaddr)desc
|
||||
type: ET_RDESC
|
||||
watcher: (id<RunLoopEvents>)self
|
||||
forMode: NSConnectionReplyMode];
|
||||
|
||||
[l addEvent: (void*)(gsaddr)desc
|
||||
type: ET_RDESC
|
||||
watcher: (id<RunLoopEvents>)self
|
||||
forMode: xWaitMode];
|
||||
|
||||
XSelectInput(xDisplay, xAppWin, PropertyChangeMask);
|
||||
XFlush(xDisplay);
|
||||
}
|
||||
|
||||
/*
|
||||
* According to the new open desktop specification
|
||||
* http://www.freedesktop.org/standards/clipboards-spec/clipboards.txt
|
||||
* these two pasteboards should be switched around. That is,
|
||||
* general should be XA_CLIPBOARD and selection XA_PRIMARY.
|
||||
* 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 and 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.
|
||||
* These objects are not released!
|
||||
*/
|
||||
p = [NSPasteboard generalPasteboard];
|
||||
o = [[XPbOwner alloc] initWithXPb: generalPb osPb: p];
|
||||
[o xSelectionClear];
|
||||
|
||||
p = [NSPasteboard pasteboardWithName: @"Selection"];
|
||||
o = [[XPbOwner alloc] initWithXPb: selectionPb osPb: p];
|
||||
[o xSelectionClear];
|
||||
|
||||
// Call this to get the class initialisation
|
||||
[XDragPbOwner class];
|
||||
NSLog(@"Unable to open X display - no X interoperation available");
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up atoms for use in X selection mechanism.
|
||||
*/
|
||||
XInternAtoms(xDisplay, atom_names, sizeof(atom_names)/sizeof(char*),
|
||||
False, atoms);
|
||||
|
||||
xRootWin = RootWindow(xDisplay, DefaultScreen(xDisplay));
|
||||
xAppWin = XCreateSimpleWindow(xDisplay, xRootWin,
|
||||
0, 0, 100, 100, 1, 1, 0L);
|
||||
/*
|
||||
* Add the X descriptor to the run loop so we get callbacks when
|
||||
* X events arrive.
|
||||
*/
|
||||
desc = XConnectionNumber(xDisplay);
|
||||
|
||||
[l addEvent: (void*)(gsaddr)desc
|
||||
type: ET_RDESC
|
||||
watcher: (id<RunLoopEvents>)self
|
||||
forMode: NSDefaultRunLoopMode];
|
||||
|
||||
[l addEvent: (void*)(gsaddr)desc
|
||||
type: ET_RDESC
|
||||
watcher: (id<RunLoopEvents>)self
|
||||
forMode: NSConnectionReplyMode];
|
||||
|
||||
[l addEvent: (void*)(gsaddr)desc
|
||||
type: ET_RDESC
|
||||
watcher: (id<RunLoopEvents>)self
|
||||
forMode: xWaitMode];
|
||||
|
||||
XSelectInput(xDisplay, xAppWin, PropertyChangeMask);
|
||||
XFlush(xDisplay);
|
||||
|
||||
/*
|
||||
* According to the new open desktop specification
|
||||
* http://www.freedesktop.org/standards/clipboards-spec/clipboards.txt
|
||||
* these two pasteboards should be switched around. That is,
|
||||
* general should be XA_CLIPBOARD and selection XA_PRIMARY.
|
||||
* 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 and 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.
|
||||
* These objects are not released!
|
||||
*/
|
||||
p = [NSPasteboard generalPasteboard];
|
||||
o = [[XPbOwner alloc] initWithXPb: generalPb osPb: p];
|
||||
[o xSelectionClear];
|
||||
|
||||
p = [NSPasteboard pasteboardWithName: @"Selection"];
|
||||
o = [[XPbOwner alloc] initWithXPb: selectionPb osPb: p];
|
||||
[o xSelectionClear];
|
||||
|
||||
// Call this to get the class initialisation
|
||||
[XDragPbOwner class];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (XPbOwner*) ownerByOsPb: (NSString*)p
|
||||
|
|
Loading…
Reference in a new issue