MCPcopy Create free account
hub / github.com/apache/cloudstack / _requestRemoteResize

Method _requestRemoteResize

systemvm/agent/noVNC/core/rfb.js:945–985  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

943 // Requests a change of remote desktop size. This message is an extension
944 // and may only be sent if we have received an ExtendedDesktopSize message
945 _requestRemoteResize() {
946 if (!this._resizeSession) {
947 return;
948 }
949 if (this._viewOnly) {
950 return;
951 }
952 if (!this._supportsSetDesktopSize) {
953 return;
954 }
955
956 // Rate limit to one pending resize at a time
957 if (this._pendingRemoteResize) {
958 return;
959 }
960
961 // And no more than once every 100ms
962 if ((Date.now() - this._lastResize) < 100) {
963 clearTimeout(this._resizeTimeout);
964 this._resizeTimeout = setTimeout(this._requestRemoteResize.bind(this),
965 100 - (Date.now() - this._lastResize));
966 return;
967 }
968 this._resizeTimeout = null;
969
970 const size = this._screenSize();
971
972 // Do we actually change anything?
973 if (size.w === this._fbWidth && size.h === this._fbHeight) {
974 return;
975 }
976
977 this._pendingRemoteResize = true;
978 this._lastResize = Date.now();
979 RFB.messages.setDesktopSize(this._sock,
980 Math.floor(size.w), Math.floor(size.h),
981 this._screenID, this._screenFlags);
982
983 Log.Debug('Requested new desktop size: ' +
984 size.w + 'x' + size.h);
985 }
986
987 // Gets the size of the available screen
988 _screenSize() {

Callers 3

resizeSessionMethod · 0.95
_handleResizeMethod · 0.95

Calls 2

_screenSizeMethod · 0.95
nowMethod · 0.80

Tested by

no test coverage detected