#include ONCE "window9.bi"

function GlobalMouseX() as Long export
	
	dim as Display ptr dsp = XOpenDisplay( NULL )
	
	if dsp then
		
		dim as integer screenNumber = DefaultScreen(dsp)
		
		dim as XEvent x_event
		
		XQueryPointer(dsp, RootWindow(dsp, DefaultScreen(dsp)),_
		@x_event.xbutton.root, @x_event.xbutton.window,_
		@x_event.xbutton.x_root, @x_event.xbutton.y_root,_
		@x_event.xbutton.x, @x_event.xbutton.y,_
		@x_event.xbutton.state)
		
		GlobalMouseX = x_event.xbutton.x
		
		XCloseDisplay( dsp )
		
	EndIf
	
end function