58 Commits

Author SHA1 Message Date
Kovid Goyal
286f3630d7
Merge branch 'macos_fix_keyboard_shortcut_encoding' of https://github.com/Luflosi/kitty 2019-12-28 08:26:03 +05:30
Luflosi
9a3c621eb6
Fix macOS keyboard shortcut encoding
`glfwGetCocoaKeyEquivalent()` in `glfw/cocoa_window.m` expects the returned characters to be of type `unichar`, which won't work for all unicode characters because it is defined as `unsigned short` according to https://developer.apple.com/documentation/foundation/unichar?language=objc, which is only guaranteed to be at least 16 bits in size. The code calling this function also expects the encoding to be UTF-16.
When I added the various keys in https://github.com/kovidgoyal/kitty/pull/1928, I missed these facts. This means, that `glfwGetCocoaKeyEquivalent()` will behave unexpectedly when called with any of the new-ish keys. Luckily this function is currently only used for determining the macOS shortcut for `new_os_window` but I plan on using it more in the future.
Some of the constants, e.g. `NSBackspaceCharacter` are UTF-16 constants, so we can't just use UTF-8 everywhere.
I fixed the problem by using either UTF-8 characters packed into a `uint32_t` or UTF-16 characters in a `unichar` and then converting them to a UTF-8 encoded char string.

`NSEventModifierFlagNumericPad` isn't guaranteed to fit in a `unichar`, which made this undefined behaviour. It also didn't work. I tried to make it work using `NSEventModifierFlagNumericPad` as a modifier instead, as can be seen in this commit, but couldn't get it to work either because the constants used are native key codes and not unicode characters. Therefore the numpad keys will be removed in the next commit.
2019-12-27 12:42:51 +01:00
Luflosi
46dd648380
Use the correct pointer type instead of void* 2019-12-25 11:51:40 +01:00
Luflosi
e0edef6719
Change return type of two functions
`on_application_reopen()` and `intercept_cocoa_fullscreen()` both only have two possible return values and can therefore have a return type of `bool`.
2019-11-24 13:06:46 +01:00
Luflosi
f9fd39b8c1
Create macOS menu bar where GLFW creates it
GLFW creates the menu bar in the applicationWillFinishLaunching method, while kitty creates it in `create_os_window()`. This patch changes the behaviour to match GLFW.
In practice, without this change, there can be a short time where the menu bar is not fully populated.
2019-11-24 08:43:01 +01:00
Benoit de Chezelles
7f2b98fad7 Rename all uses of 'scancode' to 'native_key' where relevant 2019-10-16 02:25:20 +02:00
Kovid Goyal
97fe38fbbc
monotonic_start_time needs to be a global symbol, not local to each translation unit 2019-09-28 08:18:21 +05:30
Benoit de Chezelles
53275c9137 Extract key event data to struct 2019-09-24 19:15:35 +02:00
James McCoy
34350af61c
Only use linux_joystick.c on Linux
Rather than using null_joystick.c when _plat is a bsd, use
linux_joystick.c when _plat is a linux.  This fixes a build issue with
other non-BSD, non-Linux platforms.
2019-09-03 23:02:16 -04:00
Luflosi
902fc22670
Simplify GLFW compilation code
This commit removes the need for `is_macos` in `glfw/glfw.py` by moving a few lines of code. Instead of relying on the information that the compilation is or isn't happening on macOS, the code now does the right thing based on which `module` is being built.
This changes the order of the compilation flags slightly.
2019-08-26 16:47:19 +02:00
Luflosi
599be7ddc9
Don't add Apple Frameworks twice
These Frameworks are added again a couple lines below in the check for `module == 'cocoa'`.
2019-08-11 02:26:12 +02:00
Luflosi
5f855ce547
Use context managers to open files
Inspired by d50a6ddc1b.
2019-08-01 13:21:26 -05:00
Kovid Goyal
67f23664c9
Generate Wayland protocol definitions in parallel as well 2019-07-05 20:57:56 +05:30
Kovid Goyal
b9029f6c67
Remove unnecessary extra copy 2019-07-01 13:57:16 +05:30
Kovid Goyal
841c907efc
Build glfw with all warnings enabled 2019-07-01 10:42:07 +05:30
Luflosi
a792c94ccf
Use python3 shebang for all python scripts
Fixes #1624.
Use python3 shebang for all python scripts as python still defaults to python2 on many systems.
2019-05-20 14:44:24 +02:00
Kovid Goyal
4fff84b4b9
Add void to all function declarations for functions that take no arguments
Micro-optimization for some architectures. Enforced via
-Wstrict-prototypes
2019-05-13 11:04:21 +05:30
Kovid Goyal
4629ef627f
GLFW: Add support for render frames on Cocoa (CVDisplayLink)
Allows vsync to work again since Apple broke OpenGL swap intervals on
Mojave
2019-02-20 15:08:07 +05:30
Kovid Goyal
23482e3cf4
macOS: Allow assigning only the left or right :kbd:Option key to work as the :kbd:Alt key. See :opt:macos_option_as_alt for details
Fixes #1022
2019-02-14 20:39:32 +05:30
Kovid Goyal
4c9a6ed56c
Set a default action name on the dbus notification 2019-02-03 13:53:26 +05:30
Kovid Goyal
1bf2864638
API to handle DBus user notification activation 2019-02-03 13:20:07 +05:30
Kovid Goyal
17a16ccd21
Remove unused code 2019-02-03 10:25:38 +05:30
Kovid Goyal
670de085a3
Add API to GLFW for user notifications using DBus 2019-02-02 13:48:26 +05:30
Tarmack
a6900443d5 Wayland primary selection migrated to unstable protocol
This change is actually backwards compatible with the GTK implementation before.
2018-11-13 20:58:02 +01:00
Tarmack
d519553581
Implement primary selection for Wayland 2018-10-31 09:03:22 +05:30
Kovid Goyal
5b547d9b06
Initial attempt at supporting Wayland frame events
Does not actually work because the wayland frame callback is not called
at all, fo rsome reason I cannot determine.
2018-10-26 07:42:57 +05:30
Kovid Goyal
407d19c2dc
Remove code to import/export from glfw
Since kitty now uses its own private fork, there is no point.
2018-10-24 14:18:01 +05:30
Kovid Goyal
cbab3b56de
Fixes for compilation on mojave, needs testing 2018-10-03 20:51:25 +05:30
Kovid Goyal
98864091ff
Move memfd existence test to glfw.py 2018-10-03 11:02:51 +05:30
Kovid Goyal
b82e74f99a
Fix for kitty window not being rendered until moved/resized on macOS Mojave
Fixes #887
2018-09-26 19:43:04 +05:30
Kovid Goyal
ec1f219850
macOS: Make full screening of kitty much faster by using the "traditional full screen" mode of cocoa, similar to iTerm and MacVim
Hopefully workaround a bug in glfw that causes crashes when unplugging
monitors with full screen windows.

Fixes #911
Fixes #898
2018-09-12 15:45:08 +05:30
Kovid Goyal
e630b76fac
Don't patch glfw when importing since the patch has moved upstream 2018-09-04 09:46:09 +05:30
Kovid Goyal
e3e28a023c
Fix exporting to glfw 2018-07-12 18:18:20 +05:30
Kovid Goyal
1061e40b98
Bi-directional glfw updates 2018-07-12 18:18:19 +05:30
Kovid Goyal
e91eb27e56
Refactor linux backend event loops
Allow waiting for events on an arbitrary number of fds. Needed
for async DBUS integration.
2018-07-12 18:18:17 +05:30
Kovid Goyal
cdee601137
Start work on IBUS support 2018-07-12 18:18:16 +05:30
Kovid Goyal
db5aa36f44
Fix deprecation warning from newer versions of wayland-scanner 2018-07-10 19:48:37 +05:30
Kovid Goyal
5dd3243674
Update glfw from upstream 2018-06-22 10:21:51 +05:30
Kovid Goyal
f80f61f84f
... 2018-06-08 12:54:38 +05:30
Kovid Goyal
faa5443d43
macOS: When clicking dock icon with no windows, create a new window 2018-06-07 07:19:39 +05:30
Kovid Goyal
2e8d19601b
macOS: Fix the new OS window keyboard shortcut not working if no kitty window currently has focus.
Fixes #524
2018-06-06 22:18:33 +05:30
Kovid Goyal
138b4cf5da
Fix build breakage caused by FreeBSD support
Also move the changes to the glfw files to glfw.py
2018-06-03 09:17:18 +05:30
Kovid Goyal
238508fc0a
Update glfw from upstream
Proper cross-platform fix for issue of mouse cursor not being restored
over un-focused windows.
2018-04-26 08:31:52 +05:30
Kovid Goyal
2504266806
macOS: Fix option as alt not working for keys that act as dead keys in the current keyboard layout 2018-04-19 17:44:31 +05:30
Kovid Goyal
529bb5c6a0
We need xkbcommon >= 0.5 2018-03-31 12:21:36 +05:30
Kovid Goyal
bfa53d4b45
Update glfw from upstream
Includes proper fix for Wayland key repeat
2018-03-28 15:26:56 +05:30
Kovid Goyal
69f3ceb903
Merge glfw upstream changes to build on Wayland on FreeBSD 2018-03-28 09:47:16 +05:30
Kovid Goyal
bd654d22f4
Read the required wayland protocols version from upstream instead of hardcoding it 2017-12-28 14:12:46 +05:30
Kovid Goyal
12bdd4dddd
Bump min version of wayland-protocols to match upstream 2017-12-27 07:24:38 +05:30
Kovid Goyal
4621ff41d9
Skip building the wayland backend on systems with missing wayland protocol definitions
Fixes #254
2017-12-27 06:22:36 +05:30