OSWindow and OSWindowDriver questions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

OSWindow and OSWindowDriver questions

Matthieu
Hello everyone,

I'm writing here because I would like some insight about the OSWindowDriver.

As you may know, the OSWindowDriver (via OSSDL2Driver) is responsible for many things in OSWindow such as setting up the event loop, creating the SDL window, etc.

My first question is : How are you supposed to access the driver ?

Currently you can do a "OSWindowDriver current" and it should return you the "most suited driver". It is the way the driver is picked if you don't specify a preferable driver in the OSWindow attributes.
I see two problems with this :
  - If you don't have the SDL plugin it returns you an OSWindowNullDriver and you cannot do anything with it even if you have the SDL library.
  - Let's say that SDL does not meet my requirements and I create another binding to another library. I now have the possibility to use OSWindow with two different back-ends. How does the OSWindowDriver discriminates between the twos ?

Now if I want to specify a driver I can do it by setting "preferableDriver" in the OSWindowAttributes.
But if I want an OSSDL2Driver, the only way I see for the moment is to call "OSSDL2Driver new".
But by doing so I am creating an instance of the driver per window created whereas with "OSWindowDriver current" I am only using one instance of the driver for all windows. I think something is not coherent here.
So should all specific drivers be singletons ? Should they all implement their own version of the "current" method returning the only instance of them ?

I have another remark too :

The driver needs to keep a map of all active windows to be able to dispatch events to the correct one. But when a window is destroyed, it needs to be removed from the map so there is no mess in the events and so the garbage collector can free it.
Currently the window map is a class variable of OSSDL2Driver. But I think the map should be common to all drivers because they would probably all need one. So I'd like to move the WindowMap class variable to the "OSWindowDriver" class directly with a class method to remove the selected window from it. That way when a window is destroyed, we just have to call this class method and it is easy.
What do you think about it ?

I hope I was clear enough for you to understand. I would just like to know the best way to "fix" these things.
And If I am totally wrong and there is a precise way to deal with this, please let me know :)

Thanks a lot,

Matthieu
Reply | Threaded
Open this post in threaded view
|

Re: OSWindow and OSWindowDriver questions

Matthieu
Oh, after some reflexion, I don't think it is a good idea anymore to have one window map for all kinds of drivers because if we want to use more than one back-end, the different windows will probably share some IDs so we cannot put them all in the same basket :s
It is probably better then to keep a window map per kind of driver but we still need to be able to update it when a window is destroyed.
How can we know which map is the correct one and how can we access the correct driver ?