dde-dock/frame/taskmanager/x11manager.h
tsic404 9de057e2cc refactor: add taskmanager from dde-application-manager
1. taskmanager used to identify which entry should map to window
  in x11 environmrnt, listen to xevent in anohter thread, and handle those event
when window create, destory, changed. use some way to identify which entry(desktopfile)
should mapped to changed window.
  in wayland, connected plsamawindow signal(window created destoried.
2. use taskmanager instead of dbus in old dock code

log: as title
2023-07-18 07:35:19 +00:00

64 lines
2.0 KiB
C++

// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef X11MANAGER_H
#define X11MANAGER_H
#include "windowinfox.h"
#include "xcbutils.h"
#include <QObject>
#include <QMap>
#include <QMutex>
#include <QTimer>
class TaskManager;
class X11Manager : public QObject
{
Q_OBJECT
public:
explicit X11Manager(TaskManager *_taskmanager, QObject *parent = nullptr);
WindowInfoX *findWindowByXid(XWindow xid);
WindowInfoX *registerWindow(XWindow xid);
void unregisterWindow(XWindow xid);
void handleClientListChanged();
void handleActiveWindowChangedX();
void listenRootWindowXEvent();
void listenWindowXEvent(WindowInfoX *winInfo);
void handleRootWindowPropertyNotifyEvent(XCBAtom atom);
void handleDestroyNotifyEvent(XWindow xid);
void handleMapNotifyEvent(XWindow xid);
void handleConfigureNotifyEvent(XWindow xid, int x, int y, int width, int height);
void handlePropertyNotifyEvent(XWindow xid, XCBAtom atom);
void eventHandler(uint8_t type, void *event);
void listenWindowEvent(WindowInfoX *winInfo);
void listenXEventUseXlib();
void listenXEventUseXCB();
Q_SIGNALS:
void requestUpdateHideState(bool delay);
void requestHandleActiveWindowChange(WindowInfoBase *info);
void requestAttachOrDetachWindow(WindowInfoBase *info);
private:
void addWindowLastConfigureEvent(XWindow xid, ConfigureEvent* event);
QPair<ConfigureEvent*, QTimer*> getWindowLastConfigureEvent(XWindow xid);
void delWindowLastConfigureEvent(XWindow xid);
private:
QMap<XWindow, WindowInfoX *> m_windowInfoMap;
TaskManager *m_taskmanager;
QMap<XWindow, QPair<ConfigureEvent*, QTimer*>> m_windowLastConfigureEventMap; // 手动回收ConfigureEvent和QTimer
QMutex m_mutex;
XWindow m_rootWindow; // 根窗口
bool m_listenXEvent; // 监听X事件
};
#endif // X11MANAGER_H