svnno****@sourc*****
svnno****@sourc*****
2007年 7月 6日 (金) 06:29:06 JST
Revision: 507 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=macemacsjp&view=rev&rev=507 Author: zenitani Date: 2007-07-06 06:29:06 +0900 (Fri, 06 Jul 2007) Log Message: ----------- code cleanup Modified Paths: -------------- transparency3/trunk/ChangeLog transparency3/trunk/transparency3.patch -------------- next part -------------- Modified: transparency3/trunk/ChangeLog =================================================================== --- transparency3/trunk/ChangeLog 2007-07-01 00:47:12 UTC (rev 506) +++ transparency3/trunk/ChangeLog 2007-07-05 21:29:06 UTC (rev 507) @@ -1,3 +1,7 @@ +2007-07-05 Seiji Zenitani <zenit****@mac*****> + + * code cleanup + 2007-06-27 Seiji Zenitani <zenit****@mac*****> * xfns.c: 中山さん <yoich****@geiin*****> の GTK 対応の修正を追加。 Modified: transparency3/trunk/transparency3.patch =================================================================== --- transparency3/trunk/transparency3.patch 2007-07-01 00:47:12 UTC (rev 506) +++ transparency3/trunk/transparency3.patch 2007-07-05 21:29:06 UTC (rev 507) @@ -1,5 +1,5 @@ ---- ../emacs.orig/lisp/frame.el 2007-01-22 12:09:12.000000000 +0900 -+++ lisp/frame.el 2007-02-18 16:41:32.000000000 +0900 +--- ../emacs-22.1.orig/lisp/frame.el 2007-01-20 22:53:11.000000000 -0500 ++++ lisp/frame.el 2007-07-01 20:07:53.000000000 -0400 @@ -931,6 +931,16 @@ (modify-frame-parameters (selected-frame) (list (cons 'border-color color-name)))) @@ -17,8 +17,8 @@ (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. ---- ../emacs.orig/src/frame.c 2007-02-17 13:09:37.000000000 +0900 -+++ src/frame.c 2007-02-18 16:41:32.000000000 +0900 +--- ../emacs-22.1.orig/src/frame.c 2007-02-19 20:56:11.000000000 -0500 ++++ src/frame.c 2007-07-01 20:07:53.000000000 -0400 @@ -105,6 +105,7 @@ Lisp_Object Qleft_fringe, Qright_fringe; Lisp_Object Qbuffer_predicate, Qbuffer_list; @@ -35,8 +35,8 @@ }; #ifdef HAVE_WINDOW_SYSTEM ---- ../emacs.orig/src/frame.h 2007-01-22 12:10:21.000000000 +0900 -+++ src/frame.h 2007-02-18 16:41:32.000000000 +0900 +--- ../emacs-22.1.orig/src/frame.h 2007-01-20 23:18:16.000000000 -0500 ++++ src/frame.h 2007-07-01 20:07:53.000000000 -0400 @@ -453,6 +453,9 @@ /* Additional space to put between text lines on this frame. */ int extra_line_spacing; @@ -70,8 +70,8 @@ extern Lisp_Object Qleft_fringe, Qright_fringe; extern Lisp_Object Qheight, Qwidth; ---- ../emacs.orig/src/macfns.c 2007-02-14 13:09:24.000000000 +0900 -+++ src/macfns.c 2007-02-18 16:41:32.000000000 +0900 +--- ../emacs-22.1.orig/src/macfns.c 2007-03-26 22:31:40.000000000 -0400 ++++ src/macfns.c 2007-07-01 20:07:53.000000000 -0400 @@ -56,6 +56,7 @@ /* Carbon version info */ @@ -89,8 +89,8 @@ /* 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. */ -@@ -1909,6 +1912,79 @@ - #endif /* not MAC_OSX */ +@@ -1886,6 +1889,79 @@ + x_set_name_internal (f, name); } +/* Change the opacity of frame F to ALPHA. @@ -167,9 +167,9 @@ +} + void - mac_set_scroll_bar_width (f, arg, oldval) + x_set_scroll_bar_default_width (f) struct frame *f; -@@ -2778,6 +2854,8 @@ +@@ -2760,6 +2836,8 @@ x_default_parameter (f, parms, Qscroll_bar_width, Qnil, "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); @@ -178,7 +178,7 @@ /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. Change will not be effected unless different from the current -@@ -4691,6 +4769,7 @@ +@@ -4677,6 +4755,7 @@ x_set_fringe_width, 0, /* x_set_wait_for_wm, */ x_set_fullscreen, @@ -186,7 +186,7 @@ }; void -@@ -4821,6 +4900,12 @@ +@@ -4807,6 +4886,12 @@ } #endif /* TARGET_API_MAC_CARBON */ @@ -199,9 +199,9 @@ /* X window properties. */ defsubr (&Sx_change_window_property); defsubr (&Sx_delete_window_property); ---- ../emacs.orig/src/macterm.c 2007-02-14 13:09:24.000000000 +0900 -+++ src/macterm.c 2007-02-18 16:41:32.000000000 +0900 -@@ -2541,6 +2541,29 @@ +--- ../emacs-22.1.orig/src/macterm.c 2007-05-25 08:43:34.000000000 -0400 ++++ src/macterm.c 2007-07-01 20:07:53.000000000 -0400 +@@ -2540,6 +2540,29 @@ return FONT_TYPE_UNKNOWN; } @@ -231,7 +231,7 @@ /*********************************************************************** -@@ -4261,6 +4284,7 @@ +@@ -4260,6 +4283,7 @@ ActivateControl (root_control); UNBLOCK_INPUT; x_update_cursor (f, 1); @@ -239,7 +239,7 @@ } static void -@@ -4276,6 +4300,7 @@ +@@ -4275,6 +4299,7 @@ DeactivateControl (root_control); UNBLOCK_INPUT; x_update_cursor (f, 1); @@ -247,28 +247,36 @@ } /* The focus has changed. Update the frames as necessary to reflect ---- ../emacs.orig/src/xfns.c 2007-01-22 12:10:27.000000000 +0900 -+++ src/xfns.c 2007-02-18 16:41:32.000000000 +0900 -@@ -64,6 +64,8 @@ - #include "[.bitmaps]gray.xbm" - #endif +--- ../emacs-22.1.orig/src/w32fns.c 2007-03-24 11:49:48.000000000 -0400 ++++ src/w32fns.c 2007-07-01 20:07:54.000000000 -0400 +@@ -56,6 +56,8 @@ + #include <dlgs.h> + #define FILE_NAME_TEXT_FIELD edt1 +static int frame_alpha_lower_limit; + - #ifdef USE_GTK - #include "gtkutil.h" - #endif -@@ -565,6 +567,8 @@ - Lisp_Object, - char *, char *, - int)); + void syms_of_w32fns (); + void globals_of_w32fns (); + +@@ -70,6 +72,8 @@ + + extern char *lispy_function_keys[]; + +extern void x_set_frame_alpha P_ ((struct frame *)); + - + /* 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 +266,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; - /* Store the screen positions of frame F into XPTR and YPTR. -@@ -1801,6 +1805,73 @@ - #endif + /* W95 mousewheel handler */ + unsigned int msh_mousewheel = 0; +@@ -1982,6 +1987,72 @@ + wid - 1) / wid; } +/* Change the opacity of frame F to ALPHA. @@ -337,58 +345,68 @@ + + return; +} -+ - /* Record in frame F the specified or default value according to ALIST - of the parameter named PROP (a Lisp symbol). If no value is -@@ -3356,6 +3427,8 @@ - x_default_parameter (f, parms, Qscroll_bar_width, Qnil, - "scrollBarWidth", "ScrollBarWidth", - RES_TYPE_NUMBER); -+ x_default_parameter (f, parms, Qalpha, Qnil, + /* Subroutines of creating a frame. */ + +@@ -4392,6 +4463,8 @@ + "cursorType", "CursorType", RES_TYPE_SYMBOL); + x_default_parameter (f, parameters, Qscroll_bar_width, Qnil, + "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); ++ x_default_parameter (f, parameters, Qalpha, Qnil, + "alpha", "Alpha", RES_TYPE_NUMBER); /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. Change will not be effected unless different from the current -@@ -5737,6 +5810,7 @@ +@@ -8593,6 +8666,7 @@ x_set_fringe_width, - x_set_wait_for_wm, + 0, /* x_set_wait_for_wm, */ x_set_fullscreen, + x_set_alpha, }; void -@@ -5905,6 +5979,10 @@ +@@ -8956,6 +9030,10 @@ } - #endif /* USE_GTK */ + #endif + DEFVAR_INT ("frame-alpha-lower-limit", &frame_alpha_lower_limit, + doc: /* Lower limit of alpha value of frame. */); + frame_alpha_lower_limit = 20; + - /* X window properties. */ + #if 0 /* TODO: Port to W32 */ defsubr (&Sx_change_window_property); defsubr (&Sx_delete_window_property); ---- ../emacs.orig/src/xterm.c 2007-02-15 13:10:24.000000000 +0900 -+++ src/xterm.c 2007-02-18 16:41:32.000000000 +0900 -@@ -951,6 +951,59 @@ - return FONT_TYPE_UNKNOWN; - } +@@ -9055,6 +9133,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"); -+#define OPAQUE 0xffffffff -+#define OPACITY "_NET_WM_WINDOW_OPACITY" + DEFVAR_INT ("w32-ansi-code-page", + &w32_ansi_code_page, +--- ../emacs-22.1.orig/src/w32term.c 2007-02-19 09:45:39.000000000 -0500 ++++ src/w32term.c 2007-07-01 20:07:54.000000000 -0400 +@@ -260,6 +260,8 @@ + + static Lisp_Object Qvendor_specific_keysyms; + ++SetLayeredWindowAttributes_Proc set_layered_window_attributes_fn = NULL; + + + /*********************************************************************** + Debugging +@@ -1191,6 +1193,30 @@ + return ANSI_FONT; + } + +void +x_set_frame_alpha (f) + struct frame *f; +{ -+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); -+ Display *dpy = FRAME_X_DISPLAY (f); -+ Window win = FRAME_OUTER_WINDOW (f); -+ if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc) -+ /* Since the WM decoration lies under the FRAME_OUTER_WINDOW, -+ we must treat the former instead of the latter. */ -+ win = FRAME_X_OUTPUT(f)->parent_desc; ++ struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); ++ Window window = FRAME_W32_WINDOW (f); + + double alpha = 1.0; + @@ -398,85 +416,82 @@ + alpha = f->alpha[1] / 100.0; + if (alpha < 0.0) alpha = 1.0; + -+ unsigned int opac = (unsigned int)(alpha * OPAQUE); -+ -+ /* Courtesy of Nakayama-san [Macemacsjp-users 1211] */ -+ { -+ unsigned char *data; -+ Atom actual; -+ int format; -+ unsigned long n, left; -+ -+ XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False), -+ 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, -+ (unsigned char **) &data); -+ if (data != None) -+ if (*(unsigned int *)data == opac) -+ { -+ XFree ((void *) data); -+ return; -+ } -+ else -+ { -+ XFree ((void *) data); -+ } ++ 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)(alpha * 255.0), ++ LWA_ALPHA); + } -+ /****/ -+ -+ XChangeProperty (dpy, win, XInternAtom (dpy, OPACITY, False), -+ XA_CARDINAL, 32, PropModeReplace, -+ (unsigned char *) &opac, 1L); -+ XSync (dpy, False); +} /*********************************************************************** -@@ -3152,6 +3204,7 @@ - f->output_data.x->border_pixel); - UNBLOCK_INPUT; +@@ -2820,6 +2846,7 @@ + struct frame *f; + { x_update_cursor (f, 1); + x_set_frame_alpha (f); } static void -@@ -3167,6 +3220,7 @@ - f->output_data.x->border_tile); - UNBLOCK_INPUT; +@@ -2827,6 +2854,7 @@ + struct frame *f; + { x_update_cursor (f, 1); + x_set_frame_alpha (f); } /* The focus has changed. Update the frames as necessary to reflect ---- ../emacs.orig/src/w32fns.c 2007-01-22 12:10:26.000000000 +0900 -+++ src/w32fns.c 2007-02-18 16:41:32.000000000 +0900 -@@ -56,6 +56,8 @@ - #include <dlgs.h> - #define FILE_NAME_TEXT_FIELD edt1 +--- ../emacs-22.1.orig/src/w32term.h 2007-02-22 17:50:15.000000000 -0500 ++++ src/w32term.h 2007-07-01 20:07:54.000000000 -0400 +@@ -638,6 +638,14 @@ -+static int frame_alpha_lower_limit; + #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 + - void syms_of_w32fns (); - void globals_of_w32fns (); + extern DWORD dwWindowsThreadId; + extern HANDLE hWindowsThread; + extern DWORD dwMainThreadId; +@@ -750,6 +758,8 @@ + ? BDF_1D_FONT : BDF_2D_FONT)) -@@ -70,6 +72,8 @@ + typedef DWORD (WINAPI * ClipboardSequence_Proc) (); ++typedef DWORD (WINAPI * SetLayeredWindowAttributes_Proc) ++ (HWND, DWORD, BYTE, DWORD); + typedef BOOL (WINAPI * AppendMenuW_Proc) ( + IN HMENU, + IN UINT, +--- ../emacs-22.1.orig/src/xfns.c 2007-06-02 00:00:11.000000000 -0400 ++++ src/xfns.c 2007-07-01 20:07:54.000000000 -0400 +@@ -94,6 +94,8 @@ + #include <Xm/FileSB.h> + #endif - extern char *lispy_function_keys[]; ++static int frame_alpha_lower_limit; ++ + /* Do the EDITRES protocol if running X11R5 + Exception: HP-UX (at least version A.09.05) has X11R5 without EditRes */ +@@ -565,6 +567,8 @@ + Lisp_Object, + char *, char *, + int)); +extern void x_set_frame_alpha P_ ((struct frame *)); + - /* 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 +266,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 +1983,72 @@ - wid - 1) / wid; + /* Store the screen positions of frame F into XPTR and YPTR. +@@ -1817,6 +1821,73 @@ + #endif } +/* Change the opacity of frame F to ALPHA. @@ -545,68 +560,58 @@ + + return; +} ++ - /* Subroutines of creating a frame. */ - -@@ -4380,6 +4451,8 @@ - "cursorType", "CursorType", RES_TYPE_SYMBOL); - x_default_parameter (f, parameters, Qscroll_bar_width, Qnil, - "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); -+ x_default_parameter (f, parameters, Qalpha, Qnil, + /* Record in frame F the specified or default value according to ALIST + of the parameter named PROP (a Lisp symbol). If no value is +@@ -3372,6 +3443,8 @@ + x_default_parameter (f, parms, Qscroll_bar_width, Qnil, + "scrollBarWidth", "ScrollBarWidth", + RES_TYPE_NUMBER); ++ x_default_parameter (f, parms, Qalpha, Qnil, + "alpha", "Alpha", RES_TYPE_NUMBER); /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. Change will not be effected unless different from the current -@@ -8579,6 +8652,7 @@ +@@ -5755,6 +5828,7 @@ x_set_fringe_width, - 0, /* x_set_wait_for_wm, */ + x_set_wait_for_wm, x_set_fullscreen, + x_set_alpha, }; void -@@ -8942,6 +9016,10 @@ +@@ -5923,6 +5997,10 @@ } - #endif + #endif /* USE_GTK */ + DEFVAR_INT ("frame-alpha-lower-limit", &frame_alpha_lower_limit, + doc: /* Lower limit of alpha value of frame. */); + frame_alpha_lower_limit = 20; + - #if 0 /* TODO: Port to W32 */ + /* X window properties. */ defsubr (&Sx_change_window_property); defsubr (&Sx_delete_window_property); -@@ -9041,6 +9119,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, ---- ../emacs.orig/src/w32term.c 2007-01-22 12:10:26.000000000 +0900 -+++ src/w32term.c 2007-02-18 16:41:32.000000000 +0900 -@@ -259,6 +259,8 @@ - - static Lisp_Object Qvendor_specific_keysyms; - -+SetLayeredWindowAttributes_Proc set_layered_window_attributes_fn = NULL; -+ - - /*********************************************************************** - Debugging -@@ -1190,6 +1192,30 @@ - return ANSI_FONT; +--- ../emacs-22.1.orig/src/xterm.c 2007-05-25 08:43:35.000000000 -0400 ++++ src/xterm.c 2007-07-01 20:07:54.000000000 -0400 +@@ -953,6 +953,58 @@ + return FONT_TYPE_UNKNOWN; } ++#define OPAQUE 0xffffffff ++#define OPACITY "_NET_WM_WINDOW_OPACITY" ++ +void +x_set_frame_alpha (f) + struct frame *f; +{ -+ struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); -+ Window window = FRAME_W32_WINDOW (f); ++ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); ++ Display *dpy = FRAME_X_DISPLAY (f); ++ Window win = FRAME_OUTER_WINDOW (f); ++ if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc) ++ /* Since the WM decoration lies under the FRAME_OUTER_WINDOW, ++ we must treat the former instead of the latter. */ ++ win = FRAME_X_OUTPUT(f)->parent_desc; + + double alpha = 1.0; + @@ -616,57 +621,51 @@ + alpha = f->alpha[1] / 100.0; + if (alpha < 0.0) alpha = 1.0; + -+ 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)(alpha * 255.0), -+ LWA_ALPHA); ++ unsigned int opac = (unsigned int)(alpha * OPAQUE); ++ ++ /* return unless necessary */ ++ { ++ unsigned char *data; ++ Atom actual; ++ int format; ++ unsigned long n, left; ++ ++ XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False), ++ 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, ++ (unsigned char **) &data); ++ if (data != None) ++ if (*(unsigned int *)data == opac) ++ { ++ XFree ((void *) data); ++ return; ++ } ++ else ++ { ++ XFree ((void *) data); ++ } + } ++ ++ XChangeProperty (dpy, win, XInternAtom (dpy, OPACITY, False), ++ XA_CARDINAL, 32, PropModeReplace, ++ (unsigned char *) &opac, 1L); ++ XSync (dpy, False); +} /*********************************************************************** -@@ -2819,6 +2845,7 @@ - struct frame *f; - { +@@ -3154,6 +3207,7 @@ + f->output_data.x->border_pixel); + UNBLOCK_INPUT; x_update_cursor (f, 1); + x_set_frame_alpha (f); } static void -@@ -2826,6 +2853,7 @@ - struct frame *f; - { +@@ -3169,6 +3223,7 @@ + f->output_data.x->border_tile); + UNBLOCK_INPUT; x_update_cursor (f, 1); + x_set_frame_alpha (f); } /* The focus has changed. Update the frames as necessary to reflect ---- ../emacs.orig/src/w32term.h 2007-01-22 12:10:26.000000000 +0900 -+++ src/w32term.h 2007-02-18 16:41:32.000000000 +0900 -@@ -641,6 +641,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; -@@ -753,6 +761,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,