From 1d14b121c0bad4b9384e6c7e56184a477dc780cf Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 25 May 2023 21:41:43 -0700 Subject: [PATCH] renderer: do not draw cursor cell inversion if we don't draw the cursor We previously used the "screen.viewportIsBottom" check but this is always true since awhile back since we copy only the viewport now. A cleaner check really is that we only track the cursor cell if we're even drawing the cursor. --- macos/Ghostty-Info.plist | 5 +++++ macos/Ghostty.xcodeproj/project.pbxproj | 8 ++++++-- src/renderer/Metal.zig | 13 ++++++++----- src/renderer/OpenGL.zig | 19 +++++++++++-------- 4 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 macos/Ghostty-Info.plist diff --git a/macos/Ghostty-Info.plist b/macos/Ghostty-Info.plist new file mode 100644 index 000000000..0c67376eb --- /dev/null +++ b/macos/Ghostty-Info.plist @@ -0,0 +1,5 @@ + + + + + diff --git a/macos/Ghostty.xcodeproj/project.pbxproj b/macos/Ghostty.xcodeproj/project.pbxproj index 55d973db6..c67632528 100644 --- a/macos/Ghostty.xcodeproj/project.pbxproj +++ b/macos/Ghostty.xcodeproj/project.pbxproj @@ -13,13 +13,13 @@ A55B7BB829B6F53A0055DE60 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55B7BB729B6F53A0055DE60 /* Package.swift */; }; A55B7BBC29B6FC330055DE60 /* SurfaceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55B7BBB29B6FC330055DE60 /* SurfaceView.swift */; }; A55B7BBE29B701360055DE60 /* Ghostty.SplitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55B7BBD29B701360055DE60 /* Ghostty.SplitView.swift */; }; + A571AB1D2A206FCF00248498 /* GhosttyKit.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5D495A1299BEC7E00DD1313 /* GhosttyKit.xcframework */; }; A59444F729A2ED5200725BBA /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A59444F629A2ED5200725BBA /* SettingsView.swift */; }; A5B30535299BEAAA0047F10C /* GhosttyApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5B30534299BEAAA0047F10C /* GhosttyApp.swift */; }; A5B30539299BEAAB0047F10C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A5B30538299BEAAB0047F10C /* Assets.xcassets */; }; A5CEAFDC29B8009000646FDA /* SplitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5CEAFDB29B8009000646FDA /* SplitView.swift */; }; A5CEAFDE29B8058B00646FDA /* SplitView.Divider.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5CEAFDD29B8058B00646FDA /* SplitView.Divider.swift */; }; A5CEAFFF29C2410700646FDA /* Backport.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5CEAFFE29C2410700646FDA /* Backport.swift */; }; - A5D495A2299BEC7E00DD1313 /* GhosttyKit.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5D495A1299BEC7E00DD1313 /* GhosttyKit.xcframework */; }; A5FECBD729D1FC3900022361 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FECBD629D1FC3900022361 /* ContentView.swift */; }; A5FECBD929D2010400022361 /* WindowAccessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FECBD829D2010400022361 /* WindowAccessor.swift */; }; /* End PBXBuildFile section */ @@ -31,6 +31,7 @@ A55B7BB729B6F53A0055DE60 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; A55B7BBB29B6FC330055DE60 /* SurfaceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurfaceView.swift; sourceTree = ""; }; A55B7BBD29B701360055DE60 /* Ghostty.SplitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Ghostty.SplitView.swift; sourceTree = ""; }; + A571AB1C2A206FC600248498 /* Ghostty-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "Ghostty-Info.plist"; sourceTree = ""; }; A59444F629A2ED5200725BBA /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; A5B30531299BEAAA0047F10C /* Ghostty.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ghostty.app; sourceTree = BUILT_PRODUCTS_DIR; }; A5B30534299BEAAA0047F10C /* GhosttyApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GhosttyApp.swift; sourceTree = ""; }; @@ -49,7 +50,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - A5D495A2299BEC7E00DD1313 /* GhosttyKit.xcframework in Frameworks */, + A571AB1D2A206FCF00248498 /* GhosttyKit.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -87,6 +88,7 @@ A5B30528299BEAAA0047F10C = { isa = PBXGroup; children = ( + A571AB1C2A206FC600248498 /* Ghostty-Info.plist */, A5B30538299BEAAB0047F10C /* Assets.xcassets */, A5B3053D299BEAAB0047F10C /* Ghostty.entitlements */, A54CD6ED299BEB14008C95BB /* Sources */, @@ -344,6 +346,7 @@ ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "Ghostty-Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = Ghostty; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; @@ -378,6 +381,7 @@ ENABLE_PREVIEWS = YES; GCC_OPTIMIZATION_LEVEL = fast; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "Ghostty-Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = Ghostty; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 371a8f35f..788bcb567 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -829,7 +829,8 @@ fn rebuildCells( // If this is the row with our cursor, then we may have to modify // the cell with the cursor. const start_i: usize = self.cells.items.len; - defer if (self.cursor_visible and + defer if (draw_cursor and + self.cursor_visible and self.cursor_style == .box and screen.viewportIsBottom() and y == screen.cursor.y) @@ -891,10 +892,12 @@ fn rebuildCells( // Add the cursor at the end so that it overlays everything. If we have // a cursor cell then we invert the colors on that and add it in so // that we can always see it. - if (draw_cursor) self.addCursor(screen); - if (cursor_cell) |*cell| { - cell.color = .{ 0, 0, 0, 255 }; - self.cells.appendAssumeCapacity(cell.*); + if (draw_cursor) { + self.addCursor(screen); + if (cursor_cell) |*cell| { + cell.color = .{ 0, 0, 0, 255 }; + self.cells.appendAssumeCapacity(cell.*); + } } // Some debug mode safety checks diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 489c92de1..df58137a7 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -869,7 +869,8 @@ pub fn rebuildCells( // If this is the row with our cursor, then we may have to modify // the cell with the cursor. const start_i: usize = self.cells.items.len; - defer if (self.cursor_visible and + defer if (draw_cursor and + self.cursor_visible and self.cursor_style == .box and screen.viewportIsBottom() and y == screen.cursor.y) @@ -951,13 +952,15 @@ pub fn rebuildCells( // Add the cursor at the end so that it overlays everything. If we have // a cursor cell then we invert the colors on that and add it in so // that we can always see it. - if (draw_cursor) self.addCursor(screen); - if (cursor_cell) |*cell| { - cell.fg_r = 0; - cell.fg_g = 0; - cell.fg_b = 0; - cell.fg_a = 255; - self.cells.appendAssumeCapacity(cell.*); + if (draw_cursor) { + self.addCursor(screen); + if (cursor_cell) |*cell| { + cell.fg_r = 0; + cell.fg_g = 0; + cell.fg_b = 0; + cell.fg_a = 255; + self.cells.appendAssumeCapacity(cell.*); + } } // Some debug mode safety checks