Changeset View
Changeset View
Standalone View
Standalone View
x11client.cpp
Show First 20 Lines • Show All 1243 Lines • ▼ Show 20 Line(s) | |||||
1244 | bool X11Client::isFullScreenable() const | 1244 | bool X11Client::isFullScreenable() const | ||
1245 | { | 1245 | { | ||
1246 | if (!rules()->checkFullScreen(true)) { | 1246 | if (!rules()->checkFullScreen(true)) { | ||
1247 | return false; | 1247 | return false; | ||
1248 | } | 1248 | } | ||
1249 | if (rules()->checkStrictGeometry(true)) { | 1249 | if (rules()->checkStrictGeometry(true)) { | ||
1250 | // check geometry constraints (rule to obey is set) | 1250 | // check geometry constraints (rule to obey is set) | ||
1251 | const QRect fsarea = workspace()->clientArea(FullScreenArea, this); | 1251 | const QRect fsarea = workspace()->clientArea(FullScreenArea, this); | ||
1252 | if (sizeForClientSize(fsarea.size(), SizemodeAny, true) != fsarea.size()) { | 1252 | if (sizeForClientSize(fsarea.size(), SizeModeAny, true) != fsarea.size()) { | ||
1253 | return false; // the app wouldn't fit exactly fullscreen geometry due to its strict geometry requirements | 1253 | return false; // the app wouldn't fit exactly fullscreen geometry due to its strict geometry requirements | ||
1254 | } | 1254 | } | ||
1255 | } | 1255 | } | ||
1256 | // don't check size constrains - some apps request fullscreen despite requesting fixed size | 1256 | // don't check size constrains - some apps request fullscreen despite requesting fixed size | ||
1257 | return !isSpecialWindow(); // also better disallow only weird types to go fullscreen | 1257 | return !isSpecialWindow(); // also better disallow only weird types to go fullscreen | ||
1258 | } | 1258 | } | ||
1259 | 1259 | | |||
1260 | bool X11Client::noBorder() const | 1260 | bool X11Client::noBorder() const | ||
▲ Show 20 Lines • Show All 2285 Lines • ▼ Show 20 Line(s) | |||||
3546 | 3546 | | |||
3547 | /** | 3547 | /** | ||
3548 | * Calculate the appropriate frame size for the given client size \a | 3548 | * Calculate the appropriate frame size for the given client size \a | ||
3549 | * wsize. | 3549 | * wsize. | ||
3550 | * | 3550 | * | ||
3551 | * \a wsize is adapted according to the window's size hints (minimum, | 3551 | * \a wsize is adapted according to the window's size hints (minimum, | ||
3552 | * maximum and incremental size changes). | 3552 | * maximum and incremental size changes). | ||
3553 | */ | 3553 | */ | ||
3554 | QSize X11Client::sizeForClientSize(const QSize& wsize, Sizemode mode, bool noframe) const | 3554 | QSize X11Client::sizeForClientSize(const QSize& wsize, SizeMode mode, bool noframe) const | ||
3555 | { | 3555 | { | ||
3556 | int w = wsize.width(); | 3556 | int w = wsize.width(); | ||
3557 | int h = wsize.height(); | 3557 | int h = wsize.height(); | ||
3558 | if (w < 1 || h < 1) { | 3558 | if (w < 1 || h < 1) { | ||
3559 | qCWarning(KWIN_CORE) << "sizeForClientSize() with empty size!" ; | 3559 | qCWarning(KWIN_CORE) << "sizeForClientSize() with empty size!" ; | ||
3560 | } | 3560 | } | ||
3561 | if (w < 1) w = 1; | 3561 | if (w < 1) w = 1; | ||
3562 | if (h < 1) h = 1; | 3562 | if (h < 1) h = 1; | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 3656 | { \ | |||
3660 | else \ | 3660 | else \ | ||
3661 | { \ | 3661 | { \ | ||
3662 | int delta = int( w * max_aspect_h / max_aspect_w - h ) / height_inc * height_inc; \ | 3662 | int delta = int( w * max_aspect_h / max_aspect_w - h ) / height_inc * height_inc; \ | ||
3663 | if ( h + delta <= max_height ) \ | 3663 | if ( h + delta <= max_height ) \ | ||
3664 | h += delta; \ | 3664 | h += delta; \ | ||
3665 | } \ | 3665 | } \ | ||
3666 | } | 3666 | } | ||
3667 | switch(mode) { | 3667 | switch(mode) { | ||
3668 | case SizemodeAny: | 3668 | case SizeModeAny: | ||
3669 | #if 0 // make SizemodeAny equal to SizemodeFixedW - prefer keeping fixed width, | 3669 | #if 0 // make SizeModeAny equal to SizeModeFixedW - prefer keeping fixed width, | ||
3670 | // so that changing aspect ratio to a different value and back keeps the same size (#87298) | 3670 | // so that changing aspect ratio to a different value and back keeps the same size (#87298) | ||
3671 | { | 3671 | { | ||
3672 | ASPECT_CHECK_SHRINK_H_GROW_W | 3672 | ASPECT_CHECK_SHRINK_H_GROW_W | ||
3673 | ASPECT_CHECK_SHRINK_W_GROW_H | 3673 | ASPECT_CHECK_SHRINK_W_GROW_H | ||
3674 | ASPECT_CHECK_GROW_H | 3674 | ASPECT_CHECK_GROW_H | ||
3675 | ASPECT_CHECK_GROW_W | 3675 | ASPECT_CHECK_GROW_W | ||
3676 | break; | 3676 | break; | ||
3677 | } | 3677 | } | ||
3678 | #endif | 3678 | #endif | ||
3679 | case SizemodeFixedW: { | 3679 | case SizeModeFixedW: { | ||
3680 | // the checks are order so that attempts to modify height are first | 3680 | // the checks are order so that attempts to modify height are first | ||
3681 | ASPECT_CHECK_GROW_H | 3681 | ASPECT_CHECK_GROW_H | ||
3682 | ASPECT_CHECK_SHRINK_H_GROW_W | 3682 | ASPECT_CHECK_SHRINK_H_GROW_W | ||
3683 | ASPECT_CHECK_SHRINK_W_GROW_H | 3683 | ASPECT_CHECK_SHRINK_W_GROW_H | ||
3684 | ASPECT_CHECK_GROW_W | 3684 | ASPECT_CHECK_GROW_W | ||
3685 | break; | 3685 | break; | ||
3686 | } | 3686 | } | ||
3687 | case SizemodeFixedH: { | 3687 | case SizeModeFixedH: { | ||
3688 | ASPECT_CHECK_GROW_W | 3688 | ASPECT_CHECK_GROW_W | ||
3689 | ASPECT_CHECK_SHRINK_W_GROW_H | 3689 | ASPECT_CHECK_SHRINK_W_GROW_H | ||
3690 | ASPECT_CHECK_SHRINK_H_GROW_W | 3690 | ASPECT_CHECK_SHRINK_H_GROW_W | ||
3691 | ASPECT_CHECK_GROW_H | 3691 | ASPECT_CHECK_GROW_H | ||
3692 | break; | 3692 | break; | ||
3693 | } | 3693 | } | ||
3694 | case SizemodeMax: { | 3694 | case SizeModeMax: { | ||
3695 | // first checks that try to shrink | 3695 | // first checks that try to shrink | ||
3696 | ASPECT_CHECK_SHRINK_H_GROW_W | 3696 | ASPECT_CHECK_SHRINK_H_GROW_W | ||
3697 | ASPECT_CHECK_SHRINK_W_GROW_H | 3697 | ASPECT_CHECK_SHRINK_W_GROW_H | ||
3698 | ASPECT_CHECK_GROW_W | 3698 | ASPECT_CHECK_GROW_W | ||
3699 | ASPECT_CHECK_GROW_H | 3699 | ASPECT_CHECK_GROW_H | ||
3700 | break; | 3700 | break; | ||
3701 | } | 3701 | } | ||
3702 | } | 3702 | } | ||
▲ Show 20 Lines • Show All 709 Lines • ▼ Show 20 Line(s) | 4301 | { | |||
4412 | } | 4412 | } | ||
4413 | 4413 | | |||
4414 | switch(max_mode) { | 4414 | switch(max_mode) { | ||
4415 | 4415 | | |||
4416 | case MaximizeVertical: { | 4416 | case MaximizeVertical: { | ||
4417 | if (old_mode & MaximizeHorizontal) { // actually restoring from MaximizeFull | 4417 | if (old_mode & MaximizeHorizontal) { // actually restoring from MaximizeFull | ||
4418 | if (geom_restore.width() == 0 || !clientArea.contains(geom_restore.center())) { | 4418 | if (geom_restore.width() == 0 || !clientArea.contains(geom_restore.center())) { | ||
4419 | // needs placement | 4419 | // needs placement | ||
4420 | plainResize(adjustedSize(QSize(width() * 2 / 3, clientArea.height()), SizemodeFixedH), geom_mode); | 4420 | plainResize(adjustedSize(QSize(width() * 2 / 3, clientArea.height()), SizeModeFixedH), geom_mode); | ||
4421 | Placement::self()->placeSmart(this, clientArea); | 4421 | Placement::self()->placeSmart(this, clientArea); | ||
4422 | } else { | 4422 | } else { | ||
4423 | setFrameGeometry(QRect(QPoint(geom_restore.x(), clientArea.top()), | 4423 | setFrameGeometry(QRect(QPoint(geom_restore.x(), clientArea.top()), | ||
4424 | adjustedSize(QSize(geom_restore.width(), clientArea.height()), SizemodeFixedH)), geom_mode); | 4424 | adjustedSize(QSize(geom_restore.width(), clientArea.height()), SizeModeFixedH)), geom_mode); | ||
4425 | } | 4425 | } | ||
4426 | } else { | 4426 | } else { | ||
4427 | QRect r(x(), clientArea.top(), width(), clientArea.height()); | 4427 | QRect r(x(), clientArea.top(), width(), clientArea.height()); | ||
4428 | r.setTopLeft(rules()->checkPosition(r.topLeft())); | 4428 | r.setTopLeft(rules()->checkPosition(r.topLeft())); | ||
4429 | r.setSize(adjustedSize(r.size(), SizemodeFixedH)); | 4429 | r.setSize(adjustedSize(r.size(), SizeModeFixedH)); | ||
4430 | setFrameGeometry(r, geom_mode); | 4430 | setFrameGeometry(r, geom_mode); | ||
4431 | } | 4431 | } | ||
4432 | info->setState(NET::MaxVert, NET::Max); | 4432 | info->setState(NET::MaxVert, NET::Max); | ||
4433 | break; | 4433 | break; | ||
4434 | } | 4434 | } | ||
4435 | 4435 | | |||
4436 | case MaximizeHorizontal: { | 4436 | case MaximizeHorizontal: { | ||
4437 | if (old_mode & MaximizeVertical) { // actually restoring from MaximizeFull | 4437 | if (old_mode & MaximizeVertical) { // actually restoring from MaximizeFull | ||
4438 | if (geom_restore.height() == 0 || !clientArea.contains(geom_restore.center())) { | 4438 | if (geom_restore.height() == 0 || !clientArea.contains(geom_restore.center())) { | ||
4439 | // needs placement | 4439 | // needs placement | ||
4440 | plainResize(adjustedSize(QSize(clientArea.width(), height() * 2 / 3), SizemodeFixedW), geom_mode); | 4440 | plainResize(adjustedSize(QSize(clientArea.width(), height() * 2 / 3), SizeModeFixedW), geom_mode); | ||
4441 | Placement::self()->placeSmart(this, clientArea); | 4441 | Placement::self()->placeSmart(this, clientArea); | ||
4442 | } else { | 4442 | } else { | ||
4443 | setFrameGeometry(QRect(QPoint(clientArea.left(), geom_restore.y()), | 4443 | setFrameGeometry(QRect(QPoint(clientArea.left(), geom_restore.y()), | ||
4444 | adjustedSize(QSize(clientArea.width(), geom_restore.height()), SizemodeFixedW)), geom_mode); | 4444 | adjustedSize(QSize(clientArea.width(), geom_restore.height()), SizeModeFixedW)), geom_mode); | ||
4445 | } | 4445 | } | ||
4446 | } else { | 4446 | } else { | ||
4447 | QRect r(clientArea.left(), y(), clientArea.width(), height()); | 4447 | QRect r(clientArea.left(), y(), clientArea.width(), height()); | ||
4448 | r.setTopLeft(rules()->checkPosition(r.topLeft())); | 4448 | r.setTopLeft(rules()->checkPosition(r.topLeft())); | ||
4449 | r.setSize(adjustedSize(r.size(), SizemodeFixedW)); | 4449 | r.setSize(adjustedSize(r.size(), SizeModeFixedW)); | ||
4450 | setFrameGeometry(r, geom_mode); | 4450 | setFrameGeometry(r, geom_mode); | ||
4451 | } | 4451 | } | ||
4452 | info->setState(NET::MaxHoriz, NET::Max); | 4452 | info->setState(NET::MaxHoriz, NET::Max); | ||
4453 | break; | 4453 | break; | ||
4454 | } | 4454 | } | ||
4455 | 4455 | | |||
4456 | case MaximizeRestore: { | 4456 | case MaximizeRestore: { | ||
4457 | QRect restore = frameGeometry(); | 4457 | QRect restore = frameGeometry(); | ||
Show All 17 Lines | 4467 | if (!restore.isValid()) { | |||
4475 | restore = frameGeometry(); | 4475 | restore = frameGeometry(); | ||
4476 | if (geom_restore.width() > 0) | 4476 | if (geom_restore.width() > 0) | ||
4477 | restore.moveLeft(geom_restore.x()); | 4477 | restore.moveLeft(geom_restore.x()); | ||
4478 | if (geom_restore.height() > 0) | 4478 | if (geom_restore.height() > 0) | ||
4479 | restore.moveTop(geom_restore.y()); | 4479 | restore.moveTop(geom_restore.y()); | ||
4480 | geom_restore = restore; // relevant for mouse pos calculation, bug #298646 | 4480 | geom_restore = restore; // relevant for mouse pos calculation, bug #298646 | ||
4481 | } | 4481 | } | ||
4482 | if (m_geometryHints.hasAspect()) { | 4482 | if (m_geometryHints.hasAspect()) { | ||
4483 | restore.setSize(adjustedSize(restore.size(), SizemodeAny)); | 4483 | restore.setSize(adjustedSize(restore.size(), SizeModeAny)); | ||
4484 | } | 4484 | } | ||
4485 | setFrameGeometry(restore, geom_mode); | 4485 | setFrameGeometry(restore, geom_mode); | ||
4486 | if (!clientArea.contains(geom_restore.center())) // Not restoring to the same screen | 4486 | if (!clientArea.contains(geom_restore.center())) // Not restoring to the same screen | ||
4487 | Placement::self()->place(this, clientArea); | 4487 | Placement::self()->place(this, clientArea); | ||
4488 | info->setState(NET::States(), NET::Max); | 4488 | info->setState(NET::States(), NET::Max); | ||
4489 | updateQuickTileMode(QuickTileFlag::None); | 4489 | updateQuickTileMode(QuickTileFlag::None); | ||
4490 | break; | 4490 | break; | ||
4491 | } | 4491 | } | ||
4492 | 4492 | | |||
4493 | case MaximizeFull: { | 4493 | case MaximizeFull: { | ||
4494 | QRect r(clientArea); | 4494 | QRect r(clientArea); | ||
4495 | r.setTopLeft(rules()->checkPosition(r.topLeft())); | 4495 | r.setTopLeft(rules()->checkPosition(r.topLeft())); | ||
4496 | r.setSize(adjustedSize(r.size(), SizemodeMax)); | 4496 | r.setSize(adjustedSize(r.size(), SizeModeMax)); | ||
4497 | if (r.size() != clientArea.size()) { // to avoid off-by-one errors... | 4497 | if (r.size() != clientArea.size()) { // to avoid off-by-one errors... | ||
4498 | if (isElectricBorderMaximizing() && r.width() < clientArea.width()) { | 4498 | if (isElectricBorderMaximizing() && r.width() < clientArea.width()) { | ||
4499 | r.moveLeft(qMax(clientArea.left(), Cursor::pos().x() - r.width()/2)); | 4499 | r.moveLeft(qMax(clientArea.left(), Cursor::pos().x() - r.width()/2)); | ||
4500 | r.moveRight(qMin(clientArea.right(), r.right())); | 4500 | r.moveRight(qMin(clientArea.right(), r.right())); | ||
4501 | } else { | 4501 | } else { | ||
4502 | r.moveCenter(clientArea.center()); | 4502 | r.moveCenter(clientArea.center()); | ||
4503 | const bool closeHeight = r.height() > 97*clientArea.height()/100; | 4503 | const bool closeHeight = r.height() > 97*clientArea.height()/100; | ||
4504 | const bool closeWidth = r.width() > 97*clientArea.width() /100; | 4504 | const bool closeWidth = r.width() > 97*clientArea.width() /100; | ||
▲ Show 20 Lines • Show All 449 Lines • Show Last 20 Lines |