added grid mode on Mod1Mask g
parent
dfd84f9bf3
commit
4641aa2925
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
WMSRC = bar.c client.c cmd.c draw.c event.c kb.c mouse.c util.c wm.c
|
WMSRC = bar.c client.c draw.c event.c kb.c mouse.c util.c wm.c
|
||||||
WMOBJ = ${WMSRC:.c=.o}
|
WMOBJ = ${WMSRC:.c=.o}
|
||||||
MENSRC = menu.c draw.c util.c
|
MENSRC = menu.c draw.c util.c
|
||||||
MENOBJ = ${MENSRC:.c=.o}
|
MENOBJ = ${MENSRC:.c=.o}
|
||||||
|
|
70
client.c
70
client.c
|
@ -3,6 +3,7 @@
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
@ -10,6 +11,73 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "wm.h"
|
#include "wm.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
arrange(void *aux)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
int n, cols, rows, gw, gh, i, j;
|
||||||
|
float rt, fd;
|
||||||
|
|
||||||
|
if(!clients)
|
||||||
|
return;
|
||||||
|
for(n = 0, c = clients; c; c = c->next, n++);
|
||||||
|
rt = sqrt(n);
|
||||||
|
if(modff(rt, &fd) < 0.5)
|
||||||
|
rows = floor(rt);
|
||||||
|
else
|
||||||
|
rows = ceil(rt);
|
||||||
|
if(rows * rows < n)
|
||||||
|
cols = rows + 1;
|
||||||
|
else
|
||||||
|
cols = rows;
|
||||||
|
|
||||||
|
gw = (sw - 1) / cols;
|
||||||
|
gh = (sh - bh - 1) / rows;
|
||||||
|
|
||||||
|
for(i = j = 0, c = clients; c; c = c->next) {
|
||||||
|
c->x = i * gw;
|
||||||
|
c->y = j * gh + bh;
|
||||||
|
c->w = gw;
|
||||||
|
c->h = gh;
|
||||||
|
resize(c);
|
||||||
|
if(++i == cols) {
|
||||||
|
j++;
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sel(void *aux)
|
||||||
|
{
|
||||||
|
const char *arg = aux;
|
||||||
|
Client *c = NULL;
|
||||||
|
|
||||||
|
if(!arg || !stack)
|
||||||
|
return;
|
||||||
|
if(!strncmp(arg, "next", 5))
|
||||||
|
c = stack->snext ? stack->snext : stack;
|
||||||
|
else if(!strncmp(arg, "prev", 5))
|
||||||
|
for(c = stack; c && c->snext; c = c->snext);
|
||||||
|
if(!c)
|
||||||
|
c = stack;
|
||||||
|
raise(c);
|
||||||
|
focus(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kill(void *aux)
|
||||||
|
{
|
||||||
|
Client *c = stack;
|
||||||
|
|
||||||
|
if(!c)
|
||||||
|
return;
|
||||||
|
if(c->proto & WM_PROTOCOL_DELWIN)
|
||||||
|
send_message(c->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
|
||||||
|
else
|
||||||
|
XKillClient(dpy, c->win);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
resize_title(Client *c)
|
resize_title(Client *c)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +181,7 @@ focus(Client *c)
|
||||||
draw_client(old);
|
draw_client(old);
|
||||||
}
|
}
|
||||||
XUnmapWindow(dpy, c->title);
|
XUnmapWindow(dpy, c->title);
|
||||||
draw_client(old);
|
draw_client(c);
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
}
|
}
|
||||||
|
|
52
cmd.c
52
cmd.c
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "wm.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void
|
|
||||||
run(void *aux)
|
|
||||||
{
|
|
||||||
spawn(dpy, aux);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
quit(void *aux)
|
|
||||||
{
|
|
||||||
running = False;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
sel(void *aux)
|
|
||||||
{
|
|
||||||
const char *arg = aux;
|
|
||||||
Client *c = NULL;
|
|
||||||
|
|
||||||
if(!arg || !stack)
|
|
||||||
return;
|
|
||||||
if(!strncmp(arg, "next", 5))
|
|
||||||
c = stack->snext ? stack->snext : stack;
|
|
||||||
else if(!strncmp(arg, "prev", 5))
|
|
||||||
for(c = stack; c && c->snext; c = c->snext);
|
|
||||||
if(!c)
|
|
||||||
c = stack;
|
|
||||||
raise(c);
|
|
||||||
focus(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
kill(void *aux)
|
|
||||||
{
|
|
||||||
Client *c = stack;
|
|
||||||
|
|
||||||
if(!c)
|
|
||||||
return;
|
|
||||||
if(c->proto & WM_PROTOCOL_DELWIN)
|
|
||||||
send_message(c->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
|
|
||||||
else
|
|
||||||
XKillClient(dpy, c->win);
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ X11LIB = /usr/X11R6/lib
|
||||||
VERSION = 0.0
|
VERSION = 0.0
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
|
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -lm -L${X11LIB} -lX11
|
||||||
|
|
||||||
# Linux/BSD
|
# Linux/BSD
|
||||||
CFLAGS = -g -Wall -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
CFLAGS = -g -Wall -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
||||||
|
|
12
kb.c
12
kb.c
|
@ -13,16 +13,18 @@ static const char *term[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *proglist[] = {
|
static const char *proglist[] = {
|
||||||
"sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null | awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
|
"sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null "
|
||||||
|
"| awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static Key key[] = {
|
static Key key[] = {
|
||||||
{ Mod1Mask, XK_Return, run, term },
|
{ Mod1Mask, XK_Return, run, term },
|
||||||
{ Mod1Mask, XK_p, run, proglist },
|
{ Mod1Mask, XK_p, run, proglist },
|
||||||
{ Mod1Mask, XK_k, sel, "prev"},
|
{ Mod1Mask, XK_k, sel, "prev" },
|
||||||
{ Mod1Mask, XK_j, sel, "next"},
|
{ Mod1Mask, XK_j, sel, "next" },
|
||||||
{ Mod1Mask | ShiftMask, XK_c, kill, NULL},
|
{ Mod1Mask, XK_g, arrange, NULL },
|
||||||
{ Mod1Mask | ShiftMask, XK_q, quit, NULL},
|
{ Mod1Mask | ShiftMask, XK_c, kill, NULL },
|
||||||
|
{ Mod1Mask | ShiftMask, XK_q, quit, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
12
wm.c
12
wm.c
|
@ -175,6 +175,18 @@ cleanup()
|
||||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
run(void *aux)
|
||||||
|
{
|
||||||
|
spawn(dpy, aux);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
quit(void *aux)
|
||||||
|
{
|
||||||
|
running = False;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
13
wm.h
13
wm.h
|
@ -58,12 +58,6 @@ extern Client *clients, *stack;
|
||||||
/* bar.c */
|
/* bar.c */
|
||||||
extern void draw_bar();
|
extern void draw_bar();
|
||||||
|
|
||||||
/* cmd.c */
|
|
||||||
extern void run(void *aux);
|
|
||||||
extern void quit(void *aux);
|
|
||||||
extern void kill(void *aux);
|
|
||||||
extern void sel(void *aux);
|
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
extern void manage(Window w, XWindowAttributes *wa);
|
extern void manage(Window w, XWindowAttributes *wa);
|
||||||
extern void unmanage(Client *c);
|
extern void unmanage(Client *c);
|
||||||
|
@ -76,10 +70,15 @@ extern void update_size(Client *c);
|
||||||
extern Client *gettitle(Window w);
|
extern Client *gettitle(Window w);
|
||||||
extern void raise(Client *c);
|
extern void raise(Client *c);
|
||||||
extern void lower(Client *c);
|
extern void lower(Client *c);
|
||||||
|
extern void kill(void *aux);
|
||||||
|
extern void sel(void *aux);
|
||||||
|
|
||||||
/* event.c */
|
/* event.c */
|
||||||
extern void discard_events(long even_mask);
|
extern void discard_events(long even_mask);
|
||||||
|
|
||||||
|
/* grid.c */
|
||||||
|
extern void arrange();
|
||||||
|
|
||||||
/* key.c */
|
/* key.c */
|
||||||
extern void update_keys();
|
extern void update_keys();
|
||||||
extern void keypress(XEvent *e);
|
extern void keypress(XEvent *e);
|
||||||
|
@ -92,3 +91,5 @@ extern void mmove(Client *c);
|
||||||
extern int error_handler(Display *dpy, XErrorEvent *error);
|
extern int error_handler(Display *dpy, XErrorEvent *error);
|
||||||
extern void send_message(Window w, Atom a, long value);
|
extern void send_message(Window w, Atom a, long value);
|
||||||
extern int win_proto(Window w);
|
extern int win_proto(Window w);
|
||||||
|
extern void run(void *aux);
|
||||||
|
extern void quit(void *aux);
|
||||||
|
|
Loading…
Reference in New Issue