Re: non-attached style detached in gtkinvisible.



On 5 Jan 2001, Owen Taylor wrote:

> > @@ -1025,11 +1061,17 @@ gtk_window_show (GtkWidget *widget)
> >        allocation.width  = width;
> >        allocation.height = height;
> >        gtk_widget_size_allocate (widget, &allocation);
> > -
> > -      if (GTK_WIDGET_REALIZED (widget))
> > -	gdk_window_resize (widget->window, width, height);
> > -      else
> > +
> > +      if (!GTK_WIDGET_REALIZED (widget))
> >  	gtk_widget_realize (widget);
> > +
> > +      gtk_decorated_window_calculate_frame_size (window);
>
> Hmmm, this isn't very nice, both from the perspective of keeping dependencies
> between gtkwindow.c and gtkdecoratedwindow.c low and from the perspective
> of keeping things working right.
>
> It doesn't look like things work when you change the decorations after showing
> the window.
>
> Maybe you should add a callback when the decorations (and title?) change
> to your _gdk_window_set_child_handler () function?

I ignored this for the moment. Does changing decoration hints while the
window is shown even work in X?

> Also, it's probably good to be a little dirty here and rewrite the
> event so that event->window == widget->window for key/focus events not
> redirected:
>
>  g_object_unref (event->window);
>  event->window = widget->window;
>
> Otherwise, you risk confusing some apps.

I used event->window = g_object_ref (widget->window)

> > +void
> > +gtk_window_set_frame_dimensions (GtkWindow *window,
> > +				 gint       left,
> > +				 gint       top,
> > +				 gint       right,
> > +				 gint       bottom)
> > +{
> > +  GtkAllocation *allocation;
> > +  GtkWidget *widget;
> > +
> > +  g_return_if_fail (window != NULL);
> > +  g_return_if_fail (GTK_IS_WINDOW (window));
> > +
> > +  window->frame_left = left;
> > +  window->frame_top = top;
> > +  window->frame_right = right;
> > +  window->frame_bottom = bottom;
> >  }
>
> This one, at least, should work after the widget is realized.
Ok, this now works, although it is a bit hackish to work both with
normal and decorated windows (where resizing widget->window gets proxied
to a window->frame resize).

> > #ifdef GDK_WINDOWING_FB
> > #define DECORATE_WINDOWS
> > #endif
> >
> > #ifdef DECORATE_WINDOWS
> >
> > #ifdef GDK_WINDOWING_FB
> > #include "linux-fb/gdkfb.h"
> > #endif
>
> Hmmm, you conditionalize here, but then use functions from this file unconditionally
> below?

The original idea was that other ports that might want to use decorated
window. Then they would implement their own _gdk_window_set_child_handler,
but i renamed it to gdk_fb_window_set_child_handler() instead and ignored
this idea.


> > void
> > gtk_decorated_window_calculate_frame_size (GtkWindow *window)
> > {
> >   GdkWMDecoration decorations;
> >   GtkWindowDecoration *deco = get_decoration (window);
> >
> >   if (_gdk_window_get_decorations (GTK_WIDGET (window)->window,
> > 				   &decorations))
>
> Underscored prefixed functions won't even be exported from GDK - they are
> library-private. Perhaps we should just make this XP and public - having
> getters to go along with setters is pretty customary.
Ok. I will check in X and linux-fb versions of it.


> > /* Copied from gtkwindow.c */
> > typedef struct {
> >   GdkGeometry    geometry; /* Last set of geometry hints we set */
> >   GdkWindowHints flags;
> >   gint           width;
> >   gint           height;
> > } GtkWindowLastGeometryInfo;
> >
> > typedef struct {
> >   /* Properties that the app has set on the window
> >    */
> >   GdkGeometry    geometry;	/* Geometry hints */
> >   GdkWindowHints mask;
> >   GtkWidget     *widget;	/* subwidget to which hints apply */
> >   gint           width;		/* Default size */
> >   gint           height;
> >
> >   GtkWindowLastGeometryInfo last;
> > } GtkWindowGeometryInfo;
>
> >       if ((w > 0) && (h > 0))
> > 	{
> > 	  GtkWindowGeometryInfo *info = (GtkWindowGeometryInfo *)gtk_object_get_data (GTK_OBJECT (window), "gtk-window-geometry");
>
> Urgh. As you can imagine, I don't like this. We should cleanly export
> what is needed from gtkwindow.c which seems to be
> gtk_window_constrain_size, which handles gridding, aspect ratio, etc,
> as well as min/max size.

I exported this from GtkWindow

void
_gtk_window_constrain_size (GtkWindow   *window,
			    gint         width,
			    gint         height,
			    gint        *new_width,
			    gint        *new_height)
{
  GtkWindowGeometryInfo *info = (GtkWindowGeometryInfo *)gtk_object_get_data (GTK_OBJECT (window), "gtk-window-geometry");

  if (info)
    {
      GdkWindowHints flags = info->last.flags;
      GdkGeometry *geometry = &info->last.geometry;

      gtk_window_constrain_size (window,
				 geometry,
				 flags,
				 width,
				 height,
				 new_width,
				 new_height);
    }
}



I Will check in everything when I've added some docs.

/ Alex






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