Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions panels/dock/x11dockhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include <xcb/xcb.h>
#include <xcb/xproto.h>

#include <QAbstractNativeEventFilter>

Check warning on line 15 in panels/dock/x11dockhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QAbstractNativeEventFilter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>

Check warning on line 16 in panels/dock/x11dockhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPointer>

Check warning on line 17 in panels/dock/x11dockhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPointer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusConnection>

Check warning on line 18 in panels/dock/x11dockhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace dock {
Q_LOGGING_CATEGORY(dockX11Log, "dde.shell.dock.x11")
Expand Down Expand Up @@ -319,6 +320,7 @@
: DockHelper(panel)
, m_xcbHelper(new XcbEventFilter(this))
, m_updateDockAreaTimer(new QTimer(this))
, m_showingDesktop(false)
{
m_updateDockAreaTimer->setSingleShot(true);
m_updateDockAreaTimer->setInterval(100);
Expand All @@ -333,6 +335,7 @@
connect(panel, &DockPanel::dockScreenChanged, m_updateDockAreaTimer, static_cast<void (QTimer::*)()>(&QTimer::start));

qGuiApp->installNativeEventFilter(m_xcbHelper);
setupKWinDBusConnection();
onHideModeChanged(panel->hideMode());
}

Expand Down Expand Up @@ -462,6 +465,9 @@
bool oldOverlap = data->overlap;
if (!data->isMinimized) {
data->overlap = data->rect.intersects(m_dockArea);
} else {
// 最小化的窗口不会与任务栏重叠
data->overlap = false;
}

if (oldOverlap != data->overlap) {
Expand Down Expand Up @@ -522,6 +528,11 @@

bool X11DockHelper::isWindowOverlap()
{
// 如果当前处于显示桌面状态,则认为没有窗口重叠
if (m_showingDesktop) {
return false;
}

// any widnow overlap
bool overlap = false;
std::for_each(m_windows.begin(), m_windows.end(), [&overlap](const auto &window) {
Expand Down Expand Up @@ -614,4 +625,26 @@
xcb_configure_window(m_connection, m_triggerWindow, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
xcb_flush(m_connection);
}

void X11DockHelper::setupKWinDBusConnection()
{
// 连接到 KWin 的 D-Bus 接口监听 showingDesktopChanged 信号
QDBusConnection::sessionBus().connect(
"org.kde.KWin",
"/KWin",
"org.kde.KWin",
"showingDesktopChanged",
this,
SLOT(onShowingDesktopChanged(bool))
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要同步下m_showingDesktop的状态吧,

}

void X11DockHelper::onShowingDesktopChanged(bool showing)
{
// 更新显示桌面状态
m_showingDesktop = showing;
// 触发窗口重叠状态变化检查
Q_EMIT isWindowOverlapChanged(isWindowOverlap());
}

} // namespace dock
5 changes: 5 additions & 0 deletions panels/dock/x11dockhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,20 @@ private Q_SLOTS:

void updateDockArea();

// KWin D-Bus signal handler
void onShowingDesktopChanged(bool showing);

private:
friend class XcbEventFilter;
void setupKWinDBusConnection();

private:
QHash<xcb_window_t, X11DockWakeUpArea *> m_areas;
QRect m_dockArea;
QHash<xcb_window_t, WindowData*> m_windows;
XcbEventFilter *m_xcbHelper;
QTimer *m_updateDockAreaTimer;
bool m_showingDesktop;
};

class X11DockWakeUpArea : public QObject, public DockWakeUpArea
Expand Down