KWin
Loading...
Searching...
No Matches
xdgshellintegration.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
8#include "wayland/display.h"
9#include "wayland/xdgshell.h"
10#include "wayland_server.h"
11#include "workspace.h"
12#include "xdgshellwindow.h"
13
14namespace KWin
15{
16
31 , m_shell(new XdgShellInterface(waylandServer()->display(), this))
32{
33 connect(m_shell, &XdgShellInterface::toplevelCreated,
34 this, &XdgShellIntegration::registerXdgToplevel);
35 connect(m_shell, &XdgShellInterface::popupCreated,
36 this, &XdgShellIntegration::registerXdgPopup);
37}
38
39std::chrono::milliseconds XdgShellIntegration::pingTimeout() const
40{
41 return m_shell->pingTimeoutInterval();
42}
43
44void XdgShellIntegration::setPingTimeout(std::chrono::milliseconds pingTimeout)
45{
47}
48
49void XdgShellIntegration::registerXdgToplevel(XdgToplevelInterface *toplevel)
50{
51 // Note that the window is going to be destroyed and immediately re-created when the
52 // underlying surface is unmapped. XdgToplevelWindow is re-created right away since
53 // we don't want too loose any window requests that are allowed to be sent prior to
54 // the first initial commit, e.g. set_maximized or set_fullscreen.
55 connect(toplevel, &XdgToplevelInterface::resetOccurred,
56 this, [this, toplevel] {
57 createXdgToplevelWindow(toplevel);
58 });
59
60 createXdgToplevelWindow(toplevel);
61}
62
63void XdgShellIntegration::createXdgToplevelWindow(XdgToplevelInterface *toplevel)
64{
65 if (!workspace()) {
66 qCWarning(KWIN_CORE, "An xdg-toplevel surface has been created while the compositor "
67 "is still not fully initialized. That is a compositor bug!");
68 return;
69 }
70
71 Q_EMIT windowCreated(new XdgToplevelWindow(toplevel));
72}
73
74void XdgShellIntegration::registerXdgPopup(XdgPopupInterface *popup)
75{
76 if (!workspace()) {
77 qCWarning(KWIN_CORE, "An xdg-popup surface has been created while the compositor is "
78 "still not fully initialized. That is a compositor bug!");
79 return;
80 }
81
82 Q_EMIT windowCreated(new XdgPopupWindow(popup));
83}
84
85} // namespace KWin
86
87#include "moc_xdgshellintegration.cpp"
void windowCreated(Window *window)
void setPingTimeout(std::chrono::milliseconds pingTimeout)
std::chrono::milliseconds pingTimeout() const
XdgShellIntegration(QObject *parent=nullptr)
void setPingTimeoutInterval(std::chrono::milliseconds pingTimeout)
Definition xdgshell.cpp:143
void toplevelCreated(XdgToplevelInterface *toplevel)
void popupCreated(XdgPopupInterface *popup)
std::chrono::milliseconds pingTimeoutInterval() const
Definition xdgshell.cpp:138
WaylandServer * waylandServer()
Workspace * workspace()
Definition workspace.h:830