Commit 08528492 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Introduce a property to indicate if client is placeable

The new property indicates if the client can be placed. It can be used
by input-panel or layer-shell clients to opt out from window placement.
parent 578d34db
......@@ -3087,6 +3087,9 @@ void AbstractClient::sendToScreen(int newScreen)
void AbstractClient::checkWorkspacePosition(QRect oldGeometry, int oldDesktop, QRect oldClientGeometry)
{
if (isDock() || isDesktop() || !isPlaceable()) {
return;
}
enum { Left = 0, Top, Right, Bottom };
const int border[4] = { borderLeft(), borderTop(), borderRight(), borderBottom() };
if( !oldGeometry.isValid())
......@@ -3095,16 +3098,12 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, int oldDesktop, Q
oldDesktop = desktop();
if (!oldClientGeometry.isValid())
oldClientGeometry = oldGeometry.adjusted(border[Left], border[Top], -border[Right], -border[Bottom]);
if (isDesktop())
return;
if (isFullScreen()) {
QRect area = workspace()->clientArea(FullScreenArea, this);
if (frameGeometry() != area)
setFrameGeometry(area);
return;
}
if (isDock())
return;
if (maximizeMode() != MaximizeRestore) {
GeometryUpdatesBlocker block(this);
......@@ -3513,4 +3512,9 @@ void AbstractClient::showOnScreenEdge()
qCWarning(KWIN_CORE, "%s doesn't support screen edge activation", metaObject()->className());
}
bool AbstractClient::isPlaceable() const
{
return true;
}
}
......@@ -405,6 +405,7 @@ public:
* @see captionNormal
*/
virtual QString captionSuffix() const = 0;
virtual bool isPlaceable() const;
virtual bool isCloseable() const = 0;
// TODO: remove boolean trap
virtual bool isShown(bool shaded_is_shown) const = 0;
......
......@@ -33,6 +33,7 @@ public:
void destroyClient() override;
QRect bufferGeometry() const override { return frameGeometry(); }
bool isPlaceable() const override { return false; }
bool isCloseable() const override { return false; }
bool isResizable() const override { return false; }
bool isMovable() const override { return false; }
......
......@@ -706,22 +706,24 @@ void Workspace::addShellClient(AbstractClient *client)
client->updateDecoration(false);
updateClientLayer(client);
const QRect area = clientArea(PlacementArea, Screens::self()->current(), client->desktop());
bool placementDone = false;
if (client->isInitialPositionSet()) {
placementDone = true;
}
if (client->isFullScreen()) {
placementDone = true;
}
if (client->maximizeMode() == MaximizeMode::MaximizeFull) {
placementDone = true;
}
if (client->rules()->checkPosition(invalidPoint, true) != invalidPoint) {
placementDone = true;
}
if (!placementDone) {
client->placeIn(area);
if (client->isPlaceable()) {
const QRect area = clientArea(PlacementArea, Screens::self()->current(), client->desktop());
bool placementDone = false;
if (client->isInitialPositionSet()) {
placementDone = true;
}
if (client->isFullScreen()) {
placementDone = true;
}
if (client->maximizeMode() == MaximizeMode::MaximizeFull) {
placementDone = true;
}
if (client->rules()->checkPosition(invalidPoint, true) != invalidPoint) {
placementDone = true;
}
if (!placementDone) {
client->placeIn(area);
}
}
m_allClients.append(client);
if (!unconstrained_stacking_order.contains(client)) {
......@@ -2195,9 +2197,7 @@ void Workspace::updateClientArea(bool force)
for (auto it = m_allClients.constBegin();
it != m_allClients.constEnd();
++it) {
if (!(*it)->isInputMethod()) {
(*it)->checkWorkspacePosition();
}
(*it)->checkWorkspacePosition();
}
oldrestrictedmovearea.clear(); // reset, no longer valid or needed
......
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