[cl-gtk2-devel] how to send messages to a window?

Maciej Katafiasz mathrick at gmail.com
Wed Apr 21 09:41:49 UTC 2010


On Wed, Apr 21, 2010 at 10:50, Tamas Papp <tkpapp at gmail.com> wrote:
> How can I send an "expose" message to a window from _outside_ the main
> loop?

You can't. Not in the GTK+ terms, anyway. GTK+ windows don't have
"messages", and you don't "send" anything. These are Win32 terms, and
you're probably confusing yourself because there it is indeed possible
to send messages to foreign windows (and deadlock spectacularly
because as soon as you do, you get multiple threads waiting on each
other, and that's never pretty).

Now, you need to explain how you got outside of the main loop. Is it
another thread? If so, don't do it, it *will* break and is wrong. Add
a new event source to the loop and make it take input from an async
queue, which you'll feed from the other thread. Or just add make an
idle function to the loop which will fire repaint in response to new
events deposited in the queue, without making it an event source, if
it's too much complexity for your needs.

If what you want to send events from is completely external to your
process, then the easiest way should be just to trigger plain X expose
events on the window. That goes outside of the scope of GTK+, and I'm
not familiar with X enough to tell you off-hand how to do it, but I
seem to recall there were enough low-level X bits wrapped in GDK that
it should be doable.

Cheers,
Maciej




More information about the cl-gtk2-devel mailing list