actiondrawer: Use layershell to avoid taking focus from current window

We can use layershell to avoid taking focus from the current window,
which avoids any unnecessary behavior from an unfocus event.
This commit is contained in:
Devin Lin 2024-11-07 20:06:22 -08:00
parent 6e7376990b
commit f3dc108602
2 changed files with 19 additions and 11 deletions

View file

@ -7,10 +7,11 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import QtQuick.Window
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.layershell 1.0 as LayerShell
/**
* Window with the ActionDrawer component embedded in it.
@ -18,17 +19,21 @@ import org.kde.plasma.private.nanoshell 2.0 as NanoShell
* Used for overlaying the ActionDrawer if the original window does not cover
* the whole screen.
*/
NanoShell.FullScreenOverlay {
Window {
id: window
LayerShell.Window.scope: "overlay"
LayerShell.Window.anchors: LayerShell.Window.AnchorTop | LayerShell.Window.AnchorLeft | LayerShell.Window.AnchorRight | LayerShell.Window.AnchorBottom
LayerShell.Window.layer: LayerShell.Window.LayerOverlay
LayerShell.Window.exclusionZone: -1
LayerShell.Window.keyboardInteractivity: LayerShell.Window.KeyboardInteractivityNone
/**
* The ActionDrawer component.
*/
property alias actionDrawer: drawer
visible: drawer.intendedToBeVisible
width: Screen.width
height: Screen.height
color: "transparent"

View file

@ -14,7 +14,7 @@ import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
/**
* Root element that contains all the ActionDrawer's contents, and is anchored to the screen.
*/
Rectangle {
Item {
id: root
required property var actionDrawer
@ -31,12 +31,15 @@ Rectangle {
Kirigami.Theme.inherit: false
// Background color
color: Qt.rgba(Kirigami.Theme.backgroundColor.r,
Kirigami.Theme.backgroundColor.g,
Kirigami.Theme.backgroundColor.b,
(root.actionDrawer.mode == ActionDrawer.Portrait || notificationWidget.hasNotifications) ? 0.95 : 0.9)
Behavior on color { ColorAnimation { duration: Kirigami.Units.longDuration } }
opacity: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset))
Rectangle {
anchors.fill: parent
color: Qt.rgba(Kirigami.Theme.backgroundColor.r,
Kirigami.Theme.backgroundColor.g,
Kirigami.Theme.backgroundColor.b,
(root.actionDrawer.mode == ActionDrawer.Portrait || notificationWidget.hasNotifications) ? 0.95 : 0.9)
Behavior on color { ColorAnimation { duration: Kirigami.Units.longDuration } }
opacity: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset))
}
// Layout that switches between landscape and portrait mode
Loader {