[wayland] Add a SurfaceInterface to Toplevel
Adds the SurfaceInterface identified by the surface id we get from Xwayland. This allows in an easier way to map a Toplevel to a Wayland surface and will also be useful for Wayland clients.icc-effect-5.14.5
parent
e463905f04
commit
07c972b6d4
|
@ -66,6 +66,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "killwindow.h"
|
#include "killwindow.h"
|
||||||
#include "x11eventfilter.h"
|
#include "x11eventfilter.h"
|
||||||
|
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
#include <KWayland/Server/surface_interface.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef XCB_GE_GENERIC
|
#ifndef XCB_GE_GENERIC
|
||||||
#define XCB_GE_GENERIC 35
|
#define XCB_GE_GENERIC 35
|
||||||
typedef struct xcb_ge_generic_event_t {
|
typedef struct xcb_ge_generic_event_t {
|
||||||
|
@ -1693,6 +1697,9 @@ void Toplevel::clientMessageEvent(xcb_client_message_event_t *e)
|
||||||
{
|
{
|
||||||
if (e->type == atoms->wl_surface_id) {
|
if (e->type == atoms->wl_surface_id) {
|
||||||
m_surfaceId = e->data.data32[0];
|
m_surfaceId = e->data.data32[0];
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
m_surface = KWayland::Server::SurfaceInterface::get(m_surfaceId);
|
||||||
|
#endif
|
||||||
emit surfaceIdChanged(m_surfaceId);
|
emit surfaceIdChanged(m_surfaceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
29
toplevel.h
29
toplevel.h
|
@ -41,6 +41,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// c++
|
// c++
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
namespace KWayland
|
||||||
|
{
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
class SurfaceInterface;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -344,6 +354,10 @@ public:
|
||||||
void setSkipCloseAnimation(bool set);
|
void setSkipCloseAnimation(bool set);
|
||||||
|
|
||||||
quint32 surfaceId() const;
|
quint32 surfaceId() const;
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
KWayland::Server::SurfaceInterface *surface() const;
|
||||||
|
void setSurface(KWayland::Server::SurfaceInterface *surface);
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual void sendPointerMoveEvent(const QPointF &globalPos);
|
virtual void sendPointerMoveEvent(const QPointF &globalPos);
|
||||||
virtual void sendPointerEnterEvent(const QPointF &globalPos);
|
virtual void sendPointerEnterEvent(const QPointF &globalPos);
|
||||||
|
@ -482,6 +496,9 @@ private:
|
||||||
int m_screen;
|
int m_screen;
|
||||||
bool m_skipCloseAnimation;
|
bool m_skipCloseAnimation;
|
||||||
quint32 m_surfaceId = 0;
|
quint32 m_surfaceId = 0;
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
KWayland::Server::SurfaceInterface *m_surface = nullptr;
|
||||||
|
#endif
|
||||||
// when adding new data members, check also copyToDeleted()
|
// when adding new data members, check also copyToDeleted()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -718,6 +735,18 @@ inline quint32 Toplevel::surfaceId() const
|
||||||
return m_surfaceId;
|
return m_surfaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
inline KWayland::Server::SurfaceInterface *Toplevel::surface() const
|
||||||
|
{
|
||||||
|
return m_surface;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Toplevel::setSurface(KWayland::Server::SurfaceInterface *surface)
|
||||||
|
{
|
||||||
|
m_surface = surface;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class T, class U>
|
template <class T, class U>
|
||||||
inline T *Toplevel::findInList(const QList<T*> &list, std::function<bool (const U*)> func)
|
inline T *Toplevel::findInList(const QList<T*> &list, std::function<bool (const U*)> func)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
|
#include "toplevel.h"
|
||||||
|
#include "workspace.h"
|
||||||
|
|
||||||
#include <KWayland/Server/compositor_interface.h>
|
#include <KWayland/Server/compositor_interface.h>
|
||||||
#include <KWayland/Server/display.h>
|
#include <KWayland/Server/display.h>
|
||||||
|
@ -47,6 +49,22 @@ void WaylandServer::init(const QByteArray &socketName)
|
||||||
m_display->start();
|
m_display->start();
|
||||||
m_compositor = m_display->createCompositor(m_display);
|
m_compositor = m_display->createCompositor(m_display);
|
||||||
m_compositor->create();
|
m_compositor->create();
|
||||||
|
connect(m_compositor, &CompositorInterface::surfaceCreated, this,
|
||||||
|
[this] (SurfaceInterface *surface) {
|
||||||
|
// check whether we have a Toplevel with the Surface's id
|
||||||
|
Workspace *ws = Workspace::self();
|
||||||
|
if (!ws) {
|
||||||
|
// it's possible that a Surface gets created before Workspace is created
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto check = [surface] (const Toplevel *t) {
|
||||||
|
return t->surfaceId() == surface->id();
|
||||||
|
};
|
||||||
|
if (Toplevel *t = ws->findToplevel(check)) {
|
||||||
|
t->setSurface(surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
m_shell = m_display->createShell(m_display);
|
m_shell = m_display->createShell(m_display);
|
||||||
m_shell->create();
|
m_shell->create();
|
||||||
m_display->createShm();
|
m_display->createShm();
|
||||||
|
|
Loading…
Reference in New Issue