/* The GPLv3 License (GPLv3) Copyright (c) 2022 Akos Horvath This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef WM_H #define WM_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "util.h" // TODO: when only 1 window on ws it is not focused // TODO: dont draw border on not normal windows, floating dialog window, // window type/name/... atom member variable on Client struct // TODO: get_atom probably not working correctly // TODO: important: code cleanliness, ewmh!! // TODO: config command line utility(sockets), maybe avoid global vars #define RETURN_IF_NULL(c) \ if (c == NULL) \ { \ fprintf(stderr, "wm: variable %s was null in function %s\n", #c, __func__); \ return; \ } #define DEBUG 1 #define DEBUG_PRINT(fmt, ...) \ do { if (DEBUG) fprintf(stderr, fmt, ##__VA_ARGS__); } while (0); #define WM_WS_NAME_LEN 64 typedef struct Client Client; typedef struct Workspace Workspace; typedef struct Monitor Monitor; typedef struct Keybind Keybind; typedef struct Arg Arg; typedef struct Wm Wm; enum Direction { UP, DOWN, LEFT, RIGHT }; struct Monitor { Display *display; XineramaScreenInfo info; Client *clients; Workspace *workspaces; size_t selws; size_t wscount; }; struct Client { int x; int y; int w; int h; int ws; bool hidden; Monitor *m; Window window; Client *prev; Client *next; char *name; bool has_border; bool is_floating; // linked list is not sufficent for manual tiling. // will propably need a tree. }; struct Workspace { TreeNode tree; size_t index; char name[WM_WS_NAME_LEN]; Monitor *monitor; }; struct Arg { int i; unsigned int ui; Client *c; char* s; char **sl; int count; }; struct Keybind { unsigned int mask; KeySym keysym; void (*func)(Wm*, Arg*); Arg args; }; struct Wm { // TODO INIT Display *display; Monitor *monitors; Monitor *smon; bool running; int wm_mc; bool other_wm; Client root; Window dock; // TODO: active layout not working void (*active_layout)(Wm *wm, Monitor*); float cfg_ms_p; char *cfg_border_col; char *cfg_focused_border_col; unsigned char cfg_border_width; Keybind *cfg_keybinds; int cfg_kb_count; bool cfg_focus_on_motion; int socket_fd; }; Monitor wm_monitor_open(Display *d, XineramaScreenInfo info); void wm_monitors_open_all(Wm *wm, Display *d); Display* wm_connect_display(); void wm_mstack(Wm *wm, Monitor *m); void wm_set_layout(Wm *wm, void(*f)(Wm *wm, Monitor*)); void wm_layout(Wm *wm, Monitor *m); bool wm_window_is_dock(Wm* wm, Window w); void wm_spawn(Wm* wm, char **str); void wm_switch_ws(Wm* wm, int ws); void wm_mainloop(Wm* wm); void wm_init(Wm *wm); void wm_exit(Wm *wm); void wm_init_cfg_def(Wm *wm); void wm_grab_keys(Wm *wm); void wm_kb_spawn(Wm *wm, Arg *args); void wm_kb_kill(Wm *wm, Arg *args); void wm_kb_switch_ws(Wm *wm, Arg *args); void wm_kb_focus_dir(Wm *wm, Arg *args); void wm_kb_exit(Wm* wm, Arg *args); void wm_keybinds_init_def(Wm *wm); struct sockaddr wm_socket_init(Wm *wm); void wm_socket_cleanup(Wm *wm); void wm_settings_message_parse(Wm *wm, char *c, int len); void wm_sigint_handler(Wm *wm, int signum); #endif