Skip to content

Fix combo box lists do not expand in the Preference dialog on MacOS#181

Open
Gasparoken wants to merge 1 commit into
aseprite:mainfrom
Gasparoken:fix-modal-macos-2
Open

Fix combo box lists do not expand in the Preference dialog on MacOS#181
Gasparoken wants to merge 1 commit into
aseprite:mainfrom
Gasparoken:fix-modal-macos-2

Conversation

@Gasparoken

Copy link
Copy Markdown
Member

This fixes a regression inserted in the commit aseprite/aseprite@d9785e5: PR: aseprite/aseprite#5813

@martincapello martincapello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works great and looks good to me!

@Gasparoken Gasparoken force-pushed the fix-modal-macos-2 branch from ffd31dc to 39df0e3 Compare June 2, 2026 20:56
@Gasparoken Gasparoken assigned dacap and unassigned Gasparoken Jun 2, 2026

@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 os/osx/window_delegate.h
m_impl = nullptr;
}

- (void)windowDidBecomeKey:(NSNotification*)notification;

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: expected ')' [clang-diagnostic-error]

- (void)windowDidBecomeKey:(NSNotification*)notification;
   ^
Additional context

os/osx/window_delegate.h:31: to match this '('

- (void)windowDidBecomeKey:(NSNotification*)notification;
  ^

Comment thread os/osx/window_delegate.h
m_impl = nullptr;
}

- (void)windowDidBecomeKey:(NSNotification*)notification;

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: expected external declaration [clang-diagnostic-error]

- (void)windowDidBecomeKey:(NSNotification*)notification;
^

Comment thread os/osx/window_delegate.h
m_impl = nullptr;
}

- (void)windowDidBecomeKey:(NSNotification*)notification;

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: expected unqualified-id [clang-diagnostic-error]

- (void)windowDidBecomeKey:(NSNotification*)notification;
   ^

Comment thread os/osx/window_delegate.h
}

- (void)windowDidBecomeKey:(NSNotification*)notification;
{

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: expected unqualified-id [clang-diagnostic-error]

{
^

@Gasparoken

Copy link
Copy Markdown
Member Author

I only corrected one comment after the revision.

Comment thread os/osx/window.mm Outdated
Comment on lines +145 to +148
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appDidBecomeActive:)
name:NSApplicationDidBecomeActiveNotification
object:nil];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of using the NSNotificationCenter, probably we could use the applicationDidBecomeActive from our own AppDelegate to avoid adding a new observer for each window. And then we can re-order the windows there (or call a WindowOSX function to do the appDidBecomeActive job).

(Our applicationDidBecomeActive is already doing something for floating windows)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seeing our current applicationWillResignActive:

- (void)applicationWillResignActive:(NSNotification*)notification
{
  for (id window : [NSApp windows]) {
    if ([window isKindOfClass:[WindowOSXObjc class]] && [window isFloating]) {
      [window setLevel:NSNormalWindowLevel];
      [window orderWindow:NSWindowAbove relativeTo:0];
    }
  }

  NSEvent* event = [NSApp currentEvent];
  if (event != nil)
    [ViewOSX updateKeyFlags:event];
}

Wouldn't be possible to reorder children just starting from [NSApp windows]? (without a our auxiliary m_savedChildOrder array?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Instead of using the NSNotificationCenter, probably we could use the applicationDidBecomeActive from our own AppDelegate to avoid adding a new observer for each window. And then we can re-order the windows there (or call a WindowOSX function to do the appDidBecomeActive job).

Yes, you're right! I'll explore that option.

Wouldn't be possible to reorder children just starting from [NSApp windows]? (without a our auxiliary m_savedChildOrder array?)

No, '[NSApp windows]' this array do not guarantee the correct windows order (docs). On the other hand '[NSApp orderedWindows]' is an array of window objects arranged according to their front-to-back ordering on the screen, but even with orderedWindows, we need to remember the array when Aseprite loses focus, since I empirically verified that the z-order of child windows is lost. This makes me think it might be a Cocoa/Appkit bug, but I'm not sure.

Comment thread os/osx/window.mm Outdated
if (spec->modal())
self.level = NSModalPanelWindowLevel;

m_savedChildOrder = [NSMutableArray array];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could keep m_savedChildOrder = nullptr until the first child window is added.

@dacap dacap assigned Gasparoken and unassigned dacap Jun 5, 2026
@dacap dacap added the release blocker We cannot release a new version with this issue open. label Jun 5, 2026
@Gasparoken Gasparoken force-pushed the fix-modal-macos-2 branch from 39df0e3 to d4a902c Compare June 8, 2026 21:18
@aseprite-bot

Copy link
Copy Markdown
Collaborator

clang-tidy review says "All clean, LGTM! 👍"

@Gasparoken Gasparoken force-pushed the fix-modal-macos-2 branch from d4a902c to 1caf621 Compare June 8, 2026 21:22
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)'
@aseprite-bot

Copy link
Copy Markdown
Collaborator

clang-tidy review says "All clean, LGTM! 👍"

@Gasparoken Gasparoken force-pushed the fix-modal-macos-2 branch from 1caf621 to 7f70199 Compare June 8, 2026 21:23
@aseprite-bot

Copy link
Copy Markdown
Collaborator

clang-tidy review says "All clean, LGTM! 👍"

@Gasparoken Gasparoken assigned dacap and unassigned Gasparoken Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release blocker We cannot release a new version with this issue open.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants