fix(fullscreen):bug#277721 控制面板提权界面未置顶
This commit is contained in:
parent
ed75fe08de
commit
6d744cc196
|
@ -42,6 +42,7 @@ using namespace kdk;
|
|||
|
||||
FullScreenBackground::FullScreenBackground(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_isWayland = QString(qgetenv("XDG_SESSION_TYPE")) == "wayland";
|
||||
initUI();
|
||||
initConnections();
|
||||
}
|
||||
|
@ -62,7 +63,17 @@ void FullScreenBackground::initMainWindow(
|
|||
const bool &isSupportTableMode)
|
||||
{
|
||||
if (!m_wndMain) {
|
||||
m_wndMain = new MainWindow(this);
|
||||
if (m_isWayland) {
|
||||
m_wndMain = new MainWindow();
|
||||
m_wndMain->setWindowFlags(windowFlags() | Qt::Tool | Qt::WindowStaysOnTopHint);
|
||||
KWindowSystem::setState(m_wndMain->winId(), NET::State::KeepAbove | NET::State::SkipTaskbar);
|
||||
} else {
|
||||
m_wndMain = new MainWindow(this);
|
||||
m_wndMain->setModal(true);
|
||||
}
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint & ~Qt::WindowMinimizeButtonHint);
|
||||
m_wndMain->setWindowTitle(tr("Authentication"));
|
||||
WindowManager::setSkipTaskBar(m_wndMain->windowHandle(), true);
|
||||
m_wndMain->setIcon(strIconName);
|
||||
m_wndMain->setCurProject(isMavis);
|
||||
m_wndMain->setHeader(strMsg);
|
||||
|
@ -70,6 +81,7 @@ void FullScreenBackground::initMainWindow(
|
|||
m_wndMain->setEditInputMethod(isSupportTableMode);
|
||||
m_wndMain->setFixedSize(420, 337);
|
||||
/*
|
||||
*
|
||||
mainWindow->setDetails(subjectPid, callerPid,
|
||||
actionDesc.actionId(),
|
||||
actionDesc.description(),
|
||||
|
@ -80,30 +92,30 @@ void FullScreenBackground::initMainWindow(
|
|||
qDebug() << "auth dialog finished:" << nResult;
|
||||
});
|
||||
}
|
||||
show();
|
||||
if (m_isWayland) {
|
||||
hide();
|
||||
} else {
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
void FullScreenBackground::initUI()
|
||||
{
|
||||
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
|
||||
// setWindowOpacity(0.25);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setWindowTitle(tr("Authentication"));
|
||||
if (m_isWayland) {
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setGeometry(0, 0, 0, 0);
|
||||
} else {
|
||||
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
|
||||
setWindowOpacity(0.25);
|
||||
KWindowSystem::setState(winId(), NET::State::KeepAbove | NET::State::SkipTaskbar);
|
||||
WindowManager::setSkipTaskBar(this->windowHandle(), true);
|
||||
installEventFilter(this);
|
||||
|
||||
KWindowSystem::setState(winId(), NET::State::KeepAbove | NET::State::SkipTaskbar);
|
||||
WindowManager::setSkipTaskBar(this->windowHandle(), true);
|
||||
installEventFilter(this);
|
||||
|
||||
if (!isSupportCompositing()) {
|
||||
m_pixmapBackground = getBackground();
|
||||
}
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
if (desktop) {
|
||||
setGeometry(
|
||||
desktop->geometry().x(),
|
||||
desktop->geometry().y(),
|
||||
desktop->geometry().width() + 1,
|
||||
desktop->geometry().height() + 1);
|
||||
if (!isSupportCompositing()) {
|
||||
m_pixmapBackground = getBackground();
|
||||
}
|
||||
setGeometry(0, 0, 7680, 4320);
|
||||
}
|
||||
qDebug() << "Window geometry:" << geometry();
|
||||
}
|
||||
|
@ -122,17 +134,23 @@ void FullScreenBackground::initConnections()
|
|||
void FullScreenBackground::onScreenCountChanged(int)
|
||||
{
|
||||
qDebug() << "onScreenCountChanged----";
|
||||
|
||||
if (m_isWayland) {
|
||||
update();
|
||||
moveToCursorScreen();
|
||||
return;
|
||||
}
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
if ((desktop->geometry().x() != 0 || desktop->geometry().y() != 0) && this->geometry().contains(desktop->geometry())
|
||||
&& (QApplication::screens().count() == 1)) {
|
||||
return;
|
||||
}
|
||||
setGeometry(
|
||||
desktop->geometry().x(),
|
||||
desktop->geometry().y(),
|
||||
desktop->geometry().width() + 1,
|
||||
desktop->geometry().height() + 1);
|
||||
if (desktop->geometry().height() > height() || desktop->geometry().width() > width()) {
|
||||
setGeometry(
|
||||
desktop->geometry().x(),
|
||||
desktop->geometry().y(),
|
||||
desktop->geometry().width() + 1,
|
||||
desktop->geometry().height() + 1);
|
||||
}
|
||||
|
||||
update();
|
||||
moveToCursorScreen();
|
||||
|
@ -154,16 +172,23 @@ void FullScreenBackground::onPrimaryScreenChanged()
|
|||
void FullScreenBackground::onDesktopResized()
|
||||
{
|
||||
qDebug() << "onDesktopResized----";
|
||||
if (m_isWayland) {
|
||||
update();
|
||||
moveToCursorScreen();
|
||||
return;
|
||||
}
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
if ((desktop->geometry().x() != 0 || desktop->geometry().y() != 0) && this->geometry().contains(desktop->geometry())
|
||||
&& (QGuiApplication::screens().count() == 1)) {
|
||||
return;
|
||||
}
|
||||
setGeometry(
|
||||
desktop->geometry().x(),
|
||||
desktop->geometry().y(),
|
||||
desktop->geometry().width() + 1,
|
||||
desktop->geometry().height() + 1);
|
||||
if (desktop->geometry().height() > height() || desktop->geometry().width() > width()) {
|
||||
setGeometry(
|
||||
desktop->geometry().x(),
|
||||
desktop->geometry().y(),
|
||||
desktop->geometry().width() + 1,
|
||||
desktop->geometry().height() + 1);
|
||||
}
|
||||
|
||||
update();
|
||||
moveToCursorScreen();
|
||||
|
@ -175,7 +200,9 @@ void FullScreenBackground::showDialog()
|
|||
if (m_isFirstShow) {
|
||||
m_isFirstShow = false;
|
||||
blockSomeShortCut(true);
|
||||
show();
|
||||
if (!m_isWayland) {
|
||||
show();
|
||||
}
|
||||
if (m_wndMain) {
|
||||
qDebug() << "DialogGeometry:" << m_wndMain->geometry();
|
||||
m_wndMain->show();
|
||||
|
@ -200,9 +227,12 @@ void FullScreenBackground::closeDialog()
|
|||
|
||||
bool FullScreenBackground::isSupportCompositing()
|
||||
{
|
||||
if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") {
|
||||
return true;
|
||||
}
|
||||
QDBusInterface kwinCompositor(
|
||||
"org.ukui.KWin", "/Compositor", "org.freedesktop.DBus.Properties", QDBusConnection::sessionBus());
|
||||
QDBusReply<QDBusVariant> sessionReply = kwinCompositor.call("Get", "org.ukui.kwin.Compositing", "compositingType");
|
||||
QDBusReply<QDBusVariant> sessionReply = kwinCompositor.call("Get", "org.kde.kwin.Compositing", "compositingType");
|
||||
if (!sessionReply.isValid()) {
|
||||
qWarning() << sessionReply.error();
|
||||
} else {
|
||||
|
@ -308,14 +338,25 @@ void FullScreenBackground::moveToScreen(QScreen *screen)
|
|||
void FullScreenBackground::moveToCursorScreen()
|
||||
{
|
||||
bool isFoundScreen = false;
|
||||
QPoint cursor = QCursor::pos();
|
||||
// qDebug() << "CurCursor-------------:" << cursor << WindowManager::currentOutputName();
|
||||
for (auto screen : QApplication::screens()) {
|
||||
qDebug() << "Screen:" << screen->name() << "," << screen->geometry();
|
||||
if (screen && screen->geometry().contains(cursor)) {
|
||||
isFoundScreen = true;
|
||||
moveToScreen(screen);
|
||||
break;
|
||||
if (m_isWayland) {
|
||||
QString strCurScreen = WindowManager::currentOutputName();
|
||||
for (auto screen : QApplication::screens()) {
|
||||
qDebug() << "Screen:" << screen->name() << "," << screen->geometry();
|
||||
if (screen && screen->name() == strCurScreen) {
|
||||
isFoundScreen = true;
|
||||
moveToScreen(screen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QPoint cursor = QCursor::pos();
|
||||
for (auto screen : QApplication::screens()) {
|
||||
qDebug() << "Screen:" << screen->name() << "," << screen->geometry();
|
||||
if (screen && screen->geometry().contains(cursor)) {
|
||||
isFoundScreen = true;
|
||||
moveToScreen(screen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isFoundScreen) {
|
||||
|
@ -328,34 +369,28 @@ void FullScreenBackground::moveToCursorScreen()
|
|||
|
||||
void FullScreenBackground::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
// for (auto screen : QApplication::screens()) {
|
||||
// QPainter painter(this);
|
||||
// if (!m_pixmapBackground.isNull()) {
|
||||
// painter.drawPixmap(screen->geometry(), m_pixmapBackground);
|
||||
// }
|
||||
// QPainterPath path;
|
||||
// painter.setOpacity(0.25);
|
||||
// painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
// painter.setClipping(true);
|
||||
// painter.setPen(Qt::transparent);
|
||||
// path.addRect(screen->geometry());
|
||||
// path.setFillRule(Qt::WindingFill);
|
||||
// painter.setBrush(QColor(QPalette::Base));
|
||||
// painter.setPen(Qt::transparent);
|
||||
// painter.drawPath(path);
|
||||
// }
|
||||
if (!m_isWayland) {
|
||||
for (auto screen : QApplication::screens()) {
|
||||
QPainter painter(this);
|
||||
if (!m_pixmapBackground.isNull()) {
|
||||
painter.drawPixmap(screen->geometry(), m_pixmapBackground);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void FullScreenBackground::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
qDebug() << "FullScreenBackground::closeEvent";
|
||||
// 断开屏幕变化信号
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
disconnect(desktop, &QDesktopWidget::resized, this, &FullScreenBackground::onDesktopResized);
|
||||
disconnect(desktop, &QDesktopWidget::workAreaResized, this, &FullScreenBackground::onWorkAreaResized);
|
||||
disconnect(desktop, &QDesktopWidget::primaryScreenChanged, this, &FullScreenBackground::onPrimaryScreenChanged);
|
||||
disconnect(desktop, &QDesktopWidget::screenCountChanged, this, &FullScreenBackground::onScreenCountChanged);
|
||||
if (!m_isWayland) {
|
||||
// 断开屏幕变化信号
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
disconnect(desktop, &QDesktopWidget::resized, this, &FullScreenBackground::onDesktopResized);
|
||||
disconnect(desktop, &QDesktopWidget::workAreaResized, this, &FullScreenBackground::onWorkAreaResized);
|
||||
disconnect(desktop, &QDesktopWidget::primaryScreenChanged, this, &FullScreenBackground::onPrimaryScreenChanged);
|
||||
disconnect(desktop, &QDesktopWidget::screenCountChanged, this, &FullScreenBackground::onScreenCountChanged);
|
||||
}
|
||||
|
||||
return QWidget::closeEvent(event);
|
||||
}
|
||||
|
@ -434,30 +469,37 @@ void FullScreenBackground::blockSomeShortCut(bool isBlock /* = false*/)
|
|||
"Window to Screen 4", // 窗口到屏幕 4
|
||||
};
|
||||
sIsBlocked = isBlock;
|
||||
QDBusInterface kwinInterface("org.ukui.KWin", "/KWin", "org.ukui.KWin", QDBusConnection::sessionBus());
|
||||
if (sIsBlocked) {
|
||||
// kwin shortcut
|
||||
for (QString strShortCut : listBlockShortCut) {
|
||||
QDBusMessage blockMessage = kwinInterface.call("blockShortcut", strShortCut, true);
|
||||
if (blockMessage.type() == QDBusMessage::ErrorMessage) {
|
||||
qWarning() << "Kwin dbus error:" << blockMessage.errorMessage();
|
||||
break;
|
||||
if (!m_isWayland) {
|
||||
// kwin shortcut
|
||||
QDBusInterface kwinInterface("org.ukui.KWin", "/KWin", "org.kde.KWin", QDBusConnection::sessionBus());
|
||||
for (QString strShortCut : listBlockShortCut) {
|
||||
QDBusMessage blockMessage = kwinInterface.call("blockShortcut", strShortCut, true);
|
||||
if (blockMessage.type() == QDBusMessage::ErrorMessage) {
|
||||
qWarning() << "Kwin dbus error:" << blockMessage.errorMessage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// usd shortcut
|
||||
|
||||
// usd shortcut
|
||||
if (!m_usdBlockShortCut) {
|
||||
m_usdBlockShortCut = new USDBlockShortCut(this);
|
||||
}
|
||||
} else {
|
||||
// kwin shortcut
|
||||
for (QString strShortCut : listBlockShortCut) {
|
||||
QDBusMessage blockMessage = kwinInterface.call("blockShortcut", strShortCut, false);
|
||||
if (blockMessage.type() == QDBusMessage::ErrorMessage) {
|
||||
qWarning() << "Kwin dbus error1:" << blockMessage.errorMessage();
|
||||
break;
|
||||
if (!m_isWayland) {
|
||||
// kwin shortcut
|
||||
QDBusInterface kwinInterface("org.ukui.KWin", "/KWin", "org.kde.KWin", QDBusConnection::sessionBus());
|
||||
for (QString strShortCut : listBlockShortCut) {
|
||||
QDBusMessage blockMessage = kwinInterface.call("blockShortcut", strShortCut, false);
|
||||
if (blockMessage.type() == QDBusMessage::ErrorMessage) {
|
||||
qWarning() << "Kwin dbus error1:" << blockMessage.errorMessage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// usd shortcut
|
||||
|
||||
// usd shortcut
|
||||
if (m_usdBlockShortCut) {
|
||||
delete m_usdBlockShortCut;
|
||||
m_usdBlockShortCut = nullptr;
|
||||
|
@ -467,9 +509,5 @@ void FullScreenBackground::blockSomeShortCut(bool isBlock /* = false*/)
|
|||
|
||||
bool FullScreenBackground::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::Show || event->type() == QEvent::UpdateRequest) {
|
||||
// WindowManager::setWindowLayer(this->windowHandle(), WindowLayer::ScreenLock);
|
||||
WindowManager::setWindowRadius(this->windowHandle(), 0);
|
||||
}
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
|
|
@ -167,6 +167,7 @@ private:
|
|||
QPixmap m_pixmapBackground; // 背景图
|
||||
bool m_isFirstShow = true; // 第一次显示才主动移动对话框居中
|
||||
USDBlockShortCut *m_usdBlockShortCut = nullptr; // usd禁启用快捷键实例
|
||||
bool m_isWayland = false;
|
||||
};
|
||||
|
||||
#endif // FULLSCREENMANAGER_H
|
||||
|
|
|
@ -62,15 +62,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
, m_nCurLockMin(0)
|
||||
, isbioSuccess(false)
|
||||
{
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint & ~Qt::WindowMinimizeButtonHint);
|
||||
// setBackgroundRole(QPalette::Base);
|
||||
|
||||
// setAutoFillBackground(true);
|
||||
setModal(true);
|
||||
ui->setupUi(this);
|
||||
mainLayout()->addLayout(ui->verticalLayout_2);
|
||||
setWindowTitle(tr("Authentication"));
|
||||
WindowManager::setSkipTaskBar(this->windowHandle(), true);
|
||||
|
||||
pam_tally_init(); //
|
||||
|
||||
|
@ -371,7 +364,6 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
}
|
||||
m_failMap.clear();
|
||||
emit canceled();
|
||||
|
||||
return kdk::KDialog::closeEvent(event);
|
||||
}
|
||||
|
||||
|
@ -478,7 +470,6 @@ void MainWindow::paintEvent(QPaintEvent *event)
|
|||
// 绘制一个矩形
|
||||
|
||||
p.setPen(Qt::red);
|
||||
QRectF rect(0, 290, 20, 20);
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
|
||||
|
@ -499,6 +490,12 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (obj == this) {
|
||||
if (event->type() == QEvent::Show || event->type() == QEvent::UpdateRequest) {
|
||||
if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") {
|
||||
WindowManager::setWindowLayer(this->windowHandle(), WindowLayer::Switcher + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return kdk::KDialog::eventFilter(obj, event);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ USDBlockShortCut::~USDBlockShortCut()
|
|||
|
||||
QStringList USDBlockShortCut::blockShortcuts()
|
||||
{
|
||||
QStringList listShortCut = { "WINDOWSWITCH_KEY" };
|
||||
QStringList listShortCut = {
|
||||
"WINDOWSWITCH_KEY", "WLCOM_SWITCH_WORKSPACE", "WLCOM_WINDOW_ACTION", "WLCOM_MAXIMIZED_VIEWS", "WLCOM_CTRL_VIEWS"
|
||||
};
|
||||
return listShortCut;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue