diff --git a/kwin/CMakeLists.txt b/kwin/CMakeLists.txt index 00d4381..b2bd26f 100644 --- a/kwin/CMakeLists.txt +++ b/kwin/CMakeLists.txt @@ -35,18 +35,25 @@ include(cmake/info.cmake) find_package(epoxy REQUIRED) find_package(XCB REQUIRED COMPONENTS XCB) find_package(KWinDBusInterface CONFIG REQUIRED) +find_package(Qt6 REQUIRED COMPONENTS Core) -find_library(QT6_QUICK3D_LIB - NAMES Qt6Quick3D Qt6Quick3D.so Qt6Quick3D.so.6 - PATH_SUFFIXES lib +# Qt6 sets QT6_INSTALL_QML which is distro-aware +get_target_property(QT6_QMAKE_EXECUTABLE Qt6::qmake IMPORTED_LOCATION) +execute_process( + COMMAND ${QT6_QMAKE_EXECUTABLE} -query QT_INSTALL_QML + OUTPUT_VARIABLE QT6_QML_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE ) -if(NOT QT6_QUICK3D_LIB) - message(FATAL_ERROR "Qt6 Quick3D runtime library not found (QtQuick3D). Please install the Qt6 Quick3D runtime.") + +find_path(QT6_QUICK3D_QML_DIR + NAMES QtQuick3D + PATHS ${QT6_QML_DIR} + NO_DEFAULT_PATH +) + +if(NOT QT6_QUICK3D_QML_DIR) + message(FATAL_ERROR "cmake could not find the QtQuick3D QML module.") endif() -set_package_properties(Qt6Quick3D PROPERTIES - TYPE RUNTIME - PURPOSE "Required at runtime for 3D rendering (Qt Quick 3D)." -) add_subdirectory(src) ki18n_install(po) diff --git a/kwin/docker-build/Dockerfile b/kwin/docker-build/Dockerfile index 89d8677..4b74391 100644 --- a/kwin/docker-build/Dockerfile +++ b/kwin/docker-build/Dockerfile @@ -19,6 +19,7 @@ RUN pacman -Sy --noconfirm --needed \ extra-cmake-modules \ qt6-base \ qt6-declarative \ + qt6-quick3d \ qt6-tools \ kconfig \ kconfigwidgets \ diff --git a/kwin/docker-build/init.sh b/kwin/docker-build/init.sh index 426b088..af82893 100755 --- a/kwin/docker-build/init.sh +++ b/kwin/docker-build/init.sh @@ -18,6 +18,6 @@ else fi echo "Building docker image" -docker buildx build --platform linux/amd64 -f ./docker-build/Dockerfile -t "breezy-kwin:amd64" --load . +# docker buildx build --platform linux/amd64 -f ./docker-build/Dockerfile -t "breezy-kwin:amd64" --load . # docker buildx build --platform linux/arm64 -f ./docker-build/Dockerfile -t "breezy-kwin:arm64" --load . docker buildx build --platform linux/amd64 -f ./docker-build/Dockerfile.steamos -t "breezy-kwin-steamos:amd64" --load . \ No newline at end of file diff --git a/kwin/src/breezydesktopeffect.cpp b/kwin/src/breezydesktopeffect.cpp index 9ada276..c12d876 100644 --- a/kwin/src/breezydesktopeffect.cpp +++ b/kwin/src/breezydesktopeffect.cpp @@ -1,6 +1,8 @@ #include "core/output.h" #include "core/rendertarget.h" #include "core/renderviewport.h" +#include "cursor.h" +#include "pointer_input.h" #include "kcm/shortcuts.h" #include "breezydesktopeffect.h" #include "breezydesktopconfig.h" @@ -122,6 +124,10 @@ BreezyDesktopEffect::BreezyDesktopEffect() BreezyShortcuts::TOGGLE_FOLLOW_MODE, [this]() { this->toggleSmoothFollow(); } ); + setupGlobalShortcut( + BreezyShortcuts::CURSOR_TO_FOCUSED_DISPLAY, + [this]() { this->moveCursorToFocusedDisplay(); } + ); connect(effects, &EffectsHandler::cursorShapeChanged, this, &BreezyDesktopEffect::updateCursorImage); updateCursorImage(); @@ -203,6 +209,11 @@ void BreezyDesktopEffect::recenter() { XRDriverIPC::instance().writeControlFlags(flags); } +void BreezyDesktopEffect::setLookingAtScreenIndex(int index) +{ + m_lookingAtScreenIndex = index; +} + void BreezyDesktopEffect::reconfigure(ReconfigureFlags) { BreezyDesktopConfig::self()->read(); @@ -770,6 +781,23 @@ void BreezyDesktopEffect::updateCursorPos() Q_EMIT cursorPosChanged(); } } + +void BreezyDesktopEffect::warpPointerToOutputCenter(Output *output) +{ + if (!output) { + return; + } + const QRect geometry = output->geometry(); + const QPointF center = geometry.center(); + Cursors::self()->mouse()->setPos(center); +} + +void BreezyDesktopEffect::moveCursorToFocusedDisplay() +{ + if (m_lookingAtScreenIndex == -1) return; + + warpPointerToOutputCenter(effects->screens().at(m_lookingAtScreenIndex)); +} } #include "breezydesktopeffect.moc" \ No newline at end of file diff --git a/kwin/src/breezydesktopeffect.h b/kwin/src/breezydesktopeffect.h index ec9beda..2edd699 100644 --- a/kwin/src/breezydesktopeffect.h +++ b/kwin/src/breezydesktopeffect.h @@ -19,6 +19,7 @@ namespace KWin Q_OBJECT Q_PROPERTY(bool isEnabled READ isEnabled NOTIFY enabledStateChanged) Q_PROPERTY(bool zoomOnFocusEnabled READ isZoomOnFocusEnabled WRITE setZoomOnFocusEnabled NOTIFY zoomOnFocusChanged) + Q_PROPERTY(int lookingAtScreenIndex READ lookingAtScreenIndex WRITE setLookingAtScreenIndex) Q_PROPERTY(bool imuResetState READ imuResetState NOTIFY imuResetStateChanged) Q_PROPERTY(QList imuRotations READ imuRotations) Q_PROPERTY(quint32 imuTimeElapsedMs READ imuTimeElapsedMs) @@ -62,6 +63,8 @@ namespace KWin bool isEnabled() const; bool isZoomOnFocusEnabled() const; void setZoomOnFocusEnabled(bool enabled); + int lookingAtScreenIndex() const { return m_lookingAtScreenIndex; } + void setLookingAtScreenIndex(int index); QList imuRotations() const; quint32 imuTimeElapsedMs() const; quint64 imuTimestamp() const; @@ -105,6 +108,7 @@ namespace KWin void updateCursorPos(); QVariantList listVirtualDisplays() const; bool removeVirtualDisplay(const QString &id); + void moveCursorToFocusedDisplay(); Q_SIGNALS: void lookAheadOverrideChanged(); @@ -138,12 +142,14 @@ namespace KWin void toggleSmoothFollow(); void setSmoothFollowThreshold(float threshold); void updateDriverSmoothFollowSettings(); + void warpPointerToOutputCenter(Output *output); QString m_cursorImageSource; QSize m_cursorImageSize; bool m_enabled = false; bool m_zoomOnFocusEnabled = false; + int m_lookingAtScreenIndex = -1; // -1 means disabled/unknown bool m_imuResetState; QList m_imuRotations; quint32 m_imuTimeElapsedMs; diff --git a/kwin/src/kcm/breezydesktopeffectkcm.cpp b/kwin/src/kcm/breezydesktopeffectkcm.cpp index fc34e0f..b720817 100644 --- a/kwin/src/kcm/breezydesktopeffectkcm.cpp +++ b/kwin/src/kcm/breezydesktopeffectkcm.cpp @@ -320,6 +320,7 @@ BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPlu addShortcutAction(actionCollection, BreezyShortcuts::RECENTER); addShortcutAction(actionCollection, BreezyShortcuts::TOGGLE_ZOOM_ON_FOCUS); addShortcutAction(actionCollection, BreezyShortcuts::TOGGLE_FOLLOW_MODE); + addShortcutAction(actionCollection, BreezyShortcuts::CURSOR_TO_FOCUSED_DISPLAY); ui.shortcutsEditor->addCollection(actionCollection); connect(ui.shortcutsEditor, &KShortcutsEditor::keyChange, this, &BreezyDesktopEffectConfig::markAsChanged); connect(ui.EffectEnabled, &QCheckBox::toggled, this, &BreezyDesktopEffectConfig::updateDriverEnabled); diff --git a/kwin/src/kcm/shortcuts.h b/kwin/src/kcm/shortcuts.h index 1fd778d..d4cbbe7 100644 --- a/kwin/src/kcm/shortcuts.h +++ b/kwin/src/kcm/shortcuts.h @@ -34,4 +34,10 @@ namespace BreezyShortcuts { QStringLiteral("Toggle Follow Mode"), QStringLiteral("Toggle Follow Mode") }; + + const Shortcut CURSOR_TO_FOCUSED_DISPLAY = { + Qt::CTRL | Qt::META | Qt::Key_Period, + QStringLiteral("Move Cursor to Focused Display"), + QStringLiteral("Move Cursor to Focused Display") + }; } diff --git a/kwin/src/qml/BreezyDesktop.qml b/kwin/src/qml/BreezyDesktop.qml index 435d5fb..ff6fae6 100644 --- a/kwin/src/qml/BreezyDesktop.qml +++ b/kwin/src/qml/BreezyDesktop.qml @@ -11,6 +11,7 @@ Node { required property var fovDetails required property var monitorPlacements property int focusedMonitorIndex: -1 + property int lookingAtMonitorIndex: -1 property var smoothFollowFocusedDisplay Displays { @@ -28,16 +29,24 @@ Node { const rotations = smoothFollowEnabled ? effect.smoothFollowOrigin : effect.imuRotations; if (rotations && rotations.length > 0) { let focusedIndex = -1; + let lookingAtIndex = -1; + + lookingAtIndex = displays.findFocusedMonitor( + displays.eusToNwuQuat(rotations[0]), + breezyDesktop.monitorPlacements.map(monitorVectors => monitorVectors.centerLook), + breezyDesktop.focusedMonitorIndex, + smoothFollowEnabled, + breezyDesktop.fovDetails, + breezyDesktop.screens.map(screen => screen.geometry) + ); + + if (breezyDesktop.lookingAtMonitorIndex !== lookingAtIndex) { + breezyDesktop.lookingAtMonitorIndex = lookingAtIndex; + effect.lookingAtScreenIndex = lookingAtIndex; + } if (effect.zoomOnFocusEnabled || smoothFollowEnabled) { - focusedIndex = displays.findFocusedMonitor( - displays.eusToNwuQuat(rotations[0]), - breezyDesktop.monitorPlacements.map(monitorVectors => monitorVectors.centerLook), - breezyDesktop.focusedMonitorIndex, - smoothFollowEnabled, - breezyDesktop.fovDetails, - breezyDesktop.screens.map(screen => screen.geometry) - ); + focusedIndex = lookingAtIndex; } let focusedDisplay;