=> 32cbf877ac137b28eb41a9084717707907c02d94
[1mdiff --git a/src/macos.h b/src/macos.h[m [1mindex 22a6dfff..10cbba81 100644[m [1m--- a/src/macos.h[m [1m+++ b/src/macos.h[m [36m@@ -39,8 +39,10 @@[m [mvoid hideTitleBar_MacOS (iWindow *window);[m void insertMenuItems_MacOS (const char *menuLabel, int atIndex, const iMenuItem *items, size_t count);[m void removeMenu_MacOS (int atIndex);[m void enableMenu_MacOS (const char *menuLabel, iBool enable);[m [32m+[m[32mvoid enableMenuIndex_MacOS (int index, iBool enable);[m void enableMenuItem_MacOS (const char *menuItemCommand, iBool enable);[m void enableMenuItemsByKey_MacOS (int key, int kmods, iBool enable);[m [32m+[m[32mvoid enableMenuItemsOnHomeRow_MacOS(iBool enable);[m void handleCommand_MacOS (const char *cmd);[m [m void showPopupMenu_MacOS (iWidget *source, iInt2 windowCoord, const iMenuItem *items, size_t n);[m [1mdiff --git a/src/macos.m b/src/macos.m[m [1mindex cfbca488..28e349ea 100644[m [1m--- a/src/macos.m[m [1m+++ b/src/macos.m[m [36m@@ -31,6 +31,7 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m [m #include[m #include [m [32m+[m[32m#include [m [m #import [m [m [36m@@ -439,6 +440,13 @@[m [mvoid enableMenu_MacOS(const char *menuLabel, iBool enable) {[m [menuItem setEnabled:enable];[m }[m [m [32m+[m[32mvoid enableMenuIndex_MacOS(int index, iBool enable) {[m [32m+[m[32m NSApplication *app = [NSApplication sharedApplication];[m [32m+[m[32m NSMenu *appMenu = [app mainMenu];[m [32m+[m[32m NSMenuItem *menuItem = [appMenu itemAtIndex:index];[m [32m+[m[32m [menuItem setEnabled:enable];[m[41m [m [32m+[m[32m}[m [32m+[m void enableMenuItem_MacOS(const char *menuItemCommand, iBool enable) {[m NSApplication *app = [NSApplication sharedApplication];[m NSMenu *appMenu = [app mainMenu];[m [36m@@ -513,6 +521,47 @@[m [mvoid enableMenuItemsByKey_MacOS(int key, int kmods, iBool enable) {[m delete_String(keyEquiv);[m }[m [m [32m+[m[32mvoid enableMenuItemsOnHomeRow_MacOS(iBool enable) {[m [32m+[m[32m iStringSet *homeRowKeys = new_StringSet();[m [32m+[m[32m const char *keys[] = { /* Note: another array in documentwidget.c */[m [32m+[m[32m "f", "d", "s", "a",[m [32m+[m[32m "j", "k", "l",[m [32m+[m[32m "r", "e", "w", "q",[m [32m+[m[32m "u", "i", "o", "p",[m [32m+[m[32m "v", "c", "x", "z",[m [32m+[m[32m "m", "n",[m [32m+[m[32m "g", "h",[m [32m+[m[32m "b",[m [32m+[m[32m "t", "y"[m [32m+[m[32m };[m [32m+[m[32m iForIndices(i, keys) {[m [32m+[m[32m iString str;[m [32m+[m[32m initCStr_String(&str, keys[i]);[m [32m+[m[32m insert_StringSet(homeRowKeys, &str);[m [32m+[m[32m deinit_String(&str);[m [32m+[m[32m }[m [32m+[m[32m NSApplication *app = [NSApplication sharedApplication];[m [32m+[m[32m NSMenu *appMenu = [app mainMenu];[m [32m+[m[32m for (NSMenuItem *mainMenuItem in appMenu.itemArray) {[m [32m+[m[32m NSMenu *menu = mainMenuItem.submenu;[m [32m+[m[32m if (menu) {[m [32m+[m[32m for (NSMenuItem *menuItem in menu.itemArray) {[m [32m+[m[32m if (menuItem.keyEquivalentModifierMask == 0) {[m [32m+[m[32m iString equiv;[m [32m+[m[32m initCStr_String(&equiv, [menuItem.keyEquivalent[m [32m+[m[32m cStringUsingEncoding:NSUTF8StringEncoding]);[m [32m+[m[32m if (contains_StringSet(homeRowKeys, &equiv)) {[m [32m+[m[32m [menuItem setEnabled:enable];[m [32m+[m[32m [menu setAutoenablesItems:NO];[m [32m+[m[32m }[m [32m+[m[32m deinit_String(&equiv);[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m iRelease(homeRowKeys);[m [32m+[m[32m}[m [32m+[m static void setShortcut_NSMenuItem_(NSMenuItem *item, int key, int kmods) {[m NSEventModifierFlags modMask;[m iString *str = composeKeyEquivalent_(key, kmods, &modMask);[m [1mdiff --git a/src/ui/bindingswidget.c b/src/ui/bindingswidget.c[m [1mindex 4cf8df8e..13f9434e 100644[m [1m--- a/src/ui/bindingswidget.c[m [1m+++ b/src/ui/bindingswidget.c[m [36m@@ -143,12 +143,16 @@[m [mstatic void setActiveItem_BindingsWidget_(iBindingsWidget *d, size_t pos) {[m item->isWaitingForEvent = iTrue;[m invalidateItem_ListWidget(d->list, d->activePos);[m }[m [31m-#if defined (iPlatformAppleDesktop)[m [32m+[m[32m#if defined (iPlatformAppleDesktop) && defined (iHaveNativeContextMenus)[m /* Native menus must be disabled while grabbing keys so the shortcuts don't trigger. */[m const iBool enableNativeMenus = (d->activePos == iInvalidPos);[m [32m+[m[32m enableMenu_MacOS("${menu.title.file}", enableNativeMenus);[m enableMenu_MacOS("${menu.title.edit}", enableNativeMenus);[m enableMenu_MacOS("${menu.title.view}", enableNativeMenus);[m [32m+[m[32m enableMenu_MacOS("${menu.title.bookmarks}", enableNativeMenus);[m enableMenu_MacOS("${menu.title.identity}", enableNativeMenus);[m [32m+[m[32m enableMenuIndex_MacOS(6, enableNativeMenus);[m [32m+[m[32m enableMenuIndex_MacOS(7, enableNativeMenus);[m #endif[m }[m [m [1mdiff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c[m [1mindex 46af5fcd..f83539f7 100644[m [1m--- a/src/ui/documentwidget.c[m [1m+++ b/src/ui/documentwidget.c[m [36m@@ -55,6 +55,9 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m #include "visbuf.h"[m #include "visited.h"[m [m [32m+[m[32m#if defined (iPlatformAppleDesktop)[m [32m+[m[32m# include "macos.h"[m [32m+[m[32m#endif[m #if defined (iPlatformAppleMobile)[m # include "ios.h"[m #endif[m [36m@@ -469,11 +472,18 @@[m [mstatic void enableActions_DocumentWidget_(iDocumentWidget *d, iBool enable) {[m }[m [m static void setLinkNumberMode_DocumentWidget_(iDocumentWidget *d, iBool set) {[m [31m- iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, set);[m [31m- /* Children have priority when handling events. */[m [31m- enableActions_DocumentWidget_(d, !set);[m [31m- if (d->menu) {[m [31m- setFlags_Widget(d->menu, disabled_WidgetFlag, set);[m [32m+[m[32m if (((d->flags & showLinkNumbers_DocumentWidgetFlag) != 0) != set) {[m [32m+[m[32m iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, set);[m [32m+[m[32m /* Children have priority when handling events. */[m [32m+[m[32m enableActions_DocumentWidget_(d, !set);[m [32m+[m[32m#if defined (iPlatformAppleDesktop)[m [32m+[m[32m enableMenuItemsOnHomeRow_MacOS(!set);[m [32m+[m[32m#endif[m [32m+[m[32m /* Ensure all keyboard events come here first. */[m [32m+[m[32m setKeyboardGrab_Widget(set ? as_Widget(d) : NULL);[m [32m+[m[32m if (d->menu) {[m [32m+[m[32m setFlags_Widget(d->menu, disabled_WidgetFlag, set);[m [32m+[m[32m }[m }[m }[m [m [1mdiff --git a/src/ui/widget.c b/src/ui/widget.c[m [1mindex cedda461..28c34ccf 100644[m [1m--- a/src/ui/widget.c[m [1m+++ b/src/ui/widget.c[m [36m@@ -1961,7 +1961,8 @@[m [miBool isAffectedByVisualOffset_Widget(const iWidget *d) {[m }[m [m void setFocus_Widget(iWidget *d) {[m [31m- iWindow *win = get_Window();[m [32m+[m[32m iWindow *win = d ? window_Widget(d) : get_Window();[m [32m+[m[32m iAssert(win);[m if (win->focus != d) {[m if (win->focus) {[m iAssert(!contains_PtrSet(win->focus->root->pendingDestruction, win->focus));[m [36m@@ -1976,6 +1977,13 @@[m [mvoid setFocus_Widget(iWidget *d) {[m }[m }[m [m [32m+[m[32mvoid setKeyboardGrab_Widget(iWidget *d) {[m [32m+[m[32m iWindow *win = d ? window_Widget(d) : get_Window();[m [32m+[m[32m iAssert(win);[m [32m+[m[32m win->focus = d;[m [32m+[m[32m /* no notifications sent */[m [32m+[m[32m}[m [32m+[m iWidget *focus_Widget(void) {[m return get_Window()->focus;[m }[m [1mdiff --git a/src/ui/widget.h b/src/ui/widget.h[m [1mindex 4025f5c5..57088c07 100644[m [1m--- a/src/ui/widget.h[m [1m+++ b/src/ui/widget.h[m [36m@@ -302,7 +302,8 @@[m [mvoid scrollInfo_Widget (const iWidget *, iWidgetScrollInfo *inf[m [m int backgroundFadeColor_Widget (void);[m [m [31m-void setFocus_Widget (iWidget *);[m [32m+[m[32mvoid setFocus_Widget (iWidget *); /* widget must be flagged `focusable` */[m [32m+[m[32mvoid setKeyboardGrab_Widget (iWidget *); /* sets focus on any widget */[m iWidget * focus_Widget (void);[m void setHover_Widget (iWidget *);[m iWidget * hover_Widget (void);[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).