feat: add ipc dispatch

This commit is contained in:
DreamMaoMao 2025-05-03 15:45:27 +08:00
parent c64dd51b69
commit cb4907510d
2 changed files with 24 additions and 0 deletions

View file

@ -167,6 +167,13 @@ I would probably just submit raphi's patchset but I don't think that would be po
<description summary="Quit maomao">This request allows clients to instruct the compositor to quit maomao.</description>
</request>
<request name="dispatch" since="2">
<description summary="Set the active tags of this output"/>
<arg name="dispatch" type="string" summary="dispatch name."/>
<arg name="arg1" type="string" summary="arg1."/>
<arg name="arg2" type="string" summary="arg2."/>
</request>
<!-- Version 2 -->
<event name="fullscreen" since="2">
<description summary="Update fullscreen status">

View file

@ -494,6 +494,8 @@ static void dwl_ipc_output_set_tags(struct wl_client *client,
uint32_t tagmask, uint32_t toggle_tagset);
static void dwl_ipc_output_quit(struct wl_client *client,
struct wl_resource *resource);
static void dwl_ipc_output_dispatch(struct wl_client *client,
struct wl_resource *resource,const char *dispatch,const char* arg1,const char* arg2);
static void dwl_ipc_output_release(struct wl_client *client,
struct wl_resource *resource);
static void focusclient(Client *c, int lift);
@ -703,6 +705,7 @@ static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {
.release = dwl_ipc_output_release,
.set_tags = dwl_ipc_output_set_tags,
.quit = dwl_ipc_output_quit,
.dispatch = dwl_ipc_output_dispatch,
.set_layout = dwl_ipc_output_set_layout,
.set_client_tags = dwl_ipc_output_set_client_tags};
@ -3493,6 +3496,20 @@ void dwl_ipc_output_quit(struct wl_client *client,
quit(&(Arg){0});
}
void dwl_ipc_output_dispatch(struct wl_client *client,
struct wl_resource *resource,
const char *dispatch, const char *arg1,
const char *arg2) {
void (*func)(const Arg *);
Arg arg;
func = parse_func_name((char*)dispatch, &arg, (char*)arg1, (char*)arg2);
if(func) {
func(&arg);
}
}
void dwl_ipc_output_release(struct wl_client *client,
struct wl_resource *resource) {
wl_resource_destroy(resource);