formatting: remove trailing whitespace and commented code
This commit is contained in:
parent
a0e2f2d7df
commit
beaa017c87
57
src/client.c
57
src/client.c
@ -34,8 +34,6 @@ XWindowChanges wm_client_to_xwchanges(Client *c)
|
||||
ch.y = c->y;
|
||||
ch.width = c->w;
|
||||
ch.height = c->h;
|
||||
// ch.border_width = 0;
|
||||
// ch.stack_mode = Above;
|
||||
|
||||
return ch;
|
||||
}
|
||||
@ -89,12 +87,11 @@ Client* wm_client_create(Wm *wm, Window w)
|
||||
wm->smon->clients = c;
|
||||
} else {
|
||||
t = wm_get_last_client(wm, *c->m);
|
||||
//c = &root;
|
||||
t->next = c;
|
||||
c->prev = t;
|
||||
c->next = NULL;
|
||||
}
|
||||
|
||||
|
||||
XSelectInput(wm->display, c->window, FocusChangeMask | EnterWindowMask |
|
||||
PointerMotionMask);
|
||||
|
||||
@ -226,7 +223,7 @@ void wm_client_kill(Wm *wm, Client *c)
|
||||
DEBUG_PRINT("%s\n", __func__);
|
||||
RETURN_IF_NULL(c);
|
||||
Monitor *m;
|
||||
|
||||
|
||||
m = c->m;
|
||||
|
||||
XEvent event;
|
||||
@ -343,7 +340,7 @@ Client* wm_client_get_dir_rel_c(Client *c, int dir)
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "wm: %s invalid direction: %d\n", __func__, dir);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PtrArray client_nodes = wm_treenode_find_client_nodes_ptr(&c->ws->tree);
|
||||
@ -387,9 +384,6 @@ void wm_client_border(Wm *wm, Client *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;
|
||||
XColor color;
|
||||
XColor fcolor;
|
||||
@ -404,15 +398,8 @@ void wm_client_border(Wm *wm, Client *c)
|
||||
XAllocColor(wm->display, cmap, &fcolor);
|
||||
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);
|
||||
|
||||
// DEBUG_PRINT("drawing border for: %d\n", c->window);
|
||||
if (wm_client_is_focused(wm, c)) {
|
||||
DEBUG_PRINT("drawing focused border for: %d\n", (int)c->window);
|
||||
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);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
DEBUG_PRINT("%s\n", __func__)
|
||||
@ -467,29 +431,14 @@ bool wm_client_is_focused(Wm *wm, Client *c)
|
||||
if (c == NULL)
|
||||
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;
|
||||
int r;
|
||||
|
||||
XGetInputFocus(wm->display, &w, &r);
|
||||
//DEBUG_PRINT("is_focused focused window: %d\n", w)
|
||||
|
||||
if (w == c->window) {
|
||||
// DEBUG_PRINT("IS_FOCUSED returning true for client: 0x%x", c)
|
||||
// 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->window)
|
||||
return false;
|
||||
}
|
||||
|
@ -21,9 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "wm.h"
|
||||
#include "client.h"
|
||||
|
||||
/* global configuration variables */
|
||||
// TODO: active layout not working
|
||||
|
||||
static int wm_xerror_handler(Wm *wm, Display *display, XErrorEvent *e)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
// maybe need to handle non-normal windows too
|
||||
void wm_create_handler(Wm *wm, XCreateWindowEvent e)
|
||||
{
|
||||
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)
|
||||
@ -173,7 +113,7 @@ void wm_maprequest_handler(Wm *wm, XMapRequestEvent e)
|
||||
c->hidden = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DEBUG_PRINT("%s: client not found, creating client\n", __func__)
|
||||
|
||||
|
@ -278,7 +278,7 @@ bool wm_nodearray_pop(NodeArray *arr, TreeNode *ret)
|
||||
DEBUG_PRINT("%s\n", __func__);
|
||||
assert(arr);
|
||||
assert(ret);
|
||||
|
||||
|
||||
if (arr->size == 0)
|
||||
return false;
|
||||
|
||||
|
72
src/wm.c
72
src/wm.c
@ -78,12 +78,10 @@ void wm_monitors_open_all(Wm *wm, Display *d)
|
||||
ws->tree = wm_treenode_new(NODE_CLIENT, NULL);
|
||||
}
|
||||
|
||||
//wm->monitors[i].clients = &wm->root;
|
||||
wm->monitors[i].clients = NULL;
|
||||
}
|
||||
|
||||
|
||||
wm->smon = &wm->monitors[0];
|
||||
// wm->smon->clients = &wm->root;
|
||||
DEBUG_PRINT("smon width: %d\n", wm->smon->info.width);
|
||||
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 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)
|
||||
for (size_t i = 0; i < nitems_ret; i++) {
|
||||
char *ret_str = XGetAtomName(wm->display, ((Atom*)prop_ret)[i]);
|
||||
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);
|
||||
}
|
||||
|
||||
// TODO maybe x,y is not 0, because of bar
|
||||
void wm_mstack(Wm *wm, Monitor *m)
|
||||
{
|
||||
DEBUG_PRINT("%s\n", __func__)
|
||||
@ -284,7 +280,7 @@ void wm_mstack(Wm *wm, Monitor *m)
|
||||
// TODO: function
|
||||
|
||||
// FIXME: &root probably wrong
|
||||
|
||||
|
||||
if (wm->dock != ULONG_MAX) {
|
||||
XWindowAttributes x;
|
||||
XGetWindowAttributes(wm->display, wm->dock, &x);
|
||||
@ -312,7 +308,7 @@ void wm_mstack(Wm *wm, Monitor *m)
|
||||
if (cc_sws == 1) {
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (c->ws->index == m->selws && c != &wm->root)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
c->x = 0;
|
||||
c->y = sy;
|
||||
@ -349,21 +345,12 @@ void wm_mstack(Wm *wm, Monitor *m)
|
||||
n++;
|
||||
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 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);
|
||||
wm_client_show(wm, c);
|
||||
|
||||
|
||||
DEBUG_PRINT("%s %d. client next: %p\n", __func__, n, c->next)
|
||||
|
||||
if (c->next == NULL)
|
||||
@ -428,7 +415,7 @@ Client *wm_get_last_client(Wm *wm, Monitor m)
|
||||
|
||||
if (c == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
while (c->next != NULL)
|
||||
c = c->next;
|
||||
|
||||
@ -437,44 +424,10 @@ Client *wm_get_last_client(Wm *wm, Monitor m)
|
||||
|
||||
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;
|
||||
socklen_t t = 108;
|
||||
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) {
|
||||
XEvent e;
|
||||
XNextEvent(wm->display, &e);
|
||||
@ -571,23 +524,16 @@ void wm_init(Wm *wm)
|
||||
|
||||
XChangeWindowAttributes(wm->display, wm->root.window, CWEventMask, &xa);
|
||||
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);
|
||||
|
||||
//XSetErrorHandler(&wm_other_wm_handler);
|
||||
|
||||
|
||||
// if (wm->other_wm) {
|
||||
// printf("wm: Detected other window manager. Exiting.\n");
|
||||
// exit(1);
|
||||
// }
|
||||
|
||||
wm_set_supported_atoms(wm);
|
||||
|
||||
//XSetErrorHandler(&wm_xerror_handler);
|
||||
wm_set_supported_atoms(wm);
|
||||
|
||||
wm->dock = ULONG_MAX;
|
||||
|
||||
@ -716,7 +662,7 @@ void wm_kb_focus_dir(Wm *wm, Arg *args)
|
||||
{
|
||||
Client *c;
|
||||
RETURN_IF_NULL(args)
|
||||
|
||||
|
||||
c = wm_client_get_focused(wm);
|
||||
|
||||
wm_client_focus_dir(wm, c, args->i);
|
||||
@ -747,7 +693,7 @@ struct sockaddr wm_socket_init(Wm *wm)
|
||||
"/tmp/wm_socket_%c", DisplayString(wm->display)[1]);
|
||||
|
||||
ret = bind(wm->socket_fd, (struct sockaddr *) &sock_addr, sizeof(sock_addr));
|
||||
|
||||
|
||||
if (ret == -1) {
|
||||
fprintf(stderr, "wm: could not bind to socket. Exiting.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user