read config file, early return in wm_layout when there are no clients
This commit is contained in:
22
src/wm.c
22
src/wm.c
@ -386,6 +386,8 @@ void wm_layout(Wm *wm, Monitor *m)
|
|||||||
|
|
||||||
Workspace *ws = &m->workspaces[m->selws];
|
Workspace *ws = &m->workspaces[m->selws];
|
||||||
PtrArray clients = wm_treenode_find_client_nodes_ptr(&ws->tree);
|
PtrArray clients = wm_treenode_find_client_nodes_ptr(&ws->tree);
|
||||||
|
if (clients.size == 0)
|
||||||
|
goto ret;
|
||||||
|
|
||||||
for (i = 0; i < clients.size; i++) {
|
for (i = 0; i < clients.size; i++) {
|
||||||
TreeNode *node = clients.ptrs[i];
|
TreeNode *node = clients.ptrs[i];
|
||||||
@ -403,13 +405,15 @@ void wm_layout(Wm *wm, Monitor *m)
|
|||||||
wm_client_show(wm, client);
|
wm_client_show(wm, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
wm_client_focus(wm, clients.ptrs[i]);
|
wm_client_focus(wm, ((TreeNode*)clients.ptrs[0])->client);
|
||||||
|
|
||||||
XEvent e;
|
XEvent e;
|
||||||
XSync(wm->display, False);
|
XSync(wm->display, False);
|
||||||
while(XCheckMaskEvent(wm->display, EnterWindowMask, &e));
|
while(XCheckMaskEvent(wm->display, EnterWindowMask, &e));
|
||||||
|
|
||||||
wm_monitor_clients_border(wm, m);
|
wm_monitor_clients_border(wm, m);
|
||||||
|
|
||||||
|
ret:
|
||||||
wm_ptrarray_free(&clients);
|
wm_ptrarray_free(&clients);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,6 +530,18 @@ void wm_init(Wm *wm)
|
|||||||
|
|
||||||
signal(SIGINT, wm_sigint_handler);
|
signal(SIGINT, wm_sigint_handler);
|
||||||
|
|
||||||
|
wm->config = (Config) {0};
|
||||||
|
wm_cfg_init_def(&wm->config);
|
||||||
|
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
const char* file = "/.config/wm.conf";
|
||||||
|
strncat(path, getenv("HOME"), PATH_MAX - 1);
|
||||||
|
strncat(path, file, (PATH_MAX - strlen(file)) - 1);
|
||||||
|
|
||||||
|
ConfigFile configfile = {0};
|
||||||
|
wm_configfile_init(&configfile, path);
|
||||||
|
wm_configfile_read(&configfile, &wm->config);
|
||||||
|
|
||||||
DEBUG_PRINT("wm_init\n")
|
DEBUG_PRINT("wm_init\n")
|
||||||
DEBUG_PRINT("pid: %ld\n", ((long)getpid()))
|
DEBUG_PRINT("pid: %ld\n", ((long)getpid()))
|
||||||
d = wm_connect_display();
|
d = wm_connect_display();
|
||||||
@ -555,8 +571,6 @@ void wm_init(Wm *wm)
|
|||||||
|
|
||||||
// XUngrabKey(wm->display, AnyKey, AnyModifier, root.window);
|
// XUngrabKey(wm->display, AnyKey, AnyModifier, root.window);
|
||||||
|
|
||||||
wm->config = (Config) {0};
|
|
||||||
wm_cfg_init_def(&wm->config);
|
|
||||||
wm_grab_keys(wm);
|
wm_grab_keys(wm);
|
||||||
|
|
||||||
//XSetErrorHandler(&wm_other_wm_handler);
|
//XSetErrorHandler(&wm_other_wm_handler);
|
||||||
@ -574,6 +588,8 @@ void wm_init(Wm *wm)
|
|||||||
|
|
||||||
wm->running = true;
|
wm->running = true;
|
||||||
wm_mainloop(wm);
|
wm_mainloop(wm);
|
||||||
|
|
||||||
|
wm_configfile_free(&configfile);
|
||||||
wm_exit(wm);
|
wm_exit(wm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user