26 : m_shutdownTimer(new QTimer(this))
27 , m_exposeAction(new QAction(this))
28 , m_exposeAllAction(new QAction(this))
29 , m_exposeClassAction(new QAction(this))
30 , m_exposeClassCurrentDesktopAction(new QAction(this))
32 qmlRegisterUncreatableType<WindowViewEffect>(
"org.kde.KWin.Effect.WindowView", 1, 0,
"WindowView", QStringLiteral(
"WindowView cannot be created in QML"));
34 new WindowView1Adaptor(
this);
36 QDBusConnection::sessionBus().registerObject(s_dbusObjectPath,
this);
37 QDBusConnection::sessionBus().registerService(s_dbusServiceName);
39 m_shutdownTimer->setSingleShot(
true);
40 connect(m_shutdownTimer, &QTimer::timeout,
this, &WindowViewEffect::realDeactivate);
43 setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(
"kwin/effects/windowview/qml/main.qml"))));
45 m_exposeAction->setObjectName(QStringLiteral(
"Expose"));
46 m_exposeAction->setText(i18n(
"Toggle Present Windows (Current desktop)"));
47 KGlobalAccel::self()->setDefaultShortcut(m_exposeAction, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F9));
48 KGlobalAccel::self()->setShortcut(m_exposeAction, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F9));
49 m_shortcut = KGlobalAccel::self()->shortcut(m_exposeAction);
50 connect(m_exposeAction, &QAction::triggered,
this, [
this]() {
54 m_exposeAllAction->setObjectName(QStringLiteral(
"ExposeAll"));
55 m_exposeAllAction->setText(i18n(
"Toggle Present Windows (All desktops)"));
56 KGlobalAccel::self()->setDefaultShortcut(m_exposeAllAction, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F10) << Qt::Key_LaunchC);
57 KGlobalAccel::self()->setShortcut(m_exposeAllAction, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F10) << Qt::Key_LaunchC);
58 m_shortcutAll = KGlobalAccel::self()->shortcut(m_exposeAllAction);
59 connect(m_exposeAllAction, &QAction::triggered,
this, [
this]() {
63 m_exposeClassAction->setObjectName(QStringLiteral(
"ExposeClass"));
64 m_exposeClassAction->setText(i18n(
"Toggle Present Windows (Window class)"));
65 KGlobalAccel::self()->setDefaultShortcut(m_exposeClassAction, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F7));
66 KGlobalAccel::self()->setShortcut(m_exposeClassAction, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F7));
67 m_shortcutClass = KGlobalAccel::self()->shortcut(m_exposeClassAction);
68 connect(m_exposeClassAction, &QAction::triggered,
this, [
this]() {
72 m_exposeClassCurrentDesktopAction->setObjectName(QStringLiteral(
"ExposeClassCurrentDesktop"));
73 m_exposeClassCurrentDesktopAction->setText(i18n(
"Toggle Present Windows (Window class on current desktop)"));
74 KGlobalAccel::self()->setDefaultShortcut(m_exposeClassCurrentDesktopAction, QList<QKeySequence>());
75 KGlobalAccel::self()->setShortcut(m_exposeClassCurrentDesktopAction, QList<QKeySequence>());
76 m_shortcutClassCurrentDesktop = KGlobalAccel::self()->shortcut(m_exposeClassCurrentDesktopAction);
77 connect(m_exposeClassCurrentDesktopAction, &QAction::triggered,
this, [
this]() {
81 connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged,
this, [
this](QAction *action,
const QKeySequence &seq) {
82 if (action->objectName() == QStringLiteral(
"Expose")) {
84 m_shortcut.append(seq);
85 }
else if (action->objectName() == QStringLiteral(
"ExposeAll")) {
86 m_shortcutAll.clear();
87 m_shortcutAll.append(seq);
88 }
else if (action->objectName() == QStringLiteral(
"ExposeClass")) {
89 m_shortcutClass.clear();
90 m_shortcutClass.append(seq);
91 }
else if (action->objectName() == QStringLiteral(
"ExposeClassCurrentDesktop")) {
92 m_shortcutClassCurrentDesktop.clear();
93 m_shortcutClassCurrentDesktop.append(seq);
97 m_realtimeToggleAction =
new QAction(
this);
98 connect(m_realtimeToggleAction, &QAction::triggered,
this, [
this]() {
100 if (m_partialActivationFactor < 0.5) {
106 if (m_partialActivationFactor > 0.5) {
161 WindowViewConfig::self()->read();
163 setLayout(WindowViewConfig::layoutMode());
168 for (
ElectricBorder border : std::as_const(m_borderActivateAll)) {
172 m_borderActivate.clear();
173 m_borderActivateAll.clear();
174 m_borderActivateClass.clear();
176 const auto borderActivate = WindowViewConfig::borderActivate();
177 for (
int i : borderActivate) {
181 const auto activateAll = WindowViewConfig::borderActivateAll();
182 for (
int i : activateAll) {
186 const auto activateClass = WindowViewConfig::borderActivateClass();
187 for (
int i : activateClass) {
191 const auto activateClassCurrentDesktop = WindowViewConfig::borderActivateClassCurrentDesktop();
192 for (
int i : activateClassCurrentDesktop) {
197 auto touchCallback = [
this](
ElectricBorder border,
const QPointF &deltaProgress,
const Output *screen) {
201 if (m_touchBorderActivate.contains(border)) {
203 }
else if (m_touchBorderActivateAll.contains(border)) {
205 }
else if (m_touchBorderActivateClass.contains(border)) {
207 }
else if (m_touchBorderActivateClassCurrentDesktop.contains(border)) {
210 const int maxDelta = 500;
212 partialActivate(std::min(1.0, std::abs(deltaProgress.y()) / maxDelta));
214 partialActivate(std::min(1.0, std::abs(deltaProgress.x()) / maxDelta));
218 QList<int> touchActivateBorders = WindowViewConfig::touchBorderActivate();
219 for (
const int &border : touchActivateBorders) {
223 touchActivateBorders = WindowViewConfig::touchBorderActivateAll();
224 for (
const int &border : touchActivateBorders) {
228 touchActivateBorders = WindowViewConfig::touchBorderActivateClass();
229 for (
const int &border : touchActivateBorders) {
233 touchActivateBorders = WindowViewConfig::touchBorderActivateClassCurrentDesktop();
234 for (
const int &border : touchActivateBorders) {
235 m_touchBorderActivateClassCurrentDesktop.append(
ElectricBorder(border));