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. (cherry picked from commit 4d51ad851e64da83cbdfb0a4a22428418a7bcf75)
This commit is contained in:
parent
2a5ce41f03
commit
7bb73a9513
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h> /*for getpid*/
|
#include <unistd.h> /*for getpid*/
|
||||||
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
static void signal_handler (int sig) {
|
static void signal_handler (int sig) {
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
@ -21,16 +22,9 @@ int main (int argc, const char *argv[]) {
|
||||||
signal (SIGINT, signal_handler);
|
signal (SIGINT, signal_handler);
|
||||||
signal (SIGTERM, signal_handler);
|
signal (SIGTERM, signal_handler);
|
||||||
signal (SIGPIPE, SIG_IGN);
|
signal (SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
while (1) {
|
[NSApplication sharedApplication];
|
||||||
NS_DURING
|
[NSApp run];
|
||||||
CFRunLoopRun ();
|
|
||||||
NS_HANDLER
|
|
||||||
NSString *s = [NSString stringWithFormat:@"%@ - %@",
|
|
||||||
[localException name], [localException reason]];
|
|
||||||
fprintf(stderr, "quartz-wm: caught exception: %s\n", [s UTF8String]);
|
|
||||||
NS_ENDHANDLER
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,11 @@ void x_input_run (void) {
|
||||||
XEvent e;
|
XEvent e;
|
||||||
|
|
||||||
XNextEvent (x_dpy, &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) {
|
switch (e.type) {
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
[x_selection_object () clear_event:&e.xselectionclear];
|
[x_selection_object () clear_event:&e.xselectionclear];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* x-selection.h -- proxies between NSPasteboard and X11 selections
|
/* x-selection.h -- proxies between NSPasteboard and X11 selections
|
||||||
$Id: x-selection.h,v 1.2 2002-12-13 00:21:00 jharper Exp $
|
$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
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation files
|
obtaining a copy of this software and associated documentation files
|
||||||
|
@ -102,6 +102,7 @@ struct atom_list {
|
||||||
- (void) copy_completed:(Atom)selection;
|
- (void) copy_completed:(Atom)selection;
|
||||||
|
|
||||||
- (void) reload_preferences;
|
- (void) reload_preferences;
|
||||||
|
- (BOOL) is_active;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* main.m */
|
/* main.m */
|
||||||
|
|
|
@ -324,8 +324,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
|
||||||
DB ("changed pasteboard!\n");
|
DB ("changed pasteboard!\n");
|
||||||
changeCount = countNow;
|
changeCount = countNow;
|
||||||
|
|
||||||
XSetSelectionOwner (x_dpy, atoms->primary, _selection_window, CurrentTime);
|
if (pbproxy_pasteboard_to_primary)
|
||||||
[self own_clipboard];
|
{
|
||||||
|
|
||||||
|
XSetSelectionOwner (x_dpy, atoms->primary, _selection_window, CurrentTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pbproxy_pasteboard_to_clipboard)
|
||||||
|
{
|
||||||
|
[self own_clipboard];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -449,7 +457,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
|
||||||
|
|
||||||
TRACE ();
|
TRACE ();
|
||||||
|
|
||||||
if (NO == pbproxy_clipboard_to_pasteboard)
|
if (!pbproxy_clipboard_to_pasteboard)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
owner = XGetSelectionOwner (x_dpy, atoms->clipboard);
|
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");
|
DB ("No clipboard owner.\n");
|
||||||
[self copy_completed:atoms->clipboard];
|
[self copy_completed:atoms->clipboard];
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
else if (owner == _selection_window)
|
||||||
|
{
|
||||||
|
[self copy_completed:atoms->clipboard];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DB ("requesting targets\n");
|
DB ("requesting targets\n");
|
||||||
|
@ -1223,9 +1236,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
|
||||||
|
|
||||||
- (void) reload_preferences
|
- (void) reload_preferences
|
||||||
{
|
{
|
||||||
|
if (pbproxy_clipboard_to_pasteboard)
|
||||||
|
{
|
||||||
|
[self claim_clipboard];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) is_active
|
||||||
|
{
|
||||||
|
return pbproxy_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* NSPasteboard-required methods */
|
/* NSPasteboard-required methods */
|
||||||
|
|
Loading…
Reference in New Issue