Bug 386778 - Omit use of deprecated GTK_WIDGET_SET_X and GTK_WIDGET_SET_Y for newer GTK+
Summary: Omit use of deprecated GTK_WIDGET_SET_X and GTK_WIDGET_SET_Y for newer GTK+
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.3 M2   Edit
Assignee: Arun Thondapu CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2012-08-07 15:31 EDT by Anatoly Spektor CLA
Modified: 2012-10-24 14:26 EDT (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 Anatoly Spektor CLA 2012-08-07 15:31:24 EDT
This patch omits use of deprecated constants GTK_WIDGET_SET_X and GTK_WIDGET_SET_Y using GtkAllocation instead:


http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=gtk_widget_set_xy
Comment 1 Arun Thondapu CLA 2012-08-08 07:25:56 EDT
Shouldn't we use gtk_widget_size_allocate () instead of gtk_widget_set_allocation () in this patch? The documentation for gtk_widget_set_allocation () says this clearly - "This should not be used directly, but from within a widget's size_allocate method."
Comment 2 Anatoly Spektor CLA 2012-08-08 09:46:06 EDT
(In reply to comment #1)
> Shouldn't we use gtk_widget_size_allocate () instead of
> gtk_widget_set_allocation () in this patch? The documentation for
> gtk_widget_set_allocation () says this clearly - "This should not be used
> directly, but from within a widget's size_allocate method."

On the one hand, I would say that accessing size_allocate directly is exactly what deprecated constants do, and  this function replicates their actions.

 However, I agree that we should follow documentation and make best practices we can, thus using gtk_widget_size_allocate() is better. 


Thank you for pointing that out Arun, here is revised patch:

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=gtk_widget_set_xy_


Regards,

Anatoly
Comment 3 Silenio Quarti CLA 2012-08-08 10:35:45 EDT
Sorry, the first patch is correct. We are not doing a gtk_widget_size_allocate() for performance reasons. I am not sure this is needed anymore, but we should keep this the same for now and open a separate bug to investigate whether the optimization still makes sense.
Comment 4 Anatoly Spektor CLA 2012-08-08 10:37:14 EDT
Ok, if you prefer first patch, please use first patch.

Regards,

Anatoly
Comment 5 Arun Thondapu CLA 2012-08-08 14:22:29 EDT
(In reply to comment #3)
> Sorry, the first patch is correct. We are not doing a
> gtk_widget_size_allocate() for performance reasons. I am not sure this is
> needed anymore, but we should keep this the same for now and open a separate
> bug to investigate whether the optimization still makes sense.

Silenio, to confirm, are you saying that usage of gtk_widget_size_allocate() could cause performance issues but directly invoking gtk_widget_set_allocation() is okay?
Comment 6 Silenio Quarti CLA 2012-08-08 14:44:56 EDT
Yes.

The code path that checks for ZERO_WIDTH/ZERO_HEIGHT was done to avoid gtk_widget_size_allocate().  I do not remember all the details here. I believe the root problem was either performance or support for zero sized widgets which does not work on GTK itself. gtk_widget_size_allocate() would probably print warnings to the console if called with width,height equals 0,0.

Take a look at the other code path, forceResize() calls gtk_widget_size_allocate() but sets the size to 1,1 instead of 0,0. We need to check the history of the code to understand all the details.  For now, let's just write equivalent code using gtk_widget_set_allocation().
Comment 7 Arun Thondapu CLA 2012-08-09 08:01:43 EDT
Pushed the patch from comment 0 - http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6207053cbabec2bceac5c0fcadb16091fc8a4c80 and raised bug 386921 for further investigation as suggested in comment 3.

Thanks!