summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-12-02 14:00:44 +0100
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-12-02 14:01:08 +0100
commit05bf419b206f3cd078364cf67af2df4e4d1477c0 (patch)
treec942e884e8f75a29bd9f281c993fbc85a0b832ed
parentdd5e1ffd3e9e379574325193c8546d453c11303e (diff)
parent3698b116a1973146b76319673cdb6787f13f2de6 (diff)
Merge branch 'wip-compositor-api' into dev
This introduces the new compositor API, removing the old API (which was never officially supported). Change-Id: I1dc01f0fb4edc749e34ed8356e56ad87d7d64913
-rw-r--r--.gitignore11
-rw-r--r--examples/wayland/custom-extension/client/.gitignore4
-rw-r--r--examples/wayland/custom-extension/client/client.json3
-rw-r--r--examples/wayland/custom-extension/client/client.pro18
-rw-r--r--examples/wayland/custom-extension/client/customextension.cpp85
-rw-r--r--examples/wayland/custom-extension/client/customextension.h (renamed from examples/wayland/qwindow-compositor/textureblitter.h)52
-rw-r--r--examples/wayland/custom-extension/client/main.cpp (renamed from src/compositor/wayland_wrapper/qwlqttouch_p.h)68
-rw-r--r--examples/wayland/custom-extension/compositor/.gitignore8
-rw-r--r--examples/wayland/custom-extension/compositor/compositor.pro34
-rw-r--r--examples/wayland/custom-extension/compositor/compositor.qrc7
-rw-r--r--examples/wayland/custom-extension/compositor/customextension.cpp76
-rw-r--r--examples/wayland/custom-extension/compositor/customextension.h (renamed from src/compositor/wayland_wrapper/qwlqtkey_p.h)50
-rw-r--r--examples/wayland/custom-extension/compositor/images/background.pngbin0 -> 203 bytes
-rw-r--r--examples/wayland/custom-extension/compositor/main.cpp (renamed from src/compositor/wayland_wrapper/qwltextinputmanager.cpp)39
-rw-r--r--examples/wayland/custom-extension/compositor/qml/Screen.qml92
-rw-r--r--examples/wayland/custom-extension/compositor/qml/main.qml (renamed from examples/wayland/qml-compositor/ContrastEffect.qml)96
-rw-r--r--examples/wayland/custom-extension/custom-extension.pro7
-rw-r--r--examples/wayland/custom-extension/protocol/custom.xml62
-rw-r--r--examples/wayland/custom-extension/testapp/main.cpp111
-rw-r--r--examples/wayland/custom-extension/testapp/testapp.pro6
-rw-r--r--examples/wayland/multi-output/doc/src/multi-output.qdoc41
-rw-r--r--examples/wayland/multi-output/images/background.jpg (renamed from examples/wayland/qml-compositor/background.jpg)bin30730 -> 30730 bytes
-rw-r--r--examples/wayland/multi-output/main.cpp (renamed from src/compositor/wayland_wrapper/qwldisplay.cpp)28
-rw-r--r--examples/wayland/multi-output/multi-output.pro16
-rw-r--r--examples/wayland/multi-output/multi-output.qrc9
-rw-r--r--examples/wayland/multi-output/qml/GridScreen.qml (renamed from src/compositor/wayland_wrapper/qwlqtkey.cpp)80
-rw-r--r--examples/wayland/multi-output/qml/ShellChrome.qml (renamed from src/compositor/wayland_wrapper/qwldisplay_p.h)62
-rw-r--r--examples/wayland/multi-output/qml/ShellScreen.qml76
-rw-r--r--examples/wayland/multi-output/qml/main.qml104
-rw-r--r--examples/wayland/pure-qml/doc/src/pure-qml.qdoc36
-rw-r--r--examples/wayland/pure-qml/images/background.jpgbin0 -> 30730 bytes
-rw-r--r--examples/wayland/pure-qml/main.cpp (renamed from examples/wayland/qml-compositor/WindowChrome.qml)32
-rw-r--r--examples/wayland/pure-qml/pure-qml.pro17
-rw-r--r--examples/wayland/pure-qml/pure-qml.qrc8
-rw-r--r--examples/wayland/pure-qml/qml/Chrome.qml73
-rw-r--r--examples/wayland/pure-qml/qml/Screen.qml79
-rw-r--r--examples/wayland/pure-qml/qml/main.qml86
-rw-r--r--examples/wayland/qml-compositor/WindowContainer.qml212
-rw-r--r--examples/wayland/qml-compositor/closebutton.pngbin25957 -> 0 bytes
-rw-r--r--examples/wayland/qml-compositor/compositor.js155
-rw-r--r--examples/wayland/qml-compositor/main.cpp160
-rw-r--r--examples/wayland/qml-compositor/main.qml127
-rw-r--r--examples/wayland/qml-compositor/qml-compositor.pro22
-rw-r--r--examples/wayland/qwindow-compositor/compositorwindow.cpp220
-rw-r--r--examples/wayland/qwindow-compositor/compositorwindow.h59
-rw-r--r--examples/wayland/qwindow-compositor/doc/src/qwindow-compositor.qdoc36
-rw-r--r--examples/wayland/qwindow-compositor/main.cpp33
-rw-r--r--examples/wayland/qwindow-compositor/qwindow-compositor.pro15
-rw-r--r--examples/wayland/qwindow-compositor/qwindow-compositor.qrc2
-rw-r--r--examples/wayland/qwindow-compositor/qwindowcompositor.cpp485
-rw-r--r--examples/wayland/qwindow-compositor/qwindowcompositor.h117
-rw-r--r--examples/wayland/qwindow-compositor/textureblitter.cpp199
-rw-r--r--examples/wayland/qwindow-compositor/windowcompositor.cpp300
-rw-r--r--examples/wayland/qwindow-compositor/windowcompositor.h133
-rw-r--r--examples/wayland/server-buffer/client/client.pro8
-rw-r--r--examples/wayland/server-buffer/compositor/compositor.pro19
-rw-r--r--examples/wayland/server-buffer/compositor/main.cpp85
-rw-r--r--examples/wayland/server-buffer/compositor/serverbufferitem.cpp2
-rw-r--r--examples/wayland/wayland.pro16
-rw-r--r--src/client/qwaylandabstractdecoration.cpp4
-rw-r--r--src/client/qwaylanddatadevice.cpp48
-rw-r--r--src/client/qwaylanddatadevice_p.h48
-rw-r--r--src/client/qwaylanddisplay_p.h1
-rw-r--r--src/client/qwaylanddnd_p.h2
-rw-r--r--src/client/qwaylandinputcontext.cpp48
-rw-r--r--src/client/qwaylandinputcontext_p.h48
-rw-r--r--src/client/qwaylandwindow.cpp7
-rw-r--r--src/compositor/compositor.pro6
-rw-r--r--src/compositor/compositor_api/compositor_api.pri33
-rw-r--r--src/compositor/compositor_api/qwaylandbufferref.cpp193
-rw-r--r--src/compositor/compositor_api/qwaylandbufferref.h59
-rw-r--r--src/compositor/compositor_api/qwaylandclient.cpp169
-rw-r--r--src/compositor/compositor_api/qwaylandclient.h59
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp840
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.h185
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor_p.h200
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener.cpp72
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener.h66
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener_p.h (renamed from src/compositor/wayland_wrapper/qwllistener_p.h)45
-rw-r--r--src/compositor/compositor_api/qwaylanddrag.cpp106
-rw-r--r--src/compositor/compositor_api/qwaylanddrag.h77
-rw-r--r--src/compositor/compositor_api/qwaylandglobalinterface.cpp55
-rw-r--r--src/compositor/compositor_api/qwaylandglobalinterface.h65
-rw-r--r--src/compositor/compositor_api/qwaylandinput.cpp405
-rw-r--r--src/compositor/compositor_api/qwaylandinput.h122
-rw-r--r--src/compositor/compositor_api/qwaylandinput_p.h130
-rw-r--r--src/compositor/compositor_api/qwaylandinputpanel.cpp95
-rw-r--r--src/compositor/compositor_api/qwaylandinputpanel.h65
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.cpp566
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.h113
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard_p.h139
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp843
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.h127
-rw-r--r--src/compositor/compositor_api/qwaylandoutput_p.h134
-rw-r--r--src/compositor/compositor_api/qwaylandpointer.cpp368
-rw-r--r--src/compositor/compositor_api/qwaylandpointer.h93
-rw-r--r--src/compositor/compositor_api/qwaylandpointer_p.h105
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.cpp95
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.h45
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp775
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.h152
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem_p.h126
-rw-r--r--src/compositor/compositor_api/qwaylandquickoutput.cpp97
-rw-r--r--src/compositor/compositor_api/qwaylandquickoutput.h46
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.cpp152
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.h51
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp870
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h246
-rw-r--r--src/compositor/compositor_api/qwaylandsurface_p.h150
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceinterface.cpp143
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceinterface.h127
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceitem.cpp425
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceitem.h146
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceview.cpp94
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceview.h67
-rw-r--r--src/compositor/compositor_api/qwaylandtouch.cpp271
-rw-r--r--src/compositor/compositor_api/qwaylandtouch.h81
-rw-r--r--src/compositor/compositor_api/qwaylandtouch_p.h102
-rw-r--r--src/compositor/compositor_api/qwaylandview.cpp343
-rw-r--r--src/compositor/compositor_api/qwaylandview.h97
-rw-r--r--src/compositor/compositor_api/qwaylandview_p.h97
-rw-r--r--src/compositor/doc/compositor.qdocconf44
-rw-r--r--src/compositor/doc/src/qtwaylandcompositor-cpp.qdoc50
-rw-r--r--src/compositor/doc/src/qtwaylandcompositor-examples.qdoc36
-rw-r--r--src/compositor/doc/src/qtwaylandcompositor-overview.qdoc68
-rw-r--r--src/compositor/doc/src/qtwaylandcompositor-qmltypes.qdoc52
-rw-r--r--src/compositor/extensions/extensions.pri48
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp241
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.h86
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h92
-rw-r--r--src/compositor/extensions/qwaylandshell.cpp552
-rw-r--r--src/compositor/extensions/qwaylandshell.h146
-rw-r--r--src/compositor/extensions/qwaylandshell_p.h150
-rw-r--r--src/compositor/extensions/qwaylandwindowmanagerextension.cpp114
-rw-r--r--src/compositor/extensions/qwaylandwindowmanagerextension.h73
-rw-r--r--src/compositor/extensions/qwaylandwindowmanagerextension_p.h77
-rw-r--r--src/compositor/extensions/qwlextendedsurface.cpp (renamed from src/compositor/wayland_wrapper/qwlextendedsurface.cpp)124
-rw-r--r--src/compositor/extensions/qwlextendedsurface_p.h161
-rw-r--r--src/compositor/extensions/qwlinputmethod.cpp152
-rw-r--r--src/compositor/extensions/qwlinputmethod_p.h105
-rw-r--r--src/compositor/extensions/qwlinputmethodcontext.cpp (renamed from src/compositor/wayland_wrapper/qwlinputmethodcontext.cpp)50
-rw-r--r--src/compositor/extensions/qwlinputmethodcontext_p.h (renamed from src/compositor/wayland_wrapper/qwlinputmethodcontext_p.h)52
-rw-r--r--src/compositor/extensions/qwlinputpanel.cpp130
-rw-r--r--src/compositor/extensions/qwlinputpanel_p.h99
-rw-r--r--src/compositor/extensions/qwlinputpanelsurface.cpp86
-rw-r--r--src/compositor/extensions/qwlinputpanelsurface_p.h95
-rw-r--r--src/compositor/extensions/qwlqtkey.cpp78
-rw-r--r--src/compositor/extensions/qwlqtkey_p.h80
-rw-r--r--src/compositor/extensions/qwlqttouch.cpp (renamed from src/compositor/wayland_wrapper/qwlqttouch.cpp)77
-rw-r--r--src/compositor/extensions/qwlqttouch_p.h104
-rw-r--r--src/compositor/extensions/qwltextinput.cpp (renamed from src/compositor/wayland_wrapper/qwltextinput.cpp)97
-rw-r--r--src/compositor/extensions/qwltextinput_p.h (renamed from src/compositor/wayland_wrapper/qwltextinput_p.h)68
-rw-r--r--src/compositor/extensions/qwltextinputmanager.cpp64
-rw-r--r--src/compositor/extensions/qwltextinputmanager_p.h78
-rw-r--r--src/compositor/global/global.pri8
-rw-r--r--src/compositor/global/qwaylandexport.h56
-rw-r--r--src/compositor/global/qwaylandextension.cpp178
-rw-r--r--src/compositor/global/qwaylandextension.h130
-rw-r--r--src/compositor/global/qwaylandextension_p.h84
-rw-r--r--src/compositor/global/qwaylandquickextension.h104
-rw-r--r--src/compositor/hardware_integration/hardware_integration.pri6
-rw-r--r--src/compositor/hardware_integration/qwlclientbufferintegration.cpp56
-rw-r--r--src/compositor/hardware_integration/qwlclientbufferintegration_p.h80
-rw-r--r--src/compositor/hardware_integration/qwlclientbufferintegrationfactory.cpp25
-rw-r--r--src/compositor/hardware_integration/qwlclientbufferintegrationfactory_p.h27
-rw-r--r--src/compositor/hardware_integration/qwlclientbufferintegrationplugin.cpp25
-rw-r--r--src/compositor/hardware_integration/qwlclientbufferintegrationplugin_p.h29
-rw-r--r--src/compositor/hardware_integration/qwlhwintegration.cpp58
-rw-r--r--src/compositor/hardware_integration/qwlhwintegration_p.h62
-rw-r--r--src/compositor/hardware_integration/qwlserverbufferintegration.cpp50
-rw-r--r--src/compositor/hardware_integration/qwlserverbufferintegration_p.h52
-rw-r--r--src/compositor/hardware_integration/qwlserverbufferintegrationfactory.cpp25
-rw-r--r--src/compositor/hardware_integration/qwlserverbufferintegrationfactory_p.h27
-rw-r--r--src/compositor/hardware_integration/qwlserverbufferintegrationplugin.cpp25
-rw-r--r--src/compositor/hardware_integration/qwlserverbufferintegrationplugin_p.h27
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor.cpp618
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor_p.h253
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevice.cpp161
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevice_p.h81
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevicemanager.cpp77
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevicemanager_p.h64
-rw-r--r--src/compositor/wayland_wrapper/qwldataoffer.cpp50
-rw-r--r--src/compositor/wayland_wrapper/qwldataoffer_p.h52
-rw-r--r--src/compositor/wayland_wrapper/qwldatasource.cpp53
-rw-r--r--src/compositor/wayland_wrapper/qwldatasource_p.h52
-rw-r--r--src/compositor/wayland_wrapper/qwlextendedsurface_p.h143
-rw-r--r--src/compositor/wayland_wrapper/qwlinputdevice.cpp365
-rw-r--r--src/compositor/wayland_wrapper/qwlinputdevice_p.h168
-rw-r--r--src/compositor/wayland_wrapper/qwlinputmethod.cpp150
-rw-r--r--src/compositor/wayland_wrapper/qwlinputmethod_p.h105
-rw-r--r--src/compositor/wayland_wrapper/qwlinputpanel.cpp127
-rw-r--r--src/compositor/wayland_wrapper/qwlinputpanel_p.h105
-rw-r--r--src/compositor/wayland_wrapper/qwlinputpanelsurface.cpp91
-rw-r--r--src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h98
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard.cpp444
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard_p.h176
-rw-r--r--src/compositor/wayland_wrapper/qwllistener.cpp62
-rw-r--r--src/compositor/wayland_wrapper/qwloutput.cpp271
-rw-r--r--src/compositor/wayland_wrapper/qwloutput_p.h149
-rw-r--r--src/compositor/wayland_wrapper/qwlpointer.cpp336
-rw-r--r--src/compositor/wayland_wrapper/qwlpointer_p.h159
-rw-r--r--src/compositor/wayland_wrapper/qwlregion.cpp52
-rw-r--r--src/compositor/wayland_wrapper/qwlregion_p.h54
-rw-r--r--src/compositor/wayland_wrapper/qwlshellsurface.cpp557
-rw-r--r--src/compositor/wayland_wrapper/qwlshellsurface_p.h238
-rw-r--r--src/compositor/wayland_wrapper/qwlsubsurface.cpp151
-rw-r--r--src/compositor/wayland_wrapper/qwlsubsurface_p.h103
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp593
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface_p.h307
-rw-r--r--src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp310
-rw-r--r--src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h129
-rw-r--r--src/compositor/wayland_wrapper/qwltextinputmanager_p.h80
-rw-r--r--src/compositor/wayland_wrapper/qwltouch.cpp187
-rw-r--r--src/compositor/wayland_wrapper/qwltouch_p.h131
-rw-r--r--src/compositor/wayland_wrapper/wayland_wrapper.pri46
-rw-r--r--src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp112
-rw-r--r--src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h94
-rw-r--r--src/compositor/windowmanagerprotocol/windowmanagerprotocol.pri9
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h1
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp2
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp50
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h53
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp55
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h52
-rw-r--r--src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp52
-rw-r--r--src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h56
-rw-r--r--src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp50
-rw-r--r--src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h56
-rw-r--r--src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp214
-rw-r--r--src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h66
-rw-r--r--src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp62
-rw-r--r--src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h58
-rw-r--r--src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp61
-rw-r--r--src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h56
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp52
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h59
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp54
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h54
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xlibinclude.h50
-rw-r--r--src/imports/compositor/WaylandCursorItem.qml60
-rw-r--r--src/imports/compositor/WaylandOutputWindow.qml55
-rw-r--r--src/imports/compositor/compositor.pro45
-rw-r--r--src/imports/compositor/plugins.qmltypes231
-rw-r--r--src/imports/compositor/qmldir3
-rw-r--r--src/imports/compositor/qwaylandmousetracker.cpp140
-rw-r--r--src/imports/compositor/qwaylandmousetracker_p.h77
-rw-r--r--src/imports/compositor/qwaylandquickcompositorplugin.cpp151
-rw-r--r--src/imports/imports.pro3
-rw-r--r--src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.pro2
-rw-r--r--src/plugins/hardwareintegration/compositor/brcm-egl/main.cpp2
-rw-r--r--src/plugins/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pro2
-rw-r--r--src/plugins/hardwareintegration/compositor/drm-egl-server/main.cpp2
-rw-r--r--src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro2
-rw-r--r--src/plugins/hardwareintegration/compositor/libhybris-egl-server/main.cpp4
-rw-r--r--src/plugins/hardwareintegration/compositor/wayland-egl/main.cpp4
-rw-r--r--src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro2
-rw-r--r--src/plugins/hardwareintegration/compositor/xcomposite-egl/main.cpp2
-rw-r--r--src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pro2
-rw-r--r--src/plugins/hardwareintegration/compositor/xcomposite-glx/main.cpp2
-rw-r--r--src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pro2
-rw-r--r--src/plugins/hardwareintegration/hardwareintegration.pro5
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp13
-rw-r--r--src/src.pro19
-rw-r--r--sync.profile6
-rw-r--r--tests/auto/compositor/compositor.pro2
265 files changed, 15615 insertions, 13182 deletions
diff --git a/.gitignore b/.gitignore
index 7c685024..e7ba647b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,9 +27,11 @@ lib/
include/
bin/
/plugins/
-examples/wayland/qml-compositor/qml-compositor
-examples/wayland/qwidget-compositor/qwidget-compositor
+/qml/
examples/wayland/qwindow-compositor/qwindow-compositor
+examples/wayland/custom-extension/testapp/testapp
+examples/wayland/multi-output/multi-output
+examples/wayland/pure-qml/pure-qml
examples/wayland/server-buffer/client/client
examples/wayland/server-buffer/client/qwayland-*.cpp
examples/wayland/server-buffer/client/qwayland-*.h
@@ -43,10 +45,14 @@ examples/wayland/server-buffer/compositor/*-protocol.c
examples/wayland/subsurface/subsurface
src/client/qwayland*.cpp
src/client/*-protocol.c
+src/client/QtWaylandClient.version
+src/client/QtWaylandClient.version.in
src/compositor/*-server-protocol.h
src/compositor/*-protocol.c
src/compositor/qwayland-server-*.cpp
src/compositor/qwayland-server-*.h
+src/compositor/QtWaylandCompositor.version
+src/compositor/QtWaylandCompositor.version.in
src/plugins/platforms/*/*-client-protocol.h
src/plugins/platforms/*/*-protocol.c
src/plugins/platforms/*/qwayland-*.cpp
@@ -62,6 +68,7 @@ src/plugins/hardwareintegration/*/*/qwayland*.h
src/plugins/hardwareintegration/*/*/*-server-protocol.h
src/plugins/hardwareintegration/*/*/*-client-protocol.h
src/plugins/hardwareintegration/*/*/*-protocol.c
+src/imports/compositor/compositor.qrc
tests/auto/client/tst_client
tests/auto/compositor/tst_compositor
*~
diff --git a/examples/wayland/custom-extension/client/.gitignore b/examples/wayland/custom-extension/client/.gitignore
new file mode 100644
index 00000000..b4961e18
--- /dev/null
+++ b/examples/wayland/custom-extension/client/.gitignore
@@ -0,0 +1,4 @@
+qwayland-custom.cpp
+qwayland-custom.h
+wayland-custom-client-protocol.h
+wayland-custom-protocol.c
diff --git a/examples/wayland/custom-extension/client/client.json b/examples/wayland/custom-extension/client/client.json
new file mode 100644
index 00000000..7aab544e
--- /dev/null
+++ b/examples/wayland/custom-extension/client/client.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "custom-wayland" ]
+}
diff --git a/examples/wayland/custom-extension/client/client.pro b/examples/wayland/custom-extension/client/client.pro
new file mode 100644
index 00000000..03056f22
--- /dev/null
+++ b/examples/wayland/custom-extension/client/client.pro
@@ -0,0 +1,18 @@
+PLUGIN_TYPE = platforms
+load(qt_plugin)
+
+CONFIG += wayland-scanner
+
+TARGET = custom-wayland
+
+QT += waylandclient-private
+
+WAYLANDCLIENTSOURCES += ../protocol/custom.xml
+
+OTHER_FILES += client.json
+
+SOURCES += main.cpp \
+ customextension.cpp
+
+HEADERS += customextension.h
+
diff --git a/examples/wayland/custom-extension/client/customextension.cpp b/examples/wayland/custom-extension/client/customextension.cpp
new file mode 100644
index 00000000..81694fda
--- /dev/null
+++ b/examples/wayland/custom-extension/client/customextension.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Wayland module
+**
+** $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 The Qt Company Ltd 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 "customextension.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandintegration_p.h>
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+CustomExtension::CustomExtension(QWaylandIntegration *wayland_integration)
+ : m_display(0)
+{
+ // TODO: add a simpler API for this
+
+ QtWaylandClient::QWaylandDisplay *wayland_display = wayland_integration->display();
+ struct ::wl_registry *registry = wl_display_get_registry(wayland_display->wl_display());
+ QtWayland::wl_registry::init(registry);
+}
+
+void CustomExtension::sendRequest(const QString &text, int value)
+{
+ qDebug() << "Client-side plugin sending request:" << text << value;
+ qtrequest(text, value);
+}
+
+void CustomExtension::example_extension_qtevent(struct wl_surface *surface,
+ uint32_t time,
+ const QString &text,
+ uint32_t value)
+{
+ qDebug() << "Client-side plugin received an event:" << surface << time << text << value;
+ emit eventReceived(text, value);
+}
+
+void CustomExtension::registry_global(uint32_t id, const QString &interface, uint32_t version)
+{
+ if (interface == QStringLiteral("qt_example_extension")) {
+ QtWayland::qt_example_extension::init(QtWayland::wl_registry::object(), id, version);
+ }
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/examples/wayland/qwindow-compositor/textureblitter.h b/examples/wayland/custom-extension/client/customextension.h
index 85e2bbfb..d8797a9e 100644
--- a/examples/wayland/qwindow-compositor/textureblitter.h
+++ b/examples/wayland/custom-extension/client/customextension.h
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the examples of the Qt Wayland module
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,38 +38,46 @@
**
****************************************************************************/
-#ifndef TEXTUREBLITTER_H
-#define TEXTUREBLITTER_H
+#ifndef CUSTOMEXTENSION_H
+#define CUSTOMEXTENSION_H
-#include <QtGui/QMatrix4x4>
+#include <qpa/qwindowsysteminterface.h>
+#include <QtWaylandClient/private/qwayland-wayland.h>
+#include "qwayland-custom.h"
QT_BEGIN_NAMESPACE
-class QOpenGLShaderProgram;
-class TextureBlitter
+namespace QtWaylandClient {
+
+class QWaylandDisplay;
+class QWaylandIntegration;
+
+class CustomExtension : public QObject, QtWayland::qt_example_extension, public QtWayland::wl_registry
{
+ Q_OBJECT
public:
- TextureBlitter();
- ~TextureBlitter();
- void bind(quint32 target);
- void release();
- void drawTexture(int textureId, const QRectF &sourceGeometry,
- const QSize &targetRect, int depth,
- bool targethasInvertedY, bool sourceHasInvertedY);
+ CustomExtension(QWaylandIntegration *wayland_integration);
+
+public slots:
+ void sendRequest(const QString &text, int value);
+
+signals:
+ void eventReceived(const QString &text, uint value);
private:
- QOpenGLShaderProgram *m_shaderProgram;
- QOpenGLShaderProgram *m_shaderProgramExternal;
- QOpenGLShaderProgram *m_currentProgram;
- QMatrix4x4 m_transformMatrix;
+ QWaylandDisplay *m_display;
+
+ void example_extension_qtevent(struct wl_surface *surface,
+ uint32_t time,
+ const QString &text,
+ uint32_t value) Q_DECL_OVERRIDE;
- int m_matrixLocation;
- int m_vertexCoordEntry;
- int m_textureCoordEntry;
+ void registry_global(uint32_t id, const QString &interface, uint32_t version) Q_DECL_OVERRIDE;
- quint32 m_currentTarget;
};
+}
+
QT_END_NAMESPACE
-#endif // TEXTUREBLITTER_H
+#endif // CUSTOMEXTENSION_H
diff --git a/src/compositor/wayland_wrapper/qwlqttouch_p.h b/examples/wayland/custom-extension/client/main.cpp
index 003f783d..90705388 100644
--- a/src/compositor/wayland_wrapper/qwlqttouch_p.h
+++ b/examples/wayland/custom-extension/client/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the examples of the Qt Wayland module
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,56 +38,50 @@
**
****************************************************************************/
-#ifndef WLTOUCH_H
-#define WLTOUCH_H
+#include <qpa/qplatformintegrationplugin.h>
+#include <QtWaylandClient/private/qwaylandintegration_p.h>
+#include "customextension.h"
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qwlcompositor_p.h>
-#include <QtCompositor/private/qwayland-server-touch-extension.h>
-#include "wayland-util.h"
+#include <QGuiApplication>
+#include <QDebug>
QT_BEGIN_NAMESPACE
-class Compositor;
-class Surface;
-class QTouchEvent;
-class QWaylandSurfaceView;
+namespace QtWaylandClient {
-namespace QtWayland {
+static CustomExtension * extension_global;
-class TouchExtensionGlobal : public QtWaylandServer::qt_touch_extension
+class CustomIntegrationPlugin : public QPlatformIntegrationPlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "client.json")
public:
- TouchExtensionGlobal(Compositor *compositor);
- ~TouchExtensionGlobal();
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
+};
- bool postTouchEvent(QTouchEvent *event, QWaylandSurfaceView *view);
+ QPlatformIntegration *CustomIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ Q_UNUSED(system);
- void setFlags(int flags) { m_flags = flags; }
+ qDebug() << "************* The Qt Custom Extension Example Plugin is active ************";
-protected:
- void touch_extension_bind_resource(Resource *resource) Q_DECL_OVERRIDE;
- void touch_extension_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
+ QWaylandIntegration *integration = new QWaylandIntegration();
-private:
- Compositor *m_compositor;
- int m_flags;
- QList<Resource *> m_resources;
- QVector<float> m_posData;
-};
+ extension_global = new CustomExtension(integration);
+
+ // We need a way for client apps to get hold of the extension. The proper API for this is
+ // QPlatformNativeInterface, but that's a low-level API using void*. There will be a nice
+ // client API at some point, but in the meantime, it is easier to use QObject::findChild().
+
+ extension_global->setParent(qApp);
+ extension_global->setObjectName("qt_example_custom_extension");
+
+ return integration;
+}
}
QT_END_NAMESPACE
-#endif // WLTOUCH_H
+#include "main.moc"
diff --git a/examples/wayland/custom-extension/compositor/.gitignore b/examples/wayland/custom-extension/compositor/.gitignore
new file mode 100644
index 00000000..2532eb22
--- /dev/null
+++ b/examples/wayland/custom-extension/compositor/.gitignore
@@ -0,0 +1,8 @@
+custom-compositor
+qwayland-custom.cpp
+qwayland-custom.h
+qwayland-server-custom.cpp
+qwayland-server-custom.h
+wayland-custom-client-protocol.h
+wayland-custom-protocol.c
+wayland-custom-server-protocol.h
diff --git a/examples/wayland/custom-extension/compositor/compositor.pro b/examples/wayland/custom-extension/compositor/compositor.pro
new file mode 100644
index 00000000..4ffafdb8
--- /dev/null
+++ b/examples/wayland/custom-extension/compositor/compositor.pro
@@ -0,0 +1,34 @@
+QT += core gui qml
+
+QT += waylandcompositor-private
+
+CONFIG += wayland-scanner
+CONFIG += c++11
+SOURCES += \
+ main.cpp \
+ customextension.cpp
+
+OTHER_FILES = \
+ qml/main.qml \
+ qml/Screen.qml \
+ images/background.jpg
+
+WAYLANDSERVERSOURCES += \
+ ../protocol/custom.xml
+
+RESOURCES += compositor.qrc
+
+contains(QT_CONFIG, no-pkg-config) {
+ LIBS += -lwayland-server
+} else {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += wayland-server
+}
+
+TARGET = custom-compositor
+
+HEADERS += \
+ customextension.h
+
+target.path = $$[QT_INSTALL_EXAMPLES]/wayland/custom-extension/compositor
+INSTALLS += target
diff --git a/examples/wayland/custom-extension/compositor/compositor.qrc b/examples/wayland/custom-extension/compositor/compositor.qrc
new file mode 100644
index 00000000..db3a8075
--- /dev/null
+++ b/examples/wayland/custom-extension/compositor/compositor.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/background.png</file>
+ <file>qml/main.qml</file>
+ <file>qml/Screen.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/wayland/custom-extension/compositor/customextension.cpp b/examples/wayland/custom-extension/compositor/customextension.cpp
new file mode 100644
index 00000000..bc2b676e
--- /dev/null
+++ b/examples/wayland/custom-extension/compositor/customextension.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Wayland module
+**
+** $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 The Qt Company Ltd 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 "customextension.h"
+
+#include <QWaylandSurface>
+
+#include <QDebug>
+
+namespace QtWayland {
+
+CustomExtension::CustomExtension()
+{
+}
+
+void CustomExtension::initialize(QWaylandCompositor *compositor)
+{
+ init(compositor->display(), 1);
+}
+
+void CustomExtension::sendEvent(QWaylandSurface *surface, uint time, const QString &text, uint value)
+{
+ if (surface) {
+ Resource *target = resourceMap().value(surface->waylandClient());
+ if (target) {
+ qDebug() << "Server-side extension sending an event:" << text << value;
+ send_qtevent(target->handle, surface->resource(), time, text, value);
+ }
+ }
+}
+
+void CustomExtension::example_extension_qtrequest(QtWaylandServer::qt_example_extension::Resource *resource, const QString &text, int32_t value)
+{
+ Q_UNUSED(resource);
+ qDebug() << "Server-side extension received a request:" << text << value;
+ emit requestReceived(text, value);
+}
+
+}
diff --git a/src/compositor/wayland_wrapper/qwlqtkey_p.h b/examples/wayland/custom-extension/compositor/customextension.h
index 938fa0b8..e9ace6e9 100644
--- a/src/compositor/wayland_wrapper/qwlqtkey_p.h
+++ b/examples/wayland/custom-extension/compositor/customextension.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Compositor.
+** This file is part of the examples of the Qt Wayland module
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,47 +38,31 @@
**
****************************************************************************/
-#ifndef WLQTKEY_H
-#define WLQTKEY_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qwlcompositor_p.h>
+#ifndef CUSTOMEXTENSION_H
+#define CUSTOMEXTENSION_H
#include "wayland-util.h"
-#include <QtCompositor/private/qwayland-server-qtkey-extension.h>
-
-QT_BEGIN_NAMESPACE
-
-class Compositor;
-class Surface;
-class QKeyEvent;
+#include <QtWaylandCompositor/QWaylandExtensionTemplate>
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include "qwayland-server-custom.h"
namespace QtWayland {
-class QtKeyExtensionGlobal : public QtWaylandServer::qt_key_extension
+class CustomExtension : public QWaylandExtensionTemplate<CustomExtension>, public QtWaylandServer::qt_example_extension
{
+ Q_OBJECT
public:
- QtKeyExtensionGlobal(Compositor *compositor);
-
- bool postQtKeyEvent(QKeyEvent *event, Surface *surface);
+ CustomExtension();
+ Q_INVOKABLE void initialize(QWaylandCompositor *compositor);
+ Q_INVOKABLE void sendEvent(QWaylandSurface *surface, uint time, const QString &text, uint value);
-private:
- Compositor *m_compositor;
+signals:
+ void requestReceived(const QString &text, uint value);
+protected:
+ virtual void example_extension_qtrequest(Resource *resource, const QString &text, int32_t value) Q_DECL_OVERRIDE;
};
}
-QT_END_NAMESPACE
-
-#endif // WLQTKEY_H
+#endif // CUSTOMEXTENSION_H
diff --git a/examples/wayland/custom-extension/compositor/images/background.png b/examples/wayland/custom-extension/compositor/images/background.png
new file mode 100644
index 00000000..2429df11
--- /dev/null
+++ b/examples/wayland/custom-extension/compositor/images/background.png
Binary files differ
diff --git a/src/compositor/wayland_wrapper/qwltextinputmanager.cpp b/examples/wayland/custom-extension/compositor/main.cpp
index ce16f01c..1970e5a6 100644
--- a/src/compositor/wayland_wrapper/qwltextinputmanager.cpp
+++ b/examples/wayland/custom-extension/compositor/main.cpp
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Compositor.
+** This file is part of the examples of the Qt Wayland module
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,30 +38,25 @@
**
****************************************************************************/
-#include "qwltextinputmanager_p.h"
+#include <QtCore/QUrl>
+#include <QtCore/QDebug>
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlApplicationEngine>
-#include "qwlcompositor_p.h"
-#include "qwltextinput_p.h"
+#include <QtQml/qqml.h>
+#include <QtQml/QQmlEngine>
+#include "customextension.h"
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-
-TextInputManager::TextInputManager(Compositor *compositor)
- : QtWaylandServer::wl_text_input_manager(compositor->wl_display(), 1)
- , m_compositor(compositor)
+static void registerTypes()
{
+ qmlRegisterType<QtWayland::CustomExtension>("com.theqtcompany.customextension", 1, 0, "CustomExtension");
}
-TextInputManager::~TextInputManager()
+int main(int argc, char *argv[])
{
-}
+ QGuiApplication app(argc, argv);
+ registerTypes();
+ QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml"));
-void TextInputManager::text_input_manager_create_text_input(Resource *resource, uint32_t id)
-{
- new TextInput(m_compositor, resource->client(), id);
+ return app.exec();
}
-
-} // namespace QtWayland
-
-QT_END_NAMESPACE
diff --git a/examples/wayland/custom-extension/compositor/qml/Screen.qml b/examples/wayland/custom-extension/compositor/qml/Screen.qml
new file mode 100644
index 00000000..3173c7a0
--- /dev/null
+++ b/examples/wayland/custom-extension/compositor/qml/Screen.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Wayland module
+**
+** $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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.2
+import QtWayland.Compositor 1.0
+
+WaylandOutput {
+ id: output
+ property alias surfaceArea: background
+ window: Window {
+ id: screen
+
+ property QtObject output
+
+ width: 1024
+ height: 768
+ visible: true
+
+ WaylandMouseTracker {
+ id: mouseTracker
+ anchors.fill: parent
+
+ enableWSCursor: true
+ Image {
+ id: background
+ anchors.fill: parent
+ fillMode: Image.Tile
+ source: "qrc:/images/background.png"
+ smooth: false
+ }
+ WaylandCursorItem {
+ id: cursor
+ inputEventsEnabled: false
+ x: mouseTracker.mouseX - hotspotX
+ y: mouseTracker.mouseY - hotspotY
+
+ inputDevice: output.compositor.defaultInputDevice
+ }
+ Rectangle {
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ width: 75
+ height: 75
+ color: "#BADA55"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ comp.sendEvent();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/wayland/qml-compositor/ContrastEffect.qml b/examples/wayland/custom-extension/compositor/qml/main.qml
index 562d637e..88871de8 100644
--- a/examples/wayland/qml-compositor/ContrastEffect.qml
+++ b/examples/wayland/custom-extension/compositor/qml/main.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the examples of the Qt Wayland module
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -39,52 +39,66 @@
****************************************************************************/
import QtQuick 2.0
+import QtWayland.Compositor 1.0
-ShaderEffect {
- property variant source: null;
- property color color: "#ffffff"
- property real blend;
+import com.theqtcompany.customextension 1.0
- onSourceChanged: {
- if (source != null) {
- source.setPaintEnabled(false);
+WaylandCompositor {
+ id: comp
+
+ property var lastItem: null
+
+ property int counter : 0
+
+ function sendEvent() {
+ if (lastItem != null) {
+ console.log("Compositor sending event: " + counter);
+ custom.sendEvent(lastItem.shellSurface.surface, 0, "test", counter);
+ counter++;
}
}
- property string vShaderInvertedY: "
- uniform highp mat4 qt_Matrix;
- attribute highp vec4 qt_Vertex;
- attribute highp vec2 qt_MultiTexCoord0;
- varying highp vec2 qt_TexCoord0;
- void main() {
- qt_TexCoord0 = qt_MultiTexCoord0;
- gl_Position = qt_Matrix * qt_Vertex;
+ Screen {
+ compositor: comp
}
- "
- property string vShader: "
- uniform highp mat4 qt_Matrix;
- attribute highp vec4 qt_Vertex;
- attribute highp vec2 qt_MultiTexCoord0;
- varying highp vec2 qt_TexCoord0;
- void main() {
- qt_TexCoord0 = vec2(0, 1) + qt_MultiTexCoord0 * vec2(1, -1);
- gl_Position = qt_Matrix * qt_Vertex;
+
+ Component {
+ id: chromeComponent
+ ShellSurfaceItem {
+ id: chrome
+ onSurfaceDestroyed: {
+ if (chrome === lastItem)
+ lastItem = null;
+ chrome.destroy()
+ }
+ }
}
- "
- vertexShader: source && source.isYInverted ? vShaderInvertedY : vShader
+ extensions: [
+ Shell {
+ id: defaultShell
+
+ onCreateShellSurface: {
+ var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "surface": surface } );
+ item.shellSurface.initialize(defaultShell, surface, client, id);
+ lastItem = item;
+ }
+
+ Component.onCompleted: {
+ initialize();
+ }
+ },
+ CustomExtension {
+ id: custom
+ onRequestReceived: {
+ console.log("Compositor received a request: \"" + text + "\", " + value)
+ }
+
+ Component.onCompleted: {
+ initialize(comp);
+ }
+ }
+
+ ]
- fragmentShader: "
- uniform lowp sampler2D source;
- uniform highp float qt_Opacity;
- uniform highp vec4 color;
- uniform highp float blend;
- varying highp vec2 qt_TexCoord0;
- void main() {
- highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
- highp vec3 delta = sourceColor.rgb - vec3(0.5);
- highp vec3 lowerContrast = vec3(0.5) + 0.4 * delta;
- gl_FragColor = qt_Opacity * mix(sourceColor, color * sourceColor.a * dot(lowerContrast, vec3(11, 16, 5) * (1. / 32.)), blend);
- }
- "
}
diff --git a/examples/wayland/custom-extension/custom-extension.pro b/examples/wayland/custom-extension/custom-extension.pro
new file mode 100644
index 00000000..c44464a3
--- /dev/null
+++ b/examples/wayland/custom-extension/custom-extension.pro
@@ -0,0 +1,7 @@
+TEMPLATE=subdirs
+
+SUBDIRS += client
+SUBDIRS += compositor
+SUBDIRS += testapp
+
+OTHER_FILES += protocol/custom.xml
diff --git a/examples/wayland/custom-extension/protocol/custom.xml b/examples/wayland/custom-extension/protocol/custom.xml
new file mode 100644
index 00000000..bda67829
--- /dev/null
+++ b/examples/wayland/custom-extension/protocol/custom.xml
@@ -0,0 +1,62 @@
+<protocol name="custom">
+
+ <copyright>
+ Copyright (C) 2015 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
+
+ This file is part of the examples of the Qt Wayland module
+
+ $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 The Qt Company Ltd 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$
+ </copyright>
+
+ <interface name="qt_example_extension" version="1">
+ <event name="qtevent">
+ <description summary="Qt example event">
+ Example event from server to client
+ </description>
+
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="time" type="uint"/>
+ <arg name="text" type="string"/>
+ <arg name="value" type="uint"/>
+ </event>
+
+ <request name="qtrequest">
+ <description summary="Qt example event">
+ Example request from client to server
+ </description>
+
+ <arg name="text" type="string"/>
+ <arg name="value" type="int"/>
+ </request>
+ </interface>
+</protocol>
diff --git a/examples/wayland/custom-extension/testapp/main.cpp b/examples/wayland/custom-extension/testapp/main.cpp
new file mode 100644
index 00000000..59738128
--- /dev/null
+++ b/examples/wayland/custom-extension/testapp/main.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the examples of the Qt Wayland module
+ **
+ ** $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 The Qt Company Ltd 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 <QGuiApplication>
+#include <QRasterWindow>
+#include <QPainter>
+#include <QMouseEvent>
+
+#include <QDebug>
+
+static QObject *s_custom;
+
+class TestWindow : public QRasterWindow
+{
+ Q_OBJECT
+
+public:
+ TestWindow()
+ {
+ if (s_custom)
+ connect(s_custom, SIGNAL(eventReceived(const QString &, uint)),
+ this, SLOT(handleEvent(const QString &, uint)));
+ }
+
+public slots:
+ void handleEvent(const QString &text, uint value)
+ {
+ qDebug() << "Client application received event" << text << value;
+ }
+
+protected:
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter p(this);
+ p.fillRect(QRect(0,0,width(),height()),Qt::gray);
+ p.fillRect(50,50,100,100, QColor("#C0FFEE"));
+ }
+
+ void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE
+ {
+ Q_ASSERT(s_custom);
+ bool insideRect = QRect(50,50,100,100).contains(ev->pos());
+
+ QString text = insideRect ? "Click inside" : "Click outside";
+ int value = ev->pos().x();
+
+ qDebug() << "Client application sending request:" << text << value;
+
+ QMetaObject::invokeMethod(s_custom, "sendRequest", Qt::DirectConnection,
+ Q_ARG(QString, text),
+ Q_ARG(int, value));
+ }
+
+private:
+
+};
+
+int main (int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ s_custom = app.findChild<QObject*>("qt_example_custom_extension");
+ if (!s_custom) {
+ qCritical() << "This example requires the Qt Custom Extension platform plugin,\n"
+ "add -platform custom-wayland to the command line";
+ return -1;
+ }
+ TestWindow window;
+ window.show();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/examples/wayland/custom-extension/testapp/testapp.pro b/examples/wayland/custom-extension/testapp/testapp.pro
new file mode 100644
index 00000000..062210e9
--- /dev/null
+++ b/examples/wayland/custom-extension/testapp/testapp.pro
@@ -0,0 +1,6 @@
+SOURCES += main.cpp
+
+CONFIG += c++11
+
+target.path = $$[QT_INSTALL_EXAMPLES]/wayland/custom-extension/testapp
+INSTALLS += target
diff --git a/examples/wayland/multi-output/doc/src/multi-output.qdoc b/examples/wayland/multi-output/doc/src/multi-output.qdoc
new file mode 100644
index 00000000..32b9aa69
--- /dev/null
+++ b/examples/wayland/multi-output/doc/src/multi-output.qdoc
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \title Qt Wayland Compositor Examples - Multi Output
+ \example multi-output
+ \brief Multi Output is an example that demonstrates a compositor with multiple outputs.
+ \ingroup qtwaylandcompositor-examples
+
+ Multi Output demonstrates how to display the same clients on different
+ \l{WaylandOutput}{WaylandOutputs} with different types of composition.
+
+ The example opens two different windows, one for each output. When a client connects, its
+ WaylandSurface is displayed in a GridView on one of the outputs, while a ShellSurface
+ associated with the WaylandSurface is displayed with desktop-style composition on
+ the other output.
+*/
diff --git a/examples/wayland/qml-compositor/background.jpg b/examples/wayland/multi-output/images/background.jpg
index 445567fb..445567fb 100644
--- a/examples/wayland/qml-compositor/background.jpg
+++ b/examples/wayland/multi-output/images/background.jpg
Binary files differ
diff --git a/src/compositor/wayland_wrapper/qwldisplay.cpp b/examples/wayland/multi-output/main.cpp
index fafde3f7..7ee6779d 100644
--- a/src/compositor/wayland_wrapper/qwldisplay.cpp
+++ b/examples/wayland/multi-output/main.cpp
@@ -1,9 +1,9 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Compositor.
+** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,28 +38,18 @@
**
****************************************************************************/
-#include "qwldisplay_p.h"
-
+#include <QtCore/QUrl>
#include <QtCore/QDebug>
-#include <QtCompositor/private/wayland-wayland-server-protocol.h>
-
-QT_BEGIN_NAMESPACE
+#include <QtGui/QGuiApplication>
-namespace QtWayland {
+#include <QtQml/QQmlApplicationEngine>
-Display::Display()
+int main(int argc, char *argv[])
{
- m_display = wl_display_create();
+ QGuiApplication app(argc, argv);
- Q_ASSERT(m_display);
-}
+ QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml"));
-Display::~Display()
-{
- wl_display_destroy(m_display);
+ return app.exec();
}
-
-}
-
-QT_END_NAMESPACE
diff --git a/examples/wayland/multi-output/multi-output.pro b/examples/wayland/multi-output/multi-output.pro
new file mode 100644
index 00000000..468dc2e0
--- /dev/null
+++ b/examples/wayland/multi-output/multi-output.pro
@@ -0,0 +1,16 @@
+QT += core gui qml
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES = \
+ qml/main.qml \
+ qml/GridScreen.qml \
+ qml/ShellScreen.qml \
+ qml/ShellChrome.qml \
+ images/background.jpg \
+
+RESOURCES += multi-output.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/wayland/multi-output
+INSTALLS += target
diff --git a/examples/wayland/multi-output/multi-output.qrc b/examples/wayland/multi-output/multi-output.qrc
new file mode 100644
index 00000000..86df8817
--- /dev/null
+++ b/examples/wayland/multi-output/multi-output.qrc
@@ -0,0 +1,9 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/background.jpg</file>
+ <file>qml/main.qml</file>
+ <file>qml/GridScreen.qml</file>
+ <file>qml/ShellScreen.qml</file>
+ <file>qml/ShellChrome.qml</file>
+ </qresource>
+</RCC>
diff --git a/src/compositor/wayland_wrapper/qwlqtkey.cpp b/examples/wayland/multi-output/qml/GridScreen.qml
index 1eb6c2f1..6b1d574c 100644
--- a/src/compositor/wayland_wrapper/qwlqtkey.cpp
+++ b/examples/wayland/multi-output/qml/GridScreen.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Compositor.
+** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,44 +38,48 @@
**
****************************************************************************/
-#include "qwlqtkey_p.h"
-#include "qwlsurface_p.h"
-#include <QKeyEvent>
-#include <QWindow>
+import QtQuick 2.0
+import QtQuick.Window 2.2
+import QtWayland.Compositor 1.0
-QT_BEGIN_NAMESPACE
+WaylandOutput {
+ id: output
+ property alias gridSurfaces: listModel
-namespace QtWayland {
+ window: Window {
+ width: 1024
+ height: 760
+ visible: true
-QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor)
- : QtWaylandServer::qt_key_extension(compositor->wl_display(), 2)
- , m_compositor(compositor)
-{
-}
-
-bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface)
-{
- uint32_t time = m_compositor->currentTimeMsecs();
-
- Resource *target = surface ? resourceMap().value(surface->resource()->client()) : 0;
-
- if (target) {
- send_qtkey(target->handle,
- surface ? surface->resource()->handle : 0,
- time, event->type(), event->key(), event->modifiers(),
- event->nativeScanCode(),
- event->nativeVirtualKey(),
- event->nativeModifiers(),
- event->text(),
- event->isAutoRepeat(),
- event->count());
-
- return true;
+ Image {
+ id: background
+ anchors.fill: parent
+ fillMode: Image.Tile
+ source: "qrc:/images/background.jpg"
+ smooth: true
+ GridView {
+ id: gridView
+ anchors.fill: parent
+ model: ListModel {
+ id: listModel
+ }
+ interactive: false
+ cellWidth: 200
+ cellHeight: 200
+ delegate: WaylandQuickItem {
+ id: item
+ surface: gridSurface
+ width: gridView.cellWidth
+ height: gridView.cellHeight
+ sizeFollowsSurface: false
+ inputEventsEnabled: false
+ view.discardFrontBuffers: true
+ MouseArea {
+ anchors.fill: parent
+ onClicked: item.surface.activated()
+ }
+ }
+ }
+ }
}
-
- return false;
-}
-
}
-
-QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwldisplay_p.h b/examples/wayland/multi-output/qml/ShellChrome.qml
index c89bb050..83f883da 100644
--- a/src/compositor/wayland_wrapper/qwldisplay_p.h
+++ b/examples/wayland/multi-output/qml/ShellChrome.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Compositor.
+** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,42 +38,36 @@
**
****************************************************************************/
-#ifndef WL_DISPLAY_H
-#define WL_DISPLAY_H
+import QtQuick 2.0
+import QtWayland.Compositor 1.0
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
+ShellSurfaceItem {
+ id: rootChrome
-#include <wayland-server.h>
-#include <QtCompositor/qwaylandexport.h>
+ shellSurface: ShellSurface {
+ }
-QT_BEGIN_NAMESPACE
+ onSurfaceDestroyed: {
+ view.bufferLock = true;
+ destroyAnimation.start();
+ }
-namespace QtWayland {
+ SequentialAnimation {
+ id: destroyAnimation
+ ParallelAnimation {
+ NumberAnimation { target: scaleTransform; property: "yScale"; to: 2/height; duration: 150 }
+ NumberAnimation { target: scaleTransform; property: "xScale"; to: 0.4; duration: 150 }
+ }
+ NumberAnimation { target: scaleTransform; property: "xScale"; to: 0; duration: 150 }
+ ScriptAction { script: { rootChrome.destroy(); } }
+ }
-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;
-};
+ transform: [
+ Scale {
+ id:scaleTransform
+ origin.x: rootChrome.width / 2
+ origin.y: rootChrome.height / 2
+ }
+ ]
}
-
-QT_END_NAMESPACE
-
-#endif //WL_DISPLAY_H
diff --git a/examples/wayland/multi-output/qml/ShellScreen.qml b/examples/wayland/multi-output/qml/ShellScreen.qml
new file mode 100644
index 00000000..77fbeb82
--- /dev/null
+++ b/examples/wayland/multi-output/qml/ShellScreen.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.2
+import QtWayland.Compositor 1.0
+
+WaylandOutput {
+ id: output
+ property alias surfaceArea: background
+
+ window: Window {
+ width: 1024
+ height: 760
+ visible: true
+
+ WaylandMouseTracker {
+ id: mouseTracker
+ anchors.fill: parent
+
+ enableWSCursor: true
+ Image {
+ id: background
+ anchors.fill: parent
+ fillMode: Image.Tile
+ source: "qrc:/images/background.jpg"
+ smooth: true
+ }
+ WaylandCursorItem {
+ id: cursor
+ inputEventsEnabled: false
+ x: mouseTracker.mouseX - hotspotX
+ y: mouseTracker.mouseY - hotspotY
+
+ inputDevice : output.compositor.defaultInputDevice
+ }
+ }
+ }
+}
diff --git a/examples/wayland/multi-output/qml/main.qml b/examples/wayland/multi-output/qml/main.qml
new file mode 100644
index 00000000..9fd29fc2
--- /dev/null
+++ b/examples/wayland/multi-output/qml/main.qml
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtWayland.Compositor 1.0
+
+WaylandCompositor {
+ id: comp
+
+ defaultOutput: shellScreen
+ ShellScreen {
+ id: shellScreen
+ compositor: comp
+ }
+
+ GridScreen {
+ id: gridScreen
+ compositor: comp
+ }
+
+ Component {
+ id: chromeComponent
+ ShellChrome {
+ }
+ }
+
+ Component {
+ id: surfaceComponent
+ WaylandSurface {
+ id: surface
+ signal activated()
+ onMappedChanged: {
+ if (isMapped && !cursorSurface) {
+ gridScreen.gridSurfaces.append( { "gridSurface" : surface } );
+ } else {
+ for (var i = 0; i < gridScreen.gridSurfaces.count; i++) {
+ if (gridScreen.gridSurfaces.get(i).gridSurface === surface) {
+ gridScreen.gridSurfaces.remove(i,1);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ extensions: [
+ Shell {
+ id: defaultShell
+
+ onCreateShellSurface: {
+ var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "surface": surface } );
+ item.shellSurface.initialize(defaultShell, surface, client, id);
+ surface.activated.connect(item.raise);
+ }
+
+ Component.onCompleted: {
+ initialize();
+ }
+ }
+ ]
+
+ onCreateSurface: {
+ var surface = surfaceComponent.createObject(comp, { } );
+ surface.initialize(comp, client, id, version);
+ }
+}
diff --git a/examples/wayland/pure-qml/doc/src/pure-qml.qdoc b/examples/wayland/pure-qml/doc/src/pure-qml.qdoc
new file mode 100644
index 00000000..18ca73ec
--- /dev/null
+++ b/examples/wayland/pure-qml/doc/src/pure-qml.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \title Qt Wayland Compositor Examples - Pure QML
+ \example pure-qml
+ \brief Pure QML is an example that demonstrates how to write a Wayland compositor in pure QML.
+ \ingroup qtwaylandcompositor-examples
+
+ Pure QML is a small desktop-style Wayland compositor example that demonstrates the power and ease
+ of the Qt Wayland Compositor QML APIs.
+*/
diff --git a/examples/wayland/pure-qml/images/background.jpg b/examples/wayland/pure-qml/images/background.jpg
new file mode 100644
index 00000000..445567fb
--- /dev/null
+++ b/examples/wayland/pure-qml/images/background.jpg
Binary files differ
diff --git a/examples/wayland/qml-compositor/WindowChrome.qml b/examples/wayland/pure-qml/main.cpp
index 5a29032d..7ee6779d 100644
--- a/examples/wayland/qml-compositor/WindowChrome.qml
+++ b/examples/wayland/pure-qml/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
**
@@ -38,26 +38,18 @@
**
****************************************************************************/
-import QtQuick 2.0
+#include <QtCore/QUrl>
+#include <QtCore/QDebug>
-Item {
- id: chrome
- anchors.fill: parent
+#include <QtGui/QGuiApplication>
- property variant window: parent;
- property bool selected: root.selectedWindow === window
+#include <QtQml/QQmlApplicationEngine>
- MouseArea {
- anchors.fill: parent
- enabled: !window.focus
- hoverEnabled: !window.focus
- onClicked: {
- if (selected) {
- window.takeFocus();
- } else {
- root.selectedWindow = window
- root.focus = true
- }
- }
- }
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml"));
+
+ return app.exec();
}
diff --git a/examples/wayland/pure-qml/pure-qml.pro b/examples/wayland/pure-qml/pure-qml.pro
new file mode 100644
index 00000000..d643d3ee
--- /dev/null
+++ b/examples/wayland/pure-qml/pure-qml.pro
@@ -0,0 +1,17 @@
+QT += gui qml
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES = \
+ qml/main.qml \
+ qml/Screen.qml \
+ qml/Chrome.qml \
+ images/background.jpg \
+
+RESOURCES += pure-qml.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/wayland/pure-qml
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS pure-qml.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/wayland/pure-qml
+INSTALLS += target sources
diff --git a/examples/wayland/pure-qml/pure-qml.qrc b/examples/wayland/pure-qml/pure-qml.qrc
new file mode 100644
index 00000000..65ccf947
--- /dev/null
+++ b/examples/wayland/pure-qml/pure-qml.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/background.jpg</file>
+ <file>qml/main.qml</file>
+ <file>qml/Screen.qml</file>
+ <file>qml/Chrome.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/wayland/pure-qml/qml/Chrome.qml b/examples/wayland/pure-qml/qml/Chrome.qml
new file mode 100644
index 00000000..83f883da
--- /dev/null
+++ b/examples/wayland/pure-qml/qml/Chrome.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtWayland.Compositor 1.0
+
+ShellSurfaceItem {
+ id: rootChrome
+
+ shellSurface: ShellSurface {
+ }
+
+ onSurfaceDestroyed: {
+ view.bufferLock = true;
+ destroyAnimation.start();
+ }
+
+ SequentialAnimation {
+ id: destroyAnimation
+ ParallelAnimation {
+ NumberAnimation { target: scaleTransform; property: "yScale"; to: 2/height; duration: 150 }
+ NumberAnimation { target: scaleTransform; property: "xScale"; to: 0.4; duration: 150 }
+ }
+ NumberAnimation { target: scaleTransform; property: "xScale"; to: 0; duration: 150 }
+ ScriptAction { script: { rootChrome.destroy(); } }
+ }
+
+ transform: [
+ Scale {
+ id:scaleTransform
+ origin.x: rootChrome.width / 2
+ origin.y: rootChrome.height / 2
+
+ }
+ ]
+}
diff --git a/examples/wayland/pure-qml/qml/Screen.qml b/examples/wayland/pure-qml/qml/Screen.qml
new file mode 100644
index 00000000..669d39c0
--- /dev/null
+++ b/examples/wayland/pure-qml/qml/Screen.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.2
+import QtWayland.Compositor 1.0
+
+WaylandOutput {
+ id: output
+ property alias surfaceArea: background
+ window: Window {
+ id: screen
+
+ property QtObject output
+
+ width: 1024
+ height: 760
+ visible: true
+
+ WaylandMouseTracker {
+ id: mouseTracker
+ anchors.fill: parent
+
+ enableWSCursor: true
+ Image {
+ id: background
+ anchors.fill: parent
+ fillMode: Image.Tile
+ source: "qrc:/images/background.jpg"
+ smooth: true
+ }
+ WaylandCursorItem {
+ id: cursor
+ inputEventsEnabled: false
+ x: mouseTracker.mouseX - hotspotX
+ y: mouseTracker.mouseY - hotspotY
+
+ inputDevice: output.compositor.defaultInputDevice
+ }
+ }
+ }
+}
diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml
new file mode 100644
index 00000000..0a72f7dd
--- /dev/null
+++ b/examples/wayland/pure-qml/qml/main.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 The Qt Company Ltd 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtWayland.Compositor 1.0
+
+WaylandCompositor {
+ id: comp
+
+ property var primarySurfacesArea: null
+
+ Screen {
+ compositor: comp
+ }
+
+ Component {
+ id: chromeComponent
+ Chrome {
+ }
+ }
+
+ Component {
+ id: surfaceComponent
+ WaylandSurface {
+ }
+ }
+
+ extensions: [
+ Shell {
+ id: defaultShell
+
+
+ onCreateShellSurface: {
+ var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "surface": surface } );
+ item.shellSurface.initialize(defaultShell, surface, client, id);
+ }
+
+ Component.onCompleted: {
+ initialize();
+ }
+ }
+ ]
+
+ onCreateSurface: {
+ var surface = surfaceComponent.createObject(comp, { } );
+ surface.initialize(comp, client, id, version);
+
+ }
+}
diff --git a/examples/wayland/qml-compositor/WindowContainer.qml b/examples/wayland/qml-compositor/WindowContainer.qml
deleted file mode 100644
index 017e2699..00000000
--- a/examples/wayland/qml-compositor/WindowContainer.qml
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Window 2.0
-import QtCompositor 1.0
-
-Item {
- id: container
-
- x: targetX
- y: targetY
- width: targetWidth
- height: targetHeight
- scale: targetScale
-
- visible: isFullscreen || !root.hasFullscreenWindow
- onVisibleChanged: {
- child.surface.clientRenderingEnabled = visible
- }
-
- opacity: 0
-
- property real targetX
- property real targetY
- property real targetWidth
- property real targetHeight
- property real targetScale
-
- property variant child: null
- property variant chrome: null
- property bool animationsEnabled: false
- property bool isFullscreen: state === "fullscreen"
- property int index
-
- state: child && chrome && chrome.selected && child.focus ? "fullscreen" : "normal"
-
- Behavior on x {
- enabled: container.animationsEnabled;
- NumberAnimation { easing.type: Easing.InCubic; duration: 200; }
- }
-
- Behavior on y {
- enabled: container.animationsEnabled;
- NumberAnimation { easing.type: Easing.InQuad; duration: 200; }
- }
-
- Behavior on width {
- enabled: container.animationsEnabled;
- NumberAnimation { easing.type: Easing.InCubic; duration: 200; }
- }
-
- Behavior on height {
- enabled: container.animationsEnabled;
- NumberAnimation { easing.type: Easing.InCubic; duration: 200; }
- }
-
- Behavior on scale {
- enabled: container.animationsEnabled;
- NumberAnimation { easing.type: Easing.InQuad; duration: 200; }
- }
-
- Behavior on opacity {
- enabled: true;
- NumberAnimation { easing.type: Easing.Linear; duration: 250; }
- }
-
- ContrastEffect {
- id: effect
- source: child
- anchors.fill: parent
- blend: { if (child && chrome && (chrome.selected || child.focus)) 0.0; else 0.6 }
- opacity: 1.0
- z: -1
-
- Behavior on blend {
- enabled: true;
- NumberAnimation { easing.type: Easing.Linear; duration: 200; }
- }
- }
-
- transform: [
- Scale { id: scaleTransform; origin.x: container.width / 2; origin.y: container.height / 2; xScale: 1; yScale: 1 }
- ]
-
- property real fullscreenScale: Math.min(root.width / width, root.height / height)
-
- transitions: [
- Transition {
- from: "*"; to: "normal"
- SequentialAnimation {
- ScriptAction {
- script: {
- compositor.fullscreenSurface = null
- background.opacity = 1
- }
- }
- ParallelAnimation {
- NumberAnimation { target: container; property: "x"; easing.type: Easing.Linear; to: targetX; duration: 400; }
- NumberAnimation { target: container; property: "y"; easing.type: Easing.Linear; to: targetY; duration: 400; }
- NumberAnimation { target: container; property: "scale"; easing.type: Easing.Linear; to: targetScale; duration: 400; }
- }
- ScriptAction {
- script: container.z = 0
- }
- }
- },
- Transition {
- from: "*"; to: "fullscreen"
- SequentialAnimation {
- ScriptAction {
- script: {
- container.z = 1
- background.opacity = 0
- }
- }
- ParallelAnimation {
- NumberAnimation { target: container; property: "x"; easing.type: Easing.Linear; to: (root.width - container.width) / 2; duration: 400; }
- NumberAnimation { target: container; property: "y"; easing.type: Easing.Linear; to: (root.height - container.height) / 2; duration: 400; }
- NumberAnimation { target: container; property: "scale"; easing.type: Easing.Linear; to: fullscreenScale; duration: 400; }
- }
- ScriptAction {
- script: compositor.fullscreenSurface = child.surface
- }
- }
- }
- ]
-
- SequentialAnimation {
- id: destroyAnimation
- NumberAnimation { target: scaleTransform; property: "yScale"; easing.type: Easing.Linear; to: 0.01; duration: 200; }
- NumberAnimation { target: scaleTransform; property: "xScale"; easing.type: Easing.Linear; to: 0.01; duration: 150; }
- NumberAnimation { target: container; property: "opacity"; easing.type: Easing.Linear; to: 0.0; duration: 150; }
- ScriptAction { script: container.parent.removeWindow(container) }
- }
- SequentialAnimation {
- id: unmapAnimation
- NumberAnimation { target: container; property: "opacity"; easing.type: Easing.Linear; to: 0.0; duration: 150; }
- ScriptAction { script: container.parent.removeWindow(container) }
- }
-
- Connections {
- target: container.child ? container.child.surface : null
- onUnmapped: unmapAnimation.start()
- }
- Connections {
- target: container.child ? container.child : null
- onSurfaceDestroyed: {
- destroyAnimation.start();
- }
- }
-
- Image {
- source: "closebutton.png"
- smooth: true
-
- opacity: !isFullscreen && chrome && chrome.selected ? 1 : 0
- Behavior on opacity {
- NumberAnimation { easing.type: Easing.InCubic; duration: 200; }
- }
-
- x: parent.width - 32
- y: 4
- width: 24
- height: 24
- z: 4
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- child.surface.destroySurface()
- }
- }
- }
-}
diff --git a/examples/wayland/qml-compositor/closebutton.png b/examples/wayland/qml-compositor/closebutton.png
deleted file mode 100644
index 5b5616e9..00000000
--- a/examples/wayland/qml-compositor/closebutton.png
+++ /dev/null
Binary files differ
diff --git a/examples/wayland/qml-compositor/compositor.js b/examples/wayland/qml-compositor/compositor.js
deleted file mode 100644
index 8baa2dd0..00000000
--- a/examples/wayland/qml-compositor/compositor.js
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-var windowList = null;
-var indexes = null;
-
-function relayout() {
- if (windowList === null || windowList.length == 0)
- return;
-
- var dim = Math.ceil(Math.sqrt(windowList.length));
-
- var cols = dim;
- var rows = Math.ceil(windowList.length / cols);
-
- var w = root.width / dim;
- var h = root.height / rows;
-
- var i;
- var ix = 0;
- var iy = 0;
- var lastDim = 1;
-
- indexes = new Array(dim * dim);
-
- for (i = 0; i < windowList.length; ++i) {
- if (i > 0) {
- var currentDim = Math.ceil(Math.sqrt(i + 1));
- if (currentDim == lastDim) {
- if (iy < currentDim - 1) {
- ++iy;
- if (iy == currentDim - 1)
- ix = 0;
- } else {
- ++ix;
- }
- } else {
- iy = 0;
- ix = currentDim - 1;
- }
- lastDim = currentDim;
- }
-
- indexes[iy * dim + ix] = i;
- windowList[i].index = iy * dim + ix;
-
- var cx = (ix + 0.5) * w;
- var cy = (iy + 0.5) * h;
-
- windowList[i].targetScale = 0.98 * Math.min(w / windowList[i].width, h / windowList[i].height);
-
- windowList[i].targetX = (cx - windowList[i].width / 2);
- windowList[i].targetY = (cy - windowList[i].height / 2);
- }
-}
-
-function addWindow(window)
-{
- if (windowList == null)
- windowList = new Array(0);
-
- windowList.push(window);
- relayout();
-}
-
-function removeWindow(window)
-{
- var i;
- for (i = 0; i < windowList.length; ++i) {
- if (windowList[i] == window)
- break;
- }
-
- var index = windowList[i].index;
- var dim = Math.ceil(Math.sqrt(windowList.length));
- var maxY = Math.floor((windowList.length-1) / dim);
-
- var shrinking = Math.ceil(Math.sqrt(windowList.length - 1)) != dim;
-
- while (true) {
- var ix = index % dim;
- var iy = Math.floor(index / dim);
-
- if (shrinking) {
- if (iy > 0)
- --iy;
- else if (++ix == dim)
- break;
- } else {
- if (iy < maxY) {
- if (ix > 0)
- --ix;
- else
- ++iy;
- } else {
- ++ix;
- }
- }
-
- var next = iy * dim + ix;
-
- var currentIndex = indexes[index];
- var nextIndex = indexes[next];
-
- if (nextIndex == null)
- break;
-
- var temp = windowList[currentIndex];
- windowList[currentIndex] = windowList[nextIndex];
- windowList[currentIndex].index = currentIndex;
- windowList[nextIndex] = temp;
-
- index = next;
- }
-
- windowList.splice(indexes[index], 1);
- relayout();
-}
diff --git a/examples/wayland/qml-compositor/main.cpp b/examples/wayland/qml-compositor/main.cpp
deleted file mode 100644
index 6e634563..00000000
--- a/examples/wayland/qml-compositor/main.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 The Qt Company Ltd 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 "qwaylandquickcompositor.h"
-#include "qwaylandquicksurface.h"
-
-#include <QtCompositor/qwaylandsurfaceitem.h>
-#include <QtCompositor/qwaylandoutput.h>
-
-#include <QGuiApplication>
-#include <QTimer>
-#include <QPainter>
-#include <QMouseEvent>
-
-#include <QQmlContext>
-
-#include <QQuickItem>
-#include <QQuickView>
-
-class QmlCompositor : public QQuickView, public QWaylandQuickCompositor
-{
- Q_OBJECT
- Q_PROPERTY(QWaylandQuickSurface* fullscreenSurface READ fullscreenSurface WRITE setFullscreenSurface NOTIFY fullscreenSurfaceChanged)
-
-public:
- QmlCompositor()
- : QWaylandQuickCompositor(0, DefaultExtensions | SubSurfaceExtension)
- , m_fullscreenSurface(0)
- {
- setSource(QUrl("main.qml"));
- setResizeMode(QQuickView::SizeRootObjectToView);
- setColor(Qt::black);
- winId();
- addDefaultShell();
- createOutput(this, "", "");
-
- connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()));
- }
-
- QWaylandQuickSurface *fullscreenSurface() const
- {
- return m_fullscreenSurface;
- }
-
- Q_INVOKABLE QWaylandSurfaceItem *item(QWaylandSurface *surf)
- {
- return static_cast<QWaylandSurfaceItem *>(surf->views().first());
- }
-
-signals:
- void windowAdded(QVariant window);
- void windowResized(QVariant window);
- void fullscreenSurfaceChanged();
-
-public slots:
- void destroyWindow(QVariant window) {
- qvariant_cast<QObject *>(window)->deleteLater();
- }
-
- void setFullscreenSurface(QWaylandQuickSurface *surface) {
- if (surface == m_fullscreenSurface)
- return;
- m_fullscreenSurface = surface;
- emit fullscreenSurfaceChanged();
- }
-
-private slots:
- void surfaceMapped() {
- QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(sender());
- emit windowAdded(QVariant::fromValue(surface));
- }
- void surfaceUnmapped() {
- QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(sender());
- if (surface == m_fullscreenSurface)
- m_fullscreenSurface = 0;
- }
-
- void surfaceDestroyed() {
- QWaylandQuickSurface *surface = static_cast<QWaylandQuickSurface *>(sender());
- if (surface == m_fullscreenSurface)
- m_fullscreenSurface = 0;
- }
-
- void sendCallbacks() {
- sendFrameCallbacks(surfaces());
- }
-
-protected:
- void resizeEvent(QResizeEvent *event)
- {
- QQuickView::resizeEvent(event);
- QWaylandCompositor::setOutputGeometry(QRect(0, 0, width(), height()));
- }
-
- void surfaceCreated(QWaylandSurface *surface) {
- connect(surface, SIGNAL(surfaceDestroyed()), this, SLOT(surfaceDestroyed()));
- connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped()));
- connect(surface,SIGNAL(unmapped()), this,SLOT(surfaceUnmapped()));
- }
-
-private:
- QWaylandQuickSurface *m_fullscreenSurface;
-};
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- QmlCompositor compositor;
- compositor.setTitle(QLatin1String("QML Compositor"));
- compositor.setGeometry(0, 0, 1024, 768);
- compositor.show();
-
- compositor.rootContext()->setContextProperty("compositor", &compositor);
-
- QObject::connect(&compositor, SIGNAL(windowAdded(QVariant)), compositor.rootObject(), SLOT(windowAdded(QVariant)));
- QObject::connect(&compositor, SIGNAL(windowResized(QVariant)), compositor.rootObject(), SLOT(windowResized(QVariant)));
-
- return app.exec();
-}
-
-#include "main.moc"
diff --git a/examples/wayland/qml-compositor/main.qml b/examples/wayland/qml-compositor/main.qml
deleted file mode 100644
index 5c1a2a67..00000000
--- a/examples/wayland/qml-compositor/main.qml
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtCompositor 1.0
-import "compositor.js" as CompositorLogic
-
-Item {
- id: root
-
- property variant selectedWindow: null
- property bool hasFullscreenWindow: typeof compositor != "undefined" && compositor.fullscreenSurface !== null
-
- Image {
- id: background
- Behavior on opacity {
- NumberAnimation { easing.type: Easing.InCubic; duration: 400; }
- }
- anchors.fill: parent
- fillMode: Image.Tile
- source: "background.jpg"
- smooth: true
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- root.selectedWindow = null
- root.focus = true
- }
- }
-
- MouseArea {
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- width: 2
- height: 2
- hoverEnabled: true
- onEntered: {
- root.selectedWindow = null
- root.focus = true
- }
- z: 10
- }
-
- function windowAdded(window) {
- var windowContainerComponent = Qt.createComponent("WindowContainer.qml");
- if (windowContainerComponent.status != Component.Ready) {
- console.warn("Error loading WindowContainer.qml: " + windowContainerComponent.errorString());
- return;
- }
- var windowContainer = windowContainerComponent.createObject(root);
-
- windowContainer.child = compositor.item(window);
- windowContainer.child.parent = windowContainer;
- windowContainer.child.touchEventsEnabled = true;
-
- windowContainer.targetWidth = window.size.width;
- windowContainer.targetHeight = window.size.height;
-
- var windowChromeComponent = Qt.createComponent("WindowChrome.qml");
- if (windowChromeComponent.status != Component.Ready) {
- console.warn("Error loading WindowChrome.qml: " + windowChromeComponent.errorString());
- return;
- }
- var windowChrome = windowChromeComponent.createObject(windowContainer.child);
-
- CompositorLogic.addWindow(windowContainer);
-
- windowContainer.opacity = 1
- windowContainer.animationsEnabled = true;
- windowContainer.chrome = windowChrome;
- }
-
- function windowResized(window) {
- window.width = window.surface.size.width;
- window.height = window.surface.size.height;
-
- CompositorLogic.relayout();
- }
-
- function removeWindow(window) {
- CompositorLogic.removeWindow(window);
- window.chrome.destroy();
- window.destroy();
- }
-
- onHeightChanged: CompositorLogic.relayout();
- onWidthChanged: CompositorLogic.relayout();
-}
diff --git a/examples/wayland/qml-compositor/qml-compositor.pro b/examples/wayland/qml-compositor/qml-compositor.pro
deleted file mode 100644
index f908a2f2..00000000
--- a/examples/wayland/qml-compositor/qml-compositor.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-DEFINES += QT_COMPOSITOR_QUICK
-
-LIBS += -L ../../lib
-
-QT += quick qml
-QT += quick-private
-
-QT += compositor
-
-# if you want to compile QtCompositor as part of the application
-# instead of linking to it, remove the QT += compositor and uncomment
-# the following line
-#include (../../src/compositor/compositor.pri)
-
-SOURCES += main.cpp
-
-OTHER_FILES = ContrastEffect.qml main.qml WindowChrome.qml WindowContainer.qml background.jpg closebutton.png compositor.js
-
-target.path = $$[QT_INSTALL_EXAMPLES]/wayland/qml-compositor
-sources.files = $$OTHER_FILES $$SOURCES $$HEADERS $$RESOURCES $$FORMS qml-compositor.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/wayland/qml-compositor
-INSTALLS += target sources
diff --git a/examples/wayland/qwindow-compositor/compositorwindow.cpp b/examples/wayland/qwindow-compositor/compositorwindow.cpp
index 7d855016..a902a7d0 100644
--- a/examples/wayland/qwindow-compositor/compositorwindow.cpp
+++ b/examples/wayland/qwindow-compositor/compositorwindow.cpp
@@ -39,23 +39,215 @@
****************************************************************************/
#include "compositorwindow.h"
-#include <QTouchEvent>
-CompositorWindow::CompositorWindow(const QSurfaceFormat &format, const QRect &geometry)
- : m_format(format)
+#include <QMouseEvent>
+#include <QOpenGLWindow>
+#include <QOpenGLTexture>
+#include <QOpenGLFunctions>
+#include <QMatrix4x4>
+
+#include "windowcompositor.h"
+#include <QtWaylandCompositor/qwaylandinput.h>
+
+CompositorWindow::CompositorWindow()
+ : m_backgroundTexture(0)
+ , m_compositor(0)
+ , m_grabState(NoGrab)
+ , m_dragIconView(0)
+{
+}
+
+void CompositorWindow::setCompositor(WindowCompositor *comp) {
+ m_compositor = comp;
+ connect(m_compositor, &WindowCompositor::startMove, this, &CompositorWindow::startMove);
+ connect(m_compositor, &WindowCompositor::startResize, this, &CompositorWindow::startResize);
+ connect(m_compositor, &WindowCompositor::dragStarted, this, &CompositorWindow::startDrag);
+ connect(m_compositor, &WindowCompositor::frameOffset, this, &CompositorWindow::setFrameOffset);
+}
+
+void CompositorWindow::initializeGL()
+{
+ QImage backgroundImage = QImage(QLatin1String(":/background.jpg"));
+ m_backgroundTexture = new QOpenGLTexture(backgroundImage, QOpenGLTexture::DontGenerateMipMaps);
+ m_backgroundTexture->setMinificationFilter(QOpenGLTexture::Nearest);
+ m_backgroundImageSize = backgroundImage.size();
+ m_textureBlitter.create();
+}
+
+void CompositorWindow::drawBackground()
+{
+ for (int y = 0; y < height(); y += m_backgroundImageSize.height()) {
+ for (int x = 0; x < width(); x += m_backgroundImageSize.width()) {
+ QMatrix4x4 targetTransform = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(x,y), m_backgroundImageSize), QRect(QPoint(0,0), size()));
+ m_textureBlitter.blit(m_backgroundTexture->textureId(),
+ targetTransform,
+ QOpenGLTextureBlitter::OriginTopLeft);
+ }
+ }
+}
+
+void CompositorWindow::paintGL()
+{
+ m_compositor->startRender();
+ QOpenGLFunctions *functions = context()->functions();
+ functions->glClearColor(1.f, .6f, .0f, 0.5f);
+ functions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ m_textureBlitter.bind();
+ drawBackground();
+
+ functions->glEnable(GL_BLEND);
+ functions->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ Q_FOREACH (WindowCompositorView *view, m_compositor->views()) {
+ if (view->isCursor())
+ continue;
+ GLuint textureId = view->getTexture();
+ QWaylandSurface *surface = view->surface();
+ if (surface && surface->isMapped()) {
+ QSize s = surface->size();
+ if (!s.isEmpty()) {
+ QRectF surfaceGeometry(view->position(), s);
+ QOpenGLTextureBlitter::Origin surfaceOrigin =
+ view->currentBuffer().origin() == QWaylandSurface::OriginTopLeft
+ ? QOpenGLTextureBlitter::OriginTopLeft
+ : QOpenGLTextureBlitter::OriginBottomLeft;
+ QMatrix4x4 targetTransform = QOpenGLTextureBlitter::targetTransform(surfaceGeometry, QRect(QPoint(), size()));
+ m_textureBlitter.blit(textureId, targetTransform, surfaceOrigin);
+ }
+ }
+ }
+ functions->glDisable(GL_BLEND);
+
+ m_textureBlitter.release();
+ m_compositor->endRender();
+}
+
+WindowCompositorView *CompositorWindow::viewAt(const QPointF &point)
+{
+ WindowCompositorView *ret = 0;
+ Q_FOREACH (WindowCompositorView *view, m_compositor->views()) {
+ if (view == m_dragIconView)
+ continue;
+ QPointF topLeft = view->position();
+ QWaylandSurface *surface = view->surface();
+ QRectF geo(topLeft, surface->size());
+ if (geo.contains(point))
+ ret = view;
+ }
+ return ret;
+}
+
+void CompositorWindow::startMove()
+{
+ m_grabState = MoveGrab;
+}
+
+void CompositorWindow::startResize(int edge)
+{
+ m_initialSize = m_mouseView->surface()->size();
+ m_grabState = ResizeGrab;
+ m_resizeEdge = edge;
+}
+
+void CompositorWindow::startDrag(WindowCompositorView *dragIcon)
+{
+ m_grabState = DragGrab;
+ m_dragIconView = dragIcon;
+ m_compositor->raise(dragIcon);
+}
+
+void CompositorWindow::setFrameOffset(const QPoint &offset)
+{
+ if (m_mouseView)
+ m_mouseView->setPosition(m_mouseView->position() + offset);
+}
+
+void CompositorWindow::mousePressEvent(QMouseEvent *e)
+{
+ if (mouseGrab())
+ return;
+ if (m_mouseView.isNull()) {
+ m_mouseView = viewAt(e->localPos());
+ if (!m_mouseView) {
+ m_compositor->closePopups();
+ return;
+ }
+ if (e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::MetaModifier)
+ m_grabState = MoveGrab; //start move
+ else
+ m_compositor->raise(m_mouseView);
+ m_initialMousePos = e->localPos();
+ m_mouseOffset = e->localPos() - m_mouseView->position();
+
+ QMouseEvent moveEvent(QEvent::MouseMove, e->localPos(), e->globalPos(), Qt::NoButton, Qt::NoButton, e->modifiers());
+ sendMouseEvent(&moveEvent, m_mouseView);
+ }
+ sendMouseEvent(e, m_mouseView);
+}
+
+void CompositorWindow::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (!mouseGrab())
+ sendMouseEvent(e, m_mouseView);
+ if (e->buttons() == Qt::NoButton) {
+ if (m_grabState == DragGrab) {
+ WindowCompositorView *view = viewAt(e->localPos());
+ m_compositor->handleDrag(view, e);
+ }
+ m_mouseView = 0;
+ m_grabState = NoGrab;
+ }
+}
+
+void CompositorWindow::mouseMoveEvent(QMouseEvent *e)
+{
+ switch (m_grabState) {
+ case NoGrab: {
+ WindowCompositorView *view = m_mouseView ? m_mouseView.data() : viewAt(e->localPos());
+ sendMouseEvent(e, view);
+ if (!view)
+ setCursor(Qt::ArrowCursor);
+ }
+ break;
+ case MoveGrab: {
+ m_mouseView->setPosition(e->localPos() - m_mouseOffset);
+ update();
+ }
+ break;
+ case ResizeGrab: {
+ QPoint delta = (e->localPos() - m_initialMousePos).toPoint();
+ m_compositor->handleResize(m_mouseView, m_initialSize, delta, m_resizeEdge);
+ }
+ break;
+ case DragGrab: {
+ WindowCompositorView *view = viewAt(e->localPos());
+ m_compositor->handleDrag(view, e);
+ if (m_dragIconView) {
+ m_dragIconView->setPosition(e->localPos());
+ update();
+ }
+ }
+ break;
+ }
+}
+
+void CompositorWindow::sendMouseEvent(QMouseEvent *e, WindowCompositorView *target)
+{
+ if (!target)
+ return;
+
+ QPointF mappedPos = e->localPos() - target->position();
+ QMouseEvent viewEvent(e->type(), mappedPos, e->localPos(), e->button(), e->buttons(), e->modifiers());
+ m_compositor->handleMouseEvent(target, &viewEvent);
+}
+
+void CompositorWindow::keyPressEvent(QKeyEvent *e)
{
- setSurfaceType(QWindow::OpenGLSurface);
- setGeometry(geometry);
- setFormat(format);
- create();
- m_context = new QOpenGLContext;
- m_context->setFormat(format);
- m_context->create();
+ m_compositor->defaultInputDevice()->sendKeyPressEvent(e->nativeScanCode());
}
-void CompositorWindow::touchEvent(QTouchEvent *event)
+void CompositorWindow::keyReleaseEvent(QKeyEvent *e)
{
- // Do not want any automatically synthesized mouse events
- // so make sure the touch is always accepted.
- event->accept();
+ m_compositor->defaultInputDevice()->sendKeyReleaseEvent(e->nativeScanCode());
}
diff --git a/examples/wayland/qwindow-compositor/compositorwindow.h b/examples/wayland/qwindow-compositor/compositorwindow.h
index 24c50c53..720db5bc 100644
--- a/examples/wayland/qwindow-compositor/compositorwindow.h
+++ b/examples/wayland/qwindow-compositor/compositorwindow.h
@@ -41,24 +41,61 @@
#ifndef COMPOSITORWINDOW_H
#define COMPOSITORWINDOW_H
-#include <QWindow>
-#include <QOpenGLContext>
-#include <QSurfaceFormat>
+#include <QOpenGLWindow>
+#include <QPointer>
+#include <QtGui/private/qopengltextureblitter_p.h>
-class CompositorWindow : public QWindow
+QT_BEGIN_NAMESPACE
+
+class WindowCompositor;
+class WindowCompositorView;
+class QOpenGLTexture;
+
+class CompositorWindow : public QOpenGLWindow
{
public:
- CompositorWindow(const QSurfaceFormat &format, const QRect &geometry);
- QOpenGLContext* context() { return m_context; }
- bool makeCurrent() { return m_context->makeCurrent(this); }
- void swapBuffers() { m_context->swapBuffers(this); }
+ CompositorWindow();
+
+ void setCompositor(WindowCompositor *comp);
protected:
- void touchEvent(QTouchEvent *event);
+ void initializeGL() Q_DECL_OVERRIDE;
+ void paintGL() Q_DECL_OVERRIDE;
+
+ void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+
+ void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+ void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+
+private slots:
+ void startMove();
+ void startResize(int edge);
+ void startDrag(WindowCompositorView *dragIcon);
+ void setFrameOffset(const QPoint &offset);
private:
- QOpenGLContext *m_context;
- QSurfaceFormat m_format;
+ enum GrabState { NoGrab, MoveGrab, ResizeGrab, DragGrab };
+
+ WindowCompositorView *viewAt(const QPointF &point);
+ bool mouseGrab() const { return m_grabState != NoGrab ;}
+ void drawBackground();
+ void sendMouseEvent(QMouseEvent *e, WindowCompositorView *target);
+
+ QOpenGLTextureBlitter m_textureBlitter;
+ QSize m_backgroundImageSize;
+ QOpenGLTexture *m_backgroundTexture;
+ WindowCompositor *m_compositor;
+ QPointer<WindowCompositorView> m_mouseView;
+ GrabState m_grabState;
+ QSize m_initialSize;
+ int m_resizeEdge;
+ QPointF m_mouseOffset;
+ QPointF m_initialMousePos;
+ WindowCompositorView *m_dragIconView;
};
+QT_END_NAMESPACE
+
#endif // COMPOSITORWINDOW_H
diff --git a/examples/wayland/qwindow-compositor/doc/src/qwindow-compositor.qdoc b/examples/wayland/qwindow-compositor/doc/src/qwindow-compositor.qdoc
new file mode 100644
index 00000000..d268aca4
--- /dev/null
+++ b/examples/wayland/qwindow-compositor/doc/src/qwindow-compositor.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \title Qt Wayland Compositor Examples - QWindow Compositor
+ \example qwindow-compositor
+ \brief QWindow Compositor is an example that demonstrates how to write a Wayland compositor in C++.
+ \ingroup qtwaylandcompositor-examples
+
+ QWindow Compositor is a desktop-style Wayland compositor example that demonstrates the power
+ of the Qt Wayland Compositor C++ APIs.
+*/
diff --git a/examples/wayland/qwindow-compositor/main.cpp b/examples/wayland/qwindow-compositor/main.cpp
index b4be143b..c4fa4325 100644
--- a/examples/wayland/qwindow-compositor/main.cpp
+++ b/examples/wayland/qwindow-compositor/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the examples of the Qt Wayland module
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,36 +38,19 @@
**
****************************************************************************/
-#include "compositorwindow.h"
-#include "qwindowcompositor.h"
-
#include <QGuiApplication>
-#include <QStringList>
-#include <QScreen>
-#include <QSurfaceFormat>
+#include "compositorwindow.h"
+#include "windowcompositor.h"
int main(int argc, char *argv[])
{
- // Enable the following to have touch events generated from mouse events.
- // Very handy for testing touch event delivery without a real touch device.
- // QGuiApplication::setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents, true);
-
QGuiApplication app(argc, argv);
- QScreen *screen = QGuiApplication::primaryScreen();
- QRect screenGeometry = screen->availableGeometry();
-
- QSurfaceFormat format;
- format.setDepthBufferSize(16);
- format.setStencilBufferSize(8);
-
- QRect geom = screenGeometry;
- if (QCoreApplication::arguments().contains(QLatin1String("-nofullscreen")))
- geom = QRect(screenGeometry.width() / 4, screenGeometry.height() / 4,
- screenGeometry.width() / 2, screenGeometry.height() / 2);
-
- CompositorWindow window(format, geom);
- QWindowCompositor compositor(&window);
+ CompositorWindow window;
+ WindowCompositor compositor(&window);
+ window.setCompositor(&compositor);
+ compositor.create();
+ window.resize(800,600);
window.show();
return app.exec();
diff --git a/examples/wayland/qwindow-compositor/qwindow-compositor.pro b/examples/wayland/qwindow-compositor/qwindow-compositor.pro
index 4bab000b..994276d9 100644
--- a/examples/wayland/qwindow-compositor/qwindow-compositor.pro
+++ b/examples/wayland/qwindow-compositor/qwindow-compositor.pro
@@ -1,25 +1,18 @@
-QT += gui gui-private core-private compositor
+QT += gui gui-private core-private waylandcompositor waylandcompositor-private
LIBS += -L ../../lib
-#include (../../src/qt-compositor/qt-compositor.pri)
HEADERS += \
compositorwindow.h \
- qwindowcompositor.h \
- textureblitter.h
+ windowcompositor.h
SOURCES += main.cpp \
compositorwindow.cpp \
- qwindowcompositor.cpp \
- textureblitter.cpp
+ windowcompositor.cpp
-# to make QtCompositor/... style includes working without installing
+# to make QtWaylandCompositor/... style includes working without installing
INCLUDEPATH += $$PWD/../../include
-# if you want to compile QtCompositor as part of the application
-# instead of linking to it, remove the QT += compositor and uncomment
-# the following line
-#include(../../src/compositor/compositor.pri)
RESOURCES += qwindow-compositor.qrc
diff --git a/examples/wayland/qwindow-compositor/qwindow-compositor.qrc b/examples/wayland/qwindow-compositor/qwindow-compositor.qrc
index 20dd10a5..688dd900 100644
--- a/examples/wayland/qwindow-compositor/qwindow-compositor.qrc
+++ b/examples/wayland/qwindow-compositor/qwindow-compositor.qrc
@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/">
- <file alias="background.jpg">../qml-compositor/background.jpg</file>
+ <file alias="background.jpg">../pure-qml/images/background.jpg</file>
</qresource>
</RCC>
diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
deleted file mode 100644
index 58df7ead..00000000
--- a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
+++ /dev/null
@@ -1,485 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** 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 The Qt Company Ltd 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 "qwindowcompositor.h"
-
-#include <QMouseEvent>
-#include <QKeyEvent>
-#include <QTouchEvent>
-#include <QOpenGLFunctions>
-#include <QOpenGLTexture>
-#include <QGuiApplication>
-#include <QCursor>
-#include <QPixmap>
-#include <QLinkedList>
-#include <QScreen>
-#include <QPainter>
-
-#include <QtCompositor/qwaylandinput.h>
-#include <QtCompositor/qwaylandbufferref.h>
-#include <QtCompositor/qwaylandsurfaceview.h>
-#include <QtCompositor/qwaylandoutput.h>
-
-QT_BEGIN_NAMESPACE
-
-class BufferAttacher : public QWaylandBufferAttacher
-{
-public:
- BufferAttacher()
- : QWaylandBufferAttacher()
- , shmTex(0)
- {
- }
-
- ~BufferAttacher()
- {
- delete shmTex;
- }
-
- void attach(const QWaylandBufferRef &ref) Q_DECL_OVERRIDE
- {
- if (bufferRef) {
- if (bufferRef.isShm()) {
- delete shmTex;
- shmTex = 0;
- } else {
- bufferRef.destroyTexture();
- }
- }
-
- bufferRef = ref;
-
- if (bufferRef) {
- if (bufferRef.isShm()) {
- shmTex = new QOpenGLTexture(bufferRef.image(), QOpenGLTexture::DontGenerateMipMaps);
- shmTex->setWrapMode(QOpenGLTexture::ClampToEdge);
- texture = shmTex->textureId();
- textureTarget = GL_TEXTURE_2D;
- } else {
- texture = bufferRef.createTexture();
- textureTarget = bufferRef.textureTarget();
- }
- }
- }
-
- void unmap()
- {
- delete shmTex;
- shmTex = 0;
- bufferRef = QWaylandBufferRef();
- }
-
- QImage image() const
- {
- if (!bufferRef || !bufferRef.isShm())
- return QImage();
- return bufferRef.image();
- }
-
- void updateTexture()
- {
- if (bufferRef)
- bufferRef.updateTexture();
- }
-
- QOpenGLTexture *shmTex;
- QWaylandBufferRef bufferRef;
- GLuint texture;
- GLenum textureTarget;
-};
-
-QWindowCompositor::QWindowCompositor(CompositorWindow *window)
- : QWaylandCompositor(0, DefaultExtensions)
- , m_window(window)
- , m_backgroundTexture(0)
- , m_textureBlitter(0)
- , m_renderScheduler(this)
- , m_draggingWindow(0)
- , m_dragKeyIsPressed(false)
- , m_cursorSurface(0)
- , m_cursorHotspotX(0)
- , m_cursorHotspotY(0)
- , m_modifiers(Qt::NoModifier)
-{
- m_window->makeCurrent();
-
- m_textureBlitter = new TextureBlitter();
- m_backgroundImage = makeBackgroundImage(QLatin1String(":/background.jpg"));
- m_renderScheduler.setSingleShot(true);
- connect(&m_renderScheduler,SIGNAL(timeout()),this,SLOT(render()));
-
- QOpenGLFunctions *functions = m_window->context()->functions();
- functions->glGenFramebuffers(1, &m_surface_fbo);
-
- window->installEventFilter(this);
-
- setRetainedSelectionEnabled(true);
-
- createOutput(window, "", "");
- addDefaultShell();
-}
-
-QWindowCompositor::~QWindowCompositor()
-{
- delete m_textureBlitter;
-}
-
-
-QImage QWindowCompositor::makeBackgroundImage(const QString &fileName)
-{
- Q_ASSERT(m_window);
-
- int width = m_window->width();
- int height = m_window->height();
- QImage baseImage(fileName);
- QImage patternedBackground(width, height, baseImage.format());
- QPainter painter(&patternedBackground);
-
- QSize imageSize = baseImage.size();
- for (int y = 0; y < height; y += imageSize.height()) {
- for (int x = 0; x < width; x += imageSize.width()) {
- painter.drawImage(x, y, baseImage);
- }
- }
-
- return patternedBackground;
-}
-
-void QWindowCompositor::ensureKeyboardFocusSurface(QWaylandSurface *oldSurface)
-{
- QWaylandSurface *kbdFocus = defaultInputDevice()->keyboardFocus();
- if (kbdFocus == oldSurface || !kbdFocus)
- defaultInputDevice()->setKeyboardFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last());
-}
-
-void QWindowCompositor::surfaceDestroyed()
-{
- QWaylandSurface *surface = static_cast<QWaylandSurface *>(sender());
- m_surfaces.removeOne(surface);
- ensureKeyboardFocusSurface(surface);
- m_renderScheduler.start(0);
-}
-
-void QWindowCompositor::surfaceMapped()
-{
- QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
- QPoint pos;
- if (!m_surfaces.contains(surface)) {
- if (surface->windowType() != QWaylandSurface::Popup) {
- uint px = 0;
- uint py = 0;
- if (!QCoreApplication::arguments().contains(QLatin1String("-stickytopleft"))) {
- px = 1 + (qrand() % (m_window->width() - surface->size().width() - 2));
- py = 1 + (qrand() % (m_window->height() - surface->size().height() - 2));
- }
- pos = QPoint(px, py);
- QWaylandSurfaceView *view = surface->views().first();
- view->setPos(pos);
- }
- } else {
- m_surfaces.removeOne(surface);
- }
-
- if (surface->windowType() == QWaylandSurface::Popup) {
- QWaylandSurfaceView *view = surface->views().first();
- view->setPos(surface->transientParent()->views().first()->pos() + surface->transientOffset());
- }
-
- m_surfaces.append(surface);
- defaultInputDevice()->setKeyboardFocus(surface);
-
- m_renderScheduler.start(0);
-}
-
-void QWindowCompositor::surfaceUnmapped()
-{
- QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
- if (m_surfaces.removeOne(surface))
- m_surfaces.insert(0, surface);
-
- ensureKeyboardFocusSurface(surface);
- m_renderScheduler.start(0);
-}
-
-void QWindowCompositor::surfaceCommitted()
-{
- QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
- surfaceCommitted(surface);
-}
-
-void QWindowCompositor::surfacePosChanged()
-{
- m_renderScheduler.start(0);
-}
-
-void QWindowCompositor::surfaceCommitted(QWaylandSurface *surface)
-{
- Q_UNUSED(surface)
- m_renderScheduler.start(0);
-}
-
-void QWindowCompositor::surfaceCreated(QWaylandSurface *surface)
-{
- connect(surface, SIGNAL(surfaceDestroyed()), this, SLOT(surfaceDestroyed()));
- connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped()));
- connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped()));
- connect(surface, SIGNAL(redraw()), this, SLOT(surfaceCommitted()));
- connect(surface, SIGNAL(extendedSurfaceReady()), this, SLOT(sendExpose()));
- m_renderScheduler.start(0);
-
- surface->setBufferAttacher(new BufferAttacher);
-}
-
-void QWindowCompositor::sendExpose()
-{
- QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
- surface->sendOnScreenVisibilityChange(true);
-}
-
-void QWindowCompositor::updateCursor(bool hasBuffer)
-{
- Q_UNUSED(hasBuffer)
- if (!m_cursorSurface)
- return;
-
- QImage image = static_cast<BufferAttacher *>(m_cursorSurface->bufferAttacher())->image();
-
- QCursor cursor(QPixmap::fromImage(image), m_cursorHotspotX, m_cursorHotspotY);
- static bool cursorIsSet = false;
- if (cursorIsSet) {
- QGuiApplication::changeOverrideCursor(cursor);
- } else {
- QGuiApplication::setOverrideCursor(cursor);
- cursorIsSet = true;
- }
-}
-
-QPointF QWindowCompositor::toView(QWaylandSurfaceView *view, const QPointF &pos) const
-{
- return pos - view->pos();
-}
-
-void QWindowCompositor::setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY)
-{
- if ((m_cursorSurface != surface) && surface)
- connect(surface, SIGNAL(configure(bool)), this, SLOT(updateCursor(bool)));
-
- m_cursorSurface = surface;
- m_cursorHotspotX = hotspotX;
- m_cursorHotspotY = hotspotY;
- if (m_cursorSurface && !m_cursorSurface->bufferAttacher())
- m_cursorSurface->setBufferAttacher(new BufferAttacher);
-}
-
-QWaylandSurfaceView *QWindowCompositor::viewAt(const QPointF &point, QPointF *local)
-{
- for (int i = m_surfaces.size() - 1; i >= 0; --i) {
- QWaylandSurface *surface = m_surfaces.at(i);
- foreach (QWaylandSurfaceView *view, surface->views()) {
- QRectF geo(view->pos(), surface->size());
- if (geo.contains(point)) {
- if (local)
- *local = toView(view, point);
- return view;
- }
- }
- }
- return 0;
-}
-
-void QWindowCompositor::render()
-{
- m_window->makeCurrent();
- frameStarted();
-
- cleanupGraphicsResources();
-
- if (!m_backgroundTexture)
- m_backgroundTexture = new QOpenGLTexture(m_backgroundImage, QOpenGLTexture::DontGenerateMipMaps);
-
- m_textureBlitter->bind(GL_TEXTURE_2D);
- // Draw the background image texture
- m_textureBlitter->drawTexture(m_backgroundTexture->textureId(),
- QRect(QPoint(0, 0), m_backgroundImage.size()),
- m_window->size(),
- 0, false, true);
-
- foreach (QWaylandSurface *surface, m_surfaces) {
- if (!surface->visible())
- continue;
- BufferAttacher *ba = static_cast<BufferAttacher *>(surface->bufferAttacher());
- ba->updateTexture();
- const GLuint texture = ba->texture;
- const GLenum target = ba->textureTarget;
- m_textureBlitter->bind(target);
- foreach (QWaylandSurfaceView *view, surface->views()) {
- QRect geo(view->pos().toPoint(),surface->size());
- m_textureBlitter->drawTexture(texture,geo,m_window->size(),0,false,surface->isYInverted());
- }
- }
-
- m_textureBlitter->release();
- sendFrameCallbacks(surfaces());
-
- // N.B. Never call glFinish() here as the busylooping with vsync 'feature' of the nvidia binary driver is not desirable.
- m_window->swapBuffers();
-}
-
-bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event)
-{
- if (obj != m_window)
- return false;
-
- QWaylandInputDevice *input = defaultInputDevice();
-
- switch (event->type()) {
- case QEvent::Expose:
- m_renderScheduler.start(0);
- if (m_window->isExposed()) {
- // Alt-tabbing away normally results in the alt remaining in
- // pressed state in the clients xkb state. Prevent this by sending
- // a release. This is not an issue in a "real" compositor but
- // is very annoying when running in a regular window on xcb.
- Qt::KeyboardModifiers mods = QGuiApplication::queryKeyboardModifiers();
- if (m_modifiers != mods && input->keyboardFocus()) {
- Qt::KeyboardModifiers stuckMods = m_modifiers ^ mods;
- if (stuckMods & Qt::AltModifier)
- input->sendKeyReleaseEvent(64); // native scancode for left alt
- m_modifiers = mods;
- }
- }
- break;
- case QEvent::MouseButtonPress: {
- QPointF local;
- QMouseEvent *me = static_cast<QMouseEvent *>(event);
- QWaylandSurfaceView *target = viewAt(me->localPos(), &local);
- if (m_dragKeyIsPressed && target) {
- m_draggingWindow = target;
- m_drag_diff = local;
- } else {
- if (target && input->keyboardFocus() != target->surface()) {
- input->setKeyboardFocus(target->surface());
- m_surfaces.removeOne(target->surface());
- m_surfaces.append(target->surface());
- m_renderScheduler.start(0);
- }
- input->sendMousePressEvent(me->button(), local, me->localPos());
- }
- return true;
- }
- case QEvent::MouseButtonRelease: {
- QWaylandSurfaceView *target = input->mouseFocus();
- if (m_draggingWindow) {
- m_draggingWindow = 0;
- m_drag_diff = QPointF();
- } else {
- QMouseEvent *me = static_cast<QMouseEvent *>(event);
- QPointF localPos;
- if (target)
- localPos = toView(target, me->localPos());
- input->sendMouseReleaseEvent(me->button(), localPos, me->localPos());
- }
- return true;
- }
- case QEvent::MouseMove: {
- QMouseEvent *me = static_cast<QMouseEvent *>(event);
- if (m_draggingWindow) {
- m_draggingWindow->setPos(me->localPos() - m_drag_diff);
- m_renderScheduler.start(0);
- } else {
- QPointF local;
- QWaylandSurfaceView *target = viewAt(me->localPos(), &local);
- input->sendMouseMoveEvent(target, local, me->localPos());
- }
- break;
- }
- case QEvent::Wheel: {
- QWheelEvent *we = static_cast<QWheelEvent *>(event);
- input->sendMouseWheelEvent(we->orientation(), we->delta());
- break;
- }
- case QEvent::KeyPress: {
- QKeyEvent *ke = static_cast<QKeyEvent *>(event);
- if (ke->key() == Qt::Key_Meta || ke->key() == Qt::Key_Super_L) {
- m_dragKeyIsPressed = true;
- }
- m_modifiers = ke->modifiers();
- QWaylandSurface *targetSurface = input->keyboardFocus();
- if (targetSurface)
- input->sendKeyPressEvent(ke->nativeScanCode());
- break;
- }
- case QEvent::KeyRelease: {
- QKeyEvent *ke = static_cast<QKeyEvent *>(event);
- if (ke->key() == Qt::Key_Meta || ke->key() == Qt::Key_Super_L) {
- m_dragKeyIsPressed = false;
- }
- m_modifiers = ke->modifiers();
- QWaylandSurface *targetSurface = input->keyboardFocus();
- if (targetSurface)
- input->sendKeyReleaseEvent(ke->nativeScanCode());
- break;
- }
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- {
- QWaylandSurfaceView *target = 0;
- QTouchEvent *te = static_cast<QTouchEvent *>(event);
- QList<QTouchEvent::TouchPoint> points = te->touchPoints();
- QPoint pointPos;
- if (!points.isEmpty()) {
- pointPos = points.at(0).pos().toPoint();
- target = viewAt(pointPos);
- }
- if (target && target != input->mouseFocus())
- input->setMouseFocus(target, pointPos, pointPos);
- if (input->mouseFocus())
- input->sendFullTouchEvent(te);
- break;
- }
- default:
- break;
- }
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.h b/examples/wayland/qwindow-compositor/qwindowcompositor.h
deleted file mode 100644
index cb70369c..00000000
--- a/examples/wayland/qwindow-compositor/qwindowcompositor.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** 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 The Qt Company Ltd 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 QWINDOWCOMPOSITOR_H
-#define QWINDOWCOMPOSITOR_H
-
-#include "qwaylandcompositor.h"
-#include "qwaylandsurface.h"
-#include "textureblitter.h"
-#include "compositorwindow.h"
-
-#include <QtGui/private/qopengltexturecache_p.h>
-#include <QObject>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-class QWaylandSurfaceView;
-class QOpenGLTexture;
-
-class QWindowCompositor : public QObject, public QWaylandCompositor
-{
- Q_OBJECT
-public:
- QWindowCompositor(CompositorWindow *window);
- ~QWindowCompositor();
-
-private slots:
- void surfaceDestroyed();
- void surfaceMapped();
- void surfaceUnmapped();
- void surfaceCommitted();
- void surfacePosChanged();
-
- void render();
-protected:
- void surfaceCommitted(QWaylandSurface *surface);
- void surfaceCreated(QWaylandSurface *surface);
-
- QWaylandSurfaceView* viewAt(const QPointF &point, QPointF *local = 0);
-
- bool eventFilter(QObject *obj, QEvent *event);
- QPointF toView(QWaylandSurfaceView *view, const QPointF &pos) const;
-
- void setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY);
-
- void ensureKeyboardFocusSurface(QWaylandSurface *oldSurface);
- QImage makeBackgroundImage(const QString &fileName);
-
-private slots:
- void sendExpose();
- void updateCursor(bool hasBuffer);
-
-private:
- void drawSubSurface(const QPoint &offset, QWaylandSurface *surface);
-
- CompositorWindow *m_window;
- QImage m_backgroundImage;
- QOpenGLTexture *m_backgroundTexture;
- QList<QWaylandSurface *> m_surfaces;
- TextureBlitter *m_textureBlitter;
- GLuint m_surface_fbo;
- QTimer m_renderScheduler;
-
- //Dragging windows around
- QWaylandSurfaceView *m_draggingWindow;
- bool m_dragKeyIsPressed;
- QPointF m_drag_diff;
-
- //Cursor
- QWaylandSurface *m_cursorSurface;
- int m_cursorHotspotX;
- int m_cursorHotspotY;
-
- Qt::KeyboardModifiers m_modifiers;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWCOMPOSITOR_H
diff --git a/examples/wayland/qwindow-compositor/textureblitter.cpp b/examples/wayland/qwindow-compositor/textureblitter.cpp
deleted file mode 100644
index df4fa18d..00000000
--- a/examples/wayland/qwindow-compositor/textureblitter.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** 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 The Qt Company Ltd 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 "textureblitter.h"
-
-#include <QtGui/QOpenGLShaderProgram>
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLFunctions>
-
-#ifndef GL_TEXTURE_EXTERNAL_OES
-#define GL_TEXTURE_EXTERNAL_OES 0x8D65
-#endif
-
-QT_BEGIN_NAMESPACE
-
-TextureBlitter::TextureBlitter()
- : m_shaderProgram(new QOpenGLShaderProgram)
- , m_shaderProgramExternal(new QOpenGLShaderProgram)
- , m_currentProgram(0)
- , m_currentTarget(GL_TEXTURE_2D)
-{
- static const char *textureVertexProgram =
- "uniform highp mat4 matrix;\n"
- "attribute highp vec3 vertexCoordEntry;\n"
- "attribute highp vec2 textureCoordEntry;\n"
- "varying highp vec2 textureCoord;\n"
- "void main() {\n"
- " textureCoord = textureCoordEntry;\n"
- " gl_Position = matrix * vec4(vertexCoordEntry, 1);\n"
- "}\n";
-
- static const char *textureFragmentProgram =
- "uniform sampler2D texture;\n"
- "varying highp vec2 textureCoord;\n"
- "void main() {\n"
- " gl_FragColor = texture2D(texture, textureCoord);\n"
- "}\n";
-
- static const char *textureFragmentProgramExternal =
- "#extension GL_OES_EGL_image_external : require\n"
- "uniform samplerExternalOES texture;\n"
- "varying highp vec2 textureCoord;\n"
- "void main() {\n"
- " gl_FragColor = texture2D(texture, textureCoord);\n"
- "}\n";
-
- m_shaderProgram->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
- m_shaderProgram->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram);
- m_shaderProgram->link();
-
- m_shaderProgramExternal->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
- m_shaderProgramExternal->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgramExternal);
- m_shaderProgramExternal->link();
-}
-
-TextureBlitter::~TextureBlitter()
-{
- delete m_shaderProgram;
- delete m_shaderProgramExternal;
-}
-
-void TextureBlitter::bind(quint32 target)
-{
- m_currentTarget = target;
- switch (target) {
- case GL_TEXTURE_2D:
- m_currentProgram = m_shaderProgram;
- break;
- case GL_TEXTURE_EXTERNAL_OES:
- m_currentProgram = m_shaderProgramExternal;
- break;
- default:
- qFatal("INVALID TARGET TYPE %d", target);
- break;
- }
-
- m_currentProgram->bind();
-
- m_vertexCoordEntry = m_shaderProgram->attributeLocation("vertexCoordEntry");
- m_textureCoordEntry = m_shaderProgram->attributeLocation("textureCoordEntry");
- m_matrixLocation = m_shaderProgram->uniformLocation("matrix");
-
- //Enable transparent windows
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-}
-
-void TextureBlitter::release()
-{
- m_currentProgram->release();
-}
-
-void TextureBlitter::drawTexture(int textureId, const QRectF &targetRect, const QSize &targetSize, int depth, bool targethasInvertedY, bool sourceHasInvertedY)
-{
-
- glViewport(0,0,targetSize.width(),targetSize.height());
- GLfloat zValue = depth / 1000.0f;
- //Set Texture and Vertex coordinates
- const GLfloat textureCoordinates[] = {
- 0, 0,
- 1, 0,
- 1, 1,
- 0, 1
- };
-
- GLfloat x1 = targetRect.left();
- GLfloat x2 = targetRect.right();
- GLfloat y1, y2;
- if (targethasInvertedY) {
- if (sourceHasInvertedY) {
- y1 = targetRect.top();
- y2 = targetRect.bottom();
- } else {
- y1 = targetRect.bottom();
- y2 = targetRect.top();
- }
- } else {
- if (sourceHasInvertedY) {
- y1 = targetSize.height() - targetRect.top();
- y2 = targetSize.height() - targetRect.bottom();
- } else {
- y1 = targetSize.height() - targetRect.bottom();
- y2 = targetSize.height() - targetRect.top();
- }
- }
-
- const GLfloat vertexCoordinates[] = {
- GLfloat(x1), GLfloat(y1), zValue,
- GLfloat(x2), GLfloat(y1), zValue,
- GLfloat(x2), GLfloat(y2), zValue,
- GLfloat(x1), GLfloat(y2), zValue
- };
-
- //Set matrix to transfrom geometry values into gl coordinate space.
- m_transformMatrix.setToIdentity();
- m_transformMatrix.scale( 2.0f / targetSize.width(), 2.0f / targetSize.height() );
- m_transformMatrix.translate(-targetSize.width() / 2.0f, -targetSize.height() / 2.0f);
-
- //attach the data!
- QOpenGLContext *currentContext = QOpenGLContext::currentContext();
- currentContext->functions()->glEnableVertexAttribArray(m_vertexCoordEntry);
- currentContext->functions()->glEnableVertexAttribArray(m_textureCoordEntry);
-
- currentContext->functions()->glVertexAttribPointer(m_vertexCoordEntry, 3, GL_FLOAT, GL_FALSE, 0, vertexCoordinates);
- currentContext->functions()->glVertexAttribPointer(m_textureCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinates);
-
- m_currentProgram->setUniformValue(m_matrixLocation, m_transformMatrix);
-
- glBindTexture(m_currentTarget, textureId);
-
- glTexParameterf(m_currentTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(m_currentTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- glBindTexture(m_currentTarget, 0);
-
- currentContext->functions()->glDisableVertexAttribArray(m_vertexCoordEntry);
- currentContext->functions()->glDisableVertexAttribArray(m_textureCoordEntry);
-}
-
-QT_END_NAMESPACE
diff --git a/examples/wayland/qwindow-compositor/windowcompositor.cpp b/examples/wayland/qwindow-compositor/windowcompositor.cpp
new file mode 100644
index 00000000..24a0e0f5
--- /dev/null
+++ b/examples/wayland/qwindow-compositor/windowcompositor.cpp
@@ -0,0 +1,300 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Wayland module
+**
+** $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 The Qt Company Ltd 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 "windowcompositor.h"
+
+#include <QMouseEvent>
+#include <QKeyEvent>
+#include <QTouchEvent>
+
+#include <QtWaylandCompositor/QWaylandShellSurface>
+#include <QtWaylandCompositor/qwaylandinput.h>
+#include <QtWaylandCompositor/qwaylanddrag.h>
+
+#include <QDebug>
+
+GLuint WindowCompositorView::getTexture() {
+ if (advance()) {
+ if (m_texture)
+ glDeleteTextures(1, &m_texture);
+
+ glGenTextures(1, &m_texture);
+ glBindTexture(GL_TEXTURE_2D, m_texture);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ currentBuffer().bindToTexture();
+ }
+ return m_texture;
+}
+
+bool WindowCompositorView::isCursor() const
+{
+ return surface()->isCursorSurface();
+}
+
+WindowCompositor::WindowCompositor(QWindow *window)
+ : QWaylandCompositor()
+ , m_window(window)
+ , m_shell(new QWaylandShell(this))
+{
+ connect(m_shell, &QWaylandShell::createShellSurface, this, &WindowCompositor::onCreateShellSurface);
+}
+
+WindowCompositor::~WindowCompositor()
+{
+}
+
+void WindowCompositor::create()
+{
+ new QWaylandOutput(this, m_window);
+ QWaylandCompositor::create();
+
+ connect(this, &QWaylandCompositor::surfaceCreated, this, &WindowCompositor::onSurfaceCreated);
+ connect(defaultInputDevice(), &QWaylandInputDevice::cursorSurfaceRequest, this, &WindowCompositor::adjustCursorSurface);
+ connect(defaultInputDevice()->drag(), &QWaylandDrag::dragStarted, this, &WindowCompositor::startDrag);
+}
+
+void WindowCompositor::onSurfaceCreated(QWaylandSurface *surface)
+{
+ connect(surface, &QWaylandSurface::surfaceDestroyed, this, &WindowCompositor::surfaceDestroyed);
+ connect(surface, &QWaylandSurface::mappedChanged, this, &WindowCompositor::surfaceMappedChanged);
+ connect(surface, &QWaylandSurface::redraw, this, &WindowCompositor::triggerRender);
+ connect(surface, &QWaylandSurface::offsetForNextFrame, this, &WindowCompositor::frameOffset);
+ WindowCompositorView *view = new WindowCompositorView;
+ view->setSurface(surface);
+ view->setOutput(outputFor(m_window));
+ m_views << view;
+ connect(view, &QWaylandView::surfaceDestroyed, this, &WindowCompositor::viewSurfaceDestroyed);
+}
+
+void WindowCompositor::surfaceMappedChanged()
+{
+ QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
+ if (surface->isMapped()) {
+ if (!surface->isCursorSurface())
+ defaultInputDevice()->setKeyboardFocus(surface);
+ } else if (popupActive()) {
+ for (int i = 0; i < m_popupViews.count(); i++) {
+ if (m_popupViews.at(i)->surface() == surface) {
+ m_popupViews.removeAt(i);
+ break;
+ }
+ }
+ }
+ triggerRender();
+}
+
+void WindowCompositor::surfaceDestroyed()
+{
+ triggerRender();
+}
+
+void WindowCompositor::viewSurfaceDestroyed()
+{
+ WindowCompositorView *view = qobject_cast<WindowCompositorView*>(sender());
+ m_views.removeAll(view);
+ delete view;
+}
+
+void WindowCompositor::surfaceCommittedSlot()
+{
+ triggerRender();
+}
+
+WindowCompositorView * WindowCompositor::findView(const QWaylandSurface *s) const
+{
+ Q_FOREACH (WindowCompositorView* view, m_views) {
+ if (view->surface() == s)
+ return view;
+ }
+ return Q_NULLPTR;
+}
+
+void WindowCompositor::onCreateShellSurface(QWaylandSurface *s, QWaylandClient *client, uint id)
+{
+ QWaylandSurface *surface = s;
+
+ QWaylandShellSurface *shellSurface = new QWaylandShellSurface(m_shell, surface, client, id);
+ connect(shellSurface, &QWaylandShellSurface::startMove, this, &WindowCompositor::onStartMove);
+ connect(shellSurface, &QWaylandShellSurface::startResize, this, &WindowCompositor::onStartResize);
+ connect(shellSurface, &QWaylandShellSurface::setTransient, this, &WindowCompositor::onSetTransient);
+ connect(shellSurface, &QWaylandShellSurface::setPopup, this, &WindowCompositor::onSetPopup);
+ WindowCompositorView *view = findView(s);
+ Q_ASSERT(view);
+ view->m_shellSurface = shellSurface;
+}
+
+void WindowCompositor::onStartMove()
+{
+ closePopups();
+ emit startMove();
+}
+
+void WindowCompositor::onStartResize(QWaylandInputDevice *, QWaylandShellSurface::ResizeEdge edges)
+{
+ closePopups();
+ emit startResize(int(edges));
+}
+
+void WindowCompositor::onSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, QWaylandShellSurface::FocusPolicy focusPolicy)
+{
+ qDebug() << "Transient window support not implemented" << parentSurface << relativeToParent << focusPolicy;
+}
+
+void WindowCompositor::onSetPopup(QWaylandInputDevice *inputDevice, QWaylandSurface *parent, const QPoint &relativeToParent)
+{
+ Q_UNUSED(inputDevice);
+ QWaylandShellSurface *surface = qobject_cast<QWaylandShellSurface*>(sender());
+ WindowCompositorView *view = findView(surface->surface());
+ m_popupViews << view;
+ if (view) {
+ raise(view);
+ WindowCompositorView *parentView = findView(parent);
+ if (parentView)
+ view->setPosition(parentView->position() + relativeToParent);
+ }
+}
+
+void WindowCompositor::triggerRender()
+{
+ m_window->requestUpdate();
+}
+
+void WindowCompositor::startRender()
+{
+ QWaylandOutput *out = defaultOutput();
+ if (out)
+ out->frameStarted();
+}
+
+void WindowCompositor::endRender()
+{
+ QWaylandOutput *out = defaultOutput();
+ if (out)
+ out->sendFrameCallbacks();
+}
+
+void WindowCompositor::updateCursor()
+{
+ m_cursorView.advance();
+ QImage image = m_cursorView.currentBuffer().image();
+ if (!image.isNull())
+ m_window->setCursor(QCursor(QPixmap::fromImage(image), m_cursorHotspotX, m_cursorHotspotY));
+}
+
+void WindowCompositor::adjustCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY)
+{
+ if ((m_cursorView.surface() != surface)) {
+ if (m_cursorView.surface())
+ disconnect(m_cursorView.surface(), &QWaylandSurface::redraw, this, &WindowCompositor::updateCursor);
+ if (surface)
+ connect(surface, &QWaylandSurface::redraw, this, &WindowCompositor::updateCursor);
+ }
+
+ m_cursorView.setSurface(surface);
+ m_cursorHotspotX = hotspotX;
+ m_cursorHotspotY = hotspotY;
+}
+
+void WindowCompositor::closePopups()
+{
+ Q_FOREACH (WindowCompositorView *view, m_popupViews)
+ view->m_shellSurface->sendPopupDone();
+ m_popupViews.clear();
+}
+
+void WindowCompositor::handleMouseEvent(QWaylandView *target, QMouseEvent *me)
+{
+ if (target && popupActive() && me->type() == QEvent::MouseButtonPress
+ && target->surface()->client() != m_popupViews.first()->surface()->client()) {
+ closePopups();
+ }
+ QWaylandInputDevice *input = defaultInputDevice();
+ switch (me->type()) {
+ case QEvent::MouseButtonPress:
+ input->sendMousePressEvent(me->button());
+ break;
+ case QEvent::MouseButtonRelease:
+ input->sendMouseReleaseEvent(me->button());
+ break;
+ case QEvent::MouseMove:
+ input->sendMouseMoveEvent(target, me->localPos(), me->globalPos());
+ default:
+ break;
+ }
+}
+
+void WindowCompositor::handleResize(WindowCompositorView *target, const QSize &initialSize, const QPoint &delta, int edge)
+{
+ QWaylandShellSurface *shellSurface = target->m_shellSurface;
+ if (!shellSurface)
+ return;
+ QWaylandShellSurface::ResizeEdge edges = QWaylandShellSurface::ResizeEdge(edge);
+ QSize newSize = shellSurface->sizeForResize(initialSize, delta, edges);
+ shellSurface->sendConfigure(newSize, edges);
+}
+
+void WindowCompositor::startDrag()
+{
+ QWaylandDrag *currentDrag = defaultInputDevice()->drag();
+ Q_ASSERT(currentDrag);
+ WindowCompositorView *iconView = findView(currentDrag->icon());
+
+ emit dragStarted(iconView);
+}
+
+void WindowCompositor::handleDrag(WindowCompositorView *target, QMouseEvent *me)
+{
+ QPointF pos = me->localPos();
+ QWaylandSurface *surface = 0;
+ if (target) {
+ pos -= target->position();
+ surface = target->surface();
+ }
+ QWaylandDrag *currentDrag = defaultInputDevice()->drag();
+ currentDrag->dragMove(surface, pos);
+ if (me->buttons() == Qt::NoButton)
+ currentDrag->drop();
+}
+
+void WindowCompositor::raise(WindowCompositorView *view)
+{
+ m_views.removeOne(view);
+ m_views.append(view);
+}
diff --git a/examples/wayland/qwindow-compositor/windowcompositor.h b/examples/wayland/qwindow-compositor/windowcompositor.h
new file mode 100644
index 00000000..6f878d3a
--- /dev/null
+++ b/examples/wayland/qwindow-compositor/windowcompositor.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Wayland module
+**
+** $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 The Qt Company Ltd 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 WINDOWCOMPOSITOR_H
+#define WINDOWCOMPOSITOR_H
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandSurface>
+#include <QtWaylandCompositor/QWaylandView>
+#include <QtWaylandCompositor/QWaylandShellSurface>
+#include <QTimer>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandShell;
+class QWaylandShellSurface;
+
+class WindowCompositorView : public QWaylandView
+{
+ Q_OBJECT
+public:
+ WindowCompositorView() : m_texture(0), m_shellSurface(0) {}
+ GLuint getTexture();
+ QPointF position() const { return m_position; }
+ void setPosition(const QPointF &pos) { m_position = pos; }
+ bool isCursor() const;
+ bool hasShell() const { return m_shellSurface; }
+private:
+ friend class WindowCompositor;
+ GLuint m_texture;
+ QPointF m_position;
+ QWaylandShellSurface *m_shellSurface;
+};
+
+class WindowCompositor : public QWaylandCompositor
+{
+ Q_OBJECT
+public:
+ WindowCompositor(QWindow *window);
+ ~WindowCompositor();
+ void create() Q_DECL_OVERRIDE;
+
+ void startRender();
+ void endRender();
+
+ QList<WindowCompositorView*> views() const { return m_views; }
+ void raise(WindowCompositorView *view);
+
+ void handleMouseEvent(QWaylandView *target, QMouseEvent *me);
+ void handleResize(WindowCompositorView *target, const QSize &initialSize, const QPoint &delta, int edge);
+ void handleDrag(WindowCompositorView *target, QMouseEvent *me);
+
+ bool popupActive() const { return !m_popupViews.isEmpty(); }
+ void closePopups();
+protected:
+ void adjustCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY);
+
+signals:
+ void startMove();
+ void startResize(int edge);
+ void dragStarted(WindowCompositorView *dragIcon);
+ void frameOffset(const QPoint &offset);
+
+private slots:
+ void surfaceMappedChanged();
+ void surfaceDestroyed();
+ void surfaceCommittedSlot();
+ void viewSurfaceDestroyed();
+ void onStartMove();
+ void onStartResize(QWaylandInputDevice *inputDevice, QWaylandShellSurface::ResizeEdge edges);
+
+ void startDrag();
+
+ void triggerRender();
+
+ void onSurfaceCreated(QWaylandSurface *surface);
+ void onCreateShellSurface(QWaylandSurface *s, QWaylandClient *client, uint id);
+ void onSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, QWaylandShellSurface::FocusPolicy focusPolicy);
+ void onSetPopup(QWaylandInputDevice *inputDevice, QWaylandSurface *parent, const QPoint &relativeToParent);
+
+ void updateCursor();
+private:
+ WindowCompositorView *findView(const QWaylandSurface *s) const;
+ QWindow *m_window;
+ QList<WindowCompositorView*> m_views;
+ QList<WindowCompositorView*> m_popupViews;
+ QWaylandShell *m_shell;
+ QWaylandView m_cursorView;
+ int m_cursorHotspotX;
+ int m_cursorHotspotY;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // WINDOWCOMPOSITOR_H
diff --git a/examples/wayland/server-buffer/client/client.pro b/examples/wayland/server-buffer/client/client.pro
index 9d408d9e..6c2c9285 100644
--- a/examples/wayland/server-buffer/client/client.pro
+++ b/examples/wayland/server-buffer/client/client.pro
@@ -4,11 +4,11 @@ INCLUDEPATH += .
QT += waylandclient-private
-!contains(QT_CONFIG, no-pkg-config) {
- PKGCONFIG += wayland-client
- CONFIG += link_pkgconfig
-} else {
+contains(QT_CONFIG, no-pkg-config) {
LIBS += -lwayland-client
+} else {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += wayland-client
}
CONFIG += wayland-scanner
diff --git a/examples/wayland/server-buffer/compositor/compositor.pro b/examples/wayland/server-buffer/compositor/compositor.pro
index 8d7f4882..f391d3a1 100644
--- a/examples/wayland/server-buffer/compositor/compositor.pro
+++ b/examples/wayland/server-buffer/compositor/compositor.pro
@@ -1,20 +1,23 @@
-QT += core-private gui-private quick-private compositor-private
+QT += core-private gui-private quick-private waylandcompositor-private
-LIBS += -lwayland-server
+contains(QT_CONFIG, no-pkg-config) {
+ LIBS += -lwayland-server
+} else {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += wayland-server
+}
SOURCES += \
main.cpp \
serverbufferitem.cpp
+
HEADERS += \
- serverbufferitem.h \
+ serverbufferitem.h
OTHER_FILES = \
- qml/main.qml \
- images/background.jpg \
+ images/background.jpg
RESOURCES += compositor.qrc
-CONFIG +=wayland-scanner
+CONFIG += wayland-scanner
WAYLANDSERVERSOURCES += ../share-buffer.xml
-
-DEFINES += QT_COMPOSITOR_QUICK
diff --git a/examples/wayland/server-buffer/compositor/main.cpp b/examples/wayland/server-buffer/compositor/main.cpp
index 312cff2c..57ca647b 100644
--- a/examples/wayland/server-buffer/compositor/main.cpp
+++ b/examples/wayland/server-buffer/compositor/main.cpp
@@ -41,7 +41,7 @@
#include "qwaylandquickcompositor.h"
#include "qwaylandsurface.h"
-#include "qwaylandsurfaceitem.h"
+#include "qwaylandquickitem.h"
#include <QGuiApplication>
#include <QTimer>
@@ -55,47 +55,61 @@
#include <QQuickView>
#include "qwayland-server-share-buffer.h"
-#include <QtCompositor/qwaylandoutput.h>
-#include <QtCompositor/private/qwlcompositor_p.h>
-#include <QtCompositor/private/qwlserverbufferintegration_p.h>
+#include <QtWaylandCompositor/QWaylandQuickOutput>
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandQuickItem>
+#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
+#include <QtWaylandCompositor/private/qwlserverbufferintegration_p.h>
#include "serverbufferitem.h"
#include <QtGui/private/qdistancefield_p.h>
class QmlCompositor
- : public QQuickView
- , public QWaylandQuickCompositor
+ : public QWaylandQuickCompositor
, public QtWaylandServer::qt_share_buffer
{
Q_OBJECT
public:
QmlCompositor()
- : QWaylandQuickCompositor(0, DefaultExtensions | SubSurfaceExtension)
- , QtWaylandServer::qt_share_buffer(QWaylandCompositor::handle()->wl_display(), 1)
+ : QWaylandQuickCompositor()
+ , QtWaylandServer::qt_share_buffer(QWaylandCompositor::display(), 1)
, m_server_buffer_32_bit(0)
, m_server_buffer_item_32_bit(0)
, m_server_buffer_8_bit(0)
, m_server_buffer_item_8_bit(0)
{
- setSource(QUrl("qrc:/qml/main.qml"));
- setResizeMode(QQuickView::SizeRootObjectToView);
- setColor(Qt::black);
create();
- grabWindow();
- createOutput(this, "", "");
- addDefaultShell();
+ m_view.setSource(QUrl("qrc:/qml/main.qml"));
+ m_view.setResizeMode(QQuickView::SizeRootObjectToView);
+ m_view.setColor(Qt::black);
+ m_view.create();
+ m_output = new QWaylandQuickOutput(this, &m_view);
- connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()));
+ connect(&m_view, &QQuickView::afterRendering, this, &QmlCompositor::sendCallbacks);
- connect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(initiateServerBuffer()),Qt::DirectConnection);
- connect(this, SIGNAL(serverBuffersCreated()), this, SLOT(createServerBufferItems()));
+ connect(&m_view, &QQuickView::sceneGraphInitialized, this, &QmlCompositor::initiateServerBuffer,Qt::DirectConnection);
+ connect(this, &QmlCompositor::serverBuffersCreated, this, &QmlCompositor::createServerBufferItems);
+
+ connect(&m_view, &QWindow::widthChanged, this, &QmlCompositor::sizeAdjusted);
+ connect(&m_view, &QWindow::heightChanged, this, &QmlCompositor::sizeAdjusted);
+
+ connect(this, SIGNAL(windowAdded(QVariant)), m_view.rootObject(), SLOT(windowAdded(QVariant)));
+ connect(this, SIGNAL(windowResized(QVariant)), m_view.rootObject(), SLOT(windowResized(QVariant)));
+ connect(this, SIGNAL(serverBufferItemCreated(QVariant)), m_view.rootObject(), SLOT(serverBufferItemCreated(QVariant)));
+ connect(this, &QWaylandCompositor::surfaceCreated, this, &QmlCompositor::onSurfaceCreated);
+
+ m_view.setTitle(QLatin1String("QML Compositor"));
+ m_view.setGeometry(0, 0, 1024, 768);
+ m_view.rootContext()->setContextProperty("compositor", this);
+
+ m_view.show();
}
- Q_INVOKABLE QWaylandSurfaceItem *item(QWaylandSurface *surf)
+ Q_INVOKABLE QWaylandQuickItem *item(QWaylandSurface *surf)
{
- return static_cast<QWaylandSurfaceItem *>(surf->views().first());
+ return static_cast<QWaylandQuickItem *>(surf->views().first()->renderObject());
}
signals:
@@ -118,17 +132,17 @@ private slots:
}
void sendCallbacks() {
- sendFrameCallbacks(surfaces());
+ m_output->sendFrameCallbacks();
}
void initiateServerBuffer()
{
- if (!QWaylandCompositor::handle()->serverBufferIntegration())
+ if (!QWaylandCompositorPrivate::get(this)->serverBufferIntegration())
return;
- openglContext()->makeCurrent(this);
+ m_view.openglContext()->makeCurrent(&m_view);
- QtWayland::ServerBufferIntegration *sbi = QWaylandCompositor::handle()->serverBufferIntegration();
+ QtWayland::ServerBufferIntegration *sbi = QWaylandCompositorPrivate::get(this)->serverBufferIntegration();
if (!sbi) {
qWarning("Could not find a Server Buffer Integration");
return;
@@ -197,14 +211,15 @@ private slots:
}
}
protected:
- void resizeEvent(QResizeEvent *event)
+ void sizeAdjusted()
{
- QQuickView::resizeEvent(event);
- QWaylandCompositor::setOutputGeometry(QRect(0, 0, width(), height()));
+ defaultOutput()->setGeometry(QRect(QPoint(0, 0), m_view.size()));
}
- void surfaceCreated(QWaylandSurface *surface) {
- connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped()));
+ void onSurfaceCreated(QWaylandSurface *surface) {
+ QWaylandQuickItem *item = new QWaylandQuickItem();
+ item->setSurface(surface);
+ connect(surface, &QWaylandSurface::mappedChanged, this, &QmlCompositor::surfaceMapped);
}
void share_buffer_bind_resource(Resource *resource) Q_DECL_OVERRIDE
@@ -224,6 +239,8 @@ protected:
}
private:
+ QQuickView m_view;
+ QWaylandOutput *m_output;
QtWayland::ServerBuffer *m_server_buffer_32_bit;
ServerBufferItem *m_server_buffer_item_32_bit;
QtWayland::ServerBuffer *m_server_buffer_8_bit;
@@ -242,18 +259,8 @@ int main(int argc, char *argv[])
qmlRegisterType<ServerBufferItem>();
QmlCompositor compositor;
- compositor.setTitle(QLatin1String("QML Compositor"));
- compositor.setGeometry(0, 0, 1024, 768);
- compositor.show();
-
- compositor.rootContext()->setContextProperty("compositor", &compositor);
-
- QObject::connect(&compositor, SIGNAL(windowAdded(QVariant)), compositor.rootObject(), SLOT(windowAdded(QVariant)));
- QObject::connect(&compositor, SIGNAL(windowResized(QVariant)), compositor.rootObject(), SLOT(windowResized(QVariant)));
- QObject::connect(&compositor, SIGNAL(serverBufferItemCreated(QVariant)), compositor.rootObject(), SLOT(serverBufferItemCreated(QVariant)));
- app.exec();
- qDebug() << "ending" << glGetError();
+ return app.exec();
}
#include "main.moc"
diff --git a/examples/wayland/server-buffer/compositor/serverbufferitem.cpp b/examples/wayland/server-buffer/compositor/serverbufferitem.cpp
index 96ceed0a..4cf5f71f 100644
--- a/examples/wayland/server-buffer/compositor/serverbufferitem.cpp
+++ b/examples/wayland/server-buffer/compositor/serverbufferitem.cpp
@@ -45,7 +45,7 @@
#include <QtQuick/QSGSimpleTextureNode>
#include <QtQuick/QQuickWindow>
-#include <QtCompositor/private/qwlserverbufferintegration_p.h>
+#include <QtWaylandCompositor/private/qwlserverbufferintegration_p.h>
QT_BEGIN_NAMESPACE
diff --git a/examples/wayland/wayland.pro b/examples/wayland/wayland.pro
index be50cc78..91c68b89 100644
--- a/examples/wayland/wayland.pro
+++ b/examples/wayland/wayland.pro
@@ -1,15 +1,11 @@
TEMPLATE=subdirs
-#Only build compositor examples if we are building
-#the QtCompositor API
-contains(CONFIG, wayland-compositor) {
- SUBDIRS += qwindow-compositor
+SUBDIRS += qwindow-compositor
- qtHaveModule(quick) {
- SUBDIRS += qml-compositor
- }
-
- SUBDIRS += server-buffer
+qtHaveModule(quick) {
+ SUBDIRS += pure-qml
+ SUBDIRS += multi-output
+ SUBDIRS += custom-extension
}
-SUBDIRS += subsurface
+SUBDIRS += server-buffer
diff --git a/src/client/qwaylandabstractdecoration.cpp b/src/client/qwaylandabstractdecoration.cpp
index 54a990b2..3f9852b2 100644
--- a/src/client/qwaylandabstractdecoration.cpp
+++ b/src/client/qwaylandabstractdecoration.cpp
@@ -129,7 +129,7 @@ void QWaylandAbstractDecoration::setMouseButtons(Qt::MouseButtons mb)
void QWaylandAbstractDecoration::startResize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize resize, Qt::MouseButtons buttons)
{
Q_D(QWaylandAbstractDecoration);
- if (isLeftClicked(buttons)) {
+ if (isLeftClicked(buttons) && d->m_wayland_window->shellSurface()) {
d->m_wayland_window->shellSurface()->resize(inputDevice, resize);
inputDevice->removeMouseButtonFromState(Qt::LeftButton);
}
@@ -138,7 +138,7 @@ void QWaylandAbstractDecoration::startResize(QWaylandInputDevice *inputDevice, e
void QWaylandAbstractDecoration::startMove(QWaylandInputDevice *inputDevice, Qt::MouseButtons buttons)
{
Q_D(QWaylandAbstractDecoration);
- if (isLeftClicked(buttons)) {
+ if (isLeftClicked(buttons) && d->m_wayland_window->shellSurface()) {
d->m_wayland_window->shellSurface()->move(inputDevice);
inputDevice->removeMouseButtonFromState(Qt::LeftButton);
}
diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp
index 3276348e..42ab2293 100644
--- a/src/client/qwaylanddatadevice.cpp
+++ b/src/client/qwaylanddatadevice.cpp
@@ -3,41 +3,35 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandClient module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-**
-** 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."
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include "qwaylanddatadevice_p.h"
#include "qwaylanddatadevicemanager_p.h"
diff --git a/src/client/qwaylanddatadevice_p.h b/src/client/qwaylanddatadevice_p.h
index b87529e9..37fe00d4 100644
--- a/src/client/qwaylanddatadevice_p.h
+++ b/src/client/qwaylanddatadevice_p.h
@@ -3,41 +3,35 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandClient module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-**
-** 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."
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
+
#ifndef QWAYLANDDATADEVICE_H
#define QWAYLANDDATADEVICE_H
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index f5167dd2..65e91439 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -67,7 +67,6 @@ class QSocketNotifier;
class QPlatformScreen;
namespace QtWayland {
- class qt_output_extension;
class qt_shell;
class qt_sub_surface_extension;
class qt_surface_extension;
diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h
index 42848a1d..e978563a 100644
--- a/src/client/qwaylanddnd_p.h
+++ b/src/client/qwaylanddnd_p.h
@@ -75,7 +75,7 @@ protected:
void startDrag() Q_DECL_OVERRIDE;
void cancel() Q_DECL_OVERRIDE;
void move(const QPoint &globalPos) Q_DECL_OVERRIDE;
- void drop(const QPoint &globalpos) Q_DECL_OVERRIDE;
+ void drop(const QPoint &globalPos) Q_DECL_OVERRIDE;
void endDrag() Q_DECL_OVERRIDE;
diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp
index 6a729509..b02e9f66 100644
--- a/src/client/qwaylandinputcontext.cpp
+++ b/src/client/qwaylandinputcontext.cpp
@@ -3,41 +3,35 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandClient module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-**
-** 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."
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include "qwaylandinputcontext_p.h"
#include <QGuiApplication>
diff --git a/src/client/qwaylandinputcontext_p.h b/src/client/qwaylandinputcontext_p.h
index 679baa49..b106c100 100644
--- a/src/client/qwaylandinputcontext_p.h
+++ b/src/client/qwaylandinputcontext_p.h
@@ -3,41 +3,35 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandClient module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-**
-** 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."
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
+
#ifndef QWAYLANDINPUTCONTEXT_H
#define QWAYLANDINPUTCONTEXT_H
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index ed7b656d..5c06f66d 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -170,7 +170,10 @@ void QWaylandWindow::initWindow()
if (QScreen *s = window()->screen())
setOrientationMask(s->orientationUpdateMask());
setWindowFlags(window()->flags());
- setGeometry_helper(window()->geometry());
+ if (window()->geometry().isEmpty())
+ setGeometry_helper(QRect(QPoint(), QSize(500,500)));
+ else
+ setGeometry_helper(window()->geometry());
setMask(window()->mask());
setWindowStateInternal(window()->windowState());
handleContentOrientationChange(window()->contentOrientation());
@@ -389,8 +392,8 @@ void QWaylandWindow::setCanResize(bool canResize)
doResize();
QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
} else if (mResizeDirty) {
- QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
mResizeDirty = false;
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
}
}
}
diff --git a/src/compositor/compositor.pro b/src/compositor/compositor.pro
index cf6300c0..6a64cd70 100644
--- a/src/compositor/compositor.pro
+++ b/src/compositor/compositor.pro
@@ -1,8 +1,9 @@
-TARGET = QtCompositor
+TARGET = QtWaylandCompositor
QT = core gui-private
contains(QT_CONFIG, opengl):MODULE_DEFINES = QT_COMPOSITOR_WAYLAND_GL
+MODULE=waylandcompositor
MODULE_PLUGIN_TYPES = wayland-graphics-integration-server
load(qt_module)
@@ -10,6 +11,7 @@ CONFIG -= precompile_header
CONFIG += link_pkgconfig
DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT
+QMAKE_DOCS = $$PWD/doc/compositor.qdocconf
!contains(QT_CONFIG, no-pkg-config) {
PKGCONFIG_PRIVATE += wayland-server
@@ -25,6 +27,6 @@ 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)
+include ($$PWD/extensions/extensions.pri)
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index 903eef9e..70f3e3a1 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -2,30 +2,41 @@ INCLUDEPATH += compositor_api
HEADERS += \
compositor_api/qwaylandcompositor.h \
+ compositor_api/qwaylandcompositor_p.h \
compositor_api/qwaylandclient.h \
compositor_api/qwaylandsurface.h \
compositor_api/qwaylandsurface_p.h \
compositor_api/qwaylandinput.h \
+ compositor_api/qwaylandinput_p.h \
+ compositor_api/qwaylandkeyboard.h \
+ compositor_api/qwaylandkeyboard_p.h \
+ compositor_api/qwaylandpointer.h \
+ compositor_api/qwaylandpointer_p.h \
+ compositor_api/qwaylandtouch.h \
+ compositor_api/qwaylandtouch_p.h \
compositor_api/qwaylandinputpanel.h \
compositor_api/qwaylandoutput.h \
compositor_api/qwaylanddrag.h \
compositor_api/qwaylandbufferref.h \
- compositor_api/qwaylandsurfaceview.h \
- compositor_api/qwaylandglobalinterface.h \
- compositor_api/qwaylandsurfaceinterface.h
+ compositor_api/qwaylanddestroylistener.h \
+ compositor_api/qwaylanddestroylistener_p.h \
+ compositor_api/qwaylandview.h \
+ compositor_api/qwaylandview_p.h \
SOURCES += \
compositor_api/qwaylandcompositor.cpp \
compositor_api/qwaylandclient.cpp \
compositor_api/qwaylandsurface.cpp \
compositor_api/qwaylandinput.cpp \
+ compositor_api/qwaylandkeyboard.cpp \
+ compositor_api/qwaylandpointer.cpp \
+ compositor_api/qwaylandtouch.cpp \
compositor_api/qwaylandinputpanel.cpp \
compositor_api/qwaylandoutput.cpp \
compositor_api/qwaylanddrag.cpp \
compositor_api/qwaylandbufferref.cpp \
- compositor_api/qwaylandsurfaceview.cpp \
- compositor_api/qwaylandglobalinterface.cpp \
- compositor_api/qwaylandsurfaceinterface.cpp
+ compositor_api/qwaylanddestroylistener.cpp \
+ compositor_api/qwaylandview.cpp \
QT += core-private
@@ -34,16 +45,14 @@ qtHaveModule(quick) {
compositor_api/qwaylandquickcompositor.cpp \
compositor_api/qwaylandquicksurface.cpp \
compositor_api/qwaylandquickoutput.cpp \
- compositor_api/qwaylandsurfaceitem.cpp \
- compositor_api/qwaylandtexturebufferattacher.cpp
+ compositor_api/qwaylandquickitem.cpp
HEADERS += \
compositor_api/qwaylandquickcompositor.h \
compositor_api/qwaylandquicksurface.h \
compositor_api/qwaylandquickoutput.h \
- compositor_api/qwaylandsurfaceitem.h \
- compositor_api/qwaylandtexturebufferattacher_p.h
+ compositor_api/qwaylandquickitem.h \
+ compositor_api/qwaylandquickitem_p.h
-
- QT += qml quick
+ QT += qml qml-private quick quick-private
}
diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp
index 68e52317..d0fe7ca4 100644
--- a/src/compositor/compositor_api/qwaylandbufferref.cpp
+++ b/src/compositor/compositor_api/qwaylandbufferref.cpp
@@ -3,9 +3,9 @@
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -43,14 +46,33 @@ class QWaylandBufferRefPrivate
{
public:
QtWayland::SurfaceBuffer *buffer;
+
+ bool nullOrDestroyed() {
+ return !buffer || buffer->isDestroyed();
+ }
};
+/*!
+ * \class QWaylandBufferRef
+ * \inmodule QtWaylandCompositor
+ * \brief A class which holds a reference to a surface buffer
+ *
+ * This class can be used to reference a surface buffer. As long as a reference
+ * to the buffer exists, it is owned by the compositor and the client cannot modify it.
+ */
+
+/*!
+ * Constructs a null buffer ref.
+ */
QWaylandBufferRef::QWaylandBufferRef()
: d(new QWaylandBufferRefPrivate)
{
d->buffer = 0;
}
+/*!
+ * Constructs a reference to \a buffer.
+ */
QWaylandBufferRef::QWaylandBufferRef(QtWayland::SurfaceBuffer *buffer)
: d(new QWaylandBufferRefPrivate)
{
@@ -59,13 +81,20 @@ QWaylandBufferRef::QWaylandBufferRef(QtWayland::SurfaceBuffer *buffer)
buffer->ref();
}
+/*!
+ * Creates a new reference to the buffer referenced by \a ref.
+ */
QWaylandBufferRef::QWaylandBufferRef(const QWaylandBufferRef &ref)
: d(new QWaylandBufferRefPrivate)
{
- d->buffer = 0;
- *this = ref;
+ d->buffer = ref.d->buffer;
+ if (d->buffer)
+ d->buffer->ref();
}
+/*!
+ * Dereferences the buffer.
+ */
QWaylandBufferRef::~QWaylandBufferRef()
{
if (d->buffer)
@@ -73,6 +102,10 @@ QWaylandBufferRef::~QWaylandBufferRef()
delete d;
}
+/*!
+ * Assigns \a ref to this buffer. The previously referenced buffer is
+ * dereferenced and the new one gets a new reference.
+ */
QWaylandBufferRef &QWaylandBufferRef::operator=(const QWaylandBufferRef &ref)
{
if (d->buffer)
@@ -85,61 +118,137 @@ QWaylandBufferRef &QWaylandBufferRef::operator=(const QWaylandBufferRef &ref)
return *this;
}
-QWaylandBufferRef::operator bool() const
+/*!
+ * Returns true if this QWaylandBufferRef references the same buffer as \a ref.
+ * Otherwise returns false.
+ */
+bool QWaylandBufferRef::operator==(const QWaylandBufferRef &ref)
{
- return d->buffer && d->buffer->waylandBufferHandle();
+ return d->buffer == ref.d->buffer;
}
-bool QWaylandBufferRef::isShm() const
+/*!
+ * Returns false if this QWaylandBufferRef references the same buffer as \a ref.
+ * Otherwise returns true.
+ */
+bool QWaylandBufferRef::operator!=(const QWaylandBufferRef &ref)
{
- return d->buffer->isShmBuffer();
+ return d->buffer != ref.d->buffer;
}
-QImage QWaylandBufferRef::image() const
+/*!
+ * Returns true if this QWaylandBufferRef does not reference a buffer.
+ * Otherwise returns false.
+ *
+ * \sa hasBuffer()
+ */
+bool QWaylandBufferRef::isNull() const
{
- if (d->buffer->isShmBuffer())
- return d->buffer->image();
- return QImage();
+ return !d->buffer;
}
-void *QWaylandBufferRef::waylandBuffer() const
+/*!
+ * Returns true if this QWaylandBufferRef references a buffer. Otherwise returns false.
+ *
+ * \sa isNull()
+ */
+bool QWaylandBufferRef::hasBuffer() const
{
- return d->buffer->waylandBufferHandle();
+ return d->buffer;
}
-#ifdef QT_COMPOSITOR_WAYLAND_GL
+/*!
+ * Returns true if this QWaylandBufferRef references a buffer that
+ * has been destroyed. Otherwise returns false.
+ */
+bool QWaylandBufferRef::isDestroyed() const
+{
+ return d->buffer && d->buffer->isDestroyed();
+}
-GLenum QWaylandBufferRef::textureTarget() const
+/*!
+ * Returns the Wayland resource for the buffer.
+ */
+struct ::wl_resource *QWaylandBufferRef::wl_buffer() const
{
- Q_ASSERT(d->buffer->textureCreated());
- return d->buffer->textureTarget();
+ return d->buffer ? d->buffer->waylandBufferHandle() : Q_NULLPTR;
}
-GLuint QWaylandBufferRef::createTexture()
+/*!
+ * Returns the size of the buffer.
+ * If the buffer referenced is null, an invalid QSize() is returned.
+ */
+QSize QWaylandBufferRef::size() const
{
- if (!d->buffer->isShmBuffer() && !d->buffer->textureCreated()) {
- d->buffer->createTexture();
- }
- return d->buffer->texture();
+ if (d->nullOrDestroyed())
+ return QSize();
+
+ return d->buffer->size();
}
-void QWaylandBufferRef::updateTexture()
+/*!
+ * Returns the origin of the buffer.
+ * If the buffer referenced is null, QWaylandSurface::OriginBottomLeft
+ * is returned.
+ */
+QWaylandSurface::Origin QWaylandBufferRef::origin() const
{
- if (!d->buffer->isShmBuffer() && d->buffer->textureCreated())
- d->buffer->updateTexture();
+ if (d->buffer)
+ return d->buffer->origin();
+
+ return QWaylandSurface::OriginBottomLeft;
}
-void QWaylandBufferRef::destroyTexture()
+/*!
+ * Returns true if the buffer is a shared memory buffer. Otherwise returns false.
+ */
+bool QWaylandBufferRef::isShm() const
{
- if (!d->buffer->isShmBuffer() && d->buffer->textureCreated()) {
- d->buffer->destroyTexture();
- }
+ if (d->nullOrDestroyed())
+ return false;
+
+ return d->buffer->isShm();
}
-void *QWaylandBufferRef::nativeBuffer() const
+/*!
+ * Returns an image with the contents of the buffer.
+ */
+QImage QWaylandBufferRef::image() const
{
- return d->buffer->handle();
+ if (d->nullOrDestroyed())
+ return QImage();
+
+ return d->buffer->image();
+}
+
+/*!
+ * Binds the buffer to the current OpenGL texture. This may
+ * perform a copy of the buffer data, depending on the platform
+ * and the type of the buffer.
+ */
+void QWaylandBufferRef::bindToTexture() const
+{
+ if (d->nullOrDestroyed())
+ return;
+
+ return d->buffer->bindToTexture();
+
+}
+
+int QWaylandBufferRef::textureTarget() const
+{
+ if (d->nullOrDestroyed())
+ return 0x0DE1; // GL_TEXTURE_2D
+
+ return d->buffer->textureTarget();
+}
+
+void QWaylandBufferRef::updateTexture() const
+{
+ if (d->nullOrDestroyed() || d->buffer->isShm())
+ return;
+
+ d->buffer->updateTexture();
}
-#endif
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandbufferref.h b/src/compositor/compositor_api/qwaylandbufferref.h
index 618a3662..5683a0b3 100644
--- a/src/compositor/compositor_api/qwaylandbufferref.h
+++ b/src/compositor/compositor_api/qwaylandbufferref.h
@@ -3,9 +3,9 @@
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -40,7 +43,10 @@
#include <QtGui/qopengl.h>
#endif
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/QWaylandSurface>
+#include <QtWaylandCompositor/qwaylandexport.h>
+
+struct wl_resource;
QT_BEGIN_NAMESPACE
@@ -58,24 +64,23 @@ public:
~QWaylandBufferRef();
QWaylandBufferRef &operator=(const QWaylandBufferRef &ref);
- operator bool() const;
- bool isShm() const;
+ bool isNull() const;
+ bool hasBuffer() const;
+ bool isDestroyed() const;
+ bool operator==(const QWaylandBufferRef &ref);
+ bool operator!=(const QWaylandBufferRef &ref);
+
+ struct wl_resource *wl_buffer() const;
+
+ QSize size() const;
+ QWaylandSurface::Origin origin() const;
+ bool isShm() const;
QImage image() const;
- void *waylandBuffer() const;
-#ifdef QT_COMPOSITOR_WAYLAND_GL
- /**
- * There must be a GL context bound when calling this function.
- * The texture will be automatically destroyed when the last QWaylandBufferRef
- * referring to the same underlying buffer will be destroyed or reset.
- */
- GLuint createTexture();
- GLenum textureTarget() const;
- void updateTexture();
- void destroyTexture();
- void *nativeBuffer() const;
-#endif
+ void bindToTexture() const;
+ int textureTarget() const;
+ void updateTexture() const;
private:
class QWaylandBufferRefPrivate *const d;
diff --git a/src/compositor/compositor_api/qwaylandclient.cpp b/src/compositor/compositor_api/qwaylandclient.cpp
index 216abc4f..65f1d634 100644
--- a/src/compositor/compositor_api/qwaylandclient.cpp
+++ b/src/compositor/compositor_api/qwaylandclient.cpp
@@ -3,46 +3,43 @@
** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <private/qobject_p.h>
-
-#include "wayland_wrapper/qwlcompositor_p.h"
-#include "qwaylandcompositor.h"
#include "qwaylandclient.h"
+#include <QtCore/private/qobject_p.h>
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
+
#include <wayland-server.h>
#include <wayland-util.h>
@@ -52,8 +49,9 @@ QT_BEGIN_NAMESPACE
class QWaylandClientPrivate : public QObjectPrivate
{
public:
- QWaylandClientPrivate(wl_client *_client)
- : client(_client)
+ QWaylandClientPrivate(QWaylandCompositor *compositor, wl_client *_client)
+ : compositor(compositor)
+ , client(_client)
{
// Save client credentials
wl_client_get_credentials(client, &pid, &uid, &gid);
@@ -69,10 +67,10 @@ public:
QWaylandClient *client = reinterpret_cast<Listener *>(listener)->parent;
Q_ASSERT(client != 0);
- QtWayland::Compositor::instance()->m_clients.removeOne(client);
delete client;
}
+ QWaylandCompositor *compositor;
wl_client *client;
uid_t uid;
@@ -86,8 +84,29 @@ public:
Listener listener;
};
-QWaylandClient::QWaylandClient(wl_client *client)
- : QObject(*new QWaylandClientPrivate(client))
+/*!
+ * \qmltype WaylandClient
+ * \inqmlmodule QtWayland.Compositor
+ * \brief A client connecting to the WaylandCompositor.
+ *
+ * This type represents a client connecting to the compositor using the Wayland protocol.
+ * It corresponds to the Wayland interface wl_client.
+ */
+
+/*!
+ * \class QWaylandClient
+ * \inmodule QtWaylandCompositor
+ * \brief A client connecting to the QWaylandCompositor.
+ *
+ * This class corresponds to a client connecting to the compositor using the Wayland protocol.
+ * It corresponds to the Wayland interface wl_client.
+ */
+
+/*!
+ * Constructs a QWaylandClient for the \a compositor and the Wayland \a client.
+ */
+QWaylandClient::QWaylandClient(QWaylandCompositor *compositor, wl_client *client)
+ : QObject(*new QWaylandClientPrivate(compositor, client))
{
Q_D(QWaylandClient);
@@ -95,17 +114,29 @@ QWaylandClient::QWaylandClient(wl_client *client)
d->listener.parent = this;
d->listener.listener.notify = QWaylandClientPrivate::client_destroy_callback;
wl_client_add_destroy_listener(client, &d->listener.listener);
+
+ QWaylandCompositorPrivate::get(compositor)->addClient(this);
}
+/*!
+ * Destroys the QWaylandClient.
+ */
QWaylandClient::~QWaylandClient()
{
Q_D(QWaylandClient);
// Remove listener from signal
wl_list_remove(&d->listener.listener.link);
+
+ QWaylandCompositorPrivate::get(d->compositor)->removeClient(this);
}
-QWaylandClient *QWaylandClient::fromWlClient(wl_client *wlClient)
+/*!
+ * Returns the QWaylandClient corresponding to the Wayland client \a wl_client and \a compositor.
+ * If a QWaylandClient has not already been created for \a client, it is
+ * created and returned.
+ */
+QWaylandClient *QWaylandClient::fromWlClient(QWaylandCompositor *compositor, wl_client *wlClient)
{
if (!wlClient)
return 0;
@@ -124,13 +155,15 @@ QWaylandClient *QWaylandClient::fromWlClient(wl_client *wlClient)
// bind several times resulting in multiple QWaylandClient
// instances for the same wl_client therefore we create it from
// here on demand
- client = new QWaylandClient(wlClient);
- QtWayland::Compositor::instance()->m_clients.append(client);
+ client = new QWaylandClient(compositor, wlClient);
}
return client;
}
+/*!
+ * Returns the Wayland client of this QWaylandClient.
+ */
wl_client *QWaylandClient::client() const
{
Q_D(const QWaylandClient);
@@ -138,6 +171,17 @@ wl_client *QWaylandClient::client() const
return d->client;
}
+/*!
+ * \qmlproperty int QtWaylandCompositor::WaylandClient::userId
+ *
+ * This property holds the user id of this WaylandClient.
+ */
+
+/*!
+ * \property QWaylandClient::userId
+ *
+ * This property holds the user id of this QWaylandClient.
+ */
qint64 QWaylandClient::userId() const
{
Q_D(const QWaylandClient);
@@ -145,6 +189,17 @@ qint64 QWaylandClient::userId() const
return d->uid;
}
+/*!
+ * \qmlproperty int QtWaylandCompositor::WaylandClient::groupId
+ *
+ * This property holds the group id of this WaylandClient.
+ */
+
+/*!
+ * \property int QWaylandClient::groupId
+ *
+ * This property holds the group id of this QWaylandClient.
+ */
qint64 QWaylandClient::groupId() const
{
Q_D(const QWaylandClient);
@@ -152,6 +207,17 @@ qint64 QWaylandClient::groupId() const
return d->gid;
}
+/*!
+ * \qmlproperty int QtWaylandCompositor::WaylandClient::processId
+ *
+ * This property holds the process id of this WaylandClient.
+ */
+
+/*!
+ * \property QWaylandClient::processId
+ *
+ * This property holds the process id of this QWaylandClient.
+ */
qint64 QWaylandClient::processId() const
{
Q_D(const QWaylandClient);
@@ -159,16 +225,35 @@ qint64 QWaylandClient::processId() const
return d->pid;
}
-void QWaylandClient::kill(int sig)
+/*!
+ * \qmlmethod void QtWaylandCompositor::WaylandClient::kill(signal)
+ *
+ * Kills the client with the specified \a signal.
+ */
+
+/*!
+ * Kills the client with the specified \a signal.
+ */
+void QWaylandClient::kill(int signal)
{
Q_D(QWaylandClient);
- ::kill(d->pid, sig);
+ ::kill(d->pid, signal);
}
+/*!
+ * \qmlmethod void QtWaylandCompositor::WaylandClient::close()
+ *
+ * Closes the client
+ */
+
+/*!
+ * Closes the client.
+ */
void QWaylandClient::close()
{
- QtWayland::Compositor::instance()->waylandCompositor()->destroyClient(this);
+ Q_D(QWaylandClient);
+ d->compositor->destroyClient(this);
}
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandclient.h b/src/compositor/compositor_api/qwaylandclient.h
index 9199406b..800013d3 100644
--- a/src/compositor/compositor_api/qwaylandclient.h
+++ b/src/compositor/compositor_api/qwaylandclient.h
@@ -3,36 +3,32 @@
** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -41,7 +37,7 @@
#ifndef QWAYLANDCLIENT_H
#define QWAYLANDCLIENT_H
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandexport.h>
#include <QObject>
@@ -52,6 +48,7 @@ struct wl_client;
QT_BEGIN_NAMESPACE
class QWaylandClientPrivate;
+class QWaylandCompositor;
class Q_COMPOSITOR_EXPORT QWaylandClient : public QObject
{
@@ -64,7 +61,7 @@ class Q_COMPOSITOR_EXPORT QWaylandClient : public QObject
public:
~QWaylandClient();
- static QWaylandClient *fromWlClient(wl_client *wlClient);
+ static QWaylandClient *fromWlClient(QWaylandCompositor *compositor, wl_client *wlClient);
wl_client *client() const;
@@ -73,13 +70,13 @@ public:
qint64 processId() const;
- Q_INVOKABLE void kill(int sig = SIGTERM);
+ Q_INVOKABLE void kill(int signal = SIGTERM);
public Q_SLOTS:
void close();
private:
- explicit QWaylandClient(wl_client *client);
+ explicit QWaylandClient(QWaylandCompositor *compositor, wl_client *client);
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 04d1c4ae..a431cdde 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -4,367 +4,801 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandcompositor.h"
+#include "qwaylandcompositor_p.h"
+
+#include <QtWaylandCompositor/qwaylandclient.h>
+#include <QtWaylandCompositor/qwaylandinput.h>
+#include <QtWaylandCompositor/qwaylandoutput.h>
+#include <QtWaylandCompositor/qwaylandview.h>
+#include <QtWaylandCompositor/qwaylandclient.h>
+#include <QtWaylandCompositor/qwaylandkeyboard.h>
+#include <QtWaylandCompositor/qwaylandpointer.h>
+#include <QtWaylandCompositor/qwaylandtouch.h>
-#include "qwaylandclient.h"
-#include "qwaylandinput.h"
-#include "qwaylandoutput.h"
-#include "qwaylandglobalinterface.h"
-#include "qwaylandsurfaceview.h"
+#include <QtWaylandCompositor/private/qwaylandkeyboard_p.h>
+#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
-#include "wayland_wrapper/qwlcompositor_p.h"
#include "wayland_wrapper/qwldatadevice_p.h"
-#include "wayland_wrapper/qwlsurface_p.h"
-#include "wayland_wrapper/qwlinputdevice_p.h"
-#include "wayland_wrapper/qwlinputpanel_p.h"
-#include "wayland_wrapper/qwlshellsurface_p.h"
+#include "wayland_wrapper/qwldatadevicemanager_p.h"
+
+#include "hardware_integration/qwlclientbufferintegration_p.h"
+#include "hardware_integration/qwlclientbufferintegrationfactory_p.h"
+#include "hardware_integration/qwlserverbufferintegration_p.h"
+#include "hardware_integration/qwlserverbufferintegrationfactory_p.h"
+#include "hardware_integration/qwlhwintegration_p.h"
+
+#include "extensions/qwaylandwindowmanagerextension.h"
+
+#include "qwaylandxkb.h"
+#include "qwaylandshmformathelper.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
+#include <QtCore/QSocketNotifier>
#include <QtGui/QDesktopServices>
#include <QtGui/QScreen>
-#include <QDebug>
+#include <QtGui/qpa/qwindowsysteminterface_p.h>
+#include <QtGui/qpa/qplatformnativeinterface.h>
+#include <QtGui/private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
-QWaylandCompositor::QWaylandCompositor(const char *socketName, ExtensionFlags extensions)
- : m_compositor(new QtWayland::Compositor(this, extensions))
+namespace QtWayland {
+
+class WindowSystemEventHandler : public QWindowSystemEventHandler
{
- m_compositor->m_socket_name = socketName;
- m_compositor->init();
-}
+public:
+ WindowSystemEventHandler(QWaylandCompositor *c) : compositor(c) {}
+ bool sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) Q_DECL_OVERRIDE
+ {
+ if (e->type == QWindowSystemInterfacePrivate::Key) {
+ QWindowSystemInterfacePrivate::KeyEvent *ke = static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e);
+ QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(compositor->defaultInputDevice()->keyboard());
+
+ uint32_t code = ke->nativeScanCode;
+ bool isDown = ke->keyType == QEvent::KeyPress;
+
+#ifndef QT_NO_WAYLAND_XKB
+ QString text;
+ Qt::KeyboardModifiers modifiers = QWaylandXkb::modifiers(keyb->xkbState());
+
+ const xkb_keysym_t sym = xkb_state_key_get_one_sym(keyb->xkbState(), code);
+ uint utf32 = xkb_keysym_to_utf32(sym);
+ if (utf32)
+ text = QString::fromUcs4(&utf32, 1);
+ int qtkey = QWaylandXkb::keysymToQtKey(sym, modifiers, text);
+
+ ke->key = qtkey;
+ ke->modifiers = modifiers;
+ ke->nativeVirtualKey = sym;
+ ke->nativeModifiers = keyb->xkbModsMask();
+ ke->unicode = text;
+#endif
+ if (!ke->repeat)
+ keyb->keyEvent(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
-QWaylandCompositor::QWaylandCompositor(const char *socketName, QtWayland::Compositor *dptr)
- : m_compositor(dptr)
+ QWindowSystemEventHandler::sendEvent(e);
+
+ if (!ke->repeat) {
+ keyb->updateKeymap();
+ keyb->updateModifierState(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
+ }
+ } else {
+ QWindowSystemEventHandler::sendEvent(e);
+ }
+ return true;
+ }
+
+ QWaylandCompositor *compositor;
+};
+
+} // namespace
+
+QWaylandCompositorPrivate::QWaylandCompositorPrivate(QWaylandCompositor *compositor)
+ : display(0)
+#if defined (QT_COMPOSITOR_WAYLAND_GL)
+ , use_hw_integration_extension(true)
+ , client_buffer_integration(0)
+ , server_buffer_integration(0)
+#endif
+ , retainSelection(false)
+ , initialized(false)
{
- m_compositor->m_socket_name = socketName;
- m_compositor->init();
+ display = static_cast<wl_display*>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("server_wl_display"));
+ if (!display)
+ display = wl_display_create();
+ eventHandler.reset(new QtWayland::WindowSystemEventHandler(compositor));
+ timer.start();
+
+ QWindowSystemInterfacePrivate::installWindowSystemEventHandler(eventHandler.data());
}
-QWaylandCompositor::~QWaylandCompositor()
+void QWaylandCompositorPrivate::init()
{
- qDeleteAll(m_compositor->m_globals);
- delete m_compositor;
+ Q_Q(QWaylandCompositor);
+ QStringList arguments = QCoreApplication::instance()->arguments();
+
+ int socketArg = arguments.indexOf(QLatin1String("--wayland-socket-name"));
+ if (socketArg != -1 && socketArg + 1 < arguments.size())
+ socket_name = arguments.at(socketArg + 1).toLocal8Bit();
+
+ wl_compositor::init(display, 3);
+
+ data_device_manager = new QtWayland::DataDeviceManager(q);
+
+ wl_display_init_shm(display);
+ QVector<wl_shm_format> formats = QWaylandShmFormatHelper::supportedWaylandFormats();
+ foreach (wl_shm_format format, formats)
+ wl_display_add_shm_format(display, format);
+
+ const char *socketName = 0;
+ if (socket_name.size())
+ socketName = socket_name.constData();
+ if (wl_display_add_socket(display, socketName)) {
+ qFatal("Fatal: Failed to open server socket\n");
+ }
+
+ loop = wl_display_get_event_loop(display);
+
+ int fd = wl_event_loop_get_fd(loop);
+
+ QSocketNotifier *sockNot = new QSocketNotifier(fd, QSocketNotifier::Read, q);
+ QObject::connect(sockNot, SIGNAL(activated(int)), q, SLOT(processWaylandEvents()));
+
+ QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+ QObject::connect(dispatcher, SIGNAL(aboutToBlock()), q, SLOT(processWaylandEvents()));
+
+ initializeHardwareIntegration();
+ initializeDefaultInputDevice();
+
+ initialized = true;
+
+ Q_FOREACH (QPointer<QObject> object, polish_objects) {
+ if (object) {
+ QEvent polishEvent(QEvent::Polish);
+ QCoreApplication::sendEvent(object.data(), &polishEvent);
+ }
+ }
}
-void QWaylandCompositor::addGlobalInterface(QWaylandGlobalInterface *interface)
+QWaylandCompositorPrivate::~QWaylandCompositorPrivate()
{
- wl_global_create(m_compositor->wl_display(), interface->interface(), interface->version(), interface, QtWayland::Compositor::bindGlobal);
- m_compositor->m_globals << interface;
+ qDeleteAll(clients);
+
+ qDeleteAll(outputs);
+
+ delete data_device_manager;
+
+ wl_display_destroy(display);
}
-void QWaylandCompositor::addDefaultShell()
+void QWaylandCompositorPrivate::destroySurface(QWaylandSurface *surface)
{
- addGlobalInterface(new QtWayland::Shell);
+ Q_Q(QWaylandCompositor);
+ q->surfaceAboutToBeDestroyed(surface);
+
+ delete surface;
}
-struct wl_display *QWaylandCompositor::waylandDisplay() const
+void QWaylandCompositorPrivate::unregisterSurface(QWaylandSurface *surface)
{
- return m_compositor->wl_display();
+ if (!all_surfaces.removeOne(surface))
+ qWarning("%s Unexpected state. Cant find registered surface\n", Q_FUNC_INFO);
}
-void QWaylandCompositor::sendFrameCallbacks(QList<QWaylandSurface *> visibleSurfaces)
+void QWaylandCompositorPrivate::feedRetainedSelectionData(QMimeData *data)
{
- m_compositor->sendFrameCallbacks(visibleSurfaces);
+ Q_Q(QWaylandCompositor);
+ if (retainSelection)
+ q->retainedSelectionReceived(data);
}
-void QWaylandCompositor::frameStarted()
+void QWaylandCompositorPrivate::addPolishObject(QObject *object)
{
- foreach (QtWayland::Surface *surf, m_compositor->surfaces())
- surf->frameStarted();
+ if (initialized) {
+ QCoreApplication::postEvent(object, new QEvent(QEvent::Polish));
+ } else {
+ polish_objects.append(object);
+ }
}
-void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface)
+/*!
+ \qmlsignal void QtWaylandCompositor::WaylandCompositor::createSurface(object client, int id, int version)
+
+ This signal is emitted when a client has created a surface.
+ The slot connecting to this signal may create and initialize
+ a WaylandSurface instance in the scope of the slot.
+ Otherwise a default surface is created.
+*/
+
+/*!
+ \fn void QWaylandCompositor::createSurface(QWaylandClient *client, uint id, int version)
+
+ This signal is emitted when a client has created a surface.
+ The slot connecting to this signal may create and initialize
+ a QWaylandSurface instance in the scope of the slot.
+ Otherwise a default surface is created.
+
+ Connections to this signal must be of Qt::DirectConnection connection type.
+*/
+
+/*
+ \qmlsignal void surfaceCreated(QWaylandSurface *surface)
+
+ This signal is emitted when a new WaylandSurface instance has been created.
+*/
+
+/*
+ \fn void surfaceCreated(QWaylandSurface *surface)
+
+ This signal is emitted when a new QWaylandSurface instance has been created.
+*/
+
+
+void QWaylandCompositorPrivate::compositor_create_surface(Resource *resource, uint32_t id)
{
- destroyClient(surface->client());
+ Q_Q(QWaylandCompositor);
+ QWaylandClient *client = QWaylandClient::fromWlClient(q, resource->client());
+ emit q->createSurface(client, id, resource->version());
+#ifndef QT_NO_DEBUG
+ Q_ASSERT_X(!QWaylandSurfacePrivate::hasUninitializedSurface(), "QWaylandCompositor", QStringLiteral("Found uninitialized QWaylandSurface after emitting QWaylandCompositor::createSurface for id %1. All surfaces has to be initialized immediately after creation. See QWaylandSurface::initialize.").arg(id).toLocal8Bit().constData());
+#endif
+ struct wl_resource *surfResource = wl_client_get_object(client->client(), id);
+
+ QWaylandSurface *surface;
+ if (surfResource) {
+ surface = QWaylandSurface::fromResource(surfResource);
+ } else {
+ surface = createDefaultSurface();
+ surface->initialize(q, client, id, resource->version());
+ }
+ Q_ASSERT(surface);
+ all_surfaces.append(surface);
+ emit q->surfaceCreated(surface);
}
-void QWaylandCompositor::destroyClient(QWaylandClient *client)
+void QWaylandCompositorPrivate::compositor_create_region(Resource *resource, uint32_t id)
{
- m_compositor->destroyClient(client);
+ new QtWayland::Region(resource->client(), id);
}
-QList<QWaylandSurface *> QWaylandCompositor::surfacesForClient(QWaylandClient* client) const
+/*!
+ \internal
+ Used to create a fallback QWaylandSurface when no surface was
+ created by emitting the QWaylandCompositor::createSurface signal.
+*/
+QWaylandSurface *QWaylandCompositorPrivate::createDefaultSurface()
{
- QList<QtWayland::Surface *> surfaces = m_compositor->surfaces();
+ return new QWaylandSurface();
+}
- QList<QWaylandSurface *> result;
- for (int i = 0; i < surfaces.count(); ++i) {
- if (surfaces.at(i)->waylandSurface()->client() == client) {
- result.append(surfaces.at(i)->waylandSurface());
- }
- }
+void QWaylandCompositorPrivate::initializeHardwareIntegration()
+{
+#ifdef QT_COMPOSITOR_WAYLAND_GL
+ Q_Q(QWaylandCompositor);
+ if (use_hw_integration_extension)
+ hw_integration.reset(new QtWayland::HardwareIntegration(q));
+
+ loadClientBufferIntegration();
+ loadServerBufferIntegration();
- return result;
+ if (client_buffer_integration)
+ client_buffer_integration->initializeHardware(display);
+ if (server_buffer_integration)
+ server_buffer_integration->initializeHardware(q);
+#endif
}
-QList<QWaylandSurface *> QWaylandCompositor::surfaces() const
+void QWaylandCompositorPrivate::initializeDefaultInputDevice()
{
- QList<QtWayland::Surface *> surfaces = m_compositor->surfaces();
- QList<QWaylandSurface *> surfs;
- surfs.reserve(surfaces.count());
- foreach (QtWayland::Surface *s, surfaces)
- surfs << s->waylandSurface();
- return surfs;
+ Q_Q(QWaylandCompositor);
+ inputDevices.append(q->createInputDevice());
+ q->defaultInputDeviceChanged();
}
-QList<QWaylandOutput *> QWaylandCompositor::outputs() const
+void QWaylandCompositorPrivate::loadClientBufferIntegration()
{
- return m_compositor->outputs();
+#ifdef QT_COMPOSITOR_WAYLAND_GL
+ Q_Q(QWaylandCompositor);
+ QStringList keys = QtWayland::ClientBufferIntegrationFactory::keys();
+ QString targetKey;
+ QByteArray clientBufferIntegration = qgetenv("QT_WAYLAND_HARDWARE_INTEGRATION");
+ if (clientBufferIntegration.isEmpty())
+ clientBufferIntegration = qgetenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION");
+ if (keys.contains(QString::fromLocal8Bit(clientBufferIntegration.constData()))) {
+ targetKey = QString::fromLocal8Bit(clientBufferIntegration.constData());
+ } else if (keys.contains(QString::fromLatin1("wayland-egl"))) {
+ targetKey = QString::fromLatin1("wayland-egl");
+ } else if (!keys.isEmpty()) {
+ targetKey = keys.first();
+ }
+
+ if (!targetKey.isEmpty()) {
+ client_buffer_integration.reset(QtWayland::ClientBufferIntegrationFactory::create(targetKey, QStringList()));
+ if (client_buffer_integration) {
+ client_buffer_integration->setCompositor(q);
+ if (hw_integration)
+ hw_integration->setClientBufferIntegration(targetKey);
+ }
+ }
+ //BUG: if there is no client buffer integration, bad things will happen when opengl is used
+#endif
}
-QWaylandOutput *QWaylandCompositor::output(QWindow *window)
+void QWaylandCompositorPrivate::loadServerBufferIntegration()
{
- return m_compositor->output(window);
+#ifdef QT_COMPOSITOR_WAYLAND_GL
+ QStringList keys = QtWayland::ServerBufferIntegrationFactory::keys();
+ QString targetKey;
+ QByteArray serverBufferIntegration = qgetenv("QT_WAYLAND_SERVER_BUFFER_INTEGRATION");
+ if (keys.contains(QString::fromLocal8Bit(serverBufferIntegration.constData()))) {
+ targetKey = QString::fromLocal8Bit(serverBufferIntegration.constData());
+ }
+ if (!targetKey.isEmpty()) {
+ server_buffer_integration.reset(QtWayland::ServerBufferIntegrationFactory::create(targetKey, QStringList()));
+ if (hw_integration)
+ hw_integration->setServerBufferIntegration(targetKey);
+ }
+#endif
}
-QWaylandOutput *QWaylandCompositor::primaryOutput() const
+/*!
+ \qmltype WaylandCompositor
+ \inqmlmodule QtWayland.Compositor
+ \brief Type managing the Wayland display server.
+
+ The WaylandCompositor manages the connections to the clients, as well as the different
+ \l{WaylandOutput}{outputs} and \l{WaylandInput}{input devices}.
+
+ Normally, a compositor application will have a single WaylandCompositor
+ instance, which can have several outputs as children. When a client
+ requests the compositor to create a surface, the request is handled by
+ the onCreateSurface handler.
+
+ Extensions that are supported by the compositor should be instantiated and added to the
+ extensions property.
+*/
+
+
+/*!
+ \class QWaylandCompositor
+ \inmodule QtWaylandCompositor
+ \brief Class managing the Wayland display server.
+
+ The QWaylandCompositor manages the connections to the clients, as well as the different \l{QWaylandOutput}{outputs}
+ and \l{QWaylandInput}{input devices}.
+
+ Normally, a compositor application will have a single WaylandCompositor
+ instance, which can have several outputs as children.
+*/
+
+/*!
+ * Constructs a QWaylandCompositor with the given \a parent.
+ */
+QWaylandCompositor::QWaylandCompositor(QObject *parent)
+ : QWaylandObject(*new QWaylandCompositorPrivate(this), parent)
{
- return m_compositor->primaryOutput();
}
-void QWaylandCompositor::setPrimaryOutput(QWaylandOutput *output)
+/*!
+ * \internal
+ * Constructs a QWaylandCompositor with the private object \a dptr and \a parent.
+ */
+QWaylandCompositor::QWaylandCompositor(QWaylandCompositorPrivate &dptr, QObject *parent)
+ : QWaylandObject(dptr, parent)
{
- m_compositor->setPrimaryOutput(output);
}
-void QWaylandCompositor::cleanupGraphicsResources()
+/*!
+ * Destroys the QWaylandCompositor
+ */
+QWaylandCompositor::~QWaylandCompositor()
{
- m_compositor->cleanupGraphicsResources();
}
-void QWaylandCompositor::surfaceAboutToBeDestroyed(QWaylandSurface *surface)
+/*!
+ * Initializes the QWaylandCompositor.
+ * If you override this function in your subclass, be sure to call the base class implementation.
+ */
+void QWaylandCompositor::create()
{
- Q_UNUSED(surface);
+ Q_D(QWaylandCompositor);
+ d->init();
}
-QWaylandSurfaceView *QWaylandCompositor::pickView(const QPointF &globalPosition) const
+/*!
+ * Returns true if the QWaylandCompositor has been initialized. Otherwise returns false.
+ */
+bool QWaylandCompositor::isCreated() const
{
- Q_FOREACH (QWaylandOutput *output, outputs()) {
- // Skip coordinates not in output
- if (!QRectF(output->geometry()).contains(globalPosition))
- continue;
+ Q_D(const QWaylandCompositor);
+ return d->initialized;
+}
- Q_FOREACH (QWaylandSurface *surface, output->surfaces()) {
- Q_FOREACH (QWaylandSurfaceView *view, surface->views()) {
- if (QRectF(view->pos(), surface->size()).contains(globalPosition))
- return view;
- }
- }
- }
+/*!
+ * \qmlproperty string QtWaylandCompositor::WaylandCompositor::socketName
+ *
+ * This property holds the socket name used by WaylandCompositor to communicate with
+ * clients. It must be set before the component is completed.
+ *
+ * If the socketName is empty (the default), the contents of the environment
+ * variable WAYLAND_DISPLAY is used instead. If this is not set, the
+ * default "wayland-0" is used.
+ */
- return Q_NULLPTR;
+/*!
+ * \property QWaylandCompositor::socketName
+ *
+ * This property holds the socket name used by QWaylandCompositor to communicate with
+ * clients. This must be set before the QWaylandCompositor is \l{create()}{created}.
+ *
+ * If the socketName is empty (the default), the contents of the environment
+ * variable WAYLAND_DISPLAY is used instead. If this is not set, the
+ * default "wayland-0" is used.
+ */
+void QWaylandCompositor::setSocketName(const QByteArray &name)
+{
+ Q_D(QWaylandCompositor);
+ if (d->initialized) {
+ qWarning("%s: Changing socket name after initializing the compositor is not supported.\n", Q_FUNC_INFO);
+ return;
+ }
+ d->socket_name = name;
}
-QPointF QWaylandCompositor::mapToView(QWaylandSurfaceView *surface, const QPointF &globalPosition) const
+QByteArray QWaylandCompositor::socketName() const
{
- return globalPosition - surface->pos();
+ Q_D(const QWaylandCompositor);
+ return d->socket_name;
}
/*!
- Override this to handle QDesktopServices::openUrl() requests from the clients.
-
- The default implementation simply forwards the request to QDesktopServices::openUrl().
-*/
-bool QWaylandCompositor::openUrl(QWaylandClient *client, const QUrl &url)
+ * \internal
+ */
+struct wl_display *QWaylandCompositor::display() const
{
- Q_UNUSED(client);
- return QDesktopServices::openUrl(url);
+ Q_D(const QWaylandCompositor);
+ return d->display;
}
-QtWayland::Compositor * QWaylandCompositor::handle() const
+/*!
+ * \internal
+ */
+uint32_t QWaylandCompositor::nextSerial()
{
- return m_compositor;
+ Q_D(QWaylandCompositor);
+ return wl_display_next_serial(d->display);
}
-void QWaylandCompositor::setRetainedSelectionEnabled(bool enabled)
+/*!
+ * \internal
+ */
+QList<QWaylandClient *>QWaylandCompositor::clients() const
{
- m_compositor->setRetainedSelectionEnabled(enabled);
+ Q_D(const QWaylandCompositor);
+ return d->clients;
}
-bool QWaylandCompositor::retainedSelectionEnabled() const
+/*!
+ * \qmlmethod QtWaylandCompositor::WaylandCompositor::destroyClientForSurface(surface)
+ *
+ * Destroys the client for the WaylandSurface \a surface.
+ */
+
+/*!
+ * Destroys the client for the \a surface.
+ */
+void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface)
{
- return m_compositor->retainedSelectionEnabled();
+ destroyClient(surface->client());
}
-void QWaylandCompositor::retainedSelectionReceived(QMimeData *)
+/*!
+ * \qmlmethod QtWaylandCompositor::WaylandCompositor::destroyClient(client)
+ *
+ * Destroys the given WaylandClient \a client.
+ */
+
+/*!
+ * Destroys the \a client.
+ */
+void QWaylandCompositor::destroyClient(QWaylandClient *client)
{
+ if (!client)
+ return;
+
+ QWaylandWindowManagerExtension *wmExtension = QWaylandWindowManagerExtension::findIn(this);
+ if (wmExtension)
+ wmExtension->sendQuitMessage(client->client());
+
+ wl_client_destroy(client->client());
}
-void QWaylandCompositor::overrideSelection(const QMimeData *data)
+/*!
+ * \internal
+ */
+QList<QWaylandSurface *> QWaylandCompositor::surfacesForClient(QWaylandClient* client) const
{
- m_compositor->overrideSelection(data);
+ Q_D(const QWaylandCompositor);
+ QList<QWaylandSurface *> surfs;
+ foreach (QWaylandSurface *surface, d->all_surfaces) {
+ if (surface->client() == client)
+ surfs.append(surface);
+ }
+ return surfs;
}
-void QWaylandCompositor::setClientFullScreenHint(bool value)
+/*!
+ * \internal
+ */
+QList<QWaylandSurface *> QWaylandCompositor::surfaces() const
{
- m_compositor->setClientFullScreenHint(value);
+ Q_D(const QWaylandCompositor);
+ return d->all_surfaces;
}
-const char *QWaylandCompositor::socketName() const
-{
- if (m_compositor->m_socket_name.isEmpty())
- return 0;
- return m_compositor->m_socket_name.constData();
+/*!
+ * Returns the QWaylandOutput that is connected to the given \a window.
+ */
+QWaylandOutput *QWaylandCompositor::outputFor(QWindow *window) const
+{
+ Q_D(const QWaylandCompositor);
+ foreach (QWaylandOutput *output, d->outputs) {
+ if (output->window() == window)
+ return output;
+ }
+
+ return Q_NULLPTR;
}
-#if QT_DEPRECATED_SINCE(5, 5)
/*!
- Set the screen orientation based on accelerometer data or similar.
-*/
-void QWaylandCompositor::setScreenOrientation(Qt::ScreenOrientation orientation)
+ * \qmlproperty object QtWaylandCompositor::WaylandCompositor::defaultOutput
+ *
+ * This property contains the first in the list of outputs added to the
+ * WaylandCompositor, or null if no outputs have been added.
+ *
+ * Setting a new default output prepends it to the output list, making
+ * it the new default, but the previous default is not removed from
+ * the list.
+ */
+/*!
+ * \property QWaylandCompositor::defaultOutput
+ *
+ * This property contains the first in the list of outputs added to the
+ * QWaylandCompositor, or null if no outputs have been added.
+ *
+ * Setting a new default output prepends it to the output list, making
+ * it the new default, but the previous default is not removed from
+ * the list. If the new default output was already in the list of outputs,
+ * it is moved to the beginning of the list.
+ */
+QWaylandOutput *QWaylandCompositor::defaultOutput() const
{
- QWaylandOutput *output = primaryOutput();
- if (output) {
- bool isPortrait = output->window()->screen()->primaryOrientation() == Qt::PortraitOrientation;
-
- switch (orientation) {
- case Qt::PrimaryOrientation:
- output->setTransform(QWaylandOutput::TransformNormal);
- break;
- case Qt::LandscapeOrientation:
- output->setTransform(isPortrait ? QWaylandOutput::Transform270 : QWaylandOutput::TransformNormal);
- break;
- case Qt::PortraitOrientation:
- output->setTransform(isPortrait ? QWaylandOutput::TransformNormal : QWaylandOutput::Transform90);
- break;
- case Qt::InvertedLandscapeOrientation:
- output->setTransform(isPortrait ? QWaylandOutput::Transform90 : QWaylandOutput::Transform180);
- break;
- case Qt::InvertedPortraitOrientation:
- output->setTransform(isPortrait ? QWaylandOutput::Transform180 : QWaylandOutput::Transform270);
- break;
- }
- }
+ Q_D(const QWaylandCompositor);
+ return d->defaultOutput();
}
-void QWaylandCompositor::setOutputGeometry(const QRect &geometry)
+void QWaylandCompositor::setDefaultOutput(QWaylandOutput *output)
{
- QWaylandOutput *output = primaryOutput();
- if (output)
- output->setGeometry(geometry);
+ Q_D(QWaylandCompositor);
+ if (d->outputs.size() && d->outputs.first() == output)
+ return;
+ d->outputs.removeOne(output);
+ d->outputs.prepend(output);
+ defaultOutputChanged();
}
-QRect QWaylandCompositor::outputGeometry() const
+/*!
+ * \internal
+ */
+QList<QWaylandOutput *> QWaylandCompositor::outputs() const
{
- QWaylandOutput *output = primaryOutput();
- if (output)
- return output->geometry();
- return QRect();
+ Q_D(const QWaylandCompositor);
+ return d->outputs;
}
-void QWaylandCompositor::setOutputRefreshRate(int rate)
+/*!
+ * \internal
+ */
+uint QWaylandCompositor::currentTimeMsecs() const
{
- QWaylandOutput *output = primaryOutput();
- if (output)
- output->setMode({output->mode().size, rate});
+ Q_D(const QWaylandCompositor);
+ return d->timer.elapsed();
}
-int QWaylandCompositor::outputRefreshRate() const
+/*!
+ * \internal
+ */
+void QWaylandCompositor::processWaylandEvents()
{
- QWaylandOutput *output = primaryOutput();
- if (output)
- return output->mode().refreshRate;
- return 0;
+ Q_D(QWaylandCompositor);
+ int ret = wl_event_loop_dispatch(d->loop, 0);
+ if (ret)
+ fprintf(stderr, "wl_event_loop_dispatch error: %d\n", ret);
+ wl_display_flush_clients(d->display);
}
-#endif
-QWaylandInputDevice *QWaylandCompositor::defaultInputDevice() const
+/*!
+ * \internal
+ */
+QWaylandInputDevice *QWaylandCompositor::createInputDevice()
{
- return m_compositor->defaultInputDevice()->handle();
+ return new QWaylandInputDevice(this);
}
-QWaylandInputPanel *QWaylandCompositor::inputPanel() const
+/*!
+ * \internal
+ */
+QWaylandPointer *QWaylandCompositor::createPointerDevice(QWaylandInputDevice *inputDevice)
{
- return m_compositor->inputPanel()->handle();
+ return new QWaylandPointer(inputDevice);
}
-QWaylandDrag *QWaylandCompositor::drag() const
+/*!
+ * \internal
+ */
+QWaylandKeyboard *QWaylandCompositor::createKeyboardDevice(QWaylandInputDevice *inputDevice)
{
- return m_compositor->defaultInputDevice()->dragHandle();
+ return new QWaylandKeyboard(inputDevice);
}
-bool QWaylandCompositor::isDragging() const
+/*!
+ * \internal
+ */
+QWaylandTouch *QWaylandCompositor::createTouchDevice(QWaylandInputDevice *inputDevice)
{
- return m_compositor->isDragging();
+ return new QWaylandTouch(inputDevice);
}
-void QWaylandCompositor::sendDragMoveEvent(const QPoint &global, const QPoint &local,
- QWaylandSurface *surface)
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandCompositor::retainedSelection
+ *
+ * This property holds whether retained selection is enabled.
+ */
+
+/*!
+ * \property QWaylandCompositor::retainedSelection
+ *
+ * This property holds whether retained selection is enabled.
+ */
+void QWaylandCompositor::setRetainedSelectionEnabled(bool enabled)
{
- m_compositor->sendDragMoveEvent(global, local, surface ? surface->handle() : 0);
+ Q_D(QWaylandCompositor);
+ d->retainSelection = enabled;
}
-void QWaylandCompositor::sendDragEndEvent()
+bool QWaylandCompositor::retainedSelectionEnabled() const
{
- m_compositor->sendDragEndEvent();
+ Q_D(const QWaylandCompositor);
+ return d->retainSelection;
}
-void QWaylandCompositor::setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY)
+/*!
+ * \internal
+ */
+void QWaylandCompositor::retainedSelectionReceived(QMimeData *)
{
- Q_UNUSED(surface);
- Q_UNUSED(hotspotX);
- Q_UNUSED(hotspotY);
}
-void QWaylandCompositor::configureTouchExtension(TouchExtensionFlags flags)
+/*!
+ * \internal
+ */
+void QWaylandCompositor::overrideSelection(const QMimeData *data)
{
- m_compositor->configureTouchExtension(flags);
+ Q_D(QWaylandCompositor);
+ d->data_device_manager->overrideSelection(*data);
}
-QWaylandSurfaceView *QWaylandCompositor::createView(QWaylandSurface *surface)
+/*!
+ * \qmlproperty object QtWaylandCompositor::WaylandCompositor::defaultInputDevice
+ *
+ * This property contains the default input device for this
+ * WaylandCompositor.
+ */
+
+/*!
+ * \property QWaylandCompositor::defaultInputDevice
+ *
+ * This property contains the default input device for this
+ * QWaylandCompositor.
+ */
+QWaylandInputDevice *QWaylandCompositor::defaultInputDevice() const
{
- return new QWaylandSurfaceView(surface);
+ Q_D(const QWaylandCompositor);
+ if (d->inputDevices.size())
+ return d->inputDevices.first();
+ return Q_NULLPTR;
}
+/*!
+ * \internal
+ *
+ * Currently, Qt only supports a single input device, so this exists for
+ * future proofing the APIs.
+ */
QWaylandInputDevice *QWaylandCompositor::inputDeviceFor(QInputEvent *inputEvent)
{
- return m_compositor->inputDeviceFor(inputEvent);
+ Q_D(QWaylandCompositor);
+ QWaylandInputDevice *dev = NULL;
+ for (int i = 0; i < d->inputDevices.size(); i++) {
+ QWaylandInputDevice *candidate = d->inputDevices.at(i);
+ if (candidate->isOwner(inputEvent)) {
+ dev = candidate;
+ break;
+ }
+ }
+ return dev;
}
-QWaylandOutput *QWaylandCompositor::createOutput(QWindow *window,
- const QString &manufacturer,
- const QString &model)
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandCompositor::useHardwareIntegrationExtension
+ *
+ * This property holds whether the hardware integration extension should be enabled for
+ * this WaylandCompositor.
+ *
+ * This property must be set before the compositor component is completed.
+ */
+
+/*!
+ * \property QWaylandCompositor::useHardwareIntegrationExtension
+ *
+ * This property holds whether the hardware integration extension should be enabled for
+ * this QWaylandCompositor.
+ *
+ * This property must be set before the compositor is \l{create()}{created}.
+ */
+bool QWaylandCompositor::useHardwareIntegrationExtension() const
{
- return new QWaylandOutput(this, window, manufacturer, model);
+ Q_D(const QWaylandCompositor);
+ return d->use_hw_integration_extension;
+}
+
+void QWaylandCompositor::setUseHardwareIntegrationExtension(bool use)
+{
+ Q_D(QWaylandCompositor);
+ if (use == d->use_hw_integration_extension)
+ return;
+
+ if (d->initialized)
+ qWarning("Setting QWaylandCompositor::useHardwareIntegrationExtension after initialization has no effect");
+
+ d->use_hw_integration_extension = use;
+ useHardwareIntegrationExtensionChanged();
}
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h
index 1817fa07..cae7b458 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.h
+++ b/src/compositor/compositor_api/qwaylandcompositor.h
@@ -3,36 +3,32 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -41,7 +37,9 @@
#ifndef QWAYLANDCOMPOSITOR_H
#define QWAYLANDCOMPOSITOR_H
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandextension.h>
+#include <QtWaylandCompositor/QWaylandOutput>
#include <QObject>
#include <QImage>
@@ -56,124 +54,89 @@ class QInputEvent;
class QMimeData;
class QUrl;
class QOpenGLContext;
+class QWaylandCompositorPrivate;
class QWaylandClient;
class QWaylandSurface;
class QWaylandInputDevice;
-class QWaylandInputPanel;
-class QWaylandDrag;
class QWaylandGlobalInterface;
-class QWaylandSurfaceView;
-class QWaylandOutput;
+class QWaylandView;
+class QWaylandPointer;
+class QWaylandKeyboard;
+class QWaylandTouch;
-namespace QtWayland
+class Q_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject
{
- class Compositor;
-}
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandCompositor)
+ Q_PROPERTY(QByteArray socketName READ socketName WRITE setSocketName)
+ Q_PROPERTY(bool retainedSelection READ retainedSelectionEnabled WRITE setRetainedSelectionEnabled)
+ Q_PROPERTY(QWaylandOutput *defaultOutput READ defaultOutput WRITE setDefaultOutput NOTIFY defaultOutputChanged)
+ Q_PROPERTY(bool useHardwareIntegrationExtension READ useHardwareIntegrationExtension WRITE setUseHardwareIntegrationExtension NOTIFY useHardwareIntegrationExtensionChanged)
+ Q_PROPERTY(QWaylandInputDevice *defaultInputDevice READ defaultInputDevice NOTIFY defaultInputDeviceChanged)
-class Q_COMPOSITOR_EXPORT QWaylandCompositor
-{
public:
- enum ExtensionFlag {
- WindowManagerExtension = 0x01,
- SurfaceExtension = 0x02,
- QtKeyExtension = 0x04,
- TouchExtension = 0x08,
- SubSurfaceExtension = 0x10,
- TextInputExtension = 0x20,
- HardwareIntegrationExtension = 0x40,
-
- DefaultExtensions = WindowManagerExtension | SurfaceExtension | QtKeyExtension | TouchExtension | HardwareIntegrationExtension
- };
- Q_DECLARE_FLAGS(ExtensionFlags, ExtensionFlag)
-
- QWaylandCompositor(const char *socketName = 0, ExtensionFlags extensions = DefaultExtensions);
+ QWaylandCompositor(QObject *parent = 0);
virtual ~QWaylandCompositor();
- void addGlobalInterface(QWaylandGlobalInterface *interface);
- void addDefaultShell();
- ::wl_display *waylandDisplay() const;
-
- void frameStarted();
- void sendFrameCallbacks(QList<QWaylandSurface *> visibleSurfaces);
+ virtual void create();
+ bool isCreated() const;
- void destroyClientForSurface(QWaylandSurface *surface);
- void destroyClient(QWaylandClient *client);
-
- QList<QWaylandSurface *> surfacesForClient(QWaylandClient* client) const;
- QList<QWaylandSurface *> surfaces() const;
+ void setSocketName(const QByteArray &name);
+ QByteArray socketName() const;
- QList<QWaylandOutput *> outputs() const;
- QWaylandOutput *output(QWindow *window);
+ ::wl_display *display() const;
+ uint32_t nextSerial();
- QWaylandOutput *primaryOutput() const;
- void setPrimaryOutput(QWaylandOutput *output);
+ QList<QWaylandClient *>clients() const;
+ Q_INVOKABLE void destroyClientForSurface(QWaylandSurface *surface);
+ Q_INVOKABLE void destroyClient(QWaylandClient *client);
- virtual void surfaceCreated(QWaylandSurface *surface) = 0;
- virtual void surfaceAboutToBeDestroyed(QWaylandSurface *surface);
+ QList<QWaylandSurface *> surfaces() const;
+ QList<QWaylandSurface *> surfacesForClient(QWaylandClient* client) const;
- virtual QWaylandSurfaceView *pickView(const QPointF &globalPosition) const;
- virtual QPointF mapToView(QWaylandSurfaceView *view, const QPointF &surfacePosition) const;
+ Q_INVOKABLE QWaylandOutput *outputFor(QWindow *window) const;
- virtual bool openUrl(QWaylandClient *client, const QUrl &url);
+ QWaylandOutput *defaultOutput() const;
+ void setDefaultOutput(QWaylandOutput *output);
+ QList<QWaylandOutput *> outputs() const;
- QtWayland::Compositor *handle() const;
+ uint currentTimeMsecs() const;
void setRetainedSelectionEnabled(bool enabled);
bool retainedSelectionEnabled() const;
void overrideSelection(const QMimeData *data);
- void setClientFullScreenHint(bool value);
-
- const char *socketName() const;
-
-#if QT_DEPRECATED_SINCE(5, 5)
- void setScreenOrientation(Qt::ScreenOrientation orientation);
-
- void setOutputGeometry(const QRect &outputGeometry);
- QRect outputGeometry() const;
-
- void setOutputRefreshRate(int refreshRate);
- int outputRefreshRate() const;
-#endif
-
QWaylandInputDevice *defaultInputDevice() const;
- QWaylandInputPanel *inputPanel() const;
- QWaylandDrag *drag() const;
+ QWaylandView *createSurfaceView(QWaylandSurface *surface);
- bool isDragging() const;
- void sendDragMoveEvent(const QPoint &global, const QPoint &local, QWaylandSurface *surface);
- void sendDragEndEvent();
-
- virtual void setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY);
+ QWaylandInputDevice *inputDeviceFor(QInputEvent *inputEvent);
- void cleanupGraphicsResources();
+ bool useHardwareIntegrationExtension() const;
+ void setUseHardwareIntegrationExtension(bool use);
- enum TouchExtensionFlag {
- TouchExtMouseFromTouch = 0x01
- };
- Q_DECLARE_FLAGS(TouchExtensionFlags, TouchExtensionFlag)
- void configureTouchExtension(TouchExtensionFlags flags);
+public Q_SLOTS:
+ void processWaylandEvents();
- virtual QWaylandSurfaceView *createView(QWaylandSurface *surface);
+Q_SIGNALS:
+ void createSurface(QWaylandClient *client, uint id, int version);
+ void surfaceCreated(QWaylandSurface *surface);
+ void surfaceAboutToBeDestroyed(QWaylandSurface *surface);
- QWaylandInputDevice *inputDeviceFor(QInputEvent *inputEvent);
+ void defaultOutputChanged();
+ void defaultInputDeviceChanged();
+ void useHardwareIntegrationExtensionChanged();
protected:
- QWaylandCompositor(const char *socketName, QtWayland::Compositor *dptr);
virtual void retainedSelectionReceived(QMimeData *mimeData);
+ virtual QWaylandInputDevice *createInputDevice();
+ virtual QWaylandPointer *createPointerDevice(QWaylandInputDevice *inputDevice);
+ virtual QWaylandKeyboard *createKeyboardDevice(QWaylandInputDevice *inputDevice);
+ virtual QWaylandTouch *createTouchDevice(QWaylandInputDevice *inputDevice);
- virtual QWaylandOutput *createOutput(QWindow *window,
- const QString &manufacturer,
- const QString &model);
-
- friend class QtWayland::Compositor;
- QtWayland::Compositor *m_compositor;
+ QWaylandCompositor(QWaylandCompositorPrivate &dptr, QObject *parent = 0);
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandCompositor::ExtensionFlags)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandCompositor::TouchExtensionFlags)
-
QT_END_NAMESPACE
#endif // QWAYLANDCOMPOSITOR_H
diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h
new file mode 100644
index 00000000..fb0f803e
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandcompositor_p.h
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2014-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDCOMPOSITOR_P_H
+#define QWAYLANDCOMPOSITOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtCore/private/qobject_p.h>
+#include <QtCore/QSet>
+#include <QtCore/QElapsedTimer>
+
+#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWayland {
+ class HardwareIntegration;
+ class ClientBufferIntegration;
+ class ServerBufferIntegration;
+ class DataDeviceManager;
+}
+
+class QWindowSystemEventHandler;
+class QWaylandSurface;
+
+class Q_COMPOSITOR_EXPORT QWaylandCompositorPrivate : public QObjectPrivate, public QtWaylandServer::wl_compositor
+{
+public:
+ static QWaylandCompositorPrivate *get(QWaylandCompositor *compositor) { return compositor->d_func(); }
+
+ QWaylandCompositorPrivate(QWaylandCompositor *compositor);
+ ~QWaylandCompositorPrivate();
+
+ void init();
+
+ void destroySurface(QWaylandSurface *surface);
+ void unregisterSurface(QWaylandSurface *surface);
+
+ QWaylandOutput *defaultOutput() const { return outputs.size() ? outputs.first() : Q_NULLPTR; }
+
+ inline QtWayland::ClientBufferIntegration *clientBufferIntegration() const;
+ inline QtWayland::ServerBufferIntegration *serverBufferIntegration() const;
+
+ QtWayland::DataDeviceManager *dataDeviceManager() const { return data_device_manager; }
+ void feedRetainedSelectionData(QMimeData *data);
+
+ QWaylandPointer *callCreatePointerDevice(QWaylandInputDevice *inputDevice)
+ { return q_func()->createPointerDevice(inputDevice); }
+ QWaylandKeyboard *callCreateKeyboardDevice(QWaylandInputDevice *inputDevice)
+ { return q_func()->createKeyboardDevice(inputDevice); }
+ QWaylandTouch *callCreateTouchDevice(QWaylandInputDevice *inputDevice)
+ { return q_func()->createTouchDevice(inputDevice); }
+
+ inline void addClient(QWaylandClient *client);
+ inline void removeClient(QWaylandClient *client);
+
+ void addPolishObject(QObject *object);
+
+ inline void addOutput(QWaylandOutput *output);
+ inline void removeOutput(QWaylandOutput *output);
+protected:
+ void compositor_create_surface(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
+ void compositor_create_region(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
+
+ virtual QWaylandSurface *createDefaultSurface();
+protected:
+ void initializeHardwareIntegration();
+ void initializeExtensions();
+ void initializeDefaultInputDevice();
+
+ void loadClientBufferIntegration();
+ void loadServerBufferIntegration();
+
+ QByteArray socket_name;
+ struct wl_display *display;
+
+ QList<QWaylandInputDevice *> inputDevices;
+ QList<QWaylandOutput *> outputs;
+
+ QList<QWaylandSurface *> all_surfaces;
+
+ QtWayland::DataDeviceManager *data_device_manager;
+
+ QElapsedTimer timer;
+
+ wl_event_loop *loop;
+
+ QList<QWaylandClient *> clients;
+
+#ifdef QT_COMPOSITOR_WAYLAND_GL
+ bool use_hw_integration_extension;
+ QScopedPointer<QtWayland::HardwareIntegration> hw_integration;
+ QScopedPointer<QtWayland::ClientBufferIntegration> client_buffer_integration;
+ QScopedPointer<QtWayland::ServerBufferIntegration> server_buffer_integration;
+#endif
+
+ QScopedPointer<QWindowSystemEventHandler> eventHandler;
+
+ bool retainSelection;
+ bool initialized;
+ QList<QPointer<QObject> > polish_objects;
+
+ Q_DECLARE_PUBLIC(QWaylandCompositor)
+ Q_DISABLE_COPY(QWaylandCompositorPrivate)
+};
+
+QtWayland::ClientBufferIntegration * QWaylandCompositorPrivate::clientBufferIntegration() const
+{
+#ifdef QT_COMPOSITOR_WAYLAND_GL
+ return client_buffer_integration.data();
+#else
+ return 0;
+#endif
+}
+
+QtWayland::ServerBufferIntegration * QWaylandCompositorPrivate::serverBufferIntegration() const
+{
+#ifdef QT_COMPOSITOR_WAYLAND_GL
+ return server_buffer_integration.data();
+#else
+ return 0;
+#endif
+}
+
+void QWaylandCompositorPrivate::addClient(QWaylandClient *client)
+{
+ Q_ASSERT(!clients.contains(client));
+ clients.append(client);
+}
+
+void QWaylandCompositorPrivate::removeClient(QWaylandClient *client)
+{
+ Q_ASSERT(clients.contains(client));
+ clients.removeOne(client);
+}
+
+void QWaylandCompositorPrivate::addOutput(QWaylandOutput *output)
+{
+ Q_ASSERT(output);
+ if (outputs.contains(output))
+ return;
+ outputs.append(output);
+}
+
+void QWaylandCompositorPrivate::removeOutput(QWaylandOutput *output)
+{
+ Q_ASSERT(output);
+ Q_ASSERT(outputs.count(output) == 1);
+ outputs.removeOne(output);
+}
+
+QT_END_NAMESPACE
+
+#endif //QWAYLANDCOMPOSITOR_P_H
diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.cpp b/src/compositor/compositor_api/qwaylanddestroylistener.cpp
new file mode 100644
index 00000000..13ec6384
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylanddestroylistener.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylanddestroylistener.h"
+#include "qwaylanddestroylistener_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QWaylandDestroyListenerPrivate::QWaylandDestroyListenerPrivate()
+{
+ listener.parent = this;
+ listener.listener.notify = handler;
+ wl_list_init(&listener.listener.link);
+}
+
+QWaylandDestroyListener::QWaylandDestroyListener(QObject *parent)
+ : QObject(* new QWaylandDestroyListenerPrivate(), parent)
+{
+}
+void QWaylandDestroyListener::listenForDestruction(::wl_resource *resource)
+{
+ Q_D(QWaylandDestroyListener);
+ wl_resource_add_destroy_listener(resource, &d->listener.listener);
+}
+
+void QWaylandDestroyListener::reset()
+{
+ Q_D(QWaylandDestroyListener);
+ wl_list_remove(&d->listener.listener.link);
+ wl_list_init(&d->listener.listener.link);
+}
+
+void QWaylandDestroyListenerPrivate::handler(wl_listener *listener, void *data)
+{
+ QWaylandDestroyListenerPrivate *that = reinterpret_cast<Listener *>(listener)->parent;
+ emit that->q_func()->fired(data);
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.h b/src/compositor/compositor_api/qwaylanddestroylistener.h
new file mode 100644
index 00000000..04e0546a
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylanddestroylistener.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDDESTROYLISTENER_H
+#define QWAYLANDDESTROYLISTENER_H
+
+#include <QtCore/QObject>
+#include <QtWaylandCompositor/qwaylandexport.h>
+
+struct wl_resource;
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandDestroyListenerPrivate;
+
+class Q_COMPOSITOR_EXPORT QWaylandDestroyListener : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandDestroyListener)
+public:
+ QWaylandDestroyListener(QObject *parent = 0);
+ void listenForDestruction(struct wl_resource *resource);
+ void reset();
+
+Q_SIGNALS:
+ void fired(void *data);
+
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDDESTROYLISTENER_H*/
diff --git a/src/compositor/wayland_wrapper/qwllistener_p.h b/src/compositor/compositor_api/qwaylanddestroylistener_p.h
index 296a081a..63b2d3ce 100644
--- a/src/compositor/wayland_wrapper/qwllistener_p.h
+++ b/src/compositor/compositor_api/qwaylanddestroylistener_p.h
@@ -3,9 +3,9 @@
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -45,32 +48,28 @@
// We mean it.
//
-#include <QObject>
+#include "qwaylanddestroylistener.h"
+
+#include <QtCore/private/qobject_p.h>
#include <wayland-server.h>
QT_BEGIN_NAMESPACE
-class WlListener : public QObject
+class QWaylandDestroyListenerPrivate : public QObjectPrivate
{
- Q_OBJECT
public:
- WlListener();
-
- void listenForDestruction(::wl_resource *resource);
- void reset();
+ Q_DECLARE_PUBLIC(QWaylandDestroyListener)
-signals:
- void fired(void *data);
+ QWaylandDestroyListenerPrivate();
-private:
static void handler(wl_listener *listener, void *data);
struct Listener {
wl_listener listener;
- WlListener *parent;
+ QWaylandDestroyListenerPrivate *parent;
};
- Listener m_listener;
+ Listener listener;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylanddrag.cpp b/src/compositor/compositor_api/qwaylanddrag.cpp
index b31df31b..cc45c127 100644
--- a/src/compositor/compositor_api/qwaylanddrag.cpp
+++ b/src/compositor/compositor_api/qwaylanddrag.cpp
@@ -3,36 +3,32 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -42,51 +38,85 @@
#include <private/qobject_p.h>
-#include "qwlcompositor_p.h"
-#include "qwlinputdevice_p.h"
#include "qwldatadevice_p.h"
-#include "qwlsurface_p.h"
-#include "qwaylandsurfaceview.h"
+#include "qwaylandview.h"
+#include <QtWaylandCompositor/private/qwaylandinput_p.h>
QT_BEGIN_NAMESPACE
class QWaylandDragPrivate : public QObjectPrivate
{
public:
- QWaylandDragPrivate(QtWayland::InputDevice *id)
+ QWaylandDragPrivate(QWaylandInputDevice *id)
: inputDevice(id)
{
}
- QtWayland::InputDevice *inputDevice;
-};
+ QtWayland::DataDevice *dataDevice()
+ {
+ return QWaylandInputDevicePrivate::get(inputDevice)->dataDevice();
+ }
+
+ const QtWayland::DataDevice *dataDevice() const
+ {
+ return QWaylandInputDevicePrivate::get(inputDevice)->dataDevice();
+ }
+ QWaylandInputDevice *inputDevice;
+};
-QWaylandDrag::QWaylandDrag(QtWayland::InputDevice *inputDevice)
+QWaylandDrag::QWaylandDrag(QWaylandInputDevice *inputDevice)
: QObject(* new QWaylandDragPrivate(inputDevice))
{
}
-QWaylandSurfaceView *QWaylandDrag::icon() const
+QWaylandSurface *QWaylandDrag::icon() const
{
Q_D(const QWaylandDrag);
- const QtWayland::DataDevice *dataDevice = d->inputDevice->dataDevice();
+ const QtWayland::DataDevice *dataDevice = d->dataDevice();
if (!dataDevice)
return 0;
return dataDevice->dragIcon();
}
+
bool QWaylandDrag::visible() const
{
Q_D(const QWaylandDrag);
- const QtWayland::DataDevice *dataDevice = d->inputDevice->dataDevice();
+ const QtWayland::DataDevice *dataDevice = d->dataDevice();
if (!dataDevice)
return false;
return dataDevice->dragIcon() != 0;
}
+void QWaylandDrag::dragMove(QWaylandSurface *target, const QPointF &pos)
+{
+ Q_D(QWaylandDrag);
+ QtWayland::DataDevice *dataDevice = d->dataDevice();
+ if (!dataDevice)
+ return;
+ dataDevice->dragMove(target, pos);
+}
+void QWaylandDrag::drop()
+{
+ Q_D(QWaylandDrag);
+ QtWayland::DataDevice *dataDevice = d->dataDevice();
+ if (!dataDevice)
+ return;
+ dataDevice->drop();
+}
+
+void QWaylandDrag::cancelDrag()
+{
+ Q_D(QWaylandDrag);
+ QtWayland::DataDevice *dataDevice = d->dataDevice();
+ if (!dataDevice)
+ return;
+ dataDevice->cancelDrag();
+}
+
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylanddrag.h b/src/compositor/compositor_api/qwaylanddrag.h
index c0b0aca3..e7fcaad8 100644
--- a/src/compositor/compositor_api/qwaylanddrag.h
+++ b/src/compositor/compositor_api/qwaylanddrag.h
@@ -3,36 +3,32 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -41,35 +37,48 @@
#ifndef QWAYLANDDRAG_H
#define QWAYLANDDRAG_H
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandexport.h>
-#include <QObject>
+#include <QtCore/QObject>
+#include <QtCore/QPointF>
QT_BEGIN_NAMESPACE
class QWaylandDragPrivate;
class QWaylandSurface;
-class QWaylandSurfaceView;
+class QWaylandView;
+class QWaylandInputDevice;
namespace QtWayland {
-class InputDevice;
+ class DataDevice;
}
+
class Q_COMPOSITOR_EXPORT QWaylandDrag : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandDrag)
- Q_PROPERTY(QWaylandSurfaceView* icon READ icon NOTIFY iconChanged)
+ Q_PROPERTY(QWaylandSurface *icon READ icon NOTIFY iconChanged)
Q_PROPERTY(bool visible READ visible NOTIFY iconChanged)
public:
- explicit QWaylandDrag(QtWayland::InputDevice *inputDevice);
+ explicit QWaylandDrag(QWaylandInputDevice *inputDevice);
- QWaylandSurfaceView *icon() const;
+ QWaylandSurface *icon() const;
+ // QPointF position() const;
bool visible() const;
+public Q_SLOTS:
+ void dragMove(QWaylandSurface *target, const QPointF &pos);
+ void drop();
+ void cancelDrag();
+
Q_SIGNALS:
void iconChanged();
+ void dragStarted(); // QWaylandSurface *icon????
+
+private:
+ //friend class QtWayland::DataDevice;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandglobalinterface.cpp b/src/compositor/compositor_api/qwaylandglobalinterface.cpp
deleted file mode 100644
index 79196486..00000000
--- a/src/compositor/compositor_api/qwaylandglobalinterface.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwaylandglobalinterface.h"
-
-#include <wayland-server.h>
-
-QT_BEGIN_NAMESPACE
-
-QWaylandGlobalInterface::QWaylandGlobalInterface()
-{
-
-}
-
-QWaylandGlobalInterface::~QWaylandGlobalInterface()
-{
-
-}
-
-quint32 QWaylandGlobalInterface::version() const
-{
- return interface()->version;
-}
-
-QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandglobalinterface.h b/src/compositor/compositor_api/qwaylandglobalinterface.h
deleted file mode 100644
index 6be3236f..00000000
--- a/src/compositor/compositor_api/qwaylandglobalinterface.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWAYLANDGLOBALINTERFACE_H
-#define QWAYLANDGLOBALINTERFACE_H
-
-#include <QtCompositor/qwaylandexport.h>
-
-struct wl_interface;
-struct wl_client;
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWayland {
-class Compositor;
-}
-
-class Q_COMPOSITOR_EXPORT QWaylandGlobalInterface
-{
-public:
- QWaylandGlobalInterface();
- virtual ~QWaylandGlobalInterface();
-
- virtual const wl_interface *interface() const = 0;
- virtual quint32 version() const;
-
-protected:
- virtual void bind(wl_client *client, quint32 version, quint32 id) = 0;
-
- friend class QtWayland::Compositor;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/compositor/compositor_api/qwaylandinput.cpp b/src/compositor/compositor_api/qwaylandinput.cpp
index 4e106f5f..be566c70 100644
--- a/src/compositor/compositor_api/qwaylandinput.cpp
+++ b/src/compositor/compositor_api/qwaylandinput.cpp
@@ -3,52 +3,135 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandinput.h"
+#include "qwaylandinput_p.h"
-#include "qwlinputdevice_p.h"
-#include "qwlkeyboard_p.h"
#include "qwaylandcompositor.h"
-#include "qwlsurface_p.h"
-#include "qwlcompositor_p.h"
-#include "qwaylandsurfaceview.h"
+#include "qwaylandview.h"
+#include <QtWaylandCompositor/QWaylandDrag>
+#include <QtWaylandCompositor/QWaylandTouch>
+#include <QtWaylandCompositor/QWaylandPointer>
+#include <QtWaylandCompositor/private/qwlinputmethod_p.h>
+#include <QtWaylandCompositor/private/qwaylandinput_p.h>
+#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
+#include <QtWaylandCompositor/private/qwldatadevice_p.h>
+
+#include "extensions/qwlqtkey_p.h"
QT_BEGIN_NAMESPACE
+QWaylandInputDevicePrivate::QWaylandInputDevicePrivate(QWaylandInputDevice *inputdevice, QWaylandCompositor *compositor)
+ : QObjectPrivate()
+ , QtWaylandServer::wl_seat(compositor->display(), 3)
+ , compositor(compositor)
+ , mouseFocus(Q_NULLPTR)
+ , capabilities()
+ , data_device()
+ , drag_handle(new QWaylandDrag(inputdevice))
+{
+}
+
+QWaylandInputDevicePrivate::~QWaylandInputDevicePrivate()
+{
+}
+
+void QWaylandInputDevicePrivate::setCapabilities(QWaylandInputDevice::CapabilityFlags caps)
+{
+ Q_Q(QWaylandInputDevice);
+ if (capabilities != caps) {
+ QWaylandInputDevice::CapabilityFlags changed = caps ^ capabilities;
+
+ if (changed & QWaylandInputDevice::Pointer) {
+ pointer.reset(pointer.isNull() ? QWaylandCompositorPrivate::get(compositor)->callCreatePointerDevice(q) : 0);
+ }
+
+ if (changed & QWaylandInputDevice::Keyboard) {
+ keyboard.reset(keyboard.isNull() ? QWaylandCompositorPrivate::get(compositor)->callCreateKeyboardDevice(q) : 0);
+ }
+
+ if (changed & QWaylandInputDevice::Touch) {
+ touch.reset(touch.isNull() ? QWaylandCompositorPrivate::get(compositor)->callCreateTouchDevice(q) : 0);
+ }
+
+ capabilities = caps;
+ QList<Resource *> resources = resourceMap().values();
+ for (int i = 0; i < resources.size(); i++) {
+ wl_seat::send_capabilities(resources.at(i)->handle, (uint32_t)capabilities);
+ }
+ }
+}
+
+void QWaylandInputDevicePrivate::clientRequestedDataDevice(QtWayland::DataDeviceManager *, struct wl_client *client, uint32_t id)
+{
+ Q_Q(QWaylandInputDevice);
+ if (!data_device)
+ data_device.reset(new QtWayland::DataDevice(q));
+ data_device->add(client, id, 1);
+}
+
+void QWaylandInputDevicePrivate::seat_destroy_resource(wl_seat::Resource *)
+{
+// cleanupDataDeviceForClient(resource->client(), true);
+}
+
+void QWaylandInputDevicePrivate::seat_bind_resource(wl_seat::Resource *resource)
+{
+ // The order of capabilities matches the order defined in the wayland protocol
+ wl_seat::send_capabilities(resource->handle, (uint32_t)capabilities);
+}
+
+void QWaylandInputDevicePrivate::seat_get_pointer(wl_seat::Resource *resource, uint32_t id)
+{
+ if (!pointer.isNull()) {
+ pointer->addClient(QWaylandClient::fromWlClient(compositor, resource->client()), id, resource->version());
+ }
+}
+
+void QWaylandInputDevicePrivate::seat_get_keyboard(wl_seat::Resource *resource, uint32_t id)
+{
+ if (!keyboard.isNull()) {
+ keyboard->addClient(QWaylandClient::fromWlClient(compositor, resource->client()), id, resource->version());
+ }
+}
+
+void QWaylandInputDevicePrivate::seat_get_touch(wl_seat::Resource *resource, uint32_t id)
+{
+ if (!touch.isNull()) {
+ touch->addClient(QWaylandClient::fromWlClient(compositor, resource->client()), id, resource->version());
+ }
+}
+
QWaylandKeymap::QWaylandKeymap(const QString &layout, const QString &variant, const QString &options, const QString &model, const QString &rules)
: m_layout(layout)
, m_variant(variant)
@@ -59,134 +142,302 @@ QWaylandKeymap::QWaylandKeymap(const QString &layout, const QString &variant, co
}
+/*!
+ * \class QWaylandInputDevice
+ * \inmodule QtWaylandCompositor
+ * \brief The QWaylandInputDevice class provides access to keyboard, mouse and touch input.
+ *
+ * The QWaylandInputDevice provides access to different types of user input and maintains
+ * a keyboard focus and a mouse pointer. It corresponds to the wl_seat interface in the Wayland protocol.
+ */
-QWaylandInputDevice::QWaylandInputDevice(QWaylandCompositor *compositor, CapabilityFlags caps)
- : d(new QtWayland::InputDevice(this,compositor->handle(), caps))
-{
-}
+/*!
+ * \enum QWaylandInputDevice::CapabilityFlag
+ *
+ * This enum type describes the capabilities of a QWaylandInputDevice.
+ *
+ * \value Pointer The QWaylandInputDevice supports pointer input.
+ * \value Keyboard The QWaylandInputDevice supports keyboard input.
+ * \value Touch The QWaylandInputDevice supports touch input.
+ */
-QWaylandInputDevice::~QWaylandInputDevice()
+/*!
+ * Constructs a QWaylandInputDevice for the given \a compositor and with the given \a capabilityFlags.
+ */
+QWaylandInputDevice::QWaylandInputDevice(QWaylandCompositor *compositor, CapabilityFlags capabilityFlags)
+ : QWaylandObject(*new QWaylandInputDevicePrivate(this,compositor))
{
- delete d;
+ d_func()->setCapabilities(capabilityFlags);
}
-void QWaylandInputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos)
+/*!
+ * Destroys the QWaylandInputDevice
+ */
+QWaylandInputDevice::~QWaylandInputDevice()
{
- d->sendMousePressEvent(button,localPos,globalPos);
}
-void QWaylandInputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos)
+/*!
+ * Sends a mouse press event for \a button to the QWaylandInputDevice's pointer device.
+ */
+void QWaylandInputDevice::sendMousePressEvent(Qt::MouseButton button)
{
- d->sendMouseReleaseEvent(button,localPos,globalPos);
+ Q_D(QWaylandInputDevice);
+ d->pointer->sendMousePressEvent(button);
}
-void QWaylandInputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos)
+/*!
+ * Sends a mouse release event for \a button to the QWaylandInputDevice's pointer device.
+ */
+void QWaylandInputDevice::sendMouseReleaseEvent(Qt::MouseButton button)
{
- d->sendMouseMoveEvent(localPos,globalPos);
+ Q_D(QWaylandInputDevice);
+ d->pointer->sendMouseReleaseEvent(button);
}
-/** 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
+/*!
+ * Sets the mouse focus to \a view and sends a mouse move event to the pointer device with the
+ * local position \a localPos and output space position \a outputSpacePos.
**/
-void QWaylandInputDevice::sendMouseMoveEvent(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos)
+void QWaylandInputDevice::sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos)
{
- d->sendMouseMoveEvent(surface,localPos,globalPos);
+ Q_D(QWaylandInputDevice);
+ d->pointer->sendMouseMoveEvent(view, localPos, outputSpacePos);
}
+/*!
+ * Sends a mouse wheel event to the QWaylandInputDevice's pointer device with the given \a orientation and \a delta.
+ */
void QWaylandInputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
{
- d->sendMouseWheelEvent(orientation, delta);
+ Q_D(QWaylandInputDevice);
+ d->pointer->sendMouseWheelEvent(orientation, delta);
}
+/*!
+ * Sends a key press event with the key \a code to the keyboard device.
+ */
void QWaylandInputDevice::sendKeyPressEvent(uint code)
{
- d->keyboardDevice()->sendKeyPressEvent(code);
+ Q_D(QWaylandInputDevice);
+ d->keyboard->sendKeyPressEvent(code);
}
+/*!
+ * Sends a key release event with the key \a code to the keyboard device.
+ */
void QWaylandInputDevice::sendKeyReleaseEvent(uint code)
{
- d->keyboardDevice()->sendKeyReleaseEvent(code);
+ Q_D(QWaylandInputDevice);
+ d->keyboard->sendKeyReleaseEvent(code);
}
-void QWaylandInputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state)
+/*!
+ * Sends a touch point event with the given \a id and \a state to the touch device. The position
+ * of the touch point is given by \a point.
+ */
+void QWaylandInputDevice::sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state)
{
- d->sendTouchPointEvent(id,x,y,state);
+ Q_D(QWaylandInputDevice);
+ if (d->touch.isNull()) {
+ return;
+ }
+ d->touch->sendTouchPointEvent(id, point,state);
}
+/*!
+ * Sends a frame event to the touch device.
+ */
void QWaylandInputDevice::sendTouchFrameEvent()
{
- d->sendTouchFrameEvent();
+ Q_D(QWaylandInputDevice);
+ if (!d->touch.isNull()) {
+ d->touch->sendFrameEvent();
+ }
}
+/*!
+ * Sends a cancel event to the touch device.
+ */
void QWaylandInputDevice::sendTouchCancelEvent()
{
- d->sendTouchCancelEvent();
+ Q_D(QWaylandInputDevice);
+ if (!d->touch.isNull()) {
+ d->touch->sendCancelEvent();
+ }
}
+/*!
+ * Sends the \a event to the touch device.
+ */
void QWaylandInputDevice::sendFullTouchEvent(QTouchEvent *event)
{
- d->sendFullTouchEvent(event);
+ Q_D(QWaylandInputDevice);
+ if (!mouseFocus()) {
+ qWarning("Cannot send touch event, no pointer focus, fix the compositor");
+ return;
+ }
+
+ if (!d->touch)
+ return;
+
+ d->touch->sendFullTouchEvent(event);
}
+/*!
+ * Sends the \a event to the keyboard device.
+ */
void QWaylandInputDevice::sendFullKeyEvent(QKeyEvent *event)
{
- d->sendFullKeyEvent(event);
+ Q_D(QWaylandInputDevice);
+ if (!keyboardFocus()) {
+ qWarning("Cannot send key event, no keyboard focus, fix the compositor");
+ return;
+ }
+
+ QtWayland::QtKeyExtensionGlobal *ext = QtWayland::QtKeyExtensionGlobal::findIn(d->compositor);
+ if (ext && ext->postQtKeyEvent(event, keyboardFocus()))
+ return;
+
+ if (!d->keyboard.isNull() && !event->isAutoRepeat()) {
+ if (event->type() == QEvent::KeyPress)
+ d->keyboard->sendKeyPressEvent(event->nativeScanCode());
+ else if (event->type() == QEvent::KeyRelease)
+ d->keyboard->sendKeyReleaseEvent(event->nativeScanCode());
+ }
}
-void QWaylandInputDevice::sendFullKeyEvent(QWaylandSurface *surface, QKeyEvent *event)
+/*!
+ * Returns the keyboard for this input device.
+ */
+QWaylandKeyboard *QWaylandInputDevice::keyboard() const
{
- d->sendFullKeyEvent(surface->handle(), event);
+ Q_D(const QWaylandInputDevice);
+ return d->keyboard.data();
}
+/*!
+ * Returns the current focused surface for keyboard input.
+ */
QWaylandSurface *QWaylandInputDevice::keyboardFocus() const
{
- QtWayland::Surface *wlsurface = d->keyboardFocus();
- if (wlsurface)
- return wlsurface->waylandSurface();
- return 0;
+ Q_D(const QWaylandInputDevice);
+ if (d->keyboard.isNull() || !d->keyboard->focus())
+ return Q_NULLPTR;
+
+ return d->keyboard->focus();
}
+/*!
+ * Sets the current keyboard focus to \a surface.
+ */
bool QWaylandInputDevice::setKeyboardFocus(QWaylandSurface *surface)
{
- QtWayland::Surface *wlsurface = surface?surface->handle():0;
- return d->setKeyboardFocus(wlsurface);
+ Q_D(QWaylandInputDevice);
+ if (surface && surface->isDestroyed())
+ return false;
+
+ if (surface == keyboardFocus())
+ return true;
+
+ if (!d->keyboard.isNull() && d->keyboard->setFocus(surface)) {
+ if (d->data_device)
+ d->data_device->setFocus(d->keyboard->focusClient());
+ return true;
+ }
+ return false;
}
+/*!
+ * Sets the key map of this QWaylandInputDevice to \a keymap.
+ */
void QWaylandInputDevice::setKeymap(const QWaylandKeymap &keymap)
{
- if (handle()->keyboardDevice())
- handle()->keyboardDevice()->setKeymap(keymap);
+ if (keyboard())
+ keyboard()->setKeymap(keymap);
}
-QWaylandSurfaceView *QWaylandInputDevice::mouseFocus() const
+/*!
+ * Returns the pointer device for this QWaylandInputDevice.
+ */
+QWaylandPointer *QWaylandInputDevice::pointer() const
{
- return d->mouseFocus();
+ Q_D(const QWaylandInputDevice);
+ return d->pointer.data();
}
-void QWaylandInputDevice::setMouseFocus(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos)
+/*!
+ * Returns the view that currently has mouse focus.
+ */
+QWaylandView *QWaylandInputDevice::mouseFocus() const
{
- d->setMouseFocus(surface,localPos,globalPos);
+ Q_D(const QWaylandInputDevice);
+ return d->mouseFocus;
}
+/*!
+ * Sets the current mouse focus to \a view.
+ */
+void QWaylandInputDevice::setMouseFocus(QWaylandView *view)
+{
+ Q_D(QWaylandInputDevice);
+ if (view == d->mouseFocus)
+ return;
+
+ QWaylandView *oldFocus = d->mouseFocus;
+ d->mouseFocus = view;
+ emit mouseFocusChanged(d->mouseFocus, oldFocus);
+}
+
+/*!
+ * Returns the compositor for this QWaylandInputDevice.
+ */
QWaylandCompositor *QWaylandInputDevice::compositor() const
{
- return d->compositor()->waylandCompositor();
+ Q_D(const QWaylandInputDevice);
+ return d->compositor;
}
-QtWayland::InputDevice *QWaylandInputDevice::handle() const
+/*!
+ * Returns the drag object for this QWaylandInputDevice.
+ */
+QWaylandDrag *QWaylandInputDevice::drag() const
{
- return d;
+ Q_D(const QWaylandInputDevice);
+ return d->drag_handle.data();
}
-QWaylandInputDevice::CapabilityFlags QWaylandInputDevice::capabilities()
+/*!
+ * Returns the capability flags for this QWaylandInputDevice.
+ */
+QWaylandInputDevice::CapabilityFlags QWaylandInputDevice::capabilities() const
{
- return d->capabilities();
+ Q_D(const QWaylandInputDevice);
+ return d->capabilities;
}
-bool QWaylandInputDevice::isOwner(QInputEvent *inputEvent)
+/*!
+ * \internal
+ */
+bool QWaylandInputDevice::isOwner(QInputEvent *inputEvent) const
{
Q_UNUSED(inputEvent);
return true;
}
+/*!
+ * Returns the QWaylandInputDevice corresponding to the \a resource. The \a resource is expected
+ * to have the type wl_seat.
+ */
+QWaylandInputDevice *QWaylandInputDevice::fromSeatResource(struct ::wl_resource *resource)
+{
+ return static_cast<QWaylandInputDevicePrivate *>(QWaylandInputDevicePrivate::Resource::fromResource(resource)->seat_object)->q_func();
+}
+
+/*!
+ * \fn void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus)
+ *
+ * This signal is emitted when the mouse focus has changed from \a oldFocus to \a newFocus.
+ */
+
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandinput.h b/src/compositor/compositor_api/qwaylandinput.h
index 7842fa38..e4b6e127 100644
--- a/src/compositor/compositor_api/qwaylandinput.h
+++ b/src/compositor/compositor_api/qwaylandinput.h
@@ -3,36 +3,32 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -45,7 +41,9 @@
#include <QtCore/QPoint>
#include <QtCore/QString>
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandextension.h>
+#include <QtWaylandCompositor/qwaylandkeyboard.h>
QT_BEGIN_NAMESPACE
@@ -53,35 +51,22 @@ class QWaylandCompositor;
class QWaylandSurface;
class QKeyEvent;
class QTouchEvent;
-class QWaylandSurfaceView;
+class QWaylandView;
class QInputEvent;
+class QWaylandInputDevicePrivate;
+class QWaylandDrag;
+class QWaylandKeyboard;
+class QWaylandPointer;
+class QWaylandTouch;
namespace QtWayland {
class InputDevice;
}
-class Q_COMPOSITOR_EXPORT QWaylandKeymap
-{
-public:
- QWaylandKeymap(const QString &layout = QString(), const QString &variant = QString(), const QString &options = QString(),
- const QString &model = QString(), const QString &rules = QString());
-
- inline QString layout() const { return m_layout; }
- inline QString variant() const { return m_variant; }
- inline QString options() const { return m_options; }
- inline QString rules() const { return m_rules; }
- inline QString model() const { return m_model; }
-
-private:
- QString m_layout;
- QString m_variant;
- QString m_options;
- QString m_rules;
- QString m_model;
-};
-
-class Q_COMPOSITOR_EXPORT QWaylandInputDevice
+class Q_COMPOSITOR_EXPORT QWaylandInputDevice : public QWaylandObject
{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandInputDevice)
public:
enum CapabilityFlag {
// The order should match the enum WL_SEAT_CAPABILITY_*
@@ -92,14 +77,14 @@ public:
DefaultCapabilities = Pointer | Keyboard | Touch
};
Q_DECLARE_FLAGS(CapabilityFlags, CapabilityFlag)
+ Q_ENUM(CapabilityFlags)
- QWaylandInputDevice(QWaylandCompositor *compositor, CapabilityFlags caps = DefaultCapabilities);
+ QWaylandInputDevice(QWaylandCompositor *compositor, CapabilityFlags capabilityFlags = DefaultCapabilities);
virtual ~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(QWaylandSurfaceView *surface , const QPointF &localPos, const QPointF &globalPos = QPointF());
+ void sendMousePressEvent(Qt::MouseButton button);
+ void sendMouseReleaseEvent(Qt::MouseButton button);
+ void sendMouseMoveEvent(QWaylandView *surface , const QPointF &localPos, const QPointF &outputSpacePos = QPointF());
void sendMouseWheelEvent(Qt::Orientation orientation, int delta);
void sendKeyPressEvent(uint code);
@@ -108,29 +93,38 @@ public:
void sendFullKeyEvent(QKeyEvent *event);
void sendFullKeyEvent(QWaylandSurface *surface, QKeyEvent *event);
- void sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state);
+ void sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state);
void sendTouchFrameEvent();
void sendTouchCancelEvent();
void sendFullTouchEvent(QTouchEvent *event);
+ QWaylandPointer *pointer() const;
+ //Normally set by the mouse device,
+ //But can be set manually for use with touch or can reset unset the current mouse focus;
+ QWaylandView *mouseFocus() const;
+ void setMouseFocus(QWaylandView *view);
+
+ QWaylandKeyboard *keyboard() const;
QWaylandSurface *keyboardFocus() const;
bool setKeyboardFocus(QWaylandSurface *surface);
void setKeymap(const QWaylandKeymap &keymap);
- QWaylandSurfaceView *mouseFocus() const;
- void setMouseFocus(QWaylandSurfaceView *surface, const QPointF &local_pos, const QPointF &global_pos = QPointF());
+ QWaylandTouch *touch() const;
QWaylandCompositor *compositor() const;
- QtWayland::InputDevice *handle() const;
- QWaylandInputDevice::CapabilityFlags capabilities();
+ QWaylandDrag *drag() const;
+
+ QWaylandInputDevice::CapabilityFlags capabilities() const;
+
+ virtual bool isOwner(QInputEvent *inputEvent) const;
- virtual bool isOwner(QInputEvent *inputEvent);
+ static QWaylandInputDevice *fromSeatResource(struct ::wl_resource *resource);
-private:
- QtWayland::InputDevice *d;
- Q_DISABLE_COPY(QWaylandInputDevice)
+Q_SIGNALS:
+ void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus);
+ void cursorSurfaceRequest(QWaylandSurface *surface, int hotspotX, int hotspotY);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandInputDevice::CapabilityFlags)
diff --git a/src/compositor/compositor_api/qwaylandinput_p.h b/src/compositor/compositor_api/qwaylandinput_p.h
new file mode 100644
index 00000000..4ae741d0
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandinput_p.h
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDINPUT_P_H
+#define QWAYLANDINPUT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <stdint.h>
+
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandinput.h>
+
+#include <QtCore/QList>
+#include <QtCore/QPoint>
+#include <QtCore/QScopedPointer>
+#include <QtCore/private/qobject_p.h>
+
+#ifndef QT_NO_WAYLAND_XKB
+#include <xkbcommon/xkbcommon.h>
+#endif
+
+#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
+
+QT_BEGIN_NAMESPACE
+
+class QKeyEvent;
+class QTouchEvent;
+class QWaylandInputDevice;
+class QWaylandDrag;
+class QWaylandView;
+
+namespace QtWayland {
+
+class Compositor;
+class DataDevice;
+class Surface;
+class DataDeviceManager;
+class Pointer;
+class Keyboard;
+class Touch;
+class InputMethod;
+
+}
+
+class Q_COMPOSITOR_EXPORT QWaylandInputDevicePrivate : public QObjectPrivate, public QtWaylandServer::wl_seat
+{
+public:
+ Q_DECLARE_PUBLIC(QWaylandInputDevice)
+
+ QWaylandInputDevicePrivate(QWaylandInputDevice *device, QWaylandCompositor *compositor);
+ ~QWaylandInputDevicePrivate();
+
+ void clientRequestedDataDevice(QtWayland::DataDeviceManager *dndSelection, struct wl_client *client, uint32_t id);
+ void setCapabilities(QWaylandInputDevice::CapabilityFlags caps);
+
+ static QWaylandInputDevicePrivate *get(QWaylandInputDevice *device) { return device->d_func(); }
+
+ QtWayland::DataDevice *dataDevice() const { return data_device.data(); }
+
+protected:
+ void seat_bind_resource(wl_seat::Resource *resource) Q_DECL_OVERRIDE;
+
+ void seat_get_pointer(wl_seat::Resource *resource,
+ uint32_t id) Q_DECL_OVERRIDE;
+ void seat_get_keyboard(wl_seat::Resource *resource,
+ uint32_t id) Q_DECL_OVERRIDE;
+ void seat_get_touch(wl_seat::Resource *resource,
+ uint32_t id) Q_DECL_OVERRIDE;
+
+ void seat_destroy_resource(wl_seat::Resource *resource) Q_DECL_OVERRIDE;
+
+private:
+ QWaylandCompositor *compositor;
+ QWaylandView *mouseFocus;
+ QWaylandInputDevice::CapabilityFlags capabilities;
+
+ QScopedPointer<QWaylandPointer> pointer;
+ QScopedPointer<QWaylandKeyboard> keyboard;
+ QScopedPointer<QWaylandTouch> touch;
+ QScopedPointer<QtWayland::DataDevice> data_device;
+ QScopedPointer<QWaylandDrag> drag_handle;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDINPUT_P_H
diff --git a/src/compositor/compositor_api/qwaylandinputpanel.cpp b/src/compositor/compositor_api/qwaylandinputpanel.cpp
index db4cd329..6f774cd9 100644
--- a/src/compositor/compositor_api/qwaylandinputpanel.cpp
+++ b/src/compositor/compositor_api/qwaylandinputpanel.cpp
@@ -3,36 +3,32 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -40,59 +36,48 @@
#include "qwaylandinputpanel.h"
+#include <QtWaylandCompositor/QWaylandCompositor>
+
#include <private/qobject_p.h>
#include "qwlinputpanel_p.h"
-#include "qwlsurface_p.h"
QT_BEGIN_NAMESPACE
-class QWaylandInputPanelPrivate : public QObjectPrivate
-{
-public:
- QWaylandInputPanelPrivate(QtWayland::InputPanel *panel)
- : inputPanel(panel)
- {
- }
-
- QtWayland::InputPanel *inputPanel;
-};
-
-
-QWaylandInputPanel::QWaylandInputPanel(QtWayland::InputPanel *inputPanel)
- : QObject(*new QWaylandInputPanelPrivate(inputPanel))
+QWaylandInputPanel::QWaylandInputPanel(QWaylandCompositor *compositor)
+ : QWaylandExtensionTemplate(compositor, *new QWaylandInputPanelPrivate(compositor))
{
}
-QtWayland::InputPanel *QWaylandInputPanel::handle() const
+QWaylandSurface *QWaylandInputPanel::focus() const
{
- Q_D(const QWaylandInputPanel);
+ Q_D(const QWaylandInputPanel);
- return d->inputPanel;
+ return d->focus();
}
-QWaylandSurface *QWaylandInputPanel::focus() const
+bool QWaylandInputPanel::visible() const
{
Q_D(const QWaylandInputPanel);
- QtWayland::Surface *surface = d->inputPanel->focus();
- if (surface)
- return surface->waylandSurface();
- return 0;
+ return d->inputPanelVisible();
}
-bool QWaylandInputPanel::visible() const
+QRect QWaylandInputPanel::cursorRectangle() const
{
Q_D(const QWaylandInputPanel);
- return d->inputPanel->inputPanelVisible();
+ return d->cursorRectangle();
}
-QRect QWaylandInputPanel::cursorRectangle() const
+const struct wl_interface *QWaylandInputPanel::interface()
{
- Q_D(const QWaylandInputPanel);
+ return QWaylandInputPanelPrivate::interface();
+}
- return d->inputPanel->cursorRectangle();
+QByteArray QWaylandInputPanel::interfaceName()
+{
+ return QWaylandInputPanelPrivate::interfaceName();
}
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandinputpanel.h b/src/compositor/compositor_api/qwaylandinputpanel.h
index 22dc8b9f..cce1f458 100644
--- a/src/compositor/compositor_api/qwaylandinputpanel.h
+++ b/src/compositor/compositor_api/qwaylandinputpanel.h
@@ -3,36 +3,32 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -41,7 +37,8 @@
#ifndef QWAYLANDINPUTPANEL_H
#define QWAYLANDINPUTPANEL_H
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandextension.h>
#include <QObject>
#include <QRect>
@@ -52,11 +49,7 @@ class QWaylandCompositor;
class QWaylandInputPanelPrivate;
class QWaylandSurface;
-namespace QtWayland {
-class InputPanel;
-}
-
-class Q_COMPOSITOR_EXPORT QWaylandInputPanel : public QObject
+class Q_COMPOSITOR_EXPORT QWaylandInputPanel : public QWaylandExtensionTemplate<QWaylandInputPanel>
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandInputPanel)
@@ -66,14 +59,14 @@ class Q_COMPOSITOR_EXPORT QWaylandInputPanel : public QObject
Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
public:
- explicit QWaylandInputPanel(QtWayland::InputPanel *inputPanel);
-
- QtWayland::InputPanel *handle() const;
+ explicit QWaylandInputPanel(QWaylandCompositor *compositor);
QWaylandSurface *focus() const;
bool visible() const;
QRect cursorRectangle() const;
+ static const struct wl_interface *interface();
+ static QByteArray interfaceName();
Q_SIGNALS:
void focusChanged();
void visibleChanged();
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp
new file mode 100644
index 00000000..f39bb3e0
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp
@@ -0,0 +1,566 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandkeyboard.h"
+#include "qwaylandkeyboard_p.h"
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandInputDevice>
+#include <QtWaylandCompositor/QWaylandClient>
+
+#include <QtWaylandCompositor/QWaylandShellSurface>
+
+#include <QtCore/QFile>
+#include <QtCore/QStandardPaths>
+
+#include <fcntl.h>
+#include <unistd.h>
+#ifndef QT_NO_WAYLAND_XKB
+#include <sys/mman.h>
+#include <sys/types.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QWaylandKeyboardPrivate::QWaylandKeyboardPrivate(QWaylandInputDevice *seat)
+ : QtWaylandServer::wl_keyboard()
+ , seat(seat)
+ , focus()
+ , focusResource()
+ , keys()
+ , modsDepressed()
+ , modsLatched()
+ , modsLocked()
+ , group()
+ , pendingKeymap(false)
+#ifndef QT_NO_WAYLAND_XKB
+ , keymap_fd(-1)
+ , xkb_state(0)
+#endif
+ , repeatRate(40)
+ , repeatDelay(400)
+{
+#ifndef QT_NO_WAYLAND_XKB
+ initXKB();
+#endif
+}
+
+QWaylandKeyboardPrivate::~QWaylandKeyboardPrivate()
+{
+#ifndef QT_NO_WAYLAND_XKB
+ if (xkb_context) {
+ if (keymap_area)
+ munmap(keymap_area, keymap_size);
+ close(keymap_fd);
+ xkb_context_unref(xkb_context);
+ xkb_state_unref(xkb_state);
+ }
+#endif
+}
+
+QWaylandKeyboardPrivate *QWaylandKeyboardPrivate::get(QWaylandKeyboard *keyboard)
+{
+ return keyboard->d_func();
+}
+
+void QWaylandKeyboardPrivate::checkFocusResource(Resource *keyboardResource)
+{
+ if (!keyboardResource || !focus)
+ return;
+
+ // this is already the current resource, do no send enter twice
+ if (focusResource == keyboardResource)
+ return;
+
+ // check if new wl_keyboard resource is from the client owning the focus surface
+ if (focus->resource()->client == keyboardResource->client()) {
+ sendEnter(focus, keyboardResource);
+ focusResource = keyboardResource;
+ }
+}
+
+void QWaylandKeyboardPrivate::sendEnter(QWaylandSurface *surface, Resource *keyboardResource)
+{
+ uint32_t serial = compositor()->nextSerial();
+ send_modifiers(keyboardResource->handle, serial, modsDepressed, modsLatched, modsLocked, group);
+ send_enter(keyboardResource->handle, serial, surface->resource(), QByteArray::fromRawData((char *)keys.data(), keys.size() * sizeof(uint32_t)));
+}
+
+void QWaylandKeyboardPrivate::focused(QWaylandSurface *surface)
+{
+ if (surface && surface->isCursorSurface())
+ surface = Q_NULLPTR;
+ if (focus != surface) {
+ if (focusResource) {
+ uint32_t serial = compositor()->nextSerial();
+ send_leave(focusResource->handle, serial, focus->resource());
+ }
+ focusDestroyListener.reset();
+ if (surface)
+ focusDestroyListener.listenForDestruction(surface->resource());
+ }
+
+ Resource *resource = surface ? resourceMap().value(surface->waylandClient()) : 0;
+
+ if (resource && (focus != surface || focusResource != resource))
+ sendEnter(surface, resource);
+
+ focusResource = resource;
+ focus = surface;
+ Q_EMIT q_func()->focusChanged(focus);
+}
+
+
+void QWaylandKeyboardPrivate::keyboard_bind_resource(wl_keyboard::Resource *resource)
+{
+#ifndef QT_NO_WAYLAND_XKB
+ if (xkb_context) {
+ send_keymap(resource->handle, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
+ keymap_fd, keymap_size);
+ } else
+#endif
+ {
+ int null_fd = open("/dev/null", O_RDONLY);
+ send_keymap(resource->handle, 0 /* WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP */,
+ null_fd, 0);
+ close(null_fd);
+ }
+ checkFocusResource(resource);
+}
+
+void QWaylandKeyboardPrivate::keyboard_destroy_resource(wl_keyboard::Resource *resource)
+{
+ if (focusResource == resource)
+ focusResource = 0;
+}
+
+void QWaylandKeyboardPrivate::keyboard_release(wl_keyboard::Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandKeyboardPrivate::keyEvent(uint code, uint32_t state)
+{
+ uint key = code - 8;
+ if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
+ keys << key;
+ } else {
+ for (int i = 0; i < keys.size(); ++i) {
+ if (keys.at(i) == key) {
+ keys.remove(i);
+ }
+ }
+ }
+}
+
+void QWaylandKeyboardPrivate::sendKeyEvent(uint code, uint32_t state)
+{
+ uint32_t time = compositor()->currentTimeMsecs();
+ uint32_t serial = compositor()->nextSerial();
+ uint key = code - 8;
+ if (focusResource)
+ send_key(focusResource->handle, serial, time, key, state);
+}
+
+void QWaylandKeyboardPrivate::modifiers(uint32_t serial, uint32_t mods_depressed,
+ uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
+{
+ if (focusResource) {
+ send_modifiers(focusResource->handle, serial, mods_depressed, mods_latched, mods_locked, group);
+ }
+}
+
+void QWaylandKeyboardPrivate::updateModifierState(uint code, uint32_t state)
+{
+#ifndef QT_NO_WAYLAND_XKB
+ if (!xkb_context)
+ return;
+
+ xkb_state_update_key(xkb_state, code, state == WL_KEYBOARD_KEY_STATE_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP);
+
+ uint32_t modsDepressed = xkb_state_serialize_mods(xkb_state, (xkb_state_component)XKB_STATE_DEPRESSED);
+ uint32_t modsLatched = xkb_state_serialize_mods(xkb_state, (xkb_state_component)XKB_STATE_LATCHED);
+ uint32_t modsLocked = xkb_state_serialize_mods(xkb_state, (xkb_state_component)XKB_STATE_LOCKED);
+ uint32_t group = xkb_state_serialize_group(xkb_state, (xkb_state_component)XKB_STATE_EFFECTIVE);
+
+ if (this->modsDepressed == modsDepressed
+ && this->modsLatched == modsLatched
+ && this->modsLocked == modsLocked
+ && this->group == group)
+ return;
+
+ this->modsDepressed = modsDepressed;
+ this->modsLatched = modsLatched;
+ this->modsLocked = modsLocked;
+ this->group = group;
+
+ modifiers(compositor()->nextSerial(), modsDepressed, modsLatched, modsLocked, group);
+#else
+ Q_UNUSED(code);
+ Q_UNUSED(state);
+#endif
+}
+
+void QWaylandKeyboardPrivate::updateKeymap()
+{
+ // There must be no keys pressed when changing the keymap,
+ // see http://lists.freedesktop.org/archives/wayland-devel/2013-October/011395.html
+ if (!pendingKeymap || !keys.isEmpty())
+ return;
+
+ pendingKeymap = false;
+#ifndef QT_NO_WAYLAND_XKB
+ if (!xkb_context)
+ return;
+
+ createXKBKeymap();
+ foreach (Resource *res, resourceMap()) {
+ send_keymap(res->handle, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymap_fd, keymap_size);
+ }
+
+ xkb_state_update_mask(xkb_state, 0, modsLatched, modsLocked, 0, 0, 0);
+ if (focusResource)
+ send_modifiers(focusResource->handle,
+ compositor()->nextSerial(),
+ modsDepressed,
+ modsLatched,
+ modsLocked,
+ group);
+#endif
+}
+
+#ifndef QT_NO_WAYLAND_XKB
+static int createAnonymousFile(size_t size)
+{
+ QString path = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+ if (path.isEmpty())
+ return -1;
+
+ QByteArray name = QFile::encodeName(path + QStringLiteral("/qtwayland-XXXXXX"));
+
+ int fd = mkstemp(name.data());
+ if (fd < 0)
+ return -1;
+
+ long flags = fcntl(fd, F_GETFD);
+ if (flags == -1 || fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
+ close(fd);
+ fd = -1;
+ }
+ unlink(name.constData());
+
+ if (fd < 0)
+ return -1;
+
+ if (ftruncate(fd, size) < 0) {
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+}
+
+void QWaylandKeyboardPrivate::initXKB()
+{
+ xkb_context = xkb_context_new(static_cast<xkb_context_flags>(0));
+ if (!xkb_context) {
+ qWarning("Failed to create a XKB context: keymap will not be supported");
+ return;
+ }
+
+ createXKBKeymap();
+}
+
+
+void QWaylandKeyboardPrivate::createXKBState(xkb_keymap *keymap)
+{
+ char *keymap_str = xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1);
+ if (!keymap_str) {
+ qWarning("Failed to compile global XKB keymap");
+ return;
+ }
+
+ keymap_size = strlen(keymap_str) + 1;
+ if (keymap_fd >= 0)
+ close(keymap_fd);
+ keymap_fd = createAnonymousFile(keymap_size);
+ if (keymap_fd < 0) {
+ qWarning("Failed to create anonymous file of size %lu", static_cast<unsigned long>(keymap_size));
+ return;
+ }
+
+ keymap_area = static_cast<char *>(mmap(0, keymap_size, PROT_READ | PROT_WRITE, MAP_SHARED, keymap_fd, 0));
+ if (keymap_area == MAP_FAILED) {
+ close(keymap_fd);
+ keymap_fd = -1;
+ qWarning("Failed to map shared memory segment");
+ return;
+ }
+
+ strcpy(keymap_area, keymap_str);
+ free(keymap_str);
+
+ if (xkb_state)
+ xkb_state_unref(xkb_state);
+ xkb_state = xkb_state_new(keymap);
+}
+
+void QWaylandKeyboardPrivate::createXKBKeymap()
+{
+ if (!xkb_context)
+ return;
+
+ struct xkb_rule_names rule_names = { strdup(qPrintable(keymap.rules())),
+ strdup(qPrintable(keymap.model())),
+ strdup(qPrintable(keymap.layout())),
+ strdup(qPrintable(keymap.variant())),
+ strdup(qPrintable(keymap.options())) };
+ struct xkb_keymap *keymap = xkb_keymap_new_from_names(xkb_context, &rule_names, static_cast<xkb_keymap_compile_flags>(0));
+
+ if (keymap) {
+ createXKBState(keymap);
+ xkb_keymap_unref(keymap);
+ } else {
+ qWarning("Failed to load the '%s' XKB keymap.", qPrintable(this->keymap.layout()));
+ }
+
+ free((char *)rule_names.rules);
+ free((char *)rule_names.model);
+ free((char *)rule_names.layout);
+ free((char *)rule_names.variant);
+ free((char *)rule_names.options);
+}
+#endif
+
+/*!
+ * \class QWaylandKeyboard
+ * \inmodule QtWaylandCompositor
+ * \brief The QWaylandKeyboard class provides access to a keyboard device.
+ *
+ * This class provides access to the keyboard device in a QWaylandInputDevice. It corresponds to
+ * the Wayland interface wl_keyboard.
+ */
+
+/*!
+ * Constructs a QWaylandKeyboard for the given \a inputDevice and with the given \a parent.
+ */
+QWaylandKeyboard::QWaylandKeyboard(QWaylandInputDevice *inputDevice, QObject *parent)
+ : QWaylandObject(* new QWaylandKeyboardPrivate(inputDevice), parent)
+{
+ Q_D(QWaylandKeyboard);
+ connect(&d->focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandKeyboard::focusDestroyed);
+}
+
+/*!
+ * Returns the input device for this QWaylandKeyboard.
+ */
+QWaylandInputDevice *QWaylandKeyboard::inputDevice() const
+{
+ Q_D(const QWaylandKeyboard);
+ return d->seat;
+}
+
+/*!
+ * Returns the compositor for this QWaylandKeyboard.
+ */
+QWaylandCompositor *QWaylandKeyboard::compositor() const
+{
+ Q_D(const QWaylandKeyboard);
+ return d->seat->compositor();
+}
+
+/*!
+ * \internal
+ */
+void QWaylandKeyboard::focusDestroyed(void *data)
+{
+ Q_UNUSED(data);
+ Q_D(QWaylandKeyboard);
+ d->focusDestroyListener.reset();
+
+ d->focus = 0;
+ d->focusResource = 0;
+}
+
+/*!
+ * Returns the client that currently has keyboard focus.
+ */
+QWaylandClient *QWaylandKeyboard::focusClient() const
+{
+ Q_D(const QWaylandKeyboard);
+ if (!d->focusResource)
+ return Q_NULLPTR;
+ return QWaylandClient::fromWlClient(compositor(), d->focusResource->client());
+}
+
+/*!
+ * Sends the current key modifiers to \a client with the given \a serial.
+ */
+void QWaylandKeyboard::sendKeyModifiers(QWaylandClient *client, uint serial)
+{
+ Q_D(QWaylandKeyboard);
+ QtWaylandServer::wl_keyboard::Resource *resource = d->resourceMap().value(client->client());
+ if (resource)
+ d->send_modifiers(resource->handle, serial, d->modsDepressed, d->modsLatched, d->modsLocked, d->group);
+}
+
+/*!
+ * Sends a key press event with the key \a code to the current keyboard focus.
+ */
+void QWaylandKeyboard::sendKeyPressEvent(uint code)
+{
+ Q_D(QWaylandKeyboard);
+ d->sendKeyEvent(code, WL_KEYBOARD_KEY_STATE_PRESSED);
+}
+
+/*!
+ * Sends a key release event with the key \a code to the current keyboard focus.
+ */
+void QWaylandKeyboard::sendKeyReleaseEvent(uint code)
+{
+ Q_D(QWaylandKeyboard);
+ d->sendKeyEvent(code, WL_KEYBOARD_KEY_STATE_RELEASED);
+}
+
+/*!
+ * Returns the current repeat rate.
+ */
+quint32 QWaylandKeyboard::repeatRate() const
+{
+ Q_D(const QWaylandKeyboard);
+ return d->repeatRate;
+}
+
+/*!
+ * Sets the repeat rate to \a rate.
+ */
+void QWaylandKeyboard::setRepeatRate(quint32 rate)
+{
+ Q_D(QWaylandKeyboard);
+
+ if (d->repeatRate == rate)
+ return;
+
+ // TODO: As of today 2015-11-25, we don't support Wayland 1.6
+ // because of CI limitations. Once the protocol is updated
+ // we can send keyboard repeat information to the client as
+ // per wl_seat version 4
+
+ qWarning("Setting QWaylandKeyboard::repeatRate has no effect until QtWaylandCompositor support wl_seat 4");
+
+ d->repeatRate = rate;
+ Q_EMIT repeatRateChanged(rate);
+}
+
+/*!
+ * Returns the current repeat delay.
+ */
+quint32 QWaylandKeyboard::repeatDelay() const
+{
+ Q_D(const QWaylandKeyboard);
+ return d->repeatDelay;
+}
+
+/*!
+ * Sets the repeat delay to \a delay.
+ */
+void QWaylandKeyboard::setRepeatDelay(quint32 delay)
+{
+ Q_D(QWaylandKeyboard);
+
+ if (d->repeatDelay == delay)
+ return;
+
+ // TODO: As of today 2015-11-25, we don't support Wayland 1.6
+ // because of CI limitations. Once the protocol is updated
+ // we can send keyboard repeat information to the client as
+ // per wl_seat version 4
+
+ qWarning("Setting QWaylandKeyboard::repeatDelay has no effect until QtWaylandCompositor support wl_seat 4");
+
+ d->repeatDelay = delay;
+ Q_EMIT repeatDelayChanged(delay);
+}
+
+/*!
+ * Returns the currently focused surface.
+ */
+QWaylandSurface *QWaylandKeyboard::focus() const
+{
+ Q_D(const QWaylandKeyboard);
+ return d->focus;
+}
+
+/*!
+ * Sets the current focus to \a surface.
+ */
+bool QWaylandKeyboard::setFocus(QWaylandSurface *surface)
+{
+ Q_D(QWaylandKeyboard);
+ QWaylandShellSurface *shellsurface = QWaylandShellSurface::findIn(surface);
+ if (shellsurface && shellsurface->focusPolicy() == QWaylandShellSurface::NoKeyboardFocus)
+ return false;
+ d->focused(surface);
+ return true;
+}
+
+/*!
+ * Sets the keyboard's keymap to \a keymap.
+ */
+void QWaylandKeyboard::setKeymap(const QWaylandKeymap &keymap)
+{
+ Q_D(QWaylandKeyboard);
+ d->keymap = keymap;
+ d->pendingKeymap = true;
+
+ // If there is no key currently pressed, update right away the keymap
+ // Otherwise, delay the update when keys are released
+ // see http://lists.freedesktop.org/archives/wayland-devel/2013-October/011395.html
+ if (d->keys.isEmpty()) {
+ d->updateKeymap();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandKeyboard::addClient(QWaylandClient *client, uint32_t id, uint32_t version)
+{
+ Q_D(QWaylandKeyboard);
+ d->add(client->client(), id, qMin<uint32_t>(QtWaylandServer::wl_keyboard::interfaceVersion(), version));
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h
new file mode 100644
index 00000000..3b2282ae
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandkeyboard.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDKEYBOARD_H
+#define QWAYLANDKEYBOARD_H
+
+#include <QtCore/QObject>
+
+#include <QtWaylandCompositor/QWaylandExtension>
+#include <QtWaylandCompositor/QWaylandSurface>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandKeyboard;
+class QWaylandKeyboardPrivate;
+class QWaylandInputDevice;
+
+class Q_COMPOSITOR_EXPORT QWaylandKeymap
+{
+public:
+ QWaylandKeymap(const QString &layout = QString(), const QString &variant = QString(), const QString &options = QString(),
+ const QString &model = QString(), const QString &rules = QString());
+
+ inline QString layout() const { return m_layout; }
+ inline QString variant() const { return m_variant; }
+ inline QString options() const { return m_options; }
+ inline QString rules() const { return m_rules; }
+ inline QString model() const { return m_model; }
+
+private:
+ QString m_layout;
+ QString m_variant;
+ QString m_options;
+ QString m_rules;
+ QString m_model;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandKeyboard : public QWaylandObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandKeyboard)
+ Q_PROPERTY(quint32 repeatRate READ repeatRate WRITE setRepeatRate NOTIFY repeatRateChanged)
+ Q_PROPERTY(quint32 repeatDelay READ repeatDelay WRITE setRepeatDelay NOTIFY repeatDelayChanged)
+public:
+ QWaylandKeyboard(QWaylandInputDevice *inputDevice, QObject *parent = 0);
+
+ QWaylandInputDevice *inputDevice() const;
+ QWaylandCompositor *compositor() const;
+
+ quint32 repeatRate() const;
+ void setRepeatRate(quint32 rate);
+
+ quint32 repeatDelay() const;
+ void setRepeatDelay(quint32 delay);
+
+ virtual bool setFocus(QWaylandSurface *surface);
+ virtual void setKeymap(const QWaylandKeymap &keymap);
+
+ virtual void sendKeyModifiers(QWaylandClient *client, uint32_t serial);
+ virtual void sendKeyPressEvent(uint code);
+ virtual void sendKeyReleaseEvent(uint code);
+
+ QWaylandSurface *focus() const;
+ QWaylandClient *focusClient() const;
+
+ virtual void addClient(QWaylandClient *client, uint32_t id, uint32_t version);
+
+Q_SIGNALS:
+ void focusChanged(QWaylandSurface *surface);
+ void repeatRateChanged(quint32 repeatRate);
+ void repeatDelayChanged(quint32 repeatDelay);
+
+private:
+ void focusDestroyed(void *data);
+};
+
+QT_END_NAMESPACE
+
+#endif //QWAYLANDKEYBOARD_H
diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h
new file mode 100644
index 00000000..86e3e365
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTWAYLAND_QWLKEYBOARD_P_H
+#define QTWAYLAND_QWLKEYBOARD_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandinput.h>
+#include <QtWaylandCompositor/qwaylandkeyboard.h>
+#include <QtWaylandCompositor/qwaylanddestroylistener.h>
+
+#include <QtCore/private/qobject_p.h>
+#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
+
+#include <QtCore/QVector>
+
+#ifndef QT_NO_WAYLAND_XKB
+#include <xkbcommon/xkbcommon.h>
+#endif
+
+
+QT_BEGIN_NAMESPACE
+
+class Q_COMPOSITOR_EXPORT QWaylandKeyboardPrivate : public QObjectPrivate
+ , public QtWaylandServer::wl_keyboard
+{
+public:
+ Q_DECLARE_PUBLIC(QWaylandKeyboard)
+
+ static QWaylandKeyboardPrivate *get(QWaylandKeyboard *keyboard);
+
+ QWaylandKeyboardPrivate(QWaylandInputDevice *seat);
+ ~QWaylandKeyboardPrivate();
+
+ QWaylandCompositor *compositor() const { return seat->compositor(); }
+
+ void focused(QWaylandSurface* surface);
+ void modifiers(uint32_t serial, uint32_t mods_depressed,
+ uint32_t mods_latched, uint32_t mods_locked, uint32_t group);
+
+#ifndef QT_NO_WAYLAND_XKB
+ struct xkb_state *xkbState() const { return xkb_state; }
+ uint32_t xkbModsMask() const { return modsDepressed | modsLatched | modsLocked; }
+#endif
+
+ void keyEvent(uint code, uint32_t state);
+ void sendKeyEvent(uint code, uint32_t state);
+ void updateModifierState(uint code, uint32_t state);
+ void updateKeymap();
+
+ void checkFocusResource(Resource *resource);
+ void sendEnter(QWaylandSurface *surface, Resource *resource);
+
+protected:
+ void keyboard_bind_resource(Resource *resource);
+ void keyboard_destroy_resource(Resource *resource);
+ void keyboard_release(Resource *resource) Q_DECL_OVERRIDE;
+
+private:
+#ifndef QT_NO_WAYLAND_XKB
+ void initXKB();
+ void createXKBKeymap();
+ void createXKBState(xkb_keymap *keymap);
+#endif
+
+ QWaylandInputDevice *seat;
+
+ QWaylandSurface *focus;
+ Resource *focusResource;
+ QWaylandDestroyListener focusDestroyListener;
+
+ QVector<uint32_t> keys;
+ uint32_t modsDepressed;
+ uint32_t modsLatched;
+ uint32_t modsLocked;
+ uint32_t group;
+
+ QWaylandKeymap keymap;
+ bool pendingKeymap;
+#ifndef QT_NO_WAYLAND_XKB
+ size_t keymap_size;
+ int keymap_fd;
+ char *keymap_area;
+ struct xkb_context *xkb_context;
+ struct xkb_state *xkb_state;
+#endif
+
+ quint32 repeatRate;
+ quint32 repeatDelay;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTWAYLAND_QWLKEYBOARD_P_H
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index ba9f3988..b3c94645 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -4,254 +4,893 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "qwaylandoutput.h"
+#include "qwaylandoutput_p.h"
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandView>
+
+#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
+#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
+
#include <QtCore/QCoreApplication>
#include <QtCore/QtMath>
#include <QtGui/QWindow>
#include <QtGui/QExposeEvent>
#include <private/qobject_p.h>
-#include "wayland_wrapper/qwlcompositor_p.h"
-#include "wayland_wrapper/qwloutput_p.h"
-#include "qwaylandcompositor.h"
-#include "qwaylandoutput.h"
-#include "qwaylandsurface.h"
+QT_BEGIN_NAMESPACE
-QWaylandOutput::QWaylandOutput(QWaylandCompositor *compositor, QWindow *window,
- const QString &manufacturer, const QString &model)
- : QObject()
- , d_ptr(new QtWayland::Output(compositor->handle(), window))
+static QtWaylandServer::wl_output::subpixel toWlSubpixel(const QWaylandOutput::Subpixel &value)
{
- d_ptr->m_output = this;
- d_ptr->setManufacturer(manufacturer);
- d_ptr->setModel(model);
- d_ptr->compositor()->addOutput(this);
+ switch (value) {
+ case QWaylandOutput::SubpixelUnknown:
+ return QtWaylandServer::wl_output::subpixel_unknown;
+ case QWaylandOutput::SubpixelNone:
+ return QtWaylandServer::wl_output::subpixel_none;
+ case QWaylandOutput::SubpixelHorizontalRgb:
+ return QtWaylandServer::wl_output::subpixel_horizontal_rgb;
+ case QWaylandOutput::SubpixelHorizontalBgr:
+ return QtWaylandServer::wl_output::subpixel_horizontal_bgr;
+ case QWaylandOutput::SubpixelVerticalRgb:
+ return QtWaylandServer::wl_output::subpixel_vertical_rgb;
+ case QWaylandOutput::SubpixelVerticalBgr:
+ return QtWaylandServer::wl_output::subpixel_vertical_bgr;
+ default:
+ break;
+ }
+
+ return QtWaylandServer::wl_output::subpixel_unknown;
+}
+
+static QtWaylandServer::wl_output::transform toWlTransform(const QWaylandOutput::Transform &value)
+{
+ switch (value) {
+ case QWaylandOutput::Transform90:
+ return QtWaylandServer::wl_output::transform_90;
+ case QWaylandOutput::Transform180:
+ return QtWaylandServer::wl_output::transform_180;
+ case QWaylandOutput::Transform270:
+ return QtWaylandServer::wl_output::transform_270;
+ case QWaylandOutput::TransformFlipped:
+ return QtWaylandServer::wl_output::transform_flipped;
+ case QWaylandOutput::TransformFlipped90:
+ return QtWaylandServer::wl_output::transform_flipped_90;
+ case QWaylandOutput::TransformFlipped180:
+ return QtWaylandServer::wl_output::transform_flipped_180;
+ case QWaylandOutput::TransformFlipped270:
+ return QtWaylandServer::wl_output::transform_flipped_270;
+ default:
+ break;
+ }
+
+ return QtWaylandServer::wl_output::transform_normal;
+}
+
+QWaylandOutputPrivate::QWaylandOutputPrivate()
+ : QtWaylandServer::wl_output()
+ , compositor(Q_NULLPTR)
+ , window(Q_NULLPTR)
+ , subpixel(QWaylandOutput::SubpixelUnknown)
+ , transform(QWaylandOutput::TransformNormal)
+ , scaleFactor(1)
+ , sizeFollowsWindow(true)
+ , initialized(false)
+{
+ mode.size = QSize();
+ mode.refreshRate = 60;
+
+ qRegisterMetaType<QWaylandOutput::Mode>("WaylandOutput::Mode");
}
+QWaylandOutputPrivate::~QWaylandOutputPrivate()
+{
+}
+
+void QWaylandOutputPrivate::output_bind_resource(Resource *resource)
+{
+ send_geometry(resource->handle,
+ position.x(), position.y(),
+ physicalSize.width(), physicalSize.height(),
+ toWlSubpixel(subpixel), manufacturer, model,
+ toWlTransform(transform));
+
+ send_mode(resource->handle, mode_current | mode_preferred,
+ mode.size.width(), mode.size.height(),
+ mode.refreshRate);
+
+ if (resource->version() >= 2) {
+ send_scale(resource->handle, scaleFactor);
+ send_done(resource->handle);
+ }
+}
+
+void QWaylandOutputPrivate::sendGeometryInfo()
+{
+ Q_FOREACH (Resource *resource, resourceMap().values()) {
+ send_geometry(resource->handle,
+ position.x(), position.x(),
+ physicalSize.width(), physicalSize.height(),
+ toWlSubpixel(subpixel), manufacturer, model,
+ toWlTransform(transform));
+ if (resource->version() >= 2)
+ send_done(resource->handle);
+ }
+}
+
+
+void QWaylandOutputPrivate::addView(QWaylandView *view, QWaylandSurface *surface)
+{
+ for (int i = 0; i < surfaceViews.size(); i++) {
+ if (surface == surfaceViews.at(i).surface) {
+ if (!surfaceViews.at(i).views.contains(view)) {
+ surfaceViews[i].views.append(view);
+ }
+ return;
+ }
+ }
+
+ surfaceViews.append(QWaylandSurfaceViewMapper(surface,view));
+}
+
+void QWaylandOutputPrivate::removeView(QWaylandView *view, QWaylandSurface *surface)
+{
+ Q_Q(QWaylandOutput);
+ for (int i = 0; i < surfaceViews.size(); i++) {
+ if (surface == surfaceViews.at(i).surface) {
+ bool removed = surfaceViews[i].views.removeOne(view);
+ if (surfaceViews.at(i).views.isEmpty() && removed) {
+ if (surfaceViews.at(i).has_entered)
+ q->surfaceLeave(surface);
+ surfaceViews.remove(i);
+ }
+ return;
+ }
+ }
+ qWarning("%s Could not find view %p for surface %p to remove. Possible invalid state", Q_FUNC_INFO, view, surface);
+}
+
+QWaylandOutput::QWaylandOutput()
+ : QWaylandObject(*new QWaylandOutputPrivate())
+{
+}
+
+/*!
+ \qmltype WaylandOutput
+ \inqmlmodule QtWayland.Compositor
+ \brief Type providing access to a displayable area managed by the compositor.
+
+ The WaylandOutput manages a rectangular part of the compositor's geometry that
+ can be used for displaying client content. This could, for instance, be a screen
+ managed by the WaylandCompositor.
+
+ The type corresponds to the wl_output interface in the Wayland protocol.
+*/
+
+/*!
+ \class QWaylandOutput
+ \inmodule QtWaylandCompositor
+ \brief The QWaylandOutput class provides access to a displayable area managed by the compositor.
+
+ The QWaylandOutput manages a rectangular part of the compositor's geometry that
+ can be used for displaying client content. This could, for instance, be a screen
+ managed by the QWaylandCompositor.
+
+ The class corresponds to the wl_output interface in the Wayland protocol.
+*/
+
+/*!
+ * Constructs a QWaylandOutput in \a compositor and with the specified \a window. The
+ * \l{QWaylandCompositor::create()}{create()} function must have been called on the
+ * \a compositor before a QWaylandOutput is constructed for it.
+ *
+ * The QWaylandOutput object is initialized later, in reaction to an event.
+ * At this point it is added as an output for the \a compositor. If it is the
+ * first QWaylandOutput object created for this \a compositor, it becomes the
+ * \l{QWaylandCompositor::defaultOutput()}{default output}.
+ */
+QWaylandOutput::QWaylandOutput(QWaylandCompositor *compositor, QWindow *window)
+ : QWaylandObject(*new QWaylandOutputPrivate())
+{
+ Q_D(QWaylandOutput);
+ d->compositor = compositor;
+ d->window = window;
+ QWaylandCompositorPrivate::get(compositor)->addPolishObject(this);
+}
+
+/*!
+ * Destroys the QWaylandOutput.
+ */
QWaylandOutput::~QWaylandOutput()
{
- d_ptr->compositor()->removeOutput(this);
- delete d_ptr;
+ Q_D(QWaylandOutput);
+ if (d->compositor)
+ QWaylandCompositorPrivate::get(d->compositor)->removeOutput(this);
+}
+
+/*!
+ * \internal
+ */
+void QWaylandOutput::initialize()
+{
+ Q_D(QWaylandOutput);
+
+ Q_ASSERT(!d->initialized);
+ Q_ASSERT(d->compositor);
+ Q_ASSERT(d->compositor->isCreated());
+ Q_ASSERT(d->window);
+
+ d->mode.size = d->window->size();
+
+ QWaylandCompositorPrivate::get(d->compositor)->addOutput(this);
+
+ QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::setWidth);
+ QObject::connect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::setHeight);
+ QObject::connect(d->window, &QObject::destroyed, this, &QWaylandOutput::handleWindowDestroyed);
+
+ d->init(d->compositor->display(), 2);
+
+ d->initialized = true;
}
+/*!
+ * Returns the QWaylandOutput corresponding to \a resource.
+ */
QWaylandOutput *QWaylandOutput::fromResource(wl_resource *resource)
{
- QtWayland::OutputResource *outputResource = static_cast<QtWayland::OutputResource *>(
- QtWayland::Output::Resource::fromResource(resource));
- if (!outputResource)
- return Q_NULLPTR;
+ return static_cast<QWaylandOutputPrivate *>(QWaylandOutputPrivate::Resource::fromResource(resource)->output_object)->q_func();
+}
- QtWayland::Output *output = static_cast<QtWayland::Output *>(outputResource->output_object);
- if (!output)
- return Q_NULLPTR;
+/*!
+ * \internal
+ */
+struct ::wl_resource *QWaylandOutput::resourceForClient(QWaylandClient *client) const
+{
+ Q_D(const QWaylandOutput);
+ QWaylandOutputPrivate::Resource *r = d->resourceMap().value(client->client());
+ if (r)
+ return r->handle;
- return output->output();
+ return Q_NULLPTR;
}
+/*!
+ * Schedules a QEvent::UpdateRequest to be delivered to the QWaylandOutput's \l{window()}{window}.
+ *
+ * \sa QWindow::requestUpdate()
+ */
void QWaylandOutput::update()
{
- QRect rect(QPoint(0, 0), window()->size());
- QRegion region(rect);
- QExposeEvent *event = new QExposeEvent(region);
- QCoreApplication::postEvent(window(), event);
+ Q_D(QWaylandOutput);
+ if (!d->window)
+ return;
+ d->window->requestUpdate();
}
+/*!
+ * \qmlproperty object QtWaylandCompositor::WaylandOutput::compositor
+ *
+ * This property holds the compositor displaying content on this QWaylandOutput.
+ * This property can only be set once, before the WaylandOutput component is completed.
+ */
+
+/*!
+ * Returns the compositor for this QWaylandOutput.
+ */
QWaylandCompositor *QWaylandOutput::compositor() const
{
- return d_ptr->compositor()->waylandCompositor();
+ return d_func()->compositor;
+}
+
+/*!
+ * \internal
+ */
+void QWaylandOutput::setCompositor(QWaylandCompositor *compositor)
+{
+ Q_D(QWaylandOutput);
+
+ if (d->compositor == compositor)
+ return;
+
+ if (d->initialized) {
+ qWarning("Setting QWaylandCompositor %p on QWaylandOutput %p is not supported after QWaylandOutput has been initialized\n", compositor, this);
+ return;
+ }
+ if (d->compositor && d->compositor != compositor) {
+ qWarning("Possible initialization error. Moving QWaylandOutput %p between compositor instances.\n", this);
+ }
+
+ d->compositor = compositor;
+
+ QWaylandCompositorPrivate::get(compositor)->addPolishObject(this);
}
+/*!
+ * \qmlproperty string QtWaylandCompositor::WaylandOutput::manufacturer
+ *
+ * This property holds a textual description of the manufacturer of this WaylandOutput.
+ */
+
+/*!
+ * \property QWaylandOutput::manufacturer
+ *
+ * This property holds a textual description of the manufacturer of this QWaylandOutput.
+ */
QString QWaylandOutput::manufacturer() const
{
- return d_ptr->manufacturer();
+ return d_func()->manufacturer;
}
+void QWaylandOutput::setManufacturer(const QString &manufacturer)
+{
+ d_func()->manufacturer = manufacturer;
+}
+
+/*!
+ * \qmlproperty string QtWaylandCompositor::WaylandOutput::model
+ *
+ * This property holds a textual description of the model of this WaylandOutput.
+ */
+
+/*!
+ * \property QWaylandOutput::model
+ *
+ * This property holds a textual description of the model of this QWaylandOutput.
+ */
QString QWaylandOutput::model() const
{
- return d_ptr->model();
+ return d_func()->model;
+}
+
+void QWaylandOutput::setModel(const QString &model)
+{
+ d_func()->model = model;
}
+/*!
+ * \qmlproperty point QtWaylandCompositor::WaylandOutput::position
+ *
+ * This property holds the position of this WaylandOutput in the compositor's coordinate system.
+ */
+
+/*!
+ * \property QWaylandOutput::position
+ *
+ * This property holds the position of this QWaylandOutput in the compositor's coordinate system.
+ */
QPoint QWaylandOutput::position() const
{
- return d_ptr->position();
+ return d_func()->position;
}
void QWaylandOutput::setPosition(const QPoint &pt)
{
- if (d_ptr->position() == pt)
+ Q_D(QWaylandOutput);
+ if (d->position == pt)
return;
- d_ptr->setPosition(pt);
+ d->position = pt;
+
+ d->sendGeometryInfo();
+
Q_EMIT positionChanged();
Q_EMIT geometryChanged();
}
+/*!
+ * \property QWaylandOutput::mode
+ *
+ * This property holds the output's size in pixels and refresh rate in Hz.
+ */
QWaylandOutput::Mode QWaylandOutput::mode() const
{
- return d_ptr->mode();
+ return d_func()->mode;
}
void QWaylandOutput::setMode(const Mode &mode)
{
- if (d_ptr->mode().size == mode.size && d_ptr->mode().refreshRate == mode.refreshRate)
+ Q_D(QWaylandOutput);
+ if (d->mode.size == mode.size && d->mode.refreshRate == mode.refreshRate)
return;
- d_ptr->setMode(mode);
+ d->mode = mode;
+
+ Q_FOREACH (QWaylandOutputPrivate::Resource *resource, d->resourceMap().values()) {
+ d->send_mode(resource->handle, d->mode_current,
+ d->mode.size.width(), d->mode.size.height(),
+ d->mode.refreshRate * 1000);
+ if (resource->version() >= 2)
+ d->send_done(resource->handle);
+ }
+
Q_EMIT modeChanged();
Q_EMIT geometryChanged();
- if (window()) {
- window()->resize(mode.size);
- window()->setMinimumSize(mode.size);
- window()->setMaximumSize(mode.size);
+ if (d->window) {
+ d->window->resize(mode.size);
+ d->window->setMinimumSize(mode.size);
+ d->window->setMaximumSize(mode.size);
}
}
+/*!
+ * \qmlproperty rect QtWaylandCompositor::WaylandOutput::geometry
+ *
+ * This property holds the geometry of the WaylandOutput.
+ */
+
+/*!
+ * \property QWaylandOutput::geometry
+ *
+ * This property holds the geometry of the QWaylandOutput.
+ *
+ * \sa QWaylandOutput::mode
+ */
QRect QWaylandOutput::geometry() const
{
- return d_ptr->geometry();
+ Q_D(const QWaylandOutput);
+ return QRect(d->position, d->mode.size);
}
void QWaylandOutput::setGeometry(const QRect &geometry)
{
- if (d_ptr->geometry() == geometry)
+ Q_D(QWaylandOutput);
+ if (d->position == geometry.topLeft() && d->mode.size == geometry.size())
return;
- d_ptr->setGeometry(geometry);
+ d->position = geometry.topLeft();
+ d->mode.size = geometry.size();
+
+ Q_FOREACH (QWaylandOutputPrivate::Resource *resource, d->resourceMap().values()) {
+ d->send_geometry(resource->handle,
+ d->position.x(), d->position.y(),
+ d->physicalSize.width(), d->physicalSize.height(),
+ toWlSubpixel(d->subpixel), d->manufacturer, d->model,
+ toWlTransform(d->transform));
+ d->send_mode(resource->handle, d->mode_current,
+ d->mode.size.width(), d->mode.size.height(),
+ d->mode.refreshRate * 1000);
+ if (resource->version() >= 2)
+ d->send_done(resource->handle);
+ }
Q_EMIT positionChanged();
Q_EMIT modeChanged();
-
- if (window()) {
- window()->resize(geometry.size());
- window()->setMinimumSize(geometry.size());
- window()->setMaximumSize(geometry.size());
- }
}
+/*!
+ * \qmlproperty rect QtWaylandCompositor::WaylandOutput::availableGeometry
+ *
+ * This property holds the geometry of the WaylandOutput available for displaying content.
+ *
+ * \sa QWaylandOutput::geometry
+ */
+
+/*!
+ * \property QWaylandOutput::availableGeometry
+ *
+ * This property holds the geometry of the QWaylandOutput available for displaying content.
+ *
+ * \sa QWaylandOutput::mode, QWaylandOutput::geometry
+ */
QRect QWaylandOutput::availableGeometry() const
{
- if (!d_ptr->availableGeometry().isValid())
- return QRect(d_ptr->position(), d_ptr->mode().size);
+ Q_D(const QWaylandOutput);
+ if (!d->availableGeometry.isValid())
+ return QRect(d->position, d->mode.size);
- return d_ptr->availableGeometry();
+ return d->availableGeometry;
}
void QWaylandOutput::setAvailableGeometry(const QRect &availableGeometry)
{
- if (d_ptr->availableGeometry() == availableGeometry)
+ Q_D(QWaylandOutput);
+ if (d->availableGeometry == availableGeometry)
return;
- d_ptr->setAvailableGeometry(availableGeometry);
+ d->availableGeometry = availableGeometry;
+
Q_EMIT availableGeometryChanged();
}
+/*!
+ * \qmlproperty size QtWaylandCompositor::WaylandOutput::physicalSize
+ *
+ * This property holds the physical size of the WaylandOutput in millimeters.
+ *
+ * \sa QWaylandOutput::geometry
+ */
+
+/*!
+ * \property QWaylandOutput::physicalSize
+ *
+ * This property holds the physical size of the QWaylandOutput in millimeters.
+ *
+ * \sa QWaylandOutput::geometry, QWaylandOutput::mode
+ */
QSize QWaylandOutput::physicalSize() const
{
- return d_ptr->physicalSize();
+ return d_func()->physicalSize;
}
void QWaylandOutput::setPhysicalSize(const QSize &size)
{
- if (d_ptr->physicalSize() == size)
+ Q_D(QWaylandOutput);
+ if (d->physicalSize == size)
return;
- d_ptr->setPhysicalSize(size);
+ d->physicalSize = size;
+
+ d->sendGeometryInfo();
+
Q_EMIT physicalSizeChanged();
}
+/*!
+ * \enum QWaylandOutput::Subpixel
+ *
+ * This enum type is used to specify the subpixel arrangement of a QWaylandOutput.
+ *
+ * \value SubpixelUnknown The subpixel arrangement is not set.
+ * \value SubpixelNone There are no subpixels.
+ * \value SubpixelHorizontalRgb The subpixels are arranged horizontally in red, green, blue order.
+ * \value SubpixelHorizontalBgr The subpixels are arranged horizontally in blue, green, red order.
+ * \value SubpixelVerticalRgb The subpixels are arranged vertically in red, green, blue order.
+ * \value SubpixelVerticalBgr The subpixels are arranged vertically in blue, green, red order.
+ *
+ * \sa QWaylandOutput::subpixel
+ */
+
+/*!
+ * \qmlproperty enum QtWaylandCompositor::WaylandOutput::subpixel
+ *
+ * This property holds the subpixel arrangement of this WaylandOutput.
+ *
+ * \list
+ * \li WaylandOutput.SubpixelUnknown The subpixel arrangement is not set.
+ * \li WaylandOutput.SubpixelNone There are no subpixels.
+ * \li WaylandOutput.SubpixelHorizontalRgb The subpixels are arranged horizontally in red, green, blue order.
+ * \li WaylandOutput.SubpixelHorizontalBgr The subpixels are arranged horizontally in blue, green, red order.
+ * \li WaylandOutput.SubpixelVerticalRgb The subpixels are arranged vertically in red, green, blue order.
+ * \li WaylandOutput.SubpixelVerticalBgr The subpixels are arranged vertically in blue, green, red order.
+ * \endlist
+ *
+ * The default is WaylandOutput.SubpixelUnknown.
+ */
+
+/*!
+ * \property QWaylandOutput::subpixel
+ *
+ * This property holds the subpixel arrangement of this QWaylandOutput. The default is
+ * QWaylandOutput::SubpixelUnknown.
+ */
QWaylandOutput::Subpixel QWaylandOutput::subpixel() const
{
- return d_ptr->subpixel();
+ return d_func()->subpixel;
}
void QWaylandOutput::setSubpixel(const Subpixel &subpixel)
{
- if (d_ptr->subpixel() == subpixel)
+ Q_D(QWaylandOutput);
+ if (d->subpixel == subpixel)
return;
- d_ptr->setSubpixel(subpixel);
+ d->subpixel = subpixel;
+
+ d->sendGeometryInfo();
+
Q_EMIT subpixelChanged();
}
+/*! \enum QWaylandOutput::Transform
+ *
+ * This enum type is used to specify the orientation of a QWaylandOutput.
+ *
+ * \value TransformNormal The QWaylandOutput orientation is normal.
+ * \value Transform90 The QWaylandOutput is rotated 90 degrees.
+ * \value Transform180 The QWaylandOutput is rotated 180 degrees.
+ * \value Transform270 The QWaylandOutput is rotated 270 degrees.
+ * \value TransformFlipped The QWaylandOutput is mirrored.
+ * \value TransformFlipped90 The QWaylandOutput is mirrored, and rotated 90 degrees.
+ * \value TransformFlipped180 The QWaylandOutput is mirrored, and rotated 180 degrees.
+ * \value TransformFlipped270 The QWaylandOutput is mirrored, and rotated 270 degrees.
+ *
+ * \sa QWaylandOutput::transform
+*/
+
+/*!
+ * \qmlproperty enum QtWaylandCompositor::WaylandOutput::transform
+ *
+ * This property holds the transformation that the QWaylandCompositor applies to a surface
+ * to compensate for the orientation of the QWaylandOutput.
+ *
+ * \list
+ * \li WaylandOutput.TransformNormal The QWaylandOutput orientation is normal.
+ * \li WaylandOutput.Transform90 The QWaylandOutput is rotated 90 degrees.
+ * \li WaylandOutput.Transform180 The QWaylandOutput is rotated 180 degrees.
+ * \li WaylandOutput.Transform270 The QWaylandOutput is rotated 270 degrees.
+ * \li WaylandOutput.TransformFlipped The QWaylandOutput is mirrored.
+ * \li WaylandOutput.TransformFlipped90 The QWaylandOutput is mirrored, then rotated 90 degrees.
+ * \li WaylandOutput.TransformFlipped180 The QWaylandOutput is mirrored, then rotated 180 degrees.
+ * \li WaylandOutput.TransformFlipped270 The QWaylandOutput is mirrored, then rotated 270 degrees.
+ * \endlist
+ *
+ * The default is WaylandOutput.TransformNormal.
+ */
+
+/*!
+ * \property QWaylandOutput::transform
+ *
+ * This property holds the transformation that the QWaylandCompositor applies to a surface
+ * to compensate for the orientation of the QWaylandOutput.
+ *
+ * The default is QWaylandOutput::TransformNormal.
+ */
QWaylandOutput::Transform QWaylandOutput::transform() const
{
- return d_ptr->transform();
+ return d_func()->transform;
}
void QWaylandOutput::setTransform(const Transform &transform)
{
- if (d_ptr->transform() == transform)
+ Q_D(QWaylandOutput);
+ if (d->transform == transform)
return;
- d_ptr->setTransform(transform);
+ d->transform = transform;
+
+ d->sendGeometryInfo();
+
Q_EMIT transformChanged();
}
+/*!
+ * \qmlproperty int QtWaylandCompositor::WaylandOutput::scaleFactor
+ *
+ * This property holds the factor by which the WaylandCompositor scales surface buffers
+ * before they are displayed. This is used on high density output devices where unscaled content
+ * would be too small to be practical. The client can in turn set the scale factor of its
+ * buffer to match the output if it prefers to provide high resolution content that is
+ * suitable for the output device.
+ *
+ * The default is 1 (no scaling).
+ */
+
+/*!
+ * \property QWaylandOutput::scaleFactor
+ *
+ * This property holds the factor by which the QWaylandCompositor scales surface buffers
+ * before they are displayed. This is used on high density output devices where unscaled content
+ * would be too small to be practical. The client can in turn set the scale factor of its
+ * buffer to match the output if it prefers to provide high resolution content that is
+ * suitable for the output device.
+ *
+ * The default is 1 (no scaling).
+ */
int QWaylandOutput::scaleFactor() const
{
- return d_ptr->scaleFactor();
+ return d_func()->scaleFactor;
}
void QWaylandOutput::setScaleFactor(int scale)
{
- if (d_ptr->scaleFactor() == scale)
+ Q_D(QWaylandOutput);
+ if (d->scaleFactor == scale)
return;
- d_ptr->setScaleFactor(scale);
+ d->scaleFactor = scale;
+
+ Q_FOREACH (QWaylandOutputPrivate::Resource *resource, d->resourceMap().values()) {
+ if (resource->version() >= 2) {
+ d->send_scale(resource->handle, scale);
+ d->send_done(resource->handle);
+ }
+ }
+
Q_EMIT scaleFactorChanged();
+}
+
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandOutput::sizeFollowsWindow
+ *
+ * This property controls whether the size of the WaylandOutput matches the
+ * size of its window.
+ *
+ * The default is true.
+ */
+
+/*!
+ * \property QWaylandOutput::sizeFollowsWindow
+ *
+ * This property controls whether the size of the QWaylandOutput matches the
+ * size of its window.
+ *
+ * The default is true.
+ */
+bool QWaylandOutput::sizeFollowsWindow() const
+{
+ return d_func()->sizeFollowsWindow;
+}
+void QWaylandOutput::setSizeFollowsWindow(bool follow)
+{
+ Q_D(QWaylandOutput);
+ if (follow != d->sizeFollowsWindow) {
+ if (follow) {
+ QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::setWidth);
+ QObject::connect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::setHeight);
+ } else {
+ QObject::disconnect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::setWidth);
+ QObject::disconnect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::setHeight);
+ }
+ d->sizeFollowsWindow = follow;
+ Q_EMIT sizeFollowsWindowChanged();
+ }
}
+/*!
+ * \qmlproperty object QtWaylandCompositor::WaylandOutput::window
+ *
+ * This property holds the Window for this WaylandOutput. This property can only be set once,
+ * before the WaylandOutput component is completed.
+ */
+
+/*!
+ * \property QWaylandOutput::window
+ *
+ * This property holds the QWindow for this QWaylandOutput.
+ */
QWindow *QWaylandOutput::window() const
{
- return d_ptr->window();
+ return d_func()->window;
}
-QtWayland::Output *QWaylandOutput::handle()
+void QWaylandOutput::setWindow(QWindow *window)
{
- return d_ptr;
+ Q_D(QWaylandOutput);
+ if (d->window == window)
+ return;
+ if (d->initialized) {
+ qWarning("Setting QWindow %p on QWaylandOutput %p is not supported after QWaylandOutput has been initialized\n", window, this);
+ return;
+ }
+ d->window = window;
+ emit windowChanged();
+}
+
+/*!
+ * Tells the QWaylandOutput that a frame has started.
+ */
+void QWaylandOutput::frameStarted()
+{
+ Q_D(QWaylandOutput);
+ for (int i = 0; i < d->surfaceViews.size(); i++) {
+ QWaylandSurfaceViewMapper &surfacemapper = d->surfaceViews[i];
+ if (surfacemapper.maybeThrottelingView())
+ surfacemapper.surface->frameStarted();
+ }
}
-QList<QWaylandSurface *> QWaylandOutput::surfaces() const
+/*!
+ * Sends pending frame callbacks.
+ */
+void QWaylandOutput::sendFrameCallbacks()
{
- QList<QWaylandSurface *> list;
- Q_FOREACH (QWaylandSurface *surface, d_ptr->compositor()->waylandCompositor()->surfaces()) {
- if (surface->outputs().contains(const_cast<QWaylandOutput *>(this)))
- list.append(surface);
+ Q_D(QWaylandOutput);
+ for (int i = 0; i < d->surfaceViews.size(); i++) {
+ const QWaylandSurfaceViewMapper &surfacemapper = d->surfaceViews.at(i);
+ if (surfacemapper.surface && surfacemapper.surface->isMapped()) {
+ if (!surfacemapper.has_entered) {
+ surfaceEnter(surfacemapper.surface);
+ d->surfaceViews[i].has_entered = true;
+ }
+ if (surfacemapper.maybeThrottelingView())
+ surfacemapper.surface->sendFrameCallbacks();
+ }
}
- return list;
+ wl_display_flush_clients(d->compositor->display());
+}
+
+/*!
+ * \internal
+ */
+void QWaylandOutput::surfaceEnter(QWaylandSurface *surface)
+{
+ if (!surface)
+ return;
+ QWaylandSurfacePrivate::get(surface)->send_enter(resourceForClient(surface->client()));
+}
+
+/*!
+ * \internal
+ */
+void QWaylandOutput::surfaceLeave(QWaylandSurface *surface)
+{
+ if (!surface || !surface->client())
+ return;
+ QWaylandSurfacePrivate::get(surface)->send_leave(resourceForClient(surface->client()));
+}
+
+/*!
+ * This functions sets the width of this QWaylandOutput to \a newWidth.
+ *
+ * \sa setHeight, QWaylandOutput::geometry
+ */
+void QWaylandOutput::setWidth(int newWidth)
+{
+ Q_D(QWaylandOutput);
+ if (d->mode.size.width() == newWidth)
+ return;
+
+ QSize s = d->mode.size;
+ s.setWidth(newWidth);
+ setGeometry(QRect(d->position, s));
+}
+
+/*!
+ * This functions sets the height of this QWaylandOutput to \a newHeight.
+ *
+ * \sa setWidth, QWaylandOutput::geometry
+ */
+void QWaylandOutput::setHeight(int newHeight)
+{
+ Q_D(QWaylandOutput);
+ if (d->mode.size.height() == newHeight)
+ return;
+
+ QSize s = d->mode.size;
+ s.setHeight(newHeight);
+ setGeometry(QRect(d->position, s));
+}
+
+/*!
+ * \internal
+ */
+void QWaylandOutput::handleWindowDestroyed()
+{
+ Q_D(QWaylandOutput);
+ d->window = Q_NULLPTR;
+ emit windowDestroyed();
}
+
+/*!
+ * \internal
+ */
+bool QWaylandOutput::event(QEvent *event)
+{
+ if (event->type() == QEvent::Polish)
+ initialize();
+ return QObject::event(event);
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h
index 9c9dc376..31e5fa56 100644
--- a/src/compositor/compositor_api/qwaylandoutput.h
+++ b/src/compositor/compositor_api/qwaylandoutput.h
@@ -4,36 +4,32 @@
** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -42,30 +38,33 @@
#ifndef QWAYLANDOUTPUT_H
#define QWAYLANDOUTPUT_H
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandextension.h>
+#include <QtCore/QObject>
#include <QObject>
#include <QRect>
#include <QSize>
-QT_BEGIN_NAMESPACE
-
struct wl_resource;
+QT_BEGIN_NAMESPACE
+
+class QWaylandOutputPrivate;
class QWaylandCompositor;
class QWindow;
class QWaylandSurface;
+class QWaylandView;
class QWaylandClient;
+class QWaylandOutputSpace;
-namespace QtWayland {
- class Output;
-}
-
-class Q_COMPOSITOR_EXPORT QWaylandOutput : public QObject
+class Q_COMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject
{
Q_OBJECT
- Q_PROPERTY(QString manufacturer READ manufacturer CONSTANT)
- Q_PROPERTY(QString model READ model CONSTANT)
+ Q_DECLARE_PRIVATE(QWaylandOutput)
+ Q_PROPERTY(QWaylandCompositor *compositor READ compositor WRITE setCompositor NOTIFY compositorChanged)
+ Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged)
+ Q_PROPERTY(QString manufacturer READ manufacturer WRITE setManufacturer NOTIFY manufacturerChanged)
+ Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged)
Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(QWaylandOutput::Mode mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
@@ -74,8 +73,9 @@ class Q_COMPOSITOR_EXPORT QWaylandOutput : public QObject
Q_PROPERTY(QWaylandOutput::Subpixel subpixel READ subpixel WRITE setSubpixel NOTIFY subpixelChanged)
Q_PROPERTY(QWaylandOutput::Transform transform READ transform WRITE setTransform NOTIFY transformChanged)
Q_PROPERTY(int scaleFactor READ scaleFactor WRITE setScaleFactor NOTIFY scaleFactorChanged)
- Q_PROPERTY(QWindow *window READ window CONSTANT)
+ Q_PROPERTY(bool sizeFollowsWindow READ sizeFollowsWindow WRITE setSizeFollowsWindow NOTIFY sizeFollowsWindowChanged)
Q_ENUMS(Subpixel Transform)
+
public:
enum Subpixel {
SubpixelUnknown = 0,
@@ -85,6 +85,7 @@ public:
SubpixelVerticalRgb,
SubpixelVerticalBgr
};
+ Q_ENUM(Subpixel)
enum Transform {
TransformNormal = 0,
@@ -96,6 +97,7 @@ public:
TransformFlipped180,
TransformFlipped270
};
+ Q_ENUM(Transform)
struct Mode
{
@@ -103,19 +105,24 @@ public:
int refreshRate;
};
- QWaylandOutput(QWaylandCompositor *compositor, QWindow *window,
- const QString &manufacturer, const QString &model);
+ QWaylandOutput();
+ QWaylandOutput(QWaylandCompositor *compositor, QWindow *window);
~QWaylandOutput();
static QWaylandOutput *fromResource(wl_resource *resource);
-
- virtual void update();
+ struct ::wl_resource *resourceForClient(QWaylandClient *client) const;
QWaylandCompositor *compositor() const;
+ void setCompositor(QWaylandCompositor *compositor);
+
+ QWindow *window() const;
+ void setWindow(QWindow *window);
QString manufacturer() const;
+ void setManufacturer(const QString &manufacturer);
QString model() const;
+ void setModel(const QString &model);
QPoint position() const;
void setPosition(const QPoint &pt);
@@ -125,6 +132,8 @@ public:
QRect geometry() const;
void setGeometry(const QRect &geometry);
+ void setWidth(int newWidth);
+ void setHeight(int newHeight);
QRect availableGeometry() const;
void setAvailableGeometry(const QRect &availableGeometry);
@@ -141,13 +150,23 @@ public:
int scaleFactor() const;
void setScaleFactor(int scale);
- QWindow *window() const;
+ bool sizeFollowsWindow() const;
+ void setSizeFollowsWindow(bool follow);
+
+ bool physicalSizeFollowsSize() const;
+ void setPhysicalSizeFollowsSize(bool follow);
- QtWayland::Output *handle();
+ void frameStarted();
+ void sendFrameCallbacks();
- QList<QWaylandSurface *> surfaces() const;
+ void surfaceEnter(QWaylandSurface *surface);
+ void surfaceLeave(QWaylandSurface *surface);
+
+ virtual void update();
Q_SIGNALS:
+ void compositorChanged();
+ void windowChanged();
void positionChanged();
void geometryChanged();
void modeChanged();
@@ -156,13 +175,23 @@ Q_SIGNALS:
void scaleFactorChanged();
void subpixelChanged();
void transformChanged();
+ void sizeFollowsWindowChanged();
+ void physicalSizeFollowsSizeChanged();
+ void manufacturerChanged();
+ void modelChanged();
+ void windowDestroyed();
-private:
- QtWayland::Output *const d_ptr;
-};
+private Q_SLOTS:
+ void handleWindowDestroyed();
-Q_DECLARE_METATYPE(QWaylandOutput::Mode)
+protected:
+ bool event(QEvent *event) Q_DECL_OVERRIDE;
+
+ virtual void initialize();
+};
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QWaylandOutput::Mode)
+
#endif // QWAYLANDOUTPUT_H
diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h
new file mode 100644
index 00000000..c67e45a7
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandoutput_p.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2014-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDOUTPUT_P_H
+#define QWAYLANDOUTPUT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/QWaylandOutput>
+#include <QtWaylandCompositor/QWaylandClient>
+#include <QtWaylandCompositor/QWaylandSurface>
+
+#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
+
+#include <QtCore/QRect>
+#include <QtCore/QVector>
+
+#include <QtCore/private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QWaylandSurfaceViewMapper
+{
+ QWaylandSurfaceViewMapper()
+ : surface(0)
+ , views()
+ , has_entered(false)
+ {}
+
+ QWaylandSurfaceViewMapper(QWaylandSurface *s, QWaylandView *v)
+ : surface(s)
+ , views(1, v)
+ , has_entered(false)
+ {}
+
+ QWaylandView *maybeThrottelingView() const
+ {
+ for (int i = 0; i < views.size(); i++) {
+ if (surface && surface->throttlingView() == views.at(i))
+ return views.at(i);
+ }
+ return Q_NULLPTR;
+ }
+
+ QWaylandSurface *surface;
+ QVector<QWaylandView *> views;
+ bool has_entered;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandOutputPrivate : public QObjectPrivate, public QtWaylandServer::wl_output
+{
+public:
+ QWaylandOutputPrivate();
+
+ ~QWaylandOutputPrivate();
+ static QWaylandOutputPrivate *get(QWaylandOutput *output) { return output->d_func(); }
+
+ void addView(QWaylandView *view, QWaylandSurface *surface);
+ void removeView(QWaylandView *view, QWaylandSurface *surface);
+ void sendGeometryInfo();
+
+protected:
+ void output_bind_resource(Resource *resource) Q_DECL_OVERRIDE;
+
+
+private:
+ QWaylandCompositor *compositor;
+ QWindow *window;
+ QString manufacturer;
+ QString model;
+ QPoint position;
+ QWaylandOutput::Mode mode;
+ QRect availableGeometry;
+ QVector<QWaylandSurfaceViewMapper> surfaceViews;
+ QSize physicalSize;
+ QWaylandOutput::Subpixel subpixel;
+ QWaylandOutput::Transform transform;
+ int scaleFactor;
+ bool sizeFollowsWindow;
+ bool initialized;
+
+ Q_DECLARE_PUBLIC(QWaylandOutput)
+ Q_DISABLE_COPY(QWaylandOutputPrivate)
+};
+
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDOUTPUT_P_H*/
diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp
new file mode 100644
index 00000000..51b1f791
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandpointer.cpp
@@ -0,0 +1,368 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandpointer.h"
+#include "qwaylandpointer_p.h"
+#include <QtWaylandCompositor/QWaylandClient>
+#include <QtWaylandCompositor/QWaylandCompositor>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandPointerPrivate::QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandInputDevice *seat)
+ : QObjectPrivate()
+ , wl_pointer()
+ , seat(seat)
+ , output()
+ , focusResource()
+ , hasSentEnter(false)
+ , buttonCount()
+{
+}
+
+void QWaylandPointerPrivate::pointer_destroy_resource(wl_pointer::Resource *resource)
+{
+ if (focusResource == resource->handle)
+ focusResource = 0;
+}
+
+void QWaylandPointerPrivate::pointer_release(wl_pointer::Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(serial);
+
+ if (!surface) {
+ seat->cursorSurfaceRequest(Q_NULLPTR, 0, 0);
+ return;
+ }
+
+ QWaylandSurface *s = QWaylandSurface::fromResource(surface);
+ s->markAsCursorSurface(true);
+ seat->cursorSurfaceRequest(s, hotspot_x, hotspot_y);
+}
+
+/*!
+ * \class QWaylandPointer
+ * \inmodule QtWaylandCompositor
+ * \brief The QWaylandPointer class provides access to a pointer device.
+ *
+ * This class provides access to the pointer device in a QWaylandInputDevice. It corresponds to
+ * the Wayland interface wl_pointer.
+ */
+
+/*!
+ * Constructs a QWaylandPointer for the given \a inputDevice and with the given \a parent.
+ */
+QWaylandPointer::QWaylandPointer(QWaylandInputDevice *inputDevice, QObject *parent)
+ : QWaylandObject(* new QWaylandPointerPrivate(this, inputDevice), parent)
+{
+ connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandPointer::focusDestroyed);
+ connect(inputDevice, &QWaylandInputDevice::mouseFocusChanged, this, &QWaylandPointer::pointerFocusChanged);
+}
+
+/*!
+ * Returns the input device for this QWaylandPointer.
+ */
+QWaylandInputDevice *QWaylandPointer::inputDevice() const
+{
+ Q_D(const QWaylandPointer);
+ return d->seat;
+}
+
+/*!
+ * Returns the compositor for this QWaylandPointer.
+ */
+QWaylandCompositor *QWaylandPointer::compositor() const
+{
+ Q_D(const QWaylandPointer);
+ return d->compositor();
+}
+
+/*!
+ * Returns the output for this QWaylandPointer.
+ */
+QWaylandOutput *QWaylandPointer::output() const
+{
+ Q_D(const QWaylandPointer);
+ return d->output;
+}
+
+/*!
+ * Sets the output for this QWaylandPointer to \a output.
+ */
+void QWaylandPointer::setOutput(QWaylandOutput *output)
+{
+ Q_D(QWaylandPointer);
+ if (d->output == output) return;
+ d->output = output;
+ outputChanged();
+}
+
+/*!
+ * Sends a mouse press event for \a button to the view currently holding mouse focus.
+ */
+void QWaylandPointer::sendMousePressEvent(Qt::MouseButton button)
+{
+ Q_D(QWaylandPointer);
+ uint32_t time = d->compositor()->currentTimeMsecs();
+ d->buttonCount++;
+ if (d->focusResource)
+ sendButton(d->focusResource, time, button, WL_POINTER_BUTTON_STATE_PRESSED);
+
+ if (d->buttonCount == 1) {
+ emit buttonPressedChanged();
+ }
+}
+
+/*!
+ * Sends a mouse release event for \a button to the view currently holding mouse focus.
+ */
+void QWaylandPointer::sendMouseReleaseEvent(Qt::MouseButton button)
+{
+ Q_D(QWaylandPointer);
+ uint32_t time = d->compositor()->currentTimeMsecs();
+ d->buttonCount--;
+
+ if (d->focusResource)
+ sendButton(d->focusResource, time, button, WL_POINTER_BUTTON_STATE_RELEASED);
+
+ if (d->buttonCount == 0)
+ emit buttonPressedChanged();
+}
+
+/*!
+ * Sets the current mouse focus to \a view and sends a mouse move event to it with the
+ * local position \a localPos and output space position \a outputSpacePos.
+ */
+void QWaylandPointer::sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos)
+{
+ Q_D(QWaylandPointer);
+ if (view && (!view->surface() || view->surface()->isCursorSurface()))
+ view = Q_NULLPTR;
+ d->seat->setMouseFocus(view);
+ d->localPosition = localPos;
+ d->spacePosition = outputSpacePos;
+
+ //we adjust if the mouse position is on the edge
+ //to work around Qt's event propagation
+ if (view && view->surface()) {
+ QSizeF size(view->surface()->size());
+ if (d->localPosition.x() == size.width())
+ d->localPosition.rx() -= 0.01;
+
+ if (d->localPosition.y() == size.height())
+ d->localPosition.ry() -= 0.01;
+ }
+
+ QWaylandPointerPrivate::Resource *resource = view ? d->resourceMap().value(view->surface()->waylandClient()) : 0;
+ if (resource && !d->hasSentEnter) {
+ uint32_t serial = d->compositor()->nextSerial();
+ QWaylandKeyboard *keyboard = d->seat->keyboard();
+ if (keyboard) {
+ keyboard->sendKeyModifiers(view->surface()->client(), serial);
+ }
+ d->send_enter(resource->handle, serial, view->surface()->resource(),
+ wl_fixed_from_double(d->localPosition.x()), wl_fixed_from_double(d->localPosition.y()));
+
+ d->focusDestroyListener.listenForDestruction(view->surface()->resource());
+ d->hasSentEnter = true;
+ }
+
+ d->focusResource = resource ? resource->handle : 0;
+
+ if (view && view->output())
+ setOutput(view->output());
+
+ uint32_t time = d->compositor()->currentTimeMsecs();
+
+ if (d->focusResource) {
+ wl_fixed_t x = wl_fixed_from_double(currentLocalPosition().x());
+ wl_fixed_t y = wl_fixed_from_double(currentLocalPosition().y());
+ wl_pointer_send_motion(d->focusResource, time, x, y);
+ }
+}
+
+/*!
+ * Sends a mouse wheel event with the given \a orientation and \a delta to the view that currently holds mouse focus.
+ */
+void QWaylandPointer::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
+{
+ Q_D(QWaylandPointer);
+ if (!d->focusResource)
+ return;
+
+ uint32_t time = d->compositor()->currentTimeMsecs();
+ uint32_t axis = orientation == Qt::Horizontal ? WL_POINTER_AXIS_HORIZONTAL_SCROLL
+ : WL_POINTER_AXIS_VERTICAL_SCROLL;
+ d->send_axis(d->focusResource, time, axis, wl_fixed_from_int(-delta / 12));
+}
+
+/*!
+ * Returns the view that currently holds mouse focus.
+ */
+QWaylandView *QWaylandPointer::mouseFocus() const
+{
+ Q_D(const QWaylandPointer);
+ return d->seat->mouseFocus();
+}
+
+/*!
+ * Returns the current local position of the QWaylandPointer.
+ */
+QPointF QWaylandPointer::currentLocalPosition() const
+{
+ Q_D(const QWaylandPointer);
+ return d->localPosition;
+}
+
+/*!
+ * Returns the current output space position of the QWaylandPointer.
+ */
+QPointF QWaylandPointer::currentSpacePosition() const
+{
+ Q_D(const QWaylandPointer);
+ return d->spacePosition;
+}
+
+/*!
+ * Returns true if any button is currently pressed. Otherwise returns false.
+ */
+bool QWaylandPointer::isButtonPressed() const
+{
+ Q_D(const QWaylandPointer);
+ return d->buttonCount > 0;
+}
+
+/*!
+ * \internal
+ */
+void QWaylandPointer::addClient(QWaylandClient *client, uint32_t id, uint32_t version)
+{
+ Q_D(QWaylandPointer);
+ d->add(client->client(), id, qMin<uint32_t>(QtWaylandServer::wl_pointer::interfaceVersion(), version));
+}
+
+/*!
+ * Returns the Wayland resource for this QWaylandPointer.
+ */
+struct wl_resource *QWaylandPointer::focusResource() const
+{
+ Q_D(const QWaylandPointer);
+ if (!d->focusResource)
+ return Q_NULLPTR;
+
+ return d->focusResource;
+}
+
+/*!
+ * \internal
+ */
+void QWaylandPointer::sendButton(struct wl_resource *resource, uint32_t time, Qt::MouseButton button, uint32_t state)
+{
+ Q_D(QWaylandPointer);
+ uint32_t serial = d->compositor()->nextSerial();
+ d->send_button(resource, serial, time, toWaylandButton(button), state);
+}
+
+/*!
+ * \internal
+ */
+uint32_t QWaylandPointer::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);
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandPointer::focusDestroyed(void *data)
+{
+ Q_D(QWaylandPointer);
+ Q_UNUSED(data)
+ d->focusDestroyListener.reset();
+
+ d->seat->setMouseFocus(Q_NULLPTR);
+ d->focusResource = 0;
+ d->buttonCount = 0;
+}
+
+/*!
+ * \internal
+ */
+void QWaylandPointer::pointerFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus)
+{
+ Q_UNUSED(newFocus);
+ Q_D(QWaylandPointer);
+ d->localPosition = QPointF();
+ d->hasSentEnter = false;
+ if (d->focusResource && oldFocus) {
+ uint32_t serial = d->compositor()->nextSerial();
+ d->send_leave(d->focusResource, serial, oldFocus->surfaceResource());
+ d->focusDestroyListener.reset();
+ d->focusResource = 0;
+ }
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandpointer.h b/src/compositor/compositor_api/qwaylandpointer.h
new file mode 100644
index 00000000..78e2b527
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandpointer.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDPOINTER_H
+#define QWAYLANDPOINTER_H
+
+#include <QtWaylandCompositor/QWaylandExtension>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandPointer;
+class QWaylandPointerPrivate;
+class QWaylandInputDevice;
+class QWaylandView;
+class QWaylandOutput;
+class QWaylandClient;
+
+class Q_COMPOSITOR_EXPORT QWaylandPointer : public QWaylandObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandPointer)
+ Q_PROPERTY(bool isButtonPressed READ isButtonPressed NOTIFY buttonPressedChanged)
+public:
+ QWaylandPointer(QWaylandInputDevice *inputDevice, QObject *parent = 0);
+
+ QWaylandInputDevice *inputDevice() const;
+ QWaylandCompositor *compositor() const;
+
+ QWaylandOutput *output() const;
+ void setOutput(QWaylandOutput *output);
+
+ virtual void sendMousePressEvent(Qt::MouseButton button);
+ virtual void sendMouseReleaseEvent(Qt::MouseButton button);
+ virtual void sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos);
+ virtual void sendMouseWheelEvent(Qt::Orientation orientation, int delta);
+
+ QWaylandView *mouseFocus() const;
+ QPointF currentLocalPosition() const;
+ QPointF currentSpacePosition() const;
+
+ bool isButtonPressed() const;
+
+ virtual void addClient(QWaylandClient *client, uint32_t id, uint32_t version);
+
+ struct wl_resource *focusResource() const;
+
+ static uint32_t toWaylandButton(Qt::MouseButton button);
+ void sendButton(struct wl_resource *resource, uint32_t time, Qt::MouseButton button, uint32_t state);
+Q_SIGNALS:
+ void outputChanged();
+ void buttonPressedChanged();
+
+private:
+ void focusDestroyed(void *data);
+ void pointerFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus);
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDPOINTER_H*/
diff --git a/src/compositor/compositor_api/qwaylandpointer_p.h b/src/compositor/compositor_api/qwaylandpointer_p.h
new file mode 100644
index 00000000..d7a6335a
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandpointer_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDPOINTER_P_H
+#define QWAYLANDPOINTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/QWaylandDestroyListener>
+#include <QtWaylandCompositor/QWaylandPointer>
+
+#include <QtCore/QList>
+#include <QtCore/QPoint>
+#include <QtCore/QObject>
+#include <QtCore/private/qobject_p.h>
+
+#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
+#include <QtWaylandCompositor/QWaylandView>
+#include <QtWaylandCompositor/QWaylandSurface>
+#include <QtWaylandCompositor/QWaylandInputDevice>
+
+#include <stdint.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandView;
+
+class Q_COMPOSITOR_EXPORT QWaylandPointerPrivate : public QObjectPrivate
+ , public QtWaylandServer::wl_pointer
+{
+ Q_DECLARE_PUBLIC(QWaylandPointer)
+public:
+ QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandInputDevice *seat);
+
+ QWaylandCompositor *compositor() const { return seat->compositor(); }
+
+protected:
+ void pointer_set_cursor(Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y) Q_DECL_OVERRIDE;
+ void pointer_release(Resource *resource) Q_DECL_OVERRIDE;
+ void pointer_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
+
+private:
+ void focusDestroyed(void *data);
+
+ QWaylandInputDevice *seat;
+ QWaylandOutput *output;
+
+ QPointF localPosition;
+ QPointF spacePosition;
+
+ struct ::wl_resource *focusResource;
+ bool hasSentEnter;
+
+ int buttonCount;
+
+ QWaylandDestroyListener focusDestroyListener;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDPOINTER_P_H
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
index db84ea5f..8a7ef745 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
@@ -4,9 +4,9 @@
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -17,74 +17,89 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QtCompositor/private/qwlcompositor_p.h>
-#include <QtCompositor/private/qwlsurface_p.h>
+#include <QtQml/QQmlEngine>
#include "qwaylandclient.h"
#include "qwaylandquickcompositor.h"
#include "qwaylandquicksurface.h"
-#include "qwaylandsurfaceitem.h"
#include "qwaylandquickoutput.h"
+#include "qwaylandquickitem.h"
+#include "qwaylandoutput.h"
+#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
QT_BEGIN_NAMESPACE
-class QWaylandQuickCompositorPrivate : public QtWayland::Compositor
+class QWaylandQuickCompositorPrivate : public QWaylandCompositorPrivate
{
public:
- QWaylandQuickCompositorPrivate(QWaylandQuickCompositor *compositor, QWaylandCompositor::ExtensionFlags extensions)
- : QtWayland::Compositor(compositor, extensions)
+ QWaylandQuickCompositorPrivate(QWaylandCompositor *compositor)
+ : QWaylandCompositorPrivate(compositor)
{
}
-
- void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) Q_DECL_OVERRIDE
+protected:
+ QWaylandSurface *createDefaultSurface() Q_DECL_OVERRIDE
{
- QWaylandQuickSurface *surface = new QWaylandQuickSurface(resource->client(), id, wl_resource_get_version(resource->handle), static_cast<QWaylandQuickCompositor *>(m_qt_compositor));
- surface->handle()->addToOutput(primaryOutput()->handle());
- m_surfaces << surface->handle();
- //BUG: This may not be an on-screen window surface though
- m_qt_compositor->surfaceCreated(surface);
+ return new QWaylandQuickSurface();
}
};
+QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent)
+ : QWaylandCompositor(*new QWaylandQuickCompositorPrivate(this), parent)
+{
+}
-QWaylandQuickCompositor::QWaylandQuickCompositor(const char *socketName, ExtensionFlags extensions)
- : QWaylandCompositor(socketName, new QWaylandQuickCompositorPrivate(this, extensions))
+/*!
+ * \qmlproperty list QtWaylandCompositor::WaylandCompositor::extensions
+ *
+ * A list of extensions that the compositor advertises to its clients. For
+ * any Wayland extension the compositor should support, instantiate its component,
+ * and add it to the list of extensions.
+ *
+ * For instance, the following code would allow the clients to request shell surfaces
+ * in the compositor using the wl_shell interface.
+ *
+ * \code
+ * import QtWayland.Compositor 1.0
+ *
+ * WaylandCompositor {
+ * extensions: [ Shell {
+ * // ...
+ * } ]
+ * }
+ * \endcode
+ */
+
+void QWaylandQuickCompositor::create()
{
- qmlRegisterUncreatableType<QWaylandSurfaceItem>("QtCompositor", 1, 0, "WaylandSurfaceItem", QObject::tr("Cannot create instance of WaylandSurfaceItem"));
- qmlRegisterUncreatableType<QWaylandQuickSurface>("QtCompositor", 1, 0, "WaylandQuickSurface", QObject::tr("Cannot create instance of WaylandQuickSurface"));
- qmlRegisterUncreatableType<QWaylandClient>("QtCompositor", 1, 0, "WaylandClient", QObject::tr("Cannot create instance of WaylandClient"));
- qmlRegisterUncreatableType<QWaylandOutput>("QtCompositor", 1, 0, "WaylandOutput", QObject::tr("Cannot create instance of WaylandOutput"));
+ QWaylandCompositor::create();
}
-QWaylandSurfaceView *QWaylandQuickCompositor::createView(QWaylandSurface *surf)
+
+void QWaylandQuickCompositor::classBegin()
{
- return new QWaylandSurfaceItem(static_cast<QWaylandQuickSurface *>(surf));
}
-QWaylandOutput *QWaylandQuickCompositor::createOutput(QWindow *window,
- const QString &manufacturer,
- const QString &model)
+void QWaylandQuickCompositor::componentComplete()
{
- QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(window);
- if (!quickWindow)
- qFatal("%s: couldn't cast QWindow to QQuickWindow. All output windows must "
- "be QQuickWindow derivates when using QWaylandQuickCompositor", Q_FUNC_INFO);
- return new QWaylandQuickOutput(this, quickWindow, manufacturer, model);
+ create();
}
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.h b/src/compositor/compositor_api/qwaylandquickcompositor.h
index e5401890..87650810 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.h
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.h
@@ -3,9 +3,9 @@
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -34,24 +37,26 @@
#ifndef QWAYLANDQUICKCOMPOSITOR_H
#define QWAYLANDQUICKCOMPOSITOR_H
-#include <QtCompositor/qwaylandcompositor.h>
+#include <QtWaylandCompositor/qwaylandcompositor.h>
+#include <QtQml/QQmlParserStatus>
QT_BEGIN_NAMESPACE
class QQuickWindow;
class QWaylandQuickCompositorPrivate;
-class QWaylandSurfaceView;
-class QWaylandOutput;
+class QWaylandView;
-class Q_COMPOSITOR_EXPORT QWaylandQuickCompositor : public QWaylandCompositor
+class Q_COMPOSITOR_EXPORT QWaylandQuickCompositor : public QWaylandCompositor, public QQmlParserStatus
{
+ Q_INTERFACES(QQmlParserStatus)
+ Q_OBJECT
public:
- QWaylandQuickCompositor(const char *socketName = 0, QWaylandCompositor::ExtensionFlags extensions = DefaultExtensions);
+ QWaylandQuickCompositor(QObject *parent = 0);
+ void create() Q_DECL_OVERRIDE;
- QWaylandSurfaceView *createView(QWaylandSurface *surf) Q_DECL_OVERRIDE;
- QWaylandOutput *createOutput(QWindow *window,
- const QString &manufacturer,
- const QString &model) Q_DECL_OVERRIDE;
+protected:
+ void classBegin() Q_DECL_OVERRIDE;
+ void componentComplete() Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
new file mode 100644
index 00000000..f684f64c
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -0,0 +1,775 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandquickitem.h"
+#include "qwaylandquickitem_p.h"
+#include "qwaylandquicksurface.h"
+#include <QtWaylandCompositor/qwaylandcompositor.h>
+#include <QtWaylandCompositor/qwaylandinput.h>
+#include <QtWaylandCompositor/qwaylandbufferref.h>
+#include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h>
+
+#include <QtGui/QKeyEvent>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
+
+#include <QtQuick/QSGSimpleTextureNode>
+#include <QtQuick/QQuickWindow>
+
+#include <QtCore/QMutexLocker>
+#include <QtCore/QMutex>
+
+#include <wayland-server.h>
+#include <QThread>
+QT_BEGIN_NAMESPACE
+
+QMutex *QWaylandQuickItemPrivate::mutex = 0;
+
+class QWaylandSurfaceTextureProvider : public QSGTextureProvider
+{
+public:
+ QWaylandSurfaceTextureProvider()
+ : m_smooth(false)
+ , m_sgTex(0)
+ {
+ }
+
+ ~QWaylandSurfaceTextureProvider()
+ {
+ if (m_sgTex)
+ m_sgTex->deleteLater();
+ }
+
+ void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &buffer)
+ {
+ Q_ASSERT(QThread::currentThread() == thread());
+ m_ref = buffer;
+ delete m_sgTex;
+ m_sgTex = 0;
+ if (m_ref.hasBuffer()) {
+ if (buffer.isShm()) {
+ m_sgTex = surfaceItem->window()->createTextureFromImage(buffer.image());
+ m_invertY = false;
+ if (m_sgTex) {
+ m_sgTex->bind();
+ }
+ } else {
+ QQuickWindow::CreateTextureOptions opt = QQuickWindow::TextureOwnsGLTexture;
+ QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface());
+ if (surface && surface->useTextureAlpha()) {
+ opt |= QQuickWindow::TextureHasAlphaChannel;
+ }
+
+ GLuint texture;
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ buffer.bindToTexture();
+ m_sgTex = surfaceItem->window()->createTextureFromId(texture , QSize(surfaceItem->width(), surfaceItem->height()), opt);
+ m_invertY = buffer.origin() == QWaylandSurface::OriginBottomLeft;
+ }
+ }
+ emit textureChanged();
+ }
+
+ QSGTexture *texture() const Q_DECL_OVERRIDE
+ {
+ if (m_sgTex)
+ m_sgTex->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
+ return m_sgTex;
+ }
+
+ void setSmooth(bool smooth) { m_smooth = smooth; }
+ bool invertY() const { return m_invertY; }
+private:
+ bool m_smooth;
+ bool m_invertY;
+ QSGTexture *m_sgTex;
+ QWaylandBufferRef m_ref;
+};
+
+/*!
+ * \qmltype WaylandQuickItem
+ * \inqmlmodule QtWayland.Compositor
+ * \brief A Qt Quick item representing a WaylandView.
+ *
+ * When writing a WaylandCompositor in Qt Quick, this type can be used to display a
+ * client's contents on an output device and will pass user input to the
+ * client.
+ */
+
+/*!
+ * \class QWaylandQuickItem
+ * \inmodule QtWaylandCompositor
+ * \brief A Qt Quick item representing a QWaylandView.
+ *
+ * When writing a QWaylandCompositor in Qt Quick, this class can be used to display a
+ * client's contents on an output device and will pass user input to the
+ * client.
+ */
+
+/*!
+ * Constructs a QWaylandQuickItem with the given \a parent.
+ */
+QWaylandQuickItem::QWaylandQuickItem(QQuickItem *parent)
+ : QQuickItem(*new QWaylandQuickItemPrivate(), parent)
+{
+ d_func()->init();
+}
+
+/*!
+ * \internal
+ */
+QWaylandQuickItem::QWaylandQuickItem(QWaylandQuickItemPrivate &dd, QQuickItem *parent)
+ : QQuickItem(dd, parent)
+{
+ d_func()->init();
+}
+
+/*!
+ * Destroy the QWaylandQuickItem.
+ */
+QWaylandQuickItem::~QWaylandQuickItem()
+{
+ Q_D(QWaylandQuickItem);
+ disconnect(this, &QQuickItem::windowChanged, this, &QWaylandQuickItem::updateWindow);
+ QMutexLocker locker(d->mutex);
+ if (d->provider)
+ d->provider->deleteLater();
+}
+
+/*!
+ * \qmlproperty object QtWaylandCompositor::WaylandQuickItem::compositor
+ *
+ * This property holds the compositor for the surface rendered by this WaylandQuickItem.
+ */
+
+/*!
+ * \property QWaylandQuickItem::compositor
+ *
+ * This property holds the compositor for the surface rendered by this QWaylandQuickItem.
+ */
+QWaylandCompositor *QWaylandQuickItem::compositor() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->view->surface() ? d->view->surface()->compositor() : Q_NULLPTR;
+}
+
+/*!
+ * \qmlproperty object QWaylandQuickItem::view
+ *
+ * This property holds the view rendered by this WaylandQuickItem.
+ */
+
+/*!
+ * \property QWaylandQuickItem::view
+ *
+ * This property holds the view rendered by this QWaylandQuickItem.
+ */
+QWaylandView *QWaylandQuickItem::view() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->view.data();
+}
+
+/*!
+ * \qmlproperty object QWaylandQuickItem::surface
+ *
+ * This property holds the surface rendered by this WaylandQuickItem.
+ */
+
+/*!
+ * \property QWaylandQuickItem::surface
+ *
+ * This property holds the surface rendered by this QWaylandQuickItem.
+ */
+
+QWaylandSurface *QWaylandQuickItem::surface() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->view->surface();
+}
+
+void QWaylandQuickItem::setSurface(QWaylandSurface *surface)
+{
+ Q_D(QWaylandQuickItem);
+ d->view->setSurface(surface);
+ update();
+}
+
+/*!
+ * \qmlproperty enum QtWaylandCompositor::WaylandQuickItem::origin
+ *
+ * This property holds the origin of the QWaylandQuickItem.
+ */
+
+/*!
+ * \property QWaylandQuickItem::origin
+ *
+ * This property holds the origin of the QWaylandQuickItem.
+ */
+QWaylandSurface::Origin QWaylandQuickItem::origin() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->origin;
+}
+
+/*!
+ * Returns the texture provider of this QWaylandQuickItem.
+ */
+QSGTextureProvider *QWaylandQuickItem::textureProvider() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->provider;
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::mousePressEvent(QMouseEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (!d->shouldSendInputEvents()) {
+ event->ignore();
+ return;
+ }
+
+ if (!inputRegionContains(event->pos())) {
+ event->ignore();
+ return;
+ }
+
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+
+ if (d->focusOnClick)
+ takeFocus(inputDevice);
+
+ inputDevice->sendMousePressEvent(event->button());
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->shouldSendInputEvents()) {
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+ inputDevice->sendMouseMoveEvent(d->view.data(), event->localPos(), event->windowPos());
+ } else {
+ emit mouseMove(event->windowPos());
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::mouseReleaseEvent(QMouseEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->shouldSendInputEvents()) {
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+ inputDevice->sendMouseReleaseEvent(event->button());
+ } else {
+ emit mouseRelease();
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::hoverEnterEvent(QHoverEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (!inputRegionContains(event->pos())) {
+ event->ignore();
+ return;
+ }
+ if (d->shouldSendInputEvents()) {
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+ inputDevice->sendMouseMoveEvent(d->view.data(), event->pos(), mapToScene(event->pos()));
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (surface()) {
+ if (!inputRegionContains(event->pos())) {
+ event->ignore();
+ return;
+ }
+ }
+ if (d->shouldSendInputEvents()) {
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+ inputDevice->sendMouseMoveEvent(d->view.data(), event->pos(), mapToScene(event->pos()));
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::hoverLeaveEvent(QHoverEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->shouldSendInputEvents()) {
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+ inputDevice->setMouseFocus(Q_NULLPTR);
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::wheelEvent(QWheelEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->shouldSendInputEvents()) {
+ if (!inputRegionContains(event->pos())) {
+ event->ignore();
+ return;
+ }
+
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+ inputDevice->sendMouseWheelEvent(event->orientation(), event->delta());
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::keyPressEvent(QKeyEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->shouldSendInputEvents()) {
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+ inputDevice->sendFullKeyEvent(event);
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::keyReleaseEvent(QKeyEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->shouldSendInputEvents() && hasFocus()) {
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+ inputDevice->sendFullKeyEvent(event);
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::touchEvent(QTouchEvent *event)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->shouldSendInputEvents() && d->touchEventsEnabled) {
+ QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
+
+ if (event->type() == QEvent::TouchBegin) {
+ QQuickItem *grabber = window()->mouseGrabberItem();
+ if (grabber != this)
+ grabMouse();
+ }
+
+ QPoint pointPos;
+ const QList<QTouchEvent::TouchPoint> &points = event->touchPoints();
+ if (!points.isEmpty())
+ pointPos = points.at(0).pos().toPoint();
+
+ if (event->type() == QEvent::TouchBegin && !inputRegionContains(pointPos)) {
+ event->ignore();
+ return;
+ }
+
+ event->accept();
+ if (inputDevice->mouseFocus() != d->view.data()) {
+ inputDevice->sendMouseMoveEvent(d->view.data(), pointPos, mapToScene(pointPos));
+ }
+ inputDevice->sendFullTouchEvent(event);
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::mouseUngrabEvent()
+{
+ if (surface()) {
+ QTouchEvent e(QEvent::TouchCancel);
+ touchEvent(&e);
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
+{
+ Q_UNUSED(newSurface);
+ Q_UNUSED(oldSurface);
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::handleSurfaceChanged()
+{
+ Q_D(QWaylandQuickItem);
+ if (d->oldSurface) {
+ disconnect(d->oldSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
+ disconnect(d->oldSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
+ disconnect(d->oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
+ disconnect(d->oldSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
+ disconnect(d->oldSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
+ }
+ if (QWaylandSurface *newSurface = d->view->surface()) {
+ connect(newSurface, &QWaylandSurface::mappedChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
+ connect(newSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
+ connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
+ connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
+ connect(newSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
+ if (d->sizeFollowsSurface) {
+ setWidth(newSurface->size().width());
+ setHeight(newSurface->size().height());
+ }
+ if (newSurface->origin() != d->origin) {
+ d->origin = newSurface->origin();
+ emit originChanged();
+ }
+ if (window()) {
+ QWaylandOutput *output = newSurface->compositor()->outputFor(window());
+ d->view->setOutput(output);
+ }
+ }
+ surfaceChangedEvent(d->view->surface(), d->oldSurface);
+ d->oldSurface = d->view->surface();
+}
+
+/*!
+ * Calling this function causes the item to take the focus of the
+ * input \a device.
+ */
+void QWaylandQuickItem::takeFocus(QWaylandInputDevice *device)
+{
+ setFocus(true);
+
+ if (!surface())
+ return;
+
+ QWaylandInputDevice *target = device;
+ if (!target) {
+ target = compositor()->defaultInputDevice();
+ }
+ target->setKeyboardFocus(surface());
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::surfaceMappedChanged()
+{
+ update();
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent)
+{
+ Q_UNUSED(oldParent);
+
+ if (newParent) {
+ setPaintEnabled(true);
+ setVisible(true);
+ setOpacity(1);
+ setEnabled(true);
+ }
+}
+
+/*!
+ * \internal
+ */
+void QWaylandQuickItem::updateSize()
+{
+ Q_D(QWaylandQuickItem);
+ if (d->sizeFollowsSurface && surface()) {
+ setSize(surface()->size());
+ }
+}
+
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::focusOnClick
+ *
+ * This property specifies whether the WaylandQuickItem should take focus when
+ * it is clicked.
+ *
+ * The default is true.
+ */
+
+/*!
+ * \property QWaylandQuickItem::focusOnClick
+ *
+ * This property specifies whether the QWaylandQuickItem should take focus when
+ * it is clicked.
+ *
+ * The default is true.
+ */
+bool QWaylandQuickItem::focusOnClick() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->focusOnClick;
+}
+
+void QWaylandQuickItem::setFocusOnClick(bool focus)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->focusOnClick == focus)
+ return;
+
+ d->focusOnClick = focus;
+ emit focusOnClickChanged();
+}
+
+/*!
+ * Returns true if the input region of this item's surface contains the
+ * position given by \a localPosition.
+ */
+bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition)
+{
+ if (QWaylandSurface *s = surface())
+ return s->inputRegionContains(localPosition.toPoint());
+ return false;
+}
+
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::sizeFollowsSurface
+ *
+ * This property specifies whether the size of the item should always match
+ * the size of its surface.
+ *
+ * The default is true.
+ */
+
+/*!
+ * \property QWaylandQuickItem::sizeFollowsSurface
+ *
+ * This property specifies whether the size of the item should always match
+ * the size of its surface.
+ *
+ * The default is true.
+ */
+bool QWaylandQuickItem::sizeFollowsSurface() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->sizeFollowsSurface;
+}
+
+void QWaylandQuickItem::setSizeFollowsSurface(bool sizeFollowsSurface)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->sizeFollowsSurface == sizeFollowsSurface)
+ return;
+ d->sizeFollowsSurface = sizeFollowsSurface;
+ emit sizeFollowsSurfaceChanged();
+}
+
+/*!
+ \qmlproperty bool QtWayland::QWaylandSurfaceItem::paintEnabled
+
+ If this property is true, the \l item is hidden, though the texture
+ will still be updated. As opposed to hiding the \l item by
+ setting \l{Item::visible}{visible} to false, setting this property to true
+ will not prevent mouse or keyboard input from reaching \l item.
+*/
+bool QWaylandQuickItem::paintEnabled() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->paintEnabled;
+}
+
+void QWaylandQuickItem::setPaintEnabled(bool enabled)
+{
+ Q_D(QWaylandQuickItem);
+ d->paintEnabled = enabled;
+ update();
+}
+
+bool QWaylandQuickItem::touchEventsEnabled() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->touchEventsEnabled;
+}
+
+void QWaylandQuickItem::updateBuffer(bool hasBuffer)
+{
+ Q_D(QWaylandQuickItem);
+ Q_UNUSED(hasBuffer);
+ if (d->origin != surface()->origin()) {
+ d->origin = surface()->origin();
+ emit originChanged();
+ }
+}
+
+void QWaylandQuickItem::updateWindow()
+{
+ Q_D(QWaylandQuickItem);
+ if (d->connectedWindow) {
+ disconnect(d->connectedWindow, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickItem::beforeSync);
+ }
+
+ d->connectedWindow = window();
+
+ if (d->connectedWindow) {
+ connect(d->connectedWindow, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickItem::beforeSync, Qt::DirectConnection);
+ }
+
+ if (compositor() && d->connectedWindow) {
+ QWaylandOutput *output = compositor()->outputFor(d->connectedWindow);
+ Q_ASSERT(output);
+ d->view->setOutput(output);
+ }
+}
+
+void QWaylandQuickItem::beforeSync()
+{
+ Q_D(QWaylandQuickItem);
+ if (d->view->advance()) {
+ d->newTexture = true;
+ update();
+ }
+}
+
+QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ Q_D(QWaylandQuickItem);
+ bool mapped = (surface() && surface()->isMapped() && d->view->currentBuffer().hasBuffer())
+ || (d->view->isBufferLocked() && d->provider);
+
+ if (!mapped || !d->paintEnabled) {
+ delete oldNode;
+ return 0;
+ }
+
+ QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode);
+
+ if (!node)
+ node = new QSGSimpleTextureNode();
+
+ if (!d->provider)
+ d->provider = new QWaylandSurfaceTextureProvider();
+
+ if (d->newTexture) {
+ d->newTexture = false;
+ d->provider->setBufferRef(this, d->view->currentBuffer());
+ node->setTexture(d->provider->texture());
+ }
+
+ d->provider->setSmooth(smooth());
+
+ if (d->provider->invertY()) {
+ node->setRect(0, height(), width(), -height());
+ } else {
+ node->setRect(0, 0, width(), height());
+ }
+
+ return node;
+}
+
+void QWaylandQuickItem::setTouchEventsEnabled(bool enabled)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->touchEventsEnabled != enabled) {
+ d->touchEventsEnabled = enabled;
+ emit touchEventsEnabledChanged();
+ }
+}
+
+bool QWaylandQuickItem::inputEventsEnabled() const
+{
+ Q_D(const QWaylandQuickItem);
+ return d->inputEventsEnabled;
+}
+
+void QWaylandQuickItem::setInputEventsEnabled(bool enabled)
+{
+ Q_D(QWaylandQuickItem);
+ if (d->inputEventsEnabled != enabled) {
+ d->inputEventsEnabled = enabled;
+ setAcceptHoverEvents(enabled);
+ emit inputEventsEnabledChanged();
+ }
+}
+
+void QWaylandQuickItem::lower()
+{
+ QQuickItem *parent = parentItem();
+ Q_ASSERT(parent);
+ QQuickItem *bottom = parent->childItems().first();
+ if (this != bottom)
+ stackBefore(bottom);
+}
+
+void QWaylandQuickItem::raise()
+{
+ QQuickItem *parent = parentItem();
+ Q_ASSERT(parent);
+ QQuickItem *top = parent->childItems().last();
+ if (this != top)
+ stackAfter(top);
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h
new file mode 100644
index 00000000..41f1d533
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandquickitem.h
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDSURFACEITEM_H
+#define QWAYLANDSURFACEITEM_H
+
+#include <QtWaylandCompositor/qwaylandexport.h>
+
+#include <QtQuick/QQuickItem>
+#include <QtQuick/qsgtexture.h>
+
+#include <QtQuick/qsgtextureprovider.h>
+
+#include <QtWaylandCompositor/qwaylandview.h>
+#include <QtWaylandCompositor/qwaylandquicksurface.h>
+
+Q_DECLARE_METATYPE(QWaylandQuickSurface*)
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandInputDevice;
+class QWaylandQuickItemPrivate;
+
+class Q_COMPOSITOR_EXPORT QWaylandQuickItem : public QQuickItem
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandQuickItem)
+ Q_PROPERTY(QWaylandView *view READ view CONSTANT)
+ Q_PROPERTY(QWaylandCompositor *compositor READ compositor)
+ Q_PROPERTY(QWaylandSurface *surface READ surface WRITE setSurface NOTIFY surfaceChanged)
+ Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled)
+ Q_PROPERTY(bool touchEventsEnabled READ touchEventsEnabled WRITE setTouchEventsEnabled NOTIFY touchEventsEnabledChanged)
+ Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged)
+ Q_PROPERTY(bool inputEventsEnabled READ inputEventsEnabled WRITE setInputEventsEnabled NOTIFY inputEventsEnabledChanged)
+ Q_PROPERTY(bool focusOnClick READ focusOnClick WRITE setFocusOnClick NOTIFY focusOnClickChanged)
+ Q_PROPERTY(bool sizeFollowsSurface READ sizeFollowsSurface WRITE setSizeFollowsSurface NOTIFY sizeFollowsSurfaceChanged)
+
+public:
+ QWaylandQuickItem(QQuickItem *parent = 0);
+ ~QWaylandQuickItem();
+
+ QWaylandCompositor *compositor() const;
+ QWaylandView *view() const;
+
+ QWaylandSurface *surface() const;
+ void setSurface(QWaylandSurface *surface);
+
+ QWaylandSurface::Origin origin() const;
+
+ bool isTextureProvider() const { return true; }
+ QSGTextureProvider *textureProvider() const;
+
+ bool paintEnabled() const;
+ bool touchEventsEnabled() const;
+
+ void setTouchEventsEnabled(bool enabled);
+
+ bool inputEventsEnabled() const;
+ void setInputEventsEnabled(bool enabled);
+
+ bool focusOnClick() const;
+ void setFocusOnClick(bool focus);
+
+ bool inputRegionContains(const QPointF &localPosition);
+
+ bool sizeFollowsSurface() const;
+ void setSizeFollowsSurface(bool sizeFollowsSurface);
+
+protected:
+ void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE;
+ void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE;
+ void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+
+ void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
+ void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
+
+ void touchEvent(QTouchEvent *event) Q_DECL_OVERRIDE;
+ void mouseUngrabEvent() Q_DECL_OVERRIDE;
+
+ virtual void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
+public Q_SLOTS:
+ virtual void takeFocus(QWaylandInputDevice *device = 0);
+ void setPaintEnabled(bool paintEnabled);
+ void raise();
+ void lower();
+
+private Q_SLOTS:
+ void surfaceMappedChanged();
+ void handleSurfaceChanged();
+ void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent);
+ void updateSize();
+ void updateBuffer(bool hasBuffer);
+ void updateWindow();
+ void beforeSync();
+
+Q_SIGNALS:
+ void surfaceChanged();
+ void touchEventsEnabledChanged();
+ void originChanged();
+ void surfaceDestroyed();
+ void inputEventsEnabledChanged();
+ void focusOnClickChanged();
+ void mouseMove(const QPointF &windowPosition);
+ void mouseRelease();
+ void sizeFollowsSurfaceChanged();
+
+protected:
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+
+ QWaylandQuickItem(QWaylandQuickItemPrivate &dd, QQuickItem *parent = 0);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h
new file mode 100644
index 00000000..2a5686f3
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandquickitem_p.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDQUICKITEM_P_H
+#define QWAYLANDQUICKITEM_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuick/private/qquickitem_p.h>
+
+#include "qwaylandquickitem.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandSurfaceTextureProvider;
+class QMutex;
+
+class QWaylandQuickItemPrivate : public QQuickItemPrivate
+{
+ Q_DECLARE_PUBLIC(QWaylandQuickItem)
+public:
+ QWaylandQuickItemPrivate()
+ : QQuickItemPrivate()
+ , view(Q_NULLPTR)
+ , oldSurface(Q_NULLPTR)
+ , provider(Q_NULLPTR)
+ , paintEnabled(true)
+ , touchEventsEnabled(false)
+ , inputEventsEnabled(true)
+ , newTexture(false)
+ , focusOnClick(true)
+ , sizeFollowsSurface(true)
+ , connectedWindow(Q_NULLPTR)
+ , origin(QWaylandSurface::OriginTopLeft)
+ {
+ }
+
+ void init()
+ {
+ Q_Q(QWaylandQuickItem);
+ if (!mutex)
+ mutex = new QMutex;
+
+ view.reset(new QWaylandView(q));
+ q->setFlag(QQuickItem::ItemHasContents);
+
+ q->update();
+
+ q->setSmooth(true);
+
+ q->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);
+ q->setAcceptHoverEvents(true);
+
+ QObject::connect(q, &QQuickItem::windowChanged, q, &QWaylandQuickItem::updateWindow);
+ QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::surfaceChanged);
+ QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::handleSurfaceChanged);
+ QObject::connect(view.data(), &QWaylandView::surfaceDestroyed, q, &QWaylandQuickItem::surfaceDestroyed);
+ }
+
+ bool shouldSendInputEvents() const { return view->surface() && inputEventsEnabled; }
+
+ static QMutex *mutex;
+
+ QScopedPointer<QWaylandView> view;
+ QWaylandSurface *oldSurface;
+ mutable QWaylandSurfaceTextureProvider *provider;
+ bool paintEnabled;
+ bool touchEventsEnabled;
+ bool inputEventsEnabled;
+ bool newTexture;
+ bool focusOnClick;
+ bool sizeFollowsSurface;
+
+ QQuickWindow *connectedWindow;
+ QWaylandSurface::Origin origin;
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDQUICKITEM_P_H*/
diff --git a/src/compositor/compositor_api/qwaylandquickoutput.cpp b/src/compositor/compositor_api/qwaylandquickoutput.cpp
index 9199ff84..8abf6cbb 100644
--- a/src/compositor/compositor_api/qwaylandquickoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandquickoutput.cpp
@@ -4,9 +4,9 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -17,16 +17,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -37,34 +40,84 @@
QT_BEGIN_NAMESPACE
-QWaylandQuickOutput::QWaylandQuickOutput(QWaylandCompositor *compositor, QQuickWindow *window,
- const QString &manufacturer, const QString &model)
- : QWaylandOutput(compositor, window, manufacturer, model)
+QWaylandQuickOutput::QWaylandQuickOutput()
+ : QWaylandOutput()
, m_updateScheduled(false)
+ , m_automaticFrameCallback(true)
+{
+}
+
+QWaylandQuickOutput::QWaylandQuickOutput(QWaylandCompositor *compositor, QWindow *window)
+ : QWaylandOutput(compositor, window)
+ , m_updateScheduled(false)
+ , m_automaticFrameCallback(true)
{
- connect(window, &QQuickWindow::beforeSynchronizing,
- this, &QWaylandQuickOutput::updateStarted,
- Qt::DirectConnection);
}
-QQuickWindow *QWaylandQuickOutput::quickWindow() const
+void QWaylandQuickOutput::initialize()
{
- return static_cast<QQuickWindow *>(window());
+ QWaylandOutput::initialize();
+
+ QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(window());
+ if (!quickWindow) {
+ qWarning("Initialization error: Could not locate QQuickWindow on initializing QWaylandQuickOutput %p.\n", this);
+ return;
+ }
+ connect(quickWindow, &QQuickWindow::beforeSynchronizing,
+ this, &QWaylandQuickOutput::updateStarted,
+ Qt::DirectConnection);
+
+ connect(quickWindow, &QQuickWindow::beforeRendering,
+ this, &QWaylandQuickOutput::doFrameCallbacks);
}
void QWaylandQuickOutput::update()
{
if (!m_updateScheduled) {
- quickWindow()->update();
+ //don't qobject_cast since we have verified the type in initialize
+ static_cast<QQuickWindow *>(window())->update();
m_updateScheduled = true;
}
}
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandOutput::automaticFrameCallback
+ *
+ * This property holds whether the WaylandOutput automatically sends frame
+ * callbacks when rendering.
+ *
+ * The default is true.
+ */
+bool QWaylandQuickOutput::automaticFrameCallback() const
+{
+ return m_automaticFrameCallback;
+}
+
+void QWaylandQuickOutput::setAutomaticFrameCallback(bool automatic)
+{
+ if (m_automaticFrameCallback == automatic)
+ return;
+
+ m_automaticFrameCallback = automatic;
+ automaticFrameCallbackChanged();
+}
+
+/*!
+ * \internal
+ */
void QWaylandQuickOutput::updateStarted()
{
m_updateScheduled = false;
- compositor()->frameStarted();
- compositor()->cleanupGraphicsResources();
+
+ if (!compositor())
+ return;
+
+ frameStarted();
}
+void QWaylandQuickOutput::doFrameCallbacks()
+{
+ if (m_automaticFrameCallback)
+ sendFrameCallbacks();
+}
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandquickoutput.h b/src/compositor/compositor_api/qwaylandquickoutput.h
index 70286710..48f47845 100644
--- a/src/compositor/compositor_api/qwaylandquickoutput.h
+++ b/src/compositor/compositor_api/qwaylandquickoutput.h
@@ -4,9 +4,9 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -17,16 +17,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -36,7 +39,7 @@
#define QWAYLANDQUICKOUTPUT_H
#include <QtQuick/QQuickWindow>
-#include <QtCompositor/qwaylandoutput.h>
+#include <QtWaylandCompositor/qwaylandoutput.h>
QT_BEGIN_NAMESPACE
@@ -46,19 +49,30 @@ class QQuickWindow;
class Q_COMPOSITOR_EXPORT QWaylandQuickOutput : public QWaylandOutput
{
Q_OBJECT
+ Q_PROPERTY(bool automaticFrameCallback READ automaticFrameCallback WRITE setAutomaticFrameCallback NOTIFY automaticFrameCallbackChanged)
public:
- QWaylandQuickOutput(QWaylandCompositor *compositor, QQuickWindow *window,
- const QString &manufacturer, const QString &model);
-
- QQuickWindow *quickWindow() const;
+ QWaylandQuickOutput();
+ QWaylandQuickOutput(QWaylandCompositor *compositor, QWindow *window);
void update() Q_DECL_OVERRIDE;
+ bool automaticFrameCallback() const;
+ void setAutomaticFrameCallback(bool automatic);
+
public Q_SLOTS:
void updateStarted();
+Q_SIGNALS:
+ void automaticFrameCallbackChanged();
+
+protected:
+ void initialize() Q_DECL_OVERRIDE;
+
private:
+ void doFrameCallbacks();
+
bool m_updateScheduled;
+ bool m_automaticFrameCallback;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp
index 3d52b862..0fc07c6c 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.cpp
+++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp
@@ -3,9 +3,9 @@
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -35,75 +38,59 @@
#include <QOpenGLTexture>
#include <QQuickWindow>
#include <QDebug>
-#include <QQmlPropertyMap>
#include "qwaylandquicksurface.h"
#include "qwaylandquickcompositor.h"
-#include "qwaylandsurfaceitem.h"
-#include "qwaylandoutput.h"
-#include <QtCompositor/private/qwaylandsurface_p.h>
-#include <QtCompositor/private/qwaylandtexturebufferattacher_p.h>
+#include "qwaylandquickitem.h"
+#include <QtWaylandCompositor/qwaylandbufferref.h>
+#include <QtWaylandCompositor/QWaylandView>
+#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
+
+#include <QtWaylandCompositor/private/qwayland-server-surface-extension.h>
+#include <QtWaylandCompositor/private/qwlextendedsurface_p.h>
QT_BEGIN_NAMESPACE
class QWaylandQuickSurfacePrivate : public QWaylandSurfacePrivate
{
+ Q_DECLARE_PUBLIC(QWaylandQuickSurface)
public:
- QWaylandQuickSurfacePrivate(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *c, QWaylandQuickSurface *surf)
- : QWaylandSurfacePrivate(client, id, version, c, surf)
- , compositor(c)
+ QWaylandQuickSurfacePrivate()
+ : QWaylandSurfacePrivate()
, useTextureAlpha(true)
- , windowPropertyMap(new QQmlPropertyMap)
, clientRenderingEnabled(true)
{
-
}
~QWaylandQuickSurfacePrivate()
{
- windowPropertyMap->deleteLater();
- // buffer is deleted automatically by ~Surface(), since it is the assigned attacher
- }
-
- void surface_commit(Resource *resource) Q_DECL_OVERRIDE
- {
- QWaylandSurfacePrivate::surface_commit(resource);
-
- Q_FOREACH (QtWayland::Output *output, outputs())
- output->waylandOutput()->update();
}
- QWaylandQuickCompositor *compositor;
bool useTextureAlpha;
- QQmlPropertyMap *windowPropertyMap;
bool clientRenderingEnabled;
};
-QWaylandQuickSurface::QWaylandQuickSurface(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *compositor)
- : QWaylandSurface(new QWaylandQuickSurfacePrivate(client, id, version, compositor, this))
+QWaylandQuickSurface::QWaylandQuickSurface()
+ : QWaylandSurface(* new QWaylandQuickSurfacePrivate())
{
- Q_D(QWaylandQuickSurface);
- QWaylandSurface::setBufferAttacher(new QWaylandTextureBufferAttacher(this));
- connect(this, &QWaylandSurface::windowPropertyChanged, d->windowPropertyMap, &QQmlPropertyMap::insert);
- connect(d->windowPropertyMap, &QQmlPropertyMap::valueChanged, this, &QWaylandSurface::setWindowProperty);
}
-
-QWaylandQuickSurface::~QWaylandQuickSurface()
+QWaylandQuickSurface::QWaylandQuickSurface(QWaylandCompositor *compositor, QWaylandClient *client, quint32 id, int version)
+ : QWaylandSurface(* new QWaylandQuickSurfacePrivate())
{
-
+ initialize(compositor, client, id, version);
}
-QWaylandTextureBufferAttacher *QWaylandQuickSurface::textureBufferAttacher() const
+QWaylandQuickSurface::~QWaylandQuickSurface()
{
- return static_cast<QWaylandTextureBufferAttacher*>(bufferAttacher());
-}
-QSGTexture *QWaylandQuickSurface::texture() const
-{
- return textureBufferAttacher()->texture();
}
+/*!
+ * \qmlproperty QtWaylandCompositor::WaylandSurface::useTextureAlpha
+ *
+ * This property specifies whether the surface should use texture alpha.
+ */
bool QWaylandQuickSurface::useTextureAlpha() const
{
Q_D(const QWaylandQuickSurface);
@@ -116,69 +103,15 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha)
if (d->useTextureAlpha != useTextureAlpha) {
d->useTextureAlpha = useTextureAlpha;
emit useTextureAlphaChanged();
- emit configure(textureBufferAttacher()->currentBuffer());
- }
-}
-
-QObject *QWaylandQuickSurface::windowPropertyMap() const
-{
- Q_D(const QWaylandQuickSurface);
- return d->windowPropertyMap;
-}
-
-bool QWaylandQuickSurface::event(QEvent *e)
-{
- if (e->type() == static_cast<QEvent::Type>(QWaylandSurfaceLeaveEvent::WaylandSurfaceLeave)) {
- QWaylandSurfaceLeaveEvent *event = static_cast<QWaylandSurfaceLeaveEvent *>(e);
-
- if (event->output()) {
- QQuickWindow *oldWindow = static_cast<QQuickWindow *>(event->output()->window());
- disconnect(oldWindow, &QQuickWindow::beforeSynchronizing,
- this, &QWaylandQuickSurface::updateTexture);
- disconnect(oldWindow, &QQuickWindow::sceneGraphInvalidated,
- this, &QWaylandQuickSurface::invalidateTexture);
- }
-
- return true;
- }
-
- if (e->type() == static_cast<QEvent::Type>(QWaylandSurfaceEnterEvent::WaylandSurfaceEnter)) {
- QWaylandSurfaceEnterEvent *event = static_cast<QWaylandSurfaceEnterEvent *>(e);
-
- if (event->output()) {
- QQuickWindow *window = static_cast<QQuickWindow *>(event->output()->window());
- connect(window, &QQuickWindow::beforeSynchronizing,
- this, &QWaylandQuickSurface::updateTexture,
- Qt::DirectConnection);
- connect(window, &QQuickWindow::sceneGraphInvalidated,
- this, &QWaylandQuickSurface::invalidateTexture,
- Qt::DirectConnection);
- }
-
- return true;
+ emit configure(d->bufferRef.hasBuffer());
}
-
- return QObject::event(e);
-}
-
-void QWaylandQuickSurface::updateTexture()
-{
- QWaylandTextureBufferAttacher *attacher = textureBufferAttacher();
- const bool update = attacher->isDirty();
- if (update)
- attacher->updateTexture();
- foreach (QWaylandSurfaceView *view, views())
- static_cast<QWaylandSurfaceItem *>(view)->updateTexture(update);
-}
-
-void QWaylandQuickSurface::invalidateTexture()
-{
- textureBufferAttacher()->invalidateTexture();
- foreach (QWaylandSurfaceView *view, views())
- static_cast<QWaylandSurfaceItem *>(view)->updateTexture(true);
- emit redraw();
}
+/*!
+ * \qmlproperty QtWaylandCompositor::WaylandSurface::clientRenderingEnabled
+ *
+ * This property specifies whether client rendering is enabled for the surface.
+ */
bool QWaylandQuickSurface::clientRenderingEnabled() const
{
Q_D(const QWaylandQuickSurface);
@@ -191,7 +124,8 @@ void QWaylandQuickSurface::setClientRenderingEnabled(bool enabled)
if (d->clientRenderingEnabled != enabled) {
d->clientRenderingEnabled = enabled;
- sendOnScreenVisibilityChange(enabled);
+ if (QtWayland::ExtendedSurface *extSurface = QtWayland::ExtendedSurface::findIn(this))
+ extSurface->setVisibility(enabled ? QWindow::AutomaticVisibility : QWindow::Hidden);
emit clientRenderingEnabledChanged();
}
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h
index 9126f8ff..ba53c82f 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.h
+++ b/src/compositor/compositor_api/qwaylandquicksurface.h
@@ -3,9 +3,9 @@
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -34,20 +37,14 @@
#ifndef QQUICKWAYLANDSURFACE_H
#define QQUICKWAYLANDSURFACE_H
-#include <QtCompositor/qwaylandsurface.h>
-#include <QtCompositor/qwaylandbufferref.h>
+#include <QtWaylandCompositor/qwaylandsurface.h>
struct wl_client;
QT_BEGIN_NAMESPACE
-class QSGTexture;
-
-class QWaylandSurfaceItem;
class QWaylandQuickSurfacePrivate;
class QWaylandQuickCompositor;
-class QWaylandQuickSurface;
-class QWaylandTextureBufferAttacher;
class Q_COMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface
{
@@ -55,34 +52,20 @@ class Q_COMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface
Q_DECLARE_PRIVATE(QWaylandQuickSurface)
Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha NOTIFY useTextureAlphaChanged)
Q_PROPERTY(bool clientRenderingEnabled READ clientRenderingEnabled WRITE setClientRenderingEnabled NOTIFY clientRenderingEnabledChanged)
- Q_PROPERTY(QObject *windowProperties READ windowPropertyMap CONSTANT)
public:
- QWaylandQuickSurface(wl_client *client, quint32 id, int version, QWaylandQuickCompositor *compositor);
+ QWaylandQuickSurface();
+ QWaylandQuickSurface(QWaylandCompositor *compositor, QWaylandClient *client, quint32 id, int version);
~QWaylandQuickSurface();
- QSGTexture *texture() const;
-
bool useTextureAlpha() const;
void setUseTextureAlpha(bool useTextureAlpha);
bool clientRenderingEnabled() const;
void setClientRenderingEnabled(bool enabled);
- QObject *windowPropertyMap() const;
-
- QWaylandTextureBufferAttacher *textureBufferAttacher() const;
-
-private:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
-
Q_SIGNALS:
void useTextureAlphaChanged();
void clientRenderingEnabledChanged();
-
-private:
- void updateTexture();
- void invalidateTexture();
-
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index 64f78bd7..3ac791eb 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -4,521 +4,777 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandsurface.h"
+#include "qwaylandsurface_p.h"
-#include <private/qobject_p.h>
-
-#include "wayland_wrapper/qwlsurface_p.h"
-#include "wayland_wrapper/qwlextendedsurface_p.h"
-#include "wayland_wrapper/qwlcompositor_p.h"
-#include "wayland_wrapper/qwlshellsurface_p.h"
-#include "wayland_wrapper/qwlinputdevice_p.h"
#include "wayland_wrapper/qwldatadevice_p.h"
#include "wayland_wrapper/qwldatadevicemanager_p.h"
+#include "wayland_wrapper/qwlregion_p.h"
-#include "qwaylandcompositor.h"
-#include "qwaylandclient.h"
-#include "qwaylandsurface_p.h"
-#include "qwaylandbufferref.h"
-#include "qwaylandsurfaceinterface.h"
+#include "extensions/qwlextendedsurface_p.h"
-#include <QtGui/QGuiApplication>
-#include <QtGui/QScreen>
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandClient>
+#include <QtWaylandCompositor/QWaylandView>
+#include <QtWaylandCompositor/QWaylandBufferRef>
-QT_BEGIN_NAMESPACE
+#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
+#include <QtWaylandCompositor/private/qwaylandview_p.h>
+#include <QtWaylandCompositor/private/qwaylandinput_p.h>
-const QEvent::Type QWaylandSurfaceEnterEvent::WaylandSurfaceEnter = (QEvent::Type)QEvent::registerEventType();
-const QEvent::Type QWaylandSurfaceLeaveEvent::WaylandSurfaceLeave = (QEvent::Type)QEvent::registerEventType();
+#include <QtCore/private/qobject_p.h>
-QWaylandSurfacePrivate::QWaylandSurfacePrivate(wl_client *wlClient, quint32 id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface)
- : QtWayland::Surface(wlClient, id, version, compositor, surface)
- , closing(false)
- , refCount(1)
- , client(QWaylandClient::fromWlClient(wlClient))
- , windowType(QWaylandSurface::None)
-{}
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
+#include <QtCore/QDebug>
-class QWaylandSurfaceEnterEventPrivate
-{
+QT_BEGIN_NAMESPACE
+
+namespace QtWayland {
+class FrameCallback {
public:
- QWaylandSurfaceEnterEventPrivate(QWaylandOutput *_output)
- : output(_output)
+ FrameCallback(QWaylandSurface *surf, wl_resource *res)
+ : surface(surf)
+ , resource(res)
+ , canSend(false)
{
+#if WAYLAND_VERSION_MAJOR < 1 || (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR <= 2)
+ res->data = this;
+ res->destroy = destroyCallback;
+#else
+ wl_resource_set_implementation(res, 0, this, destroyCallback);
+#endif
}
-
- QWaylandOutput *output;
+ ~FrameCallback()
+ {
+ }
+ void destroy()
+ {
+ if (resource)
+ wl_resource_destroy(resource);
+ else
+ delete this;
+ }
+ void send(uint time)
+ {
+ wl_callback_send_done(resource, time);
+ wl_resource_destroy(resource);
+ }
+ static void destroyCallback(wl_resource *res)
+ {
+#if WAYLAND_VERSION_MAJOR < 1 || (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR <= 2)
+ FrameCallback *_this = static_cast<FrameCallback *>(res->data);
+#else
+ FrameCallback *_this = static_cast<FrameCallback *>(wl_resource_get_user_data(res));
+#endif
+ if (_this->surface)
+ QWaylandSurfacePrivate::get(_this->surface)->removeFrameCallback(_this);
+ delete _this;
+ }
+ QWaylandSurface *surface;
+ wl_resource *resource;
+ bool canSend;
};
-
-
-QWaylandSurfaceEnterEvent::QWaylandSurfaceEnterEvent(QWaylandOutput *output)
- : QEvent(WaylandSurfaceEnter)
- , d(new QWaylandSurfaceEnterEventPrivate(output))
-{
-}
-
-QWaylandSurfaceEnterEvent::~QWaylandSurfaceEnterEvent()
-{
- delete d;
}
-
-QWaylandOutput *QWaylandSurfaceEnterEvent::output() const
-{
- return d->output;
+static QRegion infiniteRegion() {
+ return QRegion(QRect(QPoint(std::numeric_limits<int>::min(), std::numeric_limits<int>::min()),
+ QPoint(std::numeric_limits<int>::max(), std::numeric_limits<int>::max())));
}
+#ifndef QT_NO_DEBUG
+QList<QWaylandSurfacePrivate *> QWaylandSurfacePrivate::uninitializedSurfaces;
+#endif
-class QWaylandSurfaceLeaveEventPrivate
-{
-public:
- QWaylandSurfaceLeaveEventPrivate(QWaylandOutput *_output)
- : output(_output)
- {
+QWaylandSurfacePrivate::QWaylandSurfacePrivate()
+ : QtWaylandServer::wl_surface()
+ , compositor(Q_NULLPTR)
+ , refCount(1)
+ , client(Q_NULLPTR)
+ , buffer(0)
+ , inputPanelSurface(0)
+ , inputRegion(infiniteRegion())
+ , isCursorSurface(false)
+ , destroyed(false)
+ , mapped(false)
+ , isInitialized(false)
+ , contentOrientation(Qt::PrimaryOrientation)
+{
+ pending.buffer = 0;
+ pending.newlyAttached = false;
+ pending.inputRegion = infiniteRegion();
+#ifndef QT_NO_DEBUG
+ addUninitializedSurface(this);
+#endif
+}
+
+QWaylandSurfacePrivate::~QWaylandSurfacePrivate()
+{
+ for (int i = 0; i < views.size(); i++) {
+ QWaylandViewPrivate::get(views.at(i))->markSurfaceAsDestroyed(q_func());
}
+ views.clear();
- QWaylandOutput *output;
-};
+ bufferRef = QWaylandBufferRef();
+ for (int i = 0; i < bufferPool.size(); i++)
+ bufferPool[i]->setDestroyIfUnused(true);
-QWaylandSurfaceLeaveEvent::QWaylandSurfaceLeaveEvent(QWaylandOutput *output)
- : QEvent(WaylandSurfaceLeave)
- , d(new QWaylandSurfaceLeaveEventPrivate(output))
-{
+ foreach (QtWayland::FrameCallback *c, pendingFrameCallbacks)
+ c->destroy();
+ foreach (QtWayland::FrameCallback *c, frameCallbacks)
+ c->destroy();
}
-QWaylandSurfaceLeaveEvent::~QWaylandSurfaceLeaveEvent()
+void QWaylandSurfacePrivate::setSize(const QSize &s)
{
- delete d;
+ Q_Q(QWaylandSurface);
+ if (size != s) {
+ opaqueRegion = QRegion();
+ size = s;
+ q->sizeChanged();
+ }
}
-QWaylandOutput *QWaylandSurfaceLeaveEvent::output() const
+void QWaylandSurfacePrivate::removeFrameCallback(QtWayland::FrameCallback *callback)
{
- return d->output;
+ pendingFrameCallbacks.removeOne(callback);
+ frameCallbacks.removeOne(callback);
}
-
-QWaylandSurface::QWaylandSurface(wl_client *client, quint32 id, int version, QWaylandCompositor *compositor)
- : QObject(*new QWaylandSurfacePrivate(client, id, version, compositor, this))
+void QWaylandSurfacePrivate::notifyViewsAboutDestruction()
{
-
+ Q_Q(QWaylandSurface);
+ foreach (QWaylandView *view, views) {
+ QWaylandViewPrivate::get(view)->markSurfaceAsDestroyed(q);
+ }
+ if (mapped) {
+ mapped = false;
+ emit q->mappedChanged();
+ }
}
-QWaylandSurface::QWaylandSurface(QWaylandSurfacePrivate *dptr)
- : QObject(*dptr)
+#ifndef QT_NO_DEBUG
+void QWaylandSurfacePrivate::addUninitializedSurface(QWaylandSurfacePrivate *surface)
{
-
+ Q_ASSERT(!surface->isInitialized);
+ Q_ASSERT(!uninitializedSurfaces.contains(surface));
+ uninitializedSurfaces.append(surface);
}
-QWaylandSurface::~QWaylandSurface()
+void QWaylandSurfacePrivate::removeUninitializedSurface(QWaylandSurfacePrivate *surface)
{
- Q_D(QWaylandSurface);
- qDeleteAll(d->interfaces);
- delete d->m_attacher;
+ Q_ASSERT(surface->isInitialized);
+ bool removed = uninitializedSurfaces.removeOne(surface);
+ Q_ASSERT(removed);
}
-QWaylandClient *QWaylandSurface::client() const
+bool QWaylandSurfacePrivate::hasUninitializedSurface()
{
- Q_D(const QWaylandSurface);
- if (d->isDestroyed() || !d->compositor()->clients().contains(d->client))
- return Q_NULLPTR;
- return d->client;
+ return uninitializedSurfaces.size();
}
+#endif
-void QWaylandSurface::addInterface(QWaylandSurfaceInterface *iface)
+void QWaylandSurfacePrivate::surface_destroy_resource(Resource *)
{
- Q_D(QWaylandSurface);
- d->interfaces.prepend(iface);
+ Q_Q(QWaylandSurface);
+ notifyViewsAboutDestruction();
+
+ destroyed = true;
+ emit q->surfaceDestroyed();
+ q->destroy();
}
-void QWaylandSurface::removeInterface(QWaylandSurfaceInterface *iface)
+void QWaylandSurfacePrivate::surface_destroy(Resource *resource)
{
- Q_D(QWaylandSurface);
- d->interfaces.removeOne(iface);
+ wl_resource_destroy(resource->handle);
}
-QWaylandSurface::Type QWaylandSurface::type() const
+void QWaylandSurfacePrivate::surface_attach(Resource *, struct wl_resource *buffer, int x, int y)
{
- Q_D(const QWaylandSurface);
- return d->type();
+ if (pending.buffer)
+ pending.buffer->disown();
+ pending.buffer = createSurfaceBuffer(buffer);
+ pending.offset = QPoint(x, y);
+ pending.newlyAttached = true;
}
-bool QWaylandSurface::isYInverted() const
+void QWaylandSurfacePrivate::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height)
{
- Q_D(const QWaylandSurface);
- return d->isYInverted();
+ pending.damage = pending.damage.united(QRect(x, y, width, height));
}
-bool QWaylandSurface::visible() const
+void QWaylandSurfacePrivate::surface_frame(Resource *resource, uint32_t callback)
{
- return isMapped();
+ Q_Q(QWaylandSurface);
+ struct wl_resource *frame_callback = wl_resource_create(resource->client(), &wl_callback_interface, wl_callback_interface.version, callback);
+ pendingFrameCallbacks << new QtWayland::FrameCallback(q, frame_callback);
}
-bool QWaylandSurface::isMapped() const
+void QWaylandSurfacePrivate::surface_set_opaque_region(Resource *, struct wl_resource *region)
{
- Q_D(const QWaylandSurface);
- return d->mapped();
+ opaqueRegion = region ? QtWayland::Region::fromResource(region)->region() : QRegion();
}
-QSize QWaylandSurface::size() const
+void QWaylandSurfacePrivate::surface_set_input_region(Resource *, struct wl_resource *region)
{
- Q_D(const QWaylandSurface);
- return d->size();
+ if (region) {
+ pending.inputRegion = QtWayland::Region::fromResource(region)->region();
+ } else {
+ pending.inputRegion = infiniteRegion();
+ }
}
-void QWaylandSurface::requestSize(const QSize &size)
+void QWaylandSurfacePrivate::surface_commit(Resource *)
{
- Q_D(QWaylandSurface);
- QWaylandSurfaceResizeOp op(size);
- if (!sendInterfaceOp(op)) {
- int id = wl_resource_get_id(d->resource()->handle);
- qWarning("No surface interface forwarded the resize request for this surface (wl_surface@%d).", id);
+ Q_Q(QWaylandSurface);
+
+ if (pending.buffer || pending.newlyAttached) {
+ setBackBuffer(pending.buffer, pending.damage);
}
+
+ pending.buffer = 0;
+ pending.offset = QPoint();
+ pending.newlyAttached = false;
+ pending.damage = QRegion();
+
+ if (buffer)
+ buffer->setCommitted();
+
+ frameCallbacks << pendingFrameCallbacks;
+ pendingFrameCallbacks.clear();
+
+ inputRegion = pending.inputRegion.intersected(QRect(QPoint(), size));
+
+ emit q->redraw();
}
-Qt::ScreenOrientations QWaylandSurface::orientationUpdateMask() const
+void QWaylandSurfacePrivate::surface_set_buffer_transform(Resource *resource, int32_t orientation)
{
- Q_D(const QWaylandSurface);
- if (!d->extendedSurface())
- return Qt::PrimaryOrientation;
- return d->extendedSurface()->contentOrientationMask();
+ Q_UNUSED(resource);
+ Q_Q(QWaylandSurface);
+ QScreen *screen = QGuiApplication::primaryScreen();
+ bool isPortrait = screen->primaryOrientation() == Qt::PortraitOrientation;
+ Qt::ScreenOrientation oldOrientation = contentOrientation;
+ switch (orientation) {
+ case WL_OUTPUT_TRANSFORM_90:
+ contentOrientation = isPortrait ? Qt::InvertedLandscapeOrientation : Qt::PortraitOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ contentOrientation = isPortrait ? Qt::InvertedPortraitOrientation : Qt::InvertedLandscapeOrientation;
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ contentOrientation = isPortrait ? Qt::LandscapeOrientation : Qt::InvertedPortraitOrientation;
+ break;
+ default:
+ contentOrientation = Qt::PrimaryOrientation;
+ }
+ if (contentOrientation != oldOrientation)
+ emit q->contentOrientationChanged();
}
-Qt::ScreenOrientation QWaylandSurface::contentOrientation() const
+void QWaylandSurfacePrivate::setBackBuffer(QtWayland::SurfaceBuffer *b, const QRegion &d)
{
- Q_D(const QWaylandSurface);
- return d->contentOrientation();
+ Q_Q(QWaylandSurface);
+ buffer = b;
+
+ bufferRef = QWaylandBufferRef(buffer);
+
+ setSize(bufferRef.size());
+ damage = d.intersected(QRect(QPoint(), size));
+
+ for (int i = 0; i < views.size(); i++) {
+ views.at(i)->attach(bufferRef, damage);
+ }
+
+ emit q->damaged(damage);
+
+ bool oldMapped = mapped;
+ mapped = QtWayland::SurfaceBuffer::hasContent(buffer);
+ if (oldMapped != mapped)
+ emit q->mappedChanged();
+
+ if (!pending.offset.isNull())
+ emit q->offsetForNextFrame(pending.offset);
}
-QWaylandSurface::WindowFlags QWaylandSurface::windowFlags() const
+QtWayland::SurfaceBuffer *QWaylandSurfacePrivate::createSurfaceBuffer(struct ::wl_resource *buffer)
{
- Q_D(const QWaylandSurface);
- if (!d->extendedSurface())
- return QWaylandSurface::WindowFlags(0);
- return d->extendedSurface()->windowFlags();
+ Q_Q(QWaylandSurface);
+ QtWayland::SurfaceBuffer *newBuffer = 0;
+ for (int i = 0; i < bufferPool.size(); i++) {
+ if (!bufferPool[i]->isRegisteredWithBuffer()) {
+ newBuffer = bufferPool[i];
+ newBuffer->initialize(buffer);
+ break;
+ }
+ }
+
+ if (!newBuffer) {
+ newBuffer = new QtWayland::SurfaceBuffer(q);
+ newBuffer->initialize(buffer);
+ bufferPool.append(newBuffer);
+ if (bufferPool.size() > 3)
+ qWarning() << "Increased buffer pool size to" << bufferPool.size() << "for surface" << q;
+ }
+
+ return newBuffer;
}
-QWaylandSurface::WindowType QWaylandSurface::windowType() const
+/*!
+ * \qmltype WaylandSurface
+ * \inqmlmodule QtWayland.Compositor
+ * \brief A rectangular area which is displayed on an output device.
+ *
+ * This type encapsulates a rectangular area of pixels that is displayed on an output device. It
+ * corresponds to the interface wl_surface in the Wayland protocol.
+ */
+
+/*!
+ * \class QWaylandSurface
+ * \inmodule QtWaylandCompositor
+ * \brief A rectangular area which is displayed on an output device.
+ *
+ * This class encapsulates a rectangular area of pixels that is displayed on an output device. It
+ * corresponds to the interface wl_surface in the Wayland protocol.
+ */
+
+/*!
+ * Constructs a an uninitialized QWaylandSurface.
+ */
+QWaylandSurface::QWaylandSurface()
+ : QWaylandObject(*new QWaylandSurfacePrivate())
{
- Q_D(const QWaylandSurface);
- return d->windowType;
}
-QWaylandSurface *QWaylandSurface::transientParent() const
+/*!
+ * Constructs and initializes a QWaylandSurface for the given \a compositor and \a client, and with the given \a id
+ * and \a version.
+ */
+QWaylandSurface::QWaylandSurface(QWaylandCompositor *compositor, QWaylandClient *client, uint id, int version)
+ : QWaylandObject(*new QWaylandSurfacePrivate())
{
- Q_D(const QWaylandSurface);
- return d->transientParent() ? d->transientParent()->waylandSurface() : 0;
+ initialize(compositor, client, id, version);
}
-QPointF QWaylandSurface::transientOffset() const
+/*!
+ * \internal
+ */
+QWaylandSurface::QWaylandSurface(QWaylandSurfacePrivate &dptr)
+ : QWaylandObject(dptr)
{
- Q_D(const QWaylandSurface);
- return d->m_transientOffset;
}
-QtWayland::Surface * QWaylandSurface::handle()
+/*!
+ * Destroys the QWaylandSurface.
+ */
+QWaylandSurface::~QWaylandSurface()
{
Q_D(QWaylandSurface);
- return d;
+ QWaylandCompositorPrivate::get(d->compositor)->unregisterSurface(this);
+ d->notifyViewsAboutDestruction();
}
-QVariantMap QWaylandSurface::windowProperties() const
-{
- Q_D(const QWaylandSurface);
- if (!d->extendedSurface())
- return QVariantMap();
-
- return d->extendedSurface()->windowProperties();
-}
+/*!
+ * \qmlmethod void QtWaylandCompositor::WaylandSurface::initialize(object compositor, object client, int id, int version)
+ *
+ * Initializes the QWaylandSurface with the given \a compositor and \a client, and with the given \a id
+ * and \a version.
+ */
-void QWaylandSurface::setWindowProperty(const QString &name, const QVariant &value)
+/*!
+ * Initializes the QWaylandSurface with the given \a compositor and \a client, and with the given \a id
+ * and \a version.
+ */
+void QWaylandSurface::initialize(QWaylandCompositor *compositor, QWaylandClient *client, uint id, int version)
{
Q_D(QWaylandSurface);
- if (!d->extendedSurface())
- return;
-
- d->extendedSurface()->setWindowProperty(name, value);
+ d->compositor = compositor;
+ d->client = client;
+ d->init(client->client(), id, version);
+ d->isInitialized = true;
+#ifndef QT_NO_DEBUG
+ QWaylandSurfacePrivate::removeUninitializedSurface(d);
+#endif
}
-QWaylandCompositor *QWaylandSurface::compositor() const
+/*!
+ * Returns true if the QWaylandSurface has been initialized.
+ */
+bool QWaylandSurface::isInitialized() const
{
Q_D(const QWaylandSurface);
- return d->compositor()->waylandCompositor();
+ return d->isInitialized;
}
-QWaylandOutput *QWaylandSurface::mainOutput() const
+/*!
+ * \qmlproperty object QtWaylandCompositor::WaylandSurface::client
+ *
+ * This property holds the client using this QWaylandSurface.
+ */
+
+/*!
+ * \property QWaylandSurface::client
+ *
+ * This property holds the client using this QWaylandSurface.
+ */
+QWaylandClient *QWaylandSurface::client() const
{
Q_D(const QWaylandSurface);
+ if (isDestroyed() || !compositor()->clients().contains(d->client))
+ return Q_NULLPTR;
- // Returns the output that contains the most if not all
- // the surface (window managers will take care of setting
- // this, defaults to the first output)
- return d->mainOutput()->waylandOutput();
+ return d->client;
}
-void QWaylandSurface::setMainOutput(QWaylandOutput *mainOutput)
-{
- Q_D(QWaylandSurface);
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandSurface::isMapped
+ *
+ * This property holds whether the WaylandSurface has content.
+ */
- if (mainOutput)
- d->setMainOutput(mainOutput->handle());
+/*!
+ * \property QWaylandSurface::isMapped
+ *
+ * This property holds whether the QWaylandSurface has content.
+ */
+bool QWaylandSurface::isMapped() const
+{
+ Q_D(const QWaylandSurface);
+ return d->mapped;
}
-QList<QWaylandOutput *> QWaylandSurface::outputs() const
+/*!
+ * \qmlproperty size QtWaylandCompositor::WaylandSurface::size
+ *
+ * This property holds the WaylandSurface's size in pixels.
+ */
+
+/*!
+ * \property QWaylandSurface::size
+ *
+ * This property holds the QWaylandSurface's size in pixels.
+ */
+QSize QWaylandSurface::size() const
{
Q_D(const QWaylandSurface);
-
- QList<QWaylandOutput *> list;
- const QList<QtWayland::Output *> outputs = d->outputs();
- list.reserve(outputs.count());
- Q_FOREACH (QtWayland::Output *output, outputs)
- list.append(output->waylandOutput());
- return list;
+ return d->size;
}
-QWindow::Visibility QWaylandSurface::visibility() const
+/*!
+ * \qmlproperty enum QtWaylandCompositor::WaylandSurface::contentOrientation
+ *
+ * This property holds the orientation of the WaylandSurface's contents.
+ *
+ * \sa QtWaylandCompositor::WaylandOutput::transform
+ */
+
+/*!
+ * \property QWaylandSurface::contentOrientation
+ *
+ * This property holds the orientation of the QWaylandSurface's contents.
+ *
+ * \sa QWaylandOutput::transform
+ */
+Qt::ScreenOrientation QWaylandSurface::contentOrientation() const
{
Q_D(const QWaylandSurface);
- return d->m_visibility;
+ return d->contentOrientation;
}
-void QWaylandSurface::setVisibility(QWindow::Visibility v)
-{
- Q_D(QWaylandSurface);
- if (v == visibility())
- return;
+/*!
+ * \enum QWaylandSurface::Origin
+ *
+ * This enum type is used to specify the origin of a QWaylandSurface's buffer.
+ *
+ * \value OriginTopLeft The origin is the top left corner of the buffer.
+ * \value OriginBottomLeft The origin is the bottom left corner of the buffer.
+ */
- d->m_visibility = v;
- QWaylandSurfaceSetVisibilityOp op(v);
- sendInterfaceOp(op);
+/*!
+ * \qmlproperty enum QtWaylandCompositor::WaylandSurface::origin
+ *
+ * This property holds the origin of the WaylandSurface's buffer, or
+ * WaylandSurface.OriginTopLeft if the surface has no buffer.
+ *
+ * It can have the following values:
+ * \list
+ * \li WaylandSurface.OriginTopLeft The origin is the top left corner of the buffer.
+ * \li WaylandSurface.OriginBottomLeft The origin is the bottom left corner of the buffer.
+ * \endlist
+ */
- emit visibilityChanged();
+/*!
+ * \property QWaylandSurface::origin
+ *
+ * This property holds the origin of the QWaylandSurface's buffer, or
+ * QWaylandSurface::OriginTopLeft if the surface has no buffer.
+ */
+QWaylandSurface::Origin QWaylandSurface::origin() const
+{
+ Q_D(const QWaylandSurface);
+ return d->buffer ? d->buffer->origin() : QWaylandSurface::OriginTopLeft;
}
-bool QWaylandSurface::sendInterfaceOp(QWaylandSurfaceOp &op)
+/*!
+ * Returns the compositor for this QWaylandSurface.
+ */
+QWaylandCompositor *QWaylandSurface::compositor() const
{
- Q_D(QWaylandSurface);
- foreach (QWaylandSurfaceInterface *iface, d->interfaces) {
- if (iface->runOperation(&op))
- return true;
- }
- return false;
+ Q_D(const QWaylandSurface);
+ return d->compositor;
}
-void QWaylandSurface::ping()
+/*!
+ * Prepares all frame callbacks for sending.
+ */
+void QWaylandSurface::frameStarted()
{
Q_D(QWaylandSurface);
- uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
- QWaylandSurfacePingOp op(serial);
- if (!sendInterfaceOp(op)) {
- int id = wl_resource_get_id(d->resource()->handle);
- qWarning("No surface interface forwarded the ping for this surface (wl_surface@%d).", id);
- }
+ foreach (QtWayland::FrameCallback *c, d->frameCallbacks)
+ c->canSend = true;
}
-void QWaylandSurface::sendOnScreenVisibilityChange(bool visible)
+/*!
+ * Sends pending frame callbacks.
+ */
+void QWaylandSurface::sendFrameCallbacks()
{
- setVisibility(visible ? QWindow::AutomaticVisibility : QWindow::Hidden);
+ Q_D(QWaylandSurface);
+ uint time = d->compositor->currentTimeMsecs();
+ int i = 0;
+ while (i < d->frameCallbacks.size()) {
+ if (d->frameCallbacks.at(i)->canSend) {
+ d->frameCallbacks.at(i)->surface = Q_NULLPTR;
+ d->frameCallbacks.at(i)->send(time);
+ d->frameCallbacks.removeAt(i);
+ } else {
+ i++;
+ }
+ }
}
-QString QWaylandSurface::className() const
+/*!
+ * Returns true if the QWaylandSurface has an input panel surface. Otherwise returns false.
+ */
+bool QWaylandSurface::hasInputPanelSurface() const
{
Q_D(const QWaylandSurface);
- return d->className();
-}
-QString QWaylandSurface::title() const
-{
- Q_D(const QWaylandSurface);
- return d->title();
+ return d->inputPanelSurface != 0;
}
-bool QWaylandSurface::hasInputPanelSurface() const
+/*!
+ * Returns true if the QWaylandSurface's input region contains the point \a p.
+ * Otherwise returns false.
+ */
+bool QWaylandSurface::inputRegionContains(const QPoint &p) const
{
Q_D(const QWaylandSurface);
-
- return d->inputPanelSurface() != 0;
+ return d->inputRegion.contains(p);
}
/*!
- * \return True if WL_SHELL_SURFACE_TRANSIENT_INACTIVE was set for this surface, meaning it should not receive keyboard focus.
+ * \qmlmethod void QtWaylandCompositor::WaylandSurface::destroy()
+ *
+ * Destroys the QWaylandSurface.
+ */
+
+/*!
+ * Destroys the QWaylandSurface.
*/
-bool QWaylandSurface::transientInactive() const
+void QWaylandSurface::destroy()
{
- Q_D(const QWaylandSurface);
- return d->transientInactive();
+ Q_D(QWaylandSurface);
+ d->deref();
}
-bool QWaylandSurface::inputRegionContains(const QPoint &p) const
+/*!
+ * \qmlmethod bool QtWaylandCompositor::WaylandSurface::isDestroyed()
+ *
+ * Returns true if the WaylandSurface has been destroyed. Otherwise returns false.
+ */
+
+/*!
+ * Returns true if the QWaylandSurface has been destroyed. Otherwise returns false.
+ */
+bool QWaylandSurface::isDestroyed() const
{
Q_D(const QWaylandSurface);
- return d->inputRegion().contains(p);
+ return d->destroyed;
}
-void QWaylandSurface::destroy()
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandSurface::cursorSurface
+ *
+ * This property holds whether the WaylandSurface is a cursor surface.
+ */
+
+/*!
+ * \property QWaylandSurface::cursorSurface
+ *
+ * This property holds whether the QWaylandSurface is a cursor surface.
+ */
+void QWaylandSurface::markAsCursorSurface(bool cursorSurface)
{
Q_D(QWaylandSurface);
- if (--d->refCount == 0)
- compositor()->handle()->destroySurface(d);
+ d->isCursorSurface = cursorSurface;
}
-void QWaylandSurface::destroySurface()
+bool QWaylandSurface::isCursorSurface() const
{
- QWaylandSurfaceOp op(QWaylandSurfaceOp::Close);
- if (!sendInterfaceOp(op))
- emit surfaceDestroyed();
+ Q_D(const QWaylandSurface);
+ return d->isCursorSurface;
}
/*!
- Updates the surface with the compositor's retained clipboard selection. While this
- is done automatically when the surface receives keyboard focus, this function is
- useful for updating clients which do not have keyboard focus.
-*/
+ * Updates the surface with the compositor's retained clipboard selection. While this
+ * is done automatically when the surface receives keyboard focus, this function is
+ * useful for updating clients which do not have keyboard focus.
+ */
void QWaylandSurface::updateSelection()
{
Q_D(QWaylandSurface);
- const QtWayland::InputDevice *inputDevice = d->compositor()->defaultInputDevice();
+ QWaylandInputDevice *inputDevice = d->compositor->defaultInputDevice();
if (inputDevice) {
- const QtWayland::DataDevice *dataDevice = inputDevice->dataDevice();
+ const QtWayland::DataDevice *dataDevice = QWaylandInputDevicePrivate::get(inputDevice)->dataDevice();
if (dataDevice) {
- d->compositor()->dataDeviceManager()->offerRetainedSelection(
+ QWaylandCompositorPrivate::get(d->compositor)->dataDeviceManager()->offerRetainedSelection(
dataDevice->resourceMap().value(d->resource()->client())->handle);
}
}
}
-void QWaylandSurface::ref()
+/*!
+ * Returns this QWaylandSurface's throttling view.
+ *
+ * \sa QWaylandView::advance()
+ */
+QWaylandView *QWaylandSurface::throttlingView() const
{
- Q_D(QWaylandSurface);
- ++d->refCount;
+ Q_D(const QWaylandSurface);
+ if (d->views.isEmpty())
+ return Q_NULLPTR;
+ return d->views.first();
}
-void QWaylandSurface::setMapped(bool mapped)
+/*!
+ * Sets this QWaylandSurface's throttling view to \a view, in case there are
+ * multiple views of this surface. The throttling view is the view that
+ * governs the client's refresh rate. It takes care of discarding buffer
+ * references when QWaylandView::advance() is called. See the documentation
+ * for QWaylandView::advance() for more details.
+ *
+ * \sa QWaylandView::advance()
+ */
+void QWaylandSurface::setThrottlingView(QWaylandView *view)
{
Q_D(QWaylandSurface);
- d->setMapped(mapped);
-}
-void QWaylandSurface::setBufferAttacher(QWaylandBufferAttacher *attacher)
-{
- Q_D(QWaylandSurface);
- if (d->m_attacher) {
- delete d->m_attacher;
+ if (!view)
+ return;
+
+ int index = d->views.indexOf(view);
+
+ if (index < 0) {
+ view->setSurface(this);
+ index = d->views.indexOf(view);
}
- d->m_attacher = attacher;
-}
-QWaylandBufferAttacher *QWaylandSurface::bufferAttacher() const
-{
- Q_D(const QWaylandSurface);
- return d->m_attacher;
+ d->views.move(index, 0);
}
-QList<QWaylandSurfaceView *> QWaylandSurface::views() const
+/*!
+ * Returns the views for this QWaylandSurface.
+ */
+QList<QWaylandView *> QWaylandSurface::views() const
{
Q_D(const QWaylandSurface);
return d->views;
}
-QList<QWaylandSurfaceInterface *> QWaylandSurface::interfaces() const
+/*!
+ * Returns the QWaylandSurface corresponding to the Wayland resource \a res.
+ */
+QWaylandSurface *QWaylandSurface::fromResource(::wl_resource *res)
{
- Q_D(const QWaylandSurface);
- return d->interfaces;
+ return static_cast<QWaylandSurfacePrivate *>(QWaylandSurfacePrivate::Resource::fromResource(res)->surface_object)->q_func();
}
-QWaylandSurface *QWaylandSurface::fromResource(::wl_resource *res)
+/*!
+ * Returns the Wayland resource corresponding to this QWaylandSurface.
+ */
+struct wl_resource *QWaylandSurface::resource() const
{
- QtWayland::Surface *s = QtWayland::Surface::fromResource(res);
- if (s)
- return s->waylandSurface();
- return Q_NULLPTR;
+ Q_D(const QWaylandSurface);
+ return d->resource()->handle;
}
-void QWaylandSurfacePrivate::setTitle(const QString &title)
+QWaylandSurfacePrivate *QWaylandSurfacePrivate::get(QWaylandSurface *surface)
{
- Q_Q(QWaylandSurface);
- if (m_title != title) {
- m_title = title;
- emit q->titleChanged();
- }
+ return surface ? surface->d_func() : Q_NULLPTR;
}
-void QWaylandSurfacePrivate::setClassName(const QString &className)
+void QWaylandSurfacePrivate::ref()
{
- Q_Q(QWaylandSurface);
- if (m_className != className) {
- m_className = className;
- emit q->classNameChanged();
- }
+ ++refCount;
}
-void QWaylandSurfacePrivate::setType(QWaylandSurface::WindowType type)
+void QWaylandSurfacePrivate::deref()
{
- Q_Q(QWaylandSurface);
- if (windowType != type) {
- windowType = type;
- emit q->windowTypeChanged(type);
- }
+ if (--refCount == 0)
+ QWaylandCompositorPrivate::get(compositor)->destroySurface(q_func());
}
-class QWaylandUnmapLockPrivate
+void QWaylandSurfacePrivate::refView(QWaylandView *view)
{
-public:
- QWaylandSurface *surface;
-};
-
-/*!
- Constructs a QWaylandUnmapLock object.
+ if (views.contains(view))
+ return;
- The lock will act on the \a surface parameter, and will prevent the surface to
- be unmapped, retaining the last valid buffer when the client attachs a NULL buffer.
- The lock will be automatically released when deleted.
-*/
-QWaylandUnmapLock::QWaylandUnmapLock(QWaylandSurface *surface)
- : d(new QWaylandUnmapLockPrivate)
-{
- d->surface = surface;
- surface->handle()->addUnmapLock(this);
+ views.append(view);
+ ref();
+ QWaylandBufferRef ref(buffer);
+ view->attach(ref, QRect(QPoint(0,0), ref.size()));
}
-QWaylandUnmapLock::~QWaylandUnmapLock()
+void QWaylandSurfacePrivate::derefView(QWaylandView *view)
{
- d->surface->handle()->removeUnmapLock(this);
- delete d;
+ int nViews = views.removeAll(view);
+
+ for (int i = 0; i < nViews && refCount > 0; i++) {
+ deref();
+ }
}
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index acff6909..d3fe4f15 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -4,36 +4,32 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Compositor.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** "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 The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-**
-** 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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -42,7 +38,9 @@
#ifndef QWAYLANDSURFACE_H
#define QWAYLANDSURFACE_H
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandextension.h>
+#include <QtWaylandCompositor/qwaylandclient.h>
#include <QtCore/QScopedPointer>
#include <QtGui/QImage>
@@ -59,219 +57,87 @@ class QWaylandClient;
class QWaylandSurfacePrivate;
class QWaylandCompositor;
class QWaylandBufferRef;
-class QWaylandSurfaceView;
-class QWaylandSurfaceInterface;
+class QWaylandView;
class QWaylandSurfaceOp;
-class QWaylandOutput;
-
-namespace QtWayland {
-class Surface;
-class SurfacePrivate;
-class ExtendedSurface;
-}
-
-class Q_COMPOSITOR_EXPORT QWaylandBufferAttacher
-{
-public:
- virtual ~QWaylandBufferAttacher() {}
-
-protected:
- virtual void attach(const QWaylandBufferRef &ref) = 0;
- virtual void unmap() = 0;
- friend class QtWayland::Surface;
-};
-
-class QWaylandSurfaceEnterEventPrivate;
-
-class Q_COMPOSITOR_EXPORT QWaylandSurfaceEnterEvent : public QEvent
-{
-public:
- QWaylandSurfaceEnterEvent(QWaylandOutput *output);
- ~QWaylandSurfaceEnterEvent();
-
- QWaylandOutput *output() const;
-
- static const QEvent::Type WaylandSurfaceEnter;
-
-private:
- QWaylandSurfaceEnterEventPrivate *d;
-};
-
-class QWaylandSurfaceLeaveEventPrivate;
-
-class Q_COMPOSITOR_EXPORT QWaylandSurfaceLeaveEvent : public QEvent
-{
-public:
- QWaylandSurfaceLeaveEvent(QWaylandOutput *output);
- ~QWaylandSurfaceLeaveEvent();
-
- QWaylandOutput *output() const;
-
- static const QEvent::Type WaylandSurfaceLeave;
-
-private:
- QWaylandSurfaceLeaveEventPrivate *d;
-};
-
-class Q_COMPOSITOR_EXPORT QWaylandSurface : public QObject
+class Q_COMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandSurface)
Q_PROPERTY(QWaylandClient *client READ client CONSTANT)
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
- Q_PROPERTY(QWaylandSurface::WindowFlags windowFlags READ windowFlags NOTIFY windowFlagsChanged)
- Q_PROPERTY(QWaylandSurface::WindowType windowType READ windowType NOTIFY windowTypeChanged)
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_PROPERTY(QWindow::Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
- Q_PROPERTY(QWaylandSurface *transientParent READ transientParent)
- Q_PROPERTY(QPointF transientOffset READ transientOffset)
-
- Q_ENUMS(WindowFlag WindowType)
- Q_FLAGS(WindowFlag WindowFlags)
+ Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged)
+ Q_PROPERTY(bool isMapped READ isMapped NOTIFY mappedChanged)
+ Q_PROPERTY(bool cursorSurface READ isCursorSurface WRITE markAsCursorSurface)
public:
- enum WindowFlag {
- OverridesSystemGestures = 0x0001,
- StaysOnTop = 0x0002,
- BypassWindowManager = 0x0004
+ enum Origin {
+ OriginTopLeft,
+ OriginBottomLeft
};
- Q_DECLARE_FLAGS(WindowFlags, WindowFlag)
+ Q_ENUM(Origin)
- enum WindowType {
- None,
- Toplevel,
- Transient,
- Popup
- };
-
- enum Type {
- Invalid,
- Shm,
- Texture
- };
-
- QWaylandSurface(wl_client *client, quint32 id, int version, QWaylandCompositor *compositor);
+ QWaylandSurface();
+ QWaylandSurface(QWaylandCompositor *compositor, QWaylandClient *client, uint id, int version);
virtual ~QWaylandSurface();
- QWaylandClient *client() const;
+ Q_INVOKABLE void initialize(QWaylandCompositor *compositor, QWaylandClient *client, uint id, int version);
+ bool isInitialized() const;
- void addInterface(QWaylandSurfaceInterface *interface);
- void removeInterface(QWaylandSurfaceInterface *interface);
-
- Type type() const;
- bool isYInverted() const;
+ QWaylandClient *client() const;
+ struct wl_client *waylandClient() const { return client()->client(); }
- bool visible() const;
bool isMapped() const;
QSize size() const;
- Q_INVOKABLE void requestSize(const QSize &size);
- Qt::ScreenOrientations orientationUpdateMask() const;
Qt::ScreenOrientation contentOrientation() const;
- WindowFlags windowFlags() const;
-
- WindowType windowType() const;
-
- QWindow::Visibility visibility() const;
- void setVisibility(QWindow::Visibility visibility);
- Q_INVOKABLE void sendOnScreenVisibilityChange(bool visible); // Compat
-
- QWaylandSurface *transientParent() const;
-
- QPointF transientOffset() const;
-
- QtWayland::Surface *handle();
-
- QByteArray authenticationToken() const;
- QVariantMap windowProperties() const;
- void setWindowProperty(const QString &name, const QVariant &value);
+ Origin origin() const;
QWaylandCompositor *compositor() const;
- QWaylandOutput *mainOutput() const;
- void setMainOutput(QWaylandOutput *mainOutput);
-
- QList<QWaylandOutput *> outputs() const;
-
- QString className() const;
-
- QString title() const;
-
bool hasInputPanelSurface() const;
- bool transientInactive() const;
-
bool inputRegionContains(const QPoint &p) const;
Q_INVOKABLE void destroy();
- Q_INVOKABLE void destroySurface();
- Q_INVOKABLE void ping();
+ Q_INVOKABLE bool isDestroyed() const;
- void ref();
- void setMapped(bool mapped);
+ Q_INVOKABLE void frameStarted();
+ Q_INVOKABLE void sendFrameCallbacks();
- void setBufferAttacher(QWaylandBufferAttacher *attacher);
- QWaylandBufferAttacher *bufferAttacher() const;
+ QWaylandView *throttlingView() const;
+ void setThrottlingView(QWaylandView *view);
- QList<QWaylandSurfaceView *> views() const;
- QList<QWaylandSurfaceInterface *> interfaces() const;
-
- bool sendInterfaceOp(QWaylandSurfaceOp &op);
+ QList<QWaylandView *> views() const;
static QWaylandSurface *fromResource(::wl_resource *resource);
+ struct wl_resource *resource() const;
+
+ void markAsCursorSurface(bool cursorSurface);
+ bool isCursorSurface() const;
public Q_SLOTS:
void updateSelection();
protected:
- QWaylandSurface(QWaylandSurfacePrivate *dptr);
+ QWaylandSurface(QWaylandSurfacePrivate &dptr);
Q_SIGNALS:
- void mapped();
- void unmapped();
+ void mappedChanged();
void damaged(const QRegion &rect);
void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent);
void sizeChanged();
- void windowPropertyChanged(const QString &name, const QVariant &value);
- void windowFlagsChanged(WindowFlags flags);
- void windowTypeChanged(WindowType type);
+ void offsetForNextFrame(const QPoint &offset);
void contentOrientationChanged();
- void orientationUpdateMaskChanged();
- void extendedSurfaceReady();
- void classNameChanged();
- void titleChanged();
- void raiseRequested();
- void lowerRequested();
- void visibilityChanged();
void pong();
void surfaceDestroyed();
-
- void viewAdded(QWaylandSurfaceView *view);
- void viewRemoved(QWaylandSurfaceView *view);
+ void originChanged();
void configure(bool hasBuffer);
void redraw();
-
- friend class QWaylandSurfaceView;
- friend class QWaylandSurfaceInterface;
- friend class QtWayland::Surface;
-};
-
-class QWaylandUnmapLockPrivate;
-class Q_COMPOSITOR_EXPORT QWaylandUnmapLock
-{
-public:
- QWaylandUnmapLock(QWaylandSurface *surface);
- ~QWaylandUnmapLock();
-
-private:
- QWaylandUnmapLockPrivate *const d;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h
index 383a523b..1f3676bd 100644
--- a/src/compositor/compositor_api/qwaylandsurface_p.h
+++ b/src/compositor/compositor_api/qwaylandsurface_p.h
@@ -4,9 +4,9 @@
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -17,16 +17,19 @@
**
** 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 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -46,35 +49,132 @@
// We mean it.
//
-#include <QtCompositor/qwaylandexport.h>
+#include <QtWaylandCompositor/qwaylandexport.h>
#include <private/qobject_p.h>
-#include <QtCompositor/private/qwlsurface_p.h>
+#include <private/qwlsurfacebuffer_p.h>
+#include <QtWaylandCompositor/qwaylandsurface.h>
+#include <QtWaylandCompositor/qwaylandbufferref.h>
+
+#include <QtWaylandCompositor/private/qwlinputpanelsurface_p.h>
+#include <QtWaylandCompositor/private/qwlregion_p.h>
+
+#include <QtCore/QVector>
+#include <QtCore/QRect>
+#include <QtGui/QRegion>
+#include <QtGui/QImage>
+#include <QtGui/QWindow>
+
+#include <QtCore/QTextStream>
+#include <QtCore/QMetaType>
+
+#include <wayland-util.h>
+
+#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
QT_BEGIN_NAMESPACE
class QWaylandCompositor;
class QWaylandSurface;
-class QWaylandSurfaceView;
+class QWaylandView;
class QWaylandSurfaceInterface;
-class Q_COMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWayland::Surface
+namespace QtWayland {
+class FrameCallback;
+}
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfacePrivate : public QObjectPrivate, public QtWaylandServer::wl_surface
{
- Q_DECLARE_PUBLIC(QWaylandSurface)
public:
- QWaylandSurfacePrivate(wl_client *wlClient, quint32 id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface);
- void setType(QWaylandSurface::WindowType type);
- void setTitle(const QString &title);
- void setClassName(const QString &className);
+ static QWaylandSurfacePrivate *get(QWaylandSurface *surface);
- bool closing;
- int refCount;
+ QWaylandSurfacePrivate();
+ ~QWaylandSurfacePrivate();
+
+ void ref();
+ void deref();
+
+ void refView(QWaylandView *view);
+ void derefView(QWaylandView *view);
+
+ using QtWaylandServer::wl_surface::resource;
+
+ void setSize(const QSize &size);
+
+ void removeFrameCallback(QtWayland::FrameCallback *callback);
+
+ void notifyViewsAboutDestruction();
+
+ void setInputPanelSurface(QtWayland::InputPanelSurface *ips) { inputPanelSurface = ips; }
+#ifndef QT_NO_DEBUG
+ static void addUninitializedSurface(QWaylandSurfacePrivate *surface);
+ static void removeUninitializedSurface(QWaylandSurfacePrivate *surface);
+ static bool hasUninitializedSurface();
+#endif
+protected:
+ void surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
+
+ void surface_destroy(Resource *resource) Q_DECL_OVERRIDE;
+ void surface_attach(Resource *resource,
+ struct wl_resource *buffer, int x, int y) Q_DECL_OVERRIDE;
+ void surface_damage(Resource *resource,
+ int32_t x, int32_t y, int32_t width, int32_t height) Q_DECL_OVERRIDE;
+ void surface_frame(Resource *resource,
+ uint32_t callback) Q_DECL_OVERRIDE;
+ void surface_set_opaque_region(Resource *resource,
+ struct wl_resource *region) Q_DECL_OVERRIDE;
+ void surface_set_input_region(Resource *resource,
+ struct wl_resource *region) Q_DECL_OVERRIDE;
+ void surface_commit(Resource *resource) Q_DECL_OVERRIDE;
+ void surface_set_buffer_transform(Resource *resource, int32_t transform) Q_DECL_OVERRIDE;
+
+ void setBackBuffer(QtWayland::SurfaceBuffer *buffer, const QRegion &damage);
+ QtWayland::SurfaceBuffer *createSurfaceBuffer(struct ::wl_resource *buffer);
+
+protected: //member variables
+ QWaylandCompositor *compositor;
+ int refCount;
QWaylandClient *client;
+ QList<QWaylandView *> views;
+ QRegion damage;
+ QtWayland::SurfaceBuffer *buffer;
+ QWaylandBufferRef bufferRef;
+
+ struct {
+ QtWayland::SurfaceBuffer *buffer;
+ QRegion damage;
+ QPoint offset;
+ bool newlyAttached;
+ QRegion inputRegion;
+ } pending;
+
+ QPoint lastLocalMousePos;
+ QPoint lastGlobalMousePos;
- QWaylandSurface::WindowType windowType;
- QList<QWaylandSurfaceView *> views;
- QList<QWaylandSurfaceInterface *> interfaces;
+ QList<QtWayland::FrameCallback *> pendingFrameCallbacks;
+ QList<QtWayland::FrameCallback *> frameCallbacks;
+
+ QtWayland::InputPanelSurface *inputPanelSurface;
+
+ QRegion inputRegion;
+ QRegion opaqueRegion;
+
+ QVector<QtWayland::SurfaceBuffer *> bufferPool;
+
+ QSize size;
+ bool isCursorSurface;
+ bool destroyed;
+ bool mapped;
+ bool isInitialized;
+ Qt::ScreenOrientation contentOrientation;
+ QWindow::Visibility visibility;
+
+#ifndef QT_NO_DEBUG
+ static QList<QWaylandSurfacePrivate *> uninitializedSurfaces;
+#endif
+ Q_DECLARE_PUBLIC(QWaylandSurface)
+ Q_DISABLE_COPY(QWaylandSurfacePrivate)
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp b/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp
deleted file mode 100644
index cddd231d..00000000
--- a/src/compositor/compositor_api/qwaylandsurfaceinterface.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
-** Contact: http://www.qt.io/licensing/
-**
-** 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 The Qt Company Ltd 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 <wayland-server.h>
-
-#include "qwaylandsurfaceinterface.h"
-#include "qwaylandsurface.h"
-#include "qwaylandsurface_p.h"
-
-class QWaylandSurfaceInterface::Private
-{
-public:
- QWaylandSurface *surface;
-};
-
-QWaylandSurfaceInterface::QWaylandSurfaceInterface(QWaylandSurface *surface)
- : d(new Private)
-{
- d->surface = surface;
- surface->addInterface(this);
-}
-
-QWaylandSurfaceInterface::~QWaylandSurfaceInterface()
-{
- d->surface->removeInterface(this);
- delete d;
-}
-
-QWaylandSurface *QWaylandSurfaceInterface::surface() const
-{
- return d->surface;
-}
-
-void QWaylandSurfaceInterface::setSurfaceType(QWaylandSurface::WindowType type)
-{
- surface()->d_func()->setType(type);
-}
-
-void QWaylandSurfaceInterface::setSurfaceClassName(const QString &name)
-{
- surface()->d_func()->setClassName(name);
-}
-
-void QWaylandSurfaceInterface::setSurfaceTitle(const QString &title)
-{
- surface()->d_func()->setTitle(title);
-}
-
-
-
-class QWaylandSurfaceOp::Private
-{
-public:
- int type;
-};
-
-QWaylandSurfaceOp::QWaylandSurfaceOp(int t)
- : d(new Private)
-{
- d->type = t;
-}
-
-QWaylandSurfaceOp::~QWaylandSurfaceOp()
-{
- delete d;
-}
-
-int QWaylandSurfaceOp::type() const
-{
- return d->type;
-}
-
-
-
-QWaylandSurfaceSetVisibilityOp::QWaylandSurfaceSetVisibilityOp(QWindow::Visibility visibility)
- : QWaylandSurfaceOp(QWaylandSurfaceOp::SetVisibility)
- , m_visibility(visibility)
-{
-}
-
-QWindow::Visibility QWaylandSurfaceSetVisibilityOp::visibility() const
-{
- return m_visibility;
-}
-
-QWaylandSurfaceResizeOp::QWaylandSurfaceResizeOp(const QSize &size)
- : QWaylandSurfaceOp(QWaylandSurfaceOp::Resize)
- , m_size(size)
-{</