MacOS: Add FL_APP_ACTIVATE and DEACTIVATE.

This event is sent on application level. Add a handler
with Fl::add_handler to receive the event.
This commit is contained in:
Matthias Melcher 2025-12-21 22:49:09 +01:00
parent 31760a98ac
commit 8ec5d86fe1
3 changed files with 11 additions and 1 deletions

View File

@ -337,7 +337,13 @@ enum Fl_Event { // events
/** Triggered just before a menu is displayed. Widgets derived from Fl_Menu_
receive this event right before the menu appears, providing an opportunity
to update menu item states and activation. */
FL_BEFORE_MENU = 29
FL_BEFORE_MENU = 29,
/** Sent when the application is activate an becomes topmost and focused.
\see Fl::add_handler() */
FL_APP_ACTIVATE = 30,
/** Sent when the application is sent to the background and deactivated.
\see Fl::add_handler() */
FL_APP_DEACTIVATE = 31,
// DEV NOTE: Keep this list in sync with FL/names.h
};

View File

@ -78,6 +78,8 @@ static std::map<int, const char*> fl_eventnames = {
{ FL_ZOOM_EVENT, "FL_ZOOM_EVENT" },
{ FL_BEFORE_TOOLTIP, "FL_BEFORE_TOOLTIP" },
{ FL_BEFORE_MENU, "FL_BEFORE_MENU" },
{ FL_APP_ACTIVATE, "FL_APP_ACTIVATE" },
{ FL_APP_DEACTIVATE, "FL_APP_DEACTIVATE" },
{ /*FL_EVENT_*/ 30, "FL_EVENT_30" }, // not yet defined, just in case it /will/ be defined ...
{ /*FL_EVENT_*/ 31, "FL_EVENT_31" }, // not yet defined, just in case it /will/ be defined ...
{ /*FL_EVENT_*/ 32, "FL_EVENT_32" }, // not yet defined, just in case it /will/ be defined ...

View File

@ -1681,6 +1681,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
*/
fixup_window_levels();
Fl::handle(FL_APP_ACTIVATE, nullptr);
fl_unlock_function();
}
- (void)applicationDidChangeScreenParameters:(NSNotification *)unused
@ -1766,6 +1767,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
}
}
}
Fl::handle(FL_APP_DEACTIVATE, nullptr);
fl_unlock_function();
}
- (void)applicationWillHide:(NSNotification *)notify