Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Initial window position without content fix for #279 #281

Closed
wants to merge 1 commit into from

2 participants

@DavidKarlas
Collaborator

If window has Content everything is same except "} else if (locationSet && !shown)" where !shown is removed because it didn't make sense because it was always true but actually false(see code at start of method)

Atm InitialLocationManualWithoutContentAndSize is failing for WPF because there is some bug in WPFBackend.Move method compering to WPFBackend.Bounds(called when Size is set)
I think it's somehow connected to Xwt.WPFBackend.WpfWindow.initialX not being set by Move method.

All 3 methods are failing for GTK because known bug of 8px offset.

@sevoku
Collaborator

Has it been solved by #393?

@DavidKarlas
Collaborator

Looks like it fixed but https://github.com/mono/xwt/blob/master/Xwt/Xwt/Window.cs#L251 is still wrong(shown = true is called few lines above).

@sevoku
Collaborator

True, but not really a bug (shown is always true there)(?)
Have you tried your unit tests against the current master? Maybe they could be merged.

@DavidKarlas
Collaborator

This 3 tests...

  • Wpf: Works OK
  • Gtk:
    • Windows: Unit tests are not running(BadImageFormat...)(Changing stuff to x86 didn't help)
    • Mac: Works OK
    • Linux: Works OK
  • MonoMac: ToDesktopRect changes Y from 230 to 548(because I have MacBook with 900 pixel hight)
@sevoku
Collaborator

Ok, thanks! Could you create PRs (and split the commit) for the #L251 fix and maybe the unit tests? This one can be closed then.

Does the Mac ToDesktopRect need a fix (I have no Mac, testing my stuff in a VM)?

Looks like the GtkTestRunner needs a separate project configuration for windows.

@DavidKarlas
Collaborator

About ToDesktopRect... Not sure what is reason for that inverse calculating of Y...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 26, 2014
  1. @DavidKarlas
This page is out of date. Refresh to see the latest.
Showing with 49 additions and 4 deletions.
  1. +38 −0 Testing/Tests/WindowTests.cs
  2. +11 −4 Xwt/Xwt/Window.cs
View
38 Testing/Tests/WindowTests.cs
@@ -218,6 +218,44 @@ public void CloseCancel ()
}
Assert.IsFalse (closed, "Window should not be closed");
}
+
+ [Test]
+ public void InitialLocationManualWithoutContent ()
+ {
+ using (var win = new Window ()) {
+ win.InitialLocation = WindowLocation.Manual;
+ win.Location = new Point (210, 230);
+ win.Size = new Size (100, 100);
+ ShowWindow (win);
+ Assert.AreEqual (210, win.X);
+ Assert.AreEqual (230, win.Y);
+ }
+ }
+
+ [Test]
+ public void InitialLocationManualWithoutContentAndSize ()
+ {
+ using (var win = new Window ()) {
+ win.InitialLocation = WindowLocation.Manual;
+ win.Location = new Point (210, 230);
+ ShowWindow (win);
+ Assert.AreEqual (210, win.X);
+ Assert.AreEqual (230, win.Y);
+ }
+ }
+
+ [Test]
+ public void InitialLocationManual ()
+ {
+ using (var win = new Window ()) {
+ win.InitialLocation = WindowLocation.Manual;
+ win.Content = new Label ("Hi there!");
+ win.Location = new Point (210, 230);
+ ShowWindow (win);
+ Assert.AreEqual (210, win.X);
+ Assert.AreEqual (230, win.Y);
+ }
+ }
}
public class SquareBox: Canvas
View
15 Xwt/Xwt/Window.cs
@@ -196,9 +196,11 @@ internal void OnChildPlacementChanged (Widget child)
internal override void AdjustSize ()
{
- if (child == null)
+ if (child == null) {
+ if (!shown)
+ Show (initialBounds.Size);
return;
-
+ }
Size mMinSize, mDecorationsSize;
Backend.GetMetrics (out mMinSize, out mDecorationsSize);
@@ -230,6 +232,12 @@ internal override void AdjustSize ()
if (ws.Height > size.Height)
size.Height = ws.Height;
+ Show (size);
+ Backend.SetMinSize (new Size (ws.Width, ws.Height));
+ }
+
+ void Show (Size size)
+ {
if (!shown) {
shown = true;
@@ -249,14 +257,13 @@ internal override void AdjustSize ()
Backend.Bounds = new Rectangle (initialBounds.X, initialBounds.Y, size.Width, size.Height);
else
Backend.SetSize (size.Width, size.Height);
- } else if (locationSet && !shown)
+ } else if (locationSet)
Backend.Move (initialBounds.X, initialBounds.Y);
} else {
if (size != Size)
Backend.SetSize (size.Width, size.Height);
}
- Backend.SetMinSize (new Size (ws.Width, ws.Height));
}
}
}
Something went wrong with that request. Please try again.