Browse Source

[X11] Fixed maximize behavior for transient windows

pull/2011/head
Nikita Tsukanov 7 years ago
parent
commit
db5d3aa854
  1. 1
      samples/ControlCatalog/Pages/DialogsPage.xaml
  2. 10
      samples/ControlCatalog/Pages/DialogsPage.xaml.cs
  3. 2
      src/Avalonia.X11/X11PlatformThreading.cs
  4. 20
      src/Avalonia.X11/X11Window.cs

1
samples/ControlCatalog/Pages/DialogsPage.xaml

@ -6,6 +6,7 @@
<Button Name="SaveFile">Save File</Button>
<Button Name="SelectFolder">Select Folder</Button>
<Button Name="DecoratedWindow">Decorated window</Button>
<Button Name="DecoratedWindowDialog">Decorated window (dialog)</Button>
<Button Name="Dialog">Dialog</Button>
</StackPanel>
</UserControl>

10
samples/ControlCatalog/Pages/DialogsPage.xaml.cs

@ -31,9 +31,13 @@ namespace ControlCatalog.Pages
}.ShowAsync(GetWindow());
};
this.FindControl<Button>("DecoratedWindow").Click += delegate
{
new DecoratedWindow().ShowDialog(GetWindow());
};
{
new DecoratedWindow().Show();
};
this.FindControl<Button>("DecoratedWindowDialog").Click += delegate
{
new DecoratedWindow().ShowDialog(GetWindow());
};
this.FindControl<Button>("Dialog").Click += delegate
{
new MainWindow().ShowDialog(GetWindow());

2
src/Avalonia.X11/X11PlatformThreading.cs

@ -176,6 +176,8 @@ namespace Avalonia.X11
if (cancellationToken.IsCancellationRequested)
return;
//Flush whatever requests were made to XServer
XFlush(_display);
epoll_event ev;
var len = epoll_wait(_epoll, &ev, 1,
nextTick == null ? -1 : Math.Max(1, (int)(nextTick.Value - _clock.Elapsed).TotalMilliseconds));

20
src/Avalonia.X11/X11Window.cs

@ -95,6 +95,9 @@ namespace Avalonia.X11
_x11.Atoms.WM_DELETE_WINDOW
};
XSetWMProtocols(_x11.Display, _handle, protocols, protocols.Length);
XChangeProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_WINDOW_TYPE, _x11.Atoms.XA_ATOM,
32, PropertyMode.Replace, new[] {_x11.Atoms._NET_WM_WINDOW_TYPE_NORMAL}, 1);
var feature = (EglGlPlatformFeature)AvaloniaLocator.Current.GetService<IWindowingPlatformGlFeature>();
var surfaces = new List<object>
{
@ -105,7 +108,7 @@ namespace Avalonia.X11
new EglGlPlatformSurface((EglDisplay)feature.Display, feature.DeferredContext,
new SurfaceInfo(this, _x11.DeferredDisplay, _handle, _renderHandle)));
Surfaces = surfaces.ToArray();
UpdateMotifHits();
UpdateMotifHints();
XFlush(_x11.Display);
}
@ -141,10 +144,12 @@ namespace Avalonia.X11
public double Scaling => _window.Scaling;
}
void UpdateMotifHits()
void UpdateMotifHints()
{
var functions = MotifFunctions.All;
var decorations = MotifDecorations.All;
var functions = MotifFunctions.Move | MotifFunctions.Close | MotifFunctions.Resize |
MotifFunctions.Minimize | MotifFunctions.Maximize;
var decorations = MotifDecorations.Menu | MotifDecorations.Title | MotifDecorations.Border |
MotifDecorations.Maximize | MotifDecorations.Minimize | MotifDecorations.ResizeH;
if (_popup || !_systemDecorations)
{
@ -164,7 +169,6 @@ namespace Avalonia.X11
functions = new IntPtr((int)functions)
};
XChangeProperty(_x11.Display, _handle,
_x11.Atoms._MOTIF_WM_HINTS, _x11.Atoms._MOTIF_WM_HINTS, 32,
PropertyMode.Replace, ref hints, 5);
@ -392,6 +396,8 @@ namespace Avalonia.X11
get => _lastWindowState;
set
{
if(_lastWindowState == value)
return;
_lastWindowState = value;
if (value == WindowState.Minimized)
{
@ -624,7 +630,7 @@ namespace Avalonia.X11
public void SetSystemDecorations(bool enabled)
{
_systemDecorations = enabled;
UpdateMotifHits();
UpdateMotifHints();
}
@ -652,7 +658,7 @@ namespace Avalonia.X11
public void CanResize(bool value)
{
_canResize = value;
UpdateMotifHits();
UpdateMotifHints();
}
public void SetCursor(IPlatformHandle cursor)

Loading…
Cancel
Save