我有一个可以在X11显示器之间移动的应用程序,但是当我在显示器之外的其他位置时,尝试打开弹出菜单会导致崩溃。菜单栏中的菜单工作正常,只是弹出窗口没有。
(popuptest.pl:17147): Gdk-ERROR **: The program 'popuptest.pl' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 355 error_code 3 request_code 131 minor_code 51)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment
variable to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
Trace/breakpoint trap (core dumped)
我创建了一个简单的测试用例来重现问题:
Xvnc :1
等)vncviewer :1
)示例代码:
#!/usr/bin/perl -w
use strict;
use Glib qw/TRUE FALSE/;
use Gtk3 -init;
my $win = Gtk3::Window->new;
$win->signal_connect(destroy => sub {Gtk3::main_quit});
my $btn = Gtk3::Button->new_with_label("move to :1");
$btn->signal_connect(clicked => sub {
$win->set_screen(Gtk3::Gdk::Display::open(":1")->get_screen(0));
});
my $menu;
$btn->signal_connect('button-press-event' => sub {
my ($widget, $event) = @_;
return FALSE unless $event->button == 3;
$menu = Gtk3::Menu->new;
$menu->attach(Gtk3::MenuItem->new_with_label(''.localtime), 0, 1, 0, 1);
$menu->show_all;
$menu->popup(undef, undef, undef, undef, $event->button, $event->time);
return TRUE;
});
$win->add($btn);
$win->show_all;
Gtk3->main;
版本:
答案 0 :(得分:1)
这个版本的Gtk似乎是一个错误。
我能够在使用Gtk 3.18的系统上测试它并且工作正常。至少我知道它不是Perl代码中的错误。