diff --git a/include/minigui.h b/include/minigui.h index 870028a8..6a4c1f76 100644 --- a/include/minigui.h +++ b/include/minigui.h @@ -1851,7 +1851,7 @@ MG_EXPORT BOOL GUIAPI ServerUnregisterCompositor (const char* name); * \brief Select a compositor as the current compositor. * * This function selects a compositor as the current compositor - * and returns the compositor object. + * and returns the compositor operations. * It also destroies the old compositor object if there is old one. * * \param name The name of the compositor. If the argument is NULL, @@ -1869,7 +1869,25 @@ MG_EXPORT BOOL GUIAPI ServerUnregisterCompositor (const char* name); MG_EXPORT const CompositorOps* GUIAPI ServerSelectCompositor ( const char* name, CompositorCtxt** ctxt); -#define COMPSOR_OPS_VERSION 1 +/** + * \brief Get the name and the context of the current compositor. + * + * This function gets the name and the context of the current + * compositor. + * + * \param ops The buffer used to return the compositor operations. + * \param ctxt The buffer used to return the compositor context. + * + * \return The name of the current compositor; NULL for error. + * + * \note Only called by the server. + * + * Since 5.0.6. + */ +MG_EXPORT const char* GUIAPI ServerGetCurrentCompositor ( + const CompositorOps** ops, CompositorCtxt** ctxt); + +#define COMPSOR_OPS_VERSION 2 /** * Implement this stub to return the compositor operations diff --git a/src/kernel/compsor-manager.c b/src/kernel/compsor-manager.c index 2e704f0d..18c000dc 100644 --- a/src/kernel/compsor-manager.c +++ b/src/kernel/compsor-manager.c @@ -15,7 +15,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2020, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 2002~2021, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming * * This program is free software: you can redistribute it and/or modify @@ -489,7 +489,7 @@ const CompositorOps* GUIAPI ServerGetCompositorOps (const char* name) return NULL; for (i = 0; i < MAX_NR_COMPOSITORS; i++) { - if (strcmp (compositors [i].name, name) == 0) { + if (compositors [i].name && strcmp (compositors [i].name, name) == 0) { return compositors [i].ops; } } @@ -583,5 +583,24 @@ const CompositorOps* GUIAPI ServerSelectCompositor (const char* name, return NULL; } +const char* GUIAPI ServerGetCurrentCompositor ( + const CompositorOps** ops, CompositorCtxt** ctxt) +{ + int i; + const CompositorOps* the_ops; + + the_ops = ServerSelectCompositor (NULL, ctxt); + if (ops) { + *ops = the_ops; + } + + for (i = 0; i < MAX_NR_COMPOSITORS; i++) { + if (compositors [i].ops == the_ops) + return compositors [i].name; + } + + return NULL; +} + #endif /* defined(_MGRM_PROCESSES) && defined(_MGSCHEMA_COMPOSITING) */