unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [Mac OS X] [Win32] Frame-transparency patch
@ 2005-06-11  8:02 Seiji Zenitani
  2005-06-14 16:57 ` [Macemacsjp-dev 100] " Seiji Zenitani
  0 siblings, 1 reply; 12+ messages in thread
From: Seiji Zenitani @ 2005-06-11  8:02 UTC (permalink / raw)
  Cc: macemacs-dev

[-- Attachment #1: Type: text/plain, Size: 1522 bytes --]

Hi,

the attached patch provides frame-transparency to Emacs on Mac OSX  
and Windows. We are happy if it will be merged into the main emacs code.


===========


1. Target operating systems

* Mac OSX  :   'Carbon Emacs'
* Windows XP, 2000, ME :   'NTEmacs'


2. How to build

* Mac OSX
Frame-transparency is automatically enabled when compiled on Mac OSX  
10.2 or later.

* MS Windows
If you use Windows XP, 2000 or ME, add manually the below switch when  
configuring.
CFLAGS=-DUSE_TRANSPARENCY


3. Parameters

Two frame parameters are introduced:

* active-alpha : window opacity of the frontmost frame.
* inactive-alpha : window opacity of non-active frames.

Window opacity will be set by using a float value between 0.0  
(invisible) to 1.0 (completely opaque). By default they are set to 1.0.


4. sample settings

To set frame-transparency of the current frame

         ;; active frame
         (set-frame-parameter (selected-frame) 'active-alpha 0.9)
         ;; non active frame
         (set-frame-parameter (selected-frame) 'inactive-alpha 0.8)

To set the default frame parameters

         (setq default-frame-alist
               (append
                (list
                 '(active-alpha . 0.9)  ;; active frame
                 '(inactive-alpha . 0.8) ;; non active frame
                 ) default-frame-alist)
               )

5. authors

Ryo Yoshitake, Takashi Hiromatsu, Seiji Zenitani

contact: macemacs-dev@lists.sourceforge.jp


===========


Sincerely,


Seiji Zenitani
zenitani@mac.com



[-- Attachment #2: transparency2.patch --]
[-- Type: application/octet-stream, Size: 11174 bytes --]

--- lisp/frame.el.orig	2005-06-09 15:02:01.265625000 +0900
+++ lisp/frame.el	2005-06-09 15:25:13.406250000 +0900
@@ -927,6 +927,24 @@
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'border-color color-name))))
 
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+(defun set-active-alpha (alpha-value)
+  "Set the opacity of the selected frame in active state to ALPHA.
+When called interactively, prompt for the value of the opacity to set.
+To get the frame's current active alpha value state, use `frame-parameters'."
+  (interactive "nactive alpha: ")
+  (modify-frame-parameters (selected-frame)
+			   (list (cons 'active-alpha alpha-value))))
+
+(defun set-inactive-alpha (alpha-value)
+  "Set the opacity of the selected frame in inactive state to ALPHA.
+When called interactively, prompt for the value of the opacity to set.
+To get the frame's current inactive alpha value state, use `frame-parameters'."
+  (interactive "ninactive alpha: ")
+  (modify-frame-parameters (selected-frame)
+			   (list (cons 'inactive-alpha alpha-value))))
+
+#endif /* USE_TRANSPARENCY */
 (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.
--- src/frame.c.orig	2005-06-09 15:02:01.515625000 +0900
+++ src/frame.c	2005-06-09 15:25:13.796875000 +0900
@@ -106,6 +106,12 @@
 Lisp_Object Qleft_fringe, Qright_fringe;
 Lisp_Object Qbuffer_predicate, Qbuffer_list;
 Lisp_Object Qtty_color_mode;
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+Lisp_Object Qactive_alpha;
+Lisp_Object Qinactive_alpha;
+#endif
+#endif /* USE_TRANSPARENCY */
 
 Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
 
@@ -2575,6 +2581,12 @@
   {"right-fringe",		&Qright_fringe},
   {"wait-for-wm",		&Qwait_for_wm},
   {"fullscreen",                &Qfullscreen},
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  {"active-alpha",		&Qactive_alpha},
+  {"inactive-alpha",		&Qinactive_alpha},
+#endif
+#endif /* USE_TRANSPARENCY */
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
--- src/frame.h.orig	2005-06-09 15:02:01.671875000 +0900
+++ src/frame.h	2005-06-09 15:25:14.062500000 +0900
@@ -451,6 +451,13 @@
   /* Additional space to put between text lines on this frame.  */
   int extra_line_spacing;
 
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  /* Opacity of the Frame, which should be a number between 0.0 and 1.0  */
+  float active_alpha, inactive_alpha;
+#endif
+
+#endif /* USE_TRANSPARENCY */
   /* 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;
@@ -1003,6 +1010,12 @@
 extern Lisp_Object Qline_spacing;
 extern Lisp_Object Qwait_for_wm;
 extern Lisp_Object Qfullscreen;
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern Lisp_Object Qactive_alpha;
+extern Lisp_Object Qinactive_alpha;
+#endif
+#endif /* USE_TRANSPARENCY */
 
 extern Lisp_Object Qleft_fringe, Qright_fringe;
 extern Lisp_Object Qheight, Qwidth;
@@ -1074,6 +1087,12 @@
 					    Lisp_Object));
 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
 					Lisp_Object));
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern void x_set_active_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void x_set_inactive_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+#endif
+#endif /* USE_TRANSPARENCY */
 
 extern Lisp_Object x_icon_type P_ ((struct frame *));
 
--- src/macfns.c.orig	2005-06-09 15:02:01.968750000 +0900
+++ src/macfns.c	2005-06-09 15:25:14.468750000 +0900
@@ -2026,6 +2026,61 @@
 #endif /* not MAC_OSX */
 }
 
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020)
+/* Change the opecity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible If ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->active_alpha = XFLOAT_DATA (alpha);
+
+#if TARGET_API_MAC_CARBON
+    BLOCK_INPUT;
+
+    SetWindowAlpha (f->output_data.mac->mWP, f->active_alpha);
+
+    UNBLOCK_INPUT;
+#endif
+  }
+
+  return;
+}
+
+void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->inactive_alpha = XFLOAT_DATA (alpha);
+  }
+
+  return;
+}
+#endif /* USE_TRANSPARENCY */
 \f
 /* Subroutines of creating a frame.  */
 
@@ -2736,6 +2791,12 @@
   x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth",
 		       RES_TYPE_NUMBER);
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020)
+  x_default_parameter (f, parms, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parms, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
+#endif /* USE_TRANSPARENCY */
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -4444,6 +4505,10 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020)
+  x_set_active_alpha,
+  x_set_inactive_alpha,
+#endif /* USE_TRANSPARENCY */
 };
 
 void
--- src/macterm.c.orig	2005-06-09 15:02:02.421875000 +0900
+++ src/macterm.c	2005-06-09 15:25:15.171875000 +0900
@@ -1771,6 +1771,15 @@
   return FONT_TYPE_UNKNOWN;
 }
 
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020)
+static void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  SetWindowAlpha (f->output_data.mac->mWP, activate_p? f->active_alpha: f->inactive_alpha);
+}
+#endif /* USE_TRANSPARENCY */
 
 \f
 /***********************************************************************
@@ -3489,6 +3498,9 @@
     ActivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) 
+  x_set_frame_alpha (f, 1);
+#endif /* USE_TRANSPARENCY */
 }
 
 static void
@@ -3504,6 +3516,9 @@
     DeactivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) 
+  x_set_frame_alpha (f, 0);
+#endif /* USE_TRANSPARENCY */
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
--- src/w32fns.c.orig	2005-06-09 15:02:02.984375000 +0900
+++ src/w32fns.c	2005-06-09 15:25:15.703125000 +0900
@@ -1978,6 +1978,64 @@
 				      wid - 1) / wid;
 }
 
+#if defined (USE_TRANSPARENCY)
+/* Change the opecity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible If ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->active_alpha = XFLOAT_DATA (alpha);
+
+    BLOCK_INPUT;
+
+    SetWindowLong(FRAME_W32_WINDOW (f),GWL_EXSTYLE,
+                  GetWindowLong(FRAME_W32_WINDOW (f),GWL_EXSTYLE)|WS_EX_LAYERED);
+    SetLayeredWindowAttributes(FRAME_W32_WINDOW (f),
+                               RGB(255, 255, 255),
+                               (int)((f->active_alpha) * 255.0),
+                               LWA_ALPHA);
+
+    UNBLOCK_INPUT;
+  }
+
+  return;
+}
+
+void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->inactive_alpha = XFLOAT_DATA (alpha);
+  }
+
+  return;
+}
+#endif /* USE_TRANSPARENCY */
 \f
 /* Subroutines of creating a frame.  */
 
@@ -4321,6 +4379,12 @@
 		       "cursorType", "CursorType", RES_TYPE_SYMBOL);
   x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
+#if defined (USE_TRANSPARENCY)
+  x_default_parameter (f, parameters, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parameters, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
+#endif /* USE_TRANSPARENCY */
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -8442,6 +8506,10 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+#if defined (USE_TRANSPARENCY)
+  x_set_active_alpha,
+  x_set_inactive_alpha,
+#endif /* USE_TRANSPARENCY */
 };
 
 void
--- src/w32term.c.orig	2005-06-09 15:02:03.390625000 +0900
+++ src/w32term.c	2005-06-09 15:25:16.171875000 +0900
@@ -1183,6 +1183,20 @@
     return ANSI_FONT;
 }
 
+#if defined (USE_TRANSPARENCY)
+static void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  SetWindowLong(FRAME_W32_WINDOW (f),GWL_EXSTYLE,
+                GetWindowLong(FRAME_W32_WINDOW (f),GWL_EXSTYLE)|WS_EX_LAYERED);
+  SetLayeredWindowAttributes(FRAME_W32_WINDOW (f),
+                             RGB(255, 255, 255),
+                             (int)((activate_p? f->active_alpha: f->inactive_alpha) * 255.0),
+                             LWA_ALPHA);
+}
+#endif /* USE_TRANSPARENCY */
 
 \f
 /***********************************************************************
@@ -2780,6 +2794,9 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+#if defined (USE_TRANSPARENCY)
+  x_set_frame_alpha (f, 1);
+#endif /* USE_TRANSPARENCY */
 }
 
 static void
@@ -2787,6 +2804,9 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+#if defined (USE_TRANSPARENCY)
+  x_set_frame_alpha (f, 0);
+#endif /* USE_TRANSPARENCY */
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Macemacsjp-dev 100] [Mac OS X] [Win32] Frame-transparency patch
  2005-06-11  8:02 [Mac OS X] [Win32] Frame-transparency patch Seiji Zenitani
@ 2005-06-14 16:57 ` Seiji Zenitani
  2005-06-16 16:59   ` [Macemacsjp-dev 103] " Seiji Zenitani
  2005-06-17 20:56   ` [Macemacsjp-dev 100] " Michael Mauger
  0 siblings, 2 replies; 12+ messages in thread
From: Seiji Zenitani @ 2005-06-14 16:57 UTC (permalink / raw)
  Cc: macemacs-dev

[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]

Hi,

we have slightly revised the frame-transparency patch in order to fix  
compilation errors in some occasions. Comments, feedbacks and  
suggestions are welcome. You can see some screenshots at the  
following URL.
http://homepage.mac.com/matsuan_tamachan/emacs/TransparencyPatch.html

===========


1. Target operating systems

* Mac OSX  :   'Carbon Emacs'
* Windows XP, 2000, ME :   'NTEmacs'


2. How to build

* Mac OSX
Frame-transparency is automatically enabled when compiled on Mac OSX  
10.2 or later.

* MS Windows
If you use Windows XP, 2000 or ME, add manually the below switch when  
configuring.
CFLAGS=-DUSE_TRANSPARENCY


3. Parameters

Two frame parameters are introduced:

* active-alpha : window opacity of the frontmost frame.
* inactive-alpha : window opacity of non-active frames.

Window opacity will be set by using a float value between 0.0  
(invisible) to 1.0 (completely opaque). By default they are set to 1.0.


4. sample settings

To set frame-transparency of the current frame

         ;; active frame
         (set-frame-parameter (selected-frame) 'active-alpha 0.9)
         ;; non active frame
         (set-frame-parameter (selected-frame) 'inactive-alpha 0.8)

To set the default frame parameters

         (setq default-frame-alist
               (append
                (list
                 '(active-alpha . 0.9)  ;; active frame
                 '(inactive-alpha . 0.8) ;; non active frame
                 ) default-frame-alist)
               )

5. authors

Ryo Yoshitake, Takashi Hiromatsu, Seiji Zenitani

contact: macemacs-english@lists.sourceforge.jp


===========


Sincerely,


Seiji Zenitani
zenitani@tkg.att.ne.jp


[-- Attachment #2: transparency2.patch --]
[-- Type: application/octet-stream, Size: 11171 bytes --]

--- lisp/frame.el.orig	2005-06-09 15:02:01.265625000 +0900
+++ lisp/frame.el	2005-06-13 10:51:46.874250000 +0900
@@ -927,6 +927,22 @@
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'border-color color-name))))
 
+(when (frame-parameter nil 'active-alpha)
+  (defun set-active-alpha (alpha-value)
+    "Set the opacity of the selected frame in active state to ALPHA.
+When called interactively, prompt for the value of the opacity to set.
+To get the frame's current active alpha value state, use `frame-parameters'."
+    (interactive "nactive alpha: ")
+    (modify-frame-parameters (selected-frame)
+                             (list (cons 'active-alpha alpha-value))))
+  (defun set-inactive-alpha (alpha-value)
+    "Set the opacity of the selected frame in inactive state to ALPHA.
+When called interactively, prompt for the value of the opacity to set.
+To get the frame's current inactive alpha value state, use `frame-parameters'."
+    (interactive "ninactive alpha: ")
+    (modify-frame-parameters (selected-frame)
+                             (list (cons 'inactive-alpha alpha-value)))))
+
 (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.
--- src/frame.c.orig	2005-06-09 15:02:01.515625000 +0900
+++ src/frame.c	2005-06-09 15:25:13.796875000 +0900
@@ -106,6 +106,12 @@
 Lisp_Object Qleft_fringe, Qright_fringe;
 Lisp_Object Qbuffer_predicate, Qbuffer_list;
 Lisp_Object Qtty_color_mode;
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+Lisp_Object Qactive_alpha;
+Lisp_Object Qinactive_alpha;
+#endif
+#endif /* USE_TRANSPARENCY */
 
 Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
 
@@ -2575,6 +2581,12 @@
   {"right-fringe",		&Qright_fringe},
   {"wait-for-wm",		&Qwait_for_wm},
   {"fullscreen",                &Qfullscreen},
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  {"active-alpha",		&Qactive_alpha},
+  {"inactive-alpha",		&Qinactive_alpha},
+#endif
+#endif /* USE_TRANSPARENCY */
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
--- src/frame.h.orig	2005-06-09 15:02:01.671875000 +0900
+++ src/frame.h	2005-06-09 15:25:14.062500000 +0900
@@ -451,6 +451,13 @@
   /* Additional space to put between text lines on this frame.  */
   int extra_line_spacing;
 
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  /* Opacity of the Frame, which should be a number between 0.0 and 1.0  */
+  float active_alpha, inactive_alpha;
+#endif
+
+#endif /* USE_TRANSPARENCY */
   /* 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;
@@ -1003,6 +1010,12 @@
 extern Lisp_Object Qline_spacing;
 extern Lisp_Object Qwait_for_wm;
 extern Lisp_Object Qfullscreen;
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern Lisp_Object Qactive_alpha;
+extern Lisp_Object Qinactive_alpha;
+#endif
+#endif /* USE_TRANSPARENCY */
 
 extern Lisp_Object Qleft_fringe, Qright_fringe;
 extern Lisp_Object Qheight, Qwidth;
@@ -1074,6 +1087,12 @@
 					    Lisp_Object));
 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
 					Lisp_Object));
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) || defined (USE_TRANSPARENCY)
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern void x_set_active_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void x_set_inactive_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+#endif
+#endif /* USE_TRANSPARENCY */
 
 extern Lisp_Object x_icon_type P_ ((struct frame *));
 
--- src/macfns.c.orig	2005-06-09 15:02:01.968750000 +0900
+++ src/macfns.c	2005-06-09 15:25:14.468750000 +0900
@@ -2026,6 +2026,61 @@
 #endif /* not MAC_OSX */
 }
 
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020)
+/* Change the opecity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible If ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->active_alpha = XFLOAT_DATA (alpha);
+
+#if TARGET_API_MAC_CARBON
+    BLOCK_INPUT;
+
+    SetWindowAlpha (f->output_data.mac->mWP, f->active_alpha);
+
+    UNBLOCK_INPUT;
+#endif
+  }
+
+  return;
+}
+
+void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->inactive_alpha = XFLOAT_DATA (alpha);
+  }
+
+  return;
+}
+#endif /* USE_TRANSPARENCY */
 \f
 /* Subroutines of creating a frame.  */
 
@@ -2736,6 +2791,12 @@
   x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth",
 		       RES_TYPE_NUMBER);
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020)
+  x_default_parameter (f, parms, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parms, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
+#endif /* USE_TRANSPARENCY */
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -4444,6 +4505,10 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020)
+  x_set_active_alpha,
+  x_set_inactive_alpha,
+#endif /* USE_TRANSPARENCY */
 };
 
 void
--- src/macterm.c.orig	2005-06-09 15:02:02.421875000 +0900
+++ src/macterm.c	2005-06-09 15:25:15.171875000 +0900
@@ -1771,6 +1771,15 @@
   return FONT_TYPE_UNKNOWN;
 }
 
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020)
+static void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  SetWindowAlpha (f->output_data.mac->mWP, activate_p? f->active_alpha: f->inactive_alpha);
+}
+#endif /* USE_TRANSPARENCY */
 
 \f
 /***********************************************************************
@@ -3489,6 +3498,9 @@
     ActivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) 
+  x_set_frame_alpha (f, 1);
+#endif /* USE_TRANSPARENCY */
 }
 
 static void
@@ -3504,6 +3516,9 @@
     DeactivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1020) 
+  x_set_frame_alpha (f, 0);
+#endif /* USE_TRANSPARENCY */
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
--- src/w32fns.c.orig	2005-06-09 15:02:02.984375000 +0900
+++ src/w32fns.c	2005-06-09 15:25:15.703125000 +0900
@@ -1978,6 +1978,64 @@
 				      wid - 1) / wid;
 }
 
+#if defined (USE_TRANSPARENCY)
+/* Change the opecity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible If ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->active_alpha = XFLOAT_DATA (alpha);
+
+    BLOCK_INPUT;
+
+    SetWindowLong(FRAME_W32_WINDOW (f),GWL_EXSTYLE,
+                  GetWindowLong(FRAME_W32_WINDOW (f),GWL_EXSTYLE)|WS_EX_LAYERED);
+    SetLayeredWindowAttributes(FRAME_W32_WINDOW (f),
+                               RGB(255, 255, 255),
+                               (int)((f->active_alpha) * 255.0),
+                               LWA_ALPHA);
+
+    UNBLOCK_INPUT;
+  }
+
+  return;
+}
+
+void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->inactive_alpha = XFLOAT_DATA (alpha);
+  }
+
+  return;
+}
+#endif /* USE_TRANSPARENCY */
 \f
 /* Subroutines of creating a frame.  */
 
@@ -4321,6 +4379,12 @@
 		       "cursorType", "CursorType", RES_TYPE_SYMBOL);
   x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
+#if defined (USE_TRANSPARENCY)
+  x_default_parameter (f, parameters, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parameters, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
+#endif /* USE_TRANSPARENCY */
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -8442,6 +8506,10 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+#if defined (USE_TRANSPARENCY)
+  x_set_active_alpha,
+  x_set_inactive_alpha,
+#endif /* USE_TRANSPARENCY */
 };
 
 void
--- src/w32term.c.orig	2005-06-09 15:02:03.390625000 +0900
+++ src/w32term.c	2005-06-09 15:25:16.171875000 +0900
@@ -1183,6 +1183,20 @@
     return ANSI_FONT;
 }
 
+#if defined (USE_TRANSPARENCY)
+static void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  SetWindowLong(FRAME_W32_WINDOW (f),GWL_EXSTYLE,
+                GetWindowLong(FRAME_W32_WINDOW (f),GWL_EXSTYLE)|WS_EX_LAYERED);
+  SetLayeredWindowAttributes(FRAME_W32_WINDOW (f),
+                             RGB(255, 255, 255),
+                             (int)((activate_p? f->active_alpha: f->inactive_alpha) * 255.0),
+                             LWA_ALPHA);
+}
+#endif /* USE_TRANSPARENCY */
 
 \f
 /***********************************************************************
@@ -2780,6 +2794,9 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+#if defined (USE_TRANSPARENCY)
+  x_set_frame_alpha (f, 1);
+#endif /* USE_TRANSPARENCY */
 }
 
 static void
@@ -2787,6 +2804,9 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+#if defined (USE_TRANSPARENCY)
+  x_set_frame_alpha (f, 0);
+#endif /* USE_TRANSPARENCY */
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Macemacsjp-dev 103] Re: [Mac OS X] [Win32] Frame-transparency patch
  2005-06-14 16:57 ` [Macemacsjp-dev 100] " Seiji Zenitani
@ 2005-06-16 16:59   ` Seiji Zenitani
  2005-06-17 20:56   ` [Macemacsjp-dev 100] " Michael Mauger
  1 sibling, 0 replies; 12+ messages in thread
From: Seiji Zenitani @ 2005-06-16 16:59 UTC (permalink / raw)
  Cc: macemacs-dev

Hi

let me modify our contact information on the frame-transparency patch.

On 2005/06/15, at 1:57, Seiji Zenitani wrote:
>
> 5. authors
>
> Ryo Yoshitake, Takashi Hiromatsu, Seiji Zenitani
>
> contact: macemacs-english@lists.sourceforge.jp
>
contact: macemacsjp-english@lists.sourceforge.jp


Sincerely,

Seiji Zenitani
zenitani@tkg.att.ne.jp

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Macemacsjp-dev 100] [Mac OS X] [Win32] Frame-transparency patch
  2005-06-14 16:57 ` [Macemacsjp-dev 100] " Seiji Zenitani
  2005-06-16 16:59   ` [Macemacsjp-dev 103] " Seiji Zenitani
@ 2005-06-17 20:56   ` Michael Mauger
  2005-06-18  0:28     ` Takashi Hiromatsu
  1 sibling, 1 reply; 12+ messages in thread
From: Michael Mauger @ 2005-06-17 20:56 UTC (permalink / raw)


Seiji Zenitani <zenitani <at> tkg.att.ne.jp> writes:

> ===========
> 
> 1. Target operating systems
> 
> * Mac OSX  :   'Carbon Emacs'
> * Windows XP, 2000, ME :   'NTEmacs'
> 
> 2. How to build
> 
> * Mac OSX
> Frame-transparency is automatically enabled when compiled on Mac OSX  
> 10.2 or later.
> 
> * MS Windows
> If you use Windows XP, 2000 or ME, add manually the below switch when  
> configuring.
> CFLAGS=-DUSE_TRANSPARENCY
> 

Interesting patch.  SetLayeredWindowAttributes is not available on all W32 
releases, so you ought to dynamically locate it and call it only when 
available.  (See http://www.codeproject.com/win32/quaker1.asp for an example.)  
I build on a machine without it, but run the executables on a machine that 
does.  This will be a common situation with the released executables.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Macemacsjp-dev 100] [Mac OS X] [Win32] Frame-transparency patch
  2005-06-17 20:56   ` [Macemacsjp-dev 100] " Michael Mauger
@ 2005-06-18  0:28     ` Takashi Hiromatsu
  2005-06-20 20:36       ` Takashi Hiromatsu
  0 siblings, 1 reply; 12+ messages in thread
From: Takashi Hiromatsu @ 2005-06-18  0:28 UTC (permalink / raw)


At Fri, 17 Jun 2005 20:56:12 +0000 (UTC),
Michael Mauger wrote:
> > * MS Windows
> > If you use Windows XP, 2000 or ME, add manually the below switch when  
> > configuring.
> > CFLAGS=-DUSE_TRANSPARENCY
> > 
> 
> Interesting patch.  SetLayeredWindowAttributes is not available on all
> W32 releases, so you ought to dynamically locate it and call it only
> when available.  (See http://www.codeproject.com/win32/quaker1.asp for
> an example.)
Thank you for your suggestion. I will try it soon.

Takashi Hiromatsu

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Mac OS X] [Win32] Frame-transparency patch
  2005-06-18  0:28     ` Takashi Hiromatsu
@ 2005-06-20 20:36       ` Takashi Hiromatsu
  2005-06-20 21:58         ` Juanma Barranquero
  0 siblings, 1 reply; 12+ messages in thread
From: Takashi Hiromatsu @ 2005-06-20 20:36 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

> Thank you for your suggestion. I will try it soon.

We have done. How about this?

* On W32, dynamically check the SetLayeredWindowAttributes function
  instead of compiler switchs like "#ifdef".
* On Mac, use Gestalt function to chekc OSX version instead of compiler
  switchs.
* then no longer needed any configuration options.
* change the function x_set_frame_alpha in (mac|w32)term.c to extern, then
  can be called from (mac|w32)fns.c too.
* In frame.el, use "(eq system-type 'windows-nt)" instead of
    "(frame-parameter nil 'active-alpha)" to check tranparency function.

Takashi Hiromatsu


[-- Attachment #2: transparency2.patch --]
[-- Type: application/octet-stream, Size: 11030 bytes --]

--- lisp/frame.el.orig	2005-06-19 06:12:40.000000000 +0900
+++ lisp/frame.el	2005-06-19 08:52:09.000000000 +0900
@@ -927,6 +927,22 @@
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'border-color color-name))))
 
+(when (or (eq system-type 'windows-nt) (eq system-type 'darwin))
+  (defun set-active-alpha (alpha-value)
+    "Set the opacity of the selected frame in active state to ALPHA.
+When called interactively, prompt for the value of the opacity to set.
+To get the frame's current active alpha value state, use `frame-parameters'."
+    (interactive "nactive alpha: ")
+    (modify-frame-parameters (selected-frame)
+                             (list (cons 'active-alpha alpha-value))))
+  (defun set-inactive-alpha (alpha-value)
+    "Set the opacity of the selected frame in inactive state to ALPHA.
+When called interactively, prompt for the value of the opacity to set.
+To get the frame's current inactive alpha value state, use `frame-parameters'."
+    (interactive "ninactive alpha: ")
+    (modify-frame-parameters (selected-frame)
+                             (list (cons 'inactive-alpha alpha-value)))))
+
 (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.
--- src/frame.c.orig	2005-06-19 06:12:40.000000000 +0900
+++ src/frame.c	2005-06-19 11:50:29.000000000 +0900
@@ -106,6 +106,10 @@
 Lisp_Object Qleft_fringe, Qright_fringe;
 Lisp_Object Qbuffer_predicate, Qbuffer_list;
 Lisp_Object Qtty_color_mode;
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+Lisp_Object Qactive_alpha;
+Lisp_Object Qinactive_alpha;
+#endif
 
 Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
 
@@ -2575,6 +2579,10 @@
   {"right-fringe",		&Qright_fringe},
   {"wait-for-wm",		&Qwait_for_wm},
   {"fullscreen",                &Qfullscreen},
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  {"active-alpha",		&Qactive_alpha},
+  {"inactive-alpha",		&Qinactive_alpha},
+#endif
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
--- src/frame.h.orig	2005-06-19 06:12:40.000000000 +0900
+++ src/frame.h	2005-06-19 11:51:33.000000000 +0900
@@ -451,6 +451,11 @@
   /* Additional space to put between text lines on this frame.  */
   int extra_line_spacing;
 
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  /* Opacity of the Frame, which should be a number between 0.0 and 1.0  */
+  float active_alpha, inactive_alpha;
+#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;
@@ -1003,6 +1008,10 @@
 extern Lisp_Object Qline_spacing;
 extern Lisp_Object Qwait_for_wm;
 extern Lisp_Object Qfullscreen;
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern Lisp_Object Qactive_alpha;
+extern Lisp_Object Qinactive_alpha;
+#endif
 
 extern Lisp_Object Qleft_fringe, Qright_fringe;
 extern Lisp_Object Qheight, Qwidth;
@@ -1074,6 +1083,11 @@
 					    Lisp_Object));
 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
 					Lisp_Object));
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern void x_set_active_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void x_set_inactive_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void x_set_frame_alpha P_ ((struct frame *, int));
+#endif
 
 extern Lisp_Object x_icon_type P_ ((struct frame *));
 
--- src/macfns.c.orig	2005-06-19 08:51:34.000000000 +0900
+++ src/macfns.c	2005-06-19 11:47:45.000000000 +0900
@@ -2026,6 +2026,59 @@
 #endif /* not MAC_OSX */
 }
 
+/* Change the opecity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible If ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+    {
+      f->active_alpha = XFLOAT_DATA (alpha);
+
+#if TARGET_API_MAC_CARBON
+      BLOCK_INPUT;
+
+      x_set_frame_alpha (f, 1);
+
+      UNBLOCK_INPUT;
+#endif
+    }
+
+  return;
+}
+
+void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->inactive_alpha = XFLOAT_DATA (alpha);
+  }
+
+  return;
+}
 \f
 /* Subroutines of creating a frame.  */
 
@@ -2736,6 +2789,10 @@
   x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth",
 		       RES_TYPE_NUMBER);
+  x_default_parameter (f, parms, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parms, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -4445,6 +4502,8 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+  x_set_active_alpha,
+  x_set_inactive_alpha,
 };
 
 void
--- src/macterm.c.orig	2005-06-19 08:51:34.000000000 +0900
+++ src/macterm.c	2005-06-19 11:53:21.000000000 +0900
@@ -1771,6 +1771,23 @@
   return FONT_TYPE_UNKNOWN;
 }
 
+void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  SInt32 response;
+  OSErr err;
+
+  BLOCK_INPUT;
+  err = Gestalt (gestaltSystemVersion, &response);
+  UNBLOCK_INPUT;
+
+  if ((err == noErr) && (response >= 0x1020)) {
+    SetWindowAlpha (f->output_data.mac->mWP,
+                    activate_p? f->active_alpha: f->inactive_alpha);
+  }
+}
 
 \f
 /***********************************************************************
@@ -3493,6 +3510,7 @@
     ActivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 1);
 }
 
 static void
@@ -3508,6 +3526,7 @@
     DeactivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 0);
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
--- src/w32fns.c.orig	2005-06-19 08:51:34.000000000 +0900
+++ src/w32fns.c	2005-06-19 13:20:30.000000000 +0900
@@ -262,6 +262,7 @@
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
 ClipboardSequence_Proc clipboard_sequence_fn = NULL;
 extern AppendMenuW_Proc unicode_append_menu;
+extern SetLayeredWindowAttributes_Proc set_layered_window_attributes_fn;
 
 /* W95 mousewheel handler */
 unsigned int msh_mousewheel = 0;
@@ -1978,6 +1979,57 @@
 				      wid - 1) / wid;
 }
 
+/* Change the opecity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible If ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+    {
+      f->active_alpha = XFLOAT_DATA (alpha);
+
+      BLOCK_INPUT;
+
+      x_set_frame_alpha (f, 1);
+
+      UNBLOCK_INPUT;
+    }
+
+  return;
+}
+
+void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+  {
+    f->inactive_alpha = XFLOAT_DATA (alpha);
+  }
+
+  return;
+}
 \f
 /* Subroutines of creating a frame.  */
 
@@ -4321,6 +4373,10 @@
 		       "cursorType", "CursorType", RES_TYPE_SYMBOL);
   x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
+  x_default_parameter (f, parameters, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parameters, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -8473,6 +8529,8 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+  x_set_active_alpha,
+  x_set_inactive_alpha,
 };
 
 void
@@ -8912,6 +8970,9 @@
   /* ditto for GetClipboardSequenceNumber.  */
   clipboard_sequence_fn = (ClipboardSequence_Proc)
     GetProcAddress (user32_lib, "GetClipboardSequenceNumber");
+  /* ditto for SetLayeredWindowAttributes.  */
+  set_layered_window_attributes_fn = (SetLayeredWindowAttributes_Proc)
+    GetProcAddress (user32_lib, "SetLayeredWindowAttributes");
 
   DEFVAR_INT ("w32-ansi-code-page",
 	      &w32_ansi_code_page,
--- src/w32term.c.orig	2005-06-19 08:51:34.000000000 +0900
+++ src/w32term.c	2005-06-19 10:18:14.000000000 +0900
@@ -272,6 +272,8 @@
 
 static Lisp_Object Qvendor_specific_keysyms;
 
+SetLayeredWindowAttributes_Proc set_layered_window_attributes_fn = NULL;
+
 \f
 /***********************************************************************
 			      Debugging
@@ -1187,6 +1189,25 @@
     return ANSI_FONT;
 }
 
+void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  Window window = FRAME_W32_WINDOW (f);
+
+  if (set_layered_window_attributes_fn != NULL) {
+    SetWindowLong (window, GWL_EXSTYLE,
+                   GetWindowLong (window, GWL_EXSTYLE)|WS_EX_LAYERED);
+    set_layered_window_attributes_fn (FRAME_W32_WINDOW (f),
+                                      RGB(255, 255, 255),
+                                      (int)((activate_p?
+                                             f->active_alpha:
+                                             f->inactive_alpha)
+                                            * 255.0),
+                                      LWA_ALPHA);
+  }
+}
 
 \f
 /***********************************************************************
@@ -2786,6 +2807,7 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 1);
 }
 
 static void
@@ -2793,6 +2815,7 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 0);
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
--- src/w32term.h.orig	2005-06-19 11:54:25.000000000 +0900
+++ src/w32term.h	2005-06-19 08:49:32.000000000 +0900
@@ -755,6 +755,8 @@
       ? BDF_1D_FONT : BDF_2D_FONT))
 
 typedef DWORD (WINAPI * ClipboardSequence_Proc) ();
+typedef DWORD (WINAPI * SetLayeredWindowAttributes_Proc)
+  (HWND, DWORD, BYTE, DWORD);
 typedef BOOL (WINAPI * AppendMenuW_Proc) (
     IN HMENU,
     IN UINT,

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Mac OS X] [Win32] Frame-transparency patch
  2005-06-20 20:36       ` Takashi Hiromatsu
@ 2005-06-20 21:58         ` Juanma Barranquero
  2005-06-20 22:00           ` Juanma Barranquero
                             ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Juanma Barranquero @ 2005-06-20 21:58 UTC (permalink / raw)
  Cc: emacs-devel

On 6/20/05, Takashi Hiromatsu <matsuan@ca2.so-net.ne.jp> wrote:

> We have done. How about this?

I'm using Visual Studio .NET 2003 and I'm getting "undefined
identifier" errors for LWA_ALPHA and WS_EX_LAYERED. They are on
WinUser.h, of course; I suppose it's a _WIN32_WINNT >= 0x0500 thing.
Perhaps the easiest fix is just define the constants yourself.

Once fixed the problem, the patch works fine on my setup.

A few nitpicks:

  - In frame.el you should use

  (when (memq system-type '(windows-nt darwin))

instead of

  (when (or (eq system-type 'windows-nt) (eq system-type 'darwin))

because it's nicer and easier to extend if someday other platforms
support transparent backgrounds.

  - Functions `set-active-alpha' and `set-inactive-alpha' do have an
argument ALPHA-VALUE, referred to in the docstring as ALPHA. Change
the name of the argument or fix the docstring, please.

 - Also, capitalize the interactive messages "active alpha: " and
"inactive alpha: " to "Active alpha: " and "Inactive alpha: " (it's
customary on interactive prompt).

 - Better still would be to document what the ALPHA-VALUE is and what
is its range (0.0 to 1.0, I assume, but it is not said anywhere).

-- 
                    /L/e/k/t/u

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Mac OS X] [Win32] Frame-transparency patch
  2005-06-20 21:58         ` Juanma Barranquero
@ 2005-06-20 22:00           ` Juanma Barranquero
  2005-06-21 11:18           ` Takashi Hiromatsu
  2005-06-21 16:23           ` Kevin Rodgers
  2 siblings, 0 replies; 12+ messages in thread
From: Juanma Barranquero @ 2005-06-20 22:00 UTC (permalink / raw)
  Cc: emacs-devel

>  - Better still would be to document what the ALPHA-VALUE is and what
> is its range (0.0 to 1.0, I assume, but it is not said anywhere).

In fact, you *can* pass values over 1.0 which produce some sort of
wraparound. It'd be better to restrict the values entered to the
correct range.

-- 
                    /L/e/k/t/u

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Mac OS X] [Win32] Frame-transparency patch
  2005-06-20 21:58         ` Juanma Barranquero
  2005-06-20 22:00           ` Juanma Barranquero
@ 2005-06-21 11:18           ` Takashi Hiromatsu
  2005-06-21 15:29             ` Juanma Barranquero
  2005-06-21 16:23           ` Kevin Rodgers
  2 siblings, 1 reply; 12+ messages in thread
From: Takashi Hiromatsu @ 2005-06-21 11:18 UTC (permalink / raw)
  Cc: Juanma Barranquero, macemacs-dev

[-- Attachment #1: Type: text/plain, Size: 1281 bytes --]

Thank you for your kindly advices.

At Mon, 20 Jun 2005 23:58:35 +0200,
Juanma Barranquero wrote:
> I'm using Visual Studio .NET 2003 and I'm getting "undefined
> identifier" errors for LWA_ALPHA and WS_EX_LAYERED. They are on
> WinUser.h, of course; I suppose it's a _WIN32_WINNT >= 0x0500 thing.
> Perhaps the easiest fix is just define the constants yourself.
I've done.

>   - In frame.el you should use
....
>   (when (or (eq system-type 'windows-nt) (eq system-type 'darwin))
> 
> because it's nicer and easier to extend if someday other platforms
> support transparent backgrounds.
Done.

>   - Functions `set-active-alpha' and `set-inactive-alpha' do have an
> argument ALPHA-VALUE, referred to in the docstring as ALPHA. Change
> the name of the argument or fix the docstring, please.
Done.

>  - Also, capitalize the interactive messages "active alpha: " and
> "inactive alpha: " to "Active alpha: " and "Inactive alpha: " (it's
> customary on interactive prompt).
Doen.

>>  - Better still would be to document what the ALPHA-VALUE is and what
>> is its range (0.0 to 1.0, I assume, but it is not said anywhere).
...
> wraparound. It'd be better to restrict the values entered to the
> correct range.
Both done.

Could you check new patch.

Kind regards.

T. Hiromatsu


[-- Attachment #2: transparency2.patch --]
[-- Type: application/octet-stream, Size: 11856 bytes --]

--- lisp/frame.el.orig	2005-06-21 10:25:27.358750000 +0900
+++ lisp/frame.el	2005-06-21 12:17:59.468250000 +0900
@@ -927,6 +927,24 @@
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'border-color color-name))))
 
+(when (memq system-type '(windows-nt darwin))
+  (defun set-active-alpha (alpha)
+    "Set the opacity of the selected frame in active state to ALPHA.
+ALPHA can take value between 0.0 (invisible) to 1.0 (completely opaque).
+When called interactively, prompt for the value of the opacity to set.
+To get the frame's current active alpha value state, use `frame-parameters'."
+    (interactive "nActive alpha (0.0 - 1.0): ")
+    (modify-frame-parameters (selected-frame)
+                             (list (cons 'active-alpha alpha))))
+  (defun set-inactive-alpha (alpha)
+    "Set the opacity of the selected frame in inactive state to ALPHA.
+ALPHA can take value between 0.0 (invisible) to 1.0 (completely opaque).
+When called interactively, prompt for the value of the opacity to set.
+To get the frame's current inactive alpha value state, use `frame-parameters'."
+    (interactive "nInactive alpha (0.0 - 1.0): ")
+    (modify-frame-parameters (selected-frame)
+                             (list (cons 'inactive-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.
--- src/frame.c.orig	2005-06-21 10:25:27.671250000 +0900
+++ src/frame.c	2005-06-21 10:26:44.015000000 +0900
@@ -106,6 +106,10 @@
 Lisp_Object Qleft_fringe, Qright_fringe;
 Lisp_Object Qbuffer_predicate, Qbuffer_list;
 Lisp_Object Qtty_color_mode;
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+Lisp_Object Qactive_alpha;
+Lisp_Object Qinactive_alpha;
+#endif
 
 Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
 
@@ -2575,6 +2579,10 @@
   {"right-fringe",		&Qright_fringe},
   {"wait-for-wm",		&Qwait_for_wm},
   {"fullscreen",                &Qfullscreen},
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  {"active-alpha",		&Qactive_alpha},
+  {"inactive-alpha",		&Qinactive_alpha},
+#endif
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
--- src/frame.h.orig	2005-06-21 10:25:27.827500000 +0900
+++ src/frame.h	2005-06-21 10:26:44.155625000 +0900
@@ -451,6 +451,11 @@
   /* Additional space to put between text lines on this frame.  */
   int extra_line_spacing;
 
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  /* Opacity of the Frame, which should be a number between 0.0 and 1.0  */
+  float active_alpha, inactive_alpha;
+#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;
@@ -1003,6 +1008,10 @@
 extern Lisp_Object Qline_spacing;
 extern Lisp_Object Qwait_for_wm;
 extern Lisp_Object Qfullscreen;
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern Lisp_Object Qactive_alpha;
+extern Lisp_Object Qinactive_alpha;
+#endif
 
 extern Lisp_Object Qleft_fringe, Qright_fringe;
 extern Lisp_Object Qheight, Qwidth;
@@ -1074,6 +1083,11 @@
 					    Lisp_Object));
 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
 					Lisp_Object));
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern void x_set_active_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void x_set_inactive_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void x_set_frame_alpha P_ ((struct frame *, int));
+#endif
 
 extern Lisp_Object x_icon_type P_ ((struct frame *));
 
--- src/macfns.c.orig	2005-06-21 10:25:28.186875000 +0900
+++ src/macfns.c	2005-06-21 11:20:22.561875000 +0900
@@ -2026,6 +2026,65 @@
 #endif /* not MAC_OSX */
 }
 
+/* Change the opecity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible If ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+    {
+      if ((XFLOAT_DATA (alpha) >= 0.0) && (XFLOAT_DATA (alpha) <= 1.0))
+        {
+          f->active_alpha = XFLOAT_DATA (alpha);
+
+#if TARGET_API_MAC_CARBON
+          BLOCK_INPUT;
+
+          x_set_frame_alpha (f, 1);
+
+          UNBLOCK_INPUT;
+#endif
+        }
+    }
+
+  return;
+}
+
+void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+    {
+      if ((XFLOAT_DATA (alpha) >= 0.0) && (XFLOAT_DATA (alpha) <= 1.0))
+        {
+          f->inactive_alpha = XFLOAT_DATA (alpha);
+        }
+    }
+
+  return;
+}
 \f
 /* Subroutines of creating a frame.  */
 
@@ -2736,6 +2795,10 @@
   x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth",
 		       RES_TYPE_NUMBER);
+  x_default_parameter (f, parms, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parms, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -4445,6 +4508,8 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+  x_set_active_alpha,
+  x_set_inactive_alpha,
 };
 
 void
--- src/macterm.c.orig	2005-06-21 10:25:28.765000000 +0900
+++ src/macterm.c	2005-06-21 10:26:44.483750000 +0900
@@ -1771,6 +1771,23 @@
   return FONT_TYPE_UNKNOWN;
 }
 
+void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  SInt32 response;
+  OSErr err;
+
+  BLOCK_INPUT;
+  err = Gestalt (gestaltSystemVersion, &response);
+  UNBLOCK_INPUT;
+
+  if ((err == noErr) && (response >= 0x1020)) {
+    SetWindowAlpha (f->output_data.mac->mWP,
+                    activate_p? f->active_alpha: f->inactive_alpha);
+  }
+}
 
 \f
 /***********************************************************************
@@ -3493,6 +3510,7 @@
     ActivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 1);
 }
 
 static void
@@ -3508,6 +3526,7 @@
     DeactivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 0);
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
--- src/w32fns.c.orig	2005-06-21 10:25:29.218125000 +0900
+++ src/w32fns.c	2005-06-21 11:18:16.202500000 +0900
@@ -262,6 +262,7 @@
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
 ClipboardSequence_Proc clipboard_sequence_fn = NULL;
 extern AppendMenuW_Proc unicode_append_menu;
+extern SetLayeredWindowAttributes_Proc set_layered_window_attributes_fn;
 
 /* W95 mousewheel handler */
 unsigned int msh_mousewheel = 0;
@@ -1978,6 +1979,63 @@
 				      wid - 1) / wid;
 }
 
+/* Change the opecity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible If ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+    {
+      if ((XFLOAT_DATA (alpha) >= 0.0) && (XFLOAT_DATA (alpha) <= 1.0))
+        {
+          f->active_alpha = XFLOAT_DATA (alpha);
+
+          BLOCK_INPUT;
+
+          x_set_frame_alpha (f, 1);
+
+          UNBLOCK_INPUT;
+        }
+    }
+
+  return;
+}
+
+void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if (FLOATP (alpha))
+    {
+      if ((XFLOAT_DATA (alpha) >= 0.0) && (XFLOAT_DATA (alpha) <= 1.0))
+        {
+          f->inactive_alpha = XFLOAT_DATA (alpha);
+        }
+    }
+
+  return;
+}
 \f
 /* Subroutines of creating a frame.  */
 
@@ -4321,6 +4379,10 @@
 		       "cursorType", "CursorType", RES_TYPE_SYMBOL);
   x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
+  x_default_parameter (f, parameters, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parameters, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -8473,6 +8535,8 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+  x_set_active_alpha,
+  x_set_inactive_alpha,
 };
 
 void
@@ -8912,6 +8976,9 @@
   /* ditto for GetClipboardSequenceNumber.  */
   clipboard_sequence_fn = (ClipboardSequence_Proc)
     GetProcAddress (user32_lib, "GetClipboardSequenceNumber");
+  /* ditto for SetLayeredWindowAttributes.  */
+  set_layered_window_attributes_fn = (SetLayeredWindowAttributes_Proc)
+    GetProcAddress (user32_lib, "SetLayeredWindowAttributes");
 
   DEFVAR_INT ("w32-ansi-code-page",
 	      &w32_ansi_code_page,
--- src/w32term.c.orig	2005-06-21 10:25:29.686875000 +0900
+++ src/w32term.c	2005-06-21 10:26:44.780625000 +0900
@@ -272,6 +272,8 @@
 
 static Lisp_Object Qvendor_specific_keysyms;
 
+SetLayeredWindowAttributes_Proc set_layered_window_attributes_fn = NULL;
+
 \f
 /***********************************************************************
 			      Debugging
@@ -1187,6 +1189,25 @@
     return ANSI_FONT;
 }
 
+void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  Window window = FRAME_W32_WINDOW (f);
+
+  if (set_layered_window_attributes_fn != NULL) {
+    SetWindowLong (window, GWL_EXSTYLE,
+                   GetWindowLong (window, GWL_EXSTYLE)|WS_EX_LAYERED);
+    set_layered_window_attributes_fn (FRAME_W32_WINDOW (f),
+                                      RGB(255, 255, 255),
+                                      (int)((activate_p?
+                                             f->active_alpha:
+                                             f->inactive_alpha)
+                                            * 255.0),
+                                      LWA_ALPHA);
+  }
+}
 
 \f
 /***********************************************************************
@@ -2786,6 +2807,7 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 1);
 }
 
 static void
@@ -2793,6 +2815,7 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 0);
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
--- src/w32term.h.orig	2005-06-21 10:25:29.858750000 +0900
+++ src/w32term.h	2005-06-21 10:34:08.140000000 +0900
@@ -643,6 +643,10 @@
 
 #define WND_EXTRA_BYTES     (WND_LAST_INDEX)
 
+/* for transparency functions */
+#define LWA_ALPHA 2
+#define WS_EX_LAYERED 0x80000   /* w2k */
+
 extern DWORD dwWindowsThreadId;
 extern HANDLE hWindowsThread;
 extern DWORD dwMainThreadId;
@@ -755,6 +759,8 @@
       ? BDF_1D_FONT : BDF_2D_FONT))
 
 typedef DWORD (WINAPI * ClipboardSequence_Proc) ();
+typedef DWORD (WINAPI * SetLayeredWindowAttributes_Proc)
+  (HWND, DWORD, BYTE, DWORD);
 typedef BOOL (WINAPI * AppendMenuW_Proc) (
     IN HMENU,
     IN UINT,

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Mac OS X] [Win32] Frame-transparency patch
  2005-06-21 11:18           ` Takashi Hiromatsu
@ 2005-06-21 15:29             ` Juanma Barranquero
  2005-06-27 11:38               ` Takashi Hiromatsu
  0 siblings, 1 reply; 12+ messages in thread
From: Juanma Barranquero @ 2005-06-21 15:29 UTC (permalink / raw)
  Cc: macemacs-dev, emacs-devel

> > Perhaps the easiest fix is just define the constants yourself.
> I've done.

I'm not sure whether it would be better to protect these with #ifndef, i.e.

  #ifndef LWA_ALPHA
  #define LWA_ALPHA 2
  #endif

Take a look at other potential redefinition on the sources to see
what's usually done.

Another thing: you could easily extend the functions to deal with any
frame, for example:

  (defun set-active-alpha (alpha &optional frame)
    "Set the opacity of FRAME in active state to ALPHA.
ALPHA can take a value between 0.0 (invisible) and 1.0 (completely opaque).
When called interactively, prompt for the value of the opacity to set.
FRAME defaults to the selected frame.  To get the frame's current
active alpha value state, use `frame-parameters'."
    (interactive "nActive alpha (0.0 - 1.0): ")
    (when (or (< alpha 0.0) (> alpha 1.0))
      (error "Alpha value must be between 0.0 and 1.0, inclusive"))
    (modify-frame-parameters frame
                             (list (cons 'active-alpha alpha))))

> >>  - Better still would be to document what the ALPHA-VALUE is and what
> >> is its range (0.0 to 1.0, I assume, but it is not said anywhere).

In the function below you'll see I've reworded slightly the docstring
regarding the range of ALPHA. (I've also added error checking.)

> > wraparound. It'd be better to restrict the values entered to the
> > correct range.
> Both done.

I would have expected that entering 1.1 would produce an error. I
think it is better to do it at the frame.el level, but that depends on
who/how x_set_(active|inactive|frame)_alpha are going to be used. BTW,
I've not checked but, do the C functions need to be exported by
frame.h? It seems like they could be static.

> Could you check new patch.

I've checked it now on two-frame setups. When one frame is behind the
other and the cursor moves on the foreground frame, there's some
unexpected redisplay caused by the background frame. Also, I've seen
one case of a 4NT.exe shell not redisplaying correctly after
minimizing a partially transparent Emacs frame, but that could be a
4NT problem.

All in all, I find the feature interesting, although obviously
post-22.1 stuff (at least IMO).

-- 
                    /L/e/k/t/u

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Mac OS X] [Win32] Frame-transparency patch
  2005-06-20 21:58         ` Juanma Barranquero
  2005-06-20 22:00           ` Juanma Barranquero
  2005-06-21 11:18           ` Takashi Hiromatsu
@ 2005-06-21 16:23           ` Kevin Rodgers
  2 siblings, 0 replies; 12+ messages in thread
From: Kevin Rodgers @ 2005-06-21 16:23 UTC (permalink / raw)


Juanma Barranquero wrote:
 >  - Also, capitalize the interactive messages "active alpha: " and
 > "inactive alpha: " to "Active alpha: " and "Inactive alpha: " (it's
 > customary on interactive prompt).

Why not an actual alpha character?  :-)

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Mac OS X] [Win32] Frame-transparency patch
  2005-06-21 15:29             ` Juanma Barranquero
@ 2005-06-27 11:38               ` Takashi Hiromatsu
  0 siblings, 0 replies; 12+ messages in thread
From: Takashi Hiromatsu @ 2005-06-27 11:38 UTC (permalink / raw)
  Cc: Juanma Barranquero, macemacs-dev

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

New patch is attached.

In this patch.

    Lisp functions are modified. Add frame object as optional arguments.
        (set-(in)active-alpha alpha &optional frame)

    Parmeter check routines are added.

    Although non-highlighted frame, inactive-alpha value is reflected
    immediately

Thank you, Juanma Barranquero, for your many advices.

T.Hiromatsu


[-- Attachment #2: transparency2.patch --]
[-- Type: application/octet-stream, Size: 13252 bytes --]

--- lisp/frame.el.orig_t	2005-06-25 06:27:47.000000000 +0900
+++ lisp/frame.el	2005-06-25 06:28:20.000000000 +0900
@@ -927,6 +927,30 @@
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'border-color color-name))))
 
+(when (memq system-type '(windows-nt darwin))
+  (defun set-active-alpha (alpha &optional frame)
+    "Set the opacity of FRAME in active state to ALPHA. A floating-point
+parameter ALPHA should range from 0.0 (invisible) to 1.0 (completely opaque).
+When called interactively, prompt for the value of the opacity to set.
+FRAME defaults to the selected frame.  To get the frame's current
+active alpha value state, use `frame-parameters'."
+    (interactive "nActive alpha (0.0 - 1.0): ")
+    (when (or (< alpha 0.0) (> alpha 1.0))
+      (error "Alpha value must be between 0.0 and 1.0, inclusive"))
+    (modify-frame-parameters frame
+                             (list (cons 'active-alpha alpha))))
+  (defun set-inactive-alpha (alpha &optional frame)
+    "Set the opacity of FRAME in active state to ALPHA. A floating-point
+parameter ALPHA should range from 0.0 (invisible) to 1.0 (completely opaque).
+When called interactively, prompt for the value of the opacity to set.
+FRAME defaults to the selected frame.  To get the frame's current
+inactive alpha value state, use `frame-parameters'."
+    (interactive "nInactive alpha (0.0 - 1.0): ")
+    (when (or (< alpha 0.0) (> alpha 1.0))
+      (error "Alpha value must be between 0.0 and 1.0, inclusive"))
+    (modify-frame-parameters frame
+                             (list (cons 'inactive-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.
--- src/frame.c.orig_t	2005-06-25 06:27:47.000000000 +0900
+++ src/frame.c	2005-06-25 06:28:21.000000000 +0900
@@ -106,6 +106,10 @@
 Lisp_Object Qleft_fringe, Qright_fringe;
 Lisp_Object Qbuffer_predicate, Qbuffer_list;
 Lisp_Object Qtty_color_mode;
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+Lisp_Object Qactive_alpha;
+Lisp_Object Qinactive_alpha;
+#endif
 
 Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
 
@@ -2581,6 +2585,10 @@
   {"right-fringe",		&Qright_fringe},
   {"wait-for-wm",		&Qwait_for_wm},
   {"fullscreen",                &Qfullscreen},
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  {"active-alpha",		&Qactive_alpha},
+  {"inactive-alpha",		&Qinactive_alpha},
+#endif
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
--- src/frame.h.orig_t	2005-06-25 06:27:47.000000000 +0900
+++ src/frame.h	2005-06-25 06:28:21.000000000 +0900
@@ -451,6 +451,11 @@
   /* Additional space to put between text lines on this frame.  */
   int extra_line_spacing;
 
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+  /* Opacity of the Frame, which should be a number between 0.0 and 1.0  */
+  float active_alpha, inactive_alpha;
+#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;
@@ -1003,6 +1008,10 @@
 extern Lisp_Object Qline_spacing;
 extern Lisp_Object Qwait_for_wm;
 extern Lisp_Object Qfullscreen;
+#if defined (HAVE_CARBON) || defined (WINDOWSNT)
+extern Lisp_Object Qactive_alpha;
+extern Lisp_Object Qinactive_alpha;
+#endif
 
 extern Lisp_Object Qleft_fringe, Qright_fringe;
 extern Lisp_Object Qheight, Qwidth;
--- src/macfns.c.orig_t	2005-06-25 06:27:47.000000000 +0900
+++ src/macfns.c	2005-06-25 09:58:37.000000000 +0900
@@ -302,6 +302,8 @@
 
 extern void mac_get_window_bounds P_ ((struct frame *, Rect *, Rect *));
 
+extern void x_set_frame_alpha P_ ((struct frame *, int));
+
 /* Store the screen positions of frame F into XPTR and YPTR.
    These are the positions of the containing window manager window,
    not Emacs's own window.  */
@@ -2026,6 +2028,82 @@
 #endif /* not MAC_OSX */
 }
 
+/* Change the opacity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible if ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+static void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
+
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if ((XFLOAT_DATA (alpha) < 0.0) || (XFLOAT_DATA (alpha) > 1.0))
+    {
+      f->active_alpha = XFLOAT_DATA (old_alpha);
+      return;
+    }
+
+  if (FLOATP (alpha))
+    {
+      f->active_alpha = XFLOAT_DATA (alpha);
+
+#if TARGET_API_MAC_CARBON
+      BLOCK_INPUT;
+
+      if(dpyinfo->x_highlight_frame == f)
+        {
+          x_set_frame_alpha (f, 1);
+        }
+
+      UNBLOCK_INPUT;
+#endif
+    }
+
+  return;
+}
+
+static void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
+
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if ((XFLOAT_DATA (alpha) < 0.0) || (XFLOAT_DATA (alpha) > 1.0))
+    {
+      f->inactive_alpha = XFLOAT_DATA (old_alpha);
+      return;
+    }
+
+  if (FLOATP (alpha))
+    {
+      f->inactive_alpha = XFLOAT_DATA (alpha);
+      if(dpyinfo->x_highlight_frame != f)
+        {
+          x_set_frame_alpha (f, 0);
+        }
+    }
+
+  return;
+}
 \f
 /* Subroutines of creating a frame.  */
 
@@ -2736,6 +2814,10 @@
   x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth",
 		       RES_TYPE_NUMBER);
+  x_default_parameter (f, parms, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parms, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -4445,6 +4527,8 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+  x_set_active_alpha,
+  x_set_inactive_alpha,
 };
 
 void
--- src/macterm.c.orig_t	2005-06-25 06:27:47.000000000 +0900
+++ src/macterm.c	2005-06-25 09:58:38.000000000 +0900
@@ -1771,6 +1771,23 @@
   return FONT_TYPE_UNKNOWN;
 }
 
+void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  SInt32 response;
+  OSErr err;
+
+  BLOCK_INPUT;
+  err = Gestalt (gestaltSystemVersion, &response);
+  UNBLOCK_INPUT;
+
+  if ((err == noErr) && (response >= 0x1020)) {
+    SetWindowAlpha (f->output_data.mac->mWP,
+                    activate_p? f->active_alpha: f->inactive_alpha);
+  }
+}
 
 \f
 /***********************************************************************
@@ -3493,6 +3510,7 @@
     ActivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 1);
 }
 
 static void
@@ -3508,6 +3526,7 @@
     DeactivateControl (root_control);
   UNBLOCK_INPUT;
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 0);
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
--- src/w32fns.c.orig_t	2005-06-25 06:27:47.000000000 +0900
+++ src/w32fns.c	2005-06-25 09:56:21.000000000 +0900
@@ -70,6 +70,8 @@
 
 extern char *lispy_function_keys[];
 
+extern void x_set_frame_alpha P_ ((struct frame *, int));
+
 /* The gray bitmap `bitmaps/gray'.  This is done because w32term.c uses
    it, and including `bitmaps/gray' more than once is a problem when
    config.h defines `static' as an empty replacement string.  */
@@ -262,6 +264,7 @@
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
 ClipboardSequence_Proc clipboard_sequence_fn = NULL;
 extern AppendMenuW_Proc unicode_append_menu;
+extern SetLayeredWindowAttributes_Proc set_layered_window_attributes_fn;
 
 /* W95 mousewheel handler */
 unsigned int msh_mousewheel = 0;
@@ -1978,6 +1981,80 @@
 				      wid - 1) / wid;
 }
 
+/* Change the opacity of frame F to ALPHA.
+   ALPHA must be a number between 0.0 and 1.0
+
+   The frame will become completely invisible if ALPHA is 0.0,
+   while the value of 1.0 makes it completely opaque.  */
+
+static void
+x_set_active_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
+
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->active_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if ((XFLOAT_DATA (alpha) < 0.0) || (XFLOAT_DATA (alpha) > 1.0))
+    {
+      f->active_alpha = XFLOAT_DATA (old_alpha);
+      return;
+    }
+
+  if (FLOATP (alpha))
+    {
+      f->active_alpha = XFLOAT_DATA (alpha);
+
+      BLOCK_INPUT;
+
+      if(dpyinfo->x_highlight_frame == f)
+        {
+          x_set_frame_alpha (f, 1);
+        }
+
+      UNBLOCK_INPUT;
+    }
+
+  return;
+}
+
+static void
+x_set_inactive_alpha (f, alpha, old_alpha)
+     struct frame *f;
+     Lisp_Object alpha, old_alpha;
+{
+  struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
+
+  /* Don't change the alpha if it's already ALPHA.  */
+  if (EQ (alpha, f->inactive_alpha))
+    return;
+
+  if (NILP (alpha))
+    return;
+
+  if ((XFLOAT_DATA (alpha) < 0.0) || (XFLOAT_DATA (alpha) > 1.0))
+    {
+      f->inactive_alpha = XFLOAT_DATA (old_alpha);
+      return;
+    }
+
+  if (FLOATP (alpha))
+    {
+      f->inactive_alpha = XFLOAT_DATA (alpha);
+      if(dpyinfo->x_highlight_frame != f)
+        {
+          x_set_frame_alpha (f, 0);
+        }
+    }
+
+  return;
+}
 \f
 /* Subroutines of creating a frame.  */
 
@@ -4321,6 +4398,10 @@
 		       "cursorType", "CursorType", RES_TYPE_SYMBOL);
   x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
 		       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
+  x_default_parameter (f, parameters, Qactive_alpha, make_float(1.0),
+		       "activeAlpha", "ActiveAlpha", RES_TYPE_FLOAT);
+  x_default_parameter (f, parameters, Qinactive_alpha, make_float(1.0),
+		       "inactiveAlpha", "InactiveAlpha", RES_TYPE_FLOAT);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -8473,6 +8554,8 @@
   x_set_fringe_width,
   0, /* x_set_wait_for_wm, */
   x_set_fullscreen,
+  x_set_active_alpha,
+  x_set_inactive_alpha,
 };
 
 void
@@ -8912,6 +8995,9 @@
   /* ditto for GetClipboardSequenceNumber.  */
   clipboard_sequence_fn = (ClipboardSequence_Proc)
     GetProcAddress (user32_lib, "GetClipboardSequenceNumber");
+  /* ditto for SetLayeredWindowAttributes.  */
+  set_layered_window_attributes_fn = (SetLayeredWindowAttributes_Proc)
+    GetProcAddress (user32_lib, "SetLayeredWindowAttributes");
 
   DEFVAR_INT ("w32-ansi-code-page",
 	      &w32_ansi_code_page,
--- src/w32term.c.orig_t	2005-06-25 06:27:47.000000000 +0900
+++ src/w32term.c	2005-06-25 06:28:21.000000000 +0900
@@ -272,6 +272,8 @@
 
 static Lisp_Object Qvendor_specific_keysyms;
 
+SetLayeredWindowAttributes_Proc set_layered_window_attributes_fn = NULL;
+
 \f
 /***********************************************************************
 			      Debugging
@@ -1187,6 +1189,25 @@
     return ANSI_FONT;
 }
 
+void
+x_set_frame_alpha (f, activate_p)
+     struct frame *f;
+     int activate_p;
+{
+  Window window = FRAME_W32_WINDOW (f);
+
+  if (set_layered_window_attributes_fn != NULL) {
+    SetWindowLong (window, GWL_EXSTYLE,
+                   GetWindowLong (window, GWL_EXSTYLE)|WS_EX_LAYERED);
+    set_layered_window_attributes_fn (FRAME_W32_WINDOW (f),
+                                      RGB(255, 255, 255),
+                                      (int)((activate_p?
+                                             f->active_alpha:
+                                             f->inactive_alpha)
+                                            * 255.0),
+                                      LWA_ALPHA);
+  }
+}
 
 \f
 /***********************************************************************
@@ -2786,6 +2807,7 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 1);
 }
 
 static void
@@ -2793,6 +2815,7 @@
      struct frame *f;
 {
   x_update_cursor (f, 1);
+  x_set_frame_alpha (f, 0);
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
--- src/w32term.h.orig_t	2005-06-25 06:27:47.000000000 +0900
+++ src/w32term.h	2005-06-25 06:29:12.000000000 +0900
@@ -643,6 +643,14 @@
 
 #define WND_EXTRA_BYTES     (WND_LAST_INDEX)
 
+/* for transparency functions */
+#ifndef LWA_ALPHA
+#define LWA_ALPHA 2
+#endif
+#ifndef WS_EX_LAYERED
+#define WS_EX_LAYERED 0x80000   /* w2k */
+#endif
+
 extern DWORD dwWindowsThreadId;
 extern HANDLE hWindowsThread;
 extern DWORD dwMainThreadId;
@@ -755,6 +763,8 @@
       ? BDF_1D_FONT : BDF_2D_FONT))
 
 typedef DWORD (WINAPI * ClipboardSequence_Proc) ();
+typedef DWORD (WINAPI * SetLayeredWindowAttributes_Proc)
+  (HWND, DWORD, BYTE, DWORD);
 typedef BOOL (WINAPI * AppendMenuW_Proc) (
     IN HMENU,
     IN UINT,

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-06-27 11:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-11  8:02 [Mac OS X] [Win32] Frame-transparency patch Seiji Zenitani
2005-06-14 16:57 ` [Macemacsjp-dev 100] " Seiji Zenitani
2005-06-16 16:59   ` [Macemacsjp-dev 103] " Seiji Zenitani
2005-06-17 20:56   ` [Macemacsjp-dev 100] " Michael Mauger
2005-06-18  0:28     ` Takashi Hiromatsu
2005-06-20 20:36       ` Takashi Hiromatsu
2005-06-20 21:58         ` Juanma Barranquero
2005-06-20 22:00           ` Juanma Barranquero
2005-06-21 11:18           ` Takashi Hiromatsu
2005-06-21 15:29             ` Juanma Barranquero
2005-06-27 11:38               ` Takashi Hiromatsu
2005-06-21 16:23           ` Kevin Rodgers

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).