[X2Go-Commits] [x2goclient] 01/01: add "noresize" setting, which makes the proxy window not resizable for user.
git-admin at x2go.org
git-admin at x2go.org
Mon Aug 22 18:57:24 CEST 2022
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2goclient.
commit ba65703ca715eb6e920069f75b8d8382bb3d2d28
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date: Mon Aug 22 11:56:38 2022 -0500
add "noresize" setting, which makes the proxy window not resizable for user.
---
debian/changelog | 2 ++
src/onmainwindow.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++-----
src/onmainwindow.h | 5 ++--
src/settingswidget.cpp | 9 ++++++
src/settingswidget.h | 1 +
src/wapi.cpp | 14 +++++++++
src/wapi.h | 2 ++
7 files changed, 103 insertions(+), 9 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 1d9ba63..c794401 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -51,6 +51,8 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium
- for x2gokdrive sessions, when auto kbd layout is chosen,
x2goclient will try to set the same kbd layout on server as on the
client.
+ - add "noresize" setting, which makes the proxy window not resizable
+ for user.
[ Ryan Schmidt ]
* New upstream version (4.1.2.3):
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 9552df7..e63dcc5 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -4542,11 +4542,11 @@ void ONMainWindow::startNewSession()
{
runRemoteCommand=false;
}
+ proxyWinWidth=width;
+ proxyWinHeight=height;
#ifdef Q_OS_WIN
x2goDebug<<"Fullscreen: "<<fullscreen;
maximizeProxyWin=false;
- proxyWinWidth=width;
- proxyWinHeight=height;
xorgMode=WIN;
if (fullscreen)
xorgMode=FS;
@@ -4892,10 +4892,11 @@ void ONMainWindow::resumeSession ( const x2goSession& s )
layout=cbLayout->currentText();
QString geometry;
-#ifdef Q_OS_WIN
- maximizeProxyWin=false;
proxyWinWidth=width;
proxyWinHeight=height;
+
+#ifdef Q_OS_WIN
+ maximizeProxyWin=false;
// #ifdef CFGCLIENT
xorgMode=WIN;
if (fullscreen)
@@ -6339,7 +6340,7 @@ void ONMainWindow::slotTunnelOk(int)
bool multidisp=false;
QString dispNumber="1";
QString clipboard="both";
-
+ bool noresize=false;
if (!embedMode )
{
if (!useLdap)
@@ -6368,8 +6369,7 @@ void ONMainWindow::slotTunnelOk(int)
width=st->setting()->value ( sid+"/width", ( QVariant ) "800").toString();
height=st->setting()->value ( sid+"/height", ( QVariant ) "600").toString();
clipboard=st->setting()->value ( sid+"/clipboard", ( QVariant ) "both").toString();
-
-
+ noresize=st->setting()->value ( sid+"/noresize", ( QVariant ) false).toBool();
if (st->setting()->value ( sid+"/multidisp", ( QVariant ) false ).toBool())
@@ -6394,6 +6394,8 @@ void ONMainWindow::slotTunnelOk(int)
}
options<<"--connect"<<"localhost"<<"--port"<<localGraphicPort<<"--title"<<resumingSession.sessionId<<"-S"<<"nx/nx,options="+dirpath+
"/options:"+resumingSession.display<<"--selection"<<clipboard;
+ if(noresize)
+ options<<"--noresize";
if(resumingSession.sessionType==x2goSession::ROOTLESSKDRIVE)
{
options << "--rootless";
@@ -11970,6 +11972,62 @@ void ONMainWindow::slotXineramaConfigured()
xineramaTimer->start(500);
}
+void ONMainWindow::setProxyWinNotResizable()
+{
+#ifdef Q_OS_WIN
+ switch(wapiIsWinResizeable((HWND)proxyWinId))
+ {
+ case -1:
+ x2goDebug<<"Proxy window is closed, stop checking properties";
+ return;
+ case 1:
+ wapiSetWinNotResizable((HWND)proxyWinId);
+ default:
+ QTimer::singleShot(1000, this, SLOT(setProxyWinNotResizable()));
+ }
+#endif
+#ifdef Q_OS_LINUX
+ XWindowAttributes wattr;
+ if(! XGetWindowAttributes(QX11Info::display(), proxyWinId, &wattr))
+ {
+ x2goDebug<<"Proxy window is closed, stop checking properties";
+ return;
+ }
+ if(wattr.map_state != IsViewable)
+ {
+ QTimer::singleShot(1000, this, SLOT(setProxyWinNotResizable()));
+ return;
+ }
+
+ XSizeHints rhints;
+ long rflags;
+ if(!XGetWMNormalHints(QX11Info::display(), proxyWinId, &rhints, &rflags))
+ {
+ x2goDebug<<"Failed to get hints for proxy window, stop checking properties";
+ return;
+ }
+ if(rhints.min_width==proxyWinWidth && rhints.max_width==proxyWinWidth && rhints.min_height==proxyWinHeight && rhints.max_height==proxyWinHeight)
+ {
+ QTimer::singleShot(1000, this, SLOT(setProxyWinNotResizable()));
+ return;
+ }
+
+ XSizeHints* hints;
+ XSync(QX11Info::display(),false);
+ hints=XAllocSizeHints();
+ hints->flags= PMinSize|PMaxSize;
+ hints->base_width=hints->max_width=hints->min_width=proxyWinWidth;
+ hints->base_height=hints->max_height=hints->min_height=proxyWinHeight;
+// x2goDebug<<"Setting X11 hints on proxy window";
+ XSetWMNormalHints(QX11Info::display(), proxyWinId, hints);
+ XSync(QX11Info::display(),false);
+ XFlush(QX11Info::display());
+ XFree(hints);
+ QTimer::singleShot(1000, this, SLOT(setProxyWinNotResizable()));
+#endif
+}
+
+
void ONMainWindow::slotFindProxyWin()
{
#ifndef Q_OS_DARWIN
@@ -12023,6 +12081,13 @@ void ONMainWindow::slotFindProxyWin()
return;
}
#endif
+ if (st->setting()->value ( sid+"/noresize",
+ ( QVariant ) false ).toBool())
+ {
+ x2goDebug<<"making proxy window not resizable";
+ setProxyWinNotResizable();
+ }
+
delete st;
}
if (xinerama)
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index e88b689..dca09a7 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -838,6 +838,8 @@ private:
QAction *act_new;
QAction *act_sessicon;
QProcess *nxproxy;
+ int proxyWinWidth;
+ int proxyWinHeight;
#ifndef Q_OS_WIN
QProcess *sshd;
#else
@@ -856,8 +858,6 @@ private:
bool cyEntry;
bool maximizeProxyWin;
- int proxyWinWidth;
- int proxyWinHeight;
QTimer* xorgLogTimer;
QString xorgLogFile;
QMutex xorgLogMutex;
@@ -1080,6 +1080,7 @@ private slots:
void slotBrokerLogoutButton ();
void slotReadApplications(bool result, QString output, int pid );
void slotResLoadRequestFinished( QNetworkReply* reply );
+ void setProxyWinNotResizable();
public slots:
void slotConfig();
diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp
index 13e20ba..5cca6e6 100644
--- a/src/settingswidget.cpp
+++ b/src/settingswidget.cpp
@@ -66,6 +66,7 @@ SettingsWidget::SettingsWidget ( QString id, ONMainWindow * mw,
custom=new QRadioButton ( tr ( "Window" ),dgb );
#endif
display=new QRadioButton ( tr ( "Use whole display" ),dgb );
+ cbNoresize=new QCheckBox ( tr ( "Not resizable" ),dgb );
maxRes=new QRadioButton ( tr ( "Maximum available" ),dgb );
radio->addButton ( fs );
radio->addButton ( custom );
@@ -129,6 +130,7 @@ SettingsWidget::SettingsWidget ( QString id, ONMainWindow * mw,
dbLay->addLayout ( dgLay );
dbLay->addLayout ( dwLay );
dbLay->addLayout(dispLay);
+ dbLay->addWidget(cbNoresize);
QFrame* dhl=new QFrame ( dgb );
hLine1=dhl;
dhl->setFrameStyle ( QFrame::HLine | QFrame::Sunken );
@@ -391,6 +393,10 @@ void SettingsWidget::readConfig()
st.setting()->value ( sessionId+"/fullscreen",
( QVariant ) mainWindow->getDefaultFullscreen() ).toBool() );
+ cbNoresize->setChecked (
+ st.setting()->value ( sessionId+"/noresize",
+ ( QVariant ) false ).toBool() );
+
custom->setChecked ( ! st.setting()->value (
sessionId+"/fullscreen",
( QVariant ) mainWindow->getDefaultFullscreen()
@@ -523,6 +529,7 @@ void SettingsWidget::setDefaults()
custom->setChecked ( true );
width->setValue ( 800 );
height->setValue ( 600 );
+ cbNoresize->setChecked( false );
cbSetDPI->setChecked ( mainWindow->getDefaultSetDPI() );
DPI->setValue ( mainWindow->getDefaultDPI() );
@@ -548,6 +555,8 @@ void SettingsWidget::saveSettings()
st.setting()->setValue ( sessionId+"/fullscreen",
( QVariant ) fs->isChecked() );
+ st.setting()->setValue ( sessionId+"/noresize",
+ ( QVariant ) cbNoresize->isChecked() );
st.setting()->setValue ( sessionId+"/multidisp",
( QVariant ) display->isChecked() );
st.setting()->setValue ( sessionId+"/display",
diff --git a/src/settingswidget.h b/src/settingswidget.h
index 76f445f..cbf2779 100644
--- a/src/settingswidget.h
+++ b/src/settingswidget.h
@@ -71,6 +71,7 @@ private:
QLineEdit* leVariant;
QCheckBox* cbSetDPI;
QCheckBox* cbXinerama;
+ QCheckBox* cbNoresize;
QSpinBox* DPI;
QLabel* widthLabel;
QLabel* heightLabel;
diff --git a/src/wapi.cpp b/src/wapi.cpp
index 15bf2e5..12732c2 100644
--- a/src/wapi.cpp
+++ b/src/wapi.cpp
@@ -615,4 +615,18 @@ QString wapiGetKeyboardLayout()
return QString::null;
}
+void wapiSetWinNotResizable(HWND wnd)
+{
+ SetWindowLong ( wnd, GWL_STYLE, GetWindowLong(wnd, GWL_STYLE)&~WS_SIZEBOX&~WS_MAXIMIZEBOX);
+}
+
+short wapiIsWinResizeable(HWND wnd)
+{
+ LONG flags=GetWindowLong(wnd, GWL_STYLE);
+ if(!flags)
+ return -1;
+ if((flags & WS_SIZEBOX) || (flags & WS_MAXIMIZEBOX))
+ return 1;
+ return 0;
+}
#endif
diff --git a/src/wapi.h b/src/wapi.h
index 72cd993..b186d93 100644
--- a/src/wapi.h
+++ b/src/wapi.h
@@ -77,6 +77,8 @@ QString wapiGetDriveByLabel(const QString& label);
QString wapiGetUserName();
void wapiSetFilePermissions(const QString& path);
QString wapiGetKeyboardLayout();
+void wapiSetWinNotResizable(HWND wnd);
+short wapiIsWinResizeable(HWND wnd);
#endif
#endif
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list