Cristalle Azundris Sabon writes:
William M. Perry writes:
> 2) Static variables always scare me in XEmacs - most of those should be in
> either the GTK device structure, or the GTK frame structure. Especially
> if GTK ever gets real mulit-display support, the atoms on each display
> could be different.
No more statics. No more lisp-vars either. One lisp-func
left (gtk-put-transparency ...), which is fully documented.
Transparency for GTK/X, transparency/tinting/shading for
GTK/X+Imlib. Honours face background pixmaps/colours.
Unfazed by root pixmap changing/disappearing. Pools pixmaps
(frames using the same tinting/shading will share one pixmap).
Diverse speedups. New frames automatically inherit settings
from first frame (but their settings may subsequently be
changed). Am no longer able to produce incorrect behavour,
let alone crashes. Sample setup added in sample.init.el,
some popular transparency setups added to Options-menu.
xemacs now defaults to "no transparency" again, ie, you'll
need to specifically request the "waste of resources." ; )
> What about calling Fredraw_frame(frame,Qt) instead of directly
calling
> gtk_redraw_exposed_area(f,0,0,32000,32000)?
Caused extreme flicker in earlier test, will try vs the optimized
version later.
Replaced by a function, using actual widget-size now instead of
32000,32000.
Will submit patch as soon as I find a good set up for the
variables.
I think I have now. Find included the latest patch.
Looks like this one might actually be ready for the users. : )
Enjoy,
Azundris
diff -Nur xemacs-21.5.4/etc/make_trans.sh xemacs-21.5.4-trans/etc/make_trans.sh
--- xemacs-21.5.4/etc/make_trans.sh Thu Jan 1 01:00:00 1970
+++ xemacs-21.5.4-trans/etc/make_trans.sh Wed Jan 23 12:09:46 2002
@@ -0,0 +1,12 @@
+#!/bin/sh --
+
+# makes toolbar icons transparent. old icons will be saved in "solid"
+cd toolbar 2>/dev/null
+mkdir solid 2>/dev/null
+
+for i in *.xpm
+do
+ sed -e's/Gray75 s backgroundToolBarColor/none/g' < $i > .tmp.xpm
+ mv $i solid/$i
+ mv .tmp.xpm $i
+done
diff -Nur xemacs-21.5.4/etc/sample.init.el xemacs-21.5.4-trans/etc/sample.init.el
--- xemacs-21.5.4/etc/sample.init.el Wed May 23 11:59:33 2001
+++ xemacs-21.5.4-trans/etc/sample.init.el Wed Jan 23 10:30:54 2002
@@ -1429,3 +1429,27 @@
; ;; of the session, specify the number of lines here.
; w3-telnet-header-length 4
; )
+
+;;; ********************
+;;; The following will activate those of tinting, shading and transparency that
+;;; are available. At present, these features are only supported for GTK on X
+;;; since GTK/FB and Win XP bring their own flavour of transparency (real (alpha),
+;;; not pseudo-), so there is no point in duplicating that functionality in xemacs.
+;;; Without Imlib, tinting and shading will be disabled.
+;;; For more info, see C-h f gtk-put-transparency
+
+(if (featurep 'tinting)
+ (gtk-put-transparency (selected-frame)
+ '((trans . (tab text bg))
+ (shade . (240))
+ (red . (216))
+ (green . (0))
+ (blue . (256))))
+ (if (featurep 'shading)
+ (gtk-put-transparency (selected-frame)
+ '((trans . (tab text bg))
+ (shade . (192))))
+ (if (featurep 'transparency)
+ (gtk-put-transparency (selected-frame)
+ '((trans . (tab text bg)))))))
+
diff -Nur xemacs-21.5.4/lisp/menubar-items.el xemacs-21.5.4-trans/lisp/menubar-items.el
--- xemacs-21.5.4/lisp/menubar-items.el Thu Nov 29 19:39:21 2001
+++ xemacs-21.5.4-trans/lisp/menubar-items.el Tue Jan 22 19:14:55 2002
@@ -1062,6 +1062,20 @@
:selected (eq default-toolbar-position 'right)]
)
))
+ ,@(if (featurep 'transparency)
+ '("---"
+ ("Tinting & shading"
+ ["Set background %_non-transparent"
+ (gtk-put-transparency (selected-frame) nil)]
+ ["Set background %_transparent"
+ (gtk-put-transparency (selected-frame) '((trans tab text bg)))]
+ ["Set background transparent / tabs %_visible"
+ (gtk-put-transparency (selected-frame) '((trans text bg)))]
+ ["Tint background (%_smoked glass)"
+ (gtk-put-transparency (selected-frame) '((shade 256 256 190) (r 256) (g 256) (b
256)))]
+ ["Tint background (%_indigo)"
+ (gtk-put-transparency (selected-frame) '((shade 240) (r 184) (g 0) (b 232)))]
+ )))
,@(if (featurep 'gutter)
'("---"
["B%_uffers Tab Visible"
diff -Nur xemacs-21.5.4/src/ChangeLog.GTK xemacs-21.5.4-trans/src/ChangeLog.GTK
--- xemacs-21.5.4/src/ChangeLog.GTK Thu Apr 12 20:23:21 2001
+++ xemacs-21.5.4-trans/src/ChangeLog.GTK Wed Jan 23 12:34:20 2002
@@ -1,3 +1,12 @@
+2002-01-23 Azundris <hacks(a)azundris.com>
+
+ * various: Support for transparency and, if Imlib is present,
+ tinting and shading of the text widget. Toolbar icons will also
+ appear transparent if their backgroundcolour is set to "none"
+ (e.g. with including make_trans.sh). See help for
+ gtk-put-transparency for details. Survives changing and deleting
+ of root pixmap, and should handle errors gracefully.
+
2000-10-03 William M. Perry <wmperry(a)aventail.com>
* objects-gtk.c (gtk_font_instance_truename): Make sure we get the
diff -Nur xemacs-21.5.4/src/console-gtk.h xemacs-21.5.4-trans/src/console-gtk.h
--- xemacs-21.5.4/src/console-gtk.h Sun Dec 23 21:28:20 2001
+++ xemacs-21.5.4-trans/src/console-gtk.h Tue Jan 22 19:21:55 2002
@@ -36,6 +36,9 @@
#include "console.h"
#include <gtk/gtk.h>
+#ifdef HAVE_GDK_IMLIB_INIT
+# include <gdk_imlib.h> /* azundris 2002/01/17 */
+#endif
#define GDK_DRAWABLE(x) (GdkDrawable *) (x)
#define GET_GTK_WIDGET_WINDOW(x) (GTK_WIDGET (x)->window)
@@ -147,6 +150,17 @@
/*************************** Miscellaneous **************************/
+ /* The pixmap for transparency. azundris 2002/01/17 */
+ GdkPixmap *pixmap;
+#ifdef HAVE_GDK_IMLIB_INIT
+ GdkImlibColorModifier mod,rmod,gmod,bmod;
+#endif
+ unsigned int trans_tab:1;
+ unsigned int trans_text:1;
+ unsigned int trans_bg:1;
+ /* if we cannot get a pixmap, don't retry until circumstances change */
+ unsigned int trans_fail:1;
+
/* The icon pixmaps; these are Lisp_Image_Instance objects, or Qnil. */
Lisp_Object icon_pixmap;
Lisp_Object icon_pixmap_mask;
@@ -191,6 +205,20 @@
#define FRAME_GTK_TOTALLY_VISIBLE_P(f) (FRAME_GTK_DATA (f)->totally_visible_p)
#define FRAME_GTK_VISIBLE_P(f) (FRAME_GTK_DATA (f)->visible_p)
#define FRAME_GTK_TOP_LEVEL_FRAME_P(f) (FRAME_GTK_DATA (f)->top_level_frame_p)
+
+#define FRAME_GTK_PIXMAP(f) (FRAME_GTK_DATA (f)->pixmap)
+#ifdef HAVE_GDK_IMLIB_INIT
+# define FRAME_GTK_MOD(f) (FRAME_GTK_DATA (f)->mod)
+# define FRAME_GTK_RMOD(f) (FRAME_GTK_DATA (f)->rmod)
+# define FRAME_GTK_GMOD(f) (FRAME_GTK_DATA (f)->gmod)
+# define FRAME_GTK_BMOD(f) (FRAME_GTK_DATA (f)->bmod)
+#endif
+#define FRAME_GTK_TRANS_TAB(f) (FRAME_GTK_DATA (f)->trans_tab)
+#define FRAME_GTK_TRANS_TEXT(f) (FRAME_GTK_DATA (f)->trans_text)
+#define FRAME_GTK_TRANS_BG(f) (FRAME_GTK_DATA (f)->trans_bg)
+#define FRAME_GTK_TRANS_FAIL(f) (FRAME_GTK_DATA (f)->trans_fail)
+#define FRAME_GTK_TRANS_ANY(f)
(!FRAME_GTK_TRANS_FAIL(f)&&(FRAME_GTK_TRANS_TAB(f)||FRAME_GTK_TRANS_BG(f)||FRAME_GTK_TRANS_TEXT(f)))
+
/* Variables associated with the X display frame this emacs is using. */
diff -Nur xemacs-21.5.4/src/event-gtk.c xemacs-21.5.4-trans/src/event-gtk.c
--- xemacs-21.5.4/src/event-gtk.c Thu Sep 20 08:28:55 2001
+++ xemacs-21.5.4-trans/src/event-gtk.c Tue Jan 22 19:14:22 2002
@@ -29,6 +29,8 @@
#include "lisp.h"
#include "console-gtk.h"
+#include "redisplay-gtk.h" /* azundris 2001/12/09 */
+#include "device.h" /* azundris 2002/01/21 */
#include "blocktype.h"
#include "buffer.h"
@@ -1459,12 +1461,13 @@
GdkEvent *event,
gpointer closure)
{
- struct frame *frame = (struct frame *) closure;
+ struct frame *frame = (struct frame *) closure,*f;
Lisp_Object lisp_event = Fmake_event (Qnil, Qnil);
struct Lisp_Event *emacs_event = XEVENT (lisp_event);
GdkEvent *gdk_event_copy = &emacs_event->event.magic.underlying_gdk_event;
struct device *d = XDEVICE (FRAME_DEVICE (frame));
gboolean ignore_p = FALSE;
+ Atom prop = None; /* azundris 2002/01/17 */
set_last_server_timestamp (d, event);
@@ -1475,11 +1478,41 @@
case GDK_SELECTION_REQUEST:
case GDK_SELECTION_CLEAR:
case GDK_SELECTION_NOTIFY: FROB(selection); break;
- case GDK_PROPERTY_NOTIFY: FROB(property); break;
+ case GDK_PROPERTY_NOTIFY: FROB(property);
+ /* azundris 2001/12/09 { */
+
prop=XInternAtom(GDK_DISPLAY(),"_XROOTPMAP_ID",True);
+ if(((GdkEventProperty *)event)->atom==prop) {
+ /* backdrop has changed. force reget! */
+ Lisp_Object lfl,lf;
+ /* redraw ALL frames on this device! */
+ DEVICE_FRAME_LOOP(lfl,d) {
+ lf=XCAR(lfl);
+ f=XFRAME(lf);
+ FRAME_GTK_TRANS_FAIL(f)=0;
+ if(FRAME_GTK_PIXMAP(f)) {
+#ifdef HAVE_GDK_IMLIB_INIT
+ gdk_pixmap_unref(FRAME_GTK_PIXMAP(f));
+#endif
+ FRAME_GTK_PIXMAP(f)=NULL; }}
+ DEVICE_FRAME_LOOP(lfl,d) {
+ lf=XCAR(lfl);
+ f=XFRAME(lf);
+ if(FRAME_GTK_TRANS_ANY(f)&&
+ get_transparency_pixmap(f,1))
+ gtk_redraw_trans(f); }}
+ /* } azundris 2001/12/09 */
+ break;
case GDK_CLIENT_EVENT: FROB(client); break;
case GDK_MAP:
- case GDK_UNMAP: FROB(any); break;
- case GDK_CONFIGURE: FROB(configure); break;
+ case GDK_UNMAP: FROB(any); break;
+ case GDK_CONFIGURE: FROB(configure);
+ /* azundris 2001/12/09 { */
+ /* window was moved or such. */
+ if(FRAME_GTK_TRANS_ANY(frame)&&
+ get_transparency_pixmap(frame,0))
+ gtk_redraw_trans(frame);
+ /* } azundris 2001/12/09 */
+ break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY: FROB(crossing); break;
case GDK_FOCUS_CHANGE: FROB(focus_change); break;
diff -Nur xemacs-21.5.4/src/frame-gtk.c xemacs-21.5.4-trans/src/frame-gtk.c
--- xemacs-21.5.4/src/frame-gtk.c Thu Sep 20 08:28:59 2001
+++ xemacs-21.5.4-trans/src/frame-gtk.c Wed Jan 23 11:24:45 2002
@@ -32,6 +32,7 @@
#include "glyphs-gtk.h"
#include "objects-gtk.h"
#include "scrollbar-gtk.h"
+#include "redisplay-gtk.h" /* azundris 2002/01/21 */
#include "gtk-xemacs.h"
@@ -870,11 +871,13 @@
"selection-request-event",
"selection-notify-event",
"client-event",
- /* "configure-event", */
+ "configure-event", /* azundris 2001/12/09 */
"visibility-notify-event",
NULL };
int i;
+ gdk_window_set_user_data(GDK_ROOT_PARENT(),shell); /* azundris 2001/12/09 */
+ XSelectInput(GDK_DISPLAY(),GDK_ROOT_WINDOW(),PropertyChangeMask); /* azundris
2001/12/09 */
for (i = 0; events_to_frob[i]; i++)
{
gtk_signal_connect (GTK_OBJECT (shell), events_to_frob[i],
@@ -1007,7 +1010,54 @@
static void
gtk_init_frame_3 (struct frame *f)
-{
+{ struct frame *i=NULL,*r;
+ struct device *d=XDEVICE(FRAME_DEVICE(f));
+
+ /* find a frame to inherit transparency foo from */
+ { Lisp_Object lfl,lf;
+ DEVICE_FRAME_LOOP(lfl,d) {
+ lf=XCAR(lfl);
+ r=XFRAME(lf);
+ if(FRAME_GTK_TRANS_ANY(r)&&FRAME_GTK_PIXMAP(r)) {
+ i=r;
+ break; }}}
+
+ /* azundris 2002/01/18 */
+ if(i) {
+#ifdef HAVE_GDK_IMLIB_INIT
+ memcpy(&FRAME_GTK_MOD(f),&FRAME_GTK_MOD(i),sizeof(GdkImlibColorModifier));
+ memcpy(&FRAME_GTK_RMOD(f),&FRAME_GTK_RMOD(i),sizeof(GdkImlibColorModifier));
+ memcpy(&FRAME_GTK_GMOD(f),&FRAME_GTK_GMOD(i),sizeof(GdkImlibColorModifier));
+ memcpy(&FRAME_GTK_BMOD(f),&FRAME_GTK_BMOD(i),sizeof(GdkImlibColorModifier));
+#endif
+
+ FRAME_GTK_TRANS_TAB(f) =FRAME_GTK_TRANS_TAB(i);
+ FRAME_GTK_TRANS_TEXT(f)=FRAME_GTK_TRANS_TEXT(i);
+ FRAME_GTK_TRANS_BG(f) =FRAME_GTK_TRANS_BG(i);
+
+ /* FRAME_GTK_PIXMAP(f) =gdk_pixmap_ref(FRAME_GTK_PIXMAP(i)); */ }
+ else {
+#ifdef HAVE_GDK_IMLIB_INIT
+ FRAME_GTK_MOD(f).contrast =
+ FRAME_GTK_RMOD(f).contrast=
+ FRAME_GTK_GMOD(f).contrast=
+ FRAME_GTK_BMOD(f).contrast=256;
+
+ FRAME_GTK_MOD(f).brightness =
+ FRAME_GTK_RMOD(f).brightness=
+ FRAME_GTK_GMOD(f).brightness=
+ FRAME_GTK_BMOD(f).brightness=256;
+
+ FRAME_GTK_MOD(f).gamma =190;
+ FRAME_GTK_RMOD(f).gamma=
+ FRAME_GTK_GMOD(f).gamma=
+ FRAME_GTK_BMOD(f).gamma=256;
+#endif
+
+ FRAME_GTK_TRANS_TAB(f) =
+ FRAME_GTK_TRANS_TEXT(f)=
+ FRAME_GTK_TRANS_BG(f) =0; }
+
/* Pop up the frame. */
gtk_popup_frame (f);
}
@@ -1381,6 +1431,68 @@
gtk_recompute_cell_sizes (frm);
}
+DEFUN ("gtk-put-transparency", Fgtk_put_transparency, 2, 2, 0, /*
+Configure transparency, tinting and shading of the text widget and toolbar.
+
+FRAME is the frame to apply the settings to. Normally, one would only set
+up the first frame from ~/.xemacs/init.el, since all subsequent frames will
+inherit its settings, but it is theoretically possible to apply different
+settings to each frame. This however is a drain on memory since a pixmap
+the size of the root window will be allocated for each unique tinting/shading
+set-up (ie, several windows sharing the same tinting/shading will also share
+one pixmap; new maps are allocated only for frame with unique tinting/shading
+options). Note that only the shade and red/green/blue properties are relevant
+to a frame's "uniqueness"; frames with the same tinting/shading but
different
+trans props will still share a single pixmap.
+
+If FRAME is nil, (selected-frame) will be used.
+
+TRANSPARENCY-ALIST is an alist defining the settings for transparency,
+tinting and shading, like so:
+
+ '((trans . (tab text))
+ (shade . (180 512))
+ (red . (0))
+ (green . (128 70))
+ (blue . (256 256 90)))
+
+TRANS may be omitted, or may contain any combination of tab, text, bg.
+ If TAB is present, tabs are rendered transparent.
+ If BG is present, areas with no text are rendered transparent.
+ If TEXT is present, the background of text is rendered transparent,
+ unless a background pixmap or colour is set for the face used.
+
+SHADE, RED, GREEN, and BLUE may contain 1 - 3 values each:
+
+ brightness [contrast [gamma]]
+
+ SHADE sets the overall brightness, contrast and gamma. Use this for the
+ popular "smoked glass" (or "shading") effect.
+
+ RED, GREEN, and BLUE let you apply parameters to each colour channel separately
+ for "tinted glass."
+
+ SHADE, RED, GREEN, and BLUE may be omitted or used in any combination.
+ If all of them are omitted, no tinting/shading will be done; the properties
+ listed in TRANS will simply become transparent ("see-through").
+
+Transparency is only available when compiled with GTK. Tinting and shading
+are only available when compiled with GTK and Imlib. Use featurep to enquire
+about the presence of each, like so:
+
+ (featurep 'transparency)
+ (featurep 'tinting)
+ (featurep 'shading)
+
+If TRANSPARENCY-ALIST is nil, transparency will be turned off in the frame.
+*/
+ (frame, transparency_alist))
+{
+ if(NILP(frame))
+ frame=Fselected_frame(Qnil);
+ parse_transparency(decode_gtk_frame(frame),transparency_alist);
+ return Qt; }
+
/************************************************************************/
/* initialization */
@@ -1403,6 +1515,7 @@
#ifdef STUPID_X_SPECIFIC_GTK_STUFF
DEFSUBR (Fgtk_window_id);
#endif
+ DEFSUBR (Fgtk_put_transparency);
}
void
@@ -1444,6 +1557,13 @@
void
vars_of_frame_gtk (void)
{
+ Fprovide (Qtransparency);
+#ifdef HAVE_GDK_IMLIB_INIT
+ Fprovide (Qtinting);
+ Fprovide (Qshading);
+#endif
+ /* } azundris 2002/01/07 */
+
DEFVAR_LISP ("default-gtk-frame-plist", &Vdefault_gtk_frame_plist /*
Plist of default frame-creation properties for Gtk frames.
These override what is specified in the resource database and in
diff -Nur xemacs-21.5.4/src/general-slots.h xemacs-21.5.4-trans/src/general-slots.h
--- xemacs-21.5.4/src/general-slots.h Tue Oct 30 06:13:30 2001
+++ xemacs-21.5.4-trans/src/general-slots.h Tue Jan 22 18:51:42 2002
@@ -121,6 +121,9 @@
SYMBOL (Qgeometry);
SYMBOL (Qglobal);
SYMBOL (Qgtk);
+SYMBOL (Qtransparency);
+SYMBOL (Qtinting);
+SYMBOL (Qshading);
SYMBOL (Qgutter);
SYMBOL (Qheight);
SYMBOL_KEYWORD (Q_height);
diff -Nur xemacs-21.5.4/src/redisplay-gtk.c xemacs-21.5.4-trans/src/redisplay-gtk.c
--- xemacs-21.5.4/src/redisplay-gtk.c Sun Dec 23 21:28:21 2001
+++ xemacs-21.5.4-trans/src/redisplay-gtk.c Wed Jan 23 11:11:17 2002
@@ -34,6 +34,10 @@
#include "gccache-gtk.h"
#include "glyphs-gtk.h"
#include "objects-gtk.h"
+#include "redisplay-gtk.h" /* azundris 2001/12/09 */
+#ifdef HAVE_GDK_IMLIB_INIT
+# include <gdk_imlib.h> /* azundris 2002/01/17 */
+#endif
#include "buffer.h"
#include "debug.h"
@@ -85,6 +89,17 @@
static void gtk_clear_frame_windows (Lisp_Object window);
static void gtk_bevel_modeline (struct window *w, struct display_line *dl);
+#ifdef HAVE_GDK_IMLIB_INIT
+static GdkPixmap *create_shaded_pixmap(struct frame *,Pixmap,int,int,int,int);
+#endif
+
+static GdkPixmap *find_pixmap(struct frame *);
+static char *elt_name(Lisp_Object);
+static int strmc(char *,char *);
+static void set_trans_props(struct frame *,Lisp_Object);
+static void set_tint_pars(struct frame *,char *,Lisp_Object);
+void gtk_redraw_exposed_area(struct frame *,int,int,int,int);
+
#if 0
static void __describe_gc (GdkGC *);
#endif
@@ -97,6 +112,327 @@
int dimension;
};
+
+
+/*****************************************************************************/
+
+
+
+/* azundris 2002/01/17 -- adapted from zvt, with thanks { */
+#ifdef HAVE_GDK_IMLIB_INIT
+
+static GdkPixmap *
+create_shaded_pixmap(struct frame *f,Pixmap p,int x,int y,int w,int h) {
+ GdkPixmap *pix,*pp,*tmp;
+ GdkImlibImage *iim;
+ GdkGC *tgc;
+ int width,height,depth;
+
+ if(p==None)
+ return NULL;
+
+ pp=gdk_pixmap_foreign_new(p);
+ gdk_window_get_geometry(pp,NULL,NULL,&width,&height,&depth);
+
+ if(width<x+w||height<y+h||x<0||y<0) {
+ tmp=gdk_pixmap_new(pp,w,h,depth);
+
+ tgc=gdk_gc_new(pp);
+
+ gdk_gc_set_tile(tgc,pp);
+ gdk_gc_set_fill(tgc,GDK_TILED);
+ gdk_gc_set_ts_origin(tgc,-x,-y);
+ gdk_draw_rectangle(tmp,tgc,TRUE,0,0,w,h);
+
+ gdk_gc_destroy(tgc);
+
+ iim=gdk_imlib_create_image_from_drawable(tmp,NULL,0,0,w,h);
+
+ gdk_pixmap_unref(tmp); }
+ else
+ iim=gdk_imlib_create_image_from_drawable(pp,NULL,x,y,w,h);
+
+ gdk_xid_table_remove(GDK_WINDOW_XWINDOW(pp));
+ g_dataset_destroy(pp);
+ g_free(pp);
+
+ if(!iim)
+ return NULL;
+
+ /* apply shading */
+ gdk_imlib_set_image_modifier( iim,&FRAME_GTK_MOD(f));
+
+ /* apply tint */
+ gdk_imlib_set_image_red_modifier( iim,&FRAME_GTK_RMOD(f));
+ gdk_imlib_set_image_green_modifier(iim,&FRAME_GTK_GMOD(f));
+ gdk_imlib_set_image_blue_modifier( iim,&FRAME_GTK_BMOD(f));
+
+ /* render image */
+ gdk_imlib_render(iim,iim->rgb_width,iim->rgb_height);
+
+ //gdk_imlib_apply_modifiers_to_rgb(iim);
+
+ /* we need to return a pixmap, after all */
+ pix=gdk_imlib_move_image(iim);
+
+ /* discard temp image */
+ gdk_imlib_destroy_image(iim);
+
+ return pix; }
+
+#endif
+/* } azundris 2002/01/17 -- adapted from zvt, with thanks */
+
+
+
+static GdkPixmap *
+find_pixmap(struct frame *frame) {
+ struct device *d=XDEVICE(FRAME_DEVICE(frame));
+ struct frame *f;
+ Lisp_Object lfl,lf;
+
+#ifdef HAVE_GDK_IMLIB_INIT
+# define MOD_CMP(a,b)
((((a).brightness)==((b).brightness))&&(((a).contrast)==((b).contrast))&&(((a).gamma)==((b).gamma)))
+#endif
+
+ DEVICE_FRAME_LOOP(lfl,d) {
+ lf=XCAR(lfl);
+ f=XFRAME(lf);
+ if((f!=frame)&&(FRAME_GTK_PIXMAP(f))) {
+/* printf("testing frame %p vs %p: %d %d/%d/%d\n",f,frame,
+ MOD_CMP(FRAME_GTK_MOD(f),FRAME_GTK_MOD(frame)),
+ MOD_CMP(FRAME_GTK_RMOD(f),FRAME_GTK_RMOD(frame)),
+ MOD_CMP(FRAME_GTK_GMOD(f),FRAME_GTK_GMOD(frame)),
+ MOD_CMP(FRAME_GTK_BMOD(f),FRAME_GTK_BMOD(frame))); */
+
+#ifdef HAVE_GDK_IMLIB_INIT
+ if(MOD_CMP(FRAME_GTK_MOD(f),FRAME_GTK_MOD(frame))&&
+ MOD_CMP(FRAME_GTK_RMOD(f),FRAME_GTK_RMOD(frame))&&
+ MOD_CMP(FRAME_GTK_GMOD(f),FRAME_GTK_GMOD(frame))&&
+ MOD_CMP(FRAME_GTK_BMOD(f),FRAME_GTK_BMOD(frame)))
+#endif
+ return FRAME_GTK_PIXMAP(f); }}
+ return NULL; }
+
+
+
+void
+gtk_redraw_trans(struct frame *f) {
+ gint x,y,w,h;
+ gdk_window_get_geometry(GET_GTK_WIDGET_WINDOW(FRAME_GTK_TEXT_WIDGET(f)),
+ &x,&y,&w,&h,NULL);
+ gtk_redraw_exposed_area(f,x,y,w,h); }
+
+
+
+GdkPixmap *
+get_transparency_pixmap(struct frame *f,int reget) { /* azundris 2001/12/09 */
+ Atom prop, type;
+ int format;
+ unsigned long length, after;
+ unsigned char *data;
+ GdkPixmap **retval,*old;
+ GdkWindow *w;
+
+ if(!f)
+ return NULL;
+
+ retval=&(FRAME_GTK_PIXMAP(f));
+ old=*retval;
+
+ if(reget) {
+ if(*retval) {
+ *retval=NULL; }}
+ else if(*retval||FRAME_GTK_TRANS_FAIL(f))
+ return *retval;
+
+ if(old)
+ gdk_pixmap_unref(old);
+
+ if((*retval=find_pixmap(f))) /* reuse pixmap if we can */
+ return gdk_pixmap_ref(*retval);
+
+ if((w=GET_GTK_WIDGET_WINDOW(FRAME_GTK_TEXT_WIDGET(f)))) {
+
+ if((prop=XInternAtom(GDK_DISPLAY(),"_XROOTPMAP_ID",True))!=None) {
+
+ int ret=XGetWindowProperty(GDK_DISPLAY(),GDK_ROOT_WINDOW(),prop,0L,1L,False,
+
AnyPropertyType,&type,&format,&length,&after,&data);
+ if(ret||!data||(*((Pixmap *)data)==None)) {
+ fprintf(stderr,"XGetWindowProperty returned %d,
data=%p->%p\n",ret,data,
+ (data?*((Pixmap *)data):NULL)); }
+ else if(type==XA_PIXMAP) {
+#ifdef HAVE_GDK_IMLIB_INIT
+ if(!(*retval=create_shaded_pixmap(f, *((Pixmap *)data),
+ 0,0,
+ gdk_screen_width(),
+ gdk_screen_height())))
+ fputs("gtk-transparency: tinting/shading failed!\n",stderr);
+#else
+ if(!(*retval=gdk_pixmap_foreign_new(*((Pixmap *)data))))
+ fputs("gtk-transparency: transparency failed!\n",stderr);
+#endif
+ }}}
+
+ if(!*retval) {
+ FRAME_GTK_TRANS_FAIL(f)=1;
+ gtk_redraw_trans(f); }
+
+ return *retval; } /* } azundris */
+
+
+
+static char *
+elt_name(Lisp_Object elt) {
+ const Extbyte *temp=NULL;
+ if(SYMBOLP(elt))
+ LISP_STRING_TO_EXTERNAL((Lisp_Object)symbol_name((Lisp_Symbol
*)elt),temp,Qcommand_argument_encoding);
+ else if(STRINGP(elt))
+ LISP_STRING_TO_EXTERNAL(elt,temp,Qcommand_argument_encoding);
+ else
+ return NULL;
+ return strdup(temp); }
+
+
+
+static int
+strmc(char *a,char *b) {
+ if(!b||!a||!strlen(a))
+ return 0;
+ while(*b) {
+ /* printf("cmp \"%s\", \"%s\"\n",a,b); */
+ if(!strcasecmp(a,b))
+ return 1;
+ b+=strlen(b)+1; }
+ return 0; }
+
+
+
+static void
+set_trans_props(struct frame *f,Lisp_Object l) {
+ char *which=NULL;
+
+ FRAME_GTK_TRANS_FAIL(f)=
+ FRAME_GTK_TRANS_BG(f) =
+ FRAME_GTK_TRANS_TEXT(f)=
+ FRAME_GTK_TRANS_TAB(f) =0;
+
+ { LIST_LOOP_2(elt,l) {
+ CHECK_SYMBOL(elt);
+ if(!(CONSP(elt)&&(XCDR(elt)!=Qnil)))
+ which=elt_name(elt);
+ else
+ which=elt_name(XCDR(elt));
+ if(which) {
+ if(strmc(which,"tab\0tabs\0"))
+ FRAME_GTK_TRANS_TAB(f)=1;
+ else if(strmc(which,"text\0txt\0fg\0foreground\0"))
+ FRAME_GTK_TRANS_TEXT(f)=1;
+ else if(strmc(which,"background\0bg\0other\0"))
+ FRAME_GTK_TRANS_BG(f)=1;
+ else
+ fprintf(stderr,"ignoring unknown symbol \"%s\" in
trans...\n",which);
+ free(which); }}}}
+
+
+
+static void
+set_tint_pars(struct frame *f,char *typ,Lisp_Object l) {
+#ifdef HAVE_GDK_IMLIB_INIT
+ int c=0,v;
+ GdkImlibColorModifier m;
+
+ m.brightness=m.gamma=m.contrast=256;
+
+ { LIST_LOOP_2(elt,l) {
+ CHECK_INT(elt);
+ v=XUINT(elt);
+ switch(c) {
+ case 0: m.brightness=v; break;
+ case 1: m.contrast =v; break;
+ case 2: m.gamma =v; break;
+ default: fputs("tint expects 1-3 values only!\n",stderr); }
+ c++; }}
+
+ if(strmc(typ,"r\0red\0"))
+ memcpy(&FRAME_GTK_RMOD(f),&m,sizeof(m));
+ else if(strmc(typ,"g\0green\0"))
+ memcpy(&FRAME_GTK_GMOD(f),&m,sizeof(m));
+ else if(strmc(typ,"b\0blue\0"))
+ memcpy(&FRAME_GTK_BMOD(f),&m,sizeof(m));
+ else if(strmc(typ,"shade\0tint\0s\0t\0"))
+ memcpy(&FRAME_GTK_MOD(f),&m,sizeof(m));
+ else
+#endif
+ fprintf(stderr,"unknown modifier \"%s\" in set_tint_pars\n",typ);
}
+
+
+
+/* f -> frame to assign the transparency info to
+ ts -> alist containing transparency info:
+ (gtk-put-transparency (selected-frame)
+ '((trans . (tab text))
+ (shade . (180 512))
+ (red . (0))
+ (green . (128 70))
+ (blue . (256 256 90))))
+ trans may be omitted, or may contain any combination
+ of tab, text, bg
+ shade, red, green, blue may be omitted, or may contain
+ 1 - 3 values each: brightness [contrast [gamma]]
+ ret <- void */
+
+void
+parse_transparency(struct frame *f,Lisp_Object ts) {
+ char *nam;
+
+ if(!f) {
+ fputs("parse_transparency called with no frame!\n",stderr);
+ return; }
+
+ if(NILP(ts)) {
+ FRAME_GTK_TRANS_FAIL(f)=
+ FRAME_GTK_TRANS_TAB(f) =
+ FRAME_GTK_TRANS_BG(f) =
+ FRAME_GTK_TRANS_TEXT(f)=0; }
+ else {
+ EXTERNAL_ALIST_LOOP_4(elt, elt_car, elt_cdr, ts) {
+ CHECK_SYMBOL(elt_car);
+ CHECK_LIST(elt_cdr);
+ nam=elt_name(elt_car);
+ /* printf("::%s::\n",nam); */
+ if(strmc(nam,"trans\0transparency\0"))
+ set_trans_props(f,elt_cdr);
+ else
+#ifdef HAVE_GDK_IMLIB_INIT
+ set_tint_pars(f,nam,elt_cdr);
+#else
+ fputs("no imlib, ignoring transparing propertiers other than
'trans'\n",stderr);
+#endif
+
+ if(nam) free(nam); }
+
+#ifndef HAVE_GDK_IMLIB_INIT
+ if(!FRAME_GTK_PIXMAP(f)&&FRAME_GTK_TRANS_ANY(f))
+#endif
+ get_transparency_pixmap(f,1); }
+
+ /* if transparency has been disabled, either by passing nil instead of
+ an alist, or by passing "shade" with no properties (tab, text, ...),
+ we release the pixmap if we have one. */
+ if(FRAME_GTK_PIXMAP(f)&&!FRAME_GTK_TRANS_ANY(f)) {
+ gdk_pixmap_unref(FRAME_GTK_PIXMAP(f));
+ FRAME_GTK_PIXMAP(f)=NULL; }
+
+ /* force redisplay */
+ gtk_redraw_trans(f); }
+
+
+
+/*****************************************************************************/
+
+
+
/* Separate out the text in DYN into a series of textual runs of a
particular charset. Also convert the characters as necessary into
the format needed by XDrawImageString(), XDrawImageString16(), et
@@ -669,6 +1005,7 @@
GdkWindow *x_win = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (f));
int clip_end;
+ int trans=FRAME_GTK_TRANS_TEXT(f)&&get_transparency_pixmap(f,0);
/* Cursor-related variables */
int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
@@ -736,17 +1073,34 @@
|| !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
bg_pmap = Qnil;
- if ((cursor && focus && NILP (bar_cursor_value)
- && !NILP (w->text_cursor_visible_p)) || NILP (bg_pmap))
+ if ((cursor && focus && NILP(bar_cursor_value) &&
+ !NILP (w->text_cursor_visible_p)) ||
+ (NILP(bg_pmap)&&!trans))
bgc = 0;
else
bgc = gtk_get_gc (d, Qnil, cachel->foreground, cachel->background,
- bg_pmap, Qnil);
+ bg_pmap, Qnil);
+
+ if (bgc) { /* azundris 2001/12/08 { */
+ int wx,wy,ww,wh,px,py;
- if (bgc)
- gdk_draw_rectangle (GDK_DRAWABLE (x_win), bgc, TRUE, clip_start,
- dl->ypos - dl->ascent, clip_end - clip_start,
- height);
+ wx=clip_start;
+ wy=dl->ypos-dl->ascent;
+ ww=clip_end-clip_start;
+ wh=height;
+
+ if(!NILP(bg_pmap))
+ gdk_draw_rectangle(GDK_DRAWABLE (x_win), bgc, TRUE, clip_start,
+ dl->ypos - dl->ascent, clip_end - clip_start,
+ height);
+ else if(cachel->background!=WINDOW_FACE_CACHEL(w,0)->background)
+ bgc=0;
+ else if(trans) {
+ gdk_window_get_origin(x_win,&px,&py);
+ gdk_draw_pixmap(GDK_DRAWABLE(x_win),bgc,get_transparency_pixmap(f,0),
+ wx+px,wy+py,
+ wx,wy,ww,wh); }
+ } /* } azundris 2001/12/08 */
for (i = 0; i < nruns; i++)
{
@@ -1279,7 +1633,17 @@
WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex), bg_pmap,
Qnil);
- gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc, TRUE, x, y, width, height);
+ if(gc) { /* azundris 2002/01/07 { transparent tabs */
+ int px,py;
+
+ if(FRAME_GTK_TRANS_TAB(f)&&get_transparency_pixmap(f,0)) {
+ gdk_window_get_origin(x_win,&px,&py);
+ gdk_draw_pixmap(GDK_DRAWABLE(x_win),gc,get_transparency_pixmap(f,0),
+ x+px,y+py,
+ x,y-1,width,height+1); }
+ else {
+ gdk_draw_rectangle(GDK_DRAWABLE (x_win), gc, TRUE,
+ x, y, width, height); }} /* } azundris 2001/12/08 */
/* If this rune is marked as having the cursor, then it is actually
representing a tab. */
@@ -1616,10 +1980,20 @@
gc = gtk_get_gc (d, Qnil, fcolor, bcolor, background_pixmap, Qnil);
}
- if (gc)
+ if (gc) /* this is where we redraw text-less areas (usually to the right) azundris
2001/12/08 { */
{
- gdk_draw_rectangle (GDK_DRAWABLE (x_win), gc,TRUE,
- x, y, width, height);
+ int px,py;
+
+ if(FRAME_GTK_TRANS_BG(f)&&get_transparency_pixmap(f,0)) {
+ gdk_window_get_origin(x_win,&px,&py);
+ gdk_draw_pixmap(GDK_DRAWABLE(x_win),gc,get_transparency_pixmap(f,0),
+ x+px,y+py,
+ x,y,width,height+1); }
+ else {
+/* gdk_gc_set_tile(gc,get_transparency_pixmap(f,0)); */
+ gdk_window_get_root_origin(x_win,&px,&py);
+ gdk_draw_rectangle(GDK_DRAWABLE (x_win), gc,TRUE,
+ x, y, width, height); } /* } azundris 2001/12/08 */
}
else
{
diff -Nur xemacs-21.5.4/src/redisplay-gtk.h xemacs-21.5.4-trans/src/redisplay-gtk.h
--- xemacs-21.5.4/src/redisplay-gtk.h Thu Jan 1 01:00:00 1970
+++ xemacs-21.5.4-trans/src/redisplay-gtk.h Tue Jan 22 18:51:53 2002
@@ -0,0 +1,10 @@
+/* azundris
+ 2001/12/09 init
+ 2002/01/07 Lisp_Objects, offsets transferred here, Xatom, useless decl removed */
+
+#include <X11/Xatom.h>
+#include <gdk/gdkx.h>
+
+GdkPixmap *get_transparency_pixmap(struct frame *f,int reget);
+void gtk_redraw_trans(struct frame *f);
+void parse_transparency(struct frame *,Lisp_Object);
diff -Nur xemacs-21.5.4/src/redisplay.c xemacs-21.5.4-trans/src/redisplay.c
--- xemacs-21.5.4/src/redisplay.c Thu Sep 20 08:29:11 2001
+++ xemacs-21.5.4-trans/src/redisplay.c Tue Jan 22 18:52:12 2002
@@ -9203,6 +9203,7 @@
/* Unreached. */
}
+
void
syms_of_redisplay (void)
{
--
www.azundris.com