Git commit a65b2c062cb0c02497d593aa535150fd23b5651c by Martin Fl=C3=B6ser.
Committed on 12/08/2017 at 09:32.
Pushed by graesslin into branch 'master'.
Move event filtering for overlay window into an X11EventFilter
Summary:
The OverlayWindowX11 also inherits from X11EventFilter and performs
the filtering itself.
Test Plan: Compiles, not yet tested as I'm on Wayland
Reviewers: #kwin, #plasma
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D7197
M +0 -18 composite.cpp
M +0 -8 composite.h
M +0 -24 events.cpp
M +28 -0 plugins/platforms/x11/standalone/overlaywindow_x11.cpp
M +4 -1 plugins/platforms/x11/standalone/overlaywindow_x11.h
https://commits.kde.org/kwin/a65b2c062cb0c02497d593aa535150fd23b5651c
diff --git a/composite.cpp b/composite.cpp
index 4c848f04d..50791a87e 100644
--- a/composite.cpp
+++ b/composite.cpp
@@ -905,17 +905,6 @@ bool Compositor::checkForOverlayWindow(WId w) const
return w =3D=3D m_scene->overlayWindow()->window();
}
=
-WId Compositor::overlayWindow() const
-{
- if (!hasScene()) {
- return None;
- }
- if (!m_scene->overlayWindow()) {
- return None;
- }
- return m_scene->overlayWindow()->window();
-}
-
bool Compositor::isOverlayWindowVisible() const
{
if (!hasScene()) {
@@ -927,13 +916,6 @@ bool Compositor::isOverlayWindowVisible() const
return m_scene->overlayWindow()->isVisible();
}
=
-void Compositor::setOverlayWindowVisibility(bool visible)
-{
- if (hasScene() && m_scene->overlayWindow()) {
- m_scene->overlayWindow()->setVisibility(visible);
- }
-}
-
/*****************************************************
* Workspace
****************************************************/
diff --git a/composite.h b/composite.h
index a7aee5641..ccff306a9 100644
--- a/composite.h
+++ b/composite.h
@@ -78,18 +78,10 @@ public:
* Checks whether @p w is the Scene's overlay window.
**/
bool checkForOverlayWindow(WId w) const;
- /**
- * @returns The Scene's Overlay X Window.
- **/
- WId overlayWindow() const;
/**
* @returns Whether the Scene's Overlay X Window is visible.
**/
bool isOverlayWindowVisible() const;
- /**
- * Set's the Scene's Overlay X Window visibility to @p visible.
- **/
- void setOverlayWindowVisibility(bool visible);
=
Scene *scene() {
return m_scene;
diff --git a/events.cpp b/events.cpp
index 931c95c5a..d93214612 100644
--- a/events.cpp
+++ b/events.cpp
@@ -35,7 +35,6 @@ along with this program. If not, see .
#include "tabbox.h"
#endif
#include "group.h"
-#include "overlaywindow.h"
#include "rules.h"
#include "unmanaged.h"
#include "useractions.h"
@@ -506,29 +505,6 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
if (ScreenEdges::self()->isEntered(reinterpret_cast(e)))
return true;
break;
- case XCB_EXPOSE: {
- const auto *event =3D reinterpret_cast(e);
- if (compositing()
- && (event->window =3D=3D rootWindow() // root window nee=
ds repainting
- || (m_compositor->overlayWindow() !=3D XCB_WINDOW_NONE=
&& event->window =3D=3D m_compositor->overlayWindow()))) { // overlay need=
s repainting
- m_compositor->addRepaint(event->x, event->y, event->width, eve=
nt->height);
- }
- break;
- }
- case XCB_VISIBILITY_NOTIFY: {
- const auto *event =3D reinterpret_cast(e);
- if (compositing() && m_compositor->overlayWindow() !=3D XCB_WINDOW=
_NONE && event->window =3D=3D m_compositor->overlayWindow()) {
- bool was_visible =3D m_compositor->isOverlayWindowVisible();
- m_compositor->setOverlayWindowVisibility((event->state !=3D XC=
B_VISIBILITY_FULLY_OBSCURED));
- if (!was_visible && m_compositor->isOverlayWindowVisible()) {
- // hack for #154825
- m_compositor->addRepaintFull();
- QTimer::singleShot(2000, m_compositor, SLOT(addRepaintFull=
()));
- }
- m_compositor->scheduleRepaint();
- }
- break;
- }
default:
if (eventType =3D=3D Xcb::Extensions::self()->randrNotifyEvent() &=
& Xcb::Extensions::self()->isRandrAvailable()) {
auto *event =3D reinterpret_cast(e);
diff --git a/plugins/platforms/x11/standalone/overlaywindow_x11.cpp b/plugi=
ns/platforms/x11/standalone/overlaywindow_x11.cpp
index c1e4fe9da..5a787665f 100644
--- a/plugins/platforms/x11/standalone/overlaywindow_x11.cpp
+++ b/plugins/platforms/x11/standalone/overlaywindow_x11.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see .
#include "overlaywindow_x11.h"
=
#include "kwinglobals.h"
+#include "composite.h"
#include "screens.h"
#include "utils.h"
#include "xcbutils.h"
@@ -38,6 +39,7 @@ along with this program. If not, see .
namespace KWin {
OverlayWindowX11::OverlayWindowX11()
: OverlayWindow()
+ , X11EventFilter(QVector{XCB_EXPOSE, XCB_VISIBILITY_NOTIFY})
, m_visible(true)
, m_shown(false)
, m_window(XCB_WINDOW_NONE)
@@ -181,5 +183,31 @@ xcb_window_t OverlayWindowX11::window() const
return m_window;
}
=
+bool OverlayWindowX11::event(xcb_generic_event_t *event)
+{
+ const uint8_t eventType =3D event->response_type & ~0x80;
+ if (eventType =3D=3D XCB_EXPOSE) {
+ const auto *expose =3D reinterpret_cast(event=
);
+ if (expose->window =3D=3D rootWindow() // root window needs repa=
inting
+ || (m_window !=3D XCB_WINDOW_NONE && expose->window =3D=3D=
m_window)) { // overlay needs repainting
+ Compositor::self()->addRepaint(expose->x, expose->y, expose->w=
idth, expose->height);
+ }
+ } else if (eventType =3D=3D XCB_VISIBILITY_NOTIFY) {
+ const auto *visibility =3D reinterpret_cast(event);
+ if (m_window !=3D XCB_WINDOW_NONE && visibility->window =3D=3D m_w=
indow) {
+ bool was_visible =3D isVisible();
+ setVisibility((visibility->state !=3D XCB_VISIBILITY_FULLY_OBS=
CURED));
+ auto compositor =3D Compositor::self();
+ if (!was_visible && m_visible) {
+ // hack for #154825
+ compositor->addRepaintFull();
+ QTimer::singleShot(2000, compositor, &Compositor::addRepai=
ntFull);
+ }
+ compositor->scheduleRepaint();
+ }
+ }
+ return false;
+}
+
} // namespace KWin
=
diff --git a/plugins/platforms/x11/standalone/overlaywindow_x11.h b/plugins=
/platforms/x11/standalone/overlaywindow_x11.h
index 2cb562ae5..0ca5b143c 100644
--- a/plugins/platforms/x11/standalone/overlaywindow_x11.h
+++ b/plugins/platforms/x11/standalone/overlaywindow_x11.h
@@ -22,9 +22,10 @@ along with this program. If not, see .
#define KWIN_OVERLAYWINDOW_X11_H
=
#include "../../../../overlaywindow.h"
+#include "../../../../x11eventfilter.h"
=
namespace KWin {
-class KWIN_EXPORT OverlayWindowX11 : public OverlayWindow {
+class KWIN_EXPORT OverlayWindowX11 : public OverlayWindow, public X11Event=
Filter {
public:
OverlayWindowX11();
~OverlayWindowX11();
@@ -41,6 +42,8 @@ public:
xcb_window_t window() const override;
bool isVisible() const override;
void setVisibility(bool visible) override;
+
+ bool event(xcb_generic_event_t *event) override;
private:
void setNoneBackgroundPixmap(xcb_window_t window);
void setupInputShape(xcb_window_t window);