You are not logged in.
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)
Offline
Really simple code. I think maybe somebody will port it to pure C code within one file.
At least...
$ 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...
Offline
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
Offline
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)
Offline
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.
Offline
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.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline