You are not logged in.

#1 2009-10-04 08:50:44

doorknob60
Member
From: Oregon
Registered: 2008-09-29
Posts: 402

ScreenRuler - It measures the screen, duh

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 tongue). It no longer is a hacky bash script thing, it's now a semi-proper C program (that happens to still use zenity...).

2lvjriu.png

PKGBUILD
Github

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

#2 2009-10-04 09:05:35

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,716

Re: ScreenRuler - It measures the screen, duh

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. smile


This silver ladybug at line 28...

Offline

#3 2009-10-04 09:07:29

doorknob60
Member
From: Oregon
Registered: 2008-09-29
Posts: 402

Re: ScreenRuler - It measures the screen, duh

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 tongue

Offline

#4 2010-09-22 21:25:00

doorknob60
Member
From: Oregon
Registered: 2008-09-29
Posts: 402

Re: ScreenRuler - It measures the screen, duh

This is a later date smile I turned this into a proper C program (no, actually I cheated and used zenity for the dialogs, but no more bash tongue) 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

#5 2014-11-10 17:36:48

merilius
Member
Registered: 2012-06-15
Posts: 13

Re: ScreenRuler - It measures the screen, duh

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

#6 2014-11-10 18:45:46

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,794
Website

Re: ScreenRuler - It measures the screen, duh

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.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

Board footer

Powered by FluxBB