View difference between Paste ID: 5dVRCD1m and yck4ijXd
SHOW: | | - or go back to the newest paste.
1
int main(int argc, char *argv[])
2
{
3
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
4
	QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
5
#endif
6
7
	QGuiApplication app(argc, argv);
8
	QmlCBridge c_app;
9
10
	QQmlApplicationEngine engine;
11
	const QUrl url(QStringLiteral("qrc:/main.qml"));
12
	QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
13
					 &app, [url](QObject *obj, const QUrl &objUrl) {
14
		if (!obj && url == objUrl)
15
			QCoreApplication::exit(-1);
16
	}, Qt::QueuedConnection);
17
	engine.load(url);
18
19
	QQmlContext *root = engine.rootContext();
20
	root->setContextProperty("app", &c_app);
21
22
	QObject *component = engine.rootObjects().first();
23
	c_app.setComponent(component);
24
25
	WId window = qobject_cast<QWindow*>(component)->winId();
26
	Display *display = QX11Info::display();
27
28
	// make window visible on all desktops
29
	unsigned long data = 0xffffffff; // all desktop
30
	XChangeProperty (display, window,
31
					 XInternAtom(display, "_NET_WM_DESKTOP", False),
32
					 XA_CARDINAL,
33
					 32,
34
					 PropModeReplace,
35
					 reinterpret_cast<unsigned char *>(&data),
36
					 1);
37
38
	// make window pass-through
39
	XRectangle rect;
40
	XserverRegion region = XFixesCreateRegion(display, &rect, 1);
41
	XFixesSetWindowShapeRegion(display, window, ShapeInput, 0, 0, region);
42
	XFixesSetWindowShapeRegion (display, window, ShapeBounding, 0, 0, 0);
43
	XFixesDestroyRegion(display, region);
44
45
	XMapWindow(display, window);
46
	XFlush(display);
47
48
	int status = app.exec();
49
	return status;
50
}
51