Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxGUI GTK3 "logic" on newer OS partly broken #73

Open
GWRon opened this issue Mar 13, 2024 · 1 comment
Open

MaxGUI GTK3 "logic" on newer OS partly broken #73

GWRon opened this issue Mar 13, 2024 · 1 comment

Comments

@GWRon
Copy link
Contributor

GWRon commented Mar 13, 2024

While thinkering with some issues I spotted something interesting:

This example here (from createbutton.bmx):

' createbutton.bmx
Strict 

Import MaxGui.Drivers


Global window:TGadget = CreateWindow("MaxGUI Buttons",40,40,400,330,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_RESIZABLE)
	CreateButton("Std. Button",10,10,120,30,window,BUTTON_PUSH)
	CreateButton("OK Button",140,10,120,30,window,BUTTON_OK)
	CreateButton("Cancel Button",270,10,120,30,window,BUTTON_CANCEL)

Repeat
	Select WaitEvent()
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
			End
		Case EVENT_GADGETACTION
			Print "EVENT_GADGETACTION~n" + ..
			"GadgetText(): ~q" + GadgetText(TGadget(EventSource())) + "~q ~t " + ..
			"ButtonState(): "+ ButtonState(TGadget(EventSource()))
			
'			SetGadgetShape( window, 0, 0, 512, 512 )
			Local h:Byte Ptr = TGTKWindow(window).handle
			'gtk_window_resize(h, 512, 512)
			gtk_widget_set_size_request(h, 512, 512)
	EndSelect
Forever

On a click on one of the buttons the window will resize.

But when doing this in a default Ubuntu 23.10 installation this resizes the window way bigger..
Peek 2024-03-13 23-46

I then added some debug prints to the "Method rethink" of the TGTKWindow type

Mint 22 (working nicely):

Executing:createbutton
Rethink: 400, 330
Rethink: 400, 330
EVENT_GADGETACTION
GadgetText(): "OK Button"      ButtonState(): 0

But on Ubuntu 23 this is printed:

Executing:createbutton
Rethink: 400, 330
Rethink: 400, 330
EVENT_GADGETACTION
GadgetText(): "OK Button"      ButtonState(): 0
Rethink: 512, 512
Rethink: 564, 601
Rethink: 616, 690
Rethink: 668, 779
Rethink: 720, 868
Rethink: 772, 920
Rethink: 824, 1009
Rethink: 876, 920
Rethink: 928, 1009
Rethink: 980, 920

So wait ... Ubuntu has these nice animations when changing things ... so resizing "swishes" into the new size.

in initWindow() gtkgadget.bmx contains this:

		addConnection("check-resize", g_signal_cb2(handle, "check-resize", OnWindowSize, Self, Destroy, 0))

And this is fired for for multiple steps of this "animation".
OnWindowSize then is resulting in calls to "rethink()" which itself does the gtk_window_resize we used to "init" the resize already.

gtk_window_resize -> OnWindowSize -> rethink -> gtk_window_size

Disabling the animation (settings -> accessibility -> reduce animations) makes it work correct again.

@GWRon
Copy link
Contributor Author

GWRon commented Mar 13, 2024

Maybe a resizeable window just does not need the "rethink"-content (resizing to some calculated height).
Maybe this was just added for resizeable windows to "fit" to the content "automagically"

Maybe it is already enough to call "layoutKids()" instead of resizing a window when the event happens.

	Function OnWindowSize(widget:Byte Ptr, obj:Object)
		Local win:TGTKWindow = TGTKWindow(obj)
		If win Then
			If win.ClientHeight() <> win.oldCH Or win.ClientWidth() <> win.oldCW Then
				win.oldCH = win.ClientHeight()
				win.oldCW = win.ClientWidth()

'here ... maybe just TGTKWindow(obj).LayoutKids() would do?
				TGTKContainer(obj).rethink()
			End If
		End If
	End Function

Yet
https://www.cs.hunter.cuny.edu/~sweiss/course_materials/csci493.70/lecture_notes/GTK_Lesson_03.pdf
describes the event "check-resize" (which is calling the OnWindowSize() as:

This is emitted when the container is checking whether it has to resize itself to make room for its children

Which sounds like in there it should look if the "kids" have enough space (the 3 buttons in the sample have enough space...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant