Changeset View
Changeset View
Standalone View
Standalone View
plugins/qpa/window.cpp
Show All 11 Lines | |||||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #define WL_EGL_PLATFORM 1 | | |||
21 | #include "integration.h" | 20 | #include "integration.h" | ||
22 | #include "window.h" | 21 | #include "window.h" | ||
23 | #include "screens.h" | 22 | #include "screens.h" | ||
24 | #include "../../shell_client.h" | 23 | #include "../../shell_client.h" | ||
25 | #include "../../wayland_server.h" | 24 | #include "../../wayland_server.h" | ||
26 | #include <logging.h> | 25 | #include <logging.h> | ||
27 | 26 | | |||
28 | #include <QOpenGLFramebufferObject> | 27 | #include <QOpenGLFramebufferObject> | ||
Show All 23 Lines | 48 | { | |||
52 | QObject::connect(m_surface, &QObject::destroyed, window, [this] { m_surface = nullptr;}); | 51 | QObject::connect(m_surface, &QObject::destroyed, window, [this] { m_surface = nullptr;}); | ||
53 | QObject::connect(m_shellSurface, &QObject::destroyed, window, [this] { m_shellSurface = nullptr;}); | 52 | QObject::connect(m_shellSurface, &QObject::destroyed, window, [this] { m_shellSurface = nullptr;}); | ||
54 | waylandServer()->internalClientConection()->flush(); | 53 | waylandServer()->internalClientConection()->flush(); | ||
55 | } | 54 | } | ||
56 | 55 | | |||
57 | Window::~Window() | 56 | Window::~Window() | ||
58 | { | 57 | { | ||
59 | unmap(); | 58 | unmap(); | ||
60 | if (m_eglSurface != EGL_NO_SURFACE) { | | |||
61 | eglDestroySurface(m_integration->eglDisplay(), m_eglSurface); | | |||
62 | } | | |||
63 | #if HAVE_WAYLAND_EGL | | |||
64 | if (m_eglWaylandWindow) { | | |||
65 | wl_egl_window_destroy(m_eglWaylandWindow); | | |||
66 | } | | |||
67 | #endif | | |||
68 | delete m_shellSurface; | 59 | delete m_shellSurface; | ||
69 | delete m_surface; | 60 | delete m_surface; | ||
70 | } | 61 | } | ||
71 | 62 | | |||
72 | WId Window::winId() const | 63 | WId Window::winId() const | ||
73 | { | 64 | { | ||
74 | return m_windowId; | 65 | return m_windowId; | ||
75 | } | 66 | } | ||
Show All 25 Lines | 77 | { | |||
101 | 92 | | |||
102 | const QSize nativeSize = rect.size() * m_scale; | 93 | const QSize nativeSize = rect.size() * m_scale; | ||
103 | 94 | | |||
104 | if (m_contentFBO) { | 95 | if (m_contentFBO) { | ||
105 | if (m_contentFBO->size() != nativeSize) { | 96 | if (m_contentFBO->size() != nativeSize) { | ||
106 | m_resized = true; | 97 | m_resized = true; | ||
107 | } | 98 | } | ||
108 | } | 99 | } | ||
109 | #if HAVE_WAYLAND_EGL | | |||
110 | if (m_eglWaylandWindow) { | | |||
111 | wl_egl_window_resize(m_eglWaylandWindow, nativeSize.width(), nativeSize.height(), 0, 0); | | |||
112 | } | | |||
113 | #endif | | |||
114 | QWindowSystemInterface::handleGeometryChange(window(), geometry()); | 100 | QWindowSystemInterface::handleGeometryChange(window(), geometry()); | ||
115 | } | 101 | } | ||
116 | 102 | | |||
117 | void Window::unmap() | 103 | void Window::unmap() | ||
118 | { | 104 | { | ||
119 | if (m_shellClient) { | 105 | if (m_shellClient) { | ||
120 | m_shellClient->setInternalFramebufferObject(QSharedPointer<QOpenGLFramebufferObject>()); | 106 | m_shellClient->setInternalFramebufferObject(QSharedPointer<QOpenGLFramebufferObject>()); | ||
121 | } | 107 | } | ||
122 | if (m_surface) { | 108 | if (m_surface) { | ||
123 | m_surface->attachBuffer(KWayland::Client::Buffer::Ptr()); | 109 | m_surface->attachBuffer(KWayland::Client::Buffer::Ptr()); | ||
124 | m_surface->commit(KWayland::Client::Surface::CommitFlag::None); | 110 | m_surface->commit(KWayland::Client::Surface::CommitFlag::None); | ||
125 | } | 111 | } | ||
126 | if (waylandServer()->internalClientConection()) { | 112 | if (waylandServer()->internalClientConection()) { | ||
127 | waylandServer()->internalClientConection()->flush(); | 113 | waylandServer()->internalClientConection()->flush(); | ||
128 | } | 114 | } | ||
129 | } | 115 | } | ||
130 | 116 | | |||
131 | void Window::createEglSurface(EGLDisplay dpy, EGLConfig config) | | |||
132 | { | | |||
133 | #if HAVE_WAYLAND_EGL | | |||
134 | const QSize size = window()->size() * m_scale; | | |||
135 | m_eglWaylandWindow = wl_egl_window_create(*m_surface, size.width(), size.height()); | | |||
136 | if (!m_eglWaylandWindow) { | | |||
137 | return; | | |||
138 | } | | |||
139 | m_eglSurface = eglCreateWindowSurface(dpy, config, m_eglWaylandWindow, nullptr); | | |||
140 | #else | | |||
141 | Q_UNUSED(dpy) | | |||
142 | Q_UNUSED(config) | | |||
143 | #endif | | |||
144 | } | | |||
145 | | ||||
146 | void Window::bindContentFBO() | 117 | void Window::bindContentFBO() | ||
147 | { | 118 | { | ||
148 | if (m_resized || !m_contentFBO) { | 119 | if (m_resized || !m_contentFBO) { | ||
149 | createFBO(); | 120 | createFBO(); | ||
150 | } | 121 | } | ||
151 | m_contentFBO->bind(); | 122 | m_contentFBO->bind(); | ||
152 | } | 123 | } | ||
153 | 124 | | |||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |