unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* frame transparency for Cocoa
@ 2008-11-24  4:11 Seiji Zenitani
  2008-11-24  8:39 ` Yavor Doganov
  0 siblings, 1 reply; 4+ messages in thread
From: Seiji Zenitani @ 2008-11-24  4:11 UTC (permalink / raw)
  To: emacs-devel

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

Hi,

Here is a frame-wide transparency code for Cocoa port.
The syntax is the same as X port and w32 port.

As far as I tested, this one seamlessly coexists with
NS port's face-transparency (e.g. ns-set-background-alpha) on OSX 10.5.
Could anyone test the compatibility with GNUstep?
(It should do nothing on GNUstep.)

best wishes,
Seiji



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

Index: src/frame.c
===================================================================
RCS file: /sources/emacs/emacs/src/frame.c,v
retrieving revision 1.398
diff -u -r1.398 frame.c
--- src/frame.c	12 Nov 2008 15:52:12 -0000	1.398
+++ src/frame.c	23 Nov 2008 22:17:00 -0000
@@ -3678,7 +3678,7 @@
   for (i = 0; i < 2; i++)
     f->alpha[i] = newval[i];
 
-#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
+#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
   BLOCK_INPUT;
   x_set_frame_alpha (f);
   UNBLOCK_INPUT;
Index: src/nsfns.m
===================================================================
RCS file: /sources/emacs/emacs/src/nsfns.m,v
retrieving revision 1.26
diff -u -r1.26 nsfns.m
--- src/nsfns.m	22 Oct 2008 12:51:30 -0000	1.26
+++ src/nsfns.m	23 Nov 2008 22:17:00 -0000
@@ -1037,7 +1037,7 @@
   0, /* x_set_wait_for_wm, will ignore */
   0,  /* x_set_fullscreen will ignore */
   x_set_font_backend, /* generic OK */
-  0
+  x_set_alpha
 };
 
 
Index: src/nsterm.m
===================================================================
RCS file: /sources/emacs/emacs/src/nsterm.m,v
retrieving revision 1.35
diff -u -r1.35 nsterm.m
--- src/nsterm.m	15 Nov 2008 05:20:49 -0000	1.35
+++ src/nsterm.m	23 Nov 2008 22:17:01 -0000
@@ -957,9 +957,15 @@
          dpyinfo->x_highlight_frame != old_highlight)
     {
       if (old_highlight)
+	{
           x_update_cursor (old_highlight, 1);
+	  x_set_frame_alpha (old_highlight);
+	}
       if (dpyinfo->x_highlight_frame)
+	{
           x_update_cursor (dpyinfo->x_highlight_frame, 1);
+          x_set_frame_alpha (dpyinfo->x_highlight_frame);
+	}
     }
 }
 
@@ -1603,6 +1609,39 @@
 }
 
 
+void
+x_set_frame_alpha (struct frame *f)
+/* --------------------------------------------------------------------------
+     Experimental: 
+   -------------------------------------------------------------------------- */
+{
+  struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+  EmacsView *view = FRAME_NS_VIEW (f);
+  double alpha = 1.0;
+  double alpha_min = 1.0;
+
+  if (dpyinfo->x_highlight_frame == f)
+    alpha = f->alpha[0];
+  else
+    alpha = f->alpha[1];
+
+  if (FLOATP (Vframe_alpha_lower_limit))
+    alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit);
+  else if (INTEGERP (Vframe_alpha_lower_limit))
+    alpha_min = (XINT (Vframe_alpha_lower_limit)) / 100.0;
+
+  if (alpha < 0.0)
+    return;
+  else if (1.0 < alpha)
+    alpha = 1.0;
+  else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0)
+    alpha = alpha_min;
+  
+#ifdef NS_IMPL_COCOA
+  [[view window] setAlphaValue: alpha];
+#endif
+}
+
 
 /* ==========================================================================
 
@@ -4957,7 +4996,10 @@
   /* FIXME: for some reason needed on second and subsequent clicks away
             from sole-frame Emacs to get hollow box to show */
   if (!windowClosing && [[self window] isVisible] == YES)
-    x_update_cursor (emacsframe, 1);
+    {
+      x_update_cursor (emacsframe, 1);
+      x_set_frame_alpha (emacsframe);
+    }
 
   if (emacs_event)
     {

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




2008-11-23  Seiji Zenitani  <zenitani@mac.com>

	* frame.c (x_set_alpha) [NS_IMPL_COCOA]: Call x_set_frame_alpha.

	* nsfns.m (ns_frame_parm_handlers): Set alpha handler.

	* nsterm.m (x_set_frame_alpha): New function.


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

* Re: frame transparency for Cocoa
  2008-11-24  4:11 frame transparency for Cocoa Seiji Zenitani
@ 2008-11-24  8:39 ` Yavor Doganov
  2008-11-24 15:59   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Yavor Doganov @ 2008-11-24  8:39 UTC (permalink / raw)
  To: emacs-devel

Seiji Zenitani wrote:
> 
> (It should do nothing on GNUstep.)

In this case such a change should not be installed.





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

* Re: frame transparency for Cocoa
  2008-11-24  8:39 ` Yavor Doganov
@ 2008-11-24 15:59   ` Stefan Monnier
  2008-11-25  8:57     ` Yavor Doganov
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2008-11-24 15:59 UTC (permalink / raw)
  To: emacs-devel

>> (It should do nothing on GNUstep.)
> In this case such a change should not be installed.

I'm not sure why you'd think so.  It'd be better if it also worked under
GNUstep, of course.  But this code brings to Cocoa a feature that
already exists under X11, which sounds fine to me.


        Stefan




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

* Re: frame transparency for Cocoa
  2008-11-24 15:59   ` Stefan Monnier
@ 2008-11-25  8:57     ` Yavor Doganov
  0 siblings, 0 replies; 4+ messages in thread
From: Yavor Doganov @ 2008-11-25  8:57 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier wrote:
> 
> But this code brings to Cocoa a feature that already exists under
> X11, which sounds fine to me.

I didn't know that such a feature existed.




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

end of thread, other threads:[~2008-11-25  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-24  4:11 frame transparency for Cocoa Seiji Zenitani
2008-11-24  8:39 ` Yavor Doganov
2008-11-24 15:59   ` Stefan Monnier
2008-11-25  8:57     ` Yavor Doganov

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