Hi,

Here is an updated patch that will allow the sawfish window manager to
control top-level X window transparency.

The previous version of this patch is out of date.


Changes in this version include:

1. Changed XSetTransparency, XGetTransparency to XSetOpacity,
   XGetOpacity.

2. Added another preprocessor conditional test for the existence of
   the xtransparency extension.  This would allow a patched sawfish to
   still build when the xtransparency extension is not present.


This patch is against sawfish-1.2-gtk1.  It was tested against XFree
cvs tag xf-4_2_99_3 and xdirectfb-rc4 with the latest xtransparency
patch applied.


Scott Brumbaugh





Index: Makedefs.in
===================================================================
RCS file: /extra/cvs-sawfish/sawfish/Makedefs.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makedefs.in
--- Makedefs.in 18 Mar 2003 23:31:59 -0000      1.1.1.1
+++ Makedefs.in 19 Mar 2003 18:49:03 -0000
@@ -54,7 +54,7 @@
 LIBOBJS=
 [EMAIL PROTECTED]@
 [EMAIL PROTECTED]@ -lX11 @X_LIBS@ @X_EXTRA_LIBS@
[EMAIL PROTECTED]@ @XFT_LIBS@ -lXext
[EMAIL PROTECTED]@ @XINERAMA_LIBS@ @XFT_LIBS@ -lXext
 [EMAIL PROTECTED]@
 [EMAIL PROTECTED]@
 [EMAIL PROTECTED]@
Index: config.h.in
===================================================================
RCS file: /extra/cvs-sawfish/sawfish/config.h.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 config.h.in
--- config.h.in 18 Mar 2003 23:31:59 -0000      1.1.1.1
+++ config.h.in 19 Mar 2003 18:49:03 -0000
@@ -86,6 +86,9 @@
 /* Define if <X11/extensions/Xinerama.h> exists */
 #undef HAVE_X11_EXTENSIONS_XINERAMA_H
 
+/* Define if <X11/extensions/transparency.h> exists */
+#undef HAVE_X11_EXTENSIONS_TRANSPARENCY_H
+
 /* Define if <X11/Xft/Xft.h> exists */
 #undef HAVE_X11_XFT_XFT_H
 
Index: configure.in
===================================================================
RCS file: /extra/cvs-sawfish/sawfish/configure.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 configure.in
--- configure.in        18 Mar 2003 23:31:59 -0000      1.1.1.1
+++ configure.in        19 Mar 2003 18:49:03 -0000
@@ -91,6 +91,13 @@
 
 AC_CHECK_HEADERS(X11/SM/SMlib.h X11/extensions/Xdbe.h)
 
+XTRANSPARENCY_LIBS=""
+AC_SUBST(XTRANSPARENCY_LIBS)
+AC_CHECK_LIB(XTransparency, XTransparencyQueryExtension,
+            [XTRANSPARENCY_LIBS="-lXTransparency"
+             AC_CHECK_HEADERS(X11/extensions/transparency.h)],
+            [],[$X_LIBS -lX11 -lXext])
+
 XINERAMA_LIBS=""
 AC_SUBST(XINERAMA_LIBS)
 AC_CHECK_LIB(Xinerama, XineramaQueryScreens,
Index: src/functions.c
===================================================================
RCS file: /extra/cvs-sawfish/sawfish/src/functions.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 functions.c
--- src/functions.c     18 Mar 2003 23:31:59 -0000      1.1.1.1
+++ src/functions.c     20 Mar 2003 01:02:36 -0000
@@ -63,6 +63,11 @@
 # endif
 #endif
 
+#ifdef HAVE_X11_EXTENSIONS_TRANSPARENCY_H
+#include <X11/extensions/transparency.h>
+static int have_x_transparency;
+#endif
+
 DEFSYM(root, "root");
 DEFSYM(after_restacking_hook, "after-restacking-hook");
 DEFSYM(position, "position");
@@ -70,6 +75,54 @@
 DEFSYM(window, "window");
 DEFSYM(head, "head");
 
+#ifdef HAVE_X11_EXTENSIONS_TRANSPARENCY_H
+DEFUN("x-get-opacity", Fx_get_opacity, Sx_get_opacity,
+      (repv win), rep_Subr1 ) /*
+::doc:sawfish.wm.windows.subrs#x-get-opacity::
+x-get-opacity WINDOW
+
+Return the opacity of the top-level window WINDOW.  Values
+of opacity vary from 0 for invisible to 255 for opaque.
+::end:: */
+{
+
+    OpacityValue value;
+    rep_DECLARE1(win, WINDOWP);
+
+    if (have_x_transparency)
+    {
+        XGetOpacity(dpy, VWIN(win)->frame, &value);
+        return rep_MAKE_INT(value);
+    } else {
+        return Qnil;
+    }
+    
+}
+
+DEFUN("x-set-opacity", Fx_set_opacity, Sx_set_opacity,
+      (repv win, repv value), rep_Subr2 ) /*
+::doc:sawfish.wm.windows.subrs#x-set-opacity::
+x-set-opacity WINDOW VALUE
+
+Set the opacity of the top-level window WINDOW to VALUE.  A
+VALUE of 0 is invisible, 255 is fully opaque.
+::end:: */
+{
+
+    rep_DECLARE1(win, WINDOWP);
+    rep_DECLARE2(value, rep_INTP);
+
+    if (have_x_transparency)
+    {
+        XSetOpacity(dpy, VWIN(win)->frame, rep_INT(value));
+        return Qt;
+    } else {
+        return Qnil;
+    }
+
+}
+#endif /* HAVE_X11_EXTENSIONS_TRANSPARENCY_H */
+
 DEFUN("restack-windows", Frestack_windows, Srestack_windows,
       (repv list), rep_Subr1) /*
 ::doc:sawfish.wm.windows.subrs#restack-windows::
@@ -1322,6 +1375,10 @@
     repv tem;
 
     tem = rep_push_structure ("sawfish.wm.windows.subrs");
+#ifdef HAVE_X11_EXTENSIONS_TRANSPARENCY_H
+    rep_ADD_SUBR(Sx_get_opacity);
+    rep_ADD_SUBR(Sx_set_opacity);
+#endif
     rep_ADD_SUBR(Srestack_windows);
     rep_ADD_SUBR(Sx_raise_window);
     rep_ADD_SUBR(Sx_lower_window);
@@ -1390,6 +1447,21 @@
     xinerama_heads = debug_nheads;
 # endif
 #endif
+
+#ifdef HAVE_X11_EXTENSIONS_TRANSPARENCY_H
+    if (dpy != 0)
+    {
+        int event_base, error_base;
+        if (!XTransparencyQueryExtension(dpy, &event_base, &error_base)) {
+            fprintf(stderr, "Transparency extension not found\n");
+            have_x_transparency=0;
+        } else {
+            fprintf(stderr, "Transparency extension found\n");
+            have_x_transparency=1;
+        }
+    }
+#endif
+    
 }
 
 void



-- 
Info:  To unsubscribe send a mail to [EMAIL PROTECTED] with 
"unsubscribe directfb-dev" as subject.

Reply via email to