diff --git a/build-emacs-for-macos b/build-emacs-for-macos index a2b087b..c49a95f 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -1102,7 +1102,7 @@ class Build } end - if (27..31).include?(effective_version) + if (27..30).include?(effective_version) p << { url: 'https://github.com/d12frosted/homebrew-emacs-plus/raw/master/' \ @@ -1110,7 +1110,7 @@ class Build } end - if (29..31).include?(effective_version) + if (29..30).include?(effective_version) p << { url: 'https://github.com/d12frosted/homebrew-emacs-plus/raw/master/' \ @@ -1181,12 +1181,18 @@ class Build __dir__, 'patches', 'emacs-29', 'ns-alpha-background.patch' ) } - elsif (30..31).include?(effective_version) + elsif effective_version == 30 p << { url: "https://github.com/emacs-mirror/emacs/compare/#{meta[:sha]}" \ '...jonrubens:emacs:ns-alpha-background.patch' } + elsif effective_version == 31 + p << { + file: File.join( + __dir__, 'patches', 'emacs-31', 'ns-alpha-background.patch' + ) + } end end @@ -1211,7 +1217,7 @@ class Build fatal "\"#{target}\" does not exist." unless File.exist?(target) if patch[:file] - info 'Applying patch...' + info "Applying patch #{patch[:file]} in #{target}..." FileUtils.cd(target) do run_cmd('patch', '-f', '-p1', '-l', '-i', patch[:file]) end diff --git a/patches/emacs-31/ns-alpha-background.patch b/patches/emacs-31/ns-alpha-background.patch new file mode 100644 index 0000000..513be79 --- /dev/null +++ b/patches/emacs-31/ns-alpha-background.patch @@ -0,0 +1,168 @@ +diff -ur a/src/macfont.m b/src/macfont.m +--- a/src/macfont.m 2025-12-11 04:36:34 ++++ b/src/macfont.m 2025-12-11 10:21:09 +@@ -2994,9 +2994,14 @@ + CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face); + else + CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f); +- } ++ CGContextSetAlpha (context, 1); ++ } + else +- CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face); ++ { ++ CGContextSetAlpha (context, f->alpha_background); ++ CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face); ++ } ++ CGContextClearRect (context, background_rect); + CGContextFillRects (context, &background_rect, 1); + } + +@@ -3005,6 +3010,7 @@ + CGAffineTransform atfm; + + CGContextScaleCTM (context, 1, -1); ++ CGContextSetAlpha (context, 1); + if (s->hl == DRAW_CURSOR) + { + if (face && (NS_FACE_BACKGROUND (face) +diff -ur a/src/nsfns.m b/src/nsfns.m +--- a/src/nsfns.m 2025-12-11 04:36:34 ++++ b/src/nsfns.m 2025-12-11 10:25:21 +@@ -295,7 +295,7 @@ + struct face *face; + NSColor *col; + NSView *view = FRAME_NS_VIEW (f); +- EmacsCGFloat alpha; ++ EmacsCGFloat alpha = f->alpha_background; + + block_input (); + if (ns_lisp_to_color (arg, &col)) +@@ -310,11 +310,10 @@ + f->output_data.ns->background_color = col; + + FRAME_BACKGROUND_PIXEL (f) = [col unsignedLong]; +- alpha = [col alphaComponent]; + + if (view != nil) + { +- [[view window] setBackgroundColor: col]; ++ [[view window] setBackgroundColor: [col colorWithAlphaComponent: alpha]]; + + if (alpha != (EmacsCGFloat) 1.0) + [[view window] setOpaque: NO]; +@@ -324,10 +323,7 @@ + face = FRAME_DEFAULT_FACE (f); + if (face) + { +- col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]; +- face->background = [[col colorWithAlphaComponent: alpha] +- unsignedLong]; +- ++ face->background = [col unsignedLong]; + update_face_from_frame_parameter (f, Qbackground_color, arg); + } + +@@ -340,7 +336,37 @@ + unblock_input (); + } + ++static void ++ns_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval) ++{ ++ NSView *view = FRAME_NS_VIEW (f); ++ double alpha = 1.0; + ++ if (NILP (arg)) ++ alpha = 1.0; ++ else if (FLOATP (arg)) ++ { ++ alpha = XFLOAT_DATA (arg); ++ if (! (0 <= alpha && alpha <= 1.0)) ++ args_out_of_range (make_float (0.0), make_float (1.0)); ++ } ++ else if (FIXNUMP (arg)) ++ { ++ EMACS_INT ialpha = XFIXNUM (arg); ++ if (! (0 <= ialpha && ialpha <= 100)) ++ args_out_of_range (make_fixnum (0), make_fixnum (100)); ++ alpha = ialpha / 100.0; ++ } ++ else ++ wrong_type_argument (Qnumberp, arg); ++ ++ f->alpha_background = alpha; ++ [[view window] setBackgroundColor: [f->output_data.ns->background_color ++ colorWithAlphaComponent: alpha]]; ++ recompute_basic_faces (f); ++ SET_FRAME_GARBAGED (f); ++} ++ + static void + ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) + { +@@ -1105,7 +1131,7 @@ + ns_set_z_group, + 0, /* x_set_override_redirect */ + gui_set_no_special_glyphs, +- gui_set_alpha_background, ++ ns_set_alpha_background, + gui_set_borders_respect_alpha_background, + NULL, + #ifdef NS_IMPL_COCOA +diff -ur a/src/nsterm.m b/src/nsterm.m +--- a/src/nsterm.m 2025-12-11 04:36:34 ++++ b/src/nsterm.m 2025-12-11 10:21:09 +@@ -2624,8 +2624,10 @@ + + block_input (); + ns_focus (f, &r, 1); +- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND +- (FACE_FROM_ID (f, DEFAULT_FACE_ID))] set]; ++ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND ++ (FACE_FROM_ID (f, DEFAULT_FACE_ID))] ++ colorWithAlphaComponent: f->alpha_background] ++ set]; + NSRectFill (r); + ns_unfocus (f); + +@@ -2653,7 +2655,8 @@ + + r = NSIntersectionRect (r, [view frame]); + ns_focus (f, &r, 1); +- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set]; ++ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] ++ colorWithAlphaComponent: f->alpha_background] set]; + + NSRectFill (r); + +@@ -2757,7 +2760,8 @@ + return; + + ns_focus (f, NULL, 1); +- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set]; ++ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] ++ colorWithAlphaComponent: f->alpha_background] set]; + NSRectFill (NSMakeRect (0, margin, width, border)); + NSRectFill (NSMakeRect (0, 0, border, height)); + NSRectFill (NSMakeRect (0, margin, width, border)); +@@ -2809,7 +2813,8 @@ + NSRect r = NSMakeRect (0, y, FRAME_PIXEL_WIDTH (f), height); + ns_focus (f, &r, 1); + +- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set]; ++ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] ++ colorWithAlphaComponent: f->alpha_background] set]; + NSRectFill (NSMakeRect (0, y, width, height)); + NSRectFill (NSMakeRect (FRAME_PIXEL_WIDTH (f) - width, + y, width, height)); +@@ -3060,7 +3065,8 @@ + { + NSTRACE_RECT ("clearRect", bmpRect); + +- [[NSColor colorWithUnsignedLong:face->background] set]; ++ [[[NSColor colorWithUnsignedLong:face->background] ++ colorWithAlphaComponent: f->alpha_background] set]; + NSRectFill (bmpRect); + } +