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

George Peter Staplin gstaplin at kemper.freedesktop.org
Tue Sep 30 12:14:00 PDT 2008


 hw/xquartz/pbproxy/app-main.m    |   22 ++-------------
 hw/xquartz/pbproxy/main.m        |   54 ++++++---------------------------------
 hw/xquartz/pbproxy/x-input.m     |   14 +++++-----
 hw/xquartz/pbproxy/x-selection.h |    2 +
 hw/xquartz/pbproxy/x-selection.m |    6 ++++
 5 files changed, 27 insertions(+), 71 deletions(-)

New commits:
commit 602e8ba8f7ee196696bc9e3cea6ecdf3200dcf5c
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Tue Sep 30 13:04:35 2008 -0600

    XQuartz: pbproxy: Make the signal handler safer by using _exit, and only exit.
    
    Remove some unnecesssary headers.
    
    Remove some dead code that was never called or used in pbproxy.
    
    Make use of an NSAutoreleasePool in x_init.  It could potentially cause a leak
    on a startup without this.
    
    Start adding reload_preferences to the x_selection class, as well as event
    handling for that.

diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index b717851..0f2eaf0 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -1,7 +1,7 @@
-/* main.m
+/* app-main.m
  $Id: main.m,v 1.29 2007-04-07 20:39:03 jharper Exp $
  
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved. */
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. */
 
 #include "pbproxy.h"
 #import "x-selection.h"
@@ -9,24 +9,8 @@
 #include <pthread.h>
 #include <unistd.h> /*for getpid*/
 
-#include <X11/extensions/applewm.h>
-
-/* X11 code */
-static void x_shutdown (void) {
-    /*gstaplin: signal_handler() calls this, and I don't think these are async-signal safe. */
-    /*TODO use a socketpair() to trigger a cleanup.  This is totally unsafe according to Jordan.  It's a segfault waiting to happen on a signal*/
-
-    [_selection_object release];
-    _selection_object = nil;
-
-    XCloseDisplay (x_dpy);
-    x_dpy = NULL;
-    exit(0); 
-}
-
-/* Startup */
 static void signal_handler (int sig) {
-    x_shutdown ();
+    _exit(0);
 }
 
 int main (int argc, const char *argv[]) {
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 64b1b32..e2156a7 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -1,53 +1,25 @@
 /* main.m
  $Id: main.m,v 1.29 2007-04-07 20:39:03 jharper Exp $
  
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved. */
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. */
 
 #include "pbproxy.h"
 #import "x-selection.h"
 
 #include <pthread.h>
-#include <unistd.h> /*for getpid*/
-
 #include <X11/extensions/applewm.h>
 
 Display *x_dpy;
 int x_apple_wm_event_base, x_apple_wm_error_base;
 
-static int x_grab_count;
-static Bool x_grab_synced;
-
-static BOOL _is_active = YES;		/* FIXME: should query server */ 
-/*gstaplin: why? Is there a race?*/
-
 x_selection *_selection_object;
 
-/* X11 code */
-void x_grab_server (Bool sync) {
-    if (x_grab_count++ == 0) {
-        XGrabServer (x_dpy);
-    }
-    
-    if (sync && !x_grab_synced) {
-        XSync (x_dpy, False);
-        x_grab_synced = True;
-    }
-}
-
-void x_ungrab_server (void) {
-    if (--x_grab_count == 0) {
-        XUngrabServer (x_dpy);
-        XFlush (x_dpy);
-        x_grab_synced = False;
-    }
-}
-
 static int x_io_error_handler (Display *dpy) {
     /* We lost our connection to the server. */
     
     TRACE ();
 
-    /* TODO: tirgger the thread to restart? */
+    /* TODO: trigger the thread to restart? */
 #ifndef INTEGRATED_XPBPROXY
     exit(1);
 #endif
@@ -60,6 +32,8 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
 }
 
 void x_init (void) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
     x_dpy = XOpenDisplay (NULL);
     if (x_dpy == NULL) {
         fprintf (stderr, "can't open default display\n");
@@ -81,10 +55,13 @@ void x_init (void) {
     _selection_object = [[x_selection alloc] init];
     
     x_input_register ();
-    x_input_run ();
-
+   
     [_selection_object set_clipboard_manager];
     [_selection_object claim_clipboard];
+
+    x_input_run ();
+
+    [pool release];
 }
 
 id x_selection_object (void) {
@@ -96,19 +73,6 @@ Time x_current_timestamp (void) {
     return CurrentTime;
 }
 
-
-/* Finding things */
-BOOL x_get_is_active (void) {
-    return _is_active;
-}
-
-void x_set_is_active (BOOL state) {    
-    if (_is_active == state)
-        return;
-
-    _is_active = state;
-}
-
 void debug_printf (const char *fmt, ...) {
     static int spew = -1;
     
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index fd59881..c5e2b63 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -1,7 +1,7 @@
 /* x-input.m -- event handling
  $Id: x-input.m,v 1.26 2007-04-07 20:39:03 jharper Exp $
  
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved. */
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. */
 
 #include "pbproxy.h"
 #import "x-selection.h"
@@ -15,8 +15,7 @@
 
 #include <unistd.h>
 
-/* FIXME: .. */
-CFRunLoopSourceRef x_dpy_source;
+static CFRunLoopSourceRef x_dpy_source;
 
 /* Timestamp when the X server last told us it's active */
 static Time last_activation_time;
@@ -28,20 +27,22 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
             switch (e->kind) {
                 case AppleWMIsActive:
                     last_activation_time = e->time;
-                    x_set_is_active (YES);
                     [x_selection_object () x_active:e->time];
                     break;
                     
                 case AppleWMIsInactive:
-                    x_set_is_active (NO);
                     [x_selection_object () x_inactive:e->time];
                     break;
+
+  	        case AppleWMReloadPreferences:
+		    [x_selection_object () reload_preferences];
+		    break;
             }
             break;
             
         case AppleWMPasteboardNotify:
             switch (e->kind) {
-                case AppleWMCopyToPasteboard:
+	        case AppleWMCopyToPasteboard:
                     [x_selection_object () x_copy:e->time];
             }
             break;
@@ -128,4 +129,3 @@ void x_input_register(void) {
         exit (1);
     }
 }
-
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index f96d6d4..e653504 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -100,6 +100,8 @@ struct atom_list {
 - (void) set_clipboard_manager;
 - (void) own_clipboard;
 - (void) copy_completed:(Atom)selection;
+
+- (void) reload_preferences;
 @end
 
 /* main.m */
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index b141db0..37b80f8 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -1221,6 +1221,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     }
 }
 
+- (void) reload_preferences
+{
+    
+}
+
+
 
 /* NSPasteboard-required methods */
 


More information about the xorg-commit mailing list