Skip to content
Open
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
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Build-Depends:
libxfixes-dev,
pkg-config,
qt6-base-dev,
libxcb1-dev,
Standards-Version: 4.1.3
Homepage: https://www.deepin.org

Expand Down
4 changes: 3 additions & 1 deletion src/dde-session/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

Expand All @@ -14,6 +14,7 @@ pkg_check_modules(GIO2 REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(XCURSOR REQUIRED IMPORTED_TARGET xcursor)
pkg_check_modules(XFIXES REQUIRED IMPORTED_TARGET xfixes)
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)
pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb)

# dbus adaptor
qt_add_dbus_adaptor(ADAPTER_SOURCES
Expand Down Expand Up @@ -91,6 +92,7 @@ target_link_libraries(dde-session
PkgConfig::XCURSOR
PkgConfig::XFIXES
PkgConfig::X11
PkgConfig::XCB
)

target_include_directories(dde-session PUBLIC
Expand Down
33 changes: 33 additions & 0 deletions src/dde-session/impl/sessionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#include <QFile>
#include <QDBusPendingCall>
#include <QDBusPendingCallWatcher>
#include <QSocketNotifier>

#include <unistd.h>
#include <signal.h>
#include <xcb/xcb.h>

#define MASK_SERVICE(service) \
{\
Expand Down Expand Up @@ -541,9 +543,40 @@ void SessionManager::init()
startAtSpiService();
startObexService();

if (!Utils::IS_WAYLAND_DISPLAY) {
watchXConnection();
}

qInfo() << "session manager init finished";
}

void SessionManager::watchXConnection()
{
xcb_connection_t *conn = xcb_connect(nullptr, nullptr);
if (xcb_connection_has_error(conn)) {
qWarning() << "watchXConnection: failed to connect to X server";
xcb_disconnect(conn);
return;
}

int fd = xcb_get_file_descriptor(conn);
auto *notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(notifier, &QSocketNotifier::activated, this, [=]() {
// 排空所有待处理事件
xcb_generic_event_t *ev;
while ((ev = xcb_poll_for_event(conn)) != nullptr) {
free(ev);
}
// 若连接已断开则触发登出
if (xcb_connection_has_error(conn)) {
qWarning() << "X connection closed, logging out";
notifier->setEnabled(false);
xcb_disconnect(conn);
doLogout();
}
});
}

void SessionManager::stopSogouIme()
{
// TODO 使用kill函数杀死进程,前提是进程存在
Expand Down
1 change: 1 addition & 0 deletions src/dde-session/impl/sessionmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public Q_SLOTS:
void setDPMSMode(bool on);

void handleOSSignal();
void watchXConnection();

void shutdown(bool force);
void reboot(bool force);
Expand Down
Loading