Re: [AD] race condition in X11

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




2005/11/28, Elias Pschernig <elias@xxxxxxxxxx>:
On Mon, 2005-11-28 at 17:34 +0000, Vincent Penecherc'h wrote:
> > In short, avoid the software mouse drawer at all costs - Allegro's gfx
> > system is made to only work from one single thread (just
>
> I see.
>
> Maybe a stupid idea, but since Allegro programs are supposed to be
> calling poll_mouse, and that likely is in the main loop (as opposed to
> the timer loop), and mouse coords will only be updated by that call,
> not more often, why not draw the mouse in poll_mouse ?
> Of course, that'd be relying on poll_mouse being called in that main
> thread.

No program I know off calls poll_mouse, so it wouldn't help with
existing code.

All my programs do. I'm probably not someone to take as an average Allegro coder though.

> Also, when I read the docs after coming back to Allegro a few weeks
> ago, I saw that OS cursors are not guaranteed. In particular, some
> of my mouse cursors are full RGBA bitmaps (you can drag and drop your
> inventory items), so one would still have to have a "legacy" mouse
> path to avoid the no-mouse-on-screen problem, right ?
> Or does Allegro have a fallback for this that takes care of possible
> deadlocks ?
>

Well, most games use some sort of buffering/flipping, so it's easy to
simply draw the mouse cursor at a fixed point, and not use Allegro's one
called from the timer thread. Personally I do this:

if (show_os_cursor(MOUSE_CURSOR_ARROW) < 0)
    need_own_cursor = 1;

...

while(1) {
   ...
   if (need_own_cursor)
      draw_sprite(buffer, mouse_cursor, mouse_x, mouse_y);
   buffer_flip();
   ...
}

With lots of custom cursor, you probably can simply always use the
software drawing..

The only case it doesn't work is, if you have a single screen surface
and need to restore the mouse background.. I'm not really sure what
should be done in that case. But probably we actually could provide a
function which just calls the internal mouse drawer, but now from the
main thread and at a fixed point from the program.

Something similar to glFlip() perhaps? In there all sorts of things could
be done, including calling poll mouse/keyboard, drawing mouse and some other things I
can't think of now.


--
Kalle Last

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