Skip to content
Draft
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
38 changes: 37 additions & 1 deletion plugins/dde-dock/shutdown/shutdownplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void ShutdownPlugin::invokedMenuItem(const QString &itemKey, const QString &menu
#endif

} else {
QProcess::execute("bash -c \"originmap=$(setxkbmap -query | grep option | awk -F ' ' '{print $2}');/usr/bin/setxkbmap -option grab:break_actions&&/usr/bin/xdotool key XF86Ungrab&&dbus-send --print-reply --dest=org.deepin.dde.LockFront1 /org/deepin/dde/LockFront1 org.deepin.dde.LockFront1.Show&&setxkbmap -option $originmap\"");
lockWithBreakActions();
}
} else
DDBusSender()
Expand All @@ -331,6 +331,42 @@ void ShutdownPlugin::invokedMenuItem(const QString &itemKey, const QString &menu
.call();
}

void ShutdownPlugin::lockWithBreakActions()
{
// Query current xkbmap option
QProcess queryProc;
queryProc.start("setxkbmap", {"-query"});
queryProc.waitForFinished();
QString output = QString::fromLocal8Bit(queryProc.readAllStandardOutput());

QString originmap;
for (const QString &line : output.split('\n')) {
if (line.startsWith("options:")) {
originmap = line.section(':', 1).trimmed();
break;
}
}

// Set grab:break_actions, send XF86Ungrab, then call LockFront1.Show
if (QProcess::execute("setxkbmap", {"-option", "grab:break_actions"}) == 0) {
if (QProcess::execute("xdotool", {"key", "XF86Ungrab"}) == 0) {
QDBusMessage msg = QDBusMessage::createMethodCall(
"org.deepin.dde.LockFront1",
"/org/deepin/dde/LockFront1",
"org.deepin.dde.LockFront1",
"Show");
QDBusConnection::sessionBus().call(msg);
}
}

// Restore original xkbmap option (unconditional)
if (originmap.isEmpty()) {
QProcess::execute("setxkbmap", {"-option"});
} else {
QProcess::execute("setxkbmap", {"-option", originmap});
}
}

void ShutdownPlugin::displayModeChanged(const Dock::DisplayMode displayMode)
{
Q_UNUSED(displayMode);
Expand Down
1 change: 1 addition & 0 deletions plugins/dde-dock/shutdown/shutdownplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ShutdownPlugin : public QObject, PluginsItemInterface
private:
void loadPlugin();
void refreshPluginItemsVisible();
void lockWithBreakActions();

private:
bool m_pluginLoaded;
Expand Down
Loading