unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Seiji Zenitani <zenitani@mac.com>
Cc: emacs-devel@gnu.org
Subject: Re: new frame-parameter "alpha"
Date: Fri, 14 Mar 2008 14:28:22 -0400	[thread overview]
Message-ID: <jwvk5k5kwc0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <C257CBB2-D95C-4EC0-915C-02683121E515@mac.com> (Seiji Zenitani's message of "Fri, 14 Mar 2008 07:02:34 -0400")

> 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




  reply	other threads:[~2008-03-14 18:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14 11:02 new frame-parameter "alpha" Seiji Zenitani
2008-03-14 18:28 ` Stefan Monnier [this message]
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

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvk5k5kwc0.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=zenitani@mac.com \
    /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 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).