From 1b39d072c2601d39354fe83dff8b1e5c05095aaf Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 5 Feb 2013 12:22:17 +0100 Subject: Qt-ify the QtCompositor module Currently the QtCompositor library and API do not follow the Qt API naming conventions. This commit intends to fix these inconsistencies. filenames start with q headers containing private API's end in _p public API classes begin with Q use the qt namespace macros where necessary Wayland namespace is now QtWayland wayland_wrapper classes are now private API's It's important to make these changes not just for stylistic reasons, but also because when qmake builds the module in checks for these conventions to determine how to deploy the include files. Change-Id: I8bfadeceda92a0f52cb73c704551da75540e7587 Reviewed-by: Paul Olav Tvete --- examples/qml-compositor/main.cpp | 34 +- examples/qwidget-compositor/main.cpp | 56 +- examples/qwindow-compositor/qwindowcompositor.cpp | 62 +- examples/qwindow-compositor/qwindowcompositor.h | 28 +- src/compositor/compositor.pri | 15 - src/compositor/compositor.pro | 21 +- src/compositor/compositor_api/compositor_api.pri | 29 +- .../compositor_api/qwaylandcompositor.cpp | 271 +++++++++ src/compositor/compositor_api/qwaylandcompositor.h | 135 +++++ src/compositor/compositor_api/qwaylandinput.cpp | 162 +++++ src/compositor/compositor_api/qwaylandinput.h | 99 ++++ src/compositor/compositor_api/qwaylandsurface.cpp | 346 +++++++++++ src/compositor/compositor_api/qwaylandsurface.h | 179 ++++++ .../compositor_api/qwaylandsurfaceitem.cpp | 437 ++++++++++++++ .../compositor_api/qwaylandsurfaceitem.h | 151 +++++ .../compositor_api/qwaylandsurfacenode.cpp | 151 +++++ .../compositor_api/qwaylandsurfacenode_p.h | 92 +++ .../qwaylandsurfacetexturematerial.cpp | 122 ++++ .../qwaylandsurfacetexturematerial_p.h | 91 +++ .../compositor_api/waylandcompositor.cpp | 267 --------- src/compositor/compositor_api/waylandcompositor.h | 131 ----- src/compositor/compositor_api/waylandinput.cpp | 160 ----- src/compositor/compositor_api/waylandinput.h | 95 --- src/compositor/compositor_api/waylandsurface.cpp | 342 ----------- src/compositor/compositor_api/waylandsurface.h | 175 ------ .../compositor_api/waylandsurfaceitem.cpp | 434 -------------- src/compositor/compositor_api/waylandsurfaceitem.h | 147 ----- .../compositor_api/waylandsurfacenode.cpp | 147 ----- src/compositor/compositor_api/waylandsurfacenode.h | 88 --- .../waylandsurfacetexturematerial.cpp | 118 ---- .../compositor_api/waylandsurfacetexturematerial.h | 87 --- src/compositor/global/global.pri | 10 +- src/compositor/global/qwaylandexport.h | 60 ++ src/compositor/global/qwaylandobject.h | 99 ++++ .../global/qwaylandresourcecollection.cpp | 93 +++ src/compositor/global/qwaylandresourcecollection.h | 71 +++ src/compositor/global/waylandexport.h | 56 -- src/compositor/global/waylandobject.h | 94 --- .../global/waylandresourcecollection.cpp | 90 --- src/compositor/global/waylandresourcecollection.h | 65 --- .../graphicshardwareintegration.cpp | 46 -- .../graphicshardwareintegration.h | 76 --- .../graphicshardwareintegrationfactory.cpp | 92 --- .../graphicshardwareintegrationfactory.h | 57 -- .../graphicshardwareintegrationplugin.cpp | 52 -- .../graphicshardwareintegrationplugin.h | 64 -- .../hardware_integration/hardware_integration.pri | 17 +- .../qwaylandgraphicshardwareintegration.cpp | 50 ++ .../qwaylandgraphicshardwareintegration.h | 83 +++ .../qwaylandgraphicshardwareintegrationfactory.cpp | 96 +++ .../qwaylandgraphicshardwareintegrationfactory.h | 61 ++ .../qwaylandgraphicshardwareintegrationplugin.cpp | 55 ++ .../qwaylandgraphicshardwareintegrationplugin.h | 68 +++ src/compositor/wayland_wrapper/qwlcompositor.cpp | 573 ++++++++++++++++++ src/compositor/wayland_wrapper/qwlcompositor_p.h | 219 +++++++ src/compositor/wayland_wrapper/qwldatadevice.cpp | 131 +++++ src/compositor/wayland_wrapper/qwldatadevice_p.h | 86 +++ .../wayland_wrapper/qwldatadevicemanager.cpp | 308 ++++++++++ .../wayland_wrapper/qwldatadevicemanager_p.h | 132 +++++ src/compositor/wayland_wrapper/qwldataoffer.cpp | 120 ++++ src/compositor/wayland_wrapper/qwldataoffer_p.h | 81 +++ src/compositor/wayland_wrapper/qwldatasource.cpp | 136 +++++ src/compositor/wayland_wrapper/qwldatasource_p.h | 94 +++ src/compositor/wayland_wrapper/qwldisplay.cpp | 65 +++ src/compositor/wayland_wrapper/qwldisplay_p.h | 68 +++ .../wayland_wrapper/qwlextendedoutput.cpp | 151 +++++ .../wayland_wrapper/qwlextendedoutput_p.h | 102 ++++ .../wayland_wrapper/qwlextendedsurface.cpp | 202 +++++++ .../wayland_wrapper/qwlextendedsurface_p.h | 138 +++++ src/compositor/wayland_wrapper/qwlinputdevice.cpp | 650 +++++++++++++++++++++ src/compositor/wayland_wrapper/qwlinputdevice_p.h | 166 ++++++ src/compositor/wayland_wrapper/qwloutput.cpp | 128 ++++ src/compositor/wayland_wrapper/qwloutput_p.h | 108 ++++ src/compositor/wayland_wrapper/qwlqtkey.cpp | 117 ++++ src/compositor/wayland_wrapper/qwlqtkey_p.h | 80 +++ src/compositor/wayland_wrapper/qwlregion.cpp | 92 +++ src/compositor/wayland_wrapper/qwlregion_p.h | 84 +++ src/compositor/wayland_wrapper/qwlshellsurface.cpp | 477 +++++++++++++++ src/compositor/wayland_wrapper/qwlshellsurface_p.h | 202 +++++++ src/compositor/wayland_wrapper/qwlsubsurface.cpp | 190 ++++++ src/compositor/wayland_wrapper/qwlsubsurface_p.h | 133 +++++ src/compositor/wayland_wrapper/qwlsurface.cpp | 525 +++++++++++++++++ src/compositor/wayland_wrapper/qwlsurface_p.h | 206 +++++++ .../wayland_wrapper/qwlsurfacebuffer.cpp | 259 ++++++++ .../wayland_wrapper/qwlsurfacebuffer_p.h | 146 +++++ src/compositor/wayland_wrapper/qwltouch.cpp | 180 ++++++ src/compositor/wayland_wrapper/qwltouch_p.h | 85 +++ src/compositor/wayland_wrapper/wayland_wrapper.pri | 85 ++- src/compositor/wayland_wrapper/wlcompositor.cpp | 561 ------------------ src/compositor/wayland_wrapper/wlcompositor.h | 215 ------- src/compositor/wayland_wrapper/wldatadevice.cpp | 127 ---- src/compositor/wayland_wrapper/wldatadevice.h | 82 --- .../wayland_wrapper/wldatadevicemanager.cpp | 304 ---------- .../wayland_wrapper/wldatadevicemanager.h | 127 ---- src/compositor/wayland_wrapper/wldataoffer.cpp | 117 ---- src/compositor/wayland_wrapper/wldataoffer.h | 78 --- src/compositor/wayland_wrapper/wldatasource.cpp | 132 ----- src/compositor/wayland_wrapper/wldatasource.h | 90 --- src/compositor/wayland_wrapper/wldisplay.cpp | 62 -- src/compositor/wayland_wrapper/wldisplay.h | 63 -- .../wayland_wrapper/wlextendedoutput.cpp | 148 ----- src/compositor/wayland_wrapper/wlextendedoutput.h | 96 --- .../wayland_wrapper/wlextendedsurface.cpp | 198 ------- src/compositor/wayland_wrapper/wlextendedsurface.h | 134 ----- src/compositor/wayland_wrapper/wlinputdevice.cpp | 646 -------------------- src/compositor/wayland_wrapper/wlinputdevice.h | 162 ----- src/compositor/wayland_wrapper/wloutput.cpp | 124 ---- src/compositor/wayland_wrapper/wloutput.h | 104 ---- src/compositor/wayland_wrapper/wlqtkey.cpp | 113 ---- src/compositor/wayland_wrapper/wlqtkey.h | 76 --- src/compositor/wayland_wrapper/wlregion.cpp | 90 --- src/compositor/wayland_wrapper/wlregion.h | 80 --- src/compositor/wayland_wrapper/wlshellsurface.cpp | 473 --------------- src/compositor/wayland_wrapper/wlshellsurface.h | 200 ------- src/compositor/wayland_wrapper/wlsubsurface.cpp | 186 ------ src/compositor/wayland_wrapper/wlsubsurface.h | 130 ----- src/compositor/wayland_wrapper/wlsurface.cpp | 522 ----------------- src/compositor/wayland_wrapper/wlsurface.h | 202 ------- src/compositor/wayland_wrapper/wlsurfacebuffer.cpp | 255 -------- src/compositor/wayland_wrapper/wlsurfacebuffer.h | 142 ----- src/compositor/wayland_wrapper/wltouch.cpp | 176 ------ src/compositor/wayland_wrapper/wltouch.h | 81 --- .../waylandwindowmanagerintegration.cpp | 14 +- .../waylandwindowmanagerintegration.h | 20 +- .../windowmanagerprotocol.pri | 6 +- .../qwaylandbrcmeglintegration.cpp | 2 + .../qwayland-brcm-egl/qwaylandbrcmeglintegration.h | 6 + .../qwayland-brcm-egl/qwaylandbrcmeglwindow.cpp | 2 + .../qwayland-brcm-egl/qwaylandbrcmeglwindow.h | 4 + .../qwayland-brcm-egl/qwaylandbrcmglcontext.cpp | 2 + .../qwayland-brcm-egl/qwaylandbrcmglcontext.h | 3 + .../qwayland-egl/qwaylandegldecoration.cpp | 2 + .../platforms/qwayland-egl/qwaylandegldecoration.h | 4 + .../qwayland-egl/qwaylandeglintegration.cpp | 2 + .../qwayland-egl/qwaylandeglintegration.h | 4 + .../platforms/qwayland-egl/qwaylandeglwindow.cpp | 2 + .../platforms/qwayland-egl/qwaylandeglwindow.h | 4 + .../platforms/qwayland-egl/qwaylandglcontext.cpp | 2 + .../platforms/qwayland-egl/qwaylandglcontext.h | 3 + .../qwaylandxcompositeeglcontext.cpp | 2 + .../qwaylandxcompositeeglcontext.h | 4 + .../qwaylandxcompositeeglintegration.cpp | 2 + .../qwaylandxcompositeeglintegration.h | 4 + .../qwaylandxcompositeeglwindow.cpp | 2 + .../qwaylandxcompositeeglwindow.h | 4 + .../qwaylandxcompositeglxcontext.cpp | 2 + .../qwaylandxcompositeglxcontext.h | 4 + .../qwaylandxcompositeglxintegration.cpp | 2 + .../qwaylandxcompositeglxintegration.h | 4 + .../qwaylandxcompositeglxwindow.cpp | 2 + .../qwaylandxcompositeglxwindow.h | 4 + .../platforms/wayland_common/qwaylandbuffer.h | 4 + .../platforms/wayland_common/qwaylandclipboard.cpp | 2 + .../platforms/wayland_common/qwaylandclipboard.h | 4 + .../platforms/wayland_common/qwaylandcursor.cpp | 2 + .../platforms/wayland_common/qwaylandcursor.h | 4 + .../wayland_common/qwaylanddatadevicemanager.cpp | 2 + .../wayland_common/qwaylanddatadevicemanager.h | 4 + .../platforms/wayland_common/qwaylanddataoffer.cpp | 1 + .../platforms/wayland_common/qwaylanddataoffer.h | 7 +- .../wayland_common/qwaylanddatasource.cpp | 2 + .../platforms/wayland_common/qwaylanddatasource.h | 4 + .../wayland_common/qwaylanddecoration.cpp | 2 + .../platforms/wayland_common/qwaylanddecoration.h | 4 + .../platforms/wayland_common/qwaylanddisplay.cpp | 2 + .../platforms/wayland_common/qwaylanddisplay.h | 4 + .../platforms/wayland_common/qwaylanddnd.cpp | 2 + src/plugins/platforms/wayland_common/qwaylanddnd.h | 4 + .../wayland_common/qwaylandextendedoutput.cpp | 2 + .../wayland_common/qwaylandextendedoutput.h | 3 + .../wayland_common/qwaylandextendedsurface.cpp | 2 + .../wayland_common/qwaylandextendedsurface.h | 4 + .../wayland_common/qwaylandglintegration.cpp | 2 + .../wayland_common/qwaylandglintegration.h | 6 + .../wayland_common/qwaylandinputdevice.cpp | 2 + .../wayland_common/qwaylandintegration.cpp | 2 + .../wayland_common/qwaylandnativeinterface.cpp | 2 + .../wayland_common/qwaylandnativeinterface.h | 3 + .../platforms/wayland_common/qwaylandqtkey.cpp | 2 + .../platforms/wayland_common/qwaylandqtkey.h | 5 + .../platforms/wayland_common/qwaylandscreen.cpp | 2 + .../platforms/wayland_common/qwaylandscreen.h | 4 + .../platforms/wayland_common/qwaylandshell.cpp | 2 + .../platforms/wayland_common/qwaylandshell.h | 4 + .../wayland_common/qwaylandshellsurface.cpp | 2 + .../wayland_common/qwaylandshellsurface.h | 4 + .../wayland_common/qwaylandshmdecoration.cpp | 2 + .../wayland_common/qwaylandshmdecoration.h | 4 + .../platforms/wayland_common/qwaylandshmwindow.cpp | 2 + .../platforms/wayland_common/qwaylandshmwindow.h | 4 + .../wayland_common/qwaylandsubsurface.cpp | 2 + .../platforms/wayland_common/qwaylandsubsurface.h | 10 +- .../platforms/wayland_common/qwaylandtouch.cpp | 2 + .../platforms/wayland_common/qwaylandtouch.h | 4 + .../platforms/wayland_common/qwaylandwindow.cpp | 2 + .../platforms/wayland_common/qwaylandwindow.h | 7 +- .../qwaylandwindowmanagerintegration.cpp | 2 + .../qwaylandwindowmanagerintegration.h | 4 + .../xcomposite_share/qwaylandxcompositebuffer.cpp | 2 + .../xcomposite_share/qwaylandxcompositebuffer.h | 4 + .../waylandcompositors/brcm-egl/brcm-egl.pro | 2 +- .../waylandcompositors/brcm-egl/brcmbuffer.cpp | 4 +- .../waylandcompositors/brcm-egl/brcmbuffer.h | 12 +- .../brcm-egl/brcmeglintegration.cpp | 14 +- .../brcm-egl/brcmeglintegration.h | 10 +- src/plugins/waylandcompositors/brcm-egl/main.cpp | 14 +- .../waylandcompositors/wayland-egl/main.cpp | 14 +- .../waylandcompositors/wayland-egl/wayland-egl.pro | 2 +- .../wayland-egl/waylandeglintegration.cpp | 14 +- .../wayland-egl/waylandeglintegration.h | 12 +- .../waylandcompositors/xcomposite-egl/main.cpp | 14 +- .../xcomposite-egl/xcomposite-egl.pro | 2 +- .../xcomposite-egl/xcompositeeglintegration.cpp | 14 +- .../xcomposite-egl/xcompositeeglintegration.h | 10 +- .../waylandcompositors/xcomposite-glx/main.cpp | 14 +- .../xcomposite-glx/xcomposite-glx.pro | 2 +- .../xcomposite-glx/xcompositeglxintegration.cpp | 14 +- .../xcomposite-glx/xcompositeglxintegration.h | 10 +- .../xcomposite_share/xcompositebuffer.cpp | 4 +- .../xcomposite_share/xcompositebuffer.h | 12 +- .../xcomposite_share/xcompositehandler.cpp | 4 +- .../xcomposite_share/xcompositehandler.h | 14 +- src/shared/qwaylandmimehelper.cpp | 2 + src/shared/qwaylandmimehelper.h | 4 + tests/auto/compositor/testcompositor.cpp | 4 +- tests/auto/compositor/testcompositor.h | 12 +- tests/auto/compositor/tst_compositor.cpp | 12 +- 227 files changed, 9992 insertions(+), 9472 deletions(-) delete mode 100644 src/compositor/compositor.pri create mode 100644 src/compositor/compositor_api/qwaylandcompositor.cpp create mode 100644 src/compositor/compositor_api/qwaylandcompositor.h create mode 100644 src/compositor/compositor_api/qwaylandinput.cpp create mode 100644 src/compositor/compositor_api/qwaylandinput.h create mode 100644 src/compositor/compositor_api/qwaylandsurface.cpp create mode 100644 src/compositor/compositor_api/qwaylandsurface.h create mode 100644 src/compositor/compositor_api/qwaylandsurfaceitem.cpp create mode 100644 src/compositor/compositor_api/qwaylandsurfaceitem.h create mode 100644 src/compositor/compositor_api/qwaylandsurfacenode.cpp create mode 100644 src/compositor/compositor_api/qwaylandsurfacenode_p.h create mode 100644 src/compositor/compositor_api/qwaylandsurfacetexturematerial.cpp create mode 100644 src/compositor/compositor_api/qwaylandsurfacetexturematerial_p.h delete mode 100644 src/compositor/compositor_api/waylandcompositor.cpp delete mode 100644 src/compositor/compositor_api/waylandcompositor.h delete mode 100644 src/compositor/compositor_api/waylandinput.cpp delete mode 100644 src/compositor/compositor_api/waylandinput.h delete mode 100644 src/compositor/compositor_api/waylandsurface.cpp delete mode 100644 src/compositor/compositor_api/waylandsurface.h delete mode 100644 src/compositor/compositor_api/waylandsurfaceitem.cpp delete mode 100644 src/compositor/compositor_api/waylandsurfaceitem.h delete mode 100644 src/compositor/compositor_api/waylandsurfacenode.cpp delete mode 100644 src/compositor/compositor_api/waylandsurfacenode.h delete mode 100644 src/compositor/compositor_api/waylandsurfacetexturematerial.cpp delete mode 100644 src/compositor/compositor_api/waylandsurfacetexturematerial.h create mode 100644 src/compositor/global/qwaylandexport.h create mode 100644 src/compositor/global/qwaylandobject.h create mode 100644 src/compositor/global/qwaylandresourcecollection.cpp create mode 100644 src/compositor/global/qwaylandresourcecollection.h delete mode 100644 src/compositor/global/waylandexport.h delete mode 100644 src/compositor/global/waylandobject.h delete mode 100644 src/compositor/global/waylandresourcecollection.cpp delete mode 100644 src/compositor/global/waylandresourcecollection.h delete mode 100644 src/compositor/hardware_integration/graphicshardwareintegration.cpp delete mode 100644 src/compositor/hardware_integration/graphicshardwareintegration.h delete mode 100644 src/compositor/hardware_integration/graphicshardwareintegrationfactory.cpp delete mode 100644 src/compositor/hardware_integration/graphicshardwareintegrationfactory.h delete mode 100644 src/compositor/hardware_integration/graphicshardwareintegrationplugin.cpp delete mode 100644 src/compositor/hardware_integration/graphicshardwareintegrationplugin.h create mode 100644 src/compositor/hardware_integration/qwaylandgraphicshardwareintegration.cpp create mode 100644 src/compositor/hardware_integration/qwaylandgraphicshardwareintegration.h create mode 100644 src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationfactory.cpp create mode 100644 src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationfactory.h create mode 100644 src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationplugin.cpp create mode 100644 src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationplugin.h create mode 100644 src/compositor/wayland_wrapper/qwlcompositor.cpp create mode 100644 src/compositor/wayland_wrapper/qwlcompositor_p.h create mode 100644 src/compositor/wayland_wrapper/qwldatadevice.cpp create mode 100644 src/compositor/wayland_wrapper/qwldatadevice_p.h create mode 100644 src/compositor/wayland_wrapper/qwldatadevicemanager.cpp create mode 100644 src/compositor/wayland_wrapper/qwldatadevicemanager_p.h create mode 100644 src/compositor/wayland_wrapper/qwldataoffer.cpp create mode 100644 src/compositor/wayland_wrapper/qwldataoffer_p.h create mode 100644 src/compositor/wayland_wrapper/qwldatasource.cpp create mode 100644 src/compositor/wayland_wrapper/qwldatasource_p.h create mode 100644 src/compositor/wayland_wrapper/qwldisplay.cpp create mode 100644 src/compositor/wayland_wrapper/qwldisplay_p.h create mode 100644 src/compositor/wayland_wrapper/qwlextendedoutput.cpp create mode 100644 src/compositor/wayland_wrapper/qwlextendedoutput_p.h create mode 100644 src/compositor/wayland_wrapper/qwlextendedsurface.cpp create mode 100644 src/compositor/wayland_wrapper/qwlextendedsurface_p.h create mode 100644 src/compositor/wayland_wrapper/qwlinputdevice.cpp create mode 100644 src/compositor/wayland_wrapper/qwlinputdevice_p.h create mode 100644 src/compositor/wayland_wrapper/qwloutput.cpp create mode 100644 src/compositor/wayland_wrapper/qwloutput_p.h create mode 100644 src/compositor/wayland_wrapper/qwlqtkey.cpp create mode 100644 src/compositor/wayland_wrapper/qwlqtkey_p.h create mode 100644 src/compositor/wayland_wrapper/qwlregion.cpp create mode 100644 src/compositor/wayland_wrapper/qwlregion_p.h create mode 100644 src/compositor/wayland_wrapper/qwlshellsurface.cpp create mode 100644 src/compositor/wayland_wrapper/qwlshellsurface_p.h create mode 100644 src/compositor/wayland_wrapper/qwlsubsurface.cpp create mode 100644 src/compositor/wayland_wrapper/qwlsubsurface_p.h create mode 100644 src/compositor/wayland_wrapper/qwlsurface.cpp create mode 100644 src/compositor/wayland_wrapper/qwlsurface_p.h create mode 100644 src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp create mode 100644 src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h create mode 100644 src/compositor/wayland_wrapper/qwltouch.cpp create mode 100644 src/compositor/wayland_wrapper/qwltouch_p.h delete mode 100644 src/compositor/wayland_wrapper/wlcompositor.cpp delete mode 100644 src/compositor/wayland_wrapper/wlcompositor.h delete mode 100644 src/compositor/wayland_wrapper/wldatadevice.cpp delete mode 100644 src/compositor/wayland_wrapper/wldatadevice.h delete mode 100644 src/compositor/wayland_wrapper/wldatadevicemanager.cpp delete mode 100644 src/compositor/wayland_wrapper/wldatadevicemanager.h delete mode 100644 src/compositor/wayland_wrapper/wldataoffer.cpp delete mode 100644 src/compositor/wayland_wrapper/wldataoffer.h delete mode 100644 src/compositor/wayland_wrapper/wldatasource.cpp delete mode 100644 src/compositor/wayland_wrapper/wldatasource.h delete mode 100644 src/compositor/wayland_wrapper/wldisplay.cpp delete mode 100644 src/compositor/wayland_wrapper/wldisplay.h delete mode 100644 src/compositor/wayland_wrapper/wlextendedoutput.cpp delete mode 100644 src/compositor/wayland_wrapper/wlextendedoutput.h delete mode 100644 src/compositor/wayland_wrapper/wlextendedsurface.cpp delete mode 100644 src/compositor/wayland_wrapper/wlextendedsurface.h delete mode 100644 src/compositor/wayland_wrapper/wlinputdevice.cpp delete mode 100644 src/compositor/wayland_wrapper/wlinputdevice.h delete mode 100644 src/compositor/wayland_wrapper/wloutput.cpp delete mode 100644 src/compositor/wayland_wrapper/wloutput.h delete mode 100644 src/compositor/wayland_wrapper/wlqtkey.cpp delete mode 100644 src/compositor/wayland_wrapper/wlqtkey.h delete mode 100644 src/compositor/wayland_wrapper/wlregion.cpp delete mode 100644 src/compositor/wayland_wrapper/wlregion.h delete mode 100644 src/compositor/wayland_wrapper/wlshellsurface.cpp delete mode 100644 src/compositor/wayland_wrapper/wlshellsurface.h delete mode 100644 src/compositor/wayland_wrapper/wlsubsurface.cpp delete mode 100644 src/compositor/wayland_wrapper/wlsubsurface.h delete mode 100644 src/compositor/wayland_wrapper/wlsurface.cpp delete mode 100644 src/compositor/wayland_wrapper/wlsurface.h delete mode 100644 src/compositor/wayland_wrapper/wlsurfacebuffer.cpp delete mode 100644 src/compositor/wayland_wrapper/wlsurfacebuffer.h delete mode 100644 src/compositor/wayland_wrapper/wltouch.cpp delete mode 100644 src/compositor/wayland_wrapper/wltouch.h diff --git a/examples/qml-compositor/main.cpp b/examples/qml-compositor/main.cpp index fdaf4657c..d481a2522 100644 --- a/examples/qml-compositor/main.cpp +++ b/examples/qml-compositor/main.cpp @@ -38,9 +38,9 @@ ** ****************************************************************************/ -#include "waylandcompositor.h" -#include "waylandsurface.h" -#include "waylandsurfaceitem.h" +#include "qwaylandcompositor.h" +#include "qwaylandsurface.h" +#include "qwaylandsurfaceitem.h" #include #include @@ -52,14 +52,14 @@ #include #include -class QmlCompositor : public QQuickView, public WaylandCompositor +class QmlCompositor : public QQuickView, public QWaylandCompositor { Q_OBJECT - Q_PROPERTY(WaylandSurface* fullscreenSurface READ fullscreenSurface WRITE setFullscreenSurface NOTIFY fullscreenSurfaceChanged) + Q_PROPERTY(QWaylandSurface* fullscreenSurface READ fullscreenSurface WRITE setFullscreenSurface NOTIFY fullscreenSurfaceChanged) public: QmlCompositor() - : WaylandCompositor(this) + : QWaylandCompositor(this) , m_fullscreenSurface(0) { enableSubSurfaceExtension(); @@ -71,7 +71,7 @@ public: connect(this, SIGNAL(frameSwapped()), this, SLOT(frameSwappedSlot())); } - WaylandSurface *fullscreenSurface() const + QWaylandSurface *fullscreenSurface() const { return m_fullscreenSurface; } @@ -88,11 +88,11 @@ public slots: } void destroyClientForWindow(QVariant window) { - WaylandSurface *surface = qobject_cast(qvariant_cast(window))->surface(); + QWaylandSurface *surface = qobject_cast(qvariant_cast(window))->surface(); destroyClientForSurface(surface); } - void setFullscreenSurface(WaylandSurface *surface) { + void setFullscreenSurface(QWaylandSurface *surface) { if (surface == m_fullscreenSurface) return; m_fullscreenSurface = surface; @@ -101,22 +101,22 @@ public slots: private slots: void surfaceMapped() { - WaylandSurface *surface = qobject_cast(sender()); + QWaylandSurface *surface = qobject_cast(sender()); //Ignore surface if it's not a window surface if (!surface->hasShellSurface()) return; - WaylandSurfaceItem *item = surface->surfaceItem(); + QWaylandSurfaceItem *item = surface->surfaceItem(); //Create a WaylandSurfaceItem if we have not yet if (!item) - item = new WaylandSurfaceItem(surface, rootObject()); + item = new QWaylandSurfaceItem(surface, rootObject()); item->setTouchEventsEnabled(true); //item->takeFocus(); emit windowAdded(QVariant::fromValue(static_cast(item))); } void surfaceUnmapped() { - WaylandSurface *surface = qobject_cast(sender()); + QWaylandSurface *surface = qobject_cast(sender()); if (surface == m_fullscreenSurface) m_fullscreenSurface = 0; QQuickItem *item = surface->surfaceItem(); @@ -124,7 +124,7 @@ private slots: } void surfaceDestroyed(QObject *object) { - WaylandSurface *surface = static_cast(object); + QWaylandSurface *surface = static_cast(object); if (surface == m_fullscreenSurface) m_fullscreenSurface = 0; QQuickItem *item = surface->surfaceItem(); @@ -139,17 +139,17 @@ protected: void resizeEvent(QResizeEvent *event) { QQuickView::resizeEvent(event); - WaylandCompositor::setOutputGeometry(QRect(0, 0, width(), height())); + QWaylandCompositor::setOutputGeometry(QRect(0, 0, width(), height())); } - void surfaceCreated(WaylandSurface *surface) { + void surfaceCreated(QWaylandSurface *surface) { connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); connect(surface,SIGNAL(unmapped()), this,SLOT(surfaceUnmapped())); } private: - WaylandSurface *m_fullscreenSurface; + QWaylandSurface *m_fullscreenSurface; }; int main(int argc, char *argv[]) diff --git a/examples/qwidget-compositor/main.cpp b/examples/qwidget-compositor/main.cpp index 12160a909..0c115166c 100644 --- a/examples/qwidget-compositor/main.cpp +++ b/examples/qwidget-compositor/main.cpp @@ -38,10 +38,10 @@ ** ****************************************************************************/ -#include "waylandcompositor.h" +#include "qwaylandcompositor.h" -#include "waylandsurface.h" -#include +#include "qwaylandsurface.h" +#include #include #include @@ -61,7 +61,7 @@ #include #ifdef QT_COMPOSITOR_WAYLAND_GL -class QWidgetCompositor : public QGLWidget, public WaylandCompositor +class QWidgetCompositor : public QGLWidget, public QWaylandCompositor #else class QWidgetCompositor : public QWidget, public WaylandCompositor #endif @@ -69,7 +69,7 @@ class QWidgetCompositor : public QWidget, public WaylandCompositor Q_OBJECT public: QWidgetCompositor() - : WaylandCompositor(windowHandle()) + : QWaylandCompositor(windowHandle()) #ifdef QT_COMPOSITOR_WAYLAND_GL , m_surfaceCompositorFbo(0) , m_textureBlitter(0) @@ -90,13 +90,13 @@ public: private slots: void surfaceDestroyed(QObject *object) { - WaylandSurface *surface = static_cast(object); + QWaylandSurface *surface = static_cast(object); m_surfaces.removeAll(surface); update(); } void surfaceMapped() { - WaylandSurface *surface = qobject_cast(sender()); + QWaylandSurface *surface = qobject_cast(sender()); QPoint pos; if (!m_surfaces.contains(surface)) { uint px = 1 + (qrand() % (width() - surface->size().width() - 2)); @@ -112,12 +112,12 @@ private slots: } void surfaceDamaged(const QRect &rect) { - WaylandSurface *surface = qobject_cast(sender()); + QWaylandSurface *surface = qobject_cast(sender()); surfaceDamaged(surface, rect); } protected: - void surfaceDamaged(WaylandSurface *surface, const QRect &rect) + void surfaceDamaged(QWaylandSurface *surface, const QRect &rect) { #ifdef QT_COMPOSITOR_WAYLAND_GL Q_UNUSED(surface); @@ -128,7 +128,7 @@ protected: #endif } - void surfaceCreated(WaylandSurface *surface) { + void surfaceCreated(QWaylandSurface *surface) { connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &))); @@ -136,7 +136,7 @@ protected: } #ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint composeSurface(WaylandSurface *surface) { + GLuint composeSurface(QWaylandSurface *surface) { GLuint texture = 0; QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); @@ -145,7 +145,7 @@ protected: functions->glBindFramebuffer(GL_FRAMEBUFFER, m_surfaceCompositorFbo); - if (surface->type() == WaylandSurface::Shm) { + if (surface->type() == QWaylandSurface::Shm) { texture = m_textureCache->bindTexture(context()->contextHandle(), surface->image()); } else { texture = surface->texture(QOpenGLContext::currentContext()); @@ -161,21 +161,21 @@ protected: return texture; } - void paintChildren(WaylandSurface *surface, WaylandSurface *window) { + void paintChildren(QWaylandSurface *surface, QWaylandSurface *window) { if (surface->subSurfaces().size() == 0) return; - QLinkedListIterator i(surface->subSurfaces()); + QLinkedListIterator i(surface->subSurfaces()); while (i.hasNext()) { - WaylandSurface *subSurface = i.next(); + QWaylandSurface *subSurface = i.next(); QPointF p = subSurface->mapTo(window,QPoint(0,0)); QSize size = subSurface->size(); if (size.isValid()) { GLuint texture = 0; - if (subSurface->type() == WaylandSurface::Texture) { + if (subSurface->type() == QWaylandSurface::Texture) { texture = subSurface->texture(QOpenGLContext::currentContext()); - } else if (surface->type() == WaylandSurface::Shm ) { + } else if (surface->type() == QWaylandSurface::Shm ) { texture = m_textureCache->bindTexture(context()->contextHandle(), surface->image()); } m_textureBlitter->drawTexture(texture,QRect(p.toPoint(),size),window->size(),0,window->isYInverted(),subSurface->isYInverted()); @@ -232,7 +232,7 @@ protected: for (int i = 0; i < m_surfaces.size(); ++i) { #ifdef QT_COMPOSITOR_WAYLAND_GL GLuint texture = composeSurface(m_surfaces.at(i)); - WaylandSurface *surface = m_surfaces.at(i); + QWaylandSurface *surface = m_surfaces.at(i); QRect geo(surface->pos().toPoint(),surface->size()); m_textureBlitter->drawTexture(texture,geo,size(),0,false,m_surfaces.at(i)->isYInverted()); #else @@ -258,7 +258,7 @@ protected: } } - void raise(WaylandSurface *surface) { + void raise(QWaylandSurface *surface) { defaultInputDevice()->setKeyboardFocus(surface); surfaceDamaged(surface, QRect(QPoint(), surface->size())); m_surfaces.removeOne(surface); @@ -268,7 +268,7 @@ protected: void mousePressEvent(QMouseEvent *e) { m_cursorPos = e->pos(); QPointF local; - if (WaylandSurface *surface = surfaceAt(e->pos(), &local)) { + if (QWaylandSurface *surface = surfaceAt(e->pos(), &local)) { raise(surface); if (e->modifiers() & Qt::ControlModifier) { m_moveSurface = surface; @@ -284,7 +284,7 @@ protected: if (isDragging()) { QPoint global = e->pos(); // "global" here means the window of the compositor QPointF local; - WaylandSurface *surface = surfaceAt(e->pos(), &local); + QWaylandSurface *surface = surfaceAt(e->pos(), &local); if (surface) { if (!m_dragSourceSurface) m_dragSourceSurface = surface; @@ -335,9 +335,9 @@ protected: defaultInputDevice()->sendKeyReleaseEvent(event->nativeScanCode()); } - WaylandSurface *surfaceAt(const QPointF &point, QPointF *local = 0) { + QWaylandSurface *surfaceAt(const QPointF &point, QPointF *local = 0) { for (int i = m_surfaces.size() - 1; i >= 0; --i) { - WaylandSurface *surface = m_surfaces.at(i); + QWaylandSurface *surface = m_surfaces.at(i); QRect geo(surface->pos().toPoint(),surface->size()); if (geo.contains(point.toPoint())) { if (local) @@ -348,7 +348,7 @@ protected: return 0; } - void setCursorSurface(WaylandSurface *surface, int hotspotX, int hotspotY) { + void setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY) { m_cursorSurface = surface; m_cursorHotspot = QPoint(hotspotX, hotspotY); update(); @@ -358,7 +358,7 @@ private: QImage m_background; QPixmap m_backgroundScaled; - QList m_surfaces; + QList m_surfaces; #ifdef QT_COMPOSITOR_WAYLAND_GL GLuint m_surfaceCompositorFbo; @@ -366,12 +366,12 @@ private: QOpenGLTextureCache *m_textureCache; #endif - WaylandSurface *m_moveSurface; + QWaylandSurface *m_moveSurface; QPointF m_moveOffset; - WaylandSurface *m_dragSourceSurface; + QWaylandSurface *m_dragSourceSurface; QPointF m_lastDragSourcePos; - WaylandSurface* m_cursorSurface; + QWaylandSurface* m_cursorSurface; QPoint m_cursorPos; QPoint m_cursorHotspot; diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp index 4b543eab6..09522ae20 100644 --- a/examples/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/qwindow-compositor/qwindowcompositor.cpp @@ -51,10 +51,10 @@ #include #include -#include +#include QWindowCompositor::QWindowCompositor(QOpenGLWindow *window) - : WaylandCompositor(window) + : QWaylandCompositor(window) , m_window(window) , m_textureBlitter(0) , m_renderScheduler(this) @@ -112,16 +112,16 @@ QImage QWindowCompositor::makeBackgroundImage(const QString &fileName) return patternedBackground; } -void QWindowCompositor::ensureKeyboardFocusSurface(WaylandSurface *oldSurface) +void QWindowCompositor::ensureKeyboardFocusSurface(QWaylandSurface *oldSurface) { - WaylandSurface *kbdFocus = defaultInputDevice()->keyboardFocus(); + QWaylandSurface *kbdFocus = defaultInputDevice()->keyboardFocus(); if (kbdFocus == oldSurface || !kbdFocus) defaultInputDevice()->setKeyboardFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last()); } void QWindowCompositor::surfaceDestroyed(QObject *object) { - WaylandSurface *surface = static_cast(object); + QWaylandSurface *surface = static_cast(object); m_surfaces.removeOne(surface); ensureKeyboardFocusSurface(surface); m_renderScheduler.start(0); @@ -129,7 +129,7 @@ void QWindowCompositor::surfaceDestroyed(QObject *object) void QWindowCompositor::surfaceMapped() { - WaylandSurface *surface = qobject_cast(sender()); + QWaylandSurface *surface = qobject_cast(sender()); QPoint pos; if (!m_surfaces.contains(surface)) { uint px = 0; @@ -153,7 +153,7 @@ void QWindowCompositor::surfaceMapped() void QWindowCompositor::surfaceUnmapped() { - WaylandSurface *surface = qobject_cast(sender()); + QWaylandSurface *surface = qobject_cast(sender()); if (m_surfaces.removeOne(surface)) m_surfaces.insert(0, surface); @@ -162,18 +162,18 @@ void QWindowCompositor::surfaceUnmapped() void QWindowCompositor::surfaceDamaged(const QRect &rect) { - WaylandSurface *surface = qobject_cast(sender()); + QWaylandSurface *surface = qobject_cast(sender()); surfaceDamaged(surface, rect); } -void QWindowCompositor::surfaceDamaged(WaylandSurface *surface, const QRect &rect) +void QWindowCompositor::surfaceDamaged(QWaylandSurface *surface, const QRect &rect) { Q_UNUSED(surface) Q_UNUSED(rect) m_renderScheduler.start(0); } -void QWindowCompositor::surfaceCreated(WaylandSurface *surface) +void QWindowCompositor::surfaceCreated(QWaylandSurface *surface) { connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); @@ -185,7 +185,7 @@ void QWindowCompositor::surfaceCreated(WaylandSurface *surface) void QWindowCompositor::sendExpose() { - WaylandSurface *surface = qobject_cast(sender()); + QWaylandSurface *surface = qobject_cast(sender()); surface->sendOnScreenVisibilityChange(true); } @@ -203,12 +203,12 @@ void QWindowCompositor::updateCursor() } } -QPointF QWindowCompositor::toSurface(WaylandSurface *surface, const QPointF &pos) const +QPointF QWindowCompositor::toSurface(QWaylandSurface *surface, const QPointF &pos) const { return pos - surface->pos(); } -void QWindowCompositor::setCursorSurface(WaylandSurface *surface, int hotspotX, int hotspotY) +void QWindowCompositor::setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY) { if ((m_cursorSurface != surface) && surface) connect(surface, SIGNAL(damaged(QRect)), this, SLOT(updateCursor())); @@ -218,10 +218,10 @@ void QWindowCompositor::setCursorSurface(WaylandSurface *surface, int hotspotX, m_cursorHotspotY = hotspotY; } -WaylandSurface *QWindowCompositor::surfaceAt(const QPointF &point, QPointF *local) +QWaylandSurface *QWindowCompositor::surfaceAt(const QPointF &point, QPointF *local) { for (int i = m_surfaces.size() - 1; i >= 0; --i) { - WaylandSurface *surface = m_surfaces.at(i); + QWaylandSurface *surface = m_surfaces.at(i); QRectF geo(surface->pos(), surface->size()); if (geo.contains(point)) { if (local) @@ -232,16 +232,16 @@ WaylandSurface *QWindowCompositor::surfaceAt(const QPointF &point, QPointF *loca return 0; } -GLuint QWindowCompositor::composeSurface(WaylandSurface *surface) +GLuint QWindowCompositor::composeSurface(QWaylandSurface *surface) { GLuint texture = 0; QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); functions->glBindFramebuffer(GL_FRAMEBUFFER, m_surface_fbo); - if (surface->type() == WaylandSurface::Shm) { + if (surface->type() == QWaylandSurface::Shm) { texture = m_textureCache->bindTexture(QOpenGLContext::currentContext(),surface->image()); - } else if (surface->type() == WaylandSurface::Texture) { + } else if (surface->type() == QWaylandSurface::Texture) { texture = surface->texture(QOpenGLContext::currentContext()); } @@ -255,20 +255,20 @@ GLuint QWindowCompositor::composeSurface(WaylandSurface *surface) return texture; } -void QWindowCompositor::paintChildren(WaylandSurface *surface, WaylandSurface *window) { +void QWindowCompositor::paintChildren(QWaylandSurface *surface, QWaylandSurface *window) { if (surface->subSurfaces().size() == 0) return; - QLinkedListIterator i(surface->subSurfaces()); + QLinkedListIterator i(surface->subSurfaces()); while (i.hasNext()) { - WaylandSurface *subSurface = i.next(); + QWaylandSurface *subSurface = i.next(); QPointF p = subSurface->mapTo(window,QPointF(0,0)); if (subSurface->size().isValid()) { GLuint texture = 0; - if (subSurface->type() == WaylandSurface::Texture) { + if (subSurface->type() == QWaylandSurface::Texture) { texture = subSurface->texture(QOpenGLContext::currentContext()); - } else if (surface->type() == WaylandSurface::Shm ) { + } else if (surface->type() == QWaylandSurface::Shm ) { texture = m_textureCache->bindTexture(QOpenGLContext::currentContext(),surface->image()); } QRect geo(p.toPoint(),subSurface->size()); @@ -291,7 +291,7 @@ void QWindowCompositor::render() window()->size(), 0, false, true); - foreach (WaylandSurface *surface, m_surfaces) { + foreach (QWaylandSurface *surface, m_surfaces) { GLuint texture = composeSurface(surface); QRect geo(surface->pos().toPoint(),surface->size()); m_textureBlitter->drawTexture(texture,geo,m_window->size(),0,false,surface->isYInverted()); @@ -308,7 +308,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) if (obj != m_window) return false; - WaylandInputDevice *input = defaultInputDevice(); + QWaylandInputDevice *input = defaultInputDevice(); switch (event->type()) { case QEvent::Expose: @@ -330,7 +330,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) case QEvent::MouseButtonPress: { QPointF local; QMouseEvent *me = static_cast(event); - WaylandSurface *targetSurface = surfaceAt(me->localPos(), &local); + QWaylandSurface *targetSurface = surfaceAt(me->localPos(), &local); if (m_dragKeyIsPressed && targetSurface) { m_draggingWindow = targetSurface; m_drag_diff = local; @@ -346,7 +346,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) return true; } case QEvent::MouseButtonRelease: { - WaylandSurface *targetSurface = input->mouseFocus(); + QWaylandSurface *targetSurface = input->mouseFocus(); if (m_draggingWindow) { m_draggingWindow = 0; m_drag_diff = QPointF(); @@ -366,7 +366,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) m_renderScheduler.start(0); } else { QPointF local; - WaylandSurface *targetSurface = surfaceAt(me->localPos(), &local); + QWaylandSurface *targetSurface = surfaceAt(me->localPos(), &local); input->sendMouseMoveEvent(targetSurface, local, me->localPos()); } break; @@ -382,7 +382,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) m_dragKeyIsPressed = true; } m_modifiers = ke->modifiers(); - WaylandSurface *targetSurface = input->keyboardFocus(); + QWaylandSurface *targetSurface = input->keyboardFocus(); if (targetSurface) input->sendKeyPressEvent(ke->nativeScanCode()); break; @@ -393,7 +393,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) m_dragKeyIsPressed = false; } m_modifiers = ke->modifiers(); - WaylandSurface *targetSurface = input->keyboardFocus(); + QWaylandSurface *targetSurface = input->keyboardFocus(); if (targetSurface) input->sendKeyReleaseEvent(ke->nativeScanCode()); break; @@ -402,7 +402,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event) case QEvent::TouchUpdate: case QEvent::TouchEnd: { - WaylandSurface *targetSurface = 0; + QWaylandSurface *targetSurface = 0; QTouchEvent *te = static_cast(event); QList points = te->touchPoints(); QPoint pointPos; diff --git a/examples/qwindow-compositor/qwindowcompositor.h b/examples/qwindow-compositor/qwindowcompositor.h index 6f2c8d3d2..7ad2faf60 100644 --- a/examples/qwindow-compositor/qwindowcompositor.h +++ b/examples/qwindow-compositor/qwindowcompositor.h @@ -41,8 +41,8 @@ #ifndef QWINDOWCOMPOSITOR_H #define QWINDOWCOMPOSITOR_H -#include "waylandcompositor.h" -#include "waylandsurface.h" +#include "qwaylandcompositor.h" +#include "qwaylandsurface.h" #include "textureblitter.h" #include "qopenglwindow.h" @@ -50,7 +50,7 @@ #include #include -class QWindowCompositor : public QObject, public WaylandCompositor +class QWindowCompositor : public QObject, public QWaylandCompositor { Q_OBJECT public: @@ -65,21 +65,21 @@ private slots: void render(); protected: - void surfaceDamaged(WaylandSurface *surface, const QRect &rect); - void surfaceCreated(WaylandSurface *surface); + void surfaceDamaged(QWaylandSurface *surface, const QRect &rect); + void surfaceCreated(QWaylandSurface *surface); - WaylandSurface* surfaceAt(const QPointF &point, QPointF *local = 0); + QWaylandSurface* surfaceAt(const QPointF &point, QPointF *local = 0); - GLuint composeSurface(WaylandSurface *surface); - void paintChildren(WaylandSurface *surface, WaylandSurface *window); + GLuint composeSurface(QWaylandSurface *surface); + void paintChildren(QWaylandSurface *surface, QWaylandSurface *window); bool eventFilter(QObject *obj, QEvent *event); - QPointF toSurface(WaylandSurface *surface, const QPointF &pos) const; + QPointF toSurface(QWaylandSurface *surface, const QPointF &pos) const; - void setCursorSurface(WaylandSurface *surface, int hotspotX, int hotspotY); + void setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY); - void ensureKeyboardFocusSurface(WaylandSurface *oldSurface); + void ensureKeyboardFocusSurface(QWaylandSurface *oldSurface); QImage makeBackgroundImage(const QString &fileName); private slots: @@ -90,19 +90,19 @@ private: QOpenGLWindow *m_window; QImage m_backgroundImage; GLuint m_backgroundTexture; - QList m_surfaces; + QList m_surfaces; TextureBlitter *m_textureBlitter; QOpenGLTextureCache *m_textureCache; GLuint m_surface_fbo; QTimer m_renderScheduler; //Dragging windows around - WaylandSurface *m_draggingWindow; + QWaylandSurface *m_draggingWindow; bool m_dragKeyIsPressed; QPointF m_drag_diff; //Cursor - WaylandSurface *m_cursorSurface; + QWaylandSurface *m_cursorSurface; int m_cursorHotspotX; int m_cursorHotspotY; diff --git a/src/compositor/compositor.pri b/src/compositor/compositor.pri deleted file mode 100644 index 595bbf7c7..000000000 --- a/src/compositor/compositor.pri +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += link_pkgconfig - -DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT - -!contains(QT_CONFIG, no-pkg-config) { - PKGCONFIG += wayland-server -} else { - LIBS += -lwayland-server -} - -include ($$PWD/global/global.pri) -include ($$PWD/wayland_wrapper/wayland_wrapper.pri) -include ($$PWD/hardware_integration/hardware_integration.pri) -include ($$PWD/compositor_api/compositor_api.pri) -include ($$PWD/windowmanagerprotocol/windowmanagerprotocol.pri) diff --git a/src/compositor/compositor.pro b/src/compositor/compositor.pro index 5ba6bc111..8a2fa01e3 100644 --- a/src/compositor/compositor.pro +++ b/src/compositor/compositor.pro @@ -5,5 +5,24 @@ contains(QT_CONFIG, opengl):MODULE_DEFINES = QT_COMPOSITOR_WAYLAND_GL load(qt_module) -include(compositor.pri) +CONFIG += link_pkgconfig + +DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT + +!contains(QT_CONFIG, no-pkg-config) { + PKGCONFIG += wayland-server +} else { + LIBS += -lwayland-server +} + +INCLUDEPATH += ../shared +HEADERS += ../shared/qwaylandmimehelper.h +SOURCES += ../shared/qwaylandmimehelper.cpp + +include ($$PWD/global/global.pri) +include ($$PWD/wayland_wrapper/wayland_wrapper.pri) +include ($$PWD/hardware_integration/hardware_integration.pri) +include ($$PWD/compositor_api/compositor_api.pri) +include ($$PWD/windowmanagerprotocol/windowmanagerprotocol.pri) + diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri index 2e98c7757..f0bbe7648 100644 --- a/src/compositor/compositor_api/compositor_api.pri +++ b/src/compositor/compositor_api/compositor_api.pri @@ -1,29 +1,30 @@ -INCLUDEPATH += $$PWD +INCLUDEPATH += compositor_api HEADERS += \ - $$PWD/waylandcompositor.h \ - $$PWD/waylandsurface.h \ - $$PWD/waylandinput.h + compositor_api/qwaylandcompositor.h \ + compositor_api/qwaylandsurface.h \ + compositor_api/qwaylandinput.h SOURCES += \ - $$PWD/waylandcompositor.cpp \ - $$PWD/waylandsurface.cpp \ - $$PWD/waylandinput.cpp + compositor_api/qwaylandcompositor.cpp \ + compositor_api/qwaylandsurface.cpp \ + compositor_api/qwaylandinput.cpp QT += core-private qtHaveModule(quick) { - SOURCES += $$PWD/waylandsurfaceitem.cpp \ - $$PWD/waylandsurfacenode.cpp \ - $$PWD/waylandsurfacetexturematerial.cpp + SOURCES += \ + compositor_api/qwaylandsurfaceitem.cpp \ + compositor_api/qwaylandsurfacenode.cpp \ + compositor_api/qwaylandsurfacetexturematerial.cpp - HEADERS += $$PWD/waylandsurfaceitem.h \ - $$PWD/waylandsurfacenode.h \ - $$PWD/waylandsurfacetexturematerial.h + HEADERS += \ + compositor_api/qwaylandsurfaceitem.h \ + compositor_api/qwaylandsurfacenode_p.h \ + compositor_api/qwaylandsurfacetexturematerial_p.h DEFINES += QT_COMPOSITOR_QUICK QT += qml quick QT += quick-private gui-private } - diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp new file mode 100644 index 000000000..f742a8dea --- /dev/null +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -0,0 +1,271 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandcompositor.h" + +#include "qwaylandinput.h" + +#include "wayland_wrapper/qwlcompositor_p.h" +#include "wayland_wrapper/qwlsurface_p.h" +#include "wayland_wrapper/qwlinputdevice_p.h" + +#include +#include + +#include + +#include + +#ifdef QT_COMPOSITOR_QUICK +#include "qwaylandsurfaceitem.h" +#endif + +QT_BEGIN_NAMESPACE + +QWaylandCompositor::QWaylandCompositor(QWindow *window, const char *socketName) + : m_compositor(0) + , m_toplevel_window(window) + , m_socket_name(socketName) +{ + QStringList arguments = QCoreApplication::instance()->arguments(); + + int socketArg = arguments.indexOf(QLatin1String("--wayland-socket-name")); + if (socketArg != -1 && socketArg + 1 < arguments.size()) + m_socket_name = arguments.at(socketArg + 1).toLocal8Bit(); + + m_compositor = new QtWayland::Compositor(this); +#ifdef QT_COMPOSITOR_QUICK + qmlRegisterType("WaylandCompositor", 1, 0, "WaylandSurfaceItem"); + qmlRegisterType("WaylandCompositor", 1, 0, "WaylandSurface"); +#else + qRegisterMetaType("WaylandSurface*"); +#endif + m_compositor->initializeHardwareIntegration(); + m_compositor->initializeWindowManagerProtocol(); + m_compositor->initializeDefaultInputDevice(); +} + +QWaylandCompositor::~QWaylandCompositor() +{ + delete m_compositor; +} + +struct wl_display *QWaylandCompositor::waylandDisplay() const +{ + return m_compositor->wl_display(); +} +void QWaylandCompositor::frameFinished(QWaylandSurface *surface) +{ + QtWayland::Surface *surfaceImpl = surface? surface->handle():0; + m_compositor->frameFinished(surfaceImpl); +} + +void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface) +{ + destroyClient(surface->client()); +} + +void QWaylandCompositor::destroyClient(WaylandClient *client) +{ + m_compositor->destroyClient(client); +} + +QList QWaylandCompositor::surfacesForClient(WaylandClient* c) const +{ + wl_client *client = static_cast(c); + + QList surfaces = m_compositor->surfaces(); + + QList result; + + for (int i = 0; i < surfaces.count(); ++i) { + if (surfaces.at(i)->base()->resource.client == client) { + result.append(surfaces.at(i)->waylandSurface()); + } + } + + return result; +} + +void QWaylandCompositor::setDirectRenderSurface(QWaylandSurface *surface, QOpenGLContext *context) +{ + m_compositor->setDirectRenderSurface(surface ? surface->handle() : 0, context); +} + +QWaylandSurface *QWaylandCompositor::directRenderSurface() const +{ + QtWayland::Surface *surf = m_compositor->directRenderSurface(); + return surf ? surf->waylandSurface() : 0; +} + +QWindow * QWaylandCompositor::window() const +{ + return m_toplevel_window; +} + +void QWaylandCompositor::surfaceAboutToBeDestroyed(QWaylandSurface *surface) +{ + Q_UNUSED(surface); +} + +/*! + Override this to handle QDesktopServices::openUrl() requests from the clients. + + The default implementation simply forwards the request to QDesktopServices::openUrl(). +*/ +void QWaylandCompositor::openUrl(WaylandClient *client, const QUrl &url) +{ + Q_UNUSED(client); + QDesktopServices::openUrl(url); +} + +QtWayland::Compositor * QWaylandCompositor::handle() const +{ + return m_compositor; +} + +void QWaylandCompositor::setRetainedSelectionEnabled(bool enable) +{ + if (enable) + m_compositor->setRetainedSelectionWatcher(retainedSelectionChanged, this); + else + m_compositor->setRetainedSelectionWatcher(0, 0); +} + +void QWaylandCompositor::retainedSelectionChanged(QMimeData *mimeData, void *param) +{ + QWaylandCompositor *self = static_cast(param); + self->retainedSelectionReceived(mimeData); +} + +void QWaylandCompositor::retainedSelectionReceived(QMimeData *) +{ +} + +void QWaylandCompositor::overrideSelection(QMimeData *data) +{ + m_compositor->overrideSelection(data); +} + +void QWaylandCompositor::setClientFullScreenHint(bool value) +{ + m_compositor->setClientFullScreenHint(value); +} + +const char *QWaylandCompositor::socketName() const +{ + if (m_socket_name.isEmpty()) + return 0; + return m_socket_name.constData(); +} + +/*! + Set the screen orientation based on accelerometer data or similar. +*/ +void QWaylandCompositor::setScreenOrientation(Qt::ScreenOrientation orientation) +{ + m_compositor->setScreenOrientation(orientation); +} + +void QWaylandCompositor::setOutputGeometry(const QRect &geometry) +{ + m_compositor->setOutputGeometry(geometry); +} + +QRect QWaylandCompositor::outputGeometry() const +{ + return m_compositor->outputGeometry(); +} + +void QWaylandCompositor::setOutputRefreshRate(int rate) +{ + m_compositor->setOutputRefreshRate(rate); +} + +int QWaylandCompositor::outputRefreshRate() const +{ + return m_compositor->outputRefreshRate(); +} + +QWaylandInputDevice *QWaylandCompositor::defaultInputDevice() const +{ + return m_compositor->defaultInputDevice()->handle(); +} + +bool QWaylandCompositor::isDragging() const +{ + return m_compositor->isDragging(); +} + +void QWaylandCompositor::sendDragMoveEvent(const QPoint &global, const QPoint &local, + QWaylandSurface *surface) +{ + m_compositor->sendDragMoveEvent(global, local, surface ? surface->handle() : 0); +} + +void QWaylandCompositor::sendDragEndEvent() +{ + m_compositor->sendDragEndEvent(); +} + +void QWaylandCompositor::setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY) +{ + Q_UNUSED(surface); + Q_UNUSED(hotspotX); + Q_UNUSED(hotspotY); + qDebug() << "changeCursor" << surface->size() << hotspotX << hotspotY; +} + +void QWaylandCompositor::enableSubSurfaceExtension() +{ + m_compositor->enableSubSurfaceExtension(); +} + +void QWaylandCompositor::enableTouchExtension() +{ + // nothing to do here +} + +void QWaylandCompositor::configureTouchExtension(TouchExtensionFlags flags) +{ + m_compositor->configureTouchExtension(flags); +} + +QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h new file mode 100644 index 000000000..0f258617e --- /dev/null +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDCOMPOSITOR_H +#define QWAYLANDCOMPOSITOR_H + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QMimeData; +class QUrl; +class QOpenGLContext; +class QWaylandSurface; +class QWaylandInputDevice; + +namespace QtWayland +{ + class Compositor; +} + +class Q_COMPOSITOR_EXPORT QWaylandCompositor +{ +public: + QWaylandCompositor(QWindow *window = 0, const char *socketName = 0); + virtual ~QWaylandCompositor(); + + struct wl_display *waylandDisplay() const; + + void frameFinished(QWaylandSurface *surface = 0); + + void destroyClientForSurface(QWaylandSurface *surface); + void destroyClient(WaylandClient *client); + + QList surfacesForClient(WaylandClient* client) const; + + void setDirectRenderSurface(QWaylandSurface *surface, QOpenGLContext *context); + QWaylandSurface *directRenderSurface() const; + + QWindow *window()const; + + virtual void surfaceCreated(QWaylandSurface *surface) = 0; + virtual void surfaceAboutToBeDestroyed(QWaylandSurface *surface); + + virtual void openUrl(WaylandClient *client, const QUrl &url); + + QtWayland::Compositor *handle() const; + + void setRetainedSelectionEnabled(bool enable); + virtual void retainedSelectionReceived(QMimeData *mimeData); + void overrideSelection(QMimeData *data); + + void setClientFullScreenHint(bool value); + + const char *socketName() const; + + void setScreenOrientation(Qt::ScreenOrientation orientation); + + void setOutputGeometry(const QRect &outputGeometry); + QRect outputGeometry() const; + + void setOutputRefreshRate(int refreshRate); + int outputRefreshRate() const; + + QWaylandInputDevice *defaultInputDevice() const; + + bool isDragging() const; + void sendDragMoveEvent(const QPoint &global, const QPoint &local, QWaylandSurface *surface); + void sendDragEndEvent(); + + virtual void setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY); + + void enableSubSurfaceExtension(); + + void enableTouchExtension(); + enum TouchExtensionFlag { + TouchExtMouseFromTouch = 0x01 + }; + Q_DECLARE_FLAGS(TouchExtensionFlags, TouchExtensionFlag) + void configureTouchExtension(TouchExtensionFlags flags); + +private: + static void retainedSelectionChanged(QMimeData *mimeData, void *param); + + QtWayland::Compositor *m_compositor; + QWindow *m_toplevel_window; + QByteArray m_socket_name; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandCompositor::TouchExtensionFlags) + +QT_END_NAMESPACE + +#endif // QWAYLANDCOMPOSITOR_H diff --git a/src/compositor/compositor_api/qwaylandinput.cpp b/src/compositor/compositor_api/qwaylandinput.cpp new file mode 100644 index 000000000..c73784ebf --- /dev/null +++ b/src/compositor/compositor_api/qwaylandinput.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandinput.h" + +#include "qwlinputdevice_p.h" +#include "qwaylandcompositor.h" +#include "qwlsurface_p.h" +#include "qwlcompositor_p.h" + +QT_BEGIN_NAMESPACE + +QWaylandInputDevice::QWaylandInputDevice(QWaylandCompositor *compositor) + : d(new QtWayland::InputDevice(this,compositor->handle())) +{ +} + +QWaylandInputDevice::~QWaylandInputDevice() +{ + delete d; +} + +void QWaylandInputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) +{ + d->sendMousePressEvent(button,localPos,globalPos); +} + +void QWaylandInputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) +{ + d->sendMouseReleaseEvent(button,localPos,globalPos); +} + +void QWaylandInputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos) +{ + d->sendMouseMoveEvent(localPos,globalPos); +} + +/** Convenience function that will set the mouse focus to the surface, then send the mouse move event. + * If the mouse focus is the same surface as the surface passed in, then only the move event is sent + **/ +void QWaylandInputDevice::sendMouseMoveEvent(QWaylandSurface *surface, const QPointF &localPos, const QPointF &globalPos) +{ + QtWayland::Surface *wlsurface = surface? surface->handle():0; + d->sendMouseMoveEvent(wlsurface,localPos,globalPos); +} + +void QWaylandInputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta) +{ + d->sendMouseWheelEvent(orientation, delta); +} + +void QWaylandInputDevice::sendKeyPressEvent(uint code) +{ + d->sendKeyPressEvent(code); +} + +void QWaylandInputDevice::sendKeyReleaseEvent(uint code) +{ + d->sendKeyReleaseEvent(code); +} + +void QWaylandInputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state) +{ + d->sendTouchPointEvent(id,x,y,state); +} + +void QWaylandInputDevice::sendTouchFrameEvent() +{ + d->sendTouchFrameEvent(); +} + +void QWaylandInputDevice::sendTouchCancelEvent() +{ + d->sendTouchCancelEvent(); +} + +void QWaylandInputDevice::sendFullTouchEvent(QTouchEvent *event) +{ + d->sendFullTouchEvent(event); +} + +void QWaylandInputDevice::sendFullKeyEvent(QKeyEvent *event) +{ + d->sendFullKeyEvent(event); +} + +QWaylandSurface *QWaylandInputDevice::keyboardFocus() const +{ + QtWayland::Surface *wlsurface = d->keyboardFocus(); + if (wlsurface) + return wlsurface->waylandSurface(); + return 0; +} + +bool QWaylandInputDevice::setKeyboardFocus(QWaylandSurface *surface) +{ + QtWayland::Surface *wlsurface = surface?surface->handle():0; + return d->setKeyboardFocus(wlsurface); +} + +QWaylandSurface *QWaylandInputDevice::mouseFocus() const +{ + QtWayland::Surface *wlsurface = d->mouseFocus(); + if (wlsurface) + return wlsurface->waylandSurface(); + return 0; +} + +void QWaylandInputDevice::setMouseFocus(QWaylandSurface *surface, const QPointF &localPos, const QPointF &globalPos) +{ + QtWayland::Surface *wlsurface = surface?surface->handle():0; + d->setMouseFocus(wlsurface,localPos,globalPos); +} + +QWaylandCompositor *QWaylandInputDevice::compositor() const +{ + return d->compositor()->waylandCompositor(); +} + +QtWayland::InputDevice *QWaylandInputDevice::handle() const +{ + return d; +} + +QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandinput.h b/src/compositor/compositor_api/qwaylandinput.h new file mode 100644 index 000000000..b9d66178d --- /dev/null +++ b/src/compositor/compositor_api/qwaylandinput.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDINPUT_H +#define QWAYLANDINPUT_H + +#include +#include + +#include + +class QWaylandCompositor; +class QWaylandSurface; +class QKeyEvent; +class QTouchEvent; + +QT_BEGIN_NAMESPACE + +namespace QtWayland { +class InputDevice; +} + +class Q_COMPOSITOR_EXPORT QWaylandInputDevice +{ +public: + QWaylandInputDevice(QWaylandCompositor *compositor); + ~QWaylandInputDevice(); + + void sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF()); + void sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF()); + void sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos = QPointF()); + void sendMouseMoveEvent(QWaylandSurface *surface , const QPointF &localPos, const QPointF &globalPos = QPointF()); + void sendMouseWheelEvent(Qt::Orientation orientation, int delta); + + void sendKeyPressEvent(uint code); + void sendKeyReleaseEvent(uint code); + + void sendFullKeyEvent(QKeyEvent *event); + + void sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state); + void sendTouchFrameEvent(); + void sendTouchCancelEvent(); + + void sendFullTouchEvent(QTouchEvent *event); + + QWaylandSurface *keyboardFocus() const; + bool setKeyboardFocus(QWaylandSurface *surface); + + QWaylandSurface *mouseFocus() const; + void setMouseFocus(QWaylandSurface *surface, const QPointF &local_pos, const QPointF &global_pos = QPointF()); + + QWaylandCompositor *compositor() const; + QtWayland::InputDevice *handle() const; + +private: + QtWayland::InputDevice *d; + Q_DISABLE_COPY(QWaylandInputDevice) +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDINPUT_H diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp new file mode 100644 index 000000000..f97169255 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -0,0 +1,346 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandsurface.h" + +#include + +#include "wayland_wrapper/qwlsurface_p.h" +#include "wayland_wrapper/qwlextendedsurface_p.h" +#include "wayland_wrapper/qwlsubsurface_p.h" +#include "wayland_wrapper/qwlcompositor_p.h" +#include "wayland_wrapper/qwlshellsurface_p.h" + +#include "qwaylandcompositor.h" +#include "waylandwindowmanagerintegration.h" + +#include +#include + +#ifdef QT_COMPOSITOR_QUICK +#include "qwaylandsurfaceitem.h" +#endif + +QT_BEGIN_NAMESPACE + +class QWaylandSurfacePrivate : public QObjectPrivate +{ +public: + QWaylandSurfacePrivate(QtWayland::Surface *srfc) + : surface(srfc) +#ifdef QT_COMPOSITOR_QUICK + , surface_item(0) +#endif + {} + + ~QWaylandSurfacePrivate() + { +#ifdef QT_COMPOSITOR_QUICK + if (surface_item) + surface_item->setSurface(0); +#endif + } + + QtWayland::Surface *surface; +#ifdef QT_COMPOSITOR_QUICK + QWaylandSurfaceItem *surface_item; +#endif +}; + +QWaylandSurface::QWaylandSurface(QtWayland::Surface *surface) + : QObject(*new QWaylandSurfacePrivate(surface)) +{ +} + +WaylandClient *QWaylandSurface::client() const +{ + Q_D(const QWaylandSurface); + return d->surface->base()->resource.client; +} + +QWaylandSurface *QWaylandSurface::parentSurface() const +{ + Q_D(const QWaylandSurface); + if (d->surface->subSurface() && d->surface->subSurface()->parent()) { + return d->surface->subSurface()->parent()->waylandSurface(); + } + return 0; +} + +QLinkedList QWaylandSurface::subSurfaces() const +{ + Q_D(const QWaylandSurface); + if (d->surface->subSurface()) { + return d->surface->subSurface()->subSurfaces(); + } + return QLinkedList(); +} + +QWaylandSurface::Type QWaylandSurface::type() const +{ + Q_D(const QWaylandSurface); + return d->surface->type(); +} + +bool QWaylandSurface::isYInverted() const +{ + Q_D(const QWaylandSurface); + return d->surface->isYInverted(); +} + +bool QWaylandSurface::visible() const +{ + Q_D(const QWaylandSurface); + return d->surface->visible(); +} + +QPointF QWaylandSurface::pos() const +{ + Q_D(const QWaylandSurface); + return d->surface->pos(); +} + +void QWaylandSurface::setPos(const QPointF &pos) +{ + Q_D(QWaylandSurface); + d->surface->setPos(pos); +} + +QSize QWaylandSurface::size() const +{ + Q_D(const QWaylandSurface); + return d->surface->size(); +} + +void QWaylandSurface::setSize(const QSize &size) +{ + Q_D(QWaylandSurface); + d->surface->setSize(size); +} + +void QWaylandSurface::sendConfigure(const QSize &size) +{ + Q_D(QWaylandSurface); + if (d->surface->shellSurface()) + d->surface->shellSurface()->sendConfigure(WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, size.width(), size.height()); +} + +Qt::ScreenOrientations QWaylandSurface::orientationUpdateMask() const +{ + Q_D(const QWaylandSurface); + return d->surface->compositor()->orientationUpdateMaskForClient(static_cast(client())); +} + +Qt::ScreenOrientation QWaylandSurface::contentOrientation() const +{ + Q_D(const QWaylandSurface); + if (!d->surface->extendedSurface()) + return Qt::PrimaryOrientation; + return d->surface->extendedSurface()->contentOrientation(); +} + +QWaylandSurface::WindowFlags QWaylandSurface::windowFlags() const +{ + Q_D(const QWaylandSurface); + if (!d->surface->extendedSurface()) + return QWaylandSurface::WindowFlags(0); + return d->surface->extendedSurface()->windowFlags(); +} + + +QImage QWaylandSurface::image() const +{ + Q_D(const QWaylandSurface); + return d->surface->image(); +} + +#ifdef QT_COMPOSITOR_WAYLAND_GL +GLuint QWaylandSurface::texture(QOpenGLContext *context) const +{ + Q_D(const QWaylandSurface); + return d->surface->textureId(context); +} +#else //QT_COMPOSITOR_WAYLAND_GL +uint QWaylandSurface::texture(QOpenGLContext *) const +{ + return 0; +} +#endif + +QtWayland::Surface * QWaylandSurface::handle() const +{ + Q_D(const QWaylandSurface); + return d->surface; +} + +#ifdef QT_COMPOSITOR_QUICK +QWaylandSurfaceItem *QWaylandSurface::surfaceItem() const +{ + Q_D(const QWaylandSurface); + return d->surface_item; +} + +void QWaylandSurface::setSurfaceItem(QWaylandSurfaceItem *surfaceItem) +{ + Q_D(QWaylandSurface); + d->surface_item = surfaceItem; +} +#endif //QT_COMPOSITOR_QUICK + +qint64 QWaylandSurface::processId() const +{ + Q_D(const QWaylandSurface); + WindowManagerServerIntegration *wmIntegration = d->surface->compositor()->windowManagerIntegration(); + if (!wmIntegration) { + return 0; + } + + WaylandManagedClient *mcl = wmIntegration->managedClient(d->surface->base()->resource.client); + return mcl ? mcl->processId() : 0; +} + +QByteArray QWaylandSurface::authenticationToken() const +{ + Q_D(const QWaylandSurface); + WindowManagerServerIntegration *wmIntegration = d->surface->compositor()->windowManagerIntegration(); + if (!wmIntegration) { + return QByteArray(); + } + + WaylandManagedClient *mcl = wmIntegration->managedClient(d->surface->base()->resource.client); + return mcl ? mcl->authenticationToken() : QByteArray(); +} + +QVariantMap QWaylandSurface::windowProperties() const +{ + Q_D(const QWaylandSurface); + if (!d->surface->extendedSurface()) + return QVariantMap(); + + return d->surface->extendedSurface()->windowProperties(); +} + +void QWaylandSurface::setWindowProperty(const QString &name, const QVariant &value) +{ + Q_D(QWaylandSurface); + if (!d->surface->extendedSurface()) + return; + + d->surface->extendedSurface()->setWindowProperty(name, value); +} + +QPointF QWaylandSurface::mapToParent(const QPointF &pos) const +{ + return pos + this->pos(); +} + +QPointF QWaylandSurface::mapTo(QWaylandSurface *parent, const QPointF &pos) const +{ + QPointF p = pos; + if (parent) { + const QWaylandSurface * surface = this; + while (surface != parent) { + Q_ASSERT_X(surface, "WaylandSurface::mapTo(WaylandSurface *parent, const QPoint &pos)", + "parent must be in parent hierarchy"); + p = surface->mapToParent(p); + surface = surface->parentSurface(); + } + } + return p; +} + +QWaylandCompositor *QWaylandSurface::compositor() const +{ + Q_D(const QWaylandSurface); + return d->surface->compositor()->waylandCompositor(); +} + +void QWaylandSurface::frameFinished() +{ + Q_D(QWaylandSurface); + d->surface->frameFinished(); +} + +QWaylandSurface *QWaylandSurface::transientParent() const +{ + Q_D(const QWaylandSurface); + if (d->surface->shellSurface() && d->surface->shellSurface()->transientParent()) + return d->surface->shellSurface()->transientParent()->surface()->waylandSurface(); + return 0; +} + +void QWaylandSurface::sendOnScreenVisibilityChange(bool visible) +{ + Q_D(QWaylandSurface); + if (d->surface->extendedSurface()) + d->surface->extendedSurface()->sendOnScreenVisibility(visible); +} + +QString QWaylandSurface::className() const +{ + Q_D(const QWaylandSurface); + return d->surface->className(); +} + +QString QWaylandSurface::title() const +{ + Q_D(const QWaylandSurface); + return d->surface->title(); +} + +bool QWaylandSurface::hasShellSurface() const +{ + Q_D(const QWaylandSurface); + if (d->surface->shellSurface()) + return true; + + return false; +} + +/*! + * \return True if WL_SHELL_SURFACE_TRANSIENT_INACTIVE was set for this surface, meaning it should not receive keyboard focus. + */ +bool QWaylandSurface::transientInactive() const +{ + Q_D(const QWaylandSurface); + return d->surface->transientInactive(); +} + +QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h new file mode 100644 index 000000000..544fbc047 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDSURFACE_H +#define QWAYLANDSURFACE_H + +#include + +#include +#include +#include + +#include +#ifdef QT_COMPOSITOR_WAYLAND_GL +#include +#endif + +QT_BEGIN_NAMESPACE + +class QTouchEvent; +class QWaylandSurfacePrivate; +class QWaylandCompositor; + +#ifdef QT_COMPOSITOR_QUICK +class QWaylandSurfaceItem; +#endif + +namespace QtWayland { +class Surface; +class SurfacePrivate; +class ExtendedSurface; +} + +class Q_COMPOSITOR_EXPORT QWaylandSurface : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandSurface) + Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) + Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY posChanged) + Q_PROPERTY(QWaylandSurface::WindowFlags windowFlags READ windowFlags NOTIFY windowFlagsChanged) + Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) + Q_PROPERTY(QString className READ className NOTIFY classNameChanged) + Q_PROPERTY(QString title READ title NOTIFY titleChanged) + Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask NOTIFY orientationUpdateMaskChanged) + + Q_ENUMS(WindowFlag) + Q_FLAGS(WindowFlag WindowFlags) + +public: + enum WindowFlag { + OverridesSystemGestures = 0x0001, + StaysOnTop = 0x0002 + }; + Q_DECLARE_FLAGS(WindowFlags, WindowFlag) + + enum Type { + Invalid, + Shm, + Texture + }; + + QWaylandSurface(QtWayland::Surface *surface = 0); + + WaylandClient *client() const; + + QWaylandSurface *parentSurface() const; + QLinkedList subSurfaces() const; + + Type type() const; + bool isYInverted() const; + + bool visible() const; + + QPointF pos() const; + void setPos(const QPointF &pos); + QSize size() const; + void setSize(const QSize &size); + void sendConfigure(const QSize &size); + + Qt::ScreenOrientations orientationUpdateMask() const; + Qt::ScreenOrientation contentOrientation() const; + + WindowFlags windowFlags() const; + + QImage image() const; +#ifdef QT_COMPOSITOR_WAYLAND_GL + GLuint texture(QOpenGLContext *context) const; +#else + uint texture(QOpenGLContext *context) const; +#endif + + Q_INVOKABLE void sendOnScreenVisibilityChange(bool visible); + + void frameFinished(); + + QWaylandSurface *transientParent() const; + + QtWayland::Surface *handle() const; + +#ifdef QT_COMPOSITOR_QUICK + QWaylandSurfaceItem *surfaceItem() const; + void setSurfaceItem(QWaylandSurfaceItem *surfaceItem); +#endif + + qint64 processId() const; + QByteArray authenticationToken() const; + QVariantMap windowProperties() const; + void setWindowProperty(const QString &name, const QVariant &value); + + QPointF mapToParent(const QPointF &) const; + QPointF mapTo(QWaylandSurface *, const QPointF &) const; + + QWaylandCompositor *compositor() const; + + QString className() const; + + QString title() const; + + bool hasShellSurface() const; + + bool transientInactive() const; + +signals: + void mapped(); + void unmapped(); + void damaged(const QRect &rect); + void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); + void sizeChanged(); + void posChanged(); + void windowPropertyChanged(const QString &name, const QVariant &value); + void windowFlagsChanged(WindowFlags flags); + void contentOrientationChanged(); + void orientationUpdateMaskChanged(); + void extendedSurfaceReady(); + void classNameChanged(); + void titleChanged(); + +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDSURFACE_H diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp new file mode 100644 index 000000000..787db1770 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp @@ -0,0 +1,437 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandsurfaceitem.h" +#include "qwaylandsurfacenode_p.h" +#include "qwaylandsurface.h" +#include "qwaylandcompositor.h" +#include "qwaylandinput.h" + +#include "qwlsurface_p.h" +#include "qwlextendedsurface_p.h" + +#include +#include +#include + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandSurfaceTextureProvider : public QSGTextureProvider +{ + Q_OBJECT + +public: + QWaylandSurfaceTextureProvider() : t(0) { } + ~QWaylandSurfaceTextureProvider() { delete t; } + + QSGTexture *texture() const { + if (t) + t->setFiltering(smooth ? QSGTexture::Linear : QSGTexture::Nearest); + return t; + } + + bool smooth; + QSGTexture *t; + +public slots: + void invalidate() + { + delete t; + t = 0; + } +}; + +QMutex *QWaylandSurfaceItem::mutex = 0; + +QWaylandSurfaceItem::QWaylandSurfaceItem(QQuickItem *parent) + : QQuickItem(parent) + , m_surface(0) + , m_provider(0) + , m_node(0) + , m_paintEnabled(true) + , m_useTextureAlpha(false) + , m_clientRenderingEnabled(false) + , m_touchEventsEnabled(false) +{ + if (!mutex) + mutex = new QMutex; +} + +QWaylandSurfaceItem::QWaylandSurfaceItem(QWaylandSurface *surface, QQuickItem *parent) + : QQuickItem(parent) + , m_surface(0) + , m_provider(0) + , m_node(0) + , m_paintEnabled(true) + , m_useTextureAlpha(false) + , m_clientRenderingEnabled(false) + , m_touchEventsEnabled(false) +{ + init(surface); +} + +void QWaylandSurfaceItem::init(QWaylandSurface *surface) +{ + if (!surface) + return; + + if (m_surface) { + m_surface->setSurfaceItem(0); + } + + m_surface = surface; + m_surface->setSurfaceItem(this); + if (m_clientRenderingEnabled) { + m_surface->sendOnScreenVisibilityChange(m_clientRenderingEnabled); + } + + setWidth(surface->size().width()); + setHeight(surface->size().height()); + + setSmooth(true); + setFlag(ItemHasContents); + setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton | + Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::ExtraButton3 | Qt::ExtraButton4 | + Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 | + Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 | + Qt::ExtraButton12 | Qt::ExtraButton13); + setAcceptHoverEvents(true); + connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); + connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped())); + connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); + connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &))); + connect(surface, SIGNAL(parentChanged(QWaylandSurface*,QWaylandSurface*)), + this, SLOT(parentChanged(QWaylandSurface*,QWaylandSurface*))); + connect(surface, SIGNAL(sizeChanged()), this, SLOT(updateSize())); + connect(surface, SIGNAL(posChanged()), this, SLOT(updatePosition())); + + m_damaged = false; + m_yInverted = surface ? surface->isYInverted() : true; +} + +QWaylandSurfaceItem::~QWaylandSurfaceItem() +{ + QMutexLocker locker(mutex); + if (m_node) + m_node->setItem(0); + if (m_surface) + m_surface->setSurfaceItem(0); + if (m_provider) + m_provider->deleteLater(); +} + +void QWaylandSurfaceItem::setSurface(QWaylandSurface *surface) +{ + if (surface == m_surface) + return; + + init(surface); + emit surfaceChanged(); +} + +bool QWaylandSurfaceItem::isYInverted() const +{ + return m_yInverted; +} + +QSGTextureProvider *QWaylandSurfaceItem::textureProvider() const +{ + const_cast(this)->ensureProvider(); + return m_provider; +} + +void QWaylandSurfaceItem::ensureProvider() +{ + if (!m_provider) { + m_provider = new QWaylandSurfaceTextureProvider(); + connect(window(), SIGNAL(sceneGraphInvalidated()), m_provider, SLOT(invalidate()), Qt::DirectConnection); + } +} + +void QWaylandSurfaceItem::mousePressEvent(QMouseEvent *event) +{ + if (m_surface) { + QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); + if (inputDevice->mouseFocus() != m_surface) + inputDevice->setMouseFocus(m_surface, event->pos(), event->globalPos()); + inputDevice->sendMousePressEvent(event->button(), toSurface(event->pos()), event->globalPos()); + } +} + +void QWaylandSurfaceItem::mouseMoveEvent(QMouseEvent *event) +{ + if (m_surface){ + QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); + inputDevice->sendMouseMoveEvent(m_surface, toSurface(event->pos()), event->globalPos()); + } +} + +void QWaylandSurfaceItem::mouseReleaseEvent(QMouseEvent *event) +{ + if (m_surface){ + QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); + inputDevice->sendMouseReleaseEvent(event->button(), toSurface(event->pos()), event->globalPos()); + } +} + +void QWaylandSurfaceItem::wheelEvent(QWheelEvent *event) +{ + if (m_surface) { + QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); + inputDevice->sendMouseWheelEvent(event->orientation(), event->delta()); + } +} + +void QWaylandSurfaceItem::keyPressEvent(QKeyEvent *event) +{ + if (m_surface && hasFocus()) { + QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); + inputDevice->sendFullKeyEvent(event); + } +} + +void QWaylandSurfaceItem::keyReleaseEvent(QKeyEvent *event) +{ + if (m_surface && hasFocus()) { + QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); + inputDevice->sendFullKeyEvent(event); + } +} + +void QWaylandSurfaceItem::touchEvent(QTouchEvent *event) +{ + if (m_touchEventsEnabled && m_surface) { + QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); + event->accept(); + if (inputDevice->mouseFocus() != m_surface) { + QPoint pointPos; + QList points = event->touchPoints(); + if (!points.isEmpty()) + pointPos = points.at(0).pos().toPoint(); + inputDevice->setMouseFocus(m_surface, pointPos, pointPos); + } + inputDevice->sendFullTouchEvent(event); + } else { + event->ignore(); + } +} + +void QWaylandSurfaceItem::takeFocus() +{ + setFocus(true); + + if (m_surface) { + QWaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); + inputDevice->setKeyboardFocus(m_surface); + } +} + +QPoint QWaylandSurfaceItem::toSurface(const QPointF &pos) const +{ + return pos.toPoint(); +} + +void QWaylandSurfaceItem::surfaceMapped() +{ + setPaintEnabled(true); +} + +void QWaylandSurfaceItem::surfaceUnmapped() +{ + setPaintEnabled(false); +} + +void QWaylandSurfaceItem::surfaceDestroyed(QObject *) +{ + m_surface = 0; +} + +void QWaylandSurfaceItem::setDamagedFlag(bool on) +{ + m_damaged = on; +} + + +void QWaylandSurfaceItem::surfaceDamaged(const QRect &) +{ + m_damaged = true; + if (m_surface) { + bool inverted = m_surface->isYInverted(); + if (inverted != m_yInverted) { + m_yInverted = inverted; + emit yInvertedChanged(); + } + } + emit textureChanged(); + update(); +} + +void QWaylandSurfaceItem::parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent) +{ + Q_UNUSED(oldParent); + + QWaylandSurfaceItem *item = newParent? newParent->surfaceItem():0; + setParentItem(item); + + if (newParent) { + setPaintEnabled(true); + setVisible(true); + setOpacity(1); + setEnabled(true); + } +} + +void QWaylandSurfaceItem::updateSize() +{ + setSize(m_surface->size()); +} + +void QWaylandSurfaceItem::updatePosition() +{ + setPosition(m_surface->pos()); +} + +bool QWaylandSurfaceItem::paintEnabled() const +{ + return m_paintEnabled; +} + +void QWaylandSurfaceItem::setPaintEnabled(bool enabled) +{ + m_paintEnabled = enabled; + update(); +} + +void QWaylandSurfaceItem::updateTexture() +{ + ensureProvider(); + QSGTexture *texture = m_provider->t; + if (m_damaged) { + m_damaged = false; + QSGTexture *oldTexture = texture; + if (m_surface->type() == QWaylandSurface::Texture) { + QOpenGLContext *context = QOpenGLContext::currentContext(); + QQuickWindow::CreateTextureOptions opt = 0; + if (useTextureAlpha()) { + opt |= QQuickWindow::TextureHasAlphaChannel; + } + texture = window()->createTextureFromId(m_surface->texture(context), m_surface->size(), opt); + } else { + texture = window()->createTextureFromImage(m_surface->image()); + } + texture->bind(); + delete oldTexture; + } + + m_provider->t = texture; + m_provider->smooth = smooth(); +} + +QSGNode *QWaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) +{ + if (!m_surface) { + delete oldNode; + return 0; + } + + updateTexture(); + if (!m_provider->t || !m_paintEnabled) { + delete oldNode; + return 0; + } + + QWaylandSurfaceNode *node = static_cast(oldNode); + + if (!node) { + node = new QWaylandSurfaceNode(this); + } + + node->updateTexture(); + + if (surface()->isYInverted()) { + node->setRect(0, height(), width(), -height()); + } else { + node->setRect(0, 0, width(), height()); + } + + node->setTextureUpdated(true); + + return node; +} + +void QWaylandSurfaceItem::setUseTextureAlpha(bool useTextureAlpha) +{ + m_useTextureAlpha = useTextureAlpha; + + if ((flags() & ItemHasContents) != 0) { + update(); + } +} + +void QWaylandSurfaceItem::setClientRenderingEnabled(bool enabled) +{ + if (m_clientRenderingEnabled != enabled) { + m_clientRenderingEnabled = enabled; + + if (m_surface) { + m_surface->sendOnScreenVisibilityChange(enabled); + } + + emit clientRenderingEnabledChanged(); + } +} + +void QWaylandSurfaceItem::setTouchEventsEnabled(bool enabled) +{ + if (m_touchEventsEnabled != enabled) { + m_touchEventsEnabled = enabled; + emit touchEventsEnabledChanged(); + } +} + +#include "qwaylandsurfaceitem.moc" + +QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.h b/src/compositor/compositor_api/qwaylandsurfaceitem.h new file mode 100644 index 000000000..cc3323dd0 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.h @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDSURFACEITEM_H +#define QWAYLANDSURFACEITEM_H + +#include +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QWaylandSurfaceTextureProvider; +class QWaylandSurfaceNode; +class QMutex; + +Q_DECLARE_METATYPE(QWaylandSurface*) + +class Q_COMPOSITOR_EXPORT QWaylandSurfaceItem : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QWaylandSurface* surface READ surface WRITE setSurface NOTIFY surfaceChanged) + Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled) + Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha NOTIFY useTextureAlphaChanged) + Q_PROPERTY(bool clientRenderingEnabled READ clientRenderingEnabled WRITE setClientRenderingEnabled NOTIFY clientRenderingEnabledChanged) + Q_PROPERTY(bool touchEventsEnabled READ touchEventsEnabled WRITE setTouchEventsEnabled NOTIFY touchEventsEnabledChanged) + Q_PROPERTY(bool isYInverted READ isYInverted NOTIFY yInvertedChanged) + +public: + QWaylandSurfaceItem(QQuickItem *parent = 0); + QWaylandSurfaceItem(QWaylandSurface *surface, QQuickItem *parent = 0); + ~QWaylandSurfaceItem(); + + void setSurface(QWaylandSurface *surface); + QWaylandSurface *surface() const {return m_surface; } + + Q_INVOKABLE bool isYInverted() const; + + bool isTextureProvider() const { return true; } + QSGTextureProvider *textureProvider() const; + + bool paintEnabled() const; + bool useTextureAlpha() const { return m_useTextureAlpha; } + bool clientRenderingEnabled() const { return m_clientRenderingEnabled; } + bool touchEventsEnabled() const { return m_touchEventsEnabled; } + + void setUseTextureAlpha(bool useTextureAlpha); + void setClientRenderingEnabled(bool enabled); + void setTouchEventsEnabled(bool enabled); + + void setDamagedFlag(bool on); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void wheelEvent(QWheelEvent *event); + + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + + void touchEvent(QTouchEvent *event); + +public slots: + void takeFocus(); + void setPaintEnabled(bool paintEnabled); + +private slots: + void surfaceMapped(); + void surfaceUnmapped(); + void surfaceDestroyed(QObject *object); + void surfaceDamaged(const QRect &); + void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); + void updateSize(); + void updatePosition(); + +signals: + void textureChanged(); + void useTextureAlphaChanged(); + void clientRenderingEnabledChanged(); + void touchEventsEnabledChanged(); + void yInvertedChanged(); + void surfaceChanged(); + +protected: + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); + +private: + friend class QWaylandSurfaceNode; + void updateTexture(); + QPoint toSurface(const QPointF &pos) const; + void init(QWaylandSurface *); + void ensureProvider(); + + static QMutex *mutex; + + QWaylandSurface *m_surface; + QWaylandSurfaceTextureProvider *m_provider; + QWaylandSurfaceNode *m_node; + bool m_paintEnabled; + bool m_useTextureAlpha; + bool m_clientRenderingEnabled; + bool m_touchEventsEnabled; + bool m_damaged; + bool m_yInverted; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/compositor/compositor_api/qwaylandsurfacenode.cpp b/src/compositor/compositor_api/qwaylandsurfacenode.cpp new file mode 100644 index 000000000..513704f17 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandsurfacenode.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandsurfacenode_p.h" +#include "qwaylandsurfaceitem.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QWaylandSurfaceNode::QWaylandSurfaceNode(QWaylandSurfaceItem *item) + : m_item(item) + , m_textureUpdated(false) + , m_useTextureAlpha(false) + , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) +{ + m_textureMaterial = QWaylandSurfaceTextureMaterial::createMaterial(); + m_opaqueTextureMaterial = QWaylandSurfaceTextureOpaqueMaterial::createMaterial(); + + m_currentMaterial = m_opaqueTextureMaterial; + + setGeometry(&m_geometry); + setMaterial(m_currentMaterial); + + if (m_item) + m_item->m_node = this; + setFlag(UsePreprocess,true); +} + + +QWaylandSurfaceNode::~QWaylandSurfaceNode() +{ + QMutexLocker locker(QWaylandSurfaceItem::mutex); + if (m_item) + m_item->m_node = 0; + delete m_textureMaterial; + delete m_opaqueTextureMaterial; +} + +void QWaylandSurfaceNode::preprocess() +{ + QMutexLocker locker(QWaylandSurfaceItem::mutex); + + if (m_item && m_item->surface()) { + //Update if the item is dirty and we haven't done an updateTexture for this frame + if (m_item->m_damaged && !m_textureUpdated) { + m_item->updateTexture(); + updateTexture(); + } + } + //Reset value for next frame: we have not done updatePaintNode yet + m_textureUpdated = false; +} + +void QWaylandSurfaceNode::updateTexture() +{ + Q_ASSERT(m_item && m_item->textureProvider()); + + //If m_item->useTextureAlpha has changed to true use m_texureMaterial + //otherwise use m_opaqueTextureMaterial. + if (m_item->useTextureAlpha() != m_useTextureAlpha) { + m_useTextureAlpha = m_item->useTextureAlpha(); + if (m_useTextureAlpha) { + m_currentMaterial = m_textureMaterial; + } else { + m_currentMaterial = m_opaqueTextureMaterial; + } + setMaterial(m_currentMaterial); + } + + QSGTexture *texture = m_item->textureProvider()->texture(); + setTexture(texture); +} + +void QWaylandSurfaceNode::setRect(const QRectF &rect) +{ + if (m_rect == rect) + return; + m_rect = rect; + + if (texture()) { + QSize ts = texture()->textureSize(); + QRectF sourceRect(0, 0, ts.width(), ts.height()); + QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_rect, texture()->convertToNormalizedSourceRect(sourceRect)); + } +} + +void QWaylandSurfaceNode::setTexture(QSGTexture *texture) +{ + if (m_currentMaterial->state()->texture() == texture) + return; + m_currentMaterial->state()->setTexture(texture); + + QSize ts = texture->textureSize(); + QRectF sourceRect(0, 0, ts.width(), ts.height()); + QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_rect, texture->convertToNormalizedSourceRect(sourceRect)); + markDirty(DirtyMaterial); +} + +QSGTexture *QWaylandSurfaceNode::texture() const +{ + return m_currentMaterial->state()->texture(); +} + +void QWaylandSurfaceNode::setItem(QWaylandSurfaceItem *item) +{ + m_item = item; +} + +QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandsurfacenode_p.h b/src/compositor/compositor_api/qwaylandsurfacenode_p.h new file mode 100644 index 000000000..99bca039d --- /dev/null +++ b/src/compositor/compositor_api/qwaylandsurfacenode_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDSURFACENODE_H +#define QWAYLANDSURFACENODE_H + +#include "qwaylandsurfacetexturematerial_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandSurfaceItem; +class QSGTexture; + +class QWaylandSurfaceNode : public QSGGeometryNode +{ +public: + QWaylandSurfaceNode(QWaylandSurfaceItem *item = 0); + ~QWaylandSurfaceNode(); + + void preprocess(); + void updateTexture(); + + void setRect(const QRectF &rect); + inline void setRect(qreal x, qreal y, qreal w, qreal h) { setRect(QRectF(x, y, w, h)); } + + void setTexture(QSGTexture *texture); + QSGTexture *texture() const; + + bool isTextureUpdated() const { return m_textureUpdated; } + void setTextureUpdated(bool textureUpdated) { m_textureUpdated = textureUpdated; } + + QWaylandSurfaceItem *item() const { return m_item; } + void setItem(QWaylandSurfaceItem *item); + +private: + + QWaylandSurfaceItem *m_item; + bool m_textureUpdated; + bool m_useTextureAlpha; + + QSGGeometry m_geometry; + QSGSimpleMaterial *m_textureMaterial; + QSGSimpleMaterial *m_opaqueTextureMaterial; + QSGSimpleMaterial *m_currentMaterial; + + QRectF m_rect; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDSURFACENODE_H diff --git a/src/compositor/compositor_api/qwaylandsurfacetexturematerial.cpp b/src/compositor/compositor_api/qwaylandsurfacetexturematerial.cpp new file mode 100644 index 000000000..9562457e2 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandsurfacetexturematerial.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandsurfacetexturematerial_p.h" +#include + +QT_BEGIN_NAMESPACE + +static const char wayland_surface_texture_material_vertex[] = + "uniform highp mat4 qt_Matrix; \n" + "attribute highp vec4 qt_VertexPosition; \n" + "attribute highp vec2 qt_VertexTexCoord; \n" + "varying highp vec2 qt_TexCoord; \n" + "void main() { \n" + " qt_TexCoord = qt_VertexTexCoord; \n" + " gl_Position = qt_Matrix * qt_VertexPosition; \n" + "}"; + + +static const char wayland_surface_texture_opaque_material_fragment[] = + "varying highp vec2 qt_TexCoord; \n" + "uniform sampler2D qt_Texture; \n" + "uniform lowp float qt_Opacity; \n" + "void main() { \n" + " gl_FragColor = vec4(texture2D(qt_Texture, qt_TexCoord).rgb, 1.0) * qt_Opacity; \n" + "}"; + +static const char wayland_surface_texture_material_fragment[] = + "varying highp vec2 qt_TexCoord; \n" + "uniform sampler2D qt_Texture; \n" + "uniform lowp float qt_Opacity; \n" + "void main() { \n" + " gl_FragColor = texture2D(qt_Texture, qt_TexCoord) * qt_Opacity; \n" + "}"; + +QList QWaylandSurfaceTextureMaterial::attributes() const +{ + QList attributeList; + attributeList << "qt_VertexPosition"; + attributeList << "qt_VertexTexCoord"; + return attributeList; +} + +void QWaylandSurfaceTextureMaterial::updateState(const QWaylandSurfaceTextureState *newState, const QWaylandSurfaceTextureState *oldState) +{ + Q_UNUSED(oldState); + newState->texture()->bind(); +} + +const char *QWaylandSurfaceTextureMaterial::vertexShader() const +{ + return wayland_surface_texture_material_vertex; +} + +const char *QWaylandSurfaceTextureMaterial::fragmentShader() const +{ + return wayland_surface_texture_material_fragment; +} + +QList QWaylandSurfaceTextureOpaqueMaterial::attributes() const +{ + QList attributeList; + attributeList << "qt_VertexPosition"; + attributeList << "qt_VertexTexCoord"; + return attributeList; +} + +void QWaylandSurfaceTextureOpaqueMaterial::updateState(const QWaylandSurfaceTextureState *newState, const QWaylandSurfaceTextureState *oldState) +{ + Q_UNUSED(oldState); + newState->texture()->bind(); +} + +const char *QWaylandSurfaceTextureOpaqueMaterial::vertexShader() const +{ + return wayland_surface_texture_material_vertex; +} + +const char *QWaylandSurfaceTextureOpaqueMaterial::fragmentShader() const +{ + return wayland_surface_texture_opaque_material_fragment; +} + +QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandsurfacetexturematerial_p.h b/src/compositor/compositor_api/qwaylandsurfacetexturematerial_p.h new file mode 100644 index 000000000..4cf3df093 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandsurfacetexturematerial_p.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDSURFACETEXTUREMATERIAL_H +#define QWAYLANDSURFACETEXTUREMATERIAL_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandSurfaceTextureState { +public: + QWaylandSurfaceTextureState() + : m_texture(0) + {} + void setTexture(QSGTexture *texture) { m_texture = texture; } + QSGTexture *texture() const { return m_texture; } + +private: + QSGTexture *m_texture; +}; + +class QWaylandSurfaceTextureMaterial : public QSGSimpleMaterialShader +{ + QSG_DECLARE_SIMPLE_SHADER(QWaylandSurfaceTextureMaterial, QWaylandSurfaceTextureState) + public: + + QList attributes() const; + + void updateState(const QWaylandSurfaceTextureState *newState, const QWaylandSurfaceTextureState *oldState); +protected: + const char *vertexShader() const; + const char *fragmentShader() const; +}; + +class QWaylandSurfaceTextureOpaqueMaterial : public QSGSimpleMaterialShader +{ + QSG_DECLARE_SIMPLE_SHADER(QWaylandSurfaceTextureOpaqueMaterial, QWaylandSurfaceTextureState) + public: + + QList attributes() const; + + void updateState(const QWaylandSurfaceTextureState *newState, const QWaylandSurfaceTextureState *oldState); +protected: + const char *vertexShader() const; + const char *fragmentShader() const; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDSURFACETEXTUREMATERIAL_H diff --git a/src/compositor/compositor_api/waylandcompositor.cpp b/src/compositor/compositor_api/waylandcompositor.cpp deleted file mode 100644 index 38c404745..000000000 --- a/src/compositor/compositor_api/waylandcompositor.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandcompositor.h" - -#include "waylandinput.h" - -#include "wayland_wrapper/wlcompositor.h" -#include "wayland_wrapper/wlsurface.h" -#include "wayland_wrapper/wlinputdevice.h" - -#include -#include - -#include - -#include - -#ifdef QT_COMPOSITOR_QUICK -#include "waylandsurfaceitem.h" -#endif - -WaylandCompositor::WaylandCompositor(QWindow *window, const char *socketName) - : m_compositor(0) - , m_toplevel_window(window) - , m_socket_name(socketName) -{ - QStringList arguments = QCoreApplication::instance()->arguments(); - - int socketArg = arguments.indexOf(QLatin1String("--wayland-socket-name")); - if (socketArg != -1 && socketArg + 1 < arguments.size()) - m_socket_name = arguments.at(socketArg + 1).toLocal8Bit(); - - m_compositor = new Wayland::Compositor(this); -#ifdef QT_COMPOSITOR_QUICK - qmlRegisterType("WaylandCompositor", 1, 0, "WaylandSurfaceItem"); - qmlRegisterType("WaylandCompositor", 1, 0, "WaylandSurface"); -#else - qRegisterMetaType("WaylandSurface*"); -#endif - m_compositor->initializeHardwareIntegration(); - m_compositor->initializeWindowManagerProtocol(); - m_compositor->initializeDefaultInputDevice(); -} - -WaylandCompositor::~WaylandCompositor() -{ - delete m_compositor; -} - -struct wl_display *WaylandCompositor::waylandDisplay() const -{ - return m_compositor->wl_display(); -} -void WaylandCompositor::frameFinished(WaylandSurface *surface) -{ - Wayland::Surface *surfaceImpl = surface? surface->handle():0; - m_compositor->frameFinished(surfaceImpl); -} - -void WaylandCompositor::destroyClientForSurface(WaylandSurface *surface) -{ - destroyClient(surface->client()); -} - -void WaylandCompositor::destroyClient(WaylandClient *client) -{ - m_compositor->destroyClient(client); -} - -QList WaylandCompositor::surfacesForClient(WaylandClient* c) const -{ - wl_client *client = static_cast(c); - - QList surfaces = m_compositor->surfaces(); - - QList result; - - for (int i = 0; i < surfaces.count(); ++i) { - if (surfaces.at(i)->base()->resource.client == client) { - result.append(surfaces.at(i)->waylandSurface()); - } - } - - return result; -} - -void WaylandCompositor::setDirectRenderSurface(WaylandSurface *surface, QOpenGLContext *context) -{ - m_compositor->setDirectRenderSurface(surface ? surface->handle() : 0, context); -} - -WaylandSurface *WaylandCompositor::directRenderSurface() const -{ - Wayland::Surface *surf = m_compositor->directRenderSurface(); - return surf ? surf->waylandSurface() : 0; -} - -QWindow * WaylandCompositor::window() const -{ - return m_toplevel_window; -} - -void WaylandCompositor::surfaceAboutToBeDestroyed(WaylandSurface *surface) -{ - Q_UNUSED(surface); -} - -/*! - Override this to handle QDesktopServices::openUrl() requests from the clients. - - The default implementation simply forwards the request to QDesktopServices::openUrl(). -*/ -void WaylandCompositor::openUrl(WaylandClient *client, const QUrl &url) -{ - Q_UNUSED(client); - QDesktopServices::openUrl(url); -} - -Wayland::Compositor * WaylandCompositor::handle() const -{ - return m_compositor; -} - -void WaylandCompositor::setRetainedSelectionEnabled(bool enable) -{ - if (enable) - m_compositor->setRetainedSelectionWatcher(retainedSelectionChanged, this); - else - m_compositor->setRetainedSelectionWatcher(0, 0); -} - -void WaylandCompositor::retainedSelectionChanged(QMimeData *mimeData, void *param) -{ - WaylandCompositor *self = static_cast(param); - self->retainedSelectionReceived(mimeData); -} - -void WaylandCompositor::retainedSelectionReceived(QMimeData *) -{ -} - -void WaylandCompositor::overrideSelection(QMimeData *data) -{ - m_compositor->overrideSelection(data); -} - -void WaylandCompositor::setClientFullScreenHint(bool value) -{ - m_compositor->setClientFullScreenHint(value); -} - -const char *WaylandCompositor::socketName() const -{ - if (m_socket_name.isEmpty()) - return 0; - return m_socket_name.constData(); -} - -/*! - Set the screen orientation based on accelerometer data or similar. -*/ -void WaylandCompositor::setScreenOrientation(Qt::ScreenOrientation orientation) -{ - m_compositor->setScreenOrientation(orientation); -} - -void WaylandCompositor::setOutputGeometry(const QRect &geometry) -{ - m_compositor->setOutputGeometry(geometry); -} - -QRect WaylandCompositor::outputGeometry() const -{ - return m_compositor->outputGeometry(); -} - -void WaylandCompositor::setOutputRefreshRate(int rate) -{ - m_compositor->setOutputRefreshRate(rate); -} - -int WaylandCompositor::outputRefreshRate() const -{ - return m_compositor->outputRefreshRate(); -} - -WaylandInputDevice *WaylandCompositor::defaultInputDevice() const -{ - return m_compositor->defaultInputDevice()->handle(); -} - -bool WaylandCompositor::isDragging() const -{ - return m_compositor->isDragging(); -} - -void WaylandCompositor::sendDragMoveEvent(const QPoint &global, const QPoint &local, - WaylandSurface *surface) -{ - m_compositor->sendDragMoveEvent(global, local, surface ? surface->handle() : 0); -} - -void WaylandCompositor::sendDragEndEvent() -{ - m_compositor->sendDragEndEvent(); -} - -void WaylandCompositor::setCursorSurface(WaylandSurface *surface, int hotspotX, int hotspotY) -{ - Q_UNUSED(surface); - Q_UNUSED(hotspotX); - Q_UNUSED(hotspotY); - qDebug() << "changeCursor" << surface->size() << hotspotX << hotspotY; -} - -void WaylandCompositor::enableSubSurfaceExtension() -{ - m_compositor->enableSubSurfaceExtension(); -} - -void WaylandCompositor::enableTouchExtension() -{ - // nothing to do here -} - -void WaylandCompositor::configureTouchExtension(TouchExtensionFlags flags) -{ - m_compositor->configureTouchExtension(flags); -} diff --git a/src/compositor/compositor_api/waylandcompositor.h b/src/compositor/compositor_api/waylandcompositor.h deleted file mode 100644 index 3df737d19..000000000 --- a/src/compositor/compositor_api/waylandcompositor.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTCOMP_H -#define QTCOMP_H - -#include "waylandexport.h" - -#include -#include -#include - -class QMimeData; -class QUrl; -class QOpenGLContext; -class WaylandSurface; -class WaylandInputDevice; - -namespace Wayland -{ - class Compositor; -} - -class Q_COMPOSITOR_EXPORT WaylandCompositor -{ -public: - WaylandCompositor(QWindow *window = 0, const char *socketName = 0); - virtual ~WaylandCompositor(); - - struct wl_display *waylandDisplay() const; - - void frameFinished(WaylandSurface *surface = 0); - - void destroyClientForSurface(WaylandSurface *surface); - void destroyClient(WaylandClient *client); - - QList surfacesForClient(WaylandClient* client) const; - - void setDirectRenderSurface(WaylandSurface *surface, QOpenGLContext *context); - WaylandSurface *directRenderSurface() const; - - QWindow *window()const; - - virtual void surfaceCreated(WaylandSurface *surface) = 0; - virtual void surfaceAboutToBeDestroyed(WaylandSurface *surface); - - virtual void openUrl(WaylandClient *client, const QUrl &url); - - Wayland::Compositor *handle() const; - - void setRetainedSelectionEnabled(bool enable); - virtual void retainedSelectionReceived(QMimeData *mimeData); - void overrideSelection(QMimeData *data); - - void setClientFullScreenHint(bool value); - - const char *socketName() const; - - void setScreenOrientation(Qt::ScreenOrientation orientation); - - void setOutputGeometry(const QRect &outputGeometry); - QRect outputGeometry() const; - - void setOutputRefreshRate(int refreshRate); - int outputRefreshRate() const; - - WaylandInputDevice *defaultInputDevice() const; - - bool isDragging() const; - void sendDragMoveEvent(const QPoint &global, const QPoint &local, WaylandSurface *surface); - void sendDragEndEvent(); - - virtual void setCursorSurface(WaylandSurface *surface, int hotspotX, int hotspotY); - - void enableSubSurfaceExtension(); - - void enableTouchExtension(); - enum TouchExtensionFlag { - TouchExtMouseFromTouch = 0x01 - }; - Q_DECLARE_FLAGS(TouchExtensionFlags, TouchExtensionFlag) - void configureTouchExtension(TouchExtensionFlags flags); - -private: - static void retainedSelectionChanged(QMimeData *mimeData, void *param); - - Wayland::Compositor *m_compositor; - QWindow *m_toplevel_window; - QByteArray m_socket_name; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(WaylandCompositor::TouchExtensionFlags) - -#endif // QTCOMP_H diff --git a/src/compositor/compositor_api/waylandinput.cpp b/src/compositor/compositor_api/waylandinput.cpp deleted file mode 100644 index 4eaeae65e..000000000 --- a/src/compositor/compositor_api/waylandinput.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandinput.h" - -#include "wlinputdevice.h" -#include "waylandcompositor.h" -#include "wlsurface.h" -#include "wlcompositor.h" - -WaylandInputDevice::WaylandInputDevice(WaylandCompositor *compositor) - : d(new Wayland::InputDevice(this,compositor->handle())) -{ -} - -WaylandInputDevice::~WaylandInputDevice() -{ - delete d; -} - -void WaylandInputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) -{ - d->sendMousePressEvent(button,localPos,globalPos); -} - -void WaylandInputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) -{ - d->sendMouseReleaseEvent(button,localPos,globalPos); -} - -void WaylandInputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos) -{ - d->sendMouseMoveEvent(localPos,globalPos); -} - -/** Convenience function that will set the mouse focus to the surface, then send the mouse move event. - * If the mouse focus is the same surface as the surface passed in, then only the move event is sent - **/ -void WaylandInputDevice::sendMouseMoveEvent(WaylandSurface *surface, const QPointF &localPos, const QPointF &globalPos) -{ - Wayland::Surface *wlsurface = surface? surface->handle():0; - d->sendMouseMoveEvent(wlsurface,localPos,globalPos); -} - -void WaylandInputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta) -{ - d->sendMouseWheelEvent(orientation, delta); -} - -void WaylandInputDevice::sendKeyPressEvent(uint code) -{ - d->sendKeyPressEvent(code); -} - -void WaylandInputDevice::sendKeyReleaseEvent(uint code) -{ - d->sendKeyReleaseEvent(code); -} - -void WaylandInputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state) -{ - d->sendTouchPointEvent(id,x,y,state); -} - -void WaylandInputDevice::sendTouchFrameEvent() -{ - d->sendTouchFrameEvent(); -} - -void WaylandInputDevice::sendTouchCancelEvent() -{ - d->sendTouchCancelEvent(); -} - -void WaylandInputDevice::sendFullTouchEvent(QTouchEvent *event) -{ - d->sendFullTouchEvent(event); -} - -void WaylandInputDevice::sendFullKeyEvent(QKeyEvent *event) -{ - d->sendFullKeyEvent(event); -} - -WaylandSurface *WaylandInputDevice::keyboardFocus() const -{ - Wayland::Surface *wlsurface = d->keyboardFocus(); - if (wlsurface) - return wlsurface->waylandSurface(); - return 0; -} - -bool WaylandInputDevice::setKeyboardFocus(WaylandSurface *surface) -{ - Wayland::Surface *wlsurface = surface?surface->handle():0; - return d->setKeyboardFocus(wlsurface); -} - -WaylandSurface *WaylandInputDevice::mouseFocus() const -{ - Wayland::Surface *wlsurface = d->mouseFocus(); - if (wlsurface) - return wlsurface->waylandSurface(); - return 0; -} - -void WaylandInputDevice::setMouseFocus(WaylandSurface *surface, const QPointF &localPos, const QPointF &globalPos) -{ - Wayland::Surface *wlsurface = surface?surface->handle():0; - d->setMouseFocus(wlsurface,localPos,globalPos); -} - -WaylandCompositor *WaylandInputDevice::compositor() const -{ - return d->compositor()->waylandCompositor(); -} - -Wayland::InputDevice *WaylandInputDevice::handle() const -{ - return d; -} - - diff --git a/src/compositor/compositor_api/waylandinput.h b/src/compositor/compositor_api/waylandinput.h deleted file mode 100644 index 622291072..000000000 --- a/src/compositor/compositor_api/waylandinput.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLANDINPUT_H -#define WAYLANDINPUT_H - -#include -#include - -#include "waylandexport.h" - -class WaylandCompositor; -class WaylandSurface; -class QKeyEvent; -class QTouchEvent; - -namespace Wayland { -class InputDevice; -} - -class Q_COMPOSITOR_EXPORT WaylandInputDevice -{ -public: - WaylandInputDevice(WaylandCompositor *compositor); - ~WaylandInputDevice(); - - void sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF()); - void sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF()); - void sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos = QPointF()); - void sendMouseMoveEvent(WaylandSurface *surface , const QPointF &localPos, const QPointF &globalPos = QPointF()); - void sendMouseWheelEvent(Qt::Orientation orientation, int delta); - - void sendKeyPressEvent(uint code); - void sendKeyReleaseEvent(uint code); - - void sendFullKeyEvent(QKeyEvent *event); - - void sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state); - void sendTouchFrameEvent(); - void sendTouchCancelEvent(); - - void sendFullTouchEvent(QTouchEvent *event); - - WaylandSurface *keyboardFocus() const; - bool setKeyboardFocus(WaylandSurface *surface); - - WaylandSurface *mouseFocus() const; - void setMouseFocus(WaylandSurface *surface, const QPointF &local_pos, const QPointF &global_pos = QPointF()); - - WaylandCompositor *compositor() const; - Wayland::InputDevice *handle() const; - -private: - Wayland::InputDevice *d; - Q_DISABLE_COPY(WaylandInputDevice) -}; - -#endif // WAYLANDINPUT_H diff --git a/src/compositor/compositor_api/waylandsurface.cpp b/src/compositor/compositor_api/waylandsurface.cpp deleted file mode 100644 index e30c148ad..000000000 --- a/src/compositor/compositor_api/waylandsurface.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandsurface.h" - -#include - -#include "wayland_wrapper/wlsurface.h" -#include "wayland_wrapper/wlextendedsurface.h" -#include "wayland_wrapper/wlsubsurface.h" -#include "wayland_wrapper/wlcompositor.h" -#include "wayland_wrapper/wlshellsurface.h" - -#include "waylandcompositor.h" -#include "waylandwindowmanagerintegration.h" - -#include -#include - -#ifdef QT_COMPOSITOR_QUICK -#include "waylandsurfaceitem.h" -#endif - -class WaylandSurfacePrivate : public QObjectPrivate -{ -public: - WaylandSurfacePrivate(Wayland::Surface *srfc) - : surface(srfc) -#ifdef QT_COMPOSITOR_QUICK - , surface_item(0) -#endif - {} - - ~WaylandSurfacePrivate() - { -#ifdef QT_COMPOSITOR_QUICK - if (surface_item) - surface_item->setSurface(0); -#endif - } - - Wayland::Surface *surface; -#ifdef QT_COMPOSITOR_QUICK - WaylandSurfaceItem *surface_item; -#endif -}; - -WaylandSurface::WaylandSurface(Wayland::Surface *surface) - : QObject(*new WaylandSurfacePrivate(surface)) -{ -} - -WaylandClient *WaylandSurface::client() const -{ - Q_D(const WaylandSurface); - return d->surface->base()->resource.client; -} - -WaylandSurface *WaylandSurface::parentSurface() const -{ - Q_D(const WaylandSurface); - if (d->surface->subSurface() && d->surface->subSurface()->parent()) { - return d->surface->subSurface()->parent()->waylandSurface(); - } - return 0; -} - -QLinkedList WaylandSurface::subSurfaces() const -{ - Q_D(const WaylandSurface); - if (d->surface->subSurface()) { - return d->surface->subSurface()->subSurfaces(); - } - return QLinkedList(); -} - -WaylandSurface::Type WaylandSurface::type() const -{ - Q_D(const WaylandSurface); - return d->surface->type(); -} - -bool WaylandSurface::isYInverted() const -{ - Q_D(const WaylandSurface); - return d->surface->isYInverted(); -} - -bool WaylandSurface::visible() const -{ - Q_D(const WaylandSurface); - return d->surface->visible(); -} - -QPointF WaylandSurface::pos() const -{ - Q_D(const WaylandSurface); - return d->surface->pos(); -} - -void WaylandSurface::setPos(const QPointF &pos) -{ - Q_D(WaylandSurface); - d->surface->setPos(pos); -} - -QSize WaylandSurface::size() const -{ - Q_D(const WaylandSurface); - return d->surface->size(); -} - -void WaylandSurface::setSize(const QSize &size) -{ - Q_D(WaylandSurface); - d->surface->setSize(size); -} - -void WaylandSurface::sendConfigure(const QSize &size) -{ - Q_D(WaylandSurface); - if (d->surface->shellSurface()) - d->surface->shellSurface()->sendConfigure(WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, size.width(), size.height()); -} - -Qt::ScreenOrientations WaylandSurface::orientationUpdateMask() const -{ - Q_D(const WaylandSurface); - return d->surface->compositor()->orientationUpdateMaskForClient(static_cast(client())); -} - -Qt::ScreenOrientation WaylandSurface::contentOrientation() const -{ - Q_D(const WaylandSurface); - if (!d->surface->extendedSurface()) - return Qt::PrimaryOrientation; - return d->surface->extendedSurface()->contentOrientation(); -} - -WaylandSurface::WindowFlags WaylandSurface::windowFlags() const -{ - Q_D(const WaylandSurface); - if (!d->surface->extendedSurface()) - return WaylandSurface::WindowFlags(0); - return d->surface->extendedSurface()->windowFlags(); -} - - -QImage WaylandSurface::image() const -{ - Q_D(const WaylandSurface); - return d->surface->image(); -} - -#ifdef QT_COMPOSITOR_WAYLAND_GL -GLuint WaylandSurface::texture(QOpenGLContext *context) const -{ - Q_D(const WaylandSurface); - return d->surface->textureId(context); -} -#else //QT_COMPOSITOR_WAYLAND_GL -uint WaylandSurface::texture(QOpenGLContext *) const -{ - return 0; -} -#endif - -Wayland::Surface * WaylandSurface::handle() const -{ - Q_D(const WaylandSurface); - return d->surface; -} - -#ifdef QT_COMPOSITOR_QUICK -WaylandSurfaceItem *WaylandSurface::surfaceItem() const -{ - Q_D(const WaylandSurface); - return d->surface_item; -} - -void WaylandSurface::setSurfaceItem(WaylandSurfaceItem *surfaceItem) -{ - Q_D(WaylandSurface); - d->surface_item = surfaceItem; -} -#endif //QT_COMPOSITOR_QUICK - -qint64 WaylandSurface::processId() const -{ - Q_D(const WaylandSurface); - WindowManagerServerIntegration *wmIntegration = d->surface->compositor()->windowManagerIntegration(); - if (!wmIntegration) { - return 0; - } - - WaylandManagedClient *mcl = wmIntegration->managedClient(d->surface->base()->resource.client); - return mcl ? mcl->processId() : 0; -} - -QByteArray WaylandSurface::authenticationToken() const -{ - Q_D(const WaylandSurface); - WindowManagerServerIntegration *wmIntegration = d->surface->compositor()->windowManagerIntegration(); - if (!wmIntegration) { - return QByteArray(); - } - - WaylandManagedClient *mcl = wmIntegration->managedClient(d->surface->base()->resource.client); - return mcl ? mcl->authenticationToken() : QByteArray(); -} - -QVariantMap WaylandSurface::windowProperties() const -{ - Q_D(const WaylandSurface); - if (!d->surface->extendedSurface()) - return QVariantMap(); - - return d->surface->extendedSurface()->windowProperties(); -} - -void WaylandSurface::setWindowProperty(const QString &name, const QVariant &value) -{ - Q_D(WaylandSurface); - if (!d->surface->extendedSurface()) - return; - - d->surface->extendedSurface()->setWindowProperty(name, value); -} - -QPointF WaylandSurface::mapToParent(const QPointF &pos) const -{ - return pos + this->pos(); -} - -QPointF WaylandSurface::mapTo(WaylandSurface *parent, const QPointF &pos) const -{ - QPointF p = pos; - if (parent) { - const WaylandSurface * surface = this; - while (surface != parent) { - Q_ASSERT_X(surface, "WaylandSurface::mapTo(WaylandSurface *parent, const QPoint &pos)", - "parent must be in parent hierarchy"); - p = surface->mapToParent(p); - surface = surface->parentSurface(); - } - } - return p; -} - -WaylandCompositor *WaylandSurface::compositor() const -{ - Q_D(const WaylandSurface); - return d->surface->compositor()->waylandCompositor(); -} - -void WaylandSurface::frameFinished() -{ - Q_D(WaylandSurface); - d->surface->frameFinished(); -} - -WaylandSurface *WaylandSurface::transientParent() const -{ - Q_D(const WaylandSurface); - if (d->surface->shellSurface() && d->surface->shellSurface()->transientParent()) - return d->surface->shellSurface()->transientParent()->surface()->waylandSurface(); - return 0; -} - -void WaylandSurface::sendOnScreenVisibilityChange(bool visible) -{ - Q_D(WaylandSurface); - if (d->surface->extendedSurface()) - d->surface->extendedSurface()->sendOnScreenVisibility(visible); -} - -QString WaylandSurface::className() const -{ - Q_D(const WaylandSurface); - return d->surface->className(); -} - -QString WaylandSurface::title() const -{ - Q_D(const WaylandSurface); - return d->surface->title(); -} - -bool WaylandSurface::hasShellSurface() const -{ - Q_D(const WaylandSurface); - if (d->surface->shellSurface()) - return true; - - return false; -} - -/*! - * \return True if WL_SHELL_SURFACE_TRANSIENT_INACTIVE was set for this surface, meaning it should not receive keyboard focus. - */ -bool WaylandSurface::transientInactive() const -{ - Q_D(const WaylandSurface); - return d->surface->transientInactive(); -} diff --git a/src/compositor/compositor_api/waylandsurface.h b/src/compositor/compositor_api/waylandsurface.h deleted file mode 100644 index e21f124aa..000000000 --- a/src/compositor/compositor_api/waylandsurface.h +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLANDSURFACE_H -#define WAYLANDSURFACE_H - -#include "waylandexport.h" - -#include -#include -#include - -#include -#ifdef QT_COMPOSITOR_WAYLAND_GL -#include -#endif - -class QTouchEvent; -class WaylandSurfacePrivate; -class WaylandCompositor; - -#ifdef QT_COMPOSITOR_QUICK -class WaylandSurfaceItem; -#endif - -namespace Wayland { -class Surface; -class SurfacePrivate; -class ExtendedSurface; -} - -class Q_COMPOSITOR_EXPORT WaylandSurface : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(WaylandSurface) - Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) - Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY posChanged) - Q_PROPERTY(WaylandSurface::WindowFlags windowFlags READ windowFlags NOTIFY windowFlagsChanged) - Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) - Q_PROPERTY(QString className READ className NOTIFY classNameChanged) - Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask NOTIFY orientationUpdateMaskChanged) - - Q_ENUMS(WindowFlag) - Q_FLAGS(WindowFlag WindowFlags) - -public: - enum WindowFlag { - OverridesSystemGestures = 0x0001, - StaysOnTop = 0x0002 - }; - Q_DECLARE_FLAGS(WindowFlags, WindowFlag) - - enum Type { - Invalid, - Shm, - Texture - }; - - WaylandSurface(Wayland::Surface *surface = 0); - - WaylandClient *client() const; - - WaylandSurface *parentSurface() const; - QLinkedList subSurfaces() const; - - Type type() const; - bool isYInverted() const; - - bool visible() const; - - QPointF pos() const; - void setPos(const QPointF &pos); - QSize size() const; - void setSize(const QSize &size); - void sendConfigure(const QSize &size); - - Qt::ScreenOrientations orientationUpdateMask() const; - Qt::ScreenOrientation contentOrientation() const; - - WindowFlags windowFlags() const; - - QImage image() const; -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint texture(QOpenGLContext *context) const; -#else - uint texture(QOpenGLContext *context) const; -#endif - - Q_INVOKABLE void sendOnScreenVisibilityChange(bool visible); - - void frameFinished(); - - WaylandSurface *transientParent() const; - - Wayland::Surface *handle() const; - -#ifdef QT_COMPOSITOR_QUICK - WaylandSurfaceItem *surfaceItem() const; - void setSurfaceItem(WaylandSurfaceItem *surfaceItem); -#endif - - qint64 processId() const; - QByteArray authenticationToken() const; - QVariantMap windowProperties() const; - void setWindowProperty(const QString &name, const QVariant &value); - - QPointF mapToParent(const QPointF &) const; - QPointF mapTo(WaylandSurface *, const QPointF &) const; - - WaylandCompositor *compositor() const; - - QString className() const; - - QString title() const; - - bool hasShellSurface() const; - - bool transientInactive() const; - -signals: - void mapped(); - void unmapped(); - void damaged(const QRect &rect); - void parentChanged(WaylandSurface *newParent, WaylandSurface *oldParent); - void sizeChanged(); - void posChanged(); - void windowPropertyChanged(const QString &name, const QVariant &value); - void windowFlagsChanged(WindowFlags flags); - void contentOrientationChanged(); - void orientationUpdateMaskChanged(); - void extendedSurfaceReady(); - void classNameChanged(); - void titleChanged(); - -}; - -#endif // WAYLANDSURFACE_H diff --git a/src/compositor/compositor_api/waylandsurfaceitem.cpp b/src/compositor/compositor_api/waylandsurfaceitem.cpp deleted file mode 100644 index f90809bc9..000000000 --- a/src/compositor/compositor_api/waylandsurfaceitem.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandsurfaceitem.h" -#include "waylandsurfacenode.h" -#include "waylandsurface.h" -#include "waylandcompositor.h" -#include "waylandinput.h" - -#include "wlsurface.h" -#include "wlextendedsurface.h" - -#include -#include -#include - -#include -#include - -#include -#include - - -class WaylandSurfaceTextureProvider : public QSGTextureProvider -{ - Q_OBJECT - -public: - WaylandSurfaceTextureProvider() : t(0) { } - ~WaylandSurfaceTextureProvider() { delete t; } - - QSGTexture *texture() const { - if (t) - t->setFiltering(smooth ? QSGTexture::Linear : QSGTexture::Nearest); - return t; - } - - bool smooth; - QSGTexture *t; - -public slots: - void invalidate() - { - delete t; - t = 0; - } -}; - -QMutex *WaylandSurfaceItem::mutex = 0; - -WaylandSurfaceItem::WaylandSurfaceItem(QQuickItem *parent) - : QQuickItem(parent) - , m_surface(0) - , m_provider(0) - , m_node(0) - , m_paintEnabled(true) - , m_useTextureAlpha(false) - , m_clientRenderingEnabled(false) - , m_touchEventsEnabled(false) -{ - if (!mutex) - mutex = new QMutex; -} - -WaylandSurfaceItem::WaylandSurfaceItem(WaylandSurface *surface, QQuickItem *parent) - : QQuickItem(parent) - , m_surface(0) - , m_provider(0) - , m_node(0) - , m_paintEnabled(true) - , m_useTextureAlpha(false) - , m_clientRenderingEnabled(false) - , m_touchEventsEnabled(false) -{ - init(surface); -} - -void WaylandSurfaceItem::init(WaylandSurface *surface) -{ - if (!surface) - return; - - if (m_surface) { - m_surface->setSurfaceItem(0); - } - - m_surface = surface; - m_surface->setSurfaceItem(this); - if (m_clientRenderingEnabled) { - m_surface->sendOnScreenVisibilityChange(m_clientRenderingEnabled); - } - - setWidth(surface->size().width()); - setHeight(surface->size().height()); - - setSmooth(true); - setFlag(ItemHasContents); - setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton | - Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::ExtraButton3 | Qt::ExtraButton4 | - Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 | - Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 | - Qt::ExtraButton12 | Qt::ExtraButton13); - setAcceptHoverEvents(true); - connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); - connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped())); - connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); - connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &))); - connect(surface, SIGNAL(parentChanged(WaylandSurface*,WaylandSurface*)), - this, SLOT(parentChanged(WaylandSurface*,WaylandSurface*))); - connect(surface, SIGNAL(sizeChanged()), this, SLOT(updateSize())); - connect(surface, SIGNAL(posChanged()), this, SLOT(updatePosition())); - - m_damaged = false; - m_yInverted = surface ? surface->isYInverted() : true; -} - -WaylandSurfaceItem::~WaylandSurfaceItem() -{ - QMutexLocker locker(mutex); - if (m_node) - m_node->setItem(0); - if (m_surface) - m_surface->setSurfaceItem(0); - if (m_provider) - m_provider->deleteLater(); -} - -void WaylandSurfaceItem::setSurface(WaylandSurface *surface) -{ - if (surface == m_surface) - return; - - init(surface); - emit surfaceChanged(); -} - -bool WaylandSurfaceItem::isYInverted() const -{ - return m_yInverted; -} - -QSGTextureProvider *WaylandSurfaceItem::textureProvider() const -{ - const_cast(this)->ensureProvider(); - return m_provider; -} - -void WaylandSurfaceItem::ensureProvider() -{ - if (!m_provider) { - m_provider = new WaylandSurfaceTextureProvider(); - connect(window(), SIGNAL(sceneGraphInvalidated()), m_provider, SLOT(invalidate()), Qt::DirectConnection); - } -} - -void WaylandSurfaceItem::mousePressEvent(QMouseEvent *event) -{ - if (m_surface) { - WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); - if (inputDevice->mouseFocus() != m_surface) - inputDevice->setMouseFocus(m_surface, event->pos(), event->globalPos()); - inputDevice->sendMousePressEvent(event->button(), toSurface(event->pos()), event->globalPos()); - } -} - -void WaylandSurfaceItem::mouseMoveEvent(QMouseEvent *event) -{ - if (m_surface){ - WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); - inputDevice->sendMouseMoveEvent(m_surface, toSurface(event->pos()), event->globalPos()); - } -} - -void WaylandSurfaceItem::mouseReleaseEvent(QMouseEvent *event) -{ - if (m_surface){ - WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); - inputDevice->sendMouseReleaseEvent(event->button(), toSurface(event->pos()), event->globalPos()); - } -} - -void WaylandSurfaceItem::wheelEvent(QWheelEvent *event) -{ - if (m_surface) { - WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); - inputDevice->sendMouseWheelEvent(event->orientation(), event->delta()); - } -} - -void WaylandSurfaceItem::keyPressEvent(QKeyEvent *event) -{ - if (m_surface && hasFocus()) { - WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); - inputDevice->sendFullKeyEvent(event); - } -} - -void WaylandSurfaceItem::keyReleaseEvent(QKeyEvent *event) -{ - if (m_surface && hasFocus()) { - WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); - inputDevice->sendFullKeyEvent(event); - } -} - -void WaylandSurfaceItem::touchEvent(QTouchEvent *event) -{ - if (m_touchEventsEnabled && m_surface) { - WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); - event->accept(); - if (inputDevice->mouseFocus() != m_surface) { - QPoint pointPos; - QList points = event->touchPoints(); - if (!points.isEmpty()) - pointPos = points.at(0).pos().toPoint(); - inputDevice->setMouseFocus(m_surface, pointPos, pointPos); - } - inputDevice->sendFullTouchEvent(event); - } else { - event->ignore(); - } -} - -void WaylandSurfaceItem::takeFocus() -{ - setFocus(true); - - if (m_surface) { - WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); - inputDevice->setKeyboardFocus(m_surface); - } -} - -QPoint WaylandSurfaceItem::toSurface(const QPointF &pos) const -{ - return pos.toPoint(); -} - -void WaylandSurfaceItem::surfaceMapped() -{ - setPaintEnabled(true); -} - -void WaylandSurfaceItem::surfaceUnmapped() -{ - setPaintEnabled(false); -} - -void WaylandSurfaceItem::surfaceDestroyed(QObject *) -{ - m_surface = 0; -} - -void WaylandSurfaceItem::setDamagedFlag(bool on) -{ - m_damaged = on; -} - - -void WaylandSurfaceItem::surfaceDamaged(const QRect &) -{ - m_damaged = true; - if (m_surface) { - bool inverted = m_surface->isYInverted(); - if (inverted != m_yInverted) { - m_yInverted = inverted; - emit yInvertedChanged(); - } - } - emit textureChanged(); - update(); -} - -void WaylandSurfaceItem::parentChanged(WaylandSurface *newParent, WaylandSurface *oldParent) -{ - Q_UNUSED(oldParent); - - WaylandSurfaceItem *item = newParent? newParent->surfaceItem():0; - setParentItem(item); - - if (newParent) { - setPaintEnabled(true); - setVisible(true); - setOpacity(1); - setEnabled(true); - } -} - -void WaylandSurfaceItem::updateSize() -{ - setSize(m_surface->size()); -} - -void WaylandSurfaceItem::updatePosition() -{ - setPosition(m_surface->pos()); -} - -bool WaylandSurfaceItem::paintEnabled() const -{ - return m_paintEnabled; -} - -void WaylandSurfaceItem::setPaintEnabled(bool enabled) -{ - m_paintEnabled = enabled; - update(); -} - -void WaylandSurfaceItem::updateTexture() -{ - ensureProvider(); - QSGTexture *texture = m_provider->t; - if (m_damaged) { - m_damaged = false; - QSGTexture *oldTexture = texture; - if (m_surface->type() == WaylandSurface::Texture) { - QOpenGLContext *context = QOpenGLContext::currentContext(); - QQuickWindow::CreateTextureOptions opt = 0; - if (useTextureAlpha()) { - opt |= QQuickWindow::TextureHasAlphaChannel; - } - texture = window()->createTextureFromId(m_surface->texture(context), m_surface->size(), opt); - } else { - texture = window()->createTextureFromImage(m_surface->image()); - } - texture->bind(); - delete oldTexture; - } - - m_provider->t = texture; - m_provider->smooth = smooth(); -} - -QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) -{ - if (!m_surface) { - delete oldNode; - return 0; - } - - updateTexture(); - if (!m_provider->t || !m_paintEnabled) { - delete oldNode; - return 0; - } - - WaylandSurfaceNode *node = static_cast(oldNode); - - if (!node) { - node = new WaylandSurfaceNode(this); - } - - node->updateTexture(); - - if (surface()->isYInverted()) { - node->setRect(0, height(), width(), -height()); - } else { - node->setRect(0, 0, width(), height()); - } - - node->setTextureUpdated(true); - - return node; -} - -void WaylandSurfaceItem::setUseTextureAlpha(bool useTextureAlpha) -{ - m_useTextureAlpha = useTextureAlpha; - - if ((flags() & ItemHasContents) != 0) { - update(); - } -} - -void WaylandSurfaceItem::setClientRenderingEnabled(bool enabled) -{ - if (m_clientRenderingEnabled != enabled) { - m_clientRenderingEnabled = enabled; - - if (m_surface) { - m_surface->sendOnScreenVisibilityChange(enabled); - } - - emit clientRenderingEnabledChanged(); - } -} - -void WaylandSurfaceItem::setTouchEventsEnabled(bool enabled) -{ - if (m_touchEventsEnabled != enabled) { - m_touchEventsEnabled = enabled; - emit touchEventsEnabledChanged(); - } -} - -#include "waylandsurfaceitem.moc" diff --git a/src/compositor/compositor_api/waylandsurfaceitem.h b/src/compositor/compositor_api/waylandsurfaceitem.h deleted file mode 100644 index 6888262ab..000000000 --- a/src/compositor/compositor_api/waylandsurfaceitem.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLANDSURFACEITEM_H -#define WAYLANDSURFACEITEM_H - -#include "waylandexport.h" -#include "waylandsurface.h" - -#include -#include - -#include - -class WaylandSurfaceTextureProvider; -class WaylandSurfaceNode; -class QMutex; - -Q_DECLARE_METATYPE(WaylandSurface*) - -class Q_COMPOSITOR_EXPORT WaylandSurfaceItem : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(WaylandSurface* surface READ surface WRITE setSurface NOTIFY surfaceChanged) - Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled) - Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha NOTIFY useTextureAlphaChanged) - Q_PROPERTY(bool clientRenderingEnabled READ clientRenderingEnabled WRITE setClientRenderingEnabled NOTIFY clientRenderingEnabledChanged) - Q_PROPERTY(bool touchEventsEnabled READ touchEventsEnabled WRITE setTouchEventsEnabled NOTIFY touchEventsEnabledChanged) - Q_PROPERTY(bool isYInverted READ isYInverted NOTIFY yInvertedChanged) - -public: - WaylandSurfaceItem(QQuickItem *parent = 0); - WaylandSurfaceItem(WaylandSurface *surface, QQuickItem *parent = 0); - ~WaylandSurfaceItem(); - - void setSurface(WaylandSurface *surface); - WaylandSurface *surface() const {return m_surface; } - - Q_INVOKABLE bool isYInverted() const; - - bool isTextureProvider() const { return true; } - QSGTextureProvider *textureProvider() const; - - bool paintEnabled() const; - bool useTextureAlpha() const { return m_useTextureAlpha; } - bool clientRenderingEnabled() const { return m_clientRenderingEnabled; } - bool touchEventsEnabled() const { return m_touchEventsEnabled; } - - void setUseTextureAlpha(bool useTextureAlpha); - void setClientRenderingEnabled(bool enabled); - void setTouchEventsEnabled(bool enabled); - - void setDamagedFlag(bool on); - -protected: - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); - - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); - - void touchEvent(QTouchEvent *event); - -public slots: - void takeFocus(); - void setPaintEnabled(bool paintEnabled); - -private slots: - void surfaceMapped(); - void surfaceUnmapped(); - void surfaceDestroyed(QObject *object); - void surfaceDamaged(const QRect &); - void parentChanged(WaylandSurface *newParent, WaylandSurface *oldParent); - void updateSize(); - void updatePosition(); - -signals: - void textureChanged(); - void useTextureAlphaChanged(); - void clientRenderingEnabledChanged(); - void touchEventsEnabledChanged(); - void yInvertedChanged(); - void surfaceChanged(); - -protected: - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); - -private: - friend class WaylandSurfaceNode; - void updateTexture(); - QPoint toSurface(const QPointF &pos) const; - void init(WaylandSurface *); - void ensureProvider(); - - static QMutex *mutex; - - WaylandSurface *m_surface; - WaylandSurfaceTextureProvider *m_provider; - WaylandSurfaceNode *m_node; - bool m_paintEnabled; - bool m_useTextureAlpha; - bool m_clientRenderingEnabled; - bool m_touchEventsEnabled; - bool m_damaged; - bool m_yInverted; -}; - -#endif diff --git a/src/compositor/compositor_api/waylandsurfacenode.cpp b/src/compositor/compositor_api/waylandsurfacenode.cpp deleted file mode 100644 index a6188ff7f..000000000 --- a/src/compositor/compositor_api/waylandsurfacenode.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandsurfacenode.h" -#include "waylandsurfaceitem.h" - -#include -#include -#include -#include - -WaylandSurfaceNode::WaylandSurfaceNode(WaylandSurfaceItem *item) - : m_item(item) - , m_textureUpdated(false) - , m_useTextureAlpha(false) - , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) -{ - m_textureMaterial = WaylandSurfaceTextureMaterial::createMaterial(); - m_opaqueTextureMaterial = WaylandSurfaceTextureOpaqueMaterial::createMaterial(); - - m_currentMaterial = m_opaqueTextureMaterial; - - setGeometry(&m_geometry); - setMaterial(m_currentMaterial); - - if (m_item) - m_item->m_node = this; - setFlag(UsePreprocess,true); -} - - -WaylandSurfaceNode::~WaylandSurfaceNode() -{ - QMutexLocker locker(WaylandSurfaceItem::mutex); - if (m_item) - m_item->m_node = 0; - delete m_textureMaterial; - delete m_opaqueTextureMaterial; -} - -void WaylandSurfaceNode::preprocess() -{ - QMutexLocker locker(WaylandSurfaceItem::mutex); - - if (m_item && m_item->surface()) { - //Update if the item is dirty and we haven't done an updateTexture for this frame - if (m_item->m_damaged && !m_textureUpdated) { - m_item->updateTexture(); - updateTexture(); - } - } - //Reset value for next frame: we have not done updatePaintNode yet - m_textureUpdated = false; -} - -void WaylandSurfaceNode::updateTexture() -{ - Q_ASSERT(m_item && m_item->textureProvider()); - - //If m_item->useTextureAlpha has changed to true use m_texureMaterial - //otherwise use m_opaqueTextureMaterial. - if (m_item->useTextureAlpha() != m_useTextureAlpha) { - m_useTextureAlpha = m_item->useTextureAlpha(); - if (m_useTextureAlpha) { - m_currentMaterial = m_textureMaterial; - } else { - m_currentMaterial = m_opaqueTextureMaterial; - } - setMaterial(m_currentMaterial); - } - - QSGTexture *texture = m_item->textureProvider()->texture(); - setTexture(texture); -} - -void WaylandSurfaceNode::setRect(const QRectF &rect) -{ - if (m_rect == rect) - return; - m_rect = rect; - - if (texture()) { - QSize ts = texture()->textureSize(); - QRectF sourceRect(0, 0, ts.width(), ts.height()); - QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_rect, texture()->convertToNormalizedSourceRect(sourceRect)); - } -} - -void WaylandSurfaceNode::setTexture(QSGTexture *texture) -{ - if (m_currentMaterial->state()->texture() == texture) - return; - m_currentMaterial->state()->setTexture(texture); - - QSize ts = texture->textureSize(); - QRectF sourceRect(0, 0, ts.width(), ts.height()); - QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_rect, texture->convertToNormalizedSourceRect(sourceRect)); - markDirty(DirtyMaterial); -} - -QSGTexture *WaylandSurfaceNode::texture() const -{ - return m_currentMaterial->state()->texture(); -} - -void WaylandSurfaceNode::setItem(WaylandSurfaceItem *item) -{ - m_item = item; -} diff --git a/src/compositor/compositor_api/waylandsurfacenode.h b/src/compositor/compositor_api/waylandsurfacenode.h deleted file mode 100644 index f4c9c0ece..000000000 --- a/src/compositor/compositor_api/waylandsurfacenode.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLANDSURFACENODE_H -#define WAYLANDSURFACENODE_H - -#include "waylandsurfacetexturematerial.h" - -#include -#include - -class WaylandSurfaceItem; -class QSGTexture; - -class WaylandSurfaceNode : public QSGGeometryNode -{ -public: - WaylandSurfaceNode(WaylandSurfaceItem *item = 0); - ~WaylandSurfaceNode(); - - void preprocess(); - void updateTexture(); - - void setRect(const QRectF &rect); - inline void setRect(qreal x, qreal y, qreal w, qreal h) { setRect(QRectF(x, y, w, h)); } - - void setTexture(QSGTexture *texture); - QSGTexture *texture() const; - - bool isTextureUpdated() const { return m_textureUpdated; } - void setTextureUpdated(bool textureUpdated) { m_textureUpdated = textureUpdated; } - - WaylandSurfaceItem *item() const { return m_item; } - void setItem(WaylandSurfaceItem *item); - -private: - - WaylandSurfaceItem *m_item; - bool m_textureUpdated; - bool m_useTextureAlpha; - - QSGGeometry m_geometry; - QSGSimpleMaterial *m_textureMaterial; - QSGSimpleMaterial *m_opaqueTextureMaterial; - QSGSimpleMaterial *m_currentMaterial; - - QRectF m_rect; -}; - -#endif // WAYLANDSURFACENODE_H diff --git a/src/compositor/compositor_api/waylandsurfacetexturematerial.cpp b/src/compositor/compositor_api/waylandsurfacetexturematerial.cpp deleted file mode 100644 index 0ec8ccb48..000000000 --- a/src/compositor/compositor_api/waylandsurfacetexturematerial.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandsurfacetexturematerial.h" -#include - -static const char wayland_surface_texture_material_vertex[] = - "uniform highp mat4 qt_Matrix; \n" - "attribute highp vec4 qt_VertexPosition; \n" - "attribute highp vec2 qt_VertexTexCoord; \n" - "varying highp vec2 qt_TexCoord; \n" - "void main() { \n" - " qt_TexCoord = qt_VertexTexCoord; \n" - " gl_Position = qt_Matrix * qt_VertexPosition; \n" - "}"; - - -static const char wayland_surface_texture_opaque_material_fragment[] = - "varying highp vec2 qt_TexCoord; \n" - "uniform sampler2D qt_Texture; \n" - "uniform lowp float qt_Opacity; \n" - "void main() { \n" - " gl_FragColor = vec4(texture2D(qt_Texture, qt_TexCoord).rgb, 1.0) * qt_Opacity; \n" - "}"; - -static const char wayland_surface_texture_material_fragment[] = - "varying highp vec2 qt_TexCoord; \n" - "uniform sampler2D qt_Texture; \n" - "uniform lowp float qt_Opacity; \n" - "void main() { \n" - " gl_FragColor = texture2D(qt_Texture, qt_TexCoord) * qt_Opacity; \n" - "}"; - -QList WaylandSurfaceTextureMaterial::attributes() const -{ - QList attributeList; - attributeList << "qt_VertexPosition"; - attributeList << "qt_VertexTexCoord"; - return attributeList; -} - -void WaylandSurfaceTextureMaterial::updateState(const WaylandSurfaceTextureState *newState, const WaylandSurfaceTextureState *oldState) -{ - Q_UNUSED(oldState); - newState->texture()->bind(); -} - -const char *WaylandSurfaceTextureMaterial::vertexShader() const -{ - return wayland_surface_texture_material_vertex; -} - -const char *WaylandSurfaceTextureMaterial::fragmentShader() const -{ - return wayland_surface_texture_material_fragment; -} - -QList WaylandSurfaceTextureOpaqueMaterial::attributes() const -{ - QList attributeList; - attributeList << "qt_VertexPosition"; - attributeList << "qt_VertexTexCoord"; - return attributeList; -} - -void WaylandSurfaceTextureOpaqueMaterial::updateState(const WaylandSurfaceTextureState *newState, const WaylandSurfaceTextureState *oldState) -{ - Q_UNUSED(oldState); - newState->texture()->bind(); -} - -const char *WaylandSurfaceTextureOpaqueMaterial::vertexShader() const -{ - return wayland_surface_texture_material_vertex; -} - -const char *WaylandSurfaceTextureOpaqueMaterial::fragmentShader() const -{ - return wayland_surface_texture_opaque_material_fragment; -} diff --git a/src/compositor/compositor_api/waylandsurfacetexturematerial.h b/src/compositor/compositor_api/waylandsurfacetexturematerial.h deleted file mode 100644 index 4f5b66a3a..000000000 --- a/src/compositor/compositor_api/waylandsurfacetexturematerial.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLANDSURFACETEXTUREMATERIAL_H -#define WAYLANDSURFACETEXTUREMATERIAL_H - -#include -#include -#include - -class WaylandSurfaceTextureState { -public: - WaylandSurfaceTextureState() - : m_texture(0) - {} - void setTexture(QSGTexture *texture) { m_texture = texture; } - QSGTexture *texture() const { return m_texture; } - -private: - QSGTexture *m_texture; -}; - -class WaylandSurfaceTextureMaterial : public QSGSimpleMaterialShader -{ - QSG_DECLARE_SIMPLE_SHADER(WaylandSurfaceTextureMaterial, WaylandSurfaceTextureState) - public: - - QList attributes() const; - - void updateState(const WaylandSurfaceTextureState *newState, const WaylandSurfaceTextureState *oldState); -protected: - const char *vertexShader() const; - const char *fragmentShader() const; -}; - -class WaylandSurfaceTextureOpaqueMaterial : public QSGSimpleMaterialShader -{ - QSG_DECLARE_SIMPLE_SHADER(WaylandSurfaceTextureOpaqueMaterial, WaylandSurfaceTextureState) - public: - - QList attributes() const; - - void updateState(const WaylandSurfaceTextureState *newState, const WaylandSurfaceTextureState *oldState); -protected: - const char *vertexShader() const; - const char *fragmentShader() const; -}; - -#endif // WAYLANDSURFACETEXTUREMATERIAL_H diff --git a/src/compositor/global/global.pri b/src/compositor/global/global.pri index 4dcbe340e..f187619e5 100644 --- a/src/compositor/global/global.pri +++ b/src/compositor/global/global.pri @@ -1,10 +1,10 @@ -INCLUDEPATH += $$PWD +INCLUDEPATH += global/ HEADERS += \ - $$PWD/waylandexport.h \ - $$PWD/waylandobject.h \ - $$PWD/waylandresourcecollection.h \ + global/qwaylandexport.h \ + global/qwaylandobject.h \ + global/qwaylandresourcecollection.h SOURCES += \ - $$PWD/waylandresourcecollection.cpp \ + global/qwaylandresourcecollection.cpp diff --git a/src/compositor/global/qwaylandexport.h b/src/compositor/global/qwaylandexport.h new file mode 100644 index 000000000..4998f836f --- /dev/null +++ b/src/compositor/global/qwaylandexport.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WAYLANDEXPORT_H +#define WAYLANDEXPORT_H + +#include + +QT_BEGIN_NAMESPACE + +#if !defined(Q_COMPOSITOR_EXPORT) +# if defined(QT_SHARED) +# define Q_COMPOSITOR_EXPORT Q_DECL_EXPORT +# else +# define Q_COMPOSITOR_EXPORT +# endif +#endif + +typedef void WaylandClient; + +QT_END_NAMESPACE + +#endif //WAYLANDEXPORT_H diff --git a/src/compositor/global/qwaylandobject.h b/src/compositor/global/qwaylandobject.h new file mode 100644 index 000000000..6d93297a1 --- /dev/null +++ b/src/compositor/global/qwaylandobject.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WAYLAND_OBJECT_H +#define WAYLAND_OBJECT_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +template +class Object : public T +{ +public: + typedef T Base; + + Object() { memset(this, 0, sizeof(T)); } + + const T *base() const { return this; } + T *base() { return this; } + + template + void addClientResource(wl_client *client, + wl_resource *resource, + int id, const struct wl_interface *interface, + Implementation implementation, + void (*destroy)(struct wl_resource *resource)) + { + resource->object.id = id; + resource->object.interface = interface; + resource->object.implementation = (void (**)(void))implementation; + resource->data = this; + resource->destroy = destroy; + + wl_client_add_resource(client, resource); + } +}; + +template +T *resolve(wl_resource *from) +{ + Object *object = reinterpret_cast *>(from->data); + return static_cast(object); +} + +template +T *wayland_cast(typename T::Base *from) +{ + Object *object = reinterpret_cast *>(from); + return static_cast(object); +} + +} + +QT_END_NAMESPACE + +#endif //WAYLAND_OBJECT_H diff --git a/src/compositor/global/qwaylandresourcecollection.cpp b/src/compositor/global/qwaylandresourcecollection.cpp new file mode 100644 index 000000000..6433474a3 --- /dev/null +++ b/src/compositor/global/qwaylandresourcecollection.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandresourcecollection.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +ResourceCollection::ResourceCollection() +{ + wl_list_init(&client_resources); +} + +ResourceCollection::~ResourceCollection() +{ + +} + +void ResourceCollection::registerResource(struct wl_resource *resource) +{ + wl_list_insert(&client_resources,&resource->link); + struct wl_listener *listener = new struct wl_listener; + listener->notify = ResourceCollection::destroy_listener_notify; + wl_signal_add(&resource->destroy_signal, listener); +} + +struct wl_resource *ResourceCollection::resourceForClient(wl_client *client) const +{ + struct wl_resource *resource; + wl_list_for_each(resource,&client_resources, link) { + if (resource->client == client) { + return resource; + } + } + return 0; + +} + +bool ResourceCollection::resourceListIsEmpty() const +{ + return wl_list_empty(const_cast(&client_resources)); +} + +void ResourceCollection::destroy_listener_notify(struct wl_listener *listener, void *data) +{ + struct wl_resource *resource = reinterpret_cast(data); + wl_list_remove(&resource->link); + delete listener; +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/global/qwaylandresourcecollection.h b/src/compositor/global/qwaylandresourcecollection.h new file mode 100644 index 000000000..cfc1c32cb --- /dev/null +++ b/src/compositor/global/qwaylandresourcecollection.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WAYLAND_RESOURCE_OBJECT_H +#define WAYLAND_RESOURCE_OBJECT_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class ResourceCollection +{ +public: + ResourceCollection(); + virtual ~ResourceCollection(); + void registerResource(struct wl_resource *resource); + struct wl_resource *resourceForClient(struct wl_client *client) const; + bool resourceListIsEmpty() const; + +protected: + struct wl_list client_resources; +private: + static void destroy_listener_notify(struct wl_listener *listener, void *data); +}; + +} + +QT_END_NAMESPACE + +#endif //WAYLAND_RESOURCE_OBJECT_H diff --git a/src/compositor/global/waylandexport.h b/src/compositor/global/waylandexport.h deleted file mode 100644 index 7d1685b31..000000000 --- a/src/compositor/global/waylandexport.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLANDEXPORT_H -#define WAYLANDEXPORT_H - -#include - -#if !defined(Q_COMPOSITOR_EXPORT) -# if defined(QT_SHARED) -# define Q_COMPOSITOR_EXPORT Q_DECL_EXPORT -# else -# define Q_COMPOSITOR_EXPORT -# endif -#endif - -typedef void WaylandClient; - -#endif //WAYLANDEXPORT_H diff --git a/src/compositor/global/waylandobject.h b/src/compositor/global/waylandobject.h deleted file mode 100644 index 3f735fda2..000000000 --- a/src/compositor/global/waylandobject.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLAND_OBJECT_H -#define WAYLAND_OBJECT_H - -#include - -#include - -namespace Wayland { - -template -class Object : public T -{ -public: - typedef T Base; - - Object() { memset(this, 0, sizeof(T)); } - - const T *base() const { return this; } - T *base() { return this; } - - template - void addClientResource(wl_client *client, - wl_resource *resource, - int id, const struct wl_interface *interface, - Implementation implementation, - void (*destroy)(struct wl_resource *resource)) - { - resource->object.id = id; - resource->object.interface = interface; - resource->object.implementation = (void (**)(void))implementation; - resource->data = this; - resource->destroy = destroy; - - wl_client_add_resource(client, resource); - } -}; - -template -T *resolve(wl_resource *from) -{ - Object *object = reinterpret_cast *>(from->data); - return static_cast(object); -} - -template -T *wayland_cast(typename T::Base *from) -{ - Object *object = reinterpret_cast *>(from); - return static_cast(object); -} - -} - -#endif //WAYLAND_OBJECT_H diff --git a/src/compositor/global/waylandresourcecollection.cpp b/src/compositor/global/waylandresourcecollection.cpp deleted file mode 100644 index 0f57750fc..000000000 --- a/src/compositor/global/waylandresourcecollection.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandresourcecollection.h" - -#include - -namespace Wayland { - -ResourceCollection::ResourceCollection() -{ - wl_list_init(&client_resources); -} - -ResourceCollection::~ResourceCollection() -{ - -} - -void ResourceCollection::registerResource(struct wl_resource *resource) -{ - wl_list_insert(&client_resources,&resource->link); - struct wl_listener *listener = new struct wl_listener; - listener->notify = ResourceCollection::destroy_listener_notify; - wl_signal_add(&resource->destroy_signal, listener); -} - -struct wl_resource *ResourceCollection::resourceForClient(wl_client *client) const -{ - struct wl_resource *resource; - wl_list_for_each(resource,&client_resources, link) { - if (resource->client == client) { - return resource; - } - } - return 0; - -} - -bool ResourceCollection::resourceListIsEmpty() const -{ - return wl_list_empty(const_cast(&client_resources)); -} - -void ResourceCollection::destroy_listener_notify(struct wl_listener *listener, void *data) -{ - struct wl_resource *resource = reinterpret_cast(data); - wl_list_remove(&resource->link); - delete listener; -} - - -} diff --git a/src/compositor/global/waylandresourcecollection.h b/src/compositor/global/waylandresourcecollection.h deleted file mode 100644 index 8bcc5bd2b..000000000 --- a/src/compositor/global/waylandresourcecollection.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLAND_RESOURCE_OBJECT_H -#define WAYLAND_RESOURCE_OBJECT_H - -#include - -namespace Wayland { - -class ResourceCollection -{ -public: - ResourceCollection(); - virtual ~ResourceCollection(); - void registerResource(struct wl_resource *resource); - struct wl_resource *resourceForClient(struct wl_client *client) const; - bool resourceListIsEmpty() const; - -protected: - struct wl_list client_resources; -private: - static void destroy_listener_notify(struct wl_listener *listener, void *data); -}; - -} - -#endif //WAYLAND_RESOURCE_OBJECT_H diff --git a/src/compositor/hardware_integration/graphicshardwareintegration.cpp b/src/compositor/hardware_integration/graphicshardwareintegration.cpp deleted file mode 100644 index 13b460d71..000000000 --- a/src/compositor/hardware_integration/graphicshardwareintegration.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "graphicshardwareintegration.h" - -GraphicsHardwareIntegration::GraphicsHardwareIntegration() - : m_compositor(0) -{ -} diff --git a/src/compositor/hardware_integration/graphicshardwareintegration.h b/src/compositor/hardware_integration/graphicshardwareintegration.h deleted file mode 100644 index f6c46debf..000000000 --- a/src/compositor/hardware_integration/graphicshardwareintegration.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRAPHICSHARDWAREINTEGRATION_H -#define GRAPHICSHARDWAREINTEGRATION_H - -#include -#include -#include - -#include -#include - -class Q_COMPOSITOR_EXPORT GraphicsHardwareIntegration -{ -public: - GraphicsHardwareIntegration(); - virtual ~GraphicsHardwareIntegration() { } - - void setCompositor(WaylandCompositor *compositor) { m_compositor = compositor; } - - virtual void initializeHardware(Wayland::Display *waylandDisplay) = 0; - - /** Bind the Wayland buffer to the textureId. The correct context is the current context, - so there is no need to do makeCurrent in this function. - **/ - virtual GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context) = 0; - virtual bool isYInverted(struct wl_buffer *) const { return true; } - - virtual bool setDirectRenderSurface(WaylandSurface *) {return false;} - - virtual void *lockNativeBuffer(struct wl_buffer *, QOpenGLContext *) const { return 0; } - virtual void unlockNativeBuffer(void *, QOpenGLContext *) const { return; } - -protected: - WaylandCompositor *m_compositor; -}; - -#endif // GRAPHICSHARDWAREINTEGRATION_H diff --git a/src/compositor/hardware_integration/graphicshardwareintegrationfactory.cpp b/src/compositor/hardware_integration/graphicshardwareintegrationfactory.cpp deleted file mode 100644 index d8337c6e5..000000000 --- a/src/compositor/hardware_integration/graphicshardwareintegrationfactory.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "graphicshardwareintegrationfactory.h" -#include "graphicshardwareintegrationplugin.h" -#include "graphicshardwareintegration.h" -#include -#include -#include - -#ifndef QT_NO_LIBRARY -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, - (GraphicsHardwareIntegrationFactoryInterface_iid, QLatin1String("/waylandcompositors"), Qt::CaseInsensitive)) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, - (GraphicsHardwareIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif - -QStringList GraphicsHardwareIntegrationFactory::keys(const QString &pluginPath) -{ -#ifndef QT_NO_LIBRARY - QStringList list; - if (!pluginPath.isEmpty()) { - QCoreApplication::addLibraryPath(pluginPath); - list = directLoader()->keyMap().values(); - if (!list.isEmpty()) { - const QString postFix = QStringLiteral(" (from ") - + QDir::toNativeSeparators(pluginPath) - + QLatin1Char(')'); - const QStringList::iterator end = list.end(); - for (QStringList::iterator it = list.begin(); it != end; ++it) - (*it).append(postFix); - } - } - list.append(loader()->keyMap().values()); - return list; -#else - return QStringList(); -#endif -} - -GraphicsHardwareIntegration *GraphicsHardwareIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) -{ -#ifndef QT_NO_LIBRARY - // Try loading the plugin from platformPluginPath first: - if (!pluginPath.isEmpty()) { - QCoreApplication::addLibraryPath(pluginPath); - if (GraphicsHardwareIntegration *ret = qLoadPlugin1(directLoader(), name, args)) - return ret; - } - if (GraphicsHardwareIntegration *ret = qLoadPlugin1(loader(), name, args)) - return ret; -#endif - return 0; -} diff --git a/src/compositor/hardware_integration/graphicshardwareintegrationfactory.h b/src/compositor/hardware_integration/graphicshardwareintegrationfactory.h deleted file mode 100644 index 22bcd09cf..000000000 --- a/src/compositor/hardware_integration/graphicshardwareintegrationfactory.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRAPHICSHARDWAREINTEGRATIONFACTORY_H -#define GRAPHICSHARDWAREINTEGRATIONFACTORY_H - -#include "waylandexport.h" -#include - -class GraphicsHardwareIntegration; - -class Q_COMPOSITOR_EXPORT GraphicsHardwareIntegrationFactory -{ -public: - static QStringList keys(const QString &pluginPath = QString()); - static GraphicsHardwareIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString()); -}; - -#endif // GRAPHICSHARDWAREINTEGRATIONFACTORY_H diff --git a/src/compositor/hardware_integration/graphicshardwareintegrationplugin.cpp b/src/compositor/hardware_integration/graphicshardwareintegrationplugin.cpp deleted file mode 100644 index 3bde8e8ab..000000000 --- a/src/compositor/hardware_integration/graphicshardwareintegrationplugin.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "graphicshardwareintegrationplugin.h" - -GraphicsHardwareIntegrationPlugin::GraphicsHardwareIntegrationPlugin(QObject *parent) : - QObject(parent) -{ -} - -GraphicsHardwareIntegrationPlugin::~GraphicsHardwareIntegrationPlugin() -{ -} - diff --git a/src/compositor/hardware_integration/graphicshardwareintegrationplugin.h b/src/compositor/hardware_integration/graphicshardwareintegrationplugin.h deleted file mode 100644 index 51f605164..000000000 --- a/src/compositor/hardware_integration/graphicshardwareintegrationplugin.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRAPHICSHARDWAREINTEGRATIONPLUGIN_H -#define GRAPHICSHARDWAREINTEGRATIONPLUGIN_H - -#include "waylandexport.h" - -#include -#include - -class GraphicsHardwareIntegration; - -#define GraphicsHardwareIntegrationFactoryInterface_iid "org.qt-project.Qt.Compositor.GraphicsHardwareIntegrationFactoryInterface.5.1" - -class Q_COMPOSITOR_EXPORT GraphicsHardwareIntegrationPlugin : public QObject -{ - Q_OBJECT -public: - explicit GraphicsHardwareIntegrationPlugin(QObject *parent = 0); - ~GraphicsHardwareIntegrationPlugin(); - - virtual GraphicsHardwareIntegration *create(const QString &key, const QStringList ¶mList) = 0; -}; - -#endif // GRAPHICSHARDWAREINTEGRATIONPLUGIN_H diff --git a/src/compositor/hardware_integration/hardware_integration.pri b/src/compositor/hardware_integration/hardware_integration.pri index 352dbaee6..8477243fe 100644 --- a/src/compositor/hardware_integration/hardware_integration.pri +++ b/src/compositor/hardware_integration/hardware_integration.pri @@ -4,21 +4,16 @@ isEmpty(QT_WAYLAND_GL_CONFIG):QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG) !isEqual(QT_WAYLAND_GL_CONFIG,nogl) { HEADERS += \ - $$PWD/graphicshardwareintegration.h + hardware_integration/qwaylandgraphicshardwareintegration.h \ + hardware_integration/qwaylandgraphicshardwareintegrationfactory.h \ + hardware_integration/qwaylandgraphicshardwareintegrationplugin.h SOURCES += \ - $$PWD/graphicshardwareintegration.cpp + hardware_integration/qwaylandgraphicshardwareintegration.cpp \ + hardware_integration/qwaylandgraphicshardwareintegrationfactory.cpp \ + hardware_integration/qwaylandgraphicshardwareintegrationplugin.cpp DEFINES += QT_COMPOSITOR_WAYLAND_GL } else { system(echo "Qt-Compositor configured as raster only compositor") } - -HEADERS += \ - hardware_integration/graphicshardwareintegrationplugin.h \ - hardware_integration/graphicshardwareintegrationfactory.h - -SOURCES += \ - hardware_integration/graphicshardwareintegrationplugin.cpp \ - hardware_integration/graphicshardwareintegrationfactory.cpp - diff --git a/src/compositor/hardware_integration/qwaylandgraphicshardwareintegration.cpp b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegration.cpp new file mode 100644 index 000000000..7b213bfa5 --- /dev/null +++ b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegration.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandgraphicshardwareintegration.h" + +QT_BEGIN_NAMESPACE + +QWaylandGraphicsHardwareIntegration::QWaylandGraphicsHardwareIntegration() + : m_compositor(0) +{ +} + +QT_END_NAMESPACE diff --git a/src/compositor/hardware_integration/qwaylandgraphicshardwareintegration.h b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegration.h new file mode 100644 index 000000000..373880440 --- /dev/null +++ b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegration.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GRAPHICSHARDWAREINTEGRATION_H +#define GRAPHICSHARDWAREINTEGRATION_H + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + class Display; +} + +class Q_COMPOSITOR_EXPORT QWaylandGraphicsHardwareIntegration +{ +public: + QWaylandGraphicsHardwareIntegration(); + virtual ~QWaylandGraphicsHardwareIntegration() { } + + void setCompositor(QWaylandCompositor *compositor) { m_compositor = compositor; } + + virtual void initializeHardware(QtWayland::Display *waylandDisplay) = 0; + + /** Bind the Wayland buffer to the textureId. The correct context is the current context, + so there is no need to do makeCurrent in this function. + **/ + virtual GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context) = 0; + virtual bool isYInverted(struct wl_buffer *) const { return true; } + + virtual bool setDirectRenderSurface(QWaylandSurface *) {return false;} + + virtual void *lockNativeBuffer(struct wl_buffer *, QOpenGLContext *) const { return 0; } + virtual void unlockNativeBuffer(void *, QOpenGLContext *) const { return; } + +protected: + QWaylandCompositor *m_compositor; +}; + +QT_END_NAMESPACE + +#endif // GRAPHICSHARDWAREINTEGRATION_H diff --git a/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationfactory.cpp b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationfactory.cpp new file mode 100644 index 000000000..17e2dbdbe --- /dev/null +++ b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationfactory.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandgraphicshardwareintegrationfactory.h" +#include "qwaylandgraphicshardwareintegrationplugin.h" +#include "qwaylandgraphicshardwareintegration.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_LIBRARY +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QWaylandGraphicsHardwareIntegrationFactoryInterface_iid, QLatin1String("/waylandcompositors"), Qt::CaseInsensitive)) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, + (QWaylandGraphicsHardwareIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) +#endif + +QStringList QWaylandGraphicsHardwareIntegrationFactory::keys(const QString &pluginPath) +{ +#ifndef QT_NO_LIBRARY + QStringList list; + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + list = directLoader()->keyMap().values(); + if (!list.isEmpty()) { + const QString postFix = QStringLiteral(" (from ") + + QDir::toNativeSeparators(pluginPath) + + QLatin1Char(')'); + const QStringList::iterator end = list.end(); + for (QStringList::iterator it = list.begin(); it != end; ++it) + (*it).append(postFix); + } + } + list.append(loader()->keyMap().values()); + return list; +#else + return QStringList(); +#endif +} + +QWaylandGraphicsHardwareIntegration *QWaylandGraphicsHardwareIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) +{ +#ifndef QT_NO_LIBRARY + // Try loading the plugin from platformPluginPath first: + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + if (QWaylandGraphicsHardwareIntegration *ret = qLoadPlugin1(directLoader(), name, args)) + return ret; + } + if (QWaylandGraphicsHardwareIntegration *ret = qLoadPlugin1(loader(), name, args)) + return ret; +#endif + return 0; +} + +QT_END_NAMESPACE diff --git a/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationfactory.h b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationfactory.h new file mode 100644 index 000000000..74e5dda0c --- /dev/null +++ b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationfactory.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GRAPHICSHARDWAREINTEGRATIONFACTORY_H +#define GRAPHICSHARDWAREINTEGRATIONFACTORY_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandGraphicsHardwareIntegration; + +class Q_COMPOSITOR_EXPORT QWaylandGraphicsHardwareIntegrationFactory +{ +public: + static QStringList keys(const QString &pluginPath = QString()); + static QWaylandGraphicsHardwareIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString()); +}; + +QT_END_NAMESPACE + +#endif // GRAPHICSHARDWAREINTEGRATIONFACTORY_H diff --git a/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationplugin.cpp b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationplugin.cpp new file mode 100644 index 000000000..66e07352e --- /dev/null +++ b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationplugin.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandgraphicshardwareintegrationplugin.h" + +QT_BEGIN_NAMESPACE + +QWaylandGraphicsHardwareIntegrationPlugin::QWaylandGraphicsHardwareIntegrationPlugin(QObject *parent) : + QObject(parent) +{ +} + +QWaylandGraphicsHardwareIntegrationPlugin::~QWaylandGraphicsHardwareIntegrationPlugin() +{ +} + +QT_END_NAMESPACE diff --git a/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationplugin.h b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationplugin.h new file mode 100644 index 000000000..6d68a0cc9 --- /dev/null +++ b/src/compositor/hardware_integration/qwaylandgraphicshardwareintegrationplugin.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GRAPHICSHARDWAREINTEGRATIONPLUGIN_H +#define GRAPHICSHARDWAREINTEGRATIONPLUGIN_H + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandGraphicsHardwareIntegration; + +#define QWaylandGraphicsHardwareIntegrationFactoryInterface_iid "org.qt-project.Qt.Compositor.QWaylandGraphicsHardwareIntegrationFactoryInterface.5.1" + +class Q_COMPOSITOR_EXPORT QWaylandGraphicsHardwareIntegrationPlugin : public QObject +{ + Q_OBJECT +public: + explicit QWaylandGraphicsHardwareIntegrationPlugin(QObject *parent = 0); + ~QWaylandGraphicsHardwareIntegrationPlugin(); + + virtual QWaylandGraphicsHardwareIntegration *create(const QString &key, const QStringList ¶mList) = 0; +}; + +QT_END_NAMESPACE + +#endif // GRAPHICSHARDWAREINTEGRATIONPLUGIN_H diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp new file mode 100644 index 000000000..26defc0ba --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp @@ -0,0 +1,573 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlcompositor_p.h" + +#include "qwaylandinput.h" +#include "qwldisplay_p.h" +#include "qwloutput_p.h" +#include "qwlsurface_p.h" +#include "qwaylandcompositor.h" +#include "qwldatadevicemanager_p.h" +#include "qwldatadevice_p.h" +#include "qwlextendedoutput_p.h" +#include "qwlextendedsurface_p.h" +#include "qwlsubsurface_p.h" +#include "qwlshellsurface_p.h" +#include "qwltouch_p.h" +#include "qwlqtkey_p.h" +#include "qwlinputdevice_p.h" +#include "qwlregion_p.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "hardware_integration/qwaylandgraphicshardwareintegration.h" +#include "waylandwindowmanagerintegration.h" + +#include "hardware_integration/qwaylandgraphicshardwareintegrationfactory.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +static Compositor *compositor; + +void compositor_create_surface(struct wl_client *client, + struct wl_resource *resource, uint32_t id) +{ + static_cast(resource->data)->createSurface(client,id); +} + +void compositor_create_region(struct wl_client *client, + struct wl_resource *compositor, uint32_t id) +{ + Q_UNUSED(compositor); + new Region(client, id); +} + +const static struct wl_compositor_interface compositor_interface = { + compositor_create_surface, + compositor_create_region +}; + +void Compositor::bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + wl_client_add_object(client,&wl_compositor_interface, &compositor_interface, id,data); +} + +Compositor *Compositor::instance() +{ + return compositor; +} + +Compositor::Compositor(QWaylandCompositor *qt_compositor) + : m_display(new Display) + , m_default_input_device(0) + , m_pageFlipper(0) + , m_current_frame(0) + , m_last_queued_buf(-1) + , m_qt_compositor(qt_compositor) + , m_orientation(Qt::PrimaryOrientation) + , m_directRenderSurface(0) + , m_directRenderContext(0) + , m_directRenderActive(false) +#if defined (QT_COMPOSITOR_WAYLAND_GL) + , m_graphics_hw_integration(0) +#endif + , m_outputExtension(0) + , m_surfaceExtension(0) + , m_subSurfaceExtension(0) + , m_touchExtension(0) + , m_retainNotify(0) +{ + compositor = this; + +#if defined (QT_COMPOSITOR_WAYLAND_GL) + QWindow *window = qt_compositor->window(); + if (window && window->surfaceType() != QWindow::RasterSurface) { + QStringList keys = QWaylandGraphicsHardwareIntegrationFactory::keys(); + QString targetKey; + QByteArray hardwareIntegration = qgetenv("QT_WAYLAND_HARDWARE_INTEGRATION"); + if (keys.contains(QString::fromLocal8Bit(hardwareIntegration.constData()))) { + targetKey = QString::fromLocal8Bit(hardwareIntegration.constData()); + } else if (keys.contains(QString::fromLatin1("wayland-egl"))) { + targetKey = QString::fromLatin1("wayland-egl"); + } else if (!keys.isEmpty()) { + targetKey = keys.first(); + } + + if (!targetKey.isEmpty()) { + m_graphics_hw_integration = QWaylandGraphicsHardwareIntegrationFactory::create(targetKey, QStringList()); + if (m_graphics_hw_integration) { + m_graphics_hw_integration->setCompositor(qt_compositor); + } + } + //BUG: if there is no hw_integration, bad things will probably happen + + } +#endif + m_windowManagerIntegration = new WindowManagerServerIntegration(qt_compositor, this); + + wl_display_add_global(m_display->handle(),&wl_compositor_interface,this,Compositor::bind_func); + + m_data_device_manager = new DataDeviceManager(this); + + wl_display_init_shm(m_display->handle()); + + m_output_global = new OutputGlobal(); + wl_display_add_global(m_display->handle(),&wl_output_interface, m_output_global, OutputGlobal::output_bind_func); + + m_shell = new Shell(); + wl_display_add_global(m_display->handle(), &wl_shell_interface, m_shell, Shell::bind_func); + + m_outputExtension = new OutputExtensionGlobal(this); + m_surfaceExtension = new SurfaceExtensionGlobal(this); + m_qtkeyExtension = new QtKeyExtensionGlobal(this); + m_touchExtension = new TouchExtensionGlobal(this); + + if (wl_display_add_socket(m_display->handle(), qt_compositor->socketName())) { + fprintf(stderr, "Fatal: Failed to open server socket\n"); + exit(EXIT_FAILURE); + } + + m_loop = wl_display_get_event_loop(m_display->handle()); + + int fd = wl_event_loop_get_fd(m_loop); + + QSocketNotifier *sockNot = new QSocketNotifier(fd, QSocketNotifier::Read, this); + connect(sockNot, SIGNAL(activated(int)), this, SLOT(processWaylandEvents())); + + QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher; + connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processWaylandEvents())); + + qRegisterMetaType("SurfaceBuffer*"); + //initialize distancefieldglyphcache here +} + +Compositor::~Compositor() +{ + delete m_shell; + delete m_outputExtension; + delete m_surfaceExtension; + delete m_subSurfaceExtension; + delete m_touchExtension; + delete m_qtkeyExtension; + + delete m_default_wayland_input_device; + delete m_data_device_manager; + +#ifdef QT_COMPOSITOR_WAYLAND_GL + delete m_graphics_hw_integration; +#endif + delete m_output_global; + delete m_display; +} + +void Compositor::frameFinished(Surface *surface) +{ + if (surface && m_dirty_surfaces.contains(surface)) { + m_dirty_surfaces.remove(surface); + surface->sendFrameCallback(); + } else if (!surface) { + QSet dirty = m_dirty_surfaces; + m_dirty_surfaces.clear(); + foreach (Surface *surface, dirty) + surface->sendFrameCallback(); + } +} + +void Compositor::createSurface(struct wl_client *client, uint32_t id) +{ + Surface *surface = new Surface(client,id, this); + + m_surfaces << surface; + //BUG: This may not be an on-screen window surface though + m_qt_compositor->surfaceCreated(surface->waylandSurface()); +} + +struct wl_client *Compositor::getClientFromWinId(uint winId) const +{ + Surface *surface = getSurfaceFromWinId(winId); + if (surface) + return surface->base()->resource.client; + + return 0; +} + +Surface *Compositor::getSurfaceFromWinId(uint winId) const +{ + foreach (Surface *surface, m_surfaces) { + if (surface->id() == winId) + return surface; + } + + return 0; +} + +QImage Compositor::image(uint winId) const +{ + foreach (Surface *surface, m_surfaces) { + if (surface->id() == winId) { + return surface->image(); + } + } + + return QImage(); +} + +uint Compositor::currentTimeMsecs() +{ + //### we throw away the time information + struct timeval tv; + int ret = gettimeofday(&tv, 0); + if (ret == 0) + return tv.tv_sec*1000 + tv.tv_usec/1000; + return 0; +} + +void Compositor::releaseBuffer(SurfaceBuffer *screenBuffer) +{ + screenBuffer->scheduledRelease(); +} + +void Compositor::processWaylandEvents() +{ + int ret = wl_event_loop_dispatch(m_loop, 0); + if (ret) + fprintf(stderr, "wl_event_loop_dispatch error: %d\n", ret); + wl_display_flush_clients(m_display->handle()); +} + +void Compositor::surfaceDestroyed(Surface *surface) +{ + InputDevice *dev = defaultInputDevice(); + if (dev->mouseFocus() == surface) { + dev->setMouseFocus(0, QPointF(), QPointF()); + // Make sure the surface is reset regardless of what the grabber + // interface's focus() does. (e.g. the default implementation does + // nothing when a button is down which would be disastrous here) + wl_pointer_set_focus(dev->pointerDevice(), 0, 0, 0); + } + if (dev->keyboardFocus() == surface) + dev->setKeyboardFocus(0); + + m_surfaces.removeOne(surface); + m_dirty_surfaces.remove(surface); + if (m_directRenderSurface == surface) + setDirectRenderSurface(0, 0); + + waylandCompositor()->surfaceAboutToBeDestroyed(surface->waylandSurface()); +} + +void Compositor::markSurfaceAsDirty(QtWayland::Surface *surface) +{ + m_dirty_surfaces.insert(surface); +} + +void Compositor::destroyClient(WaylandClient *c) +{ + wl_client *client = static_cast(c); + if (!client) + return; + + if (m_windowManagerIntegration->managedClient(client)) { + m_windowManagerIntegration->sendQuitMessage(client); + m_windowManagerIntegration->removeClient(client); + } else { + wl_client_destroy(client); + } +} + +QWindow *Compositor::window() const +{ + return m_qt_compositor->window(); +} + +QWaylandGraphicsHardwareIntegration * Compositor::graphicsHWIntegration() const +{ +#ifdef QT_COMPOSITOR_WAYLAND_GL + return m_graphics_hw_integration; +#else + return 0; +#endif +} + +void Compositor::initializeHardwareIntegration() +{ +#ifdef QT_COMPOSITOR_WAYLAND_GL + if (m_graphics_hw_integration) + m_graphics_hw_integration->initializeHardware(m_display); +#endif +} + +void Compositor::initializeDefaultInputDevice() +{ + m_default_wayland_input_device = new QWaylandInputDevice(m_qt_compositor); + m_default_input_device = m_default_wayland_input_device->handle(); +} + +void Compositor::initializeWindowManagerProtocol() +{ + m_windowManagerIntegration->initialize(m_display); +} + +void Compositor::enableSubSurfaceExtension() +{ + if (!m_subSurfaceExtension) { + m_subSurfaceExtension = new SubSurfaceExtensionGlobal(this); + } +} + +bool Compositor::setDirectRenderSurface(Surface *surface, QOpenGLContext *context) +{ +#ifdef QT_COMPOSITOR_WAYLAND_GL + if (!m_pageFlipper) { + m_pageFlipper = QGuiApplication::primaryScreen()->handle()->pageFlipper(); + } + + if (!surface) + setDirectRenderingActive(false); + + if (m_graphics_hw_integration && m_graphics_hw_integration->setDirectRenderSurface(surface ? surface->waylandSurface() : 0)) { + m_directRenderSurface = surface; + m_directRenderContext = context; + return true; + } +#else + Q_UNUSED(surface); +#endif + return false; +} + +void Compositor::setDirectRenderingActive(bool active) +{ + if (m_directRenderActive == active) + return; + m_directRenderActive = active; + + if (m_pageFlipper) + QMetaObject::invokeMethod(m_pageFlipper, "setDirectRenderingActive", Q_ARG(bool, active)); +} + +QList Compositor::clients() const +{ + QList list; + foreach (Surface *surface, m_surfaces) { + struct wl_client *client = surface->base()->resource.client; + if (!list.contains(client)) + list.append(client); + } + return list; +} + +Qt::ScreenOrientations Compositor::orientationUpdateMaskForClient(wl_client *client) +{ + Output *output = m_output_global->outputForClient(client); + Q_ASSERT(output); + if (output->extendedOutput()) + return output->extendedOutput()->orientationUpdateMask(); + return 0; +} + +void Compositor::setScreenOrientation(Qt::ScreenOrientation orientation) +{ + m_orientation = orientation; + + QList clientList = clients(); + for (int i = 0; i < clientList.length(); ++i) { + struct wl_client *client = clientList.at(i); + Output *output = m_output_global->outputForClient(client); + Q_ASSERT(output); + if (output->extendedOutput()){ + output->extendedOutput()->sendOutputOrientation(orientation); + } + } +} + +Qt::ScreenOrientation Compositor::screenOrientation() const +{ + return m_orientation; +} + +void Compositor::setOutputGeometry(const QRect &geometry) +{ + if (m_output_global) + m_output_global->setGeometry(geometry); +} + +QRect Compositor::outputGeometry() const +{ + if (m_output_global) + return m_output_global->geometry(); + return QRect(); +} + +void Compositor::setOutputRefreshRate(int rate) +{ + if (m_output_global) + m_output_global->setRefreshRate(rate); +} + +int Compositor::outputRefreshRate() const +{ + if (m_output_global) + return m_output_global->refreshRate(); + return 0; +} + +void Compositor::setClientFullScreenHint(bool value) +{ + m_windowManagerIntegration->setShowIsFullScreen(value); +} + +InputDevice* Compositor::defaultInputDevice() +{ + return m_default_input_device; +} + +QList Compositor::surfacesForClient(wl_client *client) +{ + QList ret; + + for (int i=0; i < m_surfaces.count(); ++i) { + if (m_surfaces.at(i)->base()->resource.client == client) { + ret.append(m_surfaces.at(i)); + } + } + return ret; +} + +wl_resource *Compositor::resourceForSurface(wl_list *resourceList, Surface *surface) +{ + if (!surface) + return 0; + + wl_resource *r; + wl_client *surfaceClient = surface->base()->resource.client; + + wl_list_for_each(r, resourceList, link) { + if (r->client == surfaceClient) + return r; + } + + return 0; +} + +void Compositor::configureTouchExtension(int flags) +{ + if (m_touchExtension) + m_touchExtension->setFlags(flags); +} + +void Compositor::setRetainedSelectionWatcher(RetainedSelectionFunc func, void *param) +{ + m_retainNotify = func; + m_retainNotifyParam = param; +} + +bool Compositor::wantsRetainedSelection() const +{ + return m_retainNotify != 0; +} + +void Compositor::feedRetainedSelectionData(QMimeData *data) +{ + if (m_retainNotify) { + m_retainNotify(data, m_retainNotifyParam); + } +} + +void Compositor::scheduleReleaseBuffer(SurfaceBuffer *screenBuffer) +{ + QMetaObject::invokeMethod(this,"releaseBuffer",Q_ARG(SurfaceBuffer*,screenBuffer)); +} + +void Compositor::overrideSelection(QMimeData *data) +{ + m_data_device_manager->overrideSelection(*data); +} + +bool Compositor::isDragging() const +{ + return false; +} + +void Compositor::sendDragMoveEvent(const QPoint &global, const QPoint &local, + Surface *surface) +{ + Q_UNUSED(global); + Q_UNUSED(local); + Q_UNUSED(surface); +// Drag::instance()->dragMove(global, local, surface); +} + +void Compositor::sendDragEndEvent() +{ +// Drag::instance()->dragEnd(); +} + +} // namespace Wayland + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h new file mode 100644 index 000000000..628470681 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WL_COMPOSITOR_H +#define WL_COMPOSITOR_H + +#include + +#include +#include + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QWaylandCompositor; +class QWaylandInputDevice; +class QWaylandGraphicsHardwareIntegration; +class WindowManagerServerIntegration; +class QMimeData; +class QPlatformScreenPageFlipper; +class QPlatformScreenBuffer; + +namespace QtWayland { + +class Surface; +class SurfaceBuffer; +class InputDevice; +class DataDeviceManager; +class OutputGlobal; +class OutputExtensionGlobal; +class SurfaceExtensionGlobal; +class SubSurfaceExtensionGlobal; +class Shell; +class TouchExtensionGlobal; +class QtKeyExtensionGlobal; + +class Q_COMPOSITOR_EXPORT Compositor : public QObject +{ + Q_OBJECT + +public: + Compositor(QWaylandCompositor *qt_compositor); + ~Compositor(); + + void frameFinished(Surface *surface = 0); + + //these 3 functions will be removed if noone steps up soon. + Surface *getSurfaceFromWinId(uint winId) const; + struct wl_client *getClientFromWinId(uint winId) const; + QImage image(uint winId) const; + + InputDevice *defaultInputDevice(); //we just have 1 default device for now (since QPA doesn't give us anything else) + + void createSurface(struct wl_client *client, uint32_t id); + void surfaceDestroyed(Surface *surface); + void markSurfaceAsDirty(Surface *surface); + + void destroyClient(WaylandClient *client); + + static uint currentTimeMsecs(); + + QWindow *window() const; + + QWaylandGraphicsHardwareIntegration *graphicsHWIntegration() const; + void initializeHardwareIntegration(); + void initializeDefaultInputDevice(); + void initializeWindowManagerProtocol(); + void enableSubSurfaceExtension(); + bool setDirectRenderSurface(Surface *surface, QOpenGLContext *context); + Surface *directRenderSurface() const {return m_directRenderSurface;} + QOpenGLContext *directRenderContext() const {return m_directRenderContext;} + QPlatformScreenPageFlipper *pageFlipper() const { return m_pageFlipper; } + void setDirectRenderingActive(bool active); + + QList surfaces() const { return m_surfaces; } + QList surfacesForClient(wl_client* client); + QWaylandCompositor *waylandCompositor() const { return m_qt_compositor; } + + struct wl_display *wl_display() const { return m_display->handle(); } + + static Compositor *instance(); + + QList clients() const; + + WindowManagerServerIntegration *windowManagerIntegration() const { return m_windowManagerIntegration; } + + void setScreenOrientation(Qt::ScreenOrientation orientation); + Qt::ScreenOrientation screenOrientation() const; + void setOutputGeometry(const QRect &geometry); + QRect outputGeometry() const; + void setOutputRefreshRate(int rate); + int outputRefreshRate() const; + + Qt::ScreenOrientations orientationUpdateMaskForClient(wl_client *client); + + void setClientFullScreenHint(bool value); + + TouchExtensionGlobal *touchExtension() { return m_touchExtension; } + void configureTouchExtension(int flags); + + QtKeyExtensionGlobal *qtkeyExtension() { return m_qtkeyExtension; } + + bool isDragging() const; + void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface); + void sendDragEndEvent(); + + typedef void (*RetainedSelectionFunc)(QMimeData *, void *); + void setRetainedSelectionWatcher(RetainedSelectionFunc func, void *param); + void overrideSelection(QMimeData *data); + + bool wantsRetainedSelection() const; + void feedRetainedSelectionData(QMimeData *data); + + void scheduleReleaseBuffer(SurfaceBuffer *screenBuffer); + + static wl_resource *resourceForSurface(wl_list *resourceList, Surface *surface); + +private slots: + + void releaseBuffer(SurfaceBuffer *screenBuffer); + void processWaylandEvents(); + +private: + Display *m_display; + + /* Input */ + QWaylandInputDevice *m_default_wayland_input_device; + InputDevice *m_default_input_device; + + /* Output */ + //make this a list of the available screens + OutputGlobal *m_output_global; + //This one should be part of the outputs + QPlatformScreenPageFlipper *m_pageFlipper; + + DataDeviceManager *m_data_device_manager; + + QList m_surfaces; + QSet m_dirty_surfaces; + + /* Render state */ + uint32_t m_current_frame; + int m_last_queued_buf; + + wl_event_loop *m_loop; + + QWaylandCompositor *m_qt_compositor; + Qt::ScreenOrientation m_orientation; + + Surface *m_directRenderSurface; + QOpenGLContext *m_directRenderContext; + bool m_directRenderActive; + +#ifdef QT_COMPOSITOR_WAYLAND_GL + QWaylandGraphicsHardwareIntegration *m_graphics_hw_integration; +#endif + + //extensions + WindowManagerServerIntegration *m_windowManagerIntegration; + + Shell *m_shell; + OutputExtensionGlobal *m_outputExtension; + SurfaceExtensionGlobal *m_surfaceExtension; + SubSurfaceExtensionGlobal *m_subSurfaceExtension; + TouchExtensionGlobal *m_touchExtension; + QtKeyExtensionGlobal *m_qtkeyExtension; + + static void bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + + RetainedSelectionFunc m_retainNotify; + void *m_retainNotifyParam; +}; + +} + +QT_END_NAMESPACE + +#endif //WL_COMPOSITOR_H diff --git a/src/compositor/wayland_wrapper/qwldatadevice.cpp b/src/compositor/wayland_wrapper/qwldatadevice.cpp new file mode 100644 index 000000000..89fa7a08e --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldatadevice.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwldatadevice_p.h" + +#include "qwldatasource_p.h" +#include "qwldataoffer_p.h" +#include "qwldatadevicemanager_p.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +void DataDevice::start_drag(struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *source, + struct wl_resource *surface, + struct wl_resource *icon, + uint32_t time) +{ + Q_UNUSED(client); + Q_UNUSED(surface); + Q_UNUSED(icon); + Q_UNUSED(time); + DataDevice *data_device = static_cast(resource->data); + DataSource *data_source = static_cast(source->data); + Q_UNUSED(data_device); + Q_UNUSED(data_source); +} + +void DataDevice::set_selection(struct wl_client *client, + struct wl_resource *data_device_resource, + struct wl_resource *source, + uint32_t time) +{ + Q_UNUSED(client); + Q_UNUSED(time); + DataDevice *data_device = static_cast(data_device_resource->data); + DataSource *data_source = static_cast(source->data); + + data_device->m_data_device_manager->setCurrentSelectionSource(data_source); + +} + +const struct wl_data_device_interface DataDevice::data_device_interface = { + DataDevice::start_drag, + DataDevice::set_selection +}; + +DataDevice::DataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id) + : m_data_device_manager(data_device_manager) + , m_sent_selection_time(0) +{ + + //static int i = 0; + //qDebug() << "data device" << ++i; + m_data_device_resource = + wl_client_add_object(client,&wl_data_device_interface,&data_device_interface,id, this); +} + +void DataDevice::sendSelectionFocus() +{ + if (m_data_device_manager->offerFromCompositorToClient(m_data_device_resource)) + return; + + DataSource *source = m_data_device_manager->currentSelectionSource(); + if (!source || !source->client()) { + m_data_device_manager->offerRetainedSelection(m_data_device_resource); + return; + } + if (source->time() > m_sent_selection_time) { //this makes sure we don't resend + if (source->client() != m_data_device_resource->client) { //don't send selection to the client that owns the selection + DataOffer *data_offer = source->dataOffer(); + wl_resource *client_resource = + data_offer->addDataDeviceResource(m_data_device_resource); + //qDebug() << "sending data_offer for source" << source; + wl_data_device_send_selection(m_data_device_resource,client_resource); + m_sent_selection_time = source->time(); + } + } +} + +struct wl_resource *DataDevice::dataDeviceResource() const +{ + return m_data_device_resource; +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwldatadevice_p.h b/src/compositor/wayland_wrapper/qwldatadevice_p.h new file mode 100644 index 000000000..2b4acdc9d --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldatadevice_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLDATADEVICE_H +#define WLDATADEVICE_H + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class DataSource; +class DataDeviceManager; + +class DataDevice +{ +public: + DataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id); + + void createAndSetSelectionSource(struct wl_client *client, uint32_t id, const char *name, uint32_t time); + void sendSelectionFocus(); + + struct wl_resource *dataDeviceResource() const; + + struct wl_display *display() const { return m_data_device_manager->display(); } +private: + DataDeviceManager *m_data_device_manager; + uint32_t m_sent_selection_time; + struct wl_resource *m_data_device_resource; + + static const struct wl_data_device_interface data_device_interface; + static void start_drag(struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *source, + struct wl_resource *surface, + struct wl_resource *icon, + uint32_t time); + static void set_selection(struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *source, + uint32_t time); +}; + +} + +QT_END_NAMESPACE + +#endif // WLDATADEVICE_H diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp new file mode 100644 index 000000000..f89dbc314 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp @@ -0,0 +1,308 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwldatadevicemanager_p.h" + +#include "qwldatadevice_p.h" +#include "qwldatasource_p.h" +#include "qwlinputdevice_p.h" +#include "qwlcompositor_p.h" +#include "qwldataoffer_p.h" +#include "qwlsurface_p.h" +#include "qwaylandmimehelper.h" + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +DataDeviceManager::DataDeviceManager(Compositor *compositor) + : m_compositor(compositor) + , m_current_selection_source(0) + , m_retainedReadNotifier(0) + , m_compositorOwnsSelection(false) +{ + wl_display_add_global(compositor->wl_display(), &wl_data_device_manager_interface, this, DataDeviceManager::bind_func_drag); +} + +void DataDeviceManager::setCurrentSelectionSource(DataSource *source) +{ + if (m_current_selection_source + && m_current_selection_source->time() > source->time()) { + qDebug() << "Trying to set older selection"; + return; + } + + m_compositorOwnsSelection = false; + + finishReadFromClient(); + + m_current_selection_source = source; + source->setManager(this); + + // When retained selection is enabled, the compositor will query all the data from the client. + // This makes it possible to + // 1. supply the selection after the offering client is gone + // 2. make it possible for the compositor to participate in copy-paste + // The downside is decreased performance, therefore this mode has to be enabled + // explicitly in the compositors. + if (m_compositor->wantsRetainedSelection()) { + m_retainedData.clear(); + m_retainedReadIndex = 0; + retain(); + } +} + +void DataDeviceManager::sourceDestroyed(DataSource *source) +{ + Q_UNUSED(source); + if (m_current_selection_source == source) + finishReadFromClient(); +} + +void DataDeviceManager::retain() +{ + QList offers = m_current_selection_source->offerList(); + finishReadFromClient(); + if (m_retainedReadIndex >= offers.count()) { + m_compositor->feedRetainedSelectionData(&m_retainedData); + return; + } + QByteArray mimeType = offers.at(m_retainedReadIndex); + m_retainedReadBuf.clear(); + int fd[2]; + if (pipe(fd) == -1) { + qWarning("Clipboard: Failed to create pipe"); + return; + } + fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL, 0) | O_NONBLOCK); + m_current_selection_source->postSendEvent(mimeType, fd[1]); + close(fd[1]); + m_retainedReadNotifier = new QSocketNotifier(fd[0], QSocketNotifier::Read, this); + connect(m_retainedReadNotifier, SIGNAL(activated(int)), SLOT(readFromClient(int))); +} + +void DataDeviceManager::finishReadFromClient(bool exhausted) +{ + Q_UNUSED(exhausted); + if (m_retainedReadNotifier) { + if (exhausted) { + int fd = m_retainedReadNotifier->socket(); + delete m_retainedReadNotifier; + close(fd); + } else { + // Do not close the handle or destroy the read notifier here + // or else clients may SIGPIPE. + m_obsoleteRetainedReadNotifiers.append(m_retainedReadNotifier); + } + m_retainedReadNotifier = 0; + } +} + +void DataDeviceManager::readFromClient(int fd) +{ + static char buf[4096]; + int obsCount = m_obsoleteRetainedReadNotifiers.count(); + for (int i = 0; i < obsCount; ++i) { + QSocketNotifier *sn = m_obsoleteRetainedReadNotifiers.at(i); + if (sn->socket() == fd) { + // Read and drop the data, stopping to read and closing the handle + // is not yet safe because that could kill the client with SIGPIPE + // when it still tries to write. + int n; + do { + n = QT_READ(fd, buf, sizeof buf); + } while (n > 0); + if (n != -1 || (errno != EAGAIN && errno != EWOULDBLOCK)) { + m_obsoleteRetainedReadNotifiers.removeAt(i); + delete sn; + close(fd); + } + return; + } + } + int n = QT_READ(fd, buf, sizeof buf); + if (n <= 0) { + if (n != -1 || (errno != EAGAIN && errno != EWOULDBLOCK)) { + finishReadFromClient(true); + QList offers = m_current_selection_source->offerList(); + QString mimeType = QString::fromLatin1(offers.at(m_retainedReadIndex)); + m_retainedData.setData(mimeType, m_retainedReadBuf); + ++m_retainedReadIndex; + retain(); + } + } else { + m_retainedReadBuf.append(buf, n); + } +} + +DataSource *DataDeviceManager::currentSelectionSource() +{ + return m_current_selection_source; +} + +struct wl_display *DataDeviceManager::display() const +{ + return m_compositor->wl_display(); +} + +void DataDeviceManager::bind_func_drag(struct wl_client *client, void *data, uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + wl_client_add_object(client,&wl_data_device_manager_interface,&drag_interface,id,data); +} + +void DataDeviceManager::bind_func_data(struct wl_client *client, void *data, uint32_t version, uint32_t id) +{ + Q_UNUSED(client); + Q_UNUSED(data); + Q_UNUSED(version); + Q_UNUSED(id); +} + +void DataDeviceManager::get_data_device(struct wl_client *client, + struct wl_resource *data_device_manager_resource, + uint32_t id, + struct wl_resource *input_device_resource) +{ + DataDeviceManager *data_device_manager = static_cast(data_device_manager_resource->data); + InputDevice *input_device = resolve(input_device_resource); + input_device->clientRequestedDataDevice(data_device_manager,client,id); +} + +void DataDeviceManager::create_data_source(struct wl_client *client, + struct wl_resource *data_device_manager_resource, + uint32_t id) +{ + Q_UNUSED(data_device_manager_resource); + new DataSource(client,id, Compositor::currentTimeMsecs()); +} + +struct wl_data_device_manager_interface DataDeviceManager::drag_interface = { + DataDeviceManager::create_data_source, + DataDeviceManager::get_data_device +}; + +void DataDeviceManager::overrideSelection(const QMimeData &mimeData) +{ + QStringList formats = mimeData.formats(); + if (formats.isEmpty()) + return; + + m_retainedData.clear(); + foreach (const QString &format, formats) + m_retainedData.setData(format, mimeData.data(format)); + + m_compositor->feedRetainedSelectionData(&m_retainedData); + + m_compositorOwnsSelection = true; + + InputDevice *dev = m_compositor->defaultInputDevice(); + Surface *focusSurface = dev->keyboardFocus(); + if (focusSurface) + offerFromCompositorToClient( + dev->dataDevice(focusSurface->base()->resource.client)->dataDeviceResource()); +} + +bool DataDeviceManager::offerFromCompositorToClient(wl_resource *clientDataDeviceResource) +{ + if (!m_compositorOwnsSelection) + return false; + + wl_client *client = clientDataDeviceResource->client; + //qDebug("compositor offers %d types to %p", m_retainedData.formats().count(), client); + + struct wl_resource *selectionOffer = + wl_client_new_object(client, &wl_data_offer_interface, &compositor_offer_interface, this); + wl_data_device_send_data_offer(clientDataDeviceResource, selectionOffer); + foreach (const QString &format, m_retainedData.formats()) { + QByteArray ba = format.toLatin1(); + wl_data_offer_send_offer(selectionOffer, ba.constData()); + } + wl_data_device_send_selection(clientDataDeviceResource, selectionOffer); + + return true; +} + +void DataDeviceManager::offerRetainedSelection(wl_resource *clientDataDeviceResource) +{ + if (m_retainedData.formats().isEmpty()) + return; + + m_compositorOwnsSelection = true; + offerFromCompositorToClient(clientDataDeviceResource); +} + +void DataDeviceManager::comp_accept(wl_client *, wl_resource *, uint32_t, const char *) +{ +} + +void DataDeviceManager::comp_receive(wl_client *client, wl_resource *resource, const char *mime_type, int32_t fd) +{ + Q_UNUSED(client); + DataDeviceManager *self = static_cast(resource->data); + //qDebug("client %p wants data for type %s from compositor", client, mime_type); + QByteArray content = QWaylandMimeHelper::getByteArray(&self->m_retainedData, QString::fromLatin1(mime_type)); + if (!content.isEmpty()) { + QFile f; + if (f.open(fd, QIODevice::WriteOnly)) + f.write(content); + } + close(fd); +} + +void DataDeviceManager::comp_destroy(wl_client *, wl_resource *) +{ +} + +const struct wl_data_offer_interface DataDeviceManager::compositor_offer_interface = { + DataDeviceManager::comp_accept, + DataDeviceManager::comp_receive, + DataDeviceManager::comp_destroy +}; + +} //namespace + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager_p.h b/src/compositor/wayland_wrapper/qwldatadevicemanager_p.h new file mode 100644 index 000000000..11510e63b --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldatadevicemanager_p.h @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLDATADEVICEMANAGER_H +#define WLDATADEVICEMANAGER_H + +#include + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QSocketNotifier; + +namespace QtWayland { + +class Compositor; + +class DataDevice; +class DataSource; + +class DataDeviceManager : public QObject +{ + Q_OBJECT + +public: + DataDeviceManager(Compositor *compositor); + + void setCurrentSelectionSource(DataSource *source); + DataSource *currentSelectionSource(); + + struct wl_display *display() const; + + void sourceDestroyed(DataSource *source); + + void overrideSelection(const QMimeData &mimeData); + bool offerFromCompositorToClient(wl_resource *clientDataDeviceResource); + void offerRetainedSelection(wl_resource *clientDataDeviceResource); + +private slots: + void readFromClient(int fd); + +private: + void retain(); + void finishReadFromClient(bool exhausted = false); + + Compositor *m_compositor; + QList m_data_device_list; + + DataSource *m_current_selection_source; + + static void bind_func_drag(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + static void bind_func_data(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + static void get_data_device(struct wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct wl_resource *input_device); + static void create_data_source(struct wl_client *client, + struct wl_resource *resource, + uint32_t id); + static struct wl_data_device_manager_interface drag_interface; + + QMimeData m_retainedData; + QSocketNotifier *m_retainedReadNotifier; + QList m_obsoleteRetainedReadNotifiers; + int m_retainedReadIndex; + QByteArray m_retainedReadBuf; + + bool m_compositorOwnsSelection; + + + static void comp_accept(struct wl_client *client, + struct wl_resource *resource, + uint32_t time, + const char *type); + static void comp_receive(struct wl_client *client, + struct wl_resource *resource, + const char *mime_type, + int32_t fd); + static void comp_destroy(struct wl_client *client, + struct wl_resource *resource); + + static const struct wl_data_offer_interface compositor_offer_interface; +}; + +} + +QT_END_NAMESPACE + +#endif // WLDATADEVICEMANAGER_H diff --git a/src/compositor/wayland_wrapper/qwldataoffer.cpp b/src/compositor/wayland_wrapper/qwldataoffer.cpp new file mode 100644 index 000000000..c2bfea35a --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldataoffer.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwldataoffer_p.h" + +#include "qwldatadevice_p.h" + +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland +{ + +DataOffer::DataOffer(DataSource *data_source) + : m_data_source(data_source) +{ + +} + +DataOffer::~DataOffer() +{ +} + +struct wl_resource *DataOffer::addDataDeviceResource(struct wl_resource *data_device_resource) +{ + if (resourceForClient(data_device_resource->client)) { + qDebug() << "This should not happen, the client tries to add twice to a data offer"; + return 0; + } + struct wl_resource *new_object = + wl_client_new_object(data_device_resource->client,&wl_data_offer_interface,&data_interface,this); + wl_data_device_send_data_offer(data_device_resource, new_object); + + registerResource(new_object); + QList offer_list = m_data_source->offerList(); + for (int i = 0; i < offer_list.size(); i++) { + wl_data_offer_send_offer(new_object, offer_list.at(i).constData()); + } + return new_object; +} + +const struct wl_data_offer_interface DataOffer::data_interface = { + DataOffer::accept, + DataOffer::receive, + DataOffer::destroy +}; + +void DataOffer::accept(wl_client *client, wl_resource *resource, uint32_t time, const char *type) +{ + Q_UNUSED(client); + Q_UNUSED(resource); + Q_UNUSED(time); + Q_UNUSED(type); +} + +void DataOffer::receive(wl_client *client, wl_resource *resource, const char *mime_type, int32_t fd) +{ + Q_UNUSED(client); + + DataOffer *offer = static_cast(resource->data); + offer->m_data_source->postSendEvent(mime_type,fd); + close(fd); +} + +void DataOffer::destroy(wl_client *client, wl_resource *resource) +{ + Q_UNUSED(client); + DataOffer *data_offer = static_cast(resource->data); + + if (data_offer->resourceListIsEmpty()) { + delete data_offer; + } +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwldataoffer_p.h b/src/compositor/wayland_wrapper/qwldataoffer_p.h new file mode 100644 index 000000000..579434450 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldataoffer_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLDATAOFFER_H +#define WLDATAOFFER_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland +{ + +class DataOffer : public ResourceCollection +{ +public: + DataOffer(DataSource *data_source); + ~DataOffer(); + + struct wl_resource *addDataDeviceResource(struct wl_resource *client_resource); +private: + DataSource *m_data_source; + + static void accept(struct wl_client *client, + struct wl_resource *resource, + uint32_t time, + const char *type); + static void receive(struct wl_client *client, + struct wl_resource *resource, + const char *mime_type, + int32_t fd); + static void destroy(struct wl_client *client, + struct wl_resource *resource); + + static const struct wl_data_offer_interface data_interface; + +}; + +} + +QT_END_NAMESPACE + +#endif // WLDATAOFFER_H diff --git a/src/compositor/wayland_wrapper/qwldatasource.cpp b/src/compositor/wayland_wrapper/qwldatasource.cpp new file mode 100644 index 000000000..271467f2e --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldatasource.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwldatasource_p.h" +#include "qwldataoffer_p.h" +#include "qwldatadevicemanager_p.h" +#include "qwlcompositor_p.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +DataSource::DataSource(struct wl_client *client, uint32_t id, uint32_t time) + : m_time(time) +{ + m_data_source_resource = wl_client_add_object(client, &wl_data_source_interface, &DataSource::data_source_interface,id,this); + m_data_source_resource->destroy = resource_destroy; + m_data_offer = new DataOffer(this); + m_manager = 0; +} + +DataSource::~DataSource() +{ + if (m_manager) + m_manager->sourceDestroyed(this); + wl_resource_destroy(m_data_source_resource); +} + +void DataSource::resource_destroy(wl_resource *resource) +{ + DataSource *source = static_cast(resource->data); + if (source && source->m_data_source_resource == resource) + source->m_data_source_resource = 0; + free(resource); +} + +uint32_t DataSource::time() const +{ + return m_time; +} + +QList DataSource::offerList() const +{ + return m_offers; +} + +struct wl_data_source_interface DataSource::data_source_interface = { + DataSource::offer, + DataSource::destroy +}; + +void DataSource::offer(struct wl_client *client, + struct wl_resource *resource, + const char *type) +{ + Q_UNUSED(client); + //qDebug() << "received offer" << type; + static_cast(resource->data)->m_offers.append(type); +} + +void DataSource::destroy(struct wl_client *client, + struct wl_resource *resource) +{ + Q_UNUSED(client); + DataSource *self = static_cast(resource->data); + delete self; +} + +DataOffer * DataSource::dataOffer() const +{ + return m_data_offer; +} + +void DataSource::postSendEvent(const QByteArray &mimeType, int fd) +{ + if (m_data_source_resource) { + wl_data_source_send_send(m_data_source_resource, mimeType.constData(), fd); + } +} + +struct wl_client *DataSource::client() const +{ + if (m_data_source_resource) + return m_data_source_resource->client; + return 0; +} + +void DataSource::setManager(DataDeviceManager *mgr) +{ + m_manager = mgr; +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwldatasource_p.h b/src/compositor/wayland_wrapper/qwldatasource_p.h new file mode 100644 index 000000000..be855d8da --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldatasource_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLDATASOURCE_H +#define WLDATASOURCE_H + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class DataOffer; +class DataDeviceManager; + +class DataSource +{ +public: + DataSource(struct wl_client *client, uint32_t id, uint32_t time); + ~DataSource(); + uint32_t time() const; + QList offerList() const; + + DataOffer *dataOffer() const; + + void postSendEvent(const QByteArray &mimeType,int fd); + struct wl_client *client() const; + + void setManager(DataDeviceManager *mgr); + +private: + uint32_t m_time; + QList m_offers; + struct wl_resource *m_data_source_resource; + + DataOffer *m_data_offer; + + DataDeviceManager *m_manager; + + static struct wl_data_source_interface data_source_interface; + static void offer(struct wl_client *client, + struct wl_resource *resource, + const char *type); + static void destroy(struct wl_client *client, + struct wl_resource *resource); + + static void resource_destroy(struct wl_resource *resource); +}; + +} + +QT_END_NAMESPACE + +#endif // WLDATASOURCE_H diff --git a/src/compositor/wayland_wrapper/qwldisplay.cpp b/src/compositor/wayland_wrapper/qwldisplay.cpp new file mode 100644 index 000000000..be5b54182 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldisplay.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwldisplay_p.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +Display::Display() +{ + m_display = wl_display_create(); + + Q_ASSERT(m_display); +} + +Display::~Display() +{ + wl_display_destroy(m_display); +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwldisplay_p.h b/src/compositor/wayland_wrapper/qwldisplay_p.h new file mode 100644 index 000000000..f18cb1e6b --- /dev/null +++ b/src/compositor/wayland_wrapper/qwldisplay_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WL_DISPLAY_H +#define WL_DISPLAY_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Display +{ +public: + Display(); + ~Display(); + + struct wl_display *handle() const { return m_display; } + struct wl_display *handle() { return m_display; } + +private: + struct wl_display *m_display; +}; + +} + +QT_END_NAMESPACE + +#endif //WL_DISPLAY_H diff --git a/src/compositor/wayland_wrapper/qwlextendedoutput.cpp b/src/compositor/wayland_wrapper/qwlextendedoutput.cpp new file mode 100644 index 000000000..8249f2721 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlextendedoutput.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlextendedoutput_p.h" + +#include "qwlcompositor_p.h" +#include "qwlsurface_p.h" +#include "qwloutput_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +OutputExtensionGlobal::OutputExtensionGlobal(Compositor *compositor) + : m_compositor(compositor) +{ + wl_display_add_global(compositor->wl_display(), + &wl_output_extension_interface, + this, + OutputExtensionGlobal::bind_func); +} + +void OutputExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + wl_client_add_object(client,&wl_output_extension_interface,&output_extension_interface,id,data); +} + +void OutputExtensionGlobal::get_extended_output(wl_client *client, wl_resource *output_extension_resource, uint32_t id, wl_resource *output_resource) +{ + OutputExtensionGlobal *output_extension = static_cast(output_extension_resource->data); + Output *output = static_cast(output_resource->data); + new ExtendedOutput(client,id,output,output_extension->m_compositor); +} + +const struct wl_output_extension_interface OutputExtensionGlobal::output_extension_interface = { + OutputExtensionGlobal::get_extended_output +}; + +ExtendedOutput::ExtendedOutput(struct wl_client *client, uint32_t id, Output *output, Compositor *compositor) + : m_output(output) + , m_compositor(compositor) +{ + static const struct wl_extended_output_interface extended_output_interface = { + set_orientation_update_mask + }; + Q_ASSERT(m_output->extendedOutput() == 0); + m_output->setExtendedOutput(this); + m_extended_output_resource = wl_client_add_object(client,&wl_extended_output_interface,&extended_output_interface,id,this); + m_extended_output_resource->destroy = ExtendedOutput::destroy_resource; + + sendOutputOrientation(m_compositor->screenOrientation()); +} + +void ExtendedOutput::destroy_resource(wl_resource *resource) +{ + ExtendedOutput *output = static_cast(resource->data); + delete output; + free(resource); +} + +void ExtendedOutput::set_orientation_update_mask(struct wl_client *client, + struct wl_resource *resource, + int32_t orientation_update_mask) +{ + ExtendedOutput *output = static_cast(resource->data); + + Qt::ScreenOrientations mask = 0; + if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION) + mask |= Qt::PortraitOrientation; + if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION) + mask |= Qt::LandscapeOrientation; + if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION) + mask |= Qt::InvertedPortraitOrientation; + if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION) + mask |= Qt::InvertedLandscapeOrientation; + + Qt::ScreenOrientations oldMask = output->m_orientationUpdateMask; + output->m_orientationUpdateMask = mask; + + if (mask != oldMask) { + QList surfaces = output->m_compositor->surfacesForClient(client); + foreach (Surface *surface, surfaces) { + if (surface->waylandSurface()) + emit surface->waylandSurface()->orientationUpdateMaskChanged(); + } + } +} + +void ExtendedOutput::sendOutputOrientation(Qt::ScreenOrientation orientation) +{ + int sendOpperation; + switch (orientation) { + case Qt::PortraitOrientation: + sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; + break; + case Qt::LandscapeOrientation: + sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION; + break; + case Qt::InvertedPortraitOrientation: + sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION; + break; + case Qt::InvertedLandscapeOrientation: + sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION; + break; + default: + sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; + } + wl_extended_output_send_set_screen_rotation(m_extended_output_resource, sendOpperation); +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlextendedoutput_p.h b/src/compositor/wayland_wrapper/qwlextendedoutput_p.h new file mode 100644 index 000000000..46c56beb8 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlextendedoutput_p.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLEXTENDEDOUTPUT_H +#define WLEXTENDEDOUTPUT_H + +#include "wayland-server.h" +#include "wayland-output-extension-server-protocol.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Compositor; +class Output; + +class OutputExtensionGlobal +{ +public: + OutputExtensionGlobal(Compositor *compositor); + +private: + Compositor *m_compositor; + + static void bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + static void get_extended_output(struct wl_client *client, + struct wl_resource *output_extension_resource, + uint32_t id, + struct wl_resource *output_resource); + static const struct wl_output_extension_interface output_extension_interface; + +}; + +class ExtendedOutput +{ +public: + ExtendedOutput(struct wl_client *client, uint32_t id, Output *output, Compositor *compositor); + + Qt::ScreenOrientations orientationUpdateMask() { return m_orientationUpdateMask; } + + void sendOutputOrientation(Qt::ScreenOrientation orientation); + + static void destroy_resource(wl_resource *resource); + + static void set_orientation_update_mask(struct wl_client *client, + struct wl_resource *resource, + int32_t orientation_update_mask); + +private: + struct wl_resource *m_extended_output_resource; + Output *m_output; + Compositor *m_compositor; + Qt::ScreenOrientations m_orientationUpdateMask; +}; + +} + +QT_END_NAMESPACE + +#endif // WLEXTENDEDOUTPUT_H diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp new file mode 100644 index 000000000..dd550af10 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlextendedsurface_p.h" + +#include "qwlcompositor_p.h" +#include "qwlsurface_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +SurfaceExtensionGlobal::SurfaceExtensionGlobal(Compositor *compositor) + : m_compositor(compositor) +{ + wl_display_add_global(m_compositor->wl_display(), + &wl_surface_extension_interface, + this, + SurfaceExtensionGlobal::bind_func); +} + +void SurfaceExtensionGlobal::bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + wl_client_add_object(client, &wl_surface_extension_interface,&surface_extension_interface,id,data); +} + +const struct wl_surface_extension_interface SurfaceExtensionGlobal::surface_extension_interface = { + SurfaceExtensionGlobal::get_extended_surface +}; + +void SurfaceExtensionGlobal::get_extended_surface(struct wl_client *client, + struct wl_resource *surface_extension_resource, + uint32_t id, + struct wl_resource *surface_resource) +{ + Q_UNUSED(surface_extension_resource); + Surface *surface = resolve(surface_resource); + new ExtendedSurface(client,id,surface); +} + +ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface) + : m_surface(surface) + , m_contentOrientation(Qt::PrimaryOrientation) + , m_windowFlags(0) +{ + Q_ASSERT(surface->extendedSurface() == 0); + m_extended_surface_resource = wl_client_add_object(client, + &wl_extended_surface_interface, + &extended_surface_interface, + id, + this); + surface->setExtendedSurface(this); +} + +ExtendedSurface::~ExtendedSurface() +{ + +} + +void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &variant) +{ + QByteArray byteValue; + QDataStream ds(&byteValue, QIODevice::WriteOnly); + ds << variant; + wl_array data; + data.size = byteValue.size(); + data.data = (void*) byteValue.constData(); + data.alloc = 0; + wl_extended_surface_send_set_generic_property(m_extended_surface_resource, qPrintable(name), &data); + +} + +void ExtendedSurface::sendOnScreenVisibility(bool visible) +{ + int32_t visibleInt = visible; + wl_extended_surface_send_onscreen_visibility(m_extended_surface_resource, visibleInt); +} + + +void ExtendedSurface::update_generic_property(wl_client *client, wl_resource *extended_surface_resource, const char *name, wl_array *value) +{ + Q_UNUSED(client); + ExtendedSurface *extended_surface = static_cast(extended_surface_resource->data); + QVariant variantValue; + QByteArray byteValue((const char*)value->data, value->size); + QDataStream ds(&byteValue, QIODevice::ReadOnly); + ds >> variantValue; + extended_surface->setWindowProperty(QString::fromLatin1(name),variantValue,false); + +} + +static Qt::ScreenOrientation screenOrientationFromWaylandOrientation(int32_t orientation) +{ + switch (orientation) { + case WL_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION: return Qt::PortraitOrientation; + case WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION: return Qt::InvertedPortraitOrientation; + case WL_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION: return Qt::LandscapeOrientation; + case WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION: return Qt::InvertedLandscapeOrientation; + default: return Qt::PrimaryOrientation; + } +} + +Qt::ScreenOrientation ExtendedSurface::contentOrientation() const +{ + return m_contentOrientation; +} + +void ExtendedSurface::set_content_orientation(struct wl_client *client, + struct wl_resource *extended_surface_resource, + int32_t orientation) +{ + Q_UNUSED(client); + ExtendedSurface *extended_surface = static_cast(extended_surface_resource->data); + + Qt::ScreenOrientation oldOrientation = extended_surface->m_contentOrientation; + extended_surface->m_contentOrientation = screenOrientationFromWaylandOrientation(orientation); + if (extended_surface->m_contentOrientation != oldOrientation) + emit extended_surface->m_surface->waylandSurface()->contentOrientationChanged(); +} + +void ExtendedSurface::setWindowFlags(QWaylandSurface::WindowFlags flags) +{ + if (flags == m_windowFlags) + return; + m_windowFlags = flags; + emit m_surface->waylandSurface()->windowFlagsChanged(flags); +} + +QVariantMap ExtendedSurface::windowProperties() const +{ + return m_windowProperties; +} + +QVariant ExtendedSurface::windowProperty(const QString &propertyName) const +{ + QVariantMap props = m_windowProperties; + return props.value(propertyName); +} + +void ExtendedSurface::setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient) +{ + Q_UNUSED(writeUpdateToClient); + m_windowProperties.insert(name, value); + m_surface->waylandSurface()->windowPropertyChanged(name,value); + sendGenericProperty(name, value); +} + +void ExtendedSurface::set_window_flags(wl_client *client, wl_resource *resource, int32_t flags) +{ + Q_UNUSED(client); + ExtendedSurface *extended_surface = static_cast(resource->data); + extended_surface->setWindowFlags(QWaylandSurface::WindowFlags(flags)); +} + +const struct wl_extended_surface_interface ExtendedSurface::extended_surface_interface = { + ExtendedSurface::update_generic_property, + ExtendedSurface::set_content_orientation, + ExtendedSurface::set_window_flags +}; + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h new file mode 100644 index 000000000..6dc60efb0 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLEXTENDEDSURFACE_H +#define WLEXTENDEDSURFACE_H + +#include +#include "wayland-surface-extension-server-protocol.h" + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandSurface; + +namespace QtWayland { + +class Compositor; + +class SurfaceExtensionGlobal +{ +public: + SurfaceExtensionGlobal(Compositor *compositor); + +private: + Compositor *m_compositor; + + static void bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + static void get_extended_surface(struct wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct wl_resource *surface); + static const struct wl_surface_extension_interface surface_extension_interface; + +}; + +class ExtendedSurface +{ +public: + ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface); + ~ExtendedSurface(); + + void sendGenericProperty(const QString &name, const QVariant &variant); + void sendOnScreenVisibility(bool visible); + + void setSubSurface(ExtendedSurface *subSurface,int x, int y); + void removeSubSurface(ExtendedSurface *subSurfaces); + ExtendedSurface *parent() const; + void setParent(ExtendedSurface *parent); + QLinkedList subSurfaces() const; + + Qt::ScreenOrientation contentOrientation() const; + + QWaylandSurface::WindowFlags windowFlags() const { return m_windowFlags; } + + qint64 processId() const; + void setProcessId(qint64 processId); + + QVariantMap windowProperties() const; + QVariant windowProperty(const QString &propertyName) const; + void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true); + +private: + struct wl_resource *m_extended_surface_resource; + Surface *m_surface; + + Qt::ScreenOrientation m_contentOrientation; + + QWaylandSurface::WindowFlags m_windowFlags; + + QByteArray m_authenticationToken; + QVariantMap m_windowProperties; + + + static void update_generic_property(struct wl_client *client, + struct wl_resource *resource, + const char *name, + struct wl_array *value); + + static void set_content_orientation(struct wl_client *client, + struct wl_resource *resource, + int32_t orientation); + + static void set_window_flags(struct wl_client *client, + struct wl_resource *resource, + int32_t flags); + void setWindowFlags(QWaylandSurface::WindowFlags flags); + + static const struct wl_extended_surface_interface extended_surface_interface; +}; + +} + +QT_END_NAMESPACE + +#endif // WLEXTENDEDSURFACE_H diff --git a/src/compositor/wayland_wrapper/qwlinputdevice.cpp b/src/compositor/wayland_wrapper/qwlinputdevice.cpp new file mode 100644 index 000000000..8591de254 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlinputdevice.cpp @@ -0,0 +1,650 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlinputdevice_p.h" + +#include "qwlcompositor_p.h" +#include "qwldatadevice_p.h" +#include "qwlsurface_p.h" +#include "qwltouch_p.h" +#include "qwlqtkey_p.h" +#include "qwaylandcompositor.h" + +#include + +#ifndef QT_NO_WAYLAND_XKB +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +InputDevice::InputDevice(QWaylandInputDevice *handle, Compositor *compositor) + : m_handle(handle) + , m_compositor(compositor) +{ + wl_seat_init(base()); + initDevices(); + wl_display_add_global(compositor->wl_display(), + &wl_seat_interface, + this, + InputDevice::bind_func); + +#ifndef QT_NO_WAYLAND_XKB + xkb_rule_names xkb_names; + xkb_context *context = xkb_context_new(xkb_context_flags(0)); + + memset(&xkb_names, 0, sizeof(xkb_names)); + xkb_names.rules = strdup("evdev"); + xkb_names.model = strdup("pc105"); + xkb_names.layout = strdup("us"); + + xkb_keymap *keymap = xkb_map_new_from_names(context, &xkb_names, xkb_map_compile_flags(0)); + if (!keymap) + qFatal("Failed to compile global XKB keymap"); + + char *keymap_str_data = xkb_map_get_as_string(keymap); + QByteArray keymap_str = keymap_str_data; + m_keymap_size = keymap_str.size() + 1; + free(keymap_str_data); + + const char *path = getenv("XDG_RUNTIME_DIR"); + if (!path) + qFatal("XDG_RUNTIME_DIR not set"); + + QByteArray name = QByteArray(path) + "/qtwayland-xkb-map-XXXXXX"; + + int fd = mkstemp(name.data()); + if (fd >= 0) { + long flags = fcntl(fd, F_GETFD); + if (flags == -1 || fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) { + close(fd); + qFatal("Failed to set FD_CLOEXEC on anonymous file"); + } + unlink(name.data()); + } else { + qFatal("Failed to create anonymous file with name %s", name.constData()); + } + + if (ftruncate(fd, m_keymap_size) < 0) + qFatal("Failed to create anonymous file of size %lu", (unsigned long)m_keymap_size); + + m_keymap_fd = fd; + + m_keymap_area = (char *)mmap(0, m_keymap_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_keymap_fd, 0); + if (m_keymap_area == MAP_FAILED) { + close(m_keymap_fd); + qFatal("Failed to map shared memory segment"); + } + + strcpy(m_keymap_area, keymap_str.constData()); + + m_state = xkb_state_new(keymap); + + free((char *)xkb_names.rules); + free((char *)xkb_names.model); + free((char *)xkb_names.layout); + xkb_map_unref(keymap); + xkb_context_unref(context); +#endif +} + +InputDevice::~InputDevice() +{ + qDeleteAll(m_data_devices); + releaseDevices(); + +#ifndef QT_NO_WAYLAND_XKB + if (m_keymap_area) + munmap(m_keymap_area, m_keymap_size); + close(m_keymap_fd); + xkb_state_unref(m_state); +#endif +} + +void InputDevice::initDevices() +{ + wl_pointer_init(&m_device_interfaces.pointer); + wl_seat_set_pointer(base(), &m_device_interfaces.pointer); + + wl_keyboard_init(&m_device_interfaces.keyboard); + wl_seat_set_keyboard(base(), &m_device_interfaces.keyboard); + + wl_touch_init(&m_device_interfaces.touch); + wl_seat_set_touch(base(), &m_device_interfaces.touch); +} + +void InputDevice::releaseDevices() +{ + wl_pointer_release(&m_device_interfaces.pointer); + wl_keyboard_release(&m_device_interfaces.keyboard); + wl_touch_release(&m_device_interfaces.touch); +} + +wl_pointer *InputDevice::pointerDevice() +{ + return &m_device_interfaces.pointer; +} + +wl_keyboard *InputDevice::keyboardDevice() +{ + return &m_device_interfaces.keyboard; +} + +wl_touch *InputDevice::touchDevice() +{ + return &m_device_interfaces.touch; +} + +const wl_pointer *InputDevice::pointerDevice() const +{ + return &m_device_interfaces.pointer; +} + +const wl_keyboard *InputDevice::keyboardDevice() const +{ + return &m_device_interfaces.keyboard; +} + +const wl_touch *InputDevice::touchDevice() const +{ + return &m_device_interfaces.touch; +} + +void InputDevice::destroy_resource(wl_resource *resource) +{ + InputDevice *input_device = static_cast(resource->data); + if (input_device->keyboardDevice()->focus_resource == resource) { + input_device->keyboardDevice()->focus_resource = 0; + } + if (input_device->pointerDevice()->focus_resource == resource) { + input_device->pointerDevice()->focus_resource = 0; + } + + input_device->cleanupDataDeviceForClient(resource->client, true); + + wl_list_remove(&resource->link); + + free(resource); +} + +void InputDevice::bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + struct wl_resource *resource = wl_client_add_object(client, + &wl_seat_interface, + &seat_interface, + id, + data); + + struct wl_seat *seat = static_cast(data); + resource->destroy = destroy_resource; + wl_list_insert(&seat->base_resource_list, &resource->link); + + uint32_t caps = WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_KEYBOARD; + if (!QTouchDevice::devices().isEmpty()) + caps |= WL_SEAT_CAPABILITY_TOUCH; + + wl_seat_send_capabilities(resource, caps); +} + +const struct wl_pointer_interface InputDevice::pointer_interface = { + InputDevice::set_cursor +}; + +void InputDevice::set_cursor(wl_client *client, wl_resource *resource, + uint32_t serial, wl_resource *surface_resource, + int32_t hotspot_x, int32_t hotspot_y) +{ + Q_UNUSED(client); + Q_UNUSED(serial); + + wl_pointer *pointer = reinterpret_cast(resource->data); + InputDevice *inputDevice = wayland_cast(pointer->seat); + QtWayland::Surface *surface = reinterpret_cast(surface_resource->data); + + surface->setCursorSurface(true); + inputDevice->m_compositor->waylandCompositor()->setCursorSurface(surface->waylandSurface(), hotspot_x, hotspot_y); +} + +const struct wl_seat_interface InputDevice::seat_interface = { + get_pointer, + get_keyboard, + get_touch +}; + +void InputDevice::destroy_device_resource(wl_resource *resource) +{ + wl_list_remove(&resource->link); + free(resource); +} + +void InputDevice::get_pointer(struct wl_client *client, + struct wl_resource *resource, + uint32_t id) +{ + InputDevice *inputDevice = static_cast(resource->data); + wl_pointer *pointer = inputDevice->pointerDevice(); + wl_resource *clientResource = wl_client_add_object(client, + &wl_pointer_interface, + &pointer_interface, + id, + pointer); + wl_list_insert(&pointer->resource_list, &clientResource->link); + clientResource->destroy = InputDevice::destroy_device_resource; +} + +void InputDevice::get_keyboard(struct wl_client *client, + struct wl_resource *resource, + uint32_t id) +{ + InputDevice *inputDevice = static_cast(resource->data); + wl_keyboard *keyboard = inputDevice->keyboardDevice(); + wl_resource *clientResource = wl_client_add_object(client, + &wl_keyboard_interface, + 0, + id, + keyboard); + wl_list_insert(&keyboard->resource_list, &clientResource->link); + clientResource->destroy = InputDevice::destroy_device_resource; + +#ifndef QT_NO_WAYLAND_XKB + wl_keyboard_send_keymap(clientResource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, + inputDevice->m_keymap_fd, inputDevice->m_keymap_size); +#endif +} + +void InputDevice::get_touch(struct wl_client *client, + struct wl_resource *resource, + uint32_t id) +{ + InputDevice *inputDevice = static_cast(resource->data); + wl_touch *touch = inputDevice->touchDevice(); + wl_resource *clientResource = wl_client_add_object(client, + &wl_touch_interface, + 0, + id, + touch); + wl_list_insert(&touch->resource_list, &clientResource->link); + clientResource->destroy = InputDevice::destroy_device_resource; +} + +void InputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) +{ + sendMouseMoveEvent(localPos,globalPos); + wl_pointer *pointer = pointerDevice(); + pointer->button_count++; + uint32_t time = m_compositor->currentTimeMsecs(); + const struct wl_pointer_grab_interface *interface = pointer->grab->interface; + interface->button(pointer->grab, time, toWaylandButton(button), 1); +} + +void InputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) +{ + sendMouseMoveEvent(localPos,globalPos); + wl_pointer *pointer = pointerDevice(); + pointer->button_count--; + uint32_t time = m_compositor->currentTimeMsecs(); + const struct wl_pointer_grab_interface *interface = pointer->grab->interface; + interface->button(pointer->grab, time, toWaylandButton(button), 0); +} + +void InputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos) +{ + Q_UNUSED(globalPos); + uint32_t time = m_compositor->currentTimeMsecs(); + wl_pointer *pointer = pointerDevice(); + const struct wl_pointer_grab_interface *interface = pointer->grab->interface; + pointer->x = wl_fixed_from_double(globalPos.x()); + pointer->y = wl_fixed_from_double(globalPos.y()); + interface->motion(pointer->grab, + time, + wl_fixed_from_double(localPos.x()), wl_fixed_from_double(localPos.y())); +} + +void InputDevice::sendMouseMoveEvent(Surface *surface, const QPointF &localPos, const QPointF &globalPos) +{ + setMouseFocus(surface,localPos,globalPos); + sendMouseMoveEvent(localPos,globalPos); +} + +void InputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta) +{ + wl_pointer *pointer = pointerDevice(); + struct wl_resource *resource = pointer->focus_resource; + if (!resource) + return; + uint32_t time = m_compositor->currentTimeMsecs(); + uint32_t axis = orientation == Qt::Horizontal ? WL_POINTER_AXIS_HORIZONTAL_SCROLL + : WL_POINTER_AXIS_VERTICAL_SCROLL; + wl_pointer_send_axis(resource, time, axis, wl_fixed_from_int(-delta / 12)); +} + +void InputDevice::updateModifierState(uint code, int state) +{ +#ifndef QT_NO_WAYLAND_XKB + xkb_state_update_key(m_state, code, state ? XKB_KEY_DOWN : XKB_KEY_UP); + + uint32_t mods_depressed = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_DEPRESSED); + uint32_t mods_latched = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_LATCHED); + uint32_t mods_locked = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_LATCHED); + uint32_t group = xkb_state_serialize_group(m_state, (xkb_state_component)XKB_STATE_EFFECTIVE); + + wl_keyboard *keyboard = keyboardDevice(); + + if (mods_depressed == keyboard->modifiers.mods_depressed + && mods_latched == keyboard->modifiers.mods_latched + && mods_locked == keyboard->modifiers.mods_locked + && group == keyboard->modifiers.group) + { + return; // no change + } + + keyboard->modifiers.mods_depressed = mods_depressed; + keyboard->modifiers.mods_latched = mods_latched; + keyboard->modifiers.mods_locked = mods_locked; + keyboard->modifiers.group = group; + + if (keyboard->focus_resource) + sendKeyModifiers(keyboard->focus_resource); +#else + Q_UNUSED(code); + Q_UNUSED(state); +#endif +} + +void InputDevice::sendKeyModifiers(wl_resource *resource) +{ + wl_keyboard *keyboard = keyboardDevice(); + uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); + wl_keyboard_send_modifiers(resource, serial, keyboard->modifiers.mods_depressed, + keyboard->modifiers.mods_latched, keyboard->modifiers.mods_locked, keyboard->modifiers.group); +} + +void InputDevice::sendKeyPressEvent(uint code) +{ + wl_keyboard *keyboard = keyboardDevice(); + if (keyboard->focus_resource) { + uint32_t time = m_compositor->currentTimeMsecs(); + uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); + wl_keyboard_send_key(keyboard->focus_resource, + serial, time, code - 8, 1); + } + updateModifierState(code, 1); +} + +void InputDevice::sendKeyReleaseEvent(uint code) +{ + wl_keyboard *keyboard = keyboardDevice(); + if (keyboard->focus_resource) { + uint32_t time = m_compositor->currentTimeMsecs(); + uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); + wl_keyboard_send_key(keyboard->focus_resource, + serial, time, code - 8, 0); + } + updateModifierState(code, 0); +} + +void InputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state) +{ + uint32_t time = m_compositor->currentTimeMsecs(); + uint32_t serial = 0; + wl_touch *touch = touchDevice(); + wl_resource *resource = touch->focus_resource; + if (!resource) + return; + switch (state) { + case Qt::TouchPointPressed: + wl_touch_send_down(resource, serial, time, &touch->focus->resource, id, + wl_fixed_from_double(x), wl_fixed_from_double(y)); + break; + case Qt::TouchPointMoved: + wl_touch_send_motion(resource, time, id, + wl_fixed_from_double(x), wl_fixed_from_double(y)); + break; + case Qt::TouchPointReleased: + wl_touch_send_up(resource, serial, time, id); + break; + case Qt::TouchPointStationary: + // stationary points are not sent through wayland, the client must cache them + break; + default: + break; + } +} + +void InputDevice::sendTouchFrameEvent() +{ + wl_touch *touch = touchDevice(); + wl_resource *resource = touch->focus_resource; + if (resource) + wl_touch_send_frame(resource); +} + +void InputDevice::sendTouchCancelEvent() +{ + wl_touch *touch = touchDevice(); + wl_resource *resource = touch->focus_resource; + if (resource) + wl_touch_send_cancel(resource); +} + +void InputDevice::sendFullKeyEvent(QKeyEvent *event) +{ + if (!keyboardFocus()) { + qWarning("Cannot send key event, no keyboard focus, fix the compositor"); + return; + } + + QtKeyExtensionGlobal *ext = m_compositor->qtkeyExtension(); + if (ext && ext->postQtKeyEvent(event, keyboardFocus())) + return; + + if (event->type() == QEvent::KeyPress) + sendKeyPressEvent(event->nativeScanCode()); + else if (event->type() == QEvent::KeyRelease) + sendKeyReleaseEvent(event->nativeScanCode()); +} + +void InputDevice::sendFullTouchEvent(QTouchEvent *event) +{ + if (!mouseFocus()) { + qWarning("Cannot send touch event, no pointer focus, fix the compositor"); + return; + } + + if (event->type() == QEvent::TouchCancel) { + sendTouchCancelEvent(); + return; + } + + TouchExtensionGlobal *ext = m_compositor->touchExtension(); + if (ext && ext->postTouchEvent(event, mouseFocus())) + return; + + const QList points = event->touchPoints(); + if (points.isEmpty()) + return; + + const int pointCount = points.count(); + QPointF pos = mouseFocus()->pos(); + for (int i = 0; i < pointCount; ++i) { + const QTouchEvent::TouchPoint &tp(points.at(i)); + // Convert the local pos in the compositor window to surface-relative. + QPointF p = tp.pos() - pos; + sendTouchPointEvent(tp.id(), p.x(), p.y(), tp.state()); + } + sendTouchFrameEvent(); +} + +Surface *InputDevice::keyboardFocus() const +{ + return wayland_cast(keyboardDevice()->focus); +} + +/*! + * \return True if the keyboard focus is changed successfully. False for inactive transient surfaces. + */ +bool InputDevice::setKeyboardFocus(Surface *surface) +{ + if (surface && surface->transientInactive()) + return false; + + sendSelectionFocus(surface); + wl_keyboard_set_focus(keyboardDevice(), surface ? surface->base() : 0); + return true; +} + +Surface *InputDevice::mouseFocus() const +{ + return wayland_cast(pointerDevice()->focus); +} + +void InputDevice::setMouseFocus(Surface *surface, const QPointF &localPos, const QPointF &globalPos) +{ + wl_pointer *pointer = pointerDevice(); + pointer->x = wl_fixed_from_double(globalPos.x()); + pointer->y = wl_fixed_from_double(globalPos.y()); + pointer->current = surface ? surface->base() : 0; + pointer->current_x = wl_fixed_from_double(localPos.x()); + pointer->current_y = wl_fixed_from_double(localPos.y()); + pointer->grab->interface->focus(pointer->grab, + surface ? surface->base() : 0, + wl_fixed_from_double(localPos.x()), wl_fixed_from_double(localPos.y())); + + // We have no separate touch focus management so make it match the pointer focus always. + // No wl_touch_set_focus() is available so set it manually. + wl_touch *touch = touchDevice(); + touch->focus = surface ? surface->base() : 0; + touch->focus_resource = Compositor::resourceForSurface(&touch->resource_list, surface); +} + +void InputDevice::cleanupDataDeviceForClient(struct wl_client *client, bool destroyDev) +{ + for (int i = 0; i < m_data_devices.size(); i++) { + struct wl_resource *data_device_resource = + m_data_devices.at(i)->dataDeviceResource(); + if (data_device_resource->client == client) { + if (destroyDev) + delete m_data_devices.at(i); + m_data_devices.removeAt(i); + break; + } + } +} + +void InputDevice::clientRequestedDataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id) +{ + cleanupDataDeviceForClient(client, false); + DataDevice *dataDevice = new DataDevice(data_device_manager,client,id); + m_data_devices.append(dataDevice); +} + +void InputDevice::sendSelectionFocus(Surface *surface) +{ + if (!surface) + return; + DataDevice *device = dataDevice(surface->base()->resource.client); + if (device) { + device->sendSelectionFocus(); + } +} + +Compositor *InputDevice::compositor() const +{ + return m_compositor; +} + +QWaylandInputDevice *InputDevice::handle() const +{ + return m_handle; +} + +uint32_t InputDevice::toWaylandButton(Qt::MouseButton button) +{ +#ifndef BTN_LEFT + uint32_t BTN_LEFT = 0x110; +#endif + // the range of valid buttons (evdev module) is from 0x110 + // through 0x11f. 0x120 is the first 'Joystick' button. + switch (button) { + case Qt::LeftButton: return BTN_LEFT; + case Qt::RightButton: return uint32_t(0x111); + case Qt::MiddleButton: return uint32_t(0x112); + case Qt::ExtraButton1: return uint32_t(0x113); // AKA Qt::BackButton, Qt::XButton1 + case Qt::ExtraButton2: return uint32_t(0x114); // AKA Qt::ForwardButton, Qt::XButton2 + case Qt::ExtraButton3: return uint32_t(0x115); + case Qt::ExtraButton4: return uint32_t(0x116); + case Qt::ExtraButton5: return uint32_t(0x117); + case Qt::ExtraButton6: return uint32_t(0x118); + case Qt::ExtraButton7: return uint32_t(0x119); + case Qt::ExtraButton8: return uint32_t(0x11a); + case Qt::ExtraButton9: return uint32_t(0x11b); + case Qt::ExtraButton10: return uint32_t(0x11c); + case Qt::ExtraButton11: return uint32_t(0x11d); + case Qt::ExtraButton12: return uint32_t(0x11e); + case Qt::ExtraButton13: return uint32_t(0x11f); + // default should not occur; but if it does, then return Wayland's highest possible button number. + default: return uint32_t(0x11f); + } +} + +DataDevice *InputDevice::dataDevice(struct wl_client *client) const +{ + for (int i = 0; i < m_data_devices.size();i++) { + if (m_data_devices.at(i)->dataDeviceResource()->client == client) { + return m_data_devices.at(i); + } + } + return 0; +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlinputdevice_p.h b/src/compositor/wayland_wrapper/qwlinputdevice_p.h new file mode 100644 index 000000000..9365fa9de --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlinputdevice_p.h @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLINPUTDEVICE_H +#define WLINPUTDEVICE_H + +#include + +#include + +#include +#include + +#ifndef QT_NO_WAYLAND_XKB +#include +#endif + +QT_BEGIN_NAMESPACE + +class QKeyEvent; +class QTouchEvent; +class QWaylandInputDevice; + +namespace QtWayland { + +class Compositor; +class DataDevice; +class Surface; +class DataDeviceManager; + +class InputDevice : public Object +{ +public: + InputDevice(QWaylandInputDevice *handle, Compositor *compositor); + ~InputDevice(); + + void sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF()); + void sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF()); + void sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos = QPointF()); + void sendMouseMoveEvent(Surface *surface, const QPointF &localPos, const QPointF &globalPos = QPointF()); + void sendMouseWheelEvent(Qt::Orientation orientation, int delta); + + void sendKeyPressEvent(uint code); + void sendKeyReleaseEvent(uint code); + + void sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state); + void sendTouchFrameEvent(); + void sendTouchCancelEvent(); + + void sendFullKeyEvent(QKeyEvent *event); + void sendFullTouchEvent(QTouchEvent *event); + + Surface *keyboardFocus() const; + bool setKeyboardFocus(Surface *surface); + + Surface *mouseFocus() const; + void setMouseFocus(Surface *surface, const QPointF &localPos, const QPointF &globalPos); + + void clientRequestedDataDevice(DataDeviceManager *dndSelection, struct wl_client *client, uint32_t id); + DataDevice *dataDevice(struct wl_client *client) const; + void sendSelectionFocus(Surface *surface); + + Compositor *compositor() const; + QWaylandInputDevice *handle() const; + + wl_pointer *pointerDevice(); + wl_keyboard *keyboardDevice(); + wl_touch *touchDevice(); + const wl_pointer *pointerDevice() const; + const wl_keyboard *keyboardDevice() const; + const wl_touch *touchDevice() const; + +private: + void initDevices(); + void releaseDevices(); + void cleanupDataDeviceForClient(struct wl_client *client, bool destroyDev); + void updateModifierState(uint key, int state); + void sendKeyModifiers(wl_resource *resource); + + QWaylandInputDevice *m_handle; + Compositor *m_compositor; + QList m_data_devices; + struct { + wl_pointer pointer; + wl_keyboard keyboard; + wl_touch touch; + } m_device_interfaces; + +#ifndef QT_NO_WAYLAND_XKB + struct xkb_keymap *m_keymap; + struct xkb_state *m_state; + int m_keymap_fd; + size_t m_keymap_size; + char *m_keymap_area; +#endif + + uint32_t toWaylandButton(Qt::MouseButton button); + + static void bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + + static void set_cursor(struct wl_client *client, + struct wl_resource *device_base, + uint32_t serial, + struct wl_resource *surface, + int32_t hotspot_x, + int32_t hotspot_y); + const static struct wl_pointer_interface pointer_interface; + + static void get_pointer(struct wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void get_keyboard(struct wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void get_touch(struct wl_client *client, + struct wl_resource *resource, + uint32_t id); + const static struct wl_seat_interface seat_interface; + + static void destroy_resource(wl_resource *resource); + static void destroy_device_resource(wl_resource *resource); +}; + +} + +QT_END_NAMESPACE + +#endif // WLINPUTDEVICE_H diff --git a/src/compositor/wayland_wrapper/qwloutput.cpp b/src/compositor/wayland_wrapper/qwloutput.cpp new file mode 100644 index 000000000..f248dccdb --- /dev/null +++ b/src/compositor/wayland_wrapper/qwloutput.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwloutput_p.h" +#include "qwlextendedoutput_p.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +OutputGlobal::OutputGlobal() + : m_displayId(-1) + , m_numQueued(0) +{ + QScreen *screen = QGuiApplication::primaryScreen(); + m_geometry = QRect(QPoint(0, 0), screen->availableGeometry().size()); + m_refreshRate = qRound(screen->refreshRate()); +} + +OutputGlobal::~OutputGlobal() +{ + qDeleteAll(m_outputs); +} + +void OutputGlobal::setGeometry(const QRect &geometry) +{ + m_geometry = geometry; +} + +void OutputGlobal::setRefreshRate(int rate) +{ + m_refreshRate = rate; +} + +Output *OutputGlobal::outputForClient(wl_client *client) const +{ + return static_cast(resourceForClient(client)->data); +} + +void OutputGlobal::output_bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + OutputGlobal *output_global = static_cast(data); + + Output *output = new Output(output_global,client,version,id); + output_global->registerResource(output->handle()); + output_global->m_outputs.append(output); +} + + + +Output::Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id) + : m_output_global(outputGlobal) + , m_extended_output(0) +{ + Q_UNUSED(version); + m_output_resource = wl_client_add_object(client,&wl_output_interface,0,id,this); + wl_output_send_geometry(m_output_resource, 0, 0, + m_output_global->size().width(), m_output_global->size().height(),0,"","",0); + + wl_output_send_mode(m_output_resource, WL_OUTPUT_MODE_CURRENT|WL_OUTPUT_MODE_PREFERRED, + m_output_global->size().width(), m_output_global->size().height(), m_output_global->refreshRate()); + +} + +Output::~Output() +{ +} + +ExtendedOutput *Output::extendedOutput() const +{ + return m_extended_output; +} + +void Output::setExtendedOutput(ExtendedOutput *extendedOutput) +{ + m_extended_output = extendedOutput; +} + +wl_resource *Output::handle() const +{ + return m_output_resource; +} + +} // namespace Wayland + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwloutput_p.h b/src/compositor/wayland_wrapper/qwloutput_p.h new file mode 100644 index 000000000..11341737d --- /dev/null +++ b/src/compositor/wayland_wrapper/qwloutput_p.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WL_OUTPUT_H +#define WL_OUTPUT_H + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Output; +class ExtendedOutput; + +class OutputGlobal : public ResourceCollection +{ +public: + OutputGlobal(); + ~OutputGlobal(); + + void setGeometry(const QRect &geometry); + QRect geometry() const { return m_geometry; } + + int x() const { return m_geometry.x(); } + int y() const { return m_geometry.y(); } + QSize size() const { return m_geometry.size(); } + + void setRefreshRate(int rate); + int refreshRate() const { return m_refreshRate; } + + Output *outputForClient(struct wl_client *client) const; + + static void output_bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); +private: + QRect m_geometry; + int m_refreshRate; + int m_displayId; + int m_numQueued; + QList m_outputs; +}; + + +class Output +{ +public: + Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id); + ~Output(); + + OutputGlobal *outputGlobal() const; + + ExtendedOutput *extendedOutput() const; + void setExtendedOutput(ExtendedOutput *extendedOutput); + + struct wl_resource *handle() const; +private: + struct wl_resource *m_output_resource; + OutputGlobal *m_output_global; + ExtendedOutput *m_extended_output; + +}; + +} + +QT_END_NAMESPACE + +#endif //WL_OUTPUT_H diff --git a/src/compositor/wayland_wrapper/qwlqtkey.cpp b/src/compositor/wayland_wrapper/qwlqtkey.cpp new file mode 100644 index 000000000..a6fea9f2a --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlqtkey.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlqtkey_p.h" +#include "qwlsurface_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +static void dummy(wl_client *, wl_resource *) +{ +} + +const struct wl_qtkey_extension_interface QtKeyExtensionGlobal::qtkey_interface = { + dummy +}; + +QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor) + : m_compositor(compositor) +{ + wl_display_add_global(compositor->wl_display(), + &wl_qtkey_extension_interface, + this, + QtKeyExtensionGlobal::bind_func); +} + +QtKeyExtensionGlobal::~QtKeyExtensionGlobal() +{ +} + +void QtKeyExtensionGlobal::destroy_resource(wl_resource *resource) +{ + QtKeyExtensionGlobal *self = static_cast(resource->data); + self->m_resources.removeOne(resource); + free(resource); +} + +void QtKeyExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + wl_resource *resource = wl_client_add_object(client, &wl_qtkey_extension_interface, &qtkey_interface, id, data); + resource->destroy = destroy_resource; + QtKeyExtensionGlobal *self = static_cast(resource->data); + self->m_resources.append(resource); +} + +bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) +{ + wl_client *surfaceClient = surface->base()->resource.client; + uint32_t time = m_compositor->currentTimeMsecs(); + const int rescount = m_resources.count(); + + for (int res = 0; res < rescount; ++res) { + wl_resource *target = m_resources.at(res); + if (target->client != surfaceClient) + continue; + + QByteArray textUtf8 = event->text().toUtf8(); + + wl_qtkey_extension_send_qtkey(target, + time, event->type(), event->key(), event->modifiers(), + event->nativeScanCode(), + event->nativeVirtualKey(), + event->nativeModifiers(), + textUtf8.constData(), + event->isAutoRepeat(), + event->count()); + + return true; + } + + return false; +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlqtkey_p.h b/src/compositor/wayland_wrapper/qwlqtkey_p.h new file mode 100644 index 000000000..bb98f9b88 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlqtkey_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLQTKEY_H +#define WLQTKEY_H + +#include +#include "wayland-qtkey-extension-server-protocol.h" +#include "wayland-util.h" + +QT_BEGIN_NAMESPACE + +class Compositor; +class Surface; +class QKeyEvent; + +namespace QtWayland { + +class QtKeyExtensionGlobal +{ +public: + QtKeyExtensionGlobal(Compositor *compositor); + ~QtKeyExtensionGlobal(); + + bool postQtKeyEvent(QKeyEvent *event, Surface *surface); + +private: + static void bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + + static void destroy_resource(wl_resource *resource); + + static const struct wl_qtkey_extension_interface qtkey_interface; + + Compositor *m_compositor; + QList m_resources; +}; + +} + +QT_END_NAMESPACE + +#endif // WLQTKEY_H diff --git a/src/compositor/wayland_wrapper/qwlregion.cpp b/src/compositor/wayland_wrapper/qwlregion.cpp new file mode 100644 index 000000000..c9e452528 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlregion.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlregion_p.h" + +#include "qwlcompositor_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +void destroy_region(struct wl_resource *resource) +{ + delete resolve(resource); +} + +Region::Region(struct wl_client *client, uint32_t id) +{ + addClientResource(client, base(), id, &wl_region_interface, + ®ion_interface, destroy_region); +} + +Region::~Region() +{ +} + +const struct wl_region_interface Region::region_interface = { + region_destroy, + region_add, + region_subtract +}; + +void Region::region_destroy(wl_client *client, wl_resource *region) +{ + Q_UNUSED(client); + wl_resource_destroy(region); +} + +void Region::region_add(wl_client *client, wl_resource *region, + int32_t x, int32_t y, int32_t w, int32_t h) +{ + Q_UNUSED(client); + resolve(region)->m_region += QRect(x, y, w, h); +} + +void Region::region_subtract(wl_client *client, wl_resource *region, + int32_t x, int32_t y, int32_t w, int32_t h) +{ + Q_UNUSED(client); + resolve(region)->m_region -= QRect(x, y, w, h); +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlregion_p.h b/src/compositor/wayland_wrapper/qwlregion_p.h new file mode 100644 index 000000000..2002e7370 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlregion_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WL_REGION_H +#define WL_REGION_H + +#include +#include + +#include + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Q_COMPOSITOR_EXPORT Region : public Object +{ +public: + Region(struct wl_client *client, uint32_t id); + ~Region(); + + uint id() const { return base()->object.id; } + + QRegion region() const { return m_region; } + + static const struct wl_region_interface region_interface; + +private: + Q_DISABLE_COPY(Region) + + QRegion m_region; + + static void region_destroy(wl_client *client, wl_resource *region); + static void region_add(wl_client *client, wl_resource *region, + int32_t x, int32_t y, int32_t w, int32_t h); + static void region_subtract(wl_client *client, wl_resource *region, + int32_t x, int32_t y, int32_t w, int32_t h); +}; + +} + +QT_END_NAMESPACE + +#endif // WL_REGION_H + diff --git a/src/compositor/wayland_wrapper/qwlshellsurface.cpp b/src/compositor/wayland_wrapper/qwlshellsurface.cpp new file mode 100644 index 000000000..f8d6e0c5c --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlshellsurface.cpp @@ -0,0 +1,477 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlshellsurface_p.h" + +#include "qwlcompositor_p.h" +#include "qwlsurface_p.h" +#include "qwlinputdevice_p.h" +#include "qwlsubsurface_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +Shell::Shell() +{ +} + +void Shell::bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + wl_client_add_object(client,&wl_shell_interface,&shell_interface,id,data); +} + +void Shell::get_shell_surface(struct wl_client *client, + struct wl_resource *shell_resource, + uint32_t id, + struct wl_resource *surface_super) +{ + Q_UNUSED(shell_resource); + Surface *surface = resolve(surface_super); + new ShellSurface(client,id,surface); +} + +const struct wl_shell_interface Shell::shell_interface = { + Shell::get_shell_surface +}; + +ShellSurface::ShellSurface(wl_client *client, uint32_t id, Surface *surface) + : m_surface(surface) + , m_resizeGrabber(0) + , m_moveGrabber(0) + , m_transientParent(0) + , m_xOffset(0) + , m_yOffset(0) +{ + m_shellSurface = wl_client_add_object(client,&wl_shell_surface_interface,&shell_surface_interface,id,this); + surface->setShellSurface(this); +} + +void ShellSurface::sendConfigure(uint32_t edges, int32_t width, int32_t height) +{ + wl_shell_surface_send_configure(m_shellSurface,edges,width,height); +} + +Surface *ShellSurface::surface() const +{ + return m_surface; +} + +void ShellSurface::adjustPosInResize() +{ + if (m_transientParent) + return; + if (!m_resizeGrabber || !(m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP_LEFT)) + return; + + int bottomLeftX = wl_fixed_to_int(m_resizeGrabber->base()->x) + m_resizeGrabber->width; + int bottomLeftY = wl_fixed_to_int(m_resizeGrabber->base()->y) + m_resizeGrabber->height; + qreal x = surface()->pos().x(); + qreal y = surface()->pos().y(); + if (m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP) + y = bottomLeftY - surface()->size().height(); + if (m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT) + x = bottomLeftX - surface()->size().width(); + QPointF newPos(x,y); + surface()->setPos(newPos); +} + +QPointF ShellSurface::adjustedPosToTransientParent() const +{ + if (!m_transientParent || + (m_surface->subSurface() && m_surface->subSurface()->parent())) + return m_surface->nonAdjustedPos(); + + return m_transientParent->surface()->pos() + QPoint(m_xOffset,m_yOffset); +} + +void ShellSurface::resetResizeGrabber() +{ + m_resizeGrabber = 0; +} + +void ShellSurface::resetMoveGrabber() +{ + m_moveGrabber = 0; +} + +ShellSurface *ShellSurface::transientParent() const +{ + return m_transientParent; +} + +void ShellSurface::setOffset(const QPointF &offset) +{ + m_xOffset = offset.x(); + m_yOffset = offset.y(); +} + +void ShellSurface::move(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *input_device_super, + uint32_t time) +{ + Q_UNUSED(client); + Q_UNUSED(time); + ShellSurface *self = static_cast(shell_surface_resource->data); + InputDevice *input_device = static_cast(input_device_super->data); + if (self->m_resizeGrabber || self->m_moveGrabber) { + qDebug() << "invalid state"; + return; + } + + self->m_moveGrabber = new ShellSurfaceMoveGrabber(self); + wl_pointer *pointer = input_device->pointerDevice(); + self->m_moveGrabber->base()->x = pointer->x; + self->m_moveGrabber->base()->y = pointer->y; + self->m_moveGrabber->offset_x = wl_fixed_to_int(pointer->x) - self->surface()->pos().x(); + self->m_moveGrabber->offset_y = wl_fixed_to_int(pointer->y) - self->surface()->pos().y(); + + wl_pointer_start_grab(pointer, self->m_moveGrabber->base()); +} + +void ShellSurface::resize(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *input_device_super, + uint32_t time, + uint32_t edges) +{ + Q_UNUSED(shell_surface_resource); + Q_UNUSED(client); + Q_UNUSED(time); + Q_UNUSED(edges); + ShellSurface *self = static_cast(shell_surface_resource->data); + InputDevice *input_device = static_cast(input_device_super->data); + if (self->m_moveGrabber || self->m_resizeGrabber) { + qDebug() << "invalid state2"; + return; + } + self->m_resizeGrabber = new ShellSurfaceResizeGrabber(self); + wl_pointer *pointer = input_device->pointerDevice(); + self->m_resizeGrabber->base()->x = pointer->x; + self->m_resizeGrabber->base()->y = pointer->y; + self->m_resizeGrabber->resize_edges = wl_shell_surface_resize(edges); + self->m_resizeGrabber->width = self->surface()->size().width(); + self->m_resizeGrabber->height = self->surface()->size().height(); + + wl_pointer_start_grab(pointer, self->m_resizeGrabber->base()); +} + +void ShellSurface::set_toplevel(struct wl_client *client, + struct wl_resource *shell_surface_resource) +{ + Q_UNUSED(client); + ShellSurface *self = static_cast(shell_surface_resource->data); + self->m_transientParent = 0; + self->m_xOffset = 0; + self->m_yOffset = 0; + +} + +void ShellSurface::set_transient(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *parent_surface_resource, + int x, + int y, + uint32_t flags) +{ + + Q_UNUSED(client); + Q_UNUSED(flags); + ShellSurface *shell_surface = static_cast(shell_surface_resource->data); + Surface *parent_surface = static_cast(parent_surface_resource->data); + shell_surface->m_transientParent = parent_surface->shellSurface(); + shell_surface->m_xOffset = x; + shell_surface->m_yOffset = y; + if (flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE) + shell_surface->surface()->setTransientInactive(true); +} + +void ShellSurface::set_fullscreen(struct wl_client *client, + struct wl_resource *shell_surface_resource, + uint32_t method, + uint32_t framerate, + struct wl_resource *output) +{ + Q_UNUSED(client); + Q_UNUSED(shell_surface_resource); + Q_UNUSED(method); + Q_UNUSED(framerate); + Q_UNUSED(output); +} + +void ShellSurface::set_popup(wl_client *client, wl_resource *resource, wl_resource *input_device, uint32_t time, wl_resource *parent, int32_t x, int32_t y, uint32_t flags) +{ + Q_UNUSED(client); + Q_UNUSED(resource); + Q_UNUSED(input_device); + Q_UNUSED(time); + Q_UNUSED(parent); + Q_UNUSED(x); + Q_UNUSED(y); + Q_UNUSED(flags); +} + +void ShellSurface::set_maximized(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *output) +{ + Q_UNUSED(client); + Q_UNUSED(shell_surface_resource); + Q_UNUSED(output); +} + +void ShellSurface::pong(struct wl_client *client, + struct wl_resource *resource, + uint32_t serial) +{ + Q_UNUSED(client); + Q_UNUSED(resource); + Q_UNUSED(serial); +} + +void ShellSurface::set_title(struct wl_client *client, + struct wl_resource *resource, + const char *title) +{ + Q_UNUSED(client); + ShellSurface *self = static_cast(resource->data); + self->surface()->setTitle(QString::fromUtf8(title)); +} + +void ShellSurface::set_class(struct wl_client *client, + struct wl_resource *resource, + const char *class_) +{ + Q_UNUSED(client); + ShellSurface *self = static_cast(resource->data); + self->surface()->setClassName(QString::fromUtf8(class_)); +} + +const struct wl_shell_surface_interface ShellSurface::shell_surface_interface = { + ShellSurface::pong, + ShellSurface::move, + ShellSurface::resize, + ShellSurface::set_toplevel, + ShellSurface::set_transient, + ShellSurface::set_fullscreen, + ShellSurface::set_popup, + ShellSurface::set_maximized, + ShellSurface::set_title, + ShellSurface::set_class +}; + +Qt::MouseButton toQtButton(uint32_t button) +{ +#ifndef BTN_LEFT + static const uint32_t BTN_LEFT = 0x110; + static const uint32_t BTN_RIGHT = 0x111; + static const uint32_t BTN_MIDDLE = 0x112; +#endif + switch (button) { + case BTN_LEFT: + return Qt::LeftButton; + case BTN_RIGHT: + return Qt::RightButton; + case BTN_MIDDLE: + return Qt::MiddleButton; + default: + return Qt::NoButton; + } +} + +ShellSurfaceGrabber::ShellSurfaceGrabber(ShellSurface *shellSurface, const struct wl_pointer_grab_interface *interface) + : shell_surface(shellSurface) +{ + base()->interface = interface; + base()->focus = shell_surface->surface()->base(); +} + +ShellSurfaceGrabber::~ShellSurfaceGrabber() +{ +} + + +void ShellSurfaceGrabber::destroy(wl_listener *listener, wl_resource *resource, uint32_t time) +{ + Q_UNUSED(resource); + Q_UNUSED(time); + Q_UNUSED(listener); + //ShellSurfaceGrabber *shell_surface_grabber = container_of(listener, ShellSurfaceGrabber,surface_destroy_listener); + Q_ASSERT(false); //hasn't been enabled yet + //wl_input_device_end_grab(shell_surface_grabber->base()->input_device,Compositor::currentTimeMsecs()); +} + + +ShellSurfaceResizeGrabber::ShellSurfaceResizeGrabber(ShellSurface *shellSurface) + : ShellSurfaceGrabber(shellSurface,&resize_grabber_interface) +{ +} + +void ShellSurfaceResizeGrabber::focus(wl_pointer_grab *grab, wl_surface *surface, int32_t x, int32_t y) +{ + Q_UNUSED(grab); + Q_UNUSED(surface); + Q_UNUSED(x); + Q_UNUSED(y); +} + +void ShellSurfaceResizeGrabber::motion(wl_pointer_grab *grab, uint32_t time, int32_t x, int32_t y) +{ + Q_UNUSED(time); + Q_UNUSED(x); + Q_UNUSED(y); + //Should be more structured + ShellSurfaceResizeGrabber *resize_grabber = reinterpret_cast(grab); + ShellSurface *shell_surface = resize_grabber->shell_surface; + wl_pointer *pointer = grab->pointer; + int width_delta = wl_fixed_to_int(grab->x) - wl_fixed_to_int(pointer->x); + int height_delta = wl_fixed_to_int(grab->y) - wl_fixed_to_int(pointer->y); + int new_width = resize_grabber->width; + int new_height = resize_grabber->height; + if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP_LEFT) { + if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP) { + if (new_height + height_delta > 0) { + new_height += height_delta; + } else { + new_height = 1; + } + } + if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT) { + if (new_width + width_delta > 0) { + new_width += width_delta; + } else { + new_width = 1; + } + } + } + + if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) { + if (new_height - height_delta > 0) { + new_height -= height_delta; + } else { + new_height = 1; + } + } + if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_RIGHT) { + if (new_width - width_delta > 0) { + new_width -= width_delta; + } else { + new_width =1; + } + } + + shell_surface->sendConfigure(resize_grabber->resize_edges,new_width,new_height); +} + +void ShellSurfaceResizeGrabber::button(wl_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state) +{ + Q_UNUSED(time) + ShellSurfaceResizeGrabber *self = reinterpret_cast(grab); + ShellSurface *shell_surface = self->shell_surface; + if (toQtButton(button) == Qt::LeftButton && !state) { + wl_pointer_end_grab(grab->pointer); + shell_surface->resetResizeGrabber(); + delete self; + } +} + +const struct wl_pointer_grab_interface ShellSurfaceResizeGrabber::resize_grabber_interface = { + ShellSurfaceResizeGrabber::focus, + ShellSurfaceResizeGrabber::motion, + ShellSurfaceResizeGrabber::button +}; + +ShellSurfaceMoveGrabber::ShellSurfaceMoveGrabber(ShellSurface *shellSurface) + : ShellSurfaceGrabber(shellSurface,&move_grabber_interface) +{ +} + +void ShellSurfaceMoveGrabber::focus(wl_pointer_grab *grab, wl_surface *surface, int32_t x, int32_t y) +{ + Q_UNUSED(grab); + Q_UNUSED(surface); + Q_UNUSED(x); + Q_UNUSED(y); +} + +void ShellSurfaceMoveGrabber::motion(wl_pointer_grab *grab, uint32_t time, int32_t x, int32_t y) +{ + Q_UNUSED(time); + Q_UNUSED(x); + Q_UNUSED(y); + ShellSurfaceMoveGrabber *shell_surface_grabber = reinterpret_cast(grab); + ShellSurface *shell_surface = shell_surface_grabber->shell_surface; + wl_pointer *pointer = grab->pointer; + QPointF pos(wl_fixed_to_int(pointer->x) - shell_surface_grabber->offset_x, + wl_fixed_to_int(pointer->y) - shell_surface_grabber->offset_y); + shell_surface->surface()->setPos(pos); + if (shell_surface->transientParent()) + shell_surface->setOffset(pos - shell_surface->transientParent()->surface()->pos()); + shell_surface->surface()->damage(QRect(QPoint(0,0),shell_surface->surface()->size())); +} + +void ShellSurfaceMoveGrabber::button(wl_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state) +{ + Q_UNUSED(time) + ShellSurfaceResizeGrabber *self = reinterpret_cast(grab); + ShellSurface *shell_surface = self->shell_surface; + if (toQtButton(button) == Qt::LeftButton && !state) { + wl_pointer_set_focus(grab->pointer, 0, 0, 0); + wl_pointer_end_grab(grab->pointer); + shell_surface->resetMoveGrabber(); + delete self; + } +} + +const struct wl_pointer_grab_interface ShellSurfaceMoveGrabber::move_grabber_interface = { + ShellSurfaceMoveGrabber::focus, + ShellSurfaceMoveGrabber::motion, + ShellSurfaceMoveGrabber::button +}; + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlshellsurface_p.h b/src/compositor/wayland_wrapper/qwlshellsurface_p.h new file mode 100644 index 000000000..1bb0c4e42 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlshellsurface_p.h @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLSHELLSURFACE_H +#define WLSHELLSURFACE_H + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Compositor; +class Surface; +class ShellSurface; +class ShellSurfaceResizeGrabber; +class ShellSurfaceMoveGrabber; + +class Shell +{ +public: + Shell(); + + static void bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); +private: + static void get_shell_surface(struct wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct wl_resource *surface); + static const struct wl_shell_interface shell_interface; + +}; + +class ShellSurface +{ +public: + ShellSurface(struct wl_client *client, uint32_t id, Surface *surface); + void sendConfigure(uint32_t edges, int32_t width, int32_t height); + + Surface *surface() const; + + void adjustPosInResize(); + QPointF adjustedPosToTransientParent() const; + void resetResizeGrabber(); + void resetMoveGrabber(); + + ShellSurface *transientParent() const; + void setOffset(const QPointF &offset); + +private: + struct wl_resource *m_shellSurface; + Surface *m_surface; + + ShellSurfaceResizeGrabber *m_resizeGrabber; + ShellSurfaceMoveGrabber *m_moveGrabber; + + ShellSurface *m_transientParent; + + int32_t m_xOffset; + int32_t m_yOffset; + + static void move(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *input_device_super, + uint32_t time); + static void resize(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *input_device, + uint32_t time, + uint32_t edges); + static void set_toplevel(struct wl_client *client, + struct wl_resource *shell_surface_resource); + static void set_transient(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *parent_surface_resource, + int x, + int y, + uint32_t flags); + static void set_fullscreen(struct wl_client *client, + struct wl_resource *shell_surface_resource, + uint32_t method, + uint32_t framerate, + struct wl_resource *output); + static void set_popup(struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *input_device, + uint32_t time, + struct wl_resource *parent, + int32_t x, + int32_t y, + uint32_t flags); + static void set_maximized(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *output); + static void pong(struct wl_client *client, + struct wl_resource *resource, + uint32_t serial); + static void set_title(struct wl_client *client, + struct wl_resource *resource, + const char *title); + static void set_class(struct wl_client *client, + struct wl_resource *resource, + const char *class_); + + static const struct wl_shell_surface_interface shell_surface_interface; +}; + +class ShellSurfaceGrabber : public Object +{ +public: + ShellSurfaceGrabber(ShellSurface *shellSurface, const struct wl_pointer_grab_interface *interface); + ~ShellSurfaceGrabber(); + + struct wl_listener surface_destroy_listener; + static void destroy(struct wl_listener *listener, + struct wl_resource *resource, uint32_t time); + + ShellSurface *shell_surface; +}; + +class ShellSurfaceResizeGrabber : public ShellSurfaceGrabber +{ +public: + ShellSurfaceResizeGrabber(ShellSurface *shellSurface); + + + enum wl_shell_surface_resize resize_edges; + int32_t width; + int32_t height; + + static void focus(struct wl_pointer_grab *grab, + struct wl_surface *surface, int32_t x, int32_t y); + static void motion(struct wl_pointer_grab *grab, + uint32_t time, int32_t x, int32_t y); + static void button(struct wl_pointer_grab *grab, + uint32_t time, uint32_t mouse_grabber_button, uint32_t state); + static const struct wl_pointer_grab_interface resize_grabber_interface; +}; + +class ShellSurfaceMoveGrabber : public ShellSurfaceGrabber +{ +public: + ShellSurfaceMoveGrabber(ShellSurface *shellSurface); + + int32_t offset_x; + int32_t offset_y; + + static void focus(struct wl_pointer_grab *grab, + struct wl_surface *surface, int32_t x, int32_t y); + static void motion(struct wl_pointer_grab *grab, + uint32_t time, int32_t x, int32_t y); + static void button(struct wl_pointer_grab *grab, + uint32_t time, uint32_t mouse_grabber_button, uint32_t state); + static const struct wl_pointer_grab_interface move_grabber_interface; +}; + +} + +QT_END_NAMESPACE + +#endif // WLSHELLSURFACE_H diff --git a/src/compositor/wayland_wrapper/qwlsubsurface.cpp b/src/compositor/wayland_wrapper/qwlsubsurface.cpp new file mode 100644 index 000000000..f482cde6d --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlsubsurface.cpp @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlsubsurface_p.h" + +#include "qwlcompositor_p.h" +#include "qwaylandsurface.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +SubSurfaceExtensionGlobal::SubSurfaceExtensionGlobal(Compositor *compositor) + : m_compositor(compositor) +{ + wl_display_add_global(m_compositor->wl_display(), + &wl_sub_surface_extension_interface, + this, + SubSurfaceExtensionGlobal::bind_func); +} + +void SubSurfaceExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + wl_client_add_object(client, &wl_sub_surface_extension_interface,&sub_surface_extension_interface,id,data); +} + +void SubSurfaceExtensionGlobal::get_sub_surface_aware_surface(wl_client *client, wl_resource *sub_surface_extension_resource, uint32_t id, wl_resource *surface_resource) +{ + Q_UNUSED(sub_surface_extension_resource); + Surface *surface = resolve(surface_resource); + new SubSurface(client,id,surface); +} + +const struct wl_sub_surface_extension_interface SubSurfaceExtensionGlobal::sub_surface_extension_interface = { + SubSurfaceExtensionGlobal::get_sub_surface_aware_surface +}; + +SubSurface::SubSurface(wl_client *client, uint32_t id, Surface *surface) + : m_surface(surface) + , m_parent(0) +{ + surface->setSubSurface(this); + m_sub_surface_resource = wl_client_add_object(client, + &wl_sub_surface_interface, + &sub_surface_interface, + id, + this); +} + +SubSurface::~SubSurface() +{ + if (m_parent) { + m_parent->removeSubSurface(this); + } + QLinkedList::iterator it; + for (it = m_sub_surfaces.begin(); it != m_sub_surfaces.end(); ++it) { + (*it)->handle()->subSurface()->parentDestroyed(); + } +} + +void SubSurface::setSubSurface(SubSurface *subSurface, int x, int y) +{ + if (!m_sub_surfaces.contains(subSurface->m_surface->waylandSurface())) { + m_sub_surfaces.append(subSurface->m_surface->waylandSurface()); + subSurface->setParent(this); + } + subSurface->m_surface->setPos(QPointF(x,y)); +} + +void SubSurface::removeSubSurface(SubSurface *subSurfaces) +{ + Q_ASSERT(m_sub_surfaces.contains(subSurfaces->m_surface->waylandSurface())); + m_sub_surfaces.removeOne(subSurfaces->m_surface->waylandSurface()); +} + +SubSurface *SubSurface::parent() const +{ + return m_parent; +} + +void SubSurface::setParent(SubSurface *parent) +{ + if (m_parent == parent) + return; + + QWaylandSurface *oldParent = 0; + QWaylandSurface *newParent = 0; + + if (m_parent) { + oldParent = m_parent->m_surface->waylandSurface(); + m_parent->removeSubSurface(this); + } + if (parent) { + newParent = parent->m_surface->waylandSurface(); + } + m_parent = parent; + + m_surface->waylandSurface()->parentChanged(newParent,oldParent); +} + +QLinkedList SubSurface::subSurfaces() const +{ + return m_sub_surfaces; +} + +void SubSurface::parentDestroyed() +{ + m_parent = 0; +} +void SubSurface::attach_sub_surface(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource, int32_t x, int32_t y) +{ + Q_UNUSED(client); + SubSurface *parent_sub_surface = static_cast(sub_surface_parent_resource->data); + SubSurface *child_sub_surface = static_cast(sub_surface_child_resource->data); + parent_sub_surface->setSubSurface(child_sub_surface,x,y); +} + +void SubSurface::move_sub_surface(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource, int32_t x, int32_t y) +{ + Q_UNUSED(client); + Q_UNUSED(x); + Q_UNUSED(y); + SubSurface *parent_sub_surface = static_cast(sub_surface_parent_resource->data); + SubSurface *child_sub_surface = static_cast(sub_surface_child_resource->data); + Q_UNUSED(parent_sub_surface); + Q_UNUSED(child_sub_surface); +} + +void SubSurface::raise(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource) +{ + Q_UNUSED(client); + Q_UNUSED(sub_surface_parent_resource); + Q_UNUSED(sub_surface_child_resource); +} + +void SubSurface::lower(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource) +{ + Q_UNUSED(client); + Q_UNUSED(sub_surface_parent_resource); + Q_UNUSED(sub_surface_child_resource); +} + +const struct wl_sub_surface_interface SubSurface::sub_surface_interface = { + SubSurface::attach_sub_surface, + SubSurface::move_sub_surface, + SubSurface::raise, + SubSurface::lower +}; + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlsubsurface_p.h b/src/compositor/wayland_wrapper/qwlsubsurface_p.h new file mode 100644 index 000000000..4fb80d611 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlsubsurface_p.h @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLSUBSURFACE_H +#define WLSUBSURFACE_H + +#include + +#include "wayland-sub-surface-extension-server-protocol.h" + +#include + +QT_BEGIN_NAMESPACE + +class Compositor; +class QWaylandSurface; + +namespace QtWayland { + +class SubSurfaceExtensionGlobal +{ +public: + SubSurfaceExtensionGlobal(Compositor *compositor); + +private: + Compositor *m_compositor; + + static void bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + static void get_sub_surface_aware_surface(struct wl_client *client, + struct wl_resource *sub_surface_extension_resource, + uint32_t id, + struct wl_resource *surface_resource); + + static const struct wl_sub_surface_extension_interface sub_surface_extension_interface; +}; + +class SubSurface +{ +public: + SubSurface(struct wl_client *client, uint32_t id, Surface *surface); + ~SubSurface(); + + void setSubSurface(SubSurface *subSurface, int x, int y); + void removeSubSurface(SubSurface *subSurfaces); + + SubSurface *parent() const; + void setParent(SubSurface *parent); + + QLinkedList subSurfaces() const; + + Surface *surface() const; + QWaylandSurface *waylandSurface() const; + +private: + void parentDestroyed(); + struct wl_resource *m_sub_surface_resource; + Surface *m_surface; + + SubSurface *m_parent; + QLinkedList m_sub_surfaces; + + static void attach_sub_surface(struct wl_client *client, + struct wl_resource *sub_surface_parent_resource, + struct wl_resource *sub_surface_child_resource, + int32_t x, + int32_t y); + static void move_sub_surface(struct wl_client *client, + struct wl_resource *sub_surface_parent_resource, + struct wl_resource *sub_surface_child_resource, + int32_t x, + int32_t y); + static void raise(struct wl_client *client, + struct wl_resource *sub_surface_parent_resource, + struct wl_resource *sub_surface_child_resource); + static void lower(struct wl_client *client, + struct wl_resource *sub_surface_parent_resource, + struct wl_resource *sub_surface_child_resource); + static const struct wl_sub_surface_interface sub_surface_interface; +}; + +inline Surface *SubSurface::surface() const +{ + return m_surface; +} + +inline QWaylandSurface *SubSurface::waylandSurface() const +{ + return m_surface->waylandSurface(); +} + +} + +QT_END_NAMESPACE + +#endif // WLSUBSURFACE_H diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp new file mode 100644 index 000000000..e61b30fc1 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -0,0 +1,525 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlsurface_p.h" + +#include "qwaylandsurface.h" +#ifdef QT_COMPOSITOR_QUICK +#include "qwaylandsurfaceitem.h" +#endif + +#include "qwlcompositor_p.h" +#include "qwlinputdevice_p.h" +#include "qwlextendedsurface_p.h" +#include "qwlregion_p.h" +#include "qwlsubsurface_p.h" +#include "qwlsurfacebuffer_p.h" +#include "qwlshellsurface_p.h" + +#include +#include + +#include + +#ifdef QT_COMPOSITOR_WAYLAND_GL +#include "hardware_integration/qwaylandgraphicshardwareintegration.h" +#include +#endif + +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT +#include "waylandwindowmanagerintegration.h" +#endif + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +void destroy_surface(struct wl_resource *resource) +{ + Surface *surface = resolve(resource); + surface->compositor()->surfaceDestroyed(surface); + delete surface; +} + +Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) + : m_compositor(compositor) + , m_waylandSurface(new QWaylandSurface(this)) + , m_backBuffer(0) + , m_frontBuffer(0) + , m_surfaceMapped(false) + , m_extendedSurface(0) + , m_subSurface(0) + , m_shellSurface(0) + , m_transientInactive(false) + , m_isCursorSurface(false) +{ + wl_list_init(&m_frame_callback_list); + addClientResource(client, &base()->resource, id, &wl_surface_interface, + &Surface::surface_interface, destroy_surface); + for (int i = 0; i < buffer_pool_size; i++) { + m_bufferPool[i] = new SurfaceBuffer(this); + } +} + +Surface::~Surface() +{ + delete m_waylandSurface; + delete m_extendedSurface; + delete m_subSurface; + delete m_shellSurface; + + for (int i = 0; i < buffer_pool_size; i++) { + if (!m_bufferPool[i]->pageFlipperHasBuffer()) + delete m_bufferPool[i]; + } +} + +QWaylandSurface::Type Surface::type() const +{ + SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer(); + if (surfaceBuffer && surfaceBuffer->waylandBufferHandle()) { + if (surfaceBuffer->isShmBuffer()) { + return QWaylandSurface::Shm; + } else { + return QWaylandSurface::Texture; + } + } + return QWaylandSurface::Invalid; +} + +bool Surface::isYInverted() const +{ + bool ret = false; + static bool negateReturn = qgetenv("QT_COMPOSITOR_NEGATE_INVERTED_Y").toInt(); + QWaylandGraphicsHardwareIntegration *graphicsHWIntegration = m_compositor->graphicsHWIntegration(); + +#ifdef QT_COMPOSITOR_WAYLAND_GL + SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); + if (!surfacebuffer) { + ret = false; + } else if (graphicsHWIntegration && surfacebuffer->waylandBufferHandle() && type() != QWaylandSurface::Shm) { + ret = graphicsHWIntegration->isYInverted(surfacebuffer->waylandBufferHandle()); + } else +#endif + ret = true; + + return ret != negateReturn; +} + +bool Surface::visible() const +{ + + SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); + return surfacebuffer->waylandBufferHandle(); +} + +QPointF Surface::pos() const +{ + return m_shellSurface ? m_shellSurface->adjustedPosToTransientParent() : m_position; +} + +QPointF Surface::nonAdjustedPos() const +{ + return m_position; +} + +void Surface::setPos(const QPointF &pos) +{ + bool emitChange = pos != m_position; + m_position = pos; + if (emitChange) + m_waylandSurface->posChanged(); +} + +QSize Surface::size() const +{ + return m_size; +} + +void Surface::setSize(const QSize &size) +{ + if (size != m_size) { + m_opaqueRegion = QRegion(); + m_inputRegion = QRegion(QRect(QPoint(), size)); + m_size = size; + if (m_shellSurface) { + m_shellSurface->adjustPosInResize(); + } + m_waylandSurface->sizeChanged(); + } +} + +QRegion Surface::inputRegion() const +{ + return m_inputRegion; +} + +QRegion Surface::opaqueRegion() const +{ + return m_opaqueRegion; +} + +QImage Surface::image() const +{ + SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); + if (surfacebuffer && !surfacebuffer->isDestroyed() && type() == QWaylandSurface::Shm) { + struct wl_buffer *buffer = surfacebuffer->waylandBufferHandle(); + int stride = wl_shm_buffer_get_stride(buffer); + uint format = wl_shm_buffer_get_format(buffer); + (void) format; + void *data = wl_shm_buffer_get_data(buffer); + const uchar *char_data = static_cast(data); + QImage img(char_data, buffer->width, buffer->height, stride, QImage::Format_ARGB32_Premultiplied); + return img; + } + return QImage(); +} + +#ifdef QT_COMPOSITOR_WAYLAND_GL +GLuint Surface::textureId(QOpenGLContext *context) const +{ + const SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); + + if (m_compositor->graphicsHWIntegration() && type() == QWaylandSurface::Texture + && !surfacebuffer->textureCreated()) { + QWaylandGraphicsHardwareIntegration *hwIntegration = m_compositor->graphicsHWIntegration(); + const_cast(surfacebuffer)->createTexture(hwIntegration,context); + } + return surfacebuffer->texture(); +} +#endif // QT_COMPOSITOR_WAYLAND_GL + +void Surface::sendFrameCallback() +{ + SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); + surfacebuffer->setDisplayed(); + if (m_backBuffer) { + if (m_frontBuffer) + m_frontBuffer->disown(); + m_frontBuffer = m_backBuffer; + } + + bool updateNeeded = advanceBufferQueue(); + + uint time = Compositor::currentTimeMsecs(); + struct wl_resource *frame_callback, *next; + wl_list_for_each_safe(frame_callback, next, &m_frame_callback_list, link) { + wl_callback_send_done(frame_callback, time); + wl_resource_destroy(frame_callback); + } + wl_list_init(&m_frame_callback_list); + + if (updateNeeded) + doUpdate(); +} + +void Surface::frameFinished() +{ + m_compositor->frameFinished(this); +} + +QWaylandSurface * Surface::waylandSurface() const +{ + return m_waylandSurface; +} + +QPoint Surface::lastMousePos() const +{ + return m_lastLocalMousePos; +} + +void Surface::setExtendedSurface(ExtendedSurface *extendedSurface) +{ + m_extendedSurface = extendedSurface; + if (m_extendedSurface) + emit m_waylandSurface->extendedSurfaceReady(); +} + +ExtendedSurface *Surface::extendedSurface() const +{ + return m_extendedSurface; +} + +void Surface::setSubSurface(SubSurface *subSurface) +{ + m_subSurface = subSurface; +} + +SubSurface *Surface::subSurface() const +{ + return m_subSurface; +} + +void Surface::setShellSurface(ShellSurface *shellSurface) +{ + m_shellSurface = shellSurface; +} + +ShellSurface *Surface::shellSurface() const +{ + return m_shellSurface; +} + +Compositor *Surface::compositor() const +{ + return m_compositor; +} + +bool Surface::advanceBufferQueue() +{ + //has current buffer been displayed, + //do we have another buffer in the queue + //and does it have a valid damage rect + + if (m_bufferQueue.size()) { + int width = 0; + int height = 0; + if (m_backBuffer) { + width = m_backBuffer->width(); + height = m_backBuffer->height(); + } + + m_backBuffer = m_bufferQueue.takeFirst(); + while (m_backBuffer && m_backBuffer->isDestroyed()) { + m_backBuffer->disown(); + m_backBuffer = m_bufferQueue.size() ? m_bufferQueue.takeFirst() : 0; + } + + if (!m_backBuffer) + return false; //we have no new backbuffer; + + if (m_backBuffer->waylandBufferHandle()) { + width = m_backBuffer->width(); + height = m_backBuffer->height(); + } + setSize(QSize(width,height)); + + + if (m_backBuffer && (!m_subSurface || !m_subSurface->parent()) && !m_surfaceMapped) { + m_surfaceMapped = true; + emit m_waylandSurface->mapped(); + } else if (m_backBuffer && !m_backBuffer->waylandBufferHandle() && m_surfaceMapped) { + m_surfaceMapped = false; + emit m_waylandSurface->unmapped(); + } + + } else { + m_backBuffer = 0; + return false; + } + + return true; +} + +void Surface::doUpdate() { + if (postBuffer()) { +#ifdef QT_COMPOSITOR_QUICK + QWaylandSurfaceItem *surfaceItem = waylandSurface()->surfaceItem(); + if (surfaceItem) + surfaceItem->setDamagedFlag(true); // avoid flicker when we switch back to composited mode +#endif + sendFrameCallback(); + } else { + SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer(); + if (surfaceBuffer) { + if (surfaceBuffer->damageRect().isValid()) { + m_compositor->markSurfaceAsDirty(this); + emit m_waylandSurface->damaged(surfaceBuffer->damageRect()); + } + } + } +} + +SurfaceBuffer *Surface::createSurfaceBuffer(struct wl_buffer *buffer) +{ + SurfaceBuffer *newBuffer = 0; + for (int i = 0; i < Surface::buffer_pool_size; i++) { + if (!m_bufferPool[i]->isRegisteredWithBuffer()) { + newBuffer = m_bufferPool[i]; + newBuffer->initialize(buffer); + break; + } + } + + Q_ASSERT(newBuffer); + return newBuffer; +} + +bool Surface::postBuffer() { +#ifdef QT_COMPOSITOR_WAYLAND_GL + if (m_waylandSurface->handle() == m_compositor->directRenderSurface()) { + SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer(); + if (surfaceBuffer && surfaceBuffer->waylandBufferHandle()) { + if (m_compositor->pageFlipper()) { + if (m_compositor->pageFlipper()->displayBuffer(surfaceBuffer)) { + surfaceBuffer->setPageFlipperHasBuffer(true); + m_compositor->setDirectRenderingActive(true); + return true; + } else { + qDebug() << "could not post buffer"; + } + } + } + } +#endif + return false; +} + +void Surface::commit() +{ + if (!m_bufferQueue.isEmpty() && !m_backBuffer) + advanceBufferQueue(); + + doUpdate(); +} + +void Surface::attach(struct wl_buffer *buffer) +{ + SurfaceBuffer *last = m_bufferQueue.size()?m_bufferQueue.last():0; + if (last) { + if (last->waylandBufferHandle() == buffer) + return; + if (!last->damageRect().isValid() || isCursorSurface() ){ + last->disown(); + m_bufferQueue.takeLast(); + } + } + + m_bufferQueue << createSurfaceBuffer(buffer); + + if (!buffer) { + InputDevice *inputDevice = m_compositor->defaultInputDevice(); + if (inputDevice->keyboardFocus() == this) + inputDevice->setKeyboardFocus(0); + if (inputDevice->mouseFocus() == this) + inputDevice->setMouseFocus(0, QPointF(), QPointF()); + } +} + +void Surface::damage(const QRect &rect) +{ + SurfaceBuffer *surfaceBuffer = m_bufferQueue.isEmpty() ? currentSurfaceBuffer() : m_bufferQueue.last(); + if (surfaceBuffer) + surfaceBuffer->setDamage(rect); + else + qWarning() << "Surface::damage() null buffer"; +} + +const struct wl_surface_interface Surface::surface_interface = { + Surface::surface_destroy, + Surface::surface_attach, + Surface::surface_damage, + Surface::surface_frame, + Surface::surface_set_opaque_region, + Surface::surface_set_input_region, + Surface::surface_commit +}; + +void Surface::surface_destroy(struct wl_client *, struct wl_resource *surface_resource) +{ + wl_resource_destroy(surface_resource); +} + +void Surface::surface_attach(struct wl_client *client, struct wl_resource *surface, + struct wl_resource *buffer, int x, int y) +{ + Q_UNUSED(client); + Q_UNUSED(x); + Q_UNUSED(y); + resolve(surface)->attach(buffer ? reinterpret_cast(buffer->data) : 0); +} + +void Surface::surface_damage(struct wl_client *client, struct wl_resource *surface, + int32_t x, int32_t y, int32_t width, int32_t height) +{ + Q_UNUSED(client); + resolve(surface)->damage(QRect(x, y, width, height)); +} + +void Surface::surface_frame(struct wl_client *client, + struct wl_resource *resource, + uint32_t callback) +{ + Surface *surface = resolve(resource); + struct wl_resource *frame_callback = wl_client_add_object(client,&wl_callback_interface,0,callback,surface); + wl_list_insert(&surface->m_frame_callback_list,&frame_callback->link); +} + +void Surface::surface_set_opaque_region(struct wl_client *client, struct wl_resource *surfaceResource, + struct wl_resource *region) +{ + Q_UNUSED(client); + Surface *surface = resolve(surfaceResource); + surface->m_opaqueRegion = region ? resolve(region)->region() : QRegion(); +} + +void Surface::surface_set_input_region(struct wl_client *client, struct wl_resource *surfaceResource, + struct wl_resource *region) +{ + Q_UNUSED(client); + Surface *surface = resolve(surfaceResource); + surface->m_inputRegion = region ? resolve(region)->region() : QRegion(QRect(QPoint(), surface->size())); +} + +void Surface::surface_commit(wl_client *client, wl_resource *resource) +{ + Q_UNUSED(client); + resolve(resource)->commit(); +} + +void Surface::setClassName(const QString &className) +{ + if (m_className != className) { + m_className = className; + emit waylandSurface()->classNameChanged(); + } +} + +void Surface::setTitle(const QString &title) +{ + if (m_title != title) { + m_title = title; + emit waylandSurface()->titleChanged(); + } +} + +} // namespace Wayland + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h new file mode 100644 index 000000000..21b1ae742 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlsurface_p.h @@ -0,0 +1,206 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WL_SURFACE_H +#define WL_SURFACE_H + +#include + +#include +#include + +#include + +#include +#include + +#include +#include + +#ifdef QT_COMPOSITOR_WAYLAND_GL +#include +#include +#endif + +#include + +QT_BEGIN_NAMESPACE + +class QTouchEvent; + +namespace QtWayland { + +class Compositor; +class Buffer; +class ExtendedSurface; +class SubSurface; +class ShellSurface; + +class Q_COMPOSITOR_EXPORT Surface : public Object +{ +public: + Surface(struct wl_client *client, uint32_t id, Compositor *compositor); + ~Surface(); + + QWaylandSurface::Type type() const; + bool isYInverted() const; + + bool visible() const; + + uint id() const { return base()->resource.object.id; } + + QPointF pos() const; + QPointF nonAdjustedPos() const; + void setPos(const QPointF &pos); + + QSize size() const; + void setSize(const QSize &size); + + QRegion inputRegion() const; + QRegion opaqueRegion() const; + + QImage image() const; + +#ifdef QT_COMPOSITOR_WAYLAND_GL + GLuint textureId(QOpenGLContext *context) const; +#endif + + void sendFrameCallback(); + + void frameFinished(); + + QWaylandSurface *waylandSurface() const; + + QPoint lastMousePos() const; + + void setExtendedSurface(ExtendedSurface *extendedSurface); + ExtendedSurface *extendedSurface() const; + + void setSubSurface(SubSurface *subSurface); + SubSurface *subSurface() const; + + void setShellSurface(ShellSurface *shellSurface); + ShellSurface *shellSurface() const; + + Compositor *compositor() const; + + void damage(const QRect &rect); + + static const struct wl_surface_interface surface_interface; + + QString className() const { return m_className; } + void setClassName(const QString &className); + + QString title() const { return m_title; } + void setTitle(const QString &title); + + bool transientInactive() const { return m_transientInactive; } + void setTransientInactive(bool v) { m_transientInactive = v; } + + bool isCursorSurface() const { return m_isCursorSurface; } + void setCursorSurface(bool isCursor) { m_isCursorSurface = isCursor; } + +private: + Q_DISABLE_COPY(Surface) + + Compositor *m_compositor; + QWaylandSurface *m_waylandSurface; + + SurfaceBuffer *m_backBuffer; + SurfaceBuffer *m_frontBuffer; + QList m_bufferQueue; + bool m_surfaceMapped; + + QPoint m_lastLocalMousePos; + QPoint m_lastGlobalMousePos; + + struct wl_list m_frame_callback_list; + + ExtendedSurface *m_extendedSurface; + SubSurface *m_subSurface; + ShellSurface *m_shellSurface; + + QRegion m_inputRegion; + QRegion m_opaqueRegion; + + static const int buffer_pool_size = 3; + SurfaceBuffer *m_bufferPool[buffer_pool_size]; + + QPointF m_position; + QSize m_size; + QString m_className; + QString m_title; + bool m_transientInactive; + bool m_isCursorSurface; + + inline SurfaceBuffer *currentSurfaceBuffer() const; + bool advanceBufferQueue(); + void doUpdate(); + SurfaceBuffer *createSurfaceBuffer(struct wl_buffer *buffer); + void frameFinishedInternal(); + bool postBuffer(); + void commit(); + + void attach(struct wl_buffer *buffer); + + static void surface_destroy(struct wl_client *client, struct wl_resource *_surface); + static void surface_attach(struct wl_client *client, struct wl_resource *surface, + struct wl_resource *buffer, int x, int y); + static void surface_damage(struct wl_client *client, struct wl_resource *_surface, + int32_t x, int32_t y, int32_t width, int32_t height); + static void surface_frame(struct wl_client *client, struct wl_resource *resource, + uint32_t callback); + static void surface_set_opaque_region(struct wl_client *client, struct wl_resource *resource, + struct wl_resource *region); + static void surface_set_input_region(struct wl_client *client, struct wl_resource *resource, + struct wl_resource *region); + static void surface_commit(struct wl_client *client, struct wl_resource *resource); + +}; + +inline SurfaceBuffer *Surface::currentSurfaceBuffer() const { + return m_backBuffer? m_backBuffer : m_frontBuffer; +} + +} + +QT_END_NAMESPACE + +#endif //WL_SURFACE_H diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp new file mode 100644 index 000000000..cebe105b8 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlsurfacebuffer_p.h" + +#include "qwlsurface_p.h" +#include "qwlcompositor_p.h" + +#ifdef QT_COMPOSITOR_WAYLAND_GL +#include "hardware_integration/qwaylandgraphicshardwareintegration.h" +#include +#endif + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +SurfaceBuffer::SurfaceBuffer(Surface *surface) + : QPlatformScreenBuffer() + , m_surface(surface) + , m_compositor(surface->compositor()) + , m_buffer(0) + , m_is_registered_for_buffer(false) + , m_surface_has_buffer(false) + , m_page_flipper_has_buffer(false) + , m_is_displayed(false) + , m_texture(0) + , m_guard(0) + , m_is_shm_resolved(false) + , m_is_shm(false) +{ +} + +SurfaceBuffer::~SurfaceBuffer() +{ + if (m_is_registered_for_buffer) + destructBufferState(); +} + +void SurfaceBuffer::initialize(wl_buffer *buffer) +{ + m_buffer = buffer; + m_texture = 0; + m_guard = 0; + m_is_registered_for_buffer = true; + m_surface_has_buffer = true; + m_page_flipper_has_buffer = false; + m_is_displayed = false; + m_destroyed = false; + m_handle = 0; + m_is_shm_resolved = false; + m_is_shm = false; + m_destroy_listener.surfaceBuffer = this; + m_destroy_listener.listener.notify = destroy_listener_callback; + if (buffer) + wl_signal_add(&buffer->resource.destroy_signal, &m_destroy_listener.listener); + m_damageRect = QRect(); +} + +void SurfaceBuffer::destructBufferState() +{ + Q_ASSERT(!m_page_flipper_has_buffer); + + destroyTexture(); + + if (m_buffer) { + if (m_handle) { + if (m_is_shm) { + delete static_cast(m_handle); +#ifdef QT_COMPOSITOR_WAYLAND_GL + } else { + QWaylandGraphicsHardwareIntegration *hwIntegration = m_compositor->graphicsHWIntegration(); + hwIntegration->unlockNativeBuffer(m_handle, m_compositor->directRenderContext()); +#endif + } + } + wl_list_remove(&m_destroy_listener.listener.link); + sendRelease(); + } + m_buffer = 0; + m_handle = 0; + m_is_registered_for_buffer = false; + m_is_displayed = false; +} + +bool SurfaceBuffer::isShmBuffer() const +{ + if (!m_is_shm_resolved) { + SurfaceBuffer *that = const_cast(this); + that->m_is_shm = wl_buffer_is_shm(m_buffer); + that->m_is_shm_resolved = true; + } + return m_is_shm; +} + +void SurfaceBuffer::sendRelease() +{ + Q_ASSERT(m_buffer); + wl_buffer_send_release(&m_buffer->resource); +} + +void SurfaceBuffer::setPageFlipperHasBuffer(bool owns) +{ + m_page_flipper_has_buffer = owns; +} + +void SurfaceBuffer::release() +{ + m_compositor->scheduleReleaseBuffer(this); +} + +void SurfaceBuffer::scheduledRelease() +{ + m_page_flipper_has_buffer = false; + if (!m_surface_has_buffer) + destructBufferState(); + if (!m_surface) { + delete this; + } +} + +void SurfaceBuffer::disown() +{ + m_surface_has_buffer = false; + + if (!m_page_flipper_has_buffer) { + destructBufferState(); + } +} + +void SurfaceBuffer::setDisplayed() +{ + m_is_displayed = true; + m_damageRect = QRect(); +} + +void SurfaceBuffer::setDamage(const QRect &rect) +{ + if (m_damageRect.isValid()) { + m_damageRect = m_damageRect.united(rect); + } + m_damageRect = rect; +} + +void SurfaceBuffer::destroyTexture() +{ +#ifdef QT_COMPOSITOR_WAYLAND_GL + if (m_texture) { + Q_ASSERT(m_guard); + m_guard->free(); + m_guard = 0; + m_texture = 0; + } +#endif +} + +void SurfaceBuffer::handleAboutToBeDisplayed() +{ + qDebug() << Q_FUNC_INFO; +} + +void SurfaceBuffer::handleDisplayed() +{ + qDebug() << Q_FUNC_INFO; +} + +void *SurfaceBuffer::handle() const +{ + if (!m_buffer) + return 0; + + if (!m_handle) { + SurfaceBuffer *that = const_cast(this); + if (isShmBuffer()) { + const uchar *data = static_cast(wl_shm_buffer_get_data(m_buffer)); + int stride = wl_shm_buffer_get_stride(m_buffer); + int width = m_buffer->width; + int height = m_buffer->height; + QImage *image = new QImage(data,width,height,stride, QImage::Format_ARGB32_Premultiplied); + that->m_handle = image; +#ifdef QT_COMPOSITOR_WAYLAND_GL + } else { + QWaylandGraphicsHardwareIntegration *hwIntegration = m_compositor->graphicsHWIntegration(); + that->m_handle = hwIntegration->lockNativeBuffer(m_buffer, m_compositor->directRenderContext()); +#endif + } + } + return m_handle; +} + +void SurfaceBuffer::destroy_listener_callback(wl_listener *listener, void *data) +{ + Q_UNUSED(data); + struct surface_buffer_destroy_listener *destroy_listener = + reinterpret_cast(listener); + SurfaceBuffer *d = destroy_listener->surfaceBuffer; + d->destroyTexture(); + d->m_destroyed = true; + d->m_buffer = 0; +} + +void freeTexture(QOpenGLFunctions *, GLuint id) +{ + glDeleteTextures(1, &id); +} + +void SurfaceBuffer::createTexture(QWaylandGraphicsHardwareIntegration *hwIntegration, QOpenGLContext *context) +{ +#ifdef QT_COMPOSITOR_WAYLAND_GL + m_texture = hwIntegration->createTextureFromBuffer(m_buffer, context); + m_guard = new QOpenGLSharedResourceGuard(QOpenGLContext::currentContext(), m_texture, freeTexture); +#else + Q_UNUSED(hwIntegration); + Q_UNUSED(context); +#endif +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h new file mode 100644 index 000000000..dda335444 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SURFACEBUFFER_H +#define SURFACEBUFFER_H + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QWaylandGraphicsHardwareIntegration; +class QOpenGLContext; + +namespace QtWayland { + +class Surface; +class Compositor; + +struct surface_buffer_destroy_listener +{ + struct wl_listener listener; + class SurfaceBuffer *surfaceBuffer; +}; + +class SurfaceBuffer : public QPlatformScreenBuffer +{ +public: + SurfaceBuffer(Surface *surface); + + ~SurfaceBuffer(); + + void initialize(struct wl_buffer *buffer); + void destructBufferState(); + + inline int32_t width() const { return m_buffer->width; } + inline int32_t height() const { return m_buffer->height; } + + bool isShmBuffer() const; + + inline bool isRegisteredWithBuffer() const { return m_is_registered_for_buffer; } + + void sendRelease(); + void setPageFlipperHasBuffer(bool owns); + bool pageFlipperHasBuffer() const { return m_page_flipper_has_buffer; } + void release(); + void scheduledRelease(); + void disown(); + + void setDisplayed(); + + inline bool isDisplayed() const { return m_is_displayed; } + + inline QRect damageRect() const { return m_damageRect; } + void setDamage(const QRect &rect); + + inline bool textureCreated() const { return m_texture; } + + void createTexture(QWaylandGraphicsHardwareIntegration *hwIntegration, QOpenGLContext *context); + inline GLuint texture() const; + void destroyTexture(); + + inline struct wl_buffer *waylandBufferHandle() const { return m_buffer; } + + void handleAboutToBeDisplayed(); + void handleDisplayed(); + + void *handle() const; +private: + Surface *m_surface; + Compositor *m_compositor; + struct wl_buffer *m_buffer; + struct surface_buffer_destroy_listener m_destroy_listener; + QRect m_damageRect; + bool m_is_registered_for_buffer; + bool m_surface_has_buffer; + bool m_page_flipper_has_buffer; + + bool m_is_displayed; +#ifdef QT_COMPOSITOR_WAYLAND_GL + GLuint m_texture; + QOpenGLSharedResourceGuard *m_guard; +#else + uint m_texture; + uint m_guard; +#endif + void *m_handle; + bool m_is_shm_resolved; + bool m_is_shm; + + static void destroy_listener_callback(wl_listener *listener, void *data); +}; + +GLuint SurfaceBuffer::texture() const +{ + if (m_buffer) + return m_texture; + return 0; +} + +} + +QT_END_NAMESPACE + +#endif // SURFACEBUFFER_H diff --git a/src/compositor/wayland_wrapper/qwltouch.cpp b/src/compositor/wayland_wrapper/qwltouch.cpp new file mode 100644 index 000000000..458c74bf9 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwltouch.cpp @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwltouch_p.h" +#include "qwlsurface_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +static void dummy(wl_client *, wl_resource *) +{ +} + +const struct wl_touch_extension_interface TouchExtensionGlobal::touch_interface = { + dummy +}; + +static const int maxRawPos = 24; + +TouchExtensionGlobal::TouchExtensionGlobal(Compositor *compositor) + : m_compositor(compositor), + m_flags(0) +{ + wl_array_init(&m_rawdata_array); + m_rawdata_ptr = static_cast(wl_array_add(&m_rawdata_array, maxRawPos * sizeof(float) * 2)); + + wl_display_add_global(compositor->wl_display(), + &wl_touch_extension_interface, + this, + TouchExtensionGlobal::bind_func); +} + +TouchExtensionGlobal::~TouchExtensionGlobal() +{ + wl_array_release(&m_rawdata_array); +} + +void TouchExtensionGlobal::destroy_resource(wl_resource *resource) +{ + TouchExtensionGlobal *self = static_cast(resource->data); + self->m_resources.removeOne(resource); + free(resource); +} + +void TouchExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) +{ + Q_UNUSED(version); + wl_resource *resource = wl_client_add_object(client, &wl_touch_extension_interface, &touch_interface, id, data); + resource->destroy = destroy_resource; + TouchExtensionGlobal *self = static_cast(resource->data); + self->m_resources.append(resource); + wl_touch_extension_send_configure(resource, self->m_flags); +} + +static inline int toFixed(qreal f) +{ + return int(f * 10000); +} + +bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, Surface *surface) +{ + const QList points = event->touchPoints(); + const int pointCount = points.count(); + if (!pointCount) + return false; + + QPointF surfacePos = surface->pos(); + wl_client *surfaceClient = surface->base()->resource.client; + uint32_t time = m_compositor->currentTimeMsecs(); + const int rescount = m_resources.count(); + + for (int res = 0; res < rescount; ++res) { + wl_resource *target = m_resources.at(res); + if (target->client != surfaceClient) + continue; + + // We will use no touch_frame type of event, to reduce the number of + // events flowing through the wire. Instead, the number of points sent is + // included in the touch point events. + int sentPointCount = 0; + for (int i = 0; i < pointCount; ++i) { + if (points.at(i).state() != Qt::TouchPointStationary) + ++sentPointCount; + } + + for (int i = 0; i < pointCount; ++i) { + const QTouchEvent::TouchPoint &tp(points.at(i)); + // Stationary points are never sent. They are cached on client side. + if (tp.state() == Qt::TouchPointStationary) + continue; + + uint32_t id = tp.id(); + uint32_t state = (tp.state() & 0xFFFF) | (sentPointCount << 16); + uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->device()->capabilities()) << 16); + + QPointF p = tp.pos() - surfacePos; // surface-relative + int x = toFixed(p.x()); + int y = toFixed(p.y()); + int nx = toFixed(tp.normalizedPos().x()); + int ny = toFixed(tp.normalizedPos().y()); + int w = toFixed(tp.rect().width()); + int h = toFixed(tp.rect().height()); + int vx = toFixed(tp.velocity().x()); + int vy = toFixed(tp.velocity().y()); + uint32_t pressure = uint32_t(tp.pressure() * 255); + + wl_array *rawData = 0; + QVector rawPosList = tp.rawScreenPositions(); + int rawPosCount = rawPosList.count(); + if (rawPosCount) { + rawPosCount = qMin(maxRawPos, rawPosCount); + rawData = &m_rawdata_array; + rawData->size = rawPosCount * sizeof(float) * 2; + float *p = m_rawdata_ptr; + for (int rpi = 0; rpi < rawPosCount; ++rpi) { + const QPointF &rawPos(rawPosList.at(rpi)); + // This will stay in screen coordinates for performance + // reasons, clients using this data will presumably know + // what they are doing. + *p++ = float(rawPos.x()); + *p++ = float(rawPos.y()); + } + } + + wl_touch_extension_send_touch(target, + time, id, state, + x, y, nx, ny, w, h, + pressure, vx, vy, + flags, rawData); + } + + return true; + } + + return false; +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwltouch_p.h b/src/compositor/wayland_wrapper/qwltouch_p.h new file mode 100644 index 000000000..09c9a0898 --- /dev/null +++ b/src/compositor/wayland_wrapper/qwltouch_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WLTOUCH_H +#define WLTOUCH_H + +#include +#include "wayland-touch-extension-server-protocol.h" +#include "wayland-util.h" + +QT_BEGIN_NAMESPACE + +class Compositor; +class Surface; +class QTouchEvent; + +namespace QtWayland { + +class TouchExtensionGlobal +{ +public: + TouchExtensionGlobal(Compositor *compositor); + ~TouchExtensionGlobal(); + + bool postTouchEvent(QTouchEvent *event, Surface *surface); + + void setFlags(int flags) { m_flags = flags; } + +private: + static void bind_func(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + + static void destroy_resource(wl_resource *resource); + + static const struct wl_touch_extension_interface touch_interface; + + Compositor *m_compositor; + int m_flags; + QList m_resources; + wl_array m_rawdata_array; + float *m_rawdata_ptr; +}; + +} + +QT_END_NAMESPACE + +#endif // WLTOUCH_H diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index 84008c6c2..9bfe957e2 100644 --- a/src/compositor/wayland_wrapper/wayland_wrapper.pri +++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri @@ -1,53 +1,50 @@ WAYLANDSOURCES += \ - $$PWD/../../extensions/surface-extension.xml \ - $$PWD/../../extensions/sub-surface-extension.xml \ - $$PWD/../../extensions/output-extension.xml \ - $$PWD/../../extensions/touch-extension.xml \ - $$PWD/../../extensions/qtkey-extension.xml - + ../extensions/surface-extension.xml \ + ../extensions/sub-surface-extension.xml \ + ../extensions/output-extension.xml \ + ../extensions/touch-extension.xml \ + ../extensions/qtkey-extension.xml \ + ../extensions/windowmanager.xml HEADERS += \ - $$PWD/wlcompositor.h \ - $$PWD/wldisplay.h \ - $$PWD/wloutput.h \ - $$PWD/wlsurface.h \ - $$PWD/wlshellsurface.h \ - $$PWD/wlinputdevice.h \ - $$PWD/wldatadevicemanager.h \ - $$PWD/wldatadevice.h \ - $$PWD/wldataoffer.h \ - $$PWD/wldatasource.h \ - $$PWD/wlextendedsurface.h \ - $$PWD/wlextendedoutput.h \ - $$PWD/wlsubsurface.h \ - $$PWD/wltouch.h \ - $$PWD/wlqtkey.h \ - $$PWD/../../shared/qwaylandmimehelper.h \ - $$PWD/wlsurfacebuffer.h \ - $$PWD/wlregion.h + wayland_wrapper/qwlcompositor_p.h \ + wayland_wrapper/qwldatadevice_p.h \ + wayland_wrapper/qwldatadevicemanager_p.h \ + wayland_wrapper/qwldataoffer_p.h \ + wayland_wrapper/qwldatasource_p.h \ + wayland_wrapper/qwldisplay_p.h \ + wayland_wrapper/qwlextendedoutput_p.h \ + wayland_wrapper/qwlextendedsurface_p.h \ + wayland_wrapper/qwlinputdevice_p.h \ + wayland_wrapper/qwloutput_p.h \ + wayland_wrapper/qwlqtkey_p.h \ + wayland_wrapper/qwlregion_p.h \ + wayland_wrapper/qwlshellsurface_p.h \ + wayland_wrapper/qwlsubsurface_p.h \ + wayland_wrapper/qwlsurface_p.h \ + wayland_wrapper/qwlsurfacebuffer_p.h \ + wayland_wrapper/qwltouch_p.h SOURCES += \ - $$PWD/wlcompositor.cpp \ - $$PWD/wldisplay.cpp \ - $$PWD/wloutput.cpp \ - $$PWD/wlsurface.cpp \ - $$PWD/wlshellsurface.cpp \ - $$PWD/wlinputdevice.cpp \ - $$PWD/wldatadevicemanager.cpp \ - $$PWD/wldatadevice.cpp \ - $$PWD/wldataoffer.cpp \ - $$PWD/wldatasource.cpp \ - $$PWD/wlextendedsurface.cpp \ - $$PWD/wlextendedoutput.cpp \ - $$PWD/wlsubsurface.cpp \ - $$PWD/wltouch.cpp \ - $$PWD/wlqtkey.cpp \ - $$PWD/../../shared/qwaylandmimehelper.cpp \ - $$PWD/wlsurfacebuffer.cpp \ - $$PWD/wlregion.cpp + wayland_wrapper/qwlcompositor.cpp \ + wayland_wrapper/qwldatadevice.cpp \ + wayland_wrapper/qwldatadevicemanager.cpp \ + wayland_wrapper/qwldataoffer.cpp \ + wayland_wrapper/qwldatasource.cpp \ + wayland_wrapper/qwldisplay.cpp \ + wayland_wrapper/qwlextendedoutput.cpp \ + wayland_wrapper/qwlextendedsurface.cpp \ + wayland_wrapper/qwlinputdevice.cpp \ + wayland_wrapper/qwloutput.cpp \ + wayland_wrapper/qwlqtkey.cpp \ + wayland_wrapper/qwlregion.cpp \ + wayland_wrapper/qwlshellsurface.cpp \ + wayland_wrapper/qwlsubsurface.cpp \ + wayland_wrapper/qwlsurface.cpp \ + wayland_wrapper/qwlsurfacebuffer.cpp \ + wayland_wrapper/qwltouch.cpp -INCLUDEPATH += $$PWD -INCLUDEPATH += $$PWD/../../shared +INCLUDEPATH += wayland_wrapper config_xkbcommon { !contains(QT_CONFIG, no-pkg-config) { diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp deleted file mode 100644 index a0716f3b2..000000000 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ /dev/null @@ -1,561 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlcompositor.h" - -#include "waylandinput.h" -#include "wldisplay.h" -#include "wlsurface.h" -#include "waylandcompositor.h" -#include "wldatadevicemanager.h" -#include "wldatadevice.h" -#include "wlextendedoutput.h" -#include "wlextendedsurface.h" -#include "wlsubsurface.h" -#include "wlshellsurface.h" -#include "wltouch.h" -#include "wlqtkey.h" -#include "wlinputdevice.h" -#include "wlregion.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "hardware_integration/graphicshardwareintegration.h" -#include "waylandwindowmanagerintegration.h" - -#include "hardware_integration/graphicshardwareintegrationfactory.h" - -namespace Wayland { - -static Compositor *compositor; - -void compositor_create_surface(struct wl_client *client, - struct wl_resource *resource, uint32_t id) -{ - static_cast(resource->data)->createSurface(client,id); -} - -void compositor_create_region(struct wl_client *client, - struct wl_resource *compositor, uint32_t id) -{ - Q_UNUSED(compositor); - new Region(client, id); -} - -const static struct wl_compositor_interface compositor_interface = { - compositor_create_surface, - compositor_create_region -}; - -void Compositor::bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_client_add_object(client,&wl_compositor_interface, &compositor_interface, id,data); -} - -Compositor *Compositor::instance() -{ - return compositor; -} - -Compositor::Compositor(WaylandCompositor *qt_compositor) - : m_display(new Display) - , m_default_input_device(0) - , m_pageFlipper(0) - , m_current_frame(0) - , m_last_queued_buf(-1) - , m_qt_compositor(qt_compositor) - , m_orientation(Qt::PrimaryOrientation) - , m_directRenderSurface(0) - , m_directRenderContext(0) - , m_directRenderActive(false) -#if defined (QT_COMPOSITOR_WAYLAND_GL) - , m_graphics_hw_integration(0) -#endif - , m_outputExtension(0) - , m_surfaceExtension(0) - , m_subSurfaceExtension(0) - , m_touchExtension(0) - , m_retainNotify(0) -{ - compositor = this; - -#if defined (QT_COMPOSITOR_WAYLAND_GL) - QWindow *window = qt_compositor->window(); - if (window && window->surfaceType() != QWindow::RasterSurface) { - QStringList keys = GraphicsHardwareIntegrationFactory::keys(); - QString targetKey; - QByteArray hardwareIntegration = qgetenv("QT_WAYLAND_HARDWARE_INTEGRATION"); - if (keys.contains(QString::fromLocal8Bit(hardwareIntegration.constData()))) { - targetKey = QString::fromLocal8Bit(hardwareIntegration.constData()); - } else if (keys.contains(QString::fromLatin1("wayland-egl"))) { - targetKey = QString::fromLatin1("wayland-egl"); - } else if (!keys.isEmpty()) { - targetKey = keys.first(); - } - - if (!targetKey.isEmpty()) { - m_graphics_hw_integration = GraphicsHardwareIntegrationFactory::create(targetKey, QStringList()); - if (m_graphics_hw_integration) { - m_graphics_hw_integration->setCompositor(qt_compositor); - } - } - //BUG: if there is no hw_integration, bad things will probably happen - - } -#endif - m_windowManagerIntegration = new WindowManagerServerIntegration(qt_compositor, this); - - wl_display_add_global(m_display->handle(),&wl_compositor_interface,this,Compositor::bind_func); - - m_data_device_manager = new DataDeviceManager(this); - - wl_display_init_shm(m_display->handle()); - - wl_display_add_global(m_display->handle(),&wl_output_interface, &m_output_global,OutputGlobal::output_bind_func); - - m_shell = new Shell(); - wl_display_add_global(m_display->handle(), &wl_shell_interface, m_shell, Shell::bind_func); - - m_outputExtension = new OutputExtensionGlobal(this); - m_surfaceExtension = new SurfaceExtensionGlobal(this); - m_qtkeyExtension = new QtKeyExtensionGlobal(this); - m_touchExtension = new TouchExtensionGlobal(this); - - if (wl_display_add_socket(m_display->handle(), qt_compositor->socketName())) { - fprintf(stderr, "Fatal: Failed to open server socket\n"); - exit(EXIT_FAILURE); - } - - m_loop = wl_display_get_event_loop(m_display->handle()); - - int fd = wl_event_loop_get_fd(m_loop); - - QSocketNotifier *sockNot = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(sockNot, SIGNAL(activated(int)), this, SLOT(processWaylandEvents())); - - QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher; - connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processWaylandEvents())); - - qRegisterMetaType("SurfaceBuffer*"); - //initialize distancefieldglyphcache here -} - -Compositor::~Compositor() -{ - delete m_shell; - delete m_outputExtension; - delete m_surfaceExtension; - delete m_subSurfaceExtension; - delete m_touchExtension; - delete m_qtkeyExtension; - - delete m_default_wayland_input_device; - delete m_data_device_manager; - -#ifdef QT_COMPOSITOR_WAYLAND_GL - delete m_graphics_hw_integration; -#endif - - delete m_display; -} - -void Compositor::frameFinished(Surface *surface) -{ - if (surface && m_dirty_surfaces.contains(surface)) { - m_dirty_surfaces.remove(surface); - surface->sendFrameCallback(); - } else if (!surface) { - QSet dirty = m_dirty_surfaces; - m_dirty_surfaces.clear(); - foreach (Surface *surface, dirty) - surface->sendFrameCallback(); - } -} - -void Compositor::createSurface(struct wl_client *client, uint32_t id) -{ - Surface *surface = new Surface(client,id, this); - - m_surfaces << surface; - //BUG: This may not be an on-screen window surface though - m_qt_compositor->surfaceCreated(surface->waylandSurface()); -} - -struct wl_client *Compositor::getClientFromWinId(uint winId) const -{ - Surface *surface = getSurfaceFromWinId(winId); - if (surface) - return surface->base()->resource.client; - - return 0; -} - -Surface *Compositor::getSurfaceFromWinId(uint winId) const -{ - foreach (Surface *surface, m_surfaces) { - if (surface->id() == winId) - return surface; - } - - return 0; -} - -QImage Compositor::image(uint winId) const -{ - foreach (Surface *surface, m_surfaces) { - if (surface->id() == winId) { - return surface->image(); - } - } - - return QImage(); -} - -uint Compositor::currentTimeMsecs() -{ - //### we throw away the time information - struct timeval tv; - int ret = gettimeofday(&tv, 0); - if (ret == 0) - return tv.tv_sec*1000 + tv.tv_usec/1000; - return 0; -} - -void Compositor::releaseBuffer(SurfaceBuffer *screenBuffer) -{ - screenBuffer->scheduledRelease(); -} - -void Compositor::processWaylandEvents() -{ - int ret = wl_event_loop_dispatch(m_loop, 0); - if (ret) - fprintf(stderr, "wl_event_loop_dispatch error: %d\n", ret); - wl_display_flush_clients(m_display->handle()); -} - -void Compositor::surfaceDestroyed(Surface *surface) -{ - InputDevice *dev = defaultInputDevice(); - if (dev->mouseFocus() == surface) { - dev->setMouseFocus(0, QPointF(), QPointF()); - // Make sure the surface is reset regardless of what the grabber - // interface's focus() does. (e.g. the default implementation does - // nothing when a button is down which would be disastrous here) - wl_pointer_set_focus(dev->pointerDevice(), 0, 0, 0); - } - if (dev->keyboardFocus() == surface) - dev->setKeyboardFocus(0); - - m_surfaces.removeOne(surface); - m_dirty_surfaces.remove(surface); - if (m_directRenderSurface == surface) - setDirectRenderSurface(0, 0); - - waylandCompositor()->surfaceAboutToBeDestroyed(surface->waylandSurface()); -} - -void Compositor::markSurfaceAsDirty(Wayland::Surface *surface) -{ - m_dirty_surfaces.insert(surface); -} - -void Compositor::destroyClient(WaylandClient *c) -{ - wl_client *client = static_cast(c); - if (!client) - return; - - if (m_windowManagerIntegration->managedClient(client)) { - m_windowManagerIntegration->sendQuitMessage(client); - m_windowManagerIntegration->removeClient(client); - } else { - wl_client_destroy(client); - } -} - -QWindow *Compositor::window() const -{ - return m_qt_compositor->window(); -} - -GraphicsHardwareIntegration * Compositor::graphicsHWIntegration() const -{ -#ifdef QT_COMPOSITOR_WAYLAND_GL - return m_graphics_hw_integration; -#else - return 0; -#endif -} - -void Compositor::initializeHardwareIntegration() -{ -#ifdef QT_COMPOSITOR_WAYLAND_GL - if (m_graphics_hw_integration) - m_graphics_hw_integration->initializeHardware(m_display); -#endif -} - -void Compositor::initializeDefaultInputDevice() -{ - m_default_wayland_input_device = new WaylandInputDevice(m_qt_compositor); - m_default_input_device = m_default_wayland_input_device->handle(); -} - -void Compositor::initializeWindowManagerProtocol() -{ - m_windowManagerIntegration->initialize(m_display); -} - -void Compositor::enableSubSurfaceExtension() -{ - if (!m_subSurfaceExtension) { - m_subSurfaceExtension = new SubSurfaceExtensionGlobal(this); - } -} - -bool Compositor::setDirectRenderSurface(Surface *surface, QOpenGLContext *context) -{ -#ifdef QT_COMPOSITOR_WAYLAND_GL - if (!m_pageFlipper) { - m_pageFlipper = QGuiApplication::primaryScreen()->handle()->pageFlipper(); - } - - if (!surface) - setDirectRenderingActive(false); - - if (m_graphics_hw_integration && m_graphics_hw_integration->setDirectRenderSurface(surface ? surface->waylandSurface() : 0)) { - m_directRenderSurface = surface; - m_directRenderContext = context; - return true; - } -#else - Q_UNUSED(surface); -#endif - return false; -} - -void Compositor::setDirectRenderingActive(bool active) -{ - if (m_directRenderActive == active) - return; - m_directRenderActive = active; - - if (m_pageFlipper) - QMetaObject::invokeMethod(m_pageFlipper, "setDirectRenderingActive", Q_ARG(bool, active)); -} - -QList Compositor::clients() const -{ - QList list; - foreach (Surface *surface, m_surfaces) { - struct wl_client *client = surface->base()->resource.client; - if (!list.contains(client)) - list.append(client); - } - return list; -} - -Qt::ScreenOrientations Compositor::orientationUpdateMaskForClient(wl_client *client) -{ - Output *output = m_output_global.outputForClient(client); - Q_ASSERT(output); - if (output->extendedOutput()) - return output->extendedOutput()->orientationUpdateMask(); - return 0; -} - -void Compositor::setScreenOrientation(Qt::ScreenOrientation orientation) -{ - m_orientation = orientation; - - QList clientList = clients(); - for (int i = 0; i < clientList.length(); ++i) { - struct wl_client *client = clientList.at(i); - Output *output = m_output_global.outputForClient(client); - Q_ASSERT(output); - if (output->extendedOutput()){ - output->extendedOutput()->sendOutputOrientation(orientation); - } - } -} - -Qt::ScreenOrientation Compositor::screenOrientation() const -{ - return m_orientation; -} - -void Compositor::setOutputGeometry(const QRect &geometry) -{ - m_output_global.setGeometry(geometry); -} - -QRect Compositor::outputGeometry() const -{ - return m_output_global.geometry(); -} - -void Compositor::setOutputRefreshRate(int rate) -{ - m_output_global.setRefreshRate(rate); -} - -int Compositor::outputRefreshRate() const -{ - return m_output_global.refreshRate(); -} - -void Compositor::setClientFullScreenHint(bool value) -{ - m_windowManagerIntegration->setShowIsFullScreen(value); -} - -InputDevice* Compositor::defaultInputDevice() -{ - return m_default_input_device; -} - -QList Compositor::surfacesForClient(wl_client *client) -{ - QList ret; - - for (int i=0; i < m_surfaces.count(); ++i) { - if (m_surfaces.at(i)->base()->resource.client == client) { - ret.append(m_surfaces.at(i)); - } - } - return ret; -} - -wl_resource *Compositor::resourceForSurface(wl_list *resourceList, Surface *surface) -{ - if (!surface) - return 0; - - wl_resource *r; - wl_client *surfaceClient = surface->base()->resource.client; - - wl_list_for_each(r, resourceList, link) { - if (r->client == surfaceClient) - return r; - } - - return 0; -} - -void Compositor::configureTouchExtension(int flags) -{ - if (m_touchExtension) - m_touchExtension->setFlags(flags); -} - -void Compositor::setRetainedSelectionWatcher(RetainedSelectionFunc func, void *param) -{ - m_retainNotify = func; - m_retainNotifyParam = param; -} - -bool Compositor::wantsRetainedSelection() const -{ - return m_retainNotify != 0; -} - -void Compositor::feedRetainedSelectionData(QMimeData *data) -{ - if (m_retainNotify) { - m_retainNotify(data, m_retainNotifyParam); - } -} - -void Compositor::scheduleReleaseBuffer(SurfaceBuffer *screenBuffer) -{ - QMetaObject::invokeMethod(this,"releaseBuffer",Q_ARG(SurfaceBuffer*,screenBuffer)); -} - -void Compositor::overrideSelection(QMimeData *data) -{ - m_data_device_manager->overrideSelection(*data); -} - -bool Compositor::isDragging() const -{ - return false; -} - -void Compositor::sendDragMoveEvent(const QPoint &global, const QPoint &local, - Surface *surface) -{ - Q_UNUSED(global); - Q_UNUSED(local); - Q_UNUSED(surface); -// Drag::instance()->dragMove(global, local, surface); -} - -void Compositor::sendDragEndEvent() -{ -// Drag::instance()->dragEnd(); -} - -} // namespace Wayland diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h deleted file mode 100644 index a009037b5..000000000 --- a/src/compositor/wayland_wrapper/wlcompositor.h +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WL_COMPOSITOR_H -#define WL_COMPOSITOR_H - -#include "waylandexport.h" - -#include -#include - -#include "wloutput.h" -#include "wldisplay.h" - -#include - -class WaylandCompositor; -class WaylandInputDevice; -class GraphicsHardwareIntegration; -class WindowManagerServerIntegration; -class QMimeData; -class QPlatformScreenPageFlipper; -class QPlatformScreenBuffer; - -namespace Wayland { - -class Surface; -class SurfaceBuffer; -class InputDevice; -class DataDeviceManager; -class OutputExtensionGlobal; -class SurfaceExtensionGlobal; -class SubSurfaceExtensionGlobal; -class Shell; -class TouchExtensionGlobal; -class QtKeyExtensionGlobal; - -class Q_COMPOSITOR_EXPORT Compositor : public QObject -{ - Q_OBJECT - -public: - Compositor(WaylandCompositor *qt_compositor); - ~Compositor(); - - void frameFinished(Surface *surface = 0); - - //these 3 functions will be removed if noone steps up soon. - Surface *getSurfaceFromWinId(uint winId) const; - struct wl_client *getClientFromWinId(uint winId) const; - QImage image(uint winId) const; - - InputDevice *defaultInputDevice(); //we just have 1 default device for now (since QPA doesn't give us anything else) - - void createSurface(struct wl_client *client, uint32_t id); - void surfaceDestroyed(Surface *surface); - void markSurfaceAsDirty(Surface *surface); - - void destroyClient(WaylandClient *client); - - static uint currentTimeMsecs(); - - QWindow *window() const; - - GraphicsHardwareIntegration *graphicsHWIntegration() const; - void initializeHardwareIntegration(); - void initializeDefaultInputDevice(); - void initializeWindowManagerProtocol(); - void enableSubSurfaceExtension(); - bool setDirectRenderSurface(Surface *surface, QOpenGLContext *context); - Surface *directRenderSurface() const {return m_directRenderSurface;} - QOpenGLContext *directRenderContext() const {return m_directRenderContext;} - QPlatformScreenPageFlipper *pageFlipper() const { return m_pageFlipper; } - void setDirectRenderingActive(bool active); - - QList surfaces() const { return m_surfaces; } - QList surfacesForClient(wl_client* client); - WaylandCompositor *waylandCompositor() const { return m_qt_compositor; } - - struct wl_display *wl_display() const { return m_display->handle(); } - - static Compositor *instance(); - - QList clients() const; - - WindowManagerServerIntegration *windowManagerIntegration() const { return m_windowManagerIntegration; } - - void setScreenOrientation(Qt::ScreenOrientation orientation); - Qt::ScreenOrientation screenOrientation() const; - void setOutputGeometry(const QRect &geometry); - QRect outputGeometry() const; - void setOutputRefreshRate(int rate); - int outputRefreshRate() const; - - Qt::ScreenOrientations orientationUpdateMaskForClient(wl_client *client); - - void setClientFullScreenHint(bool value); - - TouchExtensionGlobal *touchExtension() { return m_touchExtension; } - void configureTouchExtension(int flags); - - QtKeyExtensionGlobal *qtkeyExtension() { return m_qtkeyExtension; } - - bool isDragging() const; - void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface); - void sendDragEndEvent(); - - typedef void (*RetainedSelectionFunc)(QMimeData *, void *); - void setRetainedSelectionWatcher(RetainedSelectionFunc func, void *param); - void overrideSelection(QMimeData *data); - - bool wantsRetainedSelection() const; - void feedRetainedSelectionData(QMimeData *data); - - void scheduleReleaseBuffer(SurfaceBuffer *screenBuffer); - - static wl_resource *resourceForSurface(wl_list *resourceList, Surface *surface); - -private slots: - - void releaseBuffer(SurfaceBuffer *screenBuffer); - void processWaylandEvents(); - -private: - Display *m_display; - - /* Input */ - WaylandInputDevice *m_default_wayland_input_device; - InputDevice *m_default_input_device; - - /* Output */ - //make this a list of the available screens - OutputGlobal m_output_global; - //This one should be part of the outputs - QPlatformScreenPageFlipper *m_pageFlipper; - - DataDeviceManager *m_data_device_manager; - - QList m_surfaces; - QSet m_dirty_surfaces; - - /* Render state */ - uint32_t m_current_frame; - int m_last_queued_buf; - - wl_event_loop *m_loop; - - WaylandCompositor *m_qt_compositor; - Qt::ScreenOrientation m_orientation; - - Surface *m_directRenderSurface; - QOpenGLContext *m_directRenderContext; - bool m_directRenderActive; - -#ifdef QT_COMPOSITOR_WAYLAND_GL - GraphicsHardwareIntegration *m_graphics_hw_integration; -#endif - - //extensions - WindowManagerServerIntegration *m_windowManagerIntegration; - - Shell *m_shell; - OutputExtensionGlobal *m_outputExtension; - SurfaceExtensionGlobal *m_surfaceExtension; - SubSurfaceExtensionGlobal *m_subSurfaceExtension; - TouchExtensionGlobal *m_touchExtension; - QtKeyExtensionGlobal *m_qtkeyExtension; - - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - - RetainedSelectionFunc m_retainNotify; - void *m_retainNotifyParam; -}; - -} - -#endif //WL_COMPOSITOR_H diff --git a/src/compositor/wayland_wrapper/wldatadevice.cpp b/src/compositor/wayland_wrapper/wldatadevice.cpp deleted file mode 100644 index 2c3bc3801..000000000 --- a/src/compositor/wayland_wrapper/wldatadevice.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wldatadevice.h" - -#include "wldatasource.h" -#include "wldataoffer.h" -#include "wldatadevicemanager.h" - -#include - -#include - -namespace Wayland { - -void DataDevice::start_drag(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *source, - struct wl_resource *surface, - struct wl_resource *icon, - uint32_t time) -{ - Q_UNUSED(client); - Q_UNUSED(surface); - Q_UNUSED(icon); - Q_UNUSED(time); - DataDevice *data_device = static_cast(resource->data); - DataSource *data_source = static_cast(source->data); - Q_UNUSED(data_device); - Q_UNUSED(data_source); -} - -void DataDevice::set_selection(struct wl_client *client, - struct wl_resource *data_device_resource, - struct wl_resource *source, - uint32_t time) -{ - Q_UNUSED(client); - Q_UNUSED(time); - DataDevice *data_device = static_cast(data_device_resource->data); - DataSource *data_source = static_cast(source->data); - - data_device->m_data_device_manager->setCurrentSelectionSource(data_source); - -} - -const struct wl_data_device_interface DataDevice::data_device_interface = { - DataDevice::start_drag, - DataDevice::set_selection -}; - -DataDevice::DataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id) - : m_data_device_manager(data_device_manager) - , m_sent_selection_time(0) -{ - - //static int i = 0; - //qDebug() << "data device" << ++i; - m_data_device_resource = - wl_client_add_object(client,&wl_data_device_interface,&data_device_interface,id, this); -} - -void DataDevice::sendSelectionFocus() -{ - if (m_data_device_manager->offerFromCompositorToClient(m_data_device_resource)) - return; - - DataSource *source = m_data_device_manager->currentSelectionSource(); - if (!source || !source->client()) { - m_data_device_manager->offerRetainedSelection(m_data_device_resource); - return; - } - if (source->time() > m_sent_selection_time) { //this makes sure we don't resend - if (source->client() != m_data_device_resource->client) { //don't send selection to the client that owns the selection - DataOffer *data_offer = source->dataOffer(); - wl_resource *client_resource = - data_offer->addDataDeviceResource(m_data_device_resource); - //qDebug() << "sending data_offer for source" << source; - wl_data_device_send_selection(m_data_device_resource,client_resource); - m_sent_selection_time = source->time(); - } - } -} - -struct wl_resource *DataDevice::dataDeviceResource() const -{ - return m_data_device_resource; -} - -} diff --git a/src/compositor/wayland_wrapper/wldatadevice.h b/src/compositor/wayland_wrapper/wldatadevice.h deleted file mode 100644 index 2f1d72f21..000000000 --- a/src/compositor/wayland_wrapper/wldatadevice.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLDATADEVICE_H -#define WLDATADEVICE_H - -#include "wldatadevicemanager.h" - -namespace Wayland { - -class DataSource; -class DataDeviceManager; - -class DataDevice -{ -public: - DataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id); - - void createAndSetSelectionSource(struct wl_client *client, uint32_t id, const char *name, uint32_t time); - void sendSelectionFocus(); - - struct wl_resource *dataDeviceResource() const; - - struct wl_display *display() const { return m_data_device_manager->display(); } -private: - DataDeviceManager *m_data_device_manager; - uint32_t m_sent_selection_time; - struct wl_resource *m_data_device_resource; - - static const struct wl_data_device_interface data_device_interface; - static void start_drag(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *source, - struct wl_resource *surface, - struct wl_resource *icon, - uint32_t time); - static void set_selection(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *source, - uint32_t time); -}; - -} - -#endif // WLDATADEVICE_H diff --git a/src/compositor/wayland_wrapper/wldatadevicemanager.cpp b/src/compositor/wayland_wrapper/wldatadevicemanager.cpp deleted file mode 100644 index cdfc0002b..000000000 --- a/src/compositor/wayland_wrapper/wldatadevicemanager.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wldatadevicemanager.h" - -#include "wldatadevice.h" -#include "wldatasource.h" -#include "wlinputdevice.h" -#include "wlcompositor.h" -#include "wldataoffer.h" -#include "wlsurface.h" -#include "qwaylandmimehelper.h" - -#include -#include -#include -#include -#include - -namespace Wayland { - -DataDeviceManager::DataDeviceManager(Compositor *compositor) - : m_compositor(compositor) - , m_current_selection_source(0) - , m_retainedReadNotifier(0) - , m_compositorOwnsSelection(false) -{ - wl_display_add_global(compositor->wl_display(), &wl_data_device_manager_interface, this, DataDeviceManager::bind_func_drag); -} - -void DataDeviceManager::setCurrentSelectionSource(DataSource *source) -{ - if (m_current_selection_source - && m_current_selection_source->time() > source->time()) { - qDebug() << "Trying to set older selection"; - return; - } - - m_compositorOwnsSelection = false; - - finishReadFromClient(); - - m_current_selection_source = source; - source->setManager(this); - - // When retained selection is enabled, the compositor will query all the data from the client. - // This makes it possible to - // 1. supply the selection after the offering client is gone - // 2. make it possible for the compositor to participate in copy-paste - // The downside is decreased performance, therefore this mode has to be enabled - // explicitly in the compositors. - if (m_compositor->wantsRetainedSelection()) { - m_retainedData.clear(); - m_retainedReadIndex = 0; - retain(); - } -} - -void DataDeviceManager::sourceDestroyed(DataSource *source) -{ - Q_UNUSED(source); - if (m_current_selection_source == source) - finishReadFromClient(); -} - -void DataDeviceManager::retain() -{ - QList offers = m_current_selection_source->offerList(); - finishReadFromClient(); - if (m_retainedReadIndex >= offers.count()) { - m_compositor->feedRetainedSelectionData(&m_retainedData); - return; - } - QByteArray mimeType = offers.at(m_retainedReadIndex); - m_retainedReadBuf.clear(); - int fd[2]; - if (pipe(fd) == -1) { - qWarning("Clipboard: Failed to create pipe"); - return; - } - fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL, 0) | O_NONBLOCK); - m_current_selection_source->postSendEvent(mimeType, fd[1]); - close(fd[1]); - m_retainedReadNotifier = new QSocketNotifier(fd[0], QSocketNotifier::Read, this); - connect(m_retainedReadNotifier, SIGNAL(activated(int)), SLOT(readFromClient(int))); -} - -void DataDeviceManager::finishReadFromClient(bool exhausted) -{ - Q_UNUSED(exhausted); - if (m_retainedReadNotifier) { - if (exhausted) { - int fd = m_retainedReadNotifier->socket(); - delete m_retainedReadNotifier; - close(fd); - } else { - // Do not close the handle or destroy the read notifier here - // or else clients may SIGPIPE. - m_obsoleteRetainedReadNotifiers.append(m_retainedReadNotifier); - } - m_retainedReadNotifier = 0; - } -} - -void DataDeviceManager::readFromClient(int fd) -{ - static char buf[4096]; - int obsCount = m_obsoleteRetainedReadNotifiers.count(); - for (int i = 0; i < obsCount; ++i) { - QSocketNotifier *sn = m_obsoleteRetainedReadNotifiers.at(i); - if (sn->socket() == fd) { - // Read and drop the data, stopping to read and closing the handle - // is not yet safe because that could kill the client with SIGPIPE - // when it still tries to write. - int n; - do { - n = QT_READ(fd, buf, sizeof buf); - } while (n > 0); - if (n != -1 || (errno != EAGAIN && errno != EWOULDBLOCK)) { - m_obsoleteRetainedReadNotifiers.removeAt(i); - delete sn; - close(fd); - } - return; - } - } - int n = QT_READ(fd, buf, sizeof buf); - if (n <= 0) { - if (n != -1 || (errno != EAGAIN && errno != EWOULDBLOCK)) { - finishReadFromClient(true); - QList offers = m_current_selection_source->offerList(); - QString mimeType = QString::fromLatin1(offers.at(m_retainedReadIndex)); - m_retainedData.setData(mimeType, m_retainedReadBuf); - ++m_retainedReadIndex; - retain(); - } - } else { - m_retainedReadBuf.append(buf, n); - } -} - -DataSource *DataDeviceManager::currentSelectionSource() -{ - return m_current_selection_source; -} - -struct wl_display *DataDeviceManager::display() const -{ - return m_compositor->wl_display(); -} - -void DataDeviceManager::bind_func_drag(struct wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_client_add_object(client,&wl_data_device_manager_interface,&drag_interface,id,data); -} - -void DataDeviceManager::bind_func_data(struct wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(client); - Q_UNUSED(data); - Q_UNUSED(version); - Q_UNUSED(id); -} - -void DataDeviceManager::get_data_device(struct wl_client *client, - struct wl_resource *data_device_manager_resource, - uint32_t id, - struct wl_resource *input_device_resource) -{ - DataDeviceManager *data_device_manager = static_cast(data_device_manager_resource->data); - InputDevice *input_device = resolve(input_device_resource); - input_device->clientRequestedDataDevice(data_device_manager,client,id); -} - -void DataDeviceManager::create_data_source(struct wl_client *client, - struct wl_resource *data_device_manager_resource, - uint32_t id) -{ - Q_UNUSED(data_device_manager_resource); - new DataSource(client,id, Compositor::currentTimeMsecs()); -} - -struct wl_data_device_manager_interface DataDeviceManager::drag_interface = { - DataDeviceManager::create_data_source, - DataDeviceManager::get_data_device -}; - -void DataDeviceManager::overrideSelection(const QMimeData &mimeData) -{ - QStringList formats = mimeData.formats(); - if (formats.isEmpty()) - return; - - m_retainedData.clear(); - foreach (const QString &format, formats) - m_retainedData.setData(format, mimeData.data(format)); - - m_compositor->feedRetainedSelectionData(&m_retainedData); - - m_compositorOwnsSelection = true; - - InputDevice *dev = m_compositor->defaultInputDevice(); - Surface *focusSurface = dev->keyboardFocus(); - if (focusSurface) - offerFromCompositorToClient( - dev->dataDevice(focusSurface->base()->resource.client)->dataDeviceResource()); -} - -bool DataDeviceManager::offerFromCompositorToClient(wl_resource *clientDataDeviceResource) -{ - if (!m_compositorOwnsSelection) - return false; - - wl_client *client = clientDataDeviceResource->client; - //qDebug("compositor offers %d types to %p", m_retainedData.formats().count(), client); - - struct wl_resource *selectionOffer = - wl_client_new_object(client, &wl_data_offer_interface, &compositor_offer_interface, this); - wl_data_device_send_data_offer(clientDataDeviceResource, selectionOffer); - foreach (const QString &format, m_retainedData.formats()) { - QByteArray ba = format.toLatin1(); - wl_data_offer_send_offer(selectionOffer, ba.constData()); - } - wl_data_device_send_selection(clientDataDeviceResource, selectionOffer); - - return true; -} - -void DataDeviceManager::offerRetainedSelection(wl_resource *clientDataDeviceResource) -{ - if (m_retainedData.formats().isEmpty()) - return; - - m_compositorOwnsSelection = true; - offerFromCompositorToClient(clientDataDeviceResource); -} - -void DataDeviceManager::comp_accept(wl_client *, wl_resource *, uint32_t, const char *) -{ -} - -void DataDeviceManager::comp_receive(wl_client *client, wl_resource *resource, const char *mime_type, int32_t fd) -{ - Q_UNUSED(client); - DataDeviceManager *self = static_cast(resource->data); - //qDebug("client %p wants data for type %s from compositor", client, mime_type); - QByteArray content = QWaylandMimeHelper::getByteArray(&self->m_retainedData, QString::fromLatin1(mime_type)); - if (!content.isEmpty()) { - QFile f; - if (f.open(fd, QIODevice::WriteOnly)) - f.write(content); - } - close(fd); -} - -void DataDeviceManager::comp_destroy(wl_client *, wl_resource *) -{ -} - -const struct wl_data_offer_interface DataDeviceManager::compositor_offer_interface = { - DataDeviceManager::comp_accept, - DataDeviceManager::comp_receive, - DataDeviceManager::comp_destroy -}; - -} //namespace diff --git a/src/compositor/wayland_wrapper/wldatadevicemanager.h b/src/compositor/wayland_wrapper/wldatadevicemanager.h deleted file mode 100644 index 5576a41f7..000000000 --- a/src/compositor/wayland_wrapper/wldatadevicemanager.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLDATADEVICEMANAGER_H -#define WLDATADEVICEMANAGER_H - -#include "wlcompositor.h" - -#include -#include -#include -#include - -class QSocketNotifier; - -namespace Wayland { - -class Compositor; - -class DataDevice; -class DataSource; - -class DataDeviceManager : public QObject -{ - Q_OBJECT - -public: - DataDeviceManager(Compositor *compositor); - - void setCurrentSelectionSource(DataSource *source); - DataSource *currentSelectionSource(); - - struct wl_display *display() const; - - void sourceDestroyed(DataSource *source); - - void overrideSelection(const QMimeData &mimeData); - bool offerFromCompositorToClient(wl_resource *clientDataDeviceResource); - void offerRetainedSelection(wl_resource *clientDataDeviceResource); - -private slots: - void readFromClient(int fd); - -private: - void retain(); - void finishReadFromClient(bool exhausted = false); - - Compositor *m_compositor; - QList m_data_device_list; - - DataSource *m_current_selection_source; - - static void bind_func_drag(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - static void bind_func_data(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - static void get_data_device(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *input_device); - static void create_data_source(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - static struct wl_data_device_manager_interface drag_interface; - - QMimeData m_retainedData; - QSocketNotifier *m_retainedReadNotifier; - QList m_obsoleteRetainedReadNotifiers; - int m_retainedReadIndex; - QByteArray m_retainedReadBuf; - - bool m_compositorOwnsSelection; - - - static void comp_accept(struct wl_client *client, - struct wl_resource *resource, - uint32_t time, - const char *type); - static void comp_receive(struct wl_client *client, - struct wl_resource *resource, - const char *mime_type, - int32_t fd); - static void comp_destroy(struct wl_client *client, - struct wl_resource *resource); - - static const struct wl_data_offer_interface compositor_offer_interface; -}; - -} -#endif // WLDATADEVICEMANAGER_H diff --git a/src/compositor/wayland_wrapper/wldataoffer.cpp b/src/compositor/wayland_wrapper/wldataoffer.cpp deleted file mode 100644 index 80293a7d3..000000000 --- a/src/compositor/wayland_wrapper/wldataoffer.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wldataoffer.h" - -#include "wldatadevice.h" - -#include - -#include -#include - -#include - -namespace Wayland -{ - -DataOffer::DataOffer(DataSource *data_source) - : m_data_source(data_source) -{ - -} - -DataOffer::~DataOffer() -{ -} - -struct wl_resource *DataOffer::addDataDeviceResource(struct wl_resource *data_device_resource) -{ - if (resourceForClient(data_device_resource->client)) { - qDebug() << "This should not happen, the client tries to add twice to a data offer"; - return 0; - } - struct wl_resource *new_object = - wl_client_new_object(data_device_resource->client,&wl_data_offer_interface,&data_interface,this); - wl_data_device_send_data_offer(data_device_resource, new_object); - - registerResource(new_object); - QList offer_list = m_data_source->offerList(); - for (int i = 0; i < offer_list.size(); i++) { - wl_data_offer_send_offer(new_object, offer_list.at(i).constData()); - } - return new_object; -} - -const struct wl_data_offer_interface DataOffer::data_interface = { - DataOffer::accept, - DataOffer::receive, - DataOffer::destroy -}; - -void DataOffer::accept(wl_client *client, wl_resource *resource, uint32_t time, const char *type) -{ - Q_UNUSED(client); - Q_UNUSED(resource); - Q_UNUSED(time); - Q_UNUSED(type); -} - -void DataOffer::receive(wl_client *client, wl_resource *resource, const char *mime_type, int32_t fd) -{ - Q_UNUSED(client); - - DataOffer *offer = static_cast(resource->data); - offer->m_data_source->postSendEvent(mime_type,fd); - close(fd); -} - -void DataOffer::destroy(wl_client *client, wl_resource *resource) -{ - Q_UNUSED(client); - DataOffer *data_offer = static_cast(resource->data); - - if (data_offer->resourceListIsEmpty()) { - delete data_offer; - } -} - - -} diff --git a/src/compositor/wayland_wrapper/wldataoffer.h b/src/compositor/wayland_wrapper/wldataoffer.h deleted file mode 100644 index 4b47c977d..000000000 --- a/src/compositor/wayland_wrapper/wldataoffer.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLDATAOFFER_H -#define WLDATAOFFER_H - -#include "wldatasource.h" - -#include "waylandresourcecollection.h" - -namespace Wayland -{ - -class DataOffer : public ResourceCollection -{ -public: - DataOffer(DataSource *data_source); - ~DataOffer(); - - struct wl_resource *addDataDeviceResource(struct wl_resource *client_resource); -private: - DataSource *m_data_source; - - static void accept(struct wl_client *client, - struct wl_resource *resource, - uint32_t time, - const char *type); - static void receive(struct wl_client *client, - struct wl_resource *resource, - const char *mime_type, - int32_t fd); - static void destroy(struct wl_client *client, - struct wl_resource *resource); - - static const struct wl_data_offer_interface data_interface; - -}; - -} - -#endif // WLDATAOFFER_H diff --git a/src/compositor/wayland_wrapper/wldatasource.cpp b/src/compositor/wayland_wrapper/wldatasource.cpp deleted file mode 100644 index d243f0a4b..000000000 --- a/src/compositor/wayland_wrapper/wldatasource.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wldatasource.h" -#include "wldataoffer.h" -#include "wldatadevicemanager.h" -#include "wlcompositor.h" - -#include - -#include - -namespace Wayland { - -DataSource::DataSource(struct wl_client *client, uint32_t id, uint32_t time) - : m_time(time) -{ - m_data_source_resource = wl_client_add_object(client, &wl_data_source_interface, &DataSource::data_source_interface,id,this); - m_data_source_resource->destroy = resource_destroy; - m_data_offer = new DataOffer(this); - m_manager = 0; -} - -DataSource::~DataSource() -{ - if (m_manager) - m_manager->sourceDestroyed(this); - wl_resource_destroy(m_data_source_resource); -} - -void DataSource::resource_destroy(wl_resource *resource) -{ - DataSource *source = static_cast(resource->data); - if (source && source->m_data_source_resource == resource) - source->m_data_source_resource = 0; - free(resource); -} - -uint32_t DataSource::time() const -{ - return m_time; -} - -QList DataSource::offerList() const -{ - return m_offers; -} - -struct wl_data_source_interface DataSource::data_source_interface = { - DataSource::offer, - DataSource::destroy -}; - -void DataSource::offer(struct wl_client *client, - struct wl_resource *resource, - const char *type) -{ - Q_UNUSED(client); - //qDebug() << "received offer" << type; - static_cast(resource->data)->m_offers.append(type); -} - -void DataSource::destroy(struct wl_client *client, - struct wl_resource *resource) -{ - Q_UNUSED(client); - DataSource *self = static_cast(resource->data); - delete self; -} - -DataOffer * DataSource::dataOffer() const -{ - return m_data_offer; -} - -void DataSource::postSendEvent(const QByteArray &mimeType, int fd) -{ - if (m_data_source_resource) { - wl_data_source_send_send(m_data_source_resource, mimeType.constData(), fd); - } -} - -struct wl_client *DataSource::client() const -{ - if (m_data_source_resource) - return m_data_source_resource->client; - return 0; -} - -void DataSource::setManager(DataDeviceManager *mgr) -{ - m_manager = mgr; -} - -} diff --git a/src/compositor/wayland_wrapper/wldatasource.h b/src/compositor/wayland_wrapper/wldatasource.h deleted file mode 100644 index 75e9bbdd6..000000000 --- a/src/compositor/wayland_wrapper/wldatasource.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLDATASOURCE_H -#define WLDATASOURCE_H - -#include - -#include -#include - -namespace Wayland { - -class DataOffer; -class DataDeviceManager; - -class DataSource -{ -public: - DataSource(struct wl_client *client, uint32_t id, uint32_t time); - ~DataSource(); - uint32_t time() const; - QList offerList() const; - - DataOffer *dataOffer() const; - - void postSendEvent(const QByteArray &mimeType,int fd); - struct wl_client *client() const; - - void setManager(DataDeviceManager *mgr); - -private: - uint32_t m_time; - QList m_offers; - struct wl_resource *m_data_source_resource; - - DataOffer *m_data_offer; - - DataDeviceManager *m_manager; - - static struct wl_data_source_interface data_source_interface; - static void offer(struct wl_client *client, - struct wl_resource *resource, - const char *type); - static void destroy(struct wl_client *client, - struct wl_resource *resource); - - static void resource_destroy(struct wl_resource *resource); -}; - -} - -#endif // WLDATASOURCE_H diff --git a/src/compositor/wayland_wrapper/wldisplay.cpp b/src/compositor/wayland_wrapper/wldisplay.cpp deleted file mode 100644 index e933e53e8..000000000 --- a/src/compositor/wayland_wrapper/wldisplay.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wldisplay.h" - -#include - -#include - -namespace Wayland { - -Display::Display() -{ - m_display = wl_display_create(); - - Q_ASSERT(m_display); -} - -Display::~Display() -{ - wl_display_destroy(m_display); -} - -} - diff --git a/src/compositor/wayland_wrapper/wldisplay.h b/src/compositor/wayland_wrapper/wldisplay.h deleted file mode 100644 index 69cc93d07..000000000 --- a/src/compositor/wayland_wrapper/wldisplay.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WL_DISPLAY_H -#define WL_DISPLAY_H - -#include - -namespace Wayland { - -class Display -{ -public: - Display(); - ~Display(); - - struct wl_display *handle() const { return m_display; } - struct wl_display *handle() { return m_display; } - -private: - struct wl_display *m_display; -}; - -} - -#endif //WL_DISPLAY_H diff --git a/src/compositor/wayland_wrapper/wlextendedoutput.cpp b/src/compositor/wayland_wrapper/wlextendedoutput.cpp deleted file mode 100644 index b9182011a..000000000 --- a/src/compositor/wayland_wrapper/wlextendedoutput.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlextendedoutput.h" - -#include "wlcompositor.h" -#include "wlsurface.h" -#include "wloutput.h" - -namespace Wayland { - -OutputExtensionGlobal::OutputExtensionGlobal(Compositor *compositor) - : m_compositor(compositor) -{ - wl_display_add_global(compositor->wl_display(), - &wl_output_extension_interface, - this, - OutputExtensionGlobal::bind_func); -} - -void OutputExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_client_add_object(client,&wl_output_extension_interface,&output_extension_interface,id,data); -} - -void OutputExtensionGlobal::get_extended_output(wl_client *client, wl_resource *output_extension_resource, uint32_t id, wl_resource *output_resource) -{ - OutputExtensionGlobal *output_extension = static_cast(output_extension_resource->data); - Output *output = static_cast(output_resource->data); - new ExtendedOutput(client,id,output,output_extension->m_compositor); -} - -const struct wl_output_extension_interface OutputExtensionGlobal::output_extension_interface = { - OutputExtensionGlobal::get_extended_output -}; - -ExtendedOutput::ExtendedOutput(struct wl_client *client, uint32_t id, Output *output, Compositor *compositor) - : m_output(output) - , m_compositor(compositor) -{ - static const struct wl_extended_output_interface extended_output_interface = { - set_orientation_update_mask - }; - Q_ASSERT(m_output->extendedOutput() == 0); - m_output->setExtendedOutput(this); - m_extended_output_resource = wl_client_add_object(client,&wl_extended_output_interface,&extended_output_interface,id,this); - m_extended_output_resource->destroy = ExtendedOutput::destroy_resource; - - sendOutputOrientation(m_compositor->screenOrientation()); -} - -void ExtendedOutput::destroy_resource(wl_resource *resource) -{ - ExtendedOutput *output = static_cast(resource->data); - delete output; - free(resource); -} - -void ExtendedOutput::set_orientation_update_mask(struct wl_client *client, - struct wl_resource *resource, - int32_t orientation_update_mask) -{ - ExtendedOutput *output = static_cast(resource->data); - - Qt::ScreenOrientations mask = 0; - if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION) - mask |= Qt::PortraitOrientation; - if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION) - mask |= Qt::LandscapeOrientation; - if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION) - mask |= Qt::InvertedPortraitOrientation; - if (orientation_update_mask & WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION) - mask |= Qt::InvertedLandscapeOrientation; - - Qt::ScreenOrientations oldMask = output->m_orientationUpdateMask; - output->m_orientationUpdateMask = mask; - - if (mask != oldMask) { - QList surfaces = output->m_compositor->surfacesForClient(client); - foreach (Surface *surface, surfaces) { - if (surface->waylandSurface()) - emit surface->waylandSurface()->orientationUpdateMaskChanged(); - } - } -} - -void ExtendedOutput::sendOutputOrientation(Qt::ScreenOrientation orientation) -{ - int sendOpperation; - switch (orientation) { - case Qt::PortraitOrientation: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; - break; - case Qt::LandscapeOrientation: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION; - break; - case Qt::InvertedPortraitOrientation: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION; - break; - case Qt::InvertedLandscapeOrientation: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION; - break; - default: - sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION; - } - wl_extended_output_send_set_screen_rotation(m_extended_output_resource, sendOpperation); -} - - -} diff --git a/src/compositor/wayland_wrapper/wlextendedoutput.h b/src/compositor/wayland_wrapper/wlextendedoutput.h deleted file mode 100644 index 0d24a9245..000000000 --- a/src/compositor/wayland_wrapper/wlextendedoutput.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLEXTENDEDOUTPUT_H -#define WLEXTENDEDOUTPUT_H - -#include "wayland-server.h" -#include "wayland-output-extension-server-protocol.h" - -#include - -namespace Wayland { - -class Compositor; -class Output; - -class OutputExtensionGlobal -{ -public: - OutputExtensionGlobal(Compositor *compositor); - -private: - Compositor *m_compositor; - - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - static void get_extended_output(struct wl_client *client, - struct wl_resource *output_extension_resource, - uint32_t id, - struct wl_resource *output_resource); - static const struct wl_output_extension_interface output_extension_interface; - -}; - -class ExtendedOutput -{ -public: - ExtendedOutput(struct wl_client *client, uint32_t id, Output *output, Compositor *compositor); - - Qt::ScreenOrientations orientationUpdateMask() { return m_orientationUpdateMask; } - - void sendOutputOrientation(Qt::ScreenOrientation orientation); - - static void destroy_resource(wl_resource *resource); - - static void set_orientation_update_mask(struct wl_client *client, - struct wl_resource *resource, - int32_t orientation_update_mask); - -private: - struct wl_resource *m_extended_output_resource; - Output *m_output; - Compositor *m_compositor; - Qt::ScreenOrientations m_orientationUpdateMask; -}; - -} - -#endif // WLEXTENDEDOUTPUT_H diff --git a/src/compositor/wayland_wrapper/wlextendedsurface.cpp b/src/compositor/wayland_wrapper/wlextendedsurface.cpp deleted file mode 100644 index 1ffb9c421..000000000 --- a/src/compositor/wayland_wrapper/wlextendedsurface.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlextendedsurface.h" - -#include "wlcompositor.h" -#include "wlsurface.h" - -namespace Wayland { - -SurfaceExtensionGlobal::SurfaceExtensionGlobal(Compositor *compositor) - : m_compositor(compositor) -{ - wl_display_add_global(m_compositor->wl_display(), - &wl_surface_extension_interface, - this, - SurfaceExtensionGlobal::bind_func); -} - -void SurfaceExtensionGlobal::bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_client_add_object(client, &wl_surface_extension_interface,&surface_extension_interface,id,data); -} - -const struct wl_surface_extension_interface SurfaceExtensionGlobal::surface_extension_interface = { - SurfaceExtensionGlobal::get_extended_surface -}; - -void SurfaceExtensionGlobal::get_extended_surface(struct wl_client *client, - struct wl_resource *surface_extension_resource, - uint32_t id, - struct wl_resource *surface_resource) -{ - Q_UNUSED(surface_extension_resource); - Surface *surface = resolve(surface_resource); - new ExtendedSurface(client,id,surface); -} - -ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface) - : m_surface(surface) - , m_contentOrientation(Qt::PrimaryOrientation) - , m_windowFlags(0) -{ - Q_ASSERT(surface->extendedSurface() == 0); - m_extended_surface_resource = wl_client_add_object(client, - &wl_extended_surface_interface, - &extended_surface_interface, - id, - this); - surface->setExtendedSurface(this); -} - -ExtendedSurface::~ExtendedSurface() -{ - -} - -void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &variant) -{ - QByteArray byteValue; - QDataStream ds(&byteValue, QIODevice::WriteOnly); - ds << variant; - wl_array data; - data.size = byteValue.size(); - data.data = (void*) byteValue.constData(); - data.alloc = 0; - wl_extended_surface_send_set_generic_property(m_extended_surface_resource, qPrintable(name), &data); - -} - -void ExtendedSurface::sendOnScreenVisibility(bool visible) -{ - int32_t visibleInt = visible; - wl_extended_surface_send_onscreen_visibility(m_extended_surface_resource, visibleInt); -} - - -void ExtendedSurface::update_generic_property(wl_client *client, wl_resource *extended_surface_resource, const char *name, wl_array *value) -{ - Q_UNUSED(client); - ExtendedSurface *extended_surface = static_cast(extended_surface_resource->data); - QVariant variantValue; - QByteArray byteValue((const char*)value->data, value->size); - QDataStream ds(&byteValue, QIODevice::ReadOnly); - ds >> variantValue; - extended_surface->setWindowProperty(QString::fromLatin1(name),variantValue,false); - -} - -static Qt::ScreenOrientation screenOrientationFromWaylandOrientation(int32_t orientation) -{ - switch (orientation) { - case WL_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION: return Qt::PortraitOrientation; - case WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION: return Qt::InvertedPortraitOrientation; - case WL_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION: return Qt::LandscapeOrientation; - case WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION: return Qt::InvertedLandscapeOrientation; - default: return Qt::PrimaryOrientation; - } -} - -Qt::ScreenOrientation ExtendedSurface::contentOrientation() const -{ - return m_contentOrientation; -} - -void ExtendedSurface::set_content_orientation(struct wl_client *client, - struct wl_resource *extended_surface_resource, - int32_t orientation) -{ - Q_UNUSED(client); - ExtendedSurface *extended_surface = static_cast(extended_surface_resource->data); - - Qt::ScreenOrientation oldOrientation = extended_surface->m_contentOrientation; - extended_surface->m_contentOrientation = screenOrientationFromWaylandOrientation(orientation); - if (extended_surface->m_contentOrientation != oldOrientation) - emit extended_surface->m_surface->waylandSurface()->contentOrientationChanged(); -} - -void ExtendedSurface::setWindowFlags(WaylandSurface::WindowFlags flags) -{ - if (flags == m_windowFlags) - return; - m_windowFlags = flags; - emit m_surface->waylandSurface()->windowFlagsChanged(flags); -} - -QVariantMap ExtendedSurface::windowProperties() const -{ - return m_windowProperties; -} - -QVariant ExtendedSurface::windowProperty(const QString &propertyName) const -{ - QVariantMap props = m_windowProperties; - return props.value(propertyName); -} - -void ExtendedSurface::setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient) -{ - Q_UNUSED(writeUpdateToClient); - m_windowProperties.insert(name, value); - m_surface->waylandSurface()->windowPropertyChanged(name,value); - sendGenericProperty(name, value); -} - -void ExtendedSurface::set_window_flags(wl_client *client, wl_resource *resource, int32_t flags) -{ - Q_UNUSED(client); - ExtendedSurface *extended_surface = static_cast(resource->data); - extended_surface->setWindowFlags(WaylandSurface::WindowFlags(flags)); -} - -const struct wl_extended_surface_interface ExtendedSurface::extended_surface_interface = { - ExtendedSurface::update_generic_property, - ExtendedSurface::set_content_orientation, - ExtendedSurface::set_window_flags -}; - -} diff --git a/src/compositor/wayland_wrapper/wlextendedsurface.h b/src/compositor/wayland_wrapper/wlextendedsurface.h deleted file mode 100644 index bb3192248..000000000 --- a/src/compositor/wayland_wrapper/wlextendedsurface.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLEXTENDEDSURFACE_H -#define WLEXTENDEDSURFACE_H - -#include -#include "wayland-surface-extension-server-protocol.h" - -#include "wlsurface.h" -#include "waylandsurface.h" - -#include -#include - -class WaylandSurface; - -namespace Wayland { - -class Compositor; - -class SurfaceExtensionGlobal -{ -public: - SurfaceExtensionGlobal(Compositor *compositor); - -private: - Compositor *m_compositor; - - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - static void get_extended_surface(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface); - static const struct wl_surface_extension_interface surface_extension_interface; - -}; - -class ExtendedSurface -{ -public: - ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface); - ~ExtendedSurface(); - - void sendGenericProperty(const QString &name, const QVariant &variant); - void sendOnScreenVisibility(bool visible); - - void setSubSurface(ExtendedSurface *subSurface,int x, int y); - void removeSubSurface(ExtendedSurface *subSurfaces); - ExtendedSurface *parent() const; - void setParent(ExtendedSurface *parent); - QLinkedList subSurfaces() const; - - Qt::ScreenOrientation contentOrientation() const; - - WaylandSurface::WindowFlags windowFlags() const { return m_windowFlags; } - - qint64 processId() const; - void setProcessId(qint64 processId); - - QVariantMap windowProperties() const; - QVariant windowProperty(const QString &propertyName) const; - void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true); - -private: - struct wl_resource *m_extended_surface_resource; - Surface *m_surface; - - Qt::ScreenOrientation m_contentOrientation; - - WaylandSurface::WindowFlags m_windowFlags; - - QByteArray m_authenticationToken; - QVariantMap m_windowProperties; - - - static void update_generic_property(struct wl_client *client, - struct wl_resource *resource, - const char *name, - struct wl_array *value); - - static void set_content_orientation(struct wl_client *client, - struct wl_resource *resource, - int32_t orientation); - - static void set_window_flags(struct wl_client *client, - struct wl_resource *resource, - int32_t flags); - void setWindowFlags(WaylandSurface::WindowFlags flags); - - static const struct wl_extended_surface_interface extended_surface_interface; -}; - -} - -#endif // WLEXTENDEDSURFACE_H diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp deleted file mode 100644 index 6b8f36409..000000000 --- a/src/compositor/wayland_wrapper/wlinputdevice.cpp +++ /dev/null @@ -1,646 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlinputdevice.h" - -#include "wlcompositor.h" -#include "wldatadevice.h" -#include "wlsurface.h" -#include "wltouch.h" -#include "wlqtkey.h" -#include "waylandcompositor.h" - -#include - -#ifndef QT_NO_WAYLAND_XKB -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -namespace Wayland { - -InputDevice::InputDevice(WaylandInputDevice *handle, Compositor *compositor) - : m_handle(handle) - , m_compositor(compositor) -{ - wl_seat_init(base()); - initDevices(); - wl_display_add_global(compositor->wl_display(), - &wl_seat_interface, - this, - InputDevice::bind_func); - -#ifndef QT_NO_WAYLAND_XKB - xkb_rule_names xkb_names; - xkb_context *context = xkb_context_new(xkb_context_flags(0)); - - memset(&xkb_names, 0, sizeof(xkb_names)); - xkb_names.rules = strdup("evdev"); - xkb_names.model = strdup("pc105"); - xkb_names.layout = strdup("us"); - - xkb_keymap *keymap = xkb_map_new_from_names(context, &xkb_names, xkb_map_compile_flags(0)); - if (!keymap) - qFatal("Failed to compile global XKB keymap"); - - char *keymap_str_data = xkb_map_get_as_string(keymap); - QByteArray keymap_str = keymap_str_data; - m_keymap_size = keymap_str.size() + 1; - free(keymap_str_data); - - const char *path = getenv("XDG_RUNTIME_DIR"); - if (!path) - qFatal("XDG_RUNTIME_DIR not set"); - - QByteArray name = QByteArray(path) + "/qtwayland-xkb-map-XXXXXX"; - - int fd = mkstemp(name.data()); - if (fd >= 0) { - long flags = fcntl(fd, F_GETFD); - if (flags == -1 || fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) { - close(fd); - qFatal("Failed to set FD_CLOEXEC on anonymous file"); - } - unlink(name.data()); - } else { - qFatal("Failed to create anonymous file with name %s", name.constData()); - } - - if (ftruncate(fd, m_keymap_size) < 0) - qFatal("Failed to create anonymous file of size %lu", (unsigned long)m_keymap_size); - - m_keymap_fd = fd; - - m_keymap_area = (char *)mmap(0, m_keymap_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_keymap_fd, 0); - if (m_keymap_area == MAP_FAILED) { - close(m_keymap_fd); - qFatal("Failed to map shared memory segment"); - } - - strcpy(m_keymap_area, keymap_str.constData()); - - m_state = xkb_state_new(keymap); - - free((char *)xkb_names.rules); - free((char *)xkb_names.model); - free((char *)xkb_names.layout); - xkb_map_unref(keymap); - xkb_context_unref(context); -#endif -} - -InputDevice::~InputDevice() -{ - qDeleteAll(m_data_devices); - releaseDevices(); - -#ifndef QT_NO_WAYLAND_XKB - if (m_keymap_area) - munmap(m_keymap_area, m_keymap_size); - close(m_keymap_fd); - xkb_state_unref(m_state); -#endif -} - -void InputDevice::initDevices() -{ - wl_pointer_init(&m_device_interfaces.pointer); - wl_seat_set_pointer(base(), &m_device_interfaces.pointer); - - wl_keyboard_init(&m_device_interfaces.keyboard); - wl_seat_set_keyboard(base(), &m_device_interfaces.keyboard); - - wl_touch_init(&m_device_interfaces.touch); - wl_seat_set_touch(base(), &m_device_interfaces.touch); -} - -void InputDevice::releaseDevices() -{ - wl_pointer_release(&m_device_interfaces.pointer); - wl_keyboard_release(&m_device_interfaces.keyboard); - wl_touch_release(&m_device_interfaces.touch); -} - -wl_pointer *InputDevice::pointerDevice() -{ - return &m_device_interfaces.pointer; -} - -wl_keyboard *InputDevice::keyboardDevice() -{ - return &m_device_interfaces.keyboard; -} - -wl_touch *InputDevice::touchDevice() -{ - return &m_device_interfaces.touch; -} - -const wl_pointer *InputDevice::pointerDevice() const -{ - return &m_device_interfaces.pointer; -} - -const wl_keyboard *InputDevice::keyboardDevice() const -{ - return &m_device_interfaces.keyboard; -} - -const wl_touch *InputDevice::touchDevice() const -{ - return &m_device_interfaces.touch; -} - -void InputDevice::destroy_resource(wl_resource *resource) -{ - InputDevice *input_device = static_cast(resource->data); - if (input_device->keyboardDevice()->focus_resource == resource) { - input_device->keyboardDevice()->focus_resource = 0; - } - if (input_device->pointerDevice()->focus_resource == resource) { - input_device->pointerDevice()->focus_resource = 0; - } - - input_device->cleanupDataDeviceForClient(resource->client, true); - - wl_list_remove(&resource->link); - - free(resource); -} - -void InputDevice::bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - struct wl_resource *resource = wl_client_add_object(client, - &wl_seat_interface, - &seat_interface, - id, - data); - - struct wl_seat *seat = static_cast(data); - resource->destroy = destroy_resource; - wl_list_insert(&seat->base_resource_list, &resource->link); - - uint32_t caps = WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_KEYBOARD; - if (!QTouchDevice::devices().isEmpty()) - caps |= WL_SEAT_CAPABILITY_TOUCH; - - wl_seat_send_capabilities(resource, caps); -} - -const struct wl_pointer_interface InputDevice::pointer_interface = { - InputDevice::set_cursor -}; - -void InputDevice::set_cursor(wl_client *client, wl_resource *resource, - uint32_t serial, wl_resource *surface_resource, - int32_t hotspot_x, int32_t hotspot_y) -{ - Q_UNUSED(client); - Q_UNUSED(serial); - - wl_pointer *pointer = reinterpret_cast(resource->data); - InputDevice *inputDevice = wayland_cast(pointer->seat); - Wayland::Surface *surface = reinterpret_cast(surface_resource->data); - - surface->setCursorSurface(true); - inputDevice->m_compositor->waylandCompositor()->setCursorSurface(surface->waylandSurface(), hotspot_x, hotspot_y); -} - -const struct wl_seat_interface InputDevice::seat_interface = { - get_pointer, - get_keyboard, - get_touch -}; - -void InputDevice::destroy_device_resource(wl_resource *resource) -{ - wl_list_remove(&resource->link); - free(resource); -} - -void InputDevice::get_pointer(struct wl_client *client, - struct wl_resource *resource, - uint32_t id) -{ - InputDevice *inputDevice = static_cast(resource->data); - wl_pointer *pointer = inputDevice->pointerDevice(); - wl_resource *clientResource = wl_client_add_object(client, - &wl_pointer_interface, - &pointer_interface, - id, - pointer); - wl_list_insert(&pointer->resource_list, &clientResource->link); - clientResource->destroy = InputDevice::destroy_device_resource; -} - -void InputDevice::get_keyboard(struct wl_client *client, - struct wl_resource *resource, - uint32_t id) -{ - InputDevice *inputDevice = static_cast(resource->data); - wl_keyboard *keyboard = inputDevice->keyboardDevice(); - wl_resource *clientResource = wl_client_add_object(client, - &wl_keyboard_interface, - 0, - id, - keyboard); - wl_list_insert(&keyboard->resource_list, &clientResource->link); - clientResource->destroy = InputDevice::destroy_device_resource; - -#ifndef QT_NO_WAYLAND_XKB - wl_keyboard_send_keymap(clientResource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, - inputDevice->m_keymap_fd, inputDevice->m_keymap_size); -#endif -} - -void InputDevice::get_touch(struct wl_client *client, - struct wl_resource *resource, - uint32_t id) -{ - InputDevice *inputDevice = static_cast(resource->data); - wl_touch *touch = inputDevice->touchDevice(); - wl_resource *clientResource = wl_client_add_object(client, - &wl_touch_interface, - 0, - id, - touch); - wl_list_insert(&touch->resource_list, &clientResource->link); - clientResource->destroy = InputDevice::destroy_device_resource; -} - -void InputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) -{ - sendMouseMoveEvent(localPos,globalPos); - wl_pointer *pointer = pointerDevice(); - pointer->button_count++; - uint32_t time = m_compositor->currentTimeMsecs(); - const struct wl_pointer_grab_interface *interface = pointer->grab->interface; - interface->button(pointer->grab, time, toWaylandButton(button), 1); -} - -void InputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos) -{ - sendMouseMoveEvent(localPos,globalPos); - wl_pointer *pointer = pointerDevice(); - pointer->button_count--; - uint32_t time = m_compositor->currentTimeMsecs(); - const struct wl_pointer_grab_interface *interface = pointer->grab->interface; - interface->button(pointer->grab, time, toWaylandButton(button), 0); -} - -void InputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos) -{ - Q_UNUSED(globalPos); - uint32_t time = m_compositor->currentTimeMsecs(); - wl_pointer *pointer = pointerDevice(); - const struct wl_pointer_grab_interface *interface = pointer->grab->interface; - pointer->x = wl_fixed_from_double(globalPos.x()); - pointer->y = wl_fixed_from_double(globalPos.y()); - interface->motion(pointer->grab, - time, - wl_fixed_from_double(localPos.x()), wl_fixed_from_double(localPos.y())); -} - -void InputDevice::sendMouseMoveEvent(Surface *surface, const QPointF &localPos, const QPointF &globalPos) -{ - setMouseFocus(surface,localPos,globalPos); - sendMouseMoveEvent(localPos,globalPos); -} - -void InputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta) -{ - wl_pointer *pointer = pointerDevice(); - struct wl_resource *resource = pointer->focus_resource; - if (!resource) - return; - uint32_t time = m_compositor->currentTimeMsecs(); - uint32_t axis = orientation == Qt::Horizontal ? WL_POINTER_AXIS_HORIZONTAL_SCROLL - : WL_POINTER_AXIS_VERTICAL_SCROLL; - wl_pointer_send_axis(resource, time, axis, wl_fixed_from_int(-delta / 12)); -} - -void InputDevice::updateModifierState(uint code, int state) -{ -#ifndef QT_NO_WAYLAND_XKB - xkb_state_update_key(m_state, code, state ? XKB_KEY_DOWN : XKB_KEY_UP); - - uint32_t mods_depressed = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_DEPRESSED); - uint32_t mods_latched = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_LATCHED); - uint32_t mods_locked = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_LATCHED); - uint32_t group = xkb_state_serialize_group(m_state, (xkb_state_component)XKB_STATE_EFFECTIVE); - - wl_keyboard *keyboard = keyboardDevice(); - - if (mods_depressed == keyboard->modifiers.mods_depressed - && mods_latched == keyboard->modifiers.mods_latched - && mods_locked == keyboard->modifiers.mods_locked - && group == keyboard->modifiers.group) - { - return; // no change - } - - keyboard->modifiers.mods_depressed = mods_depressed; - keyboard->modifiers.mods_latched = mods_latched; - keyboard->modifiers.mods_locked = mods_locked; - keyboard->modifiers.group = group; - - if (keyboard->focus_resource) - sendKeyModifiers(keyboard->focus_resource); -#else - Q_UNUSED(code); - Q_UNUSED(state); -#endif -} - -void InputDevice::sendKeyModifiers(wl_resource *resource) -{ - wl_keyboard *keyboard = keyboardDevice(); - uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); - wl_keyboard_send_modifiers(resource, serial, keyboard->modifiers.mods_depressed, - keyboard->modifiers.mods_latched, keyboard->modifiers.mods_locked, keyboard->modifiers.group); -} - -void InputDevice::sendKeyPressEvent(uint code) -{ - wl_keyboard *keyboard = keyboardDevice(); - if (keyboard->focus_resource) { - uint32_t time = m_compositor->currentTimeMsecs(); - uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); - wl_keyboard_send_key(keyboard->focus_resource, - serial, time, code - 8, 1); - } - updateModifierState(code, 1); -} - -void InputDevice::sendKeyReleaseEvent(uint code) -{ - wl_keyboard *keyboard = keyboardDevice(); - if (keyboard->focus_resource) { - uint32_t time = m_compositor->currentTimeMsecs(); - uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); - wl_keyboard_send_key(keyboard->focus_resource, - serial, time, code - 8, 0); - } - updateModifierState(code, 0); -} - -void InputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state) -{ - uint32_t time = m_compositor->currentTimeMsecs(); - uint32_t serial = 0; - wl_touch *touch = touchDevice(); - wl_resource *resource = touch->focus_resource; - if (!resource) - return; - switch (state) { - case Qt::TouchPointPressed: - wl_touch_send_down(resource, serial, time, &touch->focus->resource, id, - wl_fixed_from_double(x), wl_fixed_from_double(y)); - break; - case Qt::TouchPointMoved: - wl_touch_send_motion(resource, time, id, - wl_fixed_from_double(x), wl_fixed_from_double(y)); - break; - case Qt::TouchPointReleased: - wl_touch_send_up(resource, serial, time, id); - break; - case Qt::TouchPointStationary: - // stationary points are not sent through wayland, the client must cache them - break; - default: - break; - } -} - -void InputDevice::sendTouchFrameEvent() -{ - wl_touch *touch = touchDevice(); - wl_resource *resource = touch->focus_resource; - if (resource) - wl_touch_send_frame(resource); -} - -void InputDevice::sendTouchCancelEvent() -{ - wl_touch *touch = touchDevice(); - wl_resource *resource = touch->focus_resource; - if (resource) - wl_touch_send_cancel(resource); -} - -void InputDevice::sendFullKeyEvent(QKeyEvent *event) -{ - if (!keyboardFocus()) { - qWarning("Cannot send key event, no keyboard focus, fix the compositor"); - return; - } - - QtKeyExtensionGlobal *ext = m_compositor->qtkeyExtension(); - if (ext && ext->postQtKeyEvent(event, keyboardFocus())) - return; - - if (event->type() == QEvent::KeyPress) - sendKeyPressEvent(event->nativeScanCode()); - else if (event->type() == QEvent::KeyRelease) - sendKeyReleaseEvent(event->nativeScanCode()); -} - -void InputDevice::sendFullTouchEvent(QTouchEvent *event) -{ - if (!mouseFocus()) { - qWarning("Cannot send touch event, no pointer focus, fix the compositor"); - return; - } - - if (event->type() == QEvent::TouchCancel) { - sendTouchCancelEvent(); - return; - } - - TouchExtensionGlobal *ext = m_compositor->touchExtension(); - if (ext && ext->postTouchEvent(event, mouseFocus())) - return; - - const QList points = event->touchPoints(); - if (points.isEmpty()) - return; - - const int pointCount = points.count(); - QPointF pos = mouseFocus()->pos(); - for (int i = 0; i < pointCount; ++i) { - const QTouchEvent::TouchPoint &tp(points.at(i)); - // Convert the local pos in the compositor window to surface-relative. - QPointF p = tp.pos() - pos; - sendTouchPointEvent(tp.id(), p.x(), p.y(), tp.state()); - } - sendTouchFrameEvent(); -} - -Surface *InputDevice::keyboardFocus() const -{ - return wayland_cast(keyboardDevice()->focus); -} - -/*! - * \return True if the keyboard focus is changed successfully. False for inactive transient surfaces. - */ -bool InputDevice::setKeyboardFocus(Surface *surface) -{ - if (surface && surface->transientInactive()) - return false; - - sendSelectionFocus(surface); - wl_keyboard_set_focus(keyboardDevice(), surface ? surface->base() : 0); - return true; -} - -Surface *InputDevice::mouseFocus() const -{ - return wayland_cast(pointerDevice()->focus); -} - -void InputDevice::setMouseFocus(Surface *surface, const QPointF &localPos, const QPointF &globalPos) -{ - wl_pointer *pointer = pointerDevice(); - pointer->x = wl_fixed_from_double(globalPos.x()); - pointer->y = wl_fixed_from_double(globalPos.y()); - pointer->current = surface ? surface->base() : 0; - pointer->current_x = wl_fixed_from_double(localPos.x()); - pointer->current_y = wl_fixed_from_double(localPos.y()); - pointer->grab->interface->focus(pointer->grab, - surface ? surface->base() : 0, - wl_fixed_from_double(localPos.x()), wl_fixed_from_double(localPos.y())); - - // We have no separate touch focus management so make it match the pointer focus always. - // No wl_touch_set_focus() is available so set it manually. - wl_touch *touch = touchDevice(); - touch->focus = surface ? surface->base() : 0; - touch->focus_resource = Compositor::resourceForSurface(&touch->resource_list, surface); -} - -void InputDevice::cleanupDataDeviceForClient(struct wl_client *client, bool destroyDev) -{ - for (int i = 0; i < m_data_devices.size(); i++) { - struct wl_resource *data_device_resource = - m_data_devices.at(i)->dataDeviceResource(); - if (data_device_resource->client == client) { - if (destroyDev) - delete m_data_devices.at(i); - m_data_devices.removeAt(i); - break; - } - } -} - -void InputDevice::clientRequestedDataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id) -{ - cleanupDataDeviceForClient(client, false); - DataDevice *dataDevice = new DataDevice(data_device_manager,client,id); - m_data_devices.append(dataDevice); -} - -void InputDevice::sendSelectionFocus(Surface *surface) -{ - if (!surface) - return; - DataDevice *device = dataDevice(surface->base()->resource.client); - if (device) { - device->sendSelectionFocus(); - } -} - -Compositor *InputDevice::compositor() const -{ - return m_compositor; -} - -WaylandInputDevice *InputDevice::handle() const -{ - return m_handle; -} - -uint32_t InputDevice::toWaylandButton(Qt::MouseButton button) -{ -#ifndef BTN_LEFT - uint32_t BTN_LEFT = 0x110; -#endif - // the range of valid buttons (evdev module) is from 0x110 - // through 0x11f. 0x120 is the first 'Joystick' button. - switch (button) { - case Qt::LeftButton: return BTN_LEFT; - case Qt::RightButton: return uint32_t(0x111); - case Qt::MiddleButton: return uint32_t(0x112); - case Qt::ExtraButton1: return uint32_t(0x113); // AKA Qt::BackButton, Qt::XButton1 - case Qt::ExtraButton2: return uint32_t(0x114); // AKA Qt::ForwardButton, Qt::XButton2 - case Qt::ExtraButton3: return uint32_t(0x115); - case Qt::ExtraButton4: return uint32_t(0x116); - case Qt::ExtraButton5: return uint32_t(0x117); - case Qt::ExtraButton6: return uint32_t(0x118); - case Qt::ExtraButton7: return uint32_t(0x119); - case Qt::ExtraButton8: return uint32_t(0x11a); - case Qt::ExtraButton9: return uint32_t(0x11b); - case Qt::ExtraButton10: return uint32_t(0x11c); - case Qt::ExtraButton11: return uint32_t(0x11d); - case Qt::ExtraButton12: return uint32_t(0x11e); - case Qt::ExtraButton13: return uint32_t(0x11f); - // default should not occur; but if it does, then return Wayland's highest possible button number. - default: return uint32_t(0x11f); - } -} - -DataDevice *InputDevice::dataDevice(struct wl_client *client) const -{ - for (int i = 0; i < m_data_devices.size();i++) { - if (m_data_devices.at(i)->dataDeviceResource()->client == client) { - return m_data_devices.at(i); - } - } - return 0; -} - -} diff --git a/src/compositor/wayland_wrapper/wlinputdevice.h b/src/compositor/wayland_wrapper/wlinputdevice.h deleted file mode 100644 index afd7ff51d..000000000 --- a/src/compositor/wayland_wrapper/wlinputdevice.h +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLINPUTDEVICE_H -#define WLINPUTDEVICE_H - -#include "waylandobject.h" - -#include - -#include -#include - -#ifndef QT_NO_WAYLAND_XKB -#include -#endif - -class QKeyEvent; -class QTouchEvent; -class WaylandInputDevice; - -namespace Wayland { - -class Compositor; -class DataDevice; -class Surface; -class DataDeviceManager; - -class InputDevice : public Object -{ -public: - InputDevice(WaylandInputDevice *handle, Compositor *compositor); - ~InputDevice(); - - void sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF()); - void sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF()); - void sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos = QPointF()); - void sendMouseMoveEvent(Surface *surface, const QPointF &localPos, const QPointF &globalPos = QPointF()); - void sendMouseWheelEvent(Qt::Orientation orientation, int delta); - - void sendKeyPressEvent(uint code); - void sendKeyReleaseEvent(uint code); - - void sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state); - void sendTouchFrameEvent(); - void sendTouchCancelEvent(); - - void sendFullKeyEvent(QKeyEvent *event); - void sendFullTouchEvent(QTouchEvent *event); - - Surface *keyboardFocus() const; - bool setKeyboardFocus(Surface *surface); - - Surface *mouseFocus() const; - void setMouseFocus(Surface *surface, const QPointF &localPos, const QPointF &globalPos); - - void clientRequestedDataDevice(DataDeviceManager *dndSelection, struct wl_client *client, uint32_t id); - DataDevice *dataDevice(struct wl_client *client) const; - void sendSelectionFocus(Surface *surface); - - Compositor *compositor() const; - WaylandInputDevice *handle() const; - - wl_pointer *pointerDevice(); - wl_keyboard *keyboardDevice(); - wl_touch *touchDevice(); - const wl_pointer *pointerDevice() const; - const wl_keyboard *keyboardDevice() const; - const wl_touch *touchDevice() const; - -private: - void initDevices(); - void releaseDevices(); - void cleanupDataDeviceForClient(struct wl_client *client, bool destroyDev); - void updateModifierState(uint key, int state); - void sendKeyModifiers(wl_resource *resource); - - WaylandInputDevice *m_handle; - Compositor *m_compositor; - QList m_data_devices; - struct { - wl_pointer pointer; - wl_keyboard keyboard; - wl_touch touch; - } m_device_interfaces; - -#ifndef QT_NO_WAYLAND_XKB - struct xkb_keymap *m_keymap; - struct xkb_state *m_state; - int m_keymap_fd; - size_t m_keymap_size; - char *m_keymap_area; -#endif - - uint32_t toWaylandButton(Qt::MouseButton button); - - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - - static void set_cursor(struct wl_client *client, - struct wl_resource *device_base, - uint32_t serial, - struct wl_resource *surface, - int32_t hotspot_x, - int32_t hotspot_y); - const static struct wl_pointer_interface pointer_interface; - - static void get_pointer(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void get_keyboard(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void get_touch(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - const static struct wl_seat_interface seat_interface; - - static void destroy_resource(wl_resource *resource); - static void destroy_device_resource(wl_resource *resource); -}; - -} - -#endif // WLINPUTDEVICE_H diff --git a/src/compositor/wayland_wrapper/wloutput.cpp b/src/compositor/wayland_wrapper/wloutput.cpp deleted file mode 100644 index 33e86eee4..000000000 --- a/src/compositor/wayland_wrapper/wloutput.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wloutput.h" -#include "wlextendedoutput.h" -#include -#include -#include - -namespace Wayland { - -OutputGlobal::OutputGlobal() - : m_displayId(-1) - , m_numQueued(0) -{ - QScreen *screen = QGuiApplication::primaryScreen(); - m_geometry = QRect(QPoint(0, 0), screen->availableGeometry().size()); - m_refreshRate = qRound(screen->refreshRate()); -} - -OutputGlobal::~OutputGlobal() -{ - qDeleteAll(m_outputs); -} - -void OutputGlobal::setGeometry(const QRect &geometry) -{ - m_geometry = geometry; -} - -void OutputGlobal::setRefreshRate(int rate) -{ - m_refreshRate = rate; -} - -Output *OutputGlobal::outputForClient(wl_client *client) const -{ - return static_cast(resourceForClient(client)->data); -} - -void OutputGlobal::output_bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - OutputGlobal *output_global = static_cast(data); - - Output *output = new Output(output_global,client,version,id); - output_global->registerResource(output->handle()); - output_global->m_outputs.append(output); -} - - - -Output::Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id) - : m_output_global(outputGlobal) - , m_extended_output(0) -{ - Q_UNUSED(version); - m_output_resource = wl_client_add_object(client,&wl_output_interface,0,id,this); - wl_output_send_geometry(m_output_resource, 0, 0, - m_output_global->size().width(), m_output_global->size().height(),0,"","",0); - - wl_output_send_mode(m_output_resource, WL_OUTPUT_MODE_CURRENT|WL_OUTPUT_MODE_PREFERRED, - m_output_global->size().width(), m_output_global->size().height(), m_output_global->refreshRate()); - -} - -Output::~Output() -{ -} - -ExtendedOutput *Output::extendedOutput() const -{ - return m_extended_output; -} - -void Output::setExtendedOutput(ExtendedOutput *extendedOutput) -{ - m_extended_output = extendedOutput; -} - -wl_resource *Output::handle() const -{ - return m_output_resource; -} - -} // namespace Wayland diff --git a/src/compositor/wayland_wrapper/wloutput.h b/src/compositor/wayland_wrapper/wloutput.h deleted file mode 100644 index 8baf545f8..000000000 --- a/src/compositor/wayland_wrapper/wloutput.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WL_OUTPUT_H -#define WL_OUTPUT_H - -#include "waylandresourcecollection.h" - -#include -#include - -namespace Wayland { - -class Output; -class ExtendedOutput; - -class OutputGlobal : public ResourceCollection -{ -public: - OutputGlobal(); - ~OutputGlobal(); - - void setGeometry(const QRect &geometry); - QRect geometry() const { return m_geometry; } - - int x() const { return m_geometry.x(); } - int y() const { return m_geometry.y(); } - QSize size() const { return m_geometry.size(); } - - void setRefreshRate(int rate); - int refreshRate() const { return m_refreshRate; } - - Output *outputForClient(struct wl_client *client) const; - - static void output_bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); -private: - QRect m_geometry; - int m_refreshRate; - int m_displayId; - int m_numQueued; - QList m_outputs; -}; - - -class Output -{ -public: - Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id); - ~Output(); - - OutputGlobal *outputGlobal() const; - - ExtendedOutput *extendedOutput() const; - void setExtendedOutput(ExtendedOutput *extendedOutput); - - struct wl_resource *handle() const; -private: - struct wl_resource *m_output_resource; - OutputGlobal *m_output_global; - ExtendedOutput *m_extended_output; - -}; - -} - -#endif //WL_OUTPUT_H diff --git a/src/compositor/wayland_wrapper/wlqtkey.cpp b/src/compositor/wayland_wrapper/wlqtkey.cpp deleted file mode 100644 index a4948924b..000000000 --- a/src/compositor/wayland_wrapper/wlqtkey.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlqtkey.h" -#include "wlsurface.h" -#include -#include - -namespace Wayland { - -static void dummy(wl_client *, wl_resource *) -{ -} - -const struct wl_qtkey_extension_interface QtKeyExtensionGlobal::qtkey_interface = { - dummy -}; - -QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor) - : m_compositor(compositor) -{ - wl_display_add_global(compositor->wl_display(), - &wl_qtkey_extension_interface, - this, - QtKeyExtensionGlobal::bind_func); -} - -QtKeyExtensionGlobal::~QtKeyExtensionGlobal() -{ -} - -void QtKeyExtensionGlobal::destroy_resource(wl_resource *resource) -{ - QtKeyExtensionGlobal *self = static_cast(resource->data); - self->m_resources.removeOne(resource); - free(resource); -} - -void QtKeyExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_resource *resource = wl_client_add_object(client, &wl_qtkey_extension_interface, &qtkey_interface, id, data); - resource->destroy = destroy_resource; - QtKeyExtensionGlobal *self = static_cast(resource->data); - self->m_resources.append(resource); -} - -bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) -{ - wl_client *surfaceClient = surface->base()->resource.client; - uint32_t time = m_compositor->currentTimeMsecs(); - const int rescount = m_resources.count(); - - for (int res = 0; res < rescount; ++res) { - wl_resource *target = m_resources.at(res); - if (target->client != surfaceClient) - continue; - - QByteArray textUtf8 = event->text().toUtf8(); - - wl_qtkey_extension_send_qtkey(target, - time, event->type(), event->key(), event->modifiers(), - event->nativeScanCode(), - event->nativeVirtualKey(), - event->nativeModifiers(), - textUtf8.constData(), - event->isAutoRepeat(), - event->count()); - - return true; - } - - return false; -} - -} diff --git a/src/compositor/wayland_wrapper/wlqtkey.h b/src/compositor/wayland_wrapper/wlqtkey.h deleted file mode 100644 index d44e7c1bf..000000000 --- a/src/compositor/wayland_wrapper/wlqtkey.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLQTKEY_H -#define WLQTKEY_H - -#include "wlcompositor.h" -#include "wayland-qtkey-extension-server-protocol.h" -#include "wayland-util.h" - -class Compositor; -class Surface; -class QKeyEvent; - -namespace Wayland { - -class QtKeyExtensionGlobal -{ -public: - QtKeyExtensionGlobal(Compositor *compositor); - ~QtKeyExtensionGlobal(); - - bool postQtKeyEvent(QKeyEvent *event, Surface *surface); - -private: - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - - static void destroy_resource(wl_resource *resource); - - static const struct wl_qtkey_extension_interface qtkey_interface; - - Compositor *m_compositor; - QList m_resources; -}; - -} - -#endif // WLQTKEY_H diff --git a/src/compositor/wayland_wrapper/wlregion.cpp b/src/compositor/wayland_wrapper/wlregion.cpp deleted file mode 100644 index c4adcae49..000000000 --- a/src/compositor/wayland_wrapper/wlregion.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlregion.h" - -#include "wlcompositor.h" - -namespace Wayland { - -void destroy_region(struct wl_resource *resource) -{ - delete resolve(resource); -} - -Region::Region(struct wl_client *client, uint32_t id) -{ - addClientResource(client, base(), id, &wl_region_interface, - ®ion_interface, destroy_region); -} - -Region::~Region() -{ -} - -const struct wl_region_interface Region::region_interface = { - region_destroy, - region_add, - region_subtract -}; - -void Region::region_destroy(wl_client *client, wl_resource *region) -{ - Q_UNUSED(client); - wl_resource_destroy(region); -} - -void Region::region_add(wl_client *client, wl_resource *region, - int32_t x, int32_t y, int32_t w, int32_t h) -{ - Q_UNUSED(client); - resolve(region)->m_region += QRect(x, y, w, h); -} - -void Region::region_subtract(wl_client *client, wl_resource *region, - int32_t x, int32_t y, int32_t w, int32_t h) -{ - Q_UNUSED(client); - resolve(region)->m_region -= QRect(x, y, w, h); -} - -} - - diff --git a/src/compositor/wayland_wrapper/wlregion.h b/src/compositor/wayland_wrapper/wlregion.h deleted file mode 100644 index 80a48ab1f..000000000 --- a/src/compositor/wayland_wrapper/wlregion.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WL_REGION_H -#define WL_REGION_H - -#include "waylandexport.h" -#include "waylandobject.h" - -#include - -#include - -namespace Wayland { - -class Q_COMPOSITOR_EXPORT Region : public Object -{ -public: - Region(struct wl_client *client, uint32_t id); - ~Region(); - - uint id() const { return base()->object.id; } - - QRegion region() const { return m_region; } - - static const struct wl_region_interface region_interface; - -private: - Q_DISABLE_COPY(Region) - - QRegion m_region; - - static void region_destroy(wl_client *client, wl_resource *region); - static void region_add(wl_client *client, wl_resource *region, - int32_t x, int32_t y, int32_t w, int32_t h); - static void region_subtract(wl_client *client, wl_resource *region, - int32_t x, int32_t y, int32_t w, int32_t h); -}; - -} - -#endif // WL_REGION_H - diff --git a/src/compositor/wayland_wrapper/wlshellsurface.cpp b/src/compositor/wayland_wrapper/wlshellsurface.cpp deleted file mode 100644 index aed1ee64f..000000000 --- a/src/compositor/wayland_wrapper/wlshellsurface.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlshellsurface.h" - -#include "wlcompositor.h" -#include "wlsurface.h" -#include "wlinputdevice.h" -#include "wlsubsurface.h" - -#include -#include - -namespace Wayland { - -Shell::Shell() -{ -} - -void Shell::bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_client_add_object(client,&wl_shell_interface,&shell_interface,id,data); -} - -void Shell::get_shell_surface(struct wl_client *client, - struct wl_resource *shell_resource, - uint32_t id, - struct wl_resource *surface_super) -{ - Q_UNUSED(shell_resource); - Surface *surface = resolve(surface_super); - new ShellSurface(client,id,surface); -} - -const struct wl_shell_interface Shell::shell_interface = { - Shell::get_shell_surface -}; - -ShellSurface::ShellSurface(wl_client *client, uint32_t id, Surface *surface) - : m_surface(surface) - , m_resizeGrabber(0) - , m_moveGrabber(0) - , m_transientParent(0) - , m_xOffset(0) - , m_yOffset(0) -{ - m_shellSurface = wl_client_add_object(client,&wl_shell_surface_interface,&shell_surface_interface,id,this); - surface->setShellSurface(this); -} - -void ShellSurface::sendConfigure(uint32_t edges, int32_t width, int32_t height) -{ - wl_shell_surface_send_configure(m_shellSurface,edges,width,height); -} - -Surface *ShellSurface::surface() const -{ - return m_surface; -} - -void ShellSurface::adjustPosInResize() -{ - if (m_transientParent) - return; - if (!m_resizeGrabber || !(m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP_LEFT)) - return; - - int bottomLeftX = wl_fixed_to_int(m_resizeGrabber->base()->x) + m_resizeGrabber->width; - int bottomLeftY = wl_fixed_to_int(m_resizeGrabber->base()->y) + m_resizeGrabber->height; - qreal x = surface()->pos().x(); - qreal y = surface()->pos().y(); - if (m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP) - y = bottomLeftY - surface()->size().height(); - if (m_resizeGrabber->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT) - x = bottomLeftX - surface()->size().width(); - QPointF newPos(x,y); - surface()->setPos(newPos); -} - -QPointF ShellSurface::adjustedPosToTransientParent() const -{ - if (!m_transientParent || - (m_surface->subSurface() && m_surface->subSurface()->parent())) - return m_surface->nonAdjustedPos(); - - return m_transientParent->surface()->pos() + QPoint(m_xOffset,m_yOffset); -} - -void ShellSurface::resetResizeGrabber() -{ - m_resizeGrabber = 0; -} - -void ShellSurface::resetMoveGrabber() -{ - m_moveGrabber = 0; -} - -ShellSurface *ShellSurface::transientParent() const -{ - return m_transientParent; -} - -void ShellSurface::setOffset(const QPointF &offset) -{ - m_xOffset = offset.x(); - m_yOffset = offset.y(); -} - -void ShellSurface::move(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *input_device_super, - uint32_t time) -{ - Q_UNUSED(client); - Q_UNUSED(time); - ShellSurface *self = static_cast(shell_surface_resource->data); - InputDevice *input_device = static_cast(input_device_super->data); - if (self->m_resizeGrabber || self->m_moveGrabber) { - qDebug() << "invalid state"; - return; - } - - self->m_moveGrabber = new ShellSurfaceMoveGrabber(self); - wl_pointer *pointer = input_device->pointerDevice(); - self->m_moveGrabber->base()->x = pointer->x; - self->m_moveGrabber->base()->y = pointer->y; - self->m_moveGrabber->offset_x = wl_fixed_to_int(pointer->x) - self->surface()->pos().x(); - self->m_moveGrabber->offset_y = wl_fixed_to_int(pointer->y) - self->surface()->pos().y(); - - wl_pointer_start_grab(pointer, self->m_moveGrabber->base()); -} - -void ShellSurface::resize(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *input_device_super, - uint32_t time, - uint32_t edges) -{ - Q_UNUSED(shell_surface_resource); - Q_UNUSED(client); - Q_UNUSED(time); - Q_UNUSED(edges); - ShellSurface *self = static_cast(shell_surface_resource->data); - InputDevice *input_device = static_cast(input_device_super->data); - if (self->m_moveGrabber || self->m_resizeGrabber) { - qDebug() << "invalid state2"; - return; - } - self->m_resizeGrabber = new ShellSurfaceResizeGrabber(self); - wl_pointer *pointer = input_device->pointerDevice(); - self->m_resizeGrabber->base()->x = pointer->x; - self->m_resizeGrabber->base()->y = pointer->y; - self->m_resizeGrabber->resize_edges = wl_shell_surface_resize(edges); - self->m_resizeGrabber->width = self->surface()->size().width(); - self->m_resizeGrabber->height = self->surface()->size().height(); - - wl_pointer_start_grab(pointer, self->m_resizeGrabber->base()); -} - -void ShellSurface::set_toplevel(struct wl_client *client, - struct wl_resource *shell_surface_resource) -{ - Q_UNUSED(client); - ShellSurface *self = static_cast(shell_surface_resource->data); - self->m_transientParent = 0; - self->m_xOffset = 0; - self->m_yOffset = 0; - -} - -void ShellSurface::set_transient(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *parent_surface_resource, - int x, - int y, - uint32_t flags) -{ - - Q_UNUSED(client); - Q_UNUSED(flags); - ShellSurface *shell_surface = static_cast(shell_surface_resource->data); - Surface *parent_surface = static_cast(parent_surface_resource->data); - shell_surface->m_transientParent = parent_surface->shellSurface(); - shell_surface->m_xOffset = x; - shell_surface->m_yOffset = y; - if (flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE) - shell_surface->surface()->setTransientInactive(true); -} - -void ShellSurface::set_fullscreen(struct wl_client *client, - struct wl_resource *shell_surface_resource, - uint32_t method, - uint32_t framerate, - struct wl_resource *output) -{ - Q_UNUSED(client); - Q_UNUSED(shell_surface_resource); - Q_UNUSED(method); - Q_UNUSED(framerate); - Q_UNUSED(output); -} - -void ShellSurface::set_popup(wl_client *client, wl_resource *resource, wl_resource *input_device, uint32_t time, wl_resource *parent, int32_t x, int32_t y, uint32_t flags) -{ - Q_UNUSED(client); - Q_UNUSED(resource); - Q_UNUSED(input_device); - Q_UNUSED(time); - Q_UNUSED(parent); - Q_UNUSED(x); - Q_UNUSED(y); - Q_UNUSED(flags); -} - -void ShellSurface::set_maximized(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *output) -{ - Q_UNUSED(client); - Q_UNUSED(shell_surface_resource); - Q_UNUSED(output); -} - -void ShellSurface::pong(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - Q_UNUSED(client); - Q_UNUSED(resource); - Q_UNUSED(serial); -} - -void ShellSurface::set_title(struct wl_client *client, - struct wl_resource *resource, - const char *title) -{ - Q_UNUSED(client); - ShellSurface *self = static_cast(resource->data); - self->surface()->setTitle(QString::fromUtf8(title)); -} - -void ShellSurface::set_class(struct wl_client *client, - struct wl_resource *resource, - const char *class_) -{ - Q_UNUSED(client); - ShellSurface *self = static_cast(resource->data); - self->surface()->setClassName(QString::fromUtf8(class_)); -} - -const struct wl_shell_surface_interface ShellSurface::shell_surface_interface = { - ShellSurface::pong, - ShellSurface::move, - ShellSurface::resize, - ShellSurface::set_toplevel, - ShellSurface::set_transient, - ShellSurface::set_fullscreen, - ShellSurface::set_popup, - ShellSurface::set_maximized, - ShellSurface::set_title, - ShellSurface::set_class -}; - -Qt::MouseButton toQtButton(uint32_t button) -{ -#ifndef BTN_LEFT - static const uint32_t BTN_LEFT = 0x110; - static const uint32_t BTN_RIGHT = 0x111; - static const uint32_t BTN_MIDDLE = 0x112; -#endif - switch (button) { - case BTN_LEFT: - return Qt::LeftButton; - case BTN_RIGHT: - return Qt::RightButton; - case BTN_MIDDLE: - return Qt::MiddleButton; - default: - return Qt::NoButton; - } -} - -ShellSurfaceGrabber::ShellSurfaceGrabber(ShellSurface *shellSurface, const struct wl_pointer_grab_interface *interface) - : shell_surface(shellSurface) -{ - base()->interface = interface; - base()->focus = shell_surface->surface()->base(); -} - -ShellSurfaceGrabber::~ShellSurfaceGrabber() -{ -} - - -void ShellSurfaceGrabber::destroy(wl_listener *listener, wl_resource *resource, uint32_t time) -{ - Q_UNUSED(resource); - Q_UNUSED(time); - Q_UNUSED(listener); - //ShellSurfaceGrabber *shell_surface_grabber = container_of(listener, ShellSurfaceGrabber,surface_destroy_listener); - Q_ASSERT(false); //hasn't been enabled yet - //wl_input_device_end_grab(shell_surface_grabber->base()->input_device,Compositor::currentTimeMsecs()); -} - - -ShellSurfaceResizeGrabber::ShellSurfaceResizeGrabber(ShellSurface *shellSurface) - : ShellSurfaceGrabber(shellSurface,&resize_grabber_interface) -{ -} - -void ShellSurfaceResizeGrabber::focus(wl_pointer_grab *grab, wl_surface *surface, int32_t x, int32_t y) -{ - Q_UNUSED(grab); - Q_UNUSED(surface); - Q_UNUSED(x); - Q_UNUSED(y); -} - -void ShellSurfaceResizeGrabber::motion(wl_pointer_grab *grab, uint32_t time, int32_t x, int32_t y) -{ - Q_UNUSED(time); - Q_UNUSED(x); - Q_UNUSED(y); - //Should be more structured - ShellSurfaceResizeGrabber *resize_grabber = reinterpret_cast(grab); - ShellSurface *shell_surface = resize_grabber->shell_surface; - wl_pointer *pointer = grab->pointer; - int width_delta = wl_fixed_to_int(grab->x) - wl_fixed_to_int(pointer->x); - int height_delta = wl_fixed_to_int(grab->y) - wl_fixed_to_int(pointer->y); - int new_width = resize_grabber->width; - int new_height = resize_grabber->height; - if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP_LEFT) { - if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP) { - if (new_height + height_delta > 0) { - new_height += height_delta; - } else { - new_height = 1; - } - } - if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT) { - if (new_width + width_delta > 0) { - new_width += width_delta; - } else { - new_width = 1; - } - } - } - - if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) { - if (new_height - height_delta > 0) { - new_height -= height_delta; - } else { - new_height = 1; - } - } - if (resize_grabber->resize_edges & WL_SHELL_SURFACE_RESIZE_RIGHT) { - if (new_width - width_delta > 0) { - new_width -= width_delta; - } else { - new_width =1; - } - } - - shell_surface->sendConfigure(resize_grabber->resize_edges,new_width,new_height); -} - -void ShellSurfaceResizeGrabber::button(wl_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state) -{ - Q_UNUSED(time) - ShellSurfaceResizeGrabber *self = reinterpret_cast(grab); - ShellSurface *shell_surface = self->shell_surface; - if (toQtButton(button) == Qt::LeftButton && !state) { - wl_pointer_end_grab(grab->pointer); - shell_surface->resetResizeGrabber(); - delete self; - } -} - -const struct wl_pointer_grab_interface ShellSurfaceResizeGrabber::resize_grabber_interface = { - ShellSurfaceResizeGrabber::focus, - ShellSurfaceResizeGrabber::motion, - ShellSurfaceResizeGrabber::button -}; - -ShellSurfaceMoveGrabber::ShellSurfaceMoveGrabber(ShellSurface *shellSurface) - : ShellSurfaceGrabber(shellSurface,&move_grabber_interface) -{ -} - -void ShellSurfaceMoveGrabber::focus(wl_pointer_grab *grab, wl_surface *surface, int32_t x, int32_t y) -{ - Q_UNUSED(grab); - Q_UNUSED(surface); - Q_UNUSED(x); - Q_UNUSED(y); -} - -void ShellSurfaceMoveGrabber::motion(wl_pointer_grab *grab, uint32_t time, int32_t x, int32_t y) -{ - Q_UNUSED(time); - Q_UNUSED(x); - Q_UNUSED(y); - ShellSurfaceMoveGrabber *shell_surface_grabber = reinterpret_cast(grab); - ShellSurface *shell_surface = shell_surface_grabber->shell_surface; - wl_pointer *pointer = grab->pointer; - QPointF pos(wl_fixed_to_int(pointer->x) - shell_surface_grabber->offset_x, - wl_fixed_to_int(pointer->y) - shell_surface_grabber->offset_y); - shell_surface->surface()->setPos(pos); - if (shell_surface->transientParent()) - shell_surface->setOffset(pos - shell_surface->transientParent()->surface()->pos()); - shell_surface->surface()->damage(QRect(QPoint(0,0),shell_surface->surface()->size())); -} - -void ShellSurfaceMoveGrabber::button(wl_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state) -{ - Q_UNUSED(time) - ShellSurfaceResizeGrabber *self = reinterpret_cast(grab); - ShellSurface *shell_surface = self->shell_surface; - if (toQtButton(button) == Qt::LeftButton && !state) { - wl_pointer_set_focus(grab->pointer, 0, 0, 0); - wl_pointer_end_grab(grab->pointer); - shell_surface->resetMoveGrabber(); - delete self; - } -} - -const struct wl_pointer_grab_interface ShellSurfaceMoveGrabber::move_grabber_interface = { - ShellSurfaceMoveGrabber::focus, - ShellSurfaceMoveGrabber::motion, - ShellSurfaceMoveGrabber::button -}; - -} diff --git a/src/compositor/wayland_wrapper/wlshellsurface.h b/src/compositor/wayland_wrapper/wlshellsurface.h deleted file mode 100644 index e3a4713f1..000000000 --- a/src/compositor/wayland_wrapper/wlshellsurface.h +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLSHELLSURFACE_H -#define WLSHELLSURFACE_H - -#include "waylandobject.h" - -#include -#include - -namespace Wayland { - -class Compositor; -class Surface; -class ShellSurface; -class ShellSurfaceResizeGrabber; -class ShellSurfaceMoveGrabber; - -class Shell -{ -public: - Shell(); - - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); -private: - static void get_shell_surface(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface); - static const struct wl_shell_interface shell_interface; - -}; - -class ShellSurface -{ -public: - ShellSurface(struct wl_client *client, uint32_t id, Surface *surface); - void sendConfigure(uint32_t edges, int32_t width, int32_t height); - - Surface *surface() const; - - void adjustPosInResize(); - QPointF adjustedPosToTransientParent() const; - void resetResizeGrabber(); - void resetMoveGrabber(); - - ShellSurface *transientParent() const; - void setOffset(const QPointF &offset); - -private: - struct wl_resource *m_shellSurface; - Surface *m_surface; - - ShellSurfaceResizeGrabber *m_resizeGrabber; - ShellSurfaceMoveGrabber *m_moveGrabber; - - ShellSurface *m_transientParent; - - int32_t m_xOffset; - int32_t m_yOffset; - - static void move(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *input_device_super, - uint32_t time); - static void resize(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *input_device, - uint32_t time, - uint32_t edges); - static void set_toplevel(struct wl_client *client, - struct wl_resource *shell_surface_resource); - static void set_transient(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *parent_surface_resource, - int x, - int y, - uint32_t flags); - static void set_fullscreen(struct wl_client *client, - struct wl_resource *shell_surface_resource, - uint32_t method, - uint32_t framerate, - struct wl_resource *output); - static void set_popup(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *input_device, - uint32_t time, - struct wl_resource *parent, - int32_t x, - int32_t y, - uint32_t flags); - static void set_maximized(struct wl_client *client, - struct wl_resource *shell_surface_resource, - struct wl_resource *output); - static void pong(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void set_title(struct wl_client *client, - struct wl_resource *resource, - const char *title); - static void set_class(struct wl_client *client, - struct wl_resource *resource, - const char *class_); - - static const struct wl_shell_surface_interface shell_surface_interface; -}; - -class ShellSurfaceGrabber : public Object -{ -public: - ShellSurfaceGrabber(ShellSurface *shellSurface, const struct wl_pointer_grab_interface *interface); - ~ShellSurfaceGrabber(); - - struct wl_listener surface_destroy_listener; - static void destroy(struct wl_listener *listener, - struct wl_resource *resource, uint32_t time); - - ShellSurface *shell_surface; -}; - -class ShellSurfaceResizeGrabber : public ShellSurfaceGrabber -{ -public: - ShellSurfaceResizeGrabber(ShellSurface *shellSurface); - - - enum wl_shell_surface_resize resize_edges; - int32_t width; - int32_t height; - - static void focus(struct wl_pointer_grab *grab, - struct wl_surface *surface, int32_t x, int32_t y); - static void motion(struct wl_pointer_grab *grab, - uint32_t time, int32_t x, int32_t y); - static void button(struct wl_pointer_grab *grab, - uint32_t time, uint32_t mouse_grabber_button, uint32_t state); - static const struct wl_pointer_grab_interface resize_grabber_interface; -}; - -class ShellSurfaceMoveGrabber : public ShellSurfaceGrabber -{ -public: - ShellSurfaceMoveGrabber(ShellSurface *shellSurface); - - int32_t offset_x; - int32_t offset_y; - - static void focus(struct wl_pointer_grab *grab, - struct wl_surface *surface, int32_t x, int32_t y); - static void motion(struct wl_pointer_grab *grab, - uint32_t time, int32_t x, int32_t y); - static void button(struct wl_pointer_grab *grab, - uint32_t time, uint32_t mouse_grabber_button, uint32_t state); - static const struct wl_pointer_grab_interface move_grabber_interface; -}; - - - -} - -#endif // WLSHELLSURFACE_H diff --git a/src/compositor/wayland_wrapper/wlsubsurface.cpp b/src/compositor/wayland_wrapper/wlsubsurface.cpp deleted file mode 100644 index c6013b65a..000000000 --- a/src/compositor/wayland_wrapper/wlsubsurface.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlsubsurface.h" - -#include "wlcompositor.h" -#include "waylandsurface.h" - -namespace Wayland { - -SubSurfaceExtensionGlobal::SubSurfaceExtensionGlobal(Compositor *compositor) - : m_compositor(compositor) -{ - wl_display_add_global(m_compositor->wl_display(), - &wl_sub_surface_extension_interface, - this, - SubSurfaceExtensionGlobal::bind_func); -} - -void SubSurfaceExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_client_add_object(client, &wl_sub_surface_extension_interface,&sub_surface_extension_interface,id,data); -} - -void SubSurfaceExtensionGlobal::get_sub_surface_aware_surface(wl_client *client, wl_resource *sub_surface_extension_resource, uint32_t id, wl_resource *surface_resource) -{ - Q_UNUSED(sub_surface_extension_resource); - Surface *surface = resolve(surface_resource); - new SubSurface(client,id,surface); -} - -const struct wl_sub_surface_extension_interface SubSurfaceExtensionGlobal::sub_surface_extension_interface = { - SubSurfaceExtensionGlobal::get_sub_surface_aware_surface -}; - -SubSurface::SubSurface(wl_client *client, uint32_t id, Surface *surface) - : m_surface(surface) - , m_parent(0) -{ - surface->setSubSurface(this); - m_sub_surface_resource = wl_client_add_object(client, - &wl_sub_surface_interface, - &sub_surface_interface, - id, - this); -} - -SubSurface::~SubSurface() -{ - if (m_parent) { - m_parent->removeSubSurface(this); - } - QLinkedList::iterator it; - for (it = m_sub_surfaces.begin(); it != m_sub_surfaces.end(); ++it) { - (*it)->handle()->subSurface()->parentDestroyed(); - } -} - -void SubSurface::setSubSurface(SubSurface *subSurface, int x, int y) -{ - if (!m_sub_surfaces.contains(subSurface->m_surface->waylandSurface())) { - m_sub_surfaces.append(subSurface->m_surface->waylandSurface()); - subSurface->setParent(this); - } - subSurface->m_surface->setPos(QPointF(x,y)); -} - -void SubSurface::removeSubSurface(SubSurface *subSurfaces) -{ - Q_ASSERT(m_sub_surfaces.contains(subSurfaces->m_surface->waylandSurface())); - m_sub_surfaces.removeOne(subSurfaces->m_surface->waylandSurface()); -} - -SubSurface *SubSurface::parent() const -{ - return m_parent; -} - -void SubSurface::setParent(SubSurface *parent) -{ - if (m_parent == parent) - return; - - WaylandSurface *oldParent = 0; - WaylandSurface *newParent = 0; - - if (m_parent) { - oldParent = m_parent->m_surface->waylandSurface(); - m_parent->removeSubSurface(this); - } - if (parent) { - newParent = parent->m_surface->waylandSurface(); - } - m_parent = parent; - - m_surface->waylandSurface()->parentChanged(newParent,oldParent); -} - -QLinkedList SubSurface::subSurfaces() const -{ - return m_sub_surfaces; -} - -void SubSurface::parentDestroyed() -{ - m_parent = 0; -} -void SubSurface::attach_sub_surface(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource, int32_t x, int32_t y) -{ - Q_UNUSED(client); - SubSurface *parent_sub_surface = static_cast(sub_surface_parent_resource->data); - SubSurface *child_sub_surface = static_cast(sub_surface_child_resource->data); - parent_sub_surface->setSubSurface(child_sub_surface,x,y); -} - -void SubSurface::move_sub_surface(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource, int32_t x, int32_t y) -{ - Q_UNUSED(client); - Q_UNUSED(x); - Q_UNUSED(y); - SubSurface *parent_sub_surface = static_cast(sub_surface_parent_resource->data); - SubSurface *child_sub_surface = static_cast(sub_surface_child_resource->data); - Q_UNUSED(parent_sub_surface); - Q_UNUSED(child_sub_surface); -} - -void SubSurface::raise(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource) -{ - Q_UNUSED(client); - Q_UNUSED(sub_surface_parent_resource); - Q_UNUSED(sub_surface_child_resource); -} - -void SubSurface::lower(wl_client *client, wl_resource *sub_surface_parent_resource, wl_resource *sub_surface_child_resource) -{ - Q_UNUSED(client); - Q_UNUSED(sub_surface_parent_resource); - Q_UNUSED(sub_surface_child_resource); -} - -const struct wl_sub_surface_interface SubSurface::sub_surface_interface = { - SubSurface::attach_sub_surface, - SubSurface::move_sub_surface, - SubSurface::raise, - SubSurface::lower -}; - -} diff --git a/src/compositor/wayland_wrapper/wlsubsurface.h b/src/compositor/wayland_wrapper/wlsubsurface.h deleted file mode 100644 index 6c7ede04e..000000000 --- a/src/compositor/wayland_wrapper/wlsubsurface.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLSUBSURFACE_H -#define WLSUBSURFACE_H - -#include "wlsurface.h" - -#include "wayland-sub-surface-extension-server-protocol.h" - -#include - -class Compositor; -class WaylandSurface; - -namespace Wayland { - -class SubSurfaceExtensionGlobal -{ -public: - SubSurfaceExtensionGlobal(Compositor *compositor); - -private: - Compositor *m_compositor; - - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - static void get_sub_surface_aware_surface(struct wl_client *client, - struct wl_resource *sub_surface_extension_resource, - uint32_t id, - struct wl_resource *surface_resource); - - static const struct wl_sub_surface_extension_interface sub_surface_extension_interface; -}; - -class SubSurface -{ -public: - SubSurface(struct wl_client *client, uint32_t id, Surface *surface); - ~SubSurface(); - - void setSubSurface(SubSurface *subSurface, int x, int y); - void removeSubSurface(SubSurface *subSurfaces); - - SubSurface *parent() const; - void setParent(SubSurface *parent); - - QLinkedList subSurfaces() const; - - Surface *surface() const; - WaylandSurface *waylandSurface() const; - -private: - void parentDestroyed(); - struct wl_resource *m_sub_surface_resource; - Surface *m_surface; - - SubSurface *m_parent; - QLinkedList m_sub_surfaces; - - static void attach_sub_surface(struct wl_client *client, - struct wl_resource *sub_surface_parent_resource, - struct wl_resource *sub_surface_child_resource, - int32_t x, - int32_t y); - static void move_sub_surface(struct wl_client *client, - struct wl_resource *sub_surface_parent_resource, - struct wl_resource *sub_surface_child_resource, - int32_t x, - int32_t y); - static void raise(struct wl_client *client, - struct wl_resource *sub_surface_parent_resource, - struct wl_resource *sub_surface_child_resource); - static void lower(struct wl_client *client, - struct wl_resource *sub_surface_parent_resource, - struct wl_resource *sub_surface_child_resource); - static const struct wl_sub_surface_interface sub_surface_interface; -}; - -inline Surface *SubSurface::surface() const -{ - return m_surface; -} - -inline WaylandSurface *SubSurface::waylandSurface() const -{ - return m_surface->waylandSurface(); -} - - -} - -#endif // WLSUBSURFACE_H diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp deleted file mode 100644 index 6781f29b9..000000000 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlsurface.h" - -#include "waylandsurface.h" -#ifdef QT_COMPOSITOR_QUICK -#include "waylandsurfaceitem.h" -#endif - -#include "wlcompositor.h" -#include "wlinputdevice.h" -#include "wlextendedsurface.h" -#include "wlregion.h" -#include "wlsubsurface.h" -#include "wlsurfacebuffer.h" -#include "wlshellsurface.h" - -#include -#include - -#include - -#ifdef QT_COMPOSITOR_WAYLAND_GL -#include "hardware_integration/graphicshardwareintegration.h" -#include -#endif - -#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT -#include "waylandwindowmanagerintegration.h" -#endif - -namespace Wayland { - -void destroy_surface(struct wl_resource *resource) -{ - Surface *surface = resolve(resource); - surface->compositor()->surfaceDestroyed(surface); - delete surface; -} - -Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) - : m_compositor(compositor) - , m_waylandSurface(new WaylandSurface(this)) - , m_backBuffer(0) - , m_frontBuffer(0) - , m_surfaceMapped(false) - , m_extendedSurface(0) - , m_subSurface(0) - , m_shellSurface(0) - , m_transientInactive(false) - , m_isCursorSurface(false) -{ - wl_list_init(&m_frame_callback_list); - addClientResource(client, &base()->resource, id, &wl_surface_interface, - &Surface::surface_interface, destroy_surface); - for (int i = 0; i < buffer_pool_size; i++) { - m_bufferPool[i] = new SurfaceBuffer(this); - } -} - -Surface::~Surface() -{ - delete m_waylandSurface; - delete m_extendedSurface; - delete m_subSurface; - delete m_shellSurface; - - for (int i = 0; i < buffer_pool_size; i++) { - if (!m_bufferPool[i]->pageFlipperHasBuffer()) - delete m_bufferPool[i]; - } -} - -WaylandSurface::Type Surface::type() const -{ - SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer(); - if (surfaceBuffer && surfaceBuffer->waylandBufferHandle()) { - if (surfaceBuffer->isShmBuffer()) { - return WaylandSurface::Shm; - } else { - return WaylandSurface::Texture; - } - } - return WaylandSurface::Invalid; -} - -bool Surface::isYInverted() const -{ - bool ret = false; - static bool negateReturn = qgetenv("QT_COMPOSITOR_NEGATE_INVERTED_Y").toInt(); - GraphicsHardwareIntegration *graphicsHWIntegration = m_compositor->graphicsHWIntegration(); - -#ifdef QT_COMPOSITOR_WAYLAND_GL - SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); - if (!surfacebuffer) { - ret = false; - } else if (graphicsHWIntegration && surfacebuffer->waylandBufferHandle() && type() != WaylandSurface::Shm) { - ret = graphicsHWIntegration->isYInverted(surfacebuffer->waylandBufferHandle()); - } else -#endif - ret = true; - - return ret != negateReturn; -} - -bool Surface::visible() const -{ - - SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); - return surfacebuffer->waylandBufferHandle(); -} - -QPointF Surface::pos() const -{ - return m_shellSurface ? m_shellSurface->adjustedPosToTransientParent() : m_position; -} - -QPointF Surface::nonAdjustedPos() const -{ - return m_position; -} - -void Surface::setPos(const QPointF &pos) -{ - bool emitChange = pos != m_position; - m_position = pos; - if (emitChange) - m_waylandSurface->posChanged(); -} - -QSize Surface::size() const -{ - return m_size; -} - -void Surface::setSize(const QSize &size) -{ - if (size != m_size) { - m_opaqueRegion = QRegion(); - m_inputRegion = QRegion(QRect(QPoint(), size)); - m_size = size; - if (m_shellSurface) { - m_shellSurface->adjustPosInResize(); - } - m_waylandSurface->sizeChanged(); - } -} - -QRegion Surface::inputRegion() const -{ - return m_inputRegion; -} - -QRegion Surface::opaqueRegion() const -{ - return m_opaqueRegion; -} - -QImage Surface::image() const -{ - SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); - if (surfacebuffer && !surfacebuffer->isDestroyed() && type() == WaylandSurface::Shm) { - struct wl_buffer *buffer = surfacebuffer->waylandBufferHandle(); - int stride = wl_shm_buffer_get_stride(buffer); - uint format = wl_shm_buffer_get_format(buffer); - (void) format; - void *data = wl_shm_buffer_get_data(buffer); - const uchar *char_data = static_cast(data); - QImage img(char_data, buffer->width, buffer->height, stride, QImage::Format_ARGB32_Premultiplied); - return img; - } - return QImage(); -} - -#ifdef QT_COMPOSITOR_WAYLAND_GL -GLuint Surface::textureId(QOpenGLContext *context) const -{ - const SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); - - if (m_compositor->graphicsHWIntegration() && type() == WaylandSurface::Texture - && !surfacebuffer->textureCreated()) { - GraphicsHardwareIntegration *hwIntegration = m_compositor->graphicsHWIntegration(); - const_cast(surfacebuffer)->createTexture(hwIntegration,context); - } - return surfacebuffer->texture(); -} -#endif // QT_COMPOSITOR_WAYLAND_GL - -void Surface::sendFrameCallback() -{ - SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); - surfacebuffer->setDisplayed(); - if (m_backBuffer) { - if (m_frontBuffer) - m_frontBuffer->disown(); - m_frontBuffer = m_backBuffer; - } - - bool updateNeeded = advanceBufferQueue(); - - uint time = Compositor::currentTimeMsecs(); - struct wl_resource *frame_callback, *next; - wl_list_for_each_safe(frame_callback, next, &m_frame_callback_list, link) { - wl_callback_send_done(frame_callback, time); - wl_resource_destroy(frame_callback); - } - wl_list_init(&m_frame_callback_list); - - if (updateNeeded) - doUpdate(); -} - -void Surface::frameFinished() -{ - m_compositor->frameFinished(this); -} - -WaylandSurface * Surface::waylandSurface() const -{ - return m_waylandSurface; -} - -QPoint Surface::lastMousePos() const -{ - return m_lastLocalMousePos; -} - -void Surface::setExtendedSurface(ExtendedSurface *extendedSurface) -{ - m_extendedSurface = extendedSurface; - if (m_extendedSurface) - emit m_waylandSurface->extendedSurfaceReady(); -} - -ExtendedSurface *Surface::extendedSurface() const -{ - return m_extendedSurface; -} - -void Surface::setSubSurface(SubSurface *subSurface) -{ - m_subSurface = subSurface; -} - -SubSurface *Surface::subSurface() const -{ - return m_subSurface; -} - -void Surface::setShellSurface(ShellSurface *shellSurface) -{ - m_shellSurface = shellSurface; -} - -ShellSurface *Surface::shellSurface() const -{ - return m_shellSurface; -} - -Compositor *Surface::compositor() const -{ - return m_compositor; -} - -bool Surface::advanceBufferQueue() -{ - //has current buffer been displayed, - //do we have another buffer in the queue - //and does it have a valid damage rect - - if (m_bufferQueue.size()) { - int width = 0; - int height = 0; - if (m_backBuffer) { - width = m_backBuffer->width(); - height = m_backBuffer->height(); - } - - m_backBuffer = m_bufferQueue.takeFirst(); - while (m_backBuffer && m_backBuffer->isDestroyed()) { - m_backBuffer->disown(); - m_backBuffer = m_bufferQueue.size() ? m_bufferQueue.takeFirst() : 0; - } - - if (!m_backBuffer) - return false; //we have no new backbuffer; - - if (m_backBuffer->waylandBufferHandle()) { - width = m_backBuffer->width(); - height = m_backBuffer->height(); - } - setSize(QSize(width,height)); - - - if (m_backBuffer && (!m_subSurface || !m_subSurface->parent()) && !m_surfaceMapped) { - m_surfaceMapped = true; - emit m_waylandSurface->mapped(); - } else if (m_backBuffer && !m_backBuffer->waylandBufferHandle() && m_surfaceMapped) { - m_surfaceMapped = false; - emit m_waylandSurface->unmapped(); - } - - } else { - m_backBuffer = 0; - return false; - } - - return true; -} - -void Surface::doUpdate() { - if (postBuffer()) { -#ifdef QT_COMPOSITOR_QUICK - WaylandSurfaceItem *surfaceItem = waylandSurface()->surfaceItem(); - if (surfaceItem) - surfaceItem->setDamagedFlag(true); // avoid flicker when we switch back to composited mode -#endif - sendFrameCallback(); - } else { - SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer(); - if (surfaceBuffer) { - if (surfaceBuffer->damageRect().isValid()) { - m_compositor->markSurfaceAsDirty(this); - emit m_waylandSurface->damaged(surfaceBuffer->damageRect()); - } - } - } -} - -SurfaceBuffer *Surface::createSurfaceBuffer(struct wl_buffer *buffer) -{ - SurfaceBuffer *newBuffer = 0; - for (int i = 0; i < Surface::buffer_pool_size; i++) { - if (!m_bufferPool[i]->isRegisteredWithBuffer()) { - newBuffer = m_bufferPool[i]; - newBuffer->initialize(buffer); - break; - } - } - - Q_ASSERT(newBuffer); - return newBuffer; -} - -bool Surface::postBuffer() { -#ifdef QT_COMPOSITOR_WAYLAND_GL - if (m_waylandSurface->handle() == m_compositor->directRenderSurface()) { - SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer(); - if (surfaceBuffer && surfaceBuffer->waylandBufferHandle()) { - if (m_compositor->pageFlipper()) { - if (m_compositor->pageFlipper()->displayBuffer(surfaceBuffer)) { - surfaceBuffer->setPageFlipperHasBuffer(true); - m_compositor->setDirectRenderingActive(true); - return true; - } else { - qDebug() << "could not post buffer"; - } - } - } - } -#endif - return false; -} - -void Surface::commit() -{ - if (!m_bufferQueue.isEmpty() && !m_backBuffer) - advanceBufferQueue(); - - doUpdate(); -} - -void Surface::attach(struct wl_buffer *buffer) -{ - SurfaceBuffer *last = m_bufferQueue.size()?m_bufferQueue.last():0; - if (last) { - if (last->waylandBufferHandle() == buffer) - return; - if (!last->damageRect().isValid() || isCursorSurface() ){ - last->disown(); - m_bufferQueue.takeLast(); - } - } - - m_bufferQueue << createSurfaceBuffer(buffer); - - if (!buffer) { - InputDevice *inputDevice = m_compositor->defaultInputDevice(); - if (inputDevice->keyboardFocus() == this) - inputDevice->setKeyboardFocus(0); - if (inputDevice->mouseFocus() == this) - inputDevice->setMouseFocus(0, QPointF(), QPointF()); - } -} - -void Surface::damage(const QRect &rect) -{ - SurfaceBuffer *surfaceBuffer = m_bufferQueue.isEmpty() ? currentSurfaceBuffer() : m_bufferQueue.last(); - if (surfaceBuffer) - surfaceBuffer->setDamage(rect); - else - qWarning() << "Surface::damage() null buffer"; -} - -const struct wl_surface_interface Surface::surface_interface = { - Surface::surface_destroy, - Surface::surface_attach, - Surface::surface_damage, - Surface::surface_frame, - Surface::surface_set_opaque_region, - Surface::surface_set_input_region, - Surface::surface_commit -}; - -void Surface::surface_destroy(struct wl_client *, struct wl_resource *surface_resource) -{ - wl_resource_destroy(surface_resource); -} - -void Surface::surface_attach(struct wl_client *client, struct wl_resource *surface, - struct wl_resource *buffer, int x, int y) -{ - Q_UNUSED(client); - Q_UNUSED(x); - Q_UNUSED(y); - resolve(surface)->attach(buffer ? reinterpret_cast(buffer->data) : 0); -} - -void Surface::surface_damage(struct wl_client *client, struct wl_resource *surface, - int32_t x, int32_t y, int32_t width, int32_t height) -{ - Q_UNUSED(client); - resolve(surface)->damage(QRect(x, y, width, height)); -} - -void Surface::surface_frame(struct wl_client *client, - struct wl_resource *resource, - uint32_t callback) -{ - Surface *surface = resolve(resource); - struct wl_resource *frame_callback = wl_client_add_object(client,&wl_callback_interface,0,callback,surface); - wl_list_insert(&surface->m_frame_callback_list,&frame_callback->link); -} - -void Surface::surface_set_opaque_region(struct wl_client *client, struct wl_resource *surfaceResource, - struct wl_resource *region) -{ - Q_UNUSED(client); - Surface *surface = resolve(surfaceResource); - surface->m_opaqueRegion = region ? resolve(region)->region() : QRegion(); -} - -void Surface::surface_set_input_region(struct wl_client *client, struct wl_resource *surfaceResource, - struct wl_resource *region) -{ - Q_UNUSED(client); - Surface *surface = resolve(surfaceResource); - surface->m_inputRegion = region ? resolve(region)->region() : QRegion(QRect(QPoint(), surface->size())); -} - -void Surface::surface_commit(wl_client *client, wl_resource *resource) -{ - Q_UNUSED(client); - resolve(resource)->commit(); -} - -void Surface::setClassName(const QString &className) -{ - if (m_className != className) { - m_className = className; - emit waylandSurface()->classNameChanged(); - } -} - -void Surface::setTitle(const QString &title) -{ - if (m_title != title) { - m_title = title; - emit waylandSurface()->titleChanged(); - } -} - -} // namespace Wayland - diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h deleted file mode 100644 index 5c11c6bc4..000000000 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WL_SURFACE_H -#define WL_SURFACE_H - -#include "waylandexport.h" - -#include "wlsurfacebuffer.h" -#include "waylandsurface.h" - -#include "waylandobject.h" - -#include -#include - -#include -#include - -#ifdef QT_COMPOSITOR_WAYLAND_GL -#include -#include -#endif - -#include - -class QTouchEvent; - -namespace Wayland { - -class Compositor; -class Buffer; -class ExtendedSurface; -class SubSurface; -class ShellSurface; - -class Q_COMPOSITOR_EXPORT Surface : public Object -{ -public: - Surface(struct wl_client *client, uint32_t id, Compositor *compositor); - ~Surface(); - - WaylandSurface::Type type() const; - bool isYInverted() const; - - bool visible() const; - - uint id() const { return base()->resource.object.id; } - - QPointF pos() const; - QPointF nonAdjustedPos() const; - void setPos(const QPointF &pos); - - QSize size() const; - void setSize(const QSize &size); - - QRegion inputRegion() const; - QRegion opaqueRegion() const; - - QImage image() const; - -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint textureId(QOpenGLContext *context) const; -#endif - - void sendFrameCallback(); - - void frameFinished(); - - WaylandSurface *waylandSurface() const; - - QPoint lastMousePos() const; - - void setExtendedSurface(ExtendedSurface *extendedSurface); - ExtendedSurface *extendedSurface() const; - - void setSubSurface(SubSurface *subSurface); - SubSurface *subSurface() const; - - void setShellSurface(ShellSurface *shellSurface); - ShellSurface *shellSurface() const; - - Compositor *compositor() const; - - void damage(const QRect &rect); - - static const struct wl_surface_interface surface_interface; - - QString className() const { return m_className; } - void setClassName(const QString &className); - - QString title() const { return m_title; } - void setTitle(const QString &title); - - bool transientInactive() const { return m_transientInactive; } - void setTransientInactive(bool v) { m_transientInactive = v; } - - bool isCursorSurface() const { return m_isCursorSurface; } - void setCursorSurface(bool isCursor) { m_isCursorSurface = isCursor; } - -private: - Q_DISABLE_COPY(Surface) - - Compositor *m_compositor; - WaylandSurface *m_waylandSurface; - - SurfaceBuffer *m_backBuffer; - SurfaceBuffer *m_frontBuffer; - QList m_bufferQueue; - bool m_surfaceMapped; - - QPoint m_lastLocalMousePos; - QPoint m_lastGlobalMousePos; - - struct wl_list m_frame_callback_list; - - ExtendedSurface *m_extendedSurface; - SubSurface *m_subSurface; - ShellSurface *m_shellSurface; - - QRegion m_inputRegion; - QRegion m_opaqueRegion; - - static const int buffer_pool_size = 3; - SurfaceBuffer *m_bufferPool[buffer_pool_size]; - - QPointF m_position; - QSize m_size; - QString m_className; - QString m_title; - bool m_transientInactive; - bool m_isCursorSurface; - - inline SurfaceBuffer *currentSurfaceBuffer() const; - bool advanceBufferQueue(); - void doUpdate(); - SurfaceBuffer *createSurfaceBuffer(struct wl_buffer *buffer); - void frameFinishedInternal(); - bool postBuffer(); - void commit(); - - void attach(struct wl_buffer *buffer); - - static void surface_destroy(struct wl_client *client, struct wl_resource *_surface); - static void surface_attach(struct wl_client *client, struct wl_resource *surface, - struct wl_resource *buffer, int x, int y); - static void surface_damage(struct wl_client *client, struct wl_resource *_surface, - int32_t x, int32_t y, int32_t width, int32_t height); - static void surface_frame(struct wl_client *client, struct wl_resource *resource, - uint32_t callback); - static void surface_set_opaque_region(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *region); - static void surface_set_input_region(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *region); - static void surface_commit(struct wl_client *client, struct wl_resource *resource); - -}; - -inline SurfaceBuffer *Surface::currentSurfaceBuffer() const { - return m_backBuffer? m_backBuffer : m_frontBuffer; -} - -} - -#endif //WL_SURFACE_H diff --git a/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp deleted file mode 100644 index 6dd76532c..000000000 --- a/src/compositor/wayland_wrapper/wlsurfacebuffer.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wlsurfacebuffer.h" - -#include "wlsurface.h" -#include "wlcompositor.h" - -#ifdef QT_COMPOSITOR_WAYLAND_GL -#include "hardware_integration/graphicshardwareintegration.h" -#include -#endif - -#include - -namespace Wayland { - -SurfaceBuffer::SurfaceBuffer(Surface *surface) - : QPlatformScreenBuffer() - , m_surface(surface) - , m_compositor(surface->compositor()) - , m_buffer(0) - , m_is_registered_for_buffer(false) - , m_surface_has_buffer(false) - , m_page_flipper_has_buffer(false) - , m_is_displayed(false) - , m_texture(0) - , m_guard(0) - , m_is_shm_resolved(false) - , m_is_shm(false) -{ -} - -SurfaceBuffer::~SurfaceBuffer() -{ - if (m_is_registered_for_buffer) - destructBufferState(); -} - -void SurfaceBuffer::initialize(wl_buffer *buffer) -{ - m_buffer = buffer; - m_texture = 0; - m_guard = 0; - m_is_registered_for_buffer = true; - m_surface_has_buffer = true; - m_page_flipper_has_buffer = false; - m_is_displayed = false; - m_destroyed = false; - m_handle = 0; - m_is_shm_resolved = false; - m_is_shm = false; - m_destroy_listener.surfaceBuffer = this; - m_destroy_listener.listener.notify = destroy_listener_callback; - if (buffer) - wl_signal_add(&buffer->resource.destroy_signal, &m_destroy_listener.listener); - m_damageRect = QRect(); -} - -void SurfaceBuffer::destructBufferState() -{ - Q_ASSERT(!m_page_flipper_has_buffer); - - destroyTexture(); - - if (m_buffer) { - if (m_handle) { - if (m_is_shm) { - delete static_cast(m_handle); -#ifdef QT_COMPOSITOR_WAYLAND_GL - } else { - GraphicsHardwareIntegration *hwIntegration = m_compositor->graphicsHWIntegration(); - hwIntegration->unlockNativeBuffer(m_handle, m_compositor->directRenderContext()); -#endif - } - } - wl_list_remove(&m_destroy_listener.listener.link); - sendRelease(); - } - m_buffer = 0; - m_handle = 0; - m_is_registered_for_buffer = false; - m_is_displayed = false; -} - -bool SurfaceBuffer::isShmBuffer() const -{ - if (!m_is_shm_resolved) { - SurfaceBuffer *that = const_cast(this); - that->m_is_shm = wl_buffer_is_shm(m_buffer); - that->m_is_shm_resolved = true; - } - return m_is_shm; -} - -void SurfaceBuffer::sendRelease() -{ - Q_ASSERT(m_buffer); - wl_buffer_send_release(&m_buffer->resource); -} - -void SurfaceBuffer::setPageFlipperHasBuffer(bool owns) -{ - m_page_flipper_has_buffer = owns; -} - -void SurfaceBuffer::release() -{ - m_compositor->scheduleReleaseBuffer(this); -} - -void SurfaceBuffer::scheduledRelease() -{ - m_page_flipper_has_buffer = false; - if (!m_surface_has_buffer) - destructBufferState(); - if (!m_surface) { - delete this; - } -} - -void SurfaceBuffer::disown() -{ - m_surface_has_buffer = false; - - if (!m_page_flipper_has_buffer) { - destructBufferState(); - } -} - -void SurfaceBuffer::setDisplayed() -{ - m_is_displayed = true; - m_damageRect = QRect(); -} - -void SurfaceBuffer::setDamage(const QRect &rect) -{ - if (m_damageRect.isValid()) { - m_damageRect = m_damageRect.united(rect); - } - m_damageRect = rect; -} - -void SurfaceBuffer::destroyTexture() -{ -#ifdef QT_COMPOSITOR_WAYLAND_GL - if (m_texture) { - Q_ASSERT(m_guard); - m_guard->free(); - m_guard = 0; - m_texture = 0; - } -#endif -} - -void SurfaceBuffer::handleAboutToBeDisplayed() -{ - qDebug() << Q_FUNC_INFO; -} - -void SurfaceBuffer::handleDisplayed() -{ - qDebug() << Q_FUNC_INFO; -} - -void *SurfaceBuffer::handle() const -{ - if (!m_buffer) - return 0; - - if (!m_handle) { - SurfaceBuffer *that = const_cast(this); - if (isShmBuffer()) { - const uchar *data = static_cast(wl_shm_buffer_get_data(m_buffer)); - int stride = wl_shm_buffer_get_stride(m_buffer); - int width = m_buffer->width; - int height = m_buffer->height; - QImage *image = new QImage(data,width,height,stride, QImage::Format_ARGB32_Premultiplied); - that->m_handle = image; -#ifdef QT_COMPOSITOR_WAYLAND_GL - } else { - GraphicsHardwareIntegration *hwIntegration = m_compositor->graphicsHWIntegration(); - that->m_handle = hwIntegration->lockNativeBuffer(m_buffer, m_compositor->directRenderContext()); -#endif - } - } - return m_handle; -} - -void SurfaceBuffer::destroy_listener_callback(wl_listener *listener, void *data) -{ - Q_UNUSED(data); - struct surface_buffer_destroy_listener *destroy_listener = - reinterpret_cast(listener); - SurfaceBuffer *d = destroy_listener->surfaceBuffer; - d->destroyTexture(); - d->m_destroyed = true; - d->m_buffer = 0; -} - -void freeTexture(QOpenGLFunctions *, GLuint id) -{ - glDeleteTextures(1, &id); -} - -void SurfaceBuffer::createTexture(GraphicsHardwareIntegration *hwIntegration, QOpenGLContext *context) -{ -#ifdef QT_COMPOSITOR_WAYLAND_GL - m_texture = hwIntegration->createTextureFromBuffer(m_buffer, context); - m_guard = new QOpenGLSharedResourceGuard(QOpenGLContext::currentContext(), m_texture, freeTexture); -#else - Q_UNUSED(hwIntegration); - Q_UNUSED(context); -#endif -} - -} diff --git a/src/compositor/wayland_wrapper/wlsurfacebuffer.h b/src/compositor/wayland_wrapper/wlsurfacebuffer.h deleted file mode 100644 index 8efab29c8..000000000 --- a/src/compositor/wayland_wrapper/wlsurfacebuffer.h +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SURFACEBUFFER_H -#define SURFACEBUFFER_H - -#include -#include -#include -#include - -#include - -class GraphicsHardwareIntegration; -class QOpenGLContext; - -namespace Wayland { - -class Surface; -class Compositor; - -struct surface_buffer_destroy_listener -{ - struct wl_listener listener; - class SurfaceBuffer *surfaceBuffer; -}; - -class SurfaceBuffer : public QPlatformScreenBuffer -{ -public: - SurfaceBuffer(Surface *surface); - - ~SurfaceBuffer(); - - void initialize(struct wl_buffer *buffer); - void destructBufferState(); - - inline int32_t width() const { return m_buffer->width; } - inline int32_t height() const { return m_buffer->height; } - - bool isShmBuffer() const; - - inline bool isRegisteredWithBuffer() const { return m_is_registered_for_buffer; } - - void sendRelease(); - void setPageFlipperHasBuffer(bool owns); - bool pageFlipperHasBuffer() const { return m_page_flipper_has_buffer; } - void release(); - void scheduledRelease(); - void disown(); - - void setDisplayed(); - - inline bool isDisplayed() const { return m_is_displayed; } - - inline QRect damageRect() const { return m_damageRect; } - void setDamage(const QRect &rect); - - inline bool textureCreated() const { return m_texture; } - - void createTexture(GraphicsHardwareIntegration *hwIntegration, QOpenGLContext *context); - inline GLuint texture() const; - void destroyTexture(); - - inline struct wl_buffer *waylandBufferHandle() const { return m_buffer; } - - void handleAboutToBeDisplayed(); - void handleDisplayed(); - - void *handle() const; -private: - Surface *m_surface; - Compositor *m_compositor; - struct wl_buffer *m_buffer; - struct surface_buffer_destroy_listener m_destroy_listener; - QRect m_damageRect; - bool m_is_registered_for_buffer; - bool m_surface_has_buffer; - bool m_page_flipper_has_buffer; - - bool m_is_displayed; -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint m_texture; - QOpenGLSharedResourceGuard *m_guard; -#else - uint m_texture; - uint m_guard; -#endif - void *m_handle; - bool m_is_shm_resolved; - bool m_is_shm; - - static void destroy_listener_callback(wl_listener *listener, void *data); -}; - -GLuint SurfaceBuffer::texture() const -{ - if (m_buffer) - return m_texture; - return 0; -} - -} - -#endif // SURFACEBUFFER_H diff --git a/src/compositor/wayland_wrapper/wltouch.cpp b/src/compositor/wayland_wrapper/wltouch.cpp deleted file mode 100644 index 67efc110e..000000000 --- a/src/compositor/wayland_wrapper/wltouch.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "wltouch.h" -#include "wlsurface.h" -#include -#include - -namespace Wayland { - -static void dummy(wl_client *, wl_resource *) -{ -} - -const struct wl_touch_extension_interface TouchExtensionGlobal::touch_interface = { - dummy -}; - -static const int maxRawPos = 24; - -TouchExtensionGlobal::TouchExtensionGlobal(Compositor *compositor) - : m_compositor(compositor), - m_flags(0) -{ - wl_array_init(&m_rawdata_array); - m_rawdata_ptr = static_cast(wl_array_add(&m_rawdata_array, maxRawPos * sizeof(float) * 2)); - - wl_display_add_global(compositor->wl_display(), - &wl_touch_extension_interface, - this, - TouchExtensionGlobal::bind_func); -} - -TouchExtensionGlobal::~TouchExtensionGlobal() -{ - wl_array_release(&m_rawdata_array); -} - -void TouchExtensionGlobal::destroy_resource(wl_resource *resource) -{ - TouchExtensionGlobal *self = static_cast(resource->data); - self->m_resources.removeOne(resource); - free(resource); -} - -void TouchExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - wl_resource *resource = wl_client_add_object(client, &wl_touch_extension_interface, &touch_interface, id, data); - resource->destroy = destroy_resource; - TouchExtensionGlobal *self = static_cast(resource->data); - self->m_resources.append(resource); - wl_touch_extension_send_configure(resource, self->m_flags); -} - -static inline int toFixed(qreal f) -{ - return int(f * 10000); -} - -bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, Surface *surface) -{ - const QList points = event->touchPoints(); - const int pointCount = points.count(); - if (!pointCount) - return false; - - QPointF surfacePos = surface->pos(); - wl_client *surfaceClient = surface->base()->resource.client; - uint32_t time = m_compositor->currentTimeMsecs(); - const int rescount = m_resources.count(); - - for (int res = 0; res < rescount; ++res) { - wl_resource *target = m_resources.at(res); - if (target->client != surfaceClient) - continue; - - // We will use no touch_frame type of event, to reduce the number of - // events flowing through the wire. Instead, the number of points sent is - // included in the touch point events. - int sentPointCount = 0; - for (int i = 0; i < pointCount; ++i) { - if (points.at(i).state() != Qt::TouchPointStationary) - ++sentPointCount; - } - - for (int i = 0; i < pointCount; ++i) { - const QTouchEvent::TouchPoint &tp(points.at(i)); - // Stationary points are never sent. They are cached on client side. - if (tp.state() == Qt::TouchPointStationary) - continue; - - uint32_t id = tp.id(); - uint32_t state = (tp.state() & 0xFFFF) | (sentPointCount << 16); - uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->device()->capabilities()) << 16); - - QPointF p = tp.pos() - surfacePos; // surface-relative - int x = toFixed(p.x()); - int y = toFixed(p.y()); - int nx = toFixed(tp.normalizedPos().x()); - int ny = toFixed(tp.normalizedPos().y()); - int w = toFixed(tp.rect().width()); - int h = toFixed(tp.rect().height()); - int vx = toFixed(tp.velocity().x()); - int vy = toFixed(tp.velocity().y()); - uint32_t pressure = uint32_t(tp.pressure() * 255); - - wl_array *rawData = 0; - QVector rawPosList = tp.rawScreenPositions(); - int rawPosCount = rawPosList.count(); - if (rawPosCount) { - rawPosCount = qMin(maxRawPos, rawPosCount); - rawData = &m_rawdata_array; - rawData->size = rawPosCount * sizeof(float) * 2; - float *p = m_rawdata_ptr; - for (int rpi = 0; rpi < rawPosCount; ++rpi) { - const QPointF &rawPos(rawPosList.at(rpi)); - // This will stay in screen coordinates for performance - // reasons, clients using this data will presumably know - // what they are doing. - *p++ = float(rawPos.x()); - *p++ = float(rawPos.y()); - } - } - - wl_touch_extension_send_touch(target, - time, id, state, - x, y, nx, ny, w, h, - pressure, vx, vy, - flags, rawData); - } - - return true; - } - - return false; -} - -} diff --git a/src/compositor/wayland_wrapper/wltouch.h b/src/compositor/wayland_wrapper/wltouch.h deleted file mode 100644 index 8a4eba008..000000000 --- a/src/compositor/wayland_wrapper/wltouch.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WLTOUCH_H -#define WLTOUCH_H - -#include "wlcompositor.h" -#include "wayland-touch-extension-server-protocol.h" -#include "wayland-util.h" - -class Compositor; -class Surface; -class QTouchEvent; - -namespace Wayland { - -class TouchExtensionGlobal -{ -public: - TouchExtensionGlobal(Compositor *compositor); - ~TouchExtensionGlobal(); - - bool postTouchEvent(QTouchEvent *event, Surface *surface); - - void setFlags(int flags) { m_flags = flags; } - -private: - static void bind_func(struct wl_client *client, void *data, - uint32_t version, uint32_t id); - - static void destroy_resource(wl_resource *resource); - - static const struct wl_touch_extension_interface touch_interface; - - Compositor *m_compositor; - int m_flags; - QList m_resources; - wl_array m_rawdata_array; - float *m_rawdata_ptr; -}; - -} - -#endif // WLTOUCH_H diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp index 80c159d5c..ea16da313 100644 --- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp +++ b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp @@ -40,17 +40,19 @@ #include "waylandwindowmanagerintegration.h" -#include "wayland_wrapper/wldisplay.h" -#include "wayland_wrapper/wlcompositor.h" +#include "wayland_wrapper/qwldisplay_p.h" +#include "wayland_wrapper/qwlcompositor_p.h" -#include "compositor_api/waylandcompositor.h" +#include "compositor_api/qwaylandcompositor.h" #include "wayland-server.h" #include "wayland-windowmanager-server-protocol.h" #include -WindowManagerServerIntegration::WindowManagerServerIntegration(WaylandCompositor *compositor, QObject *parent) +QT_BEGIN_NAMESPACE + +WindowManagerServerIntegration::WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent) : QObject(parent) , m_showIsFullScreen(false) , m_compositor(compositor) @@ -62,7 +64,7 @@ WindowManagerServerIntegration::~WindowManagerServerIntegration() qDeleteAll(m_managedClients); } -void WindowManagerServerIntegration::initialize(Wayland::Display *waylandDisplay) +void WindowManagerServerIntegration::initialize(QtWayland::Display *waylandDisplay) { wl_display_add_global(waylandDisplay->handle(),&wl_windowmanager_interface,this,WindowManagerServerIntegration::bind_func); } @@ -208,3 +210,5 @@ QByteArray WaylandManagedClient::authenticationToken() const { return m_authenticationToken; } + +QT_END_NAMESPACE diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h index f261e37bd..afae39dcc 100644 --- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h +++ b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h @@ -41,8 +41,8 @@ #ifndef WAYLANDWINDOWMANAGERINTEGRATION_H #define WAYLANDWINDOWMANAGERINTEGRATION_H -#include "waylandexport.h" -#include "waylandresourcecollection.h" +#include +#include #include #include @@ -54,22 +54,24 @@ struct wl_client; struct wl_object; -namespace Wayland { +QT_BEGIN_NAMESPACE + +namespace QtWayland { class Display; } class WindowManagerObject; class WaylandManagedClient; -class WaylandCompositor; +class QWaylandCompositor; -class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QObject, private Wayland::ResourceCollection +class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QObject, private QtWayland::ResourceCollection { Q_OBJECT public: - WindowManagerServerIntegration(WaylandCompositor *compositor, QObject *parent = 0); + WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent = 0); ~WindowManagerServerIntegration(); - void initialize(Wayland::Display *waylandDisplay); + void initialize(QtWayland::Display *waylandDisplay); void removeClient(wl_client *client); WaylandManagedClient *managedClient(wl_client *client) const; @@ -86,7 +88,7 @@ private: private: bool m_showIsFullScreen; - WaylandCompositor *m_compositor; + QWaylandCompositor *m_compositor; QMap m_managedClients; static void bind_func(struct wl_client *client, void *data, @@ -121,4 +123,6 @@ private: friend class WindowManagerServerIntegration; }; +QT_END_NAMESPACE + #endif // WAYLANDWINDOWMANAGERINTEGRATION_H diff --git a/src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri b/src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri index 457080f5a..7b35c7b79 100644 --- a/src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri +++ b/src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri @@ -1,11 +1,9 @@ INCLUDEPATH += $$PWD -WAYLANDSOURCES += $$PWD/../../extensions/windowmanager.xml - HEADERS += \ - $$PWD/waylandwindowmanagerintegration.h \ + windowmanagerprotocol/waylandwindowmanagerintegration.h SOURCES += \ - $$PWD/waylandwindowmanagerintegration.cpp \ + windowmanagerprotocol/waylandwindowmanagerintegration.cpp diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp index a1d6df082..2bd5732d3 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp @@ -50,6 +50,8 @@ #include "wayland-brcm-client-protocol.h" +QT_USE_NAMESPACE + QWaylandBrcmEglIntegration::QWaylandBrcmEglIntegration(QWaylandDisplay *waylandDisplay) : m_waylandDisplay(waylandDisplay->wl_display()) { diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h index de7b38a52..c7cb41b6d 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h @@ -50,6 +50,10 @@ #define EGL_EGLEXT_PROTOTYPES #include +#include + +QT_BEGIN_NAMESPACE + class QWaylandWindow; class QWindow; @@ -85,4 +89,6 @@ private: EGLDisplay m_eglDisplay; }; +QT_END_NAMESPACE + #endif // QWAYLANDBRCMEGLINTEGRATION_H diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.cpp b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.cpp index 82f673922..0b2f4d316 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.cpp +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.cpp @@ -59,6 +59,8 @@ #include "wayland-brcm-client-protocol.h" +QT_USE_NAMESPACE + class QWaylandBrcmBuffer : public QWaylandBuffer { public: diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.h b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.h index 92c0aa57e..e8fcfbaa2 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.h +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.h @@ -49,6 +49,8 @@ #include +QT_BEGIN_NAMESPACE + class QWaylandGLContext; class QWaylandBrcmBuffer; @@ -94,4 +96,6 @@ private: QMutex m_mutex; }; +QT_END_NAMESPACE + #endif // QWAYLANDBRCMEGLWINDOW_H diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.cpp b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.cpp index a3b737f55..14b989870 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.cpp +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.cpp @@ -50,6 +50,8 @@ #include #include +QT_USE_NAMESPACE + extern QSurfaceFormat brcmFixFormat(const QSurfaceFormat &format); QWaylandBrcmGLContext::QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share) diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.h b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.h index ae248a6ad..7beef166b 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.h +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.h @@ -48,6 +48,8 @@ #include +QT_BEGIN_NAMESPACE + class QWaylandWindow; class QWaylandGLWindowSurface; @@ -76,5 +78,6 @@ private: QSurfaceFormat m_format; }; +QT_END_NAMESPACE #endif // QWAYLANDBRCMGLCONTEXT_H diff --git a/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.cpp b/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.cpp index 5cf5239a8..7724f2833 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.cpp +++ b/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.cpp @@ -46,6 +46,8 @@ #include #include +QT_USE_NAMESPACE + QWaylandEglDecoration::QWaylandEglDecoration(QWaylandEglWindow *window) : QWaylandDecoration(window) { diff --git a/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.h b/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.h index c1ef6d54a..3039b7285 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.h +++ b/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.h @@ -44,6 +44,8 @@ #include "qwaylanddecoration.h" +QT_BEGIN_NAMESPACE + class QWaylandEglWindow; class QWaylandEglDecoration : public QWaylandDecoration @@ -56,4 +58,6 @@ public: }; +QT_END_NAMESPACE + #endif // QWAYLANDEGLDECORATION_H diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp b/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp index b64798f66..53cc52706 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp @@ -50,6 +50,8 @@ #include +QT_USE_NAMESPACE + QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay) : m_waylandDisplay(waylandDisplay) { diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.h b/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.h index 77a365dfa..64e7d97de 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.h +++ b/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.h @@ -46,6 +46,8 @@ #include "qwaylandeglinclude.h" +QT_BEGIN_NAMESPACE + class QWaylandWindow; class QWindow; @@ -69,4 +71,6 @@ private: EGLDisplay m_eglDisplay; }; +QT_END_NAMESPACE + #endif // QWAYLANDEGLINTEGRATION_H diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp index caed3dfe0..6edf74832 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp +++ b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp @@ -57,6 +57,8 @@ #include "windowmanager_integration/qwaylandwindowmanagerintegration.h" #endif +QT_USE_NAMESPACE + QWaylandEglWindow::QWaylandEglWindow(QWindow *window) : QWaylandWindow(window) , m_eglIntegration(static_cast(mDisplay->eglIntegration())) diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h index 4a7b3054a..dfc5a26d9 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h +++ b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h @@ -46,6 +46,8 @@ #include "qwaylandeglinclude.h" #include "qwaylandeglintegration.h" +QT_BEGIN_NAMESPACE + class QWaylandGLContext; class QOpenGLFramebufferObject; @@ -85,4 +87,6 @@ private: QSurfaceFormat m_format; }; +QT_END_NAMESPACE + #endif // QWAYLANDEGLWINDOW_H diff --git a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp index f9ad280f7..4d8017dc2 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp @@ -54,6 +54,8 @@ #include #include +QT_USE_NAMESPACE + QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share) : QPlatformOpenGLContext() , m_eglDisplay(eglDisplay) diff --git a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h index 767f188fb..696a0b918 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h +++ b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h @@ -48,6 +48,8 @@ #include "qwaylandeglinclude.h" +QT_BEGIN_NAMESPACE + class QWaylandWindow; class QWaylandGLWindowSurface; class QOpenGLShaderProgram; @@ -84,5 +86,6 @@ private: QOpenGLShaderProgram *m_blitProgram; }; +QT_END_NAMESPACE #endif // QWAYLANDGLCONTEXT_H diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.cpp index 5024ba25d..42139ef18 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.cpp @@ -48,6 +48,8 @@ #include +QT_USE_NAMESPACE + QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display) : QEGLPlatformContext(format, share, display) { diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.h index 906f8a3f5..32cdb4322 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.h +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.h @@ -48,6 +48,8 @@ #include +QT_BEGIN_NAMESPACE + class QWaylandXCompositeEGLWindow; class QWaylandXCompositeEGLContext : public QEGLPlatformContext @@ -61,4 +63,6 @@ private: EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface); }; +QT_END_NAMESPACE + #endif // QWAYLANDXCOMPOSITEEGLCONTEXT_H diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp index c4d98a8ea..992c2dcff 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp @@ -47,6 +47,8 @@ #include "wayland-xcomposite-client-protocol.h" +QT_USE_NAMESPACE + QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) { return new QWaylandXCompositeEGLIntegration(waylandDisplay); diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h index ae0fc30bc..d3015ab57 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h @@ -60,6 +60,8 @@ struct wl_xcomposite; +QT_BEGIN_NAMESPACE + class QWaylandXCompositeEGLIntegration : public QWaylandGLIntegration { public: @@ -99,4 +101,6 @@ private: uint32_t root_window); }; +QT_END_NAMESPACE + #endif // QWAYLANDXCOMPOSITEEGLINTEGRATION_H diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp index 0f50f63f1..edf77a64f 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp @@ -53,6 +53,8 @@ #include +QT_USE_NAMESPACE + QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration) : QWaylandWindow(window) , m_glxIntegration(glxIntegration) diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.h index ac7419a9f..895ac28f0 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.h +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.h @@ -48,6 +48,8 @@ #include "qwaylandxcompositeeglintegration.h" #include "qwaylandxcompositeeglcontext.h" +QT_BEGIN_NAMESPACE + class QWaylandXCompositeEGLWindow : public QWaylandWindow { public: @@ -77,4 +79,6 @@ private: uint32_t time); }; +QT_END_NAMESPACE + #endif // QWAYLANDXCOMPOSITEEGLWINDOW_H diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.cpp index 4ba499255..286436909 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.cpp @@ -47,6 +47,8 @@ #include +QT_USE_NAMESPACE + QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen) : m_display(display) { diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.h index 55b6c2aff..de0311262 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.h @@ -47,6 +47,8 @@ #include "qwaylandxcompositeglxintegration.h" #include +QT_BEGIN_NAMESPACE + class QWaylandXCompositeGLXWindow; class QWaylandShmBuffer; @@ -71,4 +73,6 @@ private: QSurfaceFormat m_format; }; +QT_END_NAMESPACE + #endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp index d82c6456c..56554236b 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp @@ -47,6 +47,8 @@ #include "wayland-xcomposite-client-protocol.h" +QT_USE_NAMESPACE + QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) { return new QWaylandXCompositeGLXIntegration(waylandDisplay); diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h index 3417967c2..8bbbab89b 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h @@ -55,6 +55,8 @@ struct wl_xcomposite; +QT_BEGIN_NAMESPACE + class QWaylandXCompositeGLXIntegration : public QWaylandGLIntegration { public: @@ -92,4 +94,6 @@ private: uint32_t root_window); }; +QT_END_NAMESPACE + #endif // QWAYLANDXCOMPOSITEGLXINTEGRATION_H diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.cpp index ad1916b3b..1ffb5b87c 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.cpp @@ -49,6 +49,8 @@ #include +QT_USE_NAMESPACE + QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration) : QWaylandWindow(window) , m_glxIntegration(glxIntegration) diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.h index 6c19ee498..fa16c36d5 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.h +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.h @@ -50,6 +50,8 @@ #include "qwaylandbuffer.h" +QT_BEGIN_NAMESPACE + class QWaylandXCompositeGLXWindow : public QWaylandWindow { public: @@ -77,4 +79,6 @@ private: static void sync_function(void *data, struct wl_callback *wl_callback, uint32_t time); }; +QT_END_NAMESPACE + #endif // QWAYLANDXCOMPOSITEGLXWINDOW_H diff --git a/src/plugins/platforms/wayland_common/qwaylandbuffer.h b/src/plugins/platforms/wayland_common/qwaylandbuffer.h index 357862c90..eee648561 100644 --- a/src/plugins/platforms/wayland_common/qwaylandbuffer.h +++ b/src/plugins/platforms/wayland_common/qwaylandbuffer.h @@ -48,6 +48,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QWaylandBuffer { public: QWaylandBuffer() { } @@ -59,4 +61,6 @@ protected: struct wl_buffer *mBuffer; }; +QT_END_NAMESPACE + #endif // QWAYLANDBUFFER_H diff --git a/src/plugins/platforms/wayland_common/qwaylandclipboard.cpp b/src/plugins/platforms/wayland_common/qwaylandclipboard.cpp index 362584b15..31fe60455 100644 --- a/src/plugins/platforms/wayland_common/qwaylandclipboard.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandclipboard.cpp @@ -46,6 +46,8 @@ #include "qwaylanddatasource.h" #include "qwaylanddatadevicemanager.h" +QT_USE_NAMESPACE + QWaylandClipboard::QWaylandClipboard(QWaylandDisplay *display) : mDisplay(display) { diff --git a/src/plugins/platforms/wayland_common/qwaylandclipboard.h b/src/plugins/platforms/wayland_common/qwaylandclipboard.h index 7cdc8474f..a8f52e107 100644 --- a/src/plugins/platforms/wayland_common/qwaylandclipboard.h +++ b/src/plugins/platforms/wayland_common/qwaylandclipboard.h @@ -45,6 +45,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QWaylandDisplay; class QWaylandClipboard : public QPlatformClipboard @@ -64,4 +66,6 @@ private: QWaylandDisplay *mDisplay; }; +QT_END_NAMESPACE + #endif // QWAYLANDCLIPBOARD_H diff --git a/src/plugins/platforms/wayland_common/qwaylandcursor.cpp b/src/plugins/platforms/wayland_common/qwaylandcursor.cpp index 1511abcba..d48239504 100644 --- a/src/plugins/platforms/wayland_common/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandcursor.cpp @@ -51,6 +51,8 @@ #include +QT_USE_NAMESPACE + QWaylandCursor::QWaylandCursor(QWaylandScreen *screen) : mDisplay(screen->display()) { diff --git a/src/plugins/platforms/wayland_common/qwaylandcursor.h b/src/plugins/platforms/wayland_common/qwaylandcursor.h index 8b4d5e373..df5dcbe39 100644 --- a/src/plugins/platforms/wayland_common/qwaylandcursor.h +++ b/src/plugins/platforms/wayland_common/qwaylandcursor.h @@ -45,6 +45,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QWaylandDisplay; class QWaylandScreen; struct wl_cursor_theme; @@ -103,4 +105,6 @@ private: QMultiMap mCursorNamesMap; }; +QT_END_NAMESPACE + #endif // QWAYLANDCURSOR_H diff --git a/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.cpp b/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.cpp index 0b22fb2b1..d4ba61790 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.cpp +++ b/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.cpp @@ -58,6 +58,8 @@ #include +QT_USE_NAMESPACE + void QWaylandDataDeviceManager::data_offer(void *data, struct wl_data_device *data_device, struct wl_data_offer *id) diff --git a/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.h b/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.h index ba2015d1c..101f78448 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.h +++ b/src/plugins/platforms/wayland_common/qwaylanddatadevicemanager.h @@ -49,6 +49,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QWaylandDataOffer; class QWaylandDataSource; class QDrag; @@ -120,4 +122,6 @@ private: static const struct wl_data_device_listener transfer_device_listener; }; +QT_END_NAMESPACE + #endif // QWAYLANDDATADEVICEMANAGER_H diff --git a/src/plugins/platforms/wayland_common/qwaylanddataoffer.cpp b/src/plugins/platforms/wayland_common/qwaylanddataoffer.cpp index c04807c94..d2080ea55 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddataoffer.cpp +++ b/src/plugins/platforms/wayland_common/qwaylanddataoffer.cpp @@ -47,6 +47,7 @@ #include +QT_USE_NAMESPACE void QWaylandDataOffer::offer_sync_callback(void *data, struct wl_callback *callback, diff --git a/src/plugins/platforms/wayland_common/qwaylanddataoffer.h b/src/plugins/platforms/wayland_common/qwaylanddataoffer.h index 46ca3ce39..fada683a2 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddataoffer.h +++ b/src/plugins/platforms/wayland_common/qwaylanddataoffer.h @@ -51,9 +51,12 @@ #include -class QWaylandDisplay; struct wl_callback; +QT_BEGIN_NAMESPACE + +class QWaylandDisplay; + class QWaylandDataOffer : public QInternalMimeData { public: @@ -79,4 +82,6 @@ private: static const struct wl_callback_listener offer_sync_callback_listener; }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/platforms/wayland_common/qwaylanddatasource.cpp b/src/plugins/platforms/wayland_common/qwaylanddatasource.cpp index ab3f8b599..ad280b03c 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddatasource.cpp +++ b/src/plugins/platforms/wayland_common/qwaylanddatasource.cpp @@ -50,6 +50,8 @@ #include +QT_USE_NAMESPACE + void QWaylandDataSource::data_source_target(void *data, struct wl_data_source *wl_data_source, const char *mime_type) diff --git a/src/plugins/platforms/wayland_common/qwaylanddatasource.h b/src/plugins/platforms/wayland_common/qwaylanddatasource.h index 7baa05e39..8fdf06368 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddatasource.h +++ b/src/plugins/platforms/wayland_common/qwaylanddatasource.h @@ -46,6 +46,8 @@ #include +QT_BEGIN_NAMESPACE + class QWaylandDataSource { public: @@ -72,4 +74,6 @@ private: static const struct wl_data_source_listener data_source_listener; }; +QT_END_NAMESPACE + #endif // QWAYLANDDATASOURCE_H diff --git a/src/plugins/platforms/wayland_common/qwaylanddecoration.cpp b/src/plugins/platforms/wayland_common/qwaylanddecoration.cpp index 9fcc6a8bc..a0c9534cd 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddecoration.cpp +++ b/src/plugins/platforms/wayland_common/qwaylanddecoration.cpp @@ -54,6 +54,8 @@ #define BUTTON_WIDTH 25 #define BUTTON_SPACING 5 +QT_USE_NAMESPACE + QWaylandDecoration::QWaylandDecoration(QWaylandWindow *window) : m_window(window->window()) , m_wayland_window(window) diff --git a/src/plugins/platforms/wayland_common/qwaylanddecoration.h b/src/plugins/platforms/wayland_common/qwaylanddecoration.h index 30a5e31fa..0ad9b0305 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddecoration.h +++ b/src/plugins/platforms/wayland_common/qwaylanddecoration.h @@ -53,6 +53,8 @@ #include +QT_BEGIN_NAMESPACE + class QWindow; class QPaintDevice; class QPainter; @@ -154,4 +156,6 @@ inline void QWaylandDecoration::overrideCursor(Qt::CursorShape shape) } } +QT_END_NAMESPACE + #endif // QWAYLANDDECORATION_H diff --git a/src/plugins/platforms/wayland_common/qwaylanddisplay.cpp b/src/plugins/platforms/wayland_common/qwaylanddisplay.cpp index 83eaee33d..5b1d2e705 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland_common/qwaylanddisplay.cpp @@ -73,6 +73,8 @@ #include +QT_USE_NAMESPACE + struct wl_surface *QWaylandDisplay::createSurface(void *handle) { struct wl_surface * surface = wl_compositor_create_surface(mCompositor); diff --git a/src/plugins/platforms/wayland_common/qwaylanddisplay.h b/src/plugins/platforms/wayland_common/qwaylanddisplay.h index 0e5511821..de5513723 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland_common/qwaylanddisplay.h @@ -49,6 +49,8 @@ #include +QT_BEGIN_NAMESPACE + class QAbstractEventDispatcher; class QWaylandInputDevice; class QSocketNotifier; @@ -201,4 +203,6 @@ private: int32_t width, int32_t height); }; +QT_END_NAMESPACE + #endif // QWAYLANDDISPLAY_H diff --git a/src/plugins/platforms/wayland_common/qwaylanddnd.cpp b/src/plugins/platforms/wayland_common/qwaylanddnd.cpp index 800f4c186..790fbbd09 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddnd.cpp +++ b/src/plugins/platforms/wayland_common/qwaylanddnd.cpp @@ -43,6 +43,8 @@ #include "qwaylanddatadevicemanager.h" +QT_USE_NAMESPACE + QWaylandDrag::QWaylandDrag(QWaylandDisplay *display) : m_display(display) { diff --git a/src/plugins/platforms/wayland_common/qwaylanddnd.h b/src/plugins/platforms/wayland_common/qwaylanddnd.h index d766947ea..fa8f5b639 100644 --- a/src/plugins/platforms/wayland_common/qwaylanddnd.h +++ b/src/plugins/platforms/wayland_common/qwaylanddnd.h @@ -47,6 +47,8 @@ #include #include "qwaylanddisplay.h" +QT_BEGIN_NAMESPACE + class QWaylandDrag : public QPlatformDrag { public: @@ -67,4 +69,6 @@ private: QWaylandDisplay *m_display; }; +QT_END_NAMESPACE + #endif // QWAYLANDDND_H diff --git a/src/plugins/platforms/wayland_common/qwaylandextendedoutput.cpp b/src/plugins/platforms/wayland_common/qwaylandextendedoutput.cpp index 5f97a9274..7b6f9f3ca 100644 --- a/src/plugins/platforms/wayland_common/qwaylandextendedoutput.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandextendedoutput.cpp @@ -49,6 +49,8 @@ #include +QT_USE_NAMESPACE + QWaylandOutputExtension::QWaylandOutputExtension(QWaylandDisplay *display, uint32_t id) { m_output_extension = static_cast( diff --git a/src/plugins/platforms/wayland_common/qwaylandextendedoutput.h b/src/plugins/platforms/wayland_common/qwaylandextendedoutput.h index bbf4e060a..780f57023 100644 --- a/src/plugins/platforms/wayland_common/qwaylandextendedoutput.h +++ b/src/plugins/platforms/wayland_common/qwaylandextendedoutput.h @@ -44,6 +44,8 @@ #include "qwaylanddisplay.h" +QT_BEGIN_NAMESPACE + class QWaylandExtendedOutput; class QWaylandOutputExtension @@ -75,5 +77,6 @@ private: static const struct wl_extended_output_listener extended_output_listener; }; +QT_END_NAMESPACE #endif // QWAYLANDEXTENDEDOUTPUT_H diff --git a/src/plugins/platforms/wayland_common/qwaylandextendedsurface.cpp b/src/plugins/platforms/wayland_common/qwaylandextendedsurface.cpp index 0f30fcf26..82b294b09 100644 --- a/src/plugins/platforms/wayland_common/qwaylandextendedsurface.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandextendedsurface.cpp @@ -54,6 +54,8 @@ #include #include +QT_USE_NAMESPACE + QWaylandSurfaceExtension::QWaylandSurfaceExtension(QWaylandDisplay *display, uint32_t id) { m_surface_extension = static_cast( diff --git a/src/plugins/platforms/wayland_common/qwaylandextendedsurface.h b/src/plugins/platforms/wayland_common/qwaylandextendedsurface.h index 9588dfbba..940d9ab77 100644 --- a/src/plugins/platforms/wayland_common/qwaylandextendedsurface.h +++ b/src/plugins/platforms/wayland_common/qwaylandextendedsurface.h @@ -47,6 +47,8 @@ #include +QT_BEGIN_NAMESPACE + class QWaylandDisplay; class QWaylandWindow; class QWaylandExtendedSurface; @@ -97,4 +99,6 @@ private: bool m_exposed; }; +QT_END_NAMESPACE + #endif // QWAYLANDEXTENDEDSURFACE_H diff --git a/src/plugins/platforms/wayland_common/qwaylandglintegration.cpp b/src/plugins/platforms/wayland_common/qwaylandglintegration.cpp index b106f5e06..a4b3331c6 100644 --- a/src/plugins/platforms/wayland_common/qwaylandglintegration.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandglintegration.cpp @@ -41,6 +41,8 @@ #include "qwaylandglintegration.h" +QT_USE_NAMESPACE + QWaylandGLIntegration::QWaylandGLIntegration() { diff --git a/src/plugins/platforms/wayland_common/qwaylandglintegration.h b/src/plugins/platforms/wayland_common/qwaylandglintegration.h index c015ee1fa..4055790b3 100644 --- a/src/plugins/platforms/wayland_common/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland_common/qwaylandglintegration.h @@ -42,6 +42,10 @@ #ifndef QWAYLANDGLINTEGRATION_H #define QWAYLANDGLINTEGRATION_H +#include + +QT_BEGIN_NAMESPACE + class QWaylandWindow; class QWaylandDisplay; class QWindow; @@ -66,4 +70,6 @@ public: static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay); }; +QT_END_NAMESPACE + #endif // QWAYLANDGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland_common/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland_common/qwaylandinputdevice.cpp index aaef268e5..9820854da 100644 --- a/src/plugins/platforms/wayland_common/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandinputdevice.cpp @@ -63,6 +63,8 @@ #include #endif +QT_USE_NAMESPACE + QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, uint32_t id) : mQDisplay(display) , mDisplay(display->wl_display()) diff --git a/src/plugins/platforms/wayland_common/qwaylandintegration.cpp b/src/plugins/platforms/wayland_common/qwaylandintegration.cpp index b35f0c49f..7aaef546f 100644 --- a/src/plugins/platforms/wayland_common/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandintegration.cpp @@ -71,6 +71,8 @@ #include "windowmanager_integration/qwaylandwindowmanagerintegration.h" #endif +QT_USE_NAMESPACE + QWaylandIntegration::QWaylandIntegration() : mFontDb(new QGenericUnixFontDatabase()) , mEventDispatcher(createUnixEventDispatcher()) diff --git a/src/plugins/platforms/wayland_common/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland_common/qwaylandnativeinterface.cpp index 3cce96037..b49114e63 100644 --- a/src/plugins/platforms/wayland_common/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandnativeinterface.cpp @@ -50,6 +50,8 @@ #include "windowmanager_integration/qwaylandwindowmanagerintegration.h" +QT_USE_NAMESPACE + QWaylandNativeInterface::QWaylandNativeInterface(QWaylandIntegration *integration) : m_integration(integration) { diff --git a/src/plugins/platforms/wayland_common/qwaylandnativeinterface.h b/src/plugins/platforms/wayland_common/qwaylandnativeinterface.h index 26372ad3c..604115080 100644 --- a/src/plugins/platforms/wayland_common/qwaylandnativeinterface.h +++ b/src/plugins/platforms/wayland_common/qwaylandnativeinterface.h @@ -46,6 +46,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QWaylandIntegration; class QWaylandNativeInterface : public QPlatformNativeInterface @@ -70,5 +72,6 @@ private: QHash m_windowProperties; }; +QT_END_NAMESPACE #endif // QWAYLANDNATIVEINTERFACE_H diff --git a/src/plugins/platforms/wayland_common/qwaylandqtkey.cpp b/src/plugins/platforms/wayland_common/qwaylandqtkey.cpp index a6fe2f520..76d91c790 100644 --- a/src/plugins/platforms/wayland_common/qwaylandqtkey.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandqtkey.cpp @@ -44,6 +44,8 @@ #include "wayland-qtkey-extension-client-protocol.h" +QT_USE_NAMESPACE + QWaylandQtKeyExtension::QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id) : m_display(display) { diff --git a/src/plugins/platforms/wayland_common/qwaylandqtkey.h b/src/plugins/platforms/wayland_common/qwaylandqtkey.h index 8f6dbd298..adcce6134 100644 --- a/src/plugins/platforms/wayland_common/qwaylandqtkey.h +++ b/src/plugins/platforms/wayland_common/qwaylandqtkey.h @@ -46,6 +46,9 @@ #include class wl_qtkey_extension; + +QT_BEGIN_NAMESPACE + class QWaylandQtKeyExtension { public: @@ -71,4 +74,6 @@ private: uint32_t count); }; +QT_END_NAMESPACE + #endif // QWAYLANDQTKEY_H diff --git a/src/plugins/platforms/wayland_common/qwaylandscreen.cpp b/src/plugins/platforms/wayland_common/qwaylandscreen.cpp index 8689c7127..3e706557a 100644 --- a/src/plugins/platforms/wayland_common/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandscreen.cpp @@ -47,6 +47,8 @@ #include +QT_USE_NAMESPACE + QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output) : QPlatformScreen() , mWaylandDisplay(waylandDisplay) diff --git a/src/plugins/platforms/wayland_common/qwaylandscreen.h b/src/plugins/platforms/wayland_common/qwaylandscreen.h index 28be6e8b9..3d4b2948a 100644 --- a/src/plugins/platforms/wayland_common/qwaylandscreen.h +++ b/src/plugins/platforms/wayland_common/qwaylandscreen.h @@ -44,6 +44,8 @@ #include +QT_BEGIN_NAMESPACE + class QWaylandDisplay; class QWaylandCursor; class QWaylandExtendedOutput; @@ -91,4 +93,6 @@ private: QWaylandCursor *mWaylandCursor; }; +QT_END_NAMESPACE + #endif // QWAYLANDSCREEN_H diff --git a/src/plugins/platforms/wayland_common/qwaylandshell.cpp b/src/plugins/platforms/wayland_common/qwaylandshell.cpp index c82bf9bac..9c37235ca 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshell.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandshell.cpp @@ -44,6 +44,8 @@ #include "qwaylandshellsurface.h" #include "qwaylandwindow.h" +QT_USE_NAMESPACE + QWaylandShell::QWaylandShell(QWaylandDisplay *display, uint32_t id, uint32_t version) : m_display(display) { diff --git a/src/plugins/platforms/wayland_common/qwaylandshell.h b/src/plugins/platforms/wayland_common/qwaylandshell.h index 16d0a08c8..3c2014f63 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshell.h +++ b/src/plugins/platforms/wayland_common/qwaylandshell.h @@ -44,6 +44,8 @@ #include "qwaylanddisplay.h" +QT_BEGIN_NAMESPACE + class QWaylandWindow; class QWaylandShellSurface; @@ -60,4 +62,6 @@ private: QWaylandDisplay *m_display; }; +QT_END_NAMESPACE + #endif // QWAYLANDSHELL_H diff --git a/src/plugins/platforms/wayland_common/qwaylandshellsurface.cpp b/src/plugins/platforms/wayland_common/qwaylandshellsurface.cpp index 53a447214..2d1442b42 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshellsurface.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandshellsurface.cpp @@ -49,6 +49,8 @@ #include +QT_USE_NAMESPACE + QWaylandShellSurface::QWaylandShellSurface(struct wl_shell_surface *shell_surface, QWaylandWindow *window) : m_shell_surface(shell_surface) , m_window(window) diff --git a/src/plugins/platforms/wayland_common/qwaylandshellsurface.h b/src/plugins/platforms/wayland_common/qwaylandshellsurface.h index 8357ec246..0b88741cf 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshellsurface.h +++ b/src/plugins/platforms/wayland_common/qwaylandshellsurface.h @@ -46,6 +46,8 @@ #include +QT_BEGIN_NAMESPACE + class QWaylandWindow; class QWaylandInputDevice; class QWindow; @@ -91,4 +93,6 @@ private: static const struct wl_shell_surface_listener m_shell_surface_listener; }; +QT_END_NAMESPACE + #endif // QWAYLANDSHELLSURFACE_H diff --git a/src/plugins/platforms/wayland_common/qwaylandshmdecoration.cpp b/src/plugins/platforms/wayland_common/qwaylandshmdecoration.cpp index 6c9373095..24c05defc 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshmdecoration.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandshmdecoration.cpp @@ -44,6 +44,8 @@ #include "qwaylandshmwindow.h" #include "qwaylandshmbackingstore.h" +QT_USE_NAMESPACE + QWaylandShmDecoration::QWaylandShmDecoration(QWaylandShmWindow *window) : QWaylandDecoration(window) { diff --git a/src/plugins/platforms/wayland_common/qwaylandshmdecoration.h b/src/plugins/platforms/wayland_common/qwaylandshmdecoration.h index 4ff0da3d0..567e8755d 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshmdecoration.h +++ b/src/plugins/platforms/wayland_common/qwaylandshmdecoration.h @@ -44,6 +44,8 @@ #include "qwaylanddecoration.h" +QT_BEGIN_NAMESPACE + class QWaylandShmWindow; class QWaylandShmDecoration : public QWaylandDecoration @@ -56,4 +58,6 @@ public: }; +QT_END_NAMESPACE + #endif // QWAYLANDSHMDECORATION_H diff --git a/src/plugins/platforms/wayland_common/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland_common/qwaylandshmwindow.cpp index b7ec9d284..ad2fd9a23 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandshmwindow.cpp @@ -48,6 +48,8 @@ #include +QT_USE_NAMESPACE + QWaylandShmWindow::QWaylandShmWindow(QWindow *window) : QWaylandWindow(window) , mBackingStore(0) diff --git a/src/plugins/platforms/wayland_common/qwaylandshmwindow.h b/src/plugins/platforms/wayland_common/qwaylandshmwindow.h index ef5e5db07..f28e1d503 100644 --- a/src/plugins/platforms/wayland_common/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland_common/qwaylandshmwindow.h @@ -45,6 +45,8 @@ #include "qwaylandwindow.h" #include +QT_BEGIN_NAMESPACE + class QWaylandShmBackingStore; class QWaylandShmWindow : public QWaylandWindow @@ -71,4 +73,6 @@ inline QWaylandShmBackingStore *QWaylandShmWindow::backingStore() const return mBackingStore; } +QT_END_NAMESPACE + #endif // QWAYLANDSHMWINDOW_H diff --git a/src/plugins/platforms/wayland_common/qwaylandsubsurface.cpp b/src/plugins/platforms/wayland_common/qwaylandsubsurface.cpp index b92bddc9d..0ec955a86 100644 --- a/src/plugins/platforms/wayland_common/qwaylandsubsurface.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandsubsurface.cpp @@ -47,6 +47,8 @@ #include +QT_USE_NAMESPACE + QWaylandSubSurfaceExtension::QWaylandSubSurfaceExtension(QWaylandDisplay *display, uint32_t id) { m_sub_surface_extension = static_cast( diff --git a/src/plugins/platforms/wayland_common/qwaylandsubsurface.h b/src/plugins/platforms/wayland_common/qwaylandsubsurface.h index 939b9392f..e594050ec 100644 --- a/src/plugins/platforms/wayland_common/qwaylandsubsurface.h +++ b/src/plugins/platforms/wayland_common/qwaylandsubsurface.h @@ -42,12 +42,16 @@ #ifndef QWAYLANDSUBSURFACE_H #define QWAYLANDSUBSURFACE_H +#include + +#include + +QT_BEGIN_NAMESPACE + class QWaylandDisplay; class QWaylandWindow; class QWaylandSubSurface; -#include - class QWaylandSubSurfaceExtension { public: @@ -72,4 +76,6 @@ private: struct wl_sub_surface *m_sub_surface; }; +QT_END_NAMESPACE + #endif // QWAYLANDSUBSURFACE_H diff --git a/src/plugins/platforms/wayland_common/qwaylandtouch.cpp b/src/plugins/platforms/wayland_common/qwaylandtouch.cpp index 0c1587305..26f57d576 100644 --- a/src/plugins/platforms/wayland_common/qwaylandtouch.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandtouch.cpp @@ -44,6 +44,8 @@ #include "wayland-touch-extension-client-protocol.h" +QT_USE_NAMESPACE + QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_t id) : mDisplay(display), mTouchDevice(0), diff --git a/src/plugins/platforms/wayland_common/qwaylandtouch.h b/src/plugins/platforms/wayland_common/qwaylandtouch.h index 919bfe878..9762af22a 100644 --- a/src/plugins/platforms/wayland_common/qwaylandtouch.h +++ b/src/plugins/platforms/wayland_common/qwaylandtouch.h @@ -47,6 +47,8 @@ class wl_touch_extension; +QT_BEGIN_NAMESPACE + class QWaylandTouchExtension { public: @@ -96,4 +98,6 @@ private: QWaylandInputDevice *mInputDevice; }; +QT_END_NAMESPACE + #endif // QWAYLANDTOUCH_H diff --git a/src/plugins/platforms/wayland_common/qwaylandwindow.cpp b/src/plugins/platforms/wayland_common/qwaylandwindow.cpp index dc95aa93c..be962ebf2 100644 --- a/src/plugins/platforms/wayland_common/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland_common/qwaylandwindow.cpp @@ -63,6 +63,8 @@ #include +QT_USE_NAMESPACE + QWaylandWindow::QWaylandWindow(QWindow *window) : QPlatformWindow(window) , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) diff --git a/src/plugins/platforms/wayland_common/qwaylandwindow.h b/src/plugins/platforms/wayland_common/qwaylandwindow.h index a58e49db1..39d2dcc61 100644 --- a/src/plugins/platforms/wayland_common/qwaylandwindow.h +++ b/src/plugins/platforms/wayland_common/qwaylandwindow.h @@ -49,6 +49,10 @@ #include "qwaylanddisplay.h" +struct wl_egl_window; + +QT_BEGIN_NAMESPACE + class QWaylandDisplay; class QWaylandBuffer; class QWaylandShellSurface; @@ -56,8 +60,6 @@ class QWaylandExtendedSurface; class QWaylandSubSurface; class QWaylandDecoration; -struct wl_egl_window; - class QWaylandWindow : public QPlatformWindow { public: @@ -171,5 +173,6 @@ inline QPoint QWaylandWindow::attachOffset() const return mOffset; } +QT_END_NAMESPACE #endif // QWAYLANDWINDOW_H diff --git a/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.cpp index ba26b79af..68a7fdfab 100644 --- a/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.cpp +++ b/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.cpp @@ -55,6 +55,8 @@ #include +QT_USE_NAMESPACE + class QWaylandWindowManagerIntegrationPrivate { public: QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay); diff --git a/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.h b/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.h index 2e1661cc5..9145401db 100644 --- a/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.h +++ b/src/plugins/platforms/wayland_common/windowmanager_integration/qwaylandwindowmanagerintegration.h @@ -49,6 +49,8 @@ #include "qwaylanddisplay.h" #include +QT_BEGIN_NAMESPACE + class QWaylandWindow; class QWaylandWindowManagerIntegrationPrivate; @@ -90,4 +92,6 @@ private: void openUrl_helper(const QUrl &url); }; +QT_END_NAMESPACE + #endif // QWAYLANDWINDOWMANAGERINTEGRATION_H diff --git a/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.cpp index e14b6f53f..55fe3fbe9 100644 --- a/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.cpp +++ b/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.cpp @@ -44,6 +44,8 @@ #include "wayland-client.h" #include "wayland-xcomposite-client-protocol.h" +QT_USE_NAMESPACE + QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(wl_xcomposite *xcomposite, uint32_t window, const QSize &size) :mSize(size) { diff --git a/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.h b/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.h index 5a0133d9c..d621fa47e 100644 --- a/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.h +++ b/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.h @@ -48,6 +48,8 @@ struct wl_xcomposite; struct wl_visual; +QT_BEGIN_NAMESPACE + class QWaylandXCompositeBuffer : public QWaylandBuffer { public: @@ -60,4 +62,6 @@ private: QSize mSize; }; +QT_END_NAMESPACE + #endif // QWAYLANDXCOMPOSITEBUFFER_H diff --git a/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro b/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro index 585682247..c397c6131 100644 --- a/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro +++ b/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro @@ -1,7 +1,7 @@ PLUGIN_TYPE = waylandcompositors load(qt_plugin) -QT = compositor core-private gui-private +QT = compositor compositor-private core-private gui-private OTHER_FILES += wayland_egl.json diff --git a/src/plugins/waylandcompositors/brcm-egl/brcmbuffer.cpp b/src/plugins/waylandcompositors/brcm-egl/brcmbuffer.cpp index c9a71172c..7f5c3893a 100644 --- a/src/plugins/waylandcompositors/brcm-egl/brcmbuffer.cpp +++ b/src/plugins/waylandcompositors/brcm-egl/brcmbuffer.cpp @@ -45,7 +45,9 @@ #define EGL_EGLEXT_PROTOTYPES #include -BrcmBuffer::BrcmBuffer(Wayland::Compositor *compositor, const QSize &size, EGLint *data, size_t count) +QT_USE_NAMESPACE + +BrcmBuffer::BrcmBuffer(QtWayland::Compositor *compositor, const QSize &size, EGLint *data, size_t count) : m_invertedY(false) , m_handle(count) { diff --git a/src/plugins/waylandcompositors/brcm-egl/brcmbuffer.h b/src/plugins/waylandcompositors/brcm-egl/brcmbuffer.h index a06469da5..11f49d4a9 100644 --- a/src/plugins/waylandcompositors/brcm-egl/brcmbuffer.h +++ b/src/plugins/waylandcompositors/brcm-egl/brcmbuffer.h @@ -41,18 +41,20 @@ #ifndef BRCMBUFFER_H #define BRCMBUFFER_H -#include "waylandobject.h" -#include +#include +#include #include #include #include -class BrcmBuffer : public Wayland::Object +QT_BEGIN_NAMESPACE + +class BrcmBuffer : public QtWayland::Object { public: - BrcmBuffer(Wayland::Compositor *compositor, const QSize &size, EGLint *data, size_t count); + BrcmBuffer(QtWayland::Compositor *compositor, const QSize &size, EGLint *data, size_t count); ~BrcmBuffer(); static struct wl_buffer_interface buffer_interface; @@ -71,4 +73,6 @@ private: bool m_invertedY; }; +QT_END_NAMESPACE + #endif // BRCMBUFFER_H diff --git a/src/plugins/waylandcompositors/brcm-egl/brcmeglintegration.cpp b/src/plugins/waylandcompositors/brcm-egl/brcmeglintegration.cpp index 14699f8aa..b2f26f022 100644 --- a/src/plugins/waylandcompositors/brcm-egl/brcmeglintegration.cpp +++ b/src/plugins/waylandcompositors/brcm-egl/brcmeglintegration.cpp @@ -40,8 +40,8 @@ #include "brcmeglintegration.h" #include "brcmbuffer.h" -#include -#include +#include +#include #include #include #include @@ -60,7 +60,9 @@ #include "wayland-brcm-server-protocol.h" -GraphicsHardwareIntegration * GraphicsHardwareIntegration::createGraphicsHardwareIntegration(WaylandCompositor *compositor) +QT_USE_NAMESPACE + +QWaylandGraphicsHardwareIntegration * QWaylandGraphicsHardwareIntegration::createGraphicsHardwareIntegration(QWaylandCompositor *compositor) { return new BrcmEglIntegration(compositor); } @@ -81,12 +83,12 @@ public: }; BrcmEglIntegration::BrcmEglIntegration() - : GraphicsHardwareIntegration() + : QWaylandGraphicsHardwareIntegration() , d_ptr(new BrcmEglIntegrationPrivate) { } -void BrcmEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) +void BrcmEglIntegration::initializeHardware(QtWayland::Display *waylandDisplay) { Q_D(BrcmEglIntegration); @@ -137,7 +139,7 @@ GLuint BrcmEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLCon return 0; } - BrcmBuffer *brcmBuffer = Wayland::wayland_cast(buffer); + BrcmBuffer *brcmBuffer = QtWayland::wayland_cast(buffer); if (!d->eglQueryGlobalImageBRCM(brcmBuffer->handle(), brcmBuffer->handle() + 2)) { qWarning("eglQueryGlobalImageBRCM failed!"); diff --git a/src/plugins/waylandcompositors/brcm-egl/brcmeglintegration.h b/src/plugins/waylandcompositors/brcm-egl/brcmeglintegration.h index 3fde839d8..8ed7f07a8 100644 --- a/src/plugins/waylandcompositors/brcm-egl/brcmeglintegration.h +++ b/src/plugins/waylandcompositors/brcm-egl/brcmeglintegration.h @@ -41,18 +41,20 @@ #ifndef BRCMEGLINTEGRATION_H #define BRCMEGLINTEGRATION_H -#include +#include #include +QT_BEGIN_NAMESPACE + class BrcmEglIntegrationPrivate; -class BrcmEglIntegration : public GraphicsHardwareIntegration +class BrcmEglIntegration : public QWaylandGraphicsHardwareIntegration { Q_DECLARE_PRIVATE(BrcmEglIntegration) public: BrcmEglIntegration(); - void initializeHardware(Wayland::Display *waylandDisplay); + void initializeHardware(QtWayland::Display *waylandDisplay); GLuint createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context); bool isYInverted(struct wl_buffer *) const; @@ -71,5 +73,7 @@ private: QScopedPointer d_ptr; }; +QT_END_NAMESPACE + #endif // BRCMEGLINTEGRATION_H diff --git a/src/plugins/waylandcompositors/brcm-egl/main.cpp b/src/plugins/waylandcompositors/brcm-egl/main.cpp index d742a2eee..0fecd2ec0 100644 --- a/src/plugins/waylandcompositors/brcm-egl/main.cpp +++ b/src/plugins/waylandcompositors/brcm-egl/main.cpp @@ -39,16 +39,18 @@ ** ****************************************************************************/ -#include +#include #include "brcmeglintegration.h" -class QWaylandIntegrationPlugin : public GraphicsHardwareIntegrationPlugin +QT_BEGIN_NAMESPACE + +class QWaylandIntegrationPlugin : public QWaylandGraphicsHardwareIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Compositor.GraphicsHardwareIntegrationFactoryInterface.5.1" FILE "brcm-egl.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Compositor.QWaylandGraphicsHardwareIntegrationFactoryInterface.5.1" FILE "brcm-egl.json") public: QStringList keys() const; - GraphicsHardwareIntegration *create(const QString&, const QStringList&); + QWaylandGraphicsHardwareIntegration *create(const QString&, const QStringList&); }; QStringList QWaylandIntegrationPlugin::keys() const @@ -58,7 +60,7 @@ QStringList QWaylandIntegrationPlugin::keys() const return list; } -GraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) +QWaylandGraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); if (system.toLower() == "wayland-brcm") @@ -67,4 +69,6 @@ GraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& sy return 0; } +QT_END_NAMESPACE + #include "main.moc" diff --git a/src/plugins/waylandcompositors/wayland-egl/main.cpp b/src/plugins/waylandcompositors/wayland-egl/main.cpp index ee546dadd..75a9fba29 100644 --- a/src/plugins/waylandcompositors/wayland-egl/main.cpp +++ b/src/plugins/waylandcompositors/wayland-egl/main.cpp @@ -39,16 +39,18 @@ ** ****************************************************************************/ -#include +#include #include "waylandeglintegration.h" -class QWaylandIntegrationPlugin : public GraphicsHardwareIntegrationPlugin +QT_BEGIN_NAMESPACE + +class QWaylandIntegrationPlugin : public QWaylandGraphicsHardwareIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Compositor.GraphicsHardwareIntegrationFactoryInterface.5.1" FILE "wayland-egl.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Compositor.QWaylandGraphicsHardwareIntegrationFactoryInterface.5.1" FILE "wayland-egl.json") public: QStringList keys() const; - GraphicsHardwareIntegration *create(const QString&, const QStringList&); + QWaylandGraphicsHardwareIntegration *create(const QString&, const QStringList&); }; QStringList QWaylandIntegrationPlugin::keys() const @@ -58,7 +60,7 @@ QStringList QWaylandIntegrationPlugin::keys() const return list; } -GraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) +QWaylandGraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); if (system.toLower() == "wayland-egl") @@ -67,4 +69,6 @@ GraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& sy return 0; } +QT_END_NAMESPACE + #include "main.moc" diff --git a/src/plugins/waylandcompositors/wayland-egl/wayland-egl.pro b/src/plugins/waylandcompositors/wayland-egl/wayland-egl.pro index 991baceea..cc980be36 100644 --- a/src/plugins/waylandcompositors/wayland-egl/wayland-egl.pro +++ b/src/plugins/waylandcompositors/wayland-egl/wayland-egl.pro @@ -1,7 +1,7 @@ PLUGIN_TYPE = waylandcompositors load(qt_plugin) -QT = compositor core-private gui-private +QT = compositor compositor-private core-private gui-private OTHER_FILES += wayland-egl.json diff --git a/src/plugins/waylandcompositors/wayland-egl/waylandeglintegration.cpp b/src/plugins/waylandcompositors/wayland-egl/waylandeglintegration.cpp index 728776bbe..2a923ceff 100644 --- a/src/plugins/waylandcompositors/wayland-egl/waylandeglintegration.cpp +++ b/src/plugins/waylandcompositors/wayland-egl/waylandeglintegration.cpp @@ -40,8 +40,8 @@ #include "waylandeglintegration.h" -#include -#include +#include +#include #include #include #include @@ -72,6 +72,8 @@ typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); #endif +QT_USE_NAMESPACE + class WaylandEglIntegrationPrivate { public: @@ -103,12 +105,12 @@ public: }; WaylandEglIntegration::WaylandEglIntegration() - : GraphicsHardwareIntegration() + : QWaylandGraphicsHardwareIntegration() , d_ptr(new WaylandEglIntegrationPrivate) { } -void WaylandEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) +void WaylandEglIntegration::initializeHardware(QtWayland::Display *waylandDisplay) { Q_D(WaylandEglIntegration); @@ -189,12 +191,12 @@ bool WaylandEglIntegration::isYInverted(struct wl_buffer *buffer) const #ifdef EGL_WL_request_client_buffer_format return eglGetBufferYInvertedWL(buffer); #else - return GraphicsHardwareIntegration::isYInverted(buffer); + return QWaylandGraphicsHardwareIntegration::isYInverted(buffer); #endif } -bool WaylandEglIntegration::setDirectRenderSurface(WaylandSurface *surface) +bool WaylandEglIntegration::setDirectRenderSurface(QWaylandSurface *surface) { Q_D(WaylandEglIntegration); diff --git a/src/plugins/waylandcompositors/wayland-egl/waylandeglintegration.h b/src/plugins/waylandcompositors/wayland-egl/waylandeglintegration.h index de5529e21..c22ff3158 100644 --- a/src/plugins/waylandcompositors/wayland-egl/waylandeglintegration.h +++ b/src/plugins/waylandcompositors/wayland-egl/waylandeglintegration.h @@ -41,23 +41,25 @@ #ifndef WAYLANDEGLINTEGRATION_H #define WAYLANDEGLINTEGRATION_H -#include +#include #include +QT_BEGIN_NAMESPACE + class WaylandEglIntegrationPrivate; -class WaylandEglIntegration : public GraphicsHardwareIntegration +class WaylandEglIntegration : public QWaylandGraphicsHardwareIntegration { Q_DECLARE_PRIVATE(WaylandEglIntegration) public: WaylandEglIntegration(); - void initializeHardware(Wayland::Display *waylandDisplay); + void initializeHardware(QtWayland::Display *waylandDisplay); GLuint createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context); bool isYInverted(struct wl_buffer *) const; - bool setDirectRenderSurface(WaylandSurface *); + bool setDirectRenderSurface(QWaylandSurface *); virtual void *lockNativeBuffer(struct wl_buffer *buffer, QOpenGLContext *context) const; virtual void unlockNativeBuffer(void *native_buffer, QOpenGLContext *context) const; @@ -67,5 +69,7 @@ private: QScopedPointer d_ptr; }; +QT_END_NAMESPACE + #endif // WAYLANDEGLINTEGRATION_H diff --git a/src/plugins/waylandcompositors/xcomposite-egl/main.cpp b/src/plugins/waylandcompositors/xcomposite-egl/main.cpp index 6a913e276..3540d3517 100644 --- a/src/plugins/waylandcompositors/xcomposite-egl/main.cpp +++ b/src/plugins/waylandcompositors/xcomposite-egl/main.cpp @@ -39,16 +39,18 @@ ** ****************************************************************************/ -#include +#include #include "xcompositeeglintegration.h" -class QWaylandIntegrationPlugin : public GraphicsHardwareIntegrationPlugin +QT_BEGIN_NAMESPACE + +class QWaylandIntegrationPlugin : public QWaylandGraphicsHardwareIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Compositor.GraphicsHardwareIntegrationFactoryInterface.5.1" FILE "xcomposite-egl.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Compositor.QWaylandGraphicsHardwareIntegrationFactoryInterface.5.1" FILE "xcomposite-egl.json") public: QStringList keys() const; - GraphicsHardwareIntegration *create(const QString&, const QStringList&); + QWaylandGraphicsHardwareIntegration *create(const QString&, const QStringList&); }; QStringList QWaylandIntegrationPlugin::keys() const @@ -58,7 +60,7 @@ QStringList QWaylandIntegrationPlugin::keys() const return list; } -GraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) +QWaylandGraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); if (system.toLower() == "wayland-xcomposite") @@ -67,4 +69,6 @@ GraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& sy return 0; } +QT_END_NAMESPACE + #include "main.moc" diff --git a/src/plugins/waylandcompositors/xcomposite-egl/xcomposite-egl.pro b/src/plugins/waylandcompositors/xcomposite-egl/xcomposite-egl.pro index e42d37a37..d463e6e83 100644 --- a/src/plugins/waylandcompositors/xcomposite-egl/xcomposite-egl.pro +++ b/src/plugins/waylandcompositors/xcomposite-egl/xcomposite-egl.pro @@ -1,7 +1,7 @@ PLUGIN_TYPE = waylandcompositors load(qt_plugin) -QT = compositor core-private gui-private +QT = compositor compositor-private core-private gui-private OTHER_FILES += xcomposite-egl.json diff --git a/src/plugins/waylandcompositors/xcomposite-egl/xcompositeeglintegration.cpp b/src/plugins/waylandcompositors/xcomposite-egl/xcompositeeglintegration.cpp index e403cc8e2..0c291bb16 100644 --- a/src/plugins/waylandcompositors/xcomposite-egl/xcompositeeglintegration.cpp +++ b/src/plugins/waylandcompositors/xcomposite-egl/xcompositeeglintegration.cpp @@ -40,10 +40,10 @@ #include "xcompositeeglintegration.h" -#include "waylandobject.h" +#include #include "wayland-xcomposite-server-protocol.h" -#include +#include #include #include #include @@ -54,6 +54,8 @@ #include +QT_USE_NAMESPACE + QVector eglbuildSpec() { QVector spec; @@ -72,13 +74,13 @@ struct wl_xcomposite_interface XCompositeHandler::xcomposite_interface = { }; XCompositeEglIntegration::XCompositeEglIntegration() - : GraphicsHardwareIntegration() + : QWaylandGraphicsHardwareIntegration() , mDisplay(0) { } -void XCompositeEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) +void XCompositeEglIntegration::initializeHardware(QtWayland::Display *waylandDisplay) { QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); if (nativeInterface) { @@ -98,7 +100,7 @@ void XCompositeEglIntegration::initializeHardware(Wayland::Display *waylandDispl GLuint XCompositeEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *) { - XCompositeBuffer *compositorBuffer = Wayland::wayland_cast(buffer); + XCompositeBuffer *compositorBuffer = QtWayland::wayland_cast(buffer); Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window()); QVector eglConfigSpec = eglbuildSpec(); @@ -141,6 +143,6 @@ GLuint XCompositeEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpe bool XCompositeEglIntegration::isYInverted(wl_buffer *buffer) const { - XCompositeBuffer *compositorBuffer = Wayland::wayland_cast(buffer); + XCompositeBuffer *compositorBuffer = QtWayland::wayland_cast(buffer); return compositorBuffer->isYInverted(); } diff --git a/src/plugins/waylandcompositors/xcomposite-egl/xcompositeeglintegration.h b/src/plugins/waylandcompositors/xcomposite-egl/xcompositeeglintegration.h index 7bcbfc734..7a9ac4499 100644 --- a/src/plugins/waylandcompositors/xcomposite-egl/xcompositeeglintegration.h +++ b/src/plugins/waylandcompositors/xcomposite-egl/xcompositeeglintegration.h @@ -41,18 +41,20 @@ #ifndef XCOMPOSITEEGLINTEGRATION_H #define XCOMPOSITEEGLINTEGRATION_H -#include +#include #include "xlibinclude.h" #include -class XCompositeEglIntegration : public GraphicsHardwareIntegration +QT_BEGIN_NAMESPACE + +class XCompositeEglIntegration : public QWaylandGraphicsHardwareIntegration { public: XCompositeEglIntegration(); - void initializeHardware(Wayland::Display *waylandDisplay); + void initializeHardware(QtWayland::Display *waylandDisplay); GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context); bool isYInverted(wl_buffer *) const; @@ -63,4 +65,6 @@ private: int mScreen; }; +QT_END_NAMESPACE + #endif // XCOMPOSITEEGLINTEGRATION_H diff --git a/src/plugins/waylandcompositors/xcomposite-glx/main.cpp b/src/plugins/waylandcompositors/xcomposite-glx/main.cpp index dfd727163..fdc7037ea 100644 --- a/src/plugins/waylandcompositors/xcomposite-glx/main.cpp +++ b/src/plugins/waylandcompositors/xcomposite-glx/main.cpp @@ -39,16 +39,18 @@ ** ****************************************************************************/ -#include +#include #include "xcompositeglxintegration.h" -class QWaylandIntegrationPlugin : public GraphicsHardwareIntegrationPlugin +QT_BEGIN_NAMESPACE + +class QWaylandIntegrationPlugin : public QWaylandGraphicsHardwareIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Compositor.GraphicsHardwareIntegrationFactoryInterface.5.1" FILE "xcomposite-glx.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Compositor.QWaylandGraphicsHardwareIntegrationFactoryInterface.5.1" FILE "xcomposite-glx.json") public: QStringList keys() const; - GraphicsHardwareIntegration *create(const QString&, const QStringList&); + QWaylandGraphicsHardwareIntegration *create(const QString&, const QStringList&); }; QStringList QWaylandIntegrationPlugin::keys() const @@ -58,7 +60,7 @@ QStringList QWaylandIntegrationPlugin::keys() const return list; } -GraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) +QWaylandGraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); if (system.toLower() == "wayland-xcomposite") @@ -67,4 +69,6 @@ GraphicsHardwareIntegration *QWaylandIntegrationPlugin::create(const QString& sy return 0; } +QT_END_NAMESPACE + #include "main.moc" diff --git a/src/plugins/waylandcompositors/xcomposite-glx/xcomposite-glx.pro b/src/plugins/waylandcompositors/xcomposite-glx/xcomposite-glx.pro index c14a9f639..dc2d70dee 100644 --- a/src/plugins/waylandcompositors/xcomposite-glx/xcomposite-glx.pro +++ b/src/plugins/waylandcompositors/xcomposite-glx/xcomposite-glx.pro @@ -1,7 +1,7 @@ PLUGIN_TYPE = waylandcompositors load(qt_plugin) -QT = compositor core-private gui-private +QT = compositor compositor-private core-private gui-private OTHER_FILES += xcomposite-glx.json diff --git a/src/plugins/waylandcompositors/xcomposite-glx/xcompositeglxintegration.cpp b/src/plugins/waylandcompositors/xcomposite-glx/xcompositeglxintegration.cpp index c6cc8a569..1ad8aa978 100644 --- a/src/plugins/waylandcompositors/xcomposite-glx/xcompositeglxintegration.cpp +++ b/src/plugins/waylandcompositors/xcomposite-glx/xcompositeglxintegration.cpp @@ -40,8 +40,8 @@ #include "xcompositeglxintegration.h" -#include "waylandobject.h" -#include +#include +#include #include "wayland-xcomposite-server-protocol.h" #include @@ -54,6 +54,8 @@ #include +QT_USE_NAMESPACE + QVector qglx_buildSpec() { QVector spec(48); @@ -75,7 +77,7 @@ struct wl_xcomposite_interface XCompositeHandler::xcomposite_interface = { }; XCompositeGLXIntegration::XCompositeGLXIntegration() - : GraphicsHardwareIntegration() + : QWaylandGraphicsHardwareIntegration() , mDisplay(0) , mHandler(0) { @@ -86,7 +88,7 @@ XCompositeGLXIntegration::~XCompositeGLXIntegration() delete mHandler; } -void XCompositeGLXIntegration::initializeHardware(Wayland::Display *waylandDisplay) +void XCompositeGLXIntegration::initializeHardware(QtWayland::Display *waylandDisplay) { QPlatformNativeInterface *nativeInterface = QGuiApplicationPrivate::platformIntegration()->nativeInterface(); if (nativeInterface) { @@ -118,7 +120,7 @@ void XCompositeGLXIntegration::initializeHardware(Wayland::Display *waylandDispl GLuint XCompositeGLXIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *) { - XCompositeBuffer *compositorBuffer = Wayland::wayland_cast(buffer); + XCompositeBuffer *compositorBuffer = QtWayland::wayland_cast(buffer); Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window()); QVector glxConfigSpec = qglx_buildSpec(); @@ -151,6 +153,6 @@ GLuint XCompositeGLXIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpe bool XCompositeGLXIntegration::isYInverted(wl_buffer *buffer) const { - XCompositeBuffer *compositorBuffer = Wayland::wayland_cast(buffer); + XCompositeBuffer *compositorBuffer = QtWayland::wayland_cast(buffer); return compositorBuffer->isYInverted(); } diff --git a/src/plugins/waylandcompositors/xcomposite-glx/xcompositeglxintegration.h b/src/plugins/waylandcompositors/xcomposite-glx/xcompositeglxintegration.h index c17e1ac97..8e4db3937 100644 --- a/src/plugins/waylandcompositors/xcomposite-glx/xcompositeglxintegration.h +++ b/src/plugins/waylandcompositors/xcomposite-glx/xcompositeglxintegration.h @@ -41,7 +41,7 @@ #ifndef XCOMPOSITEGLXINTEGRATION_H #define XCOMPOSITEGLXINTEGRATION_H -#include +#include #include "xlibinclude.h" @@ -49,15 +49,17 @@ #include #include +QT_BEGIN_NAMESPACE + class XCompositeHandler; -class XCompositeGLXIntegration : public GraphicsHardwareIntegration +class XCompositeGLXIntegration : public QWaylandGraphicsHardwareIntegration { public: XCompositeGLXIntegration(); ~XCompositeGLXIntegration(); - void initializeHardware(Wayland::Display *waylandDisplay); + void initializeHardware(QtWayland::Display *waylandDisplay); GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context); bool isYInverted(wl_buffer *) const; @@ -71,4 +73,6 @@ private: XCompositeHandler *mHandler; }; +QT_END_NAMESPACE + #endif // XCOMPOSITEGLXINTEGRATION_H diff --git a/src/plugins/waylandcompositors/xcomposite_share/xcompositebuffer.cpp b/src/plugins/waylandcompositors/xcomposite_share/xcompositebuffer.cpp index 9e6c4e64e..4644cf29e 100644 --- a/src/plugins/waylandcompositors/xcomposite_share/xcompositebuffer.cpp +++ b/src/plugins/waylandcompositors/xcomposite_share/xcompositebuffer.cpp @@ -40,7 +40,9 @@ #include "xcompositebuffer.h" -XCompositeBuffer::XCompositeBuffer(Wayland::Compositor *compositor, Window window, const QSize &size) +QT_USE_NAMESPACE + +XCompositeBuffer::XCompositeBuffer(QtWayland::Compositor *compositor, Window window, const QSize &size) : mWindow(window) , mInvertedY(false) { diff --git a/src/plugins/waylandcompositors/xcomposite_share/xcompositebuffer.h b/src/plugins/waylandcompositors/xcomposite_share/xcompositebuffer.h index bc04ca0c9..bbcfe2bd3 100644 --- a/src/plugins/waylandcompositors/xcomposite_share/xcompositebuffer.h +++ b/src/plugins/waylandcompositors/xcomposite_share/xcompositebuffer.h @@ -41,8 +41,8 @@ #ifndef XCOMPOSITEBUFFER_H #define XCOMPOSITEBUFFER_H -#include "waylandobject.h" -#include +#include +#include #include @@ -53,10 +53,12 @@ #include -class XCompositeBuffer : public Wayland::Object +QT_BEGIN_NAMESPACE + +class XCompositeBuffer : public QtWayland::Object { public: - XCompositeBuffer(Wayland::Compositor *compositor, Window window, const QSize &size); + XCompositeBuffer(QtWayland::Compositor *compositor, Window window, const QSize &size); Window window(); @@ -73,4 +75,6 @@ private: struct wl_resource *buffer); }; +QT_END_NAMESPACE + #endif // XCOMPOSITORBUFFER_H diff --git a/src/plugins/waylandcompositors/xcomposite_share/xcompositehandler.cpp b/src/plugins/waylandcompositors/xcomposite_share/xcompositehandler.cpp index 7bb63e2b2..731963157 100644 --- a/src/plugins/waylandcompositors/xcomposite_share/xcompositehandler.cpp +++ b/src/plugins/waylandcompositors/xcomposite_share/xcompositehandler.cpp @@ -45,7 +45,9 @@ #include "xcompositebuffer.h" #include -XCompositeHandler::XCompositeHandler(Wayland::Compositor *compositor, Display *display, QWindow *window) +QT_USE_NAMESPACE + +XCompositeHandler::XCompositeHandler(QtWayland::Compositor *compositor, Display *display, QWindow *window) : mCompositor(compositor) , mwindow(window) , mDisplay(display) diff --git a/src/plugins/waylandcompositors/xcomposite_share/xcompositehandler.h b/src/plugins/waylandcompositors/xcomposite_share/xcompositehandler.h index 59f7ab1bd..e85f3565a 100644 --- a/src/plugins/waylandcompositors/xcomposite_share/xcompositehandler.h +++ b/src/plugins/waylandcompositors/xcomposite_share/xcompositehandler.h @@ -41,22 +41,24 @@ #ifndef XCOMPOSITEHANDLER_H #define XCOMPOSITEHANDLER_H -#include -#include "waylandobject.h" +#include +#include #include "xlibinclude.h" -class XCompositeHandler : public Wayland::Object +QT_BEGIN_NAMESPACE + +class XCompositeHandler : public QtWayland::Object { public: - XCompositeHandler(Wayland::Compositor *compositor, Display *display, QWindow *window); + XCompositeHandler(QtWayland::Compositor *compositor, Display *display, QWindow *window); void createBuffer(struct wl_client *client, uint32_t id, Window window, const QSize &size); static void xcomposite_bind_func(struct wl_client *client, void *data, uint32_t version, uint32_t id); static struct wl_xcomposite_interface xcomposite_interface; private: - Wayland::Compositor *mCompositor; + QtWayland::Compositor *mCompositor; QWindow *mwindow; QWindow *mFakeRootWindow; Display *mDisplay; @@ -70,4 +72,6 @@ private: }; +QT_END_NAMESPACE + #endif // XCOMPOSITEHANDLER_H diff --git a/src/shared/qwaylandmimehelper.cpp b/src/shared/qwaylandmimehelper.cpp index ccc48ef2c..d7e511440 100644 --- a/src/shared/qwaylandmimehelper.cpp +++ b/src/shared/qwaylandmimehelper.cpp @@ -46,6 +46,8 @@ #include #include +QT_USE_NAMESPACE + QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &mimeType) { QByteArray content; diff --git a/src/shared/qwaylandmimehelper.h b/src/shared/qwaylandmimehelper.h index f31685cd6..539fc3adc 100644 --- a/src/shared/qwaylandmimehelper.h +++ b/src/shared/qwaylandmimehelper.h @@ -46,10 +46,14 @@ #include #include +QT_BEGIN_NAMESPACE + class QWaylandMimeHelper { public: static QByteArray getByteArray(QMimeData *mimeData, const QString &mimeType); }; +QT_END_NAMESPACE + #endif diff --git a/tests/auto/compositor/testcompositor.cpp b/tests/auto/compositor/testcompositor.cpp index c5758753e..aa15a6ab5 100644 --- a/tests/auto/compositor/testcompositor.cpp +++ b/tests/auto/compositor/testcompositor.cpp @@ -41,12 +41,12 @@ #include "testcompositor.h" -void TestCompositor::surfaceCreated(WaylandSurface *surface) +void TestCompositor::surfaceCreated(QWaylandSurface *surface) { surfaces << surface; } -void TestCompositor::surfaceAboutToBeDestroyed(WaylandSurface *surface) +void TestCompositor::surfaceAboutToBeDestroyed(QWaylandSurface *surface) { surfaces.removeOne(surface); } diff --git a/tests/auto/compositor/testcompositor.h b/tests/auto/compositor/testcompositor.h index 785024cd7..4cb77aabc 100644 --- a/tests/auto/compositor/testcompositor.h +++ b/tests/auto/compositor/testcompositor.h @@ -39,15 +39,15 @@ ** ****************************************************************************/ -#include "waylandcompositor.h" -#include "waylandsurface.h" +#include "qwaylandcompositor.h" +#include "qwaylandsurface.h" -class TestCompositor : public WaylandCompositor +class TestCompositor : public QWaylandCompositor { public: - void surfaceCreated(WaylandSurface *surface); - void surfaceAboutToBeDestroyed(WaylandSurface *surface); + void surfaceCreated(QWaylandSurface *surface); + void surfaceAboutToBeDestroyed(QWaylandSurface *surface); - QList surfaces; + QList surfaces; }; diff --git a/tests/auto/compositor/tst_compositor.cpp b/tests/auto/compositor/tst_compositor.cpp index 65dd6e234..8656338ef 100644 --- a/tests/auto/compositor/tst_compositor.cpp +++ b/tests/auto/compositor/tst_compositor.cpp @@ -78,7 +78,7 @@ void tst_WaylandCompositor::singleClient() QCOMPARE(ca, cb); - QList surfaces = compositor.surfacesForClient(ca); + QList surfaces = compositor.surfacesForClient(ca); QCOMPARE(surfaces.size(), 2); QVERIFY((surfaces.at(0) == compositor.surfaces.at(0) && surfaces.at(1) == compositor.surfaces.at(1)) || (surfaces.at(0) == compositor.surfaces.at(1) && surfaces.at(1) == compositor.surfaces.at(0))); @@ -149,12 +149,12 @@ void tst_WaylandCompositor::mapSurface() wl_surface *surface = client.createSurface(); QTRY_COMPARE(compositor.surfaces.size(), 1); - WaylandSurface *waylandSurface = compositor.surfaces.at(0); + QWaylandSurface *waylandSurface = compositor.surfaces.at(0); QSignalSpy mappedSpy(waylandSurface, SIGNAL(mapped())); QCOMPARE(waylandSurface->size(), QSize()); - QCOMPARE(waylandSurface->type(), WaylandSurface::Invalid); + QCOMPARE(waylandSurface->type(), QWaylandSurface::Invalid); QSize size(256, 256); ShmBuffer buffer(size, client.shm); @@ -163,7 +163,7 @@ void tst_WaylandCompositor::mapSurface() wl_surface_damage(surface, 0, 0, size.width(), size.height()); QTRY_COMPARE(waylandSurface->size(), size); - QTRY_COMPARE(waylandSurface->type(), WaylandSurface::Shm); + QTRY_COMPARE(waylandSurface->type(), QWaylandSurface::Shm); QTRY_COMPARE(mappedSpy.count(), 1); wl_surface_destroy(surface); @@ -199,14 +199,14 @@ void tst_WaylandCompositor::frameCallback() int frameCounter = 0; QTRY_COMPARE(compositor.surfaces.size(), 1); - WaylandSurface *waylandSurface = compositor.surfaces.at(0); + QWaylandSurface *waylandSurface = compositor.surfaces.at(0); QSignalSpy damagedSpy(waylandSurface, SIGNAL(damaged(const QRect &))); for (int i = 0; i < 10; ++i) { registerFrameCallback(surface, &frameCounter); wl_surface_damage(surface, 0, 0, size.width(), size.height()); - QTRY_COMPARE(waylandSurface->type(), WaylandSurface::Shm); + QTRY_COMPARE(waylandSurface->type(), QWaylandSurface::Shm); QTRY_COMPARE(damagedSpy.count(), i + 1); QCOMPARE(waylandSurface->image(), buffer.image); -- cgit v1.2.3