Using ResizeWindow() to position window appears to fail
Posted: Sat Aug 08, 2015 6:34 pm
I have some code that works as expected with windows but fails when using Linux.
Run the code and drag the main window.
The temp window follows the main window and stays in it's default location.
This is the desired result.
Now drag the temp window off of the main window.
Click the button to hide the temp window.
Now click it again to unhide the temp window.
It will appear at the default location on the main window.
This is the desired result.
Now drag the temp window off of the main window again.
Hide and unhide the temp window by clicking the button two times.
It will not return to the default location but it should.
Why?
Now drag the main window and the temp window will return to the proper location.
Now you can drag the temp window off and click the button two times.
The temp window will return to correct position but you can only do it once until
you drag the main window again.
I am using Linux Mint and PureBasic 5.31 (x64).
Run the code and drag the main window.
The temp window follows the main window and stays in it's default location.
This is the desired result.
Now drag the temp window off of the main window.
Click the button to hide the temp window.
Now click it again to unhide the temp window.
It will appear at the default location on the main window.
This is the desired result.
Now drag the temp window off of the main window again.
Hide and unhide the temp window by clicking the button two times.
It will not return to the default location but it should.
Why?
Now drag the main window and the temp window will return to the proper location.
Now you can drag the temp window off and click the button two times.
The temp window will return to correct position but you can only do it once until
you drag the main window again.
I am using Linux Mint and PureBasic 5.31 (x64).
Code: Select all
EnableExplicit
Define x, y, quit, wx, wy, m$
Macro Position_Temp_Window() ; place the temp window in it's default location
x = WindowX(0,#PB_Window_InnerCoordinate) + 10 ;: Debug x
y = WindowY(0,#PB_Window_InnerCoordinate) + 150 ;: Debug y
ResizeWindow(1,x,y,#PB_Ignore,#PB_Ignore)
EndMacro
OpenWindow(0,0,0,400,400,"main window",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ButtonGadget(0,100,10,200,35,"Hide temp window",#PB_Button_Toggle)
OpenWindow(1,0,0,200,200,"temp window",#Null,WindowID(0))
Position_Temp_Window()
SetActiveWindow(0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
If EventGadget() = 0 ; button
If GetGadgetState(0) = #True ; hide the temp window
HideWindow(1,1)
SetGadgetText(0,"UnHide temp window")
Else ; show the temp window at default location on main window
Position_Temp_Window() ;<-- only works first time
HideWindow(1,0,#PB_Window_NoActivate)
SetGadgetText(0,"Hide temp window")
EndIf
EndIf
Case #PB_Event_MoveWindow ; we are dragging the main window
If EventWindow() = 0 ; temp window follows main window
Position_Temp_Window() ;<-- works always
EndIf
Case #PB_Event_CloseWindow
If EventWindow() = 0
quit = #True
EndIf
EndSelect
Until quit = #True