static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, Bool focused);
static void grabkeys(void);
+static void grab_typing_keys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
static void killclient(const Arg *arg);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c);
+static Client *snexttiled(Client *c);
static Client *nextvisible(Client *c);
static void pop(Client *);
static void propertynotify(XEvent *e);
static void run(void);
static void scan(void);
static Bool sendevent(Client *c, Atom proto);
+static void send_keycode(KeyCode key);
static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state);
static void setfocus(Client *c);
static void setup(void);
static void showhide(Client *c);
static void sigchld(int unused);
+static void kbspawn(const Arg *arg);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void zoom(const Arg *arg);
/* variables */
+static KeyCode key_buffer[100];
+static int key_buffer_len = 0;
+static Bool key_buffering = False;
static const char broken[] = "broken";
static char stext[256];
static int screen;
&& (!r->instance || strstr(instance, r->instance)))
{
c->isfloating = r->isfloating;
+ if(r->isfloating) {
+ c->x = -1; c->y = -2; // secret code for centered
+ }
c->tags |= r->tags;
c->screen_hog = r->screen_hog;
for(m = mons; m && m->num != r->monitor; m = m->next);
Bool
applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) {
Bool baseismin;
- Monitor *m = c->mon;
+ // Monitor *m = c->mon;
/* set minimum possible */
*w = MAX(1, *w);
if(*y + *h + 2 * c->bw < 0)
*y = 0;
}
- else {
- if(*x >= m->wx + m->ww)
- *x = m->wx + m->ww - WIDTH(c);
- if(*y >= m->wy + m->wh)
- *y = m->wy + m->wh - HEIGHT(c);
- if(*x + *w + 2 * c->bw <= m->wx)
- *x = m->wx;
- if(*y + *h + 2 * c->bw <= m->wy)
- *y = m->wy;
- }
+ // jason: let windows be offscreen
+ //else {
+ // if(*x >= m->wx + m->ww)
+ // *x = m->wx + m->ww - WIDTH(c);
+ // if(*y >= m->wy + m->wh)
+ // *y = m->wy + m->wh - HEIGHT(c);
+ // if(*x + *w + 2 * c->bw <= m->wx)
+ // *x = m->wx;
+ // if(*y + *h + 2 * c->bw <= m->wy)
+ // *y = m->wy;
+ //}
if(*h < bh)
*h = bh;
if(*w < bh)
void
buttonpress(XEvent *e) {
- unsigned int i, x, click;
+ unsigned int i, click;
Arg arg = {0};
Client *c;
Monitor *m;
focus(NULL);
}
if(ev->window == selmon->barwin) {
- i = x = 0;
- do
- x += TEXTW(tags[i]);
- while(ev->x >= x && ++i < LENGTH(tags));
- if(i < LENGTH(tags)) {
- click = ClkTagBar;
- arg.ui = 1 << i;
- }
- else if(ev->x < x + blw)
- click = ClkLtSymbol;
- else if(ev->x > selmon->ww - TEXTW(stext))
- click = ClkStatusText;
- else
- click = ClkWinTitle;
+ return;
}
else if((c = wintoclient(ev->window))) {
focus(c);
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
}
else if(cme->message_type == netatom[NetActiveWindow]) {
+ // Jason added this so apps can't steal focus:
return;
if(!ISVISIBLE(c)) {
c->mon->seltags ^= 1;
for(i = nextvisible(c->mon->clients); i && i != c; i = nextvisible(i->next))
next_sel = i;
// failing that, find first visible window (besides c)
- if (!next_sel)
+ if (!next_sel) {
for(i = nextvisible(c->mon->clients); i && i == c; i = nextvisible(i->next));
if (i != c)
next_sel = i;
+ }
c->mon->sel = next_sel;
}
if (prev) {
Monitor *m;
XCrossingEvent *ev = &e->xcrossing;
+ return; // jason: added to stop mouse focus
+
if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
return;
c = wintoclient(ev->window);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
}
selmon->sel = c;
- jason_layout(selmon);
+ arrange(selmon);
update_window_opacities(selmon);
drawbars();
if(c && (!root || (c->win!=root)) )
for(j = 0; j < LENGTH(modifiers); j++)
XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
True, GrabModeAsync, GrabModeAsync);
+ if(key_buffering)
+ grab_typing_keys();
+ }
+}
+
+void
+grab_typing_keys(void) {
+ updatenumlockmask();
+ {
+ unsigned int i, j;
+ unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
+ KeySym typing_keys[] = {
+ XK_space, XK_Return, XK_period, XK_slash, XK_minus, XK_apostrophe,
+ XK_A, XK_B, XK_C, XK_D, XK_E, XK_F, XK_G, XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O, XK_P, XK_Q, XK_R, XK_S, XK_T, XK_U, XK_V,
+ XK_W, XK_X, XK_Y, XK_Z, XK_0, XK_1, XK_2, XK_3, XK_4, XK_5, XK_6,
+ XK_7, XK_8, XK_9,
+ };
+
+ KeyCode code;
+
+ for(i = 0; i < LENGTH(typing_keys); i++)
+ if((code = XKeysymToKeycode(dpy, typing_keys[i])))
+ for(j = 0; j < LENGTH(modifiers); j++)
+ XGrabKey(dpy, code, modifiers[j], root,
+ True, GrabModeAsync, GrabModeAsync);
}
}
#endif /* XINERAMA */
void
+send_keycode(KeyCode key) {
+ XKeyEvent event;
+ if(!selmon->sel) {
+ return;
+ }
+ event.display = dpy;
+ event.root = root;
+ event.window = selmon->sel->win;
+ event.subwindow = None;
+ event.same_screen = True;
+ event.x = 1;
+ event.y = 1;
+ event.x_root = 1;
+ event.y_root = 1;
+ event.time = CurrentTime;
+ event.state = 0; // modifiers
+ event.keycode = key;
+ event.type = KeyPress;
+ XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
+ event.type = KeyRelease;
+ XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
+}
+
+void
keypress(XEvent *e) {
unsigned int i;
KeySym keysym;
XKeyEvent *ev;
+ Bool called = False;
ev = &e->xkey;
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
for(i = 0; i < LENGTH(keys); i++)
if(keysym == keys[i].keysym
&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
- && keys[i].func)
+ && keys[i].func) {
keys[i].func(&(keys[i].arg));
+ called = True;
+ }
+ if(!called) {
+ if(key_buffering) {
+ if(key_buffer_len == LENGTH(key_buffer)) {
+ // buffer full, bail
+ key_buffer_len = 0;
+ key_buffering = False;
+ grabkeys(); // stop grabbing typing keys
+ } else {
+ key_buffer[key_buffer_len] = (KeyCode)ev->keycode;
+ key_buffer_len += 1;
+ }
+ } else {
+ send_keycode(ev->keycode);
+ }
+ }
}
void
Client *c, *t = NULL;
Window trans = None;
XWindowChanges wc;
+ int i;
if(!(c = calloc(1, sizeof(Client))))
die("fatal: could not malloc() %u bytes\n", sizeof(Client));
applyrules(c);
}
/* geometry */
- c->x = c->oldx = wa->x;
- c->y = c->oldy = wa->y;
+ if(c->x == -1 && c->y == -2) { // secret code for centered
+ c->x = c->oldx = (c->mon->ww - wa->width) / 2;
+ c->y = c->oldy = (c->mon->wh - wa->height) / 2;
+ } else {
+ c->x = c->oldx = wa->x;
+ c->y = c->oldy = wa->y;
+ }
c->w = c->oldw = wa->width;
c->h = c->oldh = wa->height;
c->oldbw = wa->border_width;
arrange(c->mon);
XMapWindow(dpy, c->win);
focus(c);
+ if(key_buffering) {
+ // FIXME: try turning off buffering below where we send the virt keypresses
+ key_buffering = False;
+ grabkeys(); // stop grabbing typing keys
+ if(key_buffer_len > 0) {
+ for(i = 0; i < key_buffer_len; ++i) {
+ send_keycode(key_buffer[i]);
+ }
+ }
+ key_buffer_len = 0;
+ // FIXME ie here
+ }
}
void
if(!XGetWindowAttributes(dpy, ev->window, &wa))
return;
- if(wa.override_redirect)
+ if(wa.override_redirect) {
+ key_buffer_len = 0;
+ key_buffering = False;
return;
+ }
if(!wintoclient(ev->window))
manage(ev->window, &wa);
}
n++;
if(n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
- for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
- resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False, 0);
+ for(c = snexttiled(m->stack); c; c = snexttiled(c->snext)) {
+ if (c == m->sel) {
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False, 0);
+ } else {
+ // this window is should not be visible. move off top, but don't change h/w
+ resize(c, m->wx, m->wy - 4000, c->w, c->h, False, 0);
+ }
+ }
}
void
}
Client *
+snexttiled(Client *c) {
+ for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->snext);
+ return c;
+}
+
+Client *
nextvisible(Client *c) {
for(; c && !ISVISIBLE(c); c = c->next);
return c;
c->oldy = c->y; c->y = wc.y = y;
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
- base = 0;
+ // base = 0;
if (base) {
wc.stack_mode = Above;
wc.sibling = base->win;
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
netatom[NetSupportingWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
+ XInternAtom(dpy, "_MOTIF_WM_HINTS", False); /* clients may request borderless/fullscreen */
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
}
void
+kbspawn(const Arg *arg) {
+ key_buffering = True;
+ key_buffer_len = 0;
+ grab_typing_keys();
+ spawn(arg);
+}
+
+void
spawn(const Arg *arg) {
int tag = 0, i;
if(arg->v == termcmd) {