Yeah, unlike Kruler and stuff, you can measure in any direction, not just vertical and horizontal. It's simple, but it does its job well (or at least well enough ). It no longer is a hacky bash script thing, it's now a semi-proper C program (that happens to still use zenity...).
Sometime I hope to remove the requirement of zenity, but C and GTK are confusing together (why can't it be as easy as pygtk?)
Last edited by doorknob60 (2011-07-28 19:30:30)
Really simple code. I think maybe somebody will port it to pure C code within one file.
$ diff y.c x.c 45c45 < printf("%d\n", e.xbutton.y); --- > printf("%d\n", e.xbutton.x);
I bet you can put these two into one.
This silver ladybug at line 28...
Yeah, it originally was, actually, but again, this was a quick dirty hack to make it work right XD I'll mess with it more when I have time. Maybe try to learn enough C to not need to involve a bash script, but that's for a later date
This is a later date I turned this into a proper C program (no, actually I cheated and used zenity for the dialogs, but no more bash ) as a mini-project to try to learn C. I'll update the main post.
Last edited by doorknob60 (2010-09-22 21:31:29)
How is it supposed to work with X-mouse? (focus follows mouse?)
If I position the cursor somewhere all keyboard input including enter is directed to that window, not to sceenruler.
Looks like a nice project to learn with. There is really no need to close and reopen the X Display. Open it once at the start of the program, and close it again at the end. Having an open connection to the display costs nothing and interferes with nothing else.
That said, given the above comment, you may want to interfere: use XGrabPointer and there will be no need for pressing enter a couple of times, and it will not matter what window the mouse is over (nor what window is focused).
Minimal pseudo code:
1) open display
2) grab pointer
3) wait for mouse down (get x and y coordinates from the mouse down event)
4) wait for mouse up (get 2nd x and y from mouse up event)
5) release the pointer grab
6) close the display
You could even change the cursor (at steps 2 or 3 and back at 5) to indicate the measurement is being made.