bugGNU Octave - Bugs: bug #59756, octave doesn't execute resizefcn...

 
 

bug #59756: octave doesn't execute resizefcn callback when figure made visible.

Submitted by:  A.R. Burgers <arb>
Submitted on:  Wed 23 Dec 2020 09:31:26 AM UTC  
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Wed 13 Jan 2021 04:05:27 PM UTC, comment #8: 

Okay, from comment #5 I see that Matlab calls the ResizeFcn only when the figure is made visible again.

I'm marking this bug as confirmed.  Resolving this is probably going to be a fair bit of work because Octave does not automatically place callback functions in a queue which it then pulls from when another event happens.  Right now the architecture is set up so that when an event happens, such as the figure window size changes, the callback function is immediately called.

Rik <rik5>
Project Administrator
Wed 13 Jan 2021 10:30:35 AM UTC, comment #7: 

Executing the commands from comment #5 line by line in Matlab R2020b:

>> cb2 = @(h,e) disp('f2 ResizeFcn callback called');
>> f2 = double(figure('Visible', 'on'))

f2 =

     1

>> set (f2, 'resizefcn', cb2)
>> set (f2, 'visible', 'off')
>> set (f2, 'position', [0, 0, 200, 200])
>> set (f2, 'visible', 'on')
f2 ResizeFcn callback called
>>

Markus M├╝tzel <mmuetzel>
Project Member
Wed 13 Jan 2021 08:56:16 AM UTC, comment #6: 

with this:

ver = version
if exist ('OCTAVE_VERSION', 'builtin')
  graphics_toolkit('qt');
end

cb2 = @(h,e) fprintf('f2 ResizeFcn callback called for %d\n', double(h));
f2 = double(figure('Visible', 'on'))
set (f2, 'resizefcn', cb2)
set (f2, 'visible', 'off')
set (f2, 'position', [0, 0, 200, 200])
set (f2, 'visible', 'on')

launch interpreter (no GUI), and then interactively launch the script

ver = 7.0.0
f2 = 1
f2 ResizeFcn callback called for 1

or, apparently in dependence of stacking of windows

ver = 7.0.0
f2 = 1
f2 ResizeFcn callback called for 1
f2 ResizeFcn callback called for 1
f2 ResizeFcn callback called for 1

matlab

ver = '9.5.0.1049112 (R2018b) Update 3'
f2 = 1
f2 ResizeFcn callback called for 1

A.R. Burgers <arb>
Tue 12 Jan 2021 05:18:31 PM UTC, comment #5: 

And just to verify the final possibility mentioned in the Matlab documentation, could you try this code?

cb2 = @(h,e) disp('f2 ResizeFcn callback called');
f2 = double(figure('Visible', 'on'))
set (f2, 'resizefcn', cb2)
set (f2, 'visible', 'off')
set (f2, 'position', [0, 0, 200, 200])
set (f2, 'visible', 'on')

In Octave, the ResizeFcn is called after the call to set (...'position'...) even though the figure is still invisible at that time.  I expect that Matlab waits and calls the ResizeFcn only when the figure is made visible again.

Rik <rik5>
Project Administrator
Fri 08 Jan 2021 07:14:48 PM UTC, comment #4: 

a slightly different example

ver = version

if exist ('OCTAVE_VERSION', 'builtin')
  graphics_toolkit('qt');
end

cb1 = @(h,e) disp('f1 ResizeFcn callback called');
f1 = double(figure('Visible', 'off', 'ResizeFcn', cb1))
set(f1, 'Visible', 'on');
set(f1, 'Visible', 'on');

cb2 = @(h,e) disp('f2 ResizeFcn callback called');
f2 = double(figure('Visible', 'on', 'ResizeFcn', cb2))
set(f2, 'Visible', 'on');
set(f2, 'Visible', 'on');

does not call cb1/cb2 on octave-7. On matlab

ver =  '9.5.0.1049112 (R2018b) Update 3'

f1 = 1

f1 ResizeFcn callback called
f2 ResizeFcn callback called

f2 = 2

For the invisible figure cb1 is called only when made visible, for f2 on creation.

A.R. Burgers <arb>
Fri 08 Jan 2021 07:07:27 PM UTC, comment #3: 

your test code, slightly adjusted

ver = version

if exist ('OCTAVE_VERSION', 'builtin')
  graphics_toolkit('qt');
end

f = figure();
cb = @(h,e) disp('ResizeFcn callback called');
set(f, 'ResizeFcn', cb);
set(f, 'Visible', 'off');
set(f, 'Visible', 'on');

does not result in cb calls, neither octave-7 nor matlab R2018a

A.R. Burgers <arb>
Sun 27 Dec 2020 07:16:07 PM UTC, comment #2: 

Is the callback function invoked whenever you transition from not visible to visible?  Or only in this case where the figure started off not visible and then was made visible?

This test code should do it:

f = figure();
cb = @(h,e) disp('ResizeFcn callback called');
set(f, 'ResizeFcn', cb);
set(f, 'Visible', 'off');
set(f, 'Visible', 'on');

Looking at the documentation, it appears the function is called when:

This container becomes visible for the first time.

This container is visible while its size changes.

This container becomes visible for the first time after its size changes. This situation occurs when the size changes while the container is invisible, and then it becomes visible later.

I bet that Octave is only considering the most obvious second case where the size is changed when the figure is visible. 

Rik <rik5>
Project Administrator
Wed 23 Dec 2020 10:49:11 AM UTC, comment #1: 

hold for SizeChangeFcn as well

updated example:

ver = version

cb1 = @(h,e) disp('ResizeFcn callback called');
f1 = figure('Visible', 'off', 'ResizeFcn', cb1);
set(f1, 'Visible', 'on');

cb2 = @(h,e) disp('SizeChangedFcn callback called');
f2 = figure('Visible', 'off', 'SizeChangedFcn', cb2);
set(f2, 'Visible', 'on');

A.R. Burgers <arb>
Wed 23 Dec 2020 09:31:26 AM UTC, original submission:  

When a figure is made visible, matlab will call the ResizeFcn callback, octave doesn't:

ver = version
f = figure('Visible', 'off');
cb = @(h,e) disp('ResizeFcn callback called');
set(f, 'ResizeFcn', cb);
set(f, 'Visible', 'on');

matlab output:

ver =    '9.5.0.1049112 (R2018b) Update 3'

ResizeFcn callback called

octave output:

ver = 7.0.0

A.R. Burgers <arb>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by arb (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-13 rik5 StatusNeed Info => Confirmed
    2020-12-27 rik5 StatusNone => Need Info

    Back to the top


    Powered by Savane 3.5