3
我有一個可以在X11顯示器之間移動的應用程序,但是當我在顯示器之外的其他位置時,嘗試打開彈出式菜單會導致崩潰。菜單欄中的菜單正常工作,只是彈出窗口不顯示。在備用X11顯示器上打開彈出式菜單時,Gtk3崩潰
(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;
版本:
- OS:CentOS的7.1(Linux的3.10.0-229.el7.x86_64)
- 的Perl:5.16.3
- Gtk3:3.8.8
- X11:xorg的1.15.0
如果有人用另一種語言試過這個,我想知道它是否工作或沒有。 – TheAmigo