mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
feat: 适配wayland
适配wayland Log: 适配wayland Influence: wayland适配 Change-Id: I61ec8f82aa2f7e92e81e3f669d6b8019bffb4e75
This commit is contained in:
parent
0d1f12dc1b
commit
f8984e9c61
@ -25,6 +25,7 @@
|
||||
#include "xcb_misc.h"
|
||||
#include "appswingeffectbuilder.h"
|
||||
#include "appspreviewprovider.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
@ -142,6 +143,10 @@ bool AppItem::isValid() const
|
||||
// window behaviors like minimization.
|
||||
void AppItem::updateWindowIconGeometries()
|
||||
{
|
||||
// wayland没做处理
|
||||
if (Utils::IS_WAYLAND_DISPLAY)
|
||||
return;
|
||||
|
||||
const QRect r(mapToGlobal(QPoint(0, 0)),
|
||||
mapToGlobal(QPoint(width(), height())));
|
||||
if (!QX11Info::connection()) {
|
||||
|
@ -224,6 +224,8 @@ void PreviewContainer::updatePreviewCursor()
|
||||
int cursorSize = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-size", 24).toInt();
|
||||
if (theme != lastCursorTheme || cursorSize != lastCursorSize) {
|
||||
QCursor *cursor = ImageUtil::loadQCursorFromX11Cursor(theme.toStdString().c_str(), "left_ptr", cursorSize);
|
||||
if (!cursor)
|
||||
return;
|
||||
lastCursorTheme = theme;
|
||||
lastCursorSize = cursorSize;
|
||||
setCursor(*cursor);
|
||||
|
@ -221,6 +221,12 @@ int main(int argc, char *argv[])
|
||||
// 注册任务栏的DBus服务
|
||||
MainWindow mw;
|
||||
DBusDockAdaptors adaptor(&mw);
|
||||
|
||||
if(Utils::IS_WAYLAND_DISPLAY) {
|
||||
mw.setAttribute(Qt::WA_NativeWindow);
|
||||
mw.windowHandle()->setProperty("_d_dwayland_window-type", "dock");
|
||||
}
|
||||
|
||||
QDBusConnection::sessionBus().registerService("com.deepin.dde.Dock");
|
||||
QDBusConnection::sessionBus().registerObject("/com/deepin/dde/Dock", "com.deepin.dde.Dock", &mw);
|
||||
|
||||
|
@ -233,7 +233,7 @@ void AbstractPluginsController::loadPlugin(const QString &pluginFile)
|
||||
}
|
||||
|
||||
if (interface->pluginName() == "multitasking") {
|
||||
if (qEnvironmentVariable("XDG_SESSION_TYPE").contains("wayland") or Dtk::Core::DSysInfo::deepinType() == Dtk::Core::DSysInfo::DeepinServer) {
|
||||
if (Utils::IS_WAYLAND_DISPLAY or Dtk::Core::DSysInfo::deepinType() == Dtk::Core::DSysInfo::DeepinServer) {
|
||||
for (auto &pair : m_pluginLoadMap.keys()) {
|
||||
if (pair.first == pluginFile) {
|
||||
m_pluginLoadMap.remove(pair);
|
||||
|
@ -138,6 +138,8 @@ void DockPopupWindow::updatePopupWindowCursor()
|
||||
int cursorSize = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-size", 24).toInt();
|
||||
if (theme != lastCursorTheme || cursorSize != lastCursorSize) {
|
||||
QCursor *cursor = ImageUtil::loadQCursorFromX11Cursor(theme.toStdString().c_str(), "left_ptr", cursorSize);
|
||||
if (!cursor)
|
||||
return;
|
||||
lastCursorTheme = theme;
|
||||
lastCursorSize = cursorSize;
|
||||
setCursor(*cursor);
|
||||
|
@ -32,7 +32,10 @@
|
||||
#include <QVariantAnimation>
|
||||
#include <QX11Info>
|
||||
#include <QDBusConnection>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include <qpa/qplatformscreen.h>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
const QString MonitorsSwitchTime = "monitorsSwitchTime";
|
||||
const QString OnlyShowPrimary = "onlyShowPrimary";
|
||||
@ -714,13 +717,25 @@ void MultiScreenWorker::onRequestNotifyWindowManager()
|
||||
if ((!DIS_INS->isCopyMode() && m_ds.current() != m_ds.primary()) || m_hideMode != HideMode::KeepShowing) {
|
||||
lastRect = QRect();
|
||||
|
||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||
QList<QVariant> varList;
|
||||
varList.append(0);//dock位置
|
||||
varList.append(0);//dock高度/宽度
|
||||
varList.append(0);//start值
|
||||
varList.append(0);//end值
|
||||
if (parent()->windowHandle()->handle()) {
|
||||
QGuiApplication::platformNativeInterface()->setWindowProperty(parent()->windowHandle()->handle(),"_d_dwayland_dockstrut", varList);
|
||||
}
|
||||
} else {
|
||||
const auto display = QX11Info::display();
|
||||
if (!display) {
|
||||
qWarning() << "QX11Info::display() is " << display;
|
||||
return;
|
||||
}
|
||||
|
||||
//XcbMisc::instance()->clear_strut_partial(xcb_window_t(parent()->winId()));
|
||||
XcbMisc::instance()->clear_strut_partial(xcb_window_t(parent()->winId()));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -737,8 +752,42 @@ void MultiScreenWorker::onRequestNotifyWindowManager()
|
||||
qDebug() << "dock real geometry:" << dockGeometry;
|
||||
qDebug() << "screen width:" << DIS_INS->screenRawWidth() << ", height:" << DIS_INS->screenRawHeight();
|
||||
|
||||
const qreal ratio = qApp->devicePixelRatio();
|
||||
const qreal &ratio = qApp->devicePixelRatio();
|
||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||
// TODO 下面可能是问题的代码
|
||||
// TODO 未计算时尚模式的边距
|
||||
QList<QVariant> varList = {0, 0, 0, 0};
|
||||
switch (m_position) {
|
||||
case Position::Top:
|
||||
varList[0] = 1;
|
||||
varList[1] = dockGeometry.height() * ratio;
|
||||
varList[2] = dockGeometry.x() * ratio;
|
||||
varList[3] = (dockGeometry.x() + dockGeometry.width()) * ratio;
|
||||
break;
|
||||
case Position::Bottom:
|
||||
varList[0] = 3;
|
||||
varList[1] = dockGeometry.height() * ratio;
|
||||
varList[2] = dockGeometry.x() * ratio;
|
||||
varList[3] = (dockGeometry.x() + dockGeometry.width()) * ratio;
|
||||
break;
|
||||
case Position::Left:
|
||||
varList[0] = 0;
|
||||
varList[1] = dockGeometry.width() * ratio;
|
||||
varList[2] = dockGeometry.x() * ratio;
|
||||
varList[3] = dockGeometry.height() * ratio;
|
||||
break;
|
||||
case Position::Right:
|
||||
varList[0] = 2;
|
||||
varList[1] = dockGeometry.width() * ratio;
|
||||
varList[2] = dockGeometry.x() * ratio;
|
||||
varList[3] = dockGeometry.height() * ratio;
|
||||
break;
|
||||
}
|
||||
|
||||
if (parent()->windowHandle()->handle()) {
|
||||
QGuiApplication::platformNativeInterface()->setWindowProperty(parent()->windowHandle()->handle(),"_d_dwayland_dockstrut", varList);
|
||||
}
|
||||
} else {
|
||||
XcbMisc::Orientation orientation = XcbMisc::OrientationTop;
|
||||
double strut = 0;
|
||||
double strutStart = 0;
|
||||
@ -779,10 +828,11 @@ void MultiScreenWorker::onRequestNotifyWindowManager()
|
||||
return;
|
||||
}
|
||||
|
||||
// XcbMisc::instance()->set_strut_partial(static_cast<xcb_window_t>(parent()->winId()), orientation,
|
||||
// static_cast<uint>(strut + WINDOWMARGIN * ratio), // 设置窗口与屏幕边缘距离,需要乘缩放
|
||||
// static_cast<uint>(strutStart), // 设置任务栏起点坐标(上下为x,左右为y)
|
||||
// static_cast<uint>(strutEnd)); // 设置任务栏终点坐标(上下为x,左右为y)
|
||||
XcbMisc::instance()->set_strut_partial(static_cast<xcb_window_t>(parent()->winId()), orientation,
|
||||
static_cast<uint>(strut + WINDOWMARGIN * ratio), // 设置窗口与屏幕边缘距离,需要乘缩放
|
||||
static_cast<uint>(strutStart), // 设置任务栏起点坐标(上下为x,左右为y)
|
||||
static_cast<uint>(strutEnd)); // 设置任务栏终点坐标(上下为x,左右为y)
|
||||
}
|
||||
}
|
||||
|
||||
void MultiScreenWorker::onRequestUpdatePosition(const Position &fromPos, const Position &toPos)
|
||||
|
@ -1313,6 +1313,8 @@ void MainPanelControl::updatePanelCursor()
|
||||
int cursorSize = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-size", 24).toInt();
|
||||
if (theme != lastCursorTheme || cursorSize != lastCursorSize) {
|
||||
QCursor *cursor = ImageUtil::loadQCursorFromX11Cursor(theme.toStdString().c_str(), "left_ptr", cursorSize);
|
||||
if (!cursor)
|
||||
return;
|
||||
lastCursorTheme = theme;
|
||||
lastCursorSize = cursorSize;
|
||||
setCursor(*cursor);
|
||||
|
@ -143,6 +143,9 @@ private:
|
||||
lastCursorSize = cursorSize;
|
||||
const char* cursorName = (position == Bottom || position == Top) ? "v_double_arrow" : "h_double_arrow";
|
||||
QCursor *newCursor = ImageUtil::loadQCursorFromX11Cursor(theme.toStdString().c_str(), cursorName, cursorSize);
|
||||
if (!newCursor)
|
||||
return;
|
||||
|
||||
setCursor(*newCursor);
|
||||
if (lastCursor)
|
||||
delete lastCursor;
|
||||
|
Loading…
x
Reference in New Issue
Block a user