event system works, some code arranging

This commit is contained in:
Enno Boland (tox) 2009-09-07 14:21:26 +02:00
parent aa5f91e0d5
commit 2f2e21c0bb
2 changed files with 22 additions and 20 deletions

View file

@ -35,7 +35,6 @@ static const char normbgcolor[] = "#202020";
static const char normfgcolor[] = "#c0c0c0";
static const char selbgcolor[] = "#884400";
static const char selfgcolor[] = "#f0f0f0";
static const char *surfexec[] = { "surf", "-x" };
#define MODKEY ControlMask
@ -45,15 +44,15 @@ Key keys[] = { \
{ MODKEY, XK_t, newtab, { 0 } },
{ MODKEY|ShiftMask, XK_l, rotate, { .i = +1 } },
{ MODKEY|ShiftMask, XK_h, rotate, { .i = -1 } },
{ MODKEY|ShiftMask, XK_1, move, { .i = 1 } },
{ MODKEY|ShiftMask, XK_2, move, { .i = 2 } },
{ MODKEY|ShiftMask, XK_3, move, { .i = 3 } },
{ MODKEY|ShiftMask, XK_4, move, { .i = 4 } },
{ MODKEY|ShiftMask, XK_5, move, { .i = 5 } },
{ MODKEY|ShiftMask, XK_6, move, { .i = 6 } },
{ MODKEY|ShiftMask, XK_7, move, { .i = 7 } },
{ MODKEY|ShiftMask, XK_8, move, { .i = 8 } },
{ MODKEY|ShiftMask, XK_9, move, { .i = 9 } },
{ MODKEY|ShiftMask, XK_0, move, { .i = 0 } },
{ MODKEY, XK_1, move, { .i = 1 } },
{ MODKEY, XK_2, move, { .i = 2 } },
{ MODKEY, XK_3, move, { .i = 3 } },
{ MODKEY, XK_4, move, { .i = 4 } },
{ MODKEY, XK_5, move, { .i = 5 } },
{ MODKEY, XK_6, move, { .i = 6 } },
{ MODKEY, XK_7, move, { .i = 7 } },
{ MODKEY, XK_8, move, { .i = 8 } },
{ MODKEY, XK_9, move, { .i = 9 } },
{ MODKEY, XK_0, move, { .i = 10 } },
};
#endif

View file

@ -17,7 +17,7 @@
/* macros */
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define LENGTH(x) (sizeof x / sizeof x[0])
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
enum { ColFG, ColBG, ColLast }; /* color */
@ -50,12 +50,16 @@ typedef struct {
} font;
} DC; /* draw context */
typedef struct Client Client;
struct Client {
typedef struct Client {
char name[256];
struct Client *next;
Window win;
};
} Client;
typedef struct Listener {
int fd;
struct Listener *next;
} Listener;
/* function declarations */
static void cleanup(void);
@ -209,24 +213,23 @@ keypress(XEvent *e) {
void
move(const Arg *arg) {
puts("move to nth tab");
}
void
newtab(const Arg *arg) {
puts("opening new tab");
}
void
rotate(const Arg *arg) {
puts("next/prev tab");
}
void
run(void) {
XEvent ev;
/* main event loop, also reads status text from stdin */
XSync(dpy, False);
while(running) {
XNextEvent(dpy, &ev);
@ -260,7 +263,7 @@ setup(void) {
win = XCreateSimpleWindow(dpy, root, wx, wy, ww, wh, 0, dc.norm[ColFG], dc.norm[ColBG]);
XSelectInput(dpy, win, StructureNotifyMask|PointerMotionMask|
ButtonReleaseMask|ButtonPressMask|ExposureMask|
ButtonPressMask|ExposureMask|KeyPressMask|
LeaveWindowMask);
wmh = XAllocWMHints();
wmh->input = False;