Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gtk3 crash when opening a popup menu on alternate X11 display

Tags:

perl

x11

gtk3

I have an app that I can move between X11 displays, but when I'm on a display other than where I started, attempting to open a popup menu causes a crash. Menus in the menubar work fine, it's just the popup that doesn't.

(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)

I created a simple test case that reproduces the problem:

  1. Start a secondary display (i.e. another machine, Xvnc :1, etc.)
  2. Start a viewer for the 2nd display (e.g. vncviewer :1)
  3. Run the code below
  4. Right click on the button and see the popup menu work correctly
  5. Left click on the button so the window moves to the other display
  6. On the other display, right click on the button and watch the crash

Sample code:

#!/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;

Versions:

  • 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
like image 858
TheAmigo Avatar asked Dec 19 '25 12:12

TheAmigo


1 Answers

It appears to be a bug in that version of Gtk.

I was able to test it on a system with Gtk 3.18 and it works fine. At least I know it's not a bug in the Perl code.

like image 70
TheAmigo Avatar answered Dec 21 '25 06:12

TheAmigo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!