Skip to content

Commit

Permalink
Swap Ctrl and Super (Command on Mac)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-dyshel committed Aug 13, 2019
1 parent 4ef8f11 commit a076d0c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
26 changes: 13 additions & 13 deletions glfw/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ static int translateFlags(NSUInteger flags)
if (flags & NSEventModifierFlagShift)
mods |= GLFW_MOD_SHIFT;
if (flags & NSEventModifierFlagControl)
mods |= GLFW_MOD_CONTROL;
mods |= GLFW_MOD_SUPER;
if (flags & NSEventModifierFlagOption)
mods |= GLFW_MOD_ALT;
if (flags & NSEventModifierFlagCommand)
mods |= GLFW_MOD_SUPER;
mods |= GLFW_MOD_CONTROL;
if (flags & NSEventModifierFlagCapsLock)
mods |= GLFW_MOD_CAPS_LOCK;

Expand Down Expand Up @@ -371,13 +371,13 @@ static NSUInteger translateKeyToModifierFlag(int key)
return NSEventModifierFlagShift;
case GLFW_KEY_LEFT_CONTROL:
case GLFW_KEY_RIGHT_CONTROL:
return NSEventModifierFlagControl;
return NSEventModifierFlagCommand;
case GLFW_KEY_LEFT_ALT:
case GLFW_KEY_RIGHT_ALT:
return NSEventModifierFlagOption;
case GLFW_KEY_LEFT_SUPER:
case GLFW_KEY_RIGHT_SUPER:
return NSEventModifierFlagCommand;
return NSEventModifierFlagControl;
case GLFW_KEY_CAPS_LOCK:
return NSEventModifierFlagCapsLock;
}
Expand Down Expand Up @@ -885,11 +885,11 @@ - (void)updateTrackingAreas
if (flags & NSEventModifierFlagShift)
mods |= shiftKey;
if (flags & NSEventModifierFlagControl)
mods |= controlKey;
mods |= cmdKey;
if (flags & NSEventModifierFlagOption)
mods |= optionKey;
if (flags & NSEventModifierFlagCommand)
mods |= cmdKey;
mods |= controlKey;
if (flags & NSEventModifierFlagCapsLock)
mods |= alphaLock;

Expand Down Expand Up @@ -1313,18 +1313,18 @@ static void createMenuBar(void)
[appMenu addItem:[NSMenuItem separatorItem]];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
action:@selector(hide:)
keyEquivalent:@"h"];
keyEquivalent:@""];
[[appMenu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:)
keyEquivalent:@"h"]
keyEquivalent:@""]
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
[appMenu addItemWithTitle:@"Show All"
action:@selector(unhideAllApplications:)
keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
action:@selector(terminate:)
keyEquivalent:@"q"];
keyEquivalent:@""];

NSMenuItem* windowMenuItem =
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
Expand All @@ -1335,7 +1335,7 @@ static void createMenuBar(void)

[windowMenu addItemWithTitle:@"Minimize"
action:@selector(performMiniaturize:)
keyEquivalent:@"m"];
keyEquivalent:@""];
[windowMenu addItemWithTitle:@"Zoom"
action:@selector(performZoom:)
keyEquivalent:@""];
Expand All @@ -1348,7 +1348,7 @@ static void createMenuBar(void)
[windowMenu addItem:[NSMenuItem separatorItem]];
[[windowMenu addItemWithTitle:@"Enter Full Screen"
action:@selector(toggleFullScreen:)
keyEquivalent:@"f"]
keyEquivalent:@""]
setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];

// Prior to Snow Leopard, we need to use this oddly-named semi-private API
Expand Down Expand Up @@ -2257,11 +2257,11 @@ GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, unsigned sho
if (glfw_mods & GLFW_MOD_SHIFT)
*cocoa_mods |= NSEventModifierFlagShift;
if (glfw_mods & GLFW_MOD_CONTROL)
*cocoa_mods |= NSEventModifierFlagControl;
*cocoa_mods |= NSEventModifierFlagCommand;
if (glfw_mods & GLFW_MOD_ALT)
*cocoa_mods |= NSEventModifierFlagOption;
if (glfw_mods & GLFW_MOD_SUPER)
*cocoa_mods |= NSEventModifierFlagCommand;
*cocoa_mods |= NSEventModifierFlagControl;
if (glfw_mods & GLFW_MOD_CAPS_LOCK)
*cocoa_mods |= NSEventModifierFlagCapsLock;

Expand Down
8 changes: 4 additions & 4 deletions glfw/glfw3.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,13 @@ extern "C" {
#define GLFW_KEY_KP_ENTER 335
#define GLFW_KEY_KP_EQUAL 336
#define GLFW_KEY_LEFT_SHIFT 340
#define GLFW_KEY_LEFT_CONTROL 341
#define GLFW_KEY_LEFT_CONTROL 343
#define GLFW_KEY_LEFT_ALT 342
#define GLFW_KEY_LEFT_SUPER 343
#define GLFW_KEY_LEFT_SUPER 341
#define GLFW_KEY_RIGHT_SHIFT 344
#define GLFW_KEY_RIGHT_CONTROL 345
#define GLFW_KEY_RIGHT_CONTROL 347
#define GLFW_KEY_RIGHT_ALT 346
#define GLFW_KEY_RIGHT_SUPER 347
#define GLFW_KEY_RIGHT_SUPER 345
#define GLFW_KEY_MENU 348

#define GLFW_KEY_LAST GLFW_KEY_MENU
Expand Down
2 changes: 1 addition & 1 deletion kittens/diff/config_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def syntax_aliases(raw):
c('select_fg', 'black')

g('shortcuts')
k('quit', 'q', 'quit', _('Quit'))
k(' ', 'q', 'quit', _('Quit'))
k('quit', 'esc', 'quit', _('Quit'))

k('scroll_down', 'j', 'scroll_by 1', _('Scroll down'))
Expand Down
12 changes: 6 additions & 6 deletions kitty/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ - (void)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type {
action:@selector(orderFrontStandardAboutPanel:)
keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]];
NSMenuItem* preferences_menu_item = [[NSMenuItem alloc] initWithTitle:@"Preferences..." action:@selector(show_preferences:) keyEquivalent:@","], *new_os_window_menu_item = NULL;
NSMenuItem* preferences_menu_item = [[NSMenuItem alloc] initWithTitle:@"Preferences..." action:@selector(show_preferences:) keyEquivalent:@""], *new_os_window_menu_item = NULL;
[preferences_menu_item setTarget:global_menu_target];
[appMenu addItem:preferences_menu_item];
if (new_window_key) {
Expand All @@ -262,10 +262,10 @@ - (void)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type {

[appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", app_name]
action:@selector(hide:)
keyEquivalent:@"h"];
keyEquivalent:@""];
[[appMenu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:)
keyEquivalent:@"h"]
keyEquivalent:@""]
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
[appMenu addItemWithTitle:@"Show All"
action:@selector(unhideAllApplications:)
Expand All @@ -283,7 +283,7 @@ - (void)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type {

[appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", app_name]
action:@selector(terminate:)
keyEquivalent:@"q"];
keyEquivalent:@""];
[appMenu release];

NSMenuItem* windowMenuItem =
Expand All @@ -293,7 +293,7 @@ - (void)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type {

[windowMenu addItemWithTitle:@"Minimize"
action:@selector(performMiniaturize:)
keyEquivalent:@"m"];
keyEquivalent:@""];
[windowMenu addItemWithTitle:@"Zoom"
action:@selector(performZoom:)
keyEquivalent:@""];
Expand All @@ -305,7 +305,7 @@ - (void)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type {
[windowMenu addItem:[NSMenuItem separatorItem]];
[[windowMenu addItemWithTitle:@"Enter Full Screen"
action:@selector(toggleFullScreen:)
keyEquivalent:@"f"]
keyEquivalent:@""]
setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
[NSApp setWindowsMenu:windowMenu];
[windowMenu release];
Expand Down
8 changes: 4 additions & 4 deletions kitty/glfw-wrapper.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions kitty/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def extended_key_event(key, mods, action):
if mods & defines.GLFW_MOD_ALT:
m |= 0x2
if mods & defines.GLFW_MOD_CONTROL:
m |= 0x4
if mods & defines.GLFW_MOD_SUPER:
m |= 0x8
if mods & defines.GLFW_MOD_SUPER:
m |= 0x4
return 'K{}{}{}'.format(
action_map[action], base64_encode(m), name
).encode('ascii')
Expand Down

2 comments on commit a076d0c

@Ulrar
Copy link

@Ulrar Ulrar commented on a076d0c May 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,

What's the proper way of applying that, is there a way to get brew to patch kitty with this on install ?

Thanks

@sergei-dyshel
Copy link
Author

@sergei-dyshel sergei-dyshel commented on a076d0c May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can use it with Hombrew. Just apply patch to source and build according to https://sw.kovidgoyal.net/kitty/build/. Must say that my branch of Kitty with this commit is not maintained, as I moved to iTerm2 long time ago.

Please sign in to comment.