add lot of stuff

This commit is contained in:
2022-07-28 23:38:57 +02:00
parent aad5ba497f
commit 452d103a08
2 changed files with 448 additions and 46 deletions

57
wm.h
View File

@ -2,16 +2,33 @@
#include <stdio.h>
#include <stdbool.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
#include <X11/Xproto.h>
#include <unistd.h>
#include <X11/extensions/Xinerama.h>
#define LAST_WINDOW(c, smon) for (c = smon->clients; c; c = c->next) {}
#define FIND_WINDOW(c, smon, window) \
#define RETURN_IF_NULL(c) \
if (c == NULL) \
{ \
fprintf(stderr, "wm: client was null in function %s\n", __func__); \
return; \
}
#define DEBUG
//#define LAST_WINDOW(c, smon) whie {}
//#define FIND_WINDOW(c, smon, window) \
for (c = smon->clients; c; c = c->next) \
{ \
if (c->wn == window) { \
break; \
} \
}
{ \
if (c->wn == window) { \
break; \
} \
}
#ifdef DEBUG
#define DEBUG_PRINT(s) printf(s);
#define DEBUG_PRINTV(s, var) printf(s, var);
#endif
typedef struct Client Client;
typedef struct Monitor Monitor;
@ -37,6 +54,7 @@ struct Client {
Window wn;
Client *prev;
Client *next;
bool has_border;
// linked list is not sufficent for manual tiling.
// will propably need a tree.
};
@ -48,6 +66,11 @@ static int wm_mc;
static bool wm_other_wm;
static Client wm_root;
static Client *wm_last_client;
static void (*wm_active_layout)(Monitor*);
static float wm_ms_p;
static unsigned int wm_border_col = 0x222222;
static unsigned int wm_focused_border_col = 0x444444;
static unsigned char wm_border_width = 2;
static int wm_xerror_handler(Display *display, XErrorEvent *e);
static int wm_other_wm_handler(Display *display, XErrorEvent *e);
@ -56,14 +79,32 @@ void wm_destroy_handler(XDestroyWindowEvent e);
void wm_reparent_handler(XReparentEvent e);
void wm_configure_handler(XConfigureRequestEvent e);
void wm_map_handler(XMapRequestEvent e);
void wm_keyrelease_handler(XKeyReleasedEvent e);
void wm_keypress_handler(XKeyPressedEvent e);
Monitor wm_monitor_open(Display *d, XineramaScreenInfo info);
void wm_monitors_open_all(Display *d);
Display* wm_connect_display();
XWindowChanges wm_client_to_xwchanges(Client c);
void wm_mstack(Monitor *m);
void wm_set_layout(void(*f)(Monitor*));
void wm_layout(Monitor *m);
Client *wm_get_last_client(Monitor m);
void wm_create_client(Window w);
void wm_client_hide(Client *c);
void wm_client_show(Client *c);
void wm_client_focus(Client *c);
void wm_client_kill(Client *c);
Client* wm_client_get_focused();
void wm_client_border(Client *c);
void wm_client_border_focused(Client *c);
void wm_monitor_clients_border(Monitor *m);
bool wm_client_is_focused(Client *c);
XWindowChanges wm_client_to_xwchanges(Client c);
Client* wm_client_find(Window w);
void wm_switch_ws(int ws);
void wm_mainloop();
void wm_init();