From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Takashi Hiromatsu Newsgroups: gmane.emacs.devel Subject: Re: [Mac OS X] [Win32] Frame-transparency patch Date: Tue, 21 Jun 2005 05:36:12 +0900 Message-ID: References: <47B1D513-959C-4F8E-8FD1-CCE29BFFB9D4@mac.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Tue_Jun_21_05:36:12_2005-1" X-Trace: sea.gmane.org 1119301129 22849 80.91.229.2 (20 Jun 2005 20:58:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2005 20:58:49 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 20 22:58:46 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DkTL3-000058-Vc for ged-emacs-devel@m.gmane.org; Mon, 20 Jun 2005 22:57:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DkTRL-00016s-Pm for ged-emacs-devel@m.gmane.org; Mon, 20 Jun 2005 17:04:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DkTPj-0000UG-S1 for emacs-devel@gnu.org; Mon, 20 Jun 2005 17:02:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DkTMA-0008Gd-Mw for emacs-devel@gnu.org; Mon, 20 Jun 2005 16:59:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DkTM7-00087Q-4Y for emacs-devel@gnu.org; Mon, 20 Jun 2005 16:58:55 -0400 Original-Received: from [202.238.82.8] (helo=mx08.ms.so-net.ne.jp) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DkT5o-00012y-U2 for emacs-devel@gnu.org; Mon, 20 Jun 2005 16:42:05 -0400 Original-Received: from localhost (kcc-202-43-28-144.kamakuranet.ne.jp [202.43.28.144]) by mx08.ms.so-net.ne.jp with ESMTP id j5KKdD2x011099 for ; Tue, 21 Jun 2005 05:39:13 +0900 (JST) Original-To: emacs-devel@gnu.org In-Reply-To: User-Agent: Wanderlust/2.15.1 (Almost Unreal) SEMI/1.14.6 (Maruoka) LIMIT/1.14.9 (Domyoji) APEL/10.6 Emacs/22.0.50 (powerpc-apple-darwin8.1.0) MULE/5.0 (SAKAKI) X-Dispatcher: imput version 20050308(IM148) Original-Lines: 399 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:39199 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:39199 --Multipart_Tue_Jun_21_05:36:12_2005-1 Content-Type: text/plain; charset=US-ASCII > 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 --Multipart_Tue_Jun_21_05:36:12_2005-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="transparency2.patch" Content-Transfer-Encoding: 7bit --- 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; +} /* 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); + } +} /*********************************************************************** @@ -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; +} /* 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; + /*********************************************************************** 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); + } +} /*********************************************************************** @@ -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, --Multipart_Tue_Jun_21_05:36:12_2005-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --Multipart_Tue_Jun_21_05:36:12_2005-1--