Move window hiding logic to Window
The window hiding logic is mostly the same both in X11 and Wayland windows, so let's move it in Window to share the same code.
This commit is contained in:
parent
47a9504d40
commit
b90ae2f8fc
21 changed files with 65 additions and 139 deletions
|
@ -754,7 +754,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfHiddenWaylandPanel()
|
|||
QTEST(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false).toPoint(), "expectedAdjustedPoint");
|
||||
|
||||
// now let's hide the panel
|
||||
panel->hideClient();
|
||||
panel->setHidden(true);
|
||||
|
||||
// now try to snap again
|
||||
QCOMPARE(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false), targetPoint);
|
||||
|
|
|
@ -118,7 +118,6 @@ void WindowRuleTest::testApplyInitialMaximizeVert()
|
|||
QVERIFY(window);
|
||||
QVERIFY(window->isDecorated());
|
||||
QVERIFY(!window->hasStrut());
|
||||
QVERIFY(!window->isHiddenInternal());
|
||||
QVERIFY(!window->readyForPainting());
|
||||
QMetaObject::invokeMethod(window, "setReadyForPainting");
|
||||
QVERIFY(window->readyForPainting());
|
||||
|
@ -181,7 +180,6 @@ void WindowRuleTest::testWindowClassChange()
|
|||
QVERIFY(window);
|
||||
QVERIFY(window->isDecorated());
|
||||
QVERIFY(!window->hasStrut());
|
||||
QVERIFY(!window->isHiddenInternal());
|
||||
QVERIFY(!window->readyForPainting());
|
||||
QMetaObject::invokeMethod(window, "setReadyForPainting");
|
||||
QVERIFY(window->readyForPainting());
|
||||
|
|
|
@ -618,14 +618,14 @@ void TestXdgShellWindow::testHidden()
|
|||
QVERIFY(window->wantsTabFocus());
|
||||
QVERIFY(window->isShown());
|
||||
|
||||
window->hideClient();
|
||||
window->setHidden(true);
|
||||
QVERIFY(!window->isShown());
|
||||
QVERIFY(!window->isActive());
|
||||
QVERIFY(window->wantsInput());
|
||||
QVERIFY(window->wantsTabFocus());
|
||||
|
||||
// unhide again
|
||||
window->showClient();
|
||||
window->setHidden(false);
|
||||
QVERIFY(window->isShown());
|
||||
QVERIFY(window->wantsInput());
|
||||
QVERIFY(window->wantsTabFocus());
|
||||
|
|
|
@ -153,7 +153,6 @@ void XWaylandInputTest::testPointerEnterLeaveSsd()
|
|||
QVERIFY(window);
|
||||
QVERIFY(window->isDecorated());
|
||||
QVERIFY(!window->hasStrut());
|
||||
QVERIFY(!window->isHiddenInternal());
|
||||
QVERIFY(!window->readyForPainting());
|
||||
|
||||
QMetaObject::invokeMethod(window, "setReadyForPainting");
|
||||
|
|
|
@ -323,7 +323,7 @@ void Workspace::activateWindow(Window *window, bool force)
|
|||
}
|
||||
|
||||
// ensure the window is really visible - could eg. be a hidden utility window, see bug #348083
|
||||
window->showClient();
|
||||
window->setHidden(false);
|
||||
|
||||
// TODO force should perhaps allow this only if the window already contains the mouse
|
||||
if (options->focusPolicyIsReasonable() || force) {
|
||||
|
|
|
@ -1953,7 +1953,7 @@ WINDOW_HELPER(bool, isLockScreen, isLockScreen)
|
|||
WINDOW_HELPER(pid_t, pid, pid)
|
||||
WINDOW_HELPER(QUuid, internalId, internalId)
|
||||
WINDOW_HELPER(bool, isMinimized, isMinimized)
|
||||
WINDOW_HELPER(bool, isHidden, isHiddenInternal)
|
||||
WINDOW_HELPER(bool, isHidden, isHidden)
|
||||
WINDOW_HELPER(bool, isHiddenByShowDesktop, isHiddenByShowDesktop)
|
||||
WINDOW_HELPER(bool, isModal, isModal)
|
||||
WINDOW_HELPER(bool, isFullScreen, isFullScreen)
|
||||
|
|
|
@ -987,7 +987,7 @@ bool X11Window::buttonPressEvent(xcb_window_t w, int button, int state, int x, i
|
|||
if (isSplash()
|
||||
&& button == XCB_BUTTON_INDEX_1 && !bModKeyHeld) {
|
||||
// hide splashwindow if the user clicks on it
|
||||
hideClient();
|
||||
setHidden(true);
|
||||
if (w == wrapperId()) {
|
||||
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
|
||||
}
|
||||
|
|
|
@ -2563,7 +2563,7 @@ private:
|
|||
if (!window->isClient()) {
|
||||
continue;
|
||||
}
|
||||
if (!window->isOnCurrentActivity() || !window->isOnCurrentDesktop() || window->isMinimized() || window->isHiddenInternal() || window->isHiddenByShowDesktop()) {
|
||||
if (!window->isOnCurrentActivity() || !window->isOnCurrentDesktop() || window->isMinimized() || window->isHidden() || window->isHiddenByShowDesktop()) {
|
||||
continue;
|
||||
}
|
||||
if (!window->readyForPainting()) {
|
||||
|
@ -3203,7 +3203,7 @@ Window *InputRedirection::findToplevel(const QPointF &pos)
|
|||
// a deleted window doesn't get mouse events
|
||||
continue;
|
||||
}
|
||||
if (!window->isOnCurrentActivity() || !window->isOnCurrentDesktop() || window->isMinimized() || window->isHiddenInternal() || window->isHiddenByShowDesktop()) {
|
||||
if (!window->isOnCurrentActivity() || !window->isOnCurrentDesktop() || window->isMinimized() || window->isHidden() || window->isHiddenByShowDesktop()) {
|
||||
continue;
|
||||
}
|
||||
if (!window->readyForPainting()) {
|
||||
|
|
|
@ -74,7 +74,7 @@ void InputPanelV1Window::hide()
|
|||
{
|
||||
m_virtualKeyboardShouldBeShown = false;
|
||||
if (readyForPainting() && m_mode != Mode::Overlay) {
|
||||
hideClient();
|
||||
setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ void InputPanelV1Window::maybeShow()
|
|||
if (shouldShow && !isDeleted() && surface()->isMapped()) {
|
||||
markAsMapped();
|
||||
reposition();
|
||||
showClient();
|
||||
setHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -242,24 +242,6 @@ bool InternalWindow::isOutline() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool InternalWindow::isShown() const
|
||||
{
|
||||
return readyForPainting() && !isHiddenByShowDesktop();
|
||||
}
|
||||
|
||||
bool InternalWindow::isHiddenInternal() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void InternalWindow::hideClient()
|
||||
{
|
||||
}
|
||||
|
||||
void InternalWindow::showClient()
|
||||
{
|
||||
}
|
||||
|
||||
QRectF InternalWindow::resizeWithChecks(const QRectF &geometry, const QSizeF &size)
|
||||
{
|
||||
if (!m_handle) {
|
||||
|
|
|
@ -47,10 +47,6 @@ public:
|
|||
bool isInternal() const override;
|
||||
bool isLockScreen() const override;
|
||||
bool isOutline() const override;
|
||||
bool isShown() const override;
|
||||
bool isHiddenInternal() const override;
|
||||
void hideClient() override;
|
||||
void showClient() override;
|
||||
QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &size) override;
|
||||
Window *findModal(bool allow_itself = false) override;
|
||||
bool takeFocus() override;
|
||||
|
|
|
@ -297,7 +297,7 @@ void LayerShellV1Window::setVirtualKeyboardGeometry(const QRectF &geo)
|
|||
|
||||
void LayerShellV1Window::showOnScreenEdge()
|
||||
{
|
||||
// ShowOnScreenEdge can be called by an Edge, and hideClient could destroy the Edge
|
||||
// ShowOnScreenEdge can be called by an Edge, and setHidden could destroy the Edge
|
||||
// Use the singleshot to avoid use-after-free
|
||||
QTimer::singleShot(0, this, &LayerShellV1Window::deactivateScreenEdge);
|
||||
}
|
||||
|
@ -323,15 +323,15 @@ void LayerShellV1Window::installAutoHideScreenEdgeV1(KWaylandServer::AutoHideScr
|
|||
void LayerShellV1Window::reserveScreenEdge()
|
||||
{
|
||||
if (workspace()->screenEdges()->reserve(this, m_screenEdge->border())) {
|
||||
hideClient();
|
||||
setHidden(true);
|
||||
} else {
|
||||
showClient();
|
||||
setHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
void LayerShellV1Window::unreserveScreenEdge()
|
||||
{
|
||||
showClient();
|
||||
setHidden(false);
|
||||
workspace()->screenEdges()->reserve(this, ElectricNone);
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ bool WindowItem::computeVisibility() const
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (m_window->isHiddenInternal() || m_window->isHiddenByShowDesktop()) {
|
||||
if (m_window->isHidden() || m_window->isHiddenByShowDesktop()) {
|
||||
if (m_forceVisibleByHiddenCount == 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ QList<KWin::Window *> WorkspaceWrapper::windowAt(const QPointF &pos, int count)
|
|||
if (window->isDeleted()) {
|
||||
continue;
|
||||
}
|
||||
if (!window->isOnCurrentActivity() || !window->isOnCurrentDesktop() || window->isMinimized() || window->isHiddenInternal() || window->isHiddenByShowDesktop()) {
|
||||
if (!window->isOnCurrentActivity() || !window->isOnCurrentDesktop() || window->isMinimized() || window->isHidden() || window->isHiddenByShowDesktop()) {
|
||||
continue;
|
||||
}
|
||||
if (window->hitTest(pos)) {
|
||||
|
|
|
@ -238,43 +238,6 @@ void WaylandWindow::cleanGrouping()
|
|||
}
|
||||
}
|
||||
|
||||
bool WaylandWindow::isShown() const
|
||||
{
|
||||
return !isDeleted() && !isHidden() && !isHiddenByShowDesktop() && !isMinimized();
|
||||
}
|
||||
|
||||
bool WaylandWindow::isHiddenInternal() const
|
||||
{
|
||||
return isHidden();
|
||||
}
|
||||
|
||||
bool WaylandWindow::isHidden() const
|
||||
{
|
||||
return m_isHidden;
|
||||
}
|
||||
|
||||
void WaylandWindow::showClient()
|
||||
{
|
||||
if (!isHidden()) {
|
||||
return;
|
||||
}
|
||||
m_isHidden = false;
|
||||
Q_EMIT windowShown(this);
|
||||
}
|
||||
|
||||
void WaylandWindow::hideClient()
|
||||
{
|
||||
if (isHidden()) {
|
||||
return;
|
||||
}
|
||||
if (isInteractiveMoveResize()) {
|
||||
leaveInteractiveMoveResize();
|
||||
}
|
||||
m_isHidden = true;
|
||||
workspace()->windowHidden(this);
|
||||
Q_EMIT windowHidden(this);
|
||||
}
|
||||
|
||||
QRectF WaylandWindow::frameRectToBufferRect(const QRectF &rect) const
|
||||
{
|
||||
return QRectF(rect.topLeft(), surface()->size());
|
||||
|
|
|
@ -28,13 +28,8 @@ public:
|
|||
QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &size) override;
|
||||
void killWindow() override;
|
||||
QString windowRole() const override;
|
||||
bool isShown() const override;
|
||||
bool isHiddenInternal() const override;
|
||||
void hideClient() override;
|
||||
void showClient() override;
|
||||
|
||||
virtual QRectF frameRectToBufferRect(const QRectF &rect) const;
|
||||
bool isHidden() const;
|
||||
|
||||
void setCaption(const QString &caption);
|
||||
|
||||
|
@ -56,7 +51,6 @@ private:
|
|||
|
||||
QString m_captionNormal;
|
||||
QString m_captionSuffix;
|
||||
bool m_isHidden = false;
|
||||
bool m_isScreenLocker = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -3566,6 +3566,10 @@ void Window::doSetQuickTileMode()
|
|||
{
|
||||
}
|
||||
|
||||
void Window::doSetHidden()
|
||||
{
|
||||
}
|
||||
|
||||
void Window::doSetHiddenByShowDesktop()
|
||||
{
|
||||
}
|
||||
|
@ -4213,6 +4217,31 @@ WindowOffscreenRenderRef::~WindowOffscreenRenderRef()
|
|||
}
|
||||
}
|
||||
|
||||
bool Window::isShown() const
|
||||
{
|
||||
return !isDeleted() && !isHidden() && !isHiddenByShowDesktop() && !isMinimized();
|
||||
}
|
||||
|
||||
bool Window::isHidden() const
|
||||
{
|
||||
return m_hidden;
|
||||
}
|
||||
|
||||
void Window::setHidden(bool hidden)
|
||||
{
|
||||
if (m_hidden == hidden) {
|
||||
return;
|
||||
}
|
||||
m_hidden = hidden;
|
||||
doSetHidden();
|
||||
if (hidden) {
|
||||
workspace()->windowHidden(this);
|
||||
Q_EMIT windowHidden(this);
|
||||
} else {
|
||||
Q_EMIT windowShown(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::isHiddenByShowDesktop() const
|
||||
{
|
||||
return m_hiddenByShowDesktop;
|
||||
|
|
11
src/window.h
11
src/window.h
|
@ -530,7 +530,7 @@ class KWIN_EXPORT Window : public QObject
|
|||
/**
|
||||
* Whether this window is hidden. It's usually the case with auto-hide panels.
|
||||
*/
|
||||
Q_PROPERTY(bool hidden READ isHiddenInternal NOTIFY hiddenChanged)
|
||||
Q_PROPERTY(bool hidden READ isHidden NOTIFY hiddenChanged)
|
||||
|
||||
/**
|
||||
* The Tile this window is associated to, if any
|
||||
|
@ -932,10 +932,9 @@ public:
|
|||
virtual QString captionSuffix() const = 0;
|
||||
virtual bool isPlaceable() const;
|
||||
virtual bool isCloseable() const = 0;
|
||||
virtual bool isShown() const = 0;
|
||||
virtual bool isHiddenInternal() const = 0;
|
||||
virtual void hideClient() = 0;
|
||||
virtual void showClient() = 0;
|
||||
bool isShown() const;
|
||||
bool isHidden() const;
|
||||
void setHidden(bool hidden);
|
||||
bool isHiddenByShowDesktop() const;
|
||||
void setHiddenByShowDesktop(bool hidden);
|
||||
// TODO: remove boolean trap
|
||||
|
@ -1501,6 +1500,7 @@ protected:
|
|||
virtual void doSetSkipSwitcher();
|
||||
virtual void doSetDemandsAttention();
|
||||
virtual void doSetQuickTileMode();
|
||||
virtual void doSetHidden();
|
||||
virtual void doSetHiddenByShowDesktop();
|
||||
|
||||
void setupWindowManagementInterface();
|
||||
|
@ -1723,6 +1723,7 @@ protected:
|
|||
QRectF m_clientGeometry;
|
||||
QRectF m_bufferGeometry;
|
||||
bool ready_for_painting;
|
||||
bool m_hidden = false;
|
||||
bool m_hiddenByShowDesktop = false;
|
||||
|
||||
int m_refCount = 1;
|
||||
|
|
|
@ -860,7 +860,7 @@ void Workspace::updateToolWindows(bool also_hide)
|
|||
if (!options->isHideUtilityWindowsForInactive()) {
|
||||
for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) {
|
||||
if (X11Window *x11Window = qobject_cast<X11Window *>(*it)) {
|
||||
x11Window->showClient();
|
||||
x11Window->setHidden(false);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -931,11 +931,11 @@ void Workspace::updateToolWindows(bool also_hide)
|
|||
} // First show new ones, then hide
|
||||
for (int i = to_show.size() - 1; i >= 0; --i) { // From topmost
|
||||
// TODO: Since this is in stacking order, the order of taskbar entries changes :(
|
||||
to_show.at(i)->showClient();
|
||||
to_show.at(i)->setHidden(false);
|
||||
}
|
||||
if (also_hide) {
|
||||
for (auto it = to_hide.constBegin(); it != to_hide.constEnd(); ++it) { // From bottommost
|
||||
(*it)->hideClient();
|
||||
(*it)->setHidden(true);
|
||||
}
|
||||
updateToolWindowsTimer.stop();
|
||||
} else { // setActiveWindow() is after called with NULL window, quickly followed
|
||||
|
|
|
@ -315,7 +315,6 @@ X11Window::X11Window()
|
|||
info = nullptr;
|
||||
|
||||
m_fullscreenMode = FullScreenNone;
|
||||
hidden = false;
|
||||
noborder = false;
|
||||
app_noborder = false;
|
||||
ignore_focus_stealing = false;
|
||||
|
@ -424,7 +423,6 @@ void X11Window::releaseWindow(bool on_shutdown)
|
|||
grabXServer();
|
||||
exportMappingState(XCB_ICCCM_WM_STATE_WITHDRAWN);
|
||||
setModal(false); // Otherwise its mainwindow wouldn't get focus
|
||||
hidden = true; // So that it's not considered visible anymore (can't use hideClient(), it would set flags)
|
||||
if (!on_shutdown) {
|
||||
workspace()->windowHidden(this);
|
||||
}
|
||||
|
@ -495,7 +493,6 @@ void X11Window::destroyWindow()
|
|||
finishWindowRules();
|
||||
blockGeometryUpdates();
|
||||
setModal(false);
|
||||
hidden = true; // So that it's not considered visible anymore
|
||||
workspace()->windowHidden(this);
|
||||
cleanGrouping();
|
||||
workspace()->removeX11Window(this);
|
||||
|
@ -1610,27 +1607,6 @@ void X11Window::updateInputShape()
|
|||
}
|
||||
}
|
||||
|
||||
void X11Window::hideClient()
|
||||
{
|
||||
if (hidden) {
|
||||
return;
|
||||
}
|
||||
hidden = true;
|
||||
updateVisibility();
|
||||
workspace()->windowHidden(this);
|
||||
Q_EMIT windowHidden(this);
|
||||
}
|
||||
|
||||
void X11Window::showClient()
|
||||
{
|
||||
if (!hidden) {
|
||||
return;
|
||||
}
|
||||
hidden = false;
|
||||
updateVisibility();
|
||||
Q_EMIT windowShown(this);
|
||||
}
|
||||
|
||||
bool X11Window::setupCompositing()
|
||||
{
|
||||
if (!Window::setupCompositing()) {
|
||||
|
@ -1805,7 +1781,7 @@ void X11Window::updateVisibility()
|
|||
if (isUnmanaged() || isDeleted()) {
|
||||
return;
|
||||
}
|
||||
if (hidden) {
|
||||
if (isHidden()) {
|
||||
info->setState(NET::Hidden, NET::Hidden);
|
||||
setSkipTaskbar(true); // Also hide from taskbar
|
||||
if (Compositor::compositing() && options->hiddenPreviews() == HiddenPreviewsAlways) {
|
||||
|
@ -2187,6 +2163,11 @@ void X11Window::doSetDemandsAttention()
|
|||
info->setState(isDemandingAttention() ? NET::DemandsAttention : NET::States(), NET::DemandsAttention);
|
||||
}
|
||||
|
||||
void X11Window::doSetHidden()
|
||||
{
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
void X11Window::doSetHiddenByShowDesktop()
|
||||
{
|
||||
updateVisibility();
|
||||
|
@ -2911,9 +2892,9 @@ void X11Window::readShowOnScreenEdge(Xcb::Property &property)
|
|||
|
||||
auto reserveScreenEdge = [this, border]() {
|
||||
if (workspace()->screenEdges()->reserve(this, border)) {
|
||||
hideClient();
|
||||
setHidden(true);
|
||||
} else {
|
||||
showClient();
|
||||
setHidden(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2927,7 +2908,7 @@ void X11Window::readShowOnScreenEdge(Xcb::Property &property)
|
|||
// restore
|
||||
disconnect(m_edgeGeometryTrackingConnection);
|
||||
|
||||
showClient();
|
||||
setHidden(false);
|
||||
|
||||
workspace()->screenEdges()->reserve(this, ElectricNone);
|
||||
}
|
||||
|
@ -2941,7 +2922,7 @@ void X11Window::updateShowOnScreenEdge()
|
|||
|
||||
void X11Window::showOnScreenEdge()
|
||||
{
|
||||
showClient();
|
||||
setHidden(false);
|
||||
xcb_delete_property(kwinApp()->x11Connection(), window(), atoms->kde_screen_edge_show);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,10 +143,6 @@ public:
|
|||
void doSetOnActivities(const QStringList &newActivitiesList) override;
|
||||
void updateActivities(bool includeTransients) override;
|
||||
|
||||
/// Is not minimized and not hidden. I.e. normally visible on some virtual desktop.
|
||||
bool isShown() const override;
|
||||
bool isHiddenInternal() const override; // For compositing
|
||||
|
||||
bool isShadeable() const override;
|
||||
bool isMaximizable() const override;
|
||||
MaximizeMode maximizeMode() const override;
|
||||
|
@ -200,9 +196,6 @@ public:
|
|||
|
||||
/// Updates visibility depending on being shaded, virtual desktop, etc.
|
||||
void updateVisibility();
|
||||
/// Hides a client - Basically like minimize, but without effects, it's simply hidden
|
||||
void hideClient() override;
|
||||
void showClient() override;
|
||||
bool hiddenPreview() const; ///< Window is mapped in order to get a window pixmap
|
||||
|
||||
bool setupCompositing() override;
|
||||
|
@ -343,6 +336,7 @@ protected:
|
|||
void doSetSkipTaskbar() override;
|
||||
void doSetSkipSwitcher() override;
|
||||
void doSetDemandsAttention() override;
|
||||
void doSetHidden() override;
|
||||
void doSetHiddenByShowDesktop() override;
|
||||
bool belongsToDesktop() const override;
|
||||
bool doStartInteractiveMoveResize() override;
|
||||
|
@ -479,7 +473,6 @@ private:
|
|||
xcb_window_t m_originalTransientForId;
|
||||
X11Window *shade_below;
|
||||
Xcb::MotifHints m_motif;
|
||||
uint hidden : 1; ///< Forcibly hidden by calling hide()
|
||||
uint noborder : 1;
|
||||
uint app_noborder : 1; ///< App requested no border via window type, shape extension, etc.
|
||||
uint ignore_focus_stealing : 1; ///< Don't apply focus stealing prevention to this client
|
||||
|
@ -585,16 +578,6 @@ inline Group *X11Window::group()
|
|||
return in_group;
|
||||
}
|
||||
|
||||
inline bool X11Window::isShown() const
|
||||
{
|
||||
return !isMinimized() && !hidden && !isHiddenByShowDesktop();
|
||||
}
|
||||
|
||||
inline bool X11Window::isHiddenInternal() const
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
inline MaximizeMode X11Window::maximizeMode() const
|
||||
{
|
||||
return max_mode;
|
||||
|
|
Loading…
Reference in a new issue