diff console/libgnt/gntwidget.c @ 14919:056c8a27668c

[gaim-migrate @ 17691] Change some minor stuff. This should get rid of the blinking in the buddylist (and the tooltip) when a new account signs on. This just might get rid of some crashes too. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 07 Nov 2006 02:59:24 +0000
parents 065e7ac30338
children 94c69d2efae5
line wrap: on
line diff
--- a/console/libgnt/gntwidget.c	Tue Nov 07 02:53:42 2006 +0000
+++ b/console/libgnt/gntwidget.c	Tue Nov 07 02:59:24 2006 +0000
@@ -303,11 +303,8 @@
 void
 gnt_widget_show(GntWidget *widget)
 {
-	/* Draw the widget and take focus */
-	/*if (GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_CAN_TAKE_FOCUS) {*/
-		/*gnt_widget_take_focus(widget);*/
-	/*}*/
 	gnt_widget_draw(widget);
+	gnt_screen_occupy(widget);
 }
 
 void
@@ -324,39 +321,38 @@
 
 	if (widget->window == NULL)
 	{
+		int x, y, maxx, maxy, w, h;
 		gboolean shadow = TRUE;
 
 		if (!gnt_widget_has_shadow(widget))
 			shadow = FALSE;
 
+		x = widget->priv.x;
+		y = widget->priv.y;
+		w = widget->priv.width + shadow;
+		h = widget->priv.height + shadow;
+
+		getmaxyx(stdscr, maxy, maxx);
+		maxy -= 1;		/* room for the taskbar */
+
+		x = MAX(0, x);
+		y = MAX(0, y);
+		if (x + w >= maxx)
+			x = MAX(0, maxx - w);
+		if (y + h >= maxy)
+			y = MAX(0, maxy - h);
+
+		w = MIN(w, maxx);
+		h = MIN(h, maxy);
+
+		widget->priv.x = x;
+		widget->priv.y = y;
+		widget->priv.width = w - shadow;
+		widget->priv.height = h - shadow;
+
 		widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow,
 						widget->priv.y, widget->priv.x);
-		if (widget->window == NULL)     /* The size is probably too large for the screen */
-		{
-			int x = widget->priv.x, y = widget->priv.y;
-			int w = widget->priv.width + shadow, h = widget->priv.height + shadow;
-			int maxx, maxy;            /* Max-X is cool */
-
-			getmaxyx(stdscr, maxy, maxx);
-
-			if (x + w >= maxx)
-				x = MAX(0, maxx - w);
-			if (y + h >= maxy)
-				y = MAX(0, maxy - h);
-
-			w = MIN(w, maxx);
-			h = MIN(h, maxy);
-
-			widget->priv.x = x;
-			widget->priv.y = y;
-			widget->priv.width = w - shadow;
-			widget->priv.height = h - shadow;
-
-			widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow,
-							widget->priv.y, widget->priv.x);
-		}
 		init_widget(widget);
-		gnt_screen_occupy(widget);
 	}
 
 	g_signal_emit(widget, signals[SIG_DRAW], 0);