From ab3ed41e6d6a2f30e781c7202741e066a2b21d7b Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi

Date: Fri, 8 Apr 2022 06:31:47 +0300

Subject: [PATCH 1/1] macOS: Running without windows

Work in progress...


src/app.c | 986 ++++++++++++++++++++++++------------------------

src/ui/keys.c | 2 +-

src/ui/widget.c | 3 +

src/ui/window.c | 17 +-

4 files changed, 515 insertions(+), 493 deletions(-)

diff --git a/src/app.c b/src/app.c

index 3c354438..a6a2a0a2 100644

--- a/src/app.c

+++ b/src/app.c

@@ -1645,19 +1645,21 @@ void processEvents_App(enum iAppEventMode eventMode) {

                 }

             }

#endif

             iBool wasUsed = iFalse;

                 }

             }

             setCurrent_Window(d->window);

             if (!wasUsed) {

@@ -1778,7 +1780,14 @@ static int resizeWatcher_(void *user, SDL_Event *event) {

         dispatchEvent_Window(as_Window(d->window), &u);

     }

#endif

 }

 return 0;

}

@@ -2051,6 +2060,9 @@ void addWindow_App(iMainWindow *win) {

void removeWindow_App(iMainWindow *win) {

 iApp *d = &app_;

 removeOne_PtrArray(&d->mainWindows, win);

}

size_t numWindows_App(void) {

@@ -2386,11 +2398,6 @@ void closeWindow_App(iMainWindow *win) {

         }

     }

 }

}

static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) {

@@ -2552,36 +2559,10 @@ static void invalidateCachedDocuments_App_(void) {

 }

}

-iBool handleCommand_App(const char *cmd) {

+static iBool handleNonWindowRelatedCommand_App_(iApp *d, const char *cmd) {

 const iBool isFrozen = !d->window || d->window->isDrawFrozen;

-#if 0 /* disabled in v1.11 */

-#endif

     savePrefs_App_(d);

     return iTrue;

 }

@@ -2641,28 +2622,6 @@ iBool handleCommand_App(const char *cmd) {

     d->prefs.langTo   = argLabel_Command(cmd, "to");

     return iTrue;

 }

 else if (equal_Command(cmd, "window.retain")) {

     d->prefs.retainWindowSize = arg_Command(cmd);

     return iTrue;

@@ -2671,186 +2630,174 @@ iBool handleCommand_App(const char *cmd) {

     d->prefs.customFrame = arg_Command(cmd);

     return iTrue;

 }

 else if (equal_Command(cmd, "prefs.retaintabs.changed")) {

     d->prefs.retainTabs = arg_Command(cmd);

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     if (!isFrozen) {

         setFreezeDraw_MainWindow(get_MainWindow(), iTrue);

     }

     }

     }

     if (!isFrozen) {

         postCommand_App("window.unfreeze");

     }

     return iTrue;

 }

     }

     }

         postCommand_App("font.changed");

     }

     return iTrue;

 }

     }

     return iTrue;

 }

     return iTrue;

 }

     }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     d->prefs.theme = arg_Command(cmd);

     if (!isAuto) {

         if (isDark_ColorTheme(d->prefs.theme) && d->isDarkSystemTheme) {

@@ -2923,246 +2870,426 @@ iBool handleCommand_App(const char *cmd) {

     postCommand_App("document.layout.changed redo:1");

     return iTrue;

 }

     if (!isFrozen) {

     }

     }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

+#if defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT)

+#endif

     }

     }

     }

     }

     return iTrue;

 }

     }

     }

     }

     return iTrue;

 }

     }

     return iTrue;

 }

     }

     return iTrue;

 }

     }

     return iTrue;

 }

     return iTrue;

 }

+#if defined (LAGRANGE_ENABLE_IPC)

     }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

+#endif /* defined (LAGRANGE_ENABLE_IPC) */

 }

+}

+iBool handleCommand_App(const char *cmd) {

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     return iTrue;

 }

     }

     return iTrue;

 }

     }

     }

     }

     }

     return iTrue;

 }

-#if defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT)

-#endif

     }

     }

     return iTrue;

 }

     }

     }

     return iTrue;

 }

     }

     return iTrue;

 }

@@ -3337,20 +3464,6 @@ iBool handleCommand_App(const char *cmd) {

#endif

     return iFalse;

 }

 else if (equal_Command(cmd, "tabs.new")) {

     const iBool isDuplicate = argLabel_Command(cmd, "duplicate") != 0;

     newTab_App(isDuplicate ? document_App() : NULL, iTrue);

@@ -3411,12 +3524,16 @@ iBool handleCommand_App(const char *cmd) {

             }

         }

     }

+#if defined (iPlatformAppleDesktop)

+#else

     else if (numWindows_App() > 1) {

         closeWindow_App(d->window);

     }

     else {

         postCommand_App("quit");

     }

+#endif

     return iTrue;

 }

 else if (equal_Command(cmd, "keyroot.next")) {

@@ -3426,11 +3543,6 @@ iBool handleCommand_App(const char *cmd) {

     }

     return iTrue;

 }

 else if (equal_Command(cmd, "preferences")) {

     iWidget *dlg = makePreferences_Widget();

     updatePrefsThemeButtons_(dlg);

@@ -3618,27 +3730,6 @@ iBool handleCommand_App(const char *cmd) {

     }

     return iTrue;

 }

 else if (startsWith_CStr(cmd, "feeds.update.")) {

     const iWidget *navBar = findChild_Widget(get_Window()->roots[0]->widget, "navbar");

     iAnyObject *prog = findChild_Widget(navBar, "feeds.progress");

@@ -3663,10 +3754,6 @@ iBool handleCommand_App(const char *cmd) {

     }

     return iFalse;

 }

 else if (equal_Command(cmd, "document.changed")) {

     /* Set of open tabs has changed. */

     postCommand_App("document.openurls.changed");

@@ -3691,29 +3778,6 @@ iBool handleCommand_App(const char *cmd) {

     postRefresh_App();

     return iTrue;

 }

 else if (equal_Command(cmd, "ident.switch")) {

     /* This is different than "ident.signin" in that the currently used identity's activation

        URL is used instead of the current one. */

@@ -3733,33 +3797,6 @@ iBool handleCommand_App(const char *cmd) {

     }

     return iTrue;

 }

 else if (equal_Command(cmd, "fontpack.delete")) {

     const iString *packId = collect_String(suffix_Command(cmd, "id"));

     if (isEmpty_String(packId)) {

@@ -3840,35 +3877,6 @@ iBool handleCommand_App(const char *cmd) {

     }

     return iTrue;

 }

-#if defined (LAGRANGE_ENABLE_IPC)

-#endif /* defined (LAGRANGE_ENABLE_IPC) */

 else {

     return iFalse;

 }

diff --git a/src/ui/keys.c b/src/ui/keys.c

index 3428bcc8..40859f7c 100644

--- a/src/ui/keys.c

+++ b/src/ui/keys.c

@@ -451,7 +451,7 @@ void setLabel_Keys(int id, const char *label) {

iBool processEvent_Keys(const SDL_Event *ev) {

 iKeys *d = &keys_;

 if (ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP) {

     const iBinding *bind = find_Keys_(d, ev->key.keysym.sym, keyMods_Sym(ev->key.keysym.mod));

     if (bind) {

diff --git a/src/ui/widget.c b/src/ui/widget.c

index cb373c43..138b219e 100644

--- a/src/ui/widget.c

+++ b/src/ui/widget.c

@@ -2154,6 +2154,9 @@ static const iWidget *findFocusRoot_Widget_(const iWidget *d) {

}

iAny *findFocusable_Widget(const iWidget *startFrom, enum iWidgetFocusDir focusDir) {

 iRoot *uiRoot = (startFrom ? startFrom->root : get_Window()->keyRoot);

 const iWidget *focusRoot = findFocusRoot_Widget_(uiRoot->widget);

 iAssert(focusRoot != NULL);

diff --git a/src/ui/window.c b/src/ui/window.c

index cbfd0f5c..2ec64f0e 100644

--- a/src/ui/window.c

+++ b/src/ui/window.c

@@ -186,22 +186,32 @@ const iMenuItem topLevelMenus_Window[6] = {

#if defined (LAGRANGE_MAC_MENUBAR)

+static iBool macMenusInserted_;

static void insertMacMenus_(void) {

 insertMenuItems_MacOS("${menu.title.file}", 1, fileMenuItems_, iElemCount(fileMenuItems_));

 insertMenuItems_MacOS("${menu.title.edit}", 2, editMenuItems_, iElemCount(editMenuItems_));

 insertMenuItems_MacOS("${menu.title.view}", 3, viewMenuItems_, iElemCount(viewMenuItems_));

 insertMenuItems_MacOS("${menu.title.bookmarks}", 4, bookmarksMenuItems_, iElemCount(bookmarksMenuItems_));

 insertMenuItems_MacOS("${menu.title.identity}", 5, identityMenuItems_, iElemCount(identityMenuItems_));

 insertMenuItems_MacOS("${menu.title.help}", 7, helpMenuItems_, iElemCount(helpMenuItems_));

}

static void removeMacMenus_(void) {

 removeMenu_MacOS(7);

 removeMenu_MacOS(5);

 removeMenu_MacOS(4);

 removeMenu_MacOS(3);

 removeMenu_MacOS(2);

 removeMenu_MacOS(1);

}

#endif /* LAGRANGE_MAC_MENUBAR */

@@ -246,9 +256,7 @@ static void windowSizeChanged_MainWindow_(iMainWindow *d) {

static void setupUserInterface_MainWindow(iMainWindow *d) {

#if defined (LAGRANGE_MAC_MENUBAR)

#endif

 /* One root is created by default. */

 d->base.roots[0] = new_Root();

@@ -1652,6 +1660,9 @@ void setKeyboardHeight_MainWindow(iMainWindow *d, int height) {

iObjectList *listDocuments_MainWindow(iMainWindow *d, const iRoot *rootOrNull) {

 iObjectList *docs = new_ObjectList();

 iForIndices(i, d->base.roots) {

     iRoot *root = d->base.roots[i];

     if (!root) continue;

--

2.25.1

Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.13/patch/ab3ed41e6d6a2f30e781c7202741e066a2b21d7b.patch
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
559.911159 milliseconds
Gemini-to-HTML Time
12.912776 milliseconds

This content has been proxied by September (ba2dc).