all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Seiji Zenitani <zenitani@mac.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: new frame-parameter "alpha"
Date: Thu, 20 Mar 2008 18:47:10 -0400	[thread overview]
Message-ID: <9D043B74-4054-4798-8EBA-FF18632CFDA7@mac.com> (raw)
In-Reply-To: <jwvtzj2wv6z.fsf-monnier+emacs@gnu.org>

[-- 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


  reply	other threads:[~2008-03-20 22:47 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
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 [this message]
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

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

  git send-email \
    --in-reply-to=9D043B74-4054-4798-8EBA-FF18632CFDA7@mac.com \
    --to=zenitani@mac.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.