From: Seiji Zenitani <zenitani@mac.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: YOSHITAKE Ryo <ryo@shiftmode.net>, emacs-devel@gnu.org
Subject: Re: new frame-parameter "alpha"
Date: Wed, 14 May 2008 23:56:42 -0400 [thread overview]
Message-ID: <AA9C186E-2A31-4198-B7FF-7E1312DBB04D@mac.com> (raw)
In-Reply-To: <EEC622D2-0119-1000-F1CB-50016375E1D3-Webmail-10013@mac.com>
[-- 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>
next parent reply other threads:[~2008-05-15 3:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <EEC622D2-0119-1000-F1CB-50016375E1D3-Webmail-10013@mac.com>
2008-05-15 3:56 ` Seiji Zenitani [this message]
2008-05-02 20:37 new frame-parameter "alpha" Seiji Zenitani
2008-05-13 20:29 ` Stefan Monnier
2008-05-14 16:16 ` Seiji Zenitani
-- strict thread matches above, loose matches on Subject: below --
2008-04-05 17:21 Seiji Zenitani
2008-03-14 11:02 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AA9C186E-2A31-4198-B7FF-7E1312DBB04D@mac.com \
--to=zenitani@mac.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=ryo@shiftmode.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.