Commit e79bf9e1 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

static_cast QPlatformSurfaceEvent instead of dynamic_cast

We check for QEvent::PlatformSurface so we can assume this is what we get.

Differential Revision: https://phabricator.kde.org/D8005
parent 129884c7
......@@ -222,9 +222,7 @@ bool View::event(QEvent *event)
const bool retval = Dialog::event(event);
bool setState = event->type() == QEvent::Show;
if (event->type() == QEvent::PlatformSurface) {
if (auto e = dynamic_cast<QPlatformSurfaceEvent*>(event)) {
setState = e->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated;
}
setState = (static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated);
}
if (setState) {
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
......
......@@ -224,17 +224,15 @@ void KSMShutdownDlg::resizeEvent(QResizeEvent *e)
bool KSMShutdownDlg::event(QEvent *e)
{
if (e->type() == QEvent::PlatformSurface) {
if (auto pe = dynamic_cast<QPlatformSurfaceEvent*>(e)) {
switch (pe->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
KWindowEffects::enableBlurBehind(winId(), true);
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
break;
}
switch (static_cast<QPlatformSurfaceEvent*>(e)->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
KWindowEffects::enableBlurBehind(winId(), true);
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
break;
}
}
return QQuickView::event(e);
......
......@@ -130,17 +130,15 @@ void KSMSwitchUserDialog::init()
bool KSMSwitchUserDialog::event(QEvent *e)
{
if (e->type() == QEvent::PlatformSurface) {
if (auto pe = dynamic_cast<QPlatformSurfaceEvent*>(e)) {
switch (pe->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
KWindowEffects::enableBlurBehind(winId(), true);
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
break;
}
switch (static_cast<QPlatformSurfaceEvent*>(e)->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
KWindowEffects::enableBlurBehind(winId(), true);
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
break;
}
}
return QQuickView::event(e);
......
......@@ -198,17 +198,15 @@ DesktopView::SessionType DesktopView::sessionType() const
bool DesktopView::event(QEvent *e)
{
if (e->type() == QEvent::PlatformSurface) {
if (auto pe = dynamic_cast<QPlatformSurfaceEvent*>(e)) {
switch (pe->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
ensureWindowType();
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
break;
}
switch (static_cast<QPlatformSurfaceEvent*>(e)->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
ensureWindowType();
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
break;
}
}
......
......@@ -236,31 +236,29 @@ void PanelConfigView::moveEvent(QMoveEvent *ev)
bool PanelConfigView::event(QEvent *e)
{
if (e->type() == QEvent::PlatformSurface) {
if (auto pe = dynamic_cast<QPlatformSurfaceEvent*>(e)) {
switch (pe->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
if (m_shellSurface) {
switch (static_cast<QPlatformSurfaceEvent*>(e)->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
if (m_shellSurface) {
break;
}
if (ShellCorona *c = qobject_cast<ShellCorona *>(m_containment->corona())) {
using namespace KWayland::Client;
PlasmaShell *interface = c->waylandPlasmaShellInterface();
if (!interface) {
break;
}
if (ShellCorona *c = qobject_cast<ShellCorona *>(m_containment->corona())) {
using namespace KWayland::Client;
PlasmaShell *interface = c->waylandPlasmaShellInterface();
if (!interface) {
break;
}
Surface *s = Surface::fromWindow(this);
if (!s) {
break;
}
m_shellSurface = interface->createSurface(s, this);
Surface *s = Surface::fromWindow(this);
if (!s) {
break;
}
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
PanelShadows::self()->removeWindow(this);
break;
m_shellSurface = interface->createSurface(s, this);
}
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
PanelShadows::self()->removeWindow(this);
break;
}
}
......
......@@ -899,18 +899,16 @@ bool PanelView::event(QEvent *e)
break;
}
case QEvent::PlatformSurface:
if (auto pe = dynamic_cast<QPlatformSurfaceEvent*>(e)) {
switch (pe->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
PanelShadows::self()->addWindow(this, enabledBorders());
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
PanelShadows::self()->removeWindow(this);
break;
}
switch (static_cast<QPlatformSurfaceEvent*>(e)->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
setupWaylandIntegration();
PanelShadows::self()->addWindow(this, enabledBorders());
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_shellSurface;
m_shellSurface = nullptr;
PanelShadows::self()->removeWindow(this);
break;
}
break;
default:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment