Note that there are some explanatory texts on larger screens.

plurals
  1. POReuse modal dialog with different parent in GTK+ on MS Windows - broken focus
    primarykey
    data
    text
    <p>I'm reusing a modal dialog in GTK+ &mdash; I set it's parent dialog using <code>gtk_window_set_transient_for</code>, run it, and later reset it's parent to another dialog and run it again.</p> <p>On Linux everything is fine but on MS Windows the second time this dialog is displayed all GTK windows get confused which one is active.</p> <p>This is a test program:</p> <pre><code>#include &lt;gtk/gtk.h&gt; GtkWidget* main_window; void run_reused_dialog( GtkWidget* reused_dialog, const gchar *parent_title, const gchar *reused_dialog_title ) { GtkWidget* parent_dialog = gtk_dialog_new_with_buttons( parent_title, GTK_WINDOW(main_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL ); gtk_container_add( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(parent_dialog))), gtk_label_new(parent_title) ); gtk_widget_show_all(parent_dialog); gtk_dialog_run(GTK_DIALOG(parent_dialog)); gtk_window_set_transient_for(GTK_WINDOW(reused_dialog),GTK_WINDOW(parent_dialog)); gtk_window_set_title(GTK_WINDOW(reused_dialog), reused_dialog_title); GtkWidget* reused_dialog_label = gtk_label_new(GTK_WINDOW(reused_dialog)-&gt;title); gtk_container_add( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(reused_dialog))), reused_dialog_label ); gtk_widget_show_all(reused_dialog); gtk_dialog_run(GTK_DIALOG(reused_dialog)); gtk_widget_hide(reused_dialog); gtk_container_remove( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(reused_dialog))), reused_dialog_label ); gtk_widget_hide(parent_dialog); gtk_widget_destroy(parent_dialog); } int main(int argc, char *argv[]) { gtk_init(&amp;argc, &amp;argv); main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(main_window, "delete-event", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(main_window); /* This is a dialog which will be reused */ GtkWidget* reused_dialog = gtk_dialog_new_with_buttons( "Reused dialog", GTK_WINDOW(main_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL ); gtk_container_add( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(reused_dialog))), gtk_label_new(GTK_WINDOW(reused_dialog)-&gt;title) ); /* Show first dialog which will display reused dialog */ run_reused_dialog( reused_dialog, "First dialog. Click OK to display reused dialog", "Reused dialog. Click OK to close" ); /* Show second dialog which will display reused dialog */ run_reused_dialog( reused_dialog, "Second dialog. Click OK to display reused dialog", "Reused dialog. Switch to another application and switch back" ); gtk_main(); return 0; } </code></pre> <p>When "Reused dialog. Switch to another application and switch back" dialog is displayed, it ignores mouse, but reacts to keyboard input. Sometimes switching to another application and back triggers this problem.</p> <hr> <p>Questions:</p> <ol> <li><p>Am I doing something wrong or is it a bug in Windows GTK port?</p></li> <li><p>How to work around it without recreating this dialog every time it is used?</p></li> <li><p>Am I allowed to reuse GTK dialogs at all?</p></li> </ol> <hr> <p>The sample program source and compiled executable with required GTK libraries is <a href="http://prhn.ato.waw.pl/~tometzky/tmp/gtk-reused-dialog.zip" rel="nofollow">here</a>. This is cross-compiled using <code>i686-pc-mingw32-gcc gtk-reused-dialog.c $(mingw32-pkg-config --cflags --libs gtk+-2.0) -mwindows</code> on Fedora Linux 15 with <code>mingw32-gtk2</code> package and it dependencies installed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload