Heya, @Fred,
A year ago, you wrote that on Ubuntu they changed the way of assyncronity in windows or something like that.
So, I came up with a trick that would only continue executing the code after the window was officially opened.
However, the invisible and not invisible window still gives very different values, and that is the reason my open-source tool doesn't work in Ubuntu and crashes.
Here is the example code:
Code: Select all
; Display a requester with an error message.
;
; To clean up the code
;
; V1.0 - 07/APR/2024
;
Procedure MessageRequesterError(MARCOAGPINTO_error_text$)
MessageRequester("Error!",MARCOAGPINTO_error_text$,#PB_MessageRequester_Error)
EndProcedure
; Gets the maximum size a window can become in the desktop.
; (height)
;
; It opens an invisible full desktop window to find the value.
;
; 30/JUL/2024: Now asynchronous trick for Linux
;
;
; V1.0 - 14/AUG/2022
; V1.1 - 27/FEB/2024
; o Use of flag: #PB_Window_MaximizeGadget
; V1.2 - 31/MAR/2024
; o Check if temp window already exists, opening a message requester warning and exits the procedure with #False
; V1.3 - 30/JUL/2024
; o Now asynchronous trick for Linux
;
Procedure GetMaxWindowDesktopHeight()
MARCOAGPINTO_dynamic_value_for_window=3000
; Check if window already exists
If IsWindow(MARCOAGPINTO_dynamic_value_for_window)=#True
MessageRequesterError("Window number "+Str(MARCOAGPINTO_dynamic_value_for_window)+" already exists.")
ProcedureReturn #False
EndIf
If OpenWindow(MARCOAGPINTO_dynamic_value_for_window,0,0,10,10,"Getting Maximum Window Size",#PB_Window_Maximize|#PB_Window_Invisible|#PB_Window_MaximizeGadget)=0
MessageRequesterError("Can't open a window.")
ProcedureReturn 0
EndIf
Repeat
MARCOAGPINTO_event=WindowEvent()
Until IsWindow(MARCOAGPINTO_dynamic_value_for_window)
MARCOAGPINTO_max_height=WindowHeight(MARCOAGPINTO_dynamic_value_for_window)
CloseWindow(MARCOAGPINTO_dynamic_value_for_window)
ProcedureReturn MARCOAGPINTO_max_height
EndProcedure
; SAME PROCEDURE AS ABOVE BUT NOT WITH INVISIBLE WINDOW
Procedure GetMaxWindowDesktopHeight_not_invisible()
MARCOAGPINTO_dynamic_value_for_window=3000
; Check if window already exists
If IsWindow(MARCOAGPINTO_dynamic_value_for_window)=#True
MessageRequesterError("Window number "+Str(MARCOAGPINTO_dynamic_value_for_window)+" already exists.")
ProcedureReturn #False
EndIf
If OpenWindow(MARCOAGPINTO_dynamic_value_for_window,0,0,10,10,"Getting Maximum Window Size",#PB_Window_Maximize|#PB_Window_MaximizeGadget)=0
MessageRequesterError("Can't open a window.")
ProcedureReturn 0
EndIf
Repeat
MARCOAGPINTO_event=WindowEvent()
Until IsWindow(MARCOAGPINTO_dynamic_value_for_window)
MARCOAGPINTO_max_height=WindowHeight(MARCOAGPINTO_dynamic_value_for_window)
CloseWindow(MARCOAGPINTO_dynamic_value_for_window)
ProcedureReturn MARCOAGPINTO_max_height
EndProcedure
Debug GetMaxWindowDesktopHeight()
Debug GetMaxWindowDesktopHeight_not_invisible()