mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-08-27 00:24:20 -04:00
Request activate on show
Unless the window doesn't have keyboard interactivity or the caller wants it not to. To match XDG Shell behavior and general Qt window behavior.
This commit is contained in:
@ -35,6 +35,7 @@ public:
|
||||
QSize desiredSize = QSize(0, 0);
|
||||
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
||||
bool closeOnDismissed = true;
|
||||
bool activateOnShow = true;
|
||||
};
|
||||
|
||||
static QMap<QWindow *, Window *> s_map;
|
||||
@ -170,6 +171,16 @@ void Window::setCloseOnDismissed(bool close)
|
||||
d->closeOnDismissed = close;
|
||||
}
|
||||
|
||||
bool Window::activateOnShow() const
|
||||
{
|
||||
return d->activateOnShow;
|
||||
}
|
||||
|
||||
void Window::setActivateOnShow(bool activateOnShow)
|
||||
{
|
||||
d->activateOnShow = activateOnShow;
|
||||
}
|
||||
|
||||
Window::Window(QWindow *window)
|
||||
: QObject(window)
|
||||
, d(new WindowPrivate(window))
|
||||
|
@ -28,6 +28,7 @@ class LAYERSHELLQT_EXPORT Window : public QObject
|
||||
Q_PROPERTY(Layer layer READ layer WRITE setLayer NOTIFY layerChanged)
|
||||
Q_PROPERTY(KeyboardInteractivity keyboardInteractivity READ keyboardInteractivity WRITE setKeyboardInteractivity NOTIFY keyboardInteractivityChanged)
|
||||
Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration)
|
||||
Q_PROPERTY(bool activateOnShow READ activateOnShow WRITE setActivateOnShow)
|
||||
|
||||
public:
|
||||
~Window() override;
|
||||
@ -117,6 +118,18 @@ public:
|
||||
void setCloseOnDismissed(bool close);
|
||||
bool closeOnDismissed() const;
|
||||
|
||||
/**
|
||||
* Whether the window should requestActivate on show.
|
||||
*
|
||||
* Normally, you want this enabled but in case of e.g. a desktop window, this can be disabled.
|
||||
*
|
||||
* It does nothing when KeyboardInteractivity is KeyboardInteractivityNone.
|
||||
*
|
||||
* The default is true.
|
||||
*/
|
||||
void setActivateOnShow(bool activateOnShow);
|
||||
bool activateOnShow() const;
|
||||
|
||||
/**
|
||||
* Gets the LayerShell Window for a given Qt Window
|
||||
* Ownership is not transferred
|
||||
|
@ -230,6 +230,23 @@ bool QWaylandLayerSurface::requestActivate()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QWaylandLayerSurface::requestActivateOnShow()
|
||||
{
|
||||
if (!m_interface->activateOnShow()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_interface->keyboardInteractivity() == Window::KeyboardInteractivityNone) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_window->window()->property("_q_showWithoutActivating").toBool()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return requestActivate();
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setXdgActivationToken(const QString &token)
|
||||
{
|
||||
m_activationToken = token;
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
#endif
|
||||
|
||||
bool requestActivate() override;
|
||||
bool requestActivateOnShow() override;
|
||||
void setXdgActivationToken(const QString &token) override;
|
||||
void requestXdgActivationToken(quint32 serial) override;
|
||||
|
||||
|
Reference in New Issue
Block a user