From af66ace771fc16a23e7a5841d2f0bd79789e009d Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Wed, 14 Sep 2016 13:34:44 +0900 Subject: [PATCH] Fix warning messages during panel resizes Move gtk_window_resize(). Seems calling gtk_window_resize() is not good during gtk_widget_get_preferred_width/height() is called. Review URL: https://codereview.appspot.com/308320043 --- ui/gtk3/candidatepanel.vala | 21 ++++++++++----------- ui/gtk3/propertypanel.vala | 21 +++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/ui/gtk3/candidatepanel.vala b/ui/gtk3/candidatepanel.vala index 06ed0c9d2..0e5e3bc2b 100644 --- a/ui/gtk3/candidatepanel.vala +++ b/ui/gtk3/candidatepanel.vala @@ -3,7 +3,7 @@ * ibus - The Input Bus * * Copyright(c) 2011-2015 Peng Huang - * Copyright(c) 2015 Takao Fujiwara + * Copyright(c) 2015-2016 Takao Fujiwara * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -212,6 +212,15 @@ public class CandidatePanel : Gtk.Box{ } private void update() { + /* Do not call gtk_window_resize() in + * GtkWidgetClass->get_preferred_width() + * because the following warning is shown in GTK 3.20: + * "Allocating size to GtkWindow %x without calling + * gtk_widget_get_preferred_width/height(). How does the code + * know the size to allocate?" + * in gtk_widget_size_allocate_with_baseline() */ + m_toplevel.resize(1, 1); + if (m_candidate_area.get_visible() || m_preedit_label.get_visible() || m_aux_label.get_visible()) @@ -226,16 +235,6 @@ public class CandidatePanel : Gtk.Box{ m_hseparator.hide(); } - public override void get_preferred_width(out int minimum_width, out int natural_width) { - base.get_preferred_width(out minimum_width, out natural_width); - m_toplevel.resize(1, 1); - } - - public override void get_preferred_height(out int minimum_width, out int natural_width) { - base.get_preferred_height(out minimum_width, out natural_width); - m_toplevel.resize(1, 1); - } - private void create_ui() { m_preedit_label = new Gtk.Label(null); m_preedit_label.set_size_request(20, -1); diff --git a/ui/gtk3/propertypanel.vala b/ui/gtk3/propertypanel.vala index ea960b81e..dd4342ec2 100644 --- a/ui/gtk3/propertypanel.vala +++ b/ui/gtk3/propertypanel.vala @@ -244,18 +244,6 @@ public class PropertyPanel : Gtk.Box { m_follow_input_cursor_when_always_shown = is_follow; } - public override void get_preferred_width(out int minimum_width, - out int natural_width) { - base.get_preferred_width(out minimum_width, out natural_width); - m_toplevel.resize(1, 1); - } - - public override void get_preferred_height(out int minimum_width, - out int natural_width) { - base.get_preferred_height(out minimum_width, out natural_width); - m_toplevel.resize(1, 1); - } - private void create_menu_items() { int i = 0; while (true) { @@ -399,6 +387,15 @@ public class PropertyPanel : Gtk.Box { } private void show_with_auto_hide_timer() { + /* Do not call gtk_window_resize() in + * GtkWidgetClass->get_preferred_width() + * because the following warning is shown in GTK 3.20: + * "Allocating size to GtkWindow %x without calling + * gtk_widget_get_preferred_width/height(). How does the code + * know the size to allocate?" + * in gtk_widget_size_allocate_with_baseline() */ + m_toplevel.resize(1, 1); + if (m_items.length == 0) { /* Do not blink the panel with focus-in in case the panel * is always shown. */