
-----------------------------------------------------------------
--# Mouse coordinates (global)
--
-- Why all this just to get the mouse xy location?
-- Because GTK can handle multiple pointers - 
-- for example, besides the mouse (or mice), you
-- might also have a Wacom graphics tablet, 
-- Synaptics TouchPad, or touchscreen, etc.
-- for which you want the coordinates,
-- no matter where on the screen they take place.

-- If you only are interested in the mouse pointer location
-- *within* your program's window, use the simpler
-- get(win,"pointer") call. See test76.

------------------------------------------------------------------

include GtkEngine.e	

constant docs = `
<u><b>Pointer</b></u> location
Move the mouse anywhere on the 
display, and press Alt-O or &lt;enter&gt;
(do not click the mouse buttons)
`
atom disp = create(GdkDisplay)
atom mgr = get(disp,"device manager")
atom pointer = get(mgr,"client pointer") 

constant win = create(GtkWindow,"size=200x100,border_width=10,position=1,$destroy=Quit")

constant panel = create(GtkBox,VERTICAL)
    add(win,panel)

constant img = create(GtkImage,"thumbnails/input-mouse.png")
    add(panel,img)
    
constant lbl = create(GtkLabel)
    set(lbl,"markup",docs)
    add(panel,lbl)

constant
    btn1 = create(GtkButton,"gtk-quit","Quit"),
    btn2 = create(GtkButton,"~/demos/thumbnails/input-mouse.png#Mouse","Foo"),
    btnbox = create(GtkButtonBox,"margin top=5")
    add(btnbox,{btn2,btn1})
    pack(panel,-btnbox)
   
show_all(win)
main()

------------------------------------------------------------------------
global function Foo()
------------------------------------------------------------------------
object xy = get(pointer,"position") 
    Info(win,"Screen Position:",
	format("Mouse Pointer:\nx=[2], y=[3]",xy),
	"Press &lt;enter&gt; or &lt;escape&gt; to close this message box",
	GTK_BUTTONS_CLOSE)
return 1
end function
