Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable close, move, resize, maximize and minimize functions for parent of modal window on Linux. #13398

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Avalonia.X11/X11Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,15 @@ private void UpdateMotifHints()
|| _systemDecorations == SystemDecorations.None)
decorations = 0;

if (!_canResize)
if (!_canResize || !IsEnabled)
{
functions &= ~(MotifFunctions.Resize | MotifFunctions.Maximize);
decorations &= ~(MotifDecorations.Maximize | MotifDecorations.ResizeH);
}
if (!IsEnabled)
{
functions &= ~(MotifFunctions.Resize | MotifFunctions.Minimize);
}

var hints = new MotifWmHints
{
Expand Down Expand Up @@ -565,7 +569,7 @@ private void OnEvent(ref XEvent ev)
{
if (ev.ClientMessageEvent.ptr1 == _x11.Atoms.WM_DELETE_WINDOW)
{
if (Closing?.Invoke(WindowCloseReason.WindowClosing) != true)
if (IsEnabled && Closing?.Invoke(WindowCloseReason.WindowClosing) != true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really review linux specific PRs with confidence, but is it safe to disable window closing for Windows with IsEnabled=false? It will affect more than just dialog owners. Should be child window closed with the owner together?
cc @kekekeks @jmacato

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code only affects events from the OS window manager and prevents users from closing disabled windows (e.g. owner of the modal window). You can still close a disabled window via API (Window.Close).

Dispose();
}
else if (ev.ClientMessageEvent.ptr1 == _x11.Atoms._NET_WM_SYNC_REQUEST)
Expand Down Expand Up @@ -1261,6 +1265,7 @@ public void SetEnabled(bool enable)
_disabled = !enable;

UpdateWMHints();
UpdateMotifHints();
}

private void UpdateWMHints()
Expand Down