mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Merge glfw upstream changes to build on Wayland on FreeBSD
This commit is contained in:
33
glfw/glfw.py
33
glfw/glfw.py
@@ -10,6 +10,10 @@ import sys
|
|||||||
|
|
||||||
_plat = sys.platform.lower()
|
_plat = sys.platform.lower()
|
||||||
is_macos = 'darwin' in _plat
|
is_macos = 'darwin' in _plat
|
||||||
|
is_freebsd = 'freebsd' in _plat
|
||||||
|
is_netbsd = 'netbsd' in _plat
|
||||||
|
is_dragonflybsd = 'dragonfly' in _plat
|
||||||
|
is_bsd = is_freebsd or is_netbsd or is_dragonflybsd
|
||||||
base = os.path.dirname(os.path.abspath(__file__))
|
base = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
@@ -18,6 +22,20 @@ def wayland_protocol_file_name(base, ext='c'):
|
|||||||
return 'wayland-{}-client-protocol.{}'.format(base, ext)
|
return 'wayland-{}-client-protocol.{}'.format(base, ext)
|
||||||
|
|
||||||
|
|
||||||
|
def find_epoll_shim():
|
||||||
|
cflags, ldflags, libs = [], [], []
|
||||||
|
for candidate in '/usr/local/include/libepoll-shim /usr/include/libepoll-shim /usr/local/include /usr/include'.split():
|
||||||
|
if os.path.exists(os.path.join(candidate, 'sys/timerfd.h')):
|
||||||
|
cflags.append('-I' + candidate)
|
||||||
|
break
|
||||||
|
for candidate in '/usr/local/lib /usr/lib'.split():
|
||||||
|
if os.path.exists(os.path.join(candidate, 'libepoll-shim.so')):
|
||||||
|
ldflags.append('-L' + candidate)
|
||||||
|
libs.append('-lepoll-shim')
|
||||||
|
break
|
||||||
|
return cflags, ldflags, libs
|
||||||
|
|
||||||
|
|
||||||
def init_env(env, pkg_config, at_least_version, module='x11'):
|
def init_env(env, pkg_config, at_least_version, module='x11'):
|
||||||
ans = env.copy()
|
ans = env.copy()
|
||||||
ans.cflags = [
|
ans.cflags = [
|
||||||
@@ -59,6 +77,12 @@ def init_env(env, pkg_config, at_least_version, module='x11'):
|
|||||||
for p in ans.wayland_protocols:
|
for p in ans.wayland_protocols:
|
||||||
ans.sources.append(wayland_protocol_file_name(p))
|
ans.sources.append(wayland_protocol_file_name(p))
|
||||||
ans.all_headers.append(wayland_protocol_file_name(p, 'h'))
|
ans.all_headers.append(wayland_protocol_file_name(p, 'h'))
|
||||||
|
if is_bsd:
|
||||||
|
epoll_cflags, epoll_libdirs, epoll_libs = find_epoll_shim()
|
||||||
|
if not epoll_cflags + epoll_libdirs:
|
||||||
|
raise Exception('Failed to find the epoll-shim package, needed to build the GLFW Wayland backend')
|
||||||
|
ans.cflags.extend(epoll_cflags)
|
||||||
|
ans.ldpaths.extend(epoll_libdirs + epoll_libs)
|
||||||
for dep in 'wayland-egl wayland-client wayland-cursor xkbcommon'.split():
|
for dep in 'wayland-egl wayland-client wayland-cursor xkbcommon'.split():
|
||||||
ans.cflags.extend(pkg_config(dep, '--cflags-only-I'))
|
ans.cflags.extend(pkg_config(dep, '--cflags-only-I'))
|
||||||
ans.ldpaths.extend(pkg_config(dep, '--libs'))
|
ans.ldpaths.extend(pkg_config(dep, '--libs'))
|
||||||
@@ -100,13 +124,14 @@ def collect_source_information():
|
|||||||
'common': dict(extract_sources('common')),
|
'common': dict(extract_sources('common')),
|
||||||
'wayland_protocols': wayland_protocols,
|
'wayland_protocols': wayland_protocols,
|
||||||
}
|
}
|
||||||
|
joystick = 'null' if is_bsd else 'linux'
|
||||||
for group in 'cocoa win32 x11 wayland osmesa'.split():
|
for group in 'cocoa win32 x11 wayland osmesa'.split():
|
||||||
m = re.search('_GLFW_' + group.upper(), raw)
|
m = re.search('_GLFW_' + group.upper(), raw)
|
||||||
ans[group] = dict(extract_sources('glfw', m.start()))
|
ans[group] = dict(extract_sources('glfw', m.start()))
|
||||||
if group == 'x11':
|
if group in ('x11', 'wayland'):
|
||||||
ans[group]['headers'].append('linux_joystick.h')
|
ans[group]['headers'].append('{}_joystick.h'.format(joystick))
|
||||||
ans[group]['sources'].append('linux_joystick.c')
|
ans[group]['sources'].append('{}_joystick.c'.format(joystick))
|
||||||
elif group == 'wayland':
|
if group == 'wayland':
|
||||||
ans[group]['protocols'] = p = []
|
ans[group]['protocols'] = p = []
|
||||||
for m in re.finditer(r'WAYLAND_PROTOCOLS_PKGDATADIR\}/(.+?)"?$', raw, flags=re.M):
|
for m in re.finditer(r'WAYLAND_PROTOCOLS_PKGDATADIR\}/(.+?)"?$', raw, flags=re.M):
|
||||||
p.append(m.group(1))
|
p.append(m.group(1))
|
||||||
|
|||||||
@@ -55,12 +55,12 @@
|
|||||||
"wayland": {
|
"wayland": {
|
||||||
"headers": [
|
"headers": [
|
||||||
"wl_platform.h",
|
"wl_platform.h",
|
||||||
"linux_joystick.h",
|
|
||||||
"posix_time.h",
|
"posix_time.h",
|
||||||
"posix_thread.h",
|
"posix_thread.h",
|
||||||
"xkb_unicode.h",
|
"xkb_unicode.h",
|
||||||
"egl_context.h",
|
"egl_context.h",
|
||||||
"osmesa_context.h"
|
"osmesa_context.h",
|
||||||
|
"linux_joystick.h"
|
||||||
],
|
],
|
||||||
"protocols": [
|
"protocols": [
|
||||||
"stable/xdg-shell/xdg-shell.xml",
|
"stable/xdg-shell/xdg-shell.xml",
|
||||||
@@ -73,12 +73,12 @@
|
|||||||
"wl_init.c",
|
"wl_init.c",
|
||||||
"wl_monitor.c",
|
"wl_monitor.c",
|
||||||
"wl_window.c",
|
"wl_window.c",
|
||||||
"linux_joystick.c",
|
|
||||||
"posix_time.c",
|
"posix_time.c",
|
||||||
"posix_thread.c",
|
"posix_thread.c",
|
||||||
"xkb_unicode.c",
|
"xkb_unicode.c",
|
||||||
"egl_context.c",
|
"egl_context.c",
|
||||||
"osmesa_context.c"
|
"osmesa_context.c",
|
||||||
|
"linux_joystick.c"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"wayland_protocols": [
|
"wayland_protocols": [
|
||||||
|
|||||||
4
glfw/wl_init.c
vendored
4
glfw/wl_init.c
vendored
@@ -1046,8 +1046,10 @@ int _glfwPlatformInit(void)
|
|||||||
// Sync so we got all initial output events
|
// Sync so we got all initial output events
|
||||||
wl_display_roundtrip(_glfw.wl.display);
|
wl_display_roundtrip(_glfw.wl.display);
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
if (!_glfwInitJoysticksLinux())
|
if (!_glfwInitJoysticksLinux())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
_glfwInitTimerPOSIX();
|
_glfwInitTimerPOSIX();
|
||||||
|
|
||||||
@@ -1073,7 +1075,9 @@ int _glfwPlatformInit(void)
|
|||||||
|
|
||||||
void _glfwPlatformTerminate(void)
|
void _glfwPlatformTerminate(void)
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
_glfwTerminateJoysticksLinux();
|
_glfwTerminateJoysticksLinux();
|
||||||
|
#endif
|
||||||
_glfwTerminateEGL();
|
_glfwTerminateEGL();
|
||||||
if (_glfw.wl.egl.handle)
|
if (_glfw.wl.egl.handle)
|
||||||
{
|
{
|
||||||
|
|||||||
4
glfw/wl_platform.h
vendored
4
glfw/wl_platform.h
vendored
@@ -47,7 +47,11 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
|
|||||||
|
|
||||||
#include "posix_thread.h"
|
#include "posix_thread.h"
|
||||||
#include "posix_time.h"
|
#include "posix_time.h"
|
||||||
|
#ifdef __linux__
|
||||||
#include "linux_joystick.h"
|
#include "linux_joystick.h"
|
||||||
|
#else
|
||||||
|
#include "null_joystick.h"
|
||||||
|
#endif
|
||||||
#include "xkb_unicode.h"
|
#include "xkb_unicode.h"
|
||||||
#include "egl_context.h"
|
#include "egl_context.h"
|
||||||
#include "osmesa_context.h"
|
#include "osmesa_context.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user