Added an API function to check if an overlay has keyboard focus

This commit is contained in:
ksuprynowicz 2023-08-27 22:06:03 +02:00
parent 3d4a993476
commit 025f530db6
2 changed files with 11 additions and 1 deletions

View file

@ -60,7 +60,9 @@ static const QVariantMap RELATIVE_POSITION_ANCHOR {
};
DesktopScriptingInterface::DesktopScriptingInterface(QObject* parent, bool restricted)
: QObject(parent), _restricted(restricted) { }
: QObject(parent), _restricted(restricted) {
connect(this, &DesktopScriptingInterface::uiFocusChanged, [this] (bool isActive) { _isOverlayWindowFocused = isActive; });
}
int DesktopScriptingInterface::getWidth() {
QSize size = qApp->getWindow()->windowHandle()->screen()->virtualSize();

View file

@ -104,6 +104,13 @@ public:
int getWidth();
int getHeight();
/*@jsdoc
* Checks whether the keyboard focus belongs to overlay UI window.
* @function Desktop.isOverlayWindowFocused
* @returns {boolean} <code>true</code> if the keyboard focus is on overlay UI window, <code>false</code> if not.
*/
Q_INVOKABLE bool isOverlayWindowFocused() { return _isOverlayWindowFocused; };
signals:
/*@jsdoc
@ -124,6 +131,7 @@ private:
static QVariantMap getRelativePositionAnchor();
Q_INVOKABLE static QVariantMap getPresentationMode();
const bool _restricted;
std::atomic<bool> _isOverlayWindowFocused { false };
};