Use macOS cooperative app activation to activate app to foreground
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- macos, swift
- Lĩnh vực
- desktop, operating-systems
Hướng nghiên cứu
Bắt đầu với các vị trí gọi activateIgnoringOtherApps được liệt kê, bao gồm addVimController, script mvim, việc thực thi XCTest do Makefile điều khiển và foreground(). Xác nhận hành vi kích hoạt của macOS và quyết định những đường dẫn nào cần yielding hợp tác. Hoàn tất có nghĩa là thay thế đường dẫn kích hoạt đã lỗi thời trong khi vẫn giữ nguyên hành vi của dock và việc mở tệp, đồng thời ghi lại giới hạn của foreground().
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
macOS 14 Sonoma deprecated the NSApplication API activateIgnoringOtherApps, and provides a new activate API along with a cooperative yieldActivation command that can be called by the host app. We should switch to using this API.
One issue is that calling activate requires the foreground app to cooperate and willingly yield. There are a few usages of activateIgnoringOtherApps right now:
- Using the "New Window" menu item on the Dock icon. I think this actually works automatically and the activate call may be superfluous.
- Opening a new Vim from the
mvimscript so the new Vim window would be in foreground. This wouldn't work as the terminal has foreground. Calling:guifrom non-GUI mode works similarly. (Note that currently directly invokingMacVim.app/Contents/MacOS/MacVimdoes not activate the app because of how the logic inaddVimControllerbut it's ok as it's not a normal path) - Invoking
:call foreground()in Vim. This also wouldn't just work as Vim does not have the right to gain activation when it's in background under this API model. - When opening a file by dragging it to the dock, etc. This should work as MacVim should gain focus when that happens.
- Running the new XCTest test cases. This also wouldn't just work if running the tests from terminal (e.g. in CI we just run
make -C src macvim-tests) as MacVim will fail to gain foreground this way. Running from Xcode will be fine though as Xcode will yield.
To fix 2/3/5, we probably need to run a simple Swift script that calls NSApplication.shared.yieldActivation(toApplicationWithBundleIdentifier: "org.vim.MacVim") to manually force the terminal to yield to MacVim. For 2 and 5, we can call them as part of the mvim script and Makefile, respectively.
For 3, it's a little tricky. If the foreground request is invoked as a remote call using the --remote family of commands, it would work, but MacVim will lose the ability to randomly bring itself to the foreground at will (e.g. running :sleep 2 | call foreground() would not work). This is probably ok as the foreground() API doesn't work on Win32 too and in general it's best to let the foreground app has agency over when focus unless the user manually clicked away.
Currently, in macOS 14, the activateIgnoringOtherApps API is only deprecated but it still works so there's no reason to do anything. Just keep this in mind for now. If macOS 15 formally breaks it, we will implement the fix along with the manual yielding from terminal so that calling mvim from terminal, running tests etc would still work. We don't really want to do anything until this API breaks because even fixing it "properly" we will still lose case (3) where call foreground() will stop working if not called using --remote.
- Ngôn ngữ chính
- Vim Script
- Star
- 7.9k
- Fork
- 691
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của macvim-dev/macvim
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
macvim-dev/macvim#1697 · 5 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
macvim-dev/macvim#1658 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
macvim-dev/macvim#1657 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
macvim-dev/macvim#1655 ·
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
macvim-dev/macvim#1653 ·
Tất cả issue của macvim-dev/macvim
Issue tương tự
-
Startup alerts tell the user to click Save and Apply, but the settings button is labelled Save Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
alexgorbatchev/simple-ptt#11 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug good first issue multicut serialization
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
accepted bug via-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
seagle0128/doom-modeline#835 ·