tags:

views:

38

answers:

2

Hi,

In Gtk application, there is 1 main loop which listens for events (e.g. mouse click, keyboard, etc). And when a modal dialog popup, the main loop is blocked until user clicks 'OK' in the dialog, right? (i.e. nothing will happen when user clicks on the main window). Is that correct?

My question is how can firefox did its modal dialog so that it can: 1. when 1 have 2 Firefox windows 2. one of them has a modal dialog 3. other one is still interactive

If both window shares the same gtk main loop, how is that possible? Please help me understanding this.

Thank you.

A: 

If both windows share the same GTK main loop, then it's not possible. So they don't. Either they have two main loops, or they fake a modal dialog by raising the dialog every time you click on the one main window.

ptomato
How can I assign a new GTK main loop to each window?
michael
Sorry, never done it. Look in the GLib documentation, under the `g_main_whatever` functions (_not_ `gtk_main`)
ptomato
Or look in the Firefox source code ;-)
ptomato
A: 

The alert window of firefox is modal. When you open a new window in firefox, it spawns another firefox process so you have two processes, two windows, two independent main loops.

fetasail
No. I tried this on ubuntu. When I have 1 Firefox and then go to 'New Window', it still shows it uses 1 process (from 'ps -ef' output).
michael
In the modal behavior case, what's the big difference in having two processes instead of two threads with their own loop? Mozilla choosed the multithread approach for something perfectly suited for processes (for reference: http://www.linux-magazine.com/Online/News/Electrolysis-Multi-Process-Firefox) and I bet this is related to optimization. Try `ps -AL` instead.
fetasail