[Xfce4-commits] <xfce4-weather-plugin:master> Fix ugly GDK_WINDOW assertion when opening the summary window.
Harald Judt
noreply at xfce.org
Sun Aug 19 12:42:01 CEST 2012
Updating branch refs/heads/master
to 11464992ccf1eefe3ee46d274a44b9f167de517a (commit)
from 89d51d06a5cadf1e2cf370b38718c0ea085c15cf (commit)
commit 11464992ccf1eefe3ee46d274a44b9f167de517a
Author: Harald Judt <h.judt at gmx.at>
Date: Sun Aug 19 12:26:40 2012 +0200
Fix ugly GDK_WINDOW assertion when opening the summary window.
By the time we try to get the monitor geometry for determining the maximum
height, the summary window has not been realized yet. While the code
seemingly works nonetheless, this produces an ugly assertion
"Gdk-CRITICAL **: IA__gdk_window_get_origin: assertion `GDK_IS_WINDOW (window)'
failed" every time one opens the summary window.
As the window will open on the same monitor as the panel widget, we can keep
things simple and use the panel plugin icon to get the current monitor
geometry, which got it's window realized already and is always visible.
panel-plugin/weather-summary.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index 53a179f..6d484be 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -670,21 +670,25 @@ make_forecast(xfceweather_data *data)
static GtkWidget *
-create_forecast_tab(xfceweather_data *data,
- GtkWidget *window)
+create_forecast_tab(xfceweather_data *data)
{
GtkWidget *ebox, *align, *hbox, *scrolled, *table;
- GdkWindow *win;
+ GdkWindow *window;
GdkScreen *screen;
GdkRectangle rect;
- gint monitor_num, height_needed, height_max;
+ gint monitor_num = 0, height_needed, height_max;
gdouble factor;
- /* calculate maximum height we may use, subtracting some sane value for safety */
- screen = gtk_window_get_screen(GTK_WINDOW(window));
- win = GTK_WIDGET(window)->window;
- monitor_num = gdk_screen_get_monitor_at_window(GDK_SCREEN(screen), GDK_WINDOW(win));
- gdk_screen_get_monitor_geometry(GDK_SCREEN(screen), monitor_num, &rect);
+ /* To avoid causing a GDK assertion, determine the monitor
+ * geometry using the weather icon window, which has already been
+ * realized in contrast to the summary window. Then calculate the
+ * maximum height we may use, subtracting some sane value just to
+ * be on the safe side. */
+ window = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(data->iconimage)));
+ screen = GDK_SCREEN(gdk_window_get_screen(window));
+ if (G_LIKELY(window && screen))
+ monitor_num = gdk_screen_get_monitor_at_window(screen, window);
+ gdk_screen_get_monitor_geometry(screen, monitor_num, &rect);
/* optimize max height a bit depending on common resolutions */
if ((rect.height > 600 && rect.height <= 800) || rect.height <= 480)
@@ -795,7 +799,7 @@ create_summary_window (xfceweather_data *data)
notebook = gtk_notebook_new();
gtk_container_set_border_width(GTK_CONTAINER(notebook), BORDER);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- create_forecast_tab(data, window),
+ create_forecast_tab(data),
gtk_label_new_with_mnemonic(_("_Forecast")));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
create_summary_tab(data),
More information about the Xfce4-commits
mailing list