Skip to content

Commit

Permalink
Resize (#39819)
Browse files Browse the repository at this point in the history
* Resize

* ???

* ???

* Fixes to compile

* Updates to latest IronRDP with dvc fix, cleans up some of the debug code

* Hooks up resize listener on the client and sends changes as ClientScreenSpecs to the backend. Currently just gets logged in the WDS

* Handles the new DeactivateAll ProcessorOutput

* hooks up client_write_screen_resize

* Renames tdp Connection Initialized to Connection Activated
This message is now used both after the connection is first established
and after the connection executes a Deactivation-Reactivation Sequence.

This fits snugly in to our existing message flow and ensures that the fast
path processor is updated appropriately whenever a Deactivation-Reactivation
Sequence is executed due to a resize event.

* Switch monitor orientation based on width/height

* remove superfluous canvas size sync

* Updates to the most up-to-date hash for IronRDP (not merged to master). Screen resize works in this commit, though its still the case that if you do so before the channel is announced by the rdp server, it will end the session

* Updates to the most recent hash for IronRDP feat/dynamic-resize

* Adds a mechanism to withhold sending resize requests to the RDP server until we're alerted by a new callback mechanism of the DisplayControlClient that the server has sent us its capabilities. This prevents an error where we send a resize before this event, which results either in an RDP error (if the channel is not opened) or a dropped event (if the server has not sent its capabilities yet).

* Refactoring after update to the tip of Devolutions/IronRDP#424

* Adds windowOnResize to story

* adds Determine Toolchain Versions and cache paths and Print versions steps to os-compatibility-test.yaml

* fixes debug log formatting

* Updates to local IronRDP and later IronRDP api

* updates to IronRDP latest rev on Devolutions/IronRDP#430

* reverting mistaken changes

* throttle -> debounce and naming changes

* js renamings

* updates to IronRDP master

---------

Co-authored-by: Przemko Robakowski <[email protected]>
  • Loading branch information
Isaiah Becker-Mayer and probakowski authored Apr 29, 2024
1 parent f584c75 commit f2a51ed
Show file tree
Hide file tree
Showing 17 changed files with 450 additions and 135 deletions.
42 changes: 29 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ codegen-units = 1
[workspace.dependencies]
# Note: To use a local IronRDP repository as a crate (for example, ironrdp-cliprdr), define the dependency as follows:
# ironrdp-cliprdr = { path = "/path/to/local/IronRDP/crates/ironrdp-cliprdr" }
# This rev hash corresponds to https://github.com/Devolutions/IronRDP/pull/436. It is being merged while that PR is
# still open in IronRDP in order to get these changes into a release, however it should be updated once that PR is
# merged. In the meantime, no other IronRDP hash's (without these changes) should be used.
ironrdp-cliprdr = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-connector = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-graphics = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-pdu = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-rdpdr = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-rdpsnd = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-session = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-svc = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-tls = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275", features = ["rustls"]}
ironrdp-tokio = { git = "https://github.com/Devolutions/IronRDP", rev = "49dab7d8df4bd785bf17fce97ac02beaba0b0275" }
ironrdp-cliprdr = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-connector = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-displaycontrol = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-dvc = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-graphics = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-pdu = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-rdpdr = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-rdpsnd = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-session = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-svc = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
ironrdp-tls = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2", features = ["rustls"]}
ironrdp-tokio = { git = "https://github.com/Devolutions/IronRDP", rev = "fd105e4b56647ab2f54aa23954aec4aaeef118e2" }
4 changes: 4 additions & 0 deletions lib/srv/desktop/rdp/rdpclient/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ironrdp-rdpdr.workspace = true
ironrdp-rdpsnd.workspace = true
ironrdp-session.workspace = true
ironrdp-svc.workspace = true
ironrdp-dvc.workspace = true
ironrdp-displaycontrol.workspace = true
ironrdp-tls.workspace = true
ironrdp-tokio.workspace = true
iso7816 = "0.1.2"
Expand All @@ -36,6 +38,8 @@ tokio = { version = "1.37", features = ["full"] }
tokio-boring = { git = "https://github.com/gravitational/boring", rev="605253d99d5e363e178bcf97e1d4622e33844cd5", optional = true }
utf16string = "0.2.0"
uuid = { version = "1.8.0", features = ["v4"] }
tracing-subscriber = "0.3.17"
tracing = { version = "0.1", features = ["log-always" ] }

[build-dependencies]
cbindgen = "0.26.0"
Expand Down
21 changes: 15 additions & 6 deletions lib/srv/desktop/rdp/rdpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,15 @@ func (c *Client) startInputStreaming(stopCh chan struct{}) error {
c.UpdateClientActivity()

switch m := msg.(type) {
case tdp.ClientScreenSpec:
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),
C.uint32_t(m.Width),
C.uint32_t(m.Height),
); errCode != C.ErrCodeSuccess {
return trace.Errorf("ClientScreenSpec: client_write_screen_resize: %v", errCode)
}
case tdp.MouseMove:
mouseX, mouseY = m.X, m.Y
if errCode := C.client_write_rdp_pointer(
Expand Down Expand Up @@ -694,8 +703,8 @@ func (c *Client) handleRDPFastPathPDU(data []byte) C.CGOErrCode {
return C.ErrCodeSuccess
}

//export cgo_handle_rdp_connection_initialized
func cgo_handle_rdp_connection_initialized(
//export cgo_handle_rdp_connection_activated
func cgo_handle_rdp_connection_activated(
handle C.uintptr_t,
io_channel_id C.uint16_t,
user_channel_id C.uint16_t,
Expand All @@ -706,17 +715,17 @@ func cgo_handle_rdp_connection_initialized(
if err != nil {
return C.ErrCodeFailure
}
return client.handleRDPConnectionInitialized(io_channel_id, user_channel_id, screen_width, screen_height)
return client.handleRDPConnectionActivated(io_channel_id, user_channel_id, screen_width, screen_height)
}

func (c *Client) handleRDPConnectionInitialized(ioChannelID, userChannelID, screenWidth, screenHeight C.uint16_t) C.CGOErrCode {
c.cfg.Logger.DebugContext(context.Background(), "Received RDP channel IDs", "io_channel", ioChannelID, "user_channel", userChannelID)
func (c *Client) handleRDPConnectionActivated(ioChannelID, userChannelID, screenWidth, screenHeight C.uint16_t) C.CGOErrCode {
c.cfg.Logger.DebugContext(context.Background(), "Received RDP channel IDs", "io_channel_id", ioChannelID, "user_channel_id", userChannelID)

// Note: RDP doesn't always use the resolution we asked for.
// This is especially true when we request dimensions that are not a multiple of 4.
c.cfg.Logger.DebugContext(context.Background(), "RDP server provided resolution", "width", screenWidth, "height", screenHeight)

if err := c.cfg.Conn.WriteMessage(tdp.ConnectionInitialized{
if err := c.cfg.Conn.WriteMessage(tdp.ConnectionActivated{
IOChannelID: uint16(ioChannelID),
UserChannelID: uint16(userChannelID),
ScreenWidth: uint16(screenWidth),
Expand Down
Loading

0 comments on commit f2a51ed

Please sign in to comment.