Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 374754 - Remove GTK_WIDGET_REQUISITION_WIDTH and GTK_WIDGET_REQUISITION_HEIGHT.
Summary: Remove GTK_WIDGET_REQUISITION_WIDTH and GTK_WIDGET_REQUISITION_HEIGHT.
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.3 M4   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2012-03-20 09:18 EDT by Alexander Kurtakov CLA
Modified: 2012-11-16 10:44 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kurtakov CLA 2012-03-20 09:18:32 EDT
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
Comment 1 Silenio Quarti CLA 2012-03-20 14:50:43 EDT
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();
}
}
Comment 2 Grant Gayed CLA 2012-03-20 16:46:17 EDT
Moving to SSQ since he commits these patches.
Comment 3 Alexander Kurtakov CLA 2012-03-21 07:59:31 EDT
This looked like an easy win but obviously I was wrong. I'll investigate the preferred size functions.
Comment 4 Alexander Kurtakov CLA 2012-03-21 12:20:09 EDT
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 ?
Comment 5 Silenio Quarti CLA 2012-03-21 14:21:19 EDT
Closing as WONTFIX for now. Reopen once you have a proper solution.
Comment 6 Silenio Quarti CLA 2012-10-24 17:39:24 EDT
Reopening. 

Removed the natives from GTK3 for now.

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6a271e7efb43e38ed14f54e83cfcc25f94625462
Comment 7 Silenio Quarti CLA 2012-10-29 15:44:55 EDT
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
Comment 8 Silenio Quarti CLA 2012-10-29 16:32:34 EDT
Disregarded may previous comment. Comment#1 is still an issue on GTK3.
Comment 9 Silenio Quarti CLA 2012-11-02 10:46:48 EDT
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.
Comment 10 Silenio Quarti CLA 2012-11-02 16:28:19 EDT
Pushed to master.