Attached is a throw-away patch at the above (because I suck at Xlib
programming). It's just to give you an idea of the "zooming in" idea.
The labelling is not implemented, I just did a one-liner XDrawString
just to experiment with it, neither does the keybinding part.
What do you guys think?
Nazri.
throwaway patch follows..
diff --git a/keynav.c b/keynav.c
index cc37fe7..029e8f8 100644
--- a/keynav.c
+++ b/keynav.c
@@ -81,7 +81,7 @@ void cmd_start(char *args);
void cmd_warp(char *args);
void update();
-void drawborderline(struct wininfo *info, Window win, GC gc,
XRectangle *clip);
+void drawborderline(struct wininfo *info, Window win, GC gc,
XRectangle *clip, char id);
void handle_keypress(XKeyEvent *e);
void handle_commands(char *commands);
void parse_config();
@@ -412,7 +412,7 @@ GC creategc(Window win) {
void drawgrid(Window win, struct wininfo *info, int apply_clip) {
GC gc;
- XRectangle clip[30];
+ XRectangle clip[32];
/* Default start with 4 cells, 2x2 */
- wininfo.grid_x = 2;
- wininfo.grid_y = 2;
+ wininfo.grid_x = 20;
+ wininfo.grid_y = 10;
wininfo.border_thickness = 5;
wininfo.pen_size = 1;
@@ -586,28 +586,28 @@ void cmd_quit(char *args) {
void cmd_cut_up(char *args) {
if (appstate & STATE_ACTIVE == 0)
return;
- wininfo.h = percent_of(wininfo.h, args, .5);
+ wininfo.h = percent_of(wininfo.h, args, .99);
+ XDrawString(dpy, win, gc, rect->x, rect->y+20, &id, 1);
No, it's not like on a map. Each grid crossing would be labeled. The
purpose is to keep
our eyes fixated at or near the target area, then hit Ctrl+; which
brings up the grid, and
due to the sufficiently large number of cells, one or two of the
labels would be
conveniently close to our target that we don't have to move our eyes
at all to read it, and
while still focusing on the target, we move the grid crossing using
h/j/k/l (indirectly by
reducing the cell height and width) and once it's on the target we hit
the correct key
combo to activate clicking on the grid crossing associated with the label.
Thanks for pointing out the entries in the .keynavrc.
It's nice to hear from you so quick :) I've been poring over your old
blog posts on and
off for the last 2 hours or so (slow work day), scouring for gems
(found quite a few).
I found out your blog via your xdotool, which has been invaluable to
me (I paired it with wmctrl)
every single day at work for the last two months or so to automate the
mundane repetitive
things that I have todo. In other words, it save a lot of my time.
Thanks a lot for that!
nazri.
>> Attached is a throw-away patch at the above (because I suck at Xlib
>> programming). It's just to give you an idea of the "zooming in"
>> idea.
>> The labelling is not implemented, I just did a one-liner XDrawString
>> just to experiment with it, neither does the keybinding part.
>>
>> What do you guys think?
>>
> Sounds interesting. Comments on your patch inline.
Interesting idea for me too.
I can't try the patch right now, so can someone put a screenshot online?
>> + XDrawString(dpy, win, gc, rect->x, rect->y+20, &id, 1);
>>
> Frame labelling sounds interesting, but I'm not sure it has a lot of
> applications. Do you prefer labeling the columns and rows only
> (like on a
> map, labels on the outside) or labelling every cell like B4 and C7
> or both?
I like the idea of frame labels for each cell.
For example, if we could use a 60x40 grid (lots of cells), and name
each cell with the minimal amount of fixed letters (like AA, AB, AC,
and so on), one could basically point and type(tm).
Chances are, that there are so many cells that if you can't exactly
point immediately, shifting the grid in one direction a time or two
will bring at least one cell into the target.
Just thinking...
You're not missing anything. What the patch did can be achieved by the
following in your keynavrc:
g grid 20x10
ctrl+l cut-right .99
ctrl+h cut-left .99
ctrl+k cut-up .99
ctrl+j cut-down .99
Hit 'g' after hitting ctrl+; and you'll see the 20x10 cells, then
ctrl+l/h/k/j shrinks each cell so that the chosen nearest
grid-crossing gets closer to your target.
My lame attempt at labeling the cells just draw the letters at the top
row and left column only.
The following are needed to make it happen:
1. "Strung together key sequences" support.
2. Labeling of each grid crossing
3. ???
4. Profit!!!
nazri
nazri
Here's a patch. Comments are welcomed. (Now I think I suck less at Xlib :)
To make the cursor warp to a specific grid crossing, say b0, do the following:
1. hit Ctrl+; to activate keynav,
2. hit ,b0 (that's comma-bee-zero) in succession (the comma key starts
'recording' the next two keys that you press)
3. hit the spacebar and keynav should warp the cursor to wherever b0
is and perform a click there.
It'd work better with the following in your .keynavrc (because you'll
have more grid crossings, so there'll be less keypresses needed to go
to your target):
g grid 20x9
ctrl+l cut-right .99
ctrl+h cut-left .99
ctrl+k cut-up .99
ctrl+j cut-down .99
Hit g after hitting ctrl+;.
The grid size is 20 columns by 9 rows. 9 rows because if it were
higher than that then the labels that are greater than 9 would not fit
well inside the small red boxes.
The columns are labeled from 'a' onwards, while the rows are labeled
from '0' onwards. You can change the row labeling to start from 'a'
too, if you prefer (so that you can have more rows). This would make
labels like 'aa', 'ab', instead of 'a0', 'a1'.
Note that there is no checking for whether the number of columns or
grids goes beyond the printable letters.
Things that can be improved:
1. Once a grid-crossing has been selected, draw only that
grid-crossing in the next update - this would unclutter the display.
2. Use transparent color when drawing the label boxes (is it
possible?) - So that we can see what's behind it.
3. Use single pixel lines so that we can see more of where we want to
point the pointer to.
4. Push stuff down into keynavrc for further customization
(comma/label letters/etc)
Watch out for: memory leaks :D - I've implemented dynamic memory
allocation for the clipping and holes.
I don't have valgrind installed to test for any leak. My poor pipe is
congested with some torrents^H^H^H^H network activity that the
download of valgrind takes like forever. If anyone can test it for
any memory leak that'd be good.
nazri.
On Sun, Dec 7, 2008 at 4:05 PM, Jordan Sissel <j...@semicomplete.com> wrote:Here's a patch. Comments are welcomed. (Now I think I suck less at Xlib :)
> These changes should be pretty easy to make. If someone wants to make a
> proper patch to implement these things before I get to it, I'm happy to
> accept.
To make the cursor warp to a specific grid crossing, say b0, do the following:
1. hit Ctrl+; to activate keynav,
2. hit ,b0 (that's comma-bee-zero) in succession (the comma key starts
'recording' the next two keys that you press)
3. hit the spacebar and keynav should warp the cursor to wherever b0
is and perform a click there.
It'd work better with the following in your .keynavrc (because you'll
have more grid crossings, so there'll be less keypresses needed to go
to your target):
g grid 20x9
ctrl+l cut-right .99Hit g after hitting ctrl+;.
ctrl+h cut-left .99
ctrl+k cut-up .99
ctrl+j cut-down .99
The columns are labeled from 'a' onwards, while the rows are labeled
from '0' onwards. You can change the row labeling to start from 'a'
too, if you prefer (so that you can have more rows). This would make
labels like 'aa', 'ab', instead of 'a0', 'a1'.
Note that there is no checking for whether the number of columns or
grids goes beyond the printable letters.
Things that can be improved:
1. Once a grid-crossing has been selected, draw only that
grid-crossing in the next update - this would unclutter the display.
2. Use transparent color when drawing the label boxes (is it
possible?) - So that we can see what's behind it.
3. Use single pixel lines so that we can see more of where we want to
point the pointer to.
4. Push stuff down into keynavrc for further customization
(comma/label letters/etc)
Watch out for: memory leaks :D - I've implemented dynamic memory
allocation for the clipping and holes.
I don't have valgrind installed to test for any leak. My poor pipe is
congested with some torrents^H^H^H^H network activity that the
download of valgrind takes like forever. If anyone can test it for
any memory leak that'd be good.
Thanks for the heads up. Heh I didn't notice that there's a sample
keynavrc bundled in the tarball.
There's a minor bug with the calculation of the cell locations - it
uses integer arithmetic which results in loss of precision. It's
visible when you do a few .99 cut-downs on a say 20x9 grid. You'll
notice that the bottom cell row is higher than the rest, and while
doing the cut downs the grid crossing near the bottom does not go down
all the time, it goes like down, up, down, up which is very annoying.
Attached patch fixes this issue. This patch is against keynav with my
alternate navigation patch.
nazri.
This one gives me 50% improvement on the number of keypresses that I
have to make to warp to any pixel, i.e. it cuts down the number of
keypresses by half!
comma-[a-z]-[0-9] warps to the specified grid crossing (current
behavior), while apostrophe-[a-z]-[0-9] warps to the center of the
cell that owns the given bottom left grid crossing. Mnemonic: the
comma key is sort of at the bottom left of the apostrophe (at least on
my keyboard :)
After applying this I found that most of the time the area that I want
to click on fall right smack at a grid crossing or at the center of a
cell. If not, they're just a few .99 cuts-up/down/left/right away.
This patch is against keynav-20080614.01 with my
alternate.navigation.patch and cell.location.fix.patch patches.
nazri.