Skip to content

Commit

Permalink
Add support for resizing the lab window
Browse files Browse the repository at this point in the history
Add an observer to the JavaScript code to detect lab size changes
on the LMS page and send the new dimensions to the guacamole client.
  • Loading branch information
Maari Tamm committed Feb 5, 2025
1 parent 5b36637 commit 9837d44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hastexo/public/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ function HastexoGuacamoleClient(configuration) {

onidle(pause) {
return pause;
},

sendSize(height, width) {
guac_client.sendSize(height, width);
}
}

Expand Down
9 changes: 9 additions & 0 deletions hastexo/public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ function HastexoXBlock(runtime, element, configuration) {
/* Show the terminal. */
$("#terminal").append(terminal_element);

// Observe the lab size in the browser and adjust when necessary
var lab = $('#terminal')[0];
const resizeObserver = new ResizeObserver(entries => {
for (const entry of entries) {
terminal_client.sendSize(entry.contentRect.width, entry.contentRect.height);
}
});
resizeObserver.observe(lab);

/* Disconnect on tab close. */
window.onunload = function() {
terminal_client.disconnect();
Expand Down

0 comments on commit 9837d44

Please sign in to comment.