question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linux - Invalid Window.ClientSize on startup

See original GitHub issue

Issue

On Linux Window.ClientSize is invalid on startup only. This is the root cause of WindowStartupLocation = Owner/CenterScreen is not working on Linux (Related #3454).

Repro:

XAML

<Window
    x:Class="AvaloniaApplication1.Views.MainWindow"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:AvaloniaApplication1.ViewModels;assembly=AvaloniaApplication1"
    Title="AvaloniaApplication1"
    Width="450"
    Height="450"
    Icon="/Assets/avalonia-logo.ico"
    mc:Ignorable="d">
    <Grid>
      <StackPanel>
        <Button Width="200" Height="100" Name="BtnClick" Content="Refresh" />
        <TextBlock Name="Txtblock"/>
      </StackPanel>
    </Grid>
</Window>

In Code

        public MainWindow()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            this.Opened += MainWindow_Opened;
        }

        private void MainWindow_Opened(object sender, System.EventArgs e)
        {
            var txt = this.Find<TextBlock>("Txtblock");
            var sb = new StringBuilder();
            sb.AppendLine($"ClientSize.Width:{ClientSize.Width}");
            sb.AppendLine($"ClientSize.Height:{ClientSize.Height}");
            sb.AppendLine($"this.Width:{Width}");
            sb.AppendLine($"this.Height:{Height}");
            sb.AppendLine();
            txt.Text = sb.ToString();
        }

         public void Button_Clicked(object sender, RoutedEventArgs e)
        {
            MainWindow_Opened(null, null);
        }

Opened Event - Result (Linux vs Windows):

image

After clicking refresh - Result (Linux only)

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
kekekekscommented, Mar 14, 2020

For now I think we should do

update the client size immediately if the window has never been onscreen before

hack to mitigate autosizing issues for most X11 systems.

1reaction
Symbaicommented, Mar 14, 2020

This issue also affects SizeToContent to not work correctly. Both makes simulating a messagebox really annoying on Linux. It always shows up at the top left corner and needs to be resized by the user.

Is there a quick workaround possible? Perhaps waiting for X11 to be finished and then resize / apply startup location?!

Read more comments on GitHub >

github_iconTop Results From Across the Web

rdesktop failing with BadWindow (invalid Window parameter)
I'm using xmonad.org window manager, which might also contribute to some less standard GUI environment. linux · xmonad · rdesktop · Share.
Read more >
Steam doesn't open up / Newbie Corner ...
When I run steam, the only thing I see is the "Updating steam.." window for 1 second, which is all in blue for...
Read more >
Linux: Minecraft Launcher doesnt launch any other Version ...
When I created another Launch option, and selected any other gameversion beside the latest one and want to launch it, the launcher shows...
Read more >
[RESOLVED!!] Some steam games just open and close
A few days ago, I noticed that starting Noita, it would act as if opening, then close immediately, without opening a window.
Read more >
Steam Proton games not starting : r/linux_gaming
I am running endeavourOS and I can't get non-native games to start, but I can get games like Factorio or CS:GO to start....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found