[Galago-commits] r2949 - in trunk/notification-daemon: . src/themes/standard

galago-commits at freedesktop.org galago-commits at freedesktop.org
Thu Nov 9 18:04:31 PST 2006


Author: chipx86
Date: 2006-11-09 18:04:27 -0800 (Thu, 09 Nov 2006)
New Revision: 2949

Modified:
   trunk/notification-daemon/ChangeLog
   trunk/notification-daemon/src/themes/standard/theme.c
Log:
Update the top and bottom spacers outside of the window painting code, as that ended up unsurprisingly causing graphical glitches. We now update it when moving/resizing the window or setting the arrow info.


Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog	2006-11-10 01:45:26 UTC (rev 2948)
+++ trunk/notification-daemon/ChangeLog	2006-11-10 02:04:27 UTC (rev 2949)
@@ -1,3 +1,10 @@
+Thu Nov 09 18:03:31 PST 2006  Christian Hammond <chipx86 at chipx86.com>
+
+	* src/themes/standard/theme.c:
+	  - Update the top and bottom spacers outside of the window painting code,
+	    as that ended up unsurprisingly causing graphical glitches. We now
+	    update it when moving/resizing the window or setting the arrow info.
+
 Thu Nov 09 17:45:01 PST 2006  Christian Hammond <chipx86 at chipx86.com>
 
 	* src/themes/standard/theme.c:

Modified: trunk/notification-daemon/src/themes/standard/theme.c
===================================================================
--- trunk/notification-daemon/src/themes/standard/theme.c	2006-11-10 01:45:26 UTC (rev 2948)
+++ trunk/notification-daemon/src/themes/standard/theme.c	2006-11-10 02:04:27 UTC (rev 2949)
@@ -117,6 +117,26 @@
 		g_object_unref(G_OBJECT(gc));
 }
 
+static GtkArrowType
+get_notification_arrow_type(GtkWidget *nw)
+{
+	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+	int screen_height;
+
+	screen_height = gdk_screen_get_height(
+		gdk_drawable_get_screen(GDK_DRAWABLE(nw->window)));
+
+	if (windata->point_y + windata->height + DEFAULT_ARROW_HEIGHT >
+		screen_height)
+	{
+		return GTK_ARROW_DOWN;
+	}
+	else
+	{
+		return GTK_ARROW_UP;
+	}
+}
+
 #define ADD_POINT(_x, _y, shapeoffset_x, shapeoffset_y) \
 	G_STMT_START { \
 		windata->border_points[i].x = (_x); \
@@ -151,10 +171,7 @@
 
 	windata->num_border_points = 5;
 
-	if (windata->point_y + height + DEFAULT_ARROW_HEIGHT > screen_height)
-		arrow_type = GTK_ARROW_DOWN;
-	else
-		arrow_type = GTK_ARROW_UP;
+	arrow_type = get_notification_arrow_type(nw);
 
 	/* Handle the offset and such */
 	switch (arrow_type)
@@ -218,8 +235,6 @@
 
 			if (arrow_type == GTK_ARROW_UP)
 			{
-				gtk_widget_show(windata->top_spacer);
-				gtk_widget_hide(windata->bottom_spacer);
 				windata->drawn_arrow_begin_y = DEFAULT_ARROW_HEIGHT;
 				windata->drawn_arrow_middle_y = 0;
 				windata->drawn_arrow_end_y = DEFAULT_ARROW_HEIGHT;
@@ -256,8 +271,6 @@
 			}
 			else
 			{
-				gtk_widget_hide(windata->top_spacer);
-				gtk_widget_show(windata->bottom_spacer);
 				windata->drawn_arrow_begin_y = height - DEFAULT_ARROW_HEIGHT;
 				windata->drawn_arrow_middle_y = height;
 				windata->drawn_arrow_end_y = height - DEFAULT_ARROW_HEIGHT;
@@ -386,6 +399,36 @@
 }
 
 static void
+update_spacers(GtkWidget *nw)
+{
+	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+
+	if (windata->has_arrow)
+	{
+		switch (get_notification_arrow_type(GTK_WIDGET(nw)))
+		{
+			case GTK_ARROW_UP:
+				gtk_widget_show(windata->top_spacer);
+				gtk_widget_hide(windata->bottom_spacer);
+				break;
+
+			case GTK_ARROW_DOWN:
+				gtk_widget_hide(windata->top_spacer);
+				gtk_widget_show(windata->bottom_spacer);
+				break;
+
+			default:
+				g_assert_not_reached();
+		}
+	}
+	else
+	{
+		gtk_widget_hide(windata->top_spacer);
+		gtk_widget_hide(windata->bottom_spacer);
+	}
+}
+
+static void
 update_content_hbox_visibility(WindowData *windata)
 {
 	/*
@@ -412,6 +455,8 @@
 	windata->width = event->width;
 	windata->height = event->height;
 
+	update_spacers(nw);
+
 	return FALSE;
 }
 
@@ -648,7 +693,7 @@
 }
 
 void
-set_notification_arrow(GtkWindow *nw, gboolean visible, int x, int y)
+set_notification_arrow(GtkWidget *nw, gboolean visible, int x, int y)
 {
 	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
 	g_assert(windata != NULL);
@@ -657,11 +702,7 @@
 	windata->point_x = x;
 	windata->point_y = y;
 
-	if (!visible)
-	{
-		gtk_widget_hide(windata->top_spacer);
-		gtk_widget_hide(windata->bottom_spacer);
-	}
+	update_spacers(nw);
 }
 
 static gboolean
@@ -796,18 +837,18 @@
 }
 
 void
-move_notification(GtkWindow *nw, int x, int y)
+move_notification(GtkWidget *nw, int x, int y)
 {
 	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
 	g_assert(windata != NULL);
 
 	if (windata->has_arrow)
 	{
-		gtk_widget_queue_resize(GTK_WIDGET(nw));
+		gtk_widget_queue_resize(nw);
 	}
 	else
 	{
-		gtk_window_move(nw, x, y);
+		gtk_window_move(GTK_WINDOW(nw), x, y);
 	}
 }
 



More information about the galago-commits mailing list