summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnno Boland (tox) <tox@s01.de>2009-09-08 11:53:32 +0200
committerEnno Boland (tox) <tox@s01.de>2009-09-08 11:53:32 +0200
commit0f67f586b1a95c0f006f50738bf8b418968076c8 (patch)
tree67257297c2a174e1cefcbd6eebed11e1e85b7af8
parent21ae332817f235ba45e28fe6389abf39308ed93b (diff)
added tab selecting with mouse
-rw-r--r--tabbed.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tabbed.c b/tabbed.c
index d809fe0..2b94ce4 100644
--- a/tabbed.c
+++ b/tabbed.c
@@ -76,12 +76,14 @@ typedef struct Listener {
/* function declarations */
static void autostart(void);
+static void buttonpress(XEvent *e);
static void cleanup(void);
static void configurenotify(XEvent *e);
static void die(const char *errstr, ...);
static void drawbar();
static void drawtext(const char *text, unsigned long col[ColLast]);
static void expose(XEvent *e);
+static void focus(Client *c);
static unsigned long getcolor(const char *colstr);
static Client *getclient(Window w);
static Client *getfirsttab();
@@ -109,6 +111,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[ConfigureNotify] = configurenotify,
[PropertyNotify] = propertynotify,
[UnmapNotify] = unmapnotify,
+ [ButtonPress] = buttonpress,
[KeyPress] = keypress,
[Expose] = expose,
};
@@ -133,6 +136,20 @@ autostart() {
}
void
+buttonpress(XEvent *e) {
+ int i;
+ Client *c;
+ XButtonPressedEvent *ev = &e->xbutton;
+
+ for(i = 0, c = getfirsttab(); c; c = c->next, i++) {
+ if(i * tabwidth < ev->x && (i + 1) * tabwidth > ev->x) {
+ focus(c);
+ break;
+ }
+ }
+}
+
+void
cleanup(void) {
if(dc.font.set)
XFreeFontSet(dpy, dc.font.set);