Skip to content

Commit

Permalink
Ignores resizes when a desktop has screen_size set (#41198)
Browse files Browse the repository at this point in the history
* Ignores resizes when a desktop has `screen_size` set

`screen_size` is meant to be a static override of the screen size,
however this property was mistakenly lost when
#39819 was merged.

This commit restores the behavior of `screen_size` by ignoring resizes
when it is set.

* hasSizeOverride and //nolint
  • Loading branch information
Isaiah Becker-Mayer committed May 6, 2024
1 parent 8ec03f3 commit 904f6c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/srv/desktop/rdp/rdpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (c *Client) readClientSize() error {
continue
}

if c.cfg.Width != 0 && c.cfg.Height != 0 {
if c.cfg.hasSizeOverride() {
// Some desktops have a screen size in their resource definition.
// If non-zero then we always request this screen size.
c.cfg.Log.Debugf("Forcing a screen size of %dx%d", c.cfg.Width, c.cfg.Height)
Expand Down Expand Up @@ -394,6 +394,12 @@ func (c *Client) startInputStreaming(stopCh chan struct{}) error {

switch m := msg.(type) {
case tdp.ClientScreenSpec:
// If the client has specified a fixed screen size, we don't
// need to send a screen resize event.
if c.cfg.hasSizeOverride() {
continue
}

c.cfg.Log.Debugf("Client changed screen size: %d x %d", m.Width, m.Height)
if errCode := C.client_write_screen_resize(
C.ulong(c.handle),
Expand Down
7 changes: 7 additions & 0 deletions lib/srv/desktop/rdp/rdpclient/client_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ func (c *Config) checkAndSetDefaults() error {
c.Log = c.Log.WithField("rdp-addr", c.Addr)
return nil
}

// hasSizeOverride returns true if the width and height have been set.
// This will be true when a user has specified a fixed `screen_size` for
// a given desktop.
func (c *Config) hasSizeOverride() bool { //nolint:unused // used in client.go that is behind desktop_access_rdp build flag
return c.Width != 0 && c.Height != 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export default function useTdpClientCanvas(props: Props) {
) => {
// The first image fragment we see signals a successful TDP connection.
if (!initialTdpConnectionSucceeded.current) {
syncCanvas(ctx.canvas, getDisplaySize());
setTdpConnection({ status: 'success' });
initialTdpConnectionSucceeded.current = true;
}
Expand Down

0 comments on commit 904f6c0

Please sign in to comment.