Windows bug when minimized

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
mrupp
Posts: 147
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

Windows bug when minimized

Post by mrupp »

Hi there

I think I found a bug concerning windows on OS Windows. When hiding a widget (take a button as an example) while the window is minimized, this corrupts the window's size. Meaning: when normalizing (un-minimizing) the window, its size has changed and even worse, it can't be resized back to how it was, for even its minimum size seems to have changed.

I encountered this while developing my SonosController on Windows x64, but never on the targeted Amiga variants so I didn't pay it much attention then but now I thought it's better to investigate nevertheless. I also tested macOS x64 where everything works fine, so it seems only Windows is affected.

After quite some testing I finally traced this down to the function where I hide/show some buttons and created a minimal example to reproduce this behaviour:

Code: Select all

@REQUIRE "RapaGUI", {Link = True}
@APPTITLE "Hide/show when minimized"

Global m_hideButton2 = False

Function p_EventFunc(msg)
	Switch msg.ID
	Case "btnStart":
		moai.Set("btnStart", "disabled", True)
		SetTimeout(Nil, p_ToggleButtonVisibility, 5000)
	EndSwitch
EndFunction

Function p_ToggleButtonVisibility()
	Local callInitExitChange = moai.Get("check1", "selected")
	m_hideButton2 = Not m_hideButton2

	If callInitExitChange Then moai.DoMethod("group", "initChange")
	moai.Set("btn2", "hide", m_hideButton2)
	If callInitExitChange Then moai.DoMethod("group", "exitChange", False)

	moai.Set("btnStart", "disabled", False)
	DebugPrint("button 2 hidden:", m_hideButton2)
EndFunction

moai.CreateApp([[<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	<window id="mainWindow" title="Hide/show when minimized">
		<vgroup>
			<hgroup id="group">
				<button id="btn1">Button 1</button>
				<button id="btn2">Button 2</button>
			</hgroup>
			<hline />
			<textview>Textview to make this window resizeable</textview>
			<hline />
			<checkbox selected="true" id="check1">Call initChange / exitChange on group</checkbox>
			<button id="btnStart">Click here, minimize and wait 5 seconds, then normalize</button>
		</vgroup>
	</window>
</application>]])

InstallEventHandler({RapaGUI = p_EventFunc})

Repeat
	 WaitEvent
Forever
Run this script on Windows and it looks like this:

Image

Now, if you click the "Click here" button and wait for 5 seconds, it will look like this, which is the expected behaviour:

Image

But if you click it, minimize the window, wait for 5 seconds and normalize it again, it will look like this:

Image

Now this is suddenly the minimum size meaning the window can't be resized to be as small as it was before.
If you repeat these steps, the window will get larger and larger.

I thought maybe it matters if "initChange" and "exitChange" are called (hence the checkbox to test this) but this doesn't seem to affect anything.

Just to share: platforms I tested that are not affected:
  • AmigaOS 4.x
  • MorphOS
  • AROS
  • macOS x64
Hope this can be fixed with some next version of RapaGUI.

Cheers,
Michael
User avatar
airsoftsoftwair
Posts: 5446
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Windows bug when minimized

Post by airsoftsoftwair »

Yes, looks like a bug. I'll check.
Post Reply