Re: 3.8 toplevel resize bug?
- From: HMRG software <hmrgsoft soest hawaii edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: 3.8 toplevel resize bug?
- Date: Tue, 02 Apr 2013 06:36:58 -1000
Hi all,
Following is demo code for the 3.8 toplevel window resize bug I described
in the previous message on this thread. If anyone sees any errors on my
part, please let me know. I will otherwise file a bug report on this shortly.
The code displays a small main window with one button. Click it. This
causes a second small window to appear, also with one button. Click that to
hide the second window (or click the latter's titlebar window manager window
delete button if any). Then re-click the button in the first window to
re-show the second window. The latter reappears, but at a munged size.
Absolutely nothing was done within my code here to the second window or
its children between the hide and the re-show. My test platform is 64-bit
CentOS 6.4, using all the latest/greatest gtk-related packages other than
pango (still at 1.32.4 because later versions do not build for me ;-( ).
The munged resize demonstrated here does not occur under 3.6.2.
Thanks!
Roger Davis
Univ. of Hawaii
/********** begin code ************/
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
GtkWidget *mainwin, *rszwin;
void
errexit(char *msg)
{
(void) fprintf(stderr, "%s\n", msg);
exit(-1);
}
gboolean
windelproc(GtkWidget *w, GdkEvent *evt, gpointer gp)
{
if (w == mainwin) {
exit(0);
return TRUE;
}
else if (w == rszwin) {
gtk_widget_hide(rszwin);
return TRUE;
}
return FALSE;
}
void
mainopenproc(GtkWidget *w, gpointer gp)
{
gtk_widget_show(rszwin);
return;
}
void
rszcloseproc(GtkWidget *w, gpointer gp)
{
gtk_widget_hide(rszwin);
return;
}
void
mktoplevelwin(GtkWidget **tlwin, GtkWidget **scrwin, GtkWidget **layout)
{
GtkRequisition grq;
*tlwin= *scrwin= *layout= (GtkWidget *) 0;
if ((*tlwin= gtk_window_new(GTK_WINDOW_TOPLEVEL)) == (GtkWidget *) 0)
errexit("Toplevel window creation error.");
if ((*scrwin= gtk_scrolled_window_new(NULL, NULL)) == (GtkWidget *) 0)
errexit("Scrolled window window creation error.");
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(*scrwin), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(*tlwin), *scrwin);
if ((*layout= gtk_layout_new((GtkAdjustment *) NULL, (GtkAdjustment *) NULL)) == (GtkWidget *) 0)
errexit("Layout creation error.");
gtk_container_add(GTK_CONTAINER(*scrwin), *layout);
return;
}
void
mkbutton(GtkWidget **b, GtkRequisition *gr, GtkWidget *parent, gint x, gint y, char *label, void (*proc)())
{
*b= (GtkWidget *) 0;
if ((*b= gtk_button_new_with_label(label)) == (GtkWidget *) 0)
errexit("Button creation error.");
g_signal_connect(*b, "clicked", G_CALLBACK(proc), *b);
gtk_layout_put(GTK_LAYOUT(parent), *b, x, y);
gtk_widget_show_all(*b);
gtk_widget_get_preferred_size(*b, gr, NULL);
return;
}
gint
main(gint argc, gchar *argv[])
{
GtkWidget *sw, *lo, *b;
gint w, h;
GtkRequisition grq;
GdkGeometry geom;
if (gtk_init_check(&argc, &argv) == FALSE)
errexit("GTK+ initialization error.");
mktoplevelwin(&mainwin, &sw, &lo);
g_signal_connect(mainwin, "delete-event", G_CALLBACK(windelproc), (gpointer) mainwin);
mkbutton(&b, &grq, lo, 100, 100, "Open Resize Test Window", mainopenproc);
w= 100+grq.width+100;
h= 100+grq.height+100;
gtk_window_set_default_size(GTK_WINDOW(mainwin), w, h);
gtk_layout_set_size(GTK_LAYOUT(lo), w, h);
geom.max_width= w;
geom.max_height= h;
gtk_window_set_geometry_hints(GTK_WINDOW(mainwin), NULL, &geom, GDK_HINT_MAX_SIZE);
gtk_widget_show_all(sw);
mktoplevelwin(&rszwin, &sw, &lo);
g_signal_connect(rszwin, "delete-event", G_CALLBACK(windelproc), (gpointer) rszwin);
mkbutton(&b, &grq, lo, 100, 100, "Close This Window", rszcloseproc);
w= 100+grq.width+100;
h= 100+grq.height+100;
gtk_window_set_default_size(GTK_WINDOW(rszwin), w, h);
gtk_layout_set_size(GTK_LAYOUT(lo), w, h);
geom.max_width= w;
geom.max_height= h;
gtk_window_set_geometry_hints(GTK_WINDOW(rszwin), NULL, &geom, GDK_HINT_MAX_SIZE);
gtk_widget_show_all(sw);
gtk_widget_show(mainwin);
gtk_main();
return 0;
}
/********** end code ************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]