@@ -27,11 +27,13 @@ import { UtilsService } from '@shared/services/utils.service';
27
27
import { WebClientService } from '@shared/services/web-client.service' ;
28
28
import { WebSessionService } from '@shared/services/web-session.service' ;
29
29
import { MessageService } from 'primeng/api' ;
30
- import { EMPTY , from , Observable , of , Subject , throwError } from 'rxjs' ;
30
+ import { debounceTime , EMPTY , from , Observable , of , Subject , Subscription , throwError } from 'rxjs' ;
31
31
import { catchError , map , switchMap , takeUntil } from 'rxjs/operators' ;
32
32
import '@devolutions/iron-remote-desktop/iron-remote-desktop.js' ;
33
33
import { DVL_RDP_ICON , DVL_WARNING_ICON , JET_RDP_URL } from '@gateway/app.constants' ;
34
34
import { AnalyticService , ProtocolString } from '@gateway/shared/services/analytic.service' ;
35
+ import { WebSession } from '@shared/models/web-session.model' ;
36
+ import { ComponentResizeObserverService } from '@shared/services/component-resize-observer.service' ;
35
37
36
38
enum UserIronRdpErrorKind {
37
39
General = 0 ,
@@ -49,6 +51,7 @@ enum UserIronRdpErrorKind {
49
51
} )
50
52
export class WebClientRdpComponent extends WebClientBaseComponent implements OnInit , AfterViewInit , OnDestroy {
51
53
@Input ( ) webSessionId : string ;
54
+ @Input ( ) sessionsContainerElement : ElementRef ;
52
55
@Output ( ) componentStatus : EventEmitter < ComponentStatus > = new EventEmitter < ComponentStatus > ( ) ;
53
56
@Output ( ) sizeChange : EventEmitter < void > = new EventEmitter < void > ( ) ;
54
57
@@ -61,10 +64,12 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
61
64
formData : RdpFormDataInput ;
62
65
rdpError : { kind : string ; backtrace : string } ;
63
66
isFullScreenMode = false ;
64
- showToolbarDiv = true ;
65
67
useUnicodeKeyboard = false ;
66
68
cursorOverrideActive = false ;
67
69
70
+ dynamicResizeSupported = false ;
71
+ dynamicResizeEnabled = false ;
72
+
68
73
leftToolbarButtons = [
69
74
{
70
75
label : 'Start' ,
@@ -79,6 +84,11 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
79
84
] ;
80
85
81
86
middleToolbarButtons = [
87
+ {
88
+ label : 'Full Screen' ,
89
+ icon : 'dvl-icon dvl-icon-fullscreen' ,
90
+ action : ( ) => this . toggleFullscreen ( ) ,
91
+ } ,
82
92
{
83
93
label : 'Fit to Screen' ,
84
94
icon : 'dvl-icon dvl-icon-minimize' ,
@@ -111,34 +121,40 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
111
121
checkboxes = [
112
122
{
113
123
label : 'Unicode Keyboard Mode' ,
114
- default : this . useUnicodeKeyboard ,
124
+ value : this . useUnicodeKeyboard ,
115
125
onChange : ( ) => {
116
126
this . useUnicodeKeyboard = ! this . useUnicodeKeyboard ;
117
127
this . setKeyboardUnicodeMode ( this . useUnicodeKeyboard ) ;
118
128
} ,
129
+ enabled : ( ) => true ,
130
+ } ,
131
+ {
132
+ label : 'Dynamic Resize' ,
133
+ value : this . dynamicResizeEnabled ,
134
+ onChange : ( ) => this . toggleDynamicResize ( ) ,
135
+ enabled : ( ) => this . dynamicResizeSupported ,
119
136
} ,
120
137
] ;
121
138
122
139
protected removeElement = new Subject ( ) ;
123
140
private remoteClientEventListener : ( event : Event ) => void ;
124
141
private remoteClient : UserInteraction ;
125
142
143
+ private componentResizeObserverDisconnect ?: ( ) => void ;
144
+ private dynamicComponentResizeSubscription ?: Subscription ;
145
+
126
146
constructor (
127
147
private renderer : Renderer2 ,
128
148
protected utils : UtilsService ,
129
149
protected gatewayAlertMessageService : GatewayAlertMessageService ,
130
150
private webSessionService : WebSessionService ,
131
151
private webClientService : WebClientService ,
152
+ private componentResizeService : ComponentResizeObserverService ,
132
153
protected analyticService : AnalyticService ,
133
154
) {
134
155
super ( gatewayAlertMessageService , analyticService ) ;
135
156
}
136
157
137
- @HostListener ( 'document:mousemove' , [ '$event' ] )
138
- onMouseMove ( event : MouseEvent ) : void {
139
- this . handleSessionToolbarDisplay ( event ) ;
140
- }
141
-
142
158
@HostListener ( 'document:fullscreenchange' )
143
159
onFullScreenChange ( ) : void {
144
160
this . handleOnFullScreenEvent ( ) ;
@@ -155,6 +171,10 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
155
171
ngOnDestroy ( ) : void {
156
172
this . removeRemoteClientListener ( ) ;
157
173
this . removeWebClientGuiElement ( ) ;
174
+
175
+ this . dynamicComponentResizeSubscription ?. unsubscribe ( ) ;
176
+ this . componentResizeObserverDisconnect ?.( ) ;
177
+
158
178
super . ngOnDestroy ( ) ;
159
179
}
160
180
@@ -182,11 +202,7 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
182
202
}
183
203
184
204
scaleTo ( scale : ScreenScale ) : void {
185
- if ( scale === ScreenScale . Full ) {
186
- this . toggleFullscreen ( ) ;
187
- } else {
188
- this . remoteClient . setScale ( scale . valueOf ( ) ) ;
189
- }
205
+ this . remoteClient . setScale ( scale . valueOf ( ) ) ;
190
206
}
191
207
192
208
setKeyboardUnicodeMode ( useUnicode : boolean ) : void {
@@ -203,6 +219,30 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
203
219
this . cursorOverrideActive = ! this . cursorOverrideActive ;
204
220
}
205
221
222
+ toggleDynamicResize ( ) : void {
223
+ const RESIZE_DEBOUNCE_TIME = 100 ;
224
+
225
+ this . dynamicResizeEnabled = ! this . dynamicResizeEnabled ;
226
+
227
+ if ( this . dynamicResizeEnabled ) {
228
+ this . componentResizeObserverDisconnect = this . componentResizeService . observe (
229
+ this . sessionsContainerElement . nativeElement ,
230
+ ) ;
231
+
232
+ this . dynamicComponentResizeSubscription = this . componentResizeService . resize$
233
+ . pipe ( debounceTime ( RESIZE_DEBOUNCE_TIME ) )
234
+ . subscribe ( ( { width, height } ) => {
235
+ if ( ! this . isFullScreenMode ) {
236
+ height -= WebSession . TOOLBAR_SIZE ;
237
+ }
238
+ this . remoteClient . resize ( width , height ) ;
239
+ } ) ;
240
+ } else {
241
+ this . dynamicComponentResizeSubscription ?. unsubscribe ( ) ;
242
+ this . componentResizeObserverDisconnect ?.( ) ;
243
+ }
244
+ }
245
+
206
246
removeWebClientGuiElement ( ) : void {
207
247
this . removeElement . pipe ( takeUntil ( this . destroyed$ ) ) . subscribe ( {
208
248
next : ( ) : void => {
@@ -236,21 +276,11 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
236
276
}
237
277
}
238
278
239
- private handleSessionToolbarDisplay ( event : MouseEvent ) : void {
240
- if ( ! document . fullscreenElement ) {
241
- return ;
242
- }
243
-
244
- if ( event . clientY === 0 ) {
245
- this . showToolbarDiv = true ;
246
- } else if ( event . clientY > 44 ) {
247
- this . showToolbarDiv = false ;
248
- }
249
- }
250
-
251
279
private toggleFullscreen ( ) : void {
252
280
this . isFullScreenMode = ! this . isFullScreenMode ;
253
281
! document . fullscreenElement ? this . enterFullScreen ( ) : this . exitFullScreen ( ) ;
282
+
283
+ this . scaleTo ( ScreenScale . Full ) ;
254
284
}
255
285
256
286
private async enterFullScreen ( ) : Promise < void > {
@@ -259,8 +289,7 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
259
289
}
260
290
261
291
try {
262
- const sessionContainerElement = this . sessionContainerElement . nativeElement ;
263
- await sessionContainerElement . requestFullscreen ( ) ;
292
+ await this . sessionsContainerElement . nativeElement . requestFullscreen ( ) ;
264
293
} catch ( err ) {
265
294
this . isFullScreenMode = false ;
266
295
console . error ( `Error attempting to enable fullscreen mode: ${ err . message } (${ err . name } )` ) ;
@@ -277,7 +306,6 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
277
306
278
307
private handleExitFullScreenEvent ( ) : void {
279
308
this . isFullScreenMode = false ;
280
- this . showToolbarDiv = true ;
281
309
282
310
const sessionContainerElement = this . sessionContainerElement . nativeElement ;
283
311
const sessionToolbarElement = sessionContainerElement . querySelector ( '#sessionToolbar' ) ;
@@ -394,6 +422,7 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements OnI
394
422
395
423
if ( connectionParameters . enableDisplayControl ) {
396
424
configBuilder . withExtension ( displayControl ( true ) ) ;
425
+ this . dynamicResizeSupported = true ;
397
426
}
398
427
399
428
if ( connectionParameters . preConnectionBlob != null ) {
0 commit comments