modal loop [Was: creating pixmaps and cursors]



itz> How can I write my own modal loop in gdk, without busy-waiting?

Olexiy> Can't you use gtk_window_set_modal(),
Olexiy> gtk_window_set_transient_for() ?

I should have clarified that I didn't want a modal _window_ - just a
loop where I do something depending on how the mouse is moved etc.

Eventually, I did something roughly similar to your suggestion - I
just reuse the main event loop, and I keep state in my main window to
remember I am in the modal loop.  But this destroys the structure of
the program: I have to split what is logically a single action across
multiple event handlers.

In bad old Windows, you could do something like this (sorry I'm too
rusty for this to be spelled correctly, but you get the idea)

void my_modal_button_handler()
{
        Message m;

        while (GetMessage(&m)) {
                TranslateMessage(&m);
                if (m.type != BUTTON_DOWN_MSG) {
                        DispatchMessage(&m);
                } else {
                        do_my_stuff(&m);
                        break;
                }
        }
}

-- 
Ian Zimmerman, Oakland, California, U.S.A.
GPG: 433BA087  9C0F 194F 203A 63F7 B1B8  6E5A 8CA3 27DB 433B A087
EngSoc adopts market economy: cheap is wasteful, efficient is expensive.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]