foxygit / doom Log in
commit 1db716fa176d6b611083feb61f8396d73f56a04a
Author:     Simon Howard <fraggle@soulsphere.org>
AuthorDate: Fri Mar 16 23:41:44 2018 -0400
Commit:     Simon Howard <fraggle@soulsphere.org>
CommitDate: Fri Mar 16 23:41:44 2018 -0400

    textscreen: Simplify AppleScript for fileselect.

    Since macOS 10.9 it is no longer to "tell an application" in order
    to display pop-up UI elements like the file select dialogs. Quote:

    > osascript(1) is now a “UI element” process and can therefore display
    > its own UI, such as using display dialog; telling another application
    > such as System Events is no longer necessary. [12365409]

    As well as simplifying the wrapper this also fixes some issues with the
    pop-up dialogs where window focus was getting messed up after selecting
    a file.
---
 textscreen/txt_fileselect.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/textscreen/txt_fileselect.c b/textscreen/txt_fileselect.c
index 6f6332a3..b40da89f 100644
--- a/textscreen/txt_fileselect.c
+++ b/textscreen/txt_fileselect.c
@@ -331,13 +331,7 @@ char *TXT_SelectFile(char *window_title, char **extensions)
 // an Objective C dependency. This is rather silly.

 // Printf format string for the "wrapper" portion of the AppleScript:
-
-#define APPLESCRIPT_WRAPPER \
-    "tell application (path to frontmost application as text)\n" \
-    "    activate\n" \
-    "    set theFile to (%s)\n" \
-    "    copy POSIX path of theFile to stdout\n" \
-    "end tell\n"
+#define APPLESCRIPT_WRAPPER "copy POSIX path of (%s) to stdout"

 static char *EscapedString(char *s)
 {