# HG changeset patch # User giacomo # Date 1175511786 25200 # Node ID 8b4b381b43990d9c5dbaffae506ccbc3430c470c # Parent f20ca9b8cd7d6e7bca34a64b80f3c50fc46ed6ba [svn] aosd: added compile option in configure for composite support; this way, if support is compiled in, we can safely check if the composite module is loaded diff -r f20ca9b8cd7d -r 8b4b381b4399 ChangeLog --- a/ChangeLog Sun Apr 01 11:36:52 2007 -0700 +++ b/ChangeLog Mon Apr 02 04:03:06 2007 -0700 @@ -1,3 +1,11 @@ +2007-04-01 18:36:52 +0000 Giacomo Lozito + revision [1914] + aosd: added some more error checking + trunk/src/aosd/aosd_osd.c | 65 +++++++++++++++++++++++++++++----------------- + trunk/src/aosd/ghosd.c | 2 + + 2 files changed, 43 insertions(+), 24 deletions(-) + + 2007-04-01 00:44:23 +0000 Giacomo Lozito revision [1912] - aosd: beta4, ghosd source was rewritten to support argb visual (x composite extension) as an option, this allows to have real transparency in the OSD diff -r f20ca9b8cd7d -r 8b4b381b4399 configure.ac --- a/configure.ac Sun Apr 01 11:36:52 2007 -0700 +++ b/configure.ac Mon Apr 02 04:03:06 2007 -0700 @@ -359,11 +359,17 @@ dnl *** Audacious OSD plugin (pangocairo-based) AC_ARG_ENABLE(aosd, - [ --disable-aosd disable X11 Audacious OSD plugin (default=enabled)], + [ --disable-aosd disable Audacious OSD plugin (default=enabled)], [enable_aosd=$enableval], [enable_aosd="yes"] ) +AC_ARG_ENABLE(aosd_xcomp, + [ --disable-aosd-xcomp disable Audacious OSD X Composite Support (default=enabled)], + [enable_aosd_xcomp=$enableval], + [enable_aosd_xcomp="yes"] +) + if test "x$enable_aosd" = "xyes"; then have_aosd="yes" PKG_CHECK_MODULES(PANGO,[pango >= 1.14.7],, @@ -378,6 +384,21 @@ [have_aosd="no" AC_MSG_RESULT([*** pangocairo >= 1.14.7 is required for Audacious OSD plugin ***])] ) + PKG_CHECK_MODULES(XRENDER, xrender,, + [have_aosd="no" + AC_MSG_RESULT([*** X Render extension is required for Audacious OSD plugin ***])] + ) + if test "x$enable_aosd_xcomp" = "xyes"; then + have_aosd_xcomp="yes" + PKG_CHECK_MODULES(XCOMPOSITE, xcomposite, + [AC_DEFINE([HAVE_XCOMPOSITE],[],[X Composite extension available])], + [have_aosd_xcomp="no" + AC_MSG_RESULT([*** X Composite extension not found, composite support for Audacious OSD will not be compiled ***])] + ) + else + AC_MSG_RESULT([*** X Composite support for Audacious OSD plugin disabled per user request ***]) + have_aosd_xcomp="no" + fi else AC_MSG_RESULT([*** Audacious OSD plugin disabled per user request ***]) have_aosd="no" @@ -1238,6 +1259,7 @@ echo " Song Change: yes" echo " Status Icon: $have_statusicon" echo " Audacious OSD: $have_aosd" +echo " -> X Composite support: $have_aosd_xcomp" echo " Control via event device (evdev-plug): $have_evdevplug" echo " LIRC: $have_lirc" echo " AudioScrobbler Client: $scrobbler" diff -r f20ca9b8cd7d -r 8b4b381b4399 mk/rules.mk.in --- a/mk/rules.mk.in Sun Apr 01 11:36:52 2007 -0700 +++ b/mk/rules.mk.in Mon Apr 02 04:03:06 2007 -0700 @@ -343,6 +343,10 @@ AUDLDFLAGS ?= @AUDLDFLAGS@ WAVPACK_CFLAGS ?= @WAVPACK_CFLAGS@ WAVPACK_LIBS ?= @WAVPACK_LIBS@ +XCOMPOSITE_CFLAGS ?= @XCOMPOSITE_CFLAGS@ +XCOMPOSITE_LIBS ?= @XCOMPOSITE_LIBS@ +XRENDER_CFLAGS ?= @XRENDER_CFLAGS@ +XRENDER_LIBS ?= @XRENDER_LIBS@ XXF86VM_CFLAGS ?= @XXF86VM_CFLAGS@ XXF86VM_LIBS ?= @XXF86VM_LIBS@ LIBPROJECTM_CFLAGS ?= @LIBPROJECTM_CFLAGS@ diff -r f20ca9b8cd7d -r 8b4b381b4399 src/aosd/Makefile --- a/src/aosd/Makefile Sun Apr 01 11:36:52 2007 -0700 +++ b/src/aosd/Makefile Mon Apr 02 04:03:06 2007 -0700 @@ -7,12 +7,12 @@ LIBDIR = $(plugindir)/$(GENERAL_PLUGIN_DIR) -LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(CAIRO_LIBS) $(PANGOCAIRO_LIBS) +LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(CAIRO_LIBS) $(PANGOCAIRO_LIBS) $(XRENDER_LIBS) $(XCOMPOSITE_LIBS) SOURCES = aosd.c aosd_osd.c aosd_style.c aosd_trigger.c aosd_ui.c aosd_cfg.c ghosd.c ghosd-main.c OBJECTS = ${SOURCES:.c=.o} -CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(CAIRO_CFLAGS) $(PANGOCAIRO_CFLAGS) \ +CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(CAIRO_CFLAGS) $(PANGOCAIRO_CFLAGS) $(XRENDER_CFLAGS) $(XCOMPOSITE_CFLAGS) \ -I../../intl -I../.. -I.. include ../../mk/objective.mk diff -r f20ca9b8cd7d -r 8b4b381b4399 src/aosd/aosd_osd.c --- a/src/aosd/aosd_osd.c Sun Apr 01 11:36:52 2007 -0700 +++ b/src/aosd/aosd_osd.c Mon Apr 02 04:03:06 2007 -0700 @@ -444,7 +444,20 @@ if ( transparency_mode == AOSD_MISC_TRANSPARENCY_FAKE ) osd = ghosd_new(); else - osd = ghosd_new_with_argbvisual(); +#ifdef HAVE_XCOMPOSITE + { + /* check if the composite module is actually loaded */ + if ( aosd_osd_check_composite() ) + osd = ghosd_new_with_argbvisual(); /* ok */ + else + { + g_warning( "X Composite module not loaded; falling back to fake transparency.\n"); + osd = ghosd_new(); /* fall back to fake transparency */ + } + } +#else + osd = ghosd_new(); +#endif if ( osd == NULL ) g_warning( "Unable to load osd object; OSD will not work properly!\n" ); @@ -464,3 +477,11 @@ } return; } + +#ifdef HAVE_XCOMPOSITE +int +aosd_osd_check_composite ( void ) +{ + return ghosd_check_composite(); +} +#endif diff -r f20ca9b8cd7d -r 8b4b381b4399 src/aosd/aosd_osd.h --- a/src/aosd/aosd_osd.h Sun Apr 01 11:36:52 2007 -0700 +++ b/src/aosd/aosd_osd.h Mon Apr 02 04:03:06 2007 -0700 @@ -31,4 +31,8 @@ void aosd_osd_init ( gint transparency_mode ); /* to be called before any OSD usage */ void aosd_osd_cleanup ( void ); /* to be called when done with OSD usage */ +#ifdef HAVE_XCOMPOSITE +int aosd_osd_check_composite ( void ); +#endif + #endif /* !_I_AOSD_OSD_H */ diff -r f20ca9b8cd7d -r 8b4b381b4399 src/aosd/aosd_ui.c --- a/src/aosd/aosd_ui.c Sun Apr 01 11:36:52 2007 -0700 +++ b/src/aosd/aosd_ui.c Mon Apr 02 04:03:06 2007 -0700 @@ -23,6 +23,7 @@ #include "aosd_trigger.h" #include "aosd_cfg.h" #include "aosd_osd.h" +#include "aosd_common.h" #include #include #include @@ -824,10 +825,26 @@ GINT_TO_POINTER(AOSD_MISC_TRANSPARENCY_FAKE) ); g_object_set_data( G_OBJECT(mis_transp_real_rbt) , "val" , GINT_TO_POINTER(AOSD_MISC_TRANSPARENCY_REAL) ); - if ( cfg->osd->misc.transparency_mode == AOSD_MISC_TRANSPARENCY_FAKE ) + +#ifdef HAVE_XCOMPOSITE + /* check if the composite extension is loaded */ + if ( aosd_osd_check_composite() ) + { + if ( cfg->osd->misc.transparency_mode == AOSD_MISC_TRANSPARENCY_FAKE ) + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(mis_transp_fake_rbt) , TRUE ); + else + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(mis_transp_real_rbt) , TRUE ); + } + else + { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(mis_transp_fake_rbt) , TRUE ); - else - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(mis_transp_real_rbt) , TRUE ); + gtk_widget_set_sensitive( GTK_WIDGET(mis_transp_real_rbt) , FALSE ); + } +#else + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(mis_transp_fake_rbt) , TRUE ); + gtk_widget_set_sensitive( GTK_WIDGET(mis_transp_real_rbt) , FALSE ); +#endif + gtk_box_pack_start( GTK_BOX(mis_transp_vbox) , mis_transp_fake_rbt , TRUE , TRUE , 0 ); gtk_box_pack_start( GTK_BOX(mis_transp_vbox) , mis_transp_real_rbt , TRUE , TRUE , 0 ); aosd_callback_list_add( cb_list , mis_transp_vbox , aosd_cb_configure_misc_transp_commit ); diff -r f20ca9b8cd7d -r 8b4b381b4399 src/aosd/ghosd.c --- a/src/aosd/ghosd.c Sun Apr 01 11:36:52 2007 -0700 +++ b/src/aosd/ghosd.c Mon Apr 02 04:03:06 2007 -0700 @@ -9,12 +9,17 @@ */ #include "config.h" +#include "aosd_common.h" #include #include #include #include +#ifdef HAVE_XCOMPOSITE +#include +#endif + #include "ghosd.h" #include "ghosd-internal.h" @@ -42,6 +47,7 @@ return 0; } +#ifdef HAVE_XCOMPOSITE Visual * find_argb_visual (Display *dpy, int scr) { @@ -74,6 +80,7 @@ return visual; } +#endif static Pixmap take_snapshot(Ghosd *ghosd) { @@ -365,6 +372,7 @@ return ghosd; } +#ifdef HAVE_XCOMPOSITE Ghosd * ghosd_new_with_argbvisual(void) { Ghosd *ghosd; @@ -405,6 +413,30 @@ return ghosd; } +int +ghosd_check_composite(void) +{ + Display *dpy; + int have_composite = 0; + int composite_event_base = 0, composite_error_base = 0; + + dpy = XOpenDisplay(NULL); + if (dpy == NULL) { + fprintf(stderr, "Couldn't open display: (XXX FIXME)\n"); + return 0; + } + + if (!XCompositeQueryExtension(dpy, + &composite_event_base, &composite_error_base)) + have_composite = 0; + else + have_composite = 1; + + XCloseDisplay(dpy); + return have_composite; +} +#endif + void ghosd_destroy(Ghosd* ghosd) { if (ghosd->background.set) diff -r f20ca9b8cd7d -r 8b4b381b4399 src/aosd/ghosd.h --- a/src/aosd/ghosd.h Sun Apr 01 11:36:52 2007 -0700 +++ b/src/aosd/ghosd.h Mon Apr 02 04:03:06 2007 -0700 @@ -16,6 +16,8 @@ #include /* INT_MAX */ #include /* timeval */ +#include "aosd_common.h" + typedef struct _Ghosd Ghosd; /* minimal struct to handle button events */ @@ -33,8 +35,11 @@ typedef void (*GhosdEventButtonCb)(Ghosd *ghosd, GhosdEventButton *event, void *user_data); Ghosd *ghosd_new(void); +void ghosd_destroy(Ghosd* ghosd); +#ifdef HAVE_XCOMPOSITE Ghosd *ghosd_new_with_argbvisual(void); -void ghosd_destroy(Ghosd* ghosd); +int ghosd_check_composite(void); +#endif #define GHOSD_COORD_CENTER INT_MAX void ghosd_set_transparent(Ghosd *ghosd, int transparent);