gtk_window_move() when unrealized



hi,

the sequence
w = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_show (w);
gtk_window_move (w, a, b);
/* main loop */
gtk_window_hide (w);
/* main loop */
gtk_window_move (w, x, y);
gtk_window_show (w);

leads to w popping up at (a,b), instead of (x,y),
considering:

void
gtk_window_move (GtkWindow *window,
                 gint       x,
                 gint       y)
{
  /* ... */
  if (GTK_WIDGET_MAPPED (window))
    {
      /* ... */
    }
  else
    {
      /* Save this position to apply on mapping */
      info->initial_x = x;
      info->initial_y = y;
      info->initial_pos_set = TRUE;
    }
}
static void
gtk_window_map (GtkWidget *widget)
{
  /* ... */
  /* No longer use the default settings */
  window->need_default_size = FALSE;
  window->need_default_position = FALSE;
      
  gdk_window_show (widget->window);
  /* ... */
}

i'd say there're two things we could do:
1) support GTK_WIDGET_REALIZED() in gtk_window_move() to move the
   gdkwindow
2) change gtk_window_map() to read:
static void
gtk_window_map (GtkWidget *widget)
{
  /* ... */

  if (info->initial_pos_set)
    gtk_window_move (window, info->initial_x, info->initial_y);
  /* No longer use the default settings */
  window->need_default_size = FALSE;
  window->need_default_position = FALSE;
      
  gdk_window_show (widget->window);
  /* ... */
}

in both cases, the window position should be updated prior to
mapping, to avoid the window "jumping back" to its intended position.

---
ciaoTJ




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