Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 4, 2023
2 parents 1b9314f + d1ed75e commit ddc3485
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
cmake_minimum_required (VERSION 3.9)

project (Lagrange
VERSION 1.17.2
VERSION 1.17.3
DESCRIPTION "A Beautiful Gemini Client"
LANGUAGES C
)
Expand Down
6 changes: 6 additions & 0 deletions res/about/version.gmi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
```
# Release notes

## 1.17.3
* Fixed activating a pinned identity when opening a bookmark via the Bookmarks menu.
* Fixed initial scope of a created identity when using the default selection.
* Fixed issues with dropdown menus when the menu appears as a popup window.
* Fixed clearing the pinned identity of a bookmark.

## 1.17.2
* Tabs opened in background are immediately added to the URL history.
* Mouse wheel direction switches back to vertical when a wide block has been scrolled all the way.
Expand Down
2 changes: 1 addition & 1 deletion src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -3337,7 +3337,7 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) {
organization,
country);
/* Use in the chosen scope. */ {
int selScope = 2;
int selScope = 0;
const char *scopeCmd =
selectedDropdownCommand_LabelWidget(findChild_Widget(dlg, "ident.scope"));
if (startsWith_CStr(scopeCmd, "ident.scope arg:")) {
Expand Down
4 changes: 4 additions & 0 deletions src/ui/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,14 @@ const iPtrArray *list_Keys(void) {
}

iBool isDown_Keys(const iBinding *binding) {
#if defined (iPlatformTerminal)
return iFalse;
#else
int numKeys = 0;
const uint8_t *keys = SDL_GetKeyboardState(&numKeys);
const int scancode = SDL_GetScancodeFromKey(binding->key);
const int scancode2 = (scancode == SDL_SCANCODE_RALT ? SDL_SCANCODE_LALT :
scancode == SDL_SCANCODE_LALT ? SDL_SCANCODE_RALT : scancode);
return (scancode < numKeys && keys[scancode]) || (scancode2 < numKeys && keys[scancode2]);
#endif
}
4 changes: 2 additions & 2 deletions src/ui/labelwidget.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ static iBool checkModifiers_(int have, int req) {

static void trigger_LabelWidget_(const iLabelWidget *d) {
const iWidget *w = constAs_Widget(d);
postCommand_Widget(&d->widget, "%s", cstr_String(&d->command));
postCommand_Widget(w, "%s", cstr_String(&d->command));
if (flags_Widget(w) & radio_WidgetFlag) {
iForEach(ObjectList, i, children_Widget(w->parent)) {
setFlags_Widget(i.object, selected_WidgetFlag, d == i.object);
}
}
/* Triggering a menu item will always close all popup menus. */
if (d->flags.menuCanceling) {
postCommand_Widget(&d->widget, "menu.cancel");
postCommand_Root(NULL, "menu.cancel");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/sidebarwidget.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *c
if (bm) {
set_String(&bm->identity, string_Command(cmd, "fp"));
updateDropdownSelection_LabelWidget(findChild_Widget(editor, "bmed.setident"),
cstr_String(&bm->identity));
format_CStr(" fp:%s", cstr_String(&bm->identity)));
}
return iTrue;
}
Expand Down Expand Up @@ -1740,7 +1740,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
setToggle_Widget(remoteSourceTag, bm->flags & remoteSource_BookmarkFlag);
setToggle_Widget(linkSplitTag, bm->flags & linkSplit_BookmarkFlag);
updateDropdownSelection_LabelWidget(findChild_Widget(dlg, "bmed.setident"),
format_CStr("bmed.setident fp:%s",
format_CStr(" fp:%s",
cstr_String(&bm->identity)));
}
setBookmarkEditorParentFolder_Widget(dlg, bm ? bm->parentId : 0);
Expand Down
8 changes: 6 additions & 2 deletions src/ui/text_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ iLocalDef iBool isMeasuring_(enum iRunMode mode) {
}

static void runSimple_Font_(iFont *d, const iRunArgs *args) {
/* This function shapes text using a simplified, incomplete algorithm. It works for English
/* This function shapes text using a simplified, incomplete algorithm. It works for English
and other non-complex LTR scripts. Composed glyphs are not supported (must rely on text
being in a pre-composed form). This algorithm is used if HarfBuzz is not available. */
const iInt2 orig = args->pos;
Expand Down Expand Up @@ -146,7 +146,11 @@ static void runSimple_Font_(iFont *d, const iRunArgs *args) {
iColor clr = get_Color(args->color);
ansiColors_Color(capturedRange_RegExpMatch(&m, 1),
current_Text()->baseFgColorId,
none_ColorId, &clr, NULL);
none_ColorId,
iFalse,
&clr,
NULL,
NULL);
#if defined (LAGRANGE_ENABLE_STB_TRUETYPE)
SDL_SetTextureColorMod(cache, clr.r, clr.g, clr.b);
#endif
Expand Down
35 changes: 30 additions & 5 deletions src/ui/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ void setNativeMenuItems_Widget(iWidget *menu, const iMenuItem *items, size_t n)
#endif
}

iWidget *parentMenu_Widget(iWidget *menuItem) {
iWidget *parentMenu_Widget(const iWidget *menuItem) {
if (parent_Widget(menuItem)) {
if (!cmp_String(id_Widget(parent_Widget(menuItem)), "menu")) {
return parent_Widget(menuItem);
Expand Down Expand Up @@ -1531,10 +1531,12 @@ void openMenuAnchorFlags_Widget(iWidget *d, iRect windowAnchorRect, int menuOpen
}
}
iWindow *win = newPopup_Window(menuPos, d); /* window takes the widget */
#if !defined (iPlatformTerminal)
if (isFromMenuBar && menuPos.y + menuSize.y > bottom_Rect(displayRect)) {
const int maxMenuHeight = bottom_Rect(displayRect) - menuPos.y;
SDL_SetWindowMaximumSize(win->win, displayRect.size.x, maxMenuHeight);
}
#endif
setCurrent_Window(win);
SDL_SetWindowTitle(win->win, "Menu");
arrange_Widget(d);
Expand Down Expand Up @@ -1827,11 +1829,34 @@ static const iString *replaceNewlinesWithDash_(const iString *str) {
return collect_String(mod);
}

iWidget *dropdownMenu_Widget(const iWidget *dropButton) {
if (!dropButton) {
return NULL;
}
iWidget *menu = findChild_Widget(dropButton, "menu");
if (!menu) {
if (dropButton->flags2 & childMenuOpenedAsPopup_WidgetFlag2) {
/* The menu has been migrated temporarily into a popup window. We need to locate
the right popup. */
iConstForEach(PtrArray, p, popupWindows_App()) {
const iWindow *win = p.ptr;
iWidget *winRoot = win->roots[0]->widget;
if (userData_Object(winRoot) == dropButton) {
iAssert(!cmp_String(id_Widget(winRoot), "menu"));
return winRoot;
}
}
}
}
iAssert(menu);
return menu;
}

void updateDropdownSelection_LabelWidget(iLabelWidget *dropButton, const char *selectedCommand) {
if (!dropButton) {
return;
}
iWidget *menu = findChild_Widget(as_Widget(dropButton), "menu");
iWidget *menu = dropdownMenu_Widget(as_Widget(dropButton));
if (flags_Widget(menu) & nativeMenu_WidgetFlag) {
unselectAllNativeMenuItems_Widget(menu);
iMenuItem *item = findNativeMenuItem_Widget(menu, selectedCommand);
Expand Down Expand Up @@ -1866,7 +1891,7 @@ const char *selectedDropdownCommand_LabelWidget(const iLabelWidget *dropButton)
if (!dropButton) {
return "";
}
iWidget *menu = findChild_Widget(constAs_Widget(dropButton), "menu");
iWidget *menu = dropdownMenu_Widget(constAs_Widget(dropButton));
if (flags_Widget(menu) & nativeMenu_WidgetFlag) {
iConstForEach(Array, i, userData_Object(menu)) {
const iMenuItem *item = i.value;
Expand Down Expand Up @@ -4054,7 +4079,7 @@ iWidget *makeBookmarkEditor_Widget(uint32_t folderId, iBool withDup) {
iClob(makeHeading_Widget(isFolder ? "${dlg.bookmark.parentfolder}"
: "${dlg.bookmark.folder}")));
const iArray *folderItems =
makeBookmarkFolderActions_MenuItem("dlg.bookmark.setfolder", iFalse, folderId);
makeBookmarkFolderActions_MenuItem("!dlg.bookmark.setfolder", iFalse, folderId);
iLabelWidget *folderButton;
setId_Widget(addChildFlags_Widget(values,
iClob(folderButton = makeMenuButton_LabelWidget(
Expand Down Expand Up @@ -4136,7 +4161,7 @@ static iBool handleBookmarkCreationCommands_SidebarWidget_(iWidget *editor, cons
const iString *fp = string_Command(cmd, "fp");
iLabelWidget *setident = findChild_Widget(editor, "bmed.setident");
set_String(&as_Widget(setident)->data, fp);
updateDropdownSelection_LabelWidget(setident, cstr_String(fp));
updateDropdownSelection_LabelWidget(setident, format_CStr(" fp:%s", cstr_String(fp)));
return iTrue;
}
if (equal_Command(cmd, "bmed.accept") || equal_Command(cmd, "bmed.cancel")) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void setMenuItemLabel_Widget (iWidget *menu, const char *comm
void setMenuItemLabelByIndex_Widget (iWidget *menu, size_t index, const char *newLabel);
void setNativeMenuItems_Widget (iWidget *menu, const iMenuItem *items, size_t n);
iWidget * findUserData_Widget (iWidget *, void *userData);
iWidget * parentMenu_Widget (iWidget *menuItem);
iWidget * parentMenu_Widget (const iWidget *menuItem);

int checkContextMenu_Widget (iWidget *, const SDL_Event *ev); /* see macro below */
void animateToRootVisibleTop_Widget (iWidget *, uint32_t span);
Expand Down
9 changes: 9 additions & 0 deletions src/ui/widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,15 @@ void postCommand_Widget(const iAnyObject *d, const char *cmd, ...) {
}
if (!isGlobal) {
iAssert(isInstance_Object(d, &Class_Widget));
if (type_Window(window_Widget(d)) == popup_WindowType) {
/* Use the original parent root for the command, so it will be handled by
whoever owns the popup menu. */
const iWidget *originalParent =
constAs_Widget(userData_Object(parentMenu_Widget(constAs_Widget(d))));
if (originalParent) {
d = originalParent;
}
}
iString ptrStr;
init_String(&ptrStr);
/* Insert the widget pointer as the first argument so possible suffixes are unaffected. */
Expand Down
12 changes: 10 additions & 2 deletions src/ui/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ void init_MainWindow(iMainWindow *d, iRect rect) {
SDL_Surface *surf = loadImage_(&imageLogo_Resources, 0);
d->logo = SDL_CreateTextureFromSurface(d->base.render, surf);
SDL_SetTextureBlendMode(d->logo, SDL_BLENDMODE_BLEND);
#if SDL_VERSION_ATLEAST(2, 0, 12)
#if SDL_VERSION_ATLEAST(2, 0, 12) && !defined (iPlatformTerminal)
SDL_SetTextureScaleMode(d->logo, SDL_ScaleModeBest);
#endif
free(surf->pixels);
Expand Down Expand Up @@ -2370,14 +2370,22 @@ const iArray *updateBookmarksMenu_Widget(iWidget *menu) {
}
#endif
}
iString *setIdentArg = NULL;
if (!isEmpty_String(&bm->identity)) {
setIdentArg = copy_String(&bm->identity);
prependCStr_String(setIdentArg, " setident:");
}
pushBack_Array(
dest,
&(iMenuItem){ format_CStr("%s %s", cstr_String(&iconStr), cstr_String(title)),
0,
0,
isFolder_Bookmark(bm)
? format_CStr("submenu id:bfmenu.%d", id_Bookmark(bm))
: format_CStr("!open url:%s", cstr_String(&bm->url)) });
: format_CStr("!open%s url:%s",
setIdentArg ? cstr_String(setIdentArg) : "",
cstr_String(&bm->url)) });
delete_String(setIdentArg);
deinit_String(&iconStr);
}
/* Create folder menus. */
Expand Down

0 comments on commit ddc3485

Please sign in to comment.