Re: [g-a-devel]gnome-mag patch ..



OK:

Mystery solved I believe;  it seems that I missed a CVS commit somewhere
along the line, and my source tree differs from gnome-mag HEAD.

Gnome-mag HEAD contains some pretty nasty cut-and-paste which is partly
a workaround for the gtk+-2.0 gdkpixbuf's limited support for
multihead.  What I have on my machine is much, much cleaner but it
requires GTK+-2.1 (i.e. HEAD).

My recommendation would be to increment the gnome-mag dependencies to
require the multihead gdkpixbuf code (I believe it requires only
"gdk_display_get_screen()"); this will allow removal of lots of buggy
and unsupported cut-and-paste code.

I attach my current CVS "diff -u" for gnome-mag.  It can be used as a
patch which I hope may solve Adi's problem (if she is using tk+ from
HEAD and not the gtk+-2.0 branch), but it doesn't include the revisions
to configure.in to explicitly require gtk+-2.1.

I can prepare such a patch on Monday, or if you want to do this first
Michael (i.e. include the proper dependency in configure.in, and other
cruft removal), then feel free.  You will see, if you look at this diff,
that it's only about halfway done from a point of migrating fully from
gtk+2 to gtk+2.1, so we should remove "old_get_root_subimage", etc.
altogether.

Regards,

-Bill


? gnome-mag.diff
? magnifier/Magnifier-stubs.c
? magnifier/Magnifier-skels.c
? magnifier/Magnifier-common.c
? magnifier/Magnifier.h
? magnifier/Magnifier.server
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-mag/ChangeLog,v
retrieving revision 1.9
diff -u -r1.9 ChangeLog
--- ChangeLog	15 Aug 2002 16:46:31 -0000	1.9
+++ ChangeLog	16 Aug 2002 19:10:01 -0000
@@ -1,3 +1,11 @@
+<<<<<<< ChangeLog
+2002-07-16 Bill Haneman <bill haneman sun com>
+
+	* magnifier/mag_image.c:
+	rgbconvert():
+        Removed unused method; we now use gdkpixbuf to do this.
+
+=======
 2002-08-15  Michael Meeks  <michael ximian com>
 
 	* magnifier/Makefile.am: install generated header.
@@ -30,6 +38,7 @@
 
 	* magnifier/Makefile.am: add POPT_LIBS to LDADD.
 
+>>>>>>> 1.9
 2002-06-30 Bill Haneman <bill haneman sun com>
 
 	* magnifier/magnifier.c:
Index: magnifier/mag_image.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/mag_image.c,v
retrieving revision 1.5
diff -u -r1.5 mag_image.c
--- magnifier/mag_image.c	30 Jun 2002 21:36:36 -0000	1.5
+++ magnifier/mag_image.c	16 Aug 2002 19:10:03 -0000
@@ -22,7 +22,8 @@
 
 #include "mag_image.h"
 
-#define GDK_PIXBUF_ROOT_SUPPORT_IS_BROKEN /* undef when bug 86931 is fixed */
+#undef GDK_PIXBUF_ROOT_SUPPORT_IS_BROKEN /* undef when bug 86931 is fixed */
+#undef GTK_2_0_BRANCH
 
 static int get_num(char* msg);
 static void get_coord(char* msg,point *p);
@@ -1507,80 +1508,10 @@
 };
 
 static void
-rgbconvert (XImage *image, guchar *pixels, int rowstride, int alpha, xlib_colormap *cmap,
-	    MagnifierData *mag_data)
-{
-  int index = (image->byte_order == MSBFirst) | (alpha != 0) << 1;
-  int bank=5;		/* default fallback converter */
-  Visual *v = cmap->visual;
-  if (mag_data->fast_rgb_convert)
-    {	  
-	switch (v->class) {
-				/* I assume this is right for static & greyscale's too? */
-	case StaticGray:
-	case GrayScale:
-	case StaticColor:
-	case PseudoColor:
-		switch (image->bits_per_pixel) {
-		case 1:
-			bank = 0;
-			break;
-		case 8:
-			bank = 1;
-			break;
-		}
-		break;
-	case TrueColor:
-		switch (image->depth) {
-		case 15:
-			if (v->red_mask == 0x7c00 && v->green_mask == 0x3e0 && v->blue_mask == 0x1f
-			    && image->bits_per_pixel == 16)
-				bank = 2;
-			break;
-		case 16:
-			if (v->red_mask == 0xf800 && v->green_mask == 0x7e0 && v->blue_mask == 0x1f
-			    && image->bits_per_pixel == 16)
-				bank = 3;
-			break;
-		case 24:
-		case 32:
-			if (v->red_mask == 0xff0000 && v->green_mask == 0xff00 && v->blue_mask == 0xff
-			    && image->bits_per_pixel == 32)
-				bank = 4;
-			break;
-		}
-		break;
-	case DirectColor:
-		/* always use the slow version */
-		break;
-	}
-    }
-
-	if (bank==5) {
-		convert_real_slow(image, pixels, rowstride, cmap, alpha);
-	} else {
-		index |= bank << 2;
-#ifdef DEBUG_VERBOSE
-		fprintf (stderr, "using fast conversion func %d\n", index);
-#endif
-		(* convert_map[index]) (image, pixels, rowstride, cmap);
-	}
-}
-
-XImage *
-get_root_image (Window src, GdkPixbuf *dest, int x, int y, int width, int height,
-		MagnifierData *mag_data)
-{
-	return XGetSubImage (mag_data->source_display, src, x, y,
-			     width, height, AllPlanes, ZPixmap,
-			     ximage, x, y);
-}
-
-static void
 get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
 		       int width, int height, MagnifierData *mag_data)
 {
-#ifdef GDK_PIXBUF_ROOT_SUPPORT_IS_BROKEN
+#ifdef GTK_2_0_BRANCH
   old_get_root_subimage (src, dest, src_x, src_y, width, height, mag_data);
 #else
   new_get_root_subimage (src, dest, src_x, src_y, width, height, mag_data);
@@ -1588,12 +1519,12 @@
 }
 
 static void
-new_get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
+old_get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
 		       int width, int height, MagnifierData *mag_data)
 {
 	GdkColormap *cmap = gdk_rgb_get_colormap ();
 	gdk_pixbuf_xlib_get_from_drawable (dest,
-					   gdk_x11_get_default_root_xwindow (),
+					   src,
 					   GDK_COLORMAP_XCOLORMAP (cmap),
 					   GDK_VISUAL_XVISUAL (gdk_visual_get_system ()),
 					   src_x, src_y,
@@ -1602,51 +1533,17 @@
 }
 
 static void
-old_get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
+new_get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
 		   int width, int height, MagnifierData *mag_data)
 {
-	if (ximage == NULL) {
-#ifdef DEBUG_VERBOSE  
-		fprintf (stderr, "creating root ximage\n");
-#endif
-		ximage = XGetImage (mag_data->source_display, src, 0, 0,
-				    DisplayWidth (mag_data->source_display,
-						  mag_data->source_screen_num),
-				    DisplayHeight (mag_data->source_display,
-						   mag_data->source_screen_num),
-				    AllPlanes, ZPixmap);
-
-        /* Get image in ZPixmap format (packed bits). */
-	} else {
-#ifdef DEBUG_VERBOSE  
-		fprintf (stderr, "Getting X subimage\n");
-#endif
-		ximage = get_root_image (src, dest, src_x, src_y, width, height, mag_data);
-	}
-	
-	g_assert(image != NULL);
+	GdkColormap *cmap = gdk_rgb_get_colormap ();
 
-	if(x_cmap == NULL) {
-	    XWindowAttributes wa;
-	    XVisualInfo vi;
-	    int xgwaret;
-	    xgwaret = XGetWindowAttributes (mag_data->source_display,
-					    src, &wa);
-	    g_assert (xgwaret);
-	    /* XGetVisualInfo (mag_data->source_display, src, &vi); */
-#ifdef DEBUG_VERBOSE  
-	    fprintf (stderr,  "colormap %d, visual cmap entries %d\n",
-		     wa.colormap, wa.visual->map_entries);
-#endif	    
-	    x_cmap = xlib_get_colormap (wa.colormap, wa.visual, mag_data);	   } 
-
-	/* we offset into the image data based on the position
-	   we are retrieving from */
-	rgbconvert (ximage, gdk_pixbuf_get_pixels(dest),
-		    gdk_pixbuf_get_rowstride(dest),
-		    gdk_pixbuf_get_has_alpha(dest),
-		    x_cmap,
-		    mag_data);
+	gdk_pixbuf_get_from_drawable (dest,
+				      spi_source_root_window,
+				      cmap,
+				      src_x, src_y,
+				      src_x, src_y,
+				      width, height);
 }
 
 
Index: magnifier/mag_image.h
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/mag_image.h,v
retrieving revision 1.4
diff -u -r1.4 mag_image.h
--- magnifier/mag_image.h	30 Jun 2002 21:36:37 -0000	1.4
+++ magnifier/mag_image.h	16 Aug 2002 19:10:03 -0000
@@ -65,7 +65,8 @@
 point	    curpos; /* Position of the magnified cursor */
 GdkPixbuf*  image;
 GdkPixbuf*  scaled_image;
-Window	    spi_image_root_window;
+GdkWindow*  spi_source_root_window;
+Window      spi_image_root_window;
 int	    screen_num;
 int         old_factor_x;
 int         old_factor_y;
Index: magnifier/magnifier.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier.c,v
retrieving revision 1.8
diff -u -r1.8 magnifier.c
--- magnifier/magnifier.c	15 Aug 2002 16:18:27 -0000	1.8
+++ magnifier/magnifier.c	16 Aug 2002 19:10:04 -0000
@@ -297,6 +297,11 @@
 
   spi_image_root_window = RootWindow(magnifier->mag_data->source_display,
 				     magnifier->mag_data->source_screen_num);
+  
+  spi_source_root_window = gdk_screen_get_root_window (
+	  gdk_display_get_screen (gdk_display_open (global_options.source_display),
+				  magnifier->mag_data->source_screen_num));
+  
   gdk_pixbuf_xlib_init (magnifier->mag_data->target_display,
 			magnifier->mag_data->target_screen_num);
   image = gdk_pixbuf_new        (GDK_COLORSPACE_RGB,FALSE, 8,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]