* new frame-parameter "alpha"
@ 2008-03-14 11:02 Seiji Zenitani
2008-03-14 18:28 ` Stefan Monnier
2008-03-20 15:22 ` Ken Raeburn
0 siblings, 2 replies; 25+ messages in thread
From: Seiji Zenitani @ 2008-03-14 11:02 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]
Hi,
The attached patch adds the window (frame) opacity feature to GNU
Emacs. The user can control the frame opacity via a frame parameter
'alpha'. If you like the code, I'll start to contact major
contributors.
Tested on:
* Emacs 23.0.60 (CVS 2008-03-13; i686-pc-linux-gnu, GTK+ Version 2.12.0)
* Ubuntu Linux 7.10
* It may not work on older X11 systems (X11R6.x)
Elisp syntax:
We can use both a floating point number (0.0-1.0) as well as an
integer number (0-100).
(set-frame-parameter nil 'alpha 80)
(set-frame-parameter nil 'alpha 0.8)
(set-frame-parameter nil 'alpha '(<active> [<inactive>]))
(set-frame-parameter nil 'alpha '(100 70))
(set-frame-parameter nil 'alpha '(nil 70))
(set-frame-parameter nil 'alpha '(0.8 nil))
(set-frame-parameter nil 'alpha nil) ;; nil = default = opaque
(set-alpha 80)
(set-alpha 0.8)
(set-alpha '(100 0.7))
(set-alpha nil)
(setq frame-alpha-lower-limit 20)
(setq frame-alpha-lower-limit 0.2)
Contributors:
* Ryo Yoshitake (frame parameter code, x_set_frame_alpha function)
* Seiji Zenitani (x_set_alpha function)
* Meadow devel team (the original version of x_set_alpha function)
* Takashi Hiromatsu (the author of the initial version)
* Yoichi Nakayama (minor improvement to x_set_frame_alpha function)
[-- Attachment #2: transparency4-x23.patch --]
[-- Type: application/octet-stream, Size: 8656 bytes --]
diff -Naur emacs.orig/lisp/frame.el emacs.new/lisp/frame.el
--- emacs.orig/lisp/frame.el 2008-02-14 16:16:36.000000000 -0500
+++ emacs.new/lisp/frame.el 2008-03-13 07:10:40.000000000 -0400
@@ -1079,6 +1079,17 @@
(modify-frame-parameters (selected-frame)
(list (cons 'border-color color-name))))
+ (defun set-alpha (alpha &optional frame)
+ "Set the opacity of FRAME to ALPHA. First argument ALPHA
+should range from 0 (invisible) to 100 (completely opaque).
+You can also use an floating point number 0.0 to 1.0.
+When called interactively, prompt for the value of the opacity to set.
+FRAME defaults to the selected frame. To get the frame's current
+alpha value state, use `frame-parameters'."
+ (interactive "XWindow Opacity (0-100 or 0.0-1.0) : ")
+ (modify-frame-parameters frame
+ (list (cons 'alpha alpha))))
+
(defun auto-raise-mode (arg)
"Toggle whether or not the selected frame should auto-raise.
With arg, turn auto-raise mode on if and only if arg is positive.
diff -Naur emacs.orig/src/frame.c emacs.new/src/frame.c
--- emacs.orig/src/frame.c 2008-02-11 23:03:16.000000000 -0500
+++ emacs.new/src/frame.c 2008-03-13 07:10:40.000000000 -0400
@@ -67,6 +67,12 @@
Lisp_Object Vx_resource_class;
+#ifdef HAVE_X_WINDOWS
+/* Lower limit value of frame transparency. */
+
+Lisp_Object Vframe_alpha_lower_limit;
+#endif
+
#endif
Lisp_Object Qframep, Qframe_live_p;
@@ -120,6 +126,9 @@
#ifdef USE_FONT_BACKEND
Lisp_Object Qfont_backend;
#endif /* USE_FONT_BACKEND */
+#ifdef HAVE_X_WINDOWS
+Lisp_Object Qalpha;
+#endif
Lisp_Object Qinhibit_face_set_after_frame_default;
Lisp_Object Qface_set_after_frame_default;
@@ -2855,6 +2864,9 @@
{"right-fringe", &Qright_fringe},
{"wait-for-wm", &Qwait_for_wm},
{"fullscreen", &Qfullscreen},
+#ifdef HAVE_X_WINDOWS
+ {"alpha", &Qalpha},
+#endif
#ifdef USE_FONT_BACKEND
{"font-backend", &Qfont_backend}
#endif /* USE_FONT_BACKEND */
@@ -3699,6 +3711,63 @@
return Qnil;
}
+#ifdef HAVE_X_WINDOWS
+void
+x_set_alpha (f, arg, oldval)
+ struct frame *f;
+ Lisp_Object arg, oldval;
+{
+ double alpha = 1.0;
+ double newval[2];
+ int i, ialpha;
+ Lisp_Object item;
+
+ for( i=0; i<2; i++ )
+ newval[i] = 1.0;
+
+ for( i=0; i<2; i++ )
+ {
+ if( CONSP (arg) )
+ {
+ item = CAR (arg);
+ arg = CDR (arg);
+ }
+ else
+ item=arg;
+
+ if( !NILP (item) )
+ {
+ if( FLOATP(item) )
+ {
+ alpha = XFLOAT_DATA (item);
+ if ( alpha < 0.0 || 1.0 < alpha )
+ args_out_of_range (make_float (0.0), make_float (1.0));
+ }
+ else if( INTEGERP(item) )
+ {
+ ialpha = XINT (item);
+ if ( ialpha < 0 || 100 < ialpha )
+ args_out_of_range (make_number (0), make_number (100));
+ else
+ alpha = ialpha / 100.0;
+ }
+ else
+ wrong_type_argument (Qnumberp, item);
+ }
+ newval[i]=alpha;
+ }
+
+ for ( i=0; i<2; i++ )
+ f->alpha[i] = newval[i];
+
+ BLOCK_INPUT;
+ x_set_frame_alpha (f);
+ UNBLOCK_INPUT;
+
+ return;
+}
+#endif
+
\f
/* Subroutines of creating an X frame. */
@@ -4468,6 +4537,12 @@
but binding this variable locally around a call to `x-get-resource'
is a reasonable practice. See also the variable `x-resource-name'. */);
Vx_resource_class = build_string (EMACS_CLASS);
+
+#ifdef HAVE_X_WINDOWS
+ DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit,
+ doc: /* Lower limit of alpha value of frame. */);
+ Vframe_alpha_lower_limit = make_number (20);
+#endif
#endif
DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
diff -Naur emacs.orig/src/frame.h emacs.new/src/frame.h
--- emacs.orig/src/frame.h 2008-02-22 12:42:08.000000000 -0500
+++ emacs.new/src/frame.h 2008-03-13 07:10:40.000000000 -0400
@@ -204,6 +204,11 @@
be used for output. */
unsigned glyphs_initialized_p : 1;
+#ifdef HAVE_X_WINDOWS
+ /* Opacity of the Frame */
+ double alpha[2];
+#endif
+
/* Set to non-zero in change_frame_size when size of frame changed
Clear the frame in clear_garbaged_frames if set. */
unsigned resized_p : 1;
@@ -1021,6 +1026,9 @@
extern Lisp_Object Qwait_for_wm;
extern Lisp_Object Qfullscreen;
extern Lisp_Object Qfont_backend;
+#ifdef HAVE_X_WINDOWS
+extern Lisp_Object Qalpha;
+#endif
extern Lisp_Object Qleft_fringe, Qright_fringe;
extern Lisp_Object Qheight, Qwidth;
@@ -1100,6 +1108,10 @@
extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
+#if defined (HAVE_X_WINDOWS) || defined (HAVE_CARBON)
+extern Lisp_Object Vframe_alpha_lower_limit;
+extern void x_set_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+#endif
extern void validate_x_resource_name P_ ((void));
diff -Naur emacs.orig/src/xfns.c emacs.new/src/xfns.c
--- emacs.orig/src/xfns.c 2008-02-22 12:42:05.000000000 -0500
+++ emacs.new/src/xfns.c 2008-03-13 07:10:40.000000000 -0400
@@ -585,6 +585,8 @@
Lisp_Object,
char *, char *,
int));
+extern void x_set_frame_alpha P_ ((struct frame *));
+
\f
/* Store the screen positions of frame F into XPTR and YPTR.
@@ -3578,6 +3580,8 @@
x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
"scrollBarWidth", "ScrollBarWidth",
RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qalpha, Qnil,
+ "alpha", "Alpha", RES_TYPE_NUMBER);
/* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
Change will not be effected unless different from the current
@@ -5991,6 +5995,9 @@
x_set_fringe_width,
x_set_wait_for_wm,
x_set_fullscreen,
+#ifdef HAVE_X_WINDOWS
+ x_set_alpha,
+#endif
#ifdef USE_FONT_BACKEND
x_set_font_backend
#endif /* USE_FONT_BACKEND */
diff -Naur emacs.orig/src/xterm.c emacs.new/src/xterm.c
--- emacs.orig/src/xterm.c 2008-03-11 11:54:05.000000000 -0400
+++ emacs.new/src/xterm.c 2008-03-13 07:10:40.000000000 -0400
@@ -1018,6 +1018,66 @@
return FONT_TYPE_UNKNOWN;
}
+#define OPAQUE 0xffffffff
+#define OPACITY "_NET_WM_WINDOW_OPACITY"
+
+void
+x_set_frame_alpha (f)
+ struct frame *f;
+{
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+ Display *dpy = FRAME_X_DISPLAY (f);
+ Window win = FRAME_OUTER_WINDOW (f);
+ if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc)
+ /* Since the WM decoration lies under the FRAME_OUTER_WINDOW,
+ we must treat the former instead of the latter. */
+ win = FRAME_X_OUTPUT(f)->parent_desc;
+
+ double alpha = 1.0, alpha_lower_limit = 1.0;
+
+ if (dpyinfo->x_highlight_frame == f)
+ alpha = f->alpha[0];
+ else
+ alpha = f->alpha[1];
+
+ if( FLOATP(Vframe_alpha_lower_limit) )
+ alpha_lower_limit = XFLOAT_DATA (Vframe_alpha_lower_limit);
+ else if( INTEGERP(Vframe_alpha_lower_limit) )
+ alpha_lower_limit = ( XINT (Vframe_alpha_lower_limit) ) / 100.0;
+
+ if( alpha < 0.0 || 1.0 < alpha ) alpha = 1.0;
+ if ( 0.0 <= alpha && alpha < alpha_lower_limit && alpha_lower_limit < 1.0)
+ alpha = alpha_lower_limit;
+
+ unsigned int opac = (unsigned int)(alpha * OPAQUE);
+
+ /* return unless necessary */
+ {
+ unsigned char *data;
+ Atom actual;
+ int format;
+ unsigned long n, left;
+
+ XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False),
+ 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
+ (unsigned char **) &data);
+ if (data != None)
+ if (*(unsigned int *)data == opac)
+ {
+ XFree ((void *) data);
+ return;
+ }
+ else
+ {
+ XFree ((void *) data);
+ }
+ }
+
+ XChangeProperty (dpy, win, XInternAtom (dpy, OPACITY, False),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &opac, 1L);
+ XSync (dpy, False);
+}
\f
/***********************************************************************
@@ -3468,6 +3528,7 @@
f->output_data.x->border_pixel);
UNBLOCK_INPUT;
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
static void
@@ -3483,6 +3544,7 @@
f->output_data.x->border_tile);
UNBLOCK_INPUT;
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
/* The focus has changed. Update the frames as necessary to reflect
[-- Attachment #3: Type: text/plain, Size: 38 bytes --]
==
Seiji Zenitani
zenitani@mac.com
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-14 11:02 new frame-parameter "alpha" Seiji Zenitani
@ 2008-03-14 18:28 ` Stefan Monnier
2008-03-15 2:41 ` David De La Harpe Golden
2008-03-15 19:54 ` Seiji Zenitani
2008-03-20 15:22 ` Ken Raeburn
1 sibling, 2 replies; 25+ messages in thread
From: Stefan Monnier @ 2008-03-14 18:28 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: emacs-devel
> The attached patch adds the window (frame) opacity feature to GNU Emacs.
> The user can control the frame opacity via a frame parameter 'alpha'.
> If you like the code, I'll start to contact major contributors.
I do not personally care for transparency, and I'm wondering if it's not
better handled by the (compositing) window-manager, but if some people
like this feature, I'm not opposed to it.
A few comments on the code:
> + (defun set-alpha (alpha &optional frame)
> + "Set the opacity of FRAME to ALPHA. First argument ALPHA
> +should range from 0 (invisible) to 100 (completely opaque).
> +You can also use an floating point number 0.0 to 1.0.
> +When called interactively, prompt for the value of the opacity to set.
> +FRAME defaults to the selected frame. To get the frame's current
> +alpha value state, use `frame-parameters'."
> + (interactive "XWindow Opacity (0-100 or 0.0-1.0) : ")
> + (modify-frame-parameters frame
> + (list (cons 'alpha alpha))))
Is this necessary/important?
> +#ifdef HAVE_X_WINDOWS
> +/* Lower limit value of frame transparency. */
> +
> +Lisp_Object Vframe_alpha_lower_limit;
> +#endif
> +
> #endif
Only use #ifdef conditional compilation if either it's necessary to get
the code to compile, or for code which is inherently only meaningful for
a particular configuration. Since Vframe_alpha_lower_limit makes sense
with other GUIs than X11, it should not be protected with #ifdef
HAVE_X_WINDOWS.
> +#ifdef HAVE_X_WINDOWS
> +Lisp_Object Qalpha;
> +#endif
Same here and various other places.
> +#ifdef HAVE_X_WINDOWS
> +void
> +x_set_alpha (f, arg, oldval)
> + struct frame *f;
> + Lisp_Object arg, oldval;
> +{
> + double alpha = 1.0;
> + double newval[2];
> + int i, ialpha;
> + Lisp_Object item;
> +
> + for( i=0; i<2; i++ )
> + newval[i] = 1.0;
> +
> + for( i=0; i<2; i++ )
> + {
> + if( CONSP (arg) )
> + {
> + item = CAR (arg);
> + arg = CDR (arg);
> + }
> + else
> + item=arg;
> +
> + if( !NILP (item) )
> + {
> + if( FLOATP(item) )
> + {
> + alpha = XFLOAT_DATA (item);
> + if ( alpha < 0.0 || 1.0 < alpha )
> + args_out_of_range (make_float (0.0), make_float (1.0));
> + }
> + else if( INTEGERP(item) )
> + {
> + ialpha = XINT (item);
> + if ( ialpha < 0 || 100 < ialpha )
> + args_out_of_range (make_number (0), make_number (100));
> + else
> + alpha = ialpha / 100.0;
> + }
> + else
> + wrong_type_argument (Qnumberp, item);
> + }
> + newval[i]=alpha;
> + }
> +
> + for ( i=0; i<2; i++ )
> + f->alpha[i] = newval[i];
> +
> + BLOCK_INPUT;
> + x_set_frame_alpha (f);
> + UNBLOCK_INPUT;
> +
> + return;
> +}
> +#endif
Explain why you do things twice.
Also, note the coding conventions we use and try to reproduce them.
E.g. we place a space before open parentheses but no space after (and
no space before the close parenthesis either).
> +#ifdef HAVE_X_WINDOWS
> + /* Opacity of the Frame */
> + double alpha[2];
> +#endif
The comment should describe what the field holds, so in this case it
should describe *both* entries of the table.
Also in the docstring, don't just use "alpha" but "alpha transparency"
or something like that, for people who don't know what you mean by "alpha".
Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-14 18:28 ` Stefan Monnier
@ 2008-03-15 2:41 ` David De La Harpe Golden
2008-03-15 20:22 ` Seiji Zenitani
2008-03-15 19:54 ` Seiji Zenitani
1 sibling, 1 reply; 25+ messages in thread
From: David De La Harpe Golden @ 2008-03-15 2:41 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Seiji Zenitani, emacs-devel
Stefan Monnier wrote:
>> The attached patch adds the window (frame) opacity feature to GNU Emacs.
>> The user can control the frame opacity via a frame parameter 'alpha'.
>> If you like the code, I'll start to contact major contributors.
>
> I do not personally care for transparency, and I'm wondering if it's not
> better handled by the (compositing) window-manager, but if some people
> like this feature, I'm not opposed to it.
>
Well, (I think) the code is just programmatically setting the
"NET_WM_WINDOW_OPACITY" property on the X Window, which needs a
suitably-compositing-capable manager capable of interpreting it?
Though in typical use I would indeed expect users to just use the
relevant window manager preferences to set any desired overall opacity
of their emacs frames if they want it. Are managers in wide use that
interpret the opacity property but don't allow it to be set on a
per-window/application basis? (KDE's certainly allows that, dunno about
GNOME's). Still, one can set-frame-width/height or iconify-frame
from within emacs, why not opacity?
> (defun set-alpha ...
> Is this necessary/important?
If it exists, I think it should probably be called
set-frame-opacity - set-alpha is very vague and lots of things
might have alphas.
It should probably also take frame then opacity arg noninteractively.
Actually,
(set-frame-parameter (selected-frame) 'opacity 80)
should ideally work as expected if frame-parameters returns the opacity
- and if it does work, is set-frame-opacity really necessary?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-14 18:28 ` Stefan Monnier
2008-03-15 2:41 ` David De La Harpe Golden
@ 2008-03-15 19:54 ` Seiji Zenitani
2008-03-15 21:19 ` Stefan Monnier
1 sibling, 1 reply; 25+ messages in thread
From: Seiji Zenitani @ 2008-03-15 19:54 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 2870 bytes --]
Hi,
Thank you for your comments.
I have attached an revised code to this email.
On 2008/03/14, at 14:28, Stefan Monnier wrote:
>> The attached patch adds the window (frame) opacity feature to GNU
>> Emacs.
>> The user can control the frame opacity via a frame parameter
>> 'alpha'.
>> If you like the code, I'll start to contact major contributors.
>
> I do not personally care for transparency, and I'm wondering if
> it's not
> better handled by the (compositing) window-manager, but if some people
> like this feature, I'm not opposed to it.
>
I would like to mention that we can potentially use this frame
parameter on various platforms. I have another code for emacs 22,
which works both on X11 and on Mac/Carbon. As soon as the Mac/Carbon
port or other mac port comes back in emacs 23, it will be easy to
port the code to the mac port. In addition, some people use the
frame opacity code on the win32 platform.
> A few comments on the code:
>
>> + (defun set-alpha (alpha &optional frame)
(snip)
>
> Is this necessary/important?
I have removed it.
>> +#ifdef HAVE_X_WINDOWS
>> +/* Lower limit value of frame transparency. */
>> +
>> +Lisp_Object Vframe_alpha_lower_limit;
>> +#endif
>> +
>> #endif
>
> Only use #ifdef conditional compilation if either it's necessary to
> get
> the code to compile, or for code which is inherently only
> meaningful for
> a particular configuration. Since Vframe_alpha_lower_limit makes
> sense
> with other GUIs than X11, it should not be protected with #ifdef
> HAVE_X_WINDOWS.
>
>> +#ifdef HAVE_X_WINDOWS
>> +Lisp_Object Qalpha;
>> +#endif
>
> Same here and various other places.
>
I have reduced #ifdef ... #endif.
>> +#ifdef HAVE_X_WINDOWS
>> +void
>> +x_set_alpha (f, arg, oldval)
>> + struct frame *f;
>> + Lisp_Object arg, oldval;
>> +{
(snip)
>> +}
>> +#endif
>
> Explain why you do things twice.
This is because two kinds of frame opacity are set: one for an active
frame (the frontmost frame), the other for inactive frames
(background frames).
> Also, note the coding conventions we use and try to reproduce them.
> E.g. we place a space before open parentheses but no space after (and
> no space before the close parenthesis either).
>
I have modified the coding style.
>> +#ifdef HAVE_X_WINDOWS
>> + /* Opacity of the Frame */
>> + double alpha[2];
>> +#endif
>
> The comment should describe what the field holds, so in this case it
> should describe *both* entries of the table.
>
Done.
> Also in the docstring, don't just use "alpha" but "alpha transparency"
> or something like that, for people who don't know what you mean by
> "alpha".
>
> Stefan
At present I call the parameters/variables "alpha" ('alpha, frame-
alpha-lower-limit, x_set_frame_alpha, etc.) similar to Meadow. If
"alpha" is ambiguous, we can rename them to "opacity" etc.
[-- Attachment #2: transparency4-x23.patch --]
[-- Type: application/octet-stream, Size: 7951 bytes --]
diff -Naur emacs.orig/src/frame.c emacs/src/frame.c
--- emacs.orig/src/frame.c 2008-02-11 23:03:16.000000000 -0500
+++ emacs/src/frame.c 2008-03-14 22:53:51.000000000 -0400
@@ -67,6 +67,10 @@
Lisp_Object Vx_resource_class;
+/* Lower limit value of the frame opacity (alpha transparency). */
+
+Lisp_Object Vframe_alpha_lower_limit;
+
#endif
Lisp_Object Qframep, Qframe_live_p;
@@ -117,6 +121,7 @@
Lisp_Object Qtty, Qtty_type;
Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
+Lisp_Object Qalpha;
#ifdef USE_FONT_BACKEND
Lisp_Object Qfont_backend;
#endif /* USE_FONT_BACKEND */
@@ -2855,6 +2860,7 @@
{"right-fringe", &Qright_fringe},
{"wait-for-wm", &Qwait_for_wm},
{"fullscreen", &Qfullscreen},
+ {"alpha", &Qalpha},
#ifdef USE_FONT_BACKEND
{"font-backend", &Qfont_backend}
#endif /* USE_FONT_BACKEND */
@@ -3699,6 +3705,61 @@
return Qnil;
}
+void
+x_set_alpha (f, arg, oldval)
+ struct frame *f;
+ Lisp_Object arg, oldval;
+{
+ double alpha = 1.0;
+ double newval[2];
+ int i, ialpha;
+ Lisp_Object item;
+
+ for (i=0;i<2;i++)
+ {
+ newval[i] = 1.0;
+ if (CONSP (arg))
+ {
+ item = CAR (arg);
+ arg = CDR (arg);
+ }
+ else
+ item=arg;
+
+ if (!NILP (item))
+ {
+ if (FLOATP (item))
+ {
+ alpha = XFLOAT_DATA (item);
+ if (alpha < 0.0 || 1.0 < alpha)
+ args_out_of_range (make_float (0.0), make_float (1.0));
+ }
+ else if (INTEGERP (item))
+ {
+ ialpha = XINT (item);
+ if (ialpha < 0 || 100 < ialpha)
+ args_out_of_range (make_number (0), make_number (100));
+ else
+ alpha = ialpha / 100.0;
+ }
+ else
+ wrong_type_argument (Qnumberp, item);
+ }
+ newval[i] = alpha;
+ }
+
+ for (i=0;i<2;i++)
+ f->alpha[i] = newval[i];
+
+#ifdef HAVE_X_WINDOWS
+ BLOCK_INPUT;
+ x_set_frame_alpha (f);
+ UNBLOCK_INPUT;
+#endif
+
+ return;
+}
+
\f
/* Subroutines of creating an X frame. */
@@ -4468,6 +4527,13 @@
but binding this variable locally around a call to `x-get-resource'
is a reasonable practice. See also the variable `x-resource-name'. */);
Vx_resource_class = build_string (EMACS_CLASS);
+
+ DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit,
+ doc: /* The lower limit of the frame opacity (alpha transparency).
+The value should range from 0 (invisible) to 100 (completely opaque).
+The user can also use a floating number between 0.0 and 1.0.
+The default is 20. */);
+ Vframe_alpha_lower_limit = make_number (20);
#endif
DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
diff -Naur emacs.orig/src/frame.h emacs/src/frame.h
--- emacs.orig/src/frame.h 2008-02-22 12:42:08.000000000 -0500
+++ emacs/src/frame.h 2008-03-14 22:53:02.000000000 -0400
@@ -204,6 +204,11 @@
be used for output. */
unsigned glyphs_initialized_p : 1;
+ /* frame opacity
+ alpha[0]: alpha transparency of the active frame
+ alpha[1]: alpha transparency of inactive frames */
+ double alpha[2];
+
/* Set to non-zero in change_frame_size when size of frame changed
Clear the frame in clear_garbaged_frames if set. */
unsigned resized_p : 1;
@@ -1020,6 +1025,7 @@
extern Lisp_Object Qline_spacing;
extern Lisp_Object Qwait_for_wm;
extern Lisp_Object Qfullscreen;
+extern Lisp_Object Qalpha;
extern Lisp_Object Qfont_backend;
extern Lisp_Object Qleft_fringe, Qright_fringe;
@@ -1100,6 +1106,8 @@
extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
+extern Lisp_Object Vframe_alpha_lower_limit;
+extern void x_set_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
extern void validate_x_resource_name P_ ((void));
diff -Naur emacs.orig/src/macfns.c emacs/src/macfns.c
--- emacs.orig/src/macfns.c 2008-02-22 12:42:08.000000000 -0500
+++ emacs/src/macfns.c 2008-03-14 22:53:02.000000000 -0400
@@ -4680,6 +4680,7 @@
x_set_fringe_width,
0, /* x_set_wait_for_wm, */
x_set_fullscreen,
+ 0, /* x_set_alpha, */
};
void
diff -Naur emacs.orig/src/w32fns.c emacs/src/w32fns.c
--- emacs.orig/src/w32fns.c 2008-03-01 05:02:23.000000000 -0500
+++ emacs/src/w32fns.c 2008-03-14 22:53:02.000000000 -0400
@@ -8854,6 +8854,7 @@
x_set_fringe_width,
0, /* x_set_wait_for_wm, */
x_set_fullscreen,
+ 0, /* x_set_alpha, */
#ifdef USE_FONT_BACKEND
x_set_font_backend
#endif
diff -Naur emacs.orig/src/xfns.c emacs/src/xfns.c
--- emacs.orig/src/xfns.c 2008-02-22 12:42:05.000000000 -0500
+++ emacs/src/xfns.c 2008-03-14 22:53:02.000000000 -0400
@@ -3578,6 +3578,8 @@
x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
"scrollBarWidth", "ScrollBarWidth",
RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qalpha, Qnil,
+ "alpha", "Alpha", RES_TYPE_NUMBER);
/* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
Change will not be effected unless different from the current
@@ -5991,6 +5993,7 @@
x_set_fringe_width,
x_set_wait_for_wm,
x_set_fullscreen,
+ x_set_alpha,
#ifdef USE_FONT_BACKEND
x_set_font_backend
#endif /* USE_FONT_BACKEND */
diff -Naur emacs.orig/src/xterm.c emacs/src/xterm.c
--- emacs.orig/src/xterm.c 2008-03-11 11:54:05.000000000 -0400
+++ emacs/src/xterm.c 2008-03-14 22:53:02.000000000 -0400
@@ -1018,6 +1018,67 @@
return FONT_TYPE_UNKNOWN;
}
+#define OPAQUE 0xffffffff
+#define OPACITY "_NET_WM_WINDOW_OPACITY"
+
+void
+x_set_frame_alpha (f)
+ struct frame *f;
+{
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+ Display *dpy = FRAME_X_DISPLAY (f);
+ Window win = FRAME_OUTER_WINDOW (f);
+ if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc)
+ /* Since the WM decoration lies under the FRAME_OUTER_WINDOW,
+ we must treat the former instead of the latter. */
+ win = FRAME_X_OUTPUT(f)->parent_desc;
+
+ double alpha = 1.0, alpha_min = 1.0;
+
+ if (dpyinfo->x_highlight_frame == f)
+ alpha = f->alpha[0];
+ else
+ alpha = f->alpha[1];
+
+ if (FLOATP (Vframe_alpha_lower_limit))
+ alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit);
+ else if (INTEGERP (Vframe_alpha_lower_limit))
+ alpha_min = (XINT (Vframe_alpha_lower_limit)) / 100.0;
+
+ if (alpha < 0.0 || 1.0 < alpha)
+ alpha = 1.0;
+ else if (0.0 <= alpha && alpha < alpha_min && alpha_min < 1.0)
+ alpha = alpha_min;
+
+ unsigned int opac = (unsigned int)(alpha * OPAQUE);
+
+ /* return unless necessary */
+ {
+ unsigned char *data;
+ Atom actual;
+ int format;
+ unsigned long n, left;
+
+ XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False),
+ 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
+ (unsigned char **) &data);
+ if (data != None)
+ if (*(unsigned int *)data == opac)
+ {
+ XFree ((void *) data);
+ return;
+ }
+ else
+ {
+ XFree ((void *) data);
+ }
+ }
+
+ XChangeProperty (dpy, win, XInternAtom (dpy, OPACITY, False),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &opac, 1L);
+ XSync (dpy, False);
+}
\f
/***********************************************************************
@@ -3468,6 +3529,7 @@
f->output_data.x->border_pixel);
UNBLOCK_INPUT;
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
static void
@@ -3483,6 +3545,7 @@
f->output_data.x->border_tile);
UNBLOCK_INPUT;
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
/* The focus has changed. Update the frames as necessary to reflect
[-- Attachment #3: Type: text/plain, Size: 271 bytes --]
P.S.
Meadow has four settings for the frame opacity: (1) active frame, (2)
inactive frames, (3) moving frame, and (4) resizing frame.
e.g. (set-frame-parameter (selected-frame) 'alpha '(<active>
[<inactive> [<moving> [sizing]]]))
Seiji Zenitani
zenitani@mac.com
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-15 2:41 ` David De La Harpe Golden
@ 2008-03-15 20:22 ` Seiji Zenitani
2008-03-15 20:53 ` David De La Harpe Golden
0 siblings, 1 reply; 25+ messages in thread
From: Seiji Zenitani @ 2008-03-15 20:22 UTC (permalink / raw)
To: emacs-devel
On 2008/03/14, at 22:41, David De La Harpe Golden wrote:
>
> Well, (I think) the code is just programmatically setting the
> "NET_WM_WINDOW_OPACITY" property on the X Window, which needs a
> suitably-compositing-capable manager capable of interpreting it?
>
Reportedly it works on "X.org (>=6.8) or XGL with composite extension".
Is there any way to detect the capability?
Seiji
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-15 20:22 ` Seiji Zenitani
@ 2008-03-15 20:53 ` David De La Harpe Golden
0 siblings, 0 replies; 25+ messages in thread
From: David De La Harpe Golden @ 2008-03-15 20:53 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: emacs-devel
Seiji Zenitani wrote:
> Reportedly it works on "X.org (>=6.8) or XGL with composite extension".
> Is there any way to detect the capability?
>
[Well, I think there also needs to be a compositing manager in the loop
-it's possible to have a composite extension capable X server with no
composting manager actually running, so e.g. detecting the composite
extension is no guarantee the property will take effect]
If there's a running compositing manager, it'll be owning the
"_NET_WM_CM_S{N}" X Selection(s), where {N} is screen number.
N.B. But IIRC it's also quite possible to fire up or restart a
compositing manager in the middle of an existing X session, so you
probably shouldn't conditionalise property-setting behaviour on the
presence of one, maybe just warn "No compositing manager currently
running, may have no effect." at most if one isn't detected.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-15 19:54 ` Seiji Zenitani
@ 2008-03-15 21:19 ` Stefan Monnier
2008-03-18 20:11 ` Brian Cully
2008-03-19 5:51 ` Seiji Zenitani
0 siblings, 2 replies; 25+ messages in thread
From: Stefan Monnier @ 2008-03-15 21:19 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: emacs-devel
Looks good. Tho maybe I'd put the call to x_set_frame_alpha directly
inside x_update_cursor (and rename it to x_update_cursor_and_opacity).
I don't mind the use of "alpha" rather than "opacity", as long as the
docstrings are clear. The patch needs to also update the manual.
And could you describe the copyright status?
Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-15 21:19 ` Stefan Monnier
@ 2008-03-18 20:11 ` Brian Cully
2008-03-19 5:55 ` Seiji Zenitani
2008-03-19 5:51 ` Seiji Zenitani
1 sibling, 1 reply; 25+ messages in thread
From: Brian Cully @ 2008-03-18 20:11 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Seiji Zenitani, emacs-devel
On 15-Mar-2008, at 17:19, Stefan Monnier wrote:
> Looks good. Tho maybe I'd put the call to x_set_frame_alpha directly
> inside x_update_cursor (and rename it to x_update_cursor_and_opacity).
>
> I don't mind the use of "alpha" rather than "opacity", as long as the
> docstrings are clear. The patch needs to also update the manual.
> And could you describe the copyright status?
Is this for background-color alpha or the god-forsaken total-window
alpha? At least on Mac OS X, you can set the background alpha by
itself which I find far more pleasing than when the entire frame goes
semi-opaque.
-bjc
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-15 21:19 ` Stefan Monnier
2008-03-18 20:11 ` Brian Cully
@ 2008-03-19 5:51 ` Seiji Zenitani
2008-03-19 16:16 ` Stefan Monnier
1 sibling, 1 reply; 25+ messages in thread
From: Seiji Zenitani @ 2008-03-19 5:51 UTC (permalink / raw)
To: emacs-devel
On 2008/03/15, at 17:19, Stefan Monnier wrote:
> Looks good. Tho maybe I'd put the call to x_set_frame_alpha directly
> inside x_update_cursor (and rename it to x_update_cursor_and_opacity).
>
> I don't mind the use of "alpha" rather than "opacity", as long as the
> docstrings are clear. The patch needs to also update the manual.
> And could you describe the copyright status?
The frame parameter code and the x_set_frame_alpha function
were written by Ryo Yoshitake. He is ready to sign.
The lower_limit variable and the x_set_alpha function originally come
from
mw32fns.c (e.g. mw32_set_frame_alpha in l.1019-1078) in Meadow,
although they look differently because of my extensive modification.
http://www.meadowy.org/meadow/browser/trunk/src/mw32fns.c (slow
connection)
I am contacting Mr. Horiguchi, the author of the relevant part.
I already signed the paper.
The first version of the patch was developed by Takashi Hiromatsu.
I am waiting for his response in order to make sure.
Practically, his code in ver.1 was completely
replaced by Yoshitake-san's code (ver.2) and
my code based on Meadow (ver.3, ver.4).
Yoichi Nakayama wrote twenty lines to improve performance,
surrounded by the following brackets.
He agreed to contribute, but he modestly described that his
improvement is "minor".
/* return unless necessary */
{
...
}
I'll write to this list if I have an update.
Seiji Zenitani
zenitani@mac.com
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-18 20:11 ` Brian Cully
@ 2008-03-19 5:55 ` Seiji Zenitani
2008-03-19 20:23 ` David De La Harpe Golden
0 siblings, 1 reply; 25+ messages in thread
From: Seiji Zenitani @ 2008-03-19 5:55 UTC (permalink / raw)
To: Brian Cully; +Cc: Stefan Monnier, emacs-devel
On 2008/03/18, at 16:11, Brian Cully wrote:
> On 15-Mar-2008, at 17:19, Stefan Monnier wrote:
>> Looks good. Tho maybe I'd put the call to x_set_frame_alpha directly
>> inside x_update_cursor (and rename it to
>> x_update_cursor_and_opacity).
>>
>> I don't mind the use of "alpha" rather than "opacity", as long as the
>> docstrings are clear. The patch needs to also update the manual.
>> And could you describe the copyright status?
>
> Is this for background-color alpha or the god-forsaken total-
> window alpha?
It's for the total frame including the tool bar, the fringes, the
window title bar, and the proxy icon.
> At least on Mac OS X, you can set the background alpha by itself
> which I find far more pleasing than when the entire frame goes semi-
> opaque.
You are talking about Emacs.app, a coming Cocoa port. I confirmed
that Emacs.app comes with the background color alpha [e.g. (set-
background-color "ARGBccffffff") ].
My concern is that the background alpha only works on Emacs.app on
Mac OS X, a proprietary platform. It would be nice if we can set the
background alpha on X11, too, but I have no idea to implement it.
Seiji
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-19 5:51 ` Seiji Zenitani
@ 2008-03-19 16:16 ` Stefan Monnier
2008-03-20 22:47 ` Seiji Zenitani
0 siblings, 1 reply; 25+ messages in thread
From: Stefan Monnier @ 2008-03-19 16:16 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: emacs-devel
>> Looks good. Tho maybe I'd put the call to x_set_frame_alpha directly
>> inside x_update_cursor (and rename it to x_update_cursor_and_opacity).
>>
>> I don't mind the use of "alpha" rather than "opacity", as long as the
>> docstrings are clear. The patch needs to also update the manual.
>> And could you describe the copyright status?
> The frame parameter code and the x_set_frame_alpha function
> were written by Ryo Yoshitake. He is ready to sign.
Could you send him the appended form (and Cc me along the way)?
> The lower_limit variable and the x_set_alpha function originally come from
> mw32fns.c (e.g. mw32_set_frame_alpha in l.1019-1078) in Meadow,
> although they look differently because of my extensive modification.
> http://www.meadowy.org/meadow/browser/trunk/src/mw32fns.c (slow connection)
> I am contacting Mr. Horiguchi, the author of the relevant part.
Copyright only applies to actual code, not ideas, so if the code was
rewritten, copyright does not apply any more.
> The first version of the patch was developed by Takashi Hiromatsu.
> I am waiting for his response in order to make sure.
> Practically, his code in ver.1 was completely
> replaced by Yoshitake-san's code (ver.2) and
> my code based on Meadow (ver.3, ver.4).
So it sounds like he does not hold any copyrights over the current
version of the code. Is that right?
> Yoichi Nakayama wrote twenty lines to improve performance,
> surrounded by the following brackets.
> He agreed to contribute, but he modestly described that his improvement is
> "minor".
Let's leave this for later.
Stefan
Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.
Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
[What is the name of the program or package you're contributing to?]
Emacs
[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]
[Do you have an employer who might have a basis to claim to own
your changes? Do you attend a school which might make such a claim?]
[For the copyright registration, what country are you a citizen of?]
[What year were you born?]
[Please write your email address here.]
[Please write your postal address here.]
[Which files have you changed so far, and which new files have you written
so far?]
xterm.c
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-19 5:55 ` Seiji Zenitani
@ 2008-03-19 20:23 ` David De La Harpe Golden
2008-03-26 0:46 ` Seiji Zenitani
0 siblings, 1 reply; 25+ messages in thread
From: David De La Harpe Golden @ 2008-03-19 20:23 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: Brian Cully, Stefan Monnier, emacs-devel
Seiji Zenitani wrote:
>
> You are talking about Emacs.app, a coming Cocoa port. I confirmed that
> Emacs.app comes with the background color alpha [e.g.
> (set-background-color "ARGBccffffff") ].
>
Hmm. That's interesting. How general is it? :
Possibly an actually useful use for alpha blending would be "emacs
internal" alpha blending of overlapping overlay/text-properties
backgrounds+foregrounds* (rather than just the current priority-based
overriding).
Does emacs.app do that too, or is it only a hack affecting
the frame background?
* So that e.g. hi-lock faces could subtly "show through" a region
highlight on top of them, or whatever, addressing someone's
slightly over-the-top on-list complaint from a few weeks back.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-14 11:02 new frame-parameter "alpha" Seiji Zenitani
2008-03-14 18:28 ` Stefan Monnier
@ 2008-03-20 15:22 ` Ken Raeburn
2008-03-20 22:53 ` Seiji Zenitani
1 sibling, 1 reply; 25+ messages in thread
From: Ken Raeburn @ 2008-03-20 15:22 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: emacs-devel
On Mar 14, 2008, at 07:02, Seiji Zenitani wrote:
> Elisp syntax:
> We can use both a floating point number (0.0-1.0) as well as an
> integer number (0-100).
So 1 means almost-invisible and 1.0 means completely opaque? Do
float-vs-int representations of the same value have such opposite
meanings in other parts of Emacs (outside of some possible arithmetic
cases)?
Ken
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-19 16:16 ` Stefan Monnier
@ 2008-03-20 22:47 ` Seiji Zenitani
2008-03-24 19:26 ` Stefan Monnier
2008-04-29 3:12 ` Seiji Zenitani
0 siblings, 2 replies; 25+ messages in thread
From: Seiji Zenitani @ 2008-03-20 22:47 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1293 bytes --]
Hi,
On 2008/03/19, at 12:16, Stefan Monnier wrote:
>>> Looks good. Tho maybe I'd put the call to x_set_frame_alpha
>>> directly
>>> inside x_update_cursor (and rename it to
>>> x_update_cursor_and_opacity).
>>>
>>> I don't mind the use of "alpha" rather than "opacity", as long as
>>> the
>>> docstrings are clear. The patch needs to also update the manual.
>>> And could you describe the copyright status?
>
>> The frame parameter code and the x_set_frame_alpha function
>> were written by Ryo Yoshitake. He is ready to sign.
>
> Could you send him the appended form (and Cc me along the way)?
>
Done.
>> The lower_limit variable and the x_set_alpha function originally
>> come from
>> mw32fns.c (e.g. mw32_set_frame_alpha in l.1019-1078) in Meadow,
>> although they look differently because of my extensive modification.
>> http://www.meadowy.org/meadow/browser/trunk/src/mw32fns.c (slow
>> connection)
>> I am contacting Mr. Horiguchi, the author of the relevant part.
>
> Copyright only applies to actual code, not ideas, so if the code was
> rewritten, copyright does not apply any more.
>
In order to make sure, I extracted
the relevant lines which I ported from Meadow to GNU Emacs.
Let me know if there are any problems.
Attached 1 - the original lines from mw32fns.c
[-- Attachment #2: mw32fns.c --]
[-- Type: application/octet-stream, Size: 1749 bytes --]
/* Lower limit of alpha value of frame. */
int mw32_frame_alpha_lower_limit;
#define CHECK_ALPHA_RANGE(alpha) if (alpha < 0 || alpha > 100) \
args_out_of_range (make_number (0), make_number (100));
static void
mw32_set_frame_alpha (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
{
int newalpha[NUM_OF_ALPHAS];
int i, tmp;
Lisp_Object obj;
if (SetLayeredWindowAttributes == NULL)
return;
if (NILP (arg)
|| (CONSP (arg) && NILP (CAR (arg))))
tmp = -1;
else if (NUMBERP (arg))
{
tmp = XINT (arg);
CHECK_ALPHA_RANGE (tmp);
}
else if (CONSP (arg) && NUMBERP (CAR (arg)))
{
tmp = XINT (CAR (arg));
CHECK_ALPHA_RANGE (tmp);
}
else
wrong_type_argument (Qnumberp, (arg));
for (i = 0 ; i < NUM_OF_ALPHAS ; i++)
newalpha[i] = tmp;
if (CONSP (arg))
{
obj = CDR (arg);
for (i = ALPHA_INACTIVE ;
i < NUM_OF_ALPHAS && CONSP (obj) ;
i++, obj = CDR (obj))
{
if (NILP (CAR (obj)))
tmp = -1;
else if (NUMBERP (CAR (obj)))
{
tmp = XINT (CAR (obj));
CHECK_ALPHA_RANGE (tmp);
}
else
wrong_type_argument (Qnumberp, (CAR (obj)));
newalpha[i] = tmp;
}
}
for (i = 0 ; i < NUM_OF_ALPHAS ; i++)
{
/* Apply lower limit silently */
if (newalpha[i] != -1 && newalpha[i] < mw32_frame_alpha_lower_limit)
newalpha[i] = mw32_frame_alpha_lower_limit;
f->output_data.mw32->alpha[i] = newalpha[i];
}
mw32_update_frame_alpha (f);
}
\f
DEFVAR_INT ("mw32-frame-alpha-lower-limit", &mw32_frame_alpha_lower_limit,
doc: /* Lower limit of alpha value of frame. */);
mw32_frame_alpha_lower_limit = 20;
[-- Attachment #3: Type: text/plain, Size: 60 bytes --]
Attached 2 - the relevant part of our patch (in frame.c)
[-- Attachment #4: transparency4-x23-test.patch --]
[-- Type: application/octet-stream, Size: 2452 bytes --]
diff -Naur emacs.orig/src/frame.c emacs/src/frame.c
--- emacs.orig/src/frame.c 2008-02-11 23:03:16.000000000 -0500
+++ emacs/src/frame.c 2008-03-14 22:53:51.000000000 -0400
@@ -67,6 +67,10 @@
Lisp_Object Vx_resource_class;
+/* Lower limit value of the frame opacity (alpha transparency). */
+
+Lisp_Object Vframe_alpha_lower_limit;
+
#endif
Lisp_Object Qframep, Qframe_live_p;
@@ -3699,6 +3705,61 @@
return Qnil;
}
+void
+x_set_alpha (f, arg, oldval)
+ struct frame *f;
+ Lisp_Object arg, oldval;
+{
+ double alpha = 1.0;
+ double newval[2];
+ int i, ialpha;
+ Lisp_Object item;
+
+ for (i=0;i<2;i++)
+ {
+ newval[i] = 1.0;
+ if (CONSP (arg))
+ {
+ item = CAR (arg);
+ arg = CDR (arg);
+ }
+ else
+ item=arg;
+
+ if (!NILP (item))
+ {
+ if (FLOATP (item))
+ {
+ alpha = XFLOAT_DATA (item);
+ if (alpha < 0.0 || 1.0 < alpha)
+ args_out_of_range (make_float (0.0), make_float (1.0));
+ }
+ else if (INTEGERP (item))
+ {
+ ialpha = XINT (item);
+ if (ialpha < 0 || 100 < ialpha)
+ args_out_of_range (make_number (0), make_number (100));
+ else
+ alpha = ialpha / 100.0;
+ }
+ else
+ wrong_type_argument (Qnumberp, item);
+ }
+ newval[i] = alpha;
+ }
+
+ for (i=0;i<2;i++)
+ f->alpha[i] = newval[i];
+
+#ifdef HAVE_X_WINDOWS
+ BLOCK_INPUT;
+ x_set_frame_alpha (f);
+ UNBLOCK_INPUT;
+#endif
+
+ return;
+}
+
\f
/* Subroutines of creating an X frame. */
@@ -4468,6 +4527,13 @@
but binding this variable locally around a call to `x-get-resource'
is a reasonable practice. See also the variable `x-resource-name'. */);
Vx_resource_class = build_string (EMACS_CLASS);
+
+ DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit,
+ doc: /* The lower limit of the frame opacity (alpha transparency).
+The value should range from 0 (invisible) to 100 (completely opaque).
+The user can also use a floating number between 0.0 and 1.0.
+The default is 20. */);
+ Vframe_alpha_lower_limit = make_number (20);
#endif
DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
diff -Naur emacs.orig/src/frame.h emacs/src/frame.h
[-- Attachment #5: Type: text/plain, Size: 37 bytes --]
Seiji Zenitani
zenitani@mac.com
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-20 15:22 ` Ken Raeburn
@ 2008-03-20 22:53 ` Seiji Zenitani
0 siblings, 0 replies; 25+ messages in thread
From: Seiji Zenitani @ 2008-03-20 22:53 UTC (permalink / raw)
To: Ken Raeburn; +Cc: emacs-devel
On 2008/03/20, at 11:22, Ken Raeburn wrote:
> On Mar 14, 2008, at 07:02, Seiji Zenitani wrote:
>> Elisp syntax:
>> We can use both a floating point number (0.0-1.0) as well as an
>> integer number (0-100).
>
> So 1 means almost-invisible and 1.0 means completely opaque?
Correct.
(Actually 1 brings 20% opaque, when "frame-alpha-lower-limit" is set
to 20.)
> Do float-vs-int representations of the same value have such
> opposite meanings in other parts of Emacs (outside of some possible
> arithmetic cases)?
>
> Ken
One sample is 'line-spacing'.
(setq line-spacing 1) ;; 1 pt
(setq line-spacing 1.0) ;; relative height
We can also employ only float (or int)
in order to avoid confusion.
Seiji
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-20 22:47 ` Seiji Zenitani
@ 2008-03-24 19:26 ` Stefan Monnier
2008-04-29 3:12 ` Seiji Zenitani
1 sibling, 0 replies; 25+ messages in thread
From: Stefan Monnier @ 2008-03-24 19:26 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: emacs-devel
> In order to make sure, I extracted
> the relevant lines which I ported from Meadow to GNU Emacs.
> Let me know if there are any problems.
This looks fine. Just make sure the original author is happy to see his
code used in Emacs, and then we can include it as a (tiny change).
Note that if we may later include more of his code, it may be worth it
to ask him to sign the relevant paperwork (i.e. send him the same form
as you sent to Ryo Yoshitake), but we don't have to wait for this
paperwork before installing the change.
Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-19 20:23 ` David De La Harpe Golden
@ 2008-03-26 0:46 ` Seiji Zenitani
0 siblings, 0 replies; 25+ messages in thread
From: Seiji Zenitani @ 2008-03-26 0:46 UTC (permalink / raw)
To: David De La Harpe Golden; +Cc: emacs-devel
On 2008/03/19, at 16:23, David De La Harpe Golden wrote:
> Seiji Zenitani wrote:
>>
>> You are talking about Emacs.app, a coming Cocoa port. I confirmed
>> that
>> Emacs.app comes with the background color alpha [e.g.
>> (set-background-color "ARGBccffffff") ].
>
> Hmm. That's interesting. How general is it? :
>
AFAIK, only Emacs.app employs it.
Maybe there will be a chance to discuss the above background opacity
feature
when Cocoa port will be merged to the trunk.
Seiji
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
@ 2008-04-05 17:21 Seiji Zenitani
0 siblings, 0 replies; 25+ messages in thread
From: Seiji Zenitani @ 2008-04-05 17:21 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On 2008/03/24, at 15:26, Stefan Monnier wrote:
>> In order to make sure, I extracted
>> the relevant lines which I ported from Meadow to GNU Emacs.
>> Let me know if there are any problems.
>
> This looks fine. Just make sure the original author is happy to
> see his
> code used in Emacs, and then we can include it as a (tiny change).
> Note that if we may later include more of his code, it may be worth it
> to ask him to sign the relevant paperwork (i.e. send him the same form
> as you sent to Ryo Yoshitake), but we don't have to wait for this
> paperwork before installing the change.
I wrote to the original author twice, but I've got no response.
Seiji
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-03-20 22:47 ` Seiji Zenitani
2008-03-24 19:26 ` Stefan Monnier
@ 2008-04-29 3:12 ` Seiji Zenitani
2008-04-29 7:13 ` Glenn Morris
2008-05-02 15:09 ` Stefan Monnier
1 sibling, 2 replies; 25+ messages in thread
From: Seiji Zenitani @ 2008-04-29 3:12 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Hi,
On 2008/03/20, at 18:47, Seiji Zenitani wrote:
>
> On 2008/03/19, at 12:16, Stefan Monnier wrote:
>>>> Looks good. Tho maybe I'd put the call to x_set_frame_alpha
>>>> directly
>>>> inside x_update_cursor (and rename it to
>>>> x_update_cursor_and_opacity).
>>>>
>>>> I don't mind the use of "alpha" rather than "opacity", as long as
>>>> the
>>>> docstrings are clear. The patch needs to also update the manual.
>>>> And could you describe the copyright status?
>>
>>> The frame parameter code and the x_set_frame_alpha function
>>> were written by Ryo Yoshitake. He is ready to sign.
>>
>> Could you send him the appended form (and Cc me along the way)?
>>
> Done.
>
Did the FSF receive Ryo Yoshitake's paper?
In the info directory,
section 29.3 in the Emacs Lisp Reference Manual
seems to be the right place for the transparency
(frame parameter "alpha"), is this right?
Sincerely,
Seiji
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-04-29 3:12 ` Seiji Zenitani
@ 2008-04-29 7:13 ` Glenn Morris
2008-05-02 15:09 ` Stefan Monnier
1 sibling, 0 replies; 25+ messages in thread
From: Glenn Morris @ 2008-04-29 7:13 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: Stefan Monnier, emacs-devel
Seiji Zenitani wrote:
> Did the FSF receive Ryo Yoshitake's paper?
There is nothing in /gd/gnuorg/Copyright.
fsf-records at gnu.org could provide a more authoritative answer.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-04-29 3:12 ` Seiji Zenitani
2008-04-29 7:13 ` Glenn Morris
@ 2008-05-02 15:09 ` Stefan Monnier
1 sibling, 0 replies; 25+ messages in thread
From: Stefan Monnier @ 2008-05-02 15:09 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: emacs-devel
> Did the FSF receive Ryo Yoshitake's paper?
It appears they haven't received them yet.
Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
@ 2008-05-02 20:37 Seiji Zenitani
2008-05-13 20:29 ` Stefan Monnier
0 siblings, 1 reply; 25+ messages in thread
From: Seiji Zenitani @ 2008-05-02 20:37 UTC (permalink / raw)
To: Stefan Monnier; +Cc: YOSHITAKE Ryo, emacs-devel
Yoshitake-san sent the paper in early April.
Could you send another paper to him?
Seiji
On 2008/05/02, at 11:09, Stefan Monnier wrote:
>
> > Did the FSF receive Ryo Yoshitake's paper?
>
> It appears they haven't received them yet.
>
>
> Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-05-02 20:37 Seiji Zenitani
@ 2008-05-13 20:29 ` Stefan Monnier
2008-05-14 16:16 ` Seiji Zenitani
0 siblings, 1 reply; 25+ messages in thread
From: Stefan Monnier @ 2008-05-13 20:29 UTC (permalink / raw)
To: Seiji Zenitani; +Cc: YOSHITAKE Ryo, emacs-devel
> Yoshitake-san sent the paper in early April.
> Could you send another paper to him?
We just received Ryo's papers.
Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
2008-05-13 20:29 ` Stefan Monnier
@ 2008-05-14 16:16 ` Seiji Zenitani
0 siblings, 0 replies; 25+ messages in thread
From: Seiji Zenitani @ 2008-05-14 16:16 UTC (permalink / raw)
To: Stefan Monnier; +Cc: YOSHITAKE Ryo, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 933 bytes --]
Hi,
A revised code is attached to this email.
This one contains a correction
from "alpha_min < 1.0" to "alpha_min <= 1.0".
ChangeLog entries are as follows.
Thanks,
Seiji
2008-05-14 Seiji Zenitani <zenitani@mac.com>, Ryo Yoshitake <ryo@shiftmode.net>
* frame.c (Qalpha): add a new frame parameter `alpha'.
(Vframe_alpha_lower_limit) : new variable.
(x_set_alpha): Add function.
* frame.h (Qalpha, Vframe_parameter_lower_limit): export them.
* xfns.c (x-create-frame, Qalpha):
Initialize the frame parameter `alpha'.
* xterm.c (x_set_frame_alpha): Add function.
* macfns.c (mac_frame_parm_handlers): A null handler for x_set_alpha.
* w32fns.c (w32_frame_parm_handlers): Likewise.
On Tuesday, May 13, 2008, at 04:33PM, "Stefan Monnier" <monnier@iro.umontreal.ca> wrote:
>> Yoshitake-san sent the paper in early April.
>> Could you send another paper to him?
>
>We just received Ryo's papers.
>
>
> Stefan
>
[-- Attachment #2: transparency4-x23.patch --]
[-- Type: application/octet-stream, Size: 7685 bytes --]
diff -Naur emacs.orig/src/frame.c emacs/src/frame.c
--- emacs.orig/src/frame.c 2008-03-28 21:46:08.000000000 -0400
+++ emacs/src/frame.c 2008-04-05 17:30:21.000000000 -0400
@@ -67,6 +67,10 @@
Lisp_Object Vx_resource_class;
+/* Lower limit value of the frame opacity (alpha transparency). */
+
+Lisp_Object Vframe_alpha_lower_limit;
+
#endif
Lisp_Object Qframep, Qframe_live_p;
@@ -117,6 +121,7 @@
Lisp_Object Qtty, Qtty_type;
Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
+Lisp_Object Qalpha;
#ifdef USE_FONT_BACKEND
Lisp_Object Qfont_backend;
#endif /* USE_FONT_BACKEND */
@@ -2850,6 +2855,7 @@
{"right-fringe", &Qright_fringe},
{"wait-for-wm", &Qwait_for_wm},
{"fullscreen", &Qfullscreen},
+ {"alpha", &Qalpha},
#ifdef USE_FONT_BACKEND
{"font-backend", &Qfont_backend}
#endif /* USE_FONT_BACKEND */
@@ -3694,6 +3700,61 @@
return Qnil;
}
+void
+x_set_alpha (f, arg, oldval)
+ struct frame *f;
+ Lisp_Object arg, oldval;
+{
+ double alpha = 1.0;
+ double newval[2];
+ int i, ialpha;
+ Lisp_Object item;
+
+ for (i=0;i<2;i++)
+ {
+ newval[i] = 1.0;
+ if (CONSP (arg))
+ {
+ item = CAR (arg);
+ arg = CDR (arg);
+ }
+ else
+ item=arg;
+
+ if (!NILP (item))
+ {
+ if (FLOATP (item))
+ {
+ alpha = XFLOAT_DATA (item);
+ if (alpha < 0.0 || 1.0 < alpha)
+ args_out_of_range (make_float (0.0), make_float (1.0));
+ }
+ else if (INTEGERP (item))
+ {
+ ialpha = XINT (item);
+ if (ialpha < 0 || 100 < ialpha)
+ args_out_of_range (make_number (0), make_number (100));
+ else
+ alpha = ialpha / 100.0;
+ }
+ else
+ wrong_type_argument (Qnumberp, item);
+ }
+ newval[i] = alpha;
+ }
+
+ for (i=0;i<2;i++)
+ f->alpha[i] = newval[i];
+
+#ifdef HAVE_X_WINDOWS
+ BLOCK_INPUT;
+ x_set_frame_alpha (f);
+ UNBLOCK_INPUT;
+#endif
+
+ return;
+}
+
\f
/* Subroutines of creating an X frame. */
@@ -4463,6 +4524,13 @@
but binding this variable locally around a call to `x-get-resource'
is a reasonable practice. See also the variable `x-resource-name'. */);
Vx_resource_class = build_string (EMACS_CLASS);
+
+ DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit,
+ doc: /* The lower limit of the frame opacity (alpha transparency).
+The value should range from 0 (invisible) to 100 (completely opaque).
+The user can also use a floating number between 0.0 and 1.0.
+The default is 20. */);
+ Vframe_alpha_lower_limit = make_number (20);
#endif
DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
diff -Naur emacs.orig/src/frame.h emacs/src/frame.h
--- emacs.orig/src/frame.h 2008-04-04 13:56:23.000000000 -0400
+++ emacs/src/frame.h 2008-04-05 17:30:21.000000000 -0400
@@ -215,6 +215,11 @@
be used for output. */
unsigned glyphs_initialized_p : 1;
+ /* frame opacity
+ alpha[0]: alpha transparency of the active frame
+ alpha[1]: alpha transparency of inactive frames */
+ double alpha[2];
+
/* Set to non-zero in change_frame_size when size of frame changed
Clear the frame in clear_garbaged_frames if set. */
unsigned resized_p : 1;
@@ -1034,6 +1039,7 @@
extern Lisp_Object Qline_spacing;
extern Lisp_Object Qwait_for_wm;
extern Lisp_Object Qfullscreen;
+extern Lisp_Object Qalpha;
extern Lisp_Object Qfont_backend;
extern Lisp_Object Qleft_fringe, Qright_fringe;
@@ -1103,6 +1109,8 @@
extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
+extern Lisp_Object Vframe_alpha_lower_limit;
+extern void x_set_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
extern void validate_x_resource_name P_ ((void));
diff -Naur emacs.orig/src/macfns.c emacs/src/macfns.c
--- emacs.orig/src/macfns.c 2008-02-22 12:42:08.000000000 -0500
+++ emacs/src/macfns.c 2008-04-05 17:30:21.000000000 -0400
@@ -4680,6 +4680,7 @@
x_set_fringe_width,
0, /* x_set_wait_for_wm, */
x_set_fullscreen,
+ 0, /* x_set_alpha, */
};
void
diff -Naur emacs.orig/src/w32fns.c emacs/src/w32fns.c
--- emacs.orig/src/w32fns.c 2008-04-03 09:11:29.000000000 -0400
+++ emacs/src/w32fns.c 2008-04-05 17:30:21.000000000 -0400
@@ -8887,6 +8887,7 @@
x_set_fringe_width,
0, /* x_set_wait_for_wm, */
x_set_fullscreen,
+ 0, /* x_set_alpha, */
#ifdef USE_FONT_BACKEND
x_set_font_backend
#endif
diff -Naur emacs.orig/src/xfns.c emacs/src/xfns.c
--- emacs.orig/src/xfns.c 2008-02-22 12:42:05.000000000 -0500
+++ emacs/src/xfns.c 2008-04-05 17:30:21.000000000 -0400
@@ -3578,6 +3578,8 @@
x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
"scrollBarWidth", "ScrollBarWidth",
RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qalpha, Qnil,
+ "alpha", "Alpha", RES_TYPE_NUMBER);
/* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
Change will not be effected unless different from the current
@@ -5991,6 +5993,7 @@
x_set_fringe_width,
x_set_wait_for_wm,
x_set_fullscreen,
+ x_set_alpha,
#ifdef USE_FONT_BACKEND
x_set_font_backend
#endif /* USE_FONT_BACKEND */
diff -Naur emacs.orig/src/xterm.c emacs/src/xterm.c
--- emacs.orig/src/xterm.c 2008-03-28 21:46:06.000000000 -0400
+++ emacs/src/xterm.c 2008-04-05 17:30:21.000000000 -0400
@@ -1018,6 +1018,67 @@
return FONT_TYPE_UNKNOWN;
}
+#define OPAQUE 0xffffffff
+#define OPACITY "_NET_WM_WINDOW_OPACITY"
+
+void
+x_set_frame_alpha (f)
+ struct frame *f;
+{
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+ Display *dpy = FRAME_X_DISPLAY (f);
+ Window win = FRAME_OUTER_WINDOW (f);
+ if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc)
+ /* Since the WM decoration lies under the FRAME_OUTER_WINDOW,
+ we must treat the former instead of the latter. */
+ win = FRAME_X_OUTPUT(f)->parent_desc;
+
+ double alpha = 1.0, alpha_min = 1.0;
+
+ if (dpyinfo->x_highlight_frame == f)
+ alpha = f->alpha[0];
+ else
+ alpha = f->alpha[1];
+
+ if (FLOATP (Vframe_alpha_lower_limit))
+ alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit);
+ else if (INTEGERP (Vframe_alpha_lower_limit))
+ alpha_min = (XINT (Vframe_alpha_lower_limit)) / 100.0;
+
+ if (alpha < 0.0 || 1.0 < alpha)
+ alpha = 1.0;
+ else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0)
+ alpha = alpha_min;
+
+ unsigned int opac = (unsigned int)(alpha * OPAQUE);
+
+ /* return unless necessary */
+ {
+ unsigned char *data;
+ Atom actual;
+ int format;
+ unsigned long n, left;
+
+ XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False),
+ 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
+ (unsigned char **) &data);
+ if (data != None)
+ if (*(unsigned int *)data == opac)
+ {
+ XFree ((void *) data);
+ return;
+ }
+ else
+ {
+ XFree ((void *) data);
+ }
+ }
+
+ XChangeProperty (dpy, win, XInternAtom (dpy, OPACITY, False),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &opac, 1L);
+ XSync (dpy, False);
+}
\f
/***********************************************************************
@@ -3468,6 +3529,7 @@
f->output_data.x->border_pixel);
UNBLOCK_INPUT;
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
static void
@@ -3483,6 +3545,7 @@
f->output_data.x->border_tile);
UNBLOCK_INPUT;
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
/* The focus has changed. Update the frames as necessary to reflect
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: new frame-parameter "alpha"
[not found] <EEC622D2-0119-1000-F1CB-50016375E1D3-Webmail-10013@mac.com>
@ 2008-05-15 3:56 ` Seiji Zenitani
0 siblings, 0 replies; 25+ messages in thread
From: Seiji Zenitani @ 2008-05-15 3:56 UTC (permalink / raw)
To: Stefan Monnier; +Cc: YOSHITAKE Ryo, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 150 bytes --]
Hi again,
Please discard the previous patch,
which does not work due to yesterday's font-backend merge.
A revised code for today's CVS is attached.
[-- Attachment #2: transparency4-x23.patch --]
[-- Type: application/octet-stream, Size: 8019 bytes --]
diff -Naur ../emacs.orig/src/frame.c ../emacs/src/frame.c
--- ../emacs.orig/src/frame.c 2008-05-14 03:49:31.000000000 -0400
+++ ../emacs/src/frame.c 2008-05-14 23:14:44.000000000 -0400
@@ -62,6 +62,10 @@
Lisp_Object Vx_resource_class;
+/* Lower limit value of the frame opacity (alpha transparency). */
+
+Lisp_Object Vframe_alpha_lower_limit;
+
#endif
Lisp_Object Qframep, Qframe_live_p;
@@ -113,6 +117,7 @@
Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
Lisp_Object Qfont_backend;
+Lisp_Object Qalpha;
Lisp_Object Qinhibit_face_set_after_frame_default;
Lisp_Object Qface_set_after_frame_default;
@@ -2824,7 +2829,8 @@
{"right-fringe", &Qright_fringe},
{"wait-for-wm", &Qwait_for_wm},
{"fullscreen", &Qfullscreen},
- {"font-backend", &Qfont_backend}
+ {"font-backend", &Qfont_backend},
+ {"alpha", &Qalpha}
};
#ifdef HAVE_WINDOW_SYSTEM
@@ -3634,6 +3640,61 @@
return Qnil;
}
+void
+x_set_alpha (f, arg, oldval)
+ struct frame *f;
+ Lisp_Object arg, oldval;
+{
+ double alpha = 1.0;
+ double newval[2];
+ int i, ialpha;
+ Lisp_Object item;
+
+ for (i=0;i<2;i++)
+ {
+ newval[i] = 1.0;
+ if (CONSP (arg))
+ {
+ item = CAR (arg);
+ arg = CDR (arg);
+ }
+ else
+ item=arg;
+
+ if (!NILP (item))
+ {
+ if (FLOATP (item))
+ {
+ alpha = XFLOAT_DATA (item);
+ if (alpha < 0.0 || 1.0 < alpha)
+ args_out_of_range (make_float (0.0), make_float (1.0));
+ }
+ else if (INTEGERP (item))
+ {
+ ialpha = XINT (item);
+ if (ialpha < 0 || 100 < ialpha)
+ args_out_of_range (make_number (0), make_number (100));
+ else
+ alpha = ialpha / 100.0;
+ }
+ else
+ wrong_type_argument (Qnumberp, item);
+ }
+ newval[i] = alpha;
+ }
+
+ for (i=0;i<2;i++)
+ f->alpha[i] = newval[i];
+
+#ifdef HAVE_X_WINDOWS
+ BLOCK_INPUT;
+ x_set_frame_alpha (f);
+ UNBLOCK_INPUT;
+#endif
+
+ return;
+}
+
\f
/* Subroutines of creating an X frame. */
@@ -4403,6 +4464,13 @@
but binding this variable locally around a call to `x-get-resource'
is a reasonable practice. See also the variable `x-resource-name'. */);
Vx_resource_class = build_string (EMACS_CLASS);
+
+ DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit,
+ doc: /* The lower limit of the frame opacity (alpha transparency).
+The value should range from 0 (invisible) to 100 (completely opaque).
+The user can also use a floating number between 0.0 and 1.0.
+The default is 20. */);
+ Vframe_alpha_lower_limit = make_number (20);
#endif
DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
diff -Naur ../emacs.orig/src/frame.h ../emacs/src/frame.h
--- ../emacs.orig/src/frame.h 2008-05-13 21:27:45.000000000 -0400
+++ ../emacs/src/frame.h 2008-05-14 23:19:16.000000000 -0400
@@ -215,6 +215,11 @@
be used for output. */
unsigned glyphs_initialized_p : 1;
+ /* frame opacity
+ alpha[0]: alpha transparency of the active frame
+ alpha[1]: alpha transparency of inactive frames */
+ double alpha[2];
+
/* Set to non-zero in change_frame_size when size of frame changed
Clear the frame in clear_garbaged_frames if set. */
unsigned resized_p : 1;
@@ -1035,6 +1040,7 @@
extern Lisp_Object Qwait_for_wm;
extern Lisp_Object Qfullscreen;
extern Lisp_Object Qfont_backend;
+extern Lisp_Object Qalpha;
extern Lisp_Object Qleft_fringe, Qright_fringe;
extern Lisp_Object Qheight, Qwidth;
@@ -1099,6 +1105,8 @@
extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
+extern Lisp_Object Vframe_alpha_lower_limit;
+extern void x_set_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
extern void validate_x_resource_name P_ ((void));
diff -Naur ../emacs.orig/src/macfns.c ../emacs/src/macfns.c
--- ../emacs.orig/src/macfns.c 2008-05-14 03:49:40.000000000 -0400
+++ ../emacs/src/macfns.c 2008-05-14 23:12:20.000000000 -0400
@@ -4321,6 +4321,7 @@
x_set_fringe_width,
0, /* x_set_wait_for_wm, */
x_set_fullscreen,
+ 0, /* x_set_alpha, */
};
void
diff -Naur ../emacs.orig/src/w32fns.c ../emacs/src/w32fns.c
--- ../emacs.orig/src/w32fns.c 2008-05-14 03:50:03.000000000 -0400
+++ ../emacs/src/w32fns.c 2008-05-14 23:14:22.000000000 -0400
@@ -8922,7 +8922,8 @@
x_set_fringe_width,
0, /* x_set_wait_for_wm, */
x_set_fullscreen,
- x_set_font_backend
+ x_set_font_backend,
+ 0 /* x_set_alpha, */
};
void
diff -Naur ../emacs.orig/src/xfns.c ../emacs/src/xfns.c
--- ../emacs.orig/src/xfns.c 2008-05-14 03:50:22.000000000 -0400
+++ ../emacs/src/xfns.c 2008-05-14 23:15:26.000000000 -0400
@@ -3405,6 +3405,8 @@
x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
"scrollBarWidth", "ScrollBarWidth",
RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qalpha, Qnil,
+ "alpha", "Alpha", RES_TYPE_NUMBER);
/* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
Change will not be effected unless different from the current
@@ -5771,7 +5773,8 @@
x_set_fringe_width,
x_set_wait_for_wm,
x_set_fullscreen,
- x_set_font_backend
+ x_set_font_backend,
+ x_set_alpha
};
void
diff -Naur ../emacs.orig/src/xterm.c ../emacs/src/xterm.c
--- ../emacs.orig/src/xterm.c 2008-05-14 03:50:26.000000000 -0400
+++ ../emacs/src/xterm.c 2008-05-14 23:12:20.000000000 -0400
@@ -457,6 +457,67 @@
return 0;
}
+#define OPAQUE 0xffffffff
+#define OPACITY "_NET_WM_WINDOW_OPACITY"
+
+void
+x_set_frame_alpha (f)
+ struct frame *f;
+{
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+ Display *dpy = FRAME_X_DISPLAY (f);
+ Window win = FRAME_OUTER_WINDOW (f);
+ if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc)
+ /* Since the WM decoration lies under the FRAME_OUTER_WINDOW,
+ we must treat the former instead of the latter. */
+ win = FRAME_X_OUTPUT(f)->parent_desc;
+
+ double alpha = 1.0, alpha_min = 1.0;
+
+ if (dpyinfo->x_highlight_frame == f)
+ alpha = f->alpha[0];
+ else
+ alpha = f->alpha[1];
+
+ if (FLOATP (Vframe_alpha_lower_limit))
+ alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit);
+ else if (INTEGERP (Vframe_alpha_lower_limit))
+ alpha_min = (XINT (Vframe_alpha_lower_limit)) / 100.0;
+
+ if (alpha < 0.0 || 1.0 < alpha)
+ alpha = 1.0;
+ else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0)
+ alpha = alpha_min;
+
+ unsigned int opac = (unsigned int)(alpha * OPAQUE);
+
+ /* return unless necessary */
+ {
+ unsigned char *data;
+ Atom actual;
+ int format;
+ unsigned long n, left;
+
+ XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False),
+ 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
+ (unsigned char **) &data);
+ if (data != None)
+ if (*(unsigned int *)data == opac)
+ {
+ XFree ((void *) data);
+ return;
+ }
+ else
+ {
+ XFree ((void *) data);
+ }
+ }
+
+ XChangeProperty (dpy, win, XInternAtom (dpy, OPACITY, False),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &opac, 1L);
+ XSync (dpy, False);
+}
\f
/***********************************************************************
@@ -3171,6 +3232,7 @@
f->output_data.x->border_pixel);
UNBLOCK_INPUT;
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
static void
@@ -3186,6 +3248,7 @@
f->output_data.x->border_tile);
UNBLOCK_INPUT;
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
/* The focus has changed. Update the frames as necessary to reflect
[-- Attachment #3: Type: text/plain, Size: 1093 bytes --]
Sincerely,
Seiji
On 2008/05/14, at 12:16, Seiji Zenitani wrote:
> Hi,
>
> A revised code is attached to this email.
> This one contains a correction
> from "alpha_min < 1.0" to "alpha_min <= 1.0".
> ChangeLog entries are as follows.
>
> Thanks,
> Seiji
>
>
> 2008-05-14 Seiji Zenitani <zenitani@mac.com>, Ryo Yoshitake <ryo@shiftmode.net
> >
>
> * frame.c (Qalpha): add a new frame parameter `alpha'.
> (Vframe_alpha_lower_limit) : new variable.
> (x_set_alpha): Add function.
>
> * frame.h (Qalpha, Vframe_parameter_lower_limit): export them.
>
> * xfns.c (x-create-frame, Qalpha):
> Initialize the frame parameter `alpha'.
> * xterm.c (x_set_frame_alpha): Add function.
>
> * macfns.c (mac_frame_parm_handlers): A null handler for x_set_alpha.
> * w32fns.c (w32_frame_parm_handlers): Likewise.
>
>
> On Tuesday, May 13, 2008, at 04:33PM, "Stefan Monnier" <monnier@iro.umontreal.ca
> > wrote:
>>> Yoshitake-san sent the paper in early April.
>>> Could you send another paper to him?
>>
>> We just received Ryo's papers.
>>
>>
>> Stefan
>>
> <transparency4-x23.patch>
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2008-05-15 3:56 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-14 11:02 new frame-parameter "alpha" Seiji Zenitani
2008-03-14 18:28 ` Stefan Monnier
2008-03-15 2:41 ` David De La Harpe Golden
2008-03-15 20:22 ` Seiji Zenitani
2008-03-15 20:53 ` David De La Harpe Golden
2008-03-15 19:54 ` Seiji Zenitani
2008-03-15 21:19 ` Stefan Monnier
2008-03-18 20:11 ` Brian Cully
2008-03-19 5:55 ` Seiji Zenitani
2008-03-19 20:23 ` David De La Harpe Golden
2008-03-26 0:46 ` Seiji Zenitani
2008-03-19 5:51 ` Seiji Zenitani
2008-03-19 16:16 ` Stefan Monnier
2008-03-20 22:47 ` Seiji Zenitani
2008-03-24 19:26 ` Stefan Monnier
2008-04-29 3:12 ` Seiji Zenitani
2008-04-29 7:13 ` Glenn Morris
2008-05-02 15:09 ` Stefan Monnier
2008-03-20 15:22 ` Ken Raeburn
2008-03-20 22:53 ` Seiji Zenitani
-- strict thread matches above, loose matches on Subject: below --
2008-04-05 17:21 Seiji Zenitani
2008-05-02 20:37 Seiji Zenitani
2008-05-13 20:29 ` Stefan Monnier
2008-05-14 16:16 ` Seiji Zenitani
[not found] <EEC622D2-0119-1000-F1CB-50016375E1D3-Webmail-10013@mac.com>
2008-05-15 3:56 ` Seiji Zenitani
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).