Skip to content

Fix inactive window passes events to window below (fix #4561)#4835

Closed
Gasparoken wants to merge 1 commit into
aseprite:mainfrom
Gasparoken:fix-modal-window
Closed

Fix inactive window passes events to window below (fix #4561)#4835
Gasparoken wants to merge 1 commit into
aseprite:mainfrom
Gasparoken:fix-modal-window

Conversation

@Gasparoken

Copy link
Copy Markdown
Member

This is a first approach, it may be wrong and for sure I need some advice.
Ideally I would like to make it so that at the OS level another window cannot be brought to the front/activated if there is already a modal window open.
Currently, this fix allows a non-modal window to be selected and brought to the front but does not allow events to propagate to the modal window.

fix #4561

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread src/ui/manager.cpp Outdated
mouse_widgets_list);

if (mouse_widgets_list.size() == 2)
int otot=0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

warning: variable 'otot' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int otot=0;
int const otot=0;

@Gasparoken

Copy link
Copy Markdown
Member Author

I will try to find an alternative solution at the os-laf level.

Prior to this fix, if all of the following conditions were met:
+ While a modal window (such as the Preferences dialog) was open.
+ 'Multiple window UI' was enabled.
+ A non-modal window (such as the Preview window) overlapped the modal
  window.
+ The non-modal window was selected, so this window is on top of
  the modal window.
Caused mouse clicks and movements within the overlay area of ​​the
non-modal window to be incorrectly passed to the window below, i.e.
the modal window.
Instead, it would be expected that no action would be taken.
@Gasparoken

Copy link
Copy Markdown
Member Author

This fix will work if aseprite/laf#116 is merged first.

@Gasparoken Gasparoken assigned dacap and unassigned Gasparoken Dec 3, 2024
@Gasparoken Gasparoken removed the request for review from martincapello December 3, 2024 14:11

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread src/ui/manager.cpp
spec.minimizable(window->isDesktop());
spec.borderless(!window->isDesktop());
spec.transparent(window->isTransparent());
spec.modal(window->isForeground() || window->isOnTop());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

warning: no member named 'modal' in 'os::WindowSpec' [clang-diagnostic-error]

      spec.modal(window->isForeground() || window->isOnTop());
           ^

@dacap

dacap commented Jan 7, 2025

Copy link
Copy Markdown
Member

I'll left this to review in a future version as #4561 was a bug report for Windows, so I need to test this in all platform (and the laf fix was made only on macOS if I remember correctly).

@dacap

dacap commented Mar 5, 2026

Copy link
Copy Markdown
Member

I'm trying to review all pending PRs. Testing this I'm not sure if a "isOnTop()" should be treated as a modal window (e.g. the combobox popup is the only one calling "setOnTop()" and it shouldn't a modal window).

I'll merge a modified version of this patch calling

spec.modal(window->isForeground());

Anyway the modal parameter is only processed on macOS, so I think Windows will still have the original issue #4561 (it's still present on Linux even with this patch).

dacap pushed a commit that referenced this pull request Mar 5, 2026
Prior to this fix, if all of the following conditions were met:
+ While a modal window (such as the Preferences dialog) was open.
+ 'Multiple window UI' was enabled.
+ A non-modal window (such as the Preview window) overlapped the modal
  window.
+ The non-modal window was selected, so this window is on top of
  the modal window.
Caused mouse clicks and movements within the overlay area of ​​the
non-modal window to be incorrectly passed to the window below, i.e.
the modal window.
Instead, it would be expected that no action would be taken.

@dacap note: At the moment this fix only works on macOS because the
os::WindowSpec::modal() parameter is only used on macOS.
@dacap

dacap commented Mar 5, 2026

Copy link
Copy Markdown
Member

Merged in d9785e5

@dacap dacap closed this Mar 5, 2026
Gasparoken added a commit to Gasparoken/aseprite that referenced this pull request May 12, 2026
Before this fix, on MacOS, combo box lists expanded behind the
Preferences dialog when the 'UI with multiple windows' option
was enabled.

Now, If a window is foreground (modal), child windows (like
combo boxes) must also use the modal level to appear above it.

Regression of commit d9785e5:
'Fix inactive window passes events to window below (aseprite#4561, aseprite#4835)'
Gasparoken added a commit to Gasparoken/laf that referenced this pull request May 14, 2026
Before this fix, on MacOS, combo box lists expanded behind the
Preferences dialog when the 'UI with multiple windows' option
was enabled.

Now, If a window has a new child window (like combo boxes),
it must be brought to the same level as its parent to appear above it.

This fixes a regression inserted in the commit d9785e5:
'Fix inactive window passes events to window below
(aseprite/aseprite#4561, aseprite/aseprite#4835)'
Gasparoken added a commit to Gasparoken/laf that referenced this pull request May 18, 2026
Before this fix, on MacOS, combo box lists expanded behind the
Preferences dialog when the 'UI with multiple windows' option
was enabled.

Now, If a window has a new child window (like combo boxes),
it must be brought to the same level as its parent to appear above it.

This fixes a regression inserted in the commit
aseprite/aseprite@d9785e5:
'Fix inactive window passes events to window below
(aseprite/aseprite#4561, aseprite/aseprite#4835)'
Gasparoken added a commit to Gasparoken/laf that referenced this pull request May 18, 2026
Before this fix, on MacOS, combo box lists expanded behind the
Preferences dialog when the 'UI with multiple windows' option
was enabled.

Now, If a window has a new child window (like combo boxes),
it must be brought to the same level as its parent to appear above it.

This fixes a regression inserted in the commit
aseprite/aseprite@d9785e5:
'Fix inactive window passes events to window below
(aseprite/aseprite#4561, aseprite/aseprite#4835)'
Gasparoken added a commit to Gasparoken/laf that referenced this pull request Jun 2, 2026
Before this fix, on MacOS, combo box lists expanded behind the
Preferences dialog when the 'UI with multiple windows' option
was enabled.

Now, If a window has a new child window (like a combo box list),
it must be brought to the same level as its parent to appear above it.

This fixes a regression inserted in the commit
aseprite/aseprite@d9785e5:
'Fix inactive window passes events to window below
(aseprite/aseprite#4561, aseprite/aseprite#4835)'
Gasparoken added a commit to Gasparoken/laf that referenced this pull request Jun 8, 2026
Before this fix, on MacOS, combo box lists expanded behind the
Preferences dialog when the 'UI with multiple windows' option
was enabled.

Now, if a window has a new child window (like a combo box list),
it must be brought above its parent's z-order so it always
appears on top, even when the parent is clicked/activated.

This fixes a regression inserted in the commit
aseprite/aseprite@d9785e5:
'Fix inactive window passes events to window below
(aseprite/aseprite#4561, aseprite/aseprite#4835)'
Gasparoken added a commit to Gasparoken/laf that referenced this pull request Jun 8, 2026
Before this fix, on MacOS, combo box lists expanded behind the
Preferences dialog when the 'UI with multiple windows' option
was enabled.

Now, if a window has a new child window (like a combo box list),
it must be brought above its parent's z-order so it always
appears on top, even when the parent is clicked/activated.

This fixes a regression inserted in the commit
aseprite/aseprite@d9785e5:
'Fix inactive window passes events to window below
(aseprite/aseprite#4561, aseprite/aseprite#4835)'
Gasparoken added a commit to Gasparoken/laf that referenced this pull request Jun 8, 2026
Before this fix, on MacOS, combo box lists expanded behind the
Preferences dialog when the 'UI with multiple windows' option
was enabled.

Now, if a window has a new child window (like a combo box list),
it must be brought above its parent's z-order so it always
appears on top, even when the parent is clicked/activated.

This fixes a regression inserted in the commit
aseprite/aseprite@d9785e5:
'Fix inactive window passes events to window below
(aseprite/aseprite#4561, aseprite/aseprite#4835)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inactive windows in multiple-window UI mode pass events to below windows

4 participants