Changeset View
Changeset View
Standalone View
Standalone View
abstract_client.cpp
Show First 20 Lines • Show All 1424 Lines • ▼ Show 20 Line(s) | 1340 | { | |||
---|---|---|---|---|---|
1425 | connect(this, &AbstractClient::applicationMenuChanged, w, | 1425 | connect(this, &AbstractClient::applicationMenuChanged, w, | ||
1426 | [w, this] { | 1426 | [w, this] { | ||
1427 | w->setApplicationMenuPaths(applicationMenuServiceName(), applicationMenuObjectPath()); | 1427 | w->setApplicationMenuPaths(applicationMenuServiceName(), applicationMenuObjectPath()); | ||
1428 | } | 1428 | } | ||
1429 | ); | 1429 | ); | ||
1430 | connect(w, &PlasmaWindowInterface::closeRequested, this, [this] { closeWindow(); }); | 1430 | connect(w, &PlasmaWindowInterface::closeRequested, this, [this] { closeWindow(); }); | ||
1431 | connect(w, &PlasmaWindowInterface::moveRequested, this, | 1431 | connect(w, &PlasmaWindowInterface::moveRequested, this, | ||
1432 | [this] { | 1432 | [this] { | ||
1433 | Cursor::setPos(frameGeometry().center()); | 1433 | Cursors::self()->mouse()->setPos(frameGeometry().center()); | ||
1434 | performMouseCommand(Options::MouseMove, Cursor::pos()); | 1434 | performMouseCommand(Options::MouseMove, Cursors::self()->mouse()->pos()); | ||
1435 | } | 1435 | } | ||
1436 | ); | 1436 | ); | ||
1437 | connect(w, &PlasmaWindowInterface::resizeRequested, this, | 1437 | connect(w, &PlasmaWindowInterface::resizeRequested, this, | ||
1438 | [this] { | 1438 | [this] { | ||
1439 | Cursor::setPos(frameGeometry().bottomRight()); | 1439 | Cursors::self()->mouse()->setPos(frameGeometry().bottomRight()); | ||
1440 | performMouseCommand(Options::MouseResize, Cursor::pos()); | 1440 | performMouseCommand(Options::MouseResize, Cursors::self()->mouse()->pos()); | ||
1441 | } | 1441 | } | ||
1442 | ); | 1442 | ); | ||
1443 | connect(w, &PlasmaWindowInterface::virtualDesktopRequested, this, | 1443 | connect(w, &PlasmaWindowInterface::virtualDesktopRequested, this, | ||
1444 | [this] (quint32 desktop) { | 1444 | [this] (quint32 desktop) { | ||
1445 | workspace()->sendClientToDesktop(this, desktop + 1, true); | 1445 | workspace()->sendClientToDesktop(this, desktop + 1, true); | ||
1446 | } | 1446 | } | ||
1447 | ); | 1447 | ); | ||
1448 | connect(w, &PlasmaWindowInterface::fullscreenRequested, this, | 1448 | connect(w, &PlasmaWindowInterface::fullscreenRequested, this, | ||
▲ Show 20 Lines • Show All 606 Lines • ▼ Show 20 Line(s) | |||||
2055 | void AbstractClient::keyPressEvent(uint key_code) | 2055 | void AbstractClient::keyPressEvent(uint key_code) | ||
2056 | { | 2056 | { | ||
2057 | if (!isMove() && !isResize()) | 2057 | if (!isMove() && !isResize()) | ||
2058 | return; | 2058 | return; | ||
2059 | bool is_control = key_code & Qt::CTRL; | 2059 | bool is_control = key_code & Qt::CTRL; | ||
2060 | bool is_alt = key_code & Qt::ALT; | 2060 | bool is_alt = key_code & Qt::ALT; | ||
2061 | key_code = key_code & ~Qt::KeyboardModifierMask; | 2061 | key_code = key_code & ~Qt::KeyboardModifierMask; | ||
2062 | int delta = is_control ? 1 : is_alt ? 32 : 8; | 2062 | int delta = is_control ? 1 : is_alt ? 32 : 8; | ||
2063 | QPoint pos = Cursor::pos(); | 2063 | QPoint pos = Cursors::self()->mouse()->pos(); | ||
2064 | switch(key_code) { | 2064 | switch(key_code) { | ||
2065 | case Qt::Key_Left: | 2065 | case Qt::Key_Left: | ||
2066 | pos.rx() -= delta; | 2066 | pos.rx() -= delta; | ||
2067 | break; | 2067 | break; | ||
2068 | case Qt::Key_Right: | 2068 | case Qt::Key_Right: | ||
2069 | pos.rx() += delta; | 2069 | pos.rx() += delta; | ||
2070 | break; | 2070 | break; | ||
2071 | case Qt::Key_Up: | 2071 | case Qt::Key_Up: | ||
Show All 12 Lines | |||||
2084 | case Qt::Key_Escape: | 2084 | case Qt::Key_Escape: | ||
2085 | setMoveResizePointerButtonDown(false); | 2085 | setMoveResizePointerButtonDown(false); | ||
2086 | finishMoveResize(true); | 2086 | finishMoveResize(true); | ||
2087 | updateCursor(); | 2087 | updateCursor(); | ||
2088 | break; | 2088 | break; | ||
2089 | default: | 2089 | default: | ||
2090 | return; | 2090 | return; | ||
2091 | } | 2091 | } | ||
2092 | Cursor::setPos(pos); | 2092 | Cursors::self()->mouse()->setPos(pos); | ||
2093 | } | 2093 | } | ||
2094 | 2094 | | |||
2095 | QSize AbstractClient::resizeIncrements() const | 2095 | QSize AbstractClient::resizeIncrements() const | ||
2096 | { | 2096 | { | ||
2097 | return QSize(1, 1); | 2097 | return QSize(1, 1); | ||
2098 | } | 2098 | } | ||
2099 | 2099 | | |||
2100 | void AbstractClient::dontMoveResize() | 2100 | void AbstractClient::dontMoveResize() | ||
▲ Show 20 Lines • Show All 553 Lines • ▼ Show 20 Line(s) | 2647 | { | |||
2654 | } | 2654 | } | ||
2655 | m_electricMode = mode; | 2655 | m_electricMode = mode; | ||
2656 | } | 2656 | } | ||
2657 | 2657 | | |||
2658 | void AbstractClient::setElectricBorderMaximizing(bool maximizing) | 2658 | void AbstractClient::setElectricBorderMaximizing(bool maximizing) | ||
2659 | { | 2659 | { | ||
2660 | m_electricMaximizing = maximizing; | 2660 | m_electricMaximizing = maximizing; | ||
2661 | if (maximizing) | 2661 | if (maximizing) | ||
2662 | outline()->show(electricBorderMaximizeGeometry(Cursor::pos(), desktop()), moveResizeGeometry()); | 2662 | outline()->show(electricBorderMaximizeGeometry(Cursors::self()->mouse()->pos(), desktop()), moveResizeGeometry()); | ||
2663 | else | 2663 | else | ||
2664 | outline()->hide(); | 2664 | outline()->hide(); | ||
2665 | elevate(maximizing); | 2665 | elevate(maximizing); | ||
2666 | } | 2666 | } | ||
2667 | 2667 | | |||
2668 | QRect AbstractClient::electricBorderMaximizeGeometry(QPoint pos, int desktop) | 2668 | QRect AbstractClient::electricBorderMaximizeGeometry(QPoint pos, int desktop) | ||
2669 | { | 2669 | { | ||
2670 | if (electricBorderMode() == QuickTileMode(QuickTileFlag::Maximize)) { | 2670 | if (electricBorderMode() == QuickTileMode(QuickTileFlag::Maximize)) { | ||
Show All 18 Lines | |||||
2689 | 2689 | | |||
2690 | void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard) | 2690 | void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard) | ||
2691 | { | 2691 | { | ||
2692 | // Only allow quick tile on a regular window. | 2692 | // Only allow quick tile on a regular window. | ||
2693 | if (!isResizable()) { | 2693 | if (!isResizable()) { | ||
2694 | return; | 2694 | return; | ||
2695 | } | 2695 | } | ||
2696 | 2696 | | |||
2697 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event | 2697 | workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event | ||
2698 | 2698 | | |||
2699 | GeometryUpdatesBlocker blocker(this); | 2699 | GeometryUpdatesBlocker blocker(this); | ||
2700 | 2700 | | |||
2701 | if (mode == QuickTileMode(QuickTileFlag::Maximize)) { | 2701 | if (mode == QuickTileMode(QuickTileFlag::Maximize)) { | ||
2702 | m_quickTileMode = int(QuickTileFlag::None); | 2702 | m_quickTileMode = int(QuickTileFlag::None); | ||
2703 | if (maximizeMode() == MaximizeFull) { | 2703 | if (maximizeMode() == MaximizeFull) { | ||
2704 | setMaximize(false, false); | 2704 | setMaximize(false, false); | ||
2705 | } else { | 2705 | } else { | ||
Show All 25 Lines | 2730 | if (maximizeMode() != MaximizeRestore) { | |||
2731 | 2731 | | |||
2732 | if (mode != QuickTileMode(QuickTileFlag::None)) { | 2732 | if (mode != QuickTileMode(QuickTileFlag::None)) { | ||
2733 | // decorations may turn off some borders when tiled | 2733 | // decorations may turn off some borders when tiled | ||
2734 | const ForceGeometry_t geom_mode = isDecorated() ? ForceGeometrySet : NormalGeometrySet; | 2734 | const ForceGeometry_t geom_mode = isDecorated() ? ForceGeometrySet : NormalGeometrySet; | ||
2735 | m_quickTileMode = int(QuickTileFlag::None); // Temporary, so the maximize code doesn't get all confused | 2735 | m_quickTileMode = int(QuickTileFlag::None); // Temporary, so the maximize code doesn't get all confused | ||
2736 | 2736 | | |||
2737 | setMaximize(false, false); | 2737 | setMaximize(false, false); | ||
2738 | 2738 | | |||
2739 | setFrameGeometry(electricBorderMaximizeGeometry(keyboard ? frameGeometry().center() : Cursor::pos(), desktop()), geom_mode); | 2739 | setFrameGeometry(electricBorderMaximizeGeometry(keyboard ? frameGeometry().center() : Cursors::self()->mouse()->pos(), desktop()), geom_mode); | ||
2740 | // Store the mode change | 2740 | // Store the mode change | ||
2741 | m_quickTileMode = mode; | 2741 | m_quickTileMode = mode; | ||
2742 | } else { | 2742 | } else { | ||
2743 | m_quickTileMode = mode; | 2743 | m_quickTileMode = mode; | ||
2744 | setMaximize(false, false); | 2744 | setMaximize(false, false); | ||
2745 | } | 2745 | } | ||
2746 | 2746 | | |||
2747 | emit quickTileModeChanged(); | 2747 | emit quickTileModeChanged(); | ||
2748 | 2748 | | |||
2749 | return; | 2749 | return; | ||
2750 | } | 2750 | } | ||
2751 | 2751 | | |||
2752 | if (mode != QuickTileMode(QuickTileFlag::None)) { | 2752 | if (mode != QuickTileMode(QuickTileFlag::None)) { | ||
2753 | QPoint whichScreen = keyboard ? frameGeometry().center() : Cursor::pos(); | 2753 | QPoint whichScreen = keyboard ? frameGeometry().center() : Cursors::self()->mouse()->pos(); | ||
2754 | 2754 | | |||
2755 | // If trying to tile to the side that the window is already tiled to move the window to the next | 2755 | // If trying to tile to the side that the window is already tiled to move the window to the next | ||
2756 | // screen if it exists, otherwise toggle the mode (set QuickTileFlag::None) | 2756 | // screen if it exists, otherwise toggle the mode (set QuickTileFlag::None) | ||
2757 | if (quickTileMode() == mode) { | 2757 | if (quickTileMode() == mode) { | ||
2758 | const int numScreens = screens()->count(); | 2758 | const int numScreens = screens()->count(); | ||
2759 | const int curScreen = screen(); | 2759 | const int curScreen = screen(); | ||
2760 | int nextScreen = curScreen; | 2760 | int nextScreen = curScreen; | ||
2761 | QVarLengthArray<QRect> screens(numScreens); | 2761 | QVarLengthArray<QRect> screens(numScreens); | ||
▲ Show 20 Lines • Show All 541 Lines • Show Last 20 Lines |