This commit is contained in:
Simeon Schaub 2021-06-17 13:28:33 +02:00
parent 2630a7dfe4
commit 84f3a4e2d7
No known key found for this signature in database
GPG key ID: EB2EE6B6F3725876
2 changed files with 57 additions and 10 deletions

38
dwl.jl Normal file
View file

@ -0,0 +1,38 @@
module DWL
struct xkb_keysym_t
x::UInt32
end
struct Arg
x::UInt
end
struct Key
mod::UInt32
keysym::xkb_keysym_t
func::Ptr{Cvoid}
arg::Arg
end
const keys = @show unsafe_wrap(Array, cglobal(:keys, Key), unsafe_load(cglobal(:KEYS_LEN, Cint)))
const WLR_MODIFIER_CAPS = @show unsafe_load(cglobal(:_WLR_MODIFIER_CAPS, UInt32))
cleanmask(x) = x & ~WLR_MODIFIER_CAPS
#function keybinding(mods::UInt32, sym::xkb_keysym_t)::Cint
function keybinding(ptr::Ptr{Cvoid})::Cint
mods = unsafe_load(unsafe_load(Ptr{Ptr{UInt32}}(ptr)), 1)
sym = unsafe_load(unsafe_load(Ptr{Ptr{xkb_keysym_t}}(ptr)), 2)
@show mods sym
handled = false
for k in keys
if cleanmask(mods) == cleanmask(k.mod) && sym == k.keysym && k.func != C_NULL
ccall(k.func, Cvoid, (Ptr{Arg},), Ref(k.arg))
handled = true
end
end
return handled
end
end