Skip to content

Commit 403463e

Browse files
author
Chris Warren-Smith
committed
SDL: updates for flatpak build
1 parent fc53d2a commit 403463e

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/common/sys.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ extern "C" {
7171
#endif
7272

7373
// SB's constants
74-
#if defined(_SDL)
75-
#define SB_STR_VER VERSION " SDL " _SDL_VERSION SB_VERSYS SB_BIT_SZ BUILD_DATE
74+
#if defined(_SDL) && defined(_FLATPAK)
75+
#define SB_STR_VER VERSION " FLATPAK SDL " _SDL_VERSION SB_VERSYS SB_BIT_SZ BUILD_DATE
76+
#elif defined(_SDL)
77+
#define SB_STR_VER VERSION " SDL " _SDL_VERSION SB_VERSYS SB_BIT_SZ BUILD_DATE
7678
#elif defined (_ANDROID)
7779
#define SB_STR_VER VERSION " Android " BUILD_DATE
7880
#elif defined (_FLTK)

src/platform/android/app/src/main/assets/main.bas

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const colNav = theme.text1
1515
const colNav2 = theme.text6
1616
const menu_gap = -(char_w / 2)
1717
const is_android = instr(sbver, "Android") != 0
18+
const is_sandboxed_fs = len(env("SANDBOXED_FS")) > 0
1819
const is_sdl = instr(sbver, "SDL") != 0
1920
const path_sep = iff(instr(sbver, "Win_") != 0, "\\", "/")
2021
const onlineUrl = "http://smallbasic.github.io/samples/index.bas"
@@ -366,6 +367,8 @@ sub loadFileList(path, byref basList)
366367
if (len(path) > 0) then
367368
dirwalk path, "", use androidWalker(x)
368369
endif
370+
else if (is_sandboxed_fs) then
371+
dirwalk path, "", use androidWalker(x)
369372
else
370373
dirwalk path, "", use walker(x)
371374
endif
@@ -435,7 +438,10 @@ sub listFiles(byref frm, path, sortDir, byref basList)
435438
frm.inputs << bn
436439
end
437440

438-
if (is_android) then
441+
if (is_sandboxed_fs) then
442+
mk_folder_link(path)
443+
mk_link(sortNameId, "[Name]", name_col, 0, -linespacing)
444+
else if (is_android) then
439445
mk_link(sortNameId, "[Name]", name_col, 0, -linespacing)
440446
else
441447
mk_folder_link(path)

src/platform/sdl/editor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,11 @@ void Runtime::editSource(String loadPath, bool restoreOnExit) {
387387
case SB_KEY_F(7):
388388
debugStep(editWidget, helpWidget, true);
389389
break;
390+
#if !defined(_FLATPAK)
390391
case SB_KEY_F(8):
391392
exportRun(loadPath);
392393
break;
394+
#endif
393395
case SB_KEY_F(9):
394396
case SB_KEY_CTRL('r'):
395397
_state = kRunState;

src/platform/sdl/settings.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,13 @@ void restoreSettings(SDL_Rect &rect, int &fontScale, bool debug, bool restoreDir
201201
g_themeId = 0;
202202
}
203203

204+
#if defined(_FLATPAK)
204205
// start in the flatpak sandbox home
205-
if (getenv("XDG_DATA_HOME")) {
206-
chdir(getenv("XDG_DATA_HOME"));
207-
}
206+
chdir(getenv("XDG_DATA_HOME"));
207+
208+
// for main.bas handling is_sandboxed_fs
209+
setenv("SANDBOXED_FS", "true", 1);
210+
#endif
208211

209212
// restore export settings
210213
if (!debug) {

0 commit comments

Comments
 (0)