diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-05 22:49:06 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-05 22:49:06 +0200 |
commit | b7deb632513795e495e9a3aa76a9400fef4de364 (patch) | |
tree | f57006f6fee9b79aea3182df5f0c3b28e9fc71eb /src | |
parent | 52f3c7e158ee9436ee82f602ee9a6212dd54b776 (diff) |
Experimenting with an iOS build
iPlatformApple applies to both macOS and iOS. Added iPlatformAppleDesktop and iPlatformAppleMobile to make a distinction between the two.
IssueID #96
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 18 | ||||
-rw-r--r-- | src/ios.h | 27 | ||||
-rw-r--r-- | src/ios.m | 23 | ||||
-rw-r--r-- | src/main.c | 7 | ||||
-rw-r--r-- | src/ui/bindingswidget.c | 4 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 2 | ||||
-rw-r--r-- | src/ui/inputwidget.c | 4 | ||||
-rw-r--r-- | src/ui/window.c | 8 |
8 files changed, 77 insertions, 16 deletions
@@ -61,7 +61,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
61 | #include <stdarg.h> | 61 | #include <stdarg.h> |
62 | #include <errno.h> | 62 | #include <errno.h> |
63 | 63 | ||
64 | #if defined (iPlatformApple) && !defined (iPlatformIOS) | 64 | #if defined (iPlatformAppleDesktop) |
65 | # include "macos.h" | 65 | # include "macos.h" |
66 | #endif | 66 | #endif |
67 | #if defined (iPlatformMsys) | 67 | #if defined (iPlatformMsys) |
@@ -73,10 +73,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
73 | 73 | ||
74 | iDeclareType(App) | 74 | iDeclareType(App) |
75 | 75 | ||
76 | #if defined (iPlatformApple) | 76 | #if defined (iPlatformAppleDesktop) |
77 | #define EMB_BIN "../../Resources/resources.lgr" | 77 | #define EMB_BIN "../../Resources/resources.lgr" |
78 | static const char *defaultDataDir_App_ = "~/Library/Application Support/fi.skyjake.Lagrange"; | 78 | static const char *defaultDataDir_App_ = "~/Library/Application Support/fi.skyjake.Lagrange"; |
79 | #endif | 79 | #endif |
80 | #if defined (iPlatformAppleMobile) | ||
81 | #define EMB_BIN "../../Resources/resources.lgr" | ||
82 | static const char *defaultDataDir_App_ = "~/config"; | ||
83 | #endif | ||
80 | #if defined (iPlatformMsys) | 84 | #if defined (iPlatformMsys) |
81 | #define EMB_BIN "../resources.lgr" | 85 | #define EMB_BIN "../resources.lgr" |
82 | static const char *defaultDataDir_App_ = "~/AppData/Roaming/fi.skyjake.Lagrange"; | 86 | static const char *defaultDataDir_App_ = "~/AppData/Roaming/fi.skyjake.Lagrange"; |
@@ -429,7 +433,7 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
429 | d->lastEventTime = 0; | 433 | d->lastEventTime = 0; |
430 | d->sleepTimer = SDL_AddTimer(1000, checkAsleep_App_, d); | 434 | d->sleepTimer = SDL_AddTimer(1000, checkAsleep_App_, d); |
431 | #endif | 435 | #endif |
432 | #if defined (iPlatformApple) | 436 | #if defined (iPlatformAppleDesktop) |
433 | setupApplication_MacOS(); | 437 | setupApplication_MacOS(); |
434 | #endif | 438 | #endif |
435 | init_Keys(); | 439 | init_Keys(); |
@@ -628,7 +632,7 @@ void processEvents_App(enum iAppEventMode eventMode) { | |||
628 | wasUsed = processEvent_Keys(&ev); | 632 | wasUsed = processEvent_Keys(&ev); |
629 | } | 633 | } |
630 | if (ev.type == SDL_USEREVENT && ev.user.code == command_UserEventCode) { | 634 | if (ev.type == SDL_USEREVENT && ev.user.code == command_UserEventCode) { |
631 | #if defined (iPlatformApple) && !defined (iPlatformIOS) | 635 | #if defined (iPlatformAppleDesktop) |
632 | handleCommand_MacOS(command_UserEvent(&ev)); | 636 | handleCommand_MacOS(command_UserEvent(&ev)); |
633 | #endif | 637 | #endif |
634 | if (isCommand_UserEvent(&ev, "metrics.changed")) { | 638 | if (isCommand_UserEvent(&ev, "metrics.changed")) { |
@@ -1565,9 +1569,10 @@ void openInDefaultBrowser_App(const iString *url) { | |||
1565 | return; | 1569 | return; |
1566 | } | 1570 | } |
1567 | #endif | 1571 | #endif |
1572 | #if !defined (iPlatformAppleMobile) | ||
1568 | iProcess *proc = new_Process(); | 1573 | iProcess *proc = new_Process(); |
1569 | setArguments_Process(proc, | 1574 | setArguments_Process(proc, |
1570 | #if defined (iPlatformApple) | 1575 | #if defined (iPlatformAppleDesktop) |
1571 | iClob(newStringsCStr_StringList("/usr/bin/env", "open", cstr_String(url), NULL)) | 1576 | iClob(newStringsCStr_StringList("/usr/bin/env", "open", cstr_String(url), NULL)) |
1572 | #elif defined (iPlatformLinux) || defined (iPlatformOther) | 1577 | #elif defined (iPlatformLinux) || defined (iPlatformOther) |
1573 | iClob(newStringsCStr_StringList("/usr/bin/env", "xdg-open", cstr_String(url), NULL)) | 1578 | iClob(newStringsCStr_StringList("/usr/bin/env", "xdg-open", cstr_String(url), NULL)) |
@@ -1581,10 +1586,11 @@ void openInDefaultBrowser_App(const iString *url) { | |||
1581 | ); | 1586 | ); |
1582 | start_Process(proc); | 1587 | start_Process(proc); |
1583 | iRelease(proc); | 1588 | iRelease(proc); |
1589 | #endif | ||
1584 | } | 1590 | } |
1585 | 1591 | ||
1586 | void revealPath_App(const iString *path) { | 1592 | void revealPath_App(const iString *path) { |
1587 | #if defined (iPlatformApple) | 1593 | #if defined (iPlatformAppleDesktop) |
1588 | const char *scriptPath = concatPath_CStr(dataDir_App_(), "revealfile.scpt"); | 1594 | const char *scriptPath = concatPath_CStr(dataDir_App_(), "revealfile.scpt"); |
1589 | iFile *f = newCStr_File(scriptPath); | 1595 | iFile *f = newCStr_File(scriptPath); |
1590 | if (open_File(f, writeOnly_FileMode | text_FileMode)) { | 1596 | if (open_File(f, writeOnly_FileMode | text_FileMode)) { |
diff --git a/src/ios.h b/src/ios.h new file mode 100644 index 00000000..7217e74a --- /dev/null +++ b/src/ios.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* Copyright 2021 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
2 | |||
3 | Redistribution and use in source and binary forms, with or without | ||
4 | modification, are permitted provided that the following conditions are met: | ||
5 | |||
6 | 1. Redistributions of source code must retain the above copyright notice, this | ||
7 | list of conditions and the following disclaimer. | ||
8 | 2. Redistributions in binary form must reproduce the above copyright notice, | ||
9 | this list of conditions and the following disclaimer in the documentation | ||
10 | and/or other materials provided with the distribution. | ||
11 | |||
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
13 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
14 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
15 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
16 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
17 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
18 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
19 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
20 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
22 | |||
23 | #pragma once | ||
24 | |||
25 | #include "ui/util.h" | ||
26 | |||
27 | |||
diff --git a/src/ios.m b/src/ios.m new file mode 100644 index 00000000..029bd068 --- /dev/null +++ b/src/ios.m | |||
@@ -0,0 +1,23 @@ | |||
1 | /* Copyright 2021 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
2 | |||
3 | Redistribution and use in source and binary forms, with or without | ||
4 | modification, are permitted provided that the following conditions are met: | ||
5 | |||
6 | 1. Redistributions of source code must retain the above copyright notice, this | ||
7 | list of conditions and the following disclaimer. | ||
8 | 2. Redistributions in binary form must reproduce the above copyright notice, | ||
9 | this list of conditions and the following disclaimer in the documentation | ||
10 | and/or other materials provided with the distribution. | ||
11 | |||
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
13 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
14 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
15 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
16 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
17 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
18 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
19 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
20 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
22 | |||
23 | #include "ios.h" | ||
@@ -22,9 +22,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
22 | 22 | ||
23 | #include "app.h" | 23 | #include "app.h" |
24 | 24 | ||
25 | #if defined (iPlatformApple) | 25 | #if defined (iPlatformAppleDesktop) |
26 | # include "macos.h" | 26 | # include "macos.h" |
27 | #endif | 27 | #endif |
28 | #if defined (iPlatformAppleMobile) | ||
29 | # include "ios.h" | ||
30 | #endif | ||
28 | #if defined (iPlatformMsys) | 31 | #if defined (iPlatformMsys) |
29 | # include "win32.h" | 32 | # include "win32.h" |
30 | # define SDL_MAIN_HANDLED | 33 | # define SDL_MAIN_HANDLED |
@@ -41,7 +44,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
41 | int main(int argc, char **argv) { | 44 | int main(int argc, char **argv) { |
42 | printf("Lagrange: A Beautiful Gemini Client\n"); | 45 | printf("Lagrange: A Beautiful Gemini Client\n"); |
43 | signal(SIGPIPE, SIG_IGN); | 46 | signal(SIGPIPE, SIG_IGN); |
44 | #if defined (iPlatformApple) | 47 | #if defined (iPlatformAppleDesktop) |
45 | enableMomentumScroll_MacOS(); | 48 | enableMomentumScroll_MacOS(); |
46 | registerURLHandler_MacOS(); | 49 | registerURLHandler_MacOS(); |
47 | #endif | 50 | #endif |
diff --git a/src/ui/bindingswidget.c b/src/ui/bindingswidget.c index 9a2070ba..558bdcd5 100644 --- a/src/ui/bindingswidget.c +++ b/src/ui/bindingswidget.c | |||
@@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
26 | #include "command.h" | 26 | #include "command.h" |
27 | #include "util.h" | 27 | #include "util.h" |
28 | #include "app.h" | 28 | #include "app.h" |
29 | #if defined (iPlatformApple) | 29 | #if defined (iPlatformAppleDesktop) |
30 | # include "macos.h" | 30 | # include "macos.h" |
31 | #endif | 31 | #endif |
32 | 32 | ||
@@ -140,7 +140,7 @@ static void setActiveItem_BindingsWidget_(iBindingsWidget *d, size_t pos) { | |||
140 | item->isWaitingForEvent = iTrue; | 140 | item->isWaitingForEvent = iTrue; |
141 | invalidateItem_ListWidget(d->list, d->activePos); | 141 | invalidateItem_ListWidget(d->list, d->activePos); |
142 | } | 142 | } |
143 | #if defined (iPlatformApple) | 143 | #if defined (iPlatformAppleDesktop) |
144 | /* Native menus must be disabled while grabbing keys so the shortcuts don't trigger. */ | 144 | /* Native menus must be disabled while grabbing keys so the shortcuts don't trigger. */ |
145 | const iBool enableNativeMenus = (d->activePos == iInvalidPos); | 145 | const iBool enableNativeMenus = (d->activePos == iInvalidPos); |
146 | enableMenu_MacOS("Edit", enableNativeMenus); | 146 | enableMenu_MacOS("Edit", enableNativeMenus); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 79a77f61..38e7fcca 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -251,7 +251,7 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
251 | addChildFlags_Widget(w, | 251 | addChildFlags_Widget(w, |
252 | iClob(new_IndicatorWidget()), | 252 | iClob(new_IndicatorWidget()), |
253 | resizeToParentWidth_WidgetFlag | resizeToParentHeight_WidgetFlag); | 253 | resizeToParentWidth_WidgetFlag | resizeToParentHeight_WidgetFlag); |
254 | #if !defined (iPlatformApple) /* in system menu */ | 254 | #if !defined (iPlatformAppleDesktop) /* in system menu */ |
255 | addAction_Widget(w, reload_KeyShortcut, "navigate.reload"); | 255 | addAction_Widget(w, reload_KeyShortcut, "navigate.reload"); |
256 | addAction_Widget(w, closeTab_KeyShortcut, "tabs.close"); | 256 | addAction_Widget(w, closeTab_KeyShortcut, "tabs.close"); |
257 | addAction_Widget(w, SDLK_d, KMOD_PRIMARY, "bookmark.add"); | 257 | addAction_Widget(w, SDLK_d, KMOD_PRIMARY, "bookmark.add"); |
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 1674040b..2d767152 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
31 | #include <SDL_clipboard.h> | 31 | #include <SDL_clipboard.h> |
32 | #include <SDL_timer.h> | 32 | #include <SDL_timer.h> |
33 | 33 | ||
34 | #if defined (iPlatformApple) | 34 | #if defined (iPlatformAppleDesktop) |
35 | # include "macos.h" | 35 | # include "macos.h" |
36 | #endif | 36 | #endif |
37 | 37 | ||
@@ -39,7 +39,7 @@ static const int refreshInterval_InputWidget_ = 256; | |||
39 | static const size_t maxUndo_InputWidget_ = 64; | 39 | static const size_t maxUndo_InputWidget_ = 64; |
40 | 40 | ||
41 | static void enableEditorKeysInMenus_(iBool enable) { | 41 | static void enableEditorKeysInMenus_(iBool enable) { |
42 | #if defined (iPlatformApple) | 42 | #if defined (iPlatformAppleDesktop) |
43 | enableMenuItemsByKey_MacOS(SDLK_LEFT, KMOD_PRIMARY, enable); | 43 | enableMenuItemsByKey_MacOS(SDLK_LEFT, KMOD_PRIMARY, enable); |
44 | enableMenuItemsByKey_MacOS(SDLK_RIGHT, KMOD_PRIMARY, enable); | 44 | enableMenuItemsByKey_MacOS(SDLK_RIGHT, KMOD_PRIMARY, enable); |
45 | #else | 45 | #else |
diff --git a/src/ui/window.c b/src/ui/window.c index b198dd15..5c7fcaab 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
41 | #if defined (iPlatformMsys) | 41 | #if defined (iPlatformMsys) |
42 | # include "../win32.h" | 42 | # include "../win32.h" |
43 | #endif | 43 | #endif |
44 | #if defined (iPlatformApple) && !defined (iPlatformIOS) | 44 | #if defined (iPlatformAppleDesktop) |
45 | # include "macos.h" | 45 | # include "macos.h" |
46 | #endif | 46 | #endif |
47 | 47 | ||
@@ -92,7 +92,7 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) { | |||
92 | return iFalse; | 92 | return iFalse; |
93 | } | 93 | } |
94 | 94 | ||
95 | #if defined (iPlatformApple) | 95 | #if defined (iPlatformAppleDesktop) |
96 | # define iHaveNativeMenus | 96 | # define iHaveNativeMenus |
97 | #endif | 97 | #endif |
98 | 98 | ||
@@ -724,8 +724,10 @@ void init_Window(iWindow *d, iRect rect) { | |||
724 | d->isMouseInside = iTrue; | 724 | d->isMouseInside = iTrue; |
725 | d->focusGainedAt = 0; | 725 | d->focusGainedAt = 0; |
726 | uint32_t flags = 0; | 726 | uint32_t flags = 0; |
727 | #if defined (iPlatformApple) | 727 | #if defined (iPlatformAppleDesktop) |
728 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl"); | 728 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl"); |
729 | #elif defined (iPlatformAppleMobile) | ||
730 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal"); | ||
729 | #else | 731 | #else |
730 | flags |= SDL_WINDOW_OPENGL; | 732 | flags |= SDL_WINDOW_OPENGL; |
731 | #endif | 733 | #endif |