Re: [AD] multiple windows

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2006-08-16, Elias Pschernig <elias@xxxxxxxxxx> wrote:
> I'm just playing around with a minimal display driver for the new API,
> and it works like this:
> 
> AL_DISPLAY *display1 = al_create_display(640, 480, AL_WINDOWED);
> AL_DISPLAY *display2 = al_create_display(640, 480, AL_WINDOWED);
> 
> Will give me two independent windows.
> 
> It works like this:
> 
> al_create_display() uses the system_driver to get a list of available
> display drivers, e.g. the X11 driver, and creates an AL_DISPLAY with
> that driver. The display driver will create a new window with an event
> loop. To get e.g. keyboard events, you would do something like:
> 
> AL_KEYBOARD *keyboard1 = al_get_keyboard(display1)
> AL_KEYBOARD *keyboard2 = al_get_keyboard(display2)

After the discussions on the alleg-bigfive list, the keyboard event
source was decided to be global.  Otherwise if you have N windows and M
input devices, you need to keep track of N*M event sources.  There is a
field in the AL_EVENT structure which tells you which window was in
focus at the time the event was generated.

> Then if you simply want to read keys from any window, you do:
> 
> AL_EVENT_QUEUE *queue =  al_create_event_queue();
> al_register_event_source(queue keyboard1);
> al_register_event_source(queue keyboard2);
> 
> AL_EVENT event;
> al_get_next_event(queue &event);
> 
> Does it all make sense? So basically, xwin.c in 4.2 is not executed by
> allegro_init(), but by each al_create_dispay().

Not sure what you mean by that.  For example, at least the compatibility
layer should be able to 'install_keyboard' before 'set_gfx_mode', and
even in the new API it would be nice to do that.

Peter





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/