Skip to content

Commit

Permalink
ui/gtk3: Error handling with display == null
Browse files Browse the repository at this point in the history
BUG=rhbz#2188800
  • Loading branch information
fujiwarat committed Nov 25, 2023
1 parent 1be3e2f commit 0a7a4d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ui/gtk3/bindingcommon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,14 @@ class BindingCommon {
return m_default_is_xdisplay;
}

public static Gdk.X11.Display get_xdisplay() {
public static Gdk.X11.Display? get_xdisplay() {
if (m_xdisplay != null)
return m_xdisplay;
var display = Gdk.Display.get_default();
if (display == null) {
error("You should open a display for IBus panel.");
return null;
}
Type instance_type = display.get_type();
Type x11_type = typeof(Gdk.X11.Display);
if (instance_type.is_a(x11_type)) {
Expand Down
14 changes: 10 additions & 4 deletions ui/gtk3/panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1422,9 +1422,12 @@ class Panel : IBus.PanelService {

Gdk.Display display_backup = null;
if (use_x11 && !BindingCommon.default_is_xdisplay()) {
var display = BindingCommon.get_xdisplay();
display_backup = Gdk.Display.get_default();
Gdk.DisplayManager.get().set_default_display(
(Gdk.Display)BindingCommon.get_xdisplay());
if (display != null) {
Gdk.DisplayManager.get().set_default_display(
(Gdk.Display)display);
}
}

// Show system menu
Expand Down Expand Up @@ -1476,9 +1479,12 @@ class Panel : IBus.PanelService {
private Gtk.Menu create_activate_menu(bool use_x11 = false) {
Gdk.Display display_backup = null;
if (use_x11 && !BindingCommon.default_is_xdisplay()) {
var display = BindingCommon.get_xdisplay();
display_backup = Gdk.Display.get_default();
Gdk.DisplayManager.get().set_default_display(
(Gdk.Display)BindingCommon.get_xdisplay());
if (display != null) {
Gdk.DisplayManager.get().set_default_display(
(Gdk.Display)display);
}
}
m_ime_menu = new Gtk.Menu();

Expand Down

0 comments on commit 0a7a4d1

Please sign in to comment.