transparent gnome-terminal



yesterday I tested out eterm with transparency .. and found it TOOOOOOO
heavyweight (on my alpha it adds 5 megs for each terminal window to the
X server memory usage)

so I figured I'd better hack something onto zvt that was more lightweight
... so I did ... though it's ugly and doesn't work 100% ... etc ...etc ...
I intend of finishing it one of these days ... but here's a simple patch
for those interested ... performance is not that bad, but it can be
improved, it doesn't find changing desktops and sometimes still has artifacts
around ... it also doesn't do shading, but I figure that will just be a bit
of code (I want to just copy the root pixmap into a new darker pixmap and
just keep it around just like the root pixmap, that way we only use one
pixmap for all terms)...

anyway .. DON'T USE THESE PATCHES IF YOU WANT TO USE gnome-term or zvt ...
there is no switch, they just become transparent ...

you need to patch both gnome-terminal and zvt

anyway .. here they are if anyone is interested in patching them up to act
sanely, go right ahead

George

-- 
------------------------------------------------------------------------------
George Lebl <jirka@5z.com> http://www.5z.com/jirka/
------------------------------------------------------------------------------
  The following implements RSA in perl and is illegal to export from the US:

          #!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
          $/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
          lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
Index: gnome-terminal.c
===================================================================
RCS file: /cvs/gnome/gnome-core/gnome-terminal/gnome-terminal.c,v
retrieving revision 1.48
diff -u -r1.48 gnome-terminal.c
--- gnome-terminal.c	1998/10/19 01:35:17	1.48
+++ gnome-terminal.c	1998/10/22 00:32:01
@@ -1208,6 +1208,22 @@
 }
 
 static void
+term_change_pos(GtkWidget *widget)
+{
+	static int x=-999;
+	static int y=-999;
+	int nx,ny;
+	
+	if(!widget->window)
+		return;
+	
+	gdk_window_get_position(widget->window,&nx,&ny);
+	
+	if(nx!=x || ny!=y)
+		gtk_widget_queue_draw(widget);
+}
+
+static void
 new_terminal_cmd (char **cmd, struct terminal_config *cfg_in)
 {
 	GtkWidget *app, *hbox, *scrollbar;
@@ -1255,7 +1271,6 @@
 
 	app = gnome_app_new ("Terminal", "Terminal");
 	gtk_window_set_wmclass (GTK_WINDOW (app), "GnomeTerminal", "GnomeTerminal");
-
 	if (cmd != NULL)
 		initial_term = app;
 #ifdef ZVT_USES_MINIMAL_ALLOC
@@ -1269,6 +1284,9 @@
 	/* Setup the Zvt widget */
 	term = ZVT_TERM (zvt_term_new ());
 	gtk_widget_show (GTK_WIDGET (term));
+	gtk_signal_connect_object(GTK_OBJECT(app),"configure_event",
+				  GTK_SIGNAL_FUNC(term_change_pos),
+				  GTK_OBJECT(term));
 #if ZVT_USES_MINIMAL_ALLOC
 	gtk_widget_set_usize (GTK_WIDGET (term),
 			      80 * term->charwidth,
Index: zvtterm.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/zvt/zvtterm.c,v
retrieving revision 1.45
diff -u -r1.45 zvtterm.c
--- zvtterm.c	1998/10/18 23:04:14	1.45
+++ zvtterm.c	1998/10/22 00:37:21
@@ -22,6 +22,13 @@
 #include <gtk/gtkmain.h>
 #include <gtk/gtksignal.h>
 #include <gdk/gdk.h>
+
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+
 #include <gdk/gdkkeysyms.h>
 
 #include <errno.h>
@@ -66,6 +73,72 @@
 static void zvt_term_fix_scrollbar(ZvtTerm *term);
 static void vtx_unrender_selection (struct _vtx *vx);
 
+static Pixmap desktop_pixmap = None;
+
+static Pixmap
+get_desktop_pixmap(void) {
+
+    Pixmap p;
+    Atom prop, type, prop2;
+    int format;
+    unsigned long length, after;
+    unsigned char *data;
+    register unsigned long i=0;
+    time_t blah;
+    Window desktop_window;
+
+    desktop_window = GDK_ROOT_WINDOW();
+
+    prop = XInternAtom(GDK_DISPLAY(), "_XROOTPMAP_ID", True);
+    prop2 = XInternAtom(GDK_DISPLAY(), "_XROOTCOLOR_PIXEL", True);
+    
+    if (prop == None && prop2 == None) {
+	return None;
+    }
+
+    if (prop != None) {
+	XGetWindowProperty(GDK_DISPLAY(), desktop_window, prop, 0L, 1L, False, AnyPropertyType,
+			   &type, &format, &length, &after, &data);
+	if (type == XA_PIXMAP) {
+	    p = *((Pixmap *)data);
+	    /*
+	    blah = time(NULL);
+	    DPRINTF(("Time index:  %s\n", ctime(&blah)));
+	    for (i=0; i < 4000000000 && !p; i++) {
+		DPRINTF(("  Null pixmap returned.  i == %lu  Trying again in 20 ms.\n", i));
+		usleep(2000000);
+		XGetWindowProperty(Xdisplay, desktop_window, prop, 0L, 1L, False, AnyPropertyType,
+				   &type, &format, &length, &after, &data);
+		if (type != XA_PIXMAP) {
+		    p = None;
+		    break;
+		} else {
+		    p = *((Pixmap *)data);
+		}
+	    }
+	    blah = time(NULL);
+	    DPRINTF(("Time index:  %s\n", ctime(&blah)));
+	    if (i != 0 && p != 0) {
+		_exit(0);
+	    }
+	    */
+	    return p;
+	}
+    }
+    if (prop2 != None) {
+	XGetWindowProperty(GDK_DISPLAY(), desktop_window, prop2, 0L, 1L, False, AnyPropertyType,
+			   &type, &format, &length, &after, &data);
+	if (type == XA_CARDINAL) {
+	    return None;
+	}
+    }
+
+  return None;
+
+}
+
+
+
 /* Local data */
 
 enum {
@@ -101,6 +174,7 @@
   return term_type;
 }
 
+
 static void
 zvt_term_class_init (ZvtTermClass *class)
 {
@@ -1562,12 +1636,29 @@
 
   /* optimise: dont 'clear' background if not in expose, and background colour == window colour */
   /* this may look a bit weird, it really does need to be this way - so dont touch!*/
-  if (term->in_expose || vx->back_match==0) {
-    gdk_draw_rectangle(widget->window,
+  if (1 || term->in_expose || vx->back_match==0) {
+    /*gdk_draw_rectangle(widget->window,
 		       bgc,
 		       1,
 		       col*term->charwidth, row*term->charheight,
-		       len*term->charwidth, term->charheight);
+		       len*term->charwidth, term->charheight);*/
+	  int x,y;
+	  Window childret;
+	  if(desktop_pixmap == None)
+		  desktop_pixmap = get_desktop_pixmap();
+	  XTranslateCoordinates(GDK_WINDOW_XDISPLAY(widget->window),
+				GDK_WINDOW_XWINDOW(widget->window),
+				GDK_ROOT_WINDOW(),
+				col*term->charwidth,row*term->charheight,
+				&x,&y,
+				&childret);
+	  XCopyArea (GDK_WINDOW_XDISPLAY(widget->window),
+		     desktop_pixmap,
+		     GDK_WINDOW_XWINDOW(widget->window),
+		     GDK_GC_XGC(bgc),
+		     x,y,
+		     len*term->charwidth, term->charheight,
+		     col*term->charwidth, row*term->charheight);
   } else {
     d(printf("not clearing background in_expose = %d, back_match=%d\n", term->in_expose, vx->back_match));
     d(printf("txt = '%.*s'\n", len, text));
@@ -1596,13 +1687,18 @@
 #if 0
   GdkEvent *event;
 #endif
-
+  
   widget = user_data;
-
+  
   g_return_if_fail (widget != NULL);
   g_return_if_fail (ZVT_IS_TERM (widget));
-
+  
   term = ZVT_TERM (widget);
+
+  /*FIXME: bad hack*/
+  gtk_widget_queue_draw(widget);
+  return;
+
 
   /* FIXME: check args */
 


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