xserver: Branch 'xorg-server-1.5-apple' - 5 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Wed Oct 15 17:32:11 PDT 2008


 configure.ac                     |    4 
 dix/privates.c                   |  209 ++++++++++++++++++---------------------
 hw/xfree86/ddc/interpret_edid.c  |   41 +++++++
 hw/xquartz/pbproxy/Makefile.am   |    2 
 hw/xquartz/pbproxy/app-main.m    |    3 
 hw/xquartz/pbproxy/main.m        |   13 +-
 hw/xquartz/pbproxy/pbproxy.h     |    4 
 hw/xquartz/pbproxy/x-input.m     |    8 -
 hw/xquartz/pbproxy/x-selection.h |    2 
 hw/xquartz/pbproxy/x-selection.m |   44 ++++++--
 include/privates.h               |    2 
 11 files changed, 203 insertions(+), 129 deletions(-)

New commits:
commit f5201d47d0c7f63d98c847cde82ad97452e412e8
Merge: 02a05bb... 6dcfa99...
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Oct 15 17:31:44 2008 -0700

    Merge branch 'server-1.5-branch' into xorg-server-1.5-apple

commit 02a05bbdf225e2dd0ca14a55bad12d4c5e9c445f
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Oct 15 14:11:18 2008 -0700

    XQuartz: implemented primary-on-grab and fixed clipboard-to-pasteboard
    (cherry picked from commit bcb83eea729a01026d99d1cfc2b77385b5b275fd)

diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am
index fd93ce1..2eee766 100644
--- a/hw/xquartz/pbproxy/Makefile.am
+++ b/hw/xquartz/pbproxy/Makefile.am
@@ -1,5 +1,5 @@
 AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks
-AM_LDFLAGS=-L/usr/X11/lib -lX11 -lAppleWM -framework AppKit -framework Foundation -framework ApplicationServices
+AM_LDFLAGS=-L/usr/X11/lib -lX11 -lXfixes -lAppleWM -framework AppKit -framework Foundation -framework ApplicationServices
 
 SOURCE_FILES = \
 	trick_autotools.c \
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index 4847851..3dfdcb4 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -19,7 +19,8 @@ int main (int argc, const char *argv[]) {
     printf("pid: %u\n", getpid());
 #endif
 
-    x_init ();
+    if(x_init () !=0)
+        return 1;
     
     signal (SIGINT, signal_handler);
     signal (SIGTERM, signal_handler);
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 448bec4..ded18e1 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -8,9 +8,12 @@
 
 #include <pthread.h>
 #include <X11/extensions/applewm.h>
+#include <X11/extensions/xfixes.h>
 
 Display *x_dpy;
 int x_apple_wm_event_base, x_apple_wm_error_base;
+int x_xfixes_event_base, x_xfixes_error_base;
+BOOL have_xfixes;
 
 x_selection *_selection_object;
 
@@ -31,13 +34,13 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
     return 0;
 }
 
-void x_init (void) {
+int x_init (void) {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
     x_dpy = XOpenDisplay (NULL);
     if (x_dpy == NULL) {
         fprintf (stderr, "can't open default display\n");
-        exit (1);
+        return 1;
     }
     
     XSetIOErrorHandler (x_io_error_handler);
@@ -46,9 +49,11 @@ void x_init (void) {
     if (!XAppleWMQueryExtension (x_dpy, &x_apple_wm_event_base,
                                  &x_apple_wm_error_base)) {
         fprintf (stderr, "can't open AppleWM server extension\n");
-        exit (1);
+        return 1;
     }
     
+    have_xfixes = XFixesQueryExtension(x_dpy, &x_xfixes_event_base, &x_xfixes_error_base);
+    
     XAppleWMSelectInput (x_dpy, AppleWMActivationNotifyMask |
                          AppleWMPasteboardNotifyMask);
     
@@ -58,6 +63,8 @@ void x_init (void) {
     x_input_run ();
 
     [pool release];
+    
+    return 0;
 }
 
 id x_selection_object (void) {
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index bfeb868..5d4652b 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -21,10 +21,12 @@ extern void x_set_is_active (BOOL state);
 extern BOOL x_get_is_active (void);
 extern id x_selection_object (void);
 extern Time x_current_timestamp (void);
-extern void x_init (void);
+extern int x_init (void);
 
 extern Display *x_dpy;
 extern int x_apple_wm_event_base, x_apple_wm_error_base;
+extern int x_xfixes_event_base, x_xfixes_error_base;
+extern BOOL have_xfixes;
 
 /* from x-input.m */
 extern void x_input_register (void);
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index 1b2475c..b34c39a 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -87,9 +87,11 @@ void x_input_run (void) {
                 break;
                 
             default:
-                if (e.type - x_apple_wm_event_base >= 0
-                    && e.type - x_apple_wm_event_base < AppleWMNumberEvents) {
-                    x_event_apple_wm_notify ((XAppleWMNotifyEvent *) &e);
+                if(e.type >= x_apple_wm_event_base &&
+                   e.type < x_apple_wm_event_base + AppleWMNumberEvents) {
+                    x_event_apple_wm_notify((XAppleWMNotifyEvent *) &e);
+                } else if(e.type == x_xfixes_event_base + XFixesSelectionNotify) {
+                    [x_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
                 }
                 break;
         }
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index c93b676..0be8d81 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -33,6 +33,7 @@
 
 #include "pbproxy.h"
 #include <AppKit/NSPasteboard.h>
+#include <X11/extensions/xfixes.h>
 
 /* This stores image data or text. */
 struct propdata {
@@ -95,6 +96,7 @@ struct atom_list {
 - (void) request_event:(XSelectionRequestEvent *)e;
 - (void) notify_event:(XSelectionEvent *)e;
 - (void) property_event:(XPropertyEvent *)e;
+- (void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e;
 - (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct propdata *)pdata;
 - (void) claim_clipboard;
 - (BOOL) set_clipboard_manager_status:(BOOL)value;
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 6a1a9fd..888c9e8 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -36,6 +36,7 @@
 #include <X11/Xutil.h>
 #import <AppKit/NSBitmapImageRep.h>
 
+#include <X11/extensions/xfixes.h>
 
 /*
  * The basic design of the pbproxy code is as follows.
@@ -56,12 +57,10 @@
 
 /*
  * TODO:
- * 1. handle primary_on_grab
- * 2. handle  MULTIPLE - I need to study the ICCCM further.
- * 3. Handle PICT images properly.
- * 4. Handle NSPasteboard updates immediately, not on active/inactive
+ * 1. handle  MULTIPLE - I need to study the ICCCM further.
+ * 2. Handle PICT images properly.
+ * 3. Handle NSPasteboard updates immediately, not on active/inactive
  *    - Open xterm, run 'cat readme.txt | pbcopy'
- * 5. Detect if CLIPBOARD_MANAGER atom belongs to a dead client rather than just None
  */
 
 static struct {
@@ -357,7 +356,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
 	    XSetSelectionOwner (x_dpy, atoms->clipboard,
 				_selection_window, timestamp);
-	    XSetSelectionOwner (x_dpy, XA_PRIMARY,
+	    XSetSelectionOwner (x_dpy, atoms->primary,
 				_selection_window, timestamp);
 	}
 #endif
@@ -421,8 +420,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
         if(owner == _selection_window)
             return TRUE;
 
-        if(None != _selection_window) {
-            fprintf (stderr, "A clipboard manager is already running.  pbproxy will not sync clipboard to pasteboard.\n");
+        if(owner != None) {
+            fprintf (stderr, "A clipboard manager is already running on window 0x%x.  pbproxy will not sync clipboard to pasteboard.\n", (int)owner);
             return FALSE;
         }
         
@@ -1008,6 +1007,24 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     }
 }
 
+- (void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e {
+    if(!pbproxy_prefs.active)
+        return;
+    
+    switch(e->subtype) {              
+        case XFixesSetSelectionOwnerNotify:
+            if(e->selection == atoms->primary && pbproxy_prefs.primary_on_grab)
+                [self x_copy:e->timestamp];
+            break;
+                
+        case XFixesSelectionWindowDestroyNotify:
+        case XFixesSelectionClientCloseNotify:
+        default:
+            fprintf(stderr, "Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
+            break;
+    }
+}
+
 - (void) handle_targets: (Atom)selection propdata:(struct propdata *)pdata
 {
     /* Find a type we can handle and prefer from the list of ATOMs. */
@@ -1023,7 +1040,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	 * This isn't required by the ICCCM, but some apps apparently 
 	 * don't respond to TARGETS properly.
 	 */
-	preferred = XA_STRING;
+	preferred = atoms->string;
     }
 
     DB ("requesting %s\n", XGetAtomName (x_dpy, preferred));
@@ -1260,6 +1277,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     pbproxy_prefs.clipboard_to_pasteboard = prefs_get_bool(CFSTR("sync_clibpoard_to_pasteboard"), pbproxy_prefs.clipboard_to_pasteboard);
     pbproxy_prefs.pasteboard_to_primary = prefs_get_bool(CFSTR("sync_pasteboard_to_primary"), pbproxy_prefs.pasteboard_to_primary);
     pbproxy_prefs.pasteboard_to_clipboard =  prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard);
+    
+    if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !have_xfixes) {
+        fprintf(stderr, "Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
+        pbproxy_prefs.primary_on_grab = NO;
+    }
 
     /* Claim or release the CLIPBOARD_MANAGER atom */
     if(![self set_clipboard_manager_status:(pbproxy_prefs.active && pbproxy_prefs.clipboard_to_pasteboard)])
@@ -1335,6 +1357,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     pending_copy = 0;
     pending_clipboard = 0;
 
+    if(have_xfixes)
+        XFixesSelectSelectionInput(x_dpy, _selection_window, atoms->primary, 
+                                   XFixesSetSelectionOwnerNotifyMask);
+
     [self reload_preferences];
     
     return self;
commit 6dcfa994b0777bf0cabeb71672f13e650b340817
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Oct 10 15:26:32 2008 -0400

    xserver 1.5.2

diff --git a/configure.ac b/configure.ac
index ef276cc..88749a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.5.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="23 September 2008"
+AC_INIT([xorg-server], 1.5.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="10 October 2008"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit 75504517a30f1bdd593c2a32af81084b59b398a5
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Oct 10 13:41:50 2008 -0400

    EDID: Catch monitors that encode aspect ratio for physical size.
    
    This is not legal in either EDID 1.3 or 1.4, but hey, when did a little
    thing like legality stop anyone.
    (cherry picked from commit 0660dd9d7009147c395b9ea904539f76f55b9a7f)

diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c
index 21391dd..958247c 100644
--- a/hw/xfree86/ddc/interpret_edid.c
+++ b/hw/xfree86/ddc/interpret_edid.c
@@ -85,6 +85,47 @@ handle_edid_quirks(xf86MonPtr m)
 	    }
 	}
     }
+
+    /*
+     * some monitors encode the aspect ratio instead of the physical size.
+     * try to find the largest detailed timing that matches that aspect
+     * ratio and use that to fill in the feature section.
+     */
+    if ((m->features.hsize == 16 && m->features.vsize == 9) ||
+	(m->features.hsize == 16 && m->features.vsize == 10) ||
+	(m->features.hsize == 4 && m->features.vsize == 3) ||
+	(m->features.hsize == 5 && m->features.vsize == 4)) {
+	int real_hsize = 0, real_vsize = 0;
+	float target_aspect, timing_aspect;
+	
+	target_aspect = (float)m->features.hsize / (float)m->features.vsize;
+	for (i = 0; i < 4; i++) {
+	    if (m->det_mon[i].type == DT) {
+		struct detailed_timings *timing;
+		timing = &m->det_mon[i].section.d_timings;
+
+		if (!timing->v_size)
+		    continue;
+
+		timing_aspect = (float)timing->h_size / (float)timing->v_size;
+		if (fabs(1 - (timing_aspect / target_aspect)) < 0.05) {
+		    real_hsize = max(real_hsize, timing->h_size);
+		    real_vsize = max(real_vsize, timing->v_size);
+		}
+	    }
+	}
+
+	if (real_hsize && real_vsize) {
+	    /* convert mm to cm */
+	    m->features.hsize = (real_hsize + 5) / 10;
+	    m->features.vsize = (real_vsize + 5) / 10;
+	} else {
+	    m->features.hsize = m->features.vsize = 0;
+	}
+	
+	xf86Msg(X_INFO, "Quirked EDID physical size to %dx%d cm\n",
+		m->features.hsize, m->features.vsize);
+    }
 }
 
 xf86MonPtr
commit b595b65e54b1e15fbce872fe3719da14cfae5b92
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Oct 9 14:53:29 2008 -0400

    Revert "Array-index based devPrivates implementation."
    
    This reverts commit 8ef37c194fa08d3911095299413a42a01162b078.

diff --git a/dix/privates.c b/dix/privates.c
index ca03317..efb3204 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -40,8 +40,9 @@ from The Open Group.
 #include "inputstr.h"
 
 struct _Private {
-    int state;
-    pointer value;
+    DevPrivateKey      key;
+    pointer            value;
+    struct _Private    *next;
 };
 
 typedef struct _PrivateDesc {
@@ -49,36 +50,22 @@ typedef struct _PrivateDesc {
     unsigned size;
     CallbackListPtr initfuncs;
     CallbackListPtr deletefuncs;
+    struct _PrivateDesc *next;
 } PrivateDescRec;
 
-#define PRIV_MAX 256
-#define PRIV_STEP 16
-
 /* list of all allocated privates */
-static PrivateDescRec items[PRIV_MAX];
-static int nextPriv;
+static PrivateDescRec *items = NULL;
 
-static PrivateDescRec *
+static _X_INLINE PrivateDescRec *
 findItem(const DevPrivateKey key)
 {
-    if (!*key) {
-	if (nextPriv >= PRIV_MAX)
-	    return NULL;
-
-	items[nextPriv].key = key;
-	*key = nextPriv;
-	nextPriv++;
+    PrivateDescRec *item = items;
+    while (item) {
+	if (item->key == key)
+	    return item;
+	item = item->next;
     }
-
-    return items + *key;
-}
-
-static _X_INLINE int
-privateExists(PrivateRec **privates, const DevPrivateKey key)
-{
-    return *key && *privates &&
-	(*privates)[0].state > *key &&
-	(*privates)[*key].state;
+    return NULL;
 }
 
 /*
@@ -88,10 +75,21 @@ _X_EXPORT int
 dixRequestPrivate(const DevPrivateKey key, unsigned size)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item)
-	return FALSE;
-    if (size > item->size)
+    if (item) {
+	if (size > item->size)
+	    item->size = size;
+    } else {
+	item = (PrivateDescRec *)xalloc(sizeof(PrivateDescRec));
+	if (!item)
+	    return FALSE;
+	memset(item, 0, sizeof(PrivateDescRec));
+
+	/* add privates descriptor */
+	item->key = key;
 	item->size = size;
+	item->next = items;
+	items = item;
+    }
     return TRUE;
 }
 
@@ -102,52 +100,25 @@ _X_EXPORT pointer *
 dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
 {
     PrivateDescRec *item = findItem(key);
-    PrivateCallbackRec calldata;
     PrivateRec *ptr;
-    pointer value;
-    int oldsize, newsize;
-
-    newsize = (*key / PRIV_STEP + 1) * PRIV_STEP;
+    unsigned size = sizeof(PrivateRec);
+    
+    if (item)
+	size += item->size;
 
-    /* resize or init privates array */
-    if (!item)
+    ptr = (PrivateRec *)xcalloc(size, 1);
+    if (!ptr)
 	return NULL;
-
-    /* initialize privates array if necessary */
-    if (!*privates) {
-	ptr = xcalloc(newsize, sizeof(*ptr));
-	if (!ptr)
-	    return NULL;
-	*privates = ptr;
-	(*privates)[0].state = newsize;
-    }
-
-    oldsize = (*privates)[0].state;
-
-    /* resize privates array if necessary */
-    if (*key >= oldsize) {
-	ptr = xrealloc(*privates, newsize * sizeof(*ptr));
-	if (!ptr)
-	    return NULL;
-	memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr));
-	*privates = ptr;
-	(*privates)[0].state = newsize;
-    }
-
-    /* initialize slot */
-    ptr = *privates + *key;
-    ptr->state = 1;
-    if (item->size) {
-	value = xcalloc(item->size, 1);
-	if (!value)
-	    return NULL;
-	ptr->value = value;
+    ptr->key = key;
+    ptr->value = (size > sizeof(PrivateRec)) ? (ptr + 1) : NULL;
+    ptr->next = *privates;
+    *privates = ptr;
+
+    /* call any init funcs and return */
+    if (item) {
+	PrivateCallbackRec calldata = { key, &ptr->value };
+	CallCallbacks(&item->initfuncs, &calldata);
     }
-
-    calldata.key = key;
-    calldata.value = &ptr->value;
-    CallCallbacks(&item->initfuncs, &calldata);
-
     return &ptr->value;
 }
 
@@ -157,10 +128,14 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
 _X_EXPORT pointer
 dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
 {
+    PrivateRec *rec = *privates;
     pointer *ptr;
 
-    if (privateExists(privates, key))
-	return (*privates)[*key].value;
+    while (rec) {
+	if (rec->key == key)
+	    return rec->value;
+	rec = rec->next;
+    }
 
     ptr = dixAllocatePrivate(privates, key);
     return ptr ? *ptr : NULL;
@@ -172,8 +147,13 @@ dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
 _X_EXPORT pointer *
 dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
 {
-    if (privateExists(privates, key))
-	return &(*privates)[*key].value;
+    PrivateRec *rec = *privates;
+
+    while (rec) {
+	if (rec->key == key)
+	    return &rec->value;
+	rec = rec->next;
+    }
 
     return dixAllocatePrivate(privates, key);
 }
@@ -184,10 +164,16 @@ dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
 _X_EXPORT int
 dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
 {
+    PrivateRec *rec;
+
  top:
-    if (privateExists(privates, key)) {
-	(*privates)[*key].value = val;
-	return TRUE;
+    rec = *privates;
+    while (rec) {
+	if (rec->key == key) {
+	    rec->value = val;
+	    return TRUE;
+	}
+	rec = rec->next;
     }
 
     if (!dixAllocatePrivate(privates, key))
@@ -201,23 +187,27 @@ dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
 _X_EXPORT void
 dixFreePrivates(PrivateRec *privates)
 {
-    int i;
+    PrivateRec *ptr, *next;
+    PrivateDescRec *item;
     PrivateCallbackRec calldata;
 
-    if (privates)
-	for (i = 1; i < privates->state; i++)
-	    if (privates[i].state) {
-		/* call the delete callbacks */
-		calldata.key = items[i].key;
-		calldata.value = &privates[i].value;
-		CallCallbacks(&items[i].deletefuncs, &calldata);
-
-		/* free pre-allocated memory */
-		if (items[i].size)
-		    xfree(privates[i].value);
-	    }
-
-    xfree(privates);
+    /* first pass calls the delete callbacks */
+    for (ptr = privates; ptr; ptr = ptr->next) {
+	item = findItem(ptr->key);
+	if (item) {
+	    calldata.key = ptr->key;
+	    calldata.value = &ptr->value;
+	    CallCallbacks(&item->deletefuncs, &calldata);
+	}
+    }
+	
+    /* second pass frees the memory */
+    ptr = privates;
+    while (ptr) {
+	next = ptr->next;
+	xfree(ptr);
+	ptr = next;
+    }
 }
 
 /*
@@ -228,9 +218,11 @@ dixRegisterPrivateInitFunc(const DevPrivateKey key,
 			   CallbackProcPtr callback, pointer data)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item)
-	return FALSE;
-
+    if (!item) {
+	if (!dixRequestPrivate(key, 0))
+	    return FALSE;
+	item = findItem(key);
+    }
     return AddCallback(&item->initfuncs, callback, data);
 }
 
@@ -239,9 +231,11 @@ dixRegisterPrivateDeleteFunc(const DevPrivateKey key,
 			     CallbackProcPtr callback, pointer data)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item)
-	return FALSE;
-
+    if (!item) {
+	if (!dixRequestPrivate(key, 0))
+	    return FALSE;
+	item = findItem(key);
+    }
     return AddCallback(&item->deletefuncs, callback, data);
 }
 
@@ -298,17 +292,16 @@ dixLookupPrivateOffset(RESTYPE type)
 int
 dixResetPrivates(void)
 {
-    int i;
-
-    /* reset private descriptors */
-    for (i = 1; i < nextPriv; i++) {
-	*items[i].key = 0;
-	DeleteCallbackList(&items[i].initfuncs);
-	DeleteCallbackList(&items[i].deletefuncs);
+    PrivateDescRec *next;
+
+    /* reset internal structures */
+    while (items) {
+	next = items->next;
+	DeleteCallbackList(&items->initfuncs);
+	DeleteCallbackList(&items->deletefuncs);
+	xfree(items);
+	items = next;
     }
-    nextPriv = 1;
-
-    /* reset offsets */
     if (offsets)
 	xfree(offsets);
     offsetsSize = sizeof(offsetDefaults);
diff --git a/include/privates.h b/include/privates.h
index e3fa83c..98d893c 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -19,7 +19,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * STUFF FOR PRIVATES
  *****************************************************************/
 
-typedef int *DevPrivateKey;
+typedef void *DevPrivateKey;
 struct _Private;
 typedef struct _Private PrivateRec;
 


More information about the xorg-commit mailing list