Changeset View
Changeset View
Standalone View
Standalone View
abstract_client.cpp
Show First 20 Lines • Show All 1074 Lines • ▼ Show 20 Line(s) | 1052 | auto titleBarRect = [this](bool &transposed, int &requiredPixels) -> QRect { | |||
---|---|---|---|---|---|
1075 | requiredPixels = qMin(100 * (transposed ? r.width() : r.height()), | 1075 | requiredPixels = qMin(100 * (transposed ? r.width() : r.height()), | ||
1076 | moveResizeGeom.width() * moveResizeGeom.height()); | 1076 | moveResizeGeom.width() * moveResizeGeom.height()); | ||
1077 | return r; | 1077 | return r; | ||
1078 | }; | 1078 | }; | ||
1079 | 1079 | | |||
1080 | bool update = false; | 1080 | bool update = false; | ||
1081 | if (isResize()) { | 1081 | if (isResize()) { | ||
1082 | QRect orig = initialMoveResizeGeometry(); | 1082 | QRect orig = initialMoveResizeGeometry(); | ||
1083 | Sizemode sizemode = SizemodeAny; | 1083 | SizeMode sizeMode = SizeModeAny; | ||
1084 | auto calculateMoveResizeGeom = [this, &topleft, &bottomright, &orig, &sizemode, &mode]() { | 1084 | auto calculateMoveResizeGeom = [this, &topleft, &bottomright, &orig, &sizeMode, &mode]() { | ||
1085 | switch(mode) { | 1085 | switch(mode) { | ||
1086 | case PositionTopLeft: | 1086 | case PositionTopLeft: | ||
1087 | setMoveResizeGeometry(QRect(topleft, orig.bottomRight())); | 1087 | setMoveResizeGeometry(QRect(topleft, orig.bottomRight())); | ||
1088 | break; | 1088 | break; | ||
1089 | case PositionBottomRight: | 1089 | case PositionBottomRight: | ||
1090 | setMoveResizeGeometry(QRect(orig.topLeft(), bottomright)); | 1090 | setMoveResizeGeometry(QRect(orig.topLeft(), bottomright)); | ||
1091 | break; | 1091 | break; | ||
1092 | case PositionBottomLeft: | 1092 | case PositionBottomLeft: | ||
1093 | setMoveResizeGeometry(QRect(QPoint(topleft.x(), orig.y()), QPoint(orig.right(), bottomright.y()))); | 1093 | setMoveResizeGeometry(QRect(QPoint(topleft.x(), orig.y()), QPoint(orig.right(), bottomright.y()))); | ||
1094 | break; | 1094 | break; | ||
1095 | case PositionTopRight: | 1095 | case PositionTopRight: | ||
1096 | setMoveResizeGeometry(QRect(QPoint(orig.x(), topleft.y()), QPoint(bottomright.x(), orig.bottom()))); | 1096 | setMoveResizeGeometry(QRect(QPoint(orig.x(), topleft.y()), QPoint(bottomright.x(), orig.bottom()))); | ||
1097 | break; | 1097 | break; | ||
1098 | case PositionTop: | 1098 | case PositionTop: | ||
1099 | setMoveResizeGeometry(QRect(QPoint(orig.left(), topleft.y()), orig.bottomRight())); | 1099 | setMoveResizeGeometry(QRect(QPoint(orig.left(), topleft.y()), orig.bottomRight())); | ||
1100 | sizemode = SizemodeFixedH; // try not to affect height | 1100 | sizeMode = SizeModeFixedH; // try not to affect height | ||
1101 | break; | 1101 | break; | ||
1102 | case PositionBottom: | 1102 | case PositionBottom: | ||
1103 | setMoveResizeGeometry(QRect(orig.topLeft(), QPoint(orig.right(), bottomright.y()))); | 1103 | setMoveResizeGeometry(QRect(orig.topLeft(), QPoint(orig.right(), bottomright.y()))); | ||
1104 | sizemode = SizemodeFixedH; | 1104 | sizeMode = SizeModeFixedH; | ||
1105 | break; | 1105 | break; | ||
1106 | case PositionLeft: | 1106 | case PositionLeft: | ||
1107 | setMoveResizeGeometry(QRect(QPoint(topleft.x(), orig.top()), orig.bottomRight())); | 1107 | setMoveResizeGeometry(QRect(QPoint(topleft.x(), orig.top()), orig.bottomRight())); | ||
1108 | sizemode = SizemodeFixedW; | 1108 | sizeMode = SizeModeFixedW; | ||
1109 | break; | 1109 | break; | ||
1110 | case PositionRight: | 1110 | case PositionRight: | ||
1111 | setMoveResizeGeometry(QRect(orig.topLeft(), QPoint(bottomright.x(), orig.bottom()))); | 1111 | setMoveResizeGeometry(QRect(orig.topLeft(), QPoint(bottomright.x(), orig.bottom()))); | ||
1112 | sizemode = SizemodeFixedW; | 1112 | sizeMode = SizeModeFixedW; | ||
1113 | break; | 1113 | break; | ||
1114 | case PositionCenter: | 1114 | case PositionCenter: | ||
1115 | default: | 1115 | default: | ||
1116 | abort(); | 1116 | abort(); | ||
1117 | break; | 1117 | break; | ||
1118 | } | 1118 | } | ||
1119 | }; | 1119 | }; | ||
1120 | 1120 | | |||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 1204 | else if (rightChanged) | |||
1205 | moveResizeGeom.setRight(moveResizeGeom.right() + sign(previousMoveResizeGeom.right() - moveResizeGeom.right())); | 1205 | moveResizeGeom.setRight(moveResizeGeom.right() + sign(previousMoveResizeGeom.right() - moveResizeGeom.right())); | ||
1206 | else | 1206 | else | ||
1207 | break; // no position changed - that's certainly not good | 1207 | break; // no position changed - that's certainly not good | ||
1208 | setMoveResizeGeometry(moveResizeGeom); | 1208 | setMoveResizeGeometry(moveResizeGeom); | ||
1209 | } | 1209 | } | ||
1210 | } | 1210 | } | ||
1211 | 1211 | | |||
1212 | // Always obey size hints, even when in "unrestricted" mode | 1212 | // Always obey size hints, even when in "unrestricted" mode | ||
1213 | QSize size = adjustedSize(moveResizeGeometry().size(), sizemode); | 1213 | QSize size = adjustedSize(moveResizeGeometry().size(), sizeMode); | ||
1214 | // the new topleft and bottomright corners (after checking size constrains), if they'll be needed | 1214 | // the new topleft and bottomright corners (after checking size constrains), if they'll be needed | ||
1215 | topleft = QPoint(moveResizeGeometry().right() - size.width() + 1, moveResizeGeometry().bottom() - size.height() + 1); | 1215 | topleft = QPoint(moveResizeGeometry().right() - size.width() + 1, moveResizeGeometry().bottom() - size.height() + 1); | ||
1216 | bottomright = QPoint(moveResizeGeometry().left() + size.width() - 1, moveResizeGeometry().top() + size.height() - 1); | 1216 | bottomright = QPoint(moveResizeGeometry().left() + size.width() - 1, moveResizeGeometry().top() + size.height() - 1); | ||
1217 | orig = moveResizeGeometry(); | 1217 | orig = moveResizeGeometry(); | ||
1218 | 1218 | | |||
1219 | // if aspect ratios are specified, both dimensions may change. | 1219 | // if aspect ratios are specified, both dimensions may change. | ||
1220 | // Therefore grow to the right/bottom if needed. | 1220 | // Therefore grow to the right/bottom if needed. | ||
1221 | // TODO it should probably obey gravity rather than always using right/bottom ? | 1221 | // TODO it should probably obey gravity rather than always using right/bottom ? | ||
1222 | if (sizemode == SizemodeFixedH) | 1222 | if (sizeMode == SizeModeFixedH) | ||
1223 | orig.setRight(bottomright.x()); | 1223 | orig.setRight(bottomright.x()); | ||
1224 | else if (sizemode == SizemodeFixedW) | 1224 | else if (sizeMode == SizeModeFixedW) | ||
1225 | orig.setBottom(bottomright.y()); | 1225 | orig.setBottom(bottomright.y()); | ||
1226 | 1226 | | |||
1227 | calculateMoveResizeGeom(); | 1227 | calculateMoveResizeGeom(); | ||
1228 | 1228 | | |||
1229 | if (moveResizeGeometry().size() != previousMoveResizeGeom.size()) | 1229 | if (moveResizeGeometry().size() != previousMoveResizeGeom.size()) | ||
1230 | update = true; | 1230 | update = true; | ||
1231 | } else if (isMove()) { | 1231 | } else if (isMove()) { | ||
1232 | Q_ASSERT(mode == PositionCenter); | 1232 | Q_ASSERT(mode == PositionCenter); | ||
1233 | if (!isMovable()) { // isMovableAcrossScreens() must have been true to get here | 1233 | if (!isMovable()) { // isMovableAcrossScreens() must have been true to get here | ||
1234 | // Special moving of maximized windows on Xinerama screens | 1234 | // Special moving of maximized windows on Xinerama screens | ||
1235 | int screen = screens()->number(globalPos); | 1235 | int screen = screens()->number(globalPos); | ||
1236 | if (isFullScreen()) | 1236 | if (isFullScreen()) | ||
1237 | setMoveResizeGeometry(workspace()->clientArea(FullScreenArea, screen, 0)); | 1237 | setMoveResizeGeometry(workspace()->clientArea(FullScreenArea, screen, 0)); | ||
1238 | else { | 1238 | else { | ||
1239 | QRect moveResizeGeom = workspace()->clientArea(MaximizeArea, screen, 0); | 1239 | QRect moveResizeGeom = workspace()->clientArea(MaximizeArea, screen, 0); | ||
1240 | QSize adjSize = adjustedSize(moveResizeGeom.size(), SizemodeMax); | 1240 | QSize adjSize = adjustedSize(moveResizeGeom.size(), SizeModeMax); | ||
1241 | if (adjSize != moveResizeGeom.size()) { | 1241 | if (adjSize != moveResizeGeom.size()) { | ||
1242 | QRect r(moveResizeGeom); | 1242 | QRect r(moveResizeGeom); | ||
1243 | moveResizeGeom.setSize(adjSize); | 1243 | moveResizeGeom.setSize(adjSize); | ||
1244 | moveResizeGeom.moveCenter(r.center()); | 1244 | moveResizeGeom.moveCenter(r.center()); | ||
1245 | } | 1245 | } | ||
1246 | setMoveResizeGeometry(moveResizeGeom); | 1246 | setMoveResizeGeometry(moveResizeGeom); | ||
1247 | } | 1247 | } | ||
1248 | } else { | 1248 | } else { | ||
▲ Show 20 Lines • Show All 627 Lines • ▼ Show 20 Line(s) | 1872 | #define BORDER(which) \ | |||
1876 | } | 1876 | } | ||
1877 | 1877 | | |||
1878 | BORDER(Bottom) | 1878 | BORDER(Bottom) | ||
1879 | BORDER(Left) | 1879 | BORDER(Left) | ||
1880 | BORDER(Right) | 1880 | BORDER(Right) | ||
1881 | BORDER(Top) | 1881 | BORDER(Top) | ||
1882 | #undef BORDER | 1882 | #undef BORDER | ||
1883 | 1883 | | |||
1884 | QSize AbstractClient::sizeForClientSize(const QSize &wsize, Sizemode mode, bool noframe) const | 1884 | QSize AbstractClient::sizeForClientSize(const QSize &wsize, SizeMode mode, bool noframe) const | ||
1885 | { | 1885 | { | ||
1886 | Q_UNUSED(mode) | 1886 | Q_UNUSED(mode) | ||
1887 | Q_UNUSED(noframe) | 1887 | Q_UNUSED(noframe) | ||
1888 | return wsize + QSize(borderLeft() + borderRight(), borderTop() + borderBottom()); | 1888 | return wsize + QSize(borderLeft() + borderRight(), borderTop() + borderBottom()); | ||
1889 | } | 1889 | } | ||
1890 | 1890 | | |||
1891 | void AbstractClient::addRepaintDuringGeometryUpdates() | 1891 | void AbstractClient::addRepaintDuringGeometryUpdates() | ||
1892 | { | 1892 | { | ||
▲ Show 20 Lines • Show All 1227 Lines • ▼ Show 20 Line(s) | 3115 | { | |||
3120 | } | 3120 | } | ||
3121 | if (geom->top() > screenArea.bottom()) { | 3121 | if (geom->top() > screenArea.bottom()) { | ||
3122 | geom->moveTop(screenArea.bottom() - screenArea.height()/4); | 3122 | geom->moveTop(screenArea.bottom() - screenArea.height()/4); | ||
3123 | } else if (geom->bottom() < screenArea.top()) { | 3123 | } else if (geom->bottom() < screenArea.top()) { | ||
3124 | geom->moveBottom(screenArea.top() + screenArea.width()/4); | 3124 | geom->moveBottom(screenArea.top() + screenArea.width()/4); | ||
3125 | } | 3125 | } | ||
3126 | } | 3126 | } | ||
3127 | 3127 | | |||
3128 | QSize AbstractClient::adjustedSize(const QSize& frame, Sizemode mode) const | 3128 | QSize AbstractClient::adjustedSize(const QSize& frame, SizeMode mode) const | ||
3129 | { | 3129 | { | ||
3130 | // first, get the window size for the given frame size s | 3130 | // first, get the window size for the given frame size s | ||
3131 | QSize wsize = frameSizeToClientSize(frame); | 3131 | QSize wsize = frameSizeToClientSize(frame); | ||
3132 | if (wsize.isEmpty()) | 3132 | if (wsize.isEmpty()) | ||
3133 | wsize = QSize(qMax(wsize.width(), 1), qMax(wsize.height(), 1)); | 3133 | wsize = QSize(qMax(wsize.width(), 1), qMax(wsize.height(), 1)); | ||
3134 | 3134 | | |||
3135 | return sizeForClientSize(wsize, mode, false); | 3135 | return sizeForClientSize(wsize, mode, false); | ||
3136 | } | 3136 | } | ||
Show All 9 Lines |