# Window width/height trick?

**URL:** <https://forum.xojo.com/t/window-width-height-trick/86181>\
**Category:** Linux\
**Created:** [August 4, 2025, 10:21pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181 "2025-08-04T22:21:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 4, 2025, 10:21pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/1 "2025-08-04T22:21:24Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [August 5, 2025, 5:43am UTC](https://forum.xojo.com/t/window-width-height-trick/86181/2 "2025-08-05T05:43:08Z")

</div>

> [@Alexandre\_Cunha](#):
>
> its on a VM

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

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [August 5, 2025, 7:44am UTC](https://forum.xojo.com/t/window-width-height-trick/86181/3 "2025-08-05T07:44:24Z")

</div>

> [@Alexandre\_Cunha](#):
>
> Hello everyone!
> 
> How are you today?

Hello Alexandre,  
Fine, and you?

> [@Alexandre\_Cunha](#):
>
> 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…

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.

---

<div class="post-metadata">

**Author:** ![Alexander\_van\_der\_Linden](https://forum.xojo.com/user_avatar/forum.xojo.com/alexander_van_der_linden/32/323_2.png) [@Alexander\_van\_der\_Linden](https://forum.xojo.com/u/Alexander_van_der_Linden)\
**Post date:** [August 5, 2025, 9:56am UTC](https://forum.xojo.com/t/window-width-height-trick/86181/4 "2025-08-05T09:56:49Z")

</div>

```auto
PlayCanvas.Left = (Window.Width / 2) - (PlayCanvas.Width /2)
PlayCanvas.Top = (Window.Height / 2) - (PlayCanvas.Height /2)

```

---

<div class="post-metadata">

**Author:** ![Paul\_Birkholtz](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_birkholtz/32/13441_2.png) [@Paul\_Birkholtz](https://forum.xojo.com/u/Paul_Birkholtz)\
**Post date:** [August 5, 2025, 10:05am UTC](https://forum.xojo.com/t/window-width-height-trick/86181/5 "2025-08-05T10:05:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 5, 2025, 11:42am UTC](https://forum.xojo.com/t/window-width-height-trick/86181/6 "2025-08-05T11:42:33Z")

</div>

```auto
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

---

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 5, 2025, 11:45am UTC](https://forum.xojo.com/t/window-width-height-trick/86181/7 "2025-08-05T11:45:04Z")

</div>

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…)

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 5, 2025, 11:52am UTC](https://forum.xojo.com/t/window-width-height-trick/86181/8 "2025-08-05T11:52:21Z")

</div>

> [@Alexandre\_Cunha](#):
>
> ```auto
> 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

please define “not working”

---

<div class="post-metadata">

**Author:** ![Thomas\_Kaltschmidt](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/f0a364/32.png) [@Thomas\_Kaltschmidt](https://forum.xojo.com/u/Thomas_Kaltschmidt)\
**Post date:** [August 5, 2025, 11:56am UTC](https://forum.xojo.com/t/window-width-height-trick/86181/9 "2025-08-05T11:56:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 5, 2025, 12:19pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/10 "2025-08-05T12:19:13Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 5, 2025, 12:31pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/11 "2025-08-05T12:31:37Z")

</div>

> [@Alexandre\_Cunha](#):
>
> `centerThisControl`

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

---

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 5, 2025, 12:31pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/12 "2025-08-05T12:31:45Z")

</div>

could you run this for me?

[windowsize\_bug.xojo\_binary\_project.zip](https://forum.xojo.com/uploads/short-url/udKzmFGl5y6FNHyvT7uFD950Wed.zip) (4.9 KB)

---

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 5, 2025, 12:34pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/13 "2025-08-05T12:34:59Z")

</div>

on mac…

 ![mac](https://forum.xojo.com/uploads/default/original/3X/0/2/025e25029362da3d29b33cbc5e6df3604a360b26.jpeg)

on linux…

 ![linux](https://forum.xojo.com/uploads/default/original/3X/0/5/05ee956d44b1cea177ca255021f0835c85377dd3.jpeg)

---

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 5, 2025, 12:47pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/14 "2025-08-05T12:47:12Z")

</div>

[https://tracker.xojo.com/xojoinc/xojo/-/issues/79674](https://tracker.xojo.com/xojoinc/xojo/-/issues/79674)

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 5, 2025, 12:50pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/15 "2025-08-05T12:50:58Z")

</div>

> [@Alexandre\_Cunha](#):
>
> 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)

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.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [August 5, 2025, 1:00pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/16 "2025-08-05T13:00:33Z")

</div>

![image](https://forum.xojo.com/uploads/default/original/3X/b/1/b1219854d3017b736c7c243b51ea9f49a9958a40.png)

---

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 5, 2025, 1:07pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/17 "2025-08-05T13:07:47Z")

</div>

worked on mac and windows AFTER releasing the mouse

**worked on LINUX, WHILE dragging!**

yes… it’s a bug…

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [August 5, 2025, 1:27pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/18 "2025-08-05T13:27:18Z")

</div>

> [@Alexandre\_Cunha](#):
>
> worked on LINUX, WHILE dragging!

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?

---

<div class="post-metadata">

**Author:** ![Alexandre\_Cunha](https://forum.xojo.com/user_avatar/forum.xojo.com/alexandre_cunha/32/1221_2.png) [@Alexandre\_Cunha](https://forum.xojo.com/u/Alexandre_Cunha)\
**Post date:** [August 5, 2025, 1:39pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/19 "2025-08-05T13:39:08Z")

</div>

i need it on opening event.

but ok… on resized worked too.

an ugly workaround…

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [August 5, 2025, 1:47pm UTC](https://forum.xojo.com/t/window-width-height-trick/86181/20 "2025-08-05T13:47:44Z")

</div>

> [@Alexandre\_Cunha](#):
>
> i need it on opening event.

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

[Next page](https://forum.xojo.com/t/window-width-height-trick/86181.md?page=2)
