work on dock compatibilty, maprequest client creation

This commit is contained in:
2022-08-01 21:16:37 +02:00
parent 4752d41361
commit 3a87b3014b
2 changed files with 160 additions and 127 deletions

272
wm.c

@ -101,7 +101,7 @@ void wm_create_handler(XCreateWindowEvent e)
// Atom type;
// bool is_normal = false;
// t.wn = e.window;
// t.window = e.window;
// t.m = wm_smon;
// t.ws = wm_smon->selws;
// t.hidden = true;
@ -139,9 +139,9 @@ void wm_create_handler(XCreateWindowEvent e)
// nc->next = NULL;
// }
//
// XSelectInput(wm_display, nc->wn, FocusChangeMask | EnterWindowMask);
// XSelectInput(wm_display, nc->window, FocusChangeMask | EnterWindowMask);
// DEBUG_PRINT("%d window created,", nc->wn);
// DEBUG_PRINT("%d window created,", nc->window);
// DEBUG_PRINT("client ws: %d\n", nc->ws);
// // wm_client_is_dock(nc);
// wm_mstack(nc->m);
@ -157,7 +157,7 @@ void wm_destroy_handler(XDestroyWindowEvent e)
// TODO: make function for linked list management
for (c = wm_smon->clients; c; c = c->next) {
if (e.window == c->wn) {
if (e.window == c->window) {
if (c == wm_smon->clients) {
if (c->next)
wm_smon->clients = c->next;
@ -187,29 +187,23 @@ void wm_reparent_handler(XReparentEvent e)
void wm_configure_handler(XConfigureRequestEvent e)
{
DEBUG_PRINT("ConfigureRequest event\n");
Client *nc;
Client *c;
Client t;
unsigned char *prop_ret;
unsigned long nitems_ret;
Atom type;
bool is_normal = false;
XTextProperty xtp;
t.wn = e.window;
t.m = wm_smon;
t.ws = wm_smon->selws;
t.hidden = true;
c = wm_client_create(e.window);
XGetWMName(wm_display, t.wn, &xtp);
XGetWMName(wm_display, e.window, &xtp);
DEBUG_PRINT("window %d name: %s\n", (int)e.window, xtp.value);
DEBUG_PRINT("%s: created window %d name: %s\n", __func__, (int)e.window, xtp.value);
//XFree(xtp);
char *name = "_NET_WM_WINDOW_TYPE";
type = wm_client_get_atom(&t, "_NET_WM_WINDOW_TYPE", &prop_ret, &nitems_ret);
type = wm_client_get_atom(c, "_NET_WM_WINDOW_TYPE", &prop_ret, &nitems_ret);
if (type == -1) {
fprintf(stderr, "wm_client_get_atom failed\n");
@ -237,34 +231,19 @@ void wm_configure_handler(XConfigureRequestEvent e)
*/
if (type == None) {
DEBUG_PRINT("Atom %s does not exist for window.\n", name)
is_normal = true;
// is_normal = true;
}
if (!is_normal) {
DEBUG_PRINT("configure handler: window %d is not normal, returning\n",
(int)e.window)
wm_client_free(c);
return;
}
nc = malloc(sizeof(Client*));
*nc = t;
if (wm_smon->clients == NULL) {
wm_smon->clients = nc;
nc->prev = NULL;
} else {
c = wm_get_last_client(*nc->m);
//c = &wm_root;
c->next = nc;
nc->prev = c;
nc->next = NULL;
}
XSelectInput(wm_display, nc->wn, FocusChangeMask | EnterWindowMask);
// wm_client_is_dock(nc);
wm_mstack(nc->m);
wm_mstack(c->m);
// wm_client_is_dock(wm_client_find(e.window));
// Client *c;
// XWindowChanges ch;
@ -291,22 +270,11 @@ void wm_configure_handler(XConfigureRequestEvent e)
// // }
// // XConfigureWindow(wm_display, c->wn, e.value_mask, &ch);
// // XConfigureWindow(wm_display, c->window, e.value_mask, &ch);
//
// wm_layout(c->m);
}
void wm_map_handler(XMapRequestEvent e)
{
DEBUG_PRINT("MapRequest event\n")
Client *c;
XMapWindow(wm_display, e.window);
c = wm_client_find(e.window);
c->hidden = false;
}
void wm_keyrelease_handler(XKeyReleasedEvent e)
{
DEBUG_PRINT("KeyReleased event, code: %d\n", e.keycode)
@ -410,6 +378,35 @@ void wm_keypress_handler(XKeyPressedEvent e)
}
}
void wm_maprequest_handler(XMapRequestEvent e)
{
DEBUG_PRINT("MapRequest event\n")
Client *c;
c = wm_client_find(e.window);
if (c) {
DEBUG_PRINT("%s: client found, mapping window\n", __func__)
XMapWindow(wm_display, e.window);
c->hidden = false;
return;
}
if (wm_window_is_dock(e.window))
{
DEBUG_PRINT("%s: window is dock, mapping window\n", __func__)
XMapWindow(wm_display, e.window);
return;
}
DEBUG_PRINT("%s: client not found, creating client\n", __func__)
c = wm_client_create(e.window);
RETURN_IF_NULL(c)
XMapWindow(wm_display, c->window);
wm_mstack(c->m);
}
// TODO
XWindowChanges wm_client_to_xwchanges(Client c)
{
@ -430,16 +427,39 @@ Client* wm_client_find(Window w)
Client *c;
for (c = wm_smon->clients; c; c = c->next) {
if (c->wn == w)
if (c->window == w)
return c;
}
return NULL;
}
void wm_create_client(Window w)
Client* wm_client_create(Window w)
{
Client *c = NULL;
Client *t;
c = malloc(sizeof(Client));
c->window = w;
c->m = wm_smon;
c->ws = wm_smon->selws;
c->hidden = true;
if (wm_smon->clients == NULL) {
wm_smon->clients = c;
c->prev = NULL;
} else {
t = wm_get_last_client(*c->m);
//c = &wm_root;
t->next = c;
c->prev = t;
c->next = NULL;
}
XSelectInput(wm_display, c->window, FocusChangeMask | EnterWindowMask);
return c;
}
void wm_client_hide(Client *c)
@ -450,7 +470,7 @@ void wm_client_hide(Client *c)
return;
c->hidden = true;
XUnmapWindow(wm_display, c->wn);
XUnmapWindow(wm_display, c->window);
}
void wm_client_show(Client *c)
@ -461,19 +481,19 @@ void wm_client_show(Client *c)
return;
c->hidden = false;
XMapWindow(wm_display, c->wn);
XMapWindow(wm_display, c->window);
}
void wm_client_focus(Client *c)
{
RETURN_IF_NULL(c);
XSetInputFocus(wm_display, c->wn, RevertToPointerRoot, CurrentTime);
wm_client_set_atom(c, "_NET_ACTIVE_WINDOW", (unsigned char*) &c->wn,
XSetInputFocus(wm_display, c->window, RevertToPointerRoot, CurrentTime);
wm_client_set_atom(c, "_NET_ACTIVE_WINDOW", (unsigned char*) &c->window,
XA_WINDOW, 1);
// XChangeProperty(wm_display, wm_root.wn,
// XChangeProperty(wm_display, wm_root.window,
// XInternAtom(wm_display, "_NET_ACTIVE_WINDOW", False),
// 33, 32, PropModeReplace, (unsigned char *) &c->wn, 1);
// 33, 32, PropModeReplace, (unsigned char *) &c->window, 1);
wm_monitor_clients_border(c->m);
}
@ -500,10 +520,9 @@ void wm_client_focus_dir(Client *c, int dir)
}
}
void wm_client_kill(Client *c)
void wm_client_free(Client *c)
{
RETURN_IF_NULL(c);
Monitor *m;
if (c == wm_smon->clients) {
if (c->next)
@ -518,10 +537,17 @@ void wm_client_kill(Client *c)
c->next->prev = c->prev;
}
}
}
void wm_client_kill(Client *c)
{
RETURN_IF_NULL(c);
Monitor *m;
m = c->m;
XDestroyWindow(wm_display, c->wn);
free(c);
XDestroyWindow(wm_display, c->window);
wm_client_free(c);
wm_mstack(m);
}
@ -533,7 +559,7 @@ void wm_client_set_atom(Client *c, const char* name, const unsigned char *data,
RETURN_IF_NULL(name);
RETURN_IF_NULL(data);
XChangeProperty(wm_display, c->wn, XInternAtom(wm_display, name, False),
XChangeProperty(wm_display, c->window, XInternAtom(wm_display, name, False),
type, 32, PropModeReplace, data, nelements);
}
@ -555,7 +581,7 @@ Atom wm_client_get_atom(Client *c, const char *name, unsigned char **atom_ret,
unsigned long bytes_remain_ret;
int ret;
ret = XGetWindowProperty(wm_display, c->wn,
ret = XGetWindowProperty(wm_display, c->window,
XInternAtom(wm_display, name, False), 0, (~0L), False,
AnyPropertyType, &type_ret,
&format_ret, nitems_ret, &bytes_remain_ret, atom_ret);
@ -565,7 +591,7 @@ Atom wm_client_get_atom(Client *c, const char *name, unsigned char **atom_ret,
return -1;
}
DEBUG_PRINT("XGetWindowProperty return values, window %d:\n", (int)c->wn);
DEBUG_PRINT("XGetWindowProperty return values, window %d:\n", (int)c->window);
DEBUG_PRINT("actual type return: %d\n", (int)type_ret);
DEBUG_PRINT("actual format return: %d\n", format_ret)
DEBUG_PRINT("actual number of items return: %ld\n", *nitems_ret)
@ -626,7 +652,7 @@ Client* wm_client_get_dir_rel_c(Client *c, int dir)
for (r = c->m->clients; r; r = r->next) {
if ((x > r->x && x < r->x+r->w) && (y > r->y && y < r->y+r->h)) {
DEBUG_PRINT("%s ", __func__)
DEBUG_PRINT("found window %d in direction ", c->wn)
DEBUG_PRINT("found window %d in direction ", c->window)
DEBUG_PRINT("%d\n", dir)
return r;
}
@ -669,7 +695,7 @@ void wm_client_border(Client *c)
XMatchVisualInfo(wm_display, DefaultScreen(wm_display), 32,
TrueColor, &vinfo);
cmap = XCreateColormap(wm_display, c->wn, vinfo.visual, AllocNone);
cmap = XCreateColormap(wm_display, c->window, vinfo.visual, AllocNone);
XParseColor(wm_display, cmap, focuscolorstr, &fcolor);
XParseColor(wm_display, cmap, colorstr, &color);
XAllocColor(wm_display, cmap, &fcolor);
@ -678,18 +704,18 @@ void wm_client_border(Client *c)
// DEBUG_PRINT("wm_client_border c: 0x%x\n", c)
if (c) {
// DEBUG_PRINT("wm_client_border wn: %d\n", c->wn)
// DEBUG_PRINT("wm_client_border window: %d\n", c->window)
}
XSetWindowBorderWidth(wm_display, c->wn, wm_border_width);
XSetWindowBorderWidth(wm_display, c->window, wm_border_width);
// DEBUG_PRINT("drawing border for: %d\n", c->wn);
// DEBUG_PRINT("drawing border for: %d\n", c->window);
if (wm_client_is_focused(c)) {
DEBUG_PRINT("drawing focused border for: %d\n", c->wn);
XSetWindowBorder(wm_display, c->wn, fcolor.pixel);
DEBUG_PRINT("drawing focused border for: %d\n", c->window);
XSetWindowBorder(wm_display, c->window, fcolor.pixel);
}
else
XSetWindowBorder(wm_display, c->wn, color.pixel);
XSetWindowBorder(wm_display, c->window, color.pixel);
}
// TODO maybe merge two border functios
@ -706,14 +732,14 @@ void wm_client_border_focused(Client *c)
XMatchVisualInfo(wm_display, DefaultScreen(wm_display), 32,
TrueColor, &vinfo);
cmap = XCreateColormap(wm_display, c->wn, vinfo.visual, AllocNone);
cmap = XCreateColormap(wm_display, c->window, vinfo.visual, AllocNone);
XParseColor(wm_display, cmap, focuscolorstr, &fcolor);
XAllocColor(wm_display, cmap, &fcolor);
XSetWindowBorderWidth(wm_display, c->wn, wm_border_width);
XSetWindowBorderWidth(wm_display, c->window, wm_border_width);
DEBUG_PRINT("drawing border for focused wn: %d\n", c->wn);
XSetWindowBorder(wm_display, c->wn, fcolor.pixel);
DEBUG_PRINT("drawing border for focused window: %d\n", c->window);
XSetWindowBorder(wm_display, c->window, fcolor.pixel);
}
void wm_monitor_clients_border(Monitor *m)
@ -724,7 +750,7 @@ void wm_monitor_clients_border(Monitor *m)
for (c = wm_smon->clients; c; c = c->next) {
//DEBUG_PRINT("monitor border c: 0x%x\n", c)
if (c->wn != wm_root.wn)
if (c->window != wm_root.window)
wm_client_border(c);
}
}
@ -736,13 +762,13 @@ bool wm_client_is_focused(Client *c)
int prop;
// prop = XGetWindowProperty(wm_display, c->wn,
// prop = XGetWindowProperty(wm_display, c->window,
// XInternAtom(wm_display, "_NET_ACTIVE_WINDOW", False), 0, 1, False,
// XInternAtom(wm_display, "_NET_ACTIVE_WINDOW", False), XA_WINDOW,
// XA_WINDOW, unsigned long *, unsigned long *, unsigned char **)
// XChangeProperty(wm_display, wm_root.wn,
// XChangeProperty(wm_display, wm_root.window,
// XInternAtom(wm_display, "_NET_ACTIVE_WINDOW", False),
// 33, 32, PropModeReplace, (unsigned char *) &c->wn, 1);
// 33, 32, PropModeReplace, (unsigned char *) &c->window, 1);
Client *c1;
Window w;
int r;
@ -750,22 +776,19 @@ bool wm_client_is_focused(Client *c)
XGetInputFocus(wm_display, &w, &r);
//DEBUG_PRINT("is_focused focused window: %d\n", w)
if (w == c->wn) {
if (w == c->window) {
// DEBUG_PRINT("IS_FOCUSED returning true for client: 0x%x", c)
// DEBUG_PRINT("window: %d\n", c->wn)
// DEBUG_PRINT("window: %d\n", c->window)
return true;
}
// DEBUG_PRINT("IS_FOCUSED returning false for client: 0x%x", c)
// DEBUG_PRINT("window: %d\n", c->wn)
// DEBUG_PRINT("window: %d\n", c->window)
return false;
}
bool wm_client_is_dock(Client *c)
bool wm_window_is_dock(Window w)
{
if (!c)
return false;
// TODO: get atom new function
unsigned char *prop_ret;
Atom atom_ret;
@ -774,7 +797,7 @@ bool wm_client_is_dock(Client *c)
unsigned long bytes_remain_ret;
int ret;
ret = XGetWindowProperty(wm_display, c->wn,
ret = XGetWindowProperty(wm_display, w,
XInternAtom(wm_display, "_NET_WM_WINDOW_TYPE", False), 0, (~0L), False,
AnyPropertyType, &atom_ret,
&format_ret, &nitems_ret, &bytes_remain_ret, &prop_ret);
@ -783,12 +806,12 @@ bool wm_client_is_dock(Client *c)
return false;
}
DEBUG_PRINT("XGetWindowProperty return values, window %d:\n", (int)c->wn);
DEBUG_PRINT("XGetWindowProperty return values, window %d:\n", (int)w);
// DEBUG_PRINT("actual atom return: %s\n", XGetAtomName(wm_display, atom_ret));
DEBUG_PRINT("actual format return: %d\n", format_ret)
DEBUG_PRINT("actual number of items return: %ld\n", nitems_ret)
DEBUG_PRINT("bytes remaining: %ld\n", nitems_ret)
DEBUG_PRINT("property return dec: %d\n", prop_ret)
//DEBUG_PRINT("property return dec: %d\n", prop_ret)
for (int i = 0; i < nitems_ret; i++) {
printf("property return str: %s\n",
XGetAtomName(wm_display, ((Atom*)prop_ret)[i]));
@ -800,7 +823,6 @@ bool wm_client_is_dock(Client *c)
}
}
return false;
}
@ -824,7 +846,7 @@ void wm_switch_ws(int ws)
wm_client_set_atom(c, "_NET_CURRENT_DESKTOP", (unsigned char*) &(ws),
XA_CARDINAL, 1);
// XChangeProperty(wm_display, wm_root.wn,
// XChangeProperty(wm_display, wm_root.window,
// XInternAtom(wm_display, "_NET_CURRENT_DESKTOP", False), XA_CARDINAL,
// 32, PropModeReplace, (unsigned char *) &(xasws), 1);
@ -841,20 +863,30 @@ void wm_switch_ws(int ws)
// TODO maybe x,y is not 0, because of bar
void wm_mstack(Monitor *m)
{
DEBUG_PRINT("%s\n", __func__)
RETURN_IF_NULL(m);
Client *c;
XWindowChanges ch;
int cc_sws = 0;
int n = 0;
int sx, sy;
int sx = 0;
int sy = 0;
XTextProperty xt;
unsigned int value_mask = CWX | CWY | CWWidth | CWHeight;
// TODO: function
if (wm_dock != -1) {
XWindowAttributes x;
XGetWindowAttributes(wm_display, wm_dock, &x);
sx = x.x;
sy = x.y+x.height;
DEBUG_PRINT("%s dock sx x: %d y: %d\n", __func__, sx, sy)
}
for (c = m->clients; c; c = c->next) {
if (c->ws == m->selws && c != &wm_root) {
@ -870,18 +902,18 @@ void wm_mstack(Monitor *m)
break;
}
c->x = 0;
c->y = 0;
c->y = sy;
c->w = wm_smon->info.width-wm_border_width*2;
c->h = wm_smon->info.height-wm_border_width*2;
c->h = (wm_smon->info.height-wm_border_width*2)-sy;
ch = wm_client_to_xwchanges(*c);
// DEBUG_PRINT("mstack client: 0x%x\n", c);
// XGetWMName(wm_display, c->wn, &xt);
// DEBUG_PRINT("mstack window id: %d\n", c->wn);
// XGetWMName(wm_display, c->window, &xt);
// 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)
XConfigureWindow(wm_display, c->wn, value_mask, &ch);
XConfigureWindow(wm_display, c->window, value_mask, &ch);
wm_client_show(c);
//wm_client_focus(c);
}
@ -891,30 +923,30 @@ void wm_mstack(Monitor *m)
if (c->ws == m->selws && c != &wm_root) {
if (n == 0) {
c->x = 0;
c->y = 0;
c->y = sy;
c->w = m->info.width*wm_ms_p-wm_border_width*2;
c->h = m->info.height-wm_border_width*2;
c->h = (m->info.height-wm_border_width*2)-sy;
} else {
c->x = (m->info.width*wm_ms_p);
c->y = (n-1)*m->info.height/(cc_sws-1);
c->y = ((n-1)*m->info.height/(cc_sws-1))+sy;
c->w = (m->info.width - m->info.width*wm_ms_p)-wm_border_width*2;
c->h = m->info.height/(cc_sws-1)-wm_border_width*2;
c->h = (m->info.height/(cc_sws-1)-wm_border_width*2)-sy;
}
n++;
ch = wm_client_to_xwchanges(*c);
// TODO store wm name when client is created
XGetWMName(wm_display, c->wn, &xt);
XGetWMName(wm_display, c->window, &xt);
// DEBUG_PRINT("mstack client: 0x%x\n", c);
// DEBUG_PRINT("mstack window id: %d\n", c->wn);
// 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)
// DEBUG_PRINT("mstack client width: %d ", ch.width)
// DEBUG_PRINT("height: %d\n", ch.height)
XConfigureWindow(wm_display, c->wn, value_mask, &ch);
XConfigureWindow(wm_display, c->window, value_mask, &ch);
wm_client_show(c);
if (c->next == NULL)
@ -956,7 +988,7 @@ Client *wm_get_last_client(Monitor m)
void wm_mainloop()
{
// int s = DefaultScreen(wm_display);
// Window w = XCreateSimpleWindow(wm_display, wm_root.wn, 10, 10, 300, 300,
// Window w = XCreateSimpleWindow(wm_display, wm_root.window, 10, 10, 300, 300,
// 2, WhitePixel(wm_display, s), BlackPixel(wm_display, s));
// XSelectInput(wm_display, w, KeyPressMask | KeyReleaseMask);
@ -1041,7 +1073,7 @@ void wm_mainloop()
break;
case MapRequest:
DEBUG_PRINT("MapRequest: %d\n", (int)e.xmaprequest.window)
XMapWindow(wm_display, e.xmaprequest.window);
wm_maprequest_handler(e.xmaprequest);
break;
}
}
@ -1062,7 +1094,7 @@ void wm_init()
// TODO: only testing
// wm_socket_init();
wm_root.wn = XRootWindow(wm_display, DefaultScreen(wm_display));
wm_root.window = XRootWindow(wm_display, DefaultScreen(wm_display));
wm_root.ws = 999;
XSync(d, false);
@ -1071,33 +1103,33 @@ void wm_init()
SubstructureNotifyMask | SubstructureRedirectMask |
ButtonPressMask | PropertyChangeMask;
XChangeWindowAttributes(wm_display, wm_root.wn, CWEventMask, &xa);
XSelectInput(wm_display, wm_root.wn, xa.event_mask);
XChangeWindowAttributes(wm_display, wm_root.window, CWEventMask, &xa);
XSelectInput(wm_display, wm_root.window, xa.event_mask);
DEBUG_PRINT("root window id: %d\n", (wm_root.wn))
DEBUG_PRINT("root window id: %d\n", (wm_root.window))
// TODO: CONFIG KEYS!
XUngrabKey(wm_display, AnyKey, AnyModifier, wm_root.wn);
XUngrabKey(wm_display, AnyKey, AnyModifier, wm_root.window);
unsigned int modifiers[] = {0, LockMask, 0 | LockMask};
XGrabKey(wm_display, XK_C, Mod4Mask | LockMask, wm_root.wn, True,
XGrabKey(wm_display, XK_C, Mod4Mask | LockMask, wm_root.window, True,
GrabModeAsync, GrabModeAsync);
XGrabKey(wm_display, XKeysymToKeycode(wm_display, XK_C), Mod4Mask,
wm_root.wn, True, GrabModeAsync, GrabModeAsync);
XGrabKey(wm_display, XK_C, Mod4Mask | 0, wm_root.wn, True,
wm_root.window, True, GrabModeAsync, GrabModeAsync);
XGrabKey(wm_display, XK_C, Mod4Mask | 0, wm_root.window, True,
GrabModeAsync, GrabModeAsync);
XGrabKey(wm_display, XKeysymToKeycode(wm_display, XK_Return), Mod4Mask,
wm_root.wn, True, GrabModeAsync, GrabModeAsync);
wm_root.window, True, GrabModeAsync, GrabModeAsync);
// focus keys
XGrabKey(wm_display, XKeysymToKeycode(wm_display, XK_H), Mod4Mask,
wm_root.wn, True, GrabModeAsync, GrabModeAsync);
wm_root.window, True, GrabModeAsync, GrabModeAsync);
XGrabKey(wm_display, XKeysymToKeycode(wm_display, XK_J), Mod4Mask,
wm_root.wn, True, GrabModeAsync, GrabModeAsync);
wm_root.window, True, GrabModeAsync, GrabModeAsync);
XGrabKey(wm_display, XKeysymToKeycode(wm_display, XK_K), Mod4Mask,
wm_root.wn, True, GrabModeAsync, GrabModeAsync);
wm_root.window, True, GrabModeAsync, GrabModeAsync);
XGrabKey(wm_display, XKeysymToKeycode(wm_display, XK_L), Mod4Mask,
wm_root.wn, True, GrabModeAsync, GrabModeAsync);
wm_root.window, True, GrabModeAsync, GrabModeAsync);
// workspace switcher keys
@ -1105,7 +1137,7 @@ void wm_init()
for (int i = 0; i < 9; i++) {
XGrabKey(wm_display, XKeysymToKeycode(wm_display, wskeys[i]), Mod4Mask,
wm_root.wn, True, GrabModeAsync, GrabModeAsync);
wm_root.window, True, GrabModeAsync, GrabModeAsync);
}
//XSetErrorHandler(&wm_other_wm_handler);
@ -1116,7 +1148,7 @@ void wm_init()
}
//TODO: new function!
XChangeProperty(wm_display, wm_root.wn,
XChangeProperty(wm_display, wm_root.window,
XInternAtom(wm_display, "_NET_NUMBER_OF_DESKTOPS", False), XA_CARDINAL,
32, PropModeReplace, (unsigned char *) &wm_smon->wscount, 1);
@ -1128,7 +1160,7 @@ void wm_init()
XInternAtom(wm_display, "_NET_ACTIVE_WINDOW", False),
};
XChangeProperty(wm_display, wm_root.wn,
XChangeProperty(wm_display, wm_root.window,
XInternAtom(wm_display, "_NET_SUPPORTED", False), XA_ATOM, 32,
PropModeReplace, (unsigned char *) &wm_supp, sizeof(wm_supp)/sizeof(long));

15
wm.h

@ -24,7 +24,7 @@
#define RETURN_IF_NULL(c) \
if (c == NULL) \
{ \
fprintf(stderr, "wm: pointer was null in function %s\n", __func__); \
fprintf(stderr, "wm: variable %s was null in function %s\n", #c, __func__); \
return; \
}
@ -60,7 +60,7 @@ struct Client {
int ws;
bool hidden;
Monitor *m;
Window wn;
Window window;
Client *prev;
Client *next;
bool has_border;
@ -74,7 +74,7 @@ static Monitor *wm_smon;
static int wm_mc;
static bool wm_other_wm;
static Client wm_root;
static Window wm_dock;
static Window wm_dock = -1;
static void (*wm_active_layout)(Monitor*);
static float wm_ms_p;
static unsigned int wm_border_col = 0x222222;
@ -89,9 +89,9 @@ void wm_create_handler(XCreateWindowEvent e);
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);
void wm_maprequest_handler(XMapRequestEvent e);
Monitor wm_monitor_open(Display *d, XineramaScreenInfo info);
void wm_monitors_open_all(Display *d);
@ -108,19 +108,20 @@ void wm_client_set_atom(Client *c, const char *name, const unsigned char *data,
Atom wm_client_get_atom(Client *c, const char *name, unsigned char **atom_ret,
unsigned long *nitems_ret);
void wm_create_client(Window w);
Client* wm_client_create(Window w);
void wm_client_free(Client *c);
void wm_client_kill(Client *c);
void wm_client_hide(Client *c);
void wm_client_show(Client *c);
void wm_client_focus(Client *c);
void wm_client_focus_dir(Client *c, int dir);
void wm_client_kill(Client *c);
Client* wm_client_get_dir_rel_c(Client *c, int dir);
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);
bool wm_client_is_dock(Client *c);
bool wm_window_is_dock(Window w);
XWindowChanges wm_client_to_xwchanges(Client c);
Client* wm_client_find(Window w);