Method, apparatus, device and medium for dragging and dropping files in a compatibility layer environment
By setting up the proxy drag-and-drop target interface in the compatibility layer software, the problem of the missing drag-and-drop function of compatible application windows to the Linux system window is solved, and file drag-and-drop across systems is realized, improving user experience.
Patent Information
- Application Number
- CN202510238324.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2045-03-03
AI Technical Summary
The existing compatibility layer software cannot drag and drop files from compatible application windows to Linux system windows, resulting in inconvenient user operation and reducing user experience.
By setting up the proxy drag-and-drop target interface, including drag-and-drop entry interface, drag-and-drop hover interface and placement interface, drag-and-drop related data that complies with Windows specifications into interactive messages that comply with the preset drag-and-drop protocol of Unix-like systems, realizing the function of drag-and-drop files from compatible application windows to Unix-like system windows.
It solves the problem of inconsistent drag and drop protocol between Windows system and Unix-like systems, realizes the correct transmission and processing of file paths, and improves the convenience of users to drag and drop files between different systems.
Smart Images

Figure CN119718474B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a method, apparatus, device, and medium for dragging and dropping files in a compatibility layer environment. Background Art
[0002] Wine (Wine Is Not an Emulator) is a compatibility layer software that can port application programs of a second operating system to a first operating system. Since Wine can translate calls to the Windows API (Application Program Interface) into dynamic POSIX (Portable Operating System Interface) calls, Windows applications can run on operating systems other than Windows.
[0003] Windows applications running in a compatibility layer environment can be called compatible applications. Currently, in actual usage scenarios, users often have the need to drag and drop files from the window of a compatible application to the system window of Linux. For example, there is a compatible communication application running in the compatibility layer software. After a user receives and downloads a document in the compatible communication application, they often hope to directly drag and drop this document into a specified folder in the Linux system that is dedicated to storing work files for storage.
[0004] However, through in-depth analysis, it is found that there are certain limitations in the implementation of the file drag-and-drop function in existing compatibility layer software. They only implement the function of dragging and dropping files from the system window of Linux to a compatible application, but do not implement the function of dragging and dropping files from the window of a compatible application to the system window of Linux. This has brought great inconvenience to users' operations to a large extent and reduced the usage experience. Summary of the Invention
[0005] The embodiments of the present application provide a method for dragging and dropping files in a compatibility layer environment, which can realize dragging a target file from the window of a compatible application to the system window of a Unix-like system.
[0006] Correspondingly, the embodiments of the present application also provide a device for dragging and dropping files in a compatibility layer environment, an electronic device, and a machine-readable medium to ensure the implementation and application of the above method.
[0007] To solve the above problems, an embodiment of the present application discloses a method for dragging and dropping files in a compatibility layer environment. The method is applied to compatibility layer software running on a Unix-like system and is used to drag a target file from the window of a compatible application to the system window of the Unix-like system. The compatible application is a Windows application in the compatibility layer environment provided by the compatibility layer software. The method includes:
[0008] Receiving a drag-and-drop start request sent by a compatible application;
[0009] In response to the drag-and-drop start request, obtaining the mouse position;
[0010] Based on the mouse position, determining whether the target window for dragging and dropping is the system window;
[0011] If the target window for dragging and dropping is the system window, setting the drag-and-drop target interface of the system window to a proxy drag-and-drop target interface; the proxy drag-and-drop target interface includes: a drag-and-drop enter interface, a drag-and-drop hover interface, and a drop interface;
[0012] According to the drag-and-drop state of the target file, calling the proxy drag-and-drop target interface, generating an interaction message by the proxy drag-and-drop target interface, and sending the interaction message to the system window; the proxy drag-and-drop target interface is used to obtain drag-and-drop related data that conforms to the Windows specification and generate an interaction message according to the drag-and-drop related data that conforms to the Windows specification; the interaction message conforms to a preset drag-and-drop protocol, and the preset drag-and-drop protocol is the drag-and-drop protocol corresponding to the graphical user interface system of the Unix-like system; wherein, in the case where the drag-and-drop state is the first time entering the system window, calling the drag-and-drop enter interface to obtain a drag-and-drop enter message; the drag-and-drop enter message is used to notify the system window that the mouse has entered the system window; in the case where the drag-and-drop state is continuing to drag, calling the drag-and-drop hover interface to obtain a drag-and-drop position message; the drag-and-drop position message is used to notify the system window of the position of the mouse in the system window; in the case where the drag-and-drop state is releasing the mouse to end the drag-and-drop, calling the drop interface to obtain a send drop message; the drop message indicates that the user has completed the drag-and-drop action, so that the system window performs the placement process of the target file;
[0013] After sending the drop message to the system window, receiving a data request message sent by the system window;
[0014] According to the data request message, obtaining the file path of the target file from the compatible application and binding the file path of the target file to the system window;
[0015] Sending a notification message to the system window; the notification message is used to notify the system window that the file path of the target file is ready.
[0016] An embodiment of the present application also discloses a device for dragging and dropping files in a compatibility layer environment. The device is applied to compatibility layer software running on a Unix-like system and is used to drag a target file from the window of a compatibility application to the system window of the Unix-like system. The compatibility application is a Windows application program in the compatibility layer environment provided by the compatibility layer software. The device includes:
[0017] A start request receiving module, configured to receive a drag-and-drop start request sent by a compatibility application;
[0018] A position obtaining module, configured to obtain the mouse position in response to the drag-and-drop start request;
[0019] A window determination module, configured to determine whether the target window of the drag-and-drop is the system window according to the mouse position;
[0020] A setting module, configured to set the drag-and-drop target interface of the system window as a proxy drag-and-drop target interface if the target window of the drag-and-drop is the system window. The proxy drag-and-drop target interface includes: a drag-and-drop enter interface, a drag-and-drop hover interface, and a drop interface;
[0021] An invocation module, configured to invoke the proxy drag-and-drop target interface according to the drag-and-drop state of the target file, generate an interaction message by the proxy drag-and-drop target interface, and send the interaction message to the system window. The proxy drag-and-drop target interface is used to obtain drag-and-drop related data that conforms to the Windows specification, and generate an interaction message according to the drag-and-drop related data that conforms to the Windows specification. The interaction message conforms to a preset drag-and-drop protocol, and the preset drag-and-drop protocol is the drag-and-drop protocol corresponding to the graphical user interface system of the Unix-like system. Among them, in the case where the drag-and-drop state is the first time entering the system window, the drag-and-drop enter interface is invoked to obtain a drag-and-drop enter message. The drag-and-drop enter message is used to notify the system window that the mouse enters the system window. In the case where the drag-and-drop state is continuing the drag-and-drop, the drag-and-drop hover interface is invoked to obtain a drag-and-drop position message. The drag-and-drop position message is used to notify the system window of the position of the mouse in the system window. In the case where the drag-and-drop state is releasing the mouse to end the drag-and-drop, the drop interface is invoked to obtain a send drop message. The drop message indicates that the user has completed the drag-and-drop action, so that the system window performs the placement process of the target file;
[0022] A data request receiving module, configured to receive a data request message sent by the system window after sending the drop message to the system window;
[0023] A request processing module, configured to obtain the file path of the target file from the compatibility application according to the data request message, and bind the file path of the target file to the system window;
[0024] A notification sending module, configured to send a notification message to a system window; the notification message is used to notify the system window that the file path of the target file is ready.
[0025] Optionally, the window determination module includes:
[0026] A handle determination module, configured to determine the window handle corresponding to the mouse position;
[0027] A system window determination module, configured to determine that the target window for drag-and-drop is the system window if the window handle corresponding to the mouse position is not the window handle created by the compatibility layer software.
[0028] Optionally, the proxy drag-and-drop target interface further includes: a drag-and-drop leave interface; the step of calling the proxy drag-and-drop target interface according to the drag-and-drop state of the target file further includes:
[0029] In the case where the drag-and-drop state is canceling the drag-and-drop or leaving the system window, calling the drag-and-drop leave interface, and generating a drag-and-drop leave message by the drag-and-drop leave interface; the drag-and-drop leave message is used to notify the system window that the mouse has left the system window.
[0030] Optionally, if the proxy drag-and-drop target interface is a drag-and-drop enter interface, the drag-and-drop related data is the clipboard format information of the target file, and the interaction message is a drag-and-drop enter message;
[0031] If the proxy drag-and-drop target interface is a drag-and-drop hover interface, the drag-and-drop related data is the mouse position and the window identifier of the source window where the target file is located, and the interaction message is a drag-and-drop position message;
[0032] If the proxy drag-and-drop target interface is a drop interface, the interaction message is a drop message.
[0033] Optionally, before calling the proxy drag-and-drop target interface according to the drag-and-drop state of the target file, the apparatus further includes:
[0034] A selection set processing module, configured to map the target file to a selection set that conforms to a preset drag-and-drop protocol, and set the source window as the owner of the selection set.
[0035] Optionally, the apparatus further includes:
[0036] A response message receiving module, configured to receive a response message that conforms to a preset drag-and-drop protocol from the system window;
[0037] A conversion module, configured to convert the response message that conforms to the preset drag-and-drop protocol into a response message that conforms to the Windows specification;
[0038] A message processing module, configured to process the response message that conforms to the Windows specification.
[0039] Optionally, the response message receiving module includes:
[0040] A first response message receiving module, configured to receive a drag-and-drop response message that conforms to a preset drag-and-drop protocol from the system window after sending a drag-and-drop enter message to the system window and before invoking the drag-and-drop hover interface;
[0041] The message processing module includes:
[0042] A response judgment module, configured to judge whether the system window receives the placement of the target file according to the response message that conforms to the Windows specification, and obtain a judgment result;
[0043] A display module, configured to display the video feedback information corresponding to the judgment result.
[0044] Optionally, the response message receiving module includes:
[0045] A second response message receiving module, configured to receive a placement completion message that conforms to a preset drag-and-drop protocol from the system window after sending a notification message to the system window;
[0046] The device further includes: a completion notification module, configured to send a drag-and-drop completion notification to the compatible application according to the placement completion message.
[0047] Optionally, the device further includes:
[0048] A compatible window processing module, configured to, if the target window of the drag-and-drop is a compatible window created by the compatible layer software, obtain an interface pointer of the registered drag-and-drop target interface successfully registered by the compatible window, and according to the interface pointer, send a call request for the function included in the registered drag-and-drop target interface to the compatible window, and perform drag-and-drop processing of the target file to the compatible window according to the call request and the call result of the call request.
[0049] An embodiment of the present application also discloses an electronic device, including: a processor; and a memory, on which executable code is stored, and when the executable code is executed, the processor is caused to execute the method as described in the embodiment of the present application.
[0050] An embodiment of the present application also discloses a machine-readable medium, on which executable code is stored, and when the executable code is executed, a processor is caused to execute the method as described in the embodiment of the present application.
[0051] The embodiments of the present application include the following advantages:
[0052] In the technical solution of the embodiment of the present application, the set proxy drag-and-drop target interface can convert drag-and-drop related data that complies with the Windows specification into an interaction message that complies with the preset drag-and-drop protocol of the Unix-like system, solving the problem of inconsistent drag-and-drop protocols between the Windows system and the Unix-like system. Moreover, the embodiment of the present application binds the file path of the obtained target file to the system window, taking into account the differences in file path representation and management between the Windows system and the Unix-like system, enabling the file path of the target file to be correctly transmitted and processed between the two system environments.
[0053] Since the embodiment of the present application overcomes the differences between the Windows system and the Unix-like system in terms of drag-and-drop protocol, file path representation, and management, the embodiment of the present application can achieve dragging the target file from the window of a compatible application to the system window of the Unix-like system, thus providing convenience for users to drag and drop files between different systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 is a flowchart of a method for dragging and dropping files in a compatibility layer environment according to an embodiment of the present application;
[0055] Figure 2 is a flowchart of a method for dragging and dropping files in a compatibility layer environment according to an embodiment of the present application;
[0056] Figure 3 is a schematic structural diagram of a device for dragging and dropping files in a compatibility layer environment according to an embodiment of the present application;
[0057] Figure 4 is a schematic structural diagram of a device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0058] 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.
[0059] The method for dragging and dropping files in the compatibility layer environment of the embodiment of the present application can be used to drag and drop files from the window of a compatible application to the system window of the Unix-like system. The Unix-like system can specifically refer to a system evolved from the design style of UNIX. Examples of the Unix-like system can include: Linux, FreeBSD (Free Berkeley Software Distribution), etc.
[0060] In view of the technical problem that the existing compatibility layer software fails to implement the function of dragging and dropping files from the window of a compatible application to the system window of Linux, an embodiment of the present application provides a method for dragging and dropping files in a compatibility layer environment. The method is applied to compatibility layer software running on a Unix-like system and is used to drag a target file from the window of a compatible application to the system window of the Unix-like system. The compatible application is a Windows application in the compatibility layer environment provided by the compatibility layer software. The method specifically includes the following steps:
[0061] Receive a drag-and-drop start request sent by a compatible application;
[0062] In response to the drag-and-drop start request, obtain the mouse position;
[0063] According to the mouse position, determine whether the target window for dragging and dropping is the system window;
[0064] If the target window for dragging and dropping is the system window, set the drag-and-drop target interface of the system window to a proxy drag-and-drop target interface. The proxy drag-and-drop target interface specifically includes: a drag-and-drop enter interface, a drag-and-drop hover interface, and a drop interface;
[0065] According to the drag-and-drop state of the target file, call the proxy drag-and-drop target interface. The proxy drag-and-drop target interface generates an interaction message and sends the interaction message to the system window. The proxy drag-and-drop target interface is used to obtain drag-and-drop related data that conforms to the Windows specification and generate an interaction message according to the drag-and-drop related data that conforms to the Windows specification. The interaction message conforms to a preset drag-and-drop protocol, and the preset drag-and-drop protocol is the drag-and-drop protocol corresponding to the graphical user interface system of the Unix-like system. Among them, in the case where the drag-and-drop state is the first entry into the system window, call the drag-and-drop enter interface to obtain a drag-and-drop enter message. The drag-and-drop enter message is used to notify the system window that the mouse has entered the system window. In the case where the drag-and-drop state is continued dragging, call the drag-and-drop hover interface to obtain a drag-and-drop position message. The drag-and-drop position message is used to notify the system window of the position of the mouse in the system window. In the case where the drag-and-drop state is releasing the mouse to end the drag-and-drop, call the drop interface to obtain a send drop message. The drop message indicates that the user has completed the drag-and-drop action, so that the system window performs the placement process of the target file;
[0066] After sending the drop message to the system window, receive a data request message sent by the system window;
[0067] According to the data request message, obtain the file path of the target file from the compatible application and bind the file path of the target file to the system window;
[0068] Send a notification message to the system window; the above notification message is used to notify the system window that the file path of the target file is ready.
[0069] The technical solution of the embodiment of the present application specifically includes the following steps:
[0070] Drag-and-drop start and target window judgment step: Receive a drag-and-drop start request sent by a compatible application, then respond to the drag-and-drop start request, obtain the mouse position, and determine whether the target window of the drag-and-drop is the system window through the mouse position.
[0071] Proxy drag-and-drop target interface setting and call step: When it is determined that the target window is the system window, set the drag-and-drop target interface of the system window to the proxy drag-and-drop target interface. The proxy drag-and-drop target interface specifically includes a drag-and-drop enter interface, a drag-and-drop hover interface, and a drop interface. And during the drag-and-drop process, according to different drag-and-drop states of the target file, such as entering the system window for the first time, continuing to drag-and-drop, releasing the mouse to end the drag-and-drop, etc., call the corresponding proxy drag-and-drop target interface respectively. The proxy drag-and-drop target interface will obtain drag-and-drop related data that conforms to the Windows specification and convert it into an interaction message that conforms to the preset drag-and-drop protocol of the graphical user interface system corresponding to the Unix-like system. Then, send the interaction message to the system window so that the system window can understand and process the drag-and-drop operation from the compatible application.
[0072] File path binding and notification message sending step: After sending a drop message to the system window, the system window will send a data request message. At this time, the compatibility layer software obtains the file path of the target file from the compatible application according to the data request message and binds it to the system window, establishing a mapping between the file path of the target file and the system window of the Unix-like system, providing the necessary path information for the subsequent operation of the system window on the target file, so that the system window can find and process the target file through the file path. On this basis, the compatibility layer software sends a notification message to the system window, informing the system window that the file path of the target file is ready. After receiving the notification message, the system window can perform subsequent operations such as corresponding file placement processing according to the file path, thus completing the file drag-and-drop from the compatible application window to the Unix-like system window.
[0073] The proxy drag-and-drop target interface set in the embodiment of the present application can convert drag-and-drop related data conforming to the Windows specification into an interaction message conforming to the preset drag-and-drop protocol of the Unix-like system, solving the problem of inconsistent drag-and-drop protocols between the Windows system and the Unix-like system. Moreover, the embodiment of the present application binds the file path of the target file obtained to the system window, taking into account the differences in file path representation and management between the Windows system and the Unix-like system, so that the file path of the target file can be correctly transmitted and processed between the two system environments.
[0074] In summary, since the embodiment of the present application overcomes the differences between the Windows system and the Unix-like system in terms of drag-and-drop protocol, file path representation, and management, the embodiment of the present application can realize dragging the target file from the window of the compatible application to the system window of the Unix-like system, thus providing convenience for users to drag and drop files between different systems.
[0075] Method Embodiment 1
[0076] Reference Figure 1 , which shows the schematic flow chart of the steps of the method for dragging and dropping files in the compatible layer environment of an embodiment of the present application. This method is applied to the compatible layer software running on the Unix-like system and is used to drag the target file from the window of the compatible application to the system window of the Unix-like system. The compatible application is a Windows application program in the compatible layer environment provided by the compatible layer software. The method specifically includes the following steps:
[0077] Step 101: Receive a drag-and-drop start request sent by the compatible application;
[0078] Step 102: In response to the drag-and-drop start request, obtain the mouse position;
[0079] Step 103: According to the mouse position, determine whether the target window of the drag-and-drop is the system window;
[0080] Step 104: If the target window of the drag-and-drop is the system window, set the drag-and-drop target interface of the system window as the proxy drag-and-drop target interface; the proxy drag-and-drop target interface specifically includes: a drag-and-drop enter interface, a drag-and-drop hover interface, and a drop interface;
[0081] Step 105: According to the drag-and-drop state of the target file, call the proxy drag-and-drop target interface, generate an interaction message by the proxy drag-and-drop target interface, and send the interaction message to the system window.
[0082] The proxy drag-and-drop target interface is used to obtain drag-and-drop related data that complies with Windows specifications, and generate an interaction message based on the drag-and-drop related data that complies with Windows specifications; the interaction message complies with a preset drag-and-drop protocol, and the preset drag-and-drop protocol is the drag-and-drop protocol corresponding to the graphical user interface system of the Unix-like system.
[0083] Among them, in the case where the drag-and-drop state is the first time entering the system window, the drag-and-drop entry interface is called to obtain a drag-and-drop entry message; the drag-and-drop entry message is used to notify the system window that the mouse has entered the system window.
[0084] In the case where the drag-and-drop state is continuous dragging, the drag-and-drop hover interface is called to obtain a drag-and-drop position message; the drag-and-drop position message is used to notify the system window of the position of the mouse in the system window.
[0085] In the case where the drag-and-drop state is releasing the mouse to end the drag-and-drop, the drop interface is called to obtain a drop message; the drop message indicates that the user has completed the drag-and-drop action, so that the system window performs the placement process of the target file.
[0086] Step 106, after sending a drop message to the system window, receive a data request message sent by the system window;
[0087] Step 107, according to the data request message, obtain the file path of the target file from the compatible application, and bind the file path of the target file to the system window;
[0088] Step 108, send a notification message to the system window; the notification message is used to notify the system window that the file path of the target file is ready.
[0089] Figure 1 The steps included in the method embodiment shown can be used to drag and drop a file from the window of a compatible application to the system window of a Unix-like system.
[0090] Figure 1 The method embodiment shown can be executed by compatibility layer software running on a Unix-like system. Examples of compatibility layer software can include: Wine, CrossOver, etc. It can be understood that the embodiments of the present application do not limit the specific compatibility layer software.
[0091] Since the compatible application is a Windows application, the compatibility layer software can provide a virtual Windows operating environment for the compatible application. The above Windows operating environment specifically includes: simulating system calls, registry, file system, and graphical interface of Windows, etc., so that the Windows application can be normally started and run on the Unix-like system. The compatibility layer software can also adapt and optimize the installation process of the Windows application, automatically solve the dependency problems that may occur on the Unix-like system, and ensure that the application can be successfully installed and deployed. At the same time, the compatibility layer software will provide an input / output processing mechanism similar to the Windows system, including support for devices such as mice, keyboards, and printers, so that the operation experience of the Windows application on the Unix-like system is consistent with that on the Windows system, and users can perform input, output, printing, etc. operations normally as in the Windows system. In addition, the compatibility layer software can optimize and adjust the possible performance problems of the Windows application on the Unix-like system, and improve the running speed and stability of the application by reasonably allocating system resources, optimizing memory management, and graphical rendering, etc., reduce the occurrence of stuttering and crashing phenomena, and provide a smooth usage experience for users.
[0092] In step 101, the compatible application can send a drag-and-drop start request to the compatibility layer software in response to the user's drag-and-drop operation on the target file.
[0093] For example, the compatible application can call the DoDragDrop (perform drag-and-drop operation) function to initiate a drag-and-drop start request. The drag-and-drop start request is specifically: the call request of the compatible application for the DoDragDrop function.
[0094] The DoDragDrop function is a function used to start drag-and-drop operations in the Windows system environment. It allows users to drag data between windows or controls, such as dragging a file in Windows Explorer to another folder or application. This function is mainly used to implement the drag-and-drop interaction function in the user interface, so that data such as files can be conveniently transferred between different objects.
[0095] In step 102, the compatibility layer software can use the window management mechanism provided by the Unix-like system to create a virtual window on the Unix-like system to capture the mouse position.
[0096] In specific implementation, in the Linux system, relevant functions and interfaces of the X Window (X window) system can be used to create a virtual window. For example, a virtual window that conforms to the X Window system specification can be created by calling functions such as XcreateSimpleWindow (create a simple window).
[0097] After creating a virtual window, the compatibility layer software will call corresponding functions to set the mouse capture mode so that mouse events can be captured by the virtual window. For example, in the X Window system, functions such as XgrabPointer (grab the mouse pointer) can be used to achieve mouse capture.
[0098] After the mouse event is captured by the virtual window, the compatibility layer software can obtain the mouse position through the interfaces provided by the system. For example, in the X Window system, functions such as XqueryPointer (query the mouse pointer) can be used to obtain the coordinates of the mouse as the mouse position.
[0099] It should be noted that the mouse position can be obtained according to a preset time period to obtain a real-time mouse position.
[0100] In step 103, the window handle corresponding to the mouse position can be determined first; if the window handle corresponding to the mouse position is not the window handle created by the compatibility layer software, the target window for drag and drop is the system window.
[0101] In the specific implementation, functions such as WindowFromPoint (window from point) can be used to determine whether the mouse position belongs to the compatible window of the compatibility layer software. The WindowFromPoint function is used to return the window handle of the window where the mouse position is located according to the mouse position. If the window handle corresponding to the mouse position is created by the compatibility layer software, it can be considered that the target window for drag and drop is the compatible window of the compatible application; otherwise, if the window handle corresponding to the mouse position is not the window handle created by the compatibility layer software, it can be considered that the target window for drag and drop is the system window.
[0102] In the case where the target window for drag and drop is the system window, Xlib (X library) interfaces such as XqueryTree (X query tree) and XwindowAttributes (X window attributes) can be used to obtain the window identifier of the system window.
[0103] Among them, Xlib is a C language programming interface library provided by the X Window system. The XQueryTree function is used to obtain the window IDs of alternative windows such as the root window ID (identity), parent window ID, and child window ID of the system window.
[0104] XwindowAttributes is used to obtain the attributes of the alternative window, such as the position, size, visibility, etc. of the window, after obtaining the window ID of the alternative window. In this way, the window ID of the system window can be filtered out from the alternative windows according to the attributes of the alternative window.
[0105] In step 104, if the target window being dragged and dropped is a system window, set the drag-and-drop target interface of the system window to a proxy drag-and-drop target interface.
[0106] In a Windows system environment, the drag-and-drop target (IDropTarget) interface is used to handle drag-and-drop operations in the application where the target window is located.
[0107] In the traditional technology, the drag-and-drop target interface can be referred to as a registered drag-and-drop target interface. The traditional technology often uses the RegisterDragDrop (register drag-and-drop) function to register a pointer to an object of the drag-and-drop target interface for the target window being dragged and dropped (hereinafter referred to as the interface pointer of the registered drag-and-drop target interface), and sends a call request for the functions included in the registered drag-and-drop target interface to the target window according to the interface pointer. According to the call request and the call result of the call request, the drag-and-drop processing of the target file to the target window is performed.
[0108] However, in the case where the target window is a system window, due to the differences in drag-and-drop protocols between the Windows system and Unix-like systems, it is impossible to directly send a call request for the functions included in the registered drag-and-drop target interface to the target window according to the interface pointer. Therefore, the traditional technology cannot implement the function of dragging and dropping files from the window of a compatible application to the system window of Linux.
[0109] In the embodiment of the present application, creatively, in the case where the target window being dragged and dropped is a system window, set the drag-and-drop target interface of the system window to a proxy drag-and-drop target interface, and in step 105, call the proxy drag-and-drop target interface according to the drag-and-drop state of the target file. The proxy drag-and-drop target interface generates an interaction message and sends the interaction message to the system window.
[0110] Among them, the proxy drag-and-drop target interface is used to obtain drag-and-drop related data that conforms to the Windows specification, and generate an interaction message according to the drag-and-drop related data that conforms to the Windows specification; the interaction message conforms to a preset drag-and-drop protocol, and the preset drag-and-drop protocol is the drag-and-drop protocol corresponding to the graphical user interface system of Unix-like systems.
[0111] An example of the preset drag-and-drop protocol can be XDND (X Window System Drag-and-Drop). The XDND protocol is the standard protocol for implementing drag-and-drop operations in the X Window system, allowing applications to transfer data through drag-and-drop operations. The XDND protocol defines each stage of the drag-and-drop operation, including the start of dragging, data transfer during dragging, and operations at the end of dragging.
[0112] Since the proxy drag-and-drop target interface in the embodiments of the present application can convert drag-and-drop related data that complies with the Windows specification into an interaction message that complies with the preset drag-and-drop protocol of the Unix-like system, the embodiments of the present application solve the problem of inconsistent drag-and-drop protocols between the Windows system and the Unix-like system.
[0113] Referring to Table 1, an example of the drag-and-drop state and the determination method in an embodiment of the present application is shown.
[0114] Among them, the first entry into the system window may refer to: the mouse pointer first enters the area of a certain system window, indicating that the drag-and-drop operation starts to interact with this system window.
[0115] Continuing the drag-and-drop can mean that in an already started drag-and-drop operation, the mouse button is still pressed, and the mouse pointer moves within or between system windows, and the drag-and-drop process is ongoing.
[0116] Releasing the mouse to end the drag-and-drop may refer to when the user releases the mouse button, the drag-and-drop operation ends.
[0117] Canceling the drag-and-drop may refer to: during the drag-and-drop process, due to the user pressing a specific cancel key (such as the Esc key) or meeting other cancel conditions, the drag-and-drop operation is interrupted.
[0118] Leaving the system window means that the mouse pointer moves out of the area of a certain system window.
[0119] Table 1
[0120]
[0121] In the embodiments of the present application, if the proxy drag-and-drop target interface is a drag-and-drop entry interface, the drag-and-drop related data is the clipboard format information of the target file, and the interaction message is a drag-and-drop entry message; among them, the drag-and-drop entry message is used to notify the system window that the mouse has entered the system window, so that the system window determines whether to accept the drag-and-drop operation of the target file according to the clipboard format information of the target file.
[0122] If the proxy drag-and-drop target interface is a drag-and-drop hover interface, the drag-and-drop related data is the mouse position and the window identifier of the source window where the target file is located, and the interaction message is a drag-and-drop position message; the drag-and-drop position message is used to notify the system window of the position of the mouse in the system window. The compatibility layer software can send the drag-and-drop position message to the system window multiple times at a preset time frequency.
[0123] If the proxy drag-and-drop target interface is a drop interface, the interaction message is a drop message. The drop message indicates that the user has completed the drag-and-drop action, so that the system window performs the placement process of the target file.
[0124] Therefore, when the compatibility layer software of the present application is in the drag-and-drop state and enters the system window for the first time, it calls the drag-and-drop entry interface. The processing process of the drag-and-drop entry interface specifically includes: obtaining clipboard format information that conforms to the Windows specification, and generating a drag-and-drop entry message based on the clipboard format information that conforms to the Windows specification.
[0125] Among them, the process of generating a drag-and-drop entry message based on the clipboard format information that conforms to the Windows specification may include: converting the clipboard format information that conforms to the Windows specification into clipboard format information that conforms to a preset drag-and-drop protocol, and encapsulating the clipboard format information that conforms to the preset drag-and-drop protocol in the drag-and-drop entry message.
[0126] For example, in the case where the clipboard format information represents the clipboard format of a file type, the clipboard format information that conforms to the Windows specification may be: CF_HDROP; and the clipboard format information that conforms to the XDND protocol may be: text / uri– list. Among them, CF represents "Clipboard Format", HDROP is a data structure type used to process a file list. "text" indicates that the data is stored and transmitted in text format. uri (Uniform Resource Identifier) represents a resource. list represents a list of one or more uris.
[0127] It should be noted that the preset drag-and-drop protocol provides the message structure of each interaction message. The embodiments of the present application can encapsulate the interaction message according to this message structure, and the specific message structure and encapsulation process are not limited.
[0128] When the compatibility layer software of the present application is in the drag-and-drop state of continuous drag-and-drop, it calls the drag-and-drop hover interface. The processing process of the drag-and-drop hover interface specifically includes: obtaining the mouse position and the window identifier of the source window that conform to the Windows specification, and generating a drag-and-drop position message based on the mouse position and the window identifier of the source window that conform to the Windows specification. Specifically, the mouse position that conforms to the Windows specification can be converted into the mouse position and the window identifier of the source window that conform to the preset drag-and-drop protocol, and the mouse position and the window identifier of the source window that conform to the preset drag-and-drop protocol are encapsulated in the drag-and-drop position message.
[0129] Descriptions of window identifiers often vary in different system environments. In the Windows system environment, the window ID exists in the form of a window handle, which is a specific value used by the system kernel to manage windows, such as 0x00567890. In a Unix-like system environment that follows the XDND protocol, the window ID usually adopts the uri format, such as "x11:window:0xABCDEF12", where "x11" clearly indicates that it is based on the X Window system, "window" identifies it as related to a window, and "0xABCDEF12" is the unique identity identifier of the window in the X Window system. Therefore, embodiments of this application can convert the window identifier of the source window in the form of a window handle into a window identifier in the uri format, and then obtain the window identifier of the source window that conforms to the preset drag-and-drop protocol.
[0130] When the compatibility layer software of the embodiments of this application is in the drag-and-drop state where the mouse is released to end the drag-and-drop, it calls the placement interface. The processing process of the placement interface specifically includes: generating a placement message that conforms to the preset drag-and-drop protocol.
[0131] It should be noted that before the compatibility layer software calls the proxy drag-and-drop target interface according to the drag-and-drop state of the target file, it can also map the target file to a selection set that conforms to the preset drag-and-drop protocol, and set the source window as the owner of the selection set.
[0132] The Selections mechanism is a mechanism for information exchange between clients in the window system protocol of Unix-like systems, covering various operation scenarios such as copy / paste between different windows, dragging and dropping files or data.
[0133] In specific implementations, there can be any number of selection sets, and each selection set can be named by an Atom. An Atom is a data type used to identify and reference various resources (such as window attributes, selection sets, etc.). It is essentially a unique integer identifier used to quickly and efficiently search for and reference specific resources in the window system.
[0134] The selection set communicates between its owner (who owns the data stored in the selection set) and the requester (who hopes to obtain this data). Specifically in the embodiments of this application, the owner of the selection set can be the source window running on the compatibility layer software, and the requester of the selection set can be the system window.
[0135] Conditions for the requester to obtain data:
[0136] Name of the selection set: Clearly identify the selection set to be obtained.
[0137] Name of the property to be requested: Specify the specific property of the data required.
[0138] The system window to which the selection set is attached: know the window associated with the selection set.
[0139] The Atom value of the required data type: determines the expected data type.
[0140] Actions of the owner: If the requester obtains the selection set, the owner receives an event, then converts the content of the selection set into the requested data type, places the data in the properties of the system window, and sends an event to the requester indicating that the properties are available.
[0141] In one example, the XSetSelectionOwner function can be used to obtain the ownership of the selection set. XSetSelectionOwner is a function in the Xlib library that is used to set a window as the owner of a selection set.
[0142] In an alternative implementation of the present application, the above proxy drag-and-drop target interface may further include: a drag-and-drop leave interface; the calling of the proxy drag-and-drop target interface according to the drag-and-drop state of the target file may further include: in the case where the drag-and-drop state is canceling the drag-and-drop or leaving the system window, calling the drag-and-drop leave interface, and the drag-and-drop leave interface generates a drag-and-drop leave message; the drag-and-drop leave message is used to notify the system window that the mouse has left the system window.
[0143] Canceling the drag-and-drop may refer to the user actively terminating the drag-and-drop behavior during the drag-and-drop operation. Leaving the system window may refer to the object performing the drag-and-drop operation (such as the mouse pointer, or the cursor position associated with the drag-and-drop operation) moving out of the boundary range of the system window. The drag-and-drop leave message is used to notify the system window that the mouse has left the system window, so that the system window can be aware of the change in the drag-and-drop state, thereby maintaining the coherence and accuracy of the drag-and-drop operation process.
[0144] It should be noted that the drag-and-drop process of a target file may involve one or more system windows.
[0145] For the case of one system window, the user can directly drag the target file from the source window of the compatible application to a specific area of the first system window, and then release the mouse to end the drag-and-drop.
[0146] For the case of multiple system windows, the user can first drag the target file from the source window of the compatible application to the first system window, then drag the target file to a specific area of the second system window, and then release the mouse to end the drag-and-drop.
[0147] In step 106, after the compatibility layer software sends a placement message to the system window, it receives a data request message sent by the system window. The data request message is used to notify the source window that the system window needs data, and the data here can refer to the target file for which the drag-and-drop operation is completed. The data request data conforms to the aforementioned selection set mechanism.
[0148] In a specific implementation, when the system window needs to view the drag-and-drop data, it will call XConvertSelection (X conversion selection set) to request data. The above call will trigger a SelectionRequest (selection set request) event, and this event will trigger the sending of a data request message.
[0149] In step 107, after the compatibility layer software receives the data request message, it will, according to the data request message, obtain the file path of the target file from the compatible application and bind the file path of the target file to the system window.
[0150] In practical applications, the process of obtaining the file path of the target file from the compatible application according to the data request message specifically includes: using the IDataObject (data object) interface to obtain the file path of the target file and converting the obtained result into target data of the data type corresponding to the preset drag-and-drop protocol. For example, the data type corresponding to the preset drag-and-drop protocol can be: text / uri – list.
[0151] The IDataObject interface is an important interface in COM (Component Object Model) technology, mainly used to implement the drag-and-drop operation of data objects on the Windows platform. By implementing the IDataObject interface, an application can provide the data representation and operation of the data object and support the drag-and-drop function of the data.
[0152] The process of binding the file path of the target file to the system window specifically includes: calling the XChangeProperty function to place the target data.
[0153] In the window system protocol of the Unix-like system, the XChangeProperty function is used to set or modify properties on the system window. In this case, the compatibility layer software can set the converted target data as the property value to the specified property of the system window.
[0154] In step 108, the compatibility layer software can send a notification message to the system window; the notification message is used to notify the system window that the file path of the target file is ready.
[0155] After receiving a notification message, the system window can use the XGetWindowProperty function to retrieve the target data. The XGetWindowProperty() function is a function in the window system protocol of Unix-like systems and is used to obtain the property values of a window. Thus, the system window can obtain the file path of the target file and complete the drag-and-drop of the target file from the source window to the target window. It can be understood that the system window can perform preset processing based on the file path of the target file. For example, the preset processing can be: reading the target file from the file path and storing the target file in the folder of the system window.
[0156] In an alternative implementation of the present application, it is also possible to receive a response message that conforms to a preset drag-and-drop protocol from the system window; convert the response message that conforms to the preset drag-and-drop protocol into a response message that conforms to Windows specifications;
[0157] Process the response message that conforms to Windows specifications. In other words, the embodiments of the present application have the function of processing response messages.
[0158] In one implementation, the above-mentioned receiving a response message that conforms to a preset drag-and-drop protocol from the system window includes: after sending a drag-and-drop enter message to the system window and before calling the drag-and-drop hover interface, receiving a drag-and-drop response message that conforms to the preset drag-and-drop protocol from the system window; after receiving the drag-and-drop enter message, the system window will decide whether to accept the drop operation based on its own status and policy and send a drag-and-drop response message as a response.
[0159] Then the process of processing the response message that conforms to Windows specifications specifically includes: judging whether the system window accepts the placement of the target file according to the response message that conforms to Windows specifications to obtain a judgment result; displaying the video feedback information corresponding to the judgment result.
[0160] If the judgment result is that the system window accepts the placement of the target file, a first prompt message can be displayed. The first prompt message is used to prompt the user that they can drop the file. If the judgment result is that the system window does not accept the placement of the target file, a second prompt message can be displayed. The second prompt message is used to inform the user of the reason why the file cannot be placed, such as the file type is not supported, etc.
[0161] In another implementation, the process of receiving a response message that conforms to a preset drag-and-drop protocol from the system window specifically includes: after sending a notification message to the system window, receiving a placement complete message that conforms to the preset drag-and-drop protocol from the system window; after processing the target file, the system window will send a placement complete message to the source window to tell the source window that it no longer needs the data.
[0162] In this case, the method may further include: sending a drag-and-drop completion notification to the compatible application according to the placement completion message. The drag-and-drop completion notification is used to inform the compatible application that the system window has processed the target file and the drag-and-drop operation has officially ended.
[0163] The method according to the embodiment of the present application may further include: if the target window of the drag-and-drop is a compatible window created by the compatible layer software, obtaining an interface pointer of the registered drag-and-drop target interface successfully registered by the compatible window, and according to the interface pointer, sending a call request for the function included in the registered drag-and-drop target interface to the compatible window, and performing drag-and-drop processing of the target file to the compatible window according to the call request and the call result of the call request.
[0164] An interface pointer is a pointer used to point to an object that implements a specific interface. In a drag-and-drop operation, the interface pointer of the registered drag-and-drop target interface can be understood as a bridge that points to an object that implements functions related to the drag-and-drop function.
[0165] Through this interface pointer, the compatible layer software can access and call various functions included in the registered drag-and-drop target interface. These functions define how to handle different stages of the drag-and-drop operation, such as the start of the drag-and-drop, the progress of the drag-and-drop, the end of the drag-and-drop, etc., so as to realize the control and management of the drag-and-drop operation.
[0166] In an example, the registered drag-and-drop target interface specifically includes the following functions:
[0167] 1. Drag-and-drop enter function,
[0168] The drag-and-drop enter function is called when the drag-and-drop operation starts to enter the compatible window, and is used to judge whether to accept the drag-and-drop according to the incoming information and provide corresponding visual feedback, and pass the result to the caller through the drag-and-drop effect parameter.
[0169] The parameters of the drag-and-drop enter function specifically include:
[0170] Data object pointer: An interface pointer pointing to an object containing drag-and-drop data. In this scenario, the drag-and-drop data is mainly information related to the target file, such as the file path, file type, etc., and these related information are encapsulated in the data object pointer in a specific data format.
[0171] Key state parameter: Represents the current state of the keyboard keys.
[0172] Mouse position coordinate parameter: Records the current position of the mouse and is used to judge the specific position where the drag-and-drop enters the compatible window.
[0173] Drag-and-drop effect parameter: Used to return the recommended effect of the drag-and-drop operation and can be used as the call result of the drag-and-drop enter function.
[0174] After receiving a call request for the drag-and-drop enter function, the compatible window can decide whether to accept the current drag-and-drop operation based on its own state (for example, the compatible window may only accept specific types of files, or whether it is currently in a state where drag-and-drop is acceptable). If it accepts, it will set the drag-and-drop effect parameter to the corresponding valid drag-and-drop effect; if it does not accept, it will set the drag-and-drop effect parameter to not allowed.
[0175] 2. Drag-and-drop hover function
[0176] When the mouse moves within the compatible window, the drag-and-drop hover function is called. The drag-and-drop hover function is used to update the visual feedback and adjust the drag-and-drop effect according to the mouse position and keyboard state, and pass the adjusted effect to the caller through the drag-and-drop effect parameter.
[0177] After receiving a call request for the drag-and-drop hover function, the compatible window can update the visual feedback of the drag-and-drop according to the parameter value of the mouse position coordinate parameter.
[0178] Updating the visual feedback of the drag-and-drop can make corresponding adjustments to the user interface to provide users with more intuitive operation information and experience. For example, the shape of the mouse pointer can be changed to display an icon indicating that drag-and-drop is allowed (such as an arrow with a "+" sign) or an icon indicating that drag-and-drop is prohibited (such as a circle with a slash); or the corresponding area of the compatible window can be highlighted to prompt the user about the possible effects of the drag-and-drop operation.
[0179] 3. Drag-and-drop leave function
[0180] When the drag-and-drop operation is cancelled midway or the mouse leaves the compatible window, the drag-and-drop leave function is called. The drag-and-drop leave function is mainly responsible for cleaning up the temporary resources and visual feedback set during the drag-and-drop enter function and the drag-and-drop hover function stages. For example, restoring the original style of the mouse pointer and clearing the previously highlighted drag-and-drop target area, etc.
[0181] 4. Drop function
[0182] The drop function is called at the end of the drag-and-drop operation to place the target file in the appropriate position in the compatible window, adjust the drag-and-drop effect parameter according to the drop result, and display the corresponding information. For example, if the file is successfully dropped, it may show a success message to the user through message prompts on the user interface, file list updates, etc., such as displaying a "File has been successfully dropped" notification, or updating the file list in the compatible window so that the user can see the newly added file.
[0183] Therefore, when the target window is a compatible window, the compatible layer software in the embodiment of the present application communicates with the compatible window through an interface pointer. First, a registration operation is performed on the compatible window. This process associates the compatible window with the registered drag-and-drop target interface. As a result of the registration operation, the interface pointer points to the registered drag-and-drop target interface. After that, the compatible layer software can use the interface pointer to send operation instructions or request information to the target window, and the target window will receive and process these operation instructions or request information in real time, so as to make corresponding responses.
[0184] In summary, for the method of dragging and dropping files in the compatible layer environment of the embodiment of the present application, due to the set proxy drag-and-drop target interface, it can convert the drag-and-drop related data that conforms to the Windows specification into an interaction message that conforms to the preset drag-and-drop protocol of the Unix-like system, and solves the problem of inconsistent drag-and-drop protocols between the Windows system and the Unix-like system. Moreover, the embodiment of the present application binds the file path of the obtained target file to the system window, taking into account the differences in file path representation and management between the Windows system and the Unix-like system, so that the file path of the target file can be correctly transmitted and processed between the two system environments.
[0185] Since the embodiment of the present application overcomes the differences between the Windows system and the Unix-like system in terms of drag-and-drop protocol, file path representation, and management, the embodiment of the present application can realize dragging the target file from the window of the compatible application to the system window of the Unix-like system, thereby providing convenience for users to drag and drop files between different systems.
[0186] Method Embodiment Two
[0187] Reference Figure 2 , which shows the schematic flow chart of the steps of the method for dragging and dropping files in the compatible layer environment of an embodiment of the present application. This method is applied to the compatible layer software running on the Unix-like system and is used to drag the target file from the window of the compatible application to the system window of the Unix-like system. The compatible application is a Windows application program in the compatible layer environment provided by the compatible layer software. The method specifically includes the following steps:
[0188] Step 201, receive a drag-and-drop start request sent by the compatible application;
[0189] Step 202, in response to the drag-and-drop start request, obtain the mouse position;
[0190] Step 203, according to the mouse position, determine whether the target window of the drag-and-drop is the system window;
[0191] Step 204: If the target window being dragged and dropped is a system window, set the drag-and-drop target interface of the system window to a proxy drag-and-drop target interface; the proxy drag-and-drop target interface specifically includes: a drag-and-drop enter interface, a drag-and-drop hover interface, and a drop interface;
[0192] Step 205: Determine the drag-and-drop state of the target file;
[0193] Step 206: If the drag-and-drop state is the first entry into the system window, call the drag-and-drop enter interface to obtain a drag-and-drop enter message and send the drag-and-drop enter message to the system window;
[0194] The processing process of the drag-and-drop enter interface specifically includes: obtaining clipboard format information that conforms to the Windows specification, and generating a drag-and-drop enter message based on the clipboard format information that conforms to the Windows specification. The drag-and-drop enter message is used to notify the system window that the mouse has entered the system window.
[0195] Step 207: Receive a drag-and-drop response message that conforms to a preset drag-and-drop protocol from the system window;
[0196] Step 208: If the drag-and-drop response message indicates acceptance of the drag-and-drop operation of the target file and the drag-and-drop state is continued dragging, call the drag-and-drop hover interface to obtain a drag-and-drop position message and send the drag-and-drop position information to the system window;
[0197] The processing process of the drag-and-drop hover interface specifically includes: obtaining the mouse position that conforms to the Windows specification and the window identifier of the source window, and generating a drag-and-drop position message based on the mouse position and the window identifier of the source window that conforms to the Windows specification.
[0198] It should be noted that if the drag-and-drop response message indicates non-acceptance of the drag-and-drop operation of the target file, corresponding video feedback information can be displayed to enable the user to perform the next operation, such as leaving the system window or canceling the drag-and-drop.
[0199] Step 209: If the drag-and-drop state is releasing the mouse to end the drag-and-drop, call the drop interface to obtain a send drop message and send the drop message to the system window;
[0200] Step 210: Receive a data request message sent by the system window;
[0201] Step 211: According to the data request message, obtain the file path of the target file from a compatible application and bind the file path of the target file to the system window;
[0202] Step 212: Send a notification message to the system window; the notification message is used to notify the system window that the file path of the target file is ready;
[0203] Step 213: If the drag-and-drop state is canceling the drag-and-drop or leaving the system window, then call the drag-and-drop leaving interface. The drag-and-drop leaving interface generates a drag-and-drop leaving message and sends the drag-and-drop leaving message to the system window. The drag-and-drop leaving message is used to notify the system window that the mouse has left the system window.
[0204] In summary, the method for dragging and dropping files in the compatibility layer environment of the present application embodiment realizes the function of dragging files from a compatible application to a system window according to a preset drag-and-drop protocol.
[0205] It should be noted that for the method embodiments, for simplicity of 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 for the embodiments of the present application.
[0206] Based on the above embodiments, the present embodiment further provides a device for dragging and dropping files in a compatibility layer environment. Referring to Figure 3 the structural schematic diagram shown, the device is applied to compatibility layer software running on a Unix-like system, and is used to drag a target file from the window of a compatible application to the system window of the Unix-like system. The compatible application is a Windows application program in the compatibility layer environment provided by the compatibility layer software. The device includes: a start request receiving module 301, a position obtaining module 302, a window judging module 303, a setting module 304, a calling module 305, a data request receiving module 306, a request processing module 307, and a notification sending module 308.
[0207] Among them, the start request receiving module 301 is configured to receive a drag-and-drop start request sent by a compatible application;
[0208] The position obtaining module 302 is configured to obtain the mouse position in response to the drag-and-drop start request;
[0209] The window judging module 303 is configured to judge whether the target window of the drag-and-drop is the system window according to the mouse position;
[0210] The setting module 304 is configured to, if the target window of the drag-and-drop is the system window, set the drag-and-drop target interface of the system window as a proxy drag-and-drop target interface. The proxy drag-and-drop target interface includes: a drag-and-drop entering interface, a drag-and-drop hovering interface, and a placing interface;
[0211] The calling module 305 is used to call the proxy drag-and-drop target interface according to the drag-and-drop state of the target file. The proxy drag-and-drop target interface generates an interaction message and sends the interaction message to the system window. The proxy drag-and-drop target interface is used to obtain drag-and-drop related data that complies with the Windows specification and generate an interaction message according to the drag-and-drop related data that complies with the Windows specification. The interaction message complies with a preset drag-and-drop protocol, and the preset drag-and-drop protocol is the drag-and-drop protocol corresponding to the graphical user interface system of the Unix-like system. Among them, in the case where the drag-and-drop state is entering the system window for the first time, the drag-and-drop entry interface is called to obtain a drag-and-drop entry message. The drag-and-drop entry message is used to notify the system window that the mouse has entered the system window. In the case where the drag-and-drop state is continuing to drag, the drag-and-drop hover interface is called to obtain a drag-and-drop position message. The drag-and-drop position message is used to notify the system window of the position of the mouse in the system window. In the case where the drag-and-drop state is releasing the mouse to end the drag-and-drop, the placement interface is called to obtain a send placement message. The placement message indicates that the user has completed the drag-and-drop action, so that the system window performs the placement process of the target file.
[0212] The data request receiving module 306 is used to receive a data request message sent by the system window after sending the placement message to the system window.
[0213] The request processing module 307 is used to obtain the file path of the target file from the compatible application according to the data request message and bind the file path of the target file to the system window.
[0214] The notification sending module 308 is used to send a notification message to the system window. The notification message is used to notify the system window that the file path of the target file is ready.
[0215] Optionally, the window judgment module includes:
[0216] The handle determination module is used to determine the window handle corresponding to the mouse position.
[0217] The system window determination module is used to determine that the target window of the drag-and-drop is the system window if the window handle corresponding to the mouse position is not the window handle created by the compatibility layer software.
[0218] Optionally, the proxy drag-and-drop target interface further includes: a drag-and-drop leave interface. The calling of the proxy drag-and-drop target interface according to the drag-and-drop state of the target file further includes:
[0219] In the case where the drag-and-drop state is canceling the drag-and-drop or leaving the system window, the drag-and-drop leave interface is called, and the drag-and-drop leave interface generates a drag-and-drop leave message. The drag-and-drop leave message is used to notify the system window that the mouse has left the system window.
[0220] Optionally, if the proxy drag-and-drop target interface is a drag-and-drop into interface, the drag-and-drop related data is the clipboard format information of the target file, and the interaction message is a drag-and-drop into message;
[0221] If the proxy drag-and-drop target interface is a drag-and-drop hover interface, the drag-and-drop related data is the mouse position and the window identifier of the source window where the target file is located, and the interaction message is a drag-and-drop position message;
[0222] If the proxy drag-and-drop target interface is a drop interface, the interaction message is a drop message.
[0223] Optionally, before calling the proxy drag-and-drop target interface according to the drag-and-drop state of the target file, the device further includes:
[0224] A selection set processing module, configured to map the target file to a selection set that conforms to a preset drag-and-drop protocol, and set the source window as the owner of the selection set.
[0225] Optionally, the device further includes:
[0226] A response message receiving module, configured to receive a response message that conforms to a preset drag-and-drop protocol from the system window;
[0227] A conversion module, configured to convert the response message that conforms to the preset drag-and-drop protocol into a response message that conforms to Windows specifications;
[0228] A message processing module, configured to process the response message that conforms to Windows specifications.
[0229] Optionally, the response message receiving module includes:
[0230] A first response message receiving module, configured to receive a drag-and-drop response message that conforms to a preset drag-and-drop protocol from the system window after sending a drag-and-drop into message to the system window and before calling the drag-and-drop hover interface;
[0231] The message processing module includes:
[0232] A response judgment module, configured to judge whether the system window receives the placement of the target file according to the response message that conforms to Windows specifications, and obtain a judgment result;
[0233] A display module, configured to display the video feedback information corresponding to the judgment result.
[0234] Optionally, the response message receiving module includes:
[0235] A second response message receiving module, configured to receive a placement completion message that conforms to a preset drag-and-drop protocol from the system window after sending a notification message to the system window;
[0236] The device further includes: a completion notification module, configured to send a drag-and-drop completion notification to a compatible application according to the placement completion message.
[0237] Optionally, the device further includes:
[0238] a compatible window processing module, configured to, if the target window of the drag-and-drop is a compatible window created by a compatible layer software, obtain an interface pointer of a registered drag-and-drop target interface successfully registered by the compatible window, and according to the interface pointer, send a call request for a function included in the registered drag-and-drop target interface to the compatible window, and perform drag-and-drop processing of a target file to the compatible window according to the call request and a call result of the call request.
[0239] An embodiment of the present application further provides a non-volatile readable storage medium, in which one or more modules (programs) are stored, and when the one or more modules are applied to a device, instructions (instructions) for enabling the device to execute each method step in the embodiment of the present application can be provided.
[0240] An embodiment of the present application provides one or more machine-readable media, on which instructions are stored, and when executed by one or more processors, enable an electronic device to execute one or more of the methods as described in the above embodiments. In the embodiment of the present application, the electronic device includes various types of devices such as a terminal device and a server (cluster).
[0241] Embodiments of the present disclosure can be implemented as a device configured with any suitable hardware, firmware, software, or any combination thereof, and the device may include: electronic devices such as a terminal device and a server (cluster). Figure 4 Exemplary device 1100 that can be used to implement the various embodiments described in the present application is schematically shown.
[0242] For one embodiment, Figure 4 Exemplary device 1100 is shown, which has one or more processors 1102, a control module (chipset) 1104 coupled to at least one of the one or more processors 1102, a memory 1106 coupled to the control module 1104, a non-volatile memory / storage device 1108 coupled to the control module 1104, one or more input / output devices 1110 coupled to the control module 1104, and a network interface 1112 coupled to the control module 1104.
[0243] The processor 1102 may include one or more single-core or multi-core processors, and the processor 1102 may include any combination of general-purpose processors or dedicated processors (such as graphics processors, application processors, baseband processors, etc.). In some embodiments, the device 1100 can function as devices such as the terminal device, server (cluster), etc. described in the embodiments of the present application.
[0244] In some embodiments, the device 1100 may include one or more computer-readable media (such as the memory 1106 or the non-volatile memory / storage device 1108) having instructions 1114, and one or more processors 1102 that are combined with the one or more computer-readable media and are configured to execute the instructions 1114 to implement modules to perform the actions described in the present disclosure.
[0245] For one embodiment, the control module 1104 may include any suitable interface controller to provide any suitable interface to at least one of the (one or more) processors 1102 and / or any suitable device or component communicating with the control module 1104.
[0246] The control module 1104 may include a memory controller module to provide an interface to the memory 1106. The memory controller module may be a hardware module, a software module, and / or a firmware module.
[0247] The memory 1106 may be used, for example, to load and store data and / or instructions 1114 for the device 1100. For one embodiment, the memory 1106 may include any suitable volatile memory, such as a suitable DRAM (Dynamic Random Access Memory). In some embodiments, the memory 1106 may include double data rate type four synchronous dynamic random access memory.
[0248] For one embodiment, the control module 1104 may include one or more input / output controllers to provide an interface to the non-volatile memory / storage device 1108 and the (one or more) input / output devices 1110.
[0249] For example, the non-volatile memory / storage device 1108 may be used to store data and / or instructions 1114. The non-volatile memory / storage device 1108 may include any suitable non-volatile memory (such as flash memory) and / or may include any suitable (one or more) non-volatile storage devices (such as one or more hard disk drives, one or more optical disk drives, and / or one or more digital versatile disc drives).
[0250] The non-volatile memory / storage device 1108 may include storage resources that are physically part of the device on which the device 1100 is mounted, or it may be accessible by the device without being part of the device. For example, the non-volatile memory / storage device 1108 may be accessed via the network through the input / output device(s) 1110.
[0251] (The input / output device(s) 1110 may provide an interface for the device 1100 to communicate with any other suitable device. The input / output device 1110 may include a communication component, an audio component, a sensor component, etc. The network interface 1112 may provide an interface for the device 1100 to communicate through one or more networks. The device 1100 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, such as accessing a communication standard-based wireless network, such as WiFi (Wireless Fidelity), 2G (2-Generation wireless telephone technology), 3G (3-Generation wireless telephone technology), 4G (4-Generation wireless telephone technology), 5G (5-Generation wireless telephone technology), etc., or a combination thereof for wireless communication.
[0252] For one embodiment, at least one of the processor(s) 1102 may be logically encapsulated with one or more controllers of the control module 1104 (e.g., a memory controller module). For one embodiment, at least one of the processor(s) 1102 may be logically encapsulated with one or more controllers of the control module 1104 to form a system-in-package. For one embodiment, at least one of the processor(s) 1102 may be logically integrated with one or more controllers of the control module 1104 on the same die. For one embodiment, at least one of the processor(s) 1102 may be logically integrated with one or more controllers of the control module 1104 on the same die to form a system-on-chip.
[0253] In various embodiments, the device 1100 can be, but is not limited to, a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a touchscreen device, a netbook, etc.), such as a terminal device. In various embodiments, the device 1100 can have more or fewer components and / or a different architecture. For example, in some embodiments, the device 1100 includes one or more cameras, a keyboard, a liquid crystal display screen (including a touchscreen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit, and a speaker.
[0254] Among them, a main control chip can be used as a processor or a control module in the detection device, sensor data, location information, etc. are stored in a memory or a non-volatile memory / storage device, the sensor group can be used as an input / output device, and the communication interface can include a network interface.
[0255] For the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, please refer to the partial description of the method embodiments.
[0256] Each embodiment in this specification is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other.
[0257] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the 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 flowcharts and / or block diagrams, and the combination of the processes and / or blocks in the flowcharts and / or block diagrams, 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 one or more processes in the flowchart and / or one or more blocks in the block diagram.
[0258] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the functions specified in one or more processes in the flowchart and / or one or more blocks in the block diagram.
[0259] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one or more processes of the flowchart and / or one or more blocks of the block diagram.
[0260] Although the preferred embodiments of the embodiments of the present application have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concepts. Therefore, the appended claims are intended to be construed to include the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0261] Finally, it should also be noted that in this text, 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 such 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.
[0262] The above has introduced in detail a method and apparatus for dragging and dropping files in a compatible layer environment, an electronic device and a machine-readable medium provided by the present application. Specific examples are used in this text to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scenarios. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A method for dragging and dropping files in a compatibility layer environment, characterized in that: The method is applied to a compatibility layer software running on a Unix-like system, and is used to drag and drop a target file from a window of a compatible application to a system window of the Unix-like system. The compatibility layer software is used to transplant an application program of a Windows system to a Unix-like system, and the compatible application is a Windows application program in a compatibility layer environment provided by the compatibility layer software. The method comprises: receiving a drag and drop initiation request sent by a compatible application; In response to a drag and drop initiation request, obtaining a mouse position; According to the mouse position, determine whether the target window of the drag and drop is a system window; If the drag and drop target window is a system window, the drag and drop target interface of the system window is set as a proxy drag and drop target interface; the proxy drag and drop target interface includes: a drag and drop entry interface, a drag and drop hover interface and a placement interface; According to the drag-and-drop state of the target file, the proxy drag-and-drop target interface is called, and the proxy drag-and-drop target interface generates an interactive message, and sends the interactive message to the system window; the proxy drag-and-drop target interface is used to obtain drag-and-drop related data that conforms to the Windows specification, and generates an interactive message according to the drag-and-drop related data that conforms to the Windows specification; the interactive message conforms to the preset drag-and-drop protocol, and the preset drag-and-drop protocol is the drag-and-drop protocol corresponding to the graphical user interface system of the Unix-like system; wherein, when the drag-and-drop state is the first time entering the system window, the drag-and-drop entry interface is called to obtain a drag-and-drop entry message; the drag-and-drop entry message is used to notify the system window that the mouse has entered the system window; when the drag-and-drop state is to continue dragging and dropping, the drag-and-drop hover interface is called to obtain a drag-and-drop position message; the drag-and-drop position message is used to notify the system window of the position of the mouse in the system window; When the drop state is to release the mouse to end the drag and drop, the drop interface is called to obtain a send drop message; the drop message indicates that the user has completed the drag and drop action, so that the system window performs the placement processing of the target file; the processing process of the drag and drop entry interface includes: obtaining clipboard format information that complies with Windows specifications, converting the clipboard format information that complies with Windows specifications into clipboard format information that complies with a preset drag and drop protocol, and encapsulating the clipboard format information that complies with the preset drag and drop protocol in a drag and drop entry message; the processing process of the drag and drop hover interface includes: obtaining a mouse position that complies with Windows specifications and a window identifier of a source window, converting the mouse position that complies with Windows specifications into a mouse position that complies with a preset drag and drop protocol and a window identifier of a source window, and encapsulating the mouse position that complies with the preset drag and drop protocol and the window identifier of the source window in a drag and drop position message; After sending a placement message to the system window, receive a data request message sent by the system window; According to the data request message, the file path of the target file is obtained from the compatible application, and the file path of the target file is bound to the system window; the file path of the target file is obtained using the data object interface, the obtained result is converted into target data of a data type corresponding to the preset drag-and-drop protocol, and the converted target data is set as an attribute value to a specified attribute of the system window; A notification message is sent to the system window; the notification message is used to notify the system window that the file path of the target file has been prepared.
2. The method according to claim 1, characterized in that The step of determining whether the target window for dragging and dropping is a system window according to the mouse position includes: Determine the window handle corresponding to the mouse position; If the window handle corresponding to the mouse position is not the window handle created by the compatibility layer software, the target window of the drag and drop is the system window.
3. The method according to claim 1, characterized in that The proxy drag-and-drop target interface also includes: a drag-and-drop leaving interface; The calling of the proxy drag-and-drop target interface according to the drag-and-drop state of the target file further includes: When the drag-and-drop state is to cancel the drag-and-drop or to leave the system window, the drag-and-drop leaving interface is called, and the drag-and-drop leaving interface generates a drag-and-drop leaving message; the drag-and-drop leaving message is used to notify the system window that the mouse leaves the system window.
4. The method according to claim 1, characterized in that: If the proxy drag-and-drop target interface is a drag-and-drop entry interface, the drag-and-drop related data is the clipboard format information of the target file, and the interaction message is a drag-and-drop entry message; If the proxy drag-and-drop target interface is a drag-and-drop hover interface, the drag-and-drop related data is the mouse position and the window identifier of the source window where the target file is located, and the interaction message is a drag-and-drop position message; If the proxy drag-and-drop target interface is a placement interface, the interaction message is a placement message.
5. The method according to claim 1, characterized in that Before calling the proxy drag-and-drop target interface according to the drag-and-drop state of the target file, the method further includes: Maps the target file to a selection set that complies with the preset drag-and-drop protocol and sets the source window as the owner of the selection set.
6. The method according to claim 1, characterized in that The method further comprises: Receive a response message from the system window that complies with the preset drag and drop protocol; Convert the response message that complies with the preset drag-and-drop protocol into a response message that complies with the Windows specification; Process the response message in accordance with Windows specifications.
7. The method according to claim 6, characterized in that The receiving a response message conforming to a preset drag-and-drop protocol from the system window includes: After sending a drag-and-drop entry message to the system window and before calling the drag-and-drop hover interface, receiving a drag-and-drop response message that complies with a preset drag-and-drop protocol from the system window; The processing of the response message conforming to the Windows specification includes: According to the response message conforming to the Windows specification, it is judged whether the system window accepts the placement of the target file, and a judgment result is obtained; The video feedback information corresponding to the judgment result is displayed.
8. The method according to claim 6, characterized in that The receiving a response message conforming to a preset drag-and-drop protocol from the system window includes: After sending a notification message to the system window, receiving a drop completion message from the system window that complies with the preset drag-and-drop protocol; The method further includes sending a drag-and-drop completion notification to a compatible application based on the drop completion message.
9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: If the target window for dragging and dropping is a compatible window created by the compatible layer software, an interface pointer of a registered drag and drop target interface that has been successfully registered by the compatible window is obtained, and based on the interface pointer, a call request for a function included in the registered drag and drop target interface is sent to the compatible window, and based on the call request and the call result of the call request, the target file is dragged and dropped to the compatible window.
10. A device for dragging and dropping files in a compatible layer environment, characterized in that: The device is applied to a compatibility layer software running on a Unix-like system, and is used to drag and drop a target file from a window of a compatible application to a system window of the Unix-like system, wherein the Unix-like system is a Linux system, and the compatible application is a Windows application program in a compatibility layer environment provided by the compatibility layer software; the device comprises: A start request receiving module, used for receiving a drag and drop start request sent by a compatible application; A position acquisition module, used for acquiring a mouse position in response to a drag-and-drop start request; The window judgment module is used to judge whether the dragged and dropped target window is a system window according to the mouse position; A setting module, for setting the drag and drop target interface of the system window as a proxy drag and drop target interface if the drag and drop target window is a system window; the proxy drag and drop target interface includes: a drag and drop entry interface, a drag and drop hover interface and a placement interface; A calling module, used for calling the proxy drag-and-drop target interface according to the drag-and-drop state of the target file, generating an interactive message by the proxy drag-and-drop target interface, and sending the interactive message to the system window; the proxy drag-and-drop target interface is used to obtain drag-and-drop related data that conforms to the Windows specification, and generate an interactive message according to the drag-and-drop related data that conforms to the Windows specification; the interactive message conforms to a preset drag-and-drop protocol, and the preset drag-and-drop protocol is a drag-and-drop protocol corresponding to a graphical user interface system of a Unix-like system; wherein, when the drag-and-drop state is the first time entering the system window, the drag-and-drop entry interface is called to obtain a drag-and-drop entry message; the drag-and-drop entry message is used to notify the system window that the mouse has entered the system window; when the drag-and-drop state is to continue dragging and dropping, the drag-and-drop hover interface is called to obtain a drag-and-drop position message; the drag-and-drop position message is used to notify the system window of the position of the mouse in the system window Place; when the drag-and-drop state is to release the mouse to end the drag-and-drop, call the placement interface to obtain a send placement message; the placement message indicates that the user has completed the drag-and-drop action, so that the system window performs placement processing of the target file; the processing process of the drag-and-drop entry interface includes: obtaining clipboard format information that complies with Windows specifications, converting the clipboard format information that complies with Windows specifications into clipboard format information that complies with a preset drag-and-drop protocol, and encapsulating the clipboard format information that complies with the preset drag-and-drop protocol in a drag-and-drop entry message; the processing process of the drag-and-drop hover interface includes: obtaining a mouse position that complies with Windows specifications and a window identifier of a source window, converting the mouse position that complies with Windows specifications into a mouse position that complies with a preset drag-and-drop protocol and a window identifier of a source window, and encapsulating the mouse position that complies with the preset drag-and-drop protocol and the window identifier of the source window in a drag-and-drop position message; A data request receiving module, used for receiving a data request message sent by the system window after sending a placement message to the system window; A request processing module, configured to obtain a file path of a target file from a compatible application according to the data request message, and bind the file path of the target file to a system window; obtain the file path of the target file using a data object interface, convert the obtained result into target data of a data type corresponding to a preset drag-and-drop protocol, and set the converted target data as an attribute value to a specified attribute of the system window; The notification sending module is used to send a notification message to the system window; the notification message is used to notify the system window that the file path of the target file has been prepared.
11. An electronic device, characterized in that: include: processor; and A memory having executable codes stored thereon, which, when executed, causes the processor to execute the method according to any one of claims 1 to 9.
12. A machine-readable medium having executable codes stored thereon, which, when executed, causes a processor to execute the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Cross-system target object transmission method and device
CN115700453A