appwindows 1.0.5__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.
- appwindows-1.0.5/.clang-format +1 -0
- appwindows-1.0.5/.gitignore +5 -0
- appwindows-1.0.5/LICENSE.md +28 -0
- appwindows-1.0.5/PKG-INFO +46 -0
- appwindows-1.0.5/README.md +27 -0
- appwindows-1.0.5/__init__.py +3 -0
- appwindows-1.0.5/appwindows.svg +6 -0
- appwindows-1.0.5/meson.build +126 -0
- appwindows-1.0.5/pyproject.toml +38 -0
- appwindows-1.0.5/src/appwindows/appwindows.cc +22 -0
- appwindows-1.0.5/src/appwindows/core/bind.cc +103 -0
- appwindows-1.0.5/src/appwindows/core/bind.h +14 -0
- appwindows-1.0.5/src/appwindows/core/exceptions/exceptions.cc +11 -0
- appwindows-1.0.5/src/appwindows/core/exceptions/invalid_size.h +19 -0
- appwindows-1.0.5/src/appwindows/core/exceptions/window_does_not_exist.h +17 -0
- appwindows-1.0.5/src/appwindows/core/finder.h +24 -0
- appwindows-1.0.5/src/appwindows/core/geometry/geometry.cc +43 -0
- appwindows-1.0.5/src/appwindows/core/geometry/point.cc +34 -0
- appwindows-1.0.5/src/appwindows/core/geometry/point.h +22 -0
- appwindows-1.0.5/src/appwindows/core/geometry/size.cc +14 -0
- appwindows-1.0.5/src/appwindows/core/geometry/size.h +18 -0
- appwindows-1.0.5/src/appwindows/core/platform.cc +20 -0
- appwindows-1.0.5/src/appwindows/core/platform.h +11 -0
- appwindows-1.0.5/src/appwindows/core/window.h +35 -0
- appwindows-1.0.5/src/appwindows/wayland/finder.cc +0 -0
- appwindows-1.0.5/src/appwindows/wayland/finder.h +0 -0
- appwindows-1.0.5/src/appwindows/wayland/window.getters.cc +0 -0
- appwindows-1.0.5/src/appwindows/wayland/window.h +0 -0
- appwindows-1.0.5/src/appwindows/wayland/window.setters.cc +0 -0
- appwindows-1.0.5/src/appwindows/windows/finder.cc +41 -0
- appwindows-1.0.5/src/appwindows/windows/finder.h +22 -0
- appwindows-1.0.5/src/appwindows/windows/window.getters.cc +94 -0
- appwindows-1.0.5/src/appwindows/windows/window.h +36 -0
- appwindows-1.0.5/src/appwindows/windows/window.setters.cc +66 -0
- appwindows-1.0.5/src/appwindows/x_server/finder.cc +74 -0
- appwindows-1.0.5/src/appwindows/x_server/finder.h +27 -0
- appwindows-1.0.5/src/appwindows/x_server/window.getters.cc +80 -0
- appwindows-1.0.5/src/appwindows/x_server/window.h +38 -0
- appwindows-1.0.5/src/appwindows/x_server/window.setters.cc +123 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
BasedOnStyle: Google
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Terochkin A.S
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
* Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: appwindows
|
|
3
|
+
Version: 1.0.5
|
|
4
|
+
Summary: The appwindows library solves the problem of working with a graphical shell on different operating systems.
|
|
5
|
+
Author-Email: "Terochkin A.S" <apparser.development@gmail.com>
|
|
6
|
+
License-File: LICENSE.md
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
12
|
+
Classifier: Environment :: X11 Applications
|
|
13
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
14
|
+
Project-URL: Repository, https://github.com/lexter0705/appwindows
|
|
15
|
+
Project-URL: Issues, https://github.com/lexter0705/appwindows/issues
|
|
16
|
+
Requires-Python: >=3.7
|
|
17
|
+
Requires-Dist: numpy>=2.0
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
<img src="https://raw.githubusercontent.com/lexter0705/appwindows/refs/heads/master/appwindows.svg" alt="" width="40%" >
|
|
21
|
+
|
|
22
|
+
# Appwindows
|
|
23
|
+
The appwindows library solves the problem of working with a graphical shell on different operating systems.
|
|
24
|
+
# Install
|
|
25
|
+
On windows:
|
|
26
|
+
```bash
|
|
27
|
+
pip install appwindows
|
|
28
|
+
```
|
|
29
|
+
On linux xorg:
|
|
30
|
+
```bash
|
|
31
|
+
sudo apt install libx11-dev pkg-config
|
|
32
|
+
pip install appwindows
|
|
33
|
+
```
|
|
34
|
+
# Supported platforms:
|
|
35
|
+
1) Windows
|
|
36
|
+
2) Linux with X Server
|
|
37
|
+
# Docs
|
|
38
|
+
All documentation <a href="#">here</a>
|
|
39
|
+
# For Developers
|
|
40
|
+
1) If something doesn't work - open issue.
|
|
41
|
+
2) If you want something fixed - open issue.
|
|
42
|
+
3) If you can help with the library - email.
|
|
43
|
+
|
|
44
|
+
apparser.development@gmail.com
|
|
45
|
+
|
|
46
|
+
Any help in development is welcome)!
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<img src="https://raw.githubusercontent.com/lexter0705/appwindows/refs/heads/master/appwindows.svg" alt="" width="40%" >
|
|
2
|
+
|
|
3
|
+
# Appwindows
|
|
4
|
+
The appwindows library solves the problem of working with a graphical shell on different operating systems.
|
|
5
|
+
# Install
|
|
6
|
+
On windows:
|
|
7
|
+
```bash
|
|
8
|
+
pip install appwindows
|
|
9
|
+
```
|
|
10
|
+
On linux xorg:
|
|
11
|
+
```bash
|
|
12
|
+
sudo apt install libx11-dev pkg-config
|
|
13
|
+
pip install appwindows
|
|
14
|
+
```
|
|
15
|
+
# Supported platforms:
|
|
16
|
+
1) Windows
|
|
17
|
+
2) Linux with X Server
|
|
18
|
+
# Docs
|
|
19
|
+
All documentation <a href="#">here</a>
|
|
20
|
+
# For Developers
|
|
21
|
+
1) If something doesn't work - open issue.
|
|
22
|
+
2) If you want something fixed - open issue.
|
|
23
|
+
3) If you can help with the library - email.
|
|
24
|
+
|
|
25
|
+
apparser.development@gmail.com
|
|
26
|
+
|
|
27
|
+
Any help in development is welcome)!
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="512" height="512" rx="45" fill="#595783"/>
|
|
3
|
+
<rect x="128.849" y="94" width="324" height="258" rx="13" fill="white" fill-opacity="0.7"/>
|
|
4
|
+
<rect x="93.8491" y="127" width="324" height="258" rx="13" fill="white" fill-opacity="0.7"/>
|
|
5
|
+
<rect x="59" y="160" width="324" height="258" rx="13" fill="white" fill-opacity="0.7"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
project('appwindows', 'cpp',
|
|
2
|
+
license : 'BSD 3-Clause License',
|
|
3
|
+
meson_version : '>=0.56.0',
|
|
4
|
+
default_options : [
|
|
5
|
+
'cpp_std=c++17',
|
|
6
|
+
'buildtype=release',
|
|
7
|
+
'default_library=shared',
|
|
8
|
+
'b_ndebug=if-release',
|
|
9
|
+
]
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
pybind11_dep = dependency('pybind11', required : true)
|
|
13
|
+
python_dep = dependency('python3', required : true)
|
|
14
|
+
|
|
15
|
+
py3 = import('python').find_installation('python3', pure : false)
|
|
16
|
+
|
|
17
|
+
python_install_dir = py3.get_install_dir()
|
|
18
|
+
|
|
19
|
+
appwindows_inc = include_directories('src/appwindows',
|
|
20
|
+
'src/appwindows/core')
|
|
21
|
+
geometry_inc = include_directories('src/appwindows/core/geometry')
|
|
22
|
+
exceptions_inc = include_directories('src/appwindows/core/exceptions')
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
appwindows_sources = files(
|
|
26
|
+
'src/appwindows/appwindows.cc',
|
|
27
|
+
'src/appwindows/core/bind.cc',
|
|
28
|
+
'src/appwindows/core/platform.cc',
|
|
29
|
+
'src/appwindows/core/geometry/size.cc',
|
|
30
|
+
'src/appwindows/core/geometry/point.cc',
|
|
31
|
+
)
|
|
32
|
+
geometry_sources = files(
|
|
33
|
+
'src/appwindows/core/geometry/point.cc',
|
|
34
|
+
'src/appwindows/core/geometry/size.cc',
|
|
35
|
+
'src/appwindows/core/geometry/geometry.cc'
|
|
36
|
+
)
|
|
37
|
+
exceptions_sources = files('src/appwindows/core/exceptions/exceptions.cc')
|
|
38
|
+
|
|
39
|
+
platform_deps = []
|
|
40
|
+
platform_args = []
|
|
41
|
+
|
|
42
|
+
if host_machine.system() == 'windows'
|
|
43
|
+
appwindows_sources += files(
|
|
44
|
+
'src/appwindows/windows/window.getters.cc',
|
|
45
|
+
'src/appwindows/windows/window.setters.cc',
|
|
46
|
+
'src/appwindows/windows/finder.cc'
|
|
47
|
+
)
|
|
48
|
+
appwindows_inc = [appwindows_inc, include_directories('src/appwindows/windows')]
|
|
49
|
+
platform_args = ['-DWINDOWS_USED=1']
|
|
50
|
+
|
|
51
|
+
elif host_machine.system() == 'linux'
|
|
52
|
+
xdg_session_type = run_command('sh', '-c', 'loginctl show-session $(loginctl | grep $(whoami) | awk "{print $1}") -p Type', check: false)
|
|
53
|
+
session_type = xdg_session_type.stdout().strip()
|
|
54
|
+
message('!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
55
|
+
message(session_type)
|
|
56
|
+
message('!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
57
|
+
if session_type == 'Type=wayland'
|
|
58
|
+
wayland_dep = dependency('wayland-client', required : true)
|
|
59
|
+
wayland_dep.found()
|
|
60
|
+
appwindows_sources += files(
|
|
61
|
+
'src/appwindows/wayland/window.getters.cc',
|
|
62
|
+
'src/appwindows/wayland/window.setters.cc',
|
|
63
|
+
'src/appwindows/wayland/finder.cc'
|
|
64
|
+
)
|
|
65
|
+
appwindows_inc = [appwindows_inc, include_directories('src/appwindows/wayland')]
|
|
66
|
+
platform_deps += wayland_dep
|
|
67
|
+
platform_args += ['-DWAYLAND_USED=1']
|
|
68
|
+
elif session_type == 'Type=x11'
|
|
69
|
+
x11_dep = dependency('x11', required : true)
|
|
70
|
+
xext_dep = dependency('xext', required : false)
|
|
71
|
+
xfixes_dep = dependency('xfixes', required : false)
|
|
72
|
+
xinerama_dep = dependency('xinerama', required : false)
|
|
73
|
+
x11_dep.found()
|
|
74
|
+
xext_dep.found()
|
|
75
|
+
xfixes_dep.found()
|
|
76
|
+
xinerama_dep.found()
|
|
77
|
+
appwindows_sources += files(
|
|
78
|
+
'src/appwindows/x_server/window.getters.cc',
|
|
79
|
+
'src/appwindows/x_server/window.setters.cc',
|
|
80
|
+
'src/appwindows/x_server/finder.cc'
|
|
81
|
+
)
|
|
82
|
+
appwindows_inc = [appwindows_inc, include_directories('src/appwindows/x_server')]
|
|
83
|
+
platform_deps += [x11_dep, xext_dep, xfixes_dep, xinerama_dep]
|
|
84
|
+
platform_args += ['-DX_SERVER_USED=1']
|
|
85
|
+
else
|
|
86
|
+
warning('Neither Wayland nor X11 found, building without platform-specific features')
|
|
87
|
+
endif
|
|
88
|
+
|
|
89
|
+
else
|
|
90
|
+
error('Unsupported platform: ' + host_machine.system())
|
|
91
|
+
endif
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
appwindows_mod = py3.extension_module('appwindows',
|
|
96
|
+
sources : appwindows_sources,
|
|
97
|
+
dependencies : [pybind11_dep, platform_deps],
|
|
98
|
+
include_directories : [appwindows_inc, exceptions_inc, geometry_inc],
|
|
99
|
+
install : true,
|
|
100
|
+
cpp_args : platform_args,
|
|
101
|
+
subdir : 'appwindows')
|
|
102
|
+
|
|
103
|
+
geometry_mod = py3.extension_module('geometry',
|
|
104
|
+
sources : geometry_sources,
|
|
105
|
+
dependencies : [pybind11_dep],
|
|
106
|
+
include_directories : geometry_inc,
|
|
107
|
+
install : true,
|
|
108
|
+
subdir : 'appwindows')
|
|
109
|
+
|
|
110
|
+
exceptions_mod = py3.extension_module('exceptions',
|
|
111
|
+
sources : exceptions_sources,
|
|
112
|
+
dependencies : [pybind11_dep],
|
|
113
|
+
include_directories : exceptions_inc,
|
|
114
|
+
install : true,
|
|
115
|
+
subdir : 'appwindows')
|
|
116
|
+
|
|
117
|
+
configure_file(
|
|
118
|
+
input : '__init__.py',
|
|
119
|
+
output : '__init__.py',
|
|
120
|
+
copy : true
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
install_data(
|
|
124
|
+
'__init__.py',
|
|
125
|
+
install_dir : python_install_dir / 'appwindows'
|
|
126
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"meson-python>=0.10",
|
|
4
|
+
"pybind11>=2.10.0"
|
|
5
|
+
]
|
|
6
|
+
build-backend = "mesonpy"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
dependencies = ["numpy >= 2.0"]
|
|
10
|
+
name = "appwindows"
|
|
11
|
+
version = "1.0.5"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Terochkin A.S", email = "apparser.development@gmail.com" },
|
|
14
|
+
]
|
|
15
|
+
description = "The appwindows library solves the problem of working with a graphical shell on different operating systems."
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
requires-python = ">=3.7"
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"License :: OSI Approved :: BSD License",
|
|
21
|
+
"Operating System :: Microsoft :: Windows :: Windows 10",
|
|
22
|
+
"Operating System :: Microsoft :: Windows :: Windows 11",
|
|
23
|
+
"Operating System :: POSIX :: Linux",
|
|
24
|
+
"Environment :: X11 Applications",
|
|
25
|
+
"Environment :: Win32 (MS Windows)"
|
|
26
|
+
]
|
|
27
|
+
license-files = ["LICENSE.md"]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Repository = "https://github.com/lexter0705/appwindows"
|
|
31
|
+
Issues = "https://github.com/lexter0705/appwindows/issues"
|
|
32
|
+
|
|
33
|
+
[tool.mesonpy]
|
|
34
|
+
machine-file = false
|
|
35
|
+
|
|
36
|
+
[tool.mesonpy.args]
|
|
37
|
+
buildtype = "release"
|
|
38
|
+
default-library = "shared"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#include <pybind11/pybind11.h>
|
|
2
|
+
#include <pybind11/stl.h>
|
|
3
|
+
|
|
4
|
+
#include "./core/bind.h"
|
|
5
|
+
#include "./core/platform.h"
|
|
6
|
+
|
|
7
|
+
namespace py = pybind11;
|
|
8
|
+
|
|
9
|
+
PYBIND11_MODULE(appwindows, m) {
|
|
10
|
+
m.doc() =
|
|
11
|
+
"Python bindings for appwindows library\n\n"
|
|
12
|
+
"The appwindows library solves the problem of working with a graphical "
|
|
13
|
+
"shell on different operating systems.";
|
|
14
|
+
|
|
15
|
+
appwindows::core::bind_window(m);
|
|
16
|
+
appwindows::core::bind_finder(m);
|
|
17
|
+
|
|
18
|
+
m.def("get_finder", &appwindows::get_finder,
|
|
19
|
+
"Get the window finder instance\n\n"
|
|
20
|
+
"Returns:\n"
|
|
21
|
+
" Finder: Instance of window finder interface");
|
|
22
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#include "bind.h"
|
|
2
|
+
|
|
3
|
+
#include <pybind11/numpy.h>
|
|
4
|
+
#include <pybind11/pybind11.h>
|
|
5
|
+
#include <pybind11/stl.h>
|
|
6
|
+
|
|
7
|
+
#include "finder.h"
|
|
8
|
+
#include "window.h"
|
|
9
|
+
|
|
10
|
+
namespace py = pybind11;
|
|
11
|
+
|
|
12
|
+
namespace appwindows {
|
|
13
|
+
namespace core {
|
|
14
|
+
|
|
15
|
+
void bind_window(py::module &m) {
|
|
16
|
+
py::class_<Window, std::shared_ptr<Window>>(
|
|
17
|
+
m, "Window", "Interface representing an application window")
|
|
18
|
+
.def(
|
|
19
|
+
"get_points",
|
|
20
|
+
[](Window &self) {
|
|
21
|
+
auto points = self.get_points();
|
|
22
|
+
return points ? *points : std::vector<Point>{};
|
|
23
|
+
},
|
|
24
|
+
"Get all points associated with the window\n"
|
|
25
|
+
""
|
|
26
|
+
"Returns:\n"
|
|
27
|
+
" list[Point]: List of points")
|
|
28
|
+
.def(
|
|
29
|
+
"get_title",
|
|
30
|
+
[](const Window &self) {
|
|
31
|
+
const auto title = self.get_title();
|
|
32
|
+
return title ? *title : std::string{};
|
|
33
|
+
},
|
|
34
|
+
"Get the window title\n\n"
|
|
35
|
+
"Returns:\n"
|
|
36
|
+
" str: Window title")
|
|
37
|
+
.def(
|
|
38
|
+
"get_size",
|
|
39
|
+
[](const Window &self) {
|
|
40
|
+
auto size = self.get_size();
|
|
41
|
+
return size ? *size : Size{0, 0};
|
|
42
|
+
},
|
|
43
|
+
"Get current window size\n\n"
|
|
44
|
+
"Returns:\n"
|
|
45
|
+
" Size: Current window dimensions")
|
|
46
|
+
.def(
|
|
47
|
+
"get_screenshot",
|
|
48
|
+
[](const Window &self) { return self.get_screenshot(); },
|
|
49
|
+
"Get current window image\n\n"
|
|
50
|
+
"Returns:\n"
|
|
51
|
+
" ndarray: image in ndarray")
|
|
52
|
+
.def("to_foreground", &Window::to_foreground, "Moved window to forground")
|
|
53
|
+
.def("to_background", &Window::to_background,
|
|
54
|
+
"Moved window to background")
|
|
55
|
+
.def("set_minimize", &Window::set_minimize,
|
|
56
|
+
"Set window active state\n\n"
|
|
57
|
+
"Args:\n"
|
|
58
|
+
" active (bool): True to activate window",
|
|
59
|
+
py::arg("active"))
|
|
60
|
+
.def("set_fullscreen", &Window::set_fullscreen,
|
|
61
|
+
"Maximize or restore the window\n\n"
|
|
62
|
+
"Args:\n"
|
|
63
|
+
" is_maximize (bool): True to maximize window",
|
|
64
|
+
py::arg("is_maximize"))
|
|
65
|
+
.def("resize", &Window::resize,
|
|
66
|
+
"Resize the window\n\n"
|
|
67
|
+
"Args:\n"
|
|
68
|
+
" size (appwindows.geometry.Size): New window dimensions\n\n"
|
|
69
|
+
"Raises:\n"
|
|
70
|
+
" InvalidSizeError: If size is invalid",
|
|
71
|
+
py::arg("size"))
|
|
72
|
+
.def("move", &Window::move,
|
|
73
|
+
"Move window to specified position\n\n"
|
|
74
|
+
"Args:\n"
|
|
75
|
+
" point (appwindows.geometry.Point): New window position",
|
|
76
|
+
py::arg("point"))
|
|
77
|
+
.def("close", &Window::close, "Close the window");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void bind_finder(py::module &m) {
|
|
81
|
+
py::class_<Finder, std::shared_ptr<Finder>>(
|
|
82
|
+
m, "Finder", "Interface for finding application windows")
|
|
83
|
+
.def(
|
|
84
|
+
"get_window_by_title",
|
|
85
|
+
[](const Finder &self, const std::string &title) {
|
|
86
|
+
return self.get_window_by_title(title);
|
|
87
|
+
},
|
|
88
|
+
"Find window by its title\n\n"
|
|
89
|
+
"Args:\n"
|
|
90
|
+
" title (str): Window title to search for\n\n"
|
|
91
|
+
"Returns:\n"
|
|
92
|
+
" Window | None: Found window or null if window does not exist",
|
|
93
|
+
py::arg("title"))
|
|
94
|
+
.def(
|
|
95
|
+
"get_all_windows",
|
|
96
|
+
[](const Finder &self) { return self.get_all_windows(); },
|
|
97
|
+
"Find all opened windows\n\n"
|
|
98
|
+
"Returns:\n"
|
|
99
|
+
" list[Window]: Found windows\n\n");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
} // namespace core
|
|
103
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <pybind11/pybind11.h>
|
|
4
|
+
|
|
5
|
+
namespace py = pybind11;
|
|
6
|
+
|
|
7
|
+
namespace appwindows {
|
|
8
|
+
namespace core {
|
|
9
|
+
|
|
10
|
+
void bind_window(py::module &m);
|
|
11
|
+
void bind_finder(py::module &m);
|
|
12
|
+
|
|
13
|
+
} // namespace windows
|
|
14
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#include <pybind11/pybind11.h>
|
|
2
|
+
|
|
3
|
+
#include "invalid_size.h"
|
|
4
|
+
#include "window_does_not_exist.h"
|
|
5
|
+
|
|
6
|
+
namespace py = pybind11;
|
|
7
|
+
|
|
8
|
+
PYBIND11_MODULE(exceptions, m) {
|
|
9
|
+
py::register_exception<appwindows::core::exceptions::InvalidSizeException>(m, "InvalidSizeException");
|
|
10
|
+
py::register_exception<appwindows::core::exceptions::WindowDoesNotExistException>(m, "WindowDoesNotExistException");
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
namespace appwindows {
|
|
7
|
+
namespace core {
|
|
8
|
+
namespace exceptions {
|
|
9
|
+
|
|
10
|
+
class InvalidSizeException final : public std::invalid_argument {
|
|
11
|
+
public:
|
|
12
|
+
explicit InvalidSizeException(const int width, const int height)
|
|
13
|
+
: invalid_argument("Invalid width(" + std::to_string(width) +
|
|
14
|
+
") or height(" + std::to_string(height) + ")") {}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
} // namespace exceptions
|
|
18
|
+
} // namespace core
|
|
19
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
|
|
5
|
+
namespace appwindows {
|
|
6
|
+
namespace core {
|
|
7
|
+
namespace exceptions {
|
|
8
|
+
|
|
9
|
+
class WindowDoesNotExistException final : public std::runtime_error {
|
|
10
|
+
public:
|
|
11
|
+
explicit WindowDoesNotExistException()
|
|
12
|
+
: runtime_error("Window does not exist") {}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
} // namespace exceptions
|
|
16
|
+
} // namespace core
|
|
17
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
#include "window.h"
|
|
7
|
+
|
|
8
|
+
namespace appwindows {
|
|
9
|
+
namespace core {
|
|
10
|
+
|
|
11
|
+
class Finder {
|
|
12
|
+
public:
|
|
13
|
+
virtual ~Finder() = default;
|
|
14
|
+
[[nodiscard]]
|
|
15
|
+
virtual std::shared_ptr<Window> get_window_by_title(
|
|
16
|
+
std::string title) const = 0;
|
|
17
|
+
[[nodiscard]]
|
|
18
|
+
virtual std::vector<std::shared_ptr<Window>>
|
|
19
|
+
get_all_windows() const = 0;
|
|
20
|
+
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
} // namespace core
|
|
24
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#include <pybind11/pybind11.h>
|
|
2
|
+
|
|
3
|
+
#include "point.h"
|
|
4
|
+
#include "size.h"
|
|
5
|
+
|
|
6
|
+
namespace py = pybind11;
|
|
7
|
+
|
|
8
|
+
PYBIND11_MODULE(geometry, m) {
|
|
9
|
+
py::class_<appwindows::core::Point>(
|
|
10
|
+
m, "Point", "Represents a 2D point with x and y coordinates")
|
|
11
|
+
.def(py::init<int, int>(),
|
|
12
|
+
"Create a point with specified coordinates\n\n"
|
|
13
|
+
"Args:\n"
|
|
14
|
+
" x (int): X coordinate\n"
|
|
15
|
+
" y (int): Y coordinate",
|
|
16
|
+
py::arg("x"), py::arg("y"))
|
|
17
|
+
.def("__add__", &appwindows::core::Point::operator+, "Add two points")
|
|
18
|
+
.def("__sub__", &appwindows::core::Point::operator-,
|
|
19
|
+
"Subtract two points")
|
|
20
|
+
.def("__mul__", &appwindows::core::Point::operator*,
|
|
21
|
+
"Multiply two points")
|
|
22
|
+
.def("__truediv__", &appwindows::core::Point::operator/,
|
|
23
|
+
"Divide two points")
|
|
24
|
+
.def_property_readonly("x", &appwindows::core::Point::get_x,
|
|
25
|
+
"X coordinate")
|
|
26
|
+
.def_property_readonly("y", &appwindows::core::Point::get_y,
|
|
27
|
+
"Y coordinate");
|
|
28
|
+
|
|
29
|
+
py::class_<appwindows::core::Size>(
|
|
30
|
+
m, "Size", "Represents dimensions with width and height")
|
|
31
|
+
.def(py::init<int, int>(),
|
|
32
|
+
"Create size with specified dimensions\n\n"
|
|
33
|
+
"Args:\n"
|
|
34
|
+
" width (int): Width dimension\n"
|
|
35
|
+
" height (int): Height dimension\n\n"
|
|
36
|
+
"Raises:\n"
|
|
37
|
+
" InvalidSizeError: If width or height are invalid",
|
|
38
|
+
py::arg("width"), py::arg("height"))
|
|
39
|
+
.def_property_readonly("width", &appwindows::core::Size::get_width,
|
|
40
|
+
"Width dimension")
|
|
41
|
+
.def_property_readonly("height", &appwindows::core::Size::get_height,
|
|
42
|
+
"Height dimension");
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include "point.h"
|
|
2
|
+
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
|
|
5
|
+
namespace appwindows {
|
|
6
|
+
namespace core {
|
|
7
|
+
|
|
8
|
+
Point::Point(const int x, const int y) : x_(x), y_(y) {}
|
|
9
|
+
|
|
10
|
+
Point Point::operator+(const Point& other) const{
|
|
11
|
+
return Point{x_ + other.get_x(), y_ + other.get_y()};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Point Point::operator-(const Point& other) const{
|
|
15
|
+
return Point{x_ - other.get_x(), y_ - other.get_y()};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Point Point::operator/(const Point& other) const {
|
|
19
|
+
if (other.get_x() == 0 || other.get_y() == 0) {
|
|
20
|
+
throw std::invalid_argument("Division by zero in Point coordinates");
|
|
21
|
+
}
|
|
22
|
+
return Point{x_ / other.get_x(), y_ / other.get_y()};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Point Point::operator*(const Point& other) const{
|
|
26
|
+
return Point{x_ * other.get_x(), y_ * other.get_y()};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
int Point::get_x() const { return x_; }
|
|
30
|
+
|
|
31
|
+
int Point::get_y() const { return y_; }
|
|
32
|
+
|
|
33
|
+
} // namespace core
|
|
34
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
namespace appwindows {
|
|
4
|
+
namespace core {
|
|
5
|
+
|
|
6
|
+
class Point {
|
|
7
|
+
public:
|
|
8
|
+
Point(int x, int y);
|
|
9
|
+
Point operator+(const Point& other) const;
|
|
10
|
+
Point operator-(const Point& other) const;
|
|
11
|
+
Point operator*(const Point& other) const;
|
|
12
|
+
Point operator/(const Point& other) const;
|
|
13
|
+
[[nodiscard]] int get_x() const;
|
|
14
|
+
[[nodiscard]] int get_y() const;
|
|
15
|
+
|
|
16
|
+
private:
|
|
17
|
+
int x_;
|
|
18
|
+
int y_;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
} // namespace core
|
|
22
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#include "size.h"
|
|
2
|
+
|
|
3
|
+
#include "../exceptions/invalid_size.h"
|
|
4
|
+
|
|
5
|
+
namespace appwindows {
|
|
6
|
+
namespace core {
|
|
7
|
+
|
|
8
|
+
Size::Size(const int width, const int height) : width_(width), height_(height) {
|
|
9
|
+
if (width <= 0) throw exceptions::InvalidSizeException(width, height);
|
|
10
|
+
if (height <= 0) throw exceptions::InvalidSizeException(width, height);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
} // namespace core
|
|
14
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
namespace appwindows {
|
|
4
|
+
namespace core {
|
|
5
|
+
|
|
6
|
+
class Size {
|
|
7
|
+
public:
|
|
8
|
+
Size(int width, int height);
|
|
9
|
+
[[nodiscard]] int get_width() const noexcept { return width_; };
|
|
10
|
+
[[nodiscard]] int get_height() const noexcept { return height_; };
|
|
11
|
+
|
|
12
|
+
private:
|
|
13
|
+
int width_;
|
|
14
|
+
int height_;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
} // namespace core
|
|
18
|
+
} // namespace appwindows
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include "platform.h"
|
|
2
|
+
|
|
3
|
+
#ifdef WINDOWS_USED
|
|
4
|
+
#include "../windows/finder.h"
|
|
5
|
+
#elif X_SERVER_USED
|
|
6
|
+
#include "../x_server/finder.h"
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
namespace appwindows {
|
|
10
|
+
std::shared_ptr<core::Finder> get_finder() {
|
|
11
|
+
#ifdef WINDOWS_USED
|
|
12
|
+
return std::make_shared<windows::FinderWindows>();
|
|
13
|
+
#elif X_SERVER_USED
|
|
14
|
+
return std::make_shared<x_server::FinderXServer>();
|
|
15
|
+
#else
|
|
16
|
+
#error "Unsoported platform"
|
|
17
|
+
#endif
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
} // namespace appwindows
|