[5007] in testers

home help back first fref pref prev next nref lref last post

Re: Panel fish hack

daemon@ATHENA.MIT.EDU (Mike Whitson)
Mon Jul 16 17:55:38 2001

To: Bill Cattey <wdc@MIT.EDU>
Cc: testers@MIT.EDU
From: Mike Whitson <mwhitson@MIT.EDU>
Date: 16 Jul 2001 17:55:33 -0400
In-Reply-To: Bill Cattey's message of "Mon, 16 Jul 2001 21:17:50 +0000 ()"
Message-ID: <n91pub0sfmy.fsf@tiassa.mit.edu>

Sounds like you found the easter egg.  It's in gnome-core.  This is
the patch used to remove it from Ximian GNOME, which may or may not
apply cleanly to the Athena tree.

-mike

*** gnome-core-1.4.0.4.orig/panel/main.c	Wed Jun 27 13:56:40 2001
--- gnome-core-1.4.0.4/panel/main.c	Wed Jun 27 13:55:42 2001
***************
*** 94,282 ****
  	return TRUE;
  }
  
- /* Some important code copied from PonG */
- /* some evilness follows */
- typedef struct _Fish Fish;
- struct _Fish {
- 	int state;
- 	int x, y, xs, ys;
- 	GdkPixmap *fish[4];
- 	GdkBitmap *fish_mask[4];
- 	int handler;
- 	GdkWindow *win;
- };
- Fish fish = {0};
- 
- static void
- fish_kill (void)
- {
- 	int i;
- 	for (i = 0; i < 4; i++) {
- 		gdk_pixmap_unref (fish.fish[i]);
- 		gdk_bitmap_unref (fish.fish_mask[i]);
- 	}
- 	gdk_window_destroy (fish.win);
- 	gtk_timeout_remove (fish.handler);
- 	memset (&fish, 0, sizeof (Fish));
- }
- 
- /* I AAAAAM YOUUUUUUR FAAAAAAATTTTTHHHHHHHEEEEERRRRRR */
- static gboolean
- fish_move (gpointer data)
- {
- 	int orient, state;
- 	gboolean change = TRUE;
- 
- 	fish.x += fish.xs;
- 	fish.y += fish.ys;
- 	if (fish.x <= -60 ||
- 	    fish.x >= gdk_screen_width ()) {
- 		fish_kill ();
- 		return FALSE;
- 	}
- 	if (fish.y <= 0 ||
- 	    fish.y >= gdk_screen_height () - 40 ||
- 	    rand() % 50 == 0)
- 		fish.ys = -fish.ys;
- 
- 	fish.state ++;
- 	if (fish.state % 4 == 0)
- 		change = TRUE;
- 	if (fish.state >= 8)
- 		fish.state = 0;
- 
- 	state = fish.state >= 4 ? 1 : 0;
- 	orient = fish.xs >= 0 ? 0 : 2;
- 
- 	if (change) {
- 		gdk_window_set_back_pixmap (fish.win, fish.fish[orient + state], FALSE);
- 		gdk_window_shape_combine_mask (fish.win, fish.fish_mask[orient + state], 0, 0);
- 		gdk_window_clear (fish.win);
- 	}
- 
- 	gdk_window_move (fish.win, fish.x, fish.y);
- 	gdk_window_raise (fish.win);
- 
- 	return TRUE;
- }
- 
- static void
- fish_reverse (GdkPixbuf *gp)
- {
- 	guchar *pixels = gdk_pixbuf_get_pixels (gp);
- 	int x, y;
- 	int rs = gdk_pixbuf_get_rowstride (gp);
- #define DOSWAP(x,y) tmp = x; x = y; y = tmp;
- 	for (y = 0; y < 40; y++, pixels += rs) {
- 		guchar *p = pixels;
- 		guchar *p2 = pixels + 60*4 - 4;
- 		for (x = 0; x < 30; x++, p+=4, p2-=4) {
- 			guchar tmp;
- 			DOSWAP (p[0], p2[0]);
- 			DOSWAP (p[1], p2[1]);
- 			DOSWAP (p[2], p2[2]);
- 			DOSWAP (p[3], p2[3]);
- 		}
- 	}
- #undef DOSWAP
- }
- 
- static void
- fish_unwater(GdkPixbuf *gp)
- {
- 	guchar *pixels = gdk_pixbuf_get_pixels (gp);
- 	int x, y;
- 	int rs = gdk_pixbuf_get_rowstride (gp);
- 	for (y = 0; y < 40; y++, pixels += rs) {
- 		guchar *p = pixels;
- 		for (x = 0; x < 60; x++, p+=4) {
- 			if (p[0] < 55 && p[1] > 100)
- 			       p[3] = 0;	
- 		}
- 	}
- }
- 
- /* the incredibly evil function */
- static void
- check_screen (void)
- {
- 	GdkWindowAttr attributes;
- 	char *fish_file;
- 	GdkPixbuf *gp, *tmp;
- 
- 	if (fish.win != NULL)
- 		return;
- 
- 	fish_file = gnome_pixmap_file ("fish/fishanim.png");
- 	if (fish_file == NULL)
- 		return;
- 
- 	tmp = gdk_pixbuf_new_from_file (fish_file);
- 	if (tmp == NULL)
- 		return;
- 
- 	g_free (fish_file);
- 
- 	if (gdk_pixbuf_get_width (tmp) != 180 ||
- 	    gdk_pixbuf_get_height (tmp) != 40) {
- 		gdk_pixbuf_unref (tmp);
- 		return;
- 	}
- 
- 	fish.state = 0;
- 
- 	gp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 60, 40);
- 	gdk_pixbuf_copy_area (tmp, 60, 0, 60, 40, gp, 0, 0);
- 
- 	fish_unwater (gp);
- 	gdk_pixbuf_render_pixmap_and_mask (gp, &fish.fish[2], &fish.fish_mask[2], 128);
- 	fish_reverse (gp);
- 	gdk_pixbuf_render_pixmap_and_mask (gp, &fish.fish[0], &fish.fish_mask[0], 128);
- 
- 	gdk_pixbuf_copy_area (tmp, 120, 0, 60, 40, gp, 0, 0);
- 
- 	fish_unwater (gp);
- 	gdk_pixbuf_render_pixmap_and_mask (gp, &fish.fish[3], &fish.fish_mask[3], 128);
- 	fish_reverse (gp);
- 	gdk_pixbuf_render_pixmap_and_mask (gp, &fish.fish[1], &fish.fish_mask[1], 128);
- 	gdk_pixbuf_unref (gp);
- 
- 	gdk_pixbuf_unref (tmp);
- 	
- 	fish.x = -60;
- 	fish.y = (rand() % (gdk_screen_height () - 40 - 2)) + 1;
- 	fish.xs = 8;
- 	fish.ys = (rand() % 2) + 1;
- 
- 	attributes.window_type = GDK_WINDOW_TEMP;
- 	attributes.x = fish.x;
- 	attributes.y = fish.y;
- 	attributes.width = 60;
- 	attributes.height = 40;
- 	attributes.wclass = GDK_INPUT_OUTPUT;
- 	attributes.visual = gdk_rgb_get_visual();
- 	attributes.colormap = gdk_rgb_get_cmap();
- 	attributes.event_mask = 0;
- 
- 	fish.win = gdk_window_new (NULL, &attributes,
- 				   GDK_WA_X | GDK_WA_Y |
- 				   GDK_WA_VISUAL | GDK_WA_COLORMAP);
- 	gdk_window_set_back_pixmap (fish.win, fish.fish[0], FALSE);
- 	gdk_window_shape_combine_mask (fish.win, fish.fish_mask[0], 0, 0);
- 
- 	gdk_window_show (fish.win);
- 	fish.handler = gtk_timeout_add (150, fish_move, NULL);
- }
- 
- static gboolean
- check_screen_timeout (gpointer data)
- {
- 	if (((rand () >> 3) % 4000) == 666) {
- 		check_screen ();
- 	}
- 	return TRUE;
- }
- 
  static int
  try_config_sync(gpointer data)
  {
--- 94,99 ----
***************
*** 500,507 ****
  
  	/* add some timeouts */
  	gtk_timeout_add (10*1000, menu_age_timeout, NULL);
! 	gtk_timeout_add (10*60*1000, check_screen_timeout, NULL);
! 	
  	/*load these as the last thing to prevent some races any races from
  	  starting multiple goad_id's at once are libgnorba's problem*/
  	load_queued_externs ();
--- 317,323 ----
  
  	/* add some timeouts */
  	gtk_timeout_add (10*1000, menu_age_timeout, NULL);
!        
  	/*load these as the last thing to prevent some races any races from
  	  starting multiple goad_id's at once are libgnorba's problem*/
  	load_queued_externs ();

home help back first fref pref prev next nref lref last post