mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 17:27:39 +02:00
Enable building of glfw-wayland backend
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,3 +11,4 @@ asan-launcher
|
|||||||
kitty-profile
|
kitty-profile
|
||||||
dev
|
dev
|
||||||
__pycache__
|
__pycache__
|
||||||
|
glfw/wayland-*-client-protocol.h
|
||||||
|
|||||||
27
glfw/glfw.py
27
glfw/glfw.py
@@ -33,9 +33,10 @@ def init_env(env, pkg_config, at_least_version, module='x11'):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
ans.ldpaths.extend('-lrt -lm -ldl'.split())
|
ans.ldpaths.extend('-lrt -lm -ldl'.split())
|
||||||
|
sinfo = json.load(open(os.path.join(base, 'source-info.json')))
|
||||||
|
|
||||||
if module == 'x11':
|
if module == 'x11':
|
||||||
for dep in 'x11 xrandr xinerama xcursor xkbcommon-x11'.split():
|
for dep in 'x11 xrandr xinerama xcursor xkbcommon xkbcommon-x11'.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'))
|
||||||
|
|
||||||
@@ -43,12 +44,30 @@ def init_env(env, pkg_config, at_least_version, module='x11'):
|
|||||||
for f in 'Cocoa IOKit CoreFoundation CoreVideo'.split():
|
for f in 'Cocoa IOKit CoreFoundation CoreVideo'.split():
|
||||||
ans.ldpaths.extend(('-framework', f))
|
ans.ldpaths.extend(('-framework', f))
|
||||||
|
|
||||||
sinfo = json.load(open(os.path.join(base, 'source-info.json')))
|
elif module == 'wayland':
|
||||||
|
at_least_version('wayland-protocols', 1, 1)
|
||||||
|
ans.wayland_packagedir = os.path.abspath(pkg_config('wayland-protocols', '--variable=pkgdatadir')[0])
|
||||||
|
ans.wayland_scanner = os.path.abspath(pkg_config('wayland-scanner', '--variable=wayland_scanner')[0])
|
||||||
|
ans.wayland_protocols = tuple(sinfo[module]['protocols'])
|
||||||
|
for dep in 'wayland-egl wayland-client wayland-scanner xkbcommon'.split():
|
||||||
|
ans.cflags.extend(pkg_config(dep, '--cflags-only-I'))
|
||||||
|
ans.ldpaths.extend(pkg_config(dep, '--libs'))
|
||||||
|
|
||||||
ans.sources = sinfo['common']['sources'] + sinfo[module]['sources']
|
ans.sources = sinfo['common']['sources'] + sinfo[module]['sources']
|
||||||
ans.all_headers = [x for x in os.listdir(base) if x.endswith('.h')]
|
ans.all_headers = [x for x in os.listdir(base) if x.endswith('.h')]
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
def build_wayland_protocols(env, run_tool, emphasis, newer, dest_dir):
|
||||||
|
for protocol in env.wayland_protocols:
|
||||||
|
src = os.path.join(env.wayland_packagedir, protocol)
|
||||||
|
dest = os.path.basename(src).rpartition('.')[0] + '-client-protocol.h'
|
||||||
|
dest = os.path.join(dest_dir, 'wayland-' + dest)
|
||||||
|
if newer(dest, src):
|
||||||
|
run_tool([env.wayland_scanner, 'client-header', src, dest],
|
||||||
|
desc='Generating {} ...'.format(emphasis(os.path.basename(dest))))
|
||||||
|
|
||||||
|
|
||||||
def collect_source_information():
|
def collect_source_information():
|
||||||
raw = open('src/CMakeLists.txt').read()
|
raw = open('src/CMakeLists.txt').read()
|
||||||
|
|
||||||
@@ -71,6 +90,10 @@ def collect_source_information():
|
|||||||
if group == 'x11':
|
if group == 'x11':
|
||||||
ans[group]['headers'].append('linux_joystick.h')
|
ans[group]['headers'].append('linux_joystick.h')
|
||||||
ans[group]['sources'].append('linux_joystick.c')
|
ans[group]['sources'].append('linux_joystick.c')
|
||||||
|
elif group == 'wayland':
|
||||||
|
ans[group]['protocols'] = p = []
|
||||||
|
for m in re.finditer(r'WAYLAND_PROTOCOLS_PKGDATADIR\}/([^"]+)"', raw):
|
||||||
|
p.append(m.group(1))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,10 @@
|
|||||||
"egl_context.h",
|
"egl_context.h",
|
||||||
"osmesa_context.h"
|
"osmesa_context.h"
|
||||||
],
|
],
|
||||||
|
"protocols": [
|
||||||
|
"unstable/relative-pointer/relative-pointer-unstable-v1.xml",
|
||||||
|
"unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
|
||||||
|
],
|
||||||
"sources": [
|
"sources": [
|
||||||
"wl_init.c",
|
"wl_init.c",
|
||||||
"wl_monitor.c",
|
"wl_monitor.c",
|
||||||
|
|||||||
2
glfw/wl_init.c
vendored
2
glfw/wl_init.c
vendored
@@ -131,7 +131,7 @@ static void pointerHandleAxis(void* data,
|
|||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
||||||
double scrollFactor;
|
double scrollFactor;
|
||||||
double x, y;
|
double x = 0.0, y = 0.0;
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|||||||
13
setup.py
13
setup.py
@@ -384,11 +384,20 @@ def find_c_files():
|
|||||||
|
|
||||||
|
|
||||||
def compile_glfw(incremental, compilation_database, all_keys):
|
def compile_glfw(incremental, compilation_database, all_keys):
|
||||||
modules = 'cocoa' if isosx else 'x11'
|
modules = 'cocoa' if isosx else 'x11 wayland'
|
||||||
for module in modules.split():
|
for module in modules.split():
|
||||||
genv = glfw.init_env(env, pkg_config, at_least_version, module)
|
try:
|
||||||
|
genv = glfw.init_env(env, pkg_config, at_least_version, module)
|
||||||
|
except SystemExit as err:
|
||||||
|
if module != 'wayland':
|
||||||
|
raise
|
||||||
|
print(err.message, file=sys.stderr)
|
||||||
|
print('Disabling building of wayland backend', file=sys.stderr)
|
||||||
|
continue
|
||||||
sources = [os.path.join('glfw', x) for x in genv.sources]
|
sources = [os.path.join('glfw', x) for x in genv.sources]
|
||||||
all_headers = [os.path.join('glfw', x) for x in genv.all_headers]
|
all_headers = [os.path.join('glfw', x) for x in genv.all_headers]
|
||||||
|
if module == 'wayland':
|
||||||
|
glfw.build_wayland_protocols(genv, run_tool, emphasis, newer, os.path.join(base, 'glfw'))
|
||||||
compile_c_extension(genv, 'kitty/glfw-' + module, incremental, compilation_database, all_keys, sources, all_headers)
|
compile_c_extension(genv, 'kitty/glfw-' + module, incremental, compilation_database, all_keys, sources, all_headers)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user