winrt-Windows.ApplicationModel.DataTransfer.Interop 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/LICENSE +22 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/MANIFEST.in +3 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/PKG-INFO +39 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/README.md +13 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/interop.h +191 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/py.Windows.ApplicationModel.DataTransfer.Interop.cpp +142 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/pyproject.toml +54 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/requirements.txt +4 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/setup.cfg +4 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/setup.py +55 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/version.txt +1 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/winrt/_winrt_windows_applicationmodel_datatransfer_interop.pyi +4 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/winrt/windows/applicationmodel/datatransfer/interop/__init__.py +46 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/winrt/windows/applicationmodel/datatransfer/interop/py.typed +0 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/PKG-INFO +39 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/SOURCES.txt +17 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/dependency_links.txt +1 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/requires.txt +2 -0
- winrt_windows_applicationmodel_datatransfer_interop-4.0.0/winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
Copyright (c) 2021-2026 David Lechner <david@pybricks.com>
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: winrt-Windows.ApplicationModel.DataTransfer.Interop
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: Gets the DataTransferManager of a window, and shows the share sheet for it, from its handle.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Documentation, https://pywinrt.readthedocs.io
|
|
7
|
+
Project-URL: Repository, https://github.com/pywinrt/pywinrt
|
|
8
|
+
Project-URL: Changelog, https://github.com/pywinrt/pywinrt/blob/main/interop/winrt-Windows.ApplicationModel.DataTransfer.Interop/CHANGELOG.md
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: winrt-runtime<5,>=4.0.0
|
|
24
|
+
Requires-Dist: winrt-Windows.ApplicationModel.DataTransfer>=4!10.0.28000.2957
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
<!-- warning: Please don't edit this file. It was automatically generated. -->
|
|
28
|
+
|
|
29
|
+
# winrt-Windows.ApplicationModel.DataTransfer.Interop
|
|
30
|
+
|
|
31
|
+
Gets the `DataTransferManager` of a window, and shows the share sheet for it, from its handle.
|
|
32
|
+
|
|
33
|
+
This package provides the `winrt.windows.applicationmodel.datatransfer.interop` module.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
pip install winrt-Windows.ApplicationModel.DataTransfer.Interop
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
installs it with `winrt-Windows.ApplicationModel.DataTransfer`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- warning: Please don't edit this file. It was automatically generated. -->
|
|
2
|
+
|
|
3
|
+
# winrt-Windows.ApplicationModel.DataTransfer.Interop
|
|
4
|
+
|
|
5
|
+
Gets the `DataTransferManager` of a window, and shows the share sheet for it, from its handle.
|
|
6
|
+
|
|
7
|
+
This package provides the `winrt.windows.applicationmodel.datatransfer.interop` module.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
pip install winrt-Windows.ApplicationModel.DataTransfer.Interop
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
installs it with `winrt-Windows.ApplicationModel.DataTransfer`.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// WARNING: Please don't edit this file. It was copied from interop/interop.h
|
|
2
|
+
// by scripts/generate-pyproject.py.
|
|
3
|
+
|
|
4
|
+
// What an interop module needs to exchange WinRT objects and errors with
|
|
5
|
+
// winrt-runtime.
|
|
6
|
+
//
|
|
7
|
+
// An interop module shares no C ABI with the runtime and includes none of its
|
|
8
|
+
// headers. A WinRT object crosses as an interface pointer capsule, which
|
|
9
|
+
// winrt.runtime.interop.as_interface() makes from a projected object and
|
|
10
|
+
// winrt.runtime.interop.wrap_interface() makes a projected object from, and a
|
|
11
|
+
// failed call raises the exception that winrt.runtime.interop.hresult_error()
|
|
12
|
+
// builds. The capsule's name and those three functions are the whole
|
|
13
|
+
// contract, so this header can change freely.
|
|
14
|
+
//
|
|
15
|
+
// scripts/generate-pyproject.py copies this file into each interop package,
|
|
16
|
+
// so that its source distribution builds on its own.
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include <Python.h>
|
|
21
|
+
|
|
22
|
+
#include <windows.h>
|
|
23
|
+
|
|
24
|
+
#include <oleauto.h>
|
|
25
|
+
|
|
26
|
+
#include <cstddef>
|
|
27
|
+
|
|
28
|
+
// The version of the Python C API a module is compiled against: the stable
|
|
29
|
+
// ABI's where it is built for that, and otherwise that of the Python it is
|
|
30
|
+
// built for. Nothing newer is there to call.
|
|
31
|
+
#ifdef Py_LIMITED_API
|
|
32
|
+
#define INTEROP_PY_API_VERSION Py_LIMITED_API
|
|
33
|
+
#else
|
|
34
|
+
#define INTEROP_PY_API_VERSION PY_VERSION_HEX
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
namespace interop
|
|
38
|
+
{
|
|
39
|
+
/// The name every interface pointer capsule carries, in the runtime and in
|
|
40
|
+
/// every interop module alike. One holds a reference to a COM interface,
|
|
41
|
+
/// which its destructor releases.
|
|
42
|
+
inline constexpr char interface_capsule_name[] = "winrt.interface";
|
|
43
|
+
|
|
44
|
+
/// Releases the GIL for as long as it is in scope.
|
|
45
|
+
///
|
|
46
|
+
/// A call into an object in another apartment, or one that sends a window
|
|
47
|
+
/// on another thread a message, waits for that thread, which may itself
|
|
48
|
+
/// be waiting for the GIL to run a Python handler.
|
|
49
|
+
class gil_released
|
|
50
|
+
{
|
|
51
|
+
public:
|
|
52
|
+
gil_released() noexcept : state{PyEval_SaveThread()}
|
|
53
|
+
{
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
gil_released(gil_released const&) = delete;
|
|
57
|
+
gil_released& operator=(gil_released const&) = delete;
|
|
58
|
+
|
|
59
|
+
~gil_released() noexcept
|
|
60
|
+
{
|
|
61
|
+
PyEval_RestoreThread(state);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
PyThreadState* state;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/// The destructor of an interface pointer capsule this module made, which
|
|
69
|
+
/// may hold the last reference to the object.
|
|
70
|
+
inline void release_interface(PyObject* capsule) noexcept
|
|
71
|
+
{
|
|
72
|
+
auto const abi = PyCapsule_GetPointer(capsule, interface_capsule_name);
|
|
73
|
+
if (!abi)
|
|
74
|
+
{
|
|
75
|
+
PyErr_WriteUnraisable(capsule);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
gil_released const guard;
|
|
80
|
+
static_cast<IUnknown*>(abi)->Release();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/// Hands @p abi, and the reference that comes with it, to a new interface
|
|
84
|
+
/// pointer capsule. The reference is released if that fails.
|
|
85
|
+
inline PyObject* new_interface_capsule(IUnknown* abi) noexcept
|
|
86
|
+
{
|
|
87
|
+
auto const capsule
|
|
88
|
+
= PyCapsule_New(abi, interface_capsule_name, release_interface);
|
|
89
|
+
if (!capsule)
|
|
90
|
+
{
|
|
91
|
+
abi->Release();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return capsule;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// Raises what winrt.runtime.interop.hresult_error() makes of @p hr and
|
|
98
|
+
/// @p info, the error info of the call that failed with it, which may be
|
|
99
|
+
/// @c nullptr. The reference to @p info moves in.
|
|
100
|
+
/// @returns nullptr, for the caller to return.
|
|
101
|
+
inline PyObject* set_hresult_error(HRESULT hr, IErrorInfo* info) noexcept
|
|
102
|
+
{
|
|
103
|
+
auto const capsule = info ? new_interface_capsule(info) : Py_NewRef(Py_None);
|
|
104
|
+
if (!capsule)
|
|
105
|
+
{
|
|
106
|
+
return nullptr;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
auto const runtime = PyImport_ImportModule("winrt.runtime.interop");
|
|
110
|
+
if (!runtime)
|
|
111
|
+
{
|
|
112
|
+
Py_DECREF(capsule);
|
|
113
|
+
return nullptr;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
auto const error = PyObject_CallMethod(
|
|
117
|
+
runtime, "hresult_error", "lO", static_cast<long>(hr), capsule);
|
|
118
|
+
Py_DECREF(runtime);
|
|
119
|
+
Py_DECREF(capsule);
|
|
120
|
+
if (!error)
|
|
121
|
+
{
|
|
122
|
+
return nullptr;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
PyErr_SetObject(reinterpret_cast<PyObject*>(Py_TYPE(error)), error);
|
|
126
|
+
Py_DECREF(error);
|
|
127
|
+
|
|
128
|
+
return nullptr;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// Raises what winrt.runtime.interop.hresult_error() makes of @p hr and of
|
|
132
|
+
/// the error info that the call that just failed with it left on this
|
|
133
|
+
/// thread.
|
|
134
|
+
/// @returns nullptr, for the caller to return.
|
|
135
|
+
inline PyObject* set_hresult_error(HRESULT hr) noexcept
|
|
136
|
+
{
|
|
137
|
+
// The error info belongs to the thread and the next failure replaces
|
|
138
|
+
// it, so it is taken before anything else can fail.
|
|
139
|
+
IErrorInfo* info{};
|
|
140
|
+
if (GetErrorInfo(0, &info) != S_OK)
|
|
141
|
+
{
|
|
142
|
+
info = nullptr;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return set_hresult_error(hr, info);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// The @p I interface of what the interface pointer capsule @p capsule
|
|
149
|
+
/// holds, which the caller owns a reference to.
|
|
150
|
+
/// @returns false with a Python exception set when @p capsule is not one
|
|
151
|
+
/// or what it holds does not implement @p I.
|
|
152
|
+
template<typename I>
|
|
153
|
+
bool query_capsule(PyObject* capsule, I** result) noexcept
|
|
154
|
+
{
|
|
155
|
+
auto const abi = PyCapsule_GetPointer(capsule, interface_capsule_name);
|
|
156
|
+
if (!abi)
|
|
157
|
+
{
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
auto const hr = static_cast<IUnknown*>(abi)->QueryInterface(
|
|
162
|
+
__uuidof(I), reinterpret_cast<void**>(result));
|
|
163
|
+
if (FAILED(hr))
|
|
164
|
+
{
|
|
165
|
+
set_hresult_error(hr);
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/// The slots of an interop module that has nothing to set up when it is
|
|
173
|
+
/// executed. It keeps no state, but it exchanges objects and errors with
|
|
174
|
+
/// winrt-runtime, which refuses any interpreter but the main one, so it
|
|
175
|
+
/// says the same where it can. The stable ABI of Python 3.11, which its
|
|
176
|
+
/// wheels are built for, has neither slot: there CPython refuses the
|
|
177
|
+
/// module in an interpreter with a GIL of its own anyway, winrt-runtime
|
|
178
|
+
/// refuses the rest, and a free-threaded build, which is what Py_mod_gil
|
|
179
|
+
/// is for, is never a stable ABI one.
|
|
180
|
+
///
|
|
181
|
+
/// Each slot is looked for by its value: from 3.15 the headers name every
|
|
182
|
+
/// slot whatever the API, but give the values only to an API that has it.
|
|
183
|
+
inline PyModuleDef_Slot module_slots[]{
|
|
184
|
+
#ifdef Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED
|
|
185
|
+
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
|
|
186
|
+
#endif
|
|
187
|
+
#ifdef Py_MOD_GIL_NOT_USED
|
|
188
|
+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
|
|
189
|
+
#endif
|
|
190
|
+
{}};
|
|
191
|
+
} // namespace interop
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#include "interop.h"
|
|
2
|
+
|
|
3
|
+
#if __has_include("shobjidl_core.h")
|
|
4
|
+
#include <shobjidl_core.h>
|
|
5
|
+
#else
|
|
6
|
+
// some environments like MSYS2 don't have this header
|
|
7
|
+
#include <unknwn.h>
|
|
8
|
+
|
|
9
|
+
MIDL_INTERFACE("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")
|
|
10
|
+
IDataTransferManagerInterop : ::IUnknown
|
|
11
|
+
{
|
|
12
|
+
virtual HRESULT STDMETHODCALLTYPE GetForWindow(
|
|
13
|
+
HWND appWindow, REFIID riid, _COM_Outptr_ void** dataTransferManager) noexcept
|
|
14
|
+
= 0;
|
|
15
|
+
|
|
16
|
+
virtual HRESULT STDMETHODCALLTYPE ShowShareUIForWindow(HWND appWindow) noexcept = 0;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
#ifdef __CRT_UUID_DECL
|
|
20
|
+
__CRT_UUID_DECL(
|
|
21
|
+
IDataTransferManagerInterop,
|
|
22
|
+
// clang-format off
|
|
23
|
+
0x3A3DCD6C, 0x3EAB, 0x43DC, 0xBC, 0xDE, 0x45, 0x67, 0x1C, 0xE8, 0x00, 0xC8
|
|
24
|
+
// clang-format on
|
|
25
|
+
);
|
|
26
|
+
#endif
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-idatatransfermanagerinterop
|
|
30
|
+
|
|
31
|
+
namespace
|
|
32
|
+
{
|
|
33
|
+
/// ABI::Windows::ApplicationModel::DataTransfer::IDataTransferManager
|
|
34
|
+
constexpr IID IID_IDataTransferManager{
|
|
35
|
+
0xA5CAEE9B, 0x8708, 0x49D1, {0x8D, 0x36, 0x67, 0xD2, 0x5A, 0x8D, 0xA0, 0x0C}};
|
|
36
|
+
|
|
37
|
+
/// Parses the (factory, hwnd) arguments both functions take.
|
|
38
|
+
bool parse_args(
|
|
39
|
+
PyObject* args, IDataTransferManagerInterop** factory, HWND* hwnd) noexcept
|
|
40
|
+
{
|
|
41
|
+
PyObject* factory_capsule;
|
|
42
|
+
PyObject* hwnd_obj;
|
|
43
|
+
|
|
44
|
+
if (!PyArg_ParseTuple(args, "OO", &factory_capsule, &hwnd_obj))
|
|
45
|
+
{
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
auto const handle = PyLong_AsVoidPtr(hwnd_obj);
|
|
50
|
+
if (!handle && PyErr_Occurred())
|
|
51
|
+
{
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!interop::query_capsule(factory_capsule, factory))
|
|
56
|
+
{
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
*hwnd = static_cast<HWND>(handle);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
PyObject* get_for_window(PyObject* /*unused*/, PyObject* args) noexcept
|
|
65
|
+
{
|
|
66
|
+
IDataTransferManagerInterop* factory{};
|
|
67
|
+
HWND hwnd{};
|
|
68
|
+
if (!parse_args(args, &factory, &hwnd))
|
|
69
|
+
{
|
|
70
|
+
return nullptr;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
IUnknown* manager{};
|
|
74
|
+
HRESULT hr;
|
|
75
|
+
{
|
|
76
|
+
// As for any call that may wait for another thread (see
|
|
77
|
+
// interop::gil_released): the window may belong to one.
|
|
78
|
+
interop::gil_released const guard;
|
|
79
|
+
hr = factory->GetForWindow(
|
|
80
|
+
hwnd, IID_IDataTransferManager, reinterpret_cast<void**>(&manager));
|
|
81
|
+
factory->Release();
|
|
82
|
+
}
|
|
83
|
+
if (FAILED(hr))
|
|
84
|
+
{
|
|
85
|
+
return interop::set_hresult_error(hr);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return interop::new_interface_capsule(manager);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
PyObject* show_share_ui_for_window(PyObject* /*unused*/, PyObject* args) noexcept
|
|
92
|
+
{
|
|
93
|
+
IDataTransferManagerInterop* factory{};
|
|
94
|
+
HWND hwnd{};
|
|
95
|
+
if (!parse_args(args, &factory, &hwnd))
|
|
96
|
+
{
|
|
97
|
+
return nullptr;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
HRESULT hr;
|
|
101
|
+
{
|
|
102
|
+
// The window's DataTransferManager raises DataRequested to fill the
|
|
103
|
+
// sheet, and its handler may be Python.
|
|
104
|
+
interop::gil_released const guard;
|
|
105
|
+
hr = factory->ShowShareUIForWindow(hwnd);
|
|
106
|
+
factory->Release();
|
|
107
|
+
}
|
|
108
|
+
if (FAILED(hr))
|
|
109
|
+
{
|
|
110
|
+
return interop::set_hresult_error(hr);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Py_RETURN_NONE;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
PyMethodDef module_methods[]{
|
|
117
|
+
{"get_for_window", get_for_window, METH_VARARGS, nullptr},
|
|
118
|
+
{"show_share_ui_for_window", show_share_ui_for_window, METH_VARARGS, nullptr},
|
|
119
|
+
{}};
|
|
120
|
+
|
|
121
|
+
PyDoc_STRVAR(
|
|
122
|
+
module_doc,
|
|
123
|
+
"APIs for desktop interop with the Windows.ApplicationModel.DataTransfer "
|
|
124
|
+
"namespace.");
|
|
125
|
+
|
|
126
|
+
PyModuleDef module_def
|
|
127
|
+
= {PyModuleDef_HEAD_INIT,
|
|
128
|
+
"_winrt_windows_applicationmodel_datatransfer_interop",
|
|
129
|
+
module_doc,
|
|
130
|
+
0,
|
|
131
|
+
module_methods,
|
|
132
|
+
interop::module_slots,
|
|
133
|
+
nullptr,
|
|
134
|
+
nullptr,
|
|
135
|
+
nullptr};
|
|
136
|
+
} // namespace
|
|
137
|
+
|
|
138
|
+
PyMODINIT_FUNC PyInit__winrt_windows_applicationmodel_datatransfer_interop(
|
|
139
|
+
void) noexcept
|
|
140
|
+
{
|
|
141
|
+
return PyModuleDef_Init(&module_def);
|
|
142
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# WARNING: Please don't edit this file. It was automatically generated.
|
|
2
|
+
|
|
3
|
+
[build-system]
|
|
4
|
+
requires = ["setuptools>=78"]
|
|
5
|
+
build-backend = "setuptools.build_meta"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "winrt-Windows.ApplicationModel.DataTransfer.Interop"
|
|
9
|
+
description = "Gets the DataTransferManager of a window, and shows the share sheet for it, from its handle."
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Operating System :: Microsoft :: Windows",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Programming Language :: Python :: 3.14",
|
|
20
|
+
"Programming Language :: Python :: 3.15",
|
|
21
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Programming Language :: Python :: Free Threading :: 2 - Beta",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
dynamic = ["version", "dependencies"]
|
|
27
|
+
requires-python = ">=3.11"
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Documentation = "https://pywinrt.readthedocs.io"
|
|
31
|
+
Repository = "https://github.com/pywinrt/pywinrt"
|
|
32
|
+
Changelog = "https://github.com/pywinrt/pywinrt/blob/main/interop/winrt-Windows.ApplicationModel.DataTransfer.Interop/CHANGELOG.md"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.dynamic]
|
|
35
|
+
version = { file = "version.txt" }
|
|
36
|
+
dependencies = { file = "requirements.txt" }
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
include = ["winrt*"]
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.package-data]
|
|
42
|
+
"*" = ["*.pyi", "py.typed"]
|
|
43
|
+
|
|
44
|
+
[tool.cibuildwheel]
|
|
45
|
+
# don't build for PyPy
|
|
46
|
+
skip = "pp*"
|
|
47
|
+
# suppress warnings about ARM64 testing
|
|
48
|
+
test-skip = "*-win_arm64"
|
|
49
|
+
test-command = "python -c \"import winrt._winrt_windows_applicationmodel_datatransfer_interop\""
|
|
50
|
+
|
|
51
|
+
[tool.cibuildwheel.windows]
|
|
52
|
+
archs = ["x86", "AMD64", "ARM64"]
|
|
53
|
+
# nothing here is copied in after the build, so there is no repair step
|
|
54
|
+
repair-wheel-command = ""
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# WARNING: Please don't edit this file. It was automatically generated.
|
|
2
|
+
# setuptools does not annotate the build_ext methods this file overrides.
|
|
3
|
+
# pyright: reportUnknownMemberType=false
|
|
4
|
+
|
|
5
|
+
import sysconfig
|
|
6
|
+
|
|
7
|
+
from setuptools import Extension, setup
|
|
8
|
+
from setuptools.command.build_ext import build_ext
|
|
9
|
+
|
|
10
|
+
INCLUDE_DIRS: list[str] = []
|
|
11
|
+
|
|
12
|
+
# compiled against the stable ABI of Python 3.11, except where the interpreter
|
|
13
|
+
# is free-threaded, which has none, or MSYS2's, whose modules link against the
|
|
14
|
+
# version's own DLL
|
|
15
|
+
STABLE_ABI = not (
|
|
16
|
+
sysconfig.get_config_var("Py_GIL_DISABLED")
|
|
17
|
+
or sysconfig.get_platform().startswith("mingw")
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class build_ext_ex(build_ext):
|
|
22
|
+
def build_extension(self, ext: Extension) -> None:
|
|
23
|
+
# nothing in the projection uses dynamic_cast or typeid, so disabling
|
|
24
|
+
# RTTI costs nothing and makes the module about 15% smaller
|
|
25
|
+
if self.compiler.compiler_type == "msvc":
|
|
26
|
+
ext.extra_compile_args = ["/std:c++20", "/permissive-", "/GR-"]
|
|
27
|
+
elif self.compiler.compiler_type == "mingw32":
|
|
28
|
+
ext.extra_compile_args = [
|
|
29
|
+
"-std=c++20",
|
|
30
|
+
"-fno-rtti",
|
|
31
|
+
"-D_WIN32_WINNT=_WIN32_WINNT_WIN10",
|
|
32
|
+
]
|
|
33
|
+
# GCC 15 complains about some things that it didn't in the past
|
|
34
|
+
ext.extra_compile_args += ["-Wno-strict-aliasing", "-Wno-template-body"]
|
|
35
|
+
ext.extra_link_args = ["-loleaut32"]
|
|
36
|
+
else:
|
|
37
|
+
raise ValueError(f"Unsupported compiler: {self.compiler.compiler_type}")
|
|
38
|
+
|
|
39
|
+
build_ext.build_extension(self, ext)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
setup(
|
|
43
|
+
cmdclass={"build_ext": build_ext_ex},
|
|
44
|
+
ext_modules=[
|
|
45
|
+
Extension(
|
|
46
|
+
"winrt._winrt_windows_applicationmodel_datatransfer_interop",
|
|
47
|
+
sources=["py.Windows.ApplicationModel.DataTransfer.Interop.cpp"],
|
|
48
|
+
include_dirs=INCLUDE_DIRS,
|
|
49
|
+
libraries=["windowsapp"],
|
|
50
|
+
define_macros=[("Py_LIMITED_API", "0x030B0000")] if STABLE_ABI else [],
|
|
51
|
+
py_limited_api=STABLE_ABI,
|
|
52
|
+
)
|
|
53
|
+
],
|
|
54
|
+
options={"bdist_wheel": {"py_limited_api": "cp311"}} if STABLE_ABI else {},
|
|
55
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.0.0
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from uuid import UUID
|
|
2
|
+
|
|
3
|
+
import winrt.runtime.interop as _runtime
|
|
4
|
+
import winrt._winrt_windows_applicationmodel_datatransfer_interop as _native
|
|
5
|
+
from winrt.windows.applicationmodel.datatransfer import DataTransferManager
|
|
6
|
+
|
|
7
|
+
__all__ = ["get_for_window", "show_share_ui_for_window"]
|
|
8
|
+
|
|
9
|
+
# what DataTransferManager's activation factory implements for desktop apps
|
|
10
|
+
_IID_IDATATRANSFERMANAGERINTEROP = UUID("3a3dcd6c-3eab-43dc-bcde-45671ce800c8")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _factory() -> _runtime.InterfaceCapsule:
|
|
14
|
+
return _runtime.get_activation_factory(
|
|
15
|
+
DataTransferManager, _IID_IDATATRANSFERMANAGERINTEROP
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_for_window(hwnd: int, /) -> DataTransferManager:
|
|
20
|
+
"""
|
|
21
|
+
Gets the DataTransferManager of a window, whose data_requested event asks
|
|
22
|
+
for what to share when the share sheet is shown for the window.
|
|
23
|
+
|
|
24
|
+
A packaged app calls DataTransferManager.get_for_current_view(); a desktop
|
|
25
|
+
app, which has no view, calls this with its window.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
hwnd (HWND): The window whose DataTransferManager to get.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
The DataTransferManager of the window.
|
|
32
|
+
"""
|
|
33
|
+
return _runtime.wrap_interface(
|
|
34
|
+
_native.get_for_window(_factory(), hwnd), DataTransferManager
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def show_share_ui_for_window(hwnd: int, /) -> None:
|
|
39
|
+
"""
|
|
40
|
+
Shows the share sheet for a window. The window's DataTransferManager (see
|
|
41
|
+
get_for_window()) raises data_requested, whose handler fills in what to share.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
hwnd (HWND): The window to show the share sheet for.
|
|
45
|
+
"""
|
|
46
|
+
_native.show_share_ui_for_window(_factory(), hwnd)
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: winrt-Windows.ApplicationModel.DataTransfer.Interop
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: Gets the DataTransferManager of a window, and shows the share sheet for it, from its handle.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Documentation, https://pywinrt.readthedocs.io
|
|
7
|
+
Project-URL: Repository, https://github.com/pywinrt/pywinrt
|
|
8
|
+
Project-URL: Changelog, https://github.com/pywinrt/pywinrt/blob/main/interop/winrt-Windows.ApplicationModel.DataTransfer.Interop/CHANGELOG.md
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: winrt-runtime<5,>=4.0.0
|
|
24
|
+
Requires-Dist: winrt-Windows.ApplicationModel.DataTransfer>=4!10.0.28000.2957
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
<!-- warning: Please don't edit this file. It was automatically generated. -->
|
|
28
|
+
|
|
29
|
+
# winrt-Windows.ApplicationModel.DataTransfer.Interop
|
|
30
|
+
|
|
31
|
+
Gets the `DataTransferManager` of a window, and shows the share sheet for it, from its handle.
|
|
32
|
+
|
|
33
|
+
This package provides the `winrt.windows.applicationmodel.datatransfer.interop` module.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
pip install winrt-Windows.ApplicationModel.DataTransfer.Interop
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
installs it with `winrt-Windows.ApplicationModel.DataTransfer`.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
interop.h
|
|
5
|
+
py.Windows.ApplicationModel.DataTransfer.Interop.cpp
|
|
6
|
+
pyproject.toml
|
|
7
|
+
requirements.txt
|
|
8
|
+
setup.py
|
|
9
|
+
version.txt
|
|
10
|
+
winrt/_winrt_windows_applicationmodel_datatransfer_interop.pyi
|
|
11
|
+
winrt/windows/applicationmodel/datatransfer/interop/__init__.py
|
|
12
|
+
winrt/windows/applicationmodel/datatransfer/interop/py.typed
|
|
13
|
+
winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/PKG-INFO
|
|
14
|
+
winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/SOURCES.txt
|
|
15
|
+
winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/dependency_links.txt
|
|
16
|
+
winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/requires.txt
|
|
17
|
+
winrt_Windows.ApplicationModel.DataTransfer.Interop.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|