Results 11 to 12 of 12
Originally Posted by SamoaWarrrior
Think I got my answer. No callbacks, I'll provide an abstraction of the event loop.
The user code would like:
Code:
while(1)
{
myEvent = MyGetEvent( ...
- 04-20-2007 #11Linux Enthusiast
- Join Date
- Jun 2005
- Location
- The Hot Humid South
- Posts
- 602
But isn't that the same as just using the regular X event loop? I see no advantage this provides over just using what posted here before. In your code you wouldn't be able to use XCheckWindowEvent (XCheckNextEvent doesn't exist, I assume you meant this one) because XCheckWindowEvent pulls a particular event, at which point you really wouldn't need the switch to check which event it is since you're only pulling a particular event type from a window.
Originally Posted by SamoaWarrrior
You can still have the programmer write his own event handler, just use function pointers like you were thinking about doing before. If I'm not mistaken this is how most, if not all, C-based widget sets do it. This way you can also have your library handling events in a default manner and the programmer using the library can override the function pointer with his own.That's a good idea, but once I write a while(1) loop in my function, the user code from that point ahead won't be executed, right?
Good luck!"Today you are freer than ever to do what you want, provided you can pay for it!" --Bad Religion
- 04-21-2007 #12Just Joined!
- Join Date
- Apr 2007
- Posts
- 8
I think you are thinking of something like this:
Originally Posted by bidi
The user code:
My library:Code:main( ) { // Init windows and do drawing stuff, etc. . . // Register callbacks . MyLibraryHandleEvents( ); // This necessarily must be the last statement }
I guess this can be done, but is it Ok to expect users to call MyLibraryHandleEvents( ) this way?Code:void MyLibraryHandleEvents( ) { XEvent event; while(1) { case ButtonPress: // Call the registered callback, if any, else the default handler } }


Reply With Quote
