all messages for Emacs-related lists mirrored at yhetil.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

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