Zren / plasma-wallpapers

45 stars 8 forks source link

Activate blur with window single click #2

Closed psifidotos closed 5 years ago

psifidotos commented 6 years ago

In my system, plasma 5.13 when the user was activating a window with a single click the desktop blurring wasnt activated, the user had to drag the window around. I fixed it by changing the WindowsModel.qml code:

import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.3
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore

import org.kde.taskmanager 0.1 as TaskManager

Item {
    property alias screenGeometry: tasksModel.screenGeometry
    property bool noWindowActive: true
    property bool currentWindowMaximized: false
    property bool isActiveWindowPinned: false

    TaskManager.VirtualDesktopInfo { id: virtualDesktopInfo }
    TaskManager.ActivityInfo { id: activityInfo }
    TaskManager.TasksModel {
        id: tasksModel
        sortMode: TaskManager.TasksModel.SortVirtualDesktop
        groupMode: TaskManager.TasksModel.GroupDisabled

        activity: activityInfo.currentActivity
        virtualDesktop: virtualDesktopInfo.currentDesktop
        screenGeometry: wallpaper.screenGeometry

        filterByActivity: true
        filterByVirtualDesktop: true
        filterByScreen: true

        onActiveTaskChanged: {
            updateActiveWindowInfo()
        }

        Component.onCompleted: {
            activeWindowModel.sourceModel = tasksModel;
        }
    }
    PlasmaCore.SortFilterModel {
        id: activeWindowModel
        filterRole: 'IsActive'
        filterRegExp: 'true'
        onCountChanged: updateActiveWindowInfo();
    }

    function activeTask() {
        return activeWindowModel.get(0) || {}
    }

    function updateActiveWindowInfo() {
        var actTask = activeTask()
        noWindowActive = activeWindowModel.count === 0 || actTask.IsActive !== true
    }
}
nneto commented 5 years ago

@psifidotos Using Plasma 5.14, I tried installing the package with your changes but to no effect, still have to do more than open/click a window to activate.

EDIT: I think it was just a matter of restarting the computer. It's working!

bugworm commented 5 years ago

I think it should be a pull request, not issue (works for me btw)

Zren commented 5 years ago

The differences are:

diff --git a/inactiveblur/package/contents/ui/WindowModel.qml b/inactiveblur/package/contents/ui/WindowModel.qml
index 6359b61..462758c 100644
--- a/inactiveblur/package/contents/ui/WindowModel.qml
+++ b/inactiveblur/package/contents/ui/WindowModel.qml
@@ -21,29 +21,27 @@ Item {

        activity: activityInfo.currentActivity
        virtualDesktop: virtualDesktopInfo.currentDesktop
-       screenGeometry: wallpaper.screenGeometry // Warns "Unable to assign [undefined] to QRect" during init, but works thereafter.
+       screenGeometry: wallpaper.screenGeometry

        filterByActivity: true
        filterByVirtualDesktop: true
        filterByScreen: true

        onActiveTaskChanged: {
-           activeWindowModel.sourceModel = tasksModel
            updateActiveWindowInfo()
        }
-       onDataChanged: {
-           updateActiveWindowInfo()
+
+       Component.onCompleted: {
+           activeWindowModel.sourceModel = tasksModel;
        }
    }
    PlasmaCore.SortFilterModel {
        id: activeWindowModel
        filterRole: 'IsActive'
        filterRegExp: 'true'
-       sourceModel: tasksModel
-       onDataChanged: updateActiveWindowInfo()
+       onCountChanged: updateActiveWindowInfo();
    }

-
    function activeTask() {
        return activeWindowModel.get(0) || {}
    }
@@ -51,7 +49,5 @@ Item {
    function updateActiveWindowInfo() {
        var actTask = activeTask()
        noWindowActive = activeWindowModel.count === 0 || actTask.IsActive !== true
-       currentWindowMaximized = !noWindowActive && actTask.IsMaximized === true
-       isActiveWindowPinned = actTask.VirtualDesktop === -1;
    }
 }
Zren commented 5 years ago

Both mentioned changes are in v2.