Re: Problem with some widget on SGI




Chi-Deok Hwang <cdhwang@sr.hei.co.kr> writes:

> On Mon, 4 Jan 1999, Ronan BOURLIER wrote:
> 
> > Hi, I just installed glib/gtk 1.1.12.
> > 
> > I have a SGI O2 R5000, I compile with egcs 1.1b and the OS is IRIX 6.3.
> > Since version 1.1.5 I have the following problems
> > in testgtk :
> > 
> > - color selection : when I try to launch it :
> > Gdk-ERROR **: BadMatch (invalid parameter attributes)
> >   serial 24335 error_code 8 request_code 2 minor_code 0
> > aborting...
> > Abort (core dumped)
> 
> I had the same problem in solaris.
> try:
> 
> --- gtkpreview.c.orig	Tue Jan  5 08:09:32 1999
> +++ gtkpreview.c	Tue Jan  5 08:09:39 1999
> @@ -421,7 +421,7 @@
>  
>    widget->style = gtk_style_attach (widget->style, widget->window);
>    gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
> -  gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
> +  gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
>  }

There are two interelated problems here:

 - The preview sets a parent-relative background so
   that the borders when the widget is bigger than
   the buffer blend in with the parent widget.

   The easy fix for this is to just make the window
   without these borders to begin with. A patch
   to do this follows.

 - The preview widget sets its own colormap and visual
   based on what GdkRGB wants; so this may be different
   from the toplevel window. This causes several problems

    - Parent relative pixmaps can cause bad-matches on
      multi-visual displays.

    - Most PC hardware don't support multiple installed
      colormaps, so if the GdkRGB visual is private
      and the rest of GTK+ is using the system colormap,
      then something won't get displayed correctly.

   For the GtkColorSelectionDialog, there is a pretty
   easy fix - it can, in the _init() routine, do
   a gtk_widget_push_visual(gdk_rgb_get_visual()) 
   [ and the same for the colormap. ]

   This isn't a panacea, since people using GtkPreview 
   elsewhere need to do this themselves as well, for all 
   toplevel windows containing a GtkPreview.

I'll commit these changes as soon as as I test them
out a bit. It should fix the main part of the problem,
though there will still be some residual problems
with other widgets that set parent-relative backgrounds.

(You can even set parent-relative backgrounds from
 your RC file)

IMO, the GdkRGB and Imlib just need to be able to 
render in the visual and colormap they are given.

Regards,
                                        Owen

Index: gtkpreview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkpreview.c,v
retrieving revision 1.23
diff -u -r1.23 gtkpreview.c
--- gtkpreview.c	1998/11/30 19:06:31	1.23
+++ gtkpreview.c	1999/01/05 20:02:53
@@ -34,6 +34,8 @@
 static void   gtk_preview_init          (GtkPreview       *preview);
 static void   gtk_preview_finalize      (GtkObject        *object);
 static void   gtk_preview_realize       (GtkWidget        *widget);
+static void   gtk_preview_size_allocate (GtkWidget        *widget,
+					 GtkAllocation    *allocation);
 static gint   gtk_preview_expose        (GtkWidget        *widget,
 				         GdkEventExpose   *event);
 static void   gtk_preview_make_buffer   (GtkPreview       *preview);
@@ -84,6 +86,7 @@
   object_class->finalize = gtk_preview_finalize;
 
   widget_class->realize = gtk_preview_realize;
+  widget_class->size_allocate = gtk_preview_size_allocate;
   widget_class->expose_event = gtk_preview_expose;
 
   klass->info.visual = NULL;
@@ -406,10 +409,21 @@
   preview = GTK_PREVIEW (widget);
 
   attributes.window_type = GDK_WINDOW_CHILD;
-  attributes.x = widget->allocation.x;
-  attributes.y = widget->allocation.y;
-  attributes.width = widget->allocation.width;
-  attributes.height = widget->allocation.height;
+
+  if (preview->expand)
+    {
+      attributes.width = widget->allocation.width;
+      attributes.height = widget->allocation.height;
+    }
+  else
+    {
+      attributes.width = MIN (widget->requisition.width, widget->allocation.width);
+      attributes.height = MIN (widget->requisition.height, widget->allocation.height);
+    }
+
+  attributes.x = widget->allocation.x + (widget->allocation.width - attributes.width) / 2;
+  attributes.y = widget->allocation.y + (widget->allocation.height - attributes.height) / 2;;
+
   attributes.wclass = GDK_INPUT_OUTPUT;
   attributes.visual = preview_class->info.visual;
   attributes.colormap = preview_class->info.cmap;
@@ -421,14 +435,47 @@
 
   widget->style = gtk_style_attach (widget->style, widget->window);
   gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
-  gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
 }
 
+static void   
+gtk_preview_size_allocate (GtkWidget        *widget,
+			   GtkAllocation    *allocation)
+{
+  GtkPreview *preview;
+  gint width, height;
+
+  g_return_if_fail (widget != NULL);
+  g_return_if_fail (GTK_IS_PREVIEW (widget));
+
+  preview = GTK_PREVIEW (widget);
+  widget->allocation = *allocation;
+
+  if (GTK_WIDGET_REALIZED (widget))
+    {
+      if (preview->expand)
+	{
+	  width = widget->allocation.width;
+	  height = widget->allocation.height;
+	}
+      else
+	{
+	  width = MIN (widget->allocation.width, widget->requisition.width);
+	  height = MIN (widget->allocation.height, widget->requisition.height);
+	}
+
+      gdk_window_move_resize (widget->window,
+			      widget->allocation.x + (widget->allocation.width - width) / 2,
+			      widget->allocation.y + (widget->allocation.height - height) / 2,
+			      width, height);
+    }
+}
+
 static gint
 gtk_preview_expose (GtkWidget      *widget,
 		    GdkEventExpose *event)
 {
   GtkPreview *preview;
+  gint width, height;
 
   g_return_val_if_fail (widget != NULL, FALSE);
   g_return_val_if_fail (GTK_IS_PREVIEW (widget), FALSE);
@@ -438,12 +485,12 @@
     {
       preview = GTK_PREVIEW (widget);
       
+      gdk_window_get_size (widget->window, &width, &height);
+
       gtk_preview_put (GTK_PREVIEW (widget),
 		       widget->window, widget->style->black_gc,
-		       event->area.x -
-		       (widget->allocation.width - preview->buffer_width)/2,
-		       event->area.y -
-		       (widget->allocation.height - preview->buffer_height)/2,
+		       event->area.x - (width - preview->buffer_width)/2,
+		       event->area.y - (height - preview->buffer_height)/2,
 		       event->area.x, event->area.y,
 		       event->area.width, event->area.height);
     }



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