394 Commits

Author SHA1 Message Date
Kovid Goyal
c398d3d16e
Cocoa: Fix glfwSetWindowSize anchor point
This makes glfwSetWindowSize use the top-left corner as anchor point
instead of the bottom-left corner.

Upstream: 7f02898264
2019-09-08 09:16:07 +05:30
Kovid Goyal
9dbc54aad6
Fix comparison of video modes of equal area
This fixes the bug of video modes being discarded if they had
a different resolution but the same area as another mode.

Upstream: 2777f6a754
2019-09-08 09:12:39 +05:30
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
b3b830bb5f
Make adding more printable keys slightly easier
When adding keys after `GLFW_KEY_UNDERSCORE`, one now needs to change a `#define` right below the last printable key instead of changing it elsewhere in the code.
This commit now also marks `GLFW_KEY_PLUS` and `GLFW_KEY_UNDERSCORE` as printable characters.
2019-09-01 11:24:14 +02:00
Luflosi
0459dda5c2
Fix bool indentation
The wrong indentation was caused by the removal of GLFWbool in fe62700825.
2019-08-30 15:32:20 +02:00
Luflosi
c0c7cfacc2
Fix NSLog() printing of unicode format strings
See https://stackoverflow.com/questions/720052/nslog-incorrect-encoding.
The `%s` format placeholder for `NSLog()` expects an encoding other than UTF-8, which leads to garbled Unicode characters when trying to print a UTF-8 encoded string.
```Objective-C
NSLog(@"Ä %s %@", "Ä", @("Ä"));
```
prints `Ä √Ñ Ä`.

As can be seen in the example above, the workaround is to convert the UTF-8 encoded C-string to an `NSString` object and print that instead.
`debug_key()` calls `NSLog()`.
2019-08-30 15:03:51 +02:00
Kovid Goyal
90a985b73a
Make format_text() more secure 2019-08-28 05:41:20 +05:30
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
6cc720a350
Fix typos
Inspired by 4d3ee554b3.
Found using `codespell`.
2019-08-26 12:31:15 +02:00
Luflosi
94d56d1a9e
Correct indentation for two _glfwInputError() messages
This commit changes the indentation of two error messages to match the indentation in the rest of the code.
2019-08-25 21:29:58 +02:00
Luflosi
06c2263657
macOS: implement drag and drop of text into kitty
Closes #1368.
2019-08-24 01:29:33 +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
28bb123be8
Update the GLFW version number from 3.3 to 3.4
Closes https://github.com/kovidgoyal/kitty/issues/1884.
From a337c56848.
2019-08-02 11:00:16 -05:00
Luflosi
5f855ce547
Use context managers to open files
Inspired by d50a6ddc1b.
2019-08-01 13:21:26 -05:00
Kovid Goyal
9cbb726566
Fix #1865 2019-07-30 06:20:54 +05:30
Kovid Goyal
d218900b57
Remove unused header 2019-07-29 09:45:02 +05:30
Kovid Goyal
cab949a939
Fix building with compilers that dont support __has_include 2019-07-29 09:44:05 +05:30
Luflosi
464a6c1441
Fix indentation of bool variables in glfw/egl_context.h
Caused by fe62700825.
2019-07-28 00:23:17 -05:00
Luflosi
b8d2b76ee4
Reduce the difference of glfw to upstream 2019-07-28 00:10:50 -05:00
Luflosi
922bc62e0e
GLFW: Fix invalid ranges for gamepad axis sources
From 9420e6f0d0.
2019-07-26 13:30:38 -05:00
Luflosi
61df266df7
Fix indentation of bool variables in glfw/internal.h
Caused by fe62700825.
2019-07-26 11:45:32 -05:00
Luflosi
961b2c9b65
GLFW: Documentation work
From 3cf7645b96.
2019-07-25 23:07:00 -05:00
Luflosi
cdbe2f13ca
Cocoa: Move slightly towards modern Objective-C
Inspired by 9a9568212c.
2019-07-25 17:14:32 -05:00
Kovid Goyal
d9f90ef077
Make qsort invocations type independent 2019-07-23 10:20:41 +05:30
Luflosi
c02ba03f39
Remove glfw/wgl_context.c and glfw/wgl_context.h 2019-07-21 15:03:39 -05:00
Luflosi
1590c59131
Fix assertion for glfwSetGamma value
From 751c6f9a27.
2019-07-20 23:17:58 -05:00
Luflosi
489f3e6c9d
Add C dialect reminders to each glfw source file
Reduces the difference to upstream.
From 56aad76b16.
2019-07-20 21:07:27 -05:00
Kovid Goyal
5fef4726a7
Cocoa: Fix file-local function not declared static
From upstream: 062a1c22b5
2019-07-20 19:12:21 +05:30
Kovid Goyal
51fdb8200a
X11: Fix focus events not being filtered
From upstream: c6b95e3b07
2019-07-20 19:11:00 +05:30
Kovid Goyal
fb0d98ead1
Add more debugs to Wayland handleEvents() 2019-07-20 14:48:28 +05:30
Kovid Goyal
4096caba64
Cancel read if dispatch_pending fails 2019-07-20 14:32:57 +05:30
Kovid Goyal
38f77144fa
Wayland: dont abort the event handler early if there are no pending events from the compositor. This ensures that the tick callback and other event sources are dispatched. 2019-07-20 14:09:09 +05:30
Kovid Goyal
b8041ce17f
Wayland: Fix infinite loop if the compositor dies 2019-07-20 13:55:38 +05:30
Luflosi
bdc4558a43
Update GLFW copyright years
Reduces the difference to upstream.
From ab118b2529.
2019-07-20 00:30:13 -05:00
Kovid Goyal
1cb15dedac
Simplify the event loop code
Also reduce input latency by ignoring repaint_delay when
there is actual pending input.

Gets rid of request_tick_callback(). Now empty events
result in the tick callback being called so there is only a
single mechanism for waking up the main loop and getting
the tick callback called.
2019-07-18 15:51:54 +05:30
Kovid Goyal
f5cf6c1dcb
Also make the loop flags volatile 2019-07-17 19:55:19 +05:30
Kovid Goyal
89307727e7
Use atomic variables for main loop flags 2019-07-17 19:45:52 +05:30
Kovid Goyal
8244f7cd58
Linux: Only process global state when something interesting happens
This matches behavior on macOS. Had initially set the code to process
on every loop tick in an attmept to workaround the issue of the event
loop freezing on X11 until an X event is delivered. However, in light
of #1782 that workaround was incorrect anyway. Better to have similar
behavior across platforms. This also has the advantage of reducing CPU
consumption.

Also add a simple program to test event loop wakeups.
2019-07-15 21:30:00 +05:30
Kovid Goyal
eb30ba7722
Cocoa: Fix code to shutdown display link for inactive monitors 2019-07-11 22:34:28 +05:30
Kovid Goyal
f8418d68a6
Fully drain the wakeupfd 2019-07-09 18:49:46 +05:30
Kovid Goyal
c0000fb24e
Should use an unsigned int for eventfd 2019-07-09 18:42:17 +05:30
Kovid Goyal
c169f7ae83
Retry writing to wakeupfd on EAGAIN as well 2019-07-09 18:40:51 +05:30
Kovid Goyal
7e36489034
Dont call detect joysticks if support for them has been disabled 2019-07-08 11:18:00 +05:30
Kovid Goyal
d259b12ae7
Micro-optimization: Avoid repeated calls to XQLength 2019-07-08 11:05:04 +05:30
Kovid Goyal
e7173f8145
Linux: Fix a regression in 0.14.0 that caused the event loop to tick continuously, wasting CPU even when idle
Fixes #1782
2019-07-07 05:57:18 +05:30
Kovid Goyal
67f23664c9
Generate Wayland protocol definitions in parallel as well 2019-07-05 20:57:56 +05:30
Kovid Goyal
39f6071c68
macOS: Fix a deadlock with CVDisplayLink
I had added an optimization to not pass messages to
main thread every time the CVDisplayLink timer fired, unless
a render frame for that monitor was actually requested.

However, this optimization is impossible to implement wihtout a deadlock
since CVDisplayLink has its own internal lock that it does not expose.

So I guess macOS users with multiple monitors will simply have to take
the performance hit of useless wakeups sixty times a second for every
extra monitor.

Fixes #1779
2019-07-05 20:16:32 +05:30
Kovid Goyal
556992a117
Forgot to make the eventfd cloexec and non-blocking 2019-07-05 10:08:15 +05:30
Kovid Goyal
a41ef8d513
Abort if addWatch during initialization of poll data fails 2019-07-05 10:00:39 +05:30
Kovid Goyal
6d96a89328
Linux: Use the more efficient eventfd mechanism to wakeup the event loop 2019-07-05 09:54:24 +05:30