mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-28 02:34:15 +00:00
it works!
This commit is contained in:
parent
84f3a4e2d7
commit
11f5f44ae6
2
config.h
2
config.h
@ -63,7 +63,7 @@ static const int natural_scrolling = 0;
|
|||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
static const char *termcmd[] = { "alacritty", NULL };
|
static const char *termcmd[] = { "alacritty", NULL };
|
||||||
static const char *menucmd[] = { "bemenu-run", NULL };
|
static const char *menucmd[] = { "dmenu_run", NULL };
|
||||||
|
|
||||||
const Key keys[] = {
|
const Key keys[] = {
|
||||||
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
||||||
|
|||||||
38
dwl.c
38
dwl.c
@ -238,16 +238,16 @@ static void destroylayersurfacenotify(struct wl_listener *listener, void *data);
|
|||||||
static void destroynotify(struct wl_listener *listener, void *data);
|
static void destroynotify(struct wl_listener *listener, void *data);
|
||||||
static Monitor *dirtomon(enum wlr_direction dir);
|
static Monitor *dirtomon(enum wlr_direction dir);
|
||||||
static void focusclient(Client *c, int lift);
|
static void focusclient(Client *c, int lift);
|
||||||
static void focusmon(const Arg *arg);
|
void focusmon(const Arg *arg);
|
||||||
static void focusstack(const Arg *arg);
|
void focusstack(const Arg *arg);
|
||||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||||
static Client *focustop(Monitor *m);
|
static Client *focustop(Monitor *m);
|
||||||
static void incnmaster(const Arg *arg);
|
void incnmaster(const Arg *arg);
|
||||||
static void inputdevice(struct wl_listener *listener, void *data);
|
static void inputdevice(struct wl_listener *listener, void *data);
|
||||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||||
static void keypress(struct wl_listener *listener, void *data);
|
static void keypress(struct wl_listener *listener, void *data);
|
||||||
static void keypressmod(struct wl_listener *listener, void *data);
|
static void keypressmod(struct wl_listener *listener, void *data);
|
||||||
static void killclient(const Arg *arg);
|
void killclient(const Arg *arg);
|
||||||
static void maplayersurfacenotify(struct wl_listener *listener, void *data);
|
static void maplayersurfacenotify(struct wl_listener *listener, void *data);
|
||||||
static void mapnotify(struct wl_listener *listener, void *data);
|
static void mapnotify(struct wl_listener *listener, void *data);
|
||||||
static void monocle(Monitor *m);
|
static void monocle(Monitor *m);
|
||||||
@ -261,7 +261,7 @@ static void outputmgrtest(struct wl_listener *listener, void *data);
|
|||||||
static void pointerfocus(Client *c, struct wlr_surface *surface,
|
static void pointerfocus(Client *c, struct wlr_surface *surface,
|
||||||
double sx, double sy, uint32_t time);
|
double sx, double sy, uint32_t time);
|
||||||
static void printstatus(void);
|
static void printstatus(void);
|
||||||
static void quit(const Arg *arg);
|
void quit(const Arg *arg);
|
||||||
static void quitsignal(int signo);
|
static void quitsignal(int signo);
|
||||||
static void render(struct wlr_surface *surface, int sx, int sy, void *data);
|
static void render(struct wlr_surface *surface, int sx, int sy, void *data);
|
||||||
static void renderclients(Monitor *m, struct timespec *now);
|
static void renderclients(Monitor *m, struct timespec *now);
|
||||||
@ -276,31 +276,31 @@ static void setpsel(struct wl_listener *listener, void *data);
|
|||||||
static void setsel(struct wl_listener *listener, void *data);
|
static void setsel(struct wl_listener *listener, void *data);
|
||||||
static void setfloating(Client *c, int floating);
|
static void setfloating(Client *c, int floating);
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
static void setlayout(const Arg *arg);
|
void setlayout(const Arg *arg);
|
||||||
static void setmfact(const Arg *arg);
|
void setmfact(const Arg *arg);
|
||||||
static void setmon(Client *c, Monitor *m, unsigned int newtags);
|
static void setmon(Client *c, Monitor *m, unsigned int newtags);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
static void sigchld(int unused);
|
static void sigchld(int unused);
|
||||||
static void spawn(const Arg *arg);
|
void spawn(const Arg *arg);
|
||||||
static void tag(const Arg *arg);
|
void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
static void togglefloating(const Arg *arg);
|
void togglefloating(const Arg *arg);
|
||||||
static void togglefullscreen(const Arg *arg);
|
void togglefullscreen(const Arg *arg);
|
||||||
static void toggletag(const Arg *arg);
|
void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
void toggleview(const Arg *arg);
|
||||||
static void unmaplayersurface(LayerSurface *layersurface);
|
static void unmaplayersurface(LayerSurface *layersurface);
|
||||||
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
|
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
|
||||||
static void unmapnotify(struct wl_listener *listener, void *data);
|
static void unmapnotify(struct wl_listener *listener, void *data);
|
||||||
static void updatemons(struct wl_listener *listener, void *data);
|
static void updatemons(struct wl_listener *listener, void *data);
|
||||||
static void updatetitle(struct wl_listener *listener, void *data);
|
static void updatetitle(struct wl_listener *listener, void *data);
|
||||||
static void view(const Arg *arg);
|
void view(const Arg *arg);
|
||||||
static void virtualkeyboard(struct wl_listener *listener, void *data);
|
static void virtualkeyboard(struct wl_listener *listener, void *data);
|
||||||
static Client *xytoclient(double x, double y);
|
static Client *xytoclient(double x, double y);
|
||||||
static struct wlr_surface *xytolayersurface(struct wl_list *layer_surfaces,
|
static struct wlr_surface *xytolayersurface(struct wl_list *layer_surfaces,
|
||||||
double x, double y, double *sx, double *sy);
|
double x, double y, double *sx, double *sy);
|
||||||
static Monitor *xytomon(double x, double y);
|
static Monitor *xytomon(double x, double y);
|
||||||
static void zoom(const Arg *arg);
|
void zoom(const Arg *arg);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
@ -1202,8 +1202,6 @@ inputdevice(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int KEYS_LEN = LENGTH(keys);
|
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;
|
static jl_function_t* keybinding_julia;
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1224,8 +1222,10 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//return handled;
|
//return handled;
|
||||||
|
//printf("%x\n", sym);
|
||||||
void *ptr[] = {&mods, &sym};
|
void *ptr[] = {&mods, &sym};
|
||||||
return jl_unbox_int32(jl_call1(keybinding_julia, jl_box_voidpointer(ptr)));
|
//return jl_unbox_int32(jl_call1(keybinding_julia, jl_box_voidpointer(ptr)));
|
||||||
|
return jl_unbox_int32(jl_call2(keybinding_julia, jl_box_uint32(mods), jl_box_uint32(sym)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
73
dwl.jl
73
dwl.jl
@ -1,8 +1,9 @@
|
|||||||
module DWL
|
module DWL
|
||||||
|
|
||||||
struct xkb_keysym_t
|
const xkb_keysym_t = UInt32
|
||||||
x::UInt32
|
#struct xkb_keysym_t
|
||||||
end
|
# x::UInt32
|
||||||
|
#end
|
||||||
|
|
||||||
struct Arg
|
struct Arg
|
||||||
x::UInt
|
x::UInt
|
||||||
@ -15,24 +16,60 @@ struct Key
|
|||||||
arg::Arg
|
arg::Arg
|
||||||
end
|
end
|
||||||
|
|
||||||
const keys = @show unsafe_wrap(Array, cglobal(:keys, Key), unsafe_load(cglobal(:KEYS_LEN, Cint)))
|
keysym(x) = ccall((:XStringToKeysym, "libxkbfile"), xkb_keysym_t, (Cstring,), string(x))
|
||||||
|
# from wlr_keyboard.h
|
||||||
|
const WLR_MODIFIER_SHIFT = xkb_keysym_t(1 << 0)
|
||||||
|
const WLR_MODIFIER_CAPS = xkb_keysym_t(1 << 1)
|
||||||
|
const WLR_MODIFIER_CTRL = xkb_keysym_t(1 << 2)
|
||||||
|
const WLR_MODIFIER_ALT = xkb_keysym_t(1 << 3)
|
||||||
|
const WLR_MODIFIER_MOD2 = xkb_keysym_t(1 << 4)
|
||||||
|
const WLR_MODIFIER_MOD3 = xkb_keysym_t(1 << 5)
|
||||||
|
const WLR_MODIFIER_LOGO = xkb_keysym_t(1 << 6)
|
||||||
|
const WLR_MODIFIER_MOD5 = xkb_keysym_t(1 << 7)
|
||||||
|
|
||||||
const WLR_MODIFIER_CAPS = @show unsafe_load(cglobal(:_WLR_MODIFIER_CAPS, UInt32))
|
const MODKEY = WLR_MODIFIER_ALT
|
||||||
|
|
||||||
|
#const keys = @show unsafe_wrap(Array, cglobal(:keys, Key), unsafe_load(cglobal(:KEYS_LEN, Cint)))
|
||||||
|
|
||||||
|
function spawn(cmd::Vector{String})
|
||||||
|
cmd = Base.cconvert.(Cstring, cmd)
|
||||||
|
ptrs = push!(pointer.(cmd), C_NULL)
|
||||||
|
@ccall spawn(pointer(ptrs)::Ref{Ptr{Cstring}})::Cvoid
|
||||||
|
GC.@preserve cmd ptrs
|
||||||
|
end
|
||||||
|
focusstack(x::Int) = @ccall focusstack(x::Ref{Cint})::Cvoid
|
||||||
|
killclient() = @ccall killclient(C_NULL::Ptr{Cvoid})::Cvoid
|
||||||
|
quit() = @ccall quit(C_NULL::Ptr{Cvoid})::Cvoid
|
||||||
|
|
||||||
|
const keys = Dict{Tuple{UInt32, xkb_keysym_t}, Any}(
|
||||||
|
(MODKEY, keysym(:p)) => () -> spawn(["dmenu_run"]),
|
||||||
|
(MODKEY | WLR_MODIFIER_SHIFT, keysym(:Return)) => () -> spawn(["alacritty"]),
|
||||||
|
(MODKEY, keysym(:j)) => () -> focusstack(+1),
|
||||||
|
(MODKEY, keysym(:k)) => () -> focusstack(-1),
|
||||||
|
(MODKEY | WLR_MODIFIER_SHIFT, keysym(:C)) => killclient,
|
||||||
|
(MODKEY | WLR_MODIFIER_SHIFT, keysym(:Q)) => quit,
|
||||||
|
)
|
||||||
|
|
||||||
|
#const WLR_MODIFIER_CAPS = @show unsafe_load(cglobal(:_WLR_MODIFIER_CAPS, UInt32))
|
||||||
cleanmask(x) = x & ~WLR_MODIFIER_CAPS
|
cleanmask(x) = x & ~WLR_MODIFIER_CAPS
|
||||||
|
|
||||||
#function keybinding(mods::UInt32, sym::xkb_keysym_t)::Cint
|
function keybinding(mods::UInt32, sym::xkb_keysym_t)::Cint
|
||||||
function keybinding(ptr::Ptr{Cvoid})::Cint
|
#function keybinding(ptr::Ptr{Cvoid})::Cint
|
||||||
mods = unsafe_load(unsafe_load(Ptr{Ptr{UInt32}}(ptr)), 1)
|
# mods = unsafe_load(unsafe_load(Ptr{Ptr{UInt32}}(ptr)), 1)
|
||||||
sym = unsafe_load(unsafe_load(Ptr{Ptr{xkb_keysym_t}}(ptr)), 2)
|
# sym = unsafe_load(unsafe_load(Ptr{Ptr{xkb_keysym_t}}(ptr)), 2)
|
||||||
@show mods sym
|
#@show mods sym
|
||||||
handled = false
|
f = get(keys, (cleanmask(mods), sym), nothing)
|
||||||
for k in keys
|
f === nothing && return false
|
||||||
if cleanmask(mods) == cleanmask(k.mod) && sym == k.keysym && k.func != C_NULL
|
try Base.invokelatest(f) catch e; @show e end
|
||||||
ccall(k.func, Cvoid, (Ptr{Arg},), Ref(k.arg))
|
return true
|
||||||
handled = true
|
# handled = false
|
||||||
end
|
# for k in keys
|
||||||
end
|
# if cleanmask(mods) == cleanmask(k.mod) && sym == k.keysym && k.func != C_NULL
|
||||||
return handled
|
# ccall(k.func, Cvoid, (Ptr{Arg},), Ref(k.arg))
|
||||||
|
# handled = true
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# return @show handled
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user