From 7c7bdccde9d2208a9330099e3cd21060c60638be Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 19 Oct 2005 22:26:55 +0000 Subject: Bug #4244: Make XcursorSetTheme(dpy, NULL) restore the default theme. (Frederico Mena-Quintero) --- src/display.c | 37 +++++++++++++++++++++++++++++-------- src/xcursorint.h | 1 + 2 files changed, 30 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/display.c b/src/display.c index 73fb8b3..252a056 100644 --- a/src/display.c +++ b/src/display.c @@ -28,6 +28,18 @@ static XcursorDisplayInfo *_XcursorDisplayInfo; +static void +_XcursorFreeDisplayInfo (XcursorDisplayInfo *info) +{ + if (info->theme) + free (info->theme); + + if (info->theme_from_config) + free (info->theme_from_config); + + free (info); +} + static int _XcursorCloseDisplay (Display *dpy, XExtCodes *codes) { @@ -44,10 +56,8 @@ _XcursorCloseDisplay (Display *dpy, XExtCodes *codes) break; } _XUnlockMutex (_Xglobal_lock); - - if (info->theme) - free (info->theme); - free (info); + + _XcursorFreeDisplayInfo (info); return 0; } @@ -190,6 +200,7 @@ _XcursorGetDisplayInfo (Display *dpy) } info->theme = 0; + info->theme_from_config = 0; /* * Get the desired theme @@ -199,9 +210,17 @@ _XcursorGetDisplayInfo (Display *dpy) v = XGetDefault (dpy, "Xcursor", "theme"); if (v) { - info->theme = malloc (strlen (v) + 1); + int len; + + len = strlen (v) + 1; + + info->theme = malloc (len); if (info->theme) strcpy (info->theme, v); + + info->theme_from_config = malloc (len); + if (info->theme_from_config) + strcpy (info->theme_from_config, v); } /* @@ -253,9 +272,7 @@ _XcursorGetDisplayInfo (Display *dpy) break; if (old) { - if (info->theme) - free (info->theme); - free (info); + _XcursorFreeDisplayInfo (info); info = old; } else @@ -313,6 +330,10 @@ XcursorSetTheme (Display *dpy, const char *theme) if (!info) return XcursorFalse; + + if (!theme) + theme = info->theme_from_config; + if (theme) { copy = malloc (strlen (theme) + 1); diff --git a/src/xcursorint.h b/src/xcursorint.h index 1a5f50f..7887bbb 100644 --- a/src/xcursorint.h +++ b/src/xcursorint.h @@ -86,6 +86,7 @@ typedef struct _XcursorDisplayInfo { int size; XcursorFontInfo *fonts; char *theme; + char *theme_from_config; XcursorDither dither; XcursorBitmapInfo bitmaps[NUM_BITMAPS]; } XcursorDisplayInfo; -- cgit v1.2.1