Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-10

How to mimic MWSnap's "Window Information" feature on X11

12 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

MWSnap is an excellent screenshot capture program for the Windows platform. It includes a few other nice features as well. One of them is a "Window Information" feature. Awesome feature to spy on other software to get an idea how how the created the GUI layout. :-) I would like to try and write a utility for X11 platform to do the same. Anybody got any ideas how to do it?

* In MWSnap when you select "Window Information" feature, it seems to take a snapshot of the desktop. I tested this by enabling the seconds in the date/time display. The seconds stop ticking as soon as I select "Window Information" feature.
* As you move the mouse over the screen, it displays information about that window (handle, class, co-ordinates, dimensions etc).
* *This* is the real feature I'm trying to duplicate. As you move the mouse, it draws a rectangle around the window area it's giving information about.
eg: The button in a ComboBox or a Button or Edit on a Form etc.. The following link shows what I'm trying to accomplish. http://opensoft.homeip.net/~graemeg/mwsnap_screenshot.png

Has anybody written such a tool, or know of an existing tool that does this? Anybody know how MWSnap manages to do the above and how I could do the same for X11? I would guess Felipe's Magnifier application will give some hints on capturing the screen, but what about the other parts?

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Funky Beast
to Graeme Geldenhuys: MWSnap is an excellent screenshot capture program for the Windows platform. It includes a…
Graeme Geldenhuys wrote 40 lines
Hi, MWSnap is an excellent screenshot capture program for the Windows platform. It includes a few other nice features as well. One of them is a "Window Information" feature. Awesome feature to spy on other software to get an idea how how the created the GUI layout. :-) I would like to try and write a utility for X11 platform to do the same. Anybody got any ideas how to do it? * In MWSnap when you select "Window Information" feature, it seems to take a snapshot of the desktop. I tested this by enabling the seconds in the date/time display. The seconds stop ticking as soon as I select "Window Information" feature. * As you move the mouse over the screen, it displays information about that window (handle, class, co-ordinates, dimensions etc). * *This* is the real feature I'm trying to duplicate. As you move the mouse, it draws a rectangle around the window area it's giving information about. eg: The button in a ComboBox or a Button or Edit on a Form etc.. The following link shows what I'm trying to accomplish. http://opensoft.homeip.net/~graemeg/mwsnap_screenshot.png Has anybody written such a tool, or know of an existing tool that does this? Anybody know how MWSnap manages to do the above and how I could do the same for X11? I would guess Felipe's Magnifier application will give some hints on capturing the screen, but what about the other parts? Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Hi,

Try wininfo, its included in most distros.
To find out how they do it, you can get the source from: http://www.freedesktop.org/Software/wininfo

HTH,
Funky Beast

Felipe Monteiro de Carvalho
to Graeme Geldenhuys: MWSnap is an excellent screenshot capture program for the Windows platform. It includes a…

Lazarus supports screenshot taking, so this part is easy. If you are using pure X11 then take a look at the gtk2 implementation for screenshots, it uses x11.

Next you take the mouse position and give to a X11 routine to get the window. I don't know which routine to use, but surely there is one, and further using X11 you can get the size of the window.

Then you have a fullscreen app, draw the screenshot and then draw a rectangle making the window look selected. You can further draw anything else. This is how the Virtual Magnifying Glass works (I draw a glass instead of rectangles and texts)

You can also do that with hardware overlays (so you don't need a screenshot, and the background is still alive), but it's a real painful thing to implement, requiring special hardware and offering tons of headackes, so I recomend in screenshot method =)

Felipe Monteiro de Carvalho
Graeme Geldenhuys
to Michael Schneider: Ksnapshot? http://docs.kde.org/stable/en/kdegraphics/ksnapshot/
Michael Schneider wrote
Ksnapshot?

Taking a snapshot is part of the problem, but actually for me the easiest part. The second part that I'm actually after is drawing a rectangle as the mouse moves over different window areas/components and then giving information or those "embedded" windows/components.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Graeme Geldenhuys
to Funky Beast: Try wininfo, its included in most distros. To find out how they do it, you can get the…
Funky Beast wrote
Try wininfo, its included in most distros. To find out how they do it, you can get the source from: http://www.freedesktop.org/Software/wininfo

Ah, I knew about xwininfo (the command line app) which gives all the information I want, except the visual feedback (drawing rectangle) over the windows. 'wininfo' seems even closer to what I want. Thank you for the link - I think it's source will come in very handy.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Graeme Geldenhuys
to Felipe Monteiro de Carvalho: Lazarus supports screenshot taking, so this part is easy. If you are using pure X11 then…

On Fri, Oct 24, 2008 at 3:26 AM, Felipe Monteiro de Carvalho

Lazarus supports screenshot taking, so this part is easy. If you are using pure X11 then take a look at the gtk2 implementation for screenshots, it uses x11.

Thanks Felipe, I'll take a look at that code.

Next you take the mouse position and give to a X11 routine to get the window. I don't know which routine to use, but surely there is one, and further using X11 you can get the size of the window.

I think the 'wininfo' application will help me with this part.

anything else. This is how the Virtual Magnifying Glass works (I draw a glass instead of rectangles and texts)

I'll download a copy of Virtual Magnifying Glass (VMG) to get a better understanding of how it works. Maybe I can adapt VMG to draw rectangles in it's window when the magnification is set to 1x. VMG might save me a lot of work. :-)

You can also do that with hardware overlays (so you don't need a screenshot, and the background is still alive), but it's a real painful thing to implement, requiring special hardware and offering tons of headackes, so I recomend in screenshot method =)

Many Window Managers in X11 has the option to disable full window move or resize. Instead in only draws the window rectangle when you resize or move. And when you leave the mouse button, then only does it redraw the actual window. I thought I could use the same idea as that. And it doesn't seem to take a screenshot of the desktop, because the background applications are still updating while busy with a window resize. I guess they don't use hardware overlays, because it works on all hardware. I guess I will have to search through some window manager code to see how they accomplished that. Now where do I start!!?? ;-)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Graeme Geldenhuys
to Graeme Geldenhuys: MWSnap is an excellent screenshot capture program for the Windows platform. It includes a…
Graeme Geldenhuys wrote 6 lines
* *This* is the real feature I'm trying to duplicate. As you move the mouse, it draws a rectangle around the window area it's giving information about. eg: The button in a ComboBox or a Button or Edit on a Form etc.. The following link shows what I'm trying to accomplish. http://opensoft.homeip.net/~graemeg/mwsnap_screenshot.png

Just a follow-up. I managed to implement such a program for X11 without much issue. It was easier than expected. There was also no need to take a snapshot of the desktop. This is how I did it.

* To query the window/widget under the mouse pointer. I do a recursive XQueryPointer() call. This could probably be improved with a XQueryTree() call, but I couldn't figure out how to use the latter.
* Then to draw the highlighting rectangle around that window I used the same functionality as is done for "rubber banding" when you resize windows. I created a custom "outline" grahics context, set it's "._function" call to GXInvert, set SubWindowMode property to InferiorWindow and then all that remains is to draw directly onto the "root" desktop window.
* To erase the highlighting rectangle, I simply redraw over the old rectangle and GXInvert handles the rest.

Thanks to everybody that suggested alternatives etc...

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Graeme Geldenhuys
to Funky Beast
Funky Beast wrote
You might get some hints for XQueryTree from here: http://www.roard.com/docs/cookbook/cbsu19.html

Thanks for the link, but that example is just like all the others C code examples I found. XQueryTree returns a PPWindow type. A pointer to a pointer which is apparently some form of an array of TXWindow. I have no clue how to access the elements of that array. And simply doing ret_children^[n] results in a compile error. :-( But I see XQueryTree also needs to be called recursively, so I guess there isn't much difference in my method using XQueryPointer.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Felipe Monteiro de Carvalho
to Graeme Geldenhuys
Graeme Geldenhuys wrote
I have no clue how to access the elements of that array. And simply doing ret_children^[n] results in a compile error. :-(

You need to use mode objfpc to access pointers as arrays

Felipe Monteiro de Carvalho