mirror of git://git.suckless.org/svkbd
increase spacing, set scheme for window, make window render faster by removing unnecessary map requests to X
This commit is contained in:
parent
2a84ae50f9
commit
a5cb7d53ce
|
@ -4,8 +4,8 @@ static double overlay_delay = 1.0; //in seconds
|
|||
static double repeat_delay = 0.75; //in seconds, will not work on keys with overlays
|
||||
static int scan_rate = 50; //scan rate in microseconds, affects key repetition rate
|
||||
static int heightfactor = 14; //one row of keys takes up 1/x of the screen height
|
||||
static int xspacing = 3;
|
||||
static int yspacing = 3;
|
||||
static int xspacing = 5;
|
||||
static int yspacing = 5;
|
||||
static const char *defaultfonts[] = {
|
||||
"DejaVu Sans:bold:size=22"
|
||||
};
|
||||
|
@ -21,5 +21,6 @@ static const char *defaultcolors[SchemeLast][2] = {
|
|||
[SchemeHighlightShift] = { "#008ac0", "#005577" },
|
||||
[SchemeOverlay] = { "#ffffff", "#2b3313" },
|
||||
[SchemeOverlayShift] = { "#008ac0", "#2b3313" },
|
||||
[SchemeWindow] = { "#bbbbbb", "#132a33" },
|
||||
};
|
||||
|
||||
|
|
33
svkbd.c
33
svkbd.c
|
@ -38,7 +38,7 @@
|
|||
enum {
|
||||
SchemeNorm, SchemeNormABC, SchemeNormABCShift, SchemeNormShift, SchemePress,
|
||||
SchemePressShift, SchemeHighlight, SchemeHighlightShift, SchemeOverlay,
|
||||
SchemeOverlayShift, SchemeLast
|
||||
SchemeOverlayShift, SchemeWindow, SchemeLast
|
||||
};
|
||||
enum { NetWMWindowType, NetLast };
|
||||
|
||||
|
@ -70,7 +70,7 @@ static void configurenotify(XEvent *e);
|
|||
static void countrows();
|
||||
static int countkeys(Key *layer);
|
||||
static void drawkeyboard(void);
|
||||
static void drawkey(Key *k);
|
||||
static void drawkey(Key *k, Bool map);
|
||||
static void expose(XEvent *e);
|
||||
static Key *findkey(int x, int y);
|
||||
static void leavenotify(XEvent *e);
|
||||
|
@ -121,7 +121,7 @@ static int debug = 0;
|
|||
static int numlayers = 0;
|
||||
static int numkeys = 0;
|
||||
|
||||
static char *colors[10][2]; /* 10 schemes, 2 colors each */
|
||||
static char *colors[11][2]; /* 11 schemes, 2 colors each */
|
||||
static char *fonts[] = { 0 };
|
||||
|
||||
static KeySym ispressingkeysym;
|
||||
|
@ -158,12 +158,12 @@ motionnotify(XEvent *e)
|
|||
} else {
|
||||
keys[i].highlighted = True;
|
||||
}
|
||||
drawkey(&keys[i]);
|
||||
drawkey(&keys[i], True);
|
||||
}
|
||||
continue;
|
||||
} else if (keys[i].highlighted == True) {
|
||||
keys[i].highlighted = False;
|
||||
drawkey(&keys[i]);
|
||||
drawkey(&keys[i], True);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ motionnotify(XEvent *e)
|
|||
lostfocus = i;
|
||||
ispressingkeysym = 0;
|
||||
keys[i].pressed = 0;
|
||||
drawkey(&keys[i]);
|
||||
drawkey(&keys[i], True);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,18 +309,17 @@ drawkeyboard(void)
|
|||
int i;
|
||||
int row = 0;
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_setscheme(drw, scheme[SchemeWindow]);
|
||||
drw_rect(drw, 0, 0, ww, wh, 1, 1);
|
||||
drw_map(drw, win, 0, 0, ww, wh);
|
||||
for (i = 0; i < numkeys; i++) {
|
||||
if (keys[i].keysym != 0)
|
||||
drawkey(&keys[i]);
|
||||
drawkey(&keys[i], False);
|
||||
}
|
||||
drw_map(drw, win, 0, 0, ww, wh);
|
||||
}
|
||||
|
||||
void
|
||||
drawkey(Key *k)
|
||||
drawkey(Key *k, Bool map)
|
||||
{
|
||||
int x, y, w, h;
|
||||
const char *l;
|
||||
|
@ -377,6 +376,7 @@ drawkey(Key *k)
|
|||
w = TEXTW(l);
|
||||
drw_text(drw, x, y, w, h, 0, l, 0);
|
||||
}
|
||||
if (map)
|
||||
drw_map(drw, win, k->x, k->y, k->w, k->h);
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ press(Key *k, KeySym buttonmod)
|
|||
}
|
||||
}
|
||||
}
|
||||
drawkey(k);
|
||||
drawkey(k, True);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -625,7 +625,7 @@ unpress(Key *k, KeySym buttonmod)
|
|||
if (printoutput)
|
||||
printkey(&keys[i], buttonmod);
|
||||
keys[i].pressed = 0;
|
||||
drawkey(&keys[i]);
|
||||
drawkey(&keys[i], True);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,7 +639,7 @@ unpress(Key *k, KeySym buttonmod)
|
|||
if (!(keys[i].keysym == buttonmod && neutralizebuttonmod))
|
||||
simulate_keyrelease(keys[i].keysym);
|
||||
keys[i].pressed = 0;
|
||||
drawkey(&keys[i]);
|
||||
drawkey(&keys[i], True);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -786,6 +786,11 @@ readxresources(void)
|
|||
if (XrmGetResource(xdb, "svkbd.overlayshiftforeground", "*", &type, &xval) && !colors[SchemeOverlayShift][ColFg])
|
||||
colors[SchemeOverlayShift][ColFg] = estrdup(xval.addr);
|
||||
|
||||
if (XrmGetResource(xdb, "svkbd.windowbackground", "*", &type, &xval) && !colors[SchemeWindow][ColBg])
|
||||
colors[SchemeWindow][ColBg] = estrdup(xval.addr);
|
||||
if (XrmGetResource(xdb, "svkbd.windowforeground", "*", &type, &xval) && !colors[SchemeWindow][ColFg])
|
||||
colors[SchemeWindow][ColFg] = estrdup(xval.addr);
|
||||
|
||||
XrmDestroyDatabase(xdb);
|
||||
}
|
||||
}
|
||||
|
@ -1037,7 +1042,7 @@ showoverlay(int idx)
|
|||
for (i = 0; i < numkeys; i++) {
|
||||
if (keys[i].pressed && !IsModifierKey(keys[i].keysym)) {
|
||||
keys[i].pressed = 0;
|
||||
drawkey(&keys[i]);
|
||||
drawkey(&keys[i], True);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue