[PATCH] xcompmgr effects



Hi,

I've been playing around with xcomposite and xcompmgr for a while now
and as a loyal sawfish user, I've been investigating how to implement
some of the slightly fancy effects that the latest version of xfwm4 has
such as making a window translucent while it's moving.

xcompmgr is pretty simple and does nothing more than look for a
particular atom on the frame window for the opacity (and if you have
the modified xcompmgr from baghira.sf.net it also reads the shadow
properties from another atom) so the basis of any effects is just
the setting or unsetting the atom.

We need to add a function to get the frame Window id but after that
the existing atom manipulation functions will work. The attached patch
adds the frame_id method. I've also attached my opacity lisp code which
implements translucency on move and translucency on click-and-hold which
are xfwm4 behaviours. Just for fun I tried implementing translucency for
unfocussed windows (which was an option in OSX 10.0 I believe) but it's
hellishly unusable :-)

Was also very happy to see Amit's ARGB visual support patch - I don't
want to see sawfish get left behind :-)

--phil

Index: src/functions.c
===================================================================
RCS file: /cvs/gnome/sawfish/src/functions.c,v
retrieving revision 1.101
diff -u -r1.101 functions.c
--- src/functions.c	7 Feb 2005 00:11:23 -0000	1.101
+++ src/functions.c	11 Feb 2005 07:16:50 -0000
@@ -902,6 +902,19 @@
     return id ? rep_MAKE_INT(id) : Qnil;
 }
 
+DEFUN("frame-id", Fframe_id, Sframe_id,
+      (repv win), rep_Subr1) /*
+::doc:sawfish.wm.misc#frame-id::
+frame-id WINDOW
+
+Get the numeric window id of WINDOW's frame's client window. Returns nil
+if there's no frame, but that really shouldn't happen.
+::end:: */
+{
+    rep_DECLARE1(win, WINDOWP);
+    return VWIN(win)->frame ? rep_MAKE_INT (VWIN(win)->frame) : Qnil;
+}
+
 DEFUN("x-atom", Fx_atom, Sx_atom, (repv symbol), rep_Subr1) /*
 ::doc:sawfish.wm.misc#x-atom::
 x-atom SYMBOL
@@ -1352,6 +1365,7 @@
     rep_ADD_SUBR(Sget_x_property);
     rep_ADD_SUBR(Sset_x_property);
     rep_ADD_SUBR(Screate_window);
+    rep_ADD_SUBR(Sframe_id);
     rep_ADD_SUBR(Sx_atom);
     rep_ADD_SUBR(Sx_atom_name);
     rep_ADD_SUBR(Sroot_window_id);
Index: src/sawmill_subrs.h
===================================================================
RCS file: /cvs/gnome/sawfish/src/sawmill_subrs.h,v
retrieving revision 1.109
diff -u -r1.109 sawmill_subrs.h
--- src/sawmill_subrs.h	4 Jan 2005 15:34:25 -0000	1.109
+++ src/sawmill_subrs.h	11 Feb 2005 07:16:50 -0000
@@ -177,6 +177,7 @@
 extern repv Fsend_client_message (repv win, repv type, repv data, repv format);
 extern repv Fcreate_window (repv parent, repv x, repv y,
 			    repv width, repv height);
+extern repv Fframe_id (repv win);
 extern repv Fx_atom (repv symbol);
 extern repv Fx_atom_name (repv atom);
 extern repv Fdisplay_message (repv text, repv attrs);
(require 'rep.io.timers)

(define (make-opaque w)
  (delete-x-property (frame-id w) '_NET_WM_WINDOW_OPACITY))
      
(define (make-translucent w p)
  (set-x-property (frame-id w) '_NET_WM_WINDOW_OPACITY (vector p) 'CARDINAL 32))
            
(define translucency-timer nil)

(define (reset-translucent-delay)
   (if translucency-timer (delete-timer translucency-timer))
   (setq translucency-timer nil))

(defun make-translucent-on-delay (w)
  "Raise and make the current window translucent after a delay"
  (interactive "%W")
  (raise-window w)
  (setq translucency-timer
    (make-timer (lambda() (make-translucent w #x7fffffff)) 0 500)))

(defun reset-translucent-on-delay (w)
   "Reset the timer that makes the window translucent"
   (interactive "%W")
   (reset-translucent-delay)
   (make-opaque w))

(define (make-moving-window-translucent w)
  (reset-translucent-delay)
  (make-translucent w #x7fffffff))

(add-hook 'after-move-hook make-opaque t)
(add-hook 'before-move-hook make-moving-window-translucent t)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]