Method and device for realizing X window zooming in Wayland environment, electronic equipment and storage medium

By selecting the maximum scaling factor (max_scale) in the Wayland environment and updating the XWayland display parameters and coordinate transformation, the issues of blurry display and interaction offset of the X window at high resolutions are resolved, achieving clear and consistent display at high resolutions.

CN120704577AActive Publication Date: 2025-09-26KYLIN CORP
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510962001.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-14
Publication Date
2025-09-26
Estimated Expiration
2045-07-14

AI Technical Summary

Technical Problem

In the Wayland environment, X windows display blur, scaling distortion, and interactive offset issues in high-resolution and fractional scaling scenarios. In particular, in the XWayland environment, X11 applications display poorly.

Method used

The maximum scaling factor max_scale is selected by the Wayland compositor, and XWayland's xdg_output and xft.dpi are updated. XWayland redraws the window buffer and performs reverse scaling through the xwayland_unscale and xwayland_scale functions to ensure the consistency of logical coordinates and physical coordinates.

Benefits of technology

It improves the display clarity and interaction accuracy of X11 applications, solves the problems of blur and distortion, and realizes a seamless display experience in a multi-monitor environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120704577A_ABST
    Figure CN120704577A_ABST
Patent Text Reader

Abstract

The invention provides a method, a device and equipment for realizing X window zooming in a Wayland environment and a storage medium, and the method comprises the steps: selecting a maxscale, updating the related information of the maxscale, and transmitting the updated information to an XWayland; adjusting the screen size and geometric coordinates of the virtual device, and storing the updated xft.dpi and notifying the X11; x11, drawing a buffer according to the scaled screen size and the updated xft.dpi, and converting into a wlsurface and a wlbuffer on the basis of the buffer; after the Wayland synthesizer receives the surface, the Wayland synthesizer carries out reverse scaling on the surface; and when the surface is returned, the surface is zoomed and converted according to the maxscale and then is sent. Therefore, the method can solve the problem that the XWayland is blurred in display in a high-resolution scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of graphic display technology, and in particular to a method, device, electronic device and storage medium for implementing X window scaling in a Wayland environment. Background Art

[0002] In the Wayland environment, the concept of scaling is provided to ensure that text and icons have good display effects on screens with different resolutions in high-resolution or multi-monitor environments.

[0003] In the related art, the rootless mode of the X window in the Wayland environment, especially in the case of high resolution and fractional scaling, has a very unsatisfactory display of X11 applications. Blurred fonts are common. This is because the content of Wayland scaling depends on the Wayland client. The implementation of Wayland scaling is initiated by the Wayland compositor. The Wayland client can adjust its buffer and surface based on the scaling value obtained from the scaling event to adapt to displays with different resolutions or different scaling levels.

[0004] However, in the X11 environment, the screen in the Xserver has only one scale value, and the specific details of the window scaling depend on the window manager. Therefore, for XWayland, no matter what the actual scaling ratio of the Wayland output is, XWayland always applies a 1x scale to all its surfaces and buffers. This will cause the Wayland compositor to directly forcibly scale the XWayland window to the corresponding size, resulting in low-resolution display of X applications. Summary of the Invention

[0005] The present invention provides a method, device, electronic device and storage medium for implementing X window scaling in a Wayland environment, using an XWayland rootless mode to solve the problems of XWayland display blur, scaling distortion and interaction offset in high-resolution and fractional scaling scenarios.

[0006] In a first aspect, the present invention provides a method for implementing X window scaling in a Wayland environment, the method comprising:

[0007] S1. The Wayland compositor selects the maximum scaling factor max_scale of the window by calling the output_manager_get_scale function;

[0008] S2. The Wayland compositor updates the scale factor in xdg_output sent to XWayland based on max_scale and updates xft.dpi to 96*max_scale through the X11 interface.

[0009] S3. XWayland scales the screen size and geometric coordinates of the virtual output device it manages according to the updated xdg_output; it synchronously saves the updated xft.dpi and notifies all X11 applications;

[0010] S4 and X11 applications redraw their window buffers based on the scaled virtual output device's screen size and the updated xft.dpi.

[0011] S5. XWayland converts the window buffer into Wayland-related wl_surface and wl_buffer;

[0012] S6. The Wayland compositor receives the surface information transmitted from XWayland and performs reverse scaling through the xwayland_unscale function;

[0013] When the S7 and Wayland compositors return a surface to XWayland, they use the xwayland_scale function to scale the surface to max_scale before sending it back.

[0014] Furthermore, step S1 includes:

[0015] The Wayland compositor maintains a linked list for storing output-related information, where the linked list includes the scaling factor of each output display device. The output_manager_get_scale function traverses and compares all scaling factors in the linked list, and then obtains the maximum scaling factor max_scale in the linked list.

[0016] Furthermore, step S2 is only performed for the XWayland client.

[0017] Furthermore, step S5 includes:

[0018] XWayland converts the redrawn window buffer into a wl_buffer that the Wayland compositor can handle. At the same time, XWayland builds wl_surface and binds wl_buffer to wl_surface.

[0019] In a second aspect, the present invention provides a device for implementing X window scaling in a Wayland environment, comprising:

[0020] The selection module is used to select the maximum scaling factor max_scale of the window scaling by calling the output_manager_get_scale function;

[0021] Update module for updating the scaling factor in xdg_output sent to XWayland according to max_scale and updating xft.dpi to 96*max_scale via the X11 interface;

[0022] The management module is used to update xdg_output to scale the screen size and geometric coordinates of the virtual output device it manages, and to save the updated xft.dpi synchronously and notify all X11 applications;

[0023] The drawing module is used to redraw the window buffer according to the scaled screen size of the virtual output device and the updated xft.dpi;

[0024] The first conversion module is used to convert the window buffer into Wayland-related wl_surface and wl_buffer;

[0025] The receiving module is used to receive surface information transmitted from XWayland and perform reverse scaling through the xwayland_unscale function;

[0026] The second conversion module is used to scale the surface according to max_scale through the xwayland_scale function before sending it back to XWayland when returning the surface.

[0027] Furthermore, the selection module includes: maintaining a linked list for storing output-related information through the Wayland synthesizer, wherein the linked list includes the scaling factor of each output display device, and the output_manager_get_scale function traverses and compares all scaling factors in the linked list, and then obtains the maximum scaling factor max_scale in the linked list.

[0028] Furthermore, the update module is only executed for XWayland clients.

[0029] Furthermore, the first conversion module includes: XWayland converting the redrawn window buffer into a wl_buffer that can be processed by the Wayland compositor, and at the same time, XWayland constructing a wl_surface and binding the wl_buffer to the wl_surface.

[0030] In a third aspect, the present invention provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0031] The memory stores computer-executable instructions;

[0032] When the processor executes the computer-executable instructions stored in the memory, the processor is used to implement the method for implementing X window scaling in the Wayland environment according to any one of claims 1 to 4.

[0033] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method for implementing X window scaling in a Wayland environment as claimed in any one of claims 1 to 4.

[0034] The present invention provides a method, device, electronic device, and storage medium for implementing X window scaling in a Wayland environment. Using XWayland rootless mode, this method calculates scaling factors across multiple displays and selects the maximum value as the global scaling factor (max_scale) for processing XWayland windows. The Wayland compositor can synchronously update the xdg_output size sent to XWayland and the xft.dpi used by XWayland, enabling X11 applications to redraw graphics content based on the correct DPI value and generate a high-resolution buffer, effectively improving window display clarity. Furthermore, when receiving surface geometry information transmitted by XWayland, the Wayland compositor performs reverse scaling using the xwayland_unscale function, accurately converting physical coordinates into logical coordinates. When returning surface information to XWayland, the xwayland_scale function converts the logical coordinates back into physical coordinates, ensuring consistency and interactive accuracy between the logical and physical coordinate systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0036] Figure 1A schematic diagram of an application environment for scaling X applications in a Wayland environment provided by an embodiment of the present invention;

[0037] Figure 2 A flowchart of a method for implementing X window scaling in a Wayland environment provided by an embodiment of the present invention;

[0038] Figure 3 A basic logic diagram of the X window scaling implementation based on the Wayland environment and the scaling of the common Wayalnd client provided by the embodiment of the present invention;

[0039] Figure 4 A schematic diagram of a process for implementing a Wayland synthesizer end based on X window scaling in a Wayland environment provided by an embodiment of the present invention;

[0040] Figure 5 A schematic diagram of the process of implementing XWayland-side X window scaling based on the Wayland environment provided by an embodiment of the present invention;

[0041] Figure 6 A schematic diagram of the structure of a device for implementing X window scaling in a Wayland environment provided by an embodiment of the present invention;

[0042] Figure 7 A schematic diagram of the structure of the electronic device hardware provided by an embodiment of the present invention.

[0043] These drawings and textual descriptions are not intended to limit the scope of the inventive concept in any way, but rather to explain the concept of the present invention to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0044] Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. In the following description, when referring to the drawings, like numbers in different figures represent like or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present invention, as detailed in the appended claims.

[0045] In the embodiments of the present invention, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit differences. It should be noted that in the embodiments of the present invention, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the present invention should not be interpreted as being more preferred or advantageous than other embodiments or design. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way. In the embodiments of the present invention, "at least one" refers to one or more, and "more" refers to two or more.

[0046] To facilitate a clear description of the technical solutions of the embodiments of the present invention, some of the terms and technologies involved in the embodiments of the present invention are briefly introduced below:

[0047] Wayland: Wayland is a protocol that defines how Wayland clients communicate with Wayland compositors. It replaces the traditional X protocol and offers higher security, better performance, simpler implementation, better hardware support, and a better user experience.

[0048] XWayland rootless: XWayland is an implementation of the X11 protocol server that runs on a Wayland server. This mechanism allows for a gradual transition from the X11 environment to the Wayland environment while maintaining support for a wide range of existing X11 applications. A rootless window is a Wayland server that provides X11 window management and compositor, unifying Wayland and X11 windows. In XWayland rootless, each window has a corresponding wl_surface object in Wayland, which is used for input and output.

[0049] Window scaling: Window scaling refers to adjusting the window size so that the window can adapt to screen resolutions of different specifications.

[0050] xft.dpi: xft.dpi is a configuration option in the X Window System that sets the DPI (dots per inch) value for text rendering. It is a configuration parameter provided by the Xft (X FreeType) library. By setting the xft.dpi parameter, you can control the size and clarity of displayed text. X applications use the DPI value reported by the X Server when rendering text and graphics.

[0051] output_manager_get_scale function: The output_manager_get_scale function is a function in the Wayland compositor that is used to obtain the scaling factor of the display. In a Wayland environment, each display may have a different scaling ratio (for example, some displays may use 1x scaling, while others may use a scaling factor of 2x or higher). This function queries the information of all displays managed by the Wayland compositor, calculates the scaling factor of each display, and returns the maximum of these factors as the global scaling factor max_scale for processing XWayland windows. This maximum scaling factor is used to uniformly scale the display of the XWayland window.

[0052] output_manager_update_scale function: The output_manager_update_scale function is another function in the Wayland compositor that is used to update the logical resolution of the display sent to XWayland. This function receives a scaling factor as input and adjusts the xdg_output information sent to XWayland (that is, the display resolution that XWayland needs to use) according to this scaling factor. The updated display resolution is then sent to XWayland so that XWayland can recalculate and adjust the window display according to the new resolution.

[0053] xwayland_unscale function: The xwayland_unscale function is a function in the Wayland compositor that converts physical coordinates transmitted by XWayland into logical coordinates. When receiving surface geometry information from XWayland, the compositor uses this function to unscale the transmitted physical coordinates to match the logical coordinates in the Wayland system. This operation ensures correct conversion between different coordinate systems, avoids coordinate errors, and ensures consistent window position and size under different scaling factors.

[0054] xwayland_scale function: The xwayland_scale function is another function in the Wayland compositor that converts logical coordinates to physical coordinates. When returning window coordinates to XWayland, the compositor uses this function to convert the Wayland logical coordinates to actual physical coordinates. This function uses the previously selected maximum scaling factor, max_scale, to multiply the logical coordinates by max_scale to generate physical coordinates suitable for XWayland. This step ensures that the coordinates returned to XWayland are correctly mapped on the display, avoiding display errors caused by inconsistent coordinate systems.

[0055] wl_buffer and wl_surface: wl_buffer and wl_surface are two important objects in the Wayland protocol, representing a surface and its corresponding buffer, respectively. wl_surface is the display surface in Wayland, used to carry display content, while wl_buffer is the memory area associated with wl_surface, storing the surface's pixel data. In this invention, XWayland converts its generated graphics buffer into the Wayland-specific wl_surface and wl_buffer, enabling this graphics data to be correctly displayed on the screen by the Wayland compositor.

[0056] Maximum scaling factor max_scale: The maximum scaling factor max_scale is the largest scaling factor selected from the statistical calculation of the scaling factors of each display managed by the Wayland compositor. This factor is used to uniformly determine the overall scaling benchmark of XWayland in a multi-display environment. Specifically, in a Wayland environment, each display may have a different physical size and resolution, so a different scaling factor is usually configured for each display to achieve clear display of interface elements such as fonts and icons. However, XWayland itself does not have the ability to handle scaling for multiple displays independently, and can only use a global scaling factor to render all X11 windows.

[0057] X11 interface: The X11 interface refers to a set of communication protocols and programming interfaces provided by the X Window System (X11 for short), used for window drawing, event processing, graphics rendering, and interaction with the underlying display system in a graphical user interface environment. In the Wayland environment described in this invention, the X11 interface primarily refers to the interaction mechanism between the Wayland compositor or related intermediate components (such as XWayland) and X11-compatible applications or services for transferring display parameters (such as DPI values) or window information. Specifically, in the embodiments of this invention, the X11 interface plays two key roles:

[0058] (1) DPI information update channel: The Wayland compositor calls the relevant configuration function through the X11 interface (such as using the X Resource Manager XResources or modifying the xft.dpi configuration item) and passes the uniformly calculated DPI value (i.e. 96×max_scale) to XWayland. This method ensures that the X11 applications hosted by XWayland can obtain the accurate DPI value and thus render high-quality image content with an adaptive resolution based on the DPI.

[0059] (2) X11 client notification mechanism: The updated DPI value is further transmitted to all connected X11 applications through the X11 interface, enabling them to perceive the DPI change and trigger the automatic redraw mechanism to regenerate the graphics buffer according to the new scaling setting. This process is usually completed through the event distribution mechanism provided by the X protocol, ensuring that the display content of all X clients is consistent with the new scaling parameters.

[0060] With the development of display technology, high-resolution displays and multi-monitor systems have become mainstream. In modern graphics systems, appropriate scaling mechanisms are required to ensure that user interface elements (such as text, icons, and windows) display clearly, providing good readability and user experience in different DPI environments. Wayland, as a next-generation graphics display protocol that replaces the traditional X Window System (X11), introduces more flexible and sophisticated support mechanisms for scaling. In particular, when dealing with multiple physical output devices (i.e., monitors), it can set and manage the scaling factor of each monitor separately.

[0061] In the Wayland architecture, scaling operations are typically performed by the Wayland compositor. The Wayland compositor can sense the physical characteristics of the display (such as resolution and size) and, based on preset policies or user configuration, send an event containing a scaling factor to the client. Based on this event, the Wayland client adjusts the size and density of its drawn content, regenerating the graphics buffer based on the scaling factor to adapt it to the corresponding output device. This approach ensures high-quality rendering of graphical content on different display devices.

[0062] However, the X11 protocol does not natively support independent scaling for each monitor, and this problem is particularly evident when using XWayland (a compatibility layer for running X11 applications in a Wayland environment). XWayland itself acts as an intermediate layer, converting drawing requests from traditional X11 applications into surfaces and buffers acceptable to Wayland. However, in actual operation, XWayland can only use a fixed scaling ratio (usually 1x) for all its hosted windows, lacking the ability to dynamically adapt to scaling differences across multiple monitors. This limitation leads to the following key issues:

[0063] 1. When the Wayland compositor detects that a display requires a scaling factor greater than 1 (e.g., 2x), it will forcibly scale up the window contents drawn by XWayland. However, since XWayland doesn't perceive the need for scaling when initially drawing the content, it still renders the graphics at 1x scaling. The resulting image will appear noticeably blurry or jagged after scaling, especially around the edges of text and vector graphics.

[0064] 2. Wayland uses a logical coordinate system (a unified coordinate system that is independent of the scale factor), while X11 uses a physical coordinate system (in pixels). Since XWayland cannot synchronize with Wayland's scale context, the geometric size and position of its windows are misaligned with other clients within the Wayland compositor, resulting in confusing window layouts, click errors, and other issues.

[0065] 3. X11 clients typically determine drawing density by reading configuration items such as xft.dpi. However, in traditional implementations, the Wayland compositor fails to effectively pass scaling information back to XWayland and its clients. As a result, X11 applications still use the default 96DPI drawing even on high-resolution displays, making interface elements smaller and difficult to read.

[0066] In summary, in the prior art, XWayland window scaling in the Wayland environment has multiple problems such as image blur, coordinate misalignment, and the inability of X11 applications to adapt to scaling changes.

[0067] Based on this, embodiments of the present invention provide a method, device, electronic device, and storage medium for implementing X window scaling in a Wayland environment, using the XWayland rootless mode to solve the above-mentioned technical problems.

[0068] Figure 1 Schematic diagram of the application environment for scaling X applications in the Wayland environment provided by the embodiment of the present invention. Figure 1 As shown, Figure 1 It shows a dual-screen scenario with left and right layout: output1 is a 4k screen, output2 is a 1080p screen, and there is a full-screen X11 application and a Wayland application on output1 respectively.

[0069] Specifically, in a left-right dual-screen scenario, there are two physical output devices (i.e., displays): output1 and output2. Output1 is a 4K high-resolution display with a resolution of 3840×2160, and output2 is a regular full HD display (1080p) with a resolution of 1920×1080. In this layout, output1 is set as the primary display, with a scaling factor of 2.0 to ensure that graphical interface elements are presented at normal size in a high-DPI environment; output2's scaling factor is set to 1.0 to maintain the default display ratio. Output1 runs a traditional graphics application based on the X11 protocol (hereinafter referred to as "X11 application") and a Wayland application that natively supports the Wayland protocol. X11 applications access the Wayland graphics system through the XWayland compatibility layer, while Wayland applications communicate directly with the Wayland compositor, responding to scaling events and adjusting their own drawing behavior. Specifically, the Wayland compositor calls the output_manager_get_scale function, iterating over both displays (output1) and output2, obtaining their respective scaling factors (output1 is 2.0, output2 is 1.0), and selecting the maximum value as XWayland's global scaling factor, max_scale = 2.0. The Wayland compositor then updates the display scaling information in XWayland via the xdg_output protocol and sets xft.dpi to 96 × max_scale (192) via the X11 interface, explicitly instructing X11 applications to render graphics at 2x DPI.

[0070] Upon receiving these scaling parameter updates, XWayland adjusts its virtual output device, including geometric resizing and DPI configuration synchronization, and broadcasts the updated DPI information to all X11 clients. X11 applications recalculate their window layout and graphics buffer size based on the new DPI parameters, enabling native high-DPI drawing. This ensures that their output content is optimally displayed on output1's high-resolution displays without requiring additional scaling.

[0071] Example 1

[0072] Figure 2 A flowchart of a method for implementing X window scaling in a Wayland environment provided by the first embodiment of the present invention is shown as follows: Figure 2 As shown, the method includes:

[0073] S1. The Wayland compositor selects the maximum scaling factor max_scale of the window by calling the output_manager_get_scale function;

[0074] Specifically, in step S1, the Wayland compositor is responsible for collecting the scaling configurations of all currently connected physical output devices (i.e., displays) and calculating a maximum scaling factor max_scale for unified XWayland scaling processing. To implement this function, the Wayland compositor calls the output_manager_get_scale function.

[0075] S2. The Wayland compositor updates the xdg_output information sent to XWayland based on max_scale and updates xft.dpi to 96*max_scale through the X11 interface.

[0076] Specifically, in step S2, after obtaining the maximum scaling factor max_scale selected in step S1, the Wayland compositor performs a double update operation to configure two key information in the Wayland protocol and X11 protocol environments respectively, so as to correctly guide and control the XWayland window scaling behavior.

[0077] The default DPI for X11 is 96. When you need to double the size of an image, the system should set the DPI to 96 × 2 = 192. Therefore, by updating xft.dpi to 96 × max_scale, this step ensures that all X11 applications running on XWayland automatically adapt their internal font and graphic element sizes to the current environment's scaling requirements, achieving clear rendering at high resolutions and avoiding interface scaling errors or blurred content caused by inconsistent DPI.

[0078] S3. XWayland scales the screen size and geometric coordinates of the virtual output device it manages according to the updated xdg_output; it synchronously saves the updated xft.dpi and notifies all X11 applications;

[0079] Specifically, in step S3, XWayland, as a compatibility layer running in the Wayland environment, is responsible for receiving scaling parameter updates from the Wayland compositor and adjusting the display settings of its internal virtual output device based on these parameters. This process involves two key operations: First, after XWayland receives the updated xdg_output message, which contains the geometric information of the new output device (such as resolution, size, etc.). XWayland will update the screen size and geometric coordinates of the virtual output device it manages based on the xdg_output information; second, the updated xdg_output information not only affects the geometric size and coordinates within XWayland, but also affects the font rendering of X11 applications. In the X11 graphics system, the font rendering quality and display effect usually depend on the DPI (pixels per inch) setting.

[0080] In summary, the operations involved in step S3 can be understood as a two-way adaptation process. First, XWayland updates the display settings and coordinates of its virtual output device based on the new xdg_output information, ensuring that the window display matches the physical device. Second, by updating xft.dpi, XWayland ensures that all X11 applications can display text and graphics adaptively based on the new DPI configuration, avoiding issues such as blurry display and sizing issues. This adaptation process effectively resolves display issues of X11 applications in high-resolution environments and achieves compatibility between X11 and Wayland windows.

[0081] S4 and X11 applications redraw their window buffers based on the scaled virtual output device's screen size and the updated xft.dpi.

[0082] Specifically, in step S4, after receiving the updated virtual output information from XWayland (including the screen size and xft.dpi parameter), the X11 application will readjust the graphics drawing logic according to the relevant virtual output information and regenerate the window's image buffer (i.e., the drawing buffer area) to adapt to the scaling requirements of the current display environment, ensuring that the graphics content can be displayed on the corresponding physical output device with the correct size and resolution.

[0083] S5. XWayland converts the window buffer into Wayland-related wl_surface and wl_buffer;

[0084] Specifically, in step S5, XWayland converts the drawing result (window buffer) under the traditional X11 window system into the data structure wl_buffer required for Wayland graphics synthesis, binds it to the constructed wl_surface, and uses it to communicate with the Wayland compositor, thereby completing the X11 application graphics output to the Wayland compositor.

[0085] S6. The Wayland compositor receives the surface information transmitted from XWayland and performs reverse scaling through the xwayland_unscale function;

[0086] Specifically, by calling the xwayland_unscale function, the reverse processing of the image content after XWayland scaling is completed, ensuring that the scaled image can be restored to a size and coordinate system suitable for Wayland compositor display, thereby avoiding image distortion or blurring caused by improper scaling.

[0087] When the S7 and Wayland compositors return a surface to XWayland, they use the xwayland_scale function to scale the surface to max_scale before sending it back.

[0088] Specifically, step S7 ensures that the Wayland compositor can scale the window content according to max_scale by calling the xwayland_scale function, and finally returns it to XWayland, so that X11 applications can be displayed efficiently and accurately in the Wayland environment, while ensuring the consistency and clarity of windows on multiple display devices.

[0089] This embodiment provides a method, apparatus, electronic device, and storage medium for implementing X window scaling in a Wayland environment. Using the XWayland rootless mode, this method calculates scaling factors across multiple displays and selects the maximum value as the global scaling factor, max_scale. The Wayland compositor can synchronously update the xdg_output information sent to XWayland and the xft.dpi used by XWayland, enabling X11 applications to redraw graphics content based on the correct DPI value and generate a high-resolution buffer, effectively improving window display clarity. At the same time, when the Wayland compositor receives surface geometry information transmitted by XWayland, it performs reverse scaling through the xwayland_unscale function to accurately convert physical coordinates into logical coordinates. When returning surface information to XWayland, it converts the logical coordinates back to physical coordinates through the xwayland_scale function to ensure the consistency and interaction accuracy of the logical coordinate system and the physical coordinate system. That is, this method effectively avoids problems such as image blur and distortion caused by inconsistent display resolution and DPI, improves the user experience, and enables X11 applications and native Wayland applications to coexist seamlessly on the same screen or in a multi-screen environment, ensuring the consistency and smoothness of visual effects.

[0090] In some embodiments, the Wayland compositor maintains a linked list for storing output-related information, which includes the scaling factor of each output display device. The output_manager_get_scale function traverses and compares all scaling factors in the linked list to obtain the maximum scaling factor (max_scale) in the linked list. That is, the Wayland compositor maintains a linked list for storing output-related information. By using the linked list to centrally manage the scaling factors of all output devices, the Wayland compositor can dynamically adapt to the display requirements of all screens in the current system. By traversing and comparing these scaling factors through the output_manager_get_scale function, the display device with the highest graphics scaling requirement in the system can be selected, and then the scaling logic of XWayland and all windows can be uniformly adjusted based on this device. The main advantage of this is to improve the consistency of the display experience across multiple displays, especially in a multi-display heterogeneous environment (such as a regular 1080p display with a high DPI Retina display), avoiding problems such as sudden content scaling or blurring and distortion when dragging windows between different screens.

[0091] In some embodiments, the above step S2 is only performed for the XWayland client. That is, the role of the above step S2 is to "translate" the output scaling information of Wayland and pass it to XWayland so that it can take effect in the X11 client environment under its management. It is only performed for the XWayland client to solve the information asymmetry problem between the X11 client and the Wayland environment. The Wayland client has obtained complete scaling information through the protocol and does not need this intermediate forwarding process. Therefore, only the client running under XWayland needs to rely on this step to obtain the output scaling factor for operations such as DPI perception, screen coordinate conversion, and window layout update.

[0092] In some embodiments, XWayland converts the redrawn window buffer into a wl_buffer that can be processed by the Wayland compositor. At the same time, XWayland binds the wl_buffer to the constructed wl_surface. That is, XWayland converts the format of the X11 application's window buffer and generates a wl_buffer object that can be recognized and used by the Wayland compositor, ensuring that XWayland can bridge the image output results of the X11 application to the Wayland compositor so that it can participate in the final synthesis and display. Similarly, XWayland creates a corresponding wl_surface object for each X11 application window, and then binds the wl_buffer generated in the previous step to this wl_surface, thereby realizing the final rendering of the X11 application's image output in the Wayland compositor, and establishing a complete path from "X11 drawing → XWayland conversion → Wayland compositor synthesis".

[0093] For easier understanding, refer to Figures 3 to 5 As shown, a method for implementing X window scaling in a Wayland environment has the following specific implementation steps:

[0094] Step 1: The compositor calculates the maximum scale value of all outputs, max_scale, through the output_manager_get_scale function. This scale value only applies to the XWayland connection and is a global variable. To achieve higher resolution scaling, when there are multiple monitors with different scales, only one maximum scale value is applied to xdg_output.

[0095] Step 2: The compositor updates the size of xdg_output sent to XWayland via output_manager_update_scale and sends it to XWayland. It should be emphasized here that the xdg_output sent will only be scaled when the client is XWayland.

[0096] Step 3: The compositor updates xft.dpi to 96*max_scale via the X11 interface. The default xft.dpi size is 96.

[0097] Step 4: XWayland updates the display size (screen size) and position based on the updated xdg_output information, and maps the information to wl_surface. At this time, the window size of the X application in XWayland is also updated.

[0098] Step 5: XWayland saves the obtained xft.dpi in the XWayland configuration and notifies all related X11 applications that the DPI has changed.

[0099] Step 6: The X11 application redraws the window content according to the obtained screen size and DPI.

[0100] Step 7: XWayland updates the relevant wl_surface and wl_buffer based on the buffer updated in step 6. Since the surface size was mapped in step 4, the buffer size is now the same as the surface size, which is the scaled size of xdg_output sent by the Wayland compositor, but the surface geometry is inconsistent with the compositor surface geometry.

[0101] Step 8: The compositor uses the xwayland_unscale function to force the reverse scaling of the surface size and coordinates passed from XWayland. Similarly, when the compositor sends the surface size and dimensions to XWayland, it must first use the xwayland_scale function to scale the surface geometry before sending it.

[0102] It should be noted that according to the xdg_output protocol, the xdg_output information includes: zxdg_output_v1::logical_position, zxdg_output_v1::logical_size, zxdg_output_v1::name, zxdg_output_v1::description;

[0103] max_scale is used to update logical_position and logical_size.

[0104] It's important to note that in XWayland rootless, surface objects are used as input and output. In step 8, the surface geometry in XWayland is consistent with the received xdg_output. A scale factor of 2 doubles the surface size. XWayland's xdg_output is only scaled when the compositor sends it to XWayland. The xdg_output used by the compositor is consistent with the logical size, which also means the surface size of the compositor's logical size (relative to the physical output size) remains unchanged. Therefore, the compositor needs to perform some processing when communicating with XWayland and using surface objects: When the compositor receives the geometry sent by XWayland, it needs to undo the scaling (xwayland_unscale) to ensure that the XWayland surface used by the compositor for subsequent rendering matches the logical size actually used by the compositor. Also, because XWayland's coordinates are twice as large as Wayland's, the compositor needs to pass a scaling transform (xwayland_scale) when sending updated surface geometry to XWayland, ensuring that the surface coordinate system received by XWayland is consistent with the coordinate system used by the X application window.

[0105] In an embodiment of the present invention, the electronic device or main control device can be divided into functional modules according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present invention is schematic and is only a logical functional division. In actual implementation, there may be other division methods.

[0106] Example 2

[0107] Figure 6 This is a schematic diagram of the structure of the device for implementing X window scaling in the Wayland environment provided by the second embodiment of the present invention. Figure 6 As shown, the apparatus 100 for implementing X window scaling in a Wayland environment provided by an embodiment of the present invention includes a selection module 110, an update module 120, a management module 130, a drawing module 140, a first conversion module 150, a receiving module 160, and a second conversion module 170;

[0108] The selection module 110 is used to select the maximum scaling factor max_scale of the window scaling by calling the output_manager_get_scale function;

[0109] An update module 120 is configured to update the scaling factor in xdg_output sent to XWayland according to max_scale and update xft.dpi to 96*max_scale via the X11 interface;

[0110] The management module 130 is configured to update xdg_output to scale the screen size and geometric coordinates of the virtual output device it manages, and to synchronously save the updated xft.dpi and notify all X11 applications;

[0111] A drawing module 140 is configured to redraw the window buffer according to the scaled screen size of the virtual output device and the updated xft.dpi;

[0112] The first conversion module 150 is used to convert the window buffer into Wayland-related wl_surface and wl_buffer;

[0113] The receiving module 160 is used to receive surface information transmitted from XWayland and perform reverse scaling through the xwayland_unscale function;

[0114] The second conversion module 170 is used to scale the surface according to max_scale through the xwayland_scale function before sending it back to XWayland when returning the surface.

[0115] The second embodiment provides an apparatus for implementing X window scaling in a Wayland environment, which can execute the method for implementing X window scaling in a Wayland environment in the first embodiment. The implementation principles and technical effects are similar, and are not described in detail in this embodiment.

[0116] In a specific implementation of the aforementioned apparatus for implementing X window scaling in a Wayland environment, each module may be implemented as a processor, and the processor may execute computer-executable instructions stored in a memory, so that the processor performs the aforementioned method for implementing X window scaling in a Wayland environment.

[0117] Example 3

[0118] Figure 7 This is a schematic diagram of the structure of the electronic device hardware provided in the third embodiment of the present invention. Figure 7 shows a block diagram of an exemplary electronic device 12 suitable for implementing embodiments of the present invention. Figure 7 The electronic device 12 shown is only an example and should not limit the functionality and scope of use of the embodiments of the present invention.

[0119] like Figure 7 As shown, electronic device 12 is implemented as a general-purpose computing device. Components of electronic device 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 that connects various system components (including system memory 28 and processing unit 16).

[0120] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0121] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0122] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be configured to read and write non-removable, non-volatile magnetic media ( Figure 7 Not shown, often called a "hard drive"). Although Figure 7Not shown, a magnetic disk drive for reading and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.

[0123] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 42 generally implement the functions and / or methods of the embodiments described herein.

[0124] The electronic device 12 can also communicate with one or more external devices 14 (e.g., a keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 12 / server / computer, and / or any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication can occur via an input / output (I / O) interface 22. Furthermore, the electronic device 12 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with the other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown, other hardware and / or software modules can be used in conjunction with the electronic device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0125] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the X window scaling method under the Wayland environment provided by the embodiment of the present invention.

[0126] At the same time, an embodiment of the present invention further provides a storage medium containing computer executable instructions, which, when executed by a computer processor, is used to implement the method for implementing X window scaling in the Wayland environment as provided in the above embodiment.

[0127] Example 4

[0128] The computer storage medium of embodiment 4 of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.

[0129] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0130] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0131] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0132] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for implementing X window scaling in a Wayland environment, characterized in that: include: S1. The Wayland compositor selects the maximum scaling factor max_scale of the window by calling the output_manager_get_scale function; S2. The Wayland compositor updates the scale factor in xdg_output sent to XWayland based on max_scale and updates xft.dpi to 96*max_scale through the X11 interface. S3. XWayland scales the screen size and geometric coordinates of the virtual output device it manages according to the updated xdg_output; it synchronously saves the updated xft.dpi and notifies all X11 applications; S4 and X11 applications redraw their window buffers based on the scaled virtual output device's screen size and the updated xft.dpi. S5. XWayland converts the window buffer into Wayland-related wl_surface and wl_buffer; S6. The Wayland compositor receives the surface information transmitted from XWayland and performs reverse scaling through the xwayland_unscale function; When the S7 and Wayland compositors return a surface to XWayland, they use the xwayland_scale function to scale the surface to max_scale before sending it back.

2. The method for implementing X window scaling under the Wayland environment according to claim 1, characterized in that: Step S1 includes: The Wayland compositor maintains a linked list for storing output-related information, where the linked list includes the scaling factor of each output display device. The output_manager_get_scale function traverses and compares all scaling factors in the linked list, and then obtains the maximum scaling factor max_scale in the linked list.

3. The method for implementing X window scaling under the Wayland environment according to claim 1, characterized in that: Step S2 is only performed for XWayland clients.

4. The method according to claim 1, wherein Step S5 includes: XWayland converts the redrawn window buffer into a wl_buffer that the Wayland compositor can handle. At the same time, XWayland binds the wl_buffer to the constructed wl_surface.

5. A device for implementing X window scaling in a Wayland environment, characterized in that: include: The selection module is used to select the maximum scaling factor max_scale of the window scaling by calling the output_manager_get_scale function; Update module for updating the scaling factor in xdg_output sent to XWayland according to max_scale and updating xft.dpi to 96*max_scale via the X11 interface; The management module is used to update xdg_output to scale the screen size and geometric coordinates of the virtual output device it manages, and to save the updated xft.dpi synchronously and notify all X11 applications; The drawing module is used to redraw the window buffer according to the scaled screen size of the virtual output device and the updated xft.dpi; The first conversion module is used to convert the window buffer into Wayland-related wl_surface and wl_buffer; The receiving module is used to receive surface information transmitted from XWayland and perform reverse scaling through the xwayland_unscale function; The second conversion module is used to scale the surface according to max_scale through the xwayland_scale function before sending it back to XWayland when returning the surface.

6. The device for implementing X window scaling in the Wayland environment according to claim 5, characterized in that: The selection module includes: maintaining a linked list for storing output related information through the Wayland synthesizer, wherein the linked list includes the scaling factor of each output display device, and the output_manager_get_scale function traverses and compares all scaling factors in the linked list, and then obtains the maximum scaling factor max_scale in the linked list.

7. The device for implementing X window scaling in the Wayland environment according to claim 5, characterized in that: Update modules are only performed for XWayland clients.

8. The device for implementing X window scaling in the Wayland environment according to claim 5, characterized in that: The first conversion module includes: XWayland converts the redrawn window buffer into wl_buffer that can be processed by the Wayland compositor, and at the same time, XWayland constructs wl_surface and binds wl_buffer to wl_surface.

9. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; When the processor executes the computer-executable instructions stored in the memory, the processor is used to implement the method for implementing X window scaling in the Wayland environment according to any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method for implementing X window scaling in a Wayland environment according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method and device for zooming Android application window on Linux

    CN116627579A

  • Remote desktop resolution optimization method and system in wayland environment

    CN120216086A

  • A system and method for performing voice based browsing on an electronic device

    IN201911001425A