Window drawing method and device, electronic equipment and storage medium
By obtaining environment variable data in the Wine environment to change the parameters of window display operations, the inefficiency problem caused by modifying code in the prior art is solved, and efficient drawing is achieved quickly responding to window style changes.
Patent Information
- Application Number
- CN202510220020.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-07-11
AI Technical Summary
When changing the appearance of an application display window in a Wine environment, the prior art requires modifying the code and recompiling it, resulting in inefficiency.
By obtaining environment variable data, flexibly change the parameters of window display operations, without modifying application code, it directly responds to different window style requirements.
Improves window drawing efficiency, avoids the long recompilation process caused by modifying the code, and can quickly respond to window style changes.
Smart Images

Figure CN120295622A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a window drawing method, apparatus, electronic device, and storage medium. Background Art
[0002] Wine (Wine Is Not an Emulator) is an open-source compatibility layer that can run Windows programs on Unix-like operating systems (such as Linux, macOS, etc.).
[0003] When it is necessary to change the appearance of the display window of an application running in Wine, in the related art, it is necessary to modify the parameter values of the functions for window display operations in the code of the application, recompile to obtain an executable file, and then execute the executable file. This will result in wasting a large amount of time in the compilation and execution process, making the efficiency of window drawing low. Summary of the Invention
[0004] In view of the above problems, embodiments of this application are proposed to provide a window drawing method that can overcome the above problems or at least partially solve the above problems, which can avoid wasting a large amount of time in the compilation and execution process and improve the efficiency of window drawing.
[0005] Correspondingly, embodiments of this application also provide a window drawing apparatus, an electronic device, and a storage medium to ensure the implementation and application of the above method.
[0006] In a first aspect, embodiments of this application disclose a window drawing method, the method includes:
[0007] During the execution of a target application, obtain a call request of the target application for window display operations, the call request includes a first window class name and parameter values of a first window parameter;
[0008] Obtain environment variable data for window display operations in a target environment; the target environment is the running environment of the target application; the environment variable data includes a second window class name and parameter values of a second window parameter;
[0009] In a case where it is determined that the first window class name is the same as the second window class name and the parameter values of the first window parameter are different from the parameter values of the second window parameter, modify the parameter values of the first window parameter in the call request to the parameter values of the second window parameter;
[0010] Respond to the modified call request to draw the modified window.
[0011] Second aspect, embodiments of the present application disclose a window drawing device, the device comprising:
[0012] A first acquisition module, configured to acquire, during the execution of a target application, a call request of the target application for a window display operation, the call request including a first window class name and parameter values of a first window parameter;
[0013] A second acquisition module, configured to acquire environment variable data for a window display operation in a target environment; the target environment is a running environment in which the target application runs; the environment variable data includes a second window class name and parameter values of a second window parameter;
[0014] A comparison module, configured to, when it is determined that the first window class name is the same as the second window class name and the parameter values of the first window parameter are different from the parameter values of the second window parameter, modify the parameter values of the first window parameter in the call request to the parameter values of the second window parameter;
[0015] A first drawing module, configured to respond to the modified call request to draw a modified window.
[0016] Third aspect, embodiments of the present application disclose an electronic device, comprising: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete mutual communication through the communication bus; the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the steps of the window drawing method as described in any one of the foregoing.
[0017] Fourth aspect, embodiments of the present application disclose a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, it can implement the window drawing method as described in any one of the embodiments of the present application.
[0018] The window drawing method, device, electronic device, and storage medium provided by the embodiments of the present application have the following advantages:
[0019] The present application provides a window drawing method, which can be used to implement the function of changing the appearance of the display window of an application program in Wine. The present application improves the process of changing the appearance of the display window of an application program in Wine. During the running process of the application program, the appearance parameters of the window for the window display operation can be flexibly changed through the environment variable data, and the change of the window appearance can be displayed in real time. During the process of changing the appearance of the display window of the application program, the present application does not need to modify the application program code, can quickly respond to different window style requirements, can avoid the long recompilation process caused by modifying the code in the related art, and can greatly improve the window drawing efficiency. Description of the Drawings
[0020] Figure 1 is a flowchart of a window drawing method provided by an embodiment of the present application;
[0021] Figure 2 is a flowchart of another window drawing method provided by an embodiment of the present application;
[0022] Figure 3 is a structural block diagram of a window drawing device provided by an embodiment of the present application;
[0023] Figure 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed Embodiments
[0024] To make the above objects, features, and advantages of the present application more obvious and understandable, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0025] Terms such as "first" and "second" in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are usually of the same type, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after. The term "multiple" in the embodiments of the present application refers to two or more, and other quantifiers are similar.
[0026] Before introducing the window drawing methods, devices, electronic devices, and storage media provided by the present application, the application scenarios involved in each embodiment of the present application will be introduced first. The present application can be applied to the scenario of changing the appearance of the display window of an application program in Wine. The window drawing method provided by the embodiments of the present application can be applied to an electronic device that runs an application program using Wine. Among them, Wine (Wine Is Not an Emulator) is an open-source compatibility layer that can run Windows programs on Unix-like operating systems (such as Linux, macOS, etc.).
[0027] Currently, when it is necessary to change the appearance of the display window of an application running in Wine, in the related art, it is necessary to modify the parameter values of the function for window display operations in the code of the application, recompile to obtain an executable file, and then execute the executable file. This will result in a waste of a large amount of time in the compilation and execution process, making the efficiency of window drawing low.
[0028] To solve the above problems, the present application provides a window drawing method, device, electronic device, and storage medium, which can flexibly change the window appearance parameters for window display operations by obtaining environment variable data, without modifying the application code, can quickly respond to different window style requirements, can avoid the long recompilation process caused by modifying the code in the related art, and can greatly improve the window drawing efficiency.
[0029] The following combines the accompanying drawings to detail the video processing method provided by the embodiments of the present application through specific embodiments and their application scenarios.
[0030] Figure 1 is a flowchart of a window drawing method provided by an embodiment of the present application. As Figure 1 shown, this method is applied to an electronic device, and this electronic device can use Wine to run Windows applications; this method may include the following steps:
[0031] Step 101, during the execution of the target application, obtain a call request of the target application for window display operations, where the call request includes a first window class name and parameter values of a first window parameter;
[0032] Step 102, obtain environment variable data for window display operations in the target environment; the target environment is the operating environment for running the target application; the environment variable data includes a second window class name and parameter values of a second window parameter;
[0033] Step 103, in the case where it is determined that the first window class name is the same as the second window class name and the parameter values of the first window parameter are different from the parameter values of the second window parameter, modify the parameter values of the first window parameter in the call request to the parameter values of the second window parameter;
[0034] Step 104, respond to the modified call request to draw the modified window.
[0035] In step 101, during the execution of the target application, obtain a call request of the target application for window display operations. The target application is a Windows application running in Wine.
[0036] Among them, the call request includes the first window class name and the parameter value of the first window parameter.
[0037] In this step, the executable file of the target application can be obtained first. The executable file is a file of directly executable instructions obtained by compiling the program code of the target application. It contains a series of machine code instructions, which are low-level commands that can be directly understood and executed by computer hardware, instructing the computer to perform various operations such as data processing, memory access, input and output, etc. Then, the executable file can be loaded to execute the target application.
[0038] During the process of loading the executable file, the call request of the target application for window display operations can be obtained.
[0039] Among them, the call request for window display operations can include the call request for the function of window display operations. The function for window display operations can include NtUserCreateWindowEx (used to create a top-level window or a child window with specified styles and attributes in the Windows system), NtUserShowWindow (used to control the display state of the window), and NtUserRedrawWindow (used to request to redraw all or part of the specified window) and other functions.
[0040] Optionally, the call request for the function of window display operations can be obtained by interception, and the first window class name of the display window of the target application and the parameter value of the first window parameter can be extracted from the function of the call request.
[0041] In a possible implementation manner, Hook (hook technology) can be used to intercept the call request of the function. Among them, Wine supports a hook function mechanism similar to Windows. By installing a hook function, when a specific event occurs (such as window drawing display and other events), the call request of the relevant function can be intercepted. For example, the SetWindowsHookEx (used to intercept and process specific types of system messages or events) function can be used to install a hook in the Wine environment to intercept the call request of the function related to window creation, so as to obtain the first window class name of the display window of the target application and the parameter value of the first window parameter.
[0042] In step 102, the environment variable data for window display operations in the target environment is obtained.
[0043] Among them, the target environment is the running environment for running the target application; the environment variable data includes the second window class name and the parameter value of the second window parameter.
[0044] In some embodiments, the environmental variables for window display operations in the target environment can be obtained first.
[0045] Among them, the environmental variable can be represented by WIN_RW (an identification name of an environmental variable), and the value of the environmental variable can be a string. For example, it can be represented as a JSON (JavaScript Object Notation, a lightweight data interchange format) string.
[0046] Exemplarily, the value of WIN_RW can be read using the getenv function (a function in the C standard library for obtaining the value of a specified environmental variable).
[0047] Specifically, the getenv function can be used to attempt to obtain the value of the environmental variable named WIN_RW. If the environmental variable exists, the function returns a string pointer to its value; if it does not exist, NULL (null value) is returned. Therefore, it can be determined whether the environmental variable exists by judging whether the return value of the getenv function is a null value. If the environmental variable exists, the printf (output) function can be used to print its value; if it does not exist, a prompt message can be output.
[0048] Then, according to the preset data structure, the environmental parameters corresponding to the data structure in the preset data structure can be extracted from the environmental variable.
[0049] Among them, the preset data structure can include a first data structure and a second data structure, and the environmental parameter can include the second window class name and the parameter value of the second window parameter; the second window class name is the data corresponding to that in the first data structure, and the parameter value of the second window parameter is the data corresponding to that in the second data structure.
[0050] This application maps the string corresponding to the environmental variable to an internal data structure. Optionally, the preset data structure can be defined as an internal data structure, for example, it can be represented as a data structure of wm_rw. Specifically, the JSON library function can be used to convert the WIN_RW string into a preset data structure that can be processed.
[0051] Exemplarily, the JSON string to be parsed is as follows:
[0052] [{CLASSNAME:xxxxxx,FLAGS:0x0485}].
[0053] Among them, the JSON string contains an array, and each element in the array can be an object. The first element is the CLASSNAME field, and the second element is the FLAGS field.
[0054] Map the JSON string to an internal data structure. The convertible preset data structure can be expressed as: WM_RW = "[{CLASSNAME: xxxxxx, FLAGS: 0x0485}]". Here, CLASSNAME represents the second window class name, and FLAGS represents the parameter value of the second window parameter of this window. For example, the second window parameter can include the redraw flag, function, etc. of this window.
[0055] Among them, the redraw flag can be used to represent the operation name executed when different redraw operations are performed on this window, and the function can be used to represent the function that the redraw operation can achieve when a specific redraw operation is performed on this window. For example, when the "RDW_INVALIDATE" redraw operation is performed on this window, it can be used to mark a specific area of this window as invalid.
[0056] Exemplarily, the redraw flag and function of the window can be illustrated by Table 1:
[0057] Table 1
[0058]
[0059] Exemplarily, before defining the preset data structure, the json-c library can be introduced in the following way for JSON parsing. At the same time, the header files for standard input / output, standard library, and string handling are introduced, and a macro MAX_CLASSNAME_LEN is defined to specify the maximum length of the CLASSNAME character array.
[0060] Then a preset data structure can be defined. For example, first, a new name can be created for the custom data type, and a structure type can be declared, indicating that what will be defined next is a composite data type composed of multiple data members of different types. Then the member variables included in the preset data structure can be defined, such as the name and character type of the member variable. Finally, a new alias can be determined for this structure, such as WindowConfig. WindowConfig is an alias defined for this structure type. By using this alias, subsequent code can more conveniently declare variables of this structure type without having to write the complete struct definition every time.
[0061] For example, the typedef keyword (used to define a new name for an existing data type) can be used to create a new name for a custom data type, and the struct keyword can be used to declare that the structure type is a composite data type composed of multiple data members of different types. Then, member variables such as CLASSNAME and FLAGS can be defined in the preset data structure, and then the name of this structure can be determined as WindowConfig.
[0062] Thus, a structure named WindowConfig can be defined, which can contain two fields, namely the "CLASSNAME" field and the "FLAGS" field.
[0063] Next, according to the data structure of the preset data structure defined above, the environment parameters corresponding to the data structure in the preset data structure can be extracted from the environment variable.
[0064] Specifically, the corresponding environment parameters can be parsed and extracted by reading the JSON string corresponding to the environment variable.
[0065] In this embodiment, the "json-c" library can be used to parse the JSON string.
[0066] Exemplarily, the JSON string corresponding to the environment variable can be parsed first to obtain a JSON array, and then the first element (CLASSNAME field) and the second element (FLAGS field) in the JSON array can be extracted.
[0067] Among them, the json_tokener_parse function in the "json-c" library can be used to parse the input JSON string, and the json_object_object_get_ex function can be used to obtain the values of the CLASSNAME and FLAGS fields when parsing the JSON string.
[0068] During the running of the target application in this application, the value of FLAGS in NtUserRedrawWIndow of the specified window can be directly modified through the environment variable, so that the display effects of different FLAGS can be seen in real time.
[0069] In another possible implementation, since there may be missing values in the obtained JSON string, the first environment parameters corresponding to the data structure in the preset data structure can be extracted from the environment variable according to the preset data structure first; then the first environment parameters can be processed to obtain the processed environment parameters.
[0070] This application maps the parsed JSON string to an internal data structure, ensures that the fields are consistent with the expected types, and handles possible missing values. Further, this application validates the fields (including handling missing values and type mismatches). Among them, this data processing is used to fill in the missing values in the first environmental parameter, and / or correct the types in the first environmental parameter.
[0071] Exemplarily, the CLASSNAME field can be checked, and a value can be assigned in the case where the CLASSNAME field is missing.
[0072] For example, first, the CLASSNAME field can be processed. The JSON string corresponding to the CLASSNAME field can be obtained through the json_object_object_get_ex function (used to obtain the value corresponding to a specified key from a JSON object), and then the json_object_get_string function (used to obtain the string value represented by a struct json_object type object) can be used to obtain the corresponding string value. If the value obtained for the CLASSNAME field is not NULL (that is, the field is not missing in the JSON string), it can be copied to the CLASSNAME field of the WindowConfig structure. However, if the value of the CLASSNAME field is NULL (that is, the field is missing in the JSON string), the strncpy function (used to copy a part or all of a string to another character array) can be used to copy the default value "default_class" to the CLASSNAME field of the WindowConfig structure.
[0073] Next, the second window class name is filled into the first data structure, and the parameter values of the second window parameter are filled into the second data structure, obtaining the environmental variable data composed of the filled first data structure and the filled second data structure.
[0074] Optionally, in the case where the first data structure and the second data structure are obtained, the second window class name obtained in the above steps can be filled into the first data structure, and the parameter values of the second window parameter can be filled into the second data structure, so that the environmental variable data composed of the filled first data structure and the filled second data structure can be obtained.
[0075] Exemplarily, the `parse_json_from_env` function (used to parse JSON data from environment variables) can be called to parse the JSON string, and the parsed result can be stored in the `Config` structure. For example, the `printf` function can be used to output the values of the "CLASSNAME" and "FLAGS" fields after parsing. For example, the `printf` function can be as follows:
[0076] printf("CLASSNAME: %s\n", config.CLASSNAME);
[0077] printf("FLAGS: 0x%x\n", config.FLAGS);
[0078] Thus, the second window class name can be filled into the first data structure, and the parameter values of the second window parameters can be filled into the second data structure, and the environment variable data composed of the filled first data structure and the filled second data structure can be output.
[0079] In some embodiments, when the number of parameter types of the first environmental parameter is less than or equal to the number of data structures of the preset data structure, the parameter types of the first environmental parameter can be put into one-to-one correspondence with the data structures of the preset data structure; and in the data structures that do not correspond to the first environmental parameter, preset data can be filled; and the first environmental parameter and the preset data are used as the processed environmental parameter.
[0080] Exemplarily, in the actual application process, the parameters obtained from the actual environment, that is, the first environmental parameter, may only include some of the parameters in the preset data structure.
[0081] For example, first, the data structure of the preset structure can be defined. The preset structure can include four structural parts: `window_width` (width), `window_height` (height), `background_color` (color), and `font_size` (size), and the data corresponding to each structural part can be predefined. For example, `width` is defined as 800, `height` is defined as 600, `color` is defined as `white` (white), and `size` is defined as 12.
[0082] Among them, the `preset_data_structure` function can be used to specify the four parameters that the window configuration may include, and the `preset_data` parameter can provide default values for these parameters.
[0083] In this case, the first environmental parameter only contains two parameters, window_width and background_color. The number of parameter types (2) is less than the number of data structures in the preset data structure (4).
[0084] Therefore, the parameter types of the first environmental parameter can be matched with the data structures of the preset data structure, and the values in the first environmental parameter can be filled into the corresponding positions in the preset data structure. For example, the values in first_env_params (the first environmental parameter) can be filled into preset_data_structure (the preset data structure), so that window_width and background_color are replaced with the values in the first environmental parameter, while window_height and font_size are still None, indicating that there are no corresponding actual parameters yet. For those data structures in the preset data structure that do not correspond to the first environmental parameter, the preset data can be used to fill them.
[0085] By adopting the above technical solution, even if the actually obtained environmental parameters are incomplete, the preset data can be used to ensure that all necessary parameters have values, guaranteeing the normal progress of subsequent operations.
[0086] In some other embodiments, when the parameter types of the first environmental parameter are different from the preset types, the parameter types of the first environmental parameter can be corrected to the preset types; the preset types are the preset parameter types corresponding to the data structures of the preset data structure; and the corrected first environmental parameter is used as the processed environmental parameter.
[0087] Exemplarily, in the actual application process, the parameters obtained from the actual environment, that is, the first environmental parameter, may have different parameter types from the preset types because different data sources provide parameters in different ways or the parameter names change during the transmission process.
[0088] For example, first, the data structure of the preset structure can be defined, which can include six parameter types: window_width (width), window_height (height), window_x (abscissa), window_y (ordinate), background_color (background color), and window_title (title). However, the parameters obtained from the actual environment may only include five parameter types: width, height, start_, bg_colo, and title. In this case, there will be a problem of missing the window_y parameter type and inconsistent partial parameter names.
[0089] Therefore, according to the preset types, the parameter names in the first environmental parameters that do not match can be modified to the preset parameter names, while preserving the corresponding parameter values. For the missing parameters, default values can be set according to the actual situation. For example, a mapping relationship between the parameter names of the first environmental parameters and the parameter names of the preset types can be established through the param_mapping (parameter mapping) dictionary; and the first environmental parameters can be traversed, and the parameter names can be corrected according to the mapping relationship to obtain the corrected parameter names and the corresponding parameter values, which are stored in processed_env_params (processed environmental parameters); and for the missing window_y parameter, a default value can be set, such as 200.
[0090] With the above technical solution, even if the parameter types of the first environmental parameters are different from the preset types, they can be corrected to meet the preset requirements, ensuring the smooth progress of the window drawing operation.
[0091] In step 103, when it is determined that the first window class name is the same as the second window class name, and the parameter value of the first window parameter is different from the parameter value of the second window parameter, the parameter value of the first window parameter in the call request is modified to the parameter value of the second window parameter.
[0092] Optionally, first, the first string corresponding to the first window class name and the second string corresponding to the second window class name can be unified in character format through a preset comparison function; then, when the characters of the first string after format unification are the same as those of the second string after format unification, it is determined that the first window class name is the same as the second window class name.
[0093] Exemplarily, when a call request for window drawing is predefined in advance and relevant window data is also obtained from the environmental variables, among them, the first_window_params (first window parameter) in the window display call request of the target application can include the width of the window, with a value of 800 pixels as an integer; the height of the window, with a value of 600 pixels as an integer; and the background color of the window, with a value of the string red (red), etc.
[0094] And the window data of the second_window_class_name (second window parameter) in the target environment includes the width of the window, with a value of 1024 pixels as an integer; the height of the window, with a value of 768 pixels as an integer; and the background color of the window, with a value of the string blue (blue), etc.
[0095] In this case, it can be seen that the first_window_class_name (the first window parameter) and the second_window_class_name (the second window parameter) semantically refer to the same window class, but there are differences in character formats (different cases); moreover, the values of the two window parameters are also inconsistent.
[0096] Therefore, the strings corresponding to the two window class names can be converted to a unified format through a preset comparison function to more accurately determine whether they represent the same window class. For example, the two strings can be converted to lowercase through a preset comparison function to achieve the unification of character formats.
[0097] After obtaining the strings with unified formats, it can be compared whether they are equal. If they are equal, it can be considered that the first window class name and the second window class name are consistent. Then, by comparing the strings with unified formats, it can be determined that the two window class names are consistent. Then, traverse the window parameters. When it is found that a certain parameter exists in both data and the values are different, the parameter value in the call request will be modified to the parameter value in the environment variable.
[0098] By adopting the above technical solution, the window parameter values in the call request can be updated, and the updated call request can be used for window drawing.
[0099] In step 104, respond to the modified call request to draw the modified window.
[0100] In some other embodiments, in the case of determining that the first window class name is inconsistent with the second window class name, the call request can be responded to draw the initial window. In this way, when the window class names are inconsistent, the call request can be responded to draw the initial window that conforms to the settings of the target application itself.
[0101] By adopting the above technical solution, it can be used to implement the function of changing the appearance of the display window of the application in Wine. This application improves the process of changing the appearance of the display window of the application in Wine. During the process of changing the appearance of the display window of the application, the appearance parameters for window display operations can be flexibly changed by obtaining environment variable data, without modifying the application code, which can quickly respond to different window style requirements, avoid the long recompilation process caused by modifying the code in the related technology, and can greatly improve the window drawing efficiency.
[0102] In some embodiments, the parameter value of the first window parameter can also be output through the log channel in the target environment, as well as the parameter value of the first window parameter after using the parameter value of the second window parameter as the parameter value of the first window parameter.
[0103] Exemplarily, the print function can be used to simulate the log channel in the target environment. For example, before modifying the parameters, the original values of the first window parameters are output through the simulated log channel (such as the print function), which is convenient for developers to understand the state before modification. After the parameter modification is completed, the modified values of the first window parameters are output again through the simulated log channel, so that developers can obtain the parameter changes, which is convenient for debugging and monitoring the parameter adjustment during the window drawing process.
[0104] In practical applications, the log channel can be a file log, a system log, or a dedicated log service, which is used to record and store these important debugging information. In this way, the changes of window parameters can be better tracked to ensure that the window is drawn as expected.
[0105] Figure 2 is a flowchart of another window drawing method provided by an embodiment of the present application, as Figure 2 shown, the method may include the following steps.
[0106] In step 201, during the execution of the target application, a call request for the window display operation of the target application is obtained.
[0107] Among them, the call request includes the first window class name and the parameter values of the first window parameters.
[0108] In this step, the executable file of the target application can be obtained first. The executable file is a file of directly executable instructions obtained by compiling the program code of the target application. It contains a series of machine code instructions, which are low-level commands that can be directly understood and executed by computer hardware. These instructions instruct the computer to perform various operations, such as data processing, memory access, input / output, etc. Then, the executable file can be loaded to execute the target application.
[0109] During the process of loading the executable file, a call request for the window display operation of the target application can be obtained.
[0110] Among them, the call request for the window display operation may include a call request for a function for the window display operation. The functions for the window display operation include NtUserCreateWindowEx (used to create a top-level window or a child window with specified styles and attributes in the Windows system), NtUserShowWindow (used to control the display state of the window), and NtUserRedrawWindow (used to request to redraw all or part of the area of the specified window), etc.
[0111] Optionally, it is possible to intercept the call request for the function for window display operations, and extract from the function of the call request the first window class name of the display window of the target application and the parameter value of the first window parameter.
[0112] In step 202, obtain the environment variable for window display operations in the target environment.
[0113] Among them, this environment variable can be represented by WIN_RW (an identification name of an environment variable), and the value of this environment variable is a string. For example, it can be represented as a JSON (JavaScript Object Notation, a lightweight data exchange format) string.
[0114] Exemplarily, the value of WIN_RW can be read using the getenv function (a function in the C standard library for obtaining the value of a specified environment variable).
[0115] Specifically, the getenv function can be used to obtain the value of the environment variable named WIN_RW. If this environment variable exists, the getenv function returns a string pointer to its value; if it does not exist, it returns NULL (a null value). Therefore, it is possible to determine whether the environment variable exists by judging whether the return value of the getenv function is a null value. If it exists, the printf (output) function can be used to print its value; if it does not exist, a prompt message is output.
[0116] In step 203, extract the first environmental parameter corresponding to the data structure in the preset data structure from this environment variable according to the preset data structure.
[0117] Exemplarily, it is possible to first parse the JSON string corresponding to the environment variable to obtain a JSON array, and then extract the first element (CLASSNAME field) and the second element (FLAGS field) in the JSON array.
[0118] Among them, the "json-c" library's library functions can be used to parse the JSON string. For example, the json_tokener_parse function can be used to parse the input JSON string, and the json_object_object_get_ex function can be used to obtain the values of the CLASSNAME and FLAGS fields.
[0119] Thus, the second window class name can be filled into the first data structure, and the parameter value of the second window parameter can be filled into the second data structure, and the environmental variable data composed of the filled first data structure and the filled second data structure is output.
[0120] When the number of parameter types of the first environmental parameter is less than or equal to the number of data structures of the preset data structure, steps 204-206 and 209-212 are executed;
[0121] When the parameter type of the first environmental parameter is different from the preset type, steps 207-212 are executed;
[0122] In step 204, the parameter types of the first environmental parameter are put into one-to-one correspondence with the data structures of the preset data structure.
[0123] Exemplarily, in the actual application process, the parameters obtained from the actual environment, that is, the first environmental parameter, may only contain some of the parameters in the preset data structure.
[0124] First, the data structure of the preset structure can be defined. The preset structure can include four structural parts: window_width (width), window_height (height), background_color (color), and font_size (size), and the data corresponding to each structural part can be predefined. For example, width can be defined as 800, height can be defined as 600, color can be defined as white, and size can be defined as 12.
[0125] Among them, the preset_data_structure function can be used to specify the four parameters that the window configuration may include, and the preset_data parameter can provide default values for these parameters.
[0126] In this case, the first environmental parameter only contains two parameters, window_width and background_color, and the number of parameter types (2) is less than the number of data structures of the preset data structure (4).
[0127] Therefore, the parameter types of the first environmental parameter can be matched with the data structures of the preset data structure to fill the values in the first environmental parameter into the corresponding positions in the preset data structure.
[0128] In step 205, preset data is filled in the data structures that do not correspond to the first environmental parameter.
[0129] For example, the values in first_env_params (first environment parameters) can be filled into preset_data_structure (preset data structure). In this way, window_width and background_color are replaced with the values in the first environment parameters, while window_height and font_size are still None, indicating that there are no corresponding actual parameters. Therefore, for the data structures in the preset data structure that do not correspond to the first environment parameters, the preset data can be used for filling.
[0130] In step 206, the first environment parameter and the preset data are used as the processed environment parameters.
[0131] In step 207, the parameter type of the first environment parameter is corrected to the preset type.
[0132] Among them, the preset type is the preset parameter type corresponding to the data structure of the preset data structure.
[0133] Exemplarily, in the actual application process, the parameters obtained from the actual environment, that is, the first environment parameters, may have different parameter types from the preset type because different data sources provide parameters in different ways or the parameter names change during the transmission process.
[0134] For example, first, the data structure of the preset structure can be defined, which can include six parameter types: window_width (width), window_height (height), window_x (abscissa), window_y (ordinate), background_color (background color), and window_title (title). However, the parameters obtained from the actual environment may only include five parameter types: width, height, start_, bg_colo, and title. In this case, there is a problem of missing the window_y parameter type and inconsistent partial parameter names.
[0135] Therefore, according to the preset types, the parameter names in the first environmental parameters that do not match can be modified to the preset parameter names, while preserving the corresponding parameter values. For the missing parameters, default values can be set according to the actual situation. For example, the mapping relationship between the parameter names of the first environmental parameters and the parameter names of the preset types can be established through the param_mapping (parameter mapping) dictionary. And traverse the first environmental parameters, correct the parameter names according to the mapping relationship, obtain the corrected parameter names and the corresponding parameter values, and store them in processed_env_params (processed environmental parameters). And for the missing window_y parameter, it can be set to the default value, such as 200.
[0136] In step 208, the corrected first environmental parameters are used as the processed environmental parameters.
[0137] In step 209, the second window class name is filled into the first data structure, and the parameter values of the second window parameters are filled into the second data structure, obtaining the environmental variable data composed of the filled first data structure and the filled second data structure.
[0138] In the case where it is determined that the first window class name is the same as the second window class name, and the parameter value of the first window parameter is different from the parameter value of the second window parameter, steps 210 and 211 are executed;
[0139] In the case where it is determined that the first window class name is different from the second window class name, step 212 is executed;
[0140] In step 210, the parameter value of the first window parameter in the call request is modified to the parameter value of the second window parameter.
[0141] In step 211, in response to the modified call request, a modified window is drawn.
[0142] In step 212, in response to the call request, an initial window is drawn.
[0143] By adopting the above technical solution, through strictly comparing the first window class name and the second window class name, as well as the corresponding window parameter values, it is ensured that parameter modification is only performed when the class names are the same and the parameter values are different. This precise matching mechanism helps to maintain the consistency of window display operations and avoid abnormal window displays caused by incorrect parameter modifications. And when the number of parameter types of the first environment parameter is less than or equal to the number of data structures of the preset data structure, by filling the preset data, it is possible to flexibly handle the situation of missing environment parameters. This ensures that in different operating environments, even if some parameters are not explicitly provided, the window display operation can still continue based on reasonable default values, enhancing the adaptability of the system to different configurations. And if the parameter types of the first environment parameter are different from the preset types, the solution provides a mechanism to correct the parameter types. This enables the system to be compatible with environment parameters from different sources or formats, expanding the range of environment parameters that can be processed.
[0144] It should be noted that for method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present application are not limited by the described action sequences, because according to the embodiments of the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present application.
[0145] Figure 3 is a structural block diagram of a window drawing device provided by an embodiment of the present application. Referring to Figure 3 , the device includes:
[0146] The first acquisition module 301 is configured to, during the execution of the target application, acquire a call request of the target application for window display operations, where the call request includes a first window class name and parameter values of a first window parameter;
[0147] The second acquisition module 302 is configured to acquire environment variable data for window display operations in the target environment; the target environment is the operating environment in which the target application runs; the environment variable data includes a second window class name and parameter values of a second window parameter;
[0148] The comparison module 303 is configured to, when it is determined that the first window class name is the same as the second window class name and the parameter values of the first window parameter are different from the parameter values of the second window parameter, modify the parameter values of the first window parameter in the call request to the parameter values of the second window parameter;
[0149] The first drawing module 304 is configured to respond to the modified call request to draw the modified window.
[0150] Optionally, the second acquisition module includes:
[0151] An acquisition sub-module, configured to acquire an environment variable for a window display operation in a target environment;
[0152] An extraction sub-module, configured to extract, according to a preset data structure, environment parameters corresponding to the data structure in the preset data structure from the environment variable, the preset data structure includes a first data structure and a second data structure, and the environment parameters include the second window class name and the parameter values of the second window parameters; the second window class name is the data corresponding to the first data structure, and the parameter values of the second window parameters are the data corresponding to the second data structure;
[0153] A filling sub-module, configured to fill the second window class name into the first data structure, and fill the parameter values of the second window parameters into the second data structure, to obtain the environment variable data composed of the filled first data structure and the filled second data structure.
[0154] Optionally, the extraction sub-module is configured to extract, according to a preset data structure, first environment parameters corresponding to the data structure in the preset data structure from the environment variable; perform data processing on the first environment parameters to obtain processed environment parameters, where the data processing is used to fill missing values in the first environment parameters and / or correct types in the first environment parameters.
[0155] Optionally, the extraction sub-module is configured to, when the number of parameter types of the first environment parameters is less than or equal to the number of data structures of the preset data structure, make the parameter types of the first environment parameters correspond one by one to the data structures of the preset data structure; fill preset data in the data structures that do not correspond to the first environment parameters; use the first environment parameters and the preset data as the processed environment parameters.
[0156] Optionally, the extraction sub-module is configured to, when the parameter types of the first environment parameters are different from the preset types, correct the parameter types of the first environment parameters to the preset types; the preset types are the preset parameter types corresponding to the data structures of the preset data structure; use the corrected first environment parameters as the processed environment parameters.
[0157] Optionally, the comparison module includes:
[0158] A unification sub-module, configured to unify the character formats of the first string corresponding to the first window class name and the second string corresponding to the second window class name through a preset comparison function;
[0159] A determination sub-module, configured to determine that the first window class name is the same as the second window class name when the characters of the first string after format unification are the same as those of the second string after format unification.
[0160] Optionally, the apparatus further includes:
[0161] A second drawing module, configured to, when it is determined that the first window class name is different from the second window class name, respond to the call request to draw an initial window.
[0162] Optionally, the apparatus further includes:
[0163] An output module, configured to output the parameter value of the first window parameter and the parameter value of the first window parameter after using the parameter value of the second window parameter as the parameter value of the first window parameter through a log channel in the target environment.
[0164] In summary, the present application provides a window drawing apparatus, which can be used to implement the function of changing the appearance of the display window of an application in Wine. The present application improves the process of changing the appearance of the display window of an application in Wine. During the process of changing the appearance of the display window of an application, the window appearance parameters for window display operations can be flexibly changed by obtaining environment variable data, without modifying the application code, capable of quickly responding to different window style requirements, avoiding the long recompilation process caused by modifying the code in the related art, and greatly improving the window drawing efficiency.
[0165] For the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, refer to the partial description of the method embodiment.
[0166] Referring to Figure 4 , which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As Figure 4 shown, the electronic device includes: a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface complete mutual communication through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the steps of the window drawing method in the foregoing embodiment.
[0167] An embodiment of the present application provides a non-transitory computer-readable storage medium. When the instructions in the storage medium are executed by a program or a processor of a terminal, the terminal can execute the steps of the window drawing method in the foregoing embodiment.
[0168] Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other.
[0169] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application can take the form of completely hardware embodiments, completely software embodiments, or embodiments combining software and hardware aspects. Moreover, the embodiments of the present application can take the form of a computer program product implemented 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.
[0170] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal devices generate a device for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0171] These computer program instructions can also be stored in a computer-readable memory that can guide the computer or other programmable data processing terminal devices to work in a predictive manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device implements the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0172] These computer program instructions can also be loaded onto the computer or other programmable data processing terminal devices, so that a series of operation steps are executed on the computer or other programmable terminal devices to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable terminal devices provide steps for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0173] Finally, it should also be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, article or terminal device comprising the said element.
[0174] Specific examples are used in this article to elaborate on the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application; at the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to this application.
Claims
1. A window drawing method, characterized in that, The method includes: During the execution of the target application, obtaining a call request of the target application for a window display operation, where the call request includes a first window class name and parameter values of a first window parameter; Obtaining environmental variable data for a window display operation in the target environment; the target environment is the running environment where the target application runs; the environmental variable data includes a second window class name and parameter values of a second window parameter; In the case where it is determined that the first window class name is the same as the second window class name and the parameter values of the first window parameter are different from the parameter values of the second window parameter, modifying the parameter values of the first window parameter in the call request to the parameter values of the second window parameter; Responding to the modified call request to draw the modified window.
2. The method according to claim 1, wherein The obtaining environmental variable data for a window display operation in the target environment includes: Obtaining environmental variables for a window display operation in the target environment; According to a preset data structure, extracting environmental parameters corresponding to the data structure in the preset data structure from the environmental variables, where the preset data structure includes a first data structure and a second data structure, and the environmental parameters include the second window class name and parameter values of the second window parameter; the second window class name is the data corresponding to the first data structure, and the parameter values of the second window parameter are the data corresponding to the second data structure; Filling the second window class name into the first data structure and filling the parameter values of the second window parameter into the second data structure to obtain the environmental variable data composed of the filled first data structure and the filled second data structure.
3. The method according to claim 2, wherein The extracting environmental parameters corresponding to the data structure in the preset data structure from the environmental variables according to the preset data structure includes: According to the preset data structure, extracting first environmental parameters corresponding to the data structure in the preset data structure from the environmental variables; Performing data processing on the first environmental parameters to obtain processed environmental parameters, where the data processing is used to fill in missing values in the first environmental parameters and / or correct the types in the first environmental parameters.
4. The method according to claim 3, characterized in that, The performing data processing on the first environmental parameters to obtain processed environmental parameters includes: In the case where the number of parameter types of the first environmental parameters is less than or equal to the number of data structures of the preset data structure, making a one-to-one correspondence between the parameter types of the first environmental parameters and the data structures of the preset data structure; Filling preset data in the data structures to which the first environmental parameters do not correspond; Taking the first environmental parameters and the preset data as the processed environmental parameters.
5. The method according to claim 3, characterized in that The performing data processing on the first environmental parameters to obtain processed environmental parameters includes: In the case where the parameter type of the first environmental parameter is different from the preset type, correct the parameter type of the first environmental parameter to the preset type; the preset type is the preset parameter type corresponding to the data structure of the preset data structure. Use the corrected first environmental parameter as the processed environmental parameter.
6. The method according to claim 1, characterized in that, The determination that the first window class name is the same as the second window class name includes: Use a preset comparison function to unify the character formats of the first string corresponding to the first window class name and the second string corresponding to the second window class name. Determine that the first window class name is the same as the second window class name when the characters of the first string after format unification are the same as those of the second string after format unification.
7. The method according to claim 1, characterized in that, The method further includes: In the case where it is determined that the first window class name is different from the second window class name, respond to the call request to draw an initial window.
8. The method according to claim 1, characterized in that, The method further includes: Output, through the log channel in the target environment, the parameter value of the first window parameter and the parameter value of the first window parameter after using the parameter value of the second window parameter as the parameter value of the first window parameter.
9. A window drawing device, characterized in that, The apparatus includes: A first acquisition module, configured to acquire, during the execution of a target application, a call request of the target application for a window display operation, where the call request includes a first window class name and a parameter value of a first window parameter. A second acquisition module, configured to acquire environmental variable data for a window display operation in a target environment; the target environment is the operating environment for running the target application; the environmental variable data includes a second window class name and a parameter value of a second window parameter. A comparison module, configured to, in the case where it is determined that the first window class name is the same as the second window class name and the parameter value of the first window parameter is different from the parameter value of the second window parameter, modify the parameter value of the first window parameter in the call request to the parameter value of the second window parameter. A first drawing module, configured to respond to the modified call request to draw a modified window.
10. An electronic device, characterized in that, Includes: A processor, a memory, a communication interface, and a communication bus, where the processor, the memory, and the communication interface complete communication with each other through the communication bus. The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the steps of the method according to any one of claims 1 to 8.
11. A readable storage medium, characterized in that, A program or instruction is stored on the readable storage medium, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 8 are implemented.