Custom and standard cursors

BlitzMax Forums/BlitzMax Programming/Custom and standard cursors

plash(Posted 2009) [#1]
I know Brucey did bah.changecursor awhile back, but I can't find it and my copy only has windows support (from my searching it would seem he only did it for Mac and windows).

Has anyone tried to set the cursor in Linux?
I'm poking around in MaxGUI atm, and I can scavenge the Mac code from Brucey's post but I don't know if SetPointer works in Linux - or how to do the custom cursors.


Brucey(Posted 2009) [#2]
I know Brucey did bah.changecursor

I did?


plash(Posted 2009) [#3]
Module BaH.ChangeCursor

ModuleInfo "Version: 1.00"
ModuleInfo "Modserver: BRL"
ModuleInfo "Credit: Bruce Henderson first attempt, and Simon Armstrong for the <b>ConvertToBMP()</b> function."

Unless I completely forgot I found the code a loong time ago and stuck it in bah.mod (for who knows why).


Brucey(Posted 2009) [#4]
Something to do with this ?


Brucey(Posted 2009) [#5]
I don't have a change cursor module here ;-)

Although I have lots of code lying around all over the place... probably for Linux too. (If not, it's not difficult on Linux (GTK) to do it)


plash(Posted 2009) [#6]
Yes, that is one of the threads I saw.

You said the Mac code was 'leaky'.
I found the SetPointer stuff for xserver in fltkmaxgui.

This should be easy, as long as I don't loose myself in all this C.

(If not, it's not difficult on Linux (GTK) to do it)
Would the UI system matter? FLTK seems to be calling xserver stuff.

This is probably where I found it (link dead): http://www.blitzbasic.com/Community/posts.php?topic=77664#929668


plash(Posted 2009) [#7]
I think I know how to set it up using XDefineCursor, XCreatePixmapCursor and xUndefineCursor, but I'm not sure how to get the x Display and x Window handles from 'brl.mod/glgraphics.mod/glgraphics.linux.c'.

I'd think you would usually just #include the header, but glgraphics doesn't have a header for its stuff.

EDIT:
I see this:
extern Display *bbSystemDisplay();

in glgrahpics.linux.c, but no function to get the system's window. (does that line mean it is externing that function? I don't think it is because bbSystemDisplay is not further defined in glgraphics.linux.c - I actually cant find it elsewhere.)

EDIT2: I found bbSystemDisplay, and this:
void bbSetMouseVisible(visible){
	If (!x_window) Return;
	If (visible)
	{
		XUndefineCursor(x_display,x_window);
	}
	Else
	{
		If (!x_cursor)
		{
			XColor black;
			char bm[]={0,0,0,0,0,0,0,0};
			Pixmap pix=XCreateBitmapFromData(x_display,x_window,bm,8,8);
			memset(&black,0,SizeOf(XColor));
			black.flags=DoRed|DoGreen|DoBlue;
			x_cursor=XCreatePixmapCursor(x_display,pix,pix,&black,&black,0,0);
			XFreePixmap(x_display,pix);
		}
		XDefineCursor(x_display,x_window,x_cursor);
	}
}

pretty much does it right there, but I still can't find a way to get the window handle outside of that (brl.system).

EDIT3: Bleh! This would be a reallly easy add if it was done officially.. just add a function here and there :/


plash(Posted 2009) [#8]
I wonder if it is really worth it.. Do all platforms get/have transparent cursor images support?