summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt11
-rw-r--r--Depends-Android.cmake31
-rw-r--r--Depends.cmake5
-rw-r--r--Resources.cmake4
m---------lib/the_Foundation0
-rw-r--r--src/app.c39
-rw-r--r--src/main.c4
-rw-r--r--src/resources.c5
-rw-r--r--src/ui/documentwidget.c4
-rw-r--r--src/ui/touch.c4
-rw-r--r--src/ui/window.c10
11 files changed, 100 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 18789f9c..321014ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,7 +96,7 @@ set (RESOURCES
96 res/shadow.png 96 res/shadow.png
97 res/fontpack.ini 97 res/fontpack.ini
98) 98)
99file (GLOB FONTS RELATIVE ${CMAKE_SOURCE_DIR} res/fonts/*) 99file (GLOB FONTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} res/fonts/*)
100list (APPEND RESOURCES ${FONTS}) 100list (APPEND RESOURCES ${FONTS})
101if ((UNIX AND NOT APPLE) OR MSYS) 101if ((UNIX AND NOT APPLE) OR MSYS)
102 list (APPEND RESOURCES res/lagrange-64.png) 102 list (APPEND RESOURCES res/lagrange-64.png)
@@ -285,7 +285,12 @@ else ()
285endif () 285endif ()
286 286
287# Target. 287# Target.
288add_executable (app ${SOURCES} ${RESOURCES}) 288if (NOT ANDROID)
289 add_executable (app ${SOURCES} ${RESOURCES})
290else ()
291 # The whole app becomes one shared library, based on this static one.
292 add_library (app STATIC ${SOURCES})
293endif ()
289set_property (TARGET app PROPERTY C_STANDARD 11) 294set_property (TARGET app PROPERTY C_STANDARD 11)
290if (TARGET ext-deps) 295if (TARGET ext-deps)
291 add_dependencies (app ext-deps) 296 add_dependencies (app ext-deps)
@@ -445,6 +450,8 @@ elseif (HAIKU)
445 target_compile_definitions (app PUBLIC 450 target_compile_definitions (app PUBLIC
446 LAGRANGE_EMB_BIN="${CMAKE_INSTALL_PREFIX}/resources.lgr") 451 LAGRANGE_EMB_BIN="${CMAKE_INSTALL_PREFIX}/resources.lgr")
447 install (FILES ${EMB_BIN} DESTINATION .) 452 install (FILES ${EMB_BIN} DESTINATION .)
453elseif (ANDROID)
454 file (COPY ${EMB_BIN} DESTINATION ${CMAKE_SOURCE_DIR}/../app/src/main/assets)
448elseif (UNIX AND NOT APPLE) 455elseif (UNIX AND NOT APPLE)
449 include (GNUInstallDirs) 456 include (GNUInstallDirs)
450 set_target_properties (app PROPERTIES 457 set_target_properties (app PROPERTIES
diff --git a/Depends-Android.cmake b/Depends-Android.cmake
new file mode 100644
index 00000000..74635620
--- /dev/null
+++ b/Depends-Android.cmake
@@ -0,0 +1,31 @@
1if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/the_Foundation/.git)
2 message (FATAL_ERROR "'lib/the_Foundation' Git submodule not found")
3endif ()
4
5# the_Foundation is checked out as a submodule, make sure it's up to date.
6find_package (Git)
7if (GIT_FOUND)
8 execute_process (
9 COMMAND ${GIT_EXECUTABLE} submodule update
10 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
11 OUTPUT_VARIABLE subout
12 OUTPUT_STRIP_TRAILING_WHITESPACE
13 )
14 if (subout)
15 message (FATAL_ERROR "'lib/the_Foundation' Git submodule has been updated, please re-run CMake.\n")
16 endif ()
17endif ()
18
19set (INSTALL_THE_FOUNDATION OFF)
20set (TFDN_STATIC_LIBRARY ON CACHE BOOL "")
21set (TFDN_ENABLE_INSTALL OFF CACHE BOOL "")
22set (TFDN_ENABLE_TESTS OFF CACHE BOOL "")
23set (TFDN_ENABLE_WEBREQUEST OFF CACHE BOOL "")
24add_subdirectory (lib/the_Foundation)
25add_library (the_Foundation::the_Foundation ALIAS the_Foundation)
26if (NOT OPENSSL_FOUND)
27 message (FATAL_ERROR "Lagrange requires OpenSSL for TLS. Please check if pkg-config can find 'openssl'.")
28endif ()
29if (NOT ZLIB_FOUND)
30 message (FATAL_ERROR "Lagrange requires zlib for reading compressed archives. Please check if pkg-config can find 'zlib'.")
31endif () \ No newline at end of file
diff --git a/Depends.cmake b/Depends.cmake
index ca01b6c5..246f3398 100644
--- a/Depends.cmake
+++ b/Depends.cmake
@@ -3,6 +3,11 @@ if (IOS)
3 return () 3 return ()
4endif () 4endif ()
5 5
6if (ANDROID)
7 include (Depends-Android.cmake)
8 return ()
9endif ()
10
6find_package (PkgConfig) 11find_package (PkgConfig)
7find_program (MESON_EXECUTABLE meson DOC "Meson build system") 12find_program (MESON_EXECUTABLE meson DOC "Meson build system")
8find_program (NINJA_EXECUTABLE ninja DOC "Ninja build tool") 13find_program (NINJA_EXECUTABLE ninja DOC "Ninja build tool")
diff --git a/Resources.cmake b/Resources.cmake
index fc5d20c6..15ef15ea 100644
--- a/Resources.cmake
+++ b/Resources.cmake
@@ -16,11 +16,11 @@ function (make_resources dst)
16 file (REMOVE ${dst}) 16 file (REMOVE ${dst})
17 get_filename_component (dstName ${dst} NAME) 17 get_filename_component (dstName ${dst} NAME)
18 message (STATUS " ${dstName}") 18 message (STATUS " ${dstName}")
19 set (versionTempPath ${CMAKE_SOURCE_DIR}/res/VERSION) 19 set (versionTempPath ${CMAKE_CURRENT_SOURCE_DIR}/res/VERSION)
20 file (WRITE ${versionTempPath} ${PROJECT_VERSION}) 20 file (WRITE ${versionTempPath} ${PROJECT_VERSION})
21 execute_process ( 21 execute_process (
22 COMMAND ${ZIP_EXECUTABLE} -1 ${dst} VERSION ${files} 22 COMMAND ${ZIP_EXECUTABLE} -1 ${dst} VERSION ${files}
23 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/res 23 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res
24 OUTPUT_QUIET 24 OUTPUT_QUIET
25 ) 25 )
26 file (REMOVE ${versionTempPath}) 26 file (REMOVE ${versionTempPath})
diff --git a/lib/the_Foundation b/lib/the_Foundation
Subproject 92cbb82857c0794b250abe835b98c9ee1b9f9c1 Subproject 47e3a0f80dee74e008c3bd2895ae108debf94cc
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
diff --git a/src/main.c b/src/main.c
index 6e5e99e9..ad69c6df 100644
--- a/src/main.c
+++ b/src/main.c
@@ -67,9 +67,11 @@ int main(int argc, char **argv) {
67 "ECDHE-RSA-AES128-GCM-SHA256:" 67 "ECDHE-RSA-AES128-GCM-SHA256:"
68 "DHE-RSA-AES256-GCM-SHA384"); 68 "DHE-RSA-AES256-GCM-SHA384");
69 SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1"); 69 SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
70 SDL_SetHint(SDL_HINT_MAC_BACKGROUND_APP, "1");
70 SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, "1"); 71 SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, "1");
72#if SDL_VERSION_ATLEAST(2, 0, 8)
71 SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); 73 SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
72 SDL_SetHint(SDL_HINT_MAC_BACKGROUND_APP, "1"); 74#endif
73#if 0 75#if 0
74 SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1"); /* debugging! */ 76 SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1"); /* debugging! */
75#endif 77#endif
diff --git a/src/resources.c b/src/resources.c
index 0358e3a3..5c7e41ea 100644
--- a/src/resources.c
+++ b/src/resources.c
@@ -101,8 +101,9 @@ iBool init_Resources(const char *path) {
101 iBool ok = iFalse; 101 iBool ok = iFalse;
102#if defined (iPlatformAndroidMobile) 102#if defined (iPlatformAndroidMobile)
103 /* Resources are bundled as assets so they cannot be loaded as a regular file. 103 /* Resources are bundled as assets so they cannot be loaded as a regular file.
104 Fortunately, SDL implements a file wrapper. */ { 104 Fortunately, SDL implements a file wrapper. */
105 SDL_RWops *io = SDL_RWFromFile(path, "rb"); 105 SDL_RWops *io = SDL_RWFromFile(path, "rb");
106 if (io) {
106 iBlock buf; 107 iBlock buf;
107 init_Block(&buf, (size_t) SDL_RWsize(io)); 108 init_Block(&buf, (size_t) SDL_RWsize(io));
108 SDL_RWread(io, data_Block(&buf), size_Block(&buf), 1); 109 SDL_RWread(io, data_Block(&buf), size_Block(&buf), 1);
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 746e03e0..46af5fcd 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1224,10 +1224,6 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode
1224 case tooManyRedirects_GmStatusCode: 1224 case tooManyRedirects_GmStatusCode:
1225 appendFormat_String(src, "=> %s\n", cstr_String(meta)); 1225 appendFormat_String(src, "=> %s\n", cstr_String(meta));
1226 break; 1226 break;
1227 case tlsFailure_GmStatusCode:
1228// useBanner = iFalse; /* valid data wasn't received from host */
1229// appendFormat_String(src, ">%s\n", cstr_String(meta));
1230 break;
1231 case tlsServerCertificateExpired_GmStatusCode: 1227 case tlsServerCertificateExpired_GmStatusCode:
1232 makeFooterButtons_DocumentWidget_( 1228 makeFooterButtons_DocumentWidget_(
1233 d, 1229 d,
diff --git a/src/ui/touch.c b/src/ui/touch.c
index 195d1dff..d6846572 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -42,7 +42,11 @@ iDeclareType(TouchState)
42 42
43static const uint32_t longPressSpanMs_ = 500; 43static const uint32_t longPressSpanMs_ = 500;
44static const uint32_t shortPressSpanMs_ = 250; 44static const uint32_t shortPressSpanMs_ = 250;
45#if defined (iPlatformAndroidMobile)
46static const int tapRadiusPt_ = 30; /* inaccurate sensors? */
47#else
45static const int tapRadiusPt_ = 10; 48static const int tapRadiusPt_ = 10;
49#endif
46 50
47enum iTouchEdge { 51enum iTouchEdge {
48 none_TouchEdge, 52 none_TouchEdge,
diff --git a/src/ui/window.c b/src/ui/window.c
index 0bbe588c..9f12cabf 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -263,6 +263,10 @@ static float pixelRatio_Window_(const iWindow *d) {
263# define baseDPI_Window 96.0f 263# define baseDPI_Window 96.0f
264#endif 264#endif
265 265
266#if defined (iPlatformAndroidMobile)
267float displayDensity_Android(void);
268#endif
269
266static float displayScale_Window_(const iWindow *d) { 270static float displayScale_Window_(const iWindow *d) {
267 /* The environment variable LAGRANGE_OVERRIDE_DPI can be used to override the automatic 271 /* The environment variable LAGRANGE_OVERRIDE_DPI can be used to override the automatic
268 display DPI detection. If not set, or is an empty string, ignore it. 272 display DPI detection. If not set, or is an empty string, ignore it.
@@ -289,6 +293,8 @@ static float displayScale_Window_(const iWindow *d) {
289#elif defined (iPlatformMsys) 293#elif defined (iPlatformMsys)
290 iUnused(d); 294 iUnused(d);
291 return desktopDPI_Win32(); 295 return desktopDPI_Win32();
296#elif defined (iPlatformAndroidMobile)
297 return displayDensity_Android();
292#else 298#else
293 if (isRunningUnderWindowSystem_App()) { 299 if (isRunningUnderWindowSystem_App()) {
294 float vdpi = 0.0f; 300 float vdpi = 0.0f;
@@ -457,7 +463,7 @@ void init_Window(iWindow *d, enum iWindowType type, iRect rect, uint32_t flags)
457 d->mouseGrab = NULL; 463 d->mouseGrab = NULL;
458 d->focus = NULL; 464 d->focus = NULL;
459 d->pendingCursor = NULL; 465 d->pendingCursor = NULL;
460 d->isExposed = iFalse; 466 d->isExposed = (deviceType_App() != desktop_AppDeviceType);
461 d->isMinimized = iFalse; 467 d->isMinimized = iFalse;
462 d->isInvalidated = iFalse; /* set when posting event, to avoid repeated events */ 468 d->isInvalidated = iFalse; /* set when posting event, to avoid repeated events */
463 d->isMouseInside = iTrue; 469 d->isMouseInside = iTrue;
@@ -541,6 +547,8 @@ void init_MainWindow(iMainWindow *d, iRect rect) {
541 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal"); 547 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
542 flags |= SDL_WINDOW_METAL; 548 flags |= SDL_WINDOW_METAL;
543 d->base.isExposed = iTrue; 549 d->base.isExposed = iTrue;
550#elif defined (iPlatformAndroidMobile)
551 d->base.isExposed = iTrue;
544#else 552#else
545 if (!forceSoftwareRender_App()) { 553 if (!forceSoftwareRender_App()) {
546 flags |= SDL_WINDOW_OPENGL; 554 flags |= SDL_WINDOW_OPENGL;