XQuartz: pbproxy: Possibly fix a memory leak by using an [NSApp run] loop,
instead of calling CFRunLoopRun() directly. The leak wasn't reproducible on this machine, but someone was able to produce a leak trace with Instruments that indicates it was leaking in the CFRunLoopRun() path. x-input.m: dequeue and ignore events when pbproxy_active is false. x-selection.h: add an is_active method that is used by x-input.m to ignore events. x-selection.m: Handle nearly every preference, except for primary_on_grab, which I don't really understand yet.
This commit is contained in:
parent
00ca0f4d83
commit
4d51ad851e
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <pthread.h>
|
||||
#include <unistd.h> /*for getpid*/
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
static void signal_handler (int sig) {
|
||||
_exit(0);
|
||||
|
@ -21,16 +22,9 @@ int main (int argc, const char *argv[]) {
|
|||
signal (SIGINT, signal_handler);
|
||||
signal (SIGTERM, signal_handler);
|
||||
signal (SIGPIPE, SIG_IGN);
|
||||
|
||||
while (1) {
|
||||
NS_DURING
|
||||
CFRunLoopRun ();
|
||||
NS_HANDLER
|
||||
NSString *s = [NSString stringWithFormat:@"%@ - %@",
|
||||
[localException name], [localException reason]];
|
||||
fprintf(stderr, "quartz-wm: caught exception: %s\n", [s UTF8String]);
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
[NSApp run];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,11 @@ void x_input_run (void) {
|
|||
XEvent e;
|
||||
|
||||
XNextEvent (x_dpy, &e);
|
||||
|
||||
|
||||
/* If pbproxy isn't active (in the preferences), then don't do anything. */
|
||||
if (![x_selection_object() is_active])
|
||||
continue;
|
||||
|
||||
switch (e.type) {
|
||||
case SelectionClear:
|
||||
[x_selection_object () clear_event:&e.xselectionclear];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* x-selection.h -- proxies between NSPasteboard and X11 selections
|
||||
$Id: x-selection.h,v 1.2 2002-12-13 00:21:00 jharper Exp $
|
||||
|
||||
Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
|
||||
Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
|
@ -102,6 +102,7 @@ struct atom_list {
|
|||
- (void) copy_completed:(Atom)selection;
|
||||
|
||||
- (void) reload_preferences;
|
||||
- (BOOL) is_active;
|
||||
@end
|
||||
|
||||
/* main.m */
|
||||
|
|
|
@ -324,8 +324,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
|
|||
DB ("changed pasteboard!\n");
|
||||
changeCount = countNow;
|
||||
|
||||
XSetSelectionOwner (x_dpy, atoms->primary, _selection_window, CurrentTime);
|
||||
[self own_clipboard];
|
||||
if (pbproxy_pasteboard_to_primary)
|
||||
{
|
||||
|
||||
XSetSelectionOwner (x_dpy, atoms->primary, _selection_window, CurrentTime);
|
||||
}
|
||||
|
||||
if (pbproxy_pasteboard_to_clipboard)
|
||||
{
|
||||
[self own_clipboard];
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -449,7 +457,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
|
|||
|
||||
TRACE ();
|
||||
|
||||
if (NO == pbproxy_clipboard_to_pasteboard)
|
||||
if (!pbproxy_clipboard_to_pasteboard)
|
||||
return;
|
||||
|
||||
owner = XGetSelectionOwner (x_dpy, atoms->clipboard);
|
||||
|
@ -462,6 +470,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
|
|||
DB ("No clipboard owner.\n");
|
||||
[self copy_completed:atoms->clipboard];
|
||||
return;
|
||||
}
|
||||
else if (owner == _selection_window)
|
||||
{
|
||||
[self copy_completed:atoms->clipboard];
|
||||
return;
|
||||
}
|
||||
|
||||
DB ("requesting targets\n");
|
||||
|
@ -1223,9 +1236,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
|
|||
|
||||
- (void) reload_preferences
|
||||
{
|
||||
|
||||
if (pbproxy_clipboard_to_pasteboard)
|
||||
{
|
||||
[self claim_clipboard];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) is_active
|
||||
{
|
||||
return pbproxy_active;
|
||||
}
|
||||
|
||||
|
||||
/* NSPasteboard-required methods */
|
||||
|
|
Loading…
Reference in New Issue
Block a user