Skip to content

Commit

Permalink
Ignores resizes when a desktop has screen_size set
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
Isaiah Becker-Mayer committed May 4, 2024
1 parent df39993 commit e5a5da4
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.hasOverrideSize() {
// Some desktops have a screen size in their resource definition.
// If non-zero then we always request this screen size.
c.cfg.Logger.DebugContext(context.Background(), "Forcing a fixed screen size", "width", c.cfg.Width, "height", 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.hasOverrideSize() {
continue
}

c.cfg.Logger.DebugContext(context.Background(), "Client changed screen size", "width", m.Width, "height", 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.Logger = c.Logger.With("rdp-addr", c.Addr)
return nil
}

// hasOverrideSize 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) hasOverrideSize() bool {

Check failure on line 101 in lib/srv/desktop/rdp/rdpclient/client_common.go

View workflow job for this annotation

GitHub Actions / Lint (Go)

func `(*Config).hasOverrideSize` is unused (unused)
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 e5a5da4

Please sign in to comment.