mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-16 05:33:07 +02:00
Add the start for a Wine->X11 DnD wrapper
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// yabridge: a Wine VST bridge
|
||||
// Copyright (C) 2020-2021 Robbert van der Helm
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/**
|
||||
* A simple wrapper that registers a WinEvents hook to listen for new windows
|
||||
* being created, and handles XDND client messages to achieve the behaviour
|
||||
* described in `WineXdndProxy::init_proxy()`.
|
||||
*/
|
||||
class WineXdndProxy {
|
||||
protected:
|
||||
WineXdndProxy();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Initialize the Wine->X11 drag-and-drop proxy. Calling this will hook into
|
||||
* Wine's OLE drag and drop system by listening for the creation of special
|
||||
* proxy windows created by the Wine server. When a drag and drop operation
|
||||
* is started, we will initiate the XDND protocol with the same file. This
|
||||
* will allow us to drag files from Wine windows to X11 applications,
|
||||
* something that's normally not possible. Calling this function more than
|
||||
* once doesn't have any effect, but this will still be called from every
|
||||
* plugin host instance. Because of that we'll use a global Win32 mutex to
|
||||
* ensure that this is done from only one thread at a time.
|
||||
*/
|
||||
static WineXdndProxy& init_proxy();
|
||||
|
||||
private:
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wignored-attributes"
|
||||
std::unique_ptr<std::remove_pointer_t<HWINEVENTHOOK>,
|
||||
std::decay_t<decltype(&UnhookWinEvent)>>
|
||||
hook_handle;
|
||||
#pragma GCC diagnostic pop
|
||||
};
|
||||
Reference in New Issue
Block a user