Mobile terminal remote desktop touch coordinate accurate mapping method, device, equipment and medium
By acquiring and compensating for visual viewport offset and CSS transformation parameters, and combining the height of fixed elements on the interface, the target coordinates of the touch point on the mobile remote desktop are calculated, solving the problem of touch point and cursor position deviation in the existing technology and achieving high-precision touch coordinate mapping.
Patent Information
- Application Number
- CN202611376303.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies for mobile remote desktop control fail to effectively handle CSS transformations, Visual Viewport offsets, and fixed elements on the interface, resulting in significant deviations between touch points and cursor positions, especially noticeable after the soft keyboard pops up and zooms in.
By obtaining the coordinates of the touch point in the browser's visible viewport, compensating for the offset of the visual viewport relative to the layout viewport, and combining CSS transformation parameters and the fixed offset height of the interface elements, the target coordinates of the touch point on the remote desktop canvas are calculated, and the visual viewport offset of the soft keyboard pop-up is compensated on the iOS side to achieve accurate mapping.
It achieves high-precision touch coordinate mapping in various complex scenarios, with high click accuracy, strong compatibility, and adaptability to CSS transformations, Visual Viewport offsets, and fixed element placement in the interface, achieving sub-pixel precision.
Smart Images

Figure CN123177724A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of human-computer interaction technology, and in particular to a method, apparatus, device, and medium for accurate mapping of touch coordinates on a mobile remote desktop. Background Technology
[0002] In web-based mobile remote desktop control technology, accurate mapping from touch point coordinates to remote desktop canvas coordinates is the core foundation for achieving precise control. However, existing technologies have the following shortcomings in this aspect: First, it doesn't adapt to CSS transforms. To ensure the remote desktop display is complete on the small screen of a mobile device, the front-end typically uses CSS's scale and translate functions to transform the display container. The coordinates reported by touch events are the raw coordinates relative to the screen or viewport, while the remote desktop expects to receive absolute coordinates on the canvas. Existing solutions generally send touch coordinates directly as canvas coordinates without performing inverse transformations on scale and translate, resulting in a significant deviation between the touch point and the cursor position, which is especially noticeable when the screen is zoomed in.
[0003] Second, the Visual Viewport offset on iOS is not handled. In the iOS Safari browser, when the soft keyboard pops up, the `pageTop` value of `window.visualViewport` changes from 0 to a positive value (i.e., the vertical offset of the visual viewport relative to the layout viewport). Touch events' `clientX` and `clientY` always use the visual viewport as the reference frame, while CSS transforms' `translate` uses the layout viewport. This inconsistency in reference frames means that without compensation, the mapped coordinates of all touch points will experience a systematic offset after the soft keyboard pops up, resulting in a discrepancy between the user's click position and the actual cursor landing point.
[0004] Third, the placement offset of fixed elements on the interface was not considered. In mobile remote desktop applications, a browser toolbar (such as a tab bar or address bar) is often embedded at the top of the display container, and this toolbar occupies a fixed pixel height. When the touch point falls on the toolbar area, remote desktop control should not be triggered. However, when the touch point falls directly below the toolbar, if the toolbar height is not subtracted from the coordinates, it will also cause the click position to shift downwards.
[0005] In summary, existing technologies urgently need a method that can simultaneously accommodate CSS transformations, Visual Viewport offsets, and fixed element placement on the interface to achieve high-precision coordinate mapping. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to provide a method, device, equipment and medium for accurate mapping of touch coordinates of mobile remote desktop, which solves the coordinate offset problem of mobile web remote desktop in complex scenarios such as CSS transformation, soft keyboard pop-up and toolbar placeholder, with high click accuracy and strong compatibility.
[0007] In a first aspect, the present invention provides a method for accurately mapping touch coordinates on a mobile remote desktop, comprising the following steps: In response to a touch event, obtain the first coordinates of the touch point in the mobile browser's viewport, where the first coordinates include the horizontal coordinate clientX and the vertical coordinate clientY. Obtain the offset of the browser's visual viewport relative to the layout viewport, the offset including a horizontal offset pageLeft and a vertical offset pageTop; Obtain the CSS transformation parameters applied to the display container that carries the remote desktop screen. The CSS transformation parameters include the scaling value (scale), the horizontal displacement value (translateX), and the vertical displacement value (translateY). Get the fixed offset height (toolbarHeight) of the top of the display container occupied by the interface element; The target coordinates of the touch point on the remote desktop canvas are calculated using the following formula, where the target coordinates include the horizontal coordinate targetX and the vertical coordinate targetY: targetX=(clientX+pageLeft–translateX) / scale; targetY=(clientY+pageTop–translateY) / scale–toolbarHeight; The target coordinates are associated with the corresponding mouse events and sent to the remote desktop server.
[0008] Furthermore, the offsets pageLeft and pageTop are provided by the window.visualViewport interface; when the interface is unavailable, window.scrollX and window.scrollY are used as alternative values for pageLeft and pageTop, respectively. The fixed offset height toolbarHeight is the pixel height occupied by the browser toolbar embedded at the top of the display container, and the toolbar at least covers the top area of the display container.
[0009] Furthermore, after the soft keyboard pops up on the iOS device, the origin of the first coordinates clientX and clientY is still located at the upper left corner of the visual viewport; the vertical offset pageTop is greater than 0 after the soft keyboard pops up, and after compensation by the formula, the touch point is mapped to the same absolute position on the canvas as before the soft keyboard pops up.
[0010] Furthermore, it also includes: When the touch event is detected as a mouse drag event, the target coordinates of multiple touch movement frames are calculated continuously, and a smooth movement trajectory is generated and sent to the remote desktop server.
[0011] Secondly, the present invention provides a precise mapping device for touch coordinates on a mobile remote desktop, comprising: The touch coordinate acquisition module is used to respond to touch events and acquire the first coordinates of the touch point in the visible viewport of the mobile browser. The first coordinates include the horizontal coordinate clientX and the vertical coordinate clientY. The viewport offset acquisition module is used to acquire the offset of the browser's visual viewport relative to the layout viewport, the offset including a horizontal offset pageLeft and a vertical offset pageTop; The transformation parameter reading module is used to obtain the CSS transformation parameters applied by the display container that carries the remote desktop screen. The CSS transformation parameters include the scaling value (scale), the horizontal displacement value (translateX), and the vertical displacement value (translateY). A fixed offset input module is used to obtain the fixed offset height (toolbarHeight) of the top of the display container occupied by interface elements; The coordinate calculation module is used to calculate the target coordinates of the touch point on the remote desktop canvas according to the following formula, wherein the target coordinates include the horizontal coordinate targetX and the vertical coordinate targetY: targetX=(clientX+pageLeft–translateX) / scale; targetY=(clientY+pageTop–translateY) / scale–toolbarHeight; The output module associates the target coordinates with the corresponding mouse events and sends them to the remote desktop server.
[0012] Furthermore, the offsets pageLeft and pageTop are provided by the window.visualViewport interface; when the interface is unavailable, window.scrollX and window.scrollY are used as alternative values for pageLeft and pageTop, respectively. The fixed offset height toolbarHeight is the pixel height occupied by the browser toolbar embedded at the top of the display container, and the toolbar at least covers the top area of the display container.
[0013] Furthermore, after the soft keyboard pops up on the iOS device, the origin of the first coordinates clientX and clientY is still located at the upper left corner of the visual viewport; the vertical offset pageTop is greater than 0 after the soft keyboard pops up, and after compensation by the formula, the touch point is mapped to the same absolute position on the canvas as before the soft keyboard pops up.
[0014] Furthermore, it also includes: When the touch event is detected as a mouse drag event, the target coordinates of multiple touch movement frames are calculated continuously, and a smooth movement trajectory is generated and sent to the remote desktop server.
[0015] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect.
[0016] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.
[0017] One or more technical solutions provided by this invention have at least the following technical effects or advantages: (1) This invention achieves precise inverse transformation from touch point to canvas coordinates by sequentially superimposing the visualViewport offset, subtracting the CSS translation amount, dividing by the CSS scaling ratio, and deducting the height of the top fixed toolbar, and maintains subpixel-level accuracy under any scaling ratio.
[0018] (2) This invention uses the window.visualViewport.pageTop and pageLeft properties to obtain the visual viewport offset in real time and superimpose it on the touch coordinates. Even after the iOS soft keyboard pops up, the accuracy of the coordinate mapping can still be maintained, which solves the long-standing problem of coordinate offset in input scenarios of mobile Web remote desktop.
[0019] (3) This invention obtains the fixed offset height toolbarHeight at the top of the display container and deducts it in the vertical coordinate calculation, ensuring that the top toolbar does not affect the coordinate mapping accuracy of the screen below, and adapts to complex UI layouts that include a top navigation bar.
[0020] (4) When the window.visualViewport interface is unavailable, the present invention automatically downgrades to use window.scrollX and window.scrollY as alternative values, which is compatible with older browsers and WebView environments.
[0021] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0022] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0023] Figure 1 This is a flowchart of the method in Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the device in Embodiment 2 of the present invention. Detailed Implementation
[0024] The overall concept of the technical solution in this application is as follows: Supports coordinate transformation methods for Visual Viewport offset compensation: The transformation from touch coordinates to remote desktop canvas coordinates requires the reverse application of CSS scale and translate, and compensation for the visualViewport.pageTop offset caused when the iOS soft keyboard pops up, as well as the paddingTop offset caused by the embedded toolbar.
[0025] Key implementation code (touch.ts — filterEventPointer method): / ** Convert screen touch coordinates to remote desktop canvas coordinates; Reverse-apply the current translate and scale, and compensate: Visual Viewport offset caused by iOS soft keyboard (vpScrollX / vpScrollY) The paddingTop height (toolbarHeight) occupied by the top toolbar. / private filterEventPointer = ({ x, y}: { x: number; y: number}) =>{ const vp = window.visualViewport; const vpScrollX = vp ? vp.pageLeft : window.scrollX; const vpScrollY = vp ? vp.pageTop : window.scrollY; x = (x + vpScrollX - this.transform.translate.x) / this.transform.scale; y = (y + vpScrollY - this.transform.translate.y) / this.transform.scale this.toolbarHeight; return { x, y}; }; Coordinate transformation formula: Canvas X = (touch clientX + visualViewport.pageLeft - translateX) / scale Canvas Y = (touchclientY + visualViewport.pageTop - translateY) / scale -toolbarHeight. Example 1
[0026] like Figure 1 As shown, this embodiment provides a method for accurately mapping touch coordinates on a mobile remote desktop, including the following steps: In response to a touch event, obtain the first coordinates of the touch point in the mobile browser's viewport, where the first coordinates include the horizontal coordinate clientX and the vertical coordinate clientY. Obtain the offset of the browser's visual viewport relative to the layout viewport, the offset including a horizontal offset pageLeft and a vertical offset pageTop; Obtain the CSS transformation parameters applied to the display container that carries the remote desktop screen. The CSS transformation parameters include the scaling value (scale), the horizontal displacement value (translateX), and the vertical displacement value (translateY). Get the fixed offset height (toolbarHeight) of the top of the display container occupied by the interface element; The target coordinates of the touch point on the remote desktop canvas are calculated using the following formula, where the target coordinates include the horizontal coordinate targetX and the vertical coordinate targetY: targetX=(clientX+pageLeft–translateX) / scale; targetY=(clientY+pageTop–translateY) / scale–toolbarHeight; The target coordinates are associated with the corresponding mouse events and sent to the remote desktop server.
[0027] In this embodiment, preferably, the offsets pageLeft and pageTop are provided by the window.visualViewport interface; when the interface is unavailable, window.scrollX and window.scrollY are used as alternative values for pageLeft and pageTop, respectively. The fixed offset height toolbarHeight is the pixel height occupied by the browser toolbar embedded at the top of the display container, and the toolbar at least covers the top area of the display container.
[0028] In this embodiment, preferably, after the soft keyboard pops up on the iOS device, the origin of the first coordinates clientX and clientY is still located at the upper left corner of the visual viewport; the vertical offset pageTop is greater than 0 after the soft keyboard pops up, and after compensation by the formula, the touch point is mapped to the same absolute position on the canvas as before the soft keyboard pops up.
[0029] In this embodiment, preferably, it also includes: When the touch event is detected as a mouse drag event, the target coordinates of multiple touch movement frames are calculated continuously, and a smooth movement trajectory is generated and sent to the remote desktop server.
[0030] Based on the same inventive concept, this application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2. Example 2
[0031] like Figure 2 As shown, this embodiment provides a precise mapping device for touch coordinates on a mobile remote desktop, including: The touch coordinate acquisition module is used to respond to touch events and acquire the first coordinates of the touch point in the visible viewport of the mobile browser. The first coordinates include the horizontal coordinate clientX and the vertical coordinate clientY. The viewport offset acquisition module is used to acquire the offset of the browser's visual viewport relative to the layout viewport, the offset including a horizontal offset pageLeft and a vertical offset pageTop; The transformation parameter reading module is used to obtain the CSS transformation parameters applied by the display container that carries the remote desktop screen. The CSS transformation parameters include the scaling value (scale), the horizontal displacement value (translateX), and the vertical displacement value (translateY). A fixed offset input module is used to obtain the fixed offset height (toolbarHeight) of the top of the display container occupied by interface elements; The coordinate calculation module is used to calculate the target coordinates of the touch point on the remote desktop canvas according to the following formula, wherein the target coordinates include the horizontal coordinate targetX and the vertical coordinate targetY: targetX=(clientX+pageLeft–translateX) / scale; targetY=(clientY+pageTop–translateY) / scale–toolbarHeight; The output module associates the target coordinates with the corresponding mouse events and sends them to the remote desktop server.
[0032] In this embodiment, preferably, the offsets pageLeft and pageTop are provided by the window.visualViewport interface; when the interface is unavailable, window.scrollX and window.scrollY are used as alternative values for pageLeft and pageTop, respectively. The fixed offset height toolbarHeight is the pixel height occupied by the browser toolbar embedded at the top of the display container, and the toolbar at least covers the top area of the display container.
[0033] In this embodiment, preferably, after the soft keyboard pops up on the iOS device, the origin of the first coordinates clientX and clientY is still located at the upper left corner of the visual viewport; the vertical offset pageTop is greater than 0 after the soft keyboard pops up, and after compensation by the formula, the touch point is mapped to the same absolute position on the canvas as before the soft keyboard pops up.
[0034] In this embodiment, preferably, it also includes: When the touch event is detected as a mouse drag event, the target coordinates of multiple touch movement frames are calculated continuously, and a smooth movement trajectory is generated and sent to the remote desktop server.
[0035] Since the apparatus described in Embodiment 2 of the present invention is an apparatus used to implement the method of Embodiment 1 of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in Embodiment 1 of the present invention, and therefore will not be described again here. All apparatuses used in the method of Embodiment 1 of the present invention fall within the scope of protection of the present invention.
[0036] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1, as detailed in Embodiment 3. Example 3
[0037] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it can implement any of the implementation methods in Embodiment 1.
[0038] Since the electronic device described in this embodiment is the device used to implement the method in Embodiment 1 of this application, those skilled in the art can understand the specific implementation method and various variations of the electronic device in this embodiment based on the method described in Embodiment 1 of this application. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. Any device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection of this application.
[0039] Based on the same inventive concept, this application provides a storage medium corresponding to Embodiment 1, as detailed in Embodiment 4. Example 4
[0040] This embodiment provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it can implement any of the implementation methods in Embodiment 1. Example 5
[0041] This embodiment describes touch coordinate mapping in the soft keyboard pop-up scenario of the iOS Safari browser as an example. However, those skilled in the art should understand that the present invention is also applicable to other mobile browser environments with visual viewport offset.
[0042] I. Touch event capture and initial coordinate acquisition When a user performs actions such as clicking or swiping on a mobile browser's touchscreen, the browser triggers corresponding touch events (touchstart, touchmove, touchend). In this embodiment, the touch event listener first obtains the touch point information from the event object, and reads the first coordinates of the touch point in the visual viewport, including the horizontal coordinate clientX and the vertical coordinate clientY. clientX and clientY are coordinate values relative to the top-left corner of the browser's visual viewport, excluding page scroll offset. In this embodiment, for multi-touch, the first touch point is taken as the operation point, and the coordinates of this point are used uniformly in subsequent coordinate transformations.
[0043] II. Obtaining the Viewport Offset While obtaining the touch point coordinates, this embodiment uses the window.visualViewport interface to obtain the offset of the visual viewport relative to the layout viewport. Specifically, visualViewport.pageLeft is read as the horizontal offset pageLeft, and visualViewport.pageTop is read as the vertical offset pageTop.
[0044] When the soft keyboard is not displayed, the visual viewport and the layout viewport are completely aligned, pageTop = 0, and touch coordinates require no additional compensation. However, after the soft keyboard is displayed, the iOS Safari browser compresses the visual viewport upwards to make room for it, causing the visual viewport to shift downwards relative to the layout viewport. This results in pageTop becoming a positive value (usually equal to the soft keyboard height minus the address bar height). At this point, the touch event's clientY still originates from the top-left corner of the visual viewport, while the CSS transform's translate originates from the layout viewport, leading to inconsistent reference systems. This embodiment reads the pageTop value and adds it to the touch coordinate clientY, making clientY + pageTop equivalent to the coordinate value with the layout viewport as the reference system, thus unifying the reference system.
[0045] To enhance compatibility, when the window.visualViewport interface is unavailable (such as in some older browsers or WebView), this embodiment automatically downgrades and uses window.scrollX and window.scrollY as alternative values for pageLeft and pageTop, respectively.
[0046] III. Reading CSS Transformation Parameters In this embodiment, the display container carrying the remote desktop screen (i.e., the root DOM element of the RemoteView component) applies scaling and translation transformations using the CSS transform property. Specifically, the transform property value consists of three parts: translateX (horizontal displacement), translateY (vertical displacement), and scale (scaling ratio). During each touch event processing, this embodiment reads the current translateX, translateY, and scale values from the this.transform object in memory; these values are updated in real-time during front-end screen rendering and gesture operations.
[0047] IV. Obtaining the Fixed Offset Height in the Top Toolbar In this embodiment, the remote desktop display container has a RemoteToolbar browser tab toolbar embedded at the top. This toolbar is horizontally laid out in portrait mode and occupies a fixed pixel height (50px in this embodiment). This toolbar is independent of the remote desktop screen; a touch point falling on the toolbar area should not be mapped to the remote desktop canvas. However, during coordinate transformation, simply dividing the touch coordinates by scale and subtracting translate still results in canvas coordinates that include the offset caused by the toolbar height, causing the click position to shift downwards. Therefore, this embodiment obtains the actual pixel height occupied by the RemoteToolbar component via props as the toolbarHeight and deducts it during vertical coordinate transformation.
[0048] V. Precise Calculation of Canvas Target Coordinates After obtaining all the above parameters, this embodiment calculates the target coordinates (targetX, targetY) of the touch point on the remote desktop canvas according to the following formula: targetX=(clientX+pageLeft–translateX) / scale targetY=(clientY+pageTop–translateY) / scale–toolbarHeight The derivation logic of this formula is as follows: Since the display container is scaled by a factor of `scale` and translated by (translateX, translateY), the forward transformation from the absolute canvas coordinates to the screen display coordinates is: Display X = Canvas X × scale + translateX – pageLeft. Therefore, the inverse transformation is: Canvas X = (Display X + pageLeft – translateX) / scale. The same logic applies to the vertical direction, with an additional deduction for the toolbar height (toolbarHeight).
[0049] In this embodiment, the above calculations are performed in real time during the callback of each touch event, and the calculation results are stored in memory for later use.
[0050] VI. Application of Coordinate Mapping Results The calculated target coordinates are associated with the mouse event type (such as mousedown, mousemove, mouseup, click, etc.) corresponding to the current touch event, packaged into a protocol data packet, and sent to the remote desktop server via the WebSocket channel. The server then performs mouse operations at the corresponding positions on the remote desktop canvas based on the received coordinates and event type.
[0051] For mouse drag events, this embodiment further calculates the target coordinates of multiple touch movement frames continuously and sends these coordinates serially to the server, so that the server can generate a smooth movement trajectory and avoid stuttering or jumping during the drag process.
[0052] VII. Effect Verification Tests have shown that, using the coordinate mapping method of this embodiment, in the iOS Safari browser, regardless of whether the soft keyboard pops up, whether the screen is zoomed or panned, or whether the top toolbar is displayed, the error between the mapped coordinates of the touch point and the actual landing point of the remote desktop cursor is less than 1 pixel, achieving sub-pixel level accurate mapping.
[0053] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0054] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0055] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0056] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0057] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for accurately mapping touch coordinates on a mobile remote desktop, characterized in that, Includes the following steps: In response to a touch event, obtain the first coordinates of the touch point in the mobile browser's viewport, where the first coordinates include the horizontal coordinate clientX and the vertical coordinate clientY. Obtain the offset of the browser's visual viewport relative to the layout viewport, the offset including a horizontal offset pageLeft and a vertical offset pageTop; Obtain the CSS transformation parameters applied to the display container that carries the remote desktop screen. The CSS transformation parameters include the scaling value (scale), the horizontal displacement value (translateX), and the vertical displacement value (translateY). Get the fixed offset height (toolbarHeight) of the top of the display container occupied by the interface element; The target coordinates of the touch point on the remote desktop canvas are calculated using the following formula, where the target coordinates include the horizontal coordinate targetX and the vertical coordinate targetY: targetX=(clientX+pageLeft–translateX) / scale; targetY=(clientY+pageTop–translateY) / scale–toolbarHeight; The target coordinates are associated with the corresponding mouse events and sent to the remote desktop server.
2. The method according to claim 1, characterized in that, The offsets pageLeft and pageTop are provided by the window.visualViewport interface; when the interface is unavailable, window.scrollX and window.scrollY are used as alternative values for pageLeft and pageTop, respectively. The fixed offset height toolbarHeight is the pixel height occupied by the browser toolbar embedded at the top of the display container, and the toolbar at least covers the top area of the display container.
3. The method according to claim 1, characterized in that, After the soft keyboard pops up on the iOS device, the origin of the first coordinates clientX and clientY is still located at the top left corner of the visual viewport; the vertical offset pageTop is greater than 0 after the soft keyboard pops up, and after compensation by the formula, the touch point is mapped to the same absolute position on the canvas as before the soft keyboard pops up.
4. The method according to claim 1, characterized in that, Also includes: When the touch event is detected as a mouse drag event, the target coordinates of multiple touch movement frames are calculated continuously, and a smooth movement trajectory is generated and sent to the remote desktop server.
5. A precise mapping device for touch coordinates on a mobile remote desktop, characterized in that, include: The touch coordinate acquisition module is used to respond to touch events and acquire the first coordinates of the touch point in the visible viewport of the mobile browser. The first coordinates include the horizontal coordinate clientX and the vertical coordinate clientY. The viewport offset acquisition module is used to acquire the offset of the browser's visual viewport relative to the layout viewport, the offset including a horizontal offset pageLeft and a vertical offset pageTop; The transformation parameter reading module is used to obtain the CSS transformation parameters applied by the display container that carries the remote desktop screen. The CSS transformation parameters include the scaling value (scale), the horizontal displacement value (translateX), and the vertical displacement value (translateY). A fixed offset input module is used to obtain the fixed offset height (toolbarHeight) of the top of the display container occupied by interface elements; The coordinate calculation module is used to calculate the target coordinates of the touch point on the remote desktop canvas according to the following formula, wherein the target coordinates include the horizontal coordinate targetX and the vertical coordinate targetY: targetX=(clientX+pageLeft–translateX) / scale; targetY=(clientY+pageTop–translateY) / scale–toolbarHeight; The output module associates the target coordinates with the corresponding mouse events and sends them to the remote desktop server.
6. The precise mapping device for touch coordinates of a mobile remote desktop according to claim 5, characterized in that, The offsets pageLeft and pageTop are provided by the window.visualViewport interface; when the interface is unavailable, window.scrollX and window.scrollY are used as alternative values for pageLeft and pageTop, respectively. The fixed offset height toolbarHeight is the pixel height occupied by the browser toolbar embedded at the top of the display container, and the toolbar at least covers the top area of the display container.
7. The precise mapping device for touch coordinates of a mobile remote desktop according to claim 5, characterized in that, After the soft keyboard pops up on the iOS device, the origin of the first coordinates clientX and clientY is still located at the top left corner of the visual viewport; the vertical offset pageTop is greater than 0 after the soft keyboard pops up, and after compensation by the formula, the touch point is mapped to the same absolute position on the canvas as before the soft keyboard pops up.
8. A precise mapping device for touch coordinates on a mobile remote desktop according to claim 5, characterized in that, Also includes: When the touch event is detected as a mouse drag event, the target coordinates of multiple touch movement frames are calculated continuously, and a smooth movement trajectory is generated and sent to the remote desktop server.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 4.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 4.
