@@ -27,6 +27,37 @@ function GuacMe(element, guest_ip, vncport, session_id, recording_name) {
2727 /* Show the terminal. */
2828 $ ( '#terminal' ) . append ( terminal_element ) ;
2929
30+ /* Scale display to fit the browser window. */
31+ var scaleDisplay = function ( ) {
32+ var display = terminal_client . getDisplay ( ) ;
33+ var displayWidth = display . getWidth ( ) ;
34+ var displayHeight = display . getHeight ( ) ;
35+ if ( ! displayWidth || ! displayHeight ) return ;
36+
37+ var container = document . getElementById ( 'container' ) ;
38+ var containerWidth = container . offsetWidth ;
39+ var containerHeight = container . offsetHeight ;
40+ if ( ! containerWidth || ! containerHeight ) return ;
41+
42+ var scale = Math . min (
43+ containerWidth / displayWidth ,
44+ containerHeight / displayHeight
45+ ) ;
46+ display . scale ( scale ) ;
47+ } ;
48+
49+ /* Re-scale when the display size changes (initial connect). */
50+ terminal_client . getDisplay ( ) . onresize = function ( ) {
51+ scaleDisplay ( ) ;
52+ } ;
53+
54+ /* Re-scale on browser window resize (debounced). */
55+ var resizeTimeout ;
56+ window . addEventListener ( 'resize' , function ( ) {
57+ clearTimeout ( resizeTimeout ) ;
58+ resizeTimeout = setTimeout ( scaleDisplay , 100 ) ;
59+ } ) ;
60+
3061 /* Disconnect on tab close. */
3162 window . onunload = function ( ) {
3263 terminal_client . disconnect ( ) ;
@@ -38,7 +69,7 @@ function GuacMe(element, guest_ip, vncport, session_id, recording_name) {
3869 mouse . onmousedown =
3970 mouse . onmouseup =
4071 mouse . onmousemove = function ( mouseState ) {
41- terminal_client . sendMouseState ( mouseState ) ;
72+ terminal_client . sendMouseState ( mouseState , true ) ;
4273 } ;
4374
4475 /* Keyboard handling. */
0 commit comments