use config field for log file name

This commit is contained in:
Akos Horvath 2024-02-26 16:34:18 +01:00
parent fac46f74f6
commit 42779798fa
3 changed files with 27 additions and 26 deletions

View File

@ -105,7 +105,7 @@ void wm_maprequest_handler(Wm *wm, XMapRequestEvent e)
wm_client_focus(wm, c); wm_client_focus(wm, c);
if (wm->log_after_maprequest) { if (wm->log_after_maprequest) {
wm_log_state(wm, "after wm_kb_spawn", WM_LOGFILENAME); wm_log_state(wm, "after wm_kb_spawn", wm->config.log_path);
wm->log_after_maprequest = false; wm->log_after_maprequest = false;
} }
} }

View File

@ -17,21 +17,21 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "wm.h" #include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#include <asm-generic/errno.h> #include "wm.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <assert.h>
#include "config.h" #include "config.h"
#include "handler.h" #include "handler.h"
#include "client.h" #include "client.h"
@ -410,10 +410,11 @@ void wm_mainloop(Wm *wm)
void wm_init(Wm *wm) void wm_init(Wm *wm)
{ {
XSetWindowAttributes xa; DEBUG_PRINT("wm_init\n");
Display *d; DEBUG_PRINT("pid: %ld\n", getpid());
signal(SIGINT, wm_sigint_handler); XSetWindowAttributes xa;
// signal(SIGINT, wm_sigint_handler);
wm->config = (Config) {0}; wm->config = (Config) {0};
wm_cfg_init_def(&wm->config); wm_cfg_init_def(&wm->config);
@ -426,12 +427,11 @@ void wm_init(Wm *wm)
ConfigFile configfile = {0}; ConfigFile configfile = {0};
wm_configfile_init(&configfile, path); wm_configfile_init(&configfile, path);
wm_configfile_read(&configfile, &wm->config); wm_configfile_read(&configfile, &wm->config);
wm_logfile_init(wm->config.log_path);
wm->log_entries = wm_read_log(wm->config.log_path);
DEBUG_PRINT("wm_init\n") wm->display = wm_connect_display();
DEBUG_PRINT("pid: %ld\n", ((long)getpid())) wm_monitors_open_all(wm, wm->display);
d = wm_connect_display();
wm->display = d;
wm_monitors_open_all(wm, d);
char *display_string = DisplayString(wm->display); char *display_string = DisplayString(wm->display);
setenv("DISPLAY", display_string, 1); setenv("DISPLAY", display_string, 1);
@ -443,7 +443,7 @@ void wm_init(Wm *wm)
DEBUG_PRINT("root window: %ld\n", wm->root.window); DEBUG_PRINT("root window: %ld\n", wm->root.window);
XSync(d, false); XSync(wm->display, false);
xa.event_mask = StructureNotifyMask | StructureNotifyMask | xa.event_mask = StructureNotifyMask | StructureNotifyMask |
SubstructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask | SubstructureRedirectMask |

View File

@ -67,16 +67,14 @@ if (c == NULL) \
#define WM_PREFIX_LEN 4096 #define WM_PREFIX_LEN 4096
#define WM_LOGFILENAME "./log" #define WM_LOG_STATE_START(wm) do { \
wm_log_state(wm, __func__, (wm)->config.log_path); \
#define WM_LOG_STATE_START(wm) do { \
wm_log_state(wm, __func__, WM_LOGFILENAME); \
} while (0); } while (0);
#define WM_LOG_STATE_END(wm) do { \ #define WM_LOG_STATE_END(wm) do { \
char __prefix[WM_PREFIX_LEN] = {0}; \ char __prefix[WM_PREFIX_LEN] = {0}; \
snprintf(__prefix, WM_PREFIX_LEN, "after %s", __func__); \ snprintf(__prefix, WM_PREFIX_LEN, "%s:after", __func__); \
wm_log_state(wm, __prefix, WM_LOGFILENAME); \ wm_log_state(wm, __prefix, (wm)->config.log_path); \
} while (0); } while (0);
typedef struct Client Client; typedef struct Client Client;
@ -140,6 +138,9 @@ struct Wm {
bool log_after_maprequest; bool log_after_maprequest;
int socket_fd; int socket_fd;
/* UIntArray<LogEntry*> */
UIntArray *log_entries;
}; };
Monitor wm_monitor_open(Display *d, XineramaScreenInfo info); Monitor wm_monitor_open(Display *d, XineramaScreenInfo info);