X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fxscreensaver-getimage.c;h=f702f679294f7c05f353f1ed18ad5460e4987bb3;hb=d6b0217f2417bd19187f0ebc389d6c5c2233b11c;hp=d7c150875b445ddcffebbda24e111a1a4fb76f89;hpb=5f9c47ca98dd43d8f59b7c27d3fde6edfde4fe21;p=xscreensaver diff --git a/driver/xscreensaver-getimage.c b/driver/xscreensaver-getimage.c index d7c15087..f702f679 100644 --- a/driver/xscreensaver-getimage.c +++ b/driver/xscreensaver-getimage.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2001-2008 by Jamie Zawinski +/* xscreensaver, Copyright (c) 2001-2016 by Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -69,7 +69,7 @@ /* On MacOS under X11, the usual X11 mechanism of getting a screen shot doesn't work, and we need to use an external program. This is only used when running under X11 on MacOS. If it's a Cocoa build, this - path is not taken, and OSX/osxgrabscreen.m is used instead. + path is not taken, and OSX/grabclient-osx.m is used instead. */ # define USE_EXTERNAL_SCREEN_GRABBER #endif @@ -379,9 +379,11 @@ read_file_gdk (Screen *screen, Window window, Drawable drawable, &root, &x, &y, &win_width, &win_height, &bw, &win_depth); } - gdk_pixbuf_xlib_init (dpy, screen_number (screen)); + gdk_pixbuf_xlib_init_with_depth (dpy, screen_number (screen), win_depth); # ifdef HAVE_GTK2 +# if !GLIB_CHECK_VERSION(2, 36 ,0) g_type_init(); +# endif # else /* !HAVE_GTK2 */ xlib_rgb_init (dpy, screen); # endif /* !HAVE_GTK2 */ @@ -413,7 +415,7 @@ read_file_gdk (Screen *screen, Window window, Drawable drawable, int ow = w, oh = h; GdkPixbuf *opb = pb; pb = gdk_pixbuf_apply_embedded_orientation (opb); - gdk_pixbuf_unref (opb); + g_object_unref (opb); w = gdk_pixbuf_get_width (pb); h = gdk_pixbuf_get_height (pb); if (verbose_p && (w != ow || h != oh)) @@ -430,7 +432,7 @@ read_file_gdk (Screen *screen, Window window, Drawable drawable, GDK_INTERP_BILINEAR); if (pb2) { - gdk_pixbuf_unref (pb); + g_object_unref (pb); pb = pb2; w = w2; h = h2; @@ -1666,6 +1668,8 @@ get_image (Screen *screen, draw_colorbars (screen, xgwa.visual, drawable, xgwa.colormap, 0, 0, 0, 0); XSync (dpy, False); + if (! file_prop) file_prop = ""; + } break; @@ -1706,8 +1710,23 @@ get_image (Screen *screen, { Atom a = XInternAtom (dpy, XA_XSCREENSAVER_IMAGE_FILENAME, False); if (file_prop && *file_prop) - XChangeProperty (dpy, window, a, XA_STRING, 8, PropModeReplace, - (unsigned char *) file_prop, strlen(file_prop)); + { + char *f2 = strdup (file_prop); + + /* Take the extension off of the file name. */ + /* Duplicated in utils/grabclient.c. */ + char *slash = strrchr (f2, '/'); + char *dot = strrchr ((slash ? slash : f2), '.'); + if (dot) *dot = 0; + /* Replace slashes with newlines */ + /* while ((dot = strchr(f2, '/'))) *dot = '\n'; */ + /* Replace slashes with spaces */ + /* while ((dot = strchr(f2, '/'))) *dot = ' '; */ + + XChangeProperty (dpy, window, a, XA_STRING, 8, PropModeReplace, + (unsigned char *) f2, strlen(f2)); + free (f2); + } else XDeleteProperty (dpy, window, a);