Commit f57470d1 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Capitilize "mode" in Sizemode enum

Summary: Capitalize "mode" to improve readability.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26826
parent fb598c65
......@@ -1080,8 +1080,8 @@ void AbstractClient::handleMoveResize(int x, int y, int x_root, int y_root)
bool update = false;
if (isResize()) {
QRect orig = initialMoveResizeGeometry();
Sizemode sizemode = SizemodeAny;
auto calculateMoveResizeGeom = [this, &topleft, &bottomright, &orig, &sizemode, &mode]() {
SizeMode sizeMode = SizeModeAny;
auto calculateMoveResizeGeom = [this, &topleft, &bottomright, &orig, &sizeMode, &mode]() {
switch(mode) {
case PositionTopLeft:
setMoveResizeGeometry(QRect(topleft, orig.bottomRight()));
......@@ -1097,19 +1097,19 @@ void AbstractClient::handleMoveResize(int x, int y, int x_root, int y_root)
break;
case PositionTop:
setMoveResizeGeometry(QRect(QPoint(orig.left(), topleft.y()), orig.bottomRight()));
sizemode = SizemodeFixedH; // try not to affect height
sizeMode = SizeModeFixedH; // try not to affect height
break;
case PositionBottom:
setMoveResizeGeometry(QRect(orig.topLeft(), QPoint(orig.right(), bottomright.y())));
sizemode = SizemodeFixedH;
sizeMode = SizeModeFixedH;
break;
case PositionLeft:
setMoveResizeGeometry(QRect(QPoint(topleft.x(), orig.top()), orig.bottomRight()));
sizemode = SizemodeFixedW;
sizeMode = SizeModeFixedW;
break;
case PositionRight:
setMoveResizeGeometry(QRect(orig.topLeft(), QPoint(bottomright.x(), orig.bottom())));
sizemode = SizemodeFixedW;
sizeMode = SizeModeFixedW;
break;
case PositionCenter:
default:
......@@ -1210,7 +1210,7 @@ void AbstractClient::handleMoveResize(int x, int y, int x_root, int y_root)
}
// Always obey size hints, even when in "unrestricted" mode
QSize size = adjustedSize(moveResizeGeometry().size(), sizemode);
QSize size = adjustedSize(moveResizeGeometry().size(), sizeMode);
// the new topleft and bottomright corners (after checking size constrains), if they'll be needed
topleft = QPoint(moveResizeGeometry().right() - size.width() + 1, moveResizeGeometry().bottom() - size.height() + 1);
bottomright = QPoint(moveResizeGeometry().left() + size.width() - 1, moveResizeGeometry().top() + size.height() - 1);
......@@ -1219,9 +1219,9 @@ void AbstractClient::handleMoveResize(int x, int y, int x_root, int y_root)
// if aspect ratios are specified, both dimensions may change.
// Therefore grow to the right/bottom if needed.
// TODO it should probably obey gravity rather than always using right/bottom ?
if (sizemode == SizemodeFixedH)
if (sizeMode == SizeModeFixedH)
orig.setRight(bottomright.x());
else if (sizemode == SizemodeFixedW)
else if (sizeMode == SizeModeFixedW)
orig.setBottom(bottomright.y());
calculateMoveResizeGeom();
......@@ -1237,7 +1237,7 @@ void AbstractClient::handleMoveResize(int x, int y, int x_root, int y_root)
setMoveResizeGeometry(workspace()->clientArea(FullScreenArea, screen, 0));
else {
QRect moveResizeGeom = workspace()->clientArea(MaximizeArea, screen, 0);
QSize adjSize = adjustedSize(moveResizeGeom.size(), SizemodeMax);
QSize adjSize = adjustedSize(moveResizeGeom.size(), SizeModeMax);
if (adjSize != moveResizeGeom.size()) {
QRect r(moveResizeGeom);
moveResizeGeom.setSize(adjSize);
......@@ -1881,7 +1881,7 @@ BORDER(Right)
BORDER(Top)
#undef BORDER
QSize AbstractClient::sizeForClientSize(const QSize &wsize, Sizemode mode, bool noframe) const
QSize AbstractClient::sizeForClientSize(const QSize &wsize, SizeMode mode, bool noframe) const
{
Q_UNUSED(mode)
Q_UNUSED(noframe)
......@@ -3125,7 +3125,7 @@ void AbstractClient::checkOffscreenPosition(QRect* geom, const QRect& screenArea
}
}
QSize AbstractClient::adjustedSize(const QSize& frame, Sizemode mode) const
QSize AbstractClient::adjustedSize(const QSize& frame, SizeMode mode) const
{
// first, get the window size for the given frame size s
QSize wsize = frameSizeToClientSize(frame);
......
......@@ -635,11 +635,11 @@ public:
virtual void setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) = 0;
void setFrameGeometry(const QRect &rect, ForceGeometry_t force = NormalGeometrySet);
/// How to resize the window in order to obey constains (mainly aspect ratios)
enum Sizemode {
SizemodeAny,
SizemodeFixedW, ///< Try not to affect width
SizemodeFixedH, ///< Try not to affect height
SizemodeMax ///< Try not to make it larger in either direction
enum SizeMode {
SizeModeAny,
SizeModeFixedW, ///< Try not to affect width
SizeModeFixedH, ///< Try not to affect height
SizeModeMax ///< Try not to make it larger in either direction
};
/**
* Calculates the appropriate frame size for the given client size @p wsize.
......@@ -648,12 +648,12 @@ public:
*
* Default implementation returns the passed in @p wsize.
*/
virtual QSize sizeForClientSize(const QSize &wsize, Sizemode mode = SizemodeAny, bool noframe = false) const;
virtual QSize sizeForClientSize(const QSize &wsize, SizeMode mode = SizeModeAny, bool noframe = false) const;
/**
* Adjust the frame size @p frame according to the window's size hints.
*/
QSize adjustedSize(const QSize&, Sizemode mode = SizemodeAny) const;
QSize adjustedSize(const QSize&, SizeMode mode = SizeModeAny) const;
QSize adjustedSize() const;
/**
......
......@@ -748,7 +748,7 @@ void AbstractClient::growHorizontal()
return;
QRect geom = frameGeometry();
geom.setRight(workspace()->packPositionRight(this, geom.right(), true));
QSize adjsize = adjustedSize(geom.size(), SizemodeFixedW);
QSize adjsize = adjustedSize(geom.size(), SizeModeFixedW);
if (frameGeometry().size() == adjsize && geom.size() != adjsize && resizeIncrements().width() > 1) { // take care of size increments
int newright = workspace()->packPositionRight(this, geom.right() + resizeIncrements().width() - 1, true);
// check that it hasn't grown outside of the area, due to size increments
......@@ -757,8 +757,8 @@ void AbstractClient::growHorizontal()
QPoint((x() + newright) / 2, frameGeometry().center().y()), desktop()).right() >= newright)
geom.setRight(newright);
}
geom.setSize(adjustedSize(geom.size(), SizemodeFixedW));
geom.setSize(adjustedSize(geom.size(), SizemodeFixedH));
geom.setSize(adjustedSize(geom.size(), SizeModeFixedW));
geom.setSize(adjustedSize(geom.size(), SizeModeFixedH));
workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event;
setFrameGeometry(geom);
}
......@@ -777,7 +777,7 @@ void AbstractClient::shrinkHorizontal()
geom.setRight(workspace()->packPositionLeft(this, geom.right(), false));
if (geom.width() <= 1)
return;
geom.setSize(adjustedSize(geom.size(), SizemodeFixedW));
geom.setSize(adjustedSize(geom.size(), SizeModeFixedW));
if (geom.width() > 20) {
workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event;
setFrameGeometry(geom);
......@@ -796,7 +796,7 @@ void AbstractClient::growVertical()
return;
QRect geom = frameGeometry();
geom.setBottom(workspace()->packPositionDown(this, geom.bottom(), true));
QSize adjsize = adjustedSize(geom.size(), SizemodeFixedH);
QSize adjsize = adjustedSize(geom.size(), SizeModeFixedH);
if (frameGeometry().size() == adjsize && geom.size() != adjsize && resizeIncrements().height() > 1) { // take care of size increments
int newbottom = workspace()->packPositionDown(this, geom.bottom() + resizeIncrements().height() - 1, true);
// check that it hasn't grown outside of the area, due to size increments
......@@ -804,7 +804,7 @@ void AbstractClient::growVertical()
QPoint(frameGeometry().center().x(), (y() + newbottom) / 2), desktop()).bottom() >= newbottom)
geom.setBottom(newbottom);
}
geom.setSize(adjustedSize(geom.size(), SizemodeFixedH));
geom.setSize(adjustedSize(geom.size(), SizeModeFixedH));
workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event;
setFrameGeometry(geom);
}
......@@ -824,7 +824,7 @@ void AbstractClient::shrinkVertical()
geom.setBottom(workspace()->packPositionUp(this, geom.bottom(), false));
if (geom.height() <= 1)
return;
geom.setSize(adjustedSize(geom.size(), SizemodeFixedH));
geom.setSize(adjustedSize(geom.size(), SizeModeFixedH));
if (geom.height() > 20) {
workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event;
setFrameGeometry(geom);
......
......@@ -1249,7 +1249,7 @@ bool X11Client::isFullScreenable() const
if (rules()->checkStrictGeometry(true)) {
// check geometry constraints (rule to obey is set)
const QRect fsarea = workspace()->clientArea(FullScreenArea, this);
if (sizeForClientSize(fsarea.size(), SizemodeAny, true) != fsarea.size()) {
if (sizeForClientSize(fsarea.size(), SizeModeAny, true) != fsarea.size()) {
return false; // the app wouldn't fit exactly fullscreen geometry due to its strict geometry requirements
}
}
......@@ -3551,7 +3551,7 @@ void X11Client::checkActiveModal()
* \a wsize is adapted according to the window's size hints (minimum,
* maximum and incremental size changes).
*/
QSize X11Client::sizeForClientSize(const QSize& wsize, Sizemode mode, bool noframe) const
QSize X11Client::sizeForClientSize(const QSize& wsize, SizeMode mode, bool noframe) const
{
int w = wsize.width();
int h = wsize.height();
......@@ -3665,8 +3665,8 @@ QSize X11Client::sizeForClientSize(const QSize& wsize, Sizemode mode, bool nofra
} \
}
switch(mode) {
case SizemodeAny:
#if 0 // make SizemodeAny equal to SizemodeFixedW - prefer keeping fixed width,
case SizeModeAny:
#if 0 // make SizeModeAny equal to SizeModeFixedW - prefer keeping fixed width,
// so that changing aspect ratio to a different value and back keeps the same size (#87298)
{
ASPECT_CHECK_SHRINK_H_GROW_W
......@@ -3676,7 +3676,7 @@ QSize X11Client::sizeForClientSize(const QSize& wsize, Sizemode mode, bool nofra
break;
}
#endif
case SizemodeFixedW: {
case SizeModeFixedW: {
// the checks are order so that attempts to modify height are first
ASPECT_CHECK_GROW_H
ASPECT_CHECK_SHRINK_H_GROW_W
......@@ -3684,14 +3684,14 @@ QSize X11Client::sizeForClientSize(const QSize& wsize, Sizemode mode, bool nofra
ASPECT_CHECK_GROW_W
break;
}
case SizemodeFixedH: {
case SizeModeFixedH: {
ASPECT_CHECK_GROW_W
ASPECT_CHECK_SHRINK_W_GROW_H
ASPECT_CHECK_SHRINK_H_GROW_W
ASPECT_CHECK_GROW_H
break;
}
case SizemodeMax: {
case SizeModeMax: {
// first checks that try to shrink
ASPECT_CHECK_SHRINK_H_GROW_W
ASPECT_CHECK_SHRINK_W_GROW_H
......@@ -4417,16 +4417,16 @@ void X11Client::changeMaximize(bool horizontal, bool vertical, bool adjust)
if (old_mode & MaximizeHorizontal) { // actually restoring from MaximizeFull
if (geom_restore.width() == 0 || !clientArea.contains(geom_restore.center())) {
// needs placement
plainResize(adjustedSize(QSize(width() * 2 / 3, clientArea.height()), SizemodeFixedH), geom_mode);
plainResize(adjustedSize(QSize(width() * 2 / 3, clientArea.height()), SizeModeFixedH), geom_mode);
Placement::self()->placeSmart(this, clientArea);
} else {
setFrameGeometry(QRect(QPoint(geom_restore.x(), clientArea.top()),
adjustedSize(QSize(geom_restore.width(), clientArea.height()), SizemodeFixedH)), geom_mode);
adjustedSize(QSize(geom_restore.width(), clientArea.height()), SizeModeFixedH)), geom_mode);
}
} else {
QRect r(x(), clientArea.top(), width(), clientArea.height());
r.setTopLeft(rules()->checkPosition(r.topLeft()));
r.setSize(adjustedSize(r.size(), SizemodeFixedH));
r.setSize(adjustedSize(r.size(), SizeModeFixedH));
setFrameGeometry(r, geom_mode);
}
info->setState(NET::MaxVert, NET::Max);
......@@ -4437,16 +4437,16 @@ void X11Client::changeMaximize(bool horizontal, bool vertical, bool adjust)
if (old_mode & MaximizeVertical) { // actually restoring from MaximizeFull
if (geom_restore.height() == 0 || !clientArea.contains(geom_restore.center())) {
// needs placement
plainResize(adjustedSize(QSize(clientArea.width(), height() * 2 / 3), SizemodeFixedW), geom_mode);
plainResize(adjustedSize(QSize(clientArea.width(), height() * 2 / 3), SizeModeFixedW), geom_mode);
Placement::self()->placeSmart(this, clientArea);
} else {
setFrameGeometry(QRect(QPoint(clientArea.left(), geom_restore.y()),
adjustedSize(QSize(clientArea.width(), geom_restore.height()), SizemodeFixedW)), geom_mode);
adjustedSize(QSize(clientArea.width(), geom_restore.height()), SizeModeFixedW)), geom_mode);
}
} else {
QRect r(clientArea.left(), y(), clientArea.width(), height());
r.setTopLeft(rules()->checkPosition(r.topLeft()));
r.setSize(adjustedSize(r.size(), SizemodeFixedW));
r.setSize(adjustedSize(r.size(), SizeModeFixedW));
setFrameGeometry(r, geom_mode);
}
info->setState(NET::MaxHoriz, NET::Max);
......@@ -4480,7 +4480,7 @@ void X11Client::changeMaximize(bool horizontal, bool vertical, bool adjust)
geom_restore = restore; // relevant for mouse pos calculation, bug #298646
}
if (m_geometryHints.hasAspect()) {
restore.setSize(adjustedSize(restore.size(), SizemodeAny));
restore.setSize(adjustedSize(restore.size(), SizeModeAny));
}
setFrameGeometry(restore, geom_mode);
if (!clientArea.contains(geom_restore.center())) // Not restoring to the same screen
......@@ -4493,7 +4493,7 @@ void X11Client::changeMaximize(bool horizontal, bool vertical, bool adjust)
case MaximizeFull: {
QRect r(clientArea);
r.setTopLeft(rules()->checkPosition(r.topLeft()));
r.setSize(adjustedSize(r.size(), SizemodeMax));
r.setSize(adjustedSize(r.size(), SizeModeMax));
if (r.size() != clientArea.size()) { // to avoid off-by-one errors...
if (isElectricBorderMaximizing() && r.width() < clientArea.width()) {
r.moveLeft(qMax(clientArea.left(), Cursor::pos().x() - r.width()/2));
......
......@@ -194,7 +194,7 @@ public:
void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override;
void resizeWithChecks(int w, int h, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet);
void resizeWithChecks(const QSize& s, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet);
QSize sizeForClientSize(const QSize&, Sizemode mode = SizemodeAny, bool noframe = false) const override;
QSize sizeForClientSize(const QSize&, SizeMode mode = SizeModeAny, bool noframe = false) const override;
bool providesContextHelp() const override;
......
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