Re: Different behaviour under Wayland

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

 



I wrote:
>Firstly, when run under Wayland the application has a size slightly
>greater than its natural size.  That is, I am able to reduce its size
>manually.  Under X11 the application appears at its natural size and
>can only be made bigger manually.

I've looked into this further, new program attached.  It appears
that under Wayland the natural size of the widget (determined by
gtk_widget_get_preferred_size) is 52 pixels larger than under X11:

   $ ./tester
   window default size -1 -1
   widget min size 802 652   widget natural size 802 652
   $ GDK_BACKEND=x11 ./tester 
   window default size -1 -1
   widget min size 750 600   widget natural size 750 600

Under Wayland the window is larger when realised but it can be reduced
manually to the same size as under X11.

Adding an argument to the command changes the default size of the window
by calling:

   gtk_window_set_default_size(GTK_WINDOW(shell), 0, 0);

This reports:

   $ ./tester bodge
   window default size 1 1
   widget min size 802 652   widget natural size 802 652
   $ GDK_BACKEND=x11 ./tester bodge
   window default size 1 1
   widget min size 750 600   widget natural size 750 600

The natural sizes are unchanged but, surprisingly, in Wayland the window
is now realised at the same size as in X11.

Ron
#include <gtk/gtk.h>

int main(int argc, char **argv)
{
    GtkWidget *shell, *mainw, *graph;
	int width, height;
	GtkRequisition minsize, natsize;

	gtk_init(&argc, &argv);

	shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(shell), "tester");
	g_signal_connect(G_OBJECT(shell), "destroy",
						G_CALLBACK(gtk_main_quit), NULL);

	mainw = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

	gtk_container_add(GTK_CONTAINER(shell), GTK_WIDGET(mainw));
	gtk_widget_set_name(GTK_WIDGET(mainw), "MainWindow");
	gtk_widget_show(GTK_WIDGET(mainw));

	graph = gtk_drawing_area_new();

	gtk_widget_set_size_request(GTK_WIDGET(graph), 750, 600);
	gtk_widget_set_name(GTK_WIDGET(graph), "graph");

	gtk_box_pack_start(GTK_BOX(mainw), GTK_WIDGET(graph), TRUE, TRUE, 0);
	gtk_widget_show(GTK_WIDGET(graph)) ;

	if ( argc > 1 ) {
		gtk_window_set_default_size(GTK_WINDOW(shell), 0, 0);
	}

	gtk_window_get_default_size(GTK_WINDOW(shell), &width, &height);
	fprintf(stderr, "window default size %d %d\n", width, height);

	gtk_widget_get_preferred_size(GTK_WIDGET(shell), &minsize, &natsize);
	fprintf(stderr, "widget min size %d %d   widget natural size %d %d\n",
			minsize.width, minsize.height, natsize.width, natsize.height);

	gtk_widget_show_all(shell);

	gtk_main();

    return 0;
}
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux