Re: use_uposition in gtkwindow.c



On 1 Jul 1999, Owen Taylor wrote:

> 
> I've been trying to fix up the geometry-hint-setting
> code in gtkwindow.c. (There were a number of cases
> where geometry hints would not be set correctly
> if they changed after a window was first realized.)
> 
> In doing, I've discovered some real oddities with
> window->use_uposition.
> 
> There was a change last summer:
> 
> Wed Jun 24 16:38:02 1998  Tim Janik  <timj@gtk.org>
> [...]
> 	* gtk/gtkwindow.c (gtk_window_move_resize): save ->use_uposition around
> 	gtk_window_set_hints(), since we haven't calculated the new position
> 	yet.
> 
> However, gtk_window_set_hints is the only place where
> use_uposition is ever set to FALSE. So, the effect of
> this is that it used to be that setting a window
> to, say, GTK_WIN_POS_CENTER would only have an
> effect once each time the window was mapped, and if
> the size subsequently changed, there would be no
> effect.

yep, i think i tried to get GTK_WIN_POS_CENTER together with auto_shrink=TRUE
correctly going there. iirc, especially the GleSelector (a temporary dialog
in the middle of the screen) looked very ugly upon resizes when it wasn't
recentered.

> However, now, the position changes every time the
> size changes. Actually, the ChangeLog comment
> doesn't make sense, since we don't even pay
> attention to the value of ->use_uposition in
> the following code.

of course we do:

>   if (size_changed)
>     {
>       gboolean saved_use_upos;
> 
>       saved_use_upos = window->use_uposition;
save it
>       gtk_window_set_hints (widget, &widget->requisition);
>       window->use_uposition = saved_use_upos;
resore it
>     }
> 
>   x = -1;
>   y = -1;
> 
>   if (window->use_uposition)
evaluate it
>     switch (window->position)
>       {
>       case GTK_WIN_POS_CENTER:
>         x = (gdk_screen_width () - new_width) / 2;
>         y = (gdk_screen_height () - new_height) / 2;
>         gtk_widget_set_uposition (widget, x, y);
>         break;

and in gtk_window_set_hints() we do:
>      if (window->use_uposition && (flags & GDK_HINT_POS))
>        {
>          window->use_uposition = FALSE;
>          gdk_window_move (widget->window, ux, uy);
>        }
(ux and uy are the GtkWidgetAuxInfo coordinates from gtk_widget_set_uposition)

so with the old code, the gdk_window_move () call would move the window
to outdated coordinates, because the case GTK_WIN_POS_CENTER: calculation
comes *after* the call to gtk_window_set_hints(), and didn't even happen
with the old code.

> 
> I'm not sure which behavior is better, but if want
> to keep the current behavior, the code should be
> cleaned up to get rid of the ->use_uposition flag.
> 
> Opinions?

i think for *some* cases, i.e. GTK_WIN_POS_CENTER + user_didnt_resize_or_move +
auto_shrink we should keep the current behaviour (reposition upon changes in
width and/or height). it obviously does *not* make much sense with
GTK_WIN_POS_MOUSE ;)

>                                   Owen
> 

---
ciaoTJ



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