Skip to content

Commit

Permalink
Fix warning messages during panel resizes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fujiwarat committed Sep 14, 2016
1 parent 708e5e5 commit af66ace
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
21 changes: 10 additions & 11 deletions ui/gtk3/candidatepanel.vala
Expand Up @@ -3,7 +3,7 @@
* ibus - The Input Bus
*
* Copyright(c) 2011-2015 Peng Huang <shawn.p.huang@gmail.com>
* Copyright(c) 2015 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright(c) 2015-2016 Takao Fujiwara <takao.fujiwara1@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -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())
Expand All @@ -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);
Expand Down
21 changes: 9 additions & 12 deletions ui/gtk3/propertypanel.vala
Expand Up @@ -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) {
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit af66ace

Please sign in to comment.