fix ipc to work with pertag

This commit is contained in:
choc 2024-03-14 11:18:37 +08:00 committed by Stachelbeere1248
parent 2c21d84561
commit a79912efc6

54
dwl.c
View file

@ -1527,28 +1527,37 @@ void
dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index) dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index)
{ {
DwlIpcOutput *ipc_output; DwlIpcOutput *ipc_output;
Monitor *monitor; Client *c = NULL;
Monitor *monitor = NULL;
ipc_output = wl_resource_get_user_data(resource); ipc_output = wl_resource_get_user_data(resource);
if (!ipc_output) if (!ipc_output)
return; return;
monitor = ipc_output->mon; monitor = ipc_output->mon;
if (monitor != selmon)
c = focustop(selmon);
if (index >= LENGTH(layouts)) if (index >= LENGTH(layouts))
return; return;
if (index != monitor->lt[monitor->sellt] - layouts)
monitor->sellt ^= 1;
monitor->lt[monitor->sellt] = &layouts[index]; if (c) {
arrange(monitor); monitor = selmon;
printstatus(); selmon = ipc_output->mon;
}
setlayout(&(Arg){.v = &layouts[index]});
if (c) {
selmon = monitor;
focusclient(c, 0);
}
} }
void void
dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource, uint32_t tagmask, uint32_t toggle_tagset) dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource, uint32_t tagmask, uint32_t toggle_tagset)
{ {
DwlIpcOutput *ipc_output; DwlIpcOutput *ipc_output;
Monitor *monitor; Client *c = NULL;
Monitor *monitor = NULL;
unsigned int newtags = tagmask & TAGMASK; unsigned int newtags = tagmask & TAGMASK;
ipc_output = wl_resource_get_user_data(resource); ipc_output = wl_resource_get_user_data(resource);
@ -1556,16 +1565,27 @@ dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource,
return; return;
monitor = ipc_output->mon; monitor = ipc_output->mon;
if (!newtags || newtags == monitor->tagset[monitor->seltags]) if (monitor != selmon)
return; c = focustop(selmon);
if (toggle_tagset)
monitor->seltags ^= 1;
monitor->tagset[monitor->seltags] = newtags; if (!newtags)
if (selmon == monitor) return;
focusclient(focustop(monitor), 1);
arrange(monitor); /* view toggles seltags for us so we un-toggle it */
printstatus(); if (!toggle_tagset) {
monitor->seltags ^= 1;
monitor->tagset[monitor->seltags] = 0;
}
if (c) {
monitor = selmon;
selmon = ipc_output->mon;
}
view(&(Arg){.ui = newtags});
if (c) {
selmon = monitor;
focusclient(c, 0);
}
} }
void void