formatting: remove trailing whitespace and commented code

This commit is contained in:
2023-07-06 16:07:29 +02:00
parent a0e2f2d7df
commit beaa017c87
5 changed files with 15 additions and 180 deletions

View File

@ -34,8 +34,6 @@ XWindowChanges wm_client_to_xwchanges(Client *c)
ch.y = c->y; ch.y = c->y;
ch.width = c->w; ch.width = c->w;
ch.height = c->h; ch.height = c->h;
// ch.border_width = 0;
// ch.stack_mode = Above;
return ch; return ch;
} }
@ -89,7 +87,6 @@ Client* wm_client_create(Wm *wm, Window w)
wm->smon->clients = c; wm->smon->clients = c;
} else { } else {
t = wm_get_last_client(wm, *c->m); t = wm_get_last_client(wm, *c->m);
//c = &root;
t->next = c; t->next = c;
c->prev = t; c->prev = t;
c->next = NULL; c->next = NULL;
@ -387,9 +384,6 @@ void wm_client_border(Wm *wm, Client *c)
{ {
RETURN_IF_NULL(c); RETURN_IF_NULL(c);
// DEBUG_PRINT("border col: %s\nfocused border col: %s\n",
// wm->cfg_border_col, wm->cfg_focused_border_col);
XVisualInfo vinfo; XVisualInfo vinfo;
XColor color; XColor color;
XColor fcolor; XColor fcolor;
@ -404,15 +398,8 @@ void wm_client_border(Wm *wm, Client *c)
XAllocColor(wm->display, cmap, &fcolor); XAllocColor(wm->display, cmap, &fcolor);
XAllocColor(wm->display, cmap, &color); XAllocColor(wm->display, cmap, &color);
// DEBUG_PRINT("wm_client_border c: 0x%x\n", c)
if (c) {
// DEBUG_PRINT("wm_client_border window: %d\n", c->window)
}
XSetWindowBorderWidth(wm->display, c->window, wm->config.border_width); XSetWindowBorderWidth(wm->display, c->window, wm->config.border_width);
// DEBUG_PRINT("drawing border for: %d\n", c->window);
if (wm_client_is_focused(wm, c)) { if (wm_client_is_focused(wm, c)) {
DEBUG_PRINT("drawing focused border for: %d\n", (int)c->window); DEBUG_PRINT("drawing focused border for: %d\n", (int)c->window);
XSetWindowBorder(wm->display, c->window, fcolor.pixel); XSetWindowBorder(wm->display, c->window, fcolor.pixel);
@ -421,29 +408,6 @@ void wm_client_border(Wm *wm, Client *c)
XSetWindowBorder(wm->display, c->window, color.pixel); XSetWindowBorder(wm->display, c->window, color.pixel);
} }
// FIXME probably unused
// void wm_client_border_focused(Client *c)
// {
// RETURN_IF_NULL(c);
// // if (!wm_client_is_focused(c))
// // return;
// XVisualInfo vinfo;
// XColor fcolor;
// Colormap cmap;
//
// XMatchVisualInfo(wm->display, DefaultScreen(wm->display), 32,
// TrueColor, &vinfo);
//
// cmap = XCreateColormap(wm->display, c->window, vinfo.visual, AllocNone);
// XParseColor(wm->display, cmap, wm->cfg_focused_border_col, &fcolor);
// XAllocColor(wm->display, cmap, &fcolor);
//
// XSetWindowBorderWidth(wm->display, c->window, wm->cfg_border_width);
//
// DEBUG_PRINT("drawing border for focused window: %d\n", (int)c->window);
// XSetWindowBorder(wm->display, c->window, fcolor.pixel);
// }
void wm_monitor_clients_border(Wm *wm, Monitor *m) void wm_monitor_clients_border(Wm *wm, Monitor *m)
{ {
DEBUG_PRINT("%s\n", __func__) DEBUG_PRINT("%s\n", __func__)
@ -467,29 +431,14 @@ bool wm_client_is_focused(Wm *wm, Client *c)
if (c == NULL) if (c == NULL)
return false; return false;
int prop;
// 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, root.window,
// XInternAtom(wm->display, "_NET_ACTIVE_WINDOW", False),
// 33, 32, PropModeReplace, (unsigned char *) &c->window, 1);
Client *c1;
Window w; Window w;
int r; int r;
XGetInputFocus(wm->display, &w, &r); XGetInputFocus(wm->display, &w, &r);
//DEBUG_PRINT("is_focused focused window: %d\n", w)
if (w == c->window) { if (w == c->window) {
// DEBUG_PRINT("IS_FOCUSED returning true for client: 0x%x", c)
// DEBUG_PRINT("window: %d\n", c->window)
return true; return true;
} }
// DEBUG_PRINT("IS_FOCUSED returning false for client: 0x%x", c)
// DEBUG_PRINT("window: %d\n", c->window)
return false; return false;
} }

View File

@ -21,9 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "wm.h" #include "wm.h"
#include "client.h" #include "client.h"
/* global configuration variables */
// TODO: active layout not working
static int wm_xerror_handler(Wm *wm, Display *display, XErrorEvent *e) static int wm_xerror_handler(Wm *wm, Display *display, XErrorEvent *e)
{ {
printf("wm: Error occured. id: %d req_code: %d\n", printf("wm: Error occured. id: %d req_code: %d\n",
@ -46,66 +43,9 @@ static int wm_other_wm_handler(Display *display, XErrorEvent *e)
return 0; return 0;
} }
// maybe need to handle non-normal windows too
void wm_create_handler(Wm *wm, XCreateWindowEvent e) void wm_create_handler(Wm *wm, XCreateWindowEvent e)
{ {
DEBUG_PRINT("CreateNotify event\n"); DEBUG_PRINT("CreateNotify event\n");
// Client *nc;
// Client *c;
// Client t;
// unsigned char *prop_ret;
// unsigned long nitems_ret;
// Atom type;
// bool is_normal = false;
// t.window = e.window;
// t.m = wm->smon;
// t.ws = wm->smon->selws;
// t.hidden = true;
// //wm_client_is_dock(&t);
// /*
// _NET_WM_WINDOW_TYPE_NORMAL indicates that this is a normal,
// top-level window, [...] windows without _NET_WM_WINDOW_TYPE,
// must be taken as this type [...]
// https://specifications.freedesktop.org/wm-spec
// */
// if (type == None)
// is_normal = true;
//
// if (!is_normal) {
// DEBUG_PRINT("Create handler: window %d is not normal, returning",
// (int)e.window)
// 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->window, FocusChangeMask | EnterWindowMask);
// DEBUG_PRINT("%d window created,", nc->window);
// DEBUG_PRINT("client ws: %d\n", nc->ws);
// // wm_client_is_dock(nc);
// wm_mstack(nc->m);
//wm_client_focus(c);
} }
void wm_destroy_handler(Wm *wm, XDestroyWindowEvent e) void wm_destroy_handler(Wm *wm, XDestroyWindowEvent e)

View File

@ -78,12 +78,10 @@ void wm_monitors_open_all(Wm *wm, Display *d)
ws->tree = wm_treenode_new(NODE_CLIENT, NULL); ws->tree = wm_treenode_new(NODE_CLIENT, NULL);
} }
//wm->monitors[i].clients = &wm->root;
wm->monitors[i].clients = NULL; wm->monitors[i].clients = NULL;
} }
wm->smon = &wm->monitors[0]; wm->smon = &wm->monitors[0];
// wm->smon->clients = &wm->root;
DEBUG_PRINT("smon width: %d\n", wm->smon->info.width); DEBUG_PRINT("smon width: %d\n", wm->smon->info.width);
XFree(xsi); XFree(xsi);
} }
@ -149,7 +147,6 @@ bool wm_window_is_dock(Wm *wm, Window w)
DEBUG_PRINT("actual format return: %d\n", format_ret) DEBUG_PRINT("actual format return: %d\n", format_ret)
DEBUG_PRINT("actual number of items return: %ld\n", nitems_ret) DEBUG_PRINT("actual number of items return: %ld\n", nitems_ret)
DEBUG_PRINT("bytes remaining: %ld\n", nitems_ret) DEBUG_PRINT("bytes remaining: %ld\n", nitems_ret)
//DEBUG_PRINT("property return dec: %d\n", prop_ret)
for (size_t i = 0; i < nitems_ret; i++) { for (size_t i = 0; i < nitems_ret; i++) {
char *ret_str = XGetAtomName(wm->display, ((Atom*)prop_ret)[i]); char *ret_str = XGetAtomName(wm->display, ((Atom*)prop_ret)[i]);
printf("property return str: %s\n", ret_str); printf("property return str: %s\n", ret_str);
@ -265,7 +262,6 @@ void wm_switch_ws(Wm *wm, size_t ws)
wm_ptrarray_free(&switch_ws_clients); wm_ptrarray_free(&switch_ws_clients);
} }
// TODO maybe x,y is not 0, because of bar
void wm_mstack(Wm *wm, Monitor *m) void wm_mstack(Wm *wm, Monitor *m)
{ {
DEBUG_PRINT("%s\n", __func__) DEBUG_PRINT("%s\n", __func__)
@ -349,17 +345,8 @@ void wm_mstack(Wm *wm, Monitor *m)
n++; n++;
ch = wm_client_to_xwchanges(c); ch = wm_client_to_xwchanges(c);
// TODO store wm name when client is created
// FIXME vv RUNTIME MALLOC ABORT vv
//XGetWMName(wm->display, c->window, &xt);
DEBUG_PRINT("mstack client: %p\n", c); DEBUG_PRINT("mstack client: %p\n", c);
DEBUG_PRINT("mstack window id: %ld\n", c->window); DEBUG_PRINT("mstack window id: %ld\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->window, value_mask, &ch); XConfigureWindow(wm->display, c->window, value_mask, &ch);
wm_client_show(wm, c); wm_client_show(wm, c);
@ -437,44 +424,10 @@ Client *wm_get_last_client(Wm *wm, Monitor m)
void wm_mainloop(Wm *wm) void wm_mainloop(Wm *wm)
{ {
// int s = DefaultScreen(wm->display);
// Window w = XCreateSimpleWindow(wm->display, root.window, 10, 10, 300, 300,
// 2, WhitePixel(wm->display, s), BlackPixel(wm->display, s));
// XSelectInput(wm->display, w, KeyPressMask | KeyReleaseMask);
// XMapWindow(wm->display, w);
struct sockaddr s; struct sockaddr s;
socklen_t t = 108; socklen_t t = 108;
getsockname(wm->socket_fd, &s, &t); getsockname(wm->socket_fd, &s, &t);
// int accepted_socket;
// char *buffer;
// accepted_socket = accept(wm->socket_fd, &s, &t);
// if (accepted_socket == -1) {
// if (errno == EAGAIN || errno == EWOULDBLOCK) {
// // fprintf(stderr,
// // "wm: accept failed, no waiting connections are present\n");
// } else {
// fprintf(stderr, "wm: accept failed\n");
// }
// }
// else {
// DEBUG_PRINT("accept success\n")
// len = recv(accepted_socket, buffer, 100, 0);
// if (len != -1) {
// DEBUG_PRINT("got %d bytes:", len)
// for (int i = 0; i < len; i++)
// DEBUG_PRINT("%c", buffer[i])
// DEBUG_PRINT("\n")
// } else {
// fprintf(stderr, "wm: recv failed\n");
// fprintf(stderr, "errno: %d\n", errno);
// }
// }
while (wm->running) { while (wm->running) {
XEvent e; XEvent e;
XNextEvent(wm->display, &e); XNextEvent(wm->display, &e);
@ -571,11 +524,6 @@ void wm_init(Wm *wm)
XChangeWindowAttributes(wm->display, wm->root.window, CWEventMask, &xa); XChangeWindowAttributes(wm->display, wm->root.window, CWEventMask, &xa);
XSelectInput(wm->display, wm->root.window, xa.event_mask); XSelectInput(wm->display, wm->root.window, xa.event_mask);
// DEBUG_PRINT("root window id: %d\n", (root.window))
// XUngrabKey(wm->display, AnyKey, AnyModifier, root.window);
wm_grab_keys(wm); wm_grab_keys(wm);
//XSetErrorHandler(&wm_other_wm_handler); //XSetErrorHandler(&wm_other_wm_handler);
@ -587,8 +535,6 @@ void wm_init(Wm *wm)
wm_set_supported_atoms(wm); wm_set_supported_atoms(wm);
//XSetErrorHandler(&wm_xerror_handler);
wm->dock = ULONG_MAX; wm->dock = ULONG_MAX;
wm->running = true; wm->running = true;