Пример #1
0
        private void HandleSetDesktopSize()
        {
            var message         = this.c.Receive(7);
            var width           = BinaryPrimitives.ReadUInt16BigEndian(message.AsSpan(1, 2));
            var height          = BinaryPrimitives.ReadUInt16BigEndian(message.AsSpan(3, 2));
            var numberOfScreens = message[5];

            var screens = this.c.Receive(16 * numberOfScreens);

            ExtendedDesktopSizeStatus result = ExtendedDesktopSizeStatus.Prohibited;

            if (this.fbSource != null)
            {
                result = this.fbSource.SetDesktopSize(width, height);
            }

            List <Rectangle> rectangles = new List <Rectangle>();

            rectangles.Add(
                this.GetExtendedDesktopSizeRectangle(
                    ExtendedDesktopSizeReason.Client,
                    result));
            this.SendRectangles(rectangles);
        }
Пример #2
0
        private Rectangle GetExtendedDesktopSizeRectangle(ExtendedDesktopSizeReason reason, ExtendedDesktopSizeStatus status)
        {
            // https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#extendeddesktopsize-pseudo-encoding
            // The server must send an ExtendedDesktopSize rectangle in response to a FramebufferUpdateRequest with
            // incremental set to zero, assuming the client has requested the ExtendedDesktopSize pseudo-encoding
            // using the SetEncodings message.
            byte[] encodingData = new byte[20];

            // Header
            encodingData[0] = 1; // number of screens

            // SCREEN array
            BinaryPrimitives.WriteUInt32BigEndian(encodingData.AsSpan(4, 4), 0);                                // Screen id
            BinaryPrimitives.WriteUInt16BigEndian(encodingData.AsSpan(8, 2), 0);                                // X-position
            BinaryPrimitives.WriteUInt16BigEndian(encodingData.AsSpan(10, 2), 0);                               // Y-position
            BinaryPrimitives.WriteUInt16BigEndian(encodingData.AsSpan(12, 2), (ushort)this.Framebuffer.Width);  // Width
            BinaryPrimitives.WriteUInt16BigEndian(encodingData.AsSpan(14, 2), (ushort)this.Framebuffer.Height); // Height
            BinaryPrimitives.WriteUInt16BigEndian(encodingData.AsSpan(16, 4), 0);                               // Flags. Currently unused.

            return
                (new Rectangle()
            {
                Region = new VncRectangle()
                {
                    X = (int)reason,
                    Y = 0,
                    Width = this.Framebuffer.Width,
                    Height = this.Framebuffer.Height,
                },
                Contents = encodingData,
                Encoding = VncEncoding.ExtendedDesktopSize,
            });
        }