This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

xorg-xserver-1.5.3-2: Dialogs that save their positions keep drifting downwards


There is a GTK application (gschem from that saves
the position of its sub-dialogs when they close, so they reopen at the
same place.

Up to now, on Cygwin/X, this didn't always work well: in multi-window
mode, dialogs kept reopening a little lower each time, by an amount
equal to the title bar height.

When xserver-1.5.3-1 came out, I was glad to see it was fixed.
However, the symptom reappeared on xserver-1.5.3-2.

A minimal testcase is attached, as well as the cygcheck -s -v -r output.

[I should add that both the application and the testcase works
correctly on GNU/Linux (Ubuntu Intrepid), that is, closed dialogs
remember their positions.]

/* Testcase for: Dialogs that save their positions when closing
   keep drifting downwards.

  To compile: 
  gcc -Wall -o test-gtk-move-3 test-gtk-move-3.c `pkg-config --cflags --libs gtk+-2.0 glib-2.0`

  To use:
  X -multiwindow &
  export DISPLAY=:0
  Press 'Show', then close the dialog, then press 'Show' again.
  The dialog should reopen at the same place.
  In fact, it will reopen a little lower each time. Repeated execution
  will cause it to drift downwards.

#include <glib/gprintf.h>
#include <gtk/gtk.h>

GtkWidget *main_window;
GtkWidget *tool_window;

/* Hold the last dialog position */
gint tool_x = 100, tool_y = 100;

static gboolean delete_tool_window( GtkWidget *widget,
                                 GdkEvent *event,
                                 gpointer   data )
  /* At closing time, save the dialog position */
  gtk_window_get_position (GTK_WINDOW (tool_window), &tool_x, &tool_y);
  g_printf("My position was: %d,%d\n",tool_x,tool_y);
  return FALSE;

static void destroy_tool_window( GtkWidget *widget,
                                 gpointer   data )
  tool_window = NULL;

static void create_tool_window()
    tool_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect (G_OBJECT (tool_window), "delete-event",
		      G_CALLBACK (delete_tool_window), NULL);
    g_signal_connect (G_OBJECT (tool_window), "destroy",
		      G_CALLBACK (destroy_tool_window), NULL);
    gtk_container_set_border_width (GTK_CONTAINER (tool_window), 10);

static void show_tool_window( GtkWidget *widget,
                              gpointer   data )
  /* If the dialog is closed, create it. */
  if (!tool_window)
  else {
    gtk_window_get_position (GTK_WINDOW (tool_window), &tool_x, &tool_y);
    g_printf("My position is: %d,%d\n",tool_x,tool_y);
  /* Move it to the saved position */
  /* We move it before it is shown, to avoid flicker */
  gtk_window_move (GTK_WINDOW (tool_window), tool_x, tool_y);
  /* Show the window */
  gtk_widget_show (tool_window);

static void destroy( GtkWidget *widget,
                     gpointer   data )
  gtk_main_quit ();

int main( int   argc,
          char *argv[] )
    GtkWidget *button;
    gtk_init (&argc, &argv);
    main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_decorated (GTK_WINDOW(main_window), TRUE);
    g_signal_connect (G_OBJECT (main_window), "destroy",
		      G_CALLBACK (destroy), NULL);
    gtk_container_set_border_width (GTK_CONTAINER (main_window), 10);
    button = gtk_button_new_with_label ("Show");
    g_signal_connect (G_OBJECT (button), "clicked",
		      G_CALLBACK (show_tool_window), NULL);
    gtk_container_add (GTK_CONTAINER (main_window), button);
    gtk_widget_show (button);
    gtk_widget_show (main_window);
    gtk_main ();
    return 0;

Attachment: cygcheck.out.txt
Description: Text document

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]