我有两个 GTK 窗口
运行动画的普通(主)窗口,在由
gtk_widget_add_tick_callback()
.在某个时候,会创建运行模态循环的辅助窗口:
void show_modal() { GtkWindow* gw = gtkwindow(this); if( parent() ) gtk_window_set_transient_for(gw, gtkwindow( parent() )); gtk_widget_show(GTK_WIDGET(gw)); gtk_window_set_modal(gw,TRUE); gtk_window_set_keep_above(gw,TRUE); this->update_window_state(gool::WINDOW_SHOWN); while( this->is_valid_window() ) { if(this->_window_state == WINDOW_HIDDEN) break; if(this->_window_state == WINDOW_STATE_NA) break; gtk_main_iteration(); // gtk_main_iteration_do(true); } }
问题:主窗口中的动画工作正常,直到show_modal()
被调用。它显示为功能gtk_main_iteration();
添加的块刻度gtk_widget_add_tick_callback()
。一旦我关闭辅助窗口并while() {gtk_main_iteration();}
退出循环,主窗口中的动画就会再次开始运行。
关于如何在 GTK 中制作“动画友好”模式循环的任何想法?
更新:它不仅显示为gtk_main_iteration();
块,而且显示为“当前”以外的任何窗口的任何更新 - 它们只是被冻结。这种 GTK 行为的原因是什么?
更新#2:
gtk_dialog_run();
行为完全一样gtk_main_iteration();
- 锁定除活动窗口之外的任何进程中的任何窗口上的任何更新。