Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandivishellintegration.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 ITAGE Corporation, author: <yusuke.binsaki@itage.co.jp>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtCore/qsize.h>
7#include <QtCore/qdebug.h>
8
9#include <QtWaylandClient/private/qwaylanddisplay_p.h>
10#include <QtWaylandClient/private/qwaylandwindow_p.h>
11#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
12
14
15#include <mutex>
16
17#include <unistd.h>
18
19QT_BEGIN_NAMESPACE
20
21namespace QtWaylandClient {
22
25{
26public:
28 void initialize() { QWaylandClientExtensionTemplate::initialize(); }
29};
30
35
42
43/* get unique id
44 * pattern1:
45 * When set QT_IVI_SURFACE_ID, We use it as ID.
46 * Next ID is increment.
47 * pattern2:
48 * When not set QT_IVI_SURFACE_ID, We use process ID and unused bit.
49 * process ID maximum is 2^22. Unused bit is 23 to 32 bit.
50 * Therefor, We use 23 to 32 bit. This do not overlap with other clients.
51 * Next ID is increment of 23 to 32 bit.
52 * +------------+---------------------------+
53 * |31 23|22 0|
54 * +------------+---------------------------+
55 * |0000 0000 00|00 0000 0000 0000 0000 0000|
56 * |<- ID ->|<- process ID ->|
57 * +------------+---------------------------+
58 */
60{
61 const uint32_t PID_MAX_EXPONENTIATION = 22; // 22 bit shift operation
62 const uint32_t ID_LIMIT = 1 << (32 - PID_MAX_EXPONENTIATION); // 10 bit is unique id
64
65 if (m_lastSurfaceId == 0) {
66 QByteArray env = qgetenv("QT_IVI_SURFACE_ID");
67 bool ok;
69 if (ok)
70 m_useEnvSurfaceId = true;
71 else
73
74 return m_lastSurfaceId;
75 }
76
79 } else {
82 qWarning("IVI surface id counter overflow\n");
83 return 0;
84 }
86 }
87
88 return m_lastSurfaceId;
89}
90
124
125}
126
127QT_END_NAMESPACE