summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/app.c b/src/app.c
index a2de03ca..bfac84d9 100644
--- a/src/app.c
+++ b/src/app.c
@@ -92,7 +92,10 @@ static const char *defaultDataDir_App_ = "~/Library/Application Support";
92#define EMB_BIN "../resources.lgr" 92#define EMB_BIN "../resources.lgr"
93static const char *defaultDataDir_App_ = "~/AppData/Roaming/fi.skyjake.Lagrange"; 93static const char *defaultDataDir_App_ = "~/AppData/Roaming/fi.skyjake.Lagrange";
94#endif 94#endif
95#if defined (iPlatformLinux) || defined (iPlatformOther) 95#if defined (iPlatformAndroidMobile)
96#define EMB_BIN "resources.lgr" /* loaded from assets with SDL_rwops */
97static const char *defaultDataDir_App_ = NULL; /* will ask SDL */
98#elif defined (iPlatformLinux) || defined (iPlatformOther)
96#define EMB_BIN "../../share/lagrange/resources.lgr" 99#define EMB_BIN "../../share/lagrange/resources.lgr"
97#define EMB_BIN2 "../../../share/lagrange/resources.lgr" 100#define EMB_BIN2 "../../../share/lagrange/resources.lgr"
98static const char *defaultDataDir_App_ = "~/.config/lagrange"; 101static const char *defaultDataDir_App_ = "~/.config/lagrange";
@@ -137,6 +140,9 @@ struct Impl_App {
137 int autoReloadTimer; 140 int autoReloadTimer;
138 iPeriodic periodic; 141 iPeriodic periodic;
139 int warmupFrames; /* forced refresh just after resuming from background; FIXME: shouldn't be needed */ 142 int warmupFrames; /* forced refresh just after resuming from background; FIXME: shouldn't be needed */
143#if defined (iPlatformAndroidMobile)
144 float displayDensity;
145#endif
140 /* Preferences: */ 146 /* Preferences: */
141 iBool commandEcho; /* --echo */ 147 iBool commandEcho; /* --echo */
142 iBool forceSoftwareRender; /* --sw */ 148 iBool forceSoftwareRender; /* --sw */
@@ -300,7 +306,10 @@ static const char *dataDir_App_(void) {
300 return userDir; 306 return userDir;
301 } 307 }
302#endif 308#endif
303 return defaultDataDir_App_; 309 if (defaultDataDir_App_) {
310 return defaultDataDir_App_;
311 }
312 return SDL_GetPrefPath("Jaakko Keränen", "fi.skyjake.lagrange");
304} 313}
305 314
306static const char *downloadDir_App_(void) { 315static const char *downloadDir_App_(void) {
@@ -698,7 +707,7 @@ static iBool hasCommandLineOpenableScheme_(const iRangecc uri) {
698} 707}
699 708
700static void init_App_(iApp *d, int argc, char **argv) { 709static void init_App_(iApp *d, int argc, char **argv) {
701#if defined (iPlatformLinux) 710#if defined (iPlatformLinux) && !defined (iPlatformAndroid)
702 d->isRunningUnderWindowSystem = !iCmpStr(SDL_GetCurrentVideoDriver(), "x11") || 711 d->isRunningUnderWindowSystem = !iCmpStr(SDL_GetCurrentVideoDriver(), "x11") ||
703 !iCmpStr(SDL_GetCurrentVideoDriver(), "wayland"); 712 !iCmpStr(SDL_GetCurrentVideoDriver(), "wayland");
704#else 713#else
@@ -745,6 +754,8 @@ static void init_App_(iApp *d, int argc, char **argv) {
745 } 754 }
746 } 755 }
747 init_Lang(); 756 init_Lang();
757 iStringList *openCmds = new_StringList();
758#if !defined (iPlatformAndroidMobile)
748 /* Configure the valid command line options. */ { 759 /* Configure the valid command line options. */ {
749 defineValues_CommandLine(&d->args, "close-tab", 0); 760 defineValues_CommandLine(&d->args, "close-tab", 0);
750 defineValues_CommandLine(&d->args, "echo;E", 0); 761 defineValues_CommandLine(&d->args, "echo;E", 0);
@@ -759,7 +770,6 @@ static void init_App_(iApp *d, int argc, char **argv) {
759 defineValues_CommandLine(&d->args, "sw", 0); 770 defineValues_CommandLine(&d->args, "sw", 0);
760 defineValues_CommandLine(&d->args, "version;V", 0); 771 defineValues_CommandLine(&d->args, "version;V", 0);
761 } 772 }
762 iStringList *openCmds = new_StringList();
763 /* Handle command line options. */ { 773 /* Handle command line options. */ {
764 if (contains_CommandLine(&d->args, "help")) { 774 if (contains_CommandLine(&d->args, "help")) {
765 puts(cstr_Block(&blobArghelp_Resources)); 775 puts(cstr_Block(&blobArghelp_Resources));
@@ -808,6 +818,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
808 } 818 }
809 } 819 }
810 } 820 }
821#endif
811#if defined (LAGRANGE_ENABLE_IPC) 822#if defined (LAGRANGE_ENABLE_IPC)
812 /* Only one instance is allowed to run at a time; the runtime files (bookmarks, etc.) 823 /* Only one instance is allowed to run at a time; the runtime files (bookmarks, etc.)
813 are not shareable. */ { 824 are not shareable. */ {
@@ -842,7 +853,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
842 /* Must scale by UI scaling factor. */ 853 /* Must scale by UI scaling factor. */
843 mulfv_I2(&d->initialWindowRect.size, desktopDPI_Win32()); 854 mulfv_I2(&d->initialWindowRect.size, desktopDPI_Win32());
844#endif 855#endif
845#if defined (iPlatformLinux) 856#if defined (iPlatformLinux) && !defined (iPlatformAndroid)
846 /* Scale by the primary (?) monitor DPI. */ 857 /* Scale by the primary (?) monitor DPI. */
847 if (isRunningUnderWindowSystem_App()) { 858 if (isRunningUnderWindowSystem_App()) {
848 float vdpi; 859 float vdpi;
@@ -1301,6 +1312,15 @@ void processEvents_App(enum iAppEventMode eventMode) {
1301 } 1312 }
1302 ev.key.keysym.mod = mapMods_Keys(ev.key.keysym.mod & ~KMOD_CAPS); 1313 ev.key.keysym.mod = mapMods_Keys(ev.key.keysym.mod & ~KMOD_CAPS);
1303 } 1314 }
1315#if defined (iPlatformAndroidMobile)
1316 /* Ignore all mouse events; just use touch. */
1317 if (ev.type == SDL_MOUSEBUTTONDOWN ||
1318 ev.type == SDL_MOUSEBUTTONUP ||
1319 ev.type == SDL_MOUSEMOTION ||
1320 ev.type == SDL_MOUSEWHEEL) {
1321 continue;
1322 }
1323#endif
1304 /* Scroll events may be per-pixel or mouse wheel steps. */ 1324 /* Scroll events may be per-pixel or mouse wheel steps. */
1305 if (ev.type == SDL_MOUSEWHEEL) { 1325 if (ev.type == SDL_MOUSEWHEEL) {
1306#if defined (iPlatformAppleDesktop) 1326#if defined (iPlatformAppleDesktop)
@@ -1759,6 +1779,8 @@ enum iAppDeviceType deviceType_App(void) {
1759 return tablet_AppDeviceType; 1779 return tablet_AppDeviceType;
1760#elif defined (iPlatformAppleMobile) 1780#elif defined (iPlatformAppleMobile)
1761 return isPhone_iOS() ? phone_AppDeviceType : tablet_AppDeviceType; 1781 return isPhone_iOS() ? phone_AppDeviceType : tablet_AppDeviceType;
1782#elif defined (iPlatformAndroidMobile)
1783 return phone_AppDeviceType; /* TODO: Java side could tell us via cmdline if this is a tablet. */
1762#else 1784#else
1763 return desktop_AppDeviceType; 1785 return desktop_AppDeviceType;
1764#endif 1786#endif
@@ -3350,3 +3372,10 @@ void closePopups_App(void) {
3350 } 3372 }
3351 } 3373 }
3352} 3374}
3375
3376#if defined (iPlatformAndroidMobile)
3377float displayDensity_Android(void) {
3378 iApp *d = &app_;
3379 return toFloat_String(at_CommandLine(&d->args, 1));
3380}
3381#endif