Method and system for realizing touch special effect in Wayland environment
By using window synthesizers and shaders to draw dynamic circle effects in the Wayland environment, the problems of inconsistent touch effects and low degree of customization in the existing technology are solved, and efficient and beautiful touch effects are achieved, improving the user experience.
Patent Information
- Application Number
- CN202510384084.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-06-27
AI Technical Summary
In the Wayland environment, it is difficult for the existing technology to achieve unified, efficient and beautiful touch effects, resulting in inconsistent user experience and low degree of customization of special effects.
Touch events are continuously monitored through the window synthesizer, and the dynamic circle special effects are drawn using the shader. The radius and transparency of the dynamic circle change over time, achieving a unified circular touch special effects that slowly decrease and lighten transparency.
It realizes efficient, unified and beautiful touch effects in the Wayland environment, improves user experience and meets the needs of customized display effects.
Smart Images

Figure CN120215799A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image special effect generation, and particularly to a method and system for realizing touch special effects in a Wayland environment. Background Art
[0002] At present, devices equipped with touch screens are becoming increasingly popular. It has become very necessary to generate corresponding touch special effects during touch clicks to play a prompting role and achieve an aesthetic effect. Wayland is a display protocol for the Linux system, which can handle graphics display requirements simply and more efficiently. The Wayland protocol defines the communication method between the client (usually an application) and the server (usually a compositor). Through the Wayland protocol, the application and the compositor can exchange and synthesize graphic data.
[0003] In the prior art, there are mainly two methods for realizing touch click special effects in a Wayland environment. One is to implement it through the application layer, that is, directly write code in the application to capture touch events and trigger corresponding visual feedback. However, this requires separate implementation in each application, increasing the development workload; and if the implementation effects among various applications are inconsistent, it will lead to inconsistent user experience and a sense of fragmentation. The other is to implement it through the default visual feedback mechanism provided by the built-in function of the GUI toolkit for touch events. However, the default feedback effect of the toolkit is relatively single, only having the basic solid circle display effect, lacking animation effects or having unsmooth animation effects (not fast first and then slow) and transparency animation, and lacking edge anti-aliasing effects, which cannot meet the requirements of customized display effects. Therefore, providing a method for realizing globally unified touch special effects in a Wayland environment has become an urgent problem to be solved. Summary of the Invention
[0004] The technical problem to be solved by the present invention: Aiming at the above problems of the prior art, a method and system for realizing touch special effects in a Wayland environment with exquisite display effects and high unity are provided, so that a unified circular touch special effect that slowly becomes smaller and fades in transparency can be generated when any touch event is detected, solving the problems of low customization degree and single special effects in the prior art and improving the user experience of the touch screen.
[0005] To solve the above technical problems, the technical solution adopted by the present invention is as follows: A method for realizing touch special effects in a Wayland environment, comprising: Step S1, the window compositor continuously monitors touch events; Step S2, when a touch event is detected, set the animation parameters of the dynamic circle to be generated according to the touch position. The animation parameters include the starting value, ending value, animation duration of the radius, and the curve of the radius changing with time, and draw it through a shader; the starting value is greater than the ending value, so that the dynamic circle changes from large to small by adjusting the radius. Step S3, during the process of the dynamic circle changing from large to small, set the transparency according to the current radius value of the dynamic circle, so that the transparency inside the dynamic circle decreases from the circle edge to the center of the circle, and draw it through a shader; at the same time, perform edge smoothing on the circle edge of the dynamic circle.
[0006] Further, in step S2, the curve expression of the dynamic circle radius changing with time is:
[0007] In the above formula, r is the radius and t is the time.
[0008] Further, in step S3, set the transparency according to the current radius value of the dynamic circle, and the expression is:
[0009] In the above formula, alpha is the transparency of the current pixel point, radius is the current radius value, and dist is the distance between the current pixel point and the center of the dynamic circle.
[0010] Further, further subtract the attenuation value from the transparency value to obtain the final transparency; The curve of the attenuation value changing with time is:
[0011] In the above formula, attenuation is the attenuation value and t is the time.
[0012] Further, after obtaining the final transparency by subtracting the attenuation value from the transparency value, it further includes: Judge whether the final transparency is less than the minimum value defined by the transparency. If it is less, set the final transparency to the minimum value defined by the transparency; Judge whether the current pixel point is inside the dynamic circle according to the distance between the current pixel point and the center of the dynamic circle. If it is not, set the final transparency corresponding to the current pixel point to the minimum value defined by the transparency.
[0013] Further, mark the pixel points with a distance less than or equal to the radius of the dynamic circle from the center of the dynamic circle as the first value, and mark the pixel points with a distance greater than the radius of the dynamic circle from the center of the dynamic circle as the second value different from the first value.
[0014] Further, perform edge smoothing on the circumference of the dynamic circle, including: Perform edge smoothing through the smoothstep function, where the range of the smoothing width is from negative half a pixel to half a pixel.
[0015] Further, after the step S3, it further includes: When it is detected that the touch event ends, set the transparency of each pixel point inside the dynamic circle to the minimum value defined by the transparency, so that the dynamic circle disappears.
[0016] The present invention further provides a touch effect implementation system in a Wayland environment, including a microprocessor and a memory connected to each other, and the microprocessor is programmed or configured to execute a touch effect implementation method in the Wayland environment.
[0017] The present invention further provides a computer-readable storage medium, in which a computer program / instructions are stored, and the computer program / instructions are programmed or configured to execute a touch effect implementation method in the Wayland environment through a processor.
[0018] Compared with the prior art, the advantages of the present invention are as follows: The present invention continuously monitors touch events through a window compositor, so as to capture touch inputs in a short time, and it is convenient for unified processing across applications, reducing the inconsistency of self-monitoring by each application; according to the touch position, the present invention sets special effect parameters such as the starting radius, ending radius, animation duration, change curve, and transparency of the circle, and can achieve highly personalized customized animation effects. By using a shader for drawing rendering, the computing power of the GPU and the hardware acceleration effect can be fully utilized to ensure the smoothness and efficiency of the generated animation; by performing anti-aliasing processing on the circle circumference, the present invention can avoid rough edges, further enhancing the visual fineness and beauty of the animation, so as to achieve an efficient and unified touch click feedback effect. Description of the Drawings
[0019] Figure 1 It is a flowchart of the touch effect implementation method in the Wayland environment according to an embodiment of the present invention.
[0020] Figure 2 They are relevant animation parameters (including circle radius, distance from the current pixel to the center of the circle, and transparency) during shader drawing in a specific application embodiment.
[0021] Figure 3 It is a dynamic circle image generated at a certain moment during the drawing process in a specific application embodiment. Detailed Embodiments
[0022] To better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings of the specification and specific embodiments.
[0023] The following are the definitions of some abbreviations and key terms used in the present invention: Window compositor: Responsible for receiving graphic data from different applications, merging these graphics according to certain composition rules, and finally generating the desktop image seen by the user. It also undertakes the responsibility of window management, including window creation, closing, moving, etc. Among them, the window compositor developed using the Wayland protocol is called the Wayland compositor.
[0024] DBus: Allows message passing between different applications and services, enabling them to communicate and cooperate with each other. It is very important for building complex desktop applications.
[0025] Seat: A concept used to manage input devices and related input events. Especially in modern graphics systems and window managers, it can manage one or more input devices and handle input events from the devices it manages.
[0026] Special effect: A prominent visual effect that may include animations in addition to beautiful pictures, providing users with a more beautiful and smooth visual experience.
[0027] Graphics API: An application programming interface used in graphics programming that allows developers to control graphics hardware to create and render 2D or 3D graphics.
[0028] Rendering pipeline: Graphics APIs usually control the parameters and different stage processes of several rendering pipelines and submit them to the graphics processing unit (GPU) to draw images.
[0029] Shader: An editable program executed by the graphics processing unit (GPU). Compared with the code usually executed by the CPU, it is called hardware acceleration.
[0030] To improve the touch screen user experience and make the feedback special effects during touch more beautiful and intuitive, as Figure 1 shown, the embodiment of the present invention provides a method for implementing touch special effects in a Wayland environment, including: Step S1, the window compositor continuously monitors touch events; Step S2, when a touch event is detected, set the animation parameters of the dynamic circle to be generated according to the touch position. The animation parameters include the starting value, ending value, animation duration, and the curve of the radius changing with time, and draw through the shader; the starting value is greater than the ending value so that the dynamic circle changes from large to small by adjusting the radius; Step S3, during the process of the dynamic circle shrinking from large to small, set the transparency according to the current radius value of the dynamic circle, so that the transparency inside the dynamic circle decreases from the circle edge to the center of the circle, and draw it through the shader; at the same time, perform edge smoothing processing on the edge of the dynamic circle.
[0031] In a specific application embodiment, the special effect parameter control and switch can be controlled through DBus, which is convenient for communication with the desktop settings control panel, etc., so that users can customize configuration parameters using the user interface. In addition, the window compositor can accept multi-touch event inputs. For example, each finger touch event can generate a touch effect with an independent life cycle through the touch effect implementation method in the Wayland environment of this embodiment, and the compositor renders and updates the effect in real time during the animation cycle. To ensure performance and no third-party library dependencies, it is preferred to use the graphics API and shaders to draw the touch click image, and the real-time changing animation parameters (such as the circle radius) are preferably calculated by the CPU and passed into the shader to make full use of the computing power of the CPU and the image processing power of the GPU.
[0032] After setting the parameters, generate a corresponding rectangle according to the scaling and rotation of the desktop configuration of the current Wayland compositor as the canvas of the pixel shader, and the shader passes in the canvas coordinates, with the upper left corner being (0, 0) and the lower right corner being (1, 1). Calculate the distance between the normalized coordinates (0~1) and the center of the canvas (0.5, 0.5) and name it dist.
[0033] In this embodiment, the starting value of the dynamic circle radius is: the preset value of the circle radius parameter * 0.5 pixels; The ending value is: 0 pixels; The preferred range of the animation duration is: 200 - 500 milliseconds; The curve expression of the radius changing with time is: (1) In the above formula, r is the radius and t is the time. It can be understood that the animation effect of the circle shrinking from large to small with time (the circle drawn by the shader is the radius radius × the canvas pixel size) can be achieved through the parameters configured here.
[0034] In a specific application embodiment, the dynamic circle radius parameters are preferably as follows: the animation duration is 0.5s, the start value is 0.5, and the end value is 0.3. First calculate the values of the circle radius radius animation at different times in the code special effect drawing function and pass them into the shader for drawing.
[0035] In this embodiment, set the transparency according to the current radius value of the dynamic circle, and the expression is: (2) In the above formula, alpha is the transparency of the current pixel point, radius is the current radius value, and dist is the distance between the current pixel point and the center of the dynamic circle. It can be understood that by configuring the parameters here, the effect that the closer to the center, the lighter, and the transparency is equal to zero when reaching the radius radius can be achieved.
[0036] In this embodiment, the value of the transparency is further subtracted by the attenuation value to obtain the final transparency; The preferred range of the starting value of the attenuation value is: 0.2 - 0.4; The preferred range of the ending value is: 0.5 - 0.8; The preferred range of the animation duration is: 200 - 500 milliseconds; The curve of the attenuation value changing with time is: (3) In the above formula, attenuation is the attenuation value and t is the time. It can be understood that in order to avoid the maximum transparency calculated by formula (2) being too high and lacking a dynamic effect, the transparency is subtracted by an attenuation value attenuation again, so that the transparency of the finally presented circle has a better visual experience.
[0037] In a specific application embodiment, the preferred animation parameters of the transparency attenuation value attenuation are as follows: the animation duration is 0.5s, the starting value is 0.4, the ending value is 0.8, and the curve equation of formula (3) is used to achieve the animation effect of being fast first and then slow.
[0038] In this embodiment, after subtracting the attenuation value from the value of the transparency to obtain the final transparency, it further includes: Judge whether the final transparency is less than the defined minimum value of the transparency. If it is less, set the final transparency to the defined minimum value of the transparency; Judge whether the current pixel point is inside the dynamic circle according to the distance between the current pixel point and the center of the dynamic circle. If it is not, set the final transparency corresponding to the current pixel point to the defined minimum value of the transparency.
[0039] In this embodiment, the pixel points whose distance from the center of the dynamic circle is less than or equal to the radius of the dynamic circle are marked as the first value, and the pixel points whose distance from the center of the dynamic circle is greater than the radius of the dynamic circle are marked as the second value.
[0040] In a specific application embodiment, as Figure 2 shown, the calculation expression of the transparency alpha is: (4) As can be seen from formula (4), the calculated transparency alpha may be less than 0 (the defined minimum value of transparency). Therefore, the built-in function max(0, alpha) is used for judgment, and all calculated transparency values less than 0 are set to 0. In addition, the transparency values outside the generated dynamic circle area should also be set to 0. Therefore, by judging dist and the configured dynamic circle radius parameter, it is determined whether the pixel is inside the circle. If dist is less than the parameter circle radius radius, 1 (the first value) is output, otherwise 0 (the second value) is output, and the result is stored in dist2. Therefore, the transparency outside the circle area can be directly set to 0 according to alpha × dist2, while the transparency inside the circle area remains unchanged because the pixels of dist2 outside the circle area are marked as 0, and the pixels inside the circle area are marked as 1. It should be noted that the judgment operation here does not use the usual branch statement if, but is replaced by the built-in function step (passing in the comparison value, returning 1 if passed and 0 if not passed) to make full use of the optimization of the GPU.
[0041] In this embodiment, edge smoothing processing is performed on the circular edge of the dynamic circle, including: Edge smoothing processing is performed through the smoothstep function, where the range of the smoothing width is from negative half a pixel to half a pixel.
[0042] In a specific application embodiment, since the coordinates use normalized coordinates, the shader passing in the value of 1 / the size of the canvas pixels represents 1 pixel. Therefore, one pixel can be used for edge smoothing, and the range of the smoothing width is from negative half a pixel to half a pixel. Finally, the dynamic circle special effect as shown in Figure 3 can be obtained, where each dynamic circle corresponds to a touch event.
[0043] In this embodiment, after step S3, it further includes: When it is detected that the touch event ends, the transparency of each pixel point inside the dynamic circle is set to the defined minimum value of transparency, so that the dynamic circle disappears. It can be understood that after the touch event ends (such as when the finger leaves the touch screen), the circular special effect prompt image is no longer drawn, saving resource computing power and conforming to the intuitive logic.
[0044] The present invention further provides a touch special effect implementation system in the Wayland environment, including a microprocessor and a memory connected to each other. The microprocessor is programmed or configured to execute the touch special effect implementation method in the Wayland environment.
[0045] The present invention further provides a computer-readable storage medium, in which a computer program / instructions are stored. The computer program / instructions are programmed or configured to execute the touch special effect implementation method in the Wayland environment through a processor.
[0046] The system and medium of the present invention, corresponding to the above method, also have the advantages as described in the above method.
[0047] To implement all or part of the processes in the method of the above embodiments, the present invention can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium includes: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc. The memory is used to store the computer program and / or module. The processor realizes various functions by running or executing the computer program and / or module stored in the memory, and by calling the data stored in the memory. The memory can include high-speed random access memory, and can also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one magnetic disk storage device, flash device, or other volatile solid-state storage devices, etc.
[0048] The above description is only a preferred embodiment of the present invention. The protection scope of the present invention is not limited to the above embodiments. Any technical solution falling within the idea of the present invention belongs to the protection scope of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A method for realizing touch special effects in a Wayland environment, characterized in that: include: Step S1, the window synthesizer continuously monitors touch events; Step S2, when a touch event is detected, the animation parameters of the dynamic circle to be generated are set according to the touch position, the animation parameters include the starting value and ending value of the radius, the animation duration, and the curve of the radius changing over time, and are drawn through a shader; the starting value is greater than the ending value, so that the dynamic circle can be changed from large to small by adjusting the radius; Step S3, in the process of the dynamic circle changing from large to small, the transparency is set according to the current radius value of the dynamic circle, so that the transparency within the dynamic circle decreases from the circumference to the center of the circle, and is drawn through a shader; at the same time, the circumference of the dynamic circle is subjected to edge smoothing transition processing.
2. The method for realizing touch special effects in the Wayland environment according to claim 1, characterized in that: In step S2, the curve expression of the dynamic circle radius changing with time is: In the above formula, r is the radius and t is the time.
3. The method for realizing touch special effects in the Wayland environment according to claim 1, characterized in that: In step S3, the transparency is set according to the current radius value of the dynamic circle, and the expression is: In the above formula, alpha is the transparency of the current pixel, radius is the current radius value, and dist is the distance between the current pixel and the center of the dynamic circle.
4. The method for realizing touch special effects in the Wayland environment according to claim 3, characterized in that: Further subtract the attenuation value from the transparency value to get the final transparency; The curve of the attenuation value changing with time is: In the above formula, attenuation is the attenuation value and t is the time.
5. The method for realizing touch special effects in the Wayland environment according to claim 4, characterized in that: After subtracting the attenuation value from the transparency value to get the final transparency, it also includes: Determine whether the final transparency is less than the minimum transparency definition value, and if so, set the final transparency to the minimum transparency definition value; Whether the current pixel is located in the dynamic circle is determined according to the distance between the current pixel and the center of the dynamic circle. If not, the final transparency corresponding to the current pixel is set to the minimum transparency definition value.
6. The method for realizing touch special effects in the Wayland environment according to claim 5, characterized in that: Pixel points whose distance from the center of the dynamic circle is less than or equal to the radius of the dynamic circle are marked as a first value, and pixel points whose distance from the center of the dynamic circle is greater than the radius of the dynamic circle are marked as a second value different from the first value.
7. The method for realizing touch special effects in the Wayland environment according to claim 1, characterized in that: The circumferential edge of the dynamic circle is subjected to edge smoothing transition processing, including: The smoothstep function is used to perform edge smoothing transitions, where the transition width ranges from negative half a pixel to half a pixel.
8. The method for realizing touch special effects in the Wayland environment according to claim 1, characterized in that: After step S3, the following steps are also included: When the touch event is detected to be over, the transparency of each pixel in the dynamic circle is set to the minimum transparency definition value, so that the dynamic circle disappears.
9. A touch special effect implementation system in a Wayland environment, comprising a microprocessor and a memory connected to each other, characterized in that: The microprocessor is programmed or configured to execute the touch special effect implementation method in the Wayland environment as described in any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program / instruction stored therein, characterized in that: The computer program / instruction is programmed or configured to execute the touch special effect implementation method in the Wayland environment described in any one of claims 1 to 8 through a processor.