From aefb5f4dd9d41aa7377d56ece203089c73aefe07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 1 Jul 2017 19:19:14 +0200 Subject: [PATCH 1/3] Prevent endless loop in checkGLError due to GL_CONTEXT_LOST Summary: The GL_CONTEXT_LOST flag is not reset when calling glGetError. This of course bites with: "Thus, glGetError should always be called in a loop, until it returns GL_NO_ERROR, if all error flags are to be reset." (see https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetError.xhtml) As KWin calls checkGLError from init call it can result in a freeze of KWin. This is a regression reported multiple times since the release of 5.10.3 which enabled GLX_NV_robustness_video_memory_purge extension. Please note that I am not able to test this change. I do not have an NVIDIA card and are not hiting the problem. I have no way to simulate the code. I do not know whether the change will fix the problem, it is based on what others do. Inspiration for this change is mostly from mutter: https://git.gnome.org/browse/mutter/commit/?id=d4d2bf0f6c1737256b921c4f1dedd3a95138cab9 BUG: 381870 FIXED-IN: 5.10.3.1 Test Plan: See above, I can only compile check the change Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6464 --- libkwineffects/kwinglutils.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index 8f7ce38ca0..11a8163ea3 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -128,11 +128,19 @@ static QString formatGLError(GLenum err) bool checkGLError(const char* txt) { GLenum err = glGetError(); + if (err == GL_CONTEXT_LOST) { + qCWarning(LIBKWINGLUTILS) << "GL error: context lost"; + return true; + } bool hasError = false; while (err != GL_NO_ERROR) { qCWarning(LIBKWINGLUTILS) << "GL error (" << txt << "): " << formatGLError(err); hasError = true; err = glGetError(); + if (err == GL_CONTEXT_LOST) { + qCWarning(LIBKWINGLUTILS) << "GL error: context lost"; + break; + } } return hasError; } From 24ff93854ddc78990bf111e7bab4bce58a75d0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 2 Jul 2017 14:26:53 +0200 Subject: [PATCH 2/3] [effects/slideback] Ignore windows which are not in visible area Summary: The PresentWindows effect does not hide the window to close the selected window. Instead it moves it outside the visible area. As this is a "special" KWin window it is on top of the stacking order and needs to be ignored in the slideback effect. Instead of doing a special casing for this window the effect is changed to ignore windows outside the visible area in general. Windows outside the visible area just don't make sense to block the slideback effect. BUG: 381402 FIXED-IN: 5.10.4 Test Plan: Slideback works after using Present Windows effect Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6468 --- effects/slideback/slideback.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/effects/slideback/slideback.cpp b/effects/slideback/slideback.cpp index e7313c0cbf..a3bbe2ed67 100644 --- a/effects/slideback/slideback.cpp +++ b/effects/slideback/slideback.cpp @@ -307,8 +307,11 @@ bool SlideBackEffect::intersects(EffectWindow* windowUnder, const QRect &windowO EffectWindowList SlideBackEffect::usableWindows(const EffectWindowList & allWindows) { EffectWindowList retList; + auto isWindowVisible = [] (const EffectWindow *window) { + return window && effects->virtualScreenGeometry().intersects(window->geometry()); + }; foreach (EffectWindow * tmp, allWindows) { - if (isWindowUsable(tmp)) { + if (isWindowUsable(tmp) && isWindowVisible(tmp)) { retList.append(tmp); } } From 4e9456a857234fe7884cae6aa1cec93093fdf525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 2 Jul 2017 13:31:24 +0200 Subject: [PATCH 3/3] [platforms/x11] Fix incorrect screen edge approaching with switch desktop on window move Summary: There is a regression in WindowBasedEdge::soStopApproaching. Due to only operate when the edge activates for pointer it is possible that the cursor polling stays active. Explaining the situation: 1. Activate switch desktop when moving window 2. Start moving a window 3. Move mouse into the approach geometry -> doStartApproaching activates as we are moving a window 4. stop moving window -> doStopApproaching early exits as the position does not activate for pointer any more - we are not moving a window -> cursor polling is still connected and whenever mouse enters edge approaching is started The analysis shows that the check whether activates for pointer is wrong in the case of stop approaching. If the edge started to approach, we also need to stop approaching. This change addresses the problem by turning the check into whether the connection for cursor position update is set. This is the third bug fix to the X11 screen edge handling after introducing touch screen edges. This needs more manual testing by everybody in the Plasma team who is still using X11. BUG: 381849 FIXED-IN: 5.10.4 Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6467 --- plugins/platforms/x11/standalone/edge.cpp | 12 +++++++----- plugins/platforms/x11/standalone/edge.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/platforms/x11/standalone/edge.cpp b/plugins/platforms/x11/standalone/edge.cpp index f4331fabc5..700d086849 100644 --- a/plugins/platforms/x11/standalone/edge.cpp +++ b/plugins/platforms/x11/standalone/edge.cpp @@ -110,18 +110,20 @@ void WindowBasedEdge::doStartApproaching() } m_approachWindow.unmap(); Cursor *cursor = Cursor::self(); - connect(cursor, SIGNAL(posChanged(QPoint)), SLOT(updateApproaching(QPoint))); +#ifndef KWIN_UNIT_TEST + m_cursorPollingConnection = connect(cursor, &Cursor::posChanged, this, &WindowBasedEdge::updateApproaching); +#endif cursor->startMousePolling(); } void WindowBasedEdge::doStopApproaching() { - if (!activatesForPointer()) { + if (!m_cursorPollingConnection) { return; } - Cursor *cursor = Cursor::self(); - disconnect(cursor, SIGNAL(posChanged(QPoint)), this, SLOT(updateApproaching(QPoint))); - cursor->stopMousePolling(); + disconnect(m_cursorPollingConnection); + m_cursorPollingConnection = QMetaObject::Connection(); + Cursor::self()->stopMousePolling(); m_approachWindow.map(); } diff --git a/plugins/platforms/x11/standalone/edge.h b/plugins/platforms/x11/standalone/edge.h index 980c8b3ae8..6934b7dcbd 100644 --- a/plugins/platforms/x11/standalone/edge.h +++ b/plugins/platforms/x11/standalone/edge.h @@ -61,6 +61,7 @@ private: void createApproachWindow(); Xcb::Window m_window; Xcb::Window m_approachWindow; + QMetaObject::Connection m_cursorPollingConnection; }; inline quint32 WindowBasedEdge::window() const