Include an optional screen size in the WindowsDesktop spec#34580
Merged
Conversation
dd62feb to
ad0c126
Compare
Collaborator
Author
ca1399c to
00fa79b
Compare
8fd9ffc to
b144d30
Compare
b144d30 to
2da9d6d
Compare
zmb3
added a commit
that referenced
this pull request
Feb 9, 2024
See #34580 for the associated implementation
2da9d6d to
b76dfdd
Compare
probakowski
approved these changes
Feb 9, 2024
Contributor
ibeckermayer
left a comment
There was a problem hiding this comment.
The ultimate screen size is negotiated and then returned to us in handleRDPConnectionInitialized, so consider adding these changes there in order to alert the user in case what they requested was different from what was negotiated:
diff --git a/lib/srv/desktop/rdp/rdpclient/client.go b/lib/srv/desktop/rdp/rdpclient/client.go
index 38035c64c5..970761742e 100644
--- a/lib/srv/desktop/rdp/rdpclient/client.go
+++ b/lib/srv/desktop/rdp/rdpclient/client.go
@@ -72,6 +72,7 @@ import "C"
import (
"context"
+ "fmt"
"os"
"runtime/cgo"
"sync"
@@ -123,7 +124,12 @@ func init() {
type Client struct {
cfg Config
- // Parameters read from the TDP stream.
+ // `clientWidth` and `clientHeight` are initially set to either
+ // the values provided by the browser or the values provided by
+ // the config file (config file values take precedence). They are
+ // then used to request a screen size from the RDP server. Finally,
+ // they are set to the negotiated screen size returned from the RDP
+ // server, which is the actual screen size that will be used.
clientWidth, clientHeight uint16
username string
@@ -666,12 +672,36 @@ func cgo_handle_rdp_connection_initialized(
func (c *Client) handleRDPConnectionInitialized(ioChannelID, userChannelID, screenWidth, screenHeight C.uint16_t) C.CGOErrCode {
c.cfg.Log.Debugf("Received RDP channel IDs: io_channel_id=%d, user_channel_id=%d", ioChannelID, userChannelID)
c.cfg.Log.Debugf("RDP server provided resolution of %dx%d", screenWidth, screenHeight)
+ negotiatedScreenWidth, negotiatedScreenHeight := uint16(screenWidth), uint16(screenHeight)
+ // If the server provided a different resolution than requested
+ if c.clientWidth != negotiatedScreenWidth || c.clientHeight != negotiatedScreenHeight {
+ changedResMsg := fmt.Sprintf("RDP negotiated a different resolution than requested: %dx%d -> %dx%d",
+ c.clientWidth, c.clientHeight, negotiatedScreenWidth, negotiatedScreenHeight)
+
+ // Update the client's bookkeeping variables.
+ c.clientWidth, c.clientHeight = negotiatedScreenWidth, negotiatedScreenHeight
+
+ // If the user requested a specific resolution via the config,
+ // warn the user about the resolution change.
+ if c.cfg.Width != 0 && c.cfg.Height != 0 {
+ c.cfg.Log.Warn(changedResMsg)
+ if err := c.cfg.Conn.WriteMessage(tdp.Notification{Message: changedResMsg, Severity: tdp.SeverityWarning}); err != nil {
+ c.cfg.Log.Errorf("failed handling RDPChannelIDs: %v", err)
+ return C.ErrCodeFailure
+ }
+ } else {
+ // Otherwise just log the resolution change at debug level.
+ c.cfg.Log.Debug(changedResMsg)
+ }
+ }
+
+ // Send the negotiated resolution and necessary channel ID's to the browser.
if err := c.cfg.Conn.WriteMessage(tdp.ConnectionInitialized{
IOChannelID: uint16(ioChannelID),
UserChannelID: uint16(userChannelID),
- ScreenWidth: uint16(screenWidth),
- ScreenHeight: uint16(screenHeight),
+ ScreenWidth: negotiatedScreenWidth,
+ ScreenHeight: negotiatedScreenHeight,
}); err != nil {
c.cfg.Log.Errorf("failed handling RDPChannelIDs: %v", err)
return C.ErrCodeFailure
ibeckermayer
approved these changes
Feb 13, 2024
By default this should remain unspecified, which preserves the behavior we have today (Teleport uses the size of the user's browser window). These new fields allow cluster administrators to configure desktops in such a way that they always use a particular screen size, ignoring the size passed from the browser client. This is necessary to accommodate some applications which require a very specific screen resolution in order to render correctly.
b76dfdd to
d9bbafd
Compare
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Feb 16, 2024
See #34580 for the associated implementation
zmb3
added a commit
that referenced
this pull request
Feb 20, 2024
See #34580 for the associated implementation
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Mar 2, 2024
See #34580 for the associated implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

By default this should remain unspecified, which preserves the behavior we have today (Teleport uses the size of the user's browser window).
These new fields allow cluster administrators to configure desktops in such a way that they always use a particular screen size, ignoring the size passed from the browser client. This is necessary to accommodate some applications which require a very specific screen resolution in order to render correctly.
changelog: Desktops can now be configured to use the same screen resolution for all sessions.