fix malloc error: monitor clients is now initialized to NULL

This commit is contained in:
Akos Horvath 2022-09-19 11:13:20 +02:00
parent 2e1d6eb6f6
commit ed673097b6
2 changed files with 15 additions and 9 deletions

View File

@ -139,7 +139,6 @@ void wm_keypress_handler(Wm *wm, XKeyPressedEvent e)
for (int i = 0; i < wm->cfg_kb_count; i++) {
k = wm->cfg_keybinds[i];
DEBUG_PRINT("Keybind keysym: %s\n", XKeysymToString(k.keysym));
if (k.mask == e.state && k.keysym == XLookupKeysym(&e, 0))
{
(*k.func)(wm, &k.args);
@ -151,6 +150,9 @@ void wm_maprequest_handler(Wm *wm, XMapRequestEvent e)
{
DEBUG_PRINT("MapRequest event\n")
if (e.window == wm->root.window)
fprintf(stderr, "%s e.window was root\n", __func__);
Client *c;
c = wm_client_find(wm, e.window);

20
wm.c
View File

@ -47,11 +47,12 @@ void wm_monitors_open_all(Wm *wm, Display *d)
for (int j = 0; j < wm->monitors[i].wscount; j++)
wm->monitors[i].wss[i] = j;
wm->monitors[i].clients = &wm->root;
//wm->monitors[i].clients = &wm->root;
wm->monitors[i].clients = NULL;
}
wm->smon = &wm->monitors[0];
wm->smon->clients = &wm->root;
// wm->smon->clients = &wm->root;
DEBUG_PRINT("smon width: %d\n", wm->smon->info.width);
}
@ -418,9 +419,11 @@ void wm_monitor_clients_border(Wm *wm, Monitor *m)
Client *c;
for (c = wm->smon->clients; c; c = c->next) {
//DEBUG_PRINT("monitor border c: 0x%x\n", c)
if (c->window != wm->root.window)
if (c->window != wm->root.window) {
DEBUG_PRINT("monitor border c: %p\n", c)
DEBUG_PRINT("monitor border c window: %ld\n", c->window)
wm_client_border(wm, c);
}
}
}
@ -569,7 +572,6 @@ void wm_mstack(Wm *wm, Monitor *m)
//DEBUG_PRINT("mstack cc_sws: %d\n", cc_sws)
// dynamic
if (cc_sws == 1) {
DEBUG_PRINT("mstack ccw sws 1\n");
for (c = m->clients; c; c = c->next) {
if (c->ws == m->selws && c != &wm->root)
break;
@ -581,7 +583,7 @@ void wm_mstack(Wm *wm, Monitor *m)
ch = wm_client_to_xwchanges(*c);
DEBUG_PRINT("mstack client: 0x%x\n", c);
// XGetWMName(wm->display, c->window, &xt);
// DEBUG_PRINT("mstack window id: %d\n", c->window);
DEBUG_PRINT("mstack window id: %d\n", c->window);
// DEBUG_PRINT("mstack wm_name: %s\n", xt.value)
// DEBUG_PRINT("mstack client width: %d\n", ch.width)
// DEBUG_PRINT("mstack client height: %d\n", ch.height)
@ -593,7 +595,7 @@ void wm_mstack(Wm *wm, Monitor *m)
else {
// FIXME not working with dock
for (c = m->clients; c; c = c->next) {
if (c->ws == m->selws && c != &wm->root && !c->is_floating) {
if (c->ws == m->selws && c->window != wm->root.window && !c->is_floating) {
if (n == 0) {
c->x = 0;
c->y = sy;
@ -614,7 +616,7 @@ void wm_mstack(Wm *wm, Monitor *m)
// FIXME vv RUNTIME MALLOC ABORT vv
//XGetWMName(wm->display, c->window, &xt);
DEBUG_PRINT("mstack client: 0x%x\n", c);
// DEBUG_PRINT("mstack window id: %d\n", c->window);
DEBUG_PRINT("mstack window id: %d\n", c->window);
// DEBUG_PRINT("mstack wm_name: %s\n", xt.value)
// DEBUG_PRINT("mstack client x: %d ", ch.x)
// DEBUG_PRINT("y: %d\n", ch.y)
@ -780,6 +782,8 @@ void wm_init(Wm *wm)
wm->root.window = XRootWindow(wm->display, DefaultScreen(wm->display));
wm->root.ws = 999;
DEBUG_PRINT("root window: %ld\n", wm->root.window);
XSync(d, false);
xa.event_mask = StructureNotifyMask | StructureNotifyMask |