forked from openkylin/ukui-panel
fix(taskManager):优化iconGeometry实现方式
This commit is contained in:
parent
a2cb6fae1b
commit
5ebcdbdf46
|
@ -367,35 +367,29 @@ DropArea {
|
|||
*/
|
||||
property var currentWinIdList: model.CurrentWinIdList
|
||||
property int itemIndex: DelegateModel.itemsIndex
|
||||
property Component iconGeometryTimer: Component {
|
||||
Timer {
|
||||
id: timer
|
||||
interval: 500
|
||||
running: true
|
||||
onTriggered: {
|
||||
taskItemRoot.updateIconGeometry();
|
||||
timer.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
property bool invisibleOfFront: (x < taskItemView.contentX) || (y < taskItemView.contentY)
|
||||
property bool invisibleOfBack: (x > taskItemView.width + taskItemView.contentX) || (y > taskItemView.height + taskItemView.contentY)
|
||||
|
||||
function updateIconGeometry() {
|
||||
if (taskItemLoader.item && !taskItemRoot.DelegateModel.inTempItems) {
|
||||
taskItemLoader.item.updateIconGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
function addIndexToGeometryList() {
|
||||
if (model.CurrentWinIdList) {
|
||||
if (model.CurrentWinIdList.length > 0) {
|
||||
iconGeometryTimer.createObject(taskItemRoot);
|
||||
if (model.CurrentWinIdList.length > 0 && !taskItemView.pendingUpdatesList.includes(itemIndex)) {
|
||||
taskItemView.pendingUpdatesList.push(itemIndex);
|
||||
updateGeometryList.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
onItemIndexChanged: {
|
||||
updateIconGeometryTimer.restart();
|
||||
Component.onCompleted: {
|
||||
//初始化、拖拽后更新model、切换任务栏方向,都会触发
|
||||
addIndexToGeometryList();
|
||||
}
|
||||
onCurrentWinIdListChanged: {
|
||||
updateIconGeometry();
|
||||
addIndexToGeometryList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -424,20 +418,28 @@ DropArea {
|
|||
onCountChanged: {
|
||||
positionViewAtBeginning();
|
||||
}
|
||||
|
||||
onOrientationChanged: {
|
||||
positionViewAtBeginning();
|
||||
updateIconGeometryTimer.restart();
|
||||
}
|
||||
onTaskItemSizeChanged: {
|
||||
positionViewAtBeginning();
|
||||
updateIconGeometryTimer.restart();
|
||||
pushAllIndex();
|
||||
}
|
||||
onIsMergeStatusChanged: {
|
||||
positionViewAtBeginning();
|
||||
updateIconGeometryTimer.restart();
|
||||
pushAllIndex();
|
||||
}
|
||||
onWindowVisibleChanged: {
|
||||
updateIconGeometryTimer.restart();
|
||||
if(UkuiTaskManager.WindowManager.isWaylandSession) {
|
||||
pushAllIndex();
|
||||
}
|
||||
}
|
||||
onContentXChanged: {
|
||||
pushAllIndex();
|
||||
}
|
||||
onContentYChanged: {
|
||||
pushAllIndex();
|
||||
}
|
||||
function updateIconState() {
|
||||
for (let i = 0; i < taskItemDelegateModel.count; ++i) {
|
||||
|
@ -452,19 +454,63 @@ DropArea {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* iconGeometry
|
||||
*/
|
||||
property var pendingUpdatesList: []
|
||||
|
||||
Connections {
|
||||
target: Widget.container
|
||||
function onPositionChanged() {
|
||||
taskItemView.pushAllIndex();
|
||||
}
|
||||
}
|
||||
|
||||
function pushAllIndex() {
|
||||
pendingUpdatesList.length = 0;
|
||||
for (var i = 0; i < taskItemView.count; ++i) {
|
||||
pendingUpdatesList.push(i);
|
||||
}
|
||||
if (pendingUpdatesList.length > 0) {
|
||||
updateGeometryList.restart();
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: updateIconGeometryTimer
|
||||
interval: 500
|
||||
id: updateGeometryList
|
||||
interval: 1000
|
||||
|
||||
onTriggered: {
|
||||
for (var i = 0; i < taskItemView.count; ++i) {
|
||||
let item = taskItemView.itemAtIndex(i);
|
||||
for (let i = 0; i < taskItemView.pendingUpdatesList.length; ++i) {
|
||||
let index = taskItemView.pendingUpdatesList[i];
|
||||
let item = taskItemView.itemAtIndex(index);
|
||||
if (item) {
|
||||
item.updateIconGeometry();
|
||||
if (item.invisibleOfFront) {
|
||||
UkuiTaskManager.WindowManager.setMinimizedGeometry(item.currentWinIdList, virtualFrontItem);
|
||||
} else if (item.invisibleOfBack) {
|
||||
UkuiTaskManager.WindowManager.setMinimizedGeometry(item.currentWinIdList, virtualBackItem);
|
||||
} else {
|
||||
item.updateIconGeometry();
|
||||
}
|
||||
}
|
||||
}
|
||||
taskItemView.pendingUpdatesList.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: virtualFrontItem
|
||||
x: 0; y: 0
|
||||
width: 10
|
||||
height: 10
|
||||
}
|
||||
Item {
|
||||
id: virtualBackItem
|
||||
x: taskItemView.width - width; y: taskItemView.height - height
|
||||
width: 10
|
||||
height: 10
|
||||
}
|
||||
|
||||
displaced: Transition {
|
||||
NumberAnimation {
|
||||
properties: "x,y"
|
||||
|
|
|
@ -291,7 +291,7 @@ void WaylandWindowManager::setStartupGeometry(const QString &wid, QQuickItem *it
|
|||
return;
|
||||
}
|
||||
KWayland::Client::Surface *s = KWayland::Client::Surface::fromWindow(item->window());
|
||||
m_uuidToWindow.value(wid.toUtf8())->setStartupGeometry(s, {item->mapToScene({item->x(), item->y()}).toPoint(), item->size().toSize()});
|
||||
m_uuidToWindow.value(wid.toUtf8())->setStartupGeometry(s, {item->mapToScene({0, 0}).toPoint(), item->size().toSize()});
|
||||
delete s;
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ void WaylandWindowManager::setMinimizedGeometry(const QString &wid, QQuickItem *
|
|||
return;
|
||||
}
|
||||
KWayland::Client::Surface *s = KWayland::Client::Surface::fromWindow(item->window());
|
||||
m_uuidToWindow.value(wid.toUtf8())->setMinimizedGeometry(s, {item->mapToScene({item->x(), item->y()}).toPoint(), item->size().toSize()});
|
||||
m_uuidToWindow.value(wid.toUtf8())->setMinimizedGeometry(s, {item->mapToScene({0, 0}).toPoint(), item->size().toSize()});
|
||||
delete s;
|
||||
}
|
||||
|
||||
|
@ -333,4 +333,3 @@ void WaylandWindowManager::activateWindowView(const QStringList &wids)
|
|||
}
|
||||
AbstractWindowManager::activateWindowView(wids);
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,11 @@ QString WindowManager::appId(const QString &wid)
|
|||
return WindowManagerPrivate::interface()->appId(wid);
|
||||
}
|
||||
|
||||
bool WindowManager::isWaylandSession()
|
||||
{
|
||||
return QString(getenv("XDG_SESSION_TYPE")) == "wayland";
|
||||
}
|
||||
|
||||
QRect WindowManager::geometry(const QString &wid)
|
||||
{
|
||||
return WindowManagerPrivate::interface()->geometry(wid);
|
||||
|
|
|
@ -28,6 +28,7 @@ class WindowManagerPrivate;
|
|||
class WindowManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool isWaylandSession READ isWaylandSession CONSTANT)
|
||||
public:
|
||||
static WindowManager *self();
|
||||
|
||||
|
@ -57,6 +58,7 @@ public:
|
|||
static bool isDemandsAttention(const QString& wid);
|
||||
static quint32 pid(const QString& wid);
|
||||
static QString appId(const QString& wid);
|
||||
static bool isWaylandSession();
|
||||
Q_INVOKABLE static QRect geometry(const QString& wid);
|
||||
Q_INVOKABLE void setStartupGeometry(const QString& wid, QQuickItem *item);
|
||||
Q_INVOKABLE void setMinimizedGeometry(const QString& wid, QQuickItem *item);
|
||||
|
|
|
@ -265,7 +265,7 @@ void XcbWindowManager::setStartupGeometry(const QString &wid, QQuickItem *item)
|
|||
return;
|
||||
}
|
||||
NETWinInfo info(QX11Info::connection(), wid.toInt(), item->window()->winId(), NET::WMIconGeometry, {}, NET::Client);
|
||||
info.setIconGeometry(QRect(item->mapToGlobal({item->x(), item->y()}).toPoint(), item->size().toSize()));
|
||||
info.setIconGeometry(QRect(item->mapToGlobal({0, 0}).toPoint(), item->size().toSize()));
|
||||
}
|
||||
|
||||
void XcbWindowManager::setMinimizedGeometry(const QString &wid, QQuickItem *item)
|
||||
|
|
Loading…
Reference in New Issue