mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 01:36:38 +00:00
feat(patches/alpha-background): add experimental alpha-background patch (#129)
Resolves #111
This commit is contained in:
@@ -131,7 +131,6 @@ Options:
|
|||||||
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 16)
|
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 16)
|
||||||
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
|
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
|
||||||
--[no-]use-nix Use Nix instead of Homebrew to find dependencies (default: enabled if IN_NIX_SHELL is set)
|
--[no-]use-nix Use Nix instead of Homebrew to find dependencies (default: enabled if IN_NIX_SHELL is set)
|
||||||
--[no-]xwidgets Enable/disable XWidgets if supported (default: enabled)
|
|
||||||
--[no-]tree-sitter Enable/disable tree-sitter if supported (default: enabled)
|
--[no-]tree-sitter Enable/disable tree-sitter if supported (default: enabled)
|
||||||
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
|
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
|
||||||
--optimize Shorthand for --native-march --native-mtune --fomit-frame-pointer (default: disabled)
|
--optimize Shorthand for --native-march --native-mtune --fomit-frame-pointer (default: disabled)
|
||||||
@@ -142,10 +141,12 @@ Options:
|
|||||||
--[no-]relink-eln-files Enable/disable re-linking shared libraries in bundled *.eln files (default: enabled)
|
--[no-]relink-eln-files Enable/disable re-linking shared libraries in bundled *.eln files (default: enabled)
|
||||||
--[no-]rsvg Enable/disable SVG image support via librsvg (default: enabled)
|
--[no-]rsvg Enable/disable SVG image support via librsvg (default: enabled)
|
||||||
--[no-]dbus Enable/disable dbus support (default: enabled)
|
--[no-]dbus Enable/disable dbus support (default: enabled)
|
||||||
--no-titlebar Apply no-titlebar patch (default: disabled)
|
--[no-]alpha-background Enable/disable experimental alpha-background patch when building Emacs 30.x - 31.x (default: disabled)
|
||||||
--posix-spawn Apply posix-spawn patch (deprecated)
|
--no-frame-refocus Apply no-frame-refocus patch when building Emacs 27.x - 31.x (default: disabled)
|
||||||
--no-frame-refocus Apply no-frame-refocus patch (default: disabled)
|
--no-titlebar Apply no-titlebar patch when building Emacs 27.x - 28.x (default: disabled)
|
||||||
|
--[no-]xwidgets Enable/disable XWidgets when building Emacs 27.x (default: disabled)
|
||||||
--[no-]poll Apply poll patch (deprecated)
|
--[no-]poll Apply poll patch (deprecated)
|
||||||
|
--posix-spawn Apply posix-spawn patch (deprecated)
|
||||||
-p, --patch=URL Specify a custom patch file or URL to apply to the Emacs source (can be used multiple times)
|
-p, --patch=URL Specify a custom patch file or URL to apply to the Emacs source (can be used multiple times)
|
||||||
--[no-]fd-setsize SIZE Set an file descriptor (max open files) limit (default: 10000)
|
--[no-]fd-setsize SIZE Set an file descriptor (max open files) limit (default: 10000)
|
||||||
--github-src-repo REPO Specify a GitHub repo to download source tarballs from (default: emacs-mirror/emacs)
|
--github-src-repo REPO Specify a GitHub repo to download source tarballs from (default: emacs-mirror/emacs)
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ class Build
|
|||||||
end
|
end
|
||||||
|
|
||||||
tarball = download_tarball(meta[:sha])
|
tarball = download_tarball(meta[:sha])
|
||||||
@source_dir = extract_tarball(tarball, patches(options))
|
@source_dir = extract_tarball(tarball, build_patches)
|
||||||
|
|
||||||
autogen
|
autogen
|
||||||
detect_native_comp if options[:native_comp].nil?
|
detect_native_comp if options[:native_comp].nil?
|
||||||
@@ -1052,7 +1052,7 @@ class Build
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def patches(opts = {})
|
def build_patches
|
||||||
p = []
|
p = []
|
||||||
|
|
||||||
# Enabled by default patches.
|
# Enabled by default patches.
|
||||||
@@ -1129,7 +1129,7 @@ class Build
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts[:xwidgets] && effective_version == 27
|
if options[:xwidgets] && effective_version == 27
|
||||||
p << {
|
p << {
|
||||||
url:
|
url:
|
||||||
'https://github.com/d12frosted/homebrew-emacs-plus/raw/master/' \
|
'https://github.com/d12frosted/homebrew-emacs-plus/raw/master/' \
|
||||||
@@ -1137,6 +1137,22 @@ class Build
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if options[:alpha_background]
|
||||||
|
if effective_version == 29
|
||||||
|
p << {
|
||||||
|
file: File.join(
|
||||||
|
__dir__, 'patches', 'emacs-29', 'ns-alpha-background.patch'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
elsif (30..31).include?(effective_version)
|
||||||
|
p << {
|
||||||
|
url:
|
||||||
|
"https://github.com/emacs-mirror/emacs/compare/#{meta[:sha]}" \
|
||||||
|
'...jonrubens:emacs:ns-alpha-background.patch'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Custom patches.
|
# Custom patches.
|
||||||
options[:patches].each do |patch_str|
|
options[:patches].each do |patch_str|
|
||||||
patch = {}
|
patch = {}
|
||||||
@@ -1940,12 +1956,6 @@ class CLIOptions
|
|||||||
'(default: enabled if IN_NIX_SHELL is set)'
|
'(default: enabled if IN_NIX_SHELL is set)'
|
||||||
) { |v| options[:use_nix] = v }
|
) { |v| options[:use_nix] = v }
|
||||||
|
|
||||||
opts.on(
|
|
||||||
'--[no-]xwidgets',
|
|
||||||
'Enable/disable XWidgets if supported ' \
|
|
||||||
'(default: enabled)'
|
|
||||||
) { |v| options[:xwidgets] = v }
|
|
||||||
|
|
||||||
opts.on(
|
opts.on(
|
||||||
'--[no-]tree-sitter',
|
'--[no-]tree-sitter',
|
||||||
'Enable/disable tree-sitter if supported ' \
|
'Enable/disable tree-sitter if supported ' \
|
||||||
@@ -2010,23 +2020,37 @@ class CLIOptions
|
|||||||
) { |v| options[:dbus] = v }
|
) { |v| options[:dbus] = v }
|
||||||
|
|
||||||
opts.on(
|
opts.on(
|
||||||
'--no-titlebar',
|
'--alpha-background',
|
||||||
'Apply no-titlebar patch (default: disabled)'
|
'Apply experimental alpha-background patch when building Emacs ' \
|
||||||
) { options[:no_titlebar] = true }
|
'30.x - 31.x (default: disabled)'
|
||||||
|
) { |v| options[:alpha_background] = v }
|
||||||
opts.on('--posix-spawn', 'Apply posix-spawn patch (deprecated)') do
|
|
||||||
warn '==> WARN: posix-spawn patch is deprecated and has no effect.'
|
|
||||||
end
|
|
||||||
|
|
||||||
opts.on(
|
opts.on(
|
||||||
'--no-frame-refocus',
|
'--no-frame-refocus',
|
||||||
'Apply no-frame-refocus patch (default: disabled)'
|
'Apply no-frame-refocus patch when building Emacs 27.x - 31.x ' \
|
||||||
|
'(default: disabled)'
|
||||||
) { options[:no_frame_refocus] = true }
|
) { options[:no_frame_refocus] = true }
|
||||||
|
|
||||||
|
opts.on(
|
||||||
|
'--no-titlebar',
|
||||||
|
'Apply no-titlebar patch when building Emacs 27.x - 28.x ' \
|
||||||
|
'(default: disabled)'
|
||||||
|
) { options[:no_titlebar] = true }
|
||||||
|
|
||||||
|
opts.on(
|
||||||
|
'--[no-]xwidgets',
|
||||||
|
'Enable/disable XWidgets when building Emacs 27.x ' \
|
||||||
|
'(default: disabled)'
|
||||||
|
) { |v| options[:xwidgets] = v }
|
||||||
|
|
||||||
opts.on('--[no-]poll', 'Apply poll patch (deprecated)') do
|
opts.on('--[no-]poll', 'Apply poll patch (deprecated)') do
|
||||||
warn '==> WARN: poll patch is deprecated and has no effect.'
|
warn '==> WARN: poll patch is deprecated and has no effect.'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('--posix-spawn', 'Apply posix-spawn patch (deprecated)') do
|
||||||
|
warn '==> WARN: posix-spawn patch is deprecated and has no effect.'
|
||||||
|
end
|
||||||
|
|
||||||
opts.on(
|
opts.on(
|
||||||
'-p=URL', '--patch=URL',
|
'-p=URL', '--patch=URL',
|
||||||
'Specify a custom patch file or URL to apply to the Emacs source ' \
|
'Specify a custom patch file or URL to apply to the Emacs source ' \
|
||||||
|
|||||||
487
patches/emacs-29/ns-alpha-background.patch
Normal file
487
patches/emacs-29/ns-alpha-background.patch
Normal file
@@ -0,0 +1,487 @@
|
|||||||
|
From 9b436ccb00ea321fe778ea51cf1ad536aff7210f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jon Rubens <jonathanrubens@gmail.com>
|
||||||
|
Date: Wed, 24 Jan 2024 19:45:55 -0800
|
||||||
|
Subject: [PATCH 1/3] Enable frame parameter alpha_background for MacOS
|
||||||
|
|
||||||
|
---
|
||||||
|
src/macfont.m | 10 ++++++++--
|
||||||
|
src/nsfns.m | 42 ++++++++++++++++++++++++++++++++++--------
|
||||||
|
src/nsterm.m | 42 ++++++++++++++++++++++--------------------
|
||||||
|
3 files changed, 64 insertions(+), 30 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/macfont.m b/src/macfont.m
|
||||||
|
index 8aba440d196e..56c1eb57024e 100644
|
||||||
|
--- a/src/macfont.m
|
||||||
|
+++ b/src/macfont.m
|
||||||
|
@@ -2953,9 +2953,14 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2964,6 +2969,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||||
|
CGAffineTransform atfm;
|
||||||
|
|
||||||
|
CGContextScaleCTM (context, 1, -1);
|
||||||
|
+ CGContextSetAlpha(context, 1);
|
||||||
|
if (s->hl == DRAW_CURSOR)
|
||||||
|
{
|
||||||
|
if (face && (NS_FACE_BACKGROUND (face)
|
||||||
|
diff --git a/src/nsfns.m b/src/nsfns.m
|
||||||
|
index b0281aac2572..3e19cce89de9 100644
|
||||||
|
--- a/src/nsfns.m
|
||||||
|
+++ b/src/nsfns.m
|
||||||
|
@@ -301,7 +301,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||||
|
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))
|
||||||
|
@@ -316,11 +316,10 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||||
|
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];
|
||||||
|
@@ -330,10 +329,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -346,6 +342,36 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||||
|
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)
|
||||||
|
@@ -1065,7 +1091,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||||
|
ns_set_z_group,
|
||||||
|
0, /* x_set_override_redirect */
|
||||||
|
gui_set_no_special_glyphs,
|
||||||
|
- gui_set_alpha_background,
|
||||||
|
+ ns_set_alpha_background,
|
||||||
|
NULL,
|
||||||
|
#ifdef NS_IMPL_COCOA
|
||||||
|
ns_set_appearance,
|
||||||
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
|
index 518b38658d17..bda3a12172f5 100644
|
||||||
|
--- a/src/nsterm.m
|
||||||
|
+++ b/src/nsterm.m
|
||||||
|
@@ -2618,8 +2618,9 @@ Hide the window (X11 semantics)
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
@@ -2647,7 +2648,7 @@ Hide the window (X11 semantics)
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
@@ -2751,7 +2752,7 @@ Hide the window (X11 semantics)
|
||||||
|
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));
|
||||||
|
@@ -2802,7 +2803,7 @@ Hide the window (X11 semantics)
|
||||||
|
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));
|
||||||
|
@@ -2966,8 +2967,7 @@ Hide the window (X11 semantics)
|
||||||
|
if (! NSIsEmptyRect (clearRect))
|
||||||
|
{
|
||||||
|
NSTRACE_RECT ("clearRect", clearRect);
|
||||||
|
-
|
||||||
|
- [[NSColor colorWithUnsignedLong:face->background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong:face->background] colorWithAlphaComponent: f->alpha_background] set];
|
||||||
|
NSRectFill (clearRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2998,7 +2998,7 @@ Hide the window (X11 semantics)
|
||||||
|
else
|
||||||
|
bm_color = f->output_data.ns->cursor_color;
|
||||||
|
|
||||||
|
- [bm_color set];
|
||||||
|
+ [[bm_color colorWithAlphaComponent:f->alpha_background] set];
|
||||||
|
[bmp fill];
|
||||||
|
|
||||||
|
[bmp release];
|
||||||
|
@@ -3719,7 +3719,7 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
|
||||||
|
{
|
||||||
|
ns_draw_box (r, abs (hthickness), abs (vthickness),
|
||||||
|
- [NSColor colorWithUnsignedLong:face->box_color],
|
||||||
|
+ [[NSColor colorWithUnsignedLong:face->box_color] colorWithAlphaComponent: s->f->alpha_background],
|
||||||
|
left_p, right_p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
@@ -3757,8 +3757,10 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
{
|
||||||
|
if (s->hl != DRAW_CURSOR)
|
||||||
|
[(NS_FACE_BACKGROUND (face) != 0
|
||||||
|
- ? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||||
|
+ ? [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||||
|
+ colorWithAlphaComponent: s->f->alpha_background]
|
||||||
|
: FRAME_BACKGROUND_COLOR (s->f)) set];
|
||||||
|
+
|
||||||
|
else if (face && (NS_FACE_BACKGROUND (face)
|
||||||
|
== [(NSColor *) FRAME_CURSOR_COLOR (s->f)
|
||||||
|
unsignedLong]))
|
||||||
|
@@ -3902,7 +3904,7 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
otherwise, since we composite the image under NS (instead of mucking
|
||||||
|
with its background color), we must clear just the image area. */
|
||||||
|
|
||||||
|
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
|
||||||
|
if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
|
||||||
|
|| s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
|
||||||
|
@@ -3972,7 +3974,7 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
if (s->hl == DRAW_CURSOR)
|
||||||
|
{
|
||||||
|
[FRAME_CURSOR_COLOR (s->f) set];
|
||||||
|
- tdCol = [NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)];
|
||||||
|
+ tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tdCol = [NSColor colorWithUnsignedLong: NS_FACE_FOREGROUND (face)];
|
||||||
|
@@ -4066,10 +4068,10 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
|
||||||
|
prepare_face_for_display (s->f, face);
|
||||||
|
|
||||||
|
- [[NSColor colorWithUnsignedLong: face->background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong: face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
- [[NSColor colorWithUnsignedLong: s->face->background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
NSRectFill (NSMakeRect (x, y, w, h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -4095,7 +4097,7 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
if (s->hl == DRAW_CURSOR)
|
||||||
|
[FRAME_CURSOR_COLOR (s->f) set];
|
||||||
|
else
|
||||||
|
- [[NSColor colorWithUnsignedLong: s->face->background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
|
||||||
|
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
|
||||||
|
}
|
||||||
|
@@ -8436,8 +8438,8 @@ - (void)toggleFullScreen: (id)sender
|
||||||
|
}
|
||||||
|
|
||||||
|
[w setContentView:[fw contentView]];
|
||||||
|
- [w setBackgroundColor: col];
|
||||||
|
- if ([col alphaComponent] != (EmacsCGFloat) 1.0)
|
||||||
|
+ [w setBackgroundColor: [col colorWithAlphaComponent: f->alpha_background]];
|
||||||
|
+ if (f->alpha_background != (EmacsCGFloat) 1.0)
|
||||||
|
[w setOpaque: NO];
|
||||||
|
|
||||||
|
f->border_width = [w borderWidth];
|
||||||
|
@@ -9172,9 +9174,9 @@ - (instancetype) initWithEmacsFrame: (struct frame *) f
|
||||||
|
f->border_width = [self borderWidth];
|
||||||
|
|
||||||
|
col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
|
||||||
|
- (FACE_FROM_ID (f, DEFAULT_FACE_ID))];
|
||||||
|
- [self setBackgroundColor:col];
|
||||||
|
- if ([col alphaComponent] != (EmacsCGFloat) 1.0)
|
||||||
|
+ (FACE_FROM_ID (f, DEFAULT_FACE_ID))];
|
||||||
|
+ [self setBackgroundColor:[col colorWithAlphaComponent:f->alpha_background]];
|
||||||
|
+ if (f->alpha_background != (EmacsCGFloat) 1.0)
|
||||||
|
[self setOpaque:NO];
|
||||||
|
|
||||||
|
/* toolbar support */
|
||||||
|
|
||||||
|
From 58cf6e6da20eefca161c1ab1fd0d6ad67d1ba710 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jon Rubens <jonathanrubens@gmail.com>
|
||||||
|
Date: Fri, 26 Jan 2024 09:35:15 -0800
|
||||||
|
Subject: [PATCH 2/3] Fix code formatting
|
||||||
|
|
||||||
|
---
|
||||||
|
src/macfont.m | 8 ++++----
|
||||||
|
src/nsterm.m | 30 ++++++++++++++++++++----------
|
||||||
|
2 files changed, 24 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/macfont.m b/src/macfont.m
|
||||||
|
index 56c1eb57024e..8fb835c7ff01 100644
|
||||||
|
--- a/src/macfont.m
|
||||||
|
+++ b/src/macfont.m
|
||||||
|
@@ -2953,14 +2953,14 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||||
|
CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
|
||||||
|
else
|
||||||
|
CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f);
|
||||||
|
- CGContextSetAlpha(context, 1);
|
||||||
|
+ CGContextSetAlpha (context, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
- CGContextSetAlpha(context, f->alpha_background);
|
||||||
|
+ CGContextSetAlpha (context, f->alpha_background);
|
||||||
|
CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
|
||||||
|
}
|
||||||
|
- CGContextClearRect(context, background_rect);
|
||||||
|
+ CGContextClearRect (context, background_rect);
|
||||||
|
CGContextFillRects (context, &background_rect, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2969,7 +2969,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||||
|
CGAffineTransform atfm;
|
||||||
|
|
||||||
|
CGContextScaleCTM (context, 1, -1);
|
||||||
|
- CGContextSetAlpha(context, 1);
|
||||||
|
+ CGContextSetAlpha (context, 1);
|
||||||
|
if (s->hl == DRAW_CURSOR)
|
||||||
|
{
|
||||||
|
if (face && (NS_FACE_BACKGROUND (face)
|
||||||
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
|
index bda3a12172f5..9ab3ff8f783f 100644
|
||||||
|
--- a/src/nsterm.m
|
||||||
|
+++ b/src/nsterm.m
|
||||||
|
@@ -2803,7 +2803,8 @@ Hide the window (X11 semantics)
|
||||||
|
NSRect r = NSMakeRect (0, y, FRAME_PIXEL_WIDTH (f), height);
|
||||||
|
ns_focus (f, &r, 1);
|
||||||
|
|
||||||
|
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] 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));
|
||||||
|
@@ -2967,7 +2968,8 @@ Hide the window (X11 semantics)
|
||||||
|
if (! NSIsEmptyRect (clearRect))
|
||||||
|
{
|
||||||
|
NSTRACE_RECT ("clearRect", clearRect);
|
||||||
|
- [[[NSColor colorWithUnsignedLong:face->background] colorWithAlphaComponent: f->alpha_background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong:face->background]
|
||||||
|
+ colorWithAlphaComponent: f->alpha_background] set];
|
||||||
|
NSRectFill (clearRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -3719,7 +3721,8 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
|
||||||
|
{
|
||||||
|
ns_draw_box (r, abs (hthickness), abs (vthickness),
|
||||||
|
- [[NSColor colorWithUnsignedLong:face->box_color] colorWithAlphaComponent: s->f->alpha_background],
|
||||||
|
+ [[NSColor colorWithUnsignedLong:face->box_color]
|
||||||
|
+ colorWithAlphaComponent: s->f->alpha_background],
|
||||||
|
left_p, right_p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
@@ -3904,7 +3907,8 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
otherwise, since we composite the image under NS (instead of mucking
|
||||||
|
with its background color), we must clear just the image area. */
|
||||||
|
|
||||||
|
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||||
|
+ colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
|
||||||
|
if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
|
||||||
|
|| s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
|
||||||
|
@@ -3974,7 +3978,8 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
if (s->hl == DRAW_CURSOR)
|
||||||
|
{
|
||||||
|
[FRAME_CURSOR_COLOR (s->f) set];
|
||||||
|
- tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background];
|
||||||
|
+ tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)]
|
||||||
|
+ colorWithAlphaComponent: s->f->alpha_background];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tdCol = [NSColor colorWithUnsignedLong: NS_FACE_FOREGROUND (face)];
|
||||||
|
@@ -4068,10 +4073,12 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
|
||||||
|
prepare_face_for_display (s->f, face);
|
||||||
|
|
||||||
|
- [[[NSColor colorWithUnsignedLong: face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong: face->background]
|
||||||
|
+ colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
- [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong: s->face->background]
|
||||||
|
+ colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
NSRectFill (NSMakeRect (x, y, w, h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -4097,7 +4104,8 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
if (s->hl == DRAW_CURSOR)
|
||||||
|
[FRAME_CURSOR_COLOR (s->f) set];
|
||||||
|
else
|
||||||
|
- [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong: s->face->background]
|
||||||
|
+ colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
|
||||||
|
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
|
||||||
|
}
|
||||||
|
@@ -8438,7 +8446,8 @@ - (void)toggleFullScreen: (id)sender
|
||||||
|
}
|
||||||
|
|
||||||
|
[w setContentView:[fw contentView]];
|
||||||
|
- [w setBackgroundColor: [col colorWithAlphaComponent: f->alpha_background]];
|
||||||
|
+ [w setBackgroundColor: [col colorWithAlphaComponent:
|
||||||
|
+ f->alpha_background]];
|
||||||
|
if (f->alpha_background != (EmacsCGFloat) 1.0)
|
||||||
|
[w setOpaque: NO];
|
||||||
|
|
||||||
|
@@ -9175,7 +9184,8 @@ - (instancetype) initWithEmacsFrame: (struct frame *) f
|
||||||
|
|
||||||
|
col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
|
||||||
|
(FACE_FROM_ID (f, DEFAULT_FACE_ID))];
|
||||||
|
- [self setBackgroundColor:[col colorWithAlphaComponent:f->alpha_background]];
|
||||||
|
+ [self setBackgroundColor:
|
||||||
|
+ [col colorWithAlphaComponent:f->alpha_background]];
|
||||||
|
if (f->alpha_background != (EmacsCGFloat) 1.0)
|
||||||
|
[self setOpaque:NO];
|
||||||
|
|
||||||
|
|
||||||
|
From 896596aac2932ab98dbeb68f48a963275fdb76c5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jon Rubens <jonathanrubens@gmail.com>
|
||||||
|
Date: Wed, 31 Jan 2024 13:30:13 -0800
|
||||||
|
Subject: [PATCH 3/3] More code formatting
|
||||||
|
|
||||||
|
---
|
||||||
|
src/nsfns.m | 11 ++++++-----
|
||||||
|
src/nsterm.m | 8 +++++---
|
||||||
|
2 files changed, 11 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/nsfns.m b/src/nsfns.m
|
||||||
|
index 3e19cce89de9..67d8449c70dd 100644
|
||||||
|
--- a/src/nsfns.m
|
||||||
|
+++ b/src/nsfns.m
|
||||||
|
@@ -321,11 +321,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||||
|
{
|
||||||
|
[[view window] setBackgroundColor: [col colorWithAlphaComponent: alpha]];
|
||||||
|
|
||||||
|
- if (alpha != (EmacsCGFloat) 1.0)
|
||||||
|
- [[view window] setOpaque: NO];
|
||||||
|
- else
|
||||||
|
- [[view window] setOpaque: YES];
|
||||||
|
-
|
||||||
|
face = FRAME_DEFAULT_FACE (f);
|
||||||
|
if (face)
|
||||||
|
{
|
||||||
|
@@ -369,6 +364,12 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
|
||||||
|
f->alpha_background = alpha;
|
||||||
|
[[view window] setBackgroundColor: [f->output_data.ns->background_color
|
||||||
|
colorWithAlphaComponent: alpha]];
|
||||||
|
+
|
||||||
|
+ if (alpha != (EmacsCGFloat) 1.0)
|
||||||
|
+ [[view window] setOpaque: NO];
|
||||||
|
+ else
|
||||||
|
+ [[view window] setOpaque: YES];
|
||||||
|
+
|
||||||
|
recompute_basic_faces (f);
|
||||||
|
SET_FRAME_GARBAGED (f);
|
||||||
|
}
|
||||||
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
|
index 9ab3ff8f783f..6feef6236449 100644
|
||||||
|
--- a/src/nsterm.m
|
||||||
|
+++ b/src/nsterm.m
|
||||||
|
@@ -2648,9 +2648,11 @@ Hide the window (X11 semantics)
|
||||||
|
|
||||||
|
r = NSIntersectionRect (r, [view frame]);
|
||||||
|
ns_focus (f, &r, 1);
|
||||||
|
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
|
||||||
|
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||||
|
+ colorWithAlphaComponent: f->alpha_background] set];
|
||||||
|
|
||||||
|
NSRectFill (r);
|
||||||
|
+ [[view window] invalidateShadow];
|
||||||
|
|
||||||
|
ns_unfocus (f);
|
||||||
|
return;
|
||||||
|
@@ -2752,7 +2754,8 @@ Hide the window (X11 semantics)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ns_focus (f, NULL, 1);
|
||||||
|
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] 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));
|
||||||
|
@@ -4106,7 +4109,6 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
|
else
|
||||||
|
[[[NSColor colorWithUnsignedLong: s->face->background]
|
||||||
|
colorWithAlphaComponent: s->f->alpha_background] set];
|
||||||
|
-
|
||||||
|
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user