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 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 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 heightfactor = 14; //one row of keys takes up 1/x of the screen height
|
||||||
static int xspacing = 3;
|
static int xspacing = 5;
|
||||||
static int yspacing = 3;
|
static int yspacing = 5;
|
||||||
static const char *defaultfonts[] = {
|
static const char *defaultfonts[] = {
|
||||||
"DejaVu Sans:bold:size=22"
|
"DejaVu Sans:bold:size=22"
|
||||||
};
|
};
|
||||||
|
@ -21,5 +21,6 @@ static const char *defaultcolors[SchemeLast][2] = {
|
||||||
[SchemeHighlightShift] = { "#008ac0", "#005577" },
|
[SchemeHighlightShift] = { "#008ac0", "#005577" },
|
||||||
[SchemeOverlay] = { "#ffffff", "#2b3313" },
|
[SchemeOverlay] = { "#ffffff", "#2b3313" },
|
||||||
[SchemeOverlayShift] = { "#008ac0", "#2b3313" },
|
[SchemeOverlayShift] = { "#008ac0", "#2b3313" },
|
||||||
|
[SchemeWindow] = { "#bbbbbb", "#132a33" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
35
svkbd.c
35
svkbd.c
|
@ -38,7 +38,7 @@
|
||||||
enum {
|
enum {
|
||||||
SchemeNorm, SchemeNormABC, SchemeNormABCShift, SchemeNormShift, SchemePress,
|
SchemeNorm, SchemeNormABC, SchemeNormABCShift, SchemeNormShift, SchemePress,
|
||||||
SchemePressShift, SchemeHighlight, SchemeHighlightShift, SchemeOverlay,
|
SchemePressShift, SchemeHighlight, SchemeHighlightShift, SchemeOverlay,
|
||||||
SchemeOverlayShift, SchemeLast
|
SchemeOverlayShift, SchemeWindow, SchemeLast
|
||||||
};
|
};
|
||||||
enum { NetWMWindowType, NetLast };
|
enum { NetWMWindowType, NetLast };
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ static void configurenotify(XEvent *e);
|
||||||
static void countrows();
|
static void countrows();
|
||||||
static int countkeys(Key *layer);
|
static int countkeys(Key *layer);
|
||||||
static void drawkeyboard(void);
|
static void drawkeyboard(void);
|
||||||
static void drawkey(Key *k);
|
static void drawkey(Key *k, Bool map);
|
||||||
static void expose(XEvent *e);
|
static void expose(XEvent *e);
|
||||||
static Key *findkey(int x, int y);
|
static Key *findkey(int x, int y);
|
||||||
static void leavenotify(XEvent *e);
|
static void leavenotify(XEvent *e);
|
||||||
|
@ -121,7 +121,7 @@ static int debug = 0;
|
||||||
static int numlayers = 0;
|
static int numlayers = 0;
|
||||||
static int numkeys = 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 char *fonts[] = { 0 };
|
||||||
|
|
||||||
static KeySym ispressingkeysym;
|
static KeySym ispressingkeysym;
|
||||||
|
@ -158,12 +158,12 @@ motionnotify(XEvent *e)
|
||||||
} else {
|
} else {
|
||||||
keys[i].highlighted = True;
|
keys[i].highlighted = True;
|
||||||
}
|
}
|
||||||
drawkey(&keys[i]);
|
drawkey(&keys[i], True);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if (keys[i].highlighted == True) {
|
} else if (keys[i].highlighted == True) {
|
||||||
keys[i].highlighted = False;
|
keys[i].highlighted = False;
|
||||||
drawkey(&keys[i]);
|
drawkey(&keys[i], True);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ motionnotify(XEvent *e)
|
||||||
lostfocus = i;
|
lostfocus = i;
|
||||||
ispressingkeysym = 0;
|
ispressingkeysym = 0;
|
||||||
keys[i].pressed = 0;
|
keys[i].pressed = 0;
|
||||||
drawkey(&keys[i]);
|
drawkey(&keys[i], True);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,18 +309,17 @@ drawkeyboard(void)
|
||||||
int i;
|
int i;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeWindow]);
|
||||||
drw_rect(drw, 0, 0, ww, wh, 1, 1);
|
drw_rect(drw, 0, 0, ww, wh, 1, 1);
|
||||||
drw_map(drw, win, 0, 0, ww, wh);
|
|
||||||
for (i = 0; i < numkeys; i++) {
|
for (i = 0; i < numkeys; i++) {
|
||||||
if (keys[i].keysym != 0)
|
if (keys[i].keysym != 0)
|
||||||
drawkey(&keys[i]);
|
drawkey(&keys[i], False);
|
||||||
}
|
}
|
||||||
drw_map(drw, win, 0, 0, ww, wh);
|
drw_map(drw, win, 0, 0, ww, wh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawkey(Key *k)
|
drawkey(Key *k, Bool map)
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
const char *l;
|
const char *l;
|
||||||
|
@ -377,7 +376,8 @@ drawkey(Key *k)
|
||||||
w = TEXTW(l);
|
w = TEXTW(l);
|
||||||
drw_text(drw, x, y, w, h, 0, l, 0);
|
drw_text(drw, x, y, w, h, 0, l, 0);
|
||||||
}
|
}
|
||||||
drw_map(drw, win, k->x, k->y, k->w, k->h);
|
if (map)
|
||||||
|
drw_map(drw, win, k->x, k->y, k->w, k->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -475,7 +475,7 @@ press(Key *k, KeySym buttonmod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawkey(k);
|
drawkey(k, True);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -625,7 +625,7 @@ unpress(Key *k, KeySym buttonmod)
|
||||||
if (printoutput)
|
if (printoutput)
|
||||||
printkey(&keys[i], buttonmod);
|
printkey(&keys[i], buttonmod);
|
||||||
keys[i].pressed = 0;
|
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))
|
if (!(keys[i].keysym == buttonmod && neutralizebuttonmod))
|
||||||
simulate_keyrelease(keys[i].keysym);
|
simulate_keyrelease(keys[i].keysym);
|
||||||
keys[i].pressed = 0;
|
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])
|
if (XrmGetResource(xdb, "svkbd.overlayshiftforeground", "*", &type, &xval) && !colors[SchemeOverlayShift][ColFg])
|
||||||
colors[SchemeOverlayShift][ColFg] = estrdup(xval.addr);
|
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);
|
XrmDestroyDatabase(xdb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1037,7 +1042,7 @@ showoverlay(int idx)
|
||||||
for (i = 0; i < numkeys; i++) {
|
for (i = 0; i < numkeys; i++) {
|
||||||
if (keys[i].pressed && !IsModifierKey(keys[i].keysym)) {
|
if (keys[i].pressed && !IsModifierKey(keys[i].keysym)) {
|
||||||
keys[i].pressed = 0;
|
keys[i].pressed = 0;
|
||||||
drawkey(&keys[i]);
|
drawkey(&keys[i], True);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue