Community
Participate
Working Groups
OS.gtk_widget_size_request is the right way to do it and it is also more consistent with the rest of the codebase. Struct GtkWidget no longer exposes GtkRequision in GTK 3. Commit/patch: http://fedorapeople.org/gitweb?p=akurtakov/public_git/eclipse.platform.swt.git;a=commit;h=5c59fc5ad0141afe1fef9da8863dccc7dc3e633b
This patch will break compute size for widgets that have its size set. Try the the example below. The problem is that if you set the size of a widget with gtk_widget_set_size_request() then a call to gtk_widget_size_request() will return those values all the time. It also stores the actual computed size in the widget GtkRequision which we are accessing. We would have to temporarily set the size to -1,-1, call gtk_widget_size_request() and restore the previous size. Compare c50367f5a47e2a6effad63f64029f1b5d0e6e7f1 with a7a3ed6db60a114cf55a5ee5470840102664cbe2 to have an idea how this was done before we decided to access the widget GtkRequision. If I remember correctly (it has been quite same time), the problem with temporarily setting the size to -1,-1 is that, we would queue a bunch of queue_resizes, queue_redraws and size_allocates which caused a considerable performance problem. Shouldn't we stop using gtk_widget_size_request() in favour of gtk_widget_get_preferred_XXX() functions? Would the new functions have these problems? import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.*; public class PR374754 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.BORDER); label.setText("Hello World"); label.setSize(200, 200); System.out.println(label.computeSize(SWT.DEFAULT, SWT.DEFAULT)); label.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
Moving to SSQ since he commits these patches.
This looked like an easy win but obviously I was wrong. I'll investigate the preferred size functions.
Actually gtk_widget_get_preffered* functions are GTK 3 only so it will take some time before trying it as I'm pushing for fixes for GTK 3 that can be done and tested on latest GTK 2 now. Do you want me to close the bug in this case and open a new with proper and tested patch in the future ?
Closing as WONTFIX for now. Reopen once you have a proper solution.
Reopening. Removed the natives from GTK3 for now. http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6a271e7efb43e38ed14f54e83cfcc25f94625462
The problem a mentioned in comment#1 is no longer true in GTK3. We can use the requisition directly. These commits have fixed this: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=a3b341da6419dd861e4fed79ed72137e2ca99fbd http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=48d81c66e4c3a4579b6edbedb9a57af347363ecf
Disregarded may previous comment. Comment#1 is still an issue on GTK3.
We need to reset the size request to -1 before calling gtk_widget_size_request() even though this could cause bad performance by queuing resizes and draws. This is fixed in. http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=silenio/Bug389910&id=28693b715394e6d7185e331f748190abf197da68 The performance does not look that bad. I will push to master when M3 is done and we can do a performance pass after we get more basic functionality working.
Pushed to master.