Move MaximizeMode from KDecorationDefines to utils.h

Unfortunately it cannot be a enum defined in Client as client.h
depends on rules.h and with it in Client rules.h would depend on
client.h.
This commit is contained in:
Martin Gräßlin 2014-12-02 13:49:08 +01:00
parent 50019b4a31
commit 3d9a035312
14 changed files with 80 additions and 64 deletions

View file

@ -279,7 +279,7 @@ Client::Client()
ready_for_painting = false; // wait for first damage or sync reply
connect(this, &Client::geometryShapeChanged, this, &Client::geometryChanged);
auto signalMaximizeChanged = static_cast<void (Client::*)(KWin::Client*, Client::MaximizeMode)>(&Client::clientMaximizedStateChanged);
auto signalMaximizeChanged = static_cast<void (Client::*)(KWin::Client*, MaximizeMode)>(&Client::clientMaximizedStateChanged);
connect(this, signalMaximizeChanged, this, &Client::geometryChanged);
connect(this, &Client::clientStepUserMovedResized, this, &Client::geometryChanged);
connect(this, &Client::clientStartUserMovedResized, this, &Client::moveResizedChanged);
@ -708,7 +708,7 @@ void Client::checkNoBorder()
bool Client::wantsShadowToBeRendered() const
{
return !isFullScreen() && maximizeMode() != KDecorationDefines::MaximizeFull;
return !isFullScreen() && maximizeMode() != MaximizeFull;
}
void Client::updateShape()
@ -1823,9 +1823,9 @@ bool Client::untab(const QRect &toGeometry, bool clientRemoved)
setQuickTileMode(QuickTileNone); // if we leave a quicktiled group, assume that the user wants to untile
}
if (toGeometry.isValid()) {
if (maximizeMode() != Client::MaximizeRestore) {
if (maximizeMode() != MaximizeRestore) {
changedSize = true;
maximize(Client::MaximizeRestore); // explicitly calling for a geometry -> unmaximize
maximize(MaximizeRestore); // explicitly calling for a geometry -> unmaximize
}
if (keepSize && changedSize) {
geom_restore = geometry(); // checkWorkspacePosition() invokes it

View file

@ -78,7 +78,7 @@ enum class Predicate {
};
class Client
: public Toplevel, public KDecorationDefines
: public Toplevel
{
Q_OBJECT
/**
@ -749,7 +749,7 @@ private Q_SLOTS:
Q_SIGNALS:
void clientManaging(KWin::Client*);
void clientFullScreenSet(KWin::Client*, bool, bool);
void clientMaximizedStateChanged(KWin::Client*, Client::MaximizeMode);
void clientMaximizedStateChanged(KWin::Client*, MaximizeMode);
void clientMaximizedStateChanged(KWin::Client* c, bool h, bool v);
void clientMinimized(KWin::Client* client, bool animate);
void clientUnminimized(KWin::Client* client, bool animate);
@ -1158,7 +1158,7 @@ inline QRect Client::geometryRestore() const
return geom_restore;
}
inline Client::MaximizeMode Client::maximizeMode() const
inline MaximizeMode Client::maximizeMode() const
{
return max_mode;
}

View file

@ -187,7 +187,7 @@ int DecoratedClientImpl::height() const
bool DecoratedClientImpl::isMaximizedVertically() const
{
return m_client->maximizeMode() & KDecorationDefines::MaximizeVertical;
return m_client->maximizeMode() & MaximizeVertical;
}
bool DecoratedClientImpl::isMaximized() const
@ -197,7 +197,7 @@ bool DecoratedClientImpl::isMaximized() const
bool DecoratedClientImpl::isMaximizedHorizontally() const
{
return m_client->maximizeMode() & KDecorationDefines::MaximizeHorizontal;
return m_client->maximizeMode() & MaximizeHorizontal;
}
Qt::Edges DecoratedClientImpl::adjacentScreenEdges() const

View file

@ -318,7 +318,7 @@ EffectsHandlerImpl::~EffectsHandlerImpl()
void EffectsHandlerImpl::setupClientConnections(Client* c)
{
connect(c, &Client::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed);
connect(c, static_cast<void (Client::*)(KWin::Client*, Client::MaximizeMode)>(&Client::clientMaximizedStateChanged),
connect(c, static_cast<void (Client::*)(KWin::Client*, MaximizeMode)>(&Client::clientMaximizedStateChanged),
this, &EffectsHandlerImpl::slotClientMaximized);
connect(c, &Client::clientStartUserMovedResized, this,
[this](Client *c) {
@ -519,22 +519,22 @@ void EffectsHandlerImpl::startPaint()
m_currentPaintEffectFrameIterator = m_activeEffects.constBegin();
}
void EffectsHandlerImpl::slotClientMaximized(KWin::Client *c, Client::MaximizeMode maxMode)
void EffectsHandlerImpl::slotClientMaximized(KWin::Client *c, MaximizeMode maxMode)
{
bool horizontal = false;
bool vertical = false;
switch (maxMode) {
case KDecorationDefines::MaximizeHorizontal:
case MaximizeHorizontal:
horizontal = true;
break;
case KDecorationDefines::MaximizeVertical:
case MaximizeVertical:
vertical = true;
break;
case KDecorationDefines::MaximizeFull:
case MaximizeFull:
horizontal = true;
vertical = true;
break;
case KDecorationDefines::MaximizeRestore: // fall through
case MaximizeRestore: // fall through
default:
// default - nothing to do
break;

View file

@ -236,7 +236,7 @@ protected Q_SLOTS:
void slotClientShown(KWin::Toplevel*);
void slotUnmanagedShown(KWin::Toplevel*);
void slotWindowClosed(KWin::Toplevel *c);
void slotClientMaximized(KWin::Client *c, Client::MaximizeMode maxMode);
void slotClientMaximized(KWin::Client *c, MaximizeMode maxMode);
void slotOpacityChanged(KWin::Toplevel *t, qreal oldOpacity);
void slotClientModalityChanged();
void slotGeometryShapeChanged(KWin::Toplevel *t, const QRect &old);

View file

@ -371,16 +371,16 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted,
{
QSize borderSnapZone(options->borderSnapZone(), options->borderSnapZone());
QRect maxRect;
int guideMaximized = Client::MaximizeRestore;
if (c->maximizeMode() != Client::MaximizeRestore) {
int guideMaximized = MaximizeRestore;
if (c->maximizeMode() != MaximizeRestore) {
maxRect = clientArea(MaximizeArea, pos + c->rect().center(), c->desktop());
QRect geo = c->geometry();
if (c->maximizeMode() & Client::MaximizeHorizontal && (geo.x() == maxRect.left() || geo.right() == maxRect.right())) {
guideMaximized |= Client::MaximizeHorizontal;
if (c->maximizeMode() & MaximizeHorizontal && (geo.x() == maxRect.left() || geo.right() == maxRect.right())) {
guideMaximized |= MaximizeHorizontal;
borderSnapZone.setWidth(qMax(borderSnapZone.width() + 2, maxRect.width() / 16));
}
if (c->maximizeMode() & Client::MaximizeVertical && (geo.y() == maxRect.top() || geo.bottom() == maxRect.bottom())) {
guideMaximized |= Client::MaximizeVertical;
if (c->maximizeMode() & MaximizeVertical && (geo.y() == maxRect.top() || geo.bottom() == maxRect.bottom())) {
guideMaximized |= MaximizeVertical;
borderSnapZone.setHeight(qMax(borderSnapZone.height() + 2, maxRect.height() / 16));
}
}
@ -420,16 +420,16 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted,
// snap to titlebar / snap to window borders on inner screen edges
Client::Position titlePos = c->titlebarPosition();
if (padding[0] && (titlePos == Client::PositionLeft || (c->maximizeMode() & Client::MaximizeHorizontal) ||
if (padding[0] && (titlePos == Client::PositionLeft || (c->maximizeMode() & MaximizeHorizontal) ||
screens()->intersecting(geo.translated(maxRect.x() - (padding[0] + geo.x()), 0)) > 1))
padding[0] = 0;
if (padding[1] && (titlePos == Client::PositionRight || (c->maximizeMode() & Client::MaximizeHorizontal) ||
if (padding[1] && (titlePos == Client::PositionRight || (c->maximizeMode() & MaximizeHorizontal) ||
screens()->intersecting(geo.translated(maxRect.right() + padding[1] - geo.right(), 0)) > 1))
padding[1] = 0;
if (padding[2] && (titlePos == Client::PositionTop || (c->maximizeMode() & Client::MaximizeVertical) ||
if (padding[2] && (titlePos == Client::PositionTop || (c->maximizeMode() & MaximizeVertical) ||
screens()->intersecting(geo.translated(0, maxRect.y() - (padding[2] + geo.y()))) > 1))
padding[2] = 0;
if (padding[3] && (titlePos == Client::PositionBottom || (c->maximizeMode() & Client::MaximizeVertical) ||
if (padding[3] && (titlePos == Client::PositionBottom || (c->maximizeMode() & MaximizeVertical) ||
screens()->intersecting(geo.translated(0, maxRect.bottom() + padding[3] - geo.bottom())) > 1))
padding[3] = 0;
if ((sOWO ? (cx < xmin) : true) && (qAbs(xmin - cx) < snapX)) {
@ -474,7 +474,7 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted,
lrx = lx + (*l)->width();
lry = ly + (*l)->height();
if (!(guideMaximized & Client::MaximizeHorizontal) &&
if (!(guideMaximized & MaximizeHorizontal) &&
(((cy <= lry) && (cy >= ly)) || ((ry >= ly) && (ry <= lry)) || ((cy <= ly) && (ry >= lry)))) {
if ((sOWO ? (cx < lrx) : true) && (qAbs(lrx - cx) < snap) && (qAbs(lrx - cx) < deltaX)) {
deltaX = qAbs(lrx - cx);
@ -486,7 +486,7 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted,
}
}
if (!(guideMaximized & Client::MaximizeVertical) &&
if (!(guideMaximized & MaximizeVertical) &&
(((cx <= lrx) && (cx >= lx)) || ((rx >= lx) && (rx <= lrx)) || ((cx <= lx) && (rx >= lrx)))) {
if ((sOWO ? (cy < lry) : true) && (qAbs(lry - cy) < snap) && (qAbs(lry - cy) < deltaY)) {
deltaY = qAbs(lry - cy);
@ -500,7 +500,7 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted,
}
// Corner snapping
if (!(guideMaximized & Client::MaximizeVertical) && (nx == lrx || nx + cw == lx)) {
if (!(guideMaximized & MaximizeVertical) && (nx == lrx || nx + cw == lx)) {
if ((sOWO ? (ry > lry) : true) && (qAbs(lry - ry) < snap) && (qAbs(lry - ry) < deltaY)) {
deltaY = qAbs(lry - ry);
ny = lry - ch;
@ -510,7 +510,7 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted,
ny = ly;
}
}
if (!(guideMaximized & Client::MaximizeHorizontal) && (ny == lry || ny + ch == ly)) {
if (!(guideMaximized & MaximizeHorizontal) && (ny == lry || ny + ch == ly)) {
if ((sOWO ? (rx > lrx) : true) && (qAbs(lrx - rx) < snap) && (qAbs(lrx - rx) < deltaX)) {
deltaX = qAbs(lrx - rx);
nx = lrx - cw;
@ -2205,14 +2205,14 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
// call into decoration update borders
if (m_decoration && m_decoration->client()) {
const auto c = m_decoration->client().data();
if ((max_mode & KDecorationDefines::MaximizeVertical) != (old_mode & KDecorationDefines::MaximizeVertical)) {
emit c->maximizedVerticallyChanged(max_mode & KDecorationDefines::MaximizeVertical);
if ((max_mode & MaximizeVertical) != (old_mode & MaximizeVertical)) {
emit c->maximizedVerticallyChanged(max_mode & MaximizeVertical);
}
if ((max_mode & KDecorationDefines::MaximizeHorizontal) != (old_mode & KDecorationDefines::MaximizeHorizontal)) {
emit c->maximizedHorizontallyChanged(max_mode & KDecorationDefines::MaximizeHorizontal);
if ((max_mode & MaximizeHorizontal) != (old_mode & MaximizeHorizontal)) {
emit c->maximizedHorizontallyChanged(max_mode & MaximizeHorizontal);
}
if ((max_mode == KDecorationDefines::MaximizeFull) != (old_mode == KDecorationDefines::MaximizeFull)) {
emit c->maximizedChanged(max_mode & KDecorationDefines::MaximizeFull);
if ((max_mode == MaximizeFull) != (old_mode == MaximizeFull)) {
emit c->maximizedChanged(max_mode & MaximizeFull);
}
}

View file

@ -408,11 +408,11 @@ bool Client::manage(xcb_window_t w, bool isMapped)
const QSize ss = workspace()->clientArea(ScreenArea, area.center(), desktop()).size();
const QRect fsa = workspace()->clientArea(FullArea, geom.center(), desktop());
const QSize cs = clientSize();
int pseudo_max = Client::MaximizeRestore;
int pseudo_max = MaximizeRestore;
if (width() >= area.width())
pseudo_max |= Client::MaximizeHorizontal;
pseudo_max |= MaximizeHorizontal;
if (height() >= area.height())
pseudo_max |= Client::MaximizeVertical;
pseudo_max |= MaximizeVertical;
// heuristics:
// if decorated client is smaller than the entire screen, the user might want to move it around (multiscreen)
@ -424,24 +424,24 @@ bool Client::manage(xcb_window_t w, bool isMapped)
// thus a former maximized window wil become non-maximized
bool keepInFsArea = false;
if (width() < fsa.width() && (cs.width() > ss.width()+1)) {
pseudo_max &= ~Client::MaximizeHorizontal;
pseudo_max &= ~MaximizeHorizontal;
keepInFsArea = true;
}
if (height() < fsa.height() && (cs.height() > ss.height()+1)) {
pseudo_max &= ~Client::MaximizeVertical;
pseudo_max &= ~MaximizeVertical;
keepInFsArea = true;
}
if (pseudo_max != Client::MaximizeRestore) {
if (pseudo_max != MaximizeRestore) {
maximize((MaximizeMode)pseudo_max);
// from now on, care about maxmode, since the maximization call will override mode for fix aspects
dontKeepInArea |= (max_mode == Client::MaximizeFull);
dontKeepInArea |= (max_mode == MaximizeFull);
geom_restore = QRect(); // Use placement when unmaximizing ...
if (!(max_mode & Client::MaximizeVertical)) {
if (!(max_mode & MaximizeVertical)) {
geom_restore.setY(y()); // ...but only for horizontal direction
geom_restore.setHeight(height());
}
if (!(max_mode & Client::MaximizeHorizontal)) {
if (!(max_mode & MaximizeHorizontal)) {
geom_restore.setX(x()); // ...but only for vertical direction
geom_restore.setWidth(width());
}

View file

@ -256,9 +256,9 @@ void WinInfo::changeState(NET::States state, NET::States mask)
if ((mask & NET::Max) == NET::Max)
m_client->setMaximize(state & NET::MaxVert, state & NET::MaxHoriz);
else if (mask & NET::MaxVert)
m_client->setMaximize(state & NET::MaxVert, m_client->maximizeMode() & Client::MaximizeHorizontal);
m_client->setMaximize(state & NET::MaxVert, m_client->maximizeMode() & MaximizeHorizontal);
else if (mask & NET::MaxHoriz)
m_client->setMaximize(m_client->maximizeMode() & Client::MaximizeVertical, state & NET::MaxHoriz);
m_client->setMaximize(m_client->maximizeMode() & MaximizeVertical, state & NET::MaxHoriz);
if (mask & NET::Shaded)
m_client->setShade(state & NET::Shaded ? ShadeNormal : ShadeNone);

View file

@ -110,13 +110,13 @@ void Placement::place(Client* c, QRect& area, Policy policy, Policy nextPlacemen
Client::Position titlePos = c->titlebarPosition();
const QRect fullRect = workspace()->clientArea(FullArea, c);
if (!(c->maximizeMode() & KDecorationDefines::MaximizeHorizontal)) {
if (!(c->maximizeMode() & MaximizeHorizontal)) {
if (titlePos != Client::PositionRight && geo.right() == fullRect.right())
corner.rx() += cs.width() - cp.x();
if (titlePos != Client::PositionLeft && geo.x() == fullRect.x())
corner.rx() -= cp.x();
}
if (!(c->maximizeMode() & KDecorationDefines::MaximizeVertical)) {
if (!(c->maximizeMode() & MaximizeVertical)) {
if (titlePos != Client::PositionBottom && geo.bottom() == fullRect.bottom())
corner.ry() += cs.height() - cp.y();
if (titlePos != Client::PositionTop && geo.y() == fullRect.y())
@ -565,7 +565,7 @@ void Placement::placeMaximizing(Client* c, QRect& area, Policy nextPlacement)
nextPlacement = Smart;
if (c->isMaximizable() && c->maxSize().width() >= area.width() && c->maxSize().height() >= area.height()) {
if (workspace()->clientArea(MaximizeArea, c) == area)
c->maximize(Client::MaximizeFull);
c->maximize(MaximizeFull);
else { // if the geometry doesn't match default maximize area (xinerama case?),
// it's probably better to use the given area
c->setGeometry(area);

View file

@ -811,10 +811,10 @@ CHECK_RULE(IgnoreGeometry, bool)
CHECK_RULE(Desktop, int)
CHECK_RULE(Activity, QString)
CHECK_FORCE_RULE(Type, NET::WindowType)
CHECK_RULE(MaximizeVert, KDecorationDefines::MaximizeMode)
CHECK_RULE(MaximizeHoriz, KDecorationDefines::MaximizeMode)
CHECK_RULE(MaximizeVert, MaximizeMode)
CHECK_RULE(MaximizeHoriz, MaximizeMode)
KDecorationDefines::MaximizeMode WindowRules::checkMaximize(MaximizeMode mode, bool init) const
MaximizeMode WindowRules::checkMaximize(MaximizeMode mode, bool init) const
{
bool vert = checkMaximizeVert(mode, init) & MaximizeVertical;
bool horiz = checkMaximizeHoriz(mode, init) & MaximizeHorizontal;

View file

@ -44,7 +44,6 @@ class Rules;
#ifndef KCMRULES // only for kwin core
class WindowRules
: public KDecorationDefines
{
public:
explicit WindowRules(const QVector< Rules* >& rules);
@ -97,7 +96,6 @@ private:
#endif
class Rules
: public KDecorationDefines
{
public:
Rules();

View file

@ -395,7 +395,7 @@ void UserActionsMenu::menuAboutToShow()
m_resizeOperation->setEnabled(m_client.data()->isResizable());
m_moveOperation->setEnabled(m_client.data()->isMovableAcrossScreens());
m_maximizeOperation->setEnabled(m_client.data()->isMaximizable());
m_maximizeOperation->setChecked(m_client.data()->maximizeMode() == Client::MaximizeFull);
m_maximizeOperation->setChecked(m_client.data()->maximizeMode() == MaximizeFull);
m_shadeOperation->setEnabled(m_client.data()->isShadeable());
m_shadeOperation->setChecked(m_client.data()->shadeMode() != ShadeNone);
m_keepAboveOperation->setChecked(m_client.data()->keepAbove());
@ -1049,17 +1049,17 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op)
QMetaObject::invokeMethod(c, "closeWindow", Qt::QueuedConnection);
break;
case Options::MaximizeOp:
c->maximize(c->maximizeMode() == Client::MaximizeFull
? Client::MaximizeRestore : Client::MaximizeFull);
c->maximize(c->maximizeMode() == MaximizeFull
? MaximizeRestore : MaximizeFull);
break;
case Options::HMaximizeOp:
c->maximize(c->maximizeMode() ^ Client::MaximizeHorizontal);
c->maximize(c->maximizeMode() ^ MaximizeHorizontal);
break;
case Options::VMaximizeOp:
c->maximize(c->maximizeMode() ^ Client::MaximizeVertical);
c->maximize(c->maximizeMode() ^ MaximizeVertical);
break;
case Options::RestoreOp:
c->maximize(Client::MaximizeRestore);
c->maximize(MaximizeRestore);
break;
case Options::MinimizeOp:
c->minimize();
@ -1285,10 +1285,10 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
break;
}
case Options::MouseMaximize:
maximize(Client::MaximizeFull);
maximize(MaximizeFull);
break;
case Options::MouseRestore:
maximize(Client::MaximizeRestore);
maximize(MaximizeRestore);
break;
case Options::MouseMinimize:
minimize();

18
utils.h
View file

@ -120,6 +120,24 @@ enum ShadeMode {
ShadeActivated // "shaded", but visible due to alt+tab to the window
};
/**
* Maximize mode. These values specify how a window is maximized.
*/
// these values are written to session files, don't change the order
enum MaximizeMode {
MaximizeRestore = 0, ///< The window is not maximized in any direction.
MaximizeVertical = 1, ///< The window is maximized vertically.
MaximizeHorizontal = 2, ///< The window is maximized horizontally.
/// Equal to @p MaximizeVertical | @p MaximizeHorizontal
MaximizeFull = MaximizeVertical | MaximizeHorizontal
};
inline
MaximizeMode operator^(MaximizeMode m1, MaximizeMode m2)
{
return MaximizeMode(int(m1) ^ int(m2));
}
template <typename T> using ScopedCPointer = QScopedPointer<T, QScopedPointerPodDeleter>;
void updateXTime();

View file

@ -795,7 +795,7 @@ void Workspace::slotReconfigure()
for (ClientList::Iterator it = clients.begin();
it != clients.end();
++it) {
if ((*it)->maximizeMode() == Client::MaximizeFull)
if ((*it)->maximizeMode() == MaximizeFull)
(*it)->checkNoBorder();
}
}