From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: new frame-parameter "alpha" Date: Fri, 14 Mar 2008 14:28:22 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1205519321 7943 80.91.229.12 (14 Mar 2008 18:28:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Mar 2008 18:28:41 +0000 (UTC) Cc: emacs-devel@gnu.org To: Seiji Zenitani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 14 19:29:09 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JaEeQ-0002pr-C6 for ged-emacs-devel@m.gmane.org; Fri, 14 Mar 2008 19:29:06 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JaEdr-0006qv-4U for ged-emacs-devel@m.gmane.org; Fri, 14 Mar 2008 14:28:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JaEdl-0006od-Ha for emacs-devel@gnu.org; Fri, 14 Mar 2008 14:28:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JaEdk-0006nY-Dt for emacs-devel@gnu.org; Fri, 14 Mar 2008 14:28:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JaEdk-0006nB-5E for emacs-devel@gnu.org; Fri, 14 Mar 2008 14:28:24 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JaEdk-00071X-0Y for emacs-devel@gnu.org; Fri, 14 Mar 2008 14:28:24 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAI5g2kdMCrZs/2dsb2JhbACqLIEI X-IronPort-AV: E=Sophos;i="4.25,502,1199682000"; d="scan'208";a="16065748" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 14 Mar 2008 14:28:23 -0400 Original-Received: from pastel.home ([76.10.182.108]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id UVQ07923; Fri, 14 Mar 2008 14:28:23 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id CAC638F43; Fri, 14 Mar 2008 14:28:22 -0400 (EDT) In-Reply-To: (Seiji Zenitani's message of "Fri, 14 Mar 2008 07:02:34 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:92596 Archived-At: > 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