mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-28 18:44:17 +00:00
wip
This commit is contained in:
parent
2630a7dfe4
commit
84f3a4e2d7
29
dwl.c
29
dwl.c
@ -1201,6 +1201,11 @@ inputdevice(struct wl_listener *listener, void *data)
|
|||||||
wlr_seat_set_capabilities(seat, caps);
|
wlr_seat_set_capabilities(seat, caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int KEYS_LEN = LENGTH(keys);
|
||||||
|
//const wlr_keyboard_modifier _WLR_MODIFIER_CAPS = WLR_MODIFIER_CAPS;
|
||||||
|
const uint32_t _WLR_MODIFIER_CAPS = WLR_MODIFIER_CAPS;
|
||||||
|
static jl_function_t* keybinding_julia;
|
||||||
|
|
||||||
int
|
int
|
||||||
keybinding(uint32_t mods, xkb_keysym_t sym)
|
keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||||
{
|
{
|
||||||
@ -1209,16 +1214,18 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
|||||||
* processing keys, rather than passing them on to the client for its own
|
* processing keys, rather than passing them on to the client for its own
|
||||||
* processing.
|
* processing.
|
||||||
*/
|
*/
|
||||||
int handled = 0;
|
//int handled = 0;
|
||||||
const Key *k;
|
//const Key *k;
|
||||||
for (k = keys; k < END(keys); k++) {
|
//for (k = keys; k < END(keys); k++) {
|
||||||
if (CLEANMASK(mods) == CLEANMASK(k->mod) &&
|
// if (CLEANMASK(mods) == CLEANMASK(k->mod) &&
|
||||||
sym == k->keysym && k->func) {
|
// sym == k->keysym && k->func) {
|
||||||
k->func(&k->arg);
|
// k->func(&k->arg);
|
||||||
handled = 1;
|
// handled = 1;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
return handled;
|
//return handled;
|
||||||
|
void *ptr[] = {&mods, &sym};
|
||||||
|
return jl_unbox_int32(jl_call1(keybinding_julia, jl_box_voidpointer(ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -2577,6 +2584,8 @@ main(int argc, char *argv[])
|
|||||||
/* required: setup the Julia context */
|
/* required: setup the Julia context */
|
||||||
jl_init();
|
jl_init();
|
||||||
jl_eval_string("@show(cglobal(:keys))");
|
jl_eval_string("@show(cglobal(:keys))");
|
||||||
|
jl_module_t* DWL_julia = (jl_module_t*)jl_load(jl_main_module, "dwl.jl");
|
||||||
|
keybinding_julia = jl_get_function(DWL_julia, "keybinding");
|
||||||
|
|
||||||
// Wayland requires XDG_RUNTIME_DIR for creating its communications
|
// Wayland requires XDG_RUNTIME_DIR for creating its communications
|
||||||
// socket
|
// socket
|
||||||
|
|||||||
38
dwl.jl
Normal file
38
dwl.jl
Normal 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
|
||||||
Loading…
x
Reference in New Issue
Block a user