xserver: Branch 'xorg-server-1.4-apple'

George Peter Staplin gstaplin at kemper.freedesktop.org
Tue Sep 30 23:04:41 PDT 2008


 hw/xquartz/pbproxy/app-main.m    |   14 ++++----------
 hw/xquartz/pbproxy/x-input.m     |    6 +++++-
 hw/xquartz/pbproxy/x-selection.h |    3 ++-
 hw/xquartz/pbproxy/x-selection.m |   28 ++++++++++++++++++++++++----
 4 files changed, 35 insertions(+), 16 deletions(-)

New commits:
commit 4d51ad851e64da83cbdfb0a4a22428418a7bcf75
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Tue Sep 30 23:53:12 2008 -0600

    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.

diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index 0f2eaf0..7611eef 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -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;
 }
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index c5e2b63..c11ffb3 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -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];
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index e653504..9c408b4 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -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 */
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 37b80f8..0997b3a 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.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 */


More information about the xorg-commit mailing list