summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2025-12-21 22:49:09 +0100
committerMatthias Melcher <github@matthiasm.com>2025-12-21 22:49:42 +0100
commit8ec5d86fe144528b47345d8defe1149a3b8deb87 (patch)
treea3535ccb93ba9bc06b3cd9803c532c6d8e562240
parent31760a98aca6daeee846906ef7af20395f641b65 (diff)
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.
-rw-r--r--FL/Enumerations.H8
-rw-r--r--FL/names.h2
-rw-r--r--src/Fl_cocoa.mm2
3 files changed, 11 insertions, 1 deletions
diff --git a/FL/Enumerations.H b/FL/Enumerations.H
index a2434bb19..34244004d 100644
--- a/FL/Enumerations.H
+++ b/FL/Enumerations.H
@@ -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
};
diff --git a/FL/names.h b/FL/names.h
index 44f442a23..55e8c08b4 100644
--- a/FL/names.h
+++ b/FL/names.h
@@ -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 ...
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 382abc5b8..32abcbc88 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -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