This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 34c121f25a9ee333918417bf1cbe3c6cef89d112 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Mon Aug 8 11:00:37 2022 -0500 for x2gokdrive sessions, when auto kbd layout is chosen, x2goclient will try to set the same kbd layout on server as on the client. --- debian/changelog | 3 +++ src/help.cpp | 2 ++ src/onmainwindow.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++- src/onmainwindow.h | 2 +- src/wapi.cpp | 16 ++++++++---- src/wapi.h | 1 + src/x2goclientconfig.h | 3 +++ 7 files changed, 91 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index b00a51d..1d9ba63 100644 --- a/debian/changelog +++ b/debian/changelog @@ -48,6 +48,9 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium - support for recent cygwin binaries and nxproxy 3.5.99.x all cygwin binaries and DLLs should be moved into the INSTDIR/bin directory by Windows installer. + - for x2gokdrive sessions, when auto kbd layout is chosen, + x2goclient will try to set the same kbd layout on server as on the + client. [ Ryan Schmidt ] * New upstream version (4.1.2.3): diff --git a/src/help.cpp b/src/help.cpp index 3dc3b8d..ea9fcfc 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -17,6 +17,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ********************************************************************************/ +#include "x2goclientconfig.h" + #include <QCoreApplication> #include <QtDebug> #include <QTextStream> diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 666b042..9552df7 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -18,7 +18,6 @@ #include "onmainwindow_privat.h" #include "help.h" - #include <QStyleFactory> #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) @@ -4700,6 +4699,16 @@ void ONMainWindow::startNewSession() xinerama_env += "no"; } + if(usekbd && kdrive && type=="auto") + { + QString kbdl, kbdm, kbdv; + getClientKeyboardConfig(kbdl,kbdm,kbdv); + type=kbdm+"/"+kbdl; + if(kbdv.length()>0) + { + type+="\\("+kbdv+"\\)"; + } + } QString cmd=dpiEnv+xdmcpEnv+ xinerama_env + " x2gostartagent "+ geometry+" "+link+" "+pack+ " unix-kde-depth_"+depth+" "+layout+" "+type+" "; @@ -4985,6 +4994,16 @@ void ONMainWindow::resumeSession ( const x2goSession& s ) else selectSessionDlg->hide(); } + if(usekbd && (s.sessionType == x2goSession::KDRIVE || s.sessionType == x2goSession::ROOTLESSKDRIVE) && type=="auto") + { + QString kbdl, kbdm, kbdv; + getClientKeyboardConfig(kbdl,kbdm,kbdv); + type=kbdm+"/"+kbdl; + if(kbdv.length()>0) + { + type+="\\("+kbdv+"\\)"; + } + } QString cmd="x2goresume-session "+s.sessionId+" "+geometry+ " "+link+" "+pack+" "+layout+ " "+type+" "; @@ -13736,3 +13755,53 @@ bool ONMainWindow::parseResourceUrl(const QString& url) } return true; } + +void ONMainWindow::getClientKeyboardConfig(QString& layout, QString& model, QString& variant) +{ + layout = "us"; + model = "pc105"; + variant = ""; +#ifdef Q_OS_DARWIN + //TODO:implement this for Mac + return; +#endif +#ifdef Q_OS_WIN + layout = wapiGetKeyboardLayout(); +#else + QProcess proc; + proc.start("setxkbmap",QStringList() << "-query"); + if (!proc.waitForStarted()) + { + x2goDebug<<"Failed to start xkbcomp"<<proc.error(); + return; + } + if (!proc.waitForFinished()) + { + x2goDebug<<"Failed to execute xkbcomp"<<proc.error(); + return; + } + QStringList lines=QString(proc.readAllStandardOutput()).split("\n"); + QString line; + foreach (line, lines) + { + line.replace(" ",""); + line.replace("\t",""); + if(line.indexOf("model:")!=-1) + { + model=line; + model.replace("model:",""); + } + if(line.indexOf("layout:")!=-1) + { + layout=line; + layout.replace("layout:",""); + } + if(line.indexOf("variant:")!=-1) + { + variant=line; + variant.replace("variant:",""); + } + } + x2goDebug<<"xkbcomp keyboard config - model:"<<model<<" layout: "<<layout<<" variant: "<<variant; +#endif +} diff --git a/src/onmainwindow.h b/src/onmainwindow.h index f84ff26..e88b689 100644 --- a/src/onmainwindow.h +++ b/src/onmainwindow.h @@ -1004,7 +1004,6 @@ private: void plugAppsInTray(); QMenu* initTrayAppMenu(QString text, QPixmap icon); void setTrayIconToSessionIcon(QString info); - /* * Tries to get the most suitable translator for the running system. * @@ -1023,6 +1022,7 @@ private: * translation. */ static bool get_translator (const QString file_name_start, QTranslator **translator); + void getClientKeyboardConfig(QString& layout, QString& model, QString& variant); protected: diff --git a/src/wapi.cpp b/src/wapi.cpp index e7ded94..15bf2e5 100644 --- a/src/wapi.cpp +++ b/src/wapi.cpp @@ -15,17 +15,13 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef _WIN32_WINDOWS -#define _WIN32_WINDOWS 0x0500 -#define _WIN32_WINNT 0x0500 -#define WINVER 0x0500 -#endif #include "x2goclientconfig.h" #ifdef Q_OS_WIN #include <winsock2.h> #include <windows.h> #include <winerror.h> #include <sddl.h> +#include <winnls.h> #include <AccCtrl.h> #include <aclapi.h> #include "wapi.h" @@ -609,4 +605,14 @@ void wapiSetFilePermissions(const QString& path) CONTAINER_INHERIT_ACE); } +QString wapiGetKeyboardLayout() +{ + wchar_t nm[LOCALE_NAME_MAX_LENGTH]; + LCIDToLocaleName(HIWORD(GetKeyboardLayout(0)),nm,LOCALE_NAME_MAX_LENGTH,0); + QStringList l=QString::fromUtf16((char16_t*)nm).split("-"); + if(l.count()==2) + return l[1].toLower(); + return QString::null; +} + #endif diff --git a/src/wapi.h b/src/wapi.h index 588b58d..72cd993 100644 --- a/src/wapi.h +++ b/src/wapi.h @@ -76,6 +76,7 @@ void wapiRestoreWindow ( HWND hWnd, long style, const QRect& desktopGeometry ); QString wapiGetDriveByLabel(const QString& label); QString wapiGetUserName(); void wapiSetFilePermissions(const QString& path); +QString wapiGetKeyboardLayout(); #endif #endif diff --git a/src/x2goclientconfig.h b/src/x2goclientconfig.h index bdf35c8..3bb9aeb 100644 --- a/src/x2goclientconfig.h +++ b/src/x2goclientconfig.h @@ -18,6 +18,9 @@ #if !defined(_X2GOCLIENT_CONFIG_H_) #define _X2GOCLIENT_CONFIG_H_ +//min supported windows version is windows vista +#define WINVER 0x0601 + #include <stdio.h> #include <qconfig.h> #include <qglobal.h> -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git