Commit 3c69b08e authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Fix up some AbstractClient dynamic_cast<>()s

Originally, they were to check whether the given window is managed.
parent aaa429ee
Pipeline #165126 passed with stage
in 19 minutes and 43 seconds
......@@ -66,42 +66,40 @@ void Deleted::discard()
delete this;
}
void Deleted::copyToDeleted(AbstractClient *c)
{
Q_ASSERT(dynamic_cast<Deleted *>(c) == nullptr);
AbstractClient::copyToDeleted(c);
m_frameMargins = c->frameMargins();
desk = c->desktop();
m_desktops = c->desktops();
activityList = c->activities();
contentsRect = QRect(c->clientPos(), c->clientSize());
m_layer = c->layer();
m_frame = c->frameId();
m_type = c->windowType();
m_windowRole = c->windowRole();
m_shade = c->isShade();
void Deleted::copyToDeleted(AbstractClient *window)
{
Q_ASSERT(!window->isDeleted());
AbstractClient::copyToDeleted(window);
m_frameMargins = window->frameMargins();
desk = window->desktop();
m_desktops = window->desktops();
activityList = window->activities();
contentsRect = QRect(window->clientPos(), window->clientSize());
m_layer = window->layer();
m_frame = window->frameId();
m_type = window->windowType();
m_windowRole = window->windowRole();
m_shade = window->isShade();
if (WinInfo *cinfo = dynamic_cast<WinInfo *>(info)) {
cinfo->disable();
}
if (AbstractClient *client = dynamic_cast<AbstractClient *>(c)) {
if (client->isDecorated()) {
client->layoutDecorationRects(decoration_left,
decoration_top,
decoration_right,
decoration_bottom);
}
m_wasClient = true;
m_minimized = client->isMinimized();
m_modal = client->isModal();
m_mainClients = client->mainClients();
for (AbstractClient *c : qAsConst(m_mainClients)) {
connect(c, &AbstractClient::windowClosed, this, &Deleted::mainClientClosed);
}
m_fullscreen = client->isFullScreen();
m_keepAbove = client->keepAbove();
m_keepBelow = client->keepBelow();
m_caption = client->caption();
if (window->isDecorated()) {
window->layoutDecorationRects(decoration_left,
decoration_top,
decoration_right,
decoration_bottom);
}
m_wasClient = true;
m_minimized = window->isMinimized();
m_modal = window->isModal();
m_mainClients = window->mainClients();
for (AbstractClient *c : qAsConst(m_mainClients)) {
connect(c, &AbstractClient::windowClosed, this, &Deleted::mainClientClosed);
}
m_fullscreen = window->isFullScreen();
m_keepAbove = window->keepAbove();
m_keepBelow = window->keepBelow();
m_caption = window->caption();
for (auto vd : qAsConst(m_desktops)) {
connect(vd, &QObject::destroyed, this, [=] {
......@@ -109,9 +107,9 @@ void Deleted::copyToDeleted(AbstractClient *c)
});
}
m_wasPopupWindow = c->isPopupWindow();
m_wasOutline = c->isOutline();
m_wasLockScreen = c->isLockScreen();
m_wasPopupWindow = window->isPopupWindow();
m_wasOutline = window->isOutline();
m_wasLockScreen = window->isLockScreen();
}
void Deleted::unrefWindow()
......@@ -171,11 +169,9 @@ NET::WindowType Deleted::windowType(bool direct, int supportedTypes) const
return m_type;
}
void Deleted::mainClientClosed(AbstractClient *client)
void Deleted::mainClientClosed(AbstractClient *window)
{
if (AbstractClient *c = dynamic_cast<AbstractClient *>(client)) {
m_mainClients.removeAll(c);
}
m_mainClients.removeAll(window);
}
xcb_window_t Deleted::frameId() const
......
......@@ -1714,8 +1714,8 @@ public:
if (event->type() != QEvent::MouseButtonPress) {
return false;
}
AbstractClient *c = dynamic_cast<AbstractClient *>(input()->pointer()->focus());
if (!c) {
AbstractClient *c = input()->pointer()->focus();
if (!c || !c->isClient()) {
return false;
}
const auto actionResult = performClientMouseAction(event, c, MouseAction::ModifierAndWindow);
......@@ -1730,8 +1730,8 @@ public:
// only actions on vertical scroll
return false;
}
AbstractClient *c = dynamic_cast<AbstractClient *>(input()->pointer()->focus());
if (!c) {
AbstractClient *c = input()->pointer()->focus();
if (!c || !c->isClient()) {
return false;
}
const auto actionResult = performClientWheelAction(event, c, MouseAction::ModifierAndWindow);
......@@ -1748,8 +1748,8 @@ public:
if (seat->isTouchSequence()) {
return false;
}
AbstractClient *c = dynamic_cast<AbstractClient *>(input()->touch()->focus());
if (!c) {
AbstractClient *c = input()->touch()->focus();
if (!c || !c->isClient()) {
return false;
}
bool wasAction = false;
......@@ -1764,8 +1764,8 @@ public:
if (event->type() != QEvent::TabletPress) {
return false;
}
AbstractClient *c = dynamic_cast<AbstractClient *>(input()->tablet()->focus());
if (!c) {
AbstractClient *c = input()->tablet()->focus();
if (!c || !c->isClient()) {
return false;
}
bool wasAction = false;
......@@ -3116,8 +3116,8 @@ AbstractClient *InputRedirection::findManagedToplevel(const QPoint &pos)
// a deleted window doesn't get mouse events
continue;
}
if (AbstractClient *c = dynamic_cast<AbstractClient *>(t)) {
if (!c->isOnCurrentActivity() || !c->isOnCurrentDesktop() || c->isMinimized() || c->isHiddenInternal()) {
if (t->isClient()) {
if (!t->isOnCurrentActivity() || !t->isOnCurrentDesktop() || t->isMinimized() || t->isHiddenInternal()) {
continue;
}
}
......
......@@ -237,8 +237,7 @@ SurfaceItem *Scene::scanoutCandidate() const
Window *window = stacking_order[i];
AbstractClient *toplevel = window->window();
if (toplevel->isOnOutput(painted_screen) && window->isVisible() && toplevel->opacity() > 0) {
AbstractClient *c = dynamic_cast<AbstractClient *>(toplevel);
if (!c || !c->isFullScreen() || c->opacity() != 1.0) {
if (!toplevel->isClient() || !toplevel->isFullScreen() || toplevel->opacity() != 1.0) {
break;
}
if (!window->surfaceItem()) {
......@@ -373,8 +372,7 @@ void Scene::preparePaintSimpleScreen()
data.opaque = surfaceItem->mapToGlobal(surfaceItem->opaque());
}
const AbstractClient *client = dynamic_cast<const AbstractClient *>(toplevel);
if (client && !client->decorationHasAlpha()) {
if (toplevel->isClient() && !toplevel->decorationHasAlpha()) {
data.opaque |= sceneWindow->decorationShape().translated(sceneWindow->pos());
}
}
......@@ -789,8 +787,8 @@ bool Scene::Window::isVisible() const
if (!toplevel->isOnCurrentActivity()) {
return false;
}
if (AbstractClient *c = dynamic_cast<AbstractClient *>(toplevel)) {
return c->isShown();
if (toplevel->isClient()) {
return toplevel->isShown();
}
return true; // Unmanaged is always visible
}
......@@ -818,11 +816,11 @@ void Scene::Window::resetPaintingEnabled()
if (!toplevel->isOnCurrentActivity()) {
disable_painting |= PAINT_DISABLED_BY_ACTIVITY;
}
if (AbstractClient *c = dynamic_cast<AbstractClient *>(toplevel)) {
if (c->isMinimized()) {
if (toplevel->isClient()) {
if (toplevel->isMinimized()) {
disable_painting |= PAINT_DISABLED_BY_MINIMIZE;
}
if (c->isHiddenInternal()) {
if (toplevel->isHiddenInternal()) {
disable_painting |= PAINT_DISABLED;
}
}
......
Supports Markdown
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