Window width/height trick?

Hello everyone!

How are you today?

I’m finishing / adjusting a game, and i want to make it available for linux users too…

i’m trying to center a desktopcanvas on a window, after set the window fullscreen.
but, after do the fullscreen, the object does not center, because i can’t get the window width/height…

my method works on mac and windows

is there a trick to get this on linux?

the size of canvas, on IDE is 480 by 374
after window set to full screen, the “window size” is 512 by 384…
(but it is full screen, almost full hd // its on a VM)

1 Like

Now you know that for debug, testing before releas, you need to use a real hardware.

Hello Alexandre,
Fine, and you?

How are you getting the size on Mac and Windows, which doesn’t work on Linux?
We hardly can guess what is failing on your side if we don’t know what you’re doing.

PlayCanvas.Left = (Window.Width / 2) - (PlayCanvas.Width /2)
PlayCanvas.Top = (Window.Height / 2) - (PlayCanvas.Height /2)
1 Like

Thank you for having a Linux version in mind!
I’ve never had an issue with Window.height Window.Width. Is the VM in Fullscreen? Maybe it having an odd screen size / aspect ratio is causing some window math issues? Just a blind guess.

1 Like
Public Sub centerThisControl(obj as DesktopUIControl, wdw as DesktopWindow)
  obj.Left = (wdw.Width - obj.Width) / 2
  obj.Top = (wdw.Height - obj.Height) / 2
End Sub

work for mac and windows.
not on linux

yes, of course! if i’m creating a game for mac, why not publish for windows and linux?!?!

this is a crazy bug (i think it’s a bug…)

1 Like

please define “not working”

Seems not a bug to me. In my Ubuntu Linux (real PC, no VM) it seems to work as aspected.

the size of canvas, on IDE is 480 by 374
after window set to full screen, the “window size” is 512 by 384…
(but it is full screen, almost full hd // its on a VM)

add a breakpoint at the beginning of your centerThisControl method, and see the parameters passed ?

could you run this for me?

windowsize_bug.xojo_binary_project.zip (4.9 KB)

on mac…

on linux…

https://tracker.xojo.com/xojoinc/xojo/-/issues/79674

1 Like

it could be a VM problem …
can you try another linux distro on another vm ?
it could be also related to the linux distro you’re using.

image

worked on mac and windows AFTER releasing the mouse

worked on LINUX, WHILE dragging!

yes… it’s a bug…

Linux always worked like this for me: Resized event firing like if it was Resizing event.
Maybe you can set Resizing if Windows/Mac and Resized if Linux to make them work similar?

2 Likes

i need it on opening event.

but ok… on resized worked too.

an ugly workaround…

Correct, but in opening changing the size of your window should fire Resized (and/or Resizing) so at least you can ‘make-it-work’.

1 Like