summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--README4
-rw-r--r--examples/wayland/hwlayer-compositor/main.qml1
-rw-r--r--examples/wayland/minimal-qml/main.qml1
-rw-r--r--examples/wayland/multi-screen/qml/Chrome.qml1
-rw-r--r--examples/wayland/multi-screen/qml/main.qml7
-rw-r--r--examples/wayland/overview-compositor/main.qml39
-rw-r--r--examples/wayland/pure-qml/qml/Chrome.qml29
-rw-r--r--examples/wayland/pure-qml/qml/Keyboard.qml3
-rw-r--r--examples/wayland/pure-qml/qml/Screen.qml46
-rw-r--r--examples/wayland/pure-qml/qml/main.qml67
-rw-r--r--examples/wayland/qwindow-compositor/compositor.cpp12
-rw-r--r--examples/wayland/spanning-screens/main.qml75
-rw-r--r--examples/wayland/wayland.pro1
-rw-r--r--src/3rdparty/protocol/qt_attribution.json18
-rw-r--r--src/3rdparty/protocol/xdg-output-unstable-v1.xml209
-rw-r--r--src/3rdparty/protocol/xdg-shell-unstable-v5.xml608
-rw-r--r--src/3rdparty/protocol/xdg-shell.xml1078
-rw-r--r--src/client/client.pro21
-rw-r--r--src/client/qwaylandcursor.cpp379
-rw-r--r--src/client/qwaylandcursor_p.h42
-rw-r--r--src/client/qwaylanddisplay.cpp55
-rw-r--r--src/client/qwaylanddisplay_p.h21
-rw-r--r--src/client/qwaylanddnd.cpp8
-rw-r--r--src/client/qwaylanddnd_p.h4
-rw-r--r--src/client/qwaylandinputdevice.cpp26
-rw-r--r--src/client/qwaylandinputdevice_p.h6
-rw-r--r--src/client/qwaylandintegration.cpp29
-rw-r--r--src/client/qwaylandnativeinterface.cpp15
-rw-r--r--src/client/qwaylandqtkey.cpp4
-rw-r--r--src/client/qwaylandqtkey_p.h26
-rw-r--r--src/client/qwaylandscreen.cpp72
-rw-r--r--src/client/qwaylandscreen_p.h19
-rw-r--r--src/client/qwaylandshellsurface_p.h10
-rw-r--r--src/client/qwaylandwindow.cpp140
-rw-r--r--src/client/qwaylandwindow_p.h36
-rw-r--r--src/client/qwaylandxdgsurface.cpp257
-rw-r--r--src/client/shellintegration/qwaylandshellintegration_p.h5
-rw-r--r--src/client/shellintegration/qwaylandshellintegrationfactory.cpp17
-rw-r--r--src/client/shellintegration/qwaylandshellintegrationfactory_p.h5
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp117
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.h2
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor_p.h8
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.cpp41
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.h2
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard_p.h3
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp101
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.h3
-rw-r--r--src/compositor/compositor_api/qwaylandoutput_p.h3
-rw-r--r--src/compositor/compositor_api/qwaylandoutputmode.cpp12
-rw-r--r--src/compositor/compositor_api/qwaylandoutputmode.h5
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp13
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.h1
-rw-r--r--src/compositor/compositor_api/qwaylandseat.cpp44
-rw-r--r--src/compositor/compositor_api/qwaylandseat.h1
-rw-r--r--src/compositor/doc/qtwaylandcompositor.qdocconf2
-rw-r--r--src/compositor/extensions/extensions.pri4
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp45
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.h5
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h10
-rw-r--r--src/compositor/extensions/qwaylandwlshellintegration.cpp47
-rw-r--r--src/compositor/extensions/qwaylandwlshellintegration_p.h10
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5.cpp12
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5_p.h2
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5integration.cpp12
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6.cpp4
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6integration.cpp110
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6integration_p.h15
-rw-r--r--src/compositor/extensions/qwlqtkey.cpp20
-rw-r--r--src/compositor/extensions/qwlqtkey_p.h4
-rw-r--r--src/compositor/global/qwaylandquickextension.h36
-rw-r--r--src/extensions/README.md18
-rw-r--r--src/extensions/qt-key-unstable-v1.xml (renamed from src/extensions/qtkey-extension.xml)54
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp27
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h3
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp2
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp2
-rw-r--r--src/imports/compositor/qwaylandquickcompositorplugin.cpp24
-rw-r--r--src/plugins/decorations/bradient/main.cpp163
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp36
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h8
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp9
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h3
-rw-r--r--src/plugins/shellintegration/shellintegration.pro8
-rw-r--r--src/plugins/shellintegration/wl-shell/main.cpp69
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp (renamed from src/client/qwaylandwlshellintegration.cpp)37
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h (renamed from src/client/qwaylandwlshellintegration_p.h)5
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp (renamed from src/client/qwaylandwlshellsurface.cpp)116
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h (renamed from src/client/qwaylandwlshellsurface_p.h)22
-rw-r--r--src/plugins/shellintegration/wl-shell/wl-shell.json3
-rw-r--r--src/plugins/shellintegration/wl-shell/wl-shell.pro25
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/main.cpp69
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp (renamed from src/client/qwaylandxdgpopup.cpp)20
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h (renamed from src/client/qwaylandxdgpopup_p.h)17
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp (renamed from src/client/qwaylandxdgshell.cpp)34
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5_p.h (renamed from src/client/qwaylandxdgshell_p.h)25
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp (renamed from src/client/qwaylandxdgshellintegration.cpp)38
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h80
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp237
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h (renamed from src/client/qwaylandxdgsurface_p.h)47
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json3
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro30
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/main.cpp68
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp (renamed from src/client/qwaylandxdgshellv6.cpp)166
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h (renamed from src/client/qwaylandxdgshellv6_p.h)26
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp (renamed from src/client/qwaylandxdgshellv6integration.cpp)38
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h (renamed from src/client/qwaylandxdgshellv6integration_p.h)11
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.json3
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro25
-rw-r--r--src/plugins/shellintegration/xdg-shell/main.cpp68
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp338
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h159
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp87
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h (renamed from src/client/qwaylandxdgshellintegration_p.h)10
-rw-r--r--src/plugins/shellintegration/xdg-shell/xdg-shell.json3
-rw-r--r--src/plugins/shellintegration/xdg-shell/xdg-shell.pro25
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp319
-rw-r--r--sync.profile26
-rw-r--r--tests/auto/client/client/tst_client.cpp20
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp5
-rw-r--r--tests/auto/client/shared/mockcompositor.h15
-rw-r--r--tests/auto/client/shared/mocksurface.cpp5
-rw-r--r--tests/auto/client/shared/mockxdgshellv6.cpp43
-rw-r--r--tests/auto/client/shared/mockxdgshellv6.h6
-rw-r--r--tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp236
-rw-r--r--tests/auto/compositor/compositor/compositor.pro4
-rw-r--r--tests/auto/compositor/compositor/mockclient.h2
-rw-r--r--tests/auto/compositor/compositor/mockkeyboard.cpp101
-rw-r--r--tests/auto/compositor/compositor/mockkeyboard.h50
-rw-r--r--tests/auto/compositor/compositor/mockseat.cpp5
-rw-r--r--tests/auto/compositor/compositor/mockseat.h4
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp141
132 files changed, 5445 insertions, 1890 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 76c202ab9..097d8b948 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,3 +1,3 @@
load(qt_build_config)
-MODULE_VERSION = 5.11.2
+MODULE_VERSION = 5.12.0
diff --git a/README b/README
index 8215b30b9..4ce158930 100644
--- a/README
+++ b/README
@@ -70,8 +70,8 @@ the generic wl_shell or xdg_shell extensions that target desktop systems.
Custom shell protocols are added through shell integration plugins.
Which shell integration to use is determined by the QT_WAYLAND_SHELL_INTEGRATION
-environment variable. If no shell is specified, the default is to first try
-xdg-shell-v6 and then wl-shell.
+environment variable. If no shell is specified, the default is to try shells in
+the following order: xdg-shell-v6, wl-shell and then ivi-shell.
Example Usage:
diff --git a/examples/wayland/hwlayer-compositor/main.qml b/examples/wayland/hwlayer-compositor/main.qml
index de4fe6d49..2f6a5f0de 100644
--- a/examples/wayland/hwlayer-compositor/main.qml
+++ b/examples/wayland/hwlayer-compositor/main.qml
@@ -156,6 +156,5 @@ WaylandCompositor {
shellSurfaces.append({shSurface: shellSurface, animatePosition: false, animateOpacity: false, level: 0});
}
WlShell { onWlShellSurfaceCreated: addShellSurface(shellSurface) }
- XdgShellV5 { onXdgSurfaceCreated: addShellSurface(xdgSurface) }
XdgShellV6 { onToplevelCreated: addShellSurface(xdgSurface) }
}
diff --git a/examples/wayland/minimal-qml/main.qml b/examples/wayland/minimal-qml/main.qml
index 0f0ca61bc..85c8c5783 100644
--- a/examples/wayland/minimal-qml/main.qml
+++ b/examples/wayland/minimal-qml/main.qml
@@ -67,6 +67,7 @@ WaylandCompositor {
// resize/move, and forwarding of mouse and keyboard
// events to the client process.
ShellSurfaceItem {
+ autoCreatePopupItems: true
shellSurface: modelData
onSurfaceDestroyed: shellSurfaces.remove(index)
}
diff --git a/examples/wayland/multi-screen/qml/Chrome.qml b/examples/wayland/multi-screen/qml/Chrome.qml
index 99141ad25..52f449468 100644
--- a/examples/wayland/multi-screen/qml/Chrome.qml
+++ b/examples/wayland/multi-screen/qml/Chrome.qml
@@ -63,6 +63,7 @@ Item {
ShellSurfaceItem {
id: surfaceItem
+ autoCreatePopupItems: true
onSurfaceDestroyed: chrome.destroy();
}
diff --git a/examples/wayland/multi-screen/qml/main.qml b/examples/wayland/multi-screen/qml/main.qml
index 9b97c95b9..354dd1c91 100644
--- a/examples/wayland/multi-screen/qml/main.qml
+++ b/examples/wayland/multi-screen/qml/main.qml
@@ -52,7 +52,7 @@
import QtQml 2.2
import QtQuick 2.0
import QtQuick.Window 2.3 as Window
-import QtWayland.Compositor 1.0
+import QtWayland.Compositor 1.1
import QtQml.Models 2.1
WaylandCompositor {
@@ -100,9 +100,8 @@ WaylandCompositor {
onWlShellSurfaceCreated: handleShellSurfaceCreated(shellSurface)
}
- XdgShellV5 {
- onXdgSurfaceCreated: handleShellSurfaceCreated(xdgSurface)
- onXdgPopupCreated: handleShellSurfaceCreated(xdgPopup)
+ XdgShellV6 {
+ onToplevelCreated: handleShellSurfaceCreated(xdgSurface)
}
function createShellSurfaceItem(shellSurface, moveItem, output) {
diff --git a/examples/wayland/overview-compositor/main.qml b/examples/wayland/overview-compositor/main.qml
index 6e5cec985..18589e50a 100644
--- a/examples/wayland/overview-compositor/main.qml
+++ b/examples/wayland/overview-compositor/main.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
@@ -49,8 +49,8 @@
****************************************************************************/
import QtQuick 2.7
-import QtWayland.Compositor 1.0
-import QtQuick.Window 2.0
+import QtWayland.Compositor 1.1
+import QtQuick.Window 2.3
import QtQuick.Controls 2.0
WaylandCompositor {
@@ -58,18 +58,24 @@ WaylandCompositor {
sizeFollowsWindow: true
window: Window {
id: win
+
+ property int pixelWidth: width * screen.devicePixelRatio
+ property int pixelHeight: height * screen.devicePixelRatio
+
visible: true
width: 1280
height: 720
+
Grid {
id: grid
- anchors.fill: parent
- columns: Math.ceil(Math.sqrt(shellSurfaces.count))
+
property bool overview: true
property int selected: 0
property int selectedColumn: selected % columns
property int selectedRow: selected / columns
+ anchors.fill: parent
+ columns: Math.ceil(Math.sqrt(toplevels.count))
transform: [
Scale {
xScale: grid.overview ? (1.0/grid.columns) : 1
@@ -86,15 +92,16 @@ WaylandCompositor {
]
Repeater {
- model: shellSurfaces
+ model: toplevels
Item {
width: win.width
height: win.height
- WaylandQuickItem {
+ ShellSurfaceItem {
anchors.fill: parent
+ shellSurface: xdgSurface
+ autoCreatePopupItems: true
sizeFollowsSurface: false
- surface: modelData.surface
- onSurfaceDestroyed: shellSurfaces.remove(index)
+ onSurfaceDestroyed: toplevels.remove(index)
}
MouseArea {
enabled: grid.overview
@@ -116,19 +123,19 @@ WaylandCompositor {
}
Shortcut { sequence: "space"; onActivated: grid.overview = !grid.overview }
- Shortcut { sequence: "right"; onActivated: grid.selected = Math.min(grid.selected+1, shellSurfaces.count-1) }
+ Shortcut { sequence: "right"; onActivated: grid.selected = Math.min(grid.selected+1, toplevels.count-1) }
Shortcut { sequence: "left"; onActivated: grid.selected = Math.max(grid.selected-1, 0) }
Shortcut { sequence: "up"; onActivated: grid.selected = Math.max(grid.selected-grid.columns, 0) }
- Shortcut { sequence: "down"; onActivated: grid.selected = Math.min(grid.selected+grid.columns, shellSurfaces.count-1) }
+ Shortcut { sequence: "down"; onActivated: grid.selected = Math.min(grid.selected+grid.columns, toplevels.count-1) }
}
}
- ListModel { id: shellSurfaces }
+ ListModel { id: toplevels }
- WlShell {
- onWlShellSurfaceCreated: {
- shellSurfaces.append({shellSurface: shellSurface});
- shellSurface.sendConfigure(Qt.size(win.width, win.height), WlShellSurface.NoneEdge);
+ XdgShellV6 {
+ onToplevelCreated: {
+ toplevels.append({xdgSurface});
+ toplevel.sendFullscreen(Qt.size(win.pixelWidth, win.pixelHeight));
}
}
}
diff --git a/examples/wayland/pure-qml/qml/Chrome.qml b/examples/wayland/pure-qml/qml/Chrome.qml
index e6fe97476..a63ee705c 100644
--- a/examples/wayland/pure-qml/qml/Chrome.qml
+++ b/examples/wayland/pure-qml/qml/Chrome.qml
@@ -52,15 +52,28 @@ import QtQuick 2.0
import QtWayland.Compositor 1.0
ShellSurfaceItem {
- id: rootChrome
+ id: chrome
property bool isChild: parent.shellSurface !== undefined
+ signal destroyAnimationFinished
+
+ // If the client asks to show popups on this surface, automatically create child ShellSurfaceItems
+ autoCreatePopupItems: true
+
onSurfaceDestroyed: {
bufferLocked = true;
destroyAnimation.start();
}
+ transform: [
+ Scale {
+ id: scaleTransform
+ origin.x: chrome.width / 2
+ origin.y: chrome.height / 2
+ }
+ ]
+
Connections {
target: shellSurface
@@ -76,17 +89,19 @@ ShellSurfaceItem {
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: rootChrome; property: "opacity"; to: rootChrome.isChild ? 0 : 1; duration: 150 }
+ NumberAnimation { target: chrome; property: "opacity"; to: chrome.isChild ? 0 : 1; duration: 150 }
}
NumberAnimation { target: scaleTransform; property: "xScale"; to: 0; duration: 150 }
- ScriptAction { script: { rootChrome.destroy(); } }
+ ScriptAction { script: destroyAnimationFinished() }
}
SequentialAnimation {
id: receivedFocusAnimation
+
ParallelAnimation {
NumberAnimation { target: scaleTransform; property: "yScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad }
NumberAnimation { target: scaleTransform; property: "xScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad }
@@ -96,12 +111,4 @@ ShellSurfaceItem {
NumberAnimation { target: scaleTransform; property: "xScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad }
}
}
-
- transform: [
- Scale {
- id:scaleTransform
- origin.x: rootChrome.width / 2
- origin.y: rootChrome.height / 2
- }
- ]
}
diff --git a/examples/wayland/pure-qml/qml/Keyboard.qml b/examples/wayland/pure-qml/qml/Keyboard.qml
index e1f0a8b19..b2586ffd4 100644
--- a/examples/wayland/pure-qml/qml/Keyboard.qml
+++ b/examples/wayland/pure-qml/qml/Keyboard.qml
@@ -52,9 +52,8 @@ import QtQuick 2.5
import QtQuick.VirtualKeyboard 2.1
InputPanel {
- id: inputPanel
visible: active
- y: active ? parent.height - inputPanel.height : parent.height
+ y: active ? parent.height - height : parent.height
anchors.left: parent.left
anchors.right: parent.right
}
diff --git a/examples/wayland/pure-qml/qml/Screen.qml b/examples/wayland/pure-qml/qml/Screen.qml
index 562eb86c5..b156cb434 100644
--- a/examples/wayland/pure-qml/qml/Screen.qml
+++ b/examples/wayland/pure-qml/qml/Screen.qml
@@ -54,49 +54,69 @@ import QtWayland.Compositor 1.0
WaylandOutput {
id: output
- property alias surfaceArea: background
- sizeFollowsWindow: true
- window: Window {
- id: screen
- property QtObject output
+ property ListModel shellSurfaces: ListModel {}
+ property bool isNestedCompositor: Qt.platform.pluginName.startsWith("wayland") || Qt.platform.pluginName === "xcb"
+
+ function handleShellSurface(shellSurface) {
+ shellSurfaces.append({shellSurface: shellSurface});
+ }
+
+ // During development, it can be useful to start the compositor inside X11 or
+ // another Wayland compositor. In such cases, set sizeFollowsWindow to true to
+ // enable resizing of the compositor window to be forwarded to the Wayland clients
+ // as the output (screen) changing resolution. Consider setting it to false if you
+ // are running the compositor using eglfs, linuxfb or similar QPA backends.
+ sizeFollowsWindow: output.isNestedCompositor
+ window: Window {
width: 1024
height: 760
visible: true
WaylandMouseTracker {
id: mouseTracker
+
anchors.fill: parent
- windowSystemCursorEnabled: true
+ // Set this to false to disable the outer mouse cursor when running nested
+ // compositors. Otherwise you would see two mouse cursors, one for each compositor.
+ windowSystemCursorEnabled: output.isNestedCompositor
+
Image {
id: background
+
anchors.fill: parent
fillMode: Image.Tile
source: "qrc:/images/background.jpg"
smooth: true
+
+ Repeater {
+ model: output.shellSurfaces
+ // Chrome displays a shell surface on the screen (See Chrome.qml)
+ Chrome {
+ shellSurface: modelData
+ onDestroyAnimationFinished: output.shellSurfaces.remove(index)
+ }
+ }
}
+
+ // Virtual Keyboard
Loader {
anchors.fill: parent
source: "Keyboard.qml"
}
+
+ // Draws the mouse cursor for a given Wayland seat
WaylandCursorItem {
- id: cursor
inputEventsEnabled: false
x: mouseTracker.mouseX
y: mouseTracker.mouseY
-
seat: output.compositor.defaultSeat
}
}
Shortcut {
- sequence: "Meta+F"
- onActivated: qtWindowManager.showIsFullScreen = !qtWindowManager.showIsFullScreen
- }
-
- Shortcut {
sequence: "Ctrl+Alt+Backspace"
onActivated: Qt.quit()
}
diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml
index 77ed3ecd9..b188ebbb5 100644
--- a/examples/wayland/pure-qml/qml/main.qml
+++ b/examples/wayland/pure-qml/qml/main.qml
@@ -52,68 +52,21 @@ import QtQuick 2.0
import QtWayland.Compositor 1.1
WaylandCompositor {
- id: comp
+ id: waylandCompositor
- property var primarySurfacesArea: null
-
- Screen {
- compositor: comp
- }
-
- Component {
- id: chromeComponent
- Chrome {
- }
- }
-
- Component {
- id: surfaceComponent
- WaylandSurface {
- }
- }
-
- QtWindowManager {
- id: qtWindowManager
- onShowIsFullScreenChanged: console.debug("Show is fullscreen hint for Qt applications:", showIsFullScreen)
- }
-
- WlShell {
- onWlShellSurfaceCreated: {
- chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": shellSurface } );
- }
- }
-
- property variant viewsBySurface: ({})
-
- XdgShellV5 {
- onXdgSurfaceCreated: {
- var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": xdgSurface } );
- viewsBySurface[xdgSurface.surface] = item;
- }
- onXdgPopupCreated: {
- var parentView = viewsBySurface[xdgPopup.parentSurface];
- var item = chromeComponent.createObject(parentView, { "shellSurface": xdgPopup } );
- viewsBySurface[xdgPopup.surface] = item;
- }
- }
+ Screen { id: screen; compositor: waylandCompositor }
+ // Shell surface extension. Needed to provide a window concept for Wayland clients.
+ // I.e. requests and events for maximization, minimization, resizing, closing etc.
XdgShellV6 {
- onToplevelCreated: {
- var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": xdgSurface } );
- viewsBySurface[xdgSurface.surface] = item;
- }
- onPopupCreated: {
- var parentView = viewsBySurface[popup.parentXdgSurface.surface];
- var item = chromeComponent.createObject(parentView, { "shellSurface": xdgSurface } );
- viewsBySurface[xdgSurface.surface] = item;
- }
+ onToplevelCreated: screen.handleShellSurface(xdgSurface)
}
- TextInputManager {
+ // Deprecated shell extension, still used by some clients
+ WlShell {
+ onWlShellSurfaceCreated: screen.handleShellSurface(shellSurface)
}
- onSurfaceRequested: {
- var surface = surfaceComponent.createObject(comp, { } );
- surface.initialize(comp, client, id, version);
- }
+ // Extension for Virtual keyboard support
+ TextInputManager {}
}
diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp
index e224cd1c3..f25e67d87 100644
--- a/examples/wayland/qwindow-compositor/compositor.cpp
+++ b/examples/wayland/qwindow-compositor/compositor.cpp
@@ -443,25 +443,25 @@ void Compositor::handleMouseEvent(QWaylandView *target, QMouseEvent *me)
closePopups();
}
- QWaylandSeat *input = defaultSeat();
+ QWaylandSeat *seat = defaultSeat();
QWaylandSurface *surface = target ? target->surface() : nullptr;
switch (me->type()) {
case QEvent::MouseButtonPress:
- input->sendMousePressEvent(me->button());
- if (surface != input->keyboardFocus()) {
+ seat->sendMousePressEvent(me->button());
+ if (surface != seat->keyboardFocus()) {
if (surface == nullptr
|| surface->role() == QWaylandWlShellSurface::role()
|| surface->role() == QWaylandXdgSurfaceV5::role()
|| surface->role() == QWaylandXdgPopupV5::role()) {
- input->setKeyboardFocus(surface);
+ seat->setKeyboardFocus(surface);
}
}
break;
case QEvent::MouseButtonRelease:
- input->sendMouseReleaseEvent(me->button());
+ seat->sendMouseReleaseEvent(me->button());
break;
case QEvent::MouseMove:
- input->sendMouseMoveEvent(target, me->localPos(), me->globalPos());
+ seat->sendMouseMoveEvent(target, me->localPos(), me->globalPos());
default:
break;
}
diff --git a/examples/wayland/spanning-screens/main.qml b/examples/wayland/spanning-screens/main.qml
index c978f589e..a3230806b 100644
--- a/examples/wayland/spanning-screens/main.qml
+++ b/examples/wayland/spanning-screens/main.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
@@ -50,20 +50,22 @@
import QtQuick 2.6
import QtQuick.Window 2.3
-import QtWayland.Compositor 1.0
+import QtWayland.Compositor 1.1
WaylandCompositor {
- id: wlcompositor
-
WaylandOutput {
- compositor: wlcompositor
sizeFollowsWindow: true
window: Window {
id: topSurfaceArea
+
+ property int pixelHeight: screen.devicePixelRatio * height
+ property int pixelWidth: screen.devicePixelRatio * width
+
width: 1024
height: 768
visible: true
color: "#1337af"
+
Text { text: "Top screen" }
// Enable the following to make the output target an actual screen,
@@ -74,14 +76,18 @@ WaylandCompositor {
}
WaylandOutput {
- compositor: wlcompositor
sizeFollowsWindow: true
window: Window {
id: bottomSurfaceArea
+
+ property int pixelHeight: screen.devicePixelRatio * height
+ property int pixelWidth: screen.devicePixelRatio * width
+
width: 1024
height: 768
visible: true
color: "#1abacc"
+
Text { text: "Bottom screen" }
// Enable the following to make the output target an actual screen,
@@ -93,56 +99,29 @@ WaylandCompositor {
Component {
id: chromeComponent
- WaylandQuickItem {
- onSurfaceDestroyed: destroy()
- }
- }
-
- Component {
- id: xdgPopupComponent
ShellSurfaceItem {
+ autoCreatePopupItems: true
onSurfaceDestroyed: destroy()
}
}
- WlShell {
- onWlShellSurfaceCreated: handleShellSurfaceCreated(shellSurface)
- }
+ XdgShellV6 {
+ onToplevelCreated: {
+ const shellSurface = xdgSurface;
- property variant viewsBySurface: ({})
+ const topItem = chromeComponent.createObject(topSurfaceArea, {
+ shellSurface
+ });
- XdgShellV5 {
- onXdgSurfaceCreated: handleShellSurfaceCreated(xdgSurface)
- onXdgPopupCreated: {
- var parentViews = viewsBySurface[xdgPopup.parentSurface];
- xdgPopupComponent.createObject(parentViews.top, { "shellSurface": xdgPopup } );
- xdgPopupComponent.createObject(parentViews.bottom, { "shellSurface": xdgPopup } );
- }
- }
+ const bottomItem = chromeComponent.createObject(bottomSurfaceArea, {
+ shellSurface,
+ y: Qt.binding(function() { return -topSurfaceArea.height;})
+ });
- function handleShellSurfaceCreated(shellSurface) {
- var topItem = chromeComponent.createObject(topSurfaceArea, {
- "surface": shellSurface.surface
- });
-
- var bottomItem = chromeComponent.createObject(bottomSurfaceArea, {
- "surface": shellSurface.surface,
- "y": Qt.binding(function() { return -topSurfaceArea.height;})
- });
-
- viewsBySurface[shellSurface.surface] = {
- top: topItem,
- bottom: bottomItem
- };
-
- var height = bottomSurfaceArea.height + topSurfaceArea.height;
- var width = Math.max(bottomSurfaceArea.width, topSurfaceArea.width);
- var size = Qt.size(width, height);
-
- if (shellSurface.sendFullscreen) {
- shellSurface.sendFullscreen(size);
- } else if (shellSurface.sendConfigure) {
- shellSurface.sendConfigure(size, WlShellSurface.NoneEdge);
+ const height = topSurfaceArea.pixelHeight + bottomSurfaceArea.pixelHeight;
+ const width = Math.max(bottomSurfaceArea.pixelWidth, topSurfaceArea.pixelWidth);
+ const size = Qt.size(width, height);
+ toplevel.sendFullscreen(size);
}
}
}
diff --git a/examples/wayland/wayland.pro b/examples/wayland/wayland.pro
index a8eef8266..0cb050cca 100644
--- a/examples/wayland/wayland.pro
+++ b/examples/wayland/wayland.pro
@@ -12,6 +12,7 @@ qtHaveModule(quick) {
SUBDIRS += pure-qml
SUBDIRS += multi-output
SUBDIRS += multi-screen
+ SUBDIRS += overview-compositor
SUBDIRS += ivi-compositor
qtHaveModule(waylandclient) {
SUBDIRS += \
diff --git a/src/3rdparty/protocol/qt_attribution.json b/src/3rdparty/protocol/qt_attribution.json
index f35dec4f3..6034508ba 100644
--- a/src/3rdparty/protocol/qt_attribution.json
+++ b/src/3rdparty/protocol/qt_attribution.json
@@ -37,11 +37,27 @@ Copyright (c) 2013 BMW Car IT GmbH"
},
{
+ "Id": "wayland-xdg-output-protocol",
+ "Name": "Wayland XDG Output Protocol",
+ "QDocModule": "qtwaylandcompositor",
+ "QtUsage": "Used in the Qt Wayland platform plugin.",
+ "Files": "xdg-output-unstable-v1.xml",
+ "Description": "The XDG Output protocol is an extended way to describe output regions under Wayland",
+ "Homepage": "https://wayland.freedesktop.org",
+ "Version": "unstable v1, version 2",
+ "DownloadLocation": "https://cgit.freedesktop.org/wayland/wayland-protocols/plain/unstable/xdg-output/xdg-output-unstable-v1.xml?h=1.16",
+ "LicenseId": "MIT",
+ "License": "MIT License",
+ "LicenseFile": "MIT_LICENSE.txt",
+ "Copyright": "Copyright © 2017 Red Hat Inc."
+ },
+
+ {
"Id": "wayland-xdg-shell-protocol",
"Name": "Wayland XDG Shell Protocol",
"QDocModule": "qtwaylandcompositor",
"QtUsage": "Used in the Qt Wayland Compositor, and the Qt Wayland platform plugin.",
- "Files": "xdg-shell.xml",
+ "Files": "xdg-shell-unstable-v5.xml xdg-shell-unstable-v6.xml xdg-shell.xml",
"Description": "The XDG-Shell protocol is an extended way to manage surfaces under Wayland compositors.",
"Homepage": "https://wayland.freedesktop.org",
diff --git a/src/3rdparty/protocol/xdg-output-unstable-v1.xml b/src/3rdparty/protocol/xdg-output-unstable-v1.xml
new file mode 100644
index 000000000..ccbfe1c9a
--- /dev/null
+++ b/src/3rdparty/protocol/xdg-output-unstable-v1.xml
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="xdg_output_unstable_v1">
+
+ <copyright>
+ Copyright © 2017 Red Hat Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ </copyright>
+
+ <description summary="Protocol to describe output regions">
+ This protocol aims at describing outputs in a way which is more in line
+ with the concept of an output on desktop oriented systems.
+
+ Some information are more specific to the concept of an output for
+ a desktop oriented system and may not make sense in other applications,
+ such as IVI systems for example.
+
+ Typically, the global compositor space on a desktop system is made of
+ a contiguous or overlapping set of rectangular regions.
+
+ Some of the information provided in this protocol might be identical
+ to their counterparts already available from wl_output, in which case
+ the information provided by this protocol should be preferred to their
+ equivalent in wl_output. The goal is to move the desktop specific
+ concepts (such as output location within the global compositor space,
+ the connector name and types, etc.) out of the core wl_output protocol.
+
+ Warning! The protocol described in this file is experimental and
+ backward incompatible changes may be made. Backward compatible
+ changes may be added together with the corresponding interface
+ version bump.
+ Backward incompatible changes are done by bumping the version
+ number in the protocol and interface names and resetting the
+ interface version. Once the protocol is to be declared stable,
+ the 'z' prefix and the version number in the protocol and
+ interface names are removed and the interface version number is
+ reset.
+ </description>
+
+ <interface name="zxdg_output_manager_v1" version="2">
+ <description summary="manage xdg_output objects">
+ A global factory interface for xdg_output objects.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the xdg_output_manager object">
+ Using this request a client can tell the server that it is not
+ going to use the xdg_output_manager object anymore.
+
+ Any objects already created through this instance are not affected.
+ </description>
+ </request>
+
+ <request name="get_xdg_output">
+ <description summary="create an xdg output from a wl_output">
+ This creates a new xdg_output object for the given wl_output.
+ </description>
+ <arg name="id" type="new_id" interface="zxdg_output_v1"/>
+ <arg name="output" type="object" interface="wl_output"/>
+ </request>
+ </interface>
+
+ <interface name="zxdg_output_v1" version="2">
+ <description summary="compositor logical output region">
+ An xdg_output describes part of the compositor geometry.
+
+ This typically corresponds to a monitor that displays part of the
+ compositor space.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the xdg_output object">
+ Using this request a client can tell the server that it is not
+ going to use the xdg_output object anymore.
+ </description>
+ </request>
+
+ <event name="logical_position">
+ <description summary="position of the output within the global compositor space">
+ The position event describes the location of the wl_output within
+ the global compositor space.
+
+ The logical_position event is sent after creating an xdg_output
+ (see xdg_output_manager.get_xdg_output) and whenever the location
+ of the output changes within the global compositor space.
+ </description>
+ <arg name="x" type="int"
+ summary="x position within the global compositor space"/>
+ <arg name="y" type="int"
+ summary="y position within the global compositor space"/>
+ </event>
+
+ <event name="logical_size">
+ <description summary="size of the output in the global compositor space">
+ The logical_size event describes the size of the output in the
+ global compositor space.
+
+ For example, a surface without any buffer scale, transformation
+ nor rotation set, with the size matching the logical_size will
+ have the same size as the corresponding output when displayed.
+
+ Most regular Wayland clients should not pay attention to the
+ logical size and would rather rely on xdg_shell interfaces.
+
+ Some clients such as Xwayland, however, need this to configure
+ their surfaces in the global compositor space as the compositor
+ may apply a different scale from what is advertised by the output
+ scaling property (to achieve fractional scaling, for example).
+
+ For example, for a wl_output mode 3840×2160 and a scale factor 2:
+
+ - A compositor not scaling the surface buffers will advertise a
+ logical size of 3840×2160,
+
+ - A compositor automatically scaling the surface buffers will
+ advertise a logical size of 1920×1080,
+
+ - A compositor using a fractional scale of 1.5 will advertise a
+ logical size to 2560×1620.
+
+ For example, for a wl_output mode 1920×1080 and a 90 degree rotation,
+ the compositor will advertise a logical size of 1080x1920.
+
+ The logical_size event is sent after creating an xdg_output
+ (see xdg_output_manager.get_xdg_output) and whenever the logical
+ size of the output changes, either as a result of a change in the
+ applied scale or because of a change in the corresponding output
+ mode(see wl_output.mode) or transform (see wl_output.transform).
+ </description>
+ <arg name="width" type="int"
+ summary="width in global compositor space"/>
+ <arg name="height" type="int"
+ summary="height in global compositor space"/>
+ </event>
+
+ <event name="done">
+ <description summary="all information about the output have been sent">
+ This event is sent after all other properties of an xdg_output
+ have been sent.
+
+ This allows changes to the xdg_output properties to be seen as
+ atomic, even if they happen via multiple events.
+ </description>
+ </event>
+
+ <!-- Version 2 additions -->
+
+ <event name="name" since="2">
+ <description summary="name of this output">
+ Many compositors will assign names to their outputs, show them to the
+ user, allow them to be configured by name, etc. The client may wish to
+ know this name as well to offer the user similar behaviors.
+
+ The naming convention is compositor defined, but limited to
+ alphanumeric characters and dashes (-). Each name is unique among all
+ wl_output globals, but if a wl_output global is destroyed the same name
+ may be reused later. The names will also remain consistent across
+ sessions with the same hardware and software configuration.
+
+ Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do
+ not assume that the name is a reflection of an underlying DRM
+ connector, X11 connection, etc.
+
+ The name event is sent after creating an xdg_output (see
+ xdg_output_manager.get_xdg_output). This event is only sent once per
+ xdg_output, and the name does not change over the lifetime of the
+ wl_output global.
+ </description>
+ <arg name="name" type="string" summary="output name"/>
+ </event>
+
+ <event name="description" since="2">
+ <description summary="human-readable description of this output">
+ Many compositors can produce human-readable descriptions of their
+ outputs. The client may wish to know this description as well, to
+ communicate the user for various purposes.
+
+ The description is a UTF-8 string with no convention defined for its
+ contents. Examples might include 'Foocorp 11" Display' or 'Virtual X11
+ output via :1'.
+
+ The description event is sent after creating an xdg_output (see
+ xdg_output_manager.get_xdg_output). This event is only sent once per
+ xdg_output, and the description does not change over the lifetime of
+ the wl_output global. The description is optional, and may not be sent
+ at all.
+ </description>
+ <arg name="description" type="string" summary="output description"/>
+ </event>
+
+ </interface>
+</protocol>
diff --git a/src/3rdparty/protocol/xdg-shell-unstable-v5.xml b/src/3rdparty/protocol/xdg-shell-unstable-v5.xml
new file mode 100644
index 000000000..89c9d58c5
--- /dev/null
+++ b/src/3rdparty/protocol/xdg-shell-unstable-v5.xml
@@ -0,0 +1,608 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="xdg_shell_unstable_v5">
+
+ <copyright>
+ Copyright © 2008-2013 Kristian Høgsberg
+ Copyright © 2013 Rafael Antognolli
+ Copyright © 2013 Jasper St. Pierre
+ Copyright © 2010-2013 Intel Corporation
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ </copyright>
+
+ <interface name="xdg_shell" version="1">
+ <description summary="create desktop-style surfaces">
+ xdg_shell allows clients to turn a wl_surface into a "real window"
+ which can be dragged, resized, stacked, and moved around by the
+ user. Everything about this interface is suited towards traditional
+ desktop environments.
+ </description>
+
+ <enum name="version">
+ <description summary="latest protocol version">
+ The 'current' member of this enum gives the version of the
+ protocol. Implementations can compare this to the version
+ they implement using static_assert to ensure the protocol and
+ implementation versions match.
+ </description>
+ <entry name="current" value="5" summary="Always the latest version"/>
+ </enum>
+
+ <enum name="error">
+ <entry name="role" value="0" summary="given wl_surface has another role"/>
+ <entry name="defunct_surfaces" value="1" summary="xdg_shell was destroyed before children"/>
+ <entry name="not_the_topmost_popup" value="2" summary="the client tried to map or destroy a non-topmost popup"/>
+ <entry name="invalid_popup_parent" value="3" summary="the client specified an invalid popup parent surface"/>
+ </enum>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy xdg_shell">
+ Destroy this xdg_shell object.
+
+ Destroying a bound xdg_shell object while there are surfaces
+ still alive created by this xdg_shell object instance is illegal
+ and will result in a protocol error.
+ </description>
+ </request>
+
+ <request name="use_unstable_version">
+ <description summary="enable use of this unstable version">
+ Negotiate the unstable version of the interface. This
+ mechanism is in place to ensure client and server agree on the
+ unstable versions of the protocol that they speak or exit
+ cleanly if they don't agree. This request will go away once
+ the xdg-shell protocol is stable.
+ </description>
+ <arg name="version" type="int"/>
+ </request>
+
+ <request name="get_xdg_surface">
+ <description summary="create a shell surface from a surface">
+ This creates an xdg_surface for the given surface and gives it the
+ xdg_surface role. A wl_surface can only be given an xdg_surface role
+ once. If get_xdg_surface is called with a wl_surface that already has
+ an active xdg_surface associated with it, or if it had any other role,
+ an error is raised.
+
+ See the documentation of xdg_surface for more details about what an
+ xdg_surface is and how it is used.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_surface"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+
+ <request name="get_xdg_popup">
+ <description summary="create a popup for a surface">
+ This creates an xdg_popup for the given surface and gives it the
+ xdg_popup role. A wl_surface can only be given an xdg_popup role
+ once. If get_xdg_popup is called with a wl_surface that already has
+ an active xdg_popup associated with it, or if it had any other role,
+ an error is raised.
+
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event.
+
+ See the documentation of xdg_popup for more details about what an
+ xdg_popup is and how it is used.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_popup"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="parent" type="object" interface="wl_surface"/>
+ <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ </request>
+
+ <event name="ping">
+ <description summary="check if the client is alive">
+ The ping event asks the client if it's still alive. Pass the
+ serial specified in the event back to the compositor by sending
+ a "pong" request back with the specified serial.
+
+ Compositors can use this to determine if the client is still
+ alive. It's unspecified what will happen if the client doesn't
+ respond to the ping request, or in what timeframe. Clients should
+ try to respond in a reasonable amount of time.
+
+ A compositor is free to ping in any way it wants, but a client must
+ always respond to any xdg_shell object it created.
+ </description>
+ <arg name="serial" type="uint" summary="pass this to the pong request"/>
+ </event>
+
+ <request name="pong">
+ <description summary="respond to a ping event">
+ A client must respond to a ping event with a pong request or
+ the client may be deemed unresponsive.
+ </description>
+ <arg name="serial" type="uint" summary="serial of the ping event"/>
+ </request>
+ </interface>
+
+ <interface name="xdg_surface" version="1">
+ <description summary="A desktop window">
+ An interface that may be implemented by a wl_surface, for
+ implementations that provide a desktop-style user interface.
+
+ It provides requests to treat surfaces like windows, allowing to set
+ properties like maximized, fullscreen, minimized, and to move and resize
+ them, and associate metadata like title and app id.
+
+ The client must call wl_surface.commit on the corresponding wl_surface
+ for the xdg_surface state to take effect. Prior to committing the new
+ state, it can set up initial configuration, such as maximizing or setting
+ a window geometry.
+
+ Even without attaching a buffer the compositor must respond to initial
+ committed configuration, for instance sending a configure event with
+ expected window geometry if the client maximized its surface during
+ initialization.
+
+ For a surface to be mapped by the compositor the client must have
+ committed both an xdg_surface state and a buffer.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="Destroy the xdg_surface">
+ Unmap and destroy the window. The window will be effectively
+ hidden from the user's point of view, and all state like
+ maximization, fullscreen, and so on, will be lost.
+ </description>
+ </request>
+
+ <request name="set_parent">
+ <description summary="set the parent of this surface">
+ Set the "parent" of this surface. This window should be stacked
+ above a parent. The parent surface must be mapped as long as this
+ surface is mapped.
+
+ Parent windows should be set on dialogs, toolboxes, or other
+ "auxiliary" surfaces, so that the parent is raised when the dialog
+ is raised.
+ </description>
+ <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/>
+ </request>
+
+ <request name="set_title">
+ <description summary="set surface title">
+ Set a short title for the surface.
+
+ This string may be used to identify the surface in a task bar,
+ window list, or other user interface elements provided by the
+ compositor.
+
+ The string must be encoded in UTF-8.
+ </description>
+ <arg name="title" type="string"/>
+ </request>
+
+ <request name="set_app_id">
+ <description summary="set application ID">
+ Set an application identifier for the surface.
+
+ The app ID identifies the general class of applications to which
+ the surface belongs. The compositor can use this to group multiple
+ surfaces together, or to determine how to launch a new application.
+
+ For D-Bus activatable applications, the app ID is used as the D-Bus
+ service name.
+
+ The compositor shell will try to group application surfaces together
+ by their app ID. As a best practice, it is suggested to select app
+ ID's that match the basename of the application's .desktop file.
+ For example, "org.freedesktop.FooViewer" where the .desktop file is
+ "org.freedesktop.FooViewer.desktop".
+
+ See the desktop-entry specification [0] for more details on
+ application identifiers and how they relate to well-known D-Bus
+ names and .desktop files.
+
+ [0] http://standards.freedesktop.org/desktop-entry-spec/
+ </description>
+ <arg name="app_id" type="string"/>
+ </request>
+
+ <request name="show_window_menu">
+ <description summary="show the window menu">
+ Clients implementing client-side decorations might want to show
+ a context menu when right-clicking on the decorations, giving the
+ user a menu that they can use to maximize or minimize the window.
+
+ This request asks the compositor to pop up such a window menu at
+ the given position, relative to the local surface coordinates of
+ the parent surface. There are no guarantees as to what menu items
+ the window menu contains.
+
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event.
+ </description>
+
+ <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ <arg name="x" type="int" summary="the x position to pop up the window menu at"/>
+ <arg name="y" type="int" summary="the y position to pop up the window menu at"/>
+ </request>
+
+ <request name="move">
+ <description summary="start an interactive move">
+ Start an interactive, user-driven move of the surface.
+
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event. The passed
+ serial is used to determine the type of interactive move (touch,
+ pointer, etc).
+
+ The server may ignore move requests depending on the state of
+ the surface (e.g. fullscreen or maximized), or if the passed serial
+ is no longer valid.
+
+ If triggered, the surface will lose the focus of the device
+ (wl_pointer, wl_touch, etc) used for the move. It is up to the
+ compositor to visually indicate that the move is taking place, such as
+ updating a pointer cursor, during the move. There is no guarantee
+ that the device focus will return when the move is completed.
+ </description>
+ <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ </request>
+
+ <enum name="resize_edge">
+ <description summary="edge values for resizing">
+ These values are used to indicate which edge of a surface
+ is being dragged in a resize operation.
+ </description>
+ <entry name="none" value="0"/>
+ <entry name="top" value="1"/>
+ <entry name="bottom" value="2"/>
+ <entry name="left" value="4"/>
+ <entry name="top_left" value="5"/>
+ <entry name="bottom_left" value="6"/>
+ <entry name="right" value="8"/>
+ <entry name="top_right" value="9"/>
+ <entry name="bottom_right" value="10"/>
+ </enum>
+
+ <request name="resize">
+ <description summary="start an interactive resize">
+ Start a user-driven, interactive resize of the surface.
+
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event. The passed
+ serial is used to determine the type of interactive resize (touch,
+ pointer, etc).
+
+ The server may ignore resize requests depending on the state of
+ the surface (e.g. fullscreen or maximized).
+
+ If triggered, the client will receive configure events with the
+ "resize" state enum value and the expected sizes. See the "resize"
+ enum value for more details about what is required. The client
+ must also acknowledge configure events using "ack_configure". After
+ the resize is completed, the client will receive another "configure"
+ event without the resize state.
+
+ If triggered, the surface also will lose the focus of the device
+ (wl_pointer, wl_touch, etc) used for the resize. It is up to the
+ compositor to visually indicate that the resize is taking place,
+ such as updating a pointer cursor, during the resize. There is no
+ guarantee that the device focus will return when the resize is
+ completed.
+
+ The edges parameter specifies how the surface should be resized,
+ and is one of the values of the resize_edge enum. The compositor
+ may use this information to update the surface position for
+ example when dragging the top left corner. The compositor may also
+ use this information to adapt its behavior, e.g. choose an
+ appropriate cursor image.
+ </description>
+ <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ <arg name="edges" type="uint" summary="which edge or corner is being dragged"/>
+ </request>
+
+ <enum name="state">
+ <description summary="types of state on the surface">
+ The different state values used on the surface. This is designed for
+ state values like maximized, fullscreen. It is paired with the
+ configure event to ensure that both the client and the compositor
+ setting the state can be synchronized.
+
+ States set in this way are double-buffered. They will get applied on
+ the next commit.
+
+ Desktop environments may extend this enum by taking up a range of
+ values and documenting the range they chose in this description.
+ They are not required to document the values for the range that they
+ chose. Ideally, any good extensions from a desktop environment should
+ make its way into standardization into this enum.
+
+ The current reserved ranges are:
+
+ 0x0000 - 0x0FFF: xdg-shell core values, documented below.
+ 0x1000 - 0x1FFF: GNOME
+ </description>
+ <entry name="maximized" value="1" summary="the surface is maximized">
+ The surface is maximized. The window geometry specified in the configure
+ event must be obeyed by the client.
+ </entry>
+ <entry name="fullscreen" value="2" summary="the surface is fullscreen">
+ The surface is fullscreen. The window geometry specified in the configure
+ event must be obeyed by the client.
+ </entry>
+ <entry name="resizing" value="3">
+ The surface is being resized. The window geometry specified in the
+ configure event is a maximum; the client cannot resize beyond it.
+ Clients that have aspect ratio or cell sizing configuration can use
+ a smaller size, however.
+ </entry>
+ <entry name="activated" value="4">
+ Client window decorations should be painted as if the window is
+ active. Do not assume this means that the window actually has
+ keyboard or pointer focus.
+ </entry>
+ </enum>
+
+ <event name="configure">
+ <description summary="suggest a surface change">
+ The configure event asks the client to resize its surface or to
+ change its state.
+
+ The width and height arguments specify a hint to the window
+ about how its surface should be resized in window geometry
+ coordinates. See set_window_geometry.
+
+ If the width or height arguments are zero, it means the client
+ should decide its own window dimension. This may happen when the
+ compositor need to configure the state of the surface but doesn't
+ have any information about any previous or expected dimension.
+
+ The states listed in the event specify how the width/height
+ arguments should be interpreted, and possibly how it should be
+ drawn.
+
+ Clients should arrange their surface for the new size and
+ states, and then send a ack_configure request with the serial
+ sent in this configure event at some point before committing
+ the new surface.
+
+ If the client receives multiple configure events before it
+ can respond to one, it is free to discard all but the last
+ event it received.
+ </description>
+
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ <arg name="states" type="array"/>
+ <arg name="serial" type="uint"/>
+ </event>
+
+ <request name="ack_configure">
+ <description summary="ack a configure event">
+ When a configure event is received, if a client commits the
+ surface in response to the configure event, then the client
+ must make a ack_configure request before the commit request,
+ passing along the serial of the configure event.
+
+ For instance, the compositor might use this information to move
+ a surface to the top left only when the client has drawn itself
+ for the maximized or fullscreen state.
+
+ If the client receives multiple configure events before it
+ can respond to one, it only has to ack the last configure event.
+ </description>
+ <arg name="serial" type="uint" summary="the serial from the configure event"/>
+ </request>
+
+ <request name="set_window_geometry">
+ <description summary="set the new window geometry">
+ The window geometry of a window is its "visible bounds" from the
+ user's perspective. Client-side decorations often have invisible
+ portions like drop-shadows which should be ignored for the
+ purposes of aligning, placing and constraining windows.
+
+ The window geometry is double buffered, and will be applied at the
+ time wl_surface.commit of the corresponding wl_surface is called.
+
+ Once the window geometry of the surface is set once, it is not
+ possible to unset it, and it will remain the same until
+ set_window_geometry is called again, even if a new subsurface or
+ buffer is attached.
+
+ If never set, the value is the full bounds of the surface,
+ including any subsurfaces. This updates dynamically on every
+ commit. This unset mode is meant for extremely simple clients.
+
+ If responding to a configure event, the window geometry in here
+ must respect the sizing negotiations specified by the states in
+ the configure event.
+
+ The arguments are given in the surface local coordinate space of
+ the wl_surface associated with this xdg_surface.
+
+ The width and height must be greater than zero.
+ </description>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <request name="set_maximized">
+ <description summary="maximize the window">
+ Maximize the surface.
+
+ After requesting that the surface should be maximized, the compositor
+ will respond by emitting a configure event with the "maximized" state
+ and the required window geometry. The client should then update its
+ content, drawing it in a maximized state, i.e. without shadow or other
+ decoration outside of the window geometry. The client must also
+ acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ It is up to the compositor to decide how and where to maximize the
+ surface, for example which output and what region of the screen should
+ be used.
+
+ If the surface was already maximized, the compositor will still emit
+ a configure event with the "maximized" state.
+ </description>
+ </request>
+
+ <request name="unset_maximized">
+ <description summary="unmaximize the window">
+ Unmaximize the surface.
+
+ After requesting that the surface should be unmaximized, the compositor
+ will respond by emitting a configure event without the "maximized"
+ state. If available, the compositor will include the window geometry
+ dimensions the window had prior to being maximized in the configure
+ request. The client must then update its content, drawing it in a
+ regular state, i.e. potentially with shadow, etc. The client must also
+ acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ It is up to the compositor to position the surface after it was
+ unmaximized; usually the position the surface had before maximizing, if
+ applicable.
+
+ If the surface was already not maximized, the compositor will still
+ emit a configure event without the "maximized" state.
+ </description>
+ </request>
+
+ <request name="set_fullscreen">
+ <description summary="set the window as fullscreen on a monitor">
+ Make the surface fullscreen.
+
+ You can specify an output that you would prefer to be fullscreen.
+ If this value is NULL, it's up to the compositor to choose which
+ display will be used to map this surface.
+
+ If the surface doesn't cover the whole output, the compositor will
+ position the surface in the center of the output and compensate with
+ black borders filling the rest of the output.
+ </description>
+ <arg name="output" type="object" interface="wl_output" allow-null="true"/>
+ </request>
+ <request name="unset_fullscreen" />
+
+ <request name="set_minimized">
+ <description summary="set the window as minimized">
+ Request that the compositor minimize your surface. There is no
+ way to know if the surface is currently minimized, nor is there
+ any way to unset minimization on this surface.
+
+ If you are looking to throttle redrawing when minimized, please
+ instead use the wl_surface.frame event for this, as this will
+ also work with live previews on windows in Alt-Tab, Expose or
+ similar compositor features.
+ </description>
+ </request>
+
+ <event name="close">
+ <description summary="surface wants to be closed">
+ The close event is sent by the compositor when the user
+ wants the surface to be closed. This should be equivalent to
+ the user clicking the close button in client-side decorations,
+ if your application has any...
+
+ This is only a request that the user intends to close your
+ window. The client may choose to ignore this request, or show
+ a dialog to ask the user to save their data...
+ </description>
+ </event>
+ </interface>
+
+ <interface name="xdg_popup" version="1">
+ <description summary="short-lived, popup surfaces for menus">
+ A popup surface is a short-lived, temporary surface that can be
+ used to implement menus. It takes an explicit grab on the surface
+ that will be dismissed when the user dismisses the popup. This can
+ be done by the user clicking outside the surface, using the keyboard,
+ or even locking the screen through closing the lid or a timeout.
+
+ When the popup is dismissed, a popup_done event will be sent out,
+ and at the same time the surface will be unmapped. The xdg_popup
+ object is now inert and cannot be reactivated, so clients should
+ destroy it. Explicitly destroying the xdg_popup object will also
+ dismiss the popup and unmap the surface.
+
+ Clients will receive events for all their surfaces during this
+ grab (which is an "owner-events" grab in X11 parlance). This is
+ done so that users can navigate through submenus and other
+ "nested" popup windows without having to dismiss the topmost
+ popup.
+
+ Clients that want to dismiss the popup when another surface of
+ their own is clicked should dismiss the popup using the destroy
+ request.
+
+ The parent surface must have either an xdg_surface or xdg_popup
+ role.
+
+ Specifying an xdg_popup for the parent means that the popups are
+ nested, with this popup now being the topmost popup. Nested
+ popups must be destroyed in the reverse order they were created
+ in, e.g. the only popup you are allowed to destroy at all times
+ is the topmost one.
+
+ If there is an existing popup when creating a new popup, the
+ parent must be the current topmost popup.
+
+ A parent surface must be mapped before the new popup is mapped.
+
+ When compositors choose to dismiss a popup, they will likely
+ dismiss every nested popup as well. When a compositor dismisses
+ popups, it will follow the same dismissing order as required
+ from the client.
+
+ The x and y arguments passed when creating the popup object specify
+ where the top left of the popup should be placed, relative to the
+ local surface coordinates of the parent surface. See
+ xdg_shell.get_xdg_popup.
+
+ The client must call wl_surface.commit on the corresponding wl_surface
+ for the xdg_popup state to take effect.
+
+ For a surface to be mapped by the compositor the client must have
+ committed both the xdg_popup state and a buffer.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="remove xdg_popup interface">
+ This destroys the popup. Explicitly destroying the xdg_popup
+ object will also dismiss the popup, and unmap the surface.
+
+ If this xdg_popup is not the "topmost" popup, a protocol error
+ will be sent.
+ </description>
+ </request>
+
+ <event name="popup_done">
+ <description summary="popup interaction is done">
+ The popup_done event is sent out when a popup is dismissed by the
+ compositor. The client should destroy the xdg_popup object at this
+ point.
+ </description>
+ </event>
+
+ </interface>
+</protocol>
diff --git a/src/3rdparty/protocol/xdg-shell.xml b/src/3rdparty/protocol/xdg-shell.xml
index f98e760d4..d524ea9e2 100644
--- a/src/3rdparty/protocol/xdg-shell.xml
+++ b/src/3rdparty/protocol/xdg-shell.xml
@@ -6,6 +6,8 @@
Copyright © 2013 Rafael Antognolli
Copyright © 2013 Jasper St. Pierre
Copyright © 2010-2013 Intel Corporation
+ Copyright © 2015-2017 Samsung Electronics Co., Ltd
+ Copyright © 2015-2017 Red Hat Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -27,59 +29,58 @@
DEALINGS IN THE SOFTWARE.
</copyright>
- <interface name="xdg_shell" version="1">
+ <interface name="xdg_wm_base" version="1">
<description summary="create desktop-style surfaces">
- xdg_shell allows clients to turn a wl_surface into a "real window"
- which can be dragged, resized, stacked, and moved around by the
- user. Everything about this interface is suited towards traditional
- desktop environments.
+ The xdg_wm_base interface is exposed as a global object enabling clients
+ to turn their wl_surfaces into windows in a desktop environment. It
+ defines the basic functionality needed for clients and the compositor to
+ create windows that can be dragged, resized, maximized, etc, as well as
+ creating transient windows such as popup menus.
</description>
- <enum name="version">
- <description summary="latest protocol version">
- The 'current' member of this enum gives the version of the
- protocol. Implementations can compare this to the version
- they implement using static_assert to ensure the protocol and
- implementation versions match.
- </description>
- <entry name="current" value="5" summary="Always the latest version"/>
- </enum>
-
<enum name="error">
<entry name="role" value="0" summary="given wl_surface has another role"/>
- <entry name="defunct_surfaces" value="1" summary="xdg_shell was destroyed before children"/>
- <entry name="not_the_topmost_popup" value="2" summary="the client tried to map or destroy a non-topmost popup"/>
- <entry name="invalid_popup_parent" value="3" summary="the client specified an invalid popup parent surface"/>
+ <entry name="defunct_surfaces" value="1"
+ summary="xdg_wm_base was destroyed before children"/>
+ <entry name="not_the_topmost_popup" value="2"
+ summary="the client tried to map or destroy a non-topmost popup"/>
+ <entry name="invalid_popup_parent" value="3"
+ summary="the client specified an invalid popup parent surface"/>
+ <entry name="invalid_surface_state" value="4"
+ summary="the client provided an invalid surface state"/>
+ <entry name="invalid_positioner" value="5"
+ summary="the client provided an invalid positioner"/>
</enum>
<request name="destroy" type="destructor">
- <description summary="destroy xdg_shell">
- Destroy this xdg_shell object.
+ <description summary="destroy xdg_wm_base">
+ Destroy this xdg_wm_base object.
- Destroying a bound xdg_shell object while there are surfaces
- still alive created by this xdg_shell object instance is illegal
- and will result in a protocol error.
+ Destroying a bound xdg_wm_base object while there are surfaces
+ still alive created by this xdg_wm_base object instance is illegal
+ and will result in a protocol error.
</description>
</request>
- <request name="use_unstable_version">
- <description summary="enable use of this unstable version">
- Negotiate the unstable version of the interface. This
- mechanism is in place to ensure client and server agree on the
- unstable versions of the protocol that they speak or exit
- cleanly if they don't agree. This request will go away once
- the xdg-shell protocol is stable.
+ <request name="create_positioner">
+ <description summary="create a positioner object">
+ Create a positioner object. A positioner object is used to position
+ surfaces relative to some parent surface. See the interface description
+ and xdg_surface.get_popup for details.
</description>
- <arg name="version" type="int"/>
+ <arg name="id" type="new_id" interface="xdg_positioner"/>
</request>
<request name="get_xdg_surface">
<description summary="create a shell surface from a surface">
- This creates an xdg_surface for the given surface and gives it the
- xdg_surface role. A wl_surface can only be given an xdg_surface role
- once. If get_xdg_surface is called with a wl_surface that already has
- an active xdg_surface associated with it, or if it had any other role,
- an error is raised.
+ This creates an xdg_surface for the given surface. While xdg_surface
+ itself is not a role, the corresponding surface may only be assigned
+ a role extending xdg_surface, such as xdg_toplevel or xdg_popup.
+
+ This creates an xdg_surface for the given surface. An xdg_surface is
+ used as basis to define a role to a given surface, such as xdg_toplevel
+ or xdg_popup. It also manages functionality shared between xdg_surface
+ based surface roles.
See the documentation of xdg_surface for more details about what an
xdg_surface is and how it is used.
@@ -88,97 +89,489 @@
<arg name="surface" type="object" interface="wl_surface"/>
</request>
- <request name="get_xdg_popup">
- <description summary="create a popup for a surface">
- This creates an xdg_popup for the given surface and gives it the
- xdg_popup role. A wl_surface can only be given an xdg_popup role
- once. If get_xdg_popup is called with a wl_surface that already has
- an active xdg_popup associated with it, or if it had any other role,
- an error is raised.
-
- This request must be used in response to some sort of user action
- like a button press, key press, or touch down event.
-
- See the documentation of xdg_popup for more details about what an
- xdg_popup is and how it is used.
+ <request name="pong">
+ <description summary="respond to a ping event">
+ A client must respond to a ping event with a pong request or
+ the client may be deemed unresponsive. See xdg_wm_base.ping.
</description>
- <arg name="id" type="new_id" interface="xdg_popup"/>
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="parent" type="object" interface="wl_surface"/>
- <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
- <arg name="serial" type="uint" summary="the serial of the user event"/>
- <arg name="x" type="int"/>
- <arg name="y" type="int"/>
+ <arg name="serial" type="uint" summary="serial of the ping event"/>
</request>
<event name="ping">
<description summary="check if the client is alive">
- The ping event asks the client if it's still alive. Pass the
- serial specified in the event back to the compositor by sending
- a "pong" request back with the specified serial.
+ The ping event asks the client if it's still alive. Pass the
+ serial specified in the event back to the compositor by sending
+ a "pong" request back with the specified serial. See xdg_wm_base.ping.
- Compositors can use this to determine if the client is still
- alive. It's unspecified what will happen if the client doesn't
- respond to the ping request, or in what timeframe. Clients should
- try to respond in a reasonable amount of time.
+ Compositors can use this to determine if the client is still
+ alive. It's unspecified what will happen if the client doesn't
+ respond to the ping request, or in what timeframe. Clients should
+ try to respond in a reasonable amount of time.
- A compositor is free to ping in any way it wants, but a client must
- always respond to any xdg_shell object it created.
+ A compositor is free to ping in any way it wants, but a client must
+ always respond to any xdg_wm_base object it created.
</description>
<arg name="serial" type="uint" summary="pass this to the pong request"/>
</event>
+ </interface>
- <request name="pong">
- <description summary="respond to a ping event">
- A client must respond to a ping event with a pong request or
- the client may be deemed unresponsive.
+ <interface name="xdg_positioner" version="1">
+ <description summary="child surface positioner">
+ The xdg_positioner provides a collection of rules for the placement of a
+ child surface relative to a parent surface. Rules can be defined to ensure
+ the child surface remains within the visible area's borders, and to
+ specify how the child surface changes its position, such as sliding along
+ an axis, or flipping around a rectangle. These positioner-created rules are
+ constrained by the requirement that a child surface must intersect with or
+ be at least partially adjacent to its parent surface.
+
+ See the various requests for details about possible rules.
+
+ At the time of the request, the compositor makes a copy of the rules
+ specified by the xdg_positioner. Thus, after the request is complete the
+ xdg_positioner object can be destroyed or reused; further changes to the
+ object will have no effect on previous usages.
+
+ For an xdg_positioner object to be considered complete, it must have a
+ non-zero size set by set_size, and a non-zero anchor rectangle set by
+ set_anchor_rect. Passing an incomplete xdg_positioner object when
+ positioning a surface raises an error.
+ </description>
+
+ <enum name="error">
+ <entry name="invalid_input" value="0" summary="invalid input provided"/>
+ </enum>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the xdg_positioner object">
+ Notify the compositor that the xdg_positioner will no longer be used.
</description>
- <arg name="serial" type="uint" summary="serial of the ping event"/>
+ </request>
+
+ <request name="set_size">
+ <description summary="set the size of the to-be positioned rectangle">
+ Set the size of the surface that is to be positioned with the positioner
+ object. The size is in surface-local coordinates and corresponds to the
+ window geometry. See xdg_surface.set_window_geometry.
+
+ If a zero or negative size is set the invalid_input error is raised.
+ </description>
+ <arg name="width" type="int" summary="width of positioned rectangle"/>
+ <arg name="height" type="int" summary="height of positioned rectangle"/>
+ </request>
+
+ <request name="set_anchor_rect">
+ <description summary="set the anchor rectangle within the parent surface">
+ Specify the anchor rectangle within the parent surface that the child
+ surface will be placed relative to. The rectangle is relative to the
+ window geometry as defined by xdg_surface.set_window_geometry of the
+ parent surface.
+
+ When the xdg_positioner object is used to position a child surface, the
+ anchor rectangle may not extend outside the window geometry of the
+ positioned child's parent surface.
+
+ If a negative size is set the invalid_input error is raised.
+ </description>
+ <arg name="x" type="int" summary="x position of anchor rectangle"/>
+ <arg name="y" type="int" summary="y position of anchor rectangle"/>
+ <arg name="width" type="int" summary="width of anchor rectangle"/>
+ <arg name="height" type="int" summary="height of anchor rectangle"/>
+ </request>
+
+ <enum name="anchor">
+ <entry name="none" value="0"/>
+ <entry name="top" value="1"/>
+ <entry name="bottom" value="2"/>
+ <entry name="left" value="3"/>
+ <entry name="right" value="4"/>
+ <entry name="top_left" value="5"/>
+ <entry name="bottom_left" value="6"/>
+ <entry name="top_right" value="7"/>
+ <entry name="bottom_right" value="8"/>
+ </enum>
+
+ <request name="set_anchor">
+ <description summary="set anchor rectangle anchor">
+ Defines the anchor point for the anchor rectangle. The specified anchor
+ is used derive an anchor point that the child surface will be
+ positioned relative to. If a corner anchor is set (e.g. 'top_left' or
+ 'bottom_right'), the anchor point will be at the specified corner;
+ otherwise, the derived anchor point will be centered on the specified
+ edge, or in the center of the anchor rectangle if no edge is specified.
+ </description>
+ <arg name="anchor" type="uint" enum="anchor"
+ summary="anchor"/>
+ </request>
+
+ <enum name="gravity">
+ <entry name="none" value="0"/>
+ <entry name="top" value="1"/>
+ <entry name="bottom" value="2"/>
+ <entry name="left" value="3"/>
+ <entry name="right" value="4"/>
+ <entry name="top_left" value="5"/>
+ <entry name="bottom_left" value="6"/>
+ <entry name="top_right" value="7"/>
+ <entry name="bottom_right" value="8"/>
+ </enum>
+
+ <request name="set_gravity">
+ <description summary="set child surface gravity">
+ Defines in what direction a surface should be positioned, relative to
+ the anchor point of the parent surface. If a corner gravity is
+ specified (e.g. 'bottom_right' or 'top_left'), then the child surface
+ will be placed towards the specified gravity; otherwise, the child
+ surface will be centered over the anchor point on any axis that had no
+ gravity specified.
+ </description>
+ <arg name="gravity" type="uint" enum="gravity"
+ summary="gravity direction"/>
+ </request>
+
+ <enum name="constraint_adjustment" bitfield="true">
+ <description summary="constraint adjustments">
+ The constraint adjustment value define ways the compositor will adjust
+ the position of the surface, if the unadjusted position would result
+ in the surface being partly constrained.
+
+ Whether a surface is considered 'constrained' is left to the compositor
+ to determine. For example, the surface may be partly outside the
+ compositor's defined 'work area', thus necessitating the child surface's
+ position be adjusted until it is entirely inside the work area.
+
+ The adjustments can be combined, according to a defined precedence: 1)
+ Flip, 2) Slide, 3) Resize.
+ </description>
+ <entry name="none" value="0">
+ <description summary="don't move the child surface when constrained">
+ Don't alter the surface position even if it is constrained on some
+ axis, for example partially outside the edge of an output.
+ </description>
+ </entry>
+ <entry name="slide_x" value="1">
+ <description summary="move along the x axis until unconstrained">
+ Slide the surface along the x axis until it is no longer constrained.
+
+ First try to slide towards the direction of the gravity on the x axis
+ until either the edge in the opposite direction of the gravity is
+ unconstrained or the edge in the direction of the gravity is
+ constrained.
+
+ Then try to slide towards the opposite direction of the gravity on the
+ x axis until either the edge in the direction of the gravity is
+ unconstrained or the edge in the opposite direction of the gravity is
+ constrained.
+ </description>
+ </entry>
+ <entry name="slide_y" value="2">
+ <description summary="move along the y axis until unconstrained">
+ Slide the surface along the y axis until it is no longer constrained.
+
+ First try to slide towards the direction of the gravity on the y axis
+ until either the edge in the opposite direction of the gravity is
+ unconstrained or the edge in the direction of the gravity is
+ constrained.
+
+ Then try to slide towards the opposite direction of the gravity on the
+ y axis until either the edge in the direction of the gravity is
+ unconstrained or the edge in the opposite direction of the gravity is
+ constrained.
+ </description>
+ </entry>
+ <entry name="flip_x" value="4">
+ <description summary="invert the anchor and gravity on the x axis">
+ Invert the anchor and gravity on the x axis if the surface is
+ constrained on the x axis. For example, if the left edge of the
+ surface is constrained, the gravity is 'left' and the anchor is
+ 'left', change the gravity to 'right' and the anchor to 'right'.
+
+ If the adjusted position also ends up being constrained, the resulting
+ position of the flip_x adjustment will be the one before the
+ adjustment.
+ </description>
+ </entry>
+ <entry name="flip_y" value="8">
+ <description summary="invert the anchor and gravity on the y axis">
+ Invert the anchor and gravity on the y axis if the surface is
+ constrained on the y axis. For example, if the bottom edge of the
+ surface is constrained, the gravity is 'bottom' and the anchor is
+ 'bottom', change the gravity to 'top' and the anchor to 'top'.
+
+ The adjusted position is calculated given the original anchor
+ rectangle and offset, but with the new flipped anchor and gravity
+ values.
+
+ If the adjusted position also ends up being constrained, the resulting
+ position of the flip_y adjustment will be the one before the
+ adjustment.
+ </description>
+ </entry>
+ <entry name="resize_x" value="16">
+ <description summary="horizontally resize the surface">
+ Resize the surface horizontally so that it is completely
+ unconstrained.
+ </description>
+ </entry>
+ <entry name="resize_y" value="32">
+ <description summary="vertically resize the surface">
+ Resize the surface vertically so that it is completely unconstrained.
+ </description>
+ </entry>
+ </enum>
+
+ <request name="set_constraint_adjustment">
+ <description summary="set the adjustment to be done when constrained">
+ Specify how the window should be positioned if the originally intended
+ position caused the surface to be constrained, meaning at least
+ partially outside positioning boundaries set by the compositor. The
+ adjustment is set by constructing a bitmask describing the adjustment to
+ be made when the surface is constrained on that axis.
+
+ If no bit for one axis is set, the compositor will assume that the child
+ surface should not change its position on that axis when constrained.
+
+ If more than one bit for one axis is set, the order of how adjustments
+ are applied is specified in the corresponding adjustment descriptions.
+
+ The default adjustment is none.
+ </description>
+ <arg name="constraint_adjustment" type="uint"
+ summary="bit mask of constraint adjustments"/>
+ </request>
+
+ <request name="set_offset">
+ <description summary="set surface position offset">
+ Specify the surface position offset relative to the position of the
+ anchor on the anchor rectangle and the anchor on the surface. For
+ example if the anchor of the anchor rectangle is at (x, y), the surface
+ has the gravity bottom|right, and the offset is (ox, oy), the calculated
+ surface position will be (x + ox, y + oy). The offset position of the
+ surface is the one used for constraint testing. See
+ set_constraint_adjustment.
+
+ An example use case is placing a popup menu on top of a user interface
+ element, while aligning the user interface element of the parent surface
+ with some user interface element placed somewhere in the popup surface.
+ </description>
+ <arg name="x" type="int" summary="surface position x offset"/>
+ <arg name="y" type="int" summary="surface position y offset"/>
</request>
</interface>
<interface name="xdg_surface" version="1">
- <description summary="A desktop window">
+ <description summary="desktop user interface surface base interface">
An interface that may be implemented by a wl_surface, for
implementations that provide a desktop-style user interface.
- It provides requests to treat surfaces like windows, allowing to set
- properties like maximized, fullscreen, minimized, and to move and resize
- them, and associate metadata like title and app id.
+ It provides a base set of functionality required to construct user
+ interface elements requiring management by the compositor, such as
+ toplevel windows, menus, etc. The types of functionality are split into
+ xdg_surface roles.
+
+ Creating an xdg_surface does not set the role for a wl_surface. In order
+ to map an xdg_surface, the client must create a role-specific object
+ using, e.g., get_toplevel, get_popup. The wl_surface for any given
+ xdg_surface can have at most one role, and may not be assigned any role
+ not based on xdg_surface.
+
+ A role must be assigned before any other requests are made to the
+ xdg_surface object.
The client must call wl_surface.commit on the corresponding wl_surface
- for the xdg_surface state to take effect. Prior to committing the new
- state, it can set up initial configuration, such as maximizing or setting
- a window geometry.
+ for the xdg_surface state to take effect.
+
+ Creating an xdg_surface from a wl_surface which has a buffer attached or
+ committed is a client error, and any attempts by a client to attach or
+ manipulate a buffer prior to the first xdg_surface.configure call must
+ also be treated as errors.
+
+ Mapping an xdg_surface-based role surface is defined as making it
+ possible for the surface to be shown by the compositor. Note that
+ a mapped surface is not guaranteed to be visible once it is mapped.
+
+ For an xdg_surface to be mapped by the compositor, the following
+ conditions must be met:
+ (1) the client has assigned an xdg_surface-based role to the surface
+ (2) the client has set and committed the xdg_surface state and the
+ role-dependent state to the surface
+ (3) the client has committed a buffer to the surface
+
+ A newly-unmapped surface is considered to have met condition (1) out
+ of the 3 required conditions for mapping a surface if its role surface
+ has not been destroyed.
+ </description>
+
+ <enum name="error">
+ <entry name="not_constructed" value="1"/>
+ <entry name="already_constructed" value="2"/>
+ <entry name="unconfigured_buffer" value="3"/>
+ </enum>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the xdg_surface">
+ Destroy the xdg_surface object. An xdg_surface must only be destroyed
+ after its role object has been destroyed.
+ </description>
+ </request>
+
+ <request name="get_toplevel">
+ <description summary="assign the xdg_toplevel surface role">
+ This creates an xdg_toplevel object for the given xdg_surface and gives
+ the associated wl_surface the xdg_toplevel role.
+
+ See the documentation of xdg_toplevel for more details about what an
+ xdg_toplevel is and how it is used.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_toplevel"/>
+ </request>
+
+ <request name="get_popup">
+ <description summary="assign the xdg_popup surface role">
+ This creates an xdg_popup object for the given xdg_surface and gives
+ the associated wl_surface the xdg_popup role.
+
+ If null is passed as a parent, a parent surface must be specified using
+ some other protocol, before committing the initial state.
+
+ See the documentation of xdg_popup for more details about what an
+ xdg_popup is and how it is used.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_popup"/>
+ <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/>
+ <arg name="positioner" type="object" interface="xdg_positioner"/>
+ </request>
+
+ <request name="set_window_geometry">
+ <description summary="set the new window geometry">
+ The window geometry of a surface is its "visible bounds" from the
+ user's perspective. Client-side decorations often have invisible
+ portions like drop-shadows which should be ignored for the
+ purposes of aligning, placing and constraining windows.
+
+ The window geometry is double buffered, and will be applied at the
+ time wl_surface.commit of the corresponding wl_surface is called.
+
+ When maintaining a position, the compositor should treat the (x, y)
+ coordinate of the window geometry as the top left corner of the window.
+ A client changing the (x, y) window geometry coordinate should in
+ general not alter the position of the window.
+
+ Once the window geometry of the surface is set, it is not possible to
+ unset it, and it will remain the same until set_window_geometry is
+ called again, even if a new subsurface or buffer is attached.
+
+ If never set, the value is the full bounds of the surface,
+ including any subsurfaces. This updates dynamically on every
+ commit. This unset is meant for extremely simple clients.
+
+ The arguments are given in the surface-local coordinate space of
+ the wl_surface associated with this xdg_surface.
+
+ The width and height must be greater than zero. Setting an invalid size
+ will raise an error. When applied, the effective window geometry will be
+ the set window geometry clamped to the bounding rectangle of the
+ combined geometry of the surface of the xdg_surface and the associated
+ subsurfaces.
+ </description>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <request name="ack_configure">
+ <description summary="ack a configure event">
+ When a configure event is received, if a client commits the
+ surface in response to the configure event, then the client
+ must make an ack_configure request sometime before the commit
+ request, passing along the serial of the configure event.
+
+ For instance, for toplevel surfaces the compositor might use this
+ information to move a surface to the top left only when the client has
+ drawn itself for the maximized or fullscreen state.
+
+ If the client receives multiple configure events before it
+ can respond to one, it only has to ack the last configure event.
+
+ A client is not required to commit immediately after sending
+ an ack_configure request - it may even ack_configure several times
+ before its next surface commit.
+
+ A client may send multiple ack_configure requests before committing, but
+ only the last request sent before a commit indicates which configure
+ event the client really is responding to.
+ </description>
+ <arg name="serial" type="uint" summary="the serial from the configure event"/>
+ </request>
- Even without attaching a buffer the compositor must respond to initial
- committed configuration, for instance sending a configure event with
- expected window geometry if the client maximized its surface during
- initialization.
+ <event name="configure">
+ <description summary="suggest a surface change">
+ The configure event marks the end of a configure sequence. A configure
+ sequence is a set of one or more events configuring the state of the
+ xdg_surface, including the final xdg_surface.configure event.
+
+ Where applicable, xdg_surface surface roles will during a configure
+ sequence extend this event as a latched state sent as events before the
+ xdg_surface.configure event. Such events should be considered to make up
+ a set of atomically applied configuration states, where the
+ xdg_surface.configure commits the accumulated state.
+
+ Clients should arrange their surface for the new states, and then send
+ an ack_configure request with the serial sent in this configure event at
+ some point before committing the new surface.
+
+ If the client receives multiple configure events before it can respond
+ to one, it is free to discard all but the last event it received.
+ </description>
+ <arg name="serial" type="uint" summary="serial of the configure event"/>
+ </event>
+ </interface>
- For a surface to be mapped by the compositor the client must have
- committed both an xdg_surface state and a buffer.
+ <interface name="xdg_toplevel" version="1">
+ <description summary="toplevel surface">
+ This interface defines an xdg_surface role which allows a surface to,
+ among other things, set window-like properties such as maximize,
+ fullscreen, and minimize, set application-specific metadata like title and
+ id, and well as trigger user interactive operations such as interactive
+ resize and move.
+
+ Unmapping an xdg_toplevel means that the surface cannot be shown
+ by the compositor until it is explicitly mapped again.
+ All active operations (e.g., move, resize) are canceled and all
+ attributes (e.g. title, state, stacking, ...) are discarded for
+ an xdg_toplevel surface when it is unmapped.
+
+ Attaching a null buffer to a toplevel unmaps the surface.
</description>
<request name="destroy" type="destructor">
- <description summary="Destroy the xdg_surface">
- Unmap and destroy the window. The window will be effectively
- hidden from the user's point of view, and all state like
- maximization, fullscreen, and so on, will be lost.
+ <description summary="destroy the xdg_toplevel">
+ This request destroys the role surface and unmaps the surface;
+ see "Unmapping" behavior in interface section for details.
</description>
</request>
<request name="set_parent">
<description summary="set the parent of this surface">
- Set the "parent" of this surface. This window should be stacked
- above a parent. The parent surface must be mapped as long as this
- surface is mapped.
+ Set the "parent" of this surface. This surface should be stacked
+ above the parent surface and all other ancestor surfaces.
Parent windows should be set on dialogs, toolboxes, or other
"auxiliary" surfaces, so that the parent is raised when the dialog
is raised.
+
+ Setting a null parent for a child window removes any parent-child
+ relationship for the child. Setting a null parent for a window which
+ currently has no parent is a no-op.
+
+ If the parent is unmapped then its children are managed as
+ though the parent of the now-unmapped parent has become the
+ parent of this surface. If no parent exists for the now-unmapped
+ parent then the children are managed as though they have no
+ parent surface.
</description>
- <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/>
+ <arg name="parent" type="object" interface="xdg_toplevel" allow-null="true"/>
</request>
<request name="set_title">
@@ -206,7 +599,7 @@
service name.
The compositor shell will try to group application surfaces together
- by their app ID. As a best practice, it is suggested to select app
+ by their app ID. As a best practice, it is suggested to select app
ID's that match the basename of the application's .desktop file.
For example, "org.freedesktop.FooViewer" where the .desktop file is
"org.freedesktop.FooViewer.desktop".
@@ -222,19 +615,18 @@
<request name="show_window_menu">
<description summary="show the window menu">
- Clients implementing client-side decorations might want to show
- a context menu when right-clicking on the decorations, giving the
- user a menu that they can use to maximize or minimize the window.
+ Clients implementing client-side decorations might want to show
+ a context menu when right-clicking on the decorations, giving the
+ user a menu that they can use to maximize or minimize the window.
- This request asks the compositor to pop up such a window menu at
- the given position, relative to the local surface coordinates of
- the parent surface. There are no guarantees as to what menu items
- the window menu contains.
+ This request asks the compositor to pop up such a window menu at
+ the given position, relative to the local surface coordinates of
+ the parent surface. There are no guarantees as to what menu items
+ the window menu contains.
- This request must be used in response to some sort of user action
- like a button press, key press, or touch down event.
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event.
</description>
-
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
<arg name="serial" type="uint" summary="the serial of the user event"/>
<arg name="x" type="int" summary="the x position to pop up the window menu at"/>
@@ -320,189 +712,228 @@
<enum name="state">
<description summary="types of state on the surface">
- The different state values used on the surface. This is designed for
- state values like maximized, fullscreen. It is paired with the
- configure event to ensure that both the client and the compositor
- setting the state can be synchronized.
-
- States set in this way are double-buffered. They will get applied on
- the next commit.
-
- Desktop environments may extend this enum by taking up a range of
- values and documenting the range they chose in this description.
- They are not required to document the values for the range that they
- chose. Ideally, any good extensions from a desktop environment should
- make its way into standardization into this enum.
-
- The current reserved ranges are:
+ The different state values used on the surface. This is designed for
+ state values like maximized, fullscreen. It is paired with the
+ configure event to ensure that both the client and the compositor
+ setting the state can be synchronized.
- 0x0000 - 0x0FFF: xdg-shell core values, documented below.
- 0x1000 - 0x1FFF: GNOME
+ States set in this way are double-buffered. They will get applied on
+ the next commit.
</description>
<entry name="maximized" value="1" summary="the surface is maximized">
- The surface is maximized. The window geometry specified in the configure
- event must be obeyed by the client.
+ <description summary="the surface is maximized">
+ The surface is maximized. The window geometry specified in the configure
+ event must be obeyed by the client.
+ </description>
</entry>
<entry name="fullscreen" value="2" summary="the surface is fullscreen">
- The surface is fullscreen. The window geometry specified in the configure
- event must be obeyed by the client.
+ <description summary="the surface is fullscreen">
+ The surface is fullscreen. The window geometry specified in the
+ configure event is a maximum; the client cannot resize beyond it. For
+ a surface to cover the whole fullscreened area, the geometry
+ dimensions must be obeyed by the client. For more details, see
+ xdg_toplevel.set_fullscreen.
+ </description>
</entry>
- <entry name="resizing" value="3">
- The surface is being resized. The window geometry specified in the
- configure event is a maximum; the client cannot resize beyond it.
- Clients that have aspect ratio or cell sizing configuration can use
- a smaller size, however.
+ <entry name="resizing" value="3" summary="the surface is being resized">
+ <description summary="the surface is being resized">
+ The surface is being resized. The window geometry specified in the
+ configure event is a maximum; the client cannot resize beyond it.
+ Clients that have aspect ratio or cell sizing configuration can use
+ a smaller size, however.
+ </description>
</entry>
- <entry name="activated" value="4">
- Client window decorations should be painted as if the window is
- active. Do not assume this means that the window actually has
- keyboard or pointer focus.
+ <entry name="activated" value="4" summary="the surface is now activated">
+ <description summary="the surface is now activated">
+ Client window decorations should be painted as if the window is
+ active. Do not assume this means that the window actually has
+ keyboard or pointer focus.
+ </description>
</entry>
</enum>
- <event name="configure">
- <description summary="suggest a surface change">
- The configure event asks the client to resize its surface or to
- change its state.
+ <request name="set_max_size">
+ <description summary="set the maximum size">
+ Set a maximum size for the window.
- The width and height arguments specify a hint to the window
- about how its surface should be resized in window geometry
- coordinates. See set_window_geometry.
+ The client can specify a maximum size so that the compositor does
+ not try to configure the window beyond this size.
- If the width or height arguments are zero, it means the client
- should decide its own window dimension. This may happen when the
- compositor need to configure the state of the surface but doesn't
- have any information about any previous or expected dimension.
+ The width and height arguments are in window geometry coordinates.
+ See xdg_surface.set_window_geometry.
- The states listed in the event specify how the width/height
- arguments should be interpreted, and possibly how it should be
- drawn.
+ Values set in this way are double-buffered. They will get applied
+ on the next commit.
- Clients should arrange their surface for the new size and
- states, and then send a ack_configure request with the serial
- sent in this configure event at some point before committing
- the new surface.
+ The compositor can use this information to allow or disallow
+ different states like maximize or fullscreen and draw accurate
+ animations.
- If the client receives multiple configure events before it
- can respond to one, it is free to discard all but the last
- event it received.
- </description>
+ Similarly, a tiling window manager may use this information to
+ place and resize client windows in a more effective way.
- <arg name="width" type="int"/>
- <arg name="height" type="int"/>
- <arg name="states" type="array"/>
- <arg name="serial" type="uint"/>
- </event>
+ The client should not rely on the compositor to obey the maximum
+ size. The compositor may decide to ignore the values set by the
+ client and request a larger size.
- <request name="ack_configure">
- <description summary="ack a configure event">
- When a configure event is received, if a client commits the
- surface in response to the configure event, then the client
- must make a ack_configure request before the commit request,
- passing along the serial of the configure event.
+ If never set, or a value of zero in the request, means that the
+ client has no expected maximum size in the given dimension.
+ As a result, a client wishing to reset the maximum size
+ to an unspecified state can use zero for width and height in the
+ request.
- For instance, the compositor might use this information to move
- a surface to the top left only when the client has drawn itself
- for the maximized or fullscreen state.
+ Requesting a maximum size to be smaller than the minimum size of
+ a surface is illegal and will result in a protocol error.
- If the client receives multiple configure events before it
- can respond to one, it only has to ack the last configure event.
+ The width and height must be greater than or equal to zero. Using
+ strictly negative values for width and height will result in a
+ protocol error.
</description>
- <arg name="serial" type="uint" summary="the serial from the configure event"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
</request>
- <request name="set_window_geometry">
- <description summary="set the new window geometry">
- The window geometry of a window is its "visible bounds" from the
- user's perspective. Client-side decorations often have invisible
- portions like drop-shadows which should be ignored for the
- purposes of aligning, placing and constraining windows.
+ <request name="set_min_size">
+ <description summary="set the minimum size">
+ Set a minimum size for the window.
+
+ The client can specify a minimum size so that the compositor does
+ not try to configure the window below this size.
+
+ The width and height arguments are in window geometry coordinates.
+ See xdg_surface.set_window_geometry.
+
+ Values set in this way are double-buffered. They will get applied
+ on the next commit.
- The window geometry is double buffered, and will be applied at the
- time wl_surface.commit of the corresponding wl_surface is called.
+ The compositor can use this information to allow or disallow
+ different states like maximize or fullscreen and draw accurate
+ animations.
- Once the window geometry of the surface is set once, it is not
- possible to unset it, and it will remain the same until
- set_window_geometry is called again, even if a new subsurface or
- buffer is attached.
+ Similarly, a tiling window manager may use this information to
+ place and resize client windows in a more effective way.
- If never set, the value is the full bounds of the surface,
- including any subsurfaces. This updates dynamically on every
- commit. This unset mode is meant for extremely simple clients.
+ The client should not rely on the compositor to obey the minimum
+ size. The compositor may decide to ignore the values set by the
+ client and request a smaller size.
- If responding to a configure event, the window geometry in here
- must respect the sizing negotiations specified by the states in
- the configure event.
+ If never set, or a value of zero in the request, means that the
+ client has no expected minimum size in the given dimension.
+ As a result, a client wishing to reset the minimum size
+ to an unspecified state can use zero for width and height in the
+ request.
- The arguments are given in the surface local coordinate space of
- the wl_surface associated with this xdg_surface.
+ Requesting a minimum size to be larger than the maximum size of
+ a surface is illegal and will result in a protocol error.
- The width and height must be greater than zero.
+ The width and height must be greater than or equal to zero. Using
+ strictly negative values for width and height will result in a
+ protocol error.
</description>
- <arg name="x" type="int"/>
- <arg name="y" type="int"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</request>
<request name="set_maximized">
<description summary="maximize the window">
- Maximize the surface.
-
- After requesting that the surface should be maximized, the compositor
- will respond by emitting a configure event with the "maximized" state
- and the required window geometry. The client should then update its
- content, drawing it in a maximized state, i.e. without shadow or other
- decoration outside of the window geometry. The client must also
- acknowledge the configure when committing the new content (see
- ack_configure).
-
- It is up to the compositor to decide how and where to maximize the
- surface, for example which output and what region of the screen should
- be used.
-
- If the surface was already maximized, the compositor will still emit
- a configure event with the "maximized" state.
+ Maximize the surface.
+
+ After requesting that the surface should be maximized, the compositor
+ will respond by emitting a configure event with the "maximized" state
+ and the required window geometry. The client should then update its
+ content, drawing it in a maximized state, i.e. without shadow or other
+ decoration outside of the window geometry. The client must also
+ acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ It is up to the compositor to decide how and where to maximize the
+ surface, for example which output and what region of the screen should
+ be used.
+
+ If the surface was already maximized, the compositor will still emit
+ a configure event with the "maximized" state.
+
+ If the surface is in a fullscreen state, this request has no direct
+ effect. It will alter the state the surface is returned to when
+ unmaximized if not overridden by the compositor.
</description>
</request>
<request name="unset_maximized">
<description summary="unmaximize the window">
- Unmaximize the surface.
-
- After requesting that the surface should be unmaximized, the compositor
- will respond by emitting a configure event without the "maximized"
- state. If available, the compositor will include the window geometry
- dimensions the window had prior to being maximized in the configure
- request. The client must then update its content, drawing it in a
- regular state, i.e. potentially with shadow, etc. The client must also
- acknowledge the configure when committing the new content (see
- ack_configure).
-
- It is up to the compositor to position the surface after it was
- unmaximized; usually the position the surface had before maximizing, if
- applicable.
-
- If the surface was already not maximized, the compositor will still
- emit a configure event without the "maximized" state.
+ Unmaximize the surface.
+
+ After requesting that the surface should be unmaximized, the compositor
+ will respond by emitting a configure event without the "maximized"
+ state. If available, the compositor will include the window geometry
+ dimensions the window had prior to being maximized in the configure
+ event. The client must then update its content, drawing it in a
+ regular state, i.e. potentially with shadow, etc. The client must also
+ acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ It is up to the compositor to position the surface after it was
+ unmaximized; usually the position the surface had before maximizing, if
+ applicable.
+
+ If the surface was already not maximized, the compositor will still
+ emit a configure event without the "maximized" state.
+
+ If the surface is in a fullscreen state, this request has no direct
+ effect. It will alter the state the surface is returned to when
+ unmaximized if not overridden by the compositor.
</description>
</request>
<request name="set_fullscreen">
- <description summary="set the window as fullscreen on a monitor">
+ <description summary="set the window as fullscreen on an output">
Make the surface fullscreen.
- You can specify an output that you would prefer to be fullscreen.
- If this value is NULL, it's up to the compositor to choose which
- display will be used to map this surface.
-
- If the surface doesn't cover the whole output, the compositor will
- position the surface in the center of the output and compensate with
- black borders filling the rest of the output.
+ After requesting that the surface should be fullscreened, the
+ compositor will respond by emitting a configure event with the
+ "fullscreen" state and the fullscreen window geometry. The client must
+ also acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ The output passed by the request indicates the client's preference as
+ to which display it should be set fullscreen on. If this value is NULL,
+ it's up to the compositor to choose which display will be used to map
+ this surface.
+
+ If the surface doesn't cover the whole output, the compositor will
+ position the surface in the center of the output and compensate with
+ with border fill covering the rest of the output. The content of the
+ border fill is undefined, but should be assumed to be in some way that
+ attempts to blend into the surrounding area (e.g. solid black).
+
+ If the fullscreened surface is not opaque, the compositor must make
+ sure that other screen content not part of the same surface tree (made
+ up of subsurfaces, popups or similarly coupled surfaces) are not
+ visible below the fullscreened surface.
</description>
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
</request>
- <request name="unset_fullscreen" />
+
+ <request name="unset_fullscreen">
+ <description summary="unset the window as fullscreen">
+ Make the surface no longer fullscreen.
+
+ After requesting that the surface should be unfullscreened, the
+ compositor will respond by emitting a configure event without the
+ "fullscreen" state.
+
+ Making a surface unfullscreen sets states for the surface based on the following:
+ * the state(s) it may have had before becoming fullscreen
+ * any state(s) decided by the compositor
+ * any state(s) requested by the client while the surface was fullscreen
+
+ The compositor may include the previous window geometry dimensions in
+ the configure event, if applicable.
+
+ The client must also acknowledge the configure when committing the new
+ content (see ack_configure).
+ </description>
+ </request>
<request name="set_minimized">
<description summary="set the window as minimized">
@@ -517,75 +948,89 @@
</description>
</request>
+ <event name="configure">
+ <description summary="suggest a surface change">
+ This configure event asks the client to resize its toplevel surface or
+ to change its state. The configured state should not be applied
+ immediately. See xdg_surface.configure for details.
+
+ The width and height arguments specify a hint to the window
+ about how its surface should be resized in window geometry
+ coordinates. See set_window_geometry.
+
+ If the width or height arguments are zero, it means the client
+ should decide its own window dimension. This may happen when the
+ compositor needs to configure the state of the surface but doesn't
+ have any information about any previous or expected dimension.
+
+ The states listed in the event specify how the width/height
+ arguments should be interpreted, and possibly how it should be
+ drawn.
+
+ Clients must send an ack_configure in response to this event. See
+ xdg_surface.configure and xdg_surface.ack_configure for details.
+ </description>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ <arg name="states" type="array"/>
+ </event>
+
<event name="close">
<description summary="surface wants to be closed">
- The close event is sent by the compositor when the user
- wants the surface to be closed. This should be equivalent to
- the user clicking the close button in client-side decorations,
- if your application has any...
-
- This is only a request that the user intends to close your
- window. The client may choose to ignore this request, or show
- a dialog to ask the user to save their data...
+ The close event is sent by the compositor when the user
+ wants the surface to be closed. This should be equivalent to
+ the user clicking the close button in client-side decorations,
+ if your application has any.
+
+ This is only a request that the user intends to close the
+ window. The client may choose to ignore this request, or show
+ a dialog to ask the user to save their data, etc.
</description>
</event>
</interface>
<interface name="xdg_popup" version="1">
<description summary="short-lived, popup surfaces for menus">
- A popup surface is a short-lived, temporary surface that can be
- used to implement menus. It takes an explicit grab on the surface
- that will be dismissed when the user dismisses the popup. This can
- be done by the user clicking outside the surface, using the keyboard,
- or even locking the screen through closing the lid or a timeout.
-
- When the popup is dismissed, a popup_done event will be sent out,
- and at the same time the surface will be unmapped. The xdg_popup
- object is now inert and cannot be reactivated, so clients should
- destroy it. Explicitly destroying the xdg_popup object will also
- dismiss the popup and unmap the surface.
-
- Clients will receive events for all their surfaces during this
- grab (which is an "owner-events" grab in X11 parlance). This is
- done so that users can navigate through submenus and other
- "nested" popup windows without having to dismiss the topmost
- popup.
-
- Clients that want to dismiss the popup when another surface of
- their own is clicked should dismiss the popup using the destroy
- request.
+ A popup surface is a short-lived, temporary surface. It can be used to
+ implement for example menus, popovers, tooltips and other similar user
+ interface concepts.
- The parent surface must have either an xdg_surface or xdg_popup
- role.
+ A popup can be made to take an explicit grab. See xdg_popup.grab for
+ details.
- Specifying an xdg_popup for the parent means that the popups are
- nested, with this popup now being the topmost popup. Nested
- popups must be destroyed in the reverse order they were created
- in, e.g. the only popup you are allowed to destroy at all times
- is the topmost one.
+ When the popup is dismissed, a popup_done event will be sent out, and at
+ the same time the surface will be unmapped. See the xdg_popup.popup_done
+ event for details.
- If there is an existing popup when creating a new popup, the
- parent must be the current topmost popup.
+ Explicitly destroying the xdg_popup object will also dismiss the popup and
+ unmap the surface. Clients that want to dismiss the popup when another
+ surface of their own is clicked should dismiss the popup using the destroy
+ request.
- A parent surface must be mapped before the new popup is mapped.
+ The parent surface must have either the xdg_toplevel or xdg_popup surface
+ role.
- When compositors choose to dismiss a popup, they will likely
- dismiss every nested popup as well. When a compositor dismisses
- popups, it will follow the same dismissing order as required
- from the client.
+ A newly created xdg_popup will be stacked on top of all previously created
+ xdg_popup surfaces associated with the same xdg_toplevel.
+
+ The parent of an xdg_popup must be mapped (see the xdg_surface
+ description) before the xdg_popup itself.
The x and y arguments passed when creating the popup object specify
where the top left of the popup should be placed, relative to the
local surface coordinates of the parent surface. See
- xdg_shell.get_xdg_popup.
+ xdg_surface.get_popup. An xdg_popup must intersect with or be at least
+ partially adjacent to its parent surface.
The client must call wl_surface.commit on the corresponding wl_surface
for the xdg_popup state to take effect.
-
- For a surface to be mapped by the compositor the client must have
- committed both the xdg_popup state and a buffer.
</description>
+ <enum name="error">
+ <entry name="invalid_grab" value="0"
+ summary="tried to grab after being mapped"/>
+ </enum>
+
<request name="destroy" type="destructor">
<description summary="remove xdg_popup interface">
This destroys the popup. Explicitly destroying the xdg_popup
@@ -596,6 +1041,73 @@
</description>
</request>
+ <request name="grab">
+ <description summary="make the popup take an explicit grab">
+ This request makes the created popup take an explicit grab. An explicit
+ grab will be dismissed when the user dismisses the popup, or when the
+ client destroys the xdg_popup. This can be done by the user clicking
+ outside the surface, using the keyboard, or even locking the screen
+ through closing the lid or a timeout.
+
+ If the compositor denies the grab, the popup will be immediately
+ dismissed.
+
+ This request must be used in response to some sort of user action like a
+ button press, key press, or touch down event. The serial number of the
+ event should be passed as 'serial'.
+
+ The parent of a grabbing popup must either be an xdg_toplevel surface or
+ another xdg_popup with an explicit grab. If the parent is another
+ xdg_popup it means that the popups are nested, with this popup now being
+ the topmost popup.
+
+ Nested popups must be destroyed in the reverse order they were created
+ in, e.g. the only popup you are allowed to destroy at all times is the
+ topmost one.
+
+ When compositors choose to dismiss a popup, they may dismiss every
+ nested grabbing popup as well. When a compositor dismisses popups, it
+ will follow the same dismissing order as required from the client.
+
+ The parent of a grabbing popup must either be another xdg_popup with an
+ active explicit grab, or an xdg_popup or xdg_toplevel, if there are no
+ explicit grabs already taken.
+
+ If the topmost grabbing popup is destroyed, the grab will be returned to
+ the parent of the popup, if that parent previously had an explicit grab.
+
+ If the parent is a grabbing popup which has already been dismissed, this
+ popup will be immediately dismissed. If the parent is a popup that did
+ not take an explicit grab, an error will be raised.
+
+ During a popup grab, the client owning the grab will receive pointer
+ and touch events for all their surfaces as normal (similar to an
+ "owner-events" grab in X11 parlance), while the top most grabbing popup
+ will always have keyboard focus.
+ </description>
+ <arg name="seat" type="object" interface="wl_seat"
+ summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ </request>
+
+ <event name="configure">
+ <description summary="configure the popup surface">
+ This event asks the popup surface to configure itself given the
+ configuration. The configured state should not be applied immediately.
+ See xdg_surface.configure for details.
+
+ The x and y arguments represent the position the popup was placed at
+ given the xdg_positioner rule, relative to the upper left corner of the
+ window geometry of the parent surface.
+ </description>
+ <arg name="x" type="int"
+ summary="x position relative to parent surface window geometry"/>
+ <arg name="y" type="int"
+ summary="y position relative to parent surface window geometry"/>
+ <arg name="width" type="int" summary="window geometry width"/>
+ <arg name="height" type="int" summary="window geometry height"/>
+ </event>
+
<event name="popup_done">
<description summary="popup interaction is done">
The popup_done event is sent out when a popup is dismissed by the
diff --git a/src/client/client.pro b/src/client/client.pro
index eae7ad52e..45bbb976b 100644
--- a/src/client/client.pro
+++ b/src/client/client.pro
@@ -25,11 +25,10 @@ INCLUDEPATH += $$PWD/../shared
WAYLANDCLIENTSOURCES += \
../extensions/surface-extension.xml \
../extensions/touch-extension.xml \
- ../extensions/qtkey-extension.xml \
+ ../extensions/qt-key-unstable-v1.xml \
../extensions/qt-windowmanager.xml \
../3rdparty/protocol/text-input-unstable-v2.xml \
- ../3rdparty/protocol/xdg-shell.xml \
- ../3rdparty/protocol/xdg-shell-unstable-v6.xml \
+ ../3rdparty/protocol/xdg-output-unstable-v1.xml \
WAYLANDCLIENTSOURCES_SYSTEM += \
../3rdparty/protocol/wayland.xml \
@@ -43,14 +42,6 @@ SOURCES += qwaylandintegration.cpp \
qwaylandscreen.cpp \
qwaylandshmwindow.cpp \
qwaylandshellsurface.cpp \
- qwaylandwlshellsurface.cpp \
- qwaylandwlshellintegration.cpp \
- qwaylandxdgshell.cpp \
- qwaylandxdgsurface.cpp \
- qwaylandxdgpopup.cpp \
- qwaylandxdgshellintegration.cpp \
- qwaylandxdgshellv6.cpp \
- qwaylandxdgshellv6integration.cpp \
qwaylandextendedsurface.cpp \
qwaylandsubsurface.cpp \
qwaylandtouch.cpp \
@@ -76,14 +67,6 @@ HEADERS += qwaylandintegration_p.h \
qwaylandbuffer_p.h \
qwaylandshmwindow_p.h \
qwaylandshellsurface_p.h \
- qwaylandwlshellsurface_p.h \
- qwaylandwlshellintegration_p.h \
- qwaylandxdgshell_p.h \
- qwaylandxdgsurface_p.h \
- qwaylandxdgpopup_p.h \
- qwaylandxdgshellintegration_p.h \
- qwaylandxdgshellv6_p.h \
- qwaylandxdgshellv6integration_p.h \
qwaylandextendedsurface_p.h \
qwaylandsubsurface_p.h \
qwaylandtouch_p.h \
diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp
index 21a6c0811..6947e97f1 100644
--- a/src/client/qwaylandcursor.cpp
+++ b/src/client/qwaylandcursor.cpp
@@ -53,65 +53,203 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
- : mDisplay(screen->display())
+QWaylandCursorTheme *QWaylandCursorTheme::create(QWaylandShm *shm, int size)
{
- //TODO: Make wl_cursor_theme_load arguments configurable here
- QByteArray cursorTheme = qgetenv("XCURSOR_THEME");
- if (cursorTheme.isEmpty())
- cursorTheme = QByteArray("default");
- QByteArray cursorSizeFromEnv = qgetenv("XCURSOR_SIZE");
- bool hasCursorSize = false;
- int cursorSize = cursorSizeFromEnv.toInt(&hasCursorSize);
- if (!hasCursorSize || cursorSize <= 0)
- cursorSize = 32;
- mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm()->object());
- if (!mCursorTheme)
- qDebug() << "Could not load theme" << cursorTheme;
- initCursorMap();
+ static QString themeName = qEnvironmentVariable("XCURSOR_THEME", QStringLiteral("default"));
+ return create(shm, size, themeName);
}
-QWaylandCursor::~QWaylandCursor()
+QWaylandCursorTheme *QWaylandCursorTheme::create(QWaylandShm *shm, int size, const QString &themeName)
{
- if (mCursorTheme)
- wl_cursor_theme_destroy(mCursorTheme);
+ QByteArray nameBytes = themeName.toLocal8Bit();
+ struct ::wl_cursor_theme *theme = wl_cursor_theme_load(nameBytes.constData(), size, shm->object());
+
+ if (!theme) {
+ qCWarning(lcQpaWayland) << "Could not load cursor theme" << themeName << "size" << size;
+ return nullptr;
+ }
+
+ return new QWaylandCursorTheme(theme);
}
-struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape newShape)
+QWaylandCursorTheme::~QWaylandCursorTheme()
{
- struct wl_cursor *waylandCursor = nullptr;
+ wl_cursor_theme_destroy(m_theme);
+}
- /* Hide cursor */
- if (newShape == Qt::BlankCursor)
- {
- mDisplay->setCursor(nullptr, nullptr);
- return nullptr;
+wl_cursor *QWaylandCursorTheme::requestCursor(WaylandCursor shape)
+{
+ if (struct wl_cursor *cursor = m_cursors.value(shape, nullptr))
+ return cursor;
+
+ static const QMultiMap<WaylandCursor, QByteArray>cursorNamesMap {
+ {ArrowCursor, "left_ptr"},
+ {ArrowCursor, "default"},
+ {ArrowCursor, "top_left_arrow"},
+ {ArrowCursor, "left_arrow"},
+
+ {UpArrowCursor, "up_arrow"},
+
+ {CrossCursor, "cross"},
+
+ {WaitCursor, "wait"},
+ {WaitCursor, "watch"},
+ {WaitCursor, "0426c94ea35c87780ff01dc239897213"},
+
+ {IBeamCursor, "ibeam"},
+ {IBeamCursor, "text"},
+ {IBeamCursor, "xterm"},
+
+ {SizeVerCursor, "size_ver"},
+ {SizeVerCursor, "ns-resize"},
+ {SizeVerCursor, "v_double_arrow"},
+ {SizeVerCursor, "00008160000006810000408080010102"},
+
+ {SizeHorCursor, "size_hor"},
+ {SizeHorCursor, "ew-resize"},
+ {SizeHorCursor, "h_double_arrow"},
+ {SizeHorCursor, "028006030e0e7ebffc7f7070c0600140"},
+
+ {SizeBDiagCursor, "size_bdiag"},
+ {SizeBDiagCursor, "nesw-resize"},
+ {SizeBDiagCursor, "50585d75b494802d0151028115016902"},
+ {SizeBDiagCursor, "fcf1c3c7cd4491d801f1e1c78f100000"},
+
+ {SizeFDiagCursor, "size_fdiag"},
+ {SizeFDiagCursor, "nwse-resize"},
+ {SizeFDiagCursor, "38c5dff7c7b8962045400281044508d2"},
+ {SizeFDiagCursor, "c7088f0f3e6c8088236ef8e1e3e70000"},
+
+ {SizeAllCursor, "size_all"},
+
+ {SplitVCursor, "split_v"},
+ {SplitVCursor, "row-resize"},
+ {SplitVCursor, "sb_v_double_arrow"},
+ {SplitVCursor, "2870a09082c103050810ffdffffe0204"},
+ {SplitVCursor, "c07385c7190e701020ff7ffffd08103c"},
+
+ {SplitHCursor, "split_h"},
+ {SplitHCursor, "col-resize"},
+ {SplitHCursor, "sb_h_double_arrow"},
+ {SplitHCursor, "043a9f68147c53184671403ffa811cc5"},
+ {SplitHCursor, "14fef782d02440884392942c11205230"},
+
+ {PointingHandCursor, "pointing_hand"},
+ {PointingHandCursor, "pointer"},
+ {PointingHandCursor, "hand1"},
+ {PointingHandCursor, "e29285e634086352946a0e7090d73106"},
+
+ {ForbiddenCursor, "forbidden"},
+ {ForbiddenCursor, "not-allowed"},
+ {ForbiddenCursor, "crossed_circle"},
+ {ForbiddenCursor, "circle"},
+ {ForbiddenCursor, "03b6e0fcb3499374a867c041f52298f0"},
+
+ {WhatsThisCursor, "whats_this"},
+ {WhatsThisCursor, "help"},
+ {WhatsThisCursor, "question_arrow"},
+ {WhatsThisCursor, "5c6cd98b3f3ebcb1f9c7f1c204630408"},
+ {WhatsThisCursor, "d9ce0ab605698f320427677b458ad60b"},
+
+ {BusyCursor, "left_ptr_watch"},
+ {BusyCursor, "half-busy"},
+ {BusyCursor, "progress"},
+ {BusyCursor, "00000000000000020006000e7e9ffc3f"},
+ {BusyCursor, "08e8e1c95fe2fc01f976f1e063a24ccd"},
+
+ {OpenHandCursor, "openhand"},
+ {OpenHandCursor, "fleur"},
+ {OpenHandCursor, "5aca4d189052212118709018842178c0"},
+ {OpenHandCursor, "9d800788f1b08800ae810202380a0822"},
+
+ {ClosedHandCursor, "closedhand"},
+ {ClosedHandCursor, "grabbing"},
+ {ClosedHandCursor, "208530c400c041818281048008011002"},
+
+ {DragCopyCursor, "dnd-copy"},
+ {DragCopyCursor, "copy"},
+
+ {DragMoveCursor, "dnd-move"},
+ {DragMoveCursor, "move"},
+
+ {DragLinkCursor, "dnd-link"},
+ {DragLinkCursor, "link"},
+
+ {ResizeNorthCursor, "n-resize"},
+ {ResizeNorthCursor, "top_side"},
+
+ {ResizeSouthCursor, "s-resize"},
+ {ResizeSouthCursor, "bottom_side"},
+
+ {ResizeEastCursor, "e-resize"},
+ {ResizeEastCursor, "right_side"},
+
+ {ResizeWestCursor, "w-resize"},
+ {ResizeWestCursor, "left_side"},
+
+ {ResizeNorthWestCursor, "nw-resize"},
+ {ResizeNorthWestCursor, "top_left_corner"},
+
+ {ResizeSouthEastCursor, "se-resize"},
+ {ResizeSouthEastCursor, "bottom_right_corner"},
+
+ {ResizeNorthEastCursor, "ne-resize"},
+ {ResizeNorthEastCursor, "top_right_corner"},
+
+ {ResizeSouthWestCursor, "sw-resize"},
+ {ResizeSouthWestCursor, "bottom_left_corner"},
+ };
+
+ QList<QByteArray> cursorNames = cursorNamesMap.values(shape);
+ for (auto &name : qAsConst(cursorNames)) {
+ if (wl_cursor *cursor = wl_cursor_theme_get_cursor(m_theme, name.constData())) {
+ m_cursors.insert(shape, cursor);
+ return cursor;
+ }
}
- if (newShape < Qt::BitmapCursor) {
- waylandCursor = requestCursor((WaylandCursor)newShape);
- } else if (newShape == Qt::BitmapCursor) {
- // cannot create a wl_cursor_image for a CursorShape
+ // Fallback to arrow cursor
+ if (shape != ArrowCursor)
+ return requestCursor(ArrowCursor);
+
+ // Give up
+ return nullptr;
+}
+
+struct wl_cursor_image *QWaylandCursorTheme::cursorImage(Qt::CursorShape shape)
+{
+ struct wl_cursor *waylandCursor = nullptr;
+
+ if (shape < Qt::BitmapCursor) {
+ waylandCursor = requestCursor(WaylandCursor(shape));
+ } else if (shape == Qt::BitmapCursor) {
+ qCWarning(lcQpaWayland) << "cannot create a wl_cursor_image for a CursorShape";
return nullptr;
} else {
//TODO: Custom cursor logic (for resize arrows)
}
if (!waylandCursor) {
- qDebug("Could not find cursor for shape %d", newShape);
+ qCWarning(lcQpaWayland) << "Could not find cursor for shape" << shape;
return nullptr;
}
struct wl_cursor_image *image = waylandCursor->images[0];
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
if (!buffer) {
- qDebug("Could not find buffer for cursor");
+ qCWarning(lcQpaWayland) << "Could not find buffer for cursor";
return nullptr;
}
return image;
}
+QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
+ : mDisplay(screen->display())
+ , mCursorTheme(mDisplay->loadCursorTheme(screen->devicePixelRatio()))
+{
+}
+
QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapImage(const QCursor *cursor)
{
if (cursor->shape() != Qt::BitmapCursor)
@@ -123,24 +261,39 @@ QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapImage(const QCursor *
return buffer;
}
-void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
+struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape shape)
{
- Q_UNUSED(window)
+ if (!mCursorTheme)
+ return nullptr;
+ return mCursorTheme->cursorImage(shape);
+}
+void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
+{
const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor;
+ if (newShape == Qt::BlankCursor) {
+ mDisplay->setCursor(nullptr, nullptr, 1);
+ return;
+ }
+
if (newShape == Qt::BitmapCursor) {
- mDisplay->setCursor(cursorBitmapImage(cursor), cursor->hotSpot());
+ mDisplay->setCursor(cursorBitmapImage(cursor), cursor->hotSpot(), window->screen()->devicePixelRatio());
return;
}
- struct wl_cursor_image *image = cursorImage(newShape);
- if (!image) {
+ if (!mCursorTheme) {
+ qCWarning(lcQpaWayland) << "Can't set cursor from shape with no cursor theme";
return;
}
- struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
- mDisplay->setCursor(buffer, image);
+ if (struct ::wl_cursor_image *image = mCursorTheme->cursorImage(newShape)) {
+ struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
+ mDisplay->setCursor(buffer, image, window->screen()->devicePixelRatio());
+ return;
+ }
+
+ qCWarning(lcQpaWayland) << "Unable to change to cursor" << cursor;
}
void QWaylandCursor::pointerEvent(const QMouseEvent &event)
@@ -156,155 +309,7 @@ QPoint QWaylandCursor::pos() const
void QWaylandCursor::setPos(const QPoint &pos)
{
Q_UNUSED(pos);
- qWarning() << "QWaylandCursor::setPos: not implemented";
-}
-
-wl_cursor *QWaylandCursor::requestCursor(WaylandCursor shape)
-{
- struct wl_cursor *cursor = mCursors.value(shape, 0);
-
- //If the cursor has not been loaded already, load it
- if (!cursor) {
- if (!mCursorTheme)
- return nullptr;
-
- QList<QByteArray> cursorNames = mCursorNamesMap.values(shape);
- foreach (const QByteArray &name, cursorNames) {
- cursor = wl_cursor_theme_get_cursor(mCursorTheme, name.constData());
- if (cursor) {
- mCursors.insert(shape, cursor);
- break;
- }
- }
- }
-
- //If there still no cursor for a shape, use the default cursor
- if (!cursor && shape != ArrowCursor) {
- cursor = requestCursor(ArrowCursor);
- }
-
- return cursor;
-}
-
-
-void QWaylandCursor::initCursorMap()
-{
- //Fill the cursor name map will the table of xcursor names
- mCursorNamesMap.insert(ArrowCursor, "left_ptr");
- mCursorNamesMap.insert(ArrowCursor, "default");
- mCursorNamesMap.insert(ArrowCursor, "top_left_arrow");
- mCursorNamesMap.insert(ArrowCursor, "left_arrow");
-
- mCursorNamesMap.insert(UpArrowCursor, "up_arrow");
-
- mCursorNamesMap.insert(CrossCursor, "cross");
-
- mCursorNamesMap.insert(WaitCursor, "wait");
- mCursorNamesMap.insert(WaitCursor, "watch");
- mCursorNamesMap.insert(WaitCursor, "0426c94ea35c87780ff01dc239897213");
-
- mCursorNamesMap.insert(IBeamCursor, "ibeam");
- mCursorNamesMap.insert(IBeamCursor, "text");
- mCursorNamesMap.insert(IBeamCursor, "xterm");
-
- mCursorNamesMap.insert(SizeVerCursor, "size_ver");
- mCursorNamesMap.insert(SizeVerCursor, "ns-resize");
- mCursorNamesMap.insert(SizeVerCursor, "v_double_arrow");
- mCursorNamesMap.insert(SizeVerCursor, "00008160000006810000408080010102");
-
- mCursorNamesMap.insert(SizeHorCursor, "size_hor");
- mCursorNamesMap.insert(SizeHorCursor, "ew-resize");
- mCursorNamesMap.insert(SizeHorCursor, "h_double_arrow");
- mCursorNamesMap.insert(SizeHorCursor, "028006030e0e7ebffc7f7070c0600140");
-
- mCursorNamesMap.insert(SizeBDiagCursor, "size_bdiag");
- mCursorNamesMap.insert(SizeBDiagCursor, "nesw-resize");
- mCursorNamesMap.insert(SizeBDiagCursor, "50585d75b494802d0151028115016902");
- mCursorNamesMap.insert(SizeBDiagCursor, "fcf1c3c7cd4491d801f1e1c78f100000");
-
- mCursorNamesMap.insert(SizeFDiagCursor, "size_fdiag");
- mCursorNamesMap.insert(SizeFDiagCursor, "nwse-resize");
- mCursorNamesMap.insert(SizeFDiagCursor, "38c5dff7c7b8962045400281044508d2");
- mCursorNamesMap.insert(SizeFDiagCursor, "c7088f0f3e6c8088236ef8e1e3e70000");
-
- mCursorNamesMap.insert(SizeAllCursor, "size_all");
-
- mCursorNamesMap.insert(SplitVCursor, "split_v");
- mCursorNamesMap.insert(SplitVCursor, "row-resize");
- mCursorNamesMap.insert(SplitVCursor, "sb_v_double_arrow");
- mCursorNamesMap.insert(SplitVCursor, "2870a09082c103050810ffdffffe0204");
- mCursorNamesMap.insert(SplitVCursor, "c07385c7190e701020ff7ffffd08103c");
-
- mCursorNamesMap.insert(SplitHCursor, "split_h");
- mCursorNamesMap.insert(SplitHCursor, "col-resize");
- mCursorNamesMap.insert(SplitHCursor, "sb_h_double_arrow");
- mCursorNamesMap.insert(SplitHCursor, "043a9f68147c53184671403ffa811cc5");
- mCursorNamesMap.insert(SplitHCursor, "14fef782d02440884392942c11205230");
-
- mCursorNamesMap.insert(PointingHandCursor, "pointing_hand");
- mCursorNamesMap.insert(PointingHandCursor, "pointer");
- mCursorNamesMap.insert(PointingHandCursor, "hand1");
- mCursorNamesMap.insert(PointingHandCursor, "e29285e634086352946a0e7090d73106");
-
- mCursorNamesMap.insert(ForbiddenCursor, "forbidden");
- mCursorNamesMap.insert(ForbiddenCursor, "not-allowed");
- mCursorNamesMap.insert(ForbiddenCursor, "crossed_circle");
- mCursorNamesMap.insert(ForbiddenCursor, "circle");
- mCursorNamesMap.insert(ForbiddenCursor, "03b6e0fcb3499374a867c041f52298f0");
-
- mCursorNamesMap.insert(WhatsThisCursor, "whats_this");
- mCursorNamesMap.insert(WhatsThisCursor, "help");
- mCursorNamesMap.insert(WhatsThisCursor, "question_arrow");
- mCursorNamesMap.insert(WhatsThisCursor, "5c6cd98b3f3ebcb1f9c7f1c204630408");
- mCursorNamesMap.insert(WhatsThisCursor, "d9ce0ab605698f320427677b458ad60b");
-
- mCursorNamesMap.insert(BusyCursor, "left_ptr_watch");
- mCursorNamesMap.insert(BusyCursor, "half-busy");
- mCursorNamesMap.insert(BusyCursor, "progress");
- mCursorNamesMap.insert(BusyCursor, "00000000000000020006000e7e9ffc3f");
- mCursorNamesMap.insert(BusyCursor, "08e8e1c95fe2fc01f976f1e063a24ccd");
-
- mCursorNamesMap.insert(OpenHandCursor, "openhand");
- mCursorNamesMap.insert(OpenHandCursor, "fleur");
- mCursorNamesMap.insert(OpenHandCursor, "5aca4d189052212118709018842178c0");
- mCursorNamesMap.insert(OpenHandCursor, "9d800788f1b08800ae810202380a0822");
-
- mCursorNamesMap.insert(ClosedHandCursor, "closedhand");
- mCursorNamesMap.insert(ClosedHandCursor, "grabbing");
- mCursorNamesMap.insert(ClosedHandCursor, "208530c400c041818281048008011002");
-
- mCursorNamesMap.insert(DragCopyCursor, "dnd-copy");
- mCursorNamesMap.insert(DragCopyCursor, "copy");
-
- mCursorNamesMap.insert(DragMoveCursor, "dnd-move");
- mCursorNamesMap.insert(DragMoveCursor, "move");
-
- mCursorNamesMap.insert(DragLinkCursor, "dnd-link");
- mCursorNamesMap.insert(DragLinkCursor, "link");
-
- mCursorNamesMap.insert(ResizeNorthCursor, "n-resize");
- mCursorNamesMap.insert(ResizeNorthCursor, "top_side");
-
- mCursorNamesMap.insert(ResizeSouthCursor, "s-resize");
- mCursorNamesMap.insert(ResizeSouthCursor, "bottom_side");
-
- mCursorNamesMap.insert(ResizeEastCursor, "e-resize");
- mCursorNamesMap.insert(ResizeEastCursor, "right_side");
-
- mCursorNamesMap.insert(ResizeWestCursor, "w-resize");
- mCursorNamesMap.insert(ResizeWestCursor, "left_side");
-
- mCursorNamesMap.insert(ResizeNorthWestCursor, "nw-resize");
- mCursorNamesMap.insert(ResizeNorthWestCursor, "top_left_corner");
-
- mCursorNamesMap.insert(ResizeSouthEastCursor, "se-resize");
- mCursorNamesMap.insert(ResizeSouthEastCursor, "bottom_right_corner");
-
- mCursorNamesMap.insert(ResizeNorthEastCursor, "ne-resize");
- mCursorNamesMap.insert(ResizeNorthEastCursor, "top_right_corner");
-
- mCursorNamesMap.insert(ResizeSouthWestCursor, "sw-resize");
- mCursorNamesMap.insert(ResizeSouthWestCursor, "bottom_left_corner");
+ qCWarning(lcQpaWayland) << "Setting cursor position is not possible on wayland";
}
}
diff --git a/src/client/qwaylandcursor_p.h b/src/client/qwaylandcursor_p.h
index b3df93160..71f9cd1b8 100644
--- a/src/client/qwaylandcursor_p.h
+++ b/src/client/qwaylandcursor_p.h
@@ -68,20 +68,15 @@ namespace QtWaylandClient {
class QWaylandBuffer;
class QWaylandDisplay;
class QWaylandScreen;
+class QWaylandShm;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandCursor : public QPlatformCursor
+class Q_WAYLAND_CLIENT_EXPORT QWaylandCursorTheme
{
public:
- QWaylandCursor(QWaylandScreen *screen);
- ~QWaylandCursor() override;
-
- void changeCursor(QCursor *cursor, QWindow *window) override;
- void pointerEvent(const QMouseEvent &event) override;
- QPoint pos() const override;
- void setPos(const QPoint &pos) override;
-
+ static QWaylandCursorTheme *create(QWaylandShm *shm, int size);
+ static QWaylandCursorTheme *create(QWaylandShm *shm, int size, const QString &themeName);
+ ~QWaylandCursorTheme();
struct wl_cursor_image *cursorImage(Qt::CursorShape shape);
- QSharedPointer<QWaylandBuffer> cursorBitmapImage(const QCursor *cursor);
private:
enum WaylandCursor {
@@ -107,6 +102,7 @@ private:
DragCopyCursor,
DragMoveCursor,
DragLinkCursor,
+ // The following are used for cursors that don't have equivalents in Qt
ResizeNorthCursor = Qt::CustomCursor + 1,
ResizeSouthCursor,
ResizeEastCursor,
@@ -117,13 +113,29 @@ private:
ResizeSouthWestCursor
};
- struct wl_cursor* requestCursor(WaylandCursor shape);
- void initCursorMap();
+ explicit QWaylandCursorTheme(struct ::wl_cursor_theme *theme) : m_theme(theme) {}
+ struct ::wl_cursor *requestCursor(WaylandCursor shape);
+ struct ::wl_cursor_theme *m_theme = nullptr;
+ QMap<WaylandCursor, wl_cursor *> m_cursors;
+};
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandCursor : public QPlatformCursor
+{
+public:
+ QWaylandCursor(QWaylandScreen *screen);
+
+ void changeCursor(QCursor *cursor, QWindow *window) override;
+ void pointerEvent(const QMouseEvent &event) override;
+ QPoint pos() const override;
+ void setPos(const QPoint &pos) override;
+
+ QSharedPointer<QWaylandBuffer> cursorBitmapImage(const QCursor *cursor);
+ struct wl_cursor_image *cursorImage(Qt::CursorShape shape);
+
+private:
QWaylandDisplay *mDisplay = nullptr;
- struct wl_cursor_theme *mCursorTheme = nullptr;
+ QWaylandCursorTheme *mCursorTheme = nullptr;
QPoint mLastPos;
- QMap<WaylandCursor, wl_cursor *> mCursors;
- QMultiMap<WaylandCursor, QByteArray> mCursorNamesMap;
};
}
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index a9fff410a..40ceafd96 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -41,6 +41,7 @@
#include "qwaylandintegration_p.h"
#include "qwaylandwindow_p.h"
+#include "qwaylandabstractdecoration_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandcursor_p.h"
#include "qwaylandinputdevice_p.h"
@@ -50,10 +51,10 @@
#if QT_CONFIG(wayland_datadevice)
#include "qwaylanddatadevicemanager_p.h"
#endif
+#if QT_CONFIG(cursor)
+#include <wayland-cursor.h>
+#endif
#include "qwaylandhardwareintegration_p.h"
-#include "qwaylandxdgshell_p.h"
-#include "qwaylandxdgsurface_p.h"
-#include "qwaylandwlshellsurface_p.h"
#include "qwaylandinputcontext_p.h"
#include "qwaylandwindowmanagerintegration_p.h"
@@ -66,7 +67,6 @@
#include "qwaylandqtkey_p.h"
#include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/private/qguiapplication_p.h>
@@ -155,9 +155,13 @@ QWaylandDisplay::~QWaylandDisplay(void)
mWaylandIntegration->destroyScreen(screen);
}
mScreens.clear();
+
#if QT_CONFIG(wayland_datadevice)
delete mDndSelectionHandler.take();
#endif
+#if QT_CONFIG(cursor)
+ qDeleteAll(mCursorThemesBySize);
+#endif
if (mDisplay)
wl_display_disconnect(mDisplay);
}
@@ -241,7 +245,6 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
mScreens.append(screen);
// We need to get the output events before creating surfaces
forceRoundTrip();
- screen->init();
mWaylandIntegration->screenAdded(screen);
} else if (interface == QStringLiteral("wl_compositor")) {
mCompositorVersion = qMin((int)version, 3);
@@ -261,7 +264,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
mSubCompositor.reset(new QtWayland::wl_subcompositor(registry, id, 1));
} else if (interface == QStringLiteral("qt_touch_extension")) {
mTouchExtension.reset(new QWaylandTouchExtension(this, id));
- } else if (interface == QStringLiteral("qt_key_extension")) {
+ } else if (interface == QStringLiteral("zqt_key_v1")) {
mQtKeyExtension.reset(new QWaylandQtKeyExtension(this, id));
} else if (interface == QStringLiteral("zwp_text_input_manager_v2")) {
mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
@@ -273,6 +276,11 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
// make a roundtrip here since we need to receive the events sent by
// qt_hardware_integration before creating windows
forceRoundTrip();
+ } else if (interface == QLatin1String("zxdg_output_manager_v1")) {
+ mXdgOutputManager.reset(new QtWayland::zxdg_output_manager_v1(registry, id, 1));
+ for (auto *screen : qAsConst(mScreens))
+ screen->initXdgOutput(xdgOutputManager());
+ forceRoundTrip();
}
mGlobals.append(RegistryGlobal(id, interface, version, registry));
@@ -405,6 +413,9 @@ void QWaylandDisplay::handleWindowActivated(QWaylandWindow *window)
mActiveWindows.append(window);
requestWaylandSync();
+
+ if (auto *decoration = window->decoration())
+ decoration->update();
}
void QWaylandDisplay::handleWindowDeactivated(QWaylandWindow *window)
@@ -415,6 +426,9 @@ void QWaylandDisplay::handleWindowDeactivated(QWaylandWindow *window)
requestWaylandSync();
mActiveWindows.removeOne(window);
+
+ if (auto *decoration = window->decoration())
+ decoration->update();
}
void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice)
@@ -477,25 +491,46 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
}
#if QT_CONFIG(cursor)
-void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image)
+
+void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, qreal dpr)
{
/* Qt doesn't tell us which input device we should set the cursor
* for, so set it for all devices. */
for (int i = 0; i < mInputDevices.count(); i++) {
QWaylandInputDevice *inputDevice = mInputDevices.at(i);
- inputDevice->setCursor(buffer, image);
+ inputDevice->setCursor(buffer, image, dpr);
}
}
-void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot)
+void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, qreal dpr)
{
/* Qt doesn't tell us which input device we should set the cursor
* for, so set it for all devices. */
for (int i = 0; i < mInputDevices.count(); i++) {
QWaylandInputDevice *inputDevice = mInputDevices.at(i);
- inputDevice->setCursor(buffer, hotSpot);
+ inputDevice->setCursor(buffer, hotSpot, dpr);
}
}
+
+QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(qreal devicePixelRatio)
+{
+ static int cursorSize = qEnvironmentVariableIntValue("XCURSOR_SIZE");
+ if (cursorSize <= 0)
+ cursorSize = 32;
+ if (compositorVersion() >= 3) // set_buffer_scale is not supported on earlier versions
+ cursorSize *= devicePixelRatio;
+
+ if (auto *theme = mCursorThemesBySize.value(cursorSize, nullptr))
+ return theme;
+
+ if (auto *theme = QWaylandCursorTheme::create(shm(), cursorSize)) {
+ mCursorThemesBySize[cursorSize] = theme;
+ return theme;
+ }
+
+ return nullptr;
+}
+
#endif // QT_CONFIG(cursor)
}
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index a65ed320d..aee1ed45f 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -63,7 +63,6 @@
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/private/qwaylandshm_p.h>
struct wl_cursor_image;
@@ -75,16 +74,14 @@ class QSocketNotifier;
class QPlatformScreen;
namespace QtWayland {
- class qt_shell;
- class qt_sub_surface_extension;
class qt_surface_extension;
class zwp_text_input_manager_v2;
- class xdg_shell;
+ class zxdg_output_manager_v1;
}
namespace QtWaylandClient {
-Q_DECLARE_LOGGING_CATEGORY(lcQpaWayland);
+Q_WAYLAND_CLIENT_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcQpaWayland);
class QWaylandInputDevice;
class QWaylandBuffer;
@@ -95,11 +92,10 @@ class QWaylandDataDeviceManager;
class QWaylandTouchExtension;
class QWaylandQtKeyExtension;
class QWaylandWindow;
-class QWaylandEventThread;
class QWaylandIntegration;
class QWaylandHardwareIntegration;
-class QWaylandXdgShell;
class QWaylandShellSurface;
+class QWaylandCursorTheme;
typedef void (*RegistryListener)(void *data,
struct wl_registry *registry,
@@ -127,8 +123,9 @@ public:
QWaylandWindowManagerIntegration *windowManagerIntegration() const;
#if QT_CONFIG(cursor)
- void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image);
- void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot);
+ void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, qreal dpr);
+ void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, qreal dpr);
+ QWaylandCursorTheme *loadCursorTheme(qreal devicePixelRatio);
#endif
struct wl_display *wl_display() const { return mDisplay; }
struct ::wl_registry *wl_registry() { return object(); }
@@ -147,6 +144,8 @@ public:
QWaylandTouchExtension *touchExtension() const { return mTouchExtension.data(); }
QtWayland::zwp_text_input_manager_v2 *textInputManager() const { return mTextInputManager.data(); }
QWaylandHardwareIntegration *hardwareIntegration() const { return mHardwareIntegration.data(); }
+ QtWayland::zxdg_output_manager_v1 *xdgOutputManager() const { return mXdgOutputManager.data(); }
+
struct RegistryGlobal {
uint32_t id;
@@ -205,6 +204,9 @@ private:
QList<QWaylandInputDevice *> mInputDevices;
QList<Listener> mRegistryListeners;
QWaylandIntegration *mWaylandIntegration = nullptr;
+#if QT_CONFIG(cursor)
+ QMap<int, QWaylandCursorTheme *> mCursorThemesBySize;
+#endif
#if QT_CONFIG(wayland_datadevice)
QScopedPointer<QWaylandDataDeviceManager> mDndSelectionHandler;
#endif
@@ -215,6 +217,7 @@ private:
QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration;
QScopedPointer<QtWayland::zwp_text_input_manager_v2> mTextInputManager;
QScopedPointer<QWaylandHardwareIntegration> mHardwareIntegration;
+ QScopedPointer<QtWayland::zxdg_output_manager_v1> mXdgOutputManager;
QSocketNotifier *mReadNotifier = nullptr;
int mFd;
int mWritableNotificationFd;
diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp
index fe620506d..b01a9db36 100644
--- a/src/client/qwaylanddnd.cpp
+++ b/src/client/qwaylanddnd.cpp
@@ -77,15 +77,19 @@ void QWaylandDrag::cancel()
m_display->currentInputDevice()->dataDevice()->cancelDrag();
}
-void QWaylandDrag::move(const QPoint &globalPos)
+void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
Q_UNUSED(globalPos);
+ Q_UNUSED(b);
+ Q_UNUSED(mods);
// Do nothing
}
-void QWaylandDrag::drop(const QPoint &globalPos)
+void QWaylandDrag::drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
Q_UNUSED(globalPos);
+ Q_UNUSED(b);
+ Q_UNUSED(mods);
// Do nothing
}
diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h
index 04b39826c..474fe2ab1 100644
--- a/src/client/qwaylanddnd_p.h
+++ b/src/client/qwaylanddnd_p.h
@@ -78,8 +78,8 @@ public:
protected:
void startDrag() override;
void cancel() override;
- void move(const QPoint &globalPos) override;
- void drop(const QPoint &globalPos) override;
+ void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+ void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
void endDrag() override;
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
index 93344d13f..b4b7c4ef3 100644
--- a/src/client/qwaylandinputdevice.cpp
+++ b/src/client/qwaylandinputdevice.cpp
@@ -371,7 +371,7 @@ void QWaylandInputDevice::setCursor(Qt::CursorShape newShape, QWaylandScreen *sc
}
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
- setCursor(buffer, image);
+ setCursor(buffer, image, screen->devicePixelRatio());
}
void QWaylandInputDevice::setCursor(const QCursor &cursor, QWaylandScreen *screen)
@@ -381,20 +381,26 @@ void QWaylandInputDevice::setCursor(const QCursor &cursor, QWaylandScreen *scree
mPointer->mCursorShape = cursor.shape();
if (cursor.shape() == Qt::BitmapCursor) {
- setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot());
+ setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot(), screen->devicePixelRatio());
return;
}
setCursor(cursor.shape(), screen);
}
-void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image)
+void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, int bufferScale)
{
- setCursor(buffer,
- image ? QPoint(image->hotspot_x, image->hotspot_y) : QPoint(),
- image ? QSize(image->width, image->height) : QSize());
+ if (image) {
+ // Convert from pixel coordinates to surface coordinates
+ QPoint hotspot = QPoint(image->hotspot_x, image->hotspot_y) / bufferScale;
+ QSize size = QSize(image->width, image->height) / bufferScale;
+ setCursor(buffer, hotspot, size, bufferScale);
+ } else {
+ setCursor(buffer, QPoint(), QSize(), bufferScale);
+ }
}
-void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size)
+// size and hotspot are in surface coordinates
+void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size, int bufferScale)
{
if (mCaps & WL_SEAT_CAPABILITY_POINTER) {
bool force = mPointer->mEnterSerial > mPointer->mCursorSerial;
@@ -417,14 +423,16 @@ void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotS
mPointer->set_cursor(mPointer->mEnterSerial, pointerSurface,
hotSpot.x(), hotSpot.y());
wl_surface_attach(pointerSurface, buffer, 0, 0);
+ if (mQDisplay->compositorVersion() >= 3)
+ wl_surface_set_buffer_scale(pointerSurface, bufferScale);
wl_surface_damage(pointerSurface, 0, 0, size.width(), size.height());
wl_surface_commit(pointerSurface);
}
}
-void QWaylandInputDevice::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot)
+void QWaylandInputDevice::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, int bufferScale)
{
- setCursor(buffer->buffer(), hotSpot, buffer->size());
+ setCursor(buffer->buffer(), hotSpot, buffer->size(), bufferScale);
mPixmapCursor = buffer;
}
#endif
diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h
index 48c1cf57f..4b12cc089 100644
--- a/src/client/qwaylandinputdevice_p.h
+++ b/src/client/qwaylandinputdevice_p.h
@@ -110,9 +110,9 @@ public:
#if QT_CONFIG(cursor)
void setCursor(const QCursor &cursor, QWaylandScreen *screen);
- void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image);
- void setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size);
- void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot);
+ void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image, int bufferScale);
+ void setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size, int bufferScale);
+ void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, int bufferScale);
#endif
void handleWindowDestroyed(QWaylandWindow *window);
void handleEndDrag();
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
index 6b2faf0c4..e935ef31f 100644
--- a/src/client/qwaylandintegration.cpp
+++ b/src/client/qwaylandintegration.cpp
@@ -82,9 +82,6 @@
#include "qwaylandshellintegration_p.h"
#include "qwaylandshellintegrationfactory_p.h"
-#include "qwaylandxdgshellintegration_p.h"
-#include "qwaylandwlshellintegration_p.h"
-#include "qwaylandxdgshellv6integration_p.h"
#include "qwaylandinputdeviceintegration_p.h"
#include "qwaylandinputdeviceintegrationfactory_p.h"
@@ -393,13 +390,14 @@ void QWaylandIntegration::initializeShellIntegration()
{
mShellIntegrationInitialized = true;
- QByteArray integrationName = qgetenv("QT_WAYLAND_SHELL_INTEGRATION");
- QString targetKey = QString::fromLocal8Bit(integrationName);
+ QByteArray integrationNames = qgetenv("QT_WAYLAND_SHELL_INTEGRATION");
+ QString targetKeys = QString::fromLocal8Bit(integrationNames);
QStringList preferredShells;
- if (!targetKey.isEmpty()) {
- preferredShells << targetKey;
+ if (!targetKeys.isEmpty()) {
+ preferredShells = targetKeys.split(QLatin1Char(';'));
} else {
+ preferredShells << QLatin1String("xdg-shell");
preferredShells << QLatin1String("xdg-shell-v6");
QString useXdgShell = QString::fromLocal8Bit(qgetenv("QT_WAYLAND_USE_XDG_SHELL"));
if (!useXdgShell.isEmpty() && useXdgShell != QLatin1String("0")) {
@@ -418,9 +416,9 @@ void QWaylandIntegration::initializeShellIntegration()
}
}
- if (!mShellIntegration || !mShellIntegration->initialize(mDisplay.data())) {
- mShellIntegration.reset();
- qWarning("Failed to load shell integration %s", qPrintable(targetKey));
+ if (!mShellIntegration) {
+ qCWarning(lcQpaWayland) << "Loading shell integration failed.";
+ qCWarning(lcQpaWayland) << "Attempted to load the following shells" << preferredShells;
}
}
@@ -452,15 +450,10 @@ void QWaylandIntegration::initializeInputDeviceIntegration()
QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
{
- if (integrationName == QLatin1Literal("wl-shell")) {
- return QWaylandWlShellIntegration::create(mDisplay.data());
- } else if (integrationName == QLatin1Literal("xdg-shell-v5")) {
- return QWaylandXdgShellIntegration::create(mDisplay.data());
- } else if (integrationName == QLatin1Literal("xdg-shell-v6")) {
- return QWaylandXdgShellV6Integration::create(mDisplay.data());
- } else if (QWaylandShellIntegrationFactory::keys().contains(integrationName)) {
- return QWaylandShellIntegrationFactory::create(integrationName, QStringList());
+ if (QWaylandShellIntegrationFactory::keys().contains(integrationName)) {
+ return QWaylandShellIntegrationFactory::create(integrationName, mDisplay.data());
} else {
+ qCWarning(lcQpaWayland) << "No shell integration named" << integrationName << "found";
return nullptr;
}
}
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp
index 9946c3235..76acb526b 100644
--- a/src/client/qwaylandnativeinterface.cpp
+++ b/src/client/qwaylandnativeinterface.cpp
@@ -40,13 +40,13 @@
#include "qwaylandnativeinterface_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandwindow_p.h"
+#include "qwaylandshellintegration_p.h"
#include "qwaylandsubsurface_p.h"
#include "qwaylandextendedsurface_p.h"
#include "qwaylandintegration_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandwindowmanagerintegration_p.h"
#include "qwaylandscreen_p.h"
-#include "qwaylandwlshellsurface_p.h"
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QScreen>
#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
@@ -91,18 +91,13 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc
QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle());
return w ? w->object() : nullptr;
}
- if (lowerCaseResource == "wl_shell_surface") {
- QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle());
- if (!w)
- return nullptr;
- QWaylandWlShellSurface *s = qobject_cast<QWaylandWlShellSurface *>(w->shellSurface());
- if (!s)
- return nullptr;
- return s->object();
- }
+
if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration())
return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay);
+ if (auto shellIntegration = m_integration->shellIntegration())
+ return shellIntegration->nativeResourceForWindow(resourceString, window);
+
return nullptr;
}
diff --git a/src/client/qwaylandqtkey.cpp b/src/client/qwaylandqtkey.cpp
index ce0d2124e..a60185bd6 100644
--- a/src/client/qwaylandqtkey.cpp
+++ b/src/client/qwaylandqtkey.cpp
@@ -46,12 +46,12 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
QWaylandQtKeyExtension::QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id)
- : QtWayland::qt_key_extension(display->wl_registry(), id, 2)
+ : QtWayland::zqt_key_v1(display->wl_registry(), id, 1)
, m_display(display)
{
}
-void QWaylandQtKeyExtension::key_extension_qtkey(struct wl_surface *surface,
+void QWaylandQtKeyExtension::zqt_key_v1_key(struct wl_surface *surface,
uint32_t time,
uint32_t type,
uint32_t key,
diff --git a/src/client/qwaylandqtkey_p.h b/src/client/qwaylandqtkey_p.h
index 9091cf819..117c44a6d 100644
--- a/src/client/qwaylandqtkey_p.h
+++ b/src/client/qwaylandqtkey_p.h
@@ -54,7 +54,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include <QtWaylandClient/private/qwayland-qtkey-extension.h>
+#include <QtWaylandClient/private/qwayland-qt-key-unstable-v1.h>
QT_BEGIN_NAMESPACE
@@ -62,7 +62,7 @@ namespace QtWaylandClient {
class QWaylandDisplay;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandQtKeyExtension : public QtWayland::qt_key_extension
+class Q_WAYLAND_CLIENT_EXPORT QWaylandQtKeyExtension : public QtWayland::zqt_key_v1
{
public:
QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id);
@@ -70,17 +70,17 @@ public:
private:
QWaylandDisplay *m_display = nullptr;
- void key_extension_qtkey(struct wl_surface *surface,
- uint32_t time,
- uint32_t type,
- uint32_t key,
- uint32_t modifiers,
- uint32_t nativeScanCode,
- uint32_t nativeVirtualKey,
- uint32_t nativeModifiers,
- const QString &text,
- uint32_t autorep,
- uint32_t count) override;
+ void zqt_key_v1_key(struct wl_surface *surface,
+ uint32_t time,
+ uint32_t type,
+ uint32_t key,
+ uint32_t modifiers,
+ uint32_t nativeScanCode,
+ uint32_t nativeVirtualKey,
+ uint32_t nativeModifiers,
+ const QString &text,
+ uint32_t autorep,
+ uint32_t count) override;
};
diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp
index 38d97a91d..38d61f88c 100644
--- a/src/client/qwaylandscreen.cpp
+++ b/src/client/qwaylandscreen.cpp
@@ -58,20 +58,23 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
, mWaylandDisplay(waylandDisplay)
, mOutputName(QStringLiteral("Screen%1").arg(id))
{
+ if (auto *xdgOutputManager = waylandDisplay->xdgOutputManager())
+ initXdgOutput(xdgOutputManager);
}
QWaylandScreen::~QWaylandScreen()
{
-#if QT_CONFIG(cursor)
- delete mWaylandCursor;
-#endif
+ if (zxdg_output_v1::isInitialized())
+ zxdg_output_v1::destroy();
}
-void QWaylandScreen::init()
+void QWaylandScreen::initXdgOutput(QtWayland::zxdg_output_manager_v1 *xdgOutputManager)
{
-#if QT_CONFIG(cursor)
- mWaylandCursor = new QWaylandCursor(this);
-#endif
+ Q_ASSERT(xdgOutputManager);
+ if (zxdg_output_v1::isInitialized())
+ return;
+
+ zxdg_output_v1::init(xdgOutputManager->get_xdg_output(wl_output::object()));
}
QWaylandDisplay * QWaylandScreen::display() const
@@ -91,9 +94,13 @@ QString QWaylandScreen::model() const
QRect QWaylandScreen::geometry() const
{
- // Scale geometry for QScreen. This makes window and screen
- // geometry be in the same coordinate system.
- return QRect(mGeometry.topLeft(), mGeometry.size() / mScale);
+ if (zxdg_output_v1::isInitialized()) {
+ return mXdgGeometry;
+ } else {
+ // Scale geometry for QScreen. This makes window and screen
+ // geometry be in the same coordinate system.
+ return QRect(mGeometry.topLeft(), mGeometry.size() / mScale);
+ }
}
int QWaylandScreen::depth() const
@@ -116,11 +123,15 @@ QSizeF QWaylandScreen::physicalSize() const
QDpi QWaylandScreen::logicalDpi() const
{
- static int force_dpi = !qgetenv("QT_WAYLAND_FORCE_DPI").isEmpty() ? qgetenv("QT_WAYLAND_FORCE_DPI").toInt() : -1;
- if (force_dpi > 0)
- return QDpi(force_dpi, force_dpi);
+ static bool physicalDpi = qEnvironmentVariable("QT_WAYLAND_FORCE_DPI") == QStringLiteral("physical");
+ if (physicalDpi)
+ return QPlatformScreen::logicalDpi();
+
+ static int forceDpi = qgetenv("QT_WAYLAND_FORCE_DPI").toInt();
+ if (forceDpi)
+ return QDpi(forceDpi, forceDpi);
- return QPlatformScreen::logicalDpi();
+ return QDpi(96, 96);
}
QList<QPlatformScreen *> QWaylandScreen::virtualSiblings() const
@@ -165,11 +176,20 @@ qreal QWaylandScreen::refreshRate() const
}
#if QT_CONFIG(cursor)
+
QPlatformCursor *QWaylandScreen::cursor() const
{
- return mWaylandCursor;
+ return const_cast<QWaylandScreen *>(this)->waylandCursor();
+}
+
+QWaylandCursor *QWaylandScreen::waylandCursor()
+{
+ if (!mWaylandCursor)
+ mWaylandCursor.reset(new QWaylandCursor(this));
+ return mWaylandCursor.data();
}
-#endif
+
+#endif // QT_CONFIG(cursor)
QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window)
{
@@ -189,7 +209,6 @@ void QWaylandScreen::output_mode(uint32_t flags, int width, int height, int refr
return;
QSize size(width, height);
-
if (size != mGeometry.size())
mGeometry.setSize(size);
@@ -252,8 +271,25 @@ void QWaylandScreen::output_done()
QWindowSystemInterface::handleScreenOrientationChange(screen(), m_orientation);
mTransform = -1;
}
- QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), geometry());
QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate());
+ if (!zxdg_output_v1::isInitialized())
+ QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), geometry());
+}
+
+
+void QWaylandScreen::zxdg_output_v1_logical_position(int32_t x, int32_t y)
+{
+ mXdgGeometry.moveTopLeft(QPoint(x, y));
+}
+
+void QWaylandScreen::zxdg_output_v1_logical_size(int32_t width, int32_t height)
+{
+ mXdgGeometry.setSize(QSize(width, height));
+}
+
+void QWaylandScreen::zxdg_output_v1_done()
+{
+ QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), geometry());
}
}
diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h
index 9df55d603..6e4ed94f7 100644
--- a/src/client/qwaylandscreen_p.h
+++ b/src/client/qwaylandscreen_p.h
@@ -55,6 +55,8 @@
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
+#include <QtWaylandClient/private/qwayland-xdg-output-unstable-v1.h>
+
QT_BEGIN_NAMESPACE
@@ -63,13 +65,14 @@ namespace QtWaylandClient {
class QWaylandDisplay;
class QWaylandCursor;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output
+class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output, QtWayland::zxdg_output_v1
{
public:
QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id);
~QWaylandScreen() override;
- void init();
+ void initXdgOutput(QtWayland::zxdg_output_manager_v1 *xdgOutputManager);
+
QWaylandDisplay *display() const;
QString manufacturer() const override;
@@ -95,11 +98,11 @@ public:
#if QT_CONFIG(cursor)
QPlatformCursor *cursor() const override;
- QWaylandCursor *waylandCursor() const { return mWaylandCursor; }
+ QWaylandCursor *waylandCursor();
#endif
uint32_t outputId() const { return m_outputId; }
- ::wl_output *output() { return object(); }
+ ::wl_output *output() { return QtWayland::wl_output::object(); }
static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
static QWaylandScreen *fromWlOutput(::wl_output *output);
@@ -115,11 +118,17 @@ private:
void output_scale(int32_t factor) override;
void output_done() override;
+ // XdgOutput
+ void zxdg_output_v1_logical_position(int32_t x, int32_t y) override;
+ void zxdg_output_v1_logical_size(int32_t width, int32_t height) override;
+ void zxdg_output_v1_done() override;
+
int m_outputId;
QWaylandDisplay *mWaylandDisplay = nullptr;
QString mManufacturer;
QString mModel;
QRect mGeometry;
+ QRect mXdgGeometry;
int mScale = 1;
int mDepth = 32;
int mRefreshRate = 60000;
@@ -130,7 +139,7 @@ private:
Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
#if QT_CONFIG(cursor)
- QWaylandCursor *mWaylandCursor = nullptr;
+ QScopedPointer<QWaylandCursor> mWaylandCursor;
#endif
};
diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index fdc309a63..6bc3258c7 100644
--- a/src/client/qwaylandshellsurface_p.h
+++ b/src/client/qwaylandshellsurface_p.h
@@ -95,13 +95,9 @@ public:
inline QWaylandWindow *window() { return m_window; }
- virtual void setType(Qt::WindowType type, QWaylandWindow *transientParent) = 0;
-
-protected:
- virtual void setMaximized() {}
- virtual void setFullscreen() {}
- virtual void setNormal() {}
- virtual void setMinimized() {}
+ virtual void applyConfigure() {}
+ virtual void requestWindowStates(Qt::WindowStates states) {Q_UNUSED(states);}
+ virtual bool wantsDecorations() const { return false; }
private:
QWaylandWindow *m_window = nullptr;
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index b88541ad8..0ff3a72e5 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -44,8 +44,6 @@
#include "qwaylandinputdevice_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandshellsurface_p.h"
-#include "qwaylandwlshellsurface_p.h"
-#include "qwaylandxdgsurface_p.h"
#include "qwaylandsubsurface_p.h"
#include "qwaylandabstractdecoration_p.h"
#include "qwaylandwindowmanagerintegration_p.h"
@@ -143,8 +141,6 @@ void QWaylandWindow::initWindow()
mShellSurface = mDisplay->createShellSurface(this);
if (mShellSurface) {
- mShellSurface->setType(window()->type(), transientParent());
-
// Set initial surface title
setWindowTitle(window()->title());
@@ -202,11 +198,8 @@ void QWaylandWindow::initWindow()
else
setGeometry_helper(window()->geometry());
setMask(window()->mask());
- // setWindowStateInternal is a no-op if the argument is equal to mState,
- // but since we're creating the shellsurface only now we reset mState to
- // make sure the state gets sent out to the compositor
- mState = Qt::WindowNoState;
- setWindowStateInternal(window()->windowStates());
+ if (mShellSurface)
+ mShellSurface->requestWindowStates(window()->windowStates());
handleContentOrientationChange(window()->contentOrientation());
mFlags = window()->flags();
}
@@ -346,7 +339,16 @@ void QWaylandWindow::setGeometry(const QRect &rect)
sendExposeEvent(QRect(QPoint(), geometry().size()));
}
+void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+{
+ QMargins margins = frameMargins();
+ int widthWithoutMargins = qMax(sizeWithMargins.width() - (margins.left()+margins.right()), 1);
+ int heightWithoutMargins = qMax(sizeWithMargins.height() - (margins.top()+margins.bottom()), 1);
+ QRect geometry(QPoint(), QSize(widthWithoutMargins, heightWithoutMargins));
+ mOffset += offset;
+ setGeometry(geometry);
+}
void QWaylandWindow::sendExposeEvent(const QRect &rect)
{
@@ -434,46 +436,24 @@ void QWaylandWindow::setMask(const QRegion &mask)
wl_surface::commit();
}
-void QWaylandWindow::configure(uint32_t edges, int32_t width, int32_t height)
+void QWaylandWindow::applyConfigureWhenPossible()
{
QMutexLocker resizeLocker(&mResizeLock);
- mConfigure.edges |= edges;
- mConfigure.width = width;
- mConfigure.height = height;
-
- if (!mRequestResizeSent && !mConfigure.isEmpty()) {
- mRequestResizeSent= true;
- QMetaObject::invokeMethod(this, "requestResize", Qt::QueuedConnection);
+ if (!mWaitingToApplyConfigure) {
+ mWaitingToApplyConfigure = true;
+ QMetaObject::invokeMethod(this, "applyConfigure", Qt::QueuedConnection);
}
}
-void QWaylandWindow::doResize()
+void QWaylandWindow::doApplyConfigure()
{
- if (mConfigure.isEmpty()) {
+ if (!mWaitingToApplyConfigure)
return;
- }
-
- int widthWithoutMargins = qMax(mConfigure.width-(frameMargins().left() +frameMargins().right()),1);
- int heightWithoutMargins = qMax(mConfigure.height-(frameMargins().top()+frameMargins().bottom()),1);
-
- widthWithoutMargins = qMax(widthWithoutMargins, window()->minimumSize().width());
- heightWithoutMargins = qMax(heightWithoutMargins, window()->minimumSize().height());
- QRect geometry = QRect(0,0, widthWithoutMargins, heightWithoutMargins);
- int x = 0;
- int y = 0;
- QSize size = this->geometry().size();
- if (mConfigure.edges & WL_SHELL_SURFACE_RESIZE_LEFT) {
- x = size.width() - geometry.width();
- }
- if (mConfigure.edges & WL_SHELL_SURFACE_RESIZE_TOP) {
- y = size.height() - geometry.height();
- }
- mOffset += QPoint(x, y);
-
- setGeometry(geometry);
+ if (mShellSurface)
+ mShellSurface->applyConfigure();
- mConfigure.clear();
+ mWaitingToApplyConfigure = false;
}
void QWaylandWindow::setCanResize(bool canResize)
@@ -485,8 +465,8 @@ void QWaylandWindow::setCanResize(bool canResize)
if (mResizeDirty) {
QWindowSystemInterface::handleGeometryChange(window(), geometry());
}
- if (!mConfigure.isEmpty()) {
- doResize();
+ if (mWaitingToApplyConfigure) {
+ doApplyConfigure();
sendExposeEvent(QRect(QPoint(), geometry().size()));
} else if (mResizeDirty) {
mResizeDirty = false;
@@ -495,15 +475,13 @@ void QWaylandWindow::setCanResize(bool canResize)
}
}
-void QWaylandWindow::requestResize()
+void QWaylandWindow::applyConfigure()
{
QMutexLocker lock(&mResizeLock);
- if (mCanResize || !mSentInitialResize) {
- doResize();
- }
+ if (mCanResize || !mSentInitialResize)
+ doApplyConfigure();
- mRequestResizeSent = false;
lock.unlock();
sendExposeEvent(QRect(QPoint(), geometry().size()));
QWindowSystemInterface::flushWindowSystemEvents();
@@ -616,9 +594,8 @@ void QWaylandWindow::frameCallback(void *data, struct wl_callback *callback, uin
self->mWaitingForFrameSync = false;
if (self->mUpdateRequested) {
- QWindowPrivate *w = QWindowPrivate::get(self->window());
self->mUpdateRequested = false;
- w->deliverUpdateRequest();
+ self->deliverUpdateRequest();
}
}
@@ -693,10 +670,10 @@ void QWaylandWindow::setOrientationMask(Qt::ScreenOrientations mask)
mShellSurface->setContentOrientationMask(mask);
}
-void QWaylandWindow::setWindowState(Qt::WindowStates state)
+void QWaylandWindow::setWindowState(Qt::WindowStates states)
{
- if (setWindowStateInternal(state))
- QWindowSystemInterface::flushWindowSystemEvents(); // Required for oldState to work on WindowStateChanged
+ if (mShellSurface)
+ mShellSurface->requestWindowStates(states);
}
void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
@@ -710,20 +687,6 @@ void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
bool QWaylandWindow::createDecoration()
{
- // so far only xdg-shell support this "unminimize" trick, may be moved elsewhere
- if (mState & Qt::WindowMinimized) {
- QWaylandXdgSurface *xdgSurface = qobject_cast<QWaylandXdgSurface *>(mShellSurface);
- if ( xdgSurface ) {
- Qt::WindowStates states;
- if (xdgSurface->isFullscreen())
- states |= Qt::WindowFullScreen;
- if (xdgSurface->isMaximized())
- states |= Qt::WindowMaximized;
-
- setWindowStateInternal(states);
- }
- }
-
if (!mDisplay->supportsWindowDecoration())
return false;
@@ -740,12 +703,14 @@ bool QWaylandWindow::createDecoration()
default:
break;
}
- if (mFlags & Qt::FramelessWindowHint || isFullscreen())
+ if (mFlags & Qt::FramelessWindowHint)
decoration = false;
if (mFlags & Qt::BypassWindowManagerHint)
decoration = false;
if (mSubSurfaceWindow)
decoration = false;
+ if (mShellSurface && !mShellSurface->wantsDecorations())
+ decoration = false;
bool hadDecoration = mWindowDecoration;
if (decoration && !decorationPluginFailed) {
@@ -846,8 +811,13 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan
}
#if QT_CONFIG(cursor)
- if (e.type == QWaylandPointerEvent::Enter)
- restoreMouseCursor(inputDevice);
+ if (e.type == QWaylandPointerEvent::Enter) {
+ QRect windowGeometry = window()->frameGeometry();
+ windowGeometry.moveTopLeft({0, 0}); // convert to wayland surface coordinates
+ QRect contentGeometry = windowGeometry.marginsRemoved(frameMargins());
+ if (contentGeometry.contains(e.local.toPoint()))
+ restoreMouseCursor(inputDevice);
+ }
#endif
}
@@ -876,8 +846,10 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe
{
if (mMousePressedInContentArea == Qt::NoButton &&
mWindowDecoration->handleMouse(inputDevice, e.local, e.global, e.buttons, e.modifiers)) {
- if (mMouseEventsInContentArea)
+ if (mMouseEventsInContentArea) {
QWindowSystemInterface::handleLeaveEvent(window());
+ mMouseEventsInContentArea = false;
+ }
return;
}
@@ -991,31 +963,11 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
return true;
}
-bool QWaylandWindow::setWindowStateInternal(Qt::WindowStates state)
+void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
{
- if (mState == state) {
- return false;
- }
-
- // As of february 2013 QWindow::setWindowState sets the new state value after
- // QPlatformWindow::setWindowState returns, so we cannot rely on QWindow::windowState
- // here. We use then this mState variable.
- mState = state;
-
- if (mShellSurface) {
- createDecoration();
- if (state & Qt::WindowMaximized)
- mShellSurface->setMaximized();
- if (state & Qt::WindowFullScreen)
- mShellSurface->setFullscreen();
- if (state & Qt::WindowMinimized)
- mShellSurface->setMinimized();
- if (!state)
- mShellSurface->setNormal();
- }
-
- QWindowSystemInterface::handleWindowStateChanged(window(), mState);
- return true;
+ createDecoration();
+ QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
+ mLastReportedWindowStates = states;
}
void QWaylandWindow::sendProperty(const QString &name, const QVariant &value)
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 366548635..b6b499a3b 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -80,23 +80,6 @@ class QWaylandScreen;
class QWaylandShmBackingStore;
class QWaylandPointerEvent;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandWindowConfigure
-{
-public:
- QWaylandWindowConfigure()
- { }
-
- void clear()
- { width = height = edges = 0; }
-
- bool isEmpty() const
- { return !height || !width; }
-
- int width = 0;
- int height = 0;
- uint32_t edges = 0;
-};
-
class Q_WAYLAND_CLIENT_EXPORT QWaylandWindow : public QObject, public QPlatformWindow, public QtWayland::wl_surface
{
Q_OBJECT
@@ -121,8 +104,9 @@ public:
void setWindowIcon(const QIcon &icon) override;
void setGeometry(const QRect &rect) override;
+ void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
- void configure(uint32_t edges, int32_t width, int32_t height);
+ void applyConfigureWhenPossible(); //rename to possible?
using QtWayland::wl_surface::attach;
void attach(QWaylandBuffer *buffer, int x, int y);
@@ -148,8 +132,9 @@ public:
void handleContentOrientationChange(Qt::ScreenOrientation orientation) override;
void setOrientationMask(Qt::ScreenOrientations mask);
- void setWindowState(Qt::WindowStates state) override;
+ void setWindowState(Qt::WindowStates states) override;
void setWindowFlags(Qt::WindowFlags flags) override;
+ void handleWindowStatesChanged(Qt::WindowStates states);
void raise() override;
void lower() override;
@@ -173,9 +158,6 @@ public:
bool createDecoration();
- inline bool isMaximized() const { return mState & Qt::WindowMaximized; }
- inline bool isFullscreen() const { return mState & Qt::WindowFullScreen; }
-
#if QT_CONFIG(cursor)
void setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor);
void restoreMouseCursor(QWaylandInputDevice *device);
@@ -184,7 +166,7 @@ public:
QWaylandWindow *transientParent() const;
QMutex *resizeMutex() { return &mResizeLock; }
- void doResize();
+ void doApplyConfigure();
void setCanResize(bool canResize);
bool setMouseGrabEnabled(bool grab) override;
@@ -209,7 +191,7 @@ public:
void requestUpdate() override;
public slots:
- void requestResize();
+ void applyConfigure();
protected:
void surface_enter(struct ::wl_output *output) override;
@@ -231,8 +213,7 @@ protected:
QWaitCondition mFrameSyncWait;
QMutex mResizeLock;
- QWaylandWindowConfigure mConfigure;
- bool mRequestResizeSent = false;
+ bool mWaitingToApplyConfigure = false;
bool mCanResize = true;
bool mResizeDirty = false;
bool mResizeAfterSwap;
@@ -244,9 +225,9 @@ protected:
QIcon mWindowIcon;
- Qt::WindowStates mState = Qt::WindowNoState;
Qt::WindowFlags mFlags;
QRegion mMask;
+ Qt::WindowStates mLastReportedWindowStates = Qt::WindowNoState;
QWaylandShmBackingStore *mBackingStore = nullptr;
@@ -254,7 +235,6 @@ private slots:
void handleScreenRemoved(QScreen *qScreen);
private:
- bool setWindowStateInternal(Qt::WindowStates flags);
void setGeometry_helper(const QRect &rect);
void initWindow();
void initializeWlSurface();
diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp
deleted file mode 100644
index 42738528c..000000000
--- a/src/client/qwaylandxdgsurface.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the config.tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwaylandxdgsurface_p.h"
-
-#include "qwaylanddisplay_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylandinputdevice_p.h"
-#include "qwaylandabstractdecoration_p.h"
-#include "qwaylandscreen_p.h"
-#include "qwaylandextendedsurface_p.h"
-#include "qwaylandxdgshell_p.h"
-
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWaylandClient {
-
-QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow *window)
- : QWaylandShellSurface(window)
- , QtWayland::xdg_surface(shell->get_xdg_surface(window->object()))
- , m_window(window)
- , m_shell(shell)
-{
- if (window->display()->windowExtension())
- m_extendedWindow = new QWaylandExtendedSurface(window);
-}
-
-QWaylandXdgSurface::~QWaylandXdgSurface()
-{
- if (m_active)
- window()->display()->handleWindowDeactivated(m_window);
-
- xdg_surface_destroy(object());
- delete m_extendedWindow;
-}
-
-void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
-{
- // May need some conversion if types get incompatibles, ATM they're identical
- enum resize_edge const * const arg = reinterpret_cast<enum resize_edge const * const>(&edges);
- resize(inputDevice, *arg);
-}
-
-void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum resize_edge edges)
-{
- resize(inputDevice->wl_seat(),
- inputDevice->serial(),
- edges);
-}
-
-bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
-{
- move(inputDevice->wl_seat(),
- inputDevice->serial());
- return true;
-}
-
-void QWaylandXdgSurface::setMaximized()
-{
- if (!m_maximized)
- set_maximized();
-}
-
-void QWaylandXdgSurface::setFullscreen()
-{
- if (!m_fullscreen)
- set_fullscreen(nullptr);
-}
-
-void QWaylandXdgSurface::setNormal()
-{
- if (m_fullscreen || m_maximized || m_minimized) {
- if (m_maximized) {
- unset_maximized();
- }
- if (m_fullscreen) {
- unset_fullscreen();
- }
-
- m_fullscreen = m_maximized = m_minimized = false;
- }
-}
-
-void QWaylandXdgSurface::setMinimized()
-{
- m_minimized = true;
- set_minimized();
-}
-
-void QWaylandXdgSurface::updateTransientParent(QWaylandWindow *parent)
-{
- if (!parent)
- return;
- auto parentXdgSurface = qobject_cast<QWaylandXdgSurface *>(parent->shellSurface());
- Q_ASSERT(parentXdgSurface);
- set_parent(parentXdgSurface->object());
-}
-
-void QWaylandXdgSurface::setTitle(const QString & title)
-{
- return QtWayland::xdg_surface::set_title(title);
-}
-
-void QWaylandXdgSurface::setAppId(const QString & appId)
-{
- return QtWayland::xdg_surface::set_app_id(appId);
-}
-
-void QWaylandXdgSurface::raise()
-{
- if (m_extendedWindow)
- m_extendedWindow->raise();
-}
-
-void QWaylandXdgSurface::lower()
-{
- if (m_extendedWindow)
- m_extendedWindow->lower();
-}
-
-void QWaylandXdgSurface::setContentOrientationMask(Qt::ScreenOrientations orientation)
-{
- if (m_extendedWindow)
- m_extendedWindow->setContentOrientationMask(orientation);
-}
-
-void QWaylandXdgSurface::setWindowFlags(Qt::WindowFlags flags)
-{
- if (m_extendedWindow)
- m_extendedWindow->setWindowFlags(flags);
-}
-
-void QWaylandXdgSurface::sendProperty(const QString &name, const QVariant &value)
-{
- if (m_extendedWindow)
- m_extendedWindow->updateGenericProperty(name, value);
-}
-
-void QWaylandXdgSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent)
-{
- Q_UNUSED(type)
- if (transientParent)
- updateTransientParent(transientParent);
-}
-
-void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, struct wl_array *states,uint32_t serial)
-{
- uint32_t *state = reinterpret_cast<uint32_t*>(states->data);
- size_t numStates = states->size / sizeof(uint32_t);
- bool aboutToMaximize = false;
- bool aboutToFullScreen = false;
- bool aboutToActivate = false;
-
- for (size_t i = 0; i < numStates; i++) {
- switch (state[i]) {
- case XDG_SURFACE_STATE_MAXIMIZED:
- aboutToMaximize = ((width > 0) && (height > 0));
- break;
- case XDG_SURFACE_STATE_FULLSCREEN:
- aboutToFullScreen = true;
- break;
- case XDG_SURFACE_STATE_RESIZING:
- m_normalSize = QSize(width, height);
- break;
- case XDG_SURFACE_STATE_ACTIVATED:
- aboutToActivate = true;
- break;
- default:
- break;
- }
- }
-
- if (!m_active && aboutToActivate) {
- m_active = true;
- window()->display()->handleWindowActivated(m_window);
- } else if (m_active && !aboutToActivate) {
- m_active = false;
- window()->display()->handleWindowDeactivated(m_window);
- }
-
- if (!m_fullscreen && aboutToFullScreen) {
- if (!m_maximized)
- m_normalSize = m_window->window()->frameGeometry().size();
- m_fullscreen = true;
- m_window->window()->showFullScreen();
- } else if (m_fullscreen && !aboutToFullScreen) {
- m_fullscreen = false;
- if ( m_maximized ) {
- m_window->window()->showMaximized();
- } else {
- m_window->window()->showNormal();
- }
- } else if (!m_maximized && aboutToMaximize) {
- if (!m_fullscreen)
- m_normalSize = m_window->window()->frameGeometry().size();
- m_maximized = true;
- m_window->window()->showMaximized();
- } else if (m_maximized && !aboutToMaximize) {
- m_maximized = false;
- m_window->window()->showNormal();
- }
-
- if (width <= 0 || height <= 0) {
- if (!m_normalSize.isEmpty())
- m_window->configure(0, m_normalSize.width(), m_normalSize.height());
- } else {
- m_window->configure(0, width, height);
- }
-
- ack_configure(serial);
-}
-
-void QWaylandXdgSurface::xdg_surface_close()
-{
- m_window->window()->close();
-}
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/client/shellintegration/qwaylandshellintegration_p.h b/src/client/shellintegration/qwaylandshellintegration_p.h
index 7f3a2cefc..ccad00481 100644
--- a/src/client/shellintegration/qwaylandshellintegration_p.h
+++ b/src/client/shellintegration/qwaylandshellintegration_p.h
@@ -79,6 +79,11 @@ public:
if (oldFocus)
m_display->handleWindowDeactivated(oldFocus);
}
+ virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+ Q_UNUSED(resource);
+ Q_UNUSED(window);
+ return nullptr;
+ }
protected:
QWaylandDisplay *m_display = nullptr;
diff --git a/src/client/shellintegration/qwaylandshellintegrationfactory.cpp b/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
index c5a505bbe..48fda14d4 100644
--- a/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
+++ b/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
@@ -78,19 +78,24 @@ QStringList QWaylandShellIntegrationFactory::keys(const QString &pluginPath)
#endif
}
-QWaylandShellIntegration *QWaylandShellIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
+QWaylandShellIntegration *QWaylandShellIntegrationFactory::create(const QString &name, QWaylandDisplay *display, const QStringList &args, const QString &pluginPath)
{
#if QT_CONFIG(library)
+ QScopedPointer<QWaylandShellIntegration> integration;
+
// Try loading the plugin from platformPluginPath first:
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
- if (QWaylandShellIntegration *ret = qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(directLoader(), name, args))
- return ret;
+ integration.reset(qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(directLoader(), name, args));
}
- if (QWaylandShellIntegration *ret = qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(loader(), name, args))
- return ret;
+ if (!integration)
+ integration.reset(qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(loader(), name, args));
#endif
- return nullptr;
+
+ if (integration && !integration->initialize(display))
+ return nullptr;
+
+ return integration.take();
}
}
diff --git a/src/client/shellintegration/qwaylandshellintegrationfactory_p.h b/src/client/shellintegration/qwaylandshellintegrationfactory_p.h
index 3edb0a89d..515a18e1f 100644
--- a/src/client/shellintegration/qwaylandshellintegrationfactory_p.h
+++ b/src/client/shellintegration/qwaylandshellintegrationfactory_p.h
@@ -51,7 +51,10 @@
// We mean it.
//
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+
#include <QtWaylandClient/qtwaylandclientglobal.h>
+
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
@@ -64,7 +67,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandShellIntegrationFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
- static QWaylandShellIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString());
+ static QWaylandShellIntegration *create(const QString &name, QWaylandDisplay *display, const QStringList &args = QStringList(), const QString &pluginPath = QString());
};
}
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 548298c41..f08470b78 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -107,39 +107,48 @@ public:
bool sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) override
{
if (e->type == QWindowSystemInterfacePrivate::Key) {
- QWindowSystemInterfacePrivate::KeyEvent *ke = static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e);
- QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(compositor->defaultSeat()->keyboard());
+ QWindowSystemInterfacePrivate::KeyEvent *keyEvent = static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e);
+ handleKeyEvent(keyEvent);
+ } else {
+ QWindowSystemEventHandler::sendEvent(e);
+ }
+ return true;
+ }
- uint32_t code = ke->nativeScanCode;
- bool isDown = ke->keyType == QEvent::KeyPress;
+ void handleKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *ke)
+ {
+ auto *seat = compositor->defaultSeat();
+ if (!seat)
+ return;
+
+ QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(seat->keyboard());
+
+ uint32_t code = ke->nativeScanCode;
+ bool isDown = ke->keyType == QEvent::KeyPress;
#if QT_CONFIG(xkbcommon_evdev)
- QString text;
- Qt::KeyboardModifiers modifiers = QWaylandXkb::modifiers(keyb->xkbState());
-
- const xkb_keysym_t sym = xkb_state_key_get_one_sym(keyb->xkbState(), code);
- int qtkey;
- std::tie(qtkey, text) = QWaylandXkb::keysymToQtKey(sym, modifiers);
-
- ke->key = qtkey;
- ke->modifiers = modifiers;
- ke->nativeVirtualKey = sym;
- ke->nativeModifiers = keyb->xkbModsMask();
- ke->unicode = text;
+ QString text;
+ Qt::KeyboardModifiers modifiers = QWaylandXkb::modifiers(keyb->xkbState());
+
+ const xkb_keysym_t sym = xkb_state_key_get_one_sym(keyb->xkbState(), code);
+ int qtkey;
+ std::tie(qtkey, text) = QWaylandXkb::keysymToQtKey(sym, modifiers);
+
+ 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);
+ if (!ke->repeat)
+ keyb->keyEvent(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
- QWindowSystemEventHandler::sendEvent(e);
+ QWindowSystemEventHandler::sendEvent(ke);
- if (!ke->repeat) {
- keyb->maybeUpdateKeymap();
- keyb->updateModifierState(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
- }
- } else {
- QWindowSystemEventHandler::sendEvent(e);
+ if (!ke->repeat) {
+ keyb->maybeUpdateKeymap();
+ keyb->updateModifierState(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
}
- return true;
}
QWaylandCompositor *compositor = nullptr;
@@ -193,6 +202,10 @@ void QWaylandCompositorPrivate::init()
emit q->socketNameChanged(socket_name);
}
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+ connectToExternalSockets();
+#endif
+
loop = wl_display_get_event_loop(display);
int fd = wl_event_loop_get_fd(loop);
@@ -274,6 +287,18 @@ void QWaylandCompositorPrivate::addPolishObject(QObject *object)
}
}
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+void QWaylandCompositorPrivate::connectToExternalSockets()
+{
+ // Clear out any backlog of user-supplied external socket descriptors
+ for (int fd : qAsConst(externally_added_socket_fds)) {
+ if (wl_display_add_socket_fd(display, fd) != 0)
+ qWarning() << "Failed to integrate user-supplied socket fd into the Wayland event loop";
+ }
+ externally_added_socket_fds.clear();
+}
+#endif
+
void QWaylandCompositorPrivate::compositor_create_surface(wl_compositor::Resource *resource, uint32_t id)
{
Q_Q(QWaylandCompositor);
@@ -553,6 +578,46 @@ QByteArray QWaylandCompositor::socketName() const
}
/*!
+ * \qmlmethod QtWaylandCompositor::WaylandCompositor::addSocketFd(fd)
+ * \since 5.12
+ *
+ * Listen for client connections on a file descriptor referring to a
+ * server socket already bound and listening.
+ *
+ * Does not take ownership of the file descriptor; it must be closed
+ * explicitly if needed.
+ *
+ * \note This method is only available with libwayland 1.10.0 or
+ * newer. If built against an earlier libwayland runtime, this
+ * method is a noop.
+ */
+
+/*!
+ * Listen for client connections on a file descriptor referring to a
+ * server socket already bound and listening.
+ *
+ * Does not take ownership of the file descriptor; it must be closed
+ * explicitly if needed.
+ *
+ * \note This method is only available with libwayland 1.10.0 or
+ * newer. If built against an earlier libwayland runtime, this
+ * method is a noop.
+ *
+ * \since 5.12
+ */
+void QWaylandCompositor::addSocketFd(int fd)
+{
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+ Q_D(QWaylandCompositor);
+ d->externally_added_socket_fds.append(fd);
+ if (isCreated())
+ d->connectToExternalSockets();
+#else
+ qWarning() << "QWaylandCompositor::addSocketFd() does nothing on libwayland versions prior to 1.10.0";
+#endif
+}
+
+/*!
* \internal
*/
struct wl_display *QWaylandCompositor::display() const
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h
index 23844d72a..72b8f2d1b 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.h
+++ b/src/compositor/compositor_api/qwaylandcompositor.h
@@ -93,6 +93,8 @@ public:
void setSocketName(const QByteArray &name);
QByteArray socketName() const;
+ Q_INVOKABLE void addSocketFd(int fd);
+
::wl_display *display() const;
uint32_t nextSerial();
diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h
index 0d259ee84..cdf4be6b4 100644
--- a/src/compositor/compositor_api/qwaylandcompositor_p.h
+++ b/src/compositor/compositor_api/qwaylandcompositor_p.h
@@ -112,6 +112,11 @@ public:
inline void addOutput(QWaylandOutput *output);
inline void removeOutput(QWaylandOutput *output);
+
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+ void connectToExternalSockets();
+#endif
+
protected:
void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) override;
void compositor_create_region(wl_compositor::Resource *resource, uint32_t id) override;
@@ -128,6 +133,9 @@ protected:
void loadServerBufferIntegration();
QByteArray socket_name;
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+ QList<int> externally_added_socket_fds;
+#endif
struct wl_display *display = nullptr;
QList<QWaylandSeat *> seats;
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp
index 7ab8bff9e..c172bca85 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard.cpp
+++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp
@@ -54,6 +54,7 @@
#if QT_CONFIG(xkbcommon_evdev)
#include <sys/mman.h>
#include <sys/types.h>
+#include <qwaylandxkb_p.h>
#endif
QT_BEGIN_NAMESPACE
@@ -196,6 +197,32 @@ void QWaylandKeyboardPrivate::modifiers(uint32_t serial, uint32_t mods_depressed
}
}
+#if QT_CONFIG(xkbcommon_evdev)
+void QWaylandKeyboardPrivate::maybeUpdateXkbScanCodeTable()
+{
+ if (!scanCodesByQtKey.isEmpty() || !xkbState())
+ return;
+
+ if (xkb_keymap *keymap = xkb_state_get_keymap(xkb_state)) {
+ xkb_keymap_key_for_each(keymap, [](xkb_keymap *keymap, xkb_keycode_t keycode, void *d){
+ auto *scanCodesByQtKey = static_cast<QMap<ScanCodeKey, uint>*>(d);
+ uint numLayouts = xkb_keymap_num_layouts_for_key(keymap, keycode);
+ for (uint layout = 0; layout < numLayouts; ++layout) {
+ const xkb_keysym_t *syms = nullptr;
+ xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, 0, &syms);
+ if (!syms)
+ continue;
+
+ Qt::KeyboardModifiers mods = {};
+ int qtKey = QWaylandXkb::keysymToQtKey(syms[0], mods).first;
+ if (qtKey != 0)
+ scanCodesByQtKey->insert({layout, qtKey}, keycode);
+ }
+ }, &scanCodesByQtKey);
+ }
+}
+#endif
+
void QWaylandKeyboardPrivate::updateModifierState(uint code, uint32_t state)
{
#if QT_CONFIG(xkbcommon_evdev)
@@ -355,6 +382,7 @@ void QWaylandKeyboardPrivate::createXKBKeymap()
struct xkb_keymap *xkbKeymap = xkb_keymap_new_from_names(xkb_context, &rule_names, static_cast<xkb_keymap_compile_flags>(0));
if (xkbKeymap) {
+ scanCodesByQtKey.clear();
createXKBState(xkbKeymap);
xkb_keymap_unref(xkbKeymap);
} else {
@@ -561,4 +589,17 @@ void QWaylandKeyboard::addClient(QWaylandClient *client, uint32_t id, uint32_t v
d->add(client->client(), id, qMin<uint32_t>(QtWaylandServer::wl_keyboard::interfaceVersion(), version));
}
+uint QWaylandKeyboard::toScanCode(int qtKey) const
+{
+ uint scanCode = 0;
+#if QT_CONFIG(xkbcommon_evdev)
+ Q_D(const QWaylandKeyboard);
+ const_cast<QWaylandKeyboardPrivate *>(d)->maybeUpdateXkbScanCodeTable();
+ scanCode = d->scanCodesByQtKey.value({d->group, qtKey}, 0);
+#else
+ Q_UNUSED(qtKey);
+#endif
+ return scanCode;
+}
+
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h
index 580f0c4ed..e5d5e086e 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard.h
+++ b/src/compositor/compositor_api/qwaylandkeyboard.h
@@ -82,6 +82,8 @@ public:
virtual void addClient(QWaylandClient *client, uint32_t id, uint32_t version);
+ uint toScanCode(int qtKey) const;
+
Q_SIGNALS:
void focusChanged(QWaylandSurface *surface);
void repeatRateChanged(quint32 repeatRate);
diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h
index 6db312cfb..cd1f27956 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard_p.h
+++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h
@@ -89,6 +89,7 @@ public:
#if QT_CONFIG(xkbcommon_evdev)
struct xkb_state *xkbState() const { return xkb_state; }
uint32_t xkbModsMask() const { return modsDepressed | modsLatched | modsLocked; }
+ void maybeUpdateXkbScanCodeTable();
#endif
void keyEvent(uint code, uint32_t state);
@@ -131,6 +132,8 @@ private:
size_t keymap_size;
int keymap_fd = -1;
char *keymap_area = nullptr;
+ using ScanCodeKey = std::pair<uint,int>; // group/layout and QtKey
+ QMap<ScanCodeKey, uint> scanCodesByQtKey;
struct xkb_context *xkb_context = nullptr;
struct xkb_state *xkb_state = nullptr;
#endif
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index f7782da9c..b1ee9bbe0 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -165,6 +165,33 @@ void QWaylandOutputPrivate::sendModesInfo()
}
}
+void QWaylandOutputPrivate::handleWindowPixelSizeChanged()
+{
+ Q_Q(QWaylandOutput);
+ Q_ASSERT(window);
+ if (sizeFollowsWindow && currentMode <= modes.size() - 1) {
+ if (currentMode >= 0) {
+ QWaylandOutputMode mode = modes.at(currentMode);
+ mode.setSize(windowPixelSize);
+ modes.replace(currentMode, mode);
+ emit q->geometryChanged();
+ if (!availableGeometry.isValid())
+ emit q->availableGeometryChanged();
+ sendModesInfo();
+ } else {
+ // We didn't add a mode during the initialization because the window
+ // size was invalid, let's add it now
+ int mHzRefreshRate = qFloor(window->screen()->refreshRate() * 1000);
+ QWaylandOutputMode mode(windowPixelSize, mHzRefreshRate);
+ if (mode.isValid()) {
+ modes.clear();
+ q->addMode(mode, true);
+ q->setCurrentMode(mode);
+ }
+ }
+ }
+}
+
void QWaylandOutputPrivate::addView(QWaylandView *view, QWaylandSurface *surface)
{
for (int i = 0; i < surfaceViews.size(); i++) {
@@ -267,6 +294,10 @@ void QWaylandOutput::initialize()
Q_ASSERT(d->compositor);
Q_ASSERT(d->compositor->isCreated());
+ if (!d->window && d->sizeFollowsWindow) {
+ qWarning("Setting QWaylandOutput::sizeFollowsWindow without a window has no effect");
+ }
+
// Replace modes with one that follows the window size and refresh rate,
// but only if window size is valid
if (d->window && d->sizeFollowsWindow) {
@@ -282,8 +313,9 @@ void QWaylandOutput::initialize()
QWaylandCompositorPrivate::get(d->compositor)->addOutput(this);
if (d->window) {
- QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::handleSetWidth);
- QObject::connect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::handleSetHeight);
+ QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::handleMaybeWindowPixelSizeChanged);
+ QObject::connect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::handleMaybeWindowPixelSizeChanged);
+ QObject::connect(d->window, &QWindow::screenChanged, this, &QWaylandOutput::handleMaybeWindowPixelSizeChanged);
QObject::connect(d->window, &QObject::destroyed, this, &QWaylandOutput::handleWindowDestroyed);
}
@@ -817,11 +849,6 @@ void QWaylandOutput::setSizeFollowsWindow(bool follow)
{
Q_D(QWaylandOutput);
- if (!d->window) {
- qWarning("Setting QWaylandOutput::sizeFollowsWindow without a window has no effect");
- return;
- }
-
if (follow != d->sizeFollowsWindow) {
d->sizeFollowsWindow = follow;
Q_EMIT sizeFollowsWindowChanged();
@@ -921,66 +948,18 @@ void QWaylandOutput::surfaceLeave(QWaylandSurface *surface)
/*!
* \internal
*/
-void QWaylandOutput::handleSetWidth(int newWidth)
+void QWaylandOutput::handleMaybeWindowPixelSizeChanged()
{
Q_D(QWaylandOutput);
- if (!d->window || !d->sizeFollowsWindow)
+ if (!d->window)
return;
- if (d->currentMode <= d->modes.size() - 1) {
- if (d->currentMode >= 0) {
- QWaylandOutputMode mode = d->modes.at(d->currentMode);
- mode.setWidth(newWidth * d->window->devicePixelRatio());
- d->modes.replace(d->currentMode, mode);
- emit geometryChanged();
- if (!d->availableGeometry.isValid())
- emit availableGeometryChanged();
- d->sendModesInfo();
- } else {
- // We didn't add a mode during the initialization because the window
- // size was invalid, let's add it now
- QWaylandOutputMode mode(d->window->size() * d->window->devicePixelRatio(),
- qFloor(d->window->screen()->refreshRate() * 1000));
- if (mode.isValid()) {
- d->modes.clear();
- addMode(mode, true);
- setCurrentMode(mode);
- }
- }
- }
-}
-
-/*!
- * \internal
- */
-void QWaylandOutput::handleSetHeight(int newHeight)
-{
- Q_D(QWaylandOutput);
+ const QSize pixelSize = d->window->size() * d->window->devicePixelRatio();
- if (!d->window || !d->sizeFollowsWindow)
- return;
-
- if (d->currentMode <= d->modes.size() - 1) {
- if (d->currentMode >= 0) {
- QWaylandOutputMode mode = d->modes.at(d->currentMode);
- mode.setHeight(newHeight * d->window->devicePixelRatio());
- d->modes.replace(d->currentMode, mode);
- emit geometryChanged();
- if (!d->availableGeometry.isValid())
- emit availableGeometryChanged();
- d->sendModesInfo();
- } else {
- // We didn't add a mode during the initialization because the window
- // size was invalid, let's add it now
- QWaylandOutputMode mode(d->window->size() * d->window->devicePixelRatio(),
- qFloor(d->window->screen()->refreshRate() * 1000));
- if (mode.isValid()) {
- d->modes.clear();
- addMode(mode, true);
- setCurrentMode(mode);
- }
- }
+ if (pixelSize != d->windowPixelSize) {
+ d->windowPixelSize = pixelSize;
+ d->handleWindowPixelSizeChanged();
}
}
diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h
index f0bea809e..c7f2973b6 100644
--- a/src/compositor/compositor_api/qwaylandoutput.h
+++ b/src/compositor/compositor_api/qwaylandoutput.h
@@ -181,8 +181,7 @@ Q_SIGNALS:
void windowDestroyed();
private Q_SLOTS:
- void handleSetWidth(int newWidth);
- void handleSetHeight(int newHeight);
+ void handleMaybeWindowPixelSizeChanged();
void handleWindowDestroyed();
protected:
diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h
index 38bb1ec6e..d8b2c9dfa 100644
--- a/src/compositor/compositor_api/qwaylandoutput_p.h
+++ b/src/compositor/compositor_api/qwaylandoutput_p.h
@@ -108,6 +108,8 @@ public:
void sendMode(const Resource *resource, const QWaylandOutputMode &mode);
void sendModesInfo();
+ void handleWindowPixelSizeChanged();
+
protected:
void output_bind_resource(Resource *resource) override;
@@ -128,6 +130,7 @@ private:
int scaleFactor = 1;
bool sizeFollowsWindow = false;
bool initialized = false;
+ QSize windowPixelSize;
Q_DECLARE_PUBLIC(QWaylandOutput)
Q_DISABLE_COPY(QWaylandOutputPrivate)
diff --git a/src/compositor/compositor_api/qwaylandoutputmode.cpp b/src/compositor/compositor_api/qwaylandoutputmode.cpp
index 9ae285fd5..545871175 100644
--- a/src/compositor/compositor_api/qwaylandoutputmode.cpp
+++ b/src/compositor/compositor_api/qwaylandoutputmode.cpp
@@ -128,15 +128,7 @@ int QWaylandOutputMode::refreshRate() const
/*!
* \internal
*/
-void QWaylandOutputMode::setWidth(int width)
+void QWaylandOutputMode::setSize(const QSize &size)
{
- d->size.setWidth(width);
-}
-
-/*!
- * \internal
- */
-void QWaylandOutputMode::setHeight(int height)
-{
- d->size.setHeight(height);
+ d->size = size;
}
diff --git a/src/compositor/compositor_api/qwaylandoutputmode.h b/src/compositor/compositor_api/qwaylandoutputmode.h
index 7adb920e5..b03457929 100644
--- a/src/compositor/compositor_api/qwaylandoutputmode.h
+++ b/src/compositor/compositor_api/qwaylandoutputmode.h
@@ -64,10 +64,9 @@ public:
private:
class QWaylandOutputModePrivate *const d;
- friend class QWaylandOutput;
+ friend class QWaylandOutputPrivate;
- void setWidth(int width);
- void setHeight(int height);
+ void setSize(const QSize &size);
};
Q_DECLARE_TYPEINFO(QWaylandOutputMode, Q_MOVABLE_TYPE);
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index c61d84d6c..f0dc08cc2 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -1320,6 +1320,19 @@ void QWaylandQuickItem::raise()
stackAfter(top);
}
+void QWaylandQuickItem::sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat)
+{
+ if (seat == nullptr)
+ seat = compositor()->defaultSeat();
+
+ if (!seat) {
+ qWarning() << "No seat, can't send mouse event";
+ return;
+ }
+
+ seat->sendMouseMoveEvent(view(), position);
+}
+
/*!
* \internal
*
diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h
index 047fdeb65..0aa863f5f 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.h
+++ b/src/compositor/compositor_api/qwaylandquickitem.h
@@ -151,6 +151,7 @@ public Q_SLOTS:
void setPaintEnabled(bool paintEnabled);
void raise();
void lower();
+ void sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat = nullptr);
private Q_SLOTS:
void surfaceMappedChanged();
diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp
index c67e6020d..957f5ea83 100644
--- a/src/compositor/compositor_api/qwaylandseat.cpp
+++ b/src/compositor/compositor_api/qwaylandseat.cpp
@@ -440,10 +440,50 @@ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event)
return;
if (!d->keyboard.isNull() && !event->isAutoRepeat()) {
+
+ uint scanCode = event->nativeScanCode();
+ if (scanCode == 0)
+ scanCode = d->keyboard->toScanCode(event->key());
+
+ if (scanCode == 0) {
+ qWarning() << "Can't send Wayland key event: Unable to get a valid scan code";
+ return;
+ }
+
if (event->type() == QEvent::KeyPress)
- d->keyboard->sendKeyPressEvent(event->nativeScanCode());
+ d->keyboard->sendKeyPressEvent(scanCode);
else if (event->type() == QEvent::KeyRelease)
- d->keyboard->sendKeyReleaseEvent(event->nativeScanCode());
+ d->keyboard->sendKeyReleaseEvent(scanCode);
+ }
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendKeyEvent(int qtKey, bool pressed)
+ * \since 5.12
+ *
+ * Sends a key press or release to the keyboard device.
+ */
+
+/*!
+ * Sends a key press or release to the keyboard device.
+ *
+ * \since 5.12
+ */
+void QWaylandSeat::sendKeyEvent(int qtKey, bool pressed)
+{
+ Q_D(QWaylandSeat);
+ if (!keyboardFocus()) {
+ qWarning("Cannot send Wayland key event, no keyboard focus, fix the compositor");
+ return;
+ }
+
+ if (auto scanCode = d->keyboard->toScanCode(qtKey)) {
+ if (pressed)
+ d->keyboard->sendKeyPressEvent(scanCode);
+ else
+ d->keyboard->sendKeyReleaseEvent(scanCode);
+ } else {
+ qWarning() << "Can't send Wayland key event: Unable to get scan code for" << Qt::Key(qtKey);
}
}
diff --git a/src/compositor/compositor_api/qwaylandseat.h b/src/compositor/compositor_api/qwaylandseat.h
index f438b6639..6a4d6e176 100644
--- a/src/compositor/compositor_api/qwaylandseat.h
+++ b/src/compositor/compositor_api/qwaylandseat.h
@@ -97,6 +97,7 @@ public:
void sendKeyReleaseEvent(uint code);
void sendFullKeyEvent(QKeyEvent *event);
+ Q_INVOKABLE void sendKeyEvent(int qtKey, bool pressed);
uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state);
Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position);
diff --git a/src/compositor/doc/qtwaylandcompositor.qdocconf b/src/compositor/doc/qtwaylandcompositor.qdocconf
index f520c98ba..4fa9f394d 100644
--- a/src/compositor/doc/qtwaylandcompositor.qdocconf
+++ b/src/compositor/doc/qtwaylandcompositor.qdocconf
@@ -7,7 +7,7 @@ version = $QT_VERSION
qhp.projects = QtWaylandCompositor
qhp.QtWaylandCompositor.file = qtwaylandcompositor.qhp
-qhp.QtWaylandCompositor.namespace = org.qtproject.qtwaylandcompositor.$QT_VERSION_TAG
+qhp.QtWaylandCompositor.namespace = org.qt-project.qtwaylandcompositor.$QT_VERSION_TAG
qhp.QtWaylandCompositor.virtualFolder = qtwaylandcompositor
qhp.QtWaylandCompositor.indexTitle = Qt Wayland Compositor
qhp.QtWaylandCompositor.indexRoot =
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 8b36649e4..d51a75b5d 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -6,10 +6,10 @@ private_headers.CONFIG += no_check_exist
WAYLANDSERVERSOURCES += \
../extensions/touch-extension.xml \
- ../extensions/qtkey-extension.xml \
+ ../extensions/qt-key-unstable-v1.xml \
../extensions/qt-windowmanager.xml \
../3rdparty/protocol/text-input-unstable-v2.xml \
- ../3rdparty/protocol/xdg-shell.xml \
+ ../3rdparty/protocol/xdg-shell-unstable-v5.xml \
../3rdparty/protocol/xdg-shell-unstable-v6.xml \
../3rdparty/protocol/ivi-application.xml \
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
index 6b8845797..84e9c356d 100644
--- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
@@ -45,6 +45,21 @@
QT_BEGIN_NAMESPACE
+QWaylandQuickShellSurfaceItem *QWaylandQuickShellSurfaceItemPrivate::maybeCreateAutoPopup(QWaylandShellSurface* shellSurface)
+{
+ if (!m_autoCreatePopupItems)
+ return nullptr;
+
+ Q_Q(QWaylandQuickShellSurfaceItem);
+ auto *popupItem = new QWaylandQuickShellSurfaceItem(q);
+ popupItem->setShellSurface(shellSurface);
+ popupItem->setAutoCreatePopupItems(true);
+ QObject::connect(popupItem, &QWaylandQuickShellSurfaceItem::surfaceDestroyed, [popupItem](){
+ popupItem->deleteLater();
+ });
+ return popupItem;
+}
+
/*!
* \qmltype ShellSurfaceItem
* \inherits WaylandQuickItem
@@ -163,6 +178,36 @@ void QWaylandQuickShellSurfaceItem::setMoveItem(QQuickItem *moveItem)
moveItemChanged();
}
+/*!
+ * \qmlproperty bool QtWaylandCompositor::ShellSurfaceItem::autoCreatePopupItems
+ *
+ * This property holds whether ShellSurfaceItems for popups parented to the shell
+ * surface managed by this item should automatically be created.
+ */
+
+/*!
+ * \property QWaylandQuickShellSurfaceItem::autoCreatePopupItems
+ *
+ * This property holds whether QWaylandQuickShellSurfaceItems for popups
+ * parented to the shell surface managed by this item should automatically be created.
+ */
+bool QWaylandQuickShellSurfaceItem::autoCreatePopupItems()
+{
+ Q_D(const QWaylandQuickShellSurfaceItem);
+ return d->m_autoCreatePopupItems;
+}
+
+void QWaylandQuickShellSurfaceItem::setAutoCreatePopupItems(bool enabled)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+
+ if (enabled == d->m_autoCreatePopupItems)
+ return;
+
+ d->m_autoCreatePopupItems = enabled;
+ emit autoCreatePopupItemsChanged();
+}
+
void QWaylandQuickShellSurfaceItem::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QWaylandQuickShellSurfaceItem);
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h
index e2c823651..d14fa3fce 100644
--- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h
@@ -54,6 +54,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItem : public QWaylan
Q_DECLARE_PRIVATE(QWaylandQuickShellSurfaceItem)
Q_PROPERTY(QWaylandShellSurface *shellSurface READ shellSurface WRITE setShellSurface NOTIFY shellSurfaceChanged)
Q_PROPERTY(QQuickItem *moveItem READ moveItem WRITE setMoveItem NOTIFY moveItemChanged)
+ Q_PROPERTY(bool autoCreatePopupItems READ autoCreatePopupItems WRITE setAutoCreatePopupItems NOTIFY autoCreatePopupItemsChanged)
public:
QWaylandQuickShellSurfaceItem(QQuickItem *parent = nullptr);
~QWaylandQuickShellSurfaceItem() override;
@@ -64,9 +65,13 @@ public:
QQuickItem *moveItem() const;
void setMoveItem(QQuickItem *moveItem);
+ bool autoCreatePopupItems();
+ void setAutoCreatePopupItems(bool enabled);
+
Q_SIGNALS:
void shellSurfaceChanged();
void moveItemChanged();
+ void autoCreatePopupItemsChanged();
protected:
QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &dd, QQuickItem *parent);
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h
index abb56221e..7a458381e 100644
--- a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h
@@ -40,6 +40,7 @@
#ifndef QWAYLANDQUICKSHELLSURFACEITEM_P_H
#define QWAYLANDQUICKSHELLSURFACEITEM_P_H
+#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem>
#include <QtWaylandCompositor/private/qwaylandquickitem_p.h>
#include <QtCore/QBasicTimer>
@@ -60,15 +61,20 @@ QT_BEGIN_NAMESPACE
class QWaylandQuickShellIntegration;
class QWaylandShellSurface;
+class QWaylandQuickShellSurfaceItem;
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItemPrivate : public QWaylandQuickItemPrivate
{
+ Q_DECLARE_PUBLIC(QWaylandQuickShellSurfaceItem)
public:
- QWaylandQuickShellSurfaceItemPrivate()
- {}
+ QWaylandQuickShellSurfaceItemPrivate() {}
+ QWaylandQuickShellSurfaceItem *maybeCreateAutoPopup(QWaylandShellSurface* shellSurface);
+ static QWaylandQuickShellSurfaceItemPrivate *get(QWaylandQuickShellSurfaceItem *item) { return item->d_func(); }
+
QWaylandQuickShellIntegration *m_shellIntegration = nullptr;
QWaylandShellSurface *m_shellSurface = nullptr;
QQuickItem *m_moveItem = nullptr;
+ bool m_autoCreatePopupItems = false;
};
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellIntegration : public QObject
diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp
index 9e1e9dd6d..896b1587d 100644
--- a/src/compositor/extensions/qwaylandwlshellintegration.cpp
+++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp
@@ -99,6 +99,12 @@ void WlShellIntegration::handleSetDefaultTopLevel()
// so we need to unset the flags here but we save the previous state and move
// to the initial position when redrawing
nextState = State::Windowed;
+
+ // Any handlers for making maximized or fullscreen state track the size of
+ // the designated output, are unneeded now that we're going to windowed
+ // state.
+ nonwindowedState.output = nullptr;
+ disconnect(nonwindowedState.sizeChangedConnection);
}
void WlShellIntegration::handleSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive)
@@ -129,8 +135,23 @@ void WlShellIntegration::handleSetMaximized(QWaylandOutput *output)
nextState = State::Maximized;
finalPosition = designatedOutput->position() + designatedOutput->availableGeometry().topLeft();
- auto scaleFactor = m_item->view()->output()->scaleFactor();
- m_shellSurface->sendConfigure(designatedOutput->availableGeometry().size() / scaleFactor, QWaylandWlShellSurface::NoneEdge);
+ // Any prior output-resize handlers are irrelevant at this point
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = designatedOutput;
+ nonwindowedState.sizeChangedConnection = connect(designatedOutput, &QWaylandOutput::availableGeometryChanged, this, &WlShellIntegration::handleMaximizedSizeChanged);
+ handleMaximizedSizeChanged();
+}
+
+void WlShellIntegration::handleMaximizedSizeChanged()
+{
+ if (!m_shellSurface)
+ return;
+
+ if (nextState == State::Maximized) {
+ QWaylandOutput *designatedOutput = nonwindowedState.output;
+ auto scaleFactor = designatedOutput->scaleFactor();
+ m_shellSurface->sendConfigure(designatedOutput->availableGeometry().size() / scaleFactor, QWaylandWlShellSurface::NoneEdge);
+ }
}
void WlShellIntegration::handleSetFullScreen(QWaylandWlShellSurface::FullScreenMethod method, uint framerate, QWaylandOutput *output)
@@ -154,7 +175,22 @@ void WlShellIntegration::handleSetFullScreen(QWaylandWlShellSurface::FullScreenM
nextState = State::FullScreen;
finalPosition = designatedOutput->position();
- m_shellSurface->sendConfigure(designatedOutput->geometry().size(), QWaylandWlShellSurface::NoneEdge);
+ // Any prior output-resize handlers are irrelevant at this point
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = designatedOutput;
+ nonwindowedState.sizeChangedConnection = connect(designatedOutput, &QWaylandOutput::geometryChanged, this, &WlShellIntegration::handleFullScreenSizeChanged);
+ handleFullScreenSizeChanged();
+}
+
+void WlShellIntegration::handleFullScreenSizeChanged()
+{
+ if (!m_shellSurface)
+ return;
+
+ if (nextState == State::FullScreen) {
+ QWaylandOutput *designatedOutput = nonwindowedState.output;
+ m_shellSurface->sendConfigure(designatedOutput->geometry().size(), QWaylandWlShellSurface::NoneEdge);
+ }
}
void WlShellIntegration::handleSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent)
@@ -221,6 +257,11 @@ void WlShellIntegration::handleShellSurfaceDestroyed()
{
if (isPopup)
handlePopupRemoved();
+
+ // Disarm any handlers that might fire and attempt to use the now-stale pointer
+ nonwindowedState.output = nullptr;
+ disconnect(nonwindowedState.sizeChangedConnection);
+
m_shellSurface = nullptr;
}
diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h
index 68c936b1e..ff236e636 100644
--- a/src/compositor/extensions/qwaylandwlshellintegration_p.h
+++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h
@@ -80,6 +80,8 @@ private Q_SLOTS:
void handleSurfaceHasContentChanged();
void handleRedraw();
void adjustOffsetForNextFrame(const QPointF &offset);
+ void handleFullScreenSizeChanged();
+ void handleMaximizedSizeChanged();
private:
enum class GrabberState {
@@ -118,6 +120,14 @@ private:
State currentState = State::Windowed;
State nextState = State::Windowed;
+
+ struct {
+ QWaylandOutput *output = nullptr;
+ QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen,
+ // will be hooked to geometry-changed or available-
+ // geometry-changed.
+ } nonwindowedState;
+
QPointF normalPosition;
QPointF finalPosition;
};
diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp
index 6bfaf7a61..424335184 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv5.cpp
@@ -521,6 +521,8 @@ void QWaylandXdgPopupV5Private::xdg_popup_destroy(Resource *resource)
* }
* }
* \endcode
+ *
+ * \deprecated
*/
/*!
@@ -534,6 +536,8 @@ void QWaylandXdgPopupV5Private::xdg_popup_destroy(Resource *resource)
* can request that the surface is resized, moved, and so on.
*
* QWaylandXdgShellV5 corresponds to the Wayland interface \c xdg_shell.
+ *
+ * \deprecated
*/
/*!
@@ -762,6 +766,8 @@ void QWaylandXdgShellV5::handleFocusChanged(QWaylandSurface *newSurface, QWaylan
* compositors, such as resizing and moving the surface.
*
* It corresponds to the Wayland interface \c xdg_surface for the unstable xdg-shell protocol v5.
+ *
+ * \deprecated
*/
/*!
@@ -776,6 +782,8 @@ void QWaylandXdgShellV5::handleFocusChanged(QWaylandSurface *newSurface, QWaylan
* surface.
*
* It corresponds to the Wayland interface xdg_surface.
+ *
+ * \deprecated
*/
/*!
@@ -1318,6 +1326,8 @@ QWaylandQuickShellIntegration *QWaylandXdgSurfaceV5::createIntegration(QWaylandQ
* using xdg-shell.
*
* It corresponds to the Wayland interface \c xdg_popup for the unstable xdg-shell protocol v5.
+ *
+ * \deprecated
*/
/*!
@@ -1331,6 +1341,8 @@ QWaylandQuickShellIntegration *QWaylandXdgSurfaceV5::createIntegration(QWaylandQ
* specific to desktop-style menus for an xdg surface.
*
* It corresponds to the Wayland interface xdg_popup.
+ *
+ * \deprecated
*/
/*!
diff --git a/src/compositor/extensions/qwaylandxdgshellv5_p.h b/src/compositor/extensions/qwaylandxdgshellv5_p.h
index b0b51698d..032441e8d 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5_p.h
+++ b/src/compositor/extensions/qwaylandxdgshellv5_p.h
@@ -41,7 +41,7 @@
#define QWAYLANDXDGSHELLV5_P_H
#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
-#include <QtWaylandCompositor/private/qwayland-server-xdg-shell.h>
+#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v5.h>
#include <QtWaylandCompositor/QWaylandXdgShellV5>
diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
index a349a25aa..ea04a33d2 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
@@ -50,6 +50,12 @@ QT_BEGIN_NAMESPACE
namespace QtWayland {
+static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopupV5 *popup)
+{
+ if (parentItem->surface() == popup->parentSurface())
+ QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup);
+}
+
XdgShellV5Integration::XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item)
: QWaylandQuickShellIntegration(item)
, m_item(item)
@@ -66,6 +72,9 @@ XdgShellV5Integration::XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::maximizedChanged, this, &XdgShellV5Integration::handleMaximizedChanged);
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::activatedChanged, this, &XdgShellV5Integration::handleActivatedChanged);
connect(m_xdgSurface->surface(), &QWaylandSurface::sizeChanged, this, &XdgShellV5Integration::handleSurfaceSizeChanged);
+ connect(m_xdgSurface->shell(), &QWaylandXdgShellV5::xdgPopupCreated, this, [item](QWaylandXdgPopupV5 *popup){
+ handlePopupCreated(item, popup);
+ });
}
XdgShellV5Integration::~XdgShellV5Integration()
@@ -213,6 +222,9 @@ XdgPopupV5Integration::XdgPopupV5Integration(QWaylandQuickShellSurfaceItem *item
QWaylandQuickShellEventFilter::startFilter(client, [shell]() { shell->closeAllPopups(); });
connect(m_xdgPopup, &QWaylandXdgPopupV5::destroyed, this, &XdgPopupV5Integration::handlePopupDestroyed);
+ connect(m_xdgPopup->shell(), &QWaylandXdgShellV5::xdgPopupCreated, this, [item](QWaylandXdgPopupV5 *popup) {
+ handlePopupCreated(item, popup);
+ });
}
XdgPopupV5Integration::~XdgPopupV5Integration()
diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp
index 0c2159e18..8cde4668e 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv6.cpp
@@ -1054,6 +1054,8 @@ uint QWaylandXdgToplevelV6::sendUnmaximized(const QSize &size)
* Convenience for sending a configure event with the fullscreen state set, and
* maximized and resizing removed. The activated state is left in its current state.
*
+ * \sa sendUnmaximized
+ *
* \a size is the new size of the window.
*/
@@ -1061,6 +1063,8 @@ uint QWaylandXdgToplevelV6::sendUnmaximized(const QSize &size)
* Convenience for sending a configure event with the fullscreen state set, and
* maximized and resizing removed. The activated state is left in its current state.
*
+ * \sa sendUnmaximized
+ *
* \a size is the new size of the window.
*/
uint QWaylandXdgToplevelV6::sendFullscreen(const QSize &size)
diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp
index 17ee10db7..a37ee2a3c 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp
@@ -44,6 +44,12 @@ QT_BEGIN_NAMESPACE
namespace QtWayland {
+static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopupV6 *popup)
+{
+ if (parentItem->shellSurface() == popup->parentXdgSurface())
+ QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup->xdgSurface());
+}
+
XdgToplevelV6Integration::XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem *item)
: QWaylandQuickShellIntegration(item)
, m_item(item)
@@ -54,13 +60,21 @@ XdgToplevelV6Integration::XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem
Q_ASSERT(m_toplevel);
m_item->setSurface(m_xdgSurface->surface());
+
connect(m_toplevel, &QWaylandXdgToplevelV6::startMove, this, &XdgToplevelV6Integration::handleStartMove);
connect(m_toplevel, &QWaylandXdgToplevelV6::startResize, this, &XdgToplevelV6Integration::handleStartResize);
connect(m_toplevel, &QWaylandXdgToplevelV6::setMaximized, this, &XdgToplevelV6Integration::handleSetMaximized);
connect(m_toplevel, &QWaylandXdgToplevelV6::unsetMaximized, this, &XdgToplevelV6Integration::handleUnsetMaximized);
connect(m_toplevel, &QWaylandXdgToplevelV6::maximizedChanged, this, &XdgToplevelV6Integration::handleMaximizedChanged);
+ connect(m_toplevel, &QWaylandXdgToplevelV6::setFullscreen, this, &XdgToplevelV6Integration::handleSetFullscreen);
+ connect(m_toplevel, &QWaylandXdgToplevelV6::unsetFullscreen, this, &XdgToplevelV6Integration::handleUnsetFullscreen);
+ connect(m_toplevel, &QWaylandXdgToplevelV6::fullscreenChanged, this, &XdgToplevelV6Integration::handleFullscreenChanged);
connect(m_toplevel, &QWaylandXdgToplevelV6::activatedChanged, this, &XdgToplevelV6Integration::handleActivatedChanged);
+ connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){
+ handlePopupCreated(item, popup);
+ });
connect(m_xdgSurface->surface(), &QWaylandSurface::sizeChanged, this, &XdgToplevelV6Integration::handleSurfaceSizeChanged);
+ connect(m_toplevel, &QObject::destroyed, this, &XdgToplevelV6Integration::handleToplevelDestroyed);
}
bool XdgToplevelV6Integration::mouseMoveEvent(QMouseEvent *event)
@@ -125,11 +139,28 @@ void XdgToplevelV6Integration::handleSetMaximized()
if (!m_item->view()->isPrimary())
return;
- maximizeState.initialWindowSize = m_xdgSurface->windowGeometry().size();
- maximizeState.initialPosition = m_item->moveItem()->position();
+ QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states();
+
+ if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) {
+ windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size();
+ windowedGeometry.initialPosition = m_item->moveItem()->position();
+ }
+
+ // Any prior output-resize handlers are irrelevant at this point.
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = m_item->view()->output();
+ nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::availableGeometryChanged, this, &XdgToplevelV6Integration::handleMaximizedSizeChanged);
+ handleMaximizedSizeChanged();
+}
+
+void XdgToplevelV6Integration::handleMaximizedSizeChanged()
+{
+ // Insurance against handleToplevelDestroyed() not managing to disconnect this
+ // handler in time.
+ if (m_toplevel == nullptr)
+ return;
- QWaylandOutput *output = m_item->view()->output();
- m_toplevel->sendMaximized(output->availableGeometry().size() / output->scaleFactor());
+ m_toplevel->sendMaximized(nonwindowedState.output->availableGeometry().size() / nonwindowedState.output->scaleFactor());
}
void XdgToplevelV6Integration::handleUnsetMaximized()
@@ -137,7 +168,12 @@ void XdgToplevelV6Integration::handleUnsetMaximized()
if (!m_item->view()->isPrimary())
return;
- m_toplevel->sendUnmaximized(maximizeState.initialWindowSize);
+ // If no prior windowed size was recorded, send a 0x0 configure event
+ // to allow the client to choose its preferred size.
+ if (windowedGeometry.initialWindowSize.isValid())
+ m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize);
+ else
+ m_toplevel->sendUnmaximized();
}
void XdgToplevelV6Integration::handleMaximizedChanged()
@@ -146,7 +182,59 @@ void XdgToplevelV6Integration::handleMaximizedChanged()
QWaylandOutput *output = m_item->view()->output();
m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft());
} else {
- m_item->moveItem()->setPosition(maximizeState.initialPosition);
+ m_item->moveItem()->setPosition(windowedGeometry.initialPosition);
+ }
+}
+
+void XdgToplevelV6Integration::handleSetFullscreen()
+{
+ if (!m_item->view()->isPrimary())
+ return;
+
+ QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states();
+
+ if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) {
+ windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size();
+ windowedGeometry.initialPosition = m_item->moveItem()->position();
+ }
+
+ // Any prior output-resize handlers are irrelevant at this point.
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = m_item->view()->output();
+ nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::geometryChanged, this, &XdgToplevelV6Integration::handleFullscreenSizeChanged);
+ handleFullscreenSizeChanged();
+}
+
+void XdgToplevelV6Integration::handleFullscreenSizeChanged()
+{
+ // Insurance against handleToplevelDestroyed() not managing to disconnect this
+ // handler in time.
+ if (m_toplevel == nullptr)
+ return;
+
+ m_toplevel->sendFullscreen(nonwindowedState.output->geometry().size() / nonwindowedState.output->scaleFactor());
+}
+
+void XdgToplevelV6Integration::handleUnsetFullscreen()
+{
+ if (!m_item->view()->isPrimary())
+ return;
+
+ // If no prior windowed size was recorded, send a 0x0 configure event
+ // to allow the client to choose its preferred size.
+ if (windowedGeometry.initialWindowSize.isValid())
+ m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize);
+ else
+ m_toplevel->sendUnmaximized();
+}
+
+void XdgToplevelV6Integration::handleFullscreenChanged()
+{
+ if (m_toplevel->fullscreen()) {
+ QWaylandOutput *output = m_item->view()->output();
+ m_item->moveItem()->setPosition(output->position() + output->geometry().topLeft());
+ } else {
+ m_item->moveItem()->setPosition(windowedGeometry.initialPosition);
}
}
@@ -170,6 +258,13 @@ void XdgToplevelV6Integration::handleSurfaceSizeChanged()
}
}
+void XdgToplevelV6Integration::handleToplevelDestroyed()
+{
+ // Disarm any handlers that might fire on the now-stale toplevel pointer
+ nonwindowedState.output = nullptr;
+ disconnect(nonwindowedState.sizeChangedConnection);
+}
+
XdgPopupV6Integration::XdgPopupV6Integration(QWaylandQuickShellSurfaceItem *item)
: m_item(item)
, m_xdgSurface(qobject_cast<QWaylandXdgSurfaceV6 *>(item->shellSurface()))
@@ -181,6 +276,9 @@ XdgPopupV6Integration::XdgPopupV6Integration(QWaylandQuickShellSurfaceItem *item
handleGeometryChanged();
connect(m_popup, &QWaylandXdgPopupV6::configuredGeometryChanged, this, &XdgPopupV6Integration::handleGeometryChanged);
+ connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){
+ handlePopupCreated(item, popup);
+ });
}
void XdgPopupV6Integration::handleGeometryChanged()
diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h
index 4ccabfa98..5b56af89b 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h
+++ b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h
@@ -72,8 +72,14 @@ private Q_SLOTS:
void handleSetMaximized();
void handleUnsetMaximized();
void handleMaximizedChanged();
+ void handleSetFullscreen();
+ void handleUnsetFullscreen();
+ void handleFullscreenChanged();
void handleActivatedChanged();
void handleSurfaceSizeChanged();
+ void handleToplevelDestroyed();
+ void handleMaximizedSizeChanged();
+ void handleFullscreenSizeChanged();
private:
QWaylandQuickShellSurfaceItem *m_item = nullptr;
@@ -106,7 +112,14 @@ private:
struct {
QSize initialWindowSize;
QPointF initialPosition;
- } maximizeState;
+ } windowedGeometry;
+
+ struct {
+ QWaylandOutput *output = nullptr;
+ QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen,
+ // will be hooked to geometry-changed or available-
+ // geometry-changed.
+ } nonwindowedState;
};
class XdgPopupV6Integration : public QWaylandQuickShellIntegration
diff --git a/src/compositor/extensions/qwlqtkey.cpp b/src/compositor/extensions/qwlqtkey.cpp
index 73d06ae6b..94a2b5a77 100644
--- a/src/compositor/extensions/qwlqtkey.cpp
+++ b/src/compositor/extensions/qwlqtkey.cpp
@@ -48,7 +48,7 @@ namespace QtWayland {
QtKeyExtensionGlobal::QtKeyExtensionGlobal(QWaylandCompositor *compositor)
: QWaylandCompositorExtensionTemplate(compositor)
- , QtWaylandServer::qt_key_extension(compositor->display(), 2)
+ , QtWaylandServer::zqt_key_v1(compositor->display(), 1)
, m_compositor(compositor)
{
}
@@ -60,15 +60,15 @@ bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, QWaylandSurface *sur
Resource *target = surface ? resourceMap().value(surface->waylandClient()) : 0;
if (target) {
- send_qtkey(target->handle,
- surface ? surface->resource() : nullptr,
- time, event->type(), event->key(), event->modifiers(),
- event->nativeScanCode(),
- event->nativeVirtualKey(),
- event->nativeModifiers(),
- event->text(),
- event->isAutoRepeat(),
- event->count());
+ send_key(target->handle,
+ surface ? surface->resource() : nullptr,
+ time, event->type(), event->key(), event->modifiers(),
+ event->nativeScanCode(),
+ event->nativeVirtualKey(),
+ event->nativeModifiers(),
+ event->text(),
+ event->isAutoRepeat(),
+ event->count());
return true;
}
diff --git a/src/compositor/extensions/qwlqtkey_p.h b/src/compositor/extensions/qwlqtkey_p.h
index d3f573757..4944829ef 100644
--- a/src/compositor/extensions/qwlqtkey_p.h
+++ b/src/compositor/extensions/qwlqtkey_p.h
@@ -53,7 +53,7 @@
#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate>
#include <QtWaylandCompositor/QWaylandCompositor>
-#include <QtWaylandCompositor/private/qwayland-server-qtkey-extension.h>
+#include <QtWaylandCompositor/private/qwayland-server-qt-key-unstable-v1.h>
#include <wayland-util.h>
@@ -64,7 +64,7 @@ class QKeyEvent;
namespace QtWayland {
-class QtKeyExtensionGlobal : public QWaylandCompositorExtensionTemplate<QtKeyExtensionGlobal>, public QtWaylandServer::qt_key_extension
+class QtKeyExtensionGlobal : public QWaylandCompositorExtensionTemplate<QtKeyExtensionGlobal>, public QtWaylandServer::zqt_key_v1
{
Q_OBJECT
public:
diff --git a/src/compositor/global/qwaylandquickextension.h b/src/compositor/global/qwaylandquickextension.h
index c721bcb97..a0e07dad3 100644
--- a/src/compositor/global/qwaylandquickextension.h
+++ b/src/compositor/global/qwaylandquickextension.h
@@ -107,6 +107,42 @@ QT_BEGIN_NAMESPACE
QList<QObject *> m_objects; \
};
+#define Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(className) \
+ class Q_WAYLAND_COMPOSITOR_EXPORT className##QuickParent : public className \
+ { \
+/* qmake ignore Q_OBJECT */ \
+ Q_OBJECT \
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \
+ Q_CLASSINFO("DefaultProperty", "data") \
+ public: \
+ QQmlListProperty<QObject> data() \
+ { \
+ return QQmlListProperty<QObject>(this, this, \
+ &className##QuickParent::appendFunction, \
+ &className##QuickParent::countFunction, \
+ &className##QuickParent::atFunction, \
+ &className##QuickParent::clearFunction); \
+ } \
+ static void appendFunction(QQmlListProperty<QObject> *list, QObject *object) \
+ { \
+ static_cast<className##QuickParent *>(list->data)->m_children.append(object); \
+ } \
+ static int countFunction(QQmlListProperty<QObject> *list) \
+ { \
+ return static_cast<className##QuickParent *>(list->data)->m_children.size(); \
+ } \
+ static QObject *atFunction(QQmlListProperty<QObject> *list, int index) \
+ { \
+ return static_cast<className##QuickParent *>(list->data)->m_children.at(index); \
+ } \
+ static void clearFunction(QQmlListProperty<QObject> *list) \
+ { \
+ static_cast<className##QuickParent *>(list->data)->m_children.clear(); \
+ } \
+ private: \
+ QVector<QObject *> m_children; \
+ };
+
QT_END_NAMESPACE
#endif /*QWAYLANDQUICKEXTENSION_H*/
diff --git a/src/extensions/README.md b/src/extensions/README.md
new file mode 100644
index 000000000..f75e0f236
--- /dev/null
+++ b/src/extensions/README.md
@@ -0,0 +1,18 @@
+# Internal Qt protocol extensions
+
+The protocol extensions in this folder are considered implementation details of
+Qt. I.e. they may removed, renamed or changed without warning.
+
+## Suffixed protocols
+
+For protocols that have a version suffix, however, we will strive to not break
+backwards compatibility without bumping the suffix (renaming the protocol).
+E.g.: If your client sees a `zqt_key_v1` global, it can safely bind to it:
+the key event will always take the same number of arguments, regardless of
+compositor version.
+
+This is important also within a Qt-only scope if there are multiple versions of
+Qt on the system. Consider for instance an application statically linked to Qt
+(such as Qt Creator) running against a Qt compositor installed by the distro).
+In such cases we don't want the compositor and client to disagree on the
+protocol definition.
diff --git a/src/extensions/qtkey-extension.xml b/src/extensions/qt-key-unstable-v1.xml
index 34cf24797..0f8d8284c 100644
--- a/src/extensions/qtkey-extension.xml
+++ b/src/extensions/qt-key-unstable-v1.xml
@@ -1,7 +1,7 @@
-<protocol name="qtkey_extension">
+<protocol name="qt_key_unstable_v1">
<copyright>
- Copyright (C) 2015 The Qt Company Ltd.
+ Copyright (C) 2018 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
This file is part of the plugins of the Qt Toolkit.
@@ -38,26 +38,36 @@
$QT_END_LICENSE$
</copyright>
- <interface name="qt_key_extension" version="2">
- <event name="qtkey">
- <description summary="qtkey event">
- Serialized QKeyEvent
- </description>
-
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="time" type="uint"/>
- <arg name="type" type="uint"/>
- <arg name="key" type="uint"/>
- <arg name="modifiers" type="uint"/>
- <arg name="nativeScanCode" type="uint"/>
- <arg name="nativeVirtualKey" type="uint"/>
- <arg name="nativeModifiers" type="uint"/>
- <arg name="text" type="string"/>
- <arg name="autorepeat" type="uint"/>
- <arg name="count" type="uint"/>
- </event>
+ <interface name="zqt_key_v1" version="1">
+ <description summary="send serialized QKeyEvents">
+ This protocol is independent of the Wayland seat concept. Its
+ intention is to let a QKeyEvent be transferred from a Qt compositor
+ to a Qt client without losing or adding false information by going
+ through wl_seat and wl_keyboard.
- <request name="dummy">
- </request>
+ Note: This protocol is considered private to Qt. We will do our
+ best to bump version numbers when we make backwards compatible
+ changes, bump the protocol name and interface suffixes when we make
+ backwards incompatible changes, but we provide no guarantees. We
+ may also remove the protocol without warning. Implement this at
+ your own risk.
+ </description>
+ <event name="key">
+ <description summary="send key event">
+ The key event notifies the client that a QKeyEvent has occurred on
+ the server side.
+ </description>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="time" type="uint"/>
+ <arg name="type" type="uint"/>
+ <arg name="key" type="uint"/>
+ <arg name="modifiers" type="uint"/>
+ <arg name="nativeScanCode" type="uint"/>
+ <arg name="nativeVirtualKey" type="uint"/>
+ <arg name="nativeModifiers" type="uint"/>
+ <arg name="text" type="string"/>
+ <arg name="autorepeat" type="uint"/>
+ <arg name="count" type="uint"/>
+ </event>
</interface>
</protocol>
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp
index 4478b9fdf..cd0f285cd 100644
--- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp
@@ -124,6 +124,33 @@ EGLDisplay QWaylandBrcmEglIntegration::eglDisplay() const
return m_eglDisplay;
}
+void *QWaylandBrcmEglIntegration::nativeResource(NativeResource resource)
+{
+ switch (resource) {
+ case EglDisplay:
+ return m_eglDisplay;
+ default:
+ break;
+ }
+ return nullptr;
+}
+
+void *QWaylandBrcmEglIntegration::nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ switch (resource) {
+ case EglConfig:
+ return static_cast<QWaylandBrcmGLContext *>(context)->eglConfig();
+ case EglContext:
+ return static_cast<QWaylandBrcmGLContext *>(context)->eglContext();
+ case EglDisplay:
+ return m_eglDisplay;
+ default:
+ break;
+ }
+ return nullptr;
+}
+
}
QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h
index 651400d87..5e8a3bf46 100644
--- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h
@@ -82,6 +82,9 @@ public:
PFNEGLCREATEGLOBALIMAGEBRCMPROC eglCreateGlobalImageBRCM;
PFNEGLDESTROYGLOBALIMAGEBRCMPROC eglDestroyGlobalImageBRCM;
+ void *nativeResource(NativeResource resource) override;
+ void *nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context) override;
+
private:
static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version);
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
index 3b9001475..3009f9d63 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
@@ -62,7 +62,7 @@ QWaylandEglWindow::QWaylandEglWindow(QWindow *window)
if (mDisplay->supportsWindowDecoration())
fmt.setAlphaBufferSize(8);
m_eglConfig = q_configFromGLFormat(m_clientBufferIntegration->eglDisplay(), fmt);
- m_format = q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(), m_eglConfig);
+ m_format = q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(), m_eglConfig, fmt);
// Do not create anything from here. This platform window may belong to a
// RasterGLSurface window which may have pure raster content. In this case, where the
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
index 6e48659da..8b0fb638e 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
@@ -234,7 +234,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis
if (static_cast<QWaylandIntegration *>(QGuiApplicationPrivate::platformIntegration())->display()->supportsWindowDecoration())
fmt.setAlphaBufferSize(8);
m_config = q_configFromGLFormat(m_eglDisplay, fmt);
- m_format = q_glFormatFromConfig(m_eglDisplay, m_config);
+ m_format = q_glFormatFromConfig(m_eglDisplay, m_config, fmt);
m_shareEGLContext = share ? static_cast<QWaylandGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
QVector<EGLint> eglContextAttrs;
diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
index e877f6927..9f3bf5d43 100644
--- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp
+++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
@@ -72,11 +72,19 @@
QT_BEGIN_NAMESPACE
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS(QWaylandQuickCompositor)
+Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(QWaylandQuickOutput)
+Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(QWaylandQuickSurface)
+Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(QWaylandKeymap)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandQtWindowManager)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandIviApplication)
+Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(QWaylandIviSurface)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandWlShell)
+Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(QWaylandWlShellSurface)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgShellV5)
+Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(QWaylandXdgSurfaceV5)
+Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(QWaylandXdgPopupV5)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgShellV6)
+Q_COMPOSITOR_DECLARE_QUICK_PARENT_CLASS(QWaylandXdgSurfaceV6)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandTextInputManager)
class QmlUrlResolver
@@ -128,9 +136,9 @@ public:
qmlRegisterType<QWaylandQuickItem>(uri, 1, 0, "WaylandQuickItem");
qmlRegisterType<QWaylandQuickHardwareLayer>(uri, 1, 2, "WaylandHardwareLayer");
qmlRegisterType<QWaylandMouseTracker>(uri, 1, 0, "WaylandMouseTracker");
- qmlRegisterType<QWaylandQuickOutput>(uri, 1, 0, "WaylandOutput");
- qmlRegisterType<QWaylandQuickSurface>(uri, 1, 0, "WaylandSurface");
- qmlRegisterType<QWaylandKeymap>(uri, 1, 0, "WaylandKeymap");
+ qmlRegisterType<QWaylandQuickOutputQuickParent>(uri, 1, 0, "WaylandOutput");
+ qmlRegisterType<QWaylandQuickSurfaceQuickParent>(uri, 1, 0, "WaylandSurface");
+ qmlRegisterType<QWaylandKeymapQuickParent>(uri, 1, 0, "WaylandKeymap");
qmlRegisterUncreatableType<QWaylandCompositorExtension>(uri, 1, 0, "WaylandExtension", QObject::tr("Cannot create instance of WaylandExtension"));
qmlRegisterUncreatableType<QWaylandClient>(uri, 1, 0, "WaylandClient", QObject::tr("Cannot create instance of WaylandClient"));
@@ -148,18 +156,18 @@ public:
//This should probably be somewhere else
qmlRegisterType<QWaylandQtWindowManagerQuickExtension>(uri, 1, 0, "QtWindowManager");
qmlRegisterType<QWaylandIviApplicationQuickExtension>(uri, 1, 0, "IviApplication");
- qmlRegisterType<QWaylandIviSurface>(uri, 1, 0, "IviSurface");
+ qmlRegisterType<QWaylandIviSurfaceQuickParent>(uri, 1, 0, "IviSurface");
qmlRegisterType<QWaylandWlShellQuickExtension>(uri, 1, 0, "WlShell");
- qmlRegisterType<QWaylandWlShellSurface>(uri, 1, 0, "WlShellSurface");
+ qmlRegisterType<QWaylandWlShellSurfaceQuickParent>(uri, 1, 0, "WlShellSurface");
qmlRegisterType<QWaylandQuickShellSurfaceItem>(uri, 1, 0, "ShellSurfaceItem");
qmlRegisterUncreatableType<QWaylandXdgShellV5>(uri, 1, 0, "XdgShellV5Base", QObject::tr("Cannot create instance of XdgShellV5Base"));
qmlRegisterType<QWaylandXdgShellV5QuickExtension>(uri, 1, 0, "XdgShellV5");
- qmlRegisterType<QWaylandXdgSurfaceV5>(uri, 1, 0, "XdgSurfaceV5");
- qmlRegisterType<QWaylandXdgPopupV5>(uri, 1, 0, "XdgPopupV5");
+ qmlRegisterType<QWaylandXdgSurfaceV5QuickParent>(uri, 1, 0, "XdgSurfaceV5");
+ qmlRegisterType<QWaylandXdgPopupV5QuickParent>(uri, 1, 0, "XdgPopupV5");
qmlRegisterType<QWaylandTextInputManagerQuickExtension>(uri, 1, 0, "TextInputManager");
qmlRegisterType<QWaylandXdgShellV6QuickExtension>(uri, 1, 1, "XdgShellV6");
- qmlRegisterType<QWaylandXdgSurfaceV6>(uri, 1, 1, "XdgSurfaceV6");
+ qmlRegisterType<QWaylandXdgSurfaceV6QuickParent>(uri, 1, 1, "XdgSurfaceV6");
qmlRegisterUncreatableType<QWaylandXdgToplevelV6>(uri, 1, 1, "XdgToplevelV6", QObject::tr("Cannot create instance of XdgShellToplevelV6"));
qmlRegisterUncreatableType<QWaylandXdgPopupV6>(uri, 1, 1, "XdgPopupV6", QObject::tr("Cannot create instance of XdgShellPopupV6"));
}
diff --git a/src/plugins/decorations/bradient/main.cpp b/src/plugins/decorations/bradient/main.cpp
index 9a7e91e6f..1df3ac62b 100644
--- a/src/plugins/decorations/bradient/main.cpp
+++ b/src/plugins/decorations/bradient/main.cpp
@@ -55,72 +55,8 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
#define BUTTON_SPACING 5
-
-#if QT_CONFIG(imageformat_xpm)
-# define BUTTON_WIDTH 10
-
-static const char * const qt_close_xpm[] = {
-"10 10 2 1",
-"# c #000000",
-". c None",
-"..........",
-".##....##.",
-"..##..##..",
-"...####...",
-"....##....",
-"...####...",
-"..##..##..",
-".##....##.",
-"..........",
-".........."};
-
-static const char * const qt_maximize_xpm[]={
-"10 10 2 1",
-"# c #000000",
-". c None",
-"#########.",
-"#########.",
-"#.......#.",
-"#.......#.",
-"#.......#.",
-"#.......#.",
-"#.......#.",
-"#.......#.",
-"#########.",
-".........."};
-
-static const char * const qt_minimize_xpm[] = {
-"10 10 2 1",
-"# c #000000",
-". c None",
-"..........",
-"..........",
-"..........",
-"..........",
-"..........",
-"..........",
-"..........",
-".#######..",
-".#######..",
-".........."};
-
-static const char * const qt_normalizeup_xpm[] = {
-"10 10 2 1",
-"# c #000000",
-". c None",
-"...######.",
-"...######.",
-"...#....#.",
-".######.#.",
-".######.#.",
-".#....###.",
-".#....#...",
-".#....#...",
-".######...",
-".........."};
-#else
-# define BUTTON_WIDTH 22
-#endif
+#define BUTTON_WIDTH 18
+#define BUTTONS_RIGHT_MARGIN 8
enum Button
{
@@ -151,6 +87,7 @@ private:
QRectF minimizeButtonRect() const;
QColor m_foregroundColor;
+ QColor m_foregroundInactiveColor;
QColor m_backgroundColor;
QStaticText m_windowTitle;
Button m_clicking = None;
@@ -161,8 +98,9 @@ private:
QWaylandBradientDecoration::QWaylandBradientDecoration()
{
QPalette palette;
- m_foregroundColor = palette.color(QPalette::Active, QPalette::HighlightedText);
- m_backgroundColor = palette.color(QPalette::Active, QPalette::Highlight);
+ m_foregroundColor = palette.color(QPalette::Active, QPalette::WindowText);
+ m_backgroundColor = palette.color(QPalette::Active, QPalette::Window);
+ m_foregroundInactiveColor = palette.color(QPalette::Disabled, QPalette::WindowText);
QTextOption option(Qt::AlignHCenter | Qt::AlignVCenter);
option.setWrapMode(QTextOption::NoWrap);
@@ -171,19 +109,19 @@ QWaylandBradientDecoration::QWaylandBradientDecoration()
QRectF QWaylandBradientDecoration::closeButtonRect() const
{
- return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH - BUTTON_SPACING * 2,
+ return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH - BUTTON_SPACING * 0 - BUTTONS_RIGHT_MARGIN,
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
QRectF QWaylandBradientDecoration::maximizeButtonRect() const
{
- return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 2 - BUTTON_SPACING * 3,
+ return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 2 - BUTTON_SPACING * 1 - BUTTONS_RIGHT_MARGIN,
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
QRectF QWaylandBradientDecoration::minimizeButtonRect() const
{
- return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 3 - BUTTON_SPACING * 4,
+ return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 3 - BUTTON_SPACING * 2 - BUTTONS_RIGHT_MARGIN,
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
@@ -209,16 +147,12 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
p.setRenderHint(QPainter::Antialiasing);
// Title bar
- QLinearGradient grad(top.topLeft(), top.bottomLeft());
- QColor base(m_backgroundColor);
- grad.setColorAt(0, base.lighter(100));
- grad.setColorAt(1, base.darker(180));
QPainterPath roundedRect;
- roundedRect.addRoundedRect(surfaceRect, 6, 6);
+ roundedRect.addRoundedRect(surfaceRect, 3, 3);
for (int i = 0; i < 4; ++i) {
p.save();
p.setClipRect(clips[i]);
- p.fillPath(roundedRect, grad);
+ p.fillPath(roundedRect, m_backgroundColor);
p.restore();
}
@@ -249,12 +183,12 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
p.save();
p.setClipRect(titleBar);
- p.setPen(m_foregroundColor);
+ p.setPen(window()->isActive() ? m_foregroundColor : m_foregroundInactiveColor);
QSizeF size = m_windowTitle.size();
int dx = (top.width() - size.width()) /2;
int dy = (top.height()- size.height()) /2;
QFont font = p.font();
- font.setBold(true);
+ font.setPixelSize(14);
p.setFont(font);
QPoint windowTitlePoint(top.topLeft().x() + dx,
top.topLeft().y() + dy);
@@ -262,38 +196,16 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
p.restore();
}
-#if QT_CONFIG(imageformat_xpm)
- p.save();
-
- // Close button
- QPixmap closePixmap(qt_close_xpm);
- p.drawPixmap(closeButtonRect(), closePixmap, closePixmap.rect());
-
- // Maximize button
- QPixmap maximizePixmap(waylandWindow()->isMaximized()
- ? qt_normalizeup_xpm : qt_maximize_xpm);
- p.drawPixmap(maximizeButtonRect(), maximizePixmap, maximizePixmap.rect());
-
- // Minimize button
- QPixmap minimizePixmap(qt_minimize_xpm);
- p.drawPixmap(minimizeButtonRect(), minimizePixmap, minimizePixmap.rect());
-
- p.restore();
-#else
- // We don't need antialiasing from now on
- p.setRenderHint(QPainter::Antialiasing, false);
-
QRectF rect;
// Default pen
- QPen pen(m_foregroundColor);
+ QPen pen(window()->isActive() ? m_foregroundColor : m_foregroundInactiveColor);
p.setPen(pen);
// Close button
p.save();
rect = closeButtonRect();
- p.drawRect(rect);
- qreal crossSize = rect.height() / 2;
+ qreal crossSize = rect.height() / 2.3;
QPointF crossCenter(rect.center());
QRectF crossRect(crossCenter.x() - crossSize / 2, crossCenter.y() - crossSize / 2, crossSize, crossSize);
pen.setWidth(2);
@@ -304,15 +216,16 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
// Maximize button
p.save();
- p.drawRect(maximizeButtonRect());
- rect = maximizeButtonRect().adjusted(5, 5, -5, -5);
- if (waylandWindow()->isMaximized()) {
- QRectF rect1 = rect.adjusted(rect.width() / 3, 0, 0, -rect.height() / 3);
- QRectF rect2 = rect.adjusted(0, rect.height() / 4, -rect.width() / 4, 0);
+ p.setRenderHint(QPainter::Antialiasing, false);
+ rect = maximizeButtonRect().adjusted(4, 5, -4, -5);
+ if ((window()->windowStates() & Qt::WindowMaximized)) {
+ qreal inset = 2;
+ QRectF rect1 = rect.adjusted(inset, 0, 0, -inset);
+ QRectF rect2 = rect.adjusted(0, inset, -inset, 0);
p.drawRect(rect1);
+ p.setBrush(m_backgroundColor); // need to cover up some lines from the other rect
p.drawRect(rect2);
} else {
- p.setPen(m_foregroundColor);
p.drawRect(rect);
p.drawLine(rect.left(), rect.top() + 1, rect.right(), rect.top() + 1);
}
@@ -320,13 +233,12 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
// Minimize button
p.save();
- p.drawRect(minimizeButtonRect());
+ p.setRenderHint(QPainter::Antialiasing, false);
rect = minimizeButtonRect().adjusted(5, 5, -5, -5);
pen.setWidth(2);
p.setPen(pen);
p.drawLine(rect.bottomLeft(), rect.bottomRight());
p.restore();
-#endif
}
bool QWaylandBradientDecoration::clickButton(Qt::MouseButtons b, Button btn)
@@ -351,16 +263,7 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c
Q_UNUSED(global);
// Figure out what area mouse is in
- if (closeButtonRect().contains(local)) {
- if (clickButton(b, Close))
- QWindowSystemInterface::handleCloseEvent(window());
- } else if (maximizeButtonRect().contains(local)) {
- if (clickButton(b, Maximize))
- window()->setWindowState(waylandWindow()->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
- } else if (minimizeButtonRect().contains(local)) {
- if (clickButton(b, Minimize))
- window()->setWindowState(Qt::WindowMinimized);
- } else if (local.y() <= margins().top()) {
+ if (local.y() <= margins().top()) {
processMouseTop(inputDevice,local,b,mods);
} else if (local.y() > window()->height() + margins().top()) {
processMouseBottom(inputDevice,local,b,mods);
@@ -390,7 +293,7 @@ bool QWaylandBradientDecoration::handleTouch(QWaylandInputDevice *inputDevice, c
if (closeButtonRect().contains(local))
QWindowSystemInterface::handleCloseEvent(window());
else if (maximizeButtonRect().contains(local))
- window()->setWindowState(waylandWindow()->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
+ window()->setWindowStates(window()->windowStates() ^ Qt::WindowMaximized);
else if (minimizeButtonRect().contains(local))
window()->setWindowState(Qt::WindowMinimized);
else if (local.y() <= margins().top())
@@ -419,19 +322,31 @@ void QWaylandBradientDecoration::processMouseTop(QWaylandInputDevice *inputDevic
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP_RIGHT,b);
} else {
- //top reszie bit
+ //top resize bit
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP,b);
}
+ } else if (local.x() <= margins().left()) {
+ processMouseLeft(inputDevice, local, b, mods);
+ } else if (local.x() > window()->width() + margins().left()) {
+ processMouseRight(inputDevice, local, b, mods);
+ } else if (closeButtonRect().contains(local)) {
+ if (clickButton(b, Close))
+ QWindowSystemInterface::handleCloseEvent(window());
+ } else if (maximizeButtonRect().contains(local)) {
+ if (clickButton(b, Maximize))
+ window()->setWindowStates(window()->windowStates() ^ Qt::WindowMaximized);
+ } else if (minimizeButtonRect().contains(local)) {
+ if (clickButton(b, Minimize))
+ window()->setWindowState(Qt::WindowMinimized);
} else {
#if QT_CONFIG(cursor)
waylandWindow()->restoreMouseCursor(inputDevice);
#endif
startMove(inputDevice,b);
}
-
}
void QWaylandBradientDecoration::processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
index 14074625a..efb61dc9f 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
@@ -58,18 +58,21 @@ QWaylandIviShellIntegration::QWaylandIviShellIntegration()
{
}
-QWaylandIviShellIntegration::~QWaylandIviShellIntegration()
-{
- delete m_iviApplication;
- delete m_iviController;
-}
-
bool QWaylandIviShellIntegration::initialize(QWaylandDisplay *display)
{
- QWaylandShellIntegration::initialize(display);
- display->addRegistryListener(registryIvi, this);
+ for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
+ if (global.interface == QLatin1String("ivi_application") && !m_iviApplication)
+ m_iviApplication.reset(new QtWayland::ivi_application(display->wl_registry(), global.id, global.version));
+ if (global.interface == QLatin1String("ivi_controller") && !m_iviController)
+ m_iviController.reset(new QtWayland::ivi_controller(display->wl_registry(), global.id, global.version));
+ }
+
+ if (!m_iviApplication) {
+ qCDebug(lcQpaWayland) << "Couldn't find global ivi_application for ivi-shell";
+ return false;
+ }
- return true;
+ return QWaylandShellIntegration::initialize(display);
}
/* get unique id
@@ -154,21 +157,6 @@ QWaylandShellSurface *QWaylandIviShellIntegration::createShellSurface(QWaylandWi
return iviSurface;
}
-void QWaylandIviShellIntegration::registryIvi(void *data,
- struct wl_registry *registry,
- uint32_t id,
- const QString &interface,
- uint32_t version)
-{
- QWaylandIviShellIntegration *shell = static_cast<QWaylandIviShellIntegration *>(data);
-
- if (interface == QStringLiteral("ivi_application"))
- shell->m_iviApplication = new QtWayland::ivi_application(registry, id, version);
-
- if (interface == QStringLiteral("ivi_controller"))
- shell->m_iviController = new QtWayland::ivi_controller(registry, id, version);
-}
-
}
QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
index 11a2ae99b..fc16d2f64 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
@@ -58,18 +58,16 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandIviShellIntegration : public QWaylandShell
{
public:
QWaylandIviShellIntegration();
- ~QWaylandIviShellIntegration() override;
+
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
private:
- static void registryIvi(void *data, struct wl_registry *registry,
- uint32_t id, const QString &interface, uint32_t version);
uint32_t getNextUniqueSurfaceId();
private:
- QtWayland::ivi_application *m_iviApplication = nullptr;
- QtWayland::ivi_controller *m_iviController = nullptr;
+ QScopedPointer<QtWayland::ivi_application> m_iviApplication;
+ QScopedPointer<QtWayland::ivi_controller> m_iviController;
uint32_t m_lastSurfaceId = 0;
uint32_t m_surfaceNumber = 0;
bool m_useEnvSurfaceId = false;
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp
index ec529b124..10d308ba4 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp
@@ -75,11 +75,9 @@ QWaylandIviSurface::~QWaylandIviSurface()
delete m_extendedWindow;
}
-void QWaylandIviSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent)
+void QWaylandIviSurface::applyConfigure()
{
-
- Q_UNUSED(type)
- Q_UNUSED(transientParent)
+ m_window->resizeFromApplyConfigure(m_pendingSize);
}
void QWaylandIviSurface::createExtendedSurface(QWaylandWindow *window)
@@ -90,7 +88,8 @@ void QWaylandIviSurface::createExtendedSurface(QWaylandWindow *window)
void QWaylandIviSurface::ivi_surface_configure(int32_t width, int32_t height)
{
- this->m_window->configure(0, width, height);
+ m_pendingSize = {width, height};
+ m_window->applyConfigureWhenPossible();
}
void QWaylandIviSurface::ivi_controller_surface_visibility(int32_t visibility)
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
index ff943060b..f207f0584 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
@@ -62,7 +62,7 @@ public:
struct ::ivi_controller_surface *iviControllerSurface);
~QWaylandIviSurface() override;
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ void applyConfigure() override;
private:
void createExtendedSurface(QWaylandWindow *window);
@@ -71,6 +71,7 @@ private:
QWaylandWindow *m_window = nullptr;
QWaylandExtendedSurface *m_extendedWindow = nullptr;
+ QSize m_pendingSize = {0, 0};
};
}
diff --git a/src/plugins/shellintegration/shellintegration.pro b/src/plugins/shellintegration/shellintegration.pro
index 9867d2b40..48b6efa36 100644
--- a/src/plugins/shellintegration/shellintegration.pro
+++ b/src/plugins/shellintegration/shellintegration.pro
@@ -1,3 +1,9 @@
TEMPLATE = subdirs
-SUBDIRS += ivi-shell
+SUBDIRS += \
+ ivi-shell \
+ xdg-shell \
+ xdg-shell-v5 \
+ xdg-shell-v6 \
+ wl-shell \
+
diff --git a/src/plugins/shellintegration/wl-shell/main.cpp b/src/plugins/shellintegration/wl-shell/main.cpp
new file mode 100644
index 000000000..9b033b5f3
--- /dev/null
+++ b/src/plugins/shellintegration/wl-shell/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2017 ITAGE Corporation, author: <yusuke.binsaki@itage.co.jp>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandwlshellintegration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandWlShellIntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "wl-shell.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandWlShellIntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandWlShellIntegration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/client/qwaylandwlshellintegration.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp
index 81c46be29..be156dad2 100644
--- a/src/client/qwaylandwlshellintegration.cpp
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp
@@ -38,23 +38,16 @@
****************************************************************************/
#include "qwaylandwlshellintegration_p.h"
+#include "qwaylandwlshellsurface_p.h"
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
-#include <QtWaylandClient/private/qwaylandwlshellsurface_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandWlShellIntegration *QWaylandWlShellIntegration::create(QWaylandDisplay *display)
-{
- if (display->hasRegistryGlobal(QLatin1String("wl_shell")))
- return new QWaylandWlShellIntegration(display);
- return nullptr;
-}
-
-QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display)
+bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display)
{
Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
if (global.interface == QLatin1String("wl_shell")) {
@@ -62,19 +55,33 @@ QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display)
break;
}
}
-}
-bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display)
-{
- QWaylandShellIntegration::initialize(display);
- return m_wlShell != nullptr;
-};
+ if (!m_wlShell) {
+ qCDebug(lcQpaWayland) << "Couldn't find global wl_shell";
+ return false;
+ }
+
+ return QWaylandShellIntegration::initialize(display);
+}
QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window)
{
return new QWaylandWlShellSurface(m_wlShell->get_shell_surface(window->object()), window);
}
+void *QWaylandWlShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
+{
+ QByteArray lowerCaseResource = resource.toLower();
+ if (lowerCaseResource == "wl_shell_surface") {
+ if (auto waylandWindow = static_cast<QWaylandWindow *>(window->handle())) {
+ if (auto shellSurface = qobject_cast<QWaylandWlShellSurface *>(waylandWindow->shellSurface())) {
+ return shellSurface->object();
+ }
+ }
+ }
+ return nullptr;
}
+} // namespace QtWaylandClient
+
QT_END_NAMESPACE
diff --git a/src/client/qwaylandwlshellintegration_p.h b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h
index 7a6b53524..80a7507d4 100644
--- a/src/client/qwaylandwlshellintegration_p.h
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h
@@ -63,13 +63,12 @@ namespace QtWaylandClient {
class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellIntegration : public QWaylandShellIntegration
{
public:
- static QWaylandWlShellIntegration *create(QWaylandDisplay* display);
+ QWaylandWlShellIntegration() {}
bool initialize(QWaylandDisplay *) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+ void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override;
private:
- QWaylandWlShellIntegration(QWaylandDisplay* display);
-
QtWayland::wl_shell *m_wlShell = nullptr;
};
diff --git a/src/client/qwaylandwlshellsurface.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp
index 098eddcbc..d9bc83059 100644
--- a/src/client/qwaylandwlshellsurface.cpp
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp
@@ -39,12 +39,12 @@
#include "qwaylandwlshellsurface_p.h"
-#include "qwaylanddisplay_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylandinputdevice_p.h"
-#include "qwaylandabstractdecoration_p.h"
-#include "qwaylandscreen_p.h"
-#include "qwaylandextendedsurface_p.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
#include <QtCore/QDebug>
@@ -59,6 +59,15 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_
{
if (window->display()->windowExtension())
m_extendedWindow = new QWaylandExtendedSurface(window);
+
+ Qt::WindowType type = window->window()->type();
+ auto *transientParent = window->transientParent();
+ if (type == Qt::Popup && transientParent && transientParent->object())
+ setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial());
+ else if (transientParent && transientParent->object())
+ updateTransientParent(transientParent->window());
+ else
+ setTopLevel();
}
QWaylandWlShellSurface::~QWaylandWlShellSurface()
@@ -121,35 +130,70 @@ void QWaylandWlShellSurface::sendProperty(const QString &name, const QVariant &v
m_extendedWindow->updateGenericProperty(name, value);
}
-void QWaylandWlShellSurface::setMaximized()
+void QWaylandWlShellSurface::applyConfigure()
{
- m_maximized = true;
- m_size = m_window->window()->geometry().size();
- set_maximized(nullptr);
+ if ((m_pending.states & (Qt::WindowMaximized|Qt::WindowFullScreen))
+ && !(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen))) {
+ m_normalSize = m_window->window()->frameGeometry().size();
+ }
+
+ if (m_pending.states != m_applied.states)
+ m_window->handleWindowStatesChanged(m_pending.states);
+
+ if (!m_pending.size.isEmpty()) {
+ int x = 0;
+ int y = 0;
+ if (m_pending.edges & resize_left)
+ x = m_applied.size.width() - m_pending.size.width();
+ if (m_pending.edges & resize_top)
+ y = m_applied.size.height() - m_pending.size.height();
+ QPoint offset(x, y);
+ m_window->resizeFromApplyConfigure(m_pending.size, offset);
+ } else if (m_pending.size.isValid() && !m_normalSize.isEmpty()) {
+ m_window->resizeFromApplyConfigure(m_normalSize);
+ }
+
+ m_applied = m_pending;
}
-void QWaylandWlShellSurface::setFullscreen()
+bool QWaylandWlShellSurface::wantsDecorations() const
{
- m_fullscreen = true;
- m_size = m_window->window()->geometry().size();
- set_fullscreen(WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, nullptr);
+ return !(m_pending.states & Qt::WindowFullScreen);
}
-void QWaylandWlShellSurface::setNormal()
+void QWaylandWlShellSurface::requestWindowStates(Qt::WindowStates states)
{
- if (m_fullscreen || m_maximized) {
- m_fullscreen = m_maximized = false;
- setTopLevel();
- QMargins m = m_window->frameMargins();
- m_window->configure(0, m_size.width() + m.left() + m.right(), m_size.height() + m.top() + m.bottom());
+ // On wl-shell the client is in charge of states, so diff from the pending state
+ Qt::WindowStates changedStates = m_pending.states ^ states;
+ Qt::WindowStates addedStates = changedStates & states;
+
+ if (addedStates & Qt::WindowMinimized)
+ qCWarning(lcQpaWayland) << "Minimizing is not supported on wl-shell. Consider using xdg-shell instead.";
+
+ if (addedStates & Qt::WindowMaximized) {
+ set_maximized(nullptr);
+ m_window->applyConfigureWhenPossible();
}
-}
-void QWaylandWlShellSurface::setMinimized()
-{
- qCWarning(lcQpaWayland) << "Minimization is not supported on wl-shell. Consider using xdg-shell instead.";
+ if (addedStates & Qt::WindowFullScreen) {
+ set_fullscreen(WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, nullptr);
+ m_window->applyConfigureWhenPossible();
+ }
+
+ bool isNormal = ~states & (Qt::WindowMaximized | Qt::WindowFullScreen);
+ if (isNormal && (changedStates & (Qt::WindowMaximized | Qt::WindowFullScreen))) {
+ setTopLevel(); // set normal window
+ // There's usually no configure event after this, so just clear the rest of the pending
+ // configure here and queue the applyConfigure call
+ m_pending.size = {0, 0};
+ m_pending.edges = resize_none;
+ m_window->applyConfigureWhenPossible();
+ }
+
+ m_pending.states = states & ~Qt::WindowMinimized;
}
+
void QWaylandWlShellSurface::setTopLevel()
{
set_toplevel();
@@ -194,11 +238,11 @@ void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevic
{
QWaylandWindow *parent_wayland_window = parent;
if (!parent_wayland_window) {
- qWarning("setPopup called without parent window");
+ qCWarning(lcQpaWayland) << "setPopup called without a parent window";
return;
}
if (!device) {
- qWarning("setPopup called without input device");
+ qCWarning(lcQpaWayland) << "setPopup called without an input device";
return;
}
@@ -215,26 +259,18 @@ void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevic
transientPos.x(), transientPos.y(), 0);
}
-void QWaylandWlShellSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent)
-{
- if (type == Qt::Popup && transientParent && transientParent->object())
- setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial());
- else if (transientParent && transientParent->object())
- updateTransientParent(transientParent->window());
- else
- setTopLevel();
-}
-
void QWaylandWlShellSurface::shell_surface_ping(uint32_t serial)
{
pong(serial);
}
-void QWaylandWlShellSurface::shell_surface_configure(uint32_t edges,
- int32_t width,
- int32_t height)
+void QWaylandWlShellSurface::shell_surface_configure(uint32_t edges, int32_t width, int32_t height)
{
- m_window->configure(edges, width, height);
+ m_pending.size = QSize(width, height);
+ m_pending.edges = static_cast<enum resize>(edges);
+ if (m_pending.edges && !m_pending.size.isEmpty())
+ m_normalSize = m_pending.size;
+ m_window->applyConfigureWhenPossible();
}
void QWaylandWlShellSurface::shell_surface_popup_done()
diff --git a/src/client/qwaylandwlshellsurface_p.h b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
index 497ec6043..57e06525a 100644
--- a/src/client/qwaylandwlshellsurface_p.h
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
@@ -92,22 +92,26 @@ public:
void setWindowFlags(Qt::WindowFlags flags) override;
void sendProperty(const QString &name, const QVariant &value) override;
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ void applyConfigure() override;
+ bool wantsDecorations() const override;
-private:
- void setMaximized() override;
- void setFullscreen() override;
- void setNormal() override;
- void setMinimized() override;
+protected:
+ void requestWindowStates(Qt::WindowStates states) override;
+private:
void setTopLevel();
void updateTransientParent(QWindow *parent);
void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, uint serial);
QWaylandWindow *m_window = nullptr;
- bool m_maximized = false;
- bool m_fullscreen = false;
- QSize m_size;
+ struct {
+ Qt::WindowStates states = Qt::WindowNoState;
+ QSize size;
+ enum resize edges = resize_none;
+ } m_applied, m_pending;
+ QSize m_normalSize;
+ // There's really no need to have pending and applied state on wl-shell, but we do it just to
+ // keep the different shell implementations more similar.
QWaylandExtendedSurface *m_extendedWindow = nullptr;
void shell_surface_ping(uint32_t serial) override;
diff --git a/src/plugins/shellintegration/wl-shell/wl-shell.json b/src/plugins/shellintegration/wl-shell/wl-shell.json
new file mode 100644
index 000000000..1859bb58a
--- /dev/null
+++ b/src/plugins/shellintegration/wl-shell/wl-shell.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "wl-shell" ]
+}
diff --git a/src/plugins/shellintegration/wl-shell/wl-shell.pro b/src/plugins/shellintegration/wl-shell/wl-shell.pro
new file mode 100644
index 000000000..fbff63c71
--- /dev/null
+++ b/src/plugins/shellintegration/wl-shell/wl-shell.pro
@@ -0,0 +1,25 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE_PRIVATE += xkbcommon_evdev
+
+WAYLANDCLIENTSOURCES += \
+ ../../../3rdparty/protocol/wayland.xml
+
+HEADERS += \
+ qwaylandwlshellintegration_p.h \
+ qwaylandwlshellsurface_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandwlshellintegration.cpp \
+ qwaylandwlshellsurface.cpp \
+
+OTHER_FILES += \
+ wl-shell.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandWlShellIntegrationPlugin
+load(qt_plugin)
diff --git a/src/plugins/shellintegration/xdg-shell-v5/main.cpp b/src/plugins/shellintegration/xdg-shell-v5/main.cpp
new file mode 100644
index 000000000..d365f682d
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2017 ITAGE Corporation, author: <yusuke.binsaki@itage.co.jp>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellv5integration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellV5IntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "xdg-shell-v5.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandXdgShellV5IntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandXdgShellV5Integration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/client/qwaylandxdgpopup.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
index 46a12a828..539abcac7 100644
--- a/src/client/qwaylandxdgpopup.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
@@ -37,17 +37,17 @@
**
****************************************************************************/
-#include "qwaylandxdgpopup_p.h"
+#include "qwaylandxdgpopupv5_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylanddisplay_p.h"
-#include "qwaylandextendedsurface_p.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgPopup::QWaylandXdgPopup(struct ::xdg_popup *popup, QWaylandWindow *window)
+QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup *popup, QWaylandWindow *window)
: QWaylandShellSurface(window)
, QtWayland::xdg_popup(popup)
, m_window(window)
@@ -56,19 +56,13 @@ QWaylandXdgPopup::QWaylandXdgPopup(struct ::xdg_popup *popup, QWaylandWindow *wi
m_extendedWindow = new QWaylandExtendedSurface(window);
}
-QWaylandXdgPopup::~QWaylandXdgPopup()
+QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
{
xdg_popup_destroy(object());
delete m_extendedWindow;
}
-void QWaylandXdgPopup::setType(Qt::WindowType type, QWaylandWindow *transientParent)
-{
- Q_UNUSED(type);
- Q_UNUSED(transientParent);
-}
-
-void QWaylandXdgPopup::xdg_popup_popup_done()
+void QWaylandXdgPopupV5::xdg_popup_popup_done()
{
m_window->window()->close();
}
diff --git a/src/client/qwaylandxdgpopup_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
index b027c05dc..cb748c5cc 100644
--- a/src/client/qwaylandxdgpopup_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QWAYLANDXDGPOPUP_P_H
-#define QWAYLANDXDGPOPUP_P_H
+#ifndef QWAYLANDXDGPOPUPV5_P_H
+#define QWAYLANDXDGPOPUPV5_P_H
//
// W A R N I N G
@@ -51,10 +51,11 @@
// We mean it.
//
+#include "qwayland-xdg-shell-unstable-v5.h"
+
#include <wayland-client.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
QT_BEGIN_NAMESPACE
@@ -66,15 +67,13 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandExtendedSurface;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopup : public QWaylandShellSurface
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
, public QtWayland::xdg_popup
{
Q_OBJECT
public:
- QWaylandXdgPopup(struct ::xdg_popup *popup, QWaylandWindow *window);
- ~QWaylandXdgPopup() override;
-
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ QWaylandXdgPopupV5(struct ::xdg_popup *popup, QWaylandWindow *window);
+ ~QWaylandXdgPopupV5() override;
protected:
void xdg_popup_popup_done() override;
@@ -88,4 +87,4 @@ QT_END_NAMESPACE
}
-#endif // QWAYLANDXDGPOPUP_P_H
+#endif // QWAYLANDXDGPOPUPV5_P_H
diff --git a/src/client/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
index 9a34e72dd..6a693578c 100644
--- a/src/client/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
@@ -37,43 +37,43 @@
**
****************************************************************************/
-#include "qwaylandxdgshell_p.h"
-
-#include "qwaylanddisplay_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylandinputdevice_p.h"
-#include "qwaylandscreen_p.h"
-#include "qwaylandxdgpopup_p.h"
-#include "qwaylandxdgsurface_p.h"
+#include "qwaylandxdgshellv5_p.h"
+#include "qwaylandxdgpopupv5_p.h"
+#include "qwaylandxdgsurfacev5_p.h"
#include <QtCore/QDebug>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgShell::QWaylandXdgShell(struct ::xdg_shell *shell)
+QWaylandXdgShellV5::QWaylandXdgShellV5(struct ::xdg_shell *shell)
: QtWayland::xdg_shell(shell)
{
}
-QWaylandXdgShell::QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id)
+QWaylandXdgShellV5::QWaylandXdgShellV5(struct ::wl_registry *registry, uint32_t id)
: QtWayland::xdg_shell(registry, id, 1)
{
use_unstable_version(QtWayland::xdg_shell::version_current);
}
-QWaylandXdgShell::~QWaylandXdgShell()
+QWaylandXdgShellV5::~QWaylandXdgShellV5()
{
xdg_shell_destroy(object());
}
-QWaylandXdgSurface *QWaylandXdgShell::createXdgSurface(QWaylandWindow *window)
+QWaylandXdgSurfaceV5 *QWaylandXdgShellV5::createXdgSurface(QWaylandWindow *window)
{
- return new QWaylandXdgSurface(this, window);
+ return new QWaylandXdgSurfaceV5(this, window);
}
-QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice)
+QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice)
{
QWaylandWindow *parentWindow = m_popups.empty() ? window->transientParent() : m_popups.last();
::wl_surface *parentSurface = parentWindow->object();
@@ -86,9 +86,9 @@ QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWayl
int x = position.x() + parentWindow->frameMargins().left();
int y = position.y() + parentWindow->frameMargins().top();
- auto popup = new QWaylandXdgPopup(get_xdg_popup(window->object(), parentSurface, seat, m_popupSerial, x, y), window);
+ auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->object(), parentSurface, seat, m_popupSerial, x, y), window);
m_popups.append(window);
- QObject::connect(popup, &QWaylandXdgPopup::destroyed, [this, window](){
+ QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
m_popups.removeOne(window);
if (m_popups.empty())
m_popupSerial = 0;
@@ -96,7 +96,7 @@ QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWayl
return popup;
}
-void QWaylandXdgShell::xdg_shell_ping(uint32_t serial)
+void QWaylandXdgShellV5::xdg_shell_ping(uint32_t serial)
{
pong(serial);
}
diff --git a/src/client/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5_p.h
index 761f25218..ec45bb32c 100644
--- a/src/client/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QWAYLANDXDGSHELL_H
-#define QWAYLANDXDGSHELL_H
+#ifndef QWAYLANDXDGSHELLV5_H
+#define QWAYLANDXDGSHELLV5_H
//
// W A R N I N G
@@ -51,12 +51,13 @@
// We mean it.
//
+#include "qwayland-xdg-shell-unstable-v5.h"
+
#include <QtCore/QSize>
#include <QtCore/QVector>
#include <wayland-client.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
@@ -68,18 +69,18 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandInputDevice;
-class QWaylandXdgSurface;
-class QWaylandXdgPopup;
+class QWaylandXdgSurfaceV5;
+class QWaylandXdgPopupV5;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_shell
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellV5 : public QtWayland::xdg_shell
{
public:
- QWaylandXdgShell(struct ::xdg_shell *shell);
- QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id);
- ~QWaylandXdgShell() override;
+ QWaylandXdgShellV5(struct ::xdg_shell *shell);
+ QWaylandXdgShellV5(struct ::wl_registry *registry, uint32_t id);
+ ~QWaylandXdgShellV5() override;
- QWaylandXdgSurface *createXdgSurface(QWaylandWindow *window);
- QWaylandXdgPopup *createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice);
+ QWaylandXdgSurfaceV5 *createXdgSurface(QWaylandWindow *window);
+ QWaylandXdgPopupV5 *createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice);
private:
void xdg_shell_ping(uint32_t serial) override;
@@ -92,4 +93,4 @@ QT_END_NAMESPACE
}
-#endif // QWAYLANDXDGSHELL_H
+#endif // QWAYLANDXDGSHELLV5_H
diff --git a/src/client/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
index ee72c2d52..47d748b1c 100644
--- a/src/client/qwaylandxdgshellintegration.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
@@ -37,42 +37,36 @@
**
****************************************************************************/
-#include "qwaylandxdgshellintegration_p.h"
+#include "qwaylandxdgshellv5integration_p.h"
+#include "qwaylandxdgsurfacev5_p.h"
+#include "qwaylandxdgpopupv5_p.h"
+#include "qwaylandxdgshellv5_p.h"
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
-#include <QtWaylandClient/private/qwaylandxdgsurface_p.h>
-#include <QtWaylandClient/private/qwaylandxdgpopup_p.h>
-#include <QtWaylandClient/private/qwaylandxdgshell_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgShellIntegration *QWaylandXdgShellIntegration::create(QWaylandDisplay *display)
-{
- if (display->hasRegistryGlobal(QLatin1String("xdg_shell")))
- return new QWaylandXdgShellIntegration(display);
- return nullptr;
-}
-
-QWaylandXdgShellIntegration::QWaylandXdgShellIntegration(QWaylandDisplay *display)
+bool QWaylandXdgShellV5Integration::initialize(QWaylandDisplay *display)
{
Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
if (global.interface == QLatin1String("xdg_shell")) {
- m_xdgShell = new QWaylandXdgShell(display->wl_registry(), global.id);
+ m_xdgShell.reset(new QWaylandXdgShellV5(display->wl_registry(), global.id));
break;
}
}
-}
-bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
-{
- QWaylandShellIntegration::initialize(display);
- return m_xdgShell != nullptr;
+ if (!m_xdgShell) {
+ qWarning() << "Couldn't find global xdg_shell for xdg-shell unstable v5";
+ return false;
+ }
+
+ return QWaylandShellIntegration::initialize(display);
}
-QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
+QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWaylandWindow *window)
{
QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
if (window->window()->type() == Qt::WindowType::Popup && inputDevice)
@@ -81,10 +75,10 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
return m_xdgShell->createXdgSurface(window);
}
-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
- if (newFocus && qobject_cast<QWaylandXdgPopup *>(newFocus->shellSurface()))
+void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+ if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
m_display->handleWindowActivated(newFocus);
- if (oldFocus && qobject_cast<QWaylandXdgPopup *>(oldFocus->shellSurface()))
+ if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
m_display->handleWindowDeactivated(oldFocus);
}
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
new file mode 100644
index 000000000..ce6bdb9ee
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELLV5INTEGRATION_P_H
+#define QWAYLANDXDGSHELLV5INTEGRATION_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 "qwaylandxdgshellv5_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellV5;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellV5Integration : public QWaylandShellIntegration
+{
+public:
+ QWaylandXdgShellV5Integration() {}
+ bool initialize(QWaylandDisplay *display) override;
+ QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+ void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+
+private:
+ QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGSHELLV5INTEGRATION_P_H
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
new file mode 100644
index 000000000..40e2a994d
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgsurfacev5_p.h"
+#include "qwaylandxdgshellv5_p.h"
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *shell, QWaylandWindow *window)
+ : QWaylandShellSurface(window)
+ , QtWayland::xdg_surface(shell->get_xdg_surface(window->object()))
+ , m_window(window)
+ , m_shell(shell)
+{
+ if (window->display()->windowExtension())
+ m_extendedWindow = new QWaylandExtendedSurface(window);
+
+ updateTransientParent(window->transientParent());
+}
+
+QWaylandXdgSurfaceV5::~QWaylandXdgSurfaceV5()
+{
+ if (m_acked.states & Qt::WindowActive)
+ window()->display()->handleWindowDeactivated(m_window);
+
+ xdg_surface_destroy(object());
+ delete m_extendedWindow;
+}
+
+void QWaylandXdgSurfaceV5::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
+{
+ // May need some conversion if types get incompatibles, ATM they're identical
+ enum resize_edge const * const arg = reinterpret_cast<enum resize_edge const *>(&edges);
+ resize(inputDevice, *arg);
+}
+
+void QWaylandXdgSurfaceV5::resize(QWaylandInputDevice *inputDevice, enum resize_edge edges)
+{
+ resize(inputDevice->wl_seat(),
+ inputDevice->serial(),
+ edges);
+}
+
+bool QWaylandXdgSurfaceV5::move(QWaylandInputDevice *inputDevice)
+{
+ move(inputDevice->wl_seat(),
+ inputDevice->serial());
+ return true;
+}
+
+void QWaylandXdgSurfaceV5::updateTransientParent(QWaylandWindow *parent)
+{
+ if (!parent)
+ return;
+ auto parentXdgSurface = qobject_cast<QWaylandXdgSurfaceV5 *>(parent->shellSurface());
+ Q_ASSERT(parentXdgSurface);
+ set_parent(parentXdgSurface->object());
+}
+
+void QWaylandXdgSurfaceV5::setTitle(const QString & title)
+{
+ return QtWayland::xdg_surface::set_title(title);
+}
+
+void QWaylandXdgSurfaceV5::setAppId(const QString & appId)
+{
+ return QtWayland::xdg_surface::set_app_id(appId);
+}
+
+void QWaylandXdgSurfaceV5::raise()
+{
+ if (m_extendedWindow)
+ m_extendedWindow->raise();
+}
+
+void QWaylandXdgSurfaceV5::lower()
+{
+ if (m_extendedWindow)
+ m_extendedWindow->lower();
+}
+
+void QWaylandXdgSurfaceV5::setContentOrientationMask(Qt::ScreenOrientations orientation)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->setContentOrientationMask(orientation);
+}
+
+void QWaylandXdgSurfaceV5::setWindowFlags(Qt::WindowFlags flags)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->setWindowFlags(flags);
+}
+
+void QWaylandXdgSurfaceV5::sendProperty(const QString &name, const QVariant &value)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->updateGenericProperty(name, value);
+}
+
+void QWaylandXdgSurfaceV5::applyConfigure()
+{
+ if (m_pending.isResizing)
+ m_normalSize = m_pending.size;
+ else if (!(m_acked.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+ m_normalSize = m_window->window()->frameGeometry().size();
+
+ if ((m_pending.states & Qt::WindowActive) && !(m_acked.states & Qt::WindowActive))
+ m_window->display()->handleWindowActivated(m_window);
+
+ if (!(m_pending.states & Qt::WindowActive) && (m_acked.states & Qt::WindowActive))
+ m_window->display()->handleWindowDeactivated(m_window);
+
+ // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+ Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+
+ m_window->handleWindowStatesChanged(statesWithoutActive);
+ if (!m_pending.size.isEmpty())
+ m_window->resizeFromApplyConfigure(m_pending.size);
+ else if (!m_normalSize.isEmpty())
+ m_window->resizeFromApplyConfigure(m_normalSize);
+ ack_configure(m_pending.serial);
+ m_acked = m_pending;
+}
+
+void QWaylandXdgSurfaceV5::requestWindowStates(Qt::WindowStates states)
+{
+ Qt::WindowStates changedStates = m_acked.states ^ states;
+
+ if (changedStates & Qt::WindowMaximized) {
+ if (states & Qt::WindowMaximized)
+ set_maximized();
+ else
+ unset_maximized();
+ }
+
+ if (changedStates & Qt::WindowFullScreen) {
+ if (states & Qt::WindowFullScreen)
+ set_fullscreen(nullptr);
+ else
+ unset_fullscreen();
+ }
+
+ // Minimized state is not reported by the protocol, so always send it
+ if (states & Qt::WindowMinimized) {
+ set_minimized();
+ window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized);
+ }
+}
+
+bool QWaylandXdgSurfaceV5::wantsDecorations() const
+{
+ return !(m_pending.states & Qt::WindowFullScreen);
+}
+
+void QWaylandXdgSurfaceV5::xdg_surface_configure(int32_t width, int32_t height, struct wl_array *states,uint32_t serial)
+{
+ uint32_t *xdgStates = reinterpret_cast<uint32_t*>(states->data);
+ size_t numStates = states->size / sizeof(uint32_t);
+ m_pending.serial = serial;
+ m_pending.size = QSize(width, height);
+ m_pending.isResizing = false;
+ m_pending.states = Qt::WindowNoState;
+ for (size_t i = 0; i < numStates; i++) {
+ switch (xdgStates[i]) {
+ case XDG_SURFACE_STATE_MAXIMIZED:
+ m_pending.states |= Qt::WindowMaximized;
+ break;
+ case XDG_SURFACE_STATE_FULLSCREEN:
+ m_pending.states |= Qt::WindowFullScreen;
+ break;
+ case XDG_SURFACE_STATE_RESIZING:
+ m_pending.isResizing = true;
+ break;
+ case XDG_SURFACE_STATE_ACTIVATED:
+ m_pending.states |= Qt::WindowActive;
+ break;
+ default:
+ break;
+ }
+ }
+ m_window->applyConfigureWhenPossible();
+}
+
+void QWaylandXdgSurfaceV5::xdg_surface_close()
+{
+ m_window->window()->close();
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/qwaylandxdgsurface_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
index b8dd93f47..e69433248 100644
--- a/src/client/qwaylandxdgsurface_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QWAYLANDXDGSURFACE_H
-#define QWAYLANDXDGSURFACE_H
+#ifndef QWAYLANDXDGSURFACEV5_P_H
+#define QWAYLANDXDGSURFACEV5_P_H
//
// W A R N I N G
@@ -51,15 +51,16 @@
// We mean it.
//
+#include "qwayland-xdg-shell-unstable-v5.h"
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
+
#include <QtCore/QSize>
#include <QtCore/QMargins>
#include <wayland-client.h>
-#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
-#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
-
QT_BEGIN_NAMESPACE
class QWindow;
@@ -69,15 +70,15 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandInputDevice;
class QWaylandExtendedSurface;
-class QWaylandXdgShell;
+class QWaylandXdgShellV5;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurfaceV5 : public QWaylandShellSurface
, public QtWayland::xdg_surface
{
Q_OBJECT
public:
- QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow *window);
- ~QWaylandXdgSurface() override;
+ QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *shell, QWaylandWindow *window);
+ ~QWaylandXdgSurfaceV5() override;
using QtWayland::xdg_surface::resize;
void resize(QWaylandInputDevice *inputDevice, enum resize_edge edges);
@@ -96,26 +97,22 @@ public:
void setWindowFlags(Qt::WindowFlags flags) override;
void sendProperty(const QString &name, const QVariant &value) override;
- bool isFullscreen() const { return m_fullscreen; }
- bool isMaximized() const { return m_maximized; }
-
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ void applyConfigure() override;
+ void requestWindowStates(Qt::WindowStates states) override;
+ bool wantsDecorations() const override;
private:
- void setMaximized() override;
- void setFullscreen() override;
- void setNormal() override;
- void setMinimized() override;
-
void updateTransientParent(QWaylandWindow *parent);
private:
QWaylandWindow *m_window = nullptr;
- QWaylandXdgShell* m_shell = nullptr;
- bool m_maximized = false;
- bool m_minimized = false;
- bool m_fullscreen = false;
- bool m_active = false;
+ QWaylandXdgShellV5* m_shell = nullptr;
+ struct {
+ Qt::WindowStates states = Qt::WindowNoState;
+ bool isResizing = false;
+ QSize size = {0, 0};
+ uint serial = 0;
+ } m_acked, m_pending;
QSize m_normalSize;
QMargins m_margins;
QWaylandExtendedSurface *m_extendedWindow = nullptr;
@@ -133,4 +130,4 @@ QT_END_NAMESPACE
}
-#endif // QWAYLANDXDGSURFACE_H
+#endif // QWAYLANDXDGSURFACEV5_P_H
diff --git a/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json
new file mode 100644
index 000000000..ba1ed4489
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "xdg-shell-v5" ]
+}
diff --git a/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro
new file mode 100644
index 000000000..0e97832e4
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro
@@ -0,0 +1,30 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE += xkbcommon_evdev
+
+WAYLANDCLIENTSOURCES += \
+ ../../../3rdparty/protocol/xdg-shell-unstable-v5.xml
+
+HEADERS += \
+ qwaylandxdgpopupv5_p.h \
+ qwaylandxdgshellv5_p.h \
+ qwaylandxdgshellv5integration_p.h \
+ qwaylandxdgsurfacev5_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandxdgpopupv5.cpp \
+ qwaylandxdgshellv5.cpp \
+ qwaylandxdgshellv5integration.cpp \
+ qwaylandxdgsurfacev5.cpp \
+
+OTHER_FILES += \
+ xdg-shell-v5.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandXdgShellV5IntegrationPlugin
+load(qt_plugin)
diff --git a/src/plugins/shellintegration/xdg-shell-v6/main.cpp b/src/plugins/shellintegration/xdg-shell-v6/main.cpp
new file mode 100644
index 000000000..8cd302f32
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v6/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellv6integration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellV6IntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "xdg-shell-v6.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandXdgShellV6IntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandXdgShellV6Integration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/client/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
index 2c910d116..1dc43b371 100644
--- a/src/client/qwaylandxdgshellv6.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
@@ -40,13 +40,11 @@
#include "qwaylandxdgshellv6_p.h"
-#include "qwaylanddisplay_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylandinputdevice_p.h"
-#include "qwaylandscreen_p.h"
-#include "qwaylandabstractdecoration_p.h"
-
-#include <QtCore/QDebug>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
QT_BEGIN_NAMESPACE
@@ -56,32 +54,69 @@ QWaylandXdgSurfaceV6::Toplevel::Toplevel(QWaylandXdgSurfaceV6 *xdgSurface)
: QtWayland::zxdg_toplevel_v6(xdgSurface->get_toplevel())
, m_xdgSurface(xdgSurface)
{
+ requestWindowStates(xdgSurface->window()->window()->windowStates());
}
QWaylandXdgSurfaceV6::Toplevel::~Toplevel()
{
+ if (m_applied.states & Qt::WindowActive) {
+ QWaylandWindow *window = m_xdgSurface->window();
+ window->display()->handleWindowDeactivated(window);
+ }
if (isInitialized())
destroy();
}
void QWaylandXdgSurfaceV6::Toplevel::applyConfigure()
{
- //TODO: resize, activate etc
- m_xdgSurface->m_window->configure(0, m_configureState.width, m_configureState.height);
+ if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+ m_normalSize = m_xdgSurface->m_window->window()->frameGeometry().size();
+
+ if (m_pending.size.isEmpty() && !m_normalSize.isEmpty())
+ m_pending.size = m_normalSize;
+
+ if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
+ m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+
+ if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
+ m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+
+ // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+ Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+
+ m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
+ m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+ QSize windowGeometrySize = m_xdgSurface->m_window->window()->frameGeometry().size();
+ m_xdgSurface->set_window_geometry(0, 0, windowGeometrySize.width(), windowGeometrySize.height());
+ m_applied = m_pending;
}
void QWaylandXdgSurfaceV6::Toplevel::zxdg_toplevel_v6_configure(int32_t width, int32_t height, wl_array *states)
{
- m_configureState.width = width;
- m_configureState.height = height;
+ m_pending.size = QSize(width, height);
- uint32_t *state = reinterpret_cast<uint32_t *>(states->data);
+ auto *xdgStates = static_cast<uint32_t *>(states->data);
size_t numStates = states->size / sizeof(uint32_t);
- m_configureState.states.reserve(numStates);
- m_configureState.states.clear();
- for (size_t i = 0; i < numStates; i++)
- m_configureState.states << state[i];
+ m_pending.states = Qt::WindowNoState;
+
+ for (size_t i = 0; i < numStates; i++) {
+ switch (xdgStates[i]) {
+ case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED:
+ m_pending.states |= Qt::WindowActive;
+ break;
+ case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED:
+ m_pending.states |= Qt::WindowMaximized;
+ break;
+ case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
+ m_pending.states |= Qt::WindowFullScreen;
+ break;
+ default:
+ break;
+ }
+ }
+ qCDebug(lcQpaWayland) << "Received zxdg_toplevel_v6.configure with" << m_pending.size
+ << "and" << m_pending.states;
}
void QWaylandXdgSurfaceV6::Toplevel::zxdg_toplevel_v6_close()
@@ -89,6 +124,32 @@ void QWaylandXdgSurfaceV6::Toplevel::zxdg_toplevel_v6_close()
m_xdgSurface->m_window->window()->close();
}
+void QWaylandXdgSurfaceV6::Toplevel::requestWindowStates(Qt::WindowStates states)
+{
+ // Re-send what's different from the applied state
+ Qt::WindowStates changedStates = m_applied.states ^ states;
+
+ if (changedStates & Qt::WindowMaximized) {
+ if (states & Qt::WindowMaximized)
+ set_maximized();
+ else
+ unset_maximized();
+ }
+
+ if (changedStates & Qt::WindowFullScreen) {
+ if (states & Qt::WindowFullScreen)
+ set_fullscreen(nullptr);
+ else
+ unset_fullscreen();
+ }
+
+ // Minimized state is not reported by the protocol, so always send it
+ if (states & Qt::WindowMinimized) {
+ set_minimized();
+ m_xdgSurface->window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized);
+ }
+}
+
QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parent,
QtWayland::zxdg_positioner_v6 *positioner)
: zxdg_popup_v6(xdgSurface->get_popup(parent->object(), positioner->object()))
@@ -109,11 +170,6 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
}
}
-void QWaylandXdgSurfaceV6::Popup::applyConfigure()
-{
-
-}
-
void QWaylandXdgSurfaceV6::Popup::grab(QWaylandInputDevice *seat, uint serial)
{
m_xdgSurface->m_shell->m_topmostPopup = this;
@@ -132,6 +188,20 @@ QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *shell, ::zxdg_sur
, m_shell(shell)
, m_window(window)
{
+ QWaylandDisplay *display = window->display();
+ Qt::WindowType type = window->window()->type();
+ auto *transientParent = window->transientParent();
+
+ if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) {
+ setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup);
+ } else {
+ setToplevel();
+ if (transientParent) {
+ auto parentXdgSurface = static_cast<QWaylandXdgSurfaceV6 *>(transientParent->shellSurface());
+ if (parentXdgSurface)
+ m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+ }
+ }
}
QWaylandXdgSurfaceV6::~QWaylandXdgSurfaceV6()
@@ -155,7 +225,7 @@ void QWaylandXdgSurfaceV6::resize(QWaylandInputDevice *inputDevice, zxdg_topleve
void QWaylandXdgSurfaceV6::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
{
- auto xdgEdges = reinterpret_cast<enum zxdg_toplevel_v6_resize_edge const * const>(&edges);
+ auto xdgEdges = reinterpret_cast<enum zxdg_toplevel_v6_resize_edge const *>(&edges);
resize(inputDevice, *xdgEdges);
}
@@ -181,21 +251,6 @@ void QWaylandXdgSurfaceV6::setAppId(const QString &appId)
m_toplevel->set_app_id(appId);
}
-void QWaylandXdgSurfaceV6::setType(Qt::WindowType type, QWaylandWindow *transientParent)
-{
- QWaylandDisplay *display = m_window->display();
- if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) {
- setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup);
- } else {
- setToplevel();
- if (transientParent) {
- auto parentXdgSurface = static_cast<QWaylandXdgSurfaceV6 *>(transientParent->shellSurface());
- if (parentXdgSurface)
- m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
- }
- }
-}
-
bool QWaylandXdgSurfaceV6::handleExpose(const QRegion &region)
{
if (!m_configured && !region.isEmpty()) {
@@ -205,6 +260,32 @@ bool QWaylandXdgSurfaceV6::handleExpose(const QRegion &region)
return false;
}
+void QWaylandXdgSurfaceV6::applyConfigure()
+{
+ Q_ASSERT(m_pendingConfigureSerial != 0);
+
+ if (m_toplevel)
+ m_toplevel->applyConfigure();
+
+ m_configured = true;
+ ack_configure(m_pendingConfigureSerial);
+
+ m_pendingConfigureSerial = 0;
+}
+
+bool QWaylandXdgSurfaceV6::wantsDecorations() const
+{
+ return m_toplevel && !(m_toplevel->m_pending.states & Qt::WindowFullScreen);
+}
+
+void QWaylandXdgSurfaceV6::requestWindowStates(Qt::WindowStates states)
+{
+ if (m_toplevel)
+ m_toplevel->requestWindowStates(states);
+ else
+ qCWarning(lcQpaWayland) << "Non-toplevel surfaces can't request window states";
+}
+
void QWaylandXdgSurfaceV6::setToplevel()
{
Q_ASSERT(!m_toplevel && !m_popup);
@@ -245,21 +326,14 @@ void QWaylandXdgSurfaceV6::setPopup(QWaylandWindow *parent, QWaylandInputDevice
void QWaylandXdgSurfaceV6::zxdg_surface_v6_configure(uint32_t serial)
{
- m_configured = true;
- if (m_toplevel)
- m_toplevel->applyConfigure();
- else if (m_popup)
- m_popup->applyConfigure();
-
+ m_window->applyConfigureWhenPossible();
+ m_pendingConfigureSerial = serial;
if (!m_exposeRegion.isEmpty()) {
QWindowSystemInterface::handleExposeEvent(m_window->window(), m_exposeRegion);
m_exposeRegion = QRegion();
}
- ack_configure(serial);
}
-
-
QWaylandXdgShellV6::QWaylandXdgShellV6(struct ::wl_registry *registry, uint32_t id, uint32_t availableVersion)
: QtWayland::zxdg_shell_v6(registry, id, qMin(availableVersion, 1u))
{
diff --git a/src/client/qwaylandxdgshellv6_p.h b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
index e6434c02f..38b711f88 100644
--- a/src/client/qwaylandxdgshellv6_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
@@ -52,15 +52,16 @@
// We mean it.
//
+#include "qwayland-xdg-shell-unstable-v6.h"
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
+
#include <QtCore/QSize>
#include <QtGui/QRegion>
#include <wayland-client.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell-unstable-v6.h>
-#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include "qwaylandshellsurface_p.h"
-
QT_BEGIN_NAMESPACE
class QWindow;
@@ -73,6 +74,7 @@ class QWaylandXdgShellV6;
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurfaceV6 : public QWaylandShellSurface, public QtWayland::zxdg_surface_v6
{
+ Q_OBJECT
public:
QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *shell, ::zxdg_surface_v6 *surface, QWaylandWindow *window);
~QWaylandXdgSurfaceV6() override;
@@ -83,10 +85,14 @@ public:
void setTitle(const QString &title) override;
void setAppId(const QString &appId) override;
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ bool isExposed() const override { return m_configured; }
bool handleExpose(const QRegion &) override;
+ bool handlesActiveState() const { return m_toplevel; }
+ void applyConfigure() override;
+ bool wantsDecorations() const override;
protected:
+ void requestWindowStates(Qt::WindowStates states) override;
void zxdg_surface_v6_configure(uint32_t serial) override;
private:
@@ -101,10 +107,12 @@ private:
void zxdg_toplevel_v6_configure(int32_t width, int32_t height, wl_array *states) override;
void zxdg_toplevel_v6_close() override;
+ void requestWindowStates(Qt::WindowStates states);
struct {
- int32_t width, height;
- QVarLengthArray<uint32_t> states;
- } m_configureState;
+ QSize size = {0, 0};
+ Qt::WindowStates states = Qt::WindowNoState;
+ } m_pending, m_applied;
+ QSize m_normalSize;
QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr;
};
@@ -114,7 +122,6 @@ private:
Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parent, QtWayland::zxdg_positioner_v6 *positioner);
~Popup() override;
- void applyConfigure();
void grab(QWaylandInputDevice *seat, uint serial);
void zxdg_popup_v6_popup_done() override;
@@ -132,6 +139,7 @@ private:
Popup *m_popup = nullptr;
bool m_configured = false;
QRegion m_exposeRegion;
+ uint m_pendingConfigureSerial = 0;
friend class QWaylandXdgShellV6;
};
diff --git a/src/client/qwaylandxdgshellv6integration.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
index cb82354b6..031643165 100644
--- a/src/client/qwaylandxdgshellv6integration.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
@@ -41,36 +41,26 @@
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
-#include <QtWaylandClient/private/qwaylandxdgsurface_p.h>
-#include <QtWaylandClient/private/qwaylandxdgpopup_p.h>
-#include <QtWaylandClient/private/qwaylandxdgshell_p.h>
-#include <QtWaylandClient/private/qwaylandxdgshellv6_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgShellV6Integration::QWaylandXdgShellV6Integration(QWaylandDisplay *display)
+bool QWaylandXdgShellV6Integration::initialize(QWaylandDisplay *display)
{
for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
if (global.interface == QLatin1String("zxdg_shell_v6")) {
- m_xdgShell = new QWaylandXdgShellV6(display->wl_registry(), global.id, global.version);
+ m_xdgShell.reset(new QWaylandXdgShellV6(display->wl_registry(), global.id, global.version));
break;
}
}
-}
-QWaylandXdgShellV6Integration *QWaylandXdgShellV6Integration::create(QWaylandDisplay *display)
-{
- if (display->hasRegistryGlobal(QLatin1String("zxdg_shell_v6")))
- return new QWaylandXdgShellV6Integration(display);
- return nullptr;
-}
+ if (!m_xdgShell) {
+ qCDebug(lcQpaWayland) << "Couldn't find global zxdg_shell_v6 for xdg-shell unstable v6";
+ return false;
+ }
-bool QWaylandXdgShellV6Integration::initialize(QWaylandDisplay *display)
-{
- QWaylandShellIntegration::initialize(display);
- return m_xdgShell != nullptr;
+ return QWaylandShellIntegration::initialize(display);
}
QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWaylandWindow *window)
@@ -78,6 +68,20 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
return m_xdgShell->getXdgSurface(window);
}
+void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+{
+ if (newFocus) {
+ auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+ if (xdgSurface && !xdgSurface->handlesActiveState())
+ m_display->handleWindowActivated(newFocus);
+ }
+ if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+ auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+ if (xdgSurface && !xdgSurface->handlesActiveState())
+ m_display->handleWindowDeactivated(oldFocus);
+ }
+}
+
}
QT_END_NAMESPACE
diff --git a/src/client/qwaylandxdgshellv6integration_p.h b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
index bdfd19723..261f8cbb4 100644
--- a/src/client/qwaylandxdgshellv6integration_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <wayland-client.h>
+#include "qwaylandxdgshellv6_p.h"
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
@@ -59,19 +59,16 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-class QWaylandXdgShellV6;
-
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellV6Integration : public QWaylandShellIntegration
{
public:
- static QWaylandXdgShellV6Integration *create(QWaylandDisplay* display);
+ QWaylandXdgShellV6Integration() {}
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+ void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
private:
- QWaylandXdgShellV6Integration(QWaylandDisplay *display);
-
- QWaylandXdgShellV6 *m_xdgShell = nullptr;
+ QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
};
}
diff --git a/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.json b/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.json
new file mode 100644
index 000000000..b1b8db31b
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "xdg-shell-v6" ]
+}
diff --git a/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro b/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro
new file mode 100644
index 000000000..5d5046f60
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro
@@ -0,0 +1,25 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE_PRIVATE += xkbcommon_evdev
+
+WAYLANDCLIENTSOURCES += \
+ ../../../3rdparty/protocol/xdg-shell-unstable-v6.xml
+
+HEADERS += \
+ qwaylandxdgshellv6_p.h \
+ qwaylandxdgshellv6integration_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandxdgshellv6.cpp \
+ qwaylandxdgshellv6integration.cpp \
+
+OTHER_FILES += \
+ xdg-shell-v6.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandXdgShellV6IntegrationPlugin
+load(qt_plugin)
diff --git a/src/plugins/shellintegration/xdg-shell/main.cpp b/src/plugins/shellintegration/xdg-shell/main.cpp
new file mode 100644
index 000000000..a9ea4bc1e
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellintegration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellIntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "xdg-shell.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandXdgShellIntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandXdgShellIntegration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
new file mode 100644
index 000000000..12c77d80d
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -0,0 +1,338 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshell_p.h"
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ : QtWayland::xdg_toplevel(xdgSurface->get_toplevel())
+ , m_xdgSurface(xdgSurface)
+{
+ requestWindowStates(xdgSurface->window()->window()->windowStates());
+}
+
+QWaylandXdgSurface::Toplevel::~Toplevel()
+{
+ if (m_applied.states & Qt::WindowActive) {
+ QWaylandWindow *window = m_xdgSurface->window();
+ window->display()->handleWindowDeactivated(window);
+ }
+ if (isInitialized())
+ destroy();
+}
+
+void QWaylandXdgSurface::Toplevel::applyConfigure()
+{
+ if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+ m_normalSize = m_xdgSurface->m_window->window()->frameGeometry().size();
+
+ if (m_pending.size.isEmpty() && !m_normalSize.isEmpty())
+ m_pending.size = m_normalSize;
+
+ if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
+ m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+
+ if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
+ m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+
+ // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+ Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+
+ m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
+ m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+ QSize windowGeometrySize = m_xdgSurface->m_window->window()->frameGeometry().size();
+ m_xdgSurface->set_window_geometry(0, 0, windowGeometrySize.width(), windowGeometrySize.height());
+ m_applied = m_pending;
+}
+
+void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states)
+{
+ m_pending.size = QSize(width, height);
+
+ auto *xdgStates = static_cast<uint32_t *>(states->data);
+ size_t numStates = states->size / sizeof(uint32_t);
+
+ m_pending.states = Qt::WindowNoState;
+
+ for (size_t i = 0; i < numStates; i++) {
+ switch (xdgStates[i]) {
+ case XDG_TOPLEVEL_STATE_ACTIVATED:
+ m_pending.states |= Qt::WindowActive;
+ break;
+ case XDG_TOPLEVEL_STATE_MAXIMIZED:
+ m_pending.states |= Qt::WindowMaximized;
+ break;
+ case XDG_TOPLEVEL_STATE_FULLSCREEN:
+ m_pending.states |= Qt::WindowFullScreen;
+ break;
+ default:
+ break;
+ }
+ }
+ qCDebug(lcQpaWayland) << "Received xdg_toplevel.configure with" << m_pending.size
+ << "and" << m_pending.states;
+}
+
+void QWaylandXdgSurface::Toplevel::xdg_toplevel_close()
+{
+ m_xdgSurface->m_window->window()->close();
+}
+
+void QWaylandXdgSurface::Toplevel::requestWindowStates(Qt::WindowStates states)
+{
+ // Re-send what's different from the applied state
+ Qt::WindowStates changedStates = m_applied.states ^ states;
+
+ if (changedStates & Qt::WindowMaximized) {
+ if (states & Qt::WindowMaximized)
+ set_maximized();
+ else
+ unset_maximized();
+ }
+
+ if (changedStates & Qt::WindowFullScreen) {
+ if (states & Qt::WindowFullScreen)
+ set_fullscreen(nullptr);
+ else
+ unset_fullscreen();
+ }
+
+ // Minimized state is not reported by the protocol, so always send it
+ if (states & Qt::WindowMinimized) {
+ set_minimized();
+ m_xdgSurface->window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized);
+ }
+}
+
+QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
+ QtWayland::xdg_positioner *positioner)
+ : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+ , m_xdgSurface(xdgSurface)
+{
+}
+
+QWaylandXdgSurface::Popup::~Popup()
+{
+ if (isInitialized())
+ destroy();
+}
+
+void QWaylandXdgSurface::Popup::xdg_popup_popup_done()
+{
+ m_xdgSurface->m_window->window()->close();
+}
+
+QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *surface, QWaylandWindow *window)
+ : QWaylandShellSurface(window)
+ , xdg_surface(surface)
+ , m_shell(shell)
+ , m_window(window)
+{
+ QWaylandDisplay *display = window->display();
+ Qt::WindowType type = window->window()->type();
+ auto *transientParent = window->transientParent();
+
+ if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) {
+ setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup);
+ } else {
+ setToplevel();
+ if (transientParent) {
+ auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(transientParent->shellSurface());
+ if (parentXdgSurface)
+ m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+ }
+ }
+}
+
+QWaylandXdgSurface::~QWaylandXdgSurface()
+{
+ if (m_toplevel) {
+ delete m_toplevel;
+ m_toplevel = nullptr;
+ }
+ if (m_popup) {
+ delete m_popup;
+ m_popup = nullptr;
+ }
+ destroy();
+}
+
+void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, xdg_toplevel_resize_edge edges)
+{
+ Q_ASSERT(m_toplevel && m_toplevel->isInitialized());
+ m_toplevel->resize(inputDevice->wl_seat(), inputDevice->serial(), edges);
+}
+
+void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
+{
+ auto xdgEdges = reinterpret_cast<enum xdg_toplevel_resize_edge const *>(&edges);
+ resize(inputDevice, *xdgEdges);
+}
+
+
+bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
+{
+ if (m_toplevel && m_toplevel->isInitialized()) {
+ m_toplevel->move(inputDevice->wl_seat(), inputDevice->serial());
+ return true;
+ }
+ return false;
+}
+
+void QWaylandXdgSurface::setTitle(const QString &title)
+{
+ if (m_toplevel)
+ m_toplevel->set_title(title);
+}
+
+void QWaylandXdgSurface::setAppId(const QString &appId)
+{
+ if (m_toplevel)
+ m_toplevel->set_app_id(appId);
+}
+
+bool QWaylandXdgSurface::handleExpose(const QRegion &region)
+{
+ if (!m_configured && !region.isEmpty()) {
+ m_exposeRegion = region;
+ return true;
+ }
+ return false;
+}
+
+void QWaylandXdgSurface::applyConfigure()
+{
+ Q_ASSERT(m_pendingConfigureSerial != 0);
+
+ if (m_toplevel)
+ m_toplevel->applyConfigure();
+
+ m_configured = true;
+ ack_configure(m_pendingConfigureSerial);
+
+ m_pendingConfigureSerial = 0;
+}
+
+bool QWaylandXdgSurface::wantsDecorations() const
+{
+ return m_toplevel && !(m_toplevel->m_pending.states & Qt::WindowFullScreen);
+}
+
+void QWaylandXdgSurface::requestWindowStates(Qt::WindowStates states)
+{
+ if (m_toplevel)
+ m_toplevel->requestWindowStates(states);
+ else
+ qCWarning(lcQpaWayland) << "Non-toplevel surfaces can't request window states";
+}
+
+void QWaylandXdgSurface::setToplevel()
+{
+ Q_ASSERT(!m_toplevel && !m_popup);
+ m_toplevel = new Toplevel(this);
+}
+
+void QWaylandXdgSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial, bool grab)
+{
+ Q_ASSERT(!m_toplevel && !m_popup);
+
+ auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+ auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+ // set_popup expects a position relative to the parent
+ QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+ transientPos -= parent->geometry().topLeft();
+ if (parent->decoration()) {
+ transientPos.setX(transientPos.x() + parent->decoration()->margins().left());
+ transientPos.setY(transientPos.y() + parent->decoration()->margins().top());
+ }
+ positioner->set_anchor_rect(transientPos.x(), transientPos.y(), 1, 1);
+ positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+ positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+ positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+ m_popup = new Popup(this, parentXdgSurface, positioner);
+ positioner->destroy();
+ delete positioner;
+ if (grab) {
+ m_popup->grab(device->wl_seat(), serial);
+ }
+}
+
+void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+{
+ m_window->applyConfigureWhenPossible();
+ m_pendingConfigureSerial = serial;
+ if (!m_exposeRegion.isEmpty()) {
+ QWindowSystemInterface::handleExposeEvent(m_window->window(), m_exposeRegion);
+ m_exposeRegion = QRegion();
+ }
+}
+
+QWaylandXdgShell::QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id, uint32_t availableVersion)
+ : QtWayland::xdg_wm_base(registry, id, qMin(availableVersion, 1u))
+{
+}
+
+QWaylandXdgShell::~QWaylandXdgShell()
+{
+ destroy();
+}
+
+QWaylandXdgSurface *QWaylandXdgShell::getXdgSurface(QWaylandWindow *window)
+{
+ return new QWaylandXdgSurface(this, get_xdg_surface(window->object()), window);
+}
+
+void QWaylandXdgShell::xdg_wm_base_ping(uint32_t serial)
+{
+ pong(serial);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
new file mode 100644
index 000000000..7fb851315
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELL_H
+#define QWAYLANDXDGSHELL_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 "qwayland-xdg-shell.h"
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
+
+#include <QtCore/QSize>
+#include <QtGui/QRegion>
+
+#include <wayland-client.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+
+namespace QtWaylandClient {
+
+class QWaylandWindow;
+class QWaylandInputDevice;
+class QWaylandXdgShell;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface, public QtWayland::xdg_surface
+{
+ Q_OBJECT
+public:
+ QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *surface, QWaylandWindow *window);
+ ~QWaylandXdgSurface() override;
+
+ void resize(QWaylandInputDevice *inputDevice, enum xdg_toplevel_resize_edge edges);
+ void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) override;
+ bool move(QWaylandInputDevice *inputDevice) override;
+ void setTitle(const QString &title) override;
+ void setAppId(const QString &appId) override;
+
+ bool isExposed() const override { return m_configured; }
+ bool handleExpose(const QRegion &) override;
+ bool handlesActiveState() const { return m_toplevel; }
+ void applyConfigure() override;
+ bool wantsDecorations() const override;
+
+protected:
+ void requestWindowStates(Qt::WindowStates states) override;
+ void xdg_surface_configure(uint32_t serial) override;
+
+private:
+ class Toplevel: public QtWayland::xdg_toplevel
+ {
+ public:
+ Toplevel(QWaylandXdgSurface *xdgSurface);
+ ~Toplevel() override;
+
+ void applyConfigure();
+
+ void xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states) override;
+ void xdg_toplevel_close() override;
+
+ void requestWindowStates(Qt::WindowStates states);
+ struct {
+ QSize size = {0, 0};
+ Qt::WindowStates states = Qt::WindowNoState;
+ } m_pending, m_applied;
+ QSize m_normalSize;
+
+ QWaylandXdgSurface *m_xdgSurface = nullptr;
+ };
+
+ class Popup : public QtWayland::xdg_popup {
+ public:
+ Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
+ ~Popup() override;
+
+ void xdg_popup_popup_done() override;
+
+ QWaylandXdgSurface *m_xdgSurface = nullptr;
+ };
+
+ void setToplevel();
+ void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial, bool grab);
+
+ QWaylandXdgShell *m_shell = nullptr;
+ QWaylandWindow *m_window = nullptr;
+ Toplevel *m_toplevel = nullptr;
+ Popup *m_popup = nullptr;
+ bool m_configured = false;
+ QRegion m_exposeRegion;
+ uint m_pendingConfigureSerial = 0;
+};
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_wm_base
+{
+public:
+ QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id, uint32_t availableVersion);
+
+ QWaylandXdgSurface *getXdgSurface(QWaylandWindow *window);
+
+ ~QWaylandXdgShell() override;
+
+private:
+ void xdg_wm_base_ping(uint32_t serial) override;
+};
+
+QT_END_NAMESPACE
+
+}
+
+#endif // QWAYLANDXDGSHELL_H
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
new file mode 100644
index 000000000..54d5b55ed
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellintegration_p.h"
+
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
+{
+ for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
+ if (global.interface == QLatin1String("xdg_wm_base")) {
+ m_xdgShell.reset(new QWaylandXdgShell(display->wl_registry(), global.id, global.version));
+ break;
+ }
+ }
+
+ if (!m_xdgShell) {
+ qCDebug(lcQpaWayland) << "Couldn't find global xdg_wm_base for xdg-shell stable";
+ return false;
+ }
+
+ return QWaylandShellIntegration::initialize(display);
+}
+
+QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
+{
+ return m_xdgShell->getXdgSurface(window);
+}
+
+void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+{
+ if (newFocus) {
+ auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+ if (xdgSurface && !xdgSurface->handlesActiveState())
+ m_display->handleWindowActivated(newFocus);
+ }
+ if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+ auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+ if (xdgSurface && !xdgSurface->handlesActiveState())
+ m_display->handleWindowDeactivated(oldFocus);
+ }
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/qwaylandxdgshellintegration_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
index ed307a5de..b6caa6c95 100644
--- a/src/client/qwaylandxdgshellintegration_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <wayland-client.h>
+#include "qwaylandxdgshell_p.h"
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
@@ -59,20 +59,16 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-class QWaylandXdgShell;
-
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShellIntegration
{
public:
- static QWaylandXdgShellIntegration *create(QWaylandDisplay* display);
+ QWaylandXdgShellIntegration() {}
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
private:
- QWaylandXdgShellIntegration(QWaylandDisplay *display);
-
- QWaylandXdgShell *m_xdgShell = nullptr;
+ QScopedPointer<QWaylandXdgShell> m_xdgShell;
};
}
diff --git a/src/plugins/shellintegration/xdg-shell/xdg-shell.json b/src/plugins/shellintegration/xdg-shell/xdg-shell.json
new file mode 100644
index 000000000..2de86b8d0
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/xdg-shell.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "xdg-shell" ]
+}
diff --git a/src/plugins/shellintegration/xdg-shell/xdg-shell.pro b/src/plugins/shellintegration/xdg-shell/xdg-shell.pro
new file mode 100644
index 000000000..1fabf2c64
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/xdg-shell.pro
@@ -0,0 +1,25 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE_PRIVATE += xkbcommon_evdev
+
+WAYLANDCLIENTSOURCES += \
+ ../../../3rdparty/protocol/xdg-shell.xml
+
+HEADERS += \
+ qwaylandxdgshell_p.h \
+ qwaylandxdgshellintegration_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandxdgshell.cpp \
+ qwaylandxdgshellintegration.cpp \
+
+OTHER_FILES += \
+ xdg-shell.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandXdgShellIntegrationPlugin
+load(qt_plugin)
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index 1b884a424..bdcbffa0d 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -41,92 +41,152 @@
#include <QFile>
#include <QXmlStreamReader>
-enum Option {
- ClientHeader,
- ServerHeader,
- ClientCode,
- ServerCode
-} option;
-
-bool isServerSide()
+class Scanner
{
- return option == ServerHeader || option == ServerCode;
+public:
+ explicit Scanner() {}
+ ~Scanner() { delete m_xml; }
+
+ bool parseArguments(int argc, char **argv);
+ void printUsage();
+ bool process();
+ void printErrors();
+
+private:
+ struct WaylandEnumEntry {
+ QByteArray name;
+ QByteArray value;
+ QByteArray summary;
+ };
+
+ struct WaylandEnum {
+ QByteArray name;
+
+ QList<WaylandEnumEntry> entries;
+ };
+
+ struct WaylandArgument {
+ QByteArray name;
+ QByteArray type;
+ QByteArray interface;
+ QByteArray summary;
+ bool allowNull;
+ };
+
+ struct WaylandEvent {
+ bool request;
+ QByteArray name;
+ QByteArray type;
+ QList<WaylandArgument> arguments;
+ };
+
+ struct WaylandInterface {
+ QByteArray name;
+ int version;
+
+ QList<WaylandEnum> enums;
+ QList<WaylandEvent> events;
+ QList<WaylandEvent> requests;
+ };
+
+ bool isServerSide();
+ bool parseOption(const char *str);
+
+ QByteArray byteArrayValue(const QXmlStreamReader &xml, const char *name);
+ int intValue(const QXmlStreamReader &xml, const char *name, int defaultValue = 0);
+ bool boolValue(const QXmlStreamReader &xml, const char *name);
+ WaylandEvent readEvent(QXmlStreamReader &xml, bool request);
+ Scanner::WaylandEnum readEnum(QXmlStreamReader &xml);
+ Scanner::WaylandInterface readInterface(QXmlStreamReader &xml);
+ QByteArray waylandToCType(const QByteArray &waylandType, const QByteArray &interface);
+ QByteArray waylandToQtType(const QByteArray &waylandType, const QByteArray &interface, bool cStyleArray);
+ const Scanner::WaylandArgument *newIdArgument(const QList<WaylandArgument> &arguments);
+
+ void printEvent(const WaylandEvent &e, bool omitNames = false, bool withResource = false);
+ void printEventHandlerSignature(const WaylandEvent &e, const char *interfaceName, bool deepIndent = true);
+ void printEnums(const QList<WaylandEnum> &enums);
+
+ QByteArray stripInterfaceName(const QByteArray &name);
+ bool ignoreInterface(const QByteArray &name);
+
+ enum Option {
+ ClientHeader,
+ ServerHeader,
+ ClientCode,
+ ServerCode
+ } m_option;
+
+ QByteArray m_protocolName;
+ QByteArray m_protocolFilePath;
+ QByteArray m_scannerName;
+ QByteArray m_headerPath;
+ QByteArray m_prefix;
+ QXmlStreamReader *m_xml = nullptr;
+};
+
+bool Scanner::parseArguments(int argc, char **argv)
+{
+ QByteArray m_scannerName = argv[0];
+
+ if (argc <= 2 || !parseOption(argv[1]))
+ return false;
+
+ m_protocolFilePath = QByteArray(argv[2]);
+
+ if (argc >= 4)
+ m_headerPath = QByteArray(argv[3]);
+ if (argc == 5)
+ m_prefix = QByteArray(argv[4]);
+
+ return true;
}
-QByteArray protocolName;
+void Scanner::printUsage()
+{
+ fprintf(stderr, "Usage: %s [client-header|server-header|client-code|server-code] specfile [header-path] [prefix]\n", m_scannerName.constData());
+}
-bool parseOption(const char *str, Option *option)
+bool Scanner::isServerSide()
+{
+ return m_option == ServerHeader || m_option == ServerCode;
+}
+
+bool Scanner::parseOption(const char *str)
{
if (str == QLatin1String("client-header"))
- *option = ClientHeader;
+ m_option = ClientHeader;
else if (str == QLatin1String("server-header"))
- *option = ServerHeader;
+ m_option = ServerHeader;
else if (str == QLatin1String("client-code"))
- *option = ClientCode;
+ m_option = ClientCode;
else if (str == QLatin1String("server-code"))
- *option = ServerCode;
+ m_option = ServerCode;
else
return false;
return true;
}
-struct WaylandEnumEntry {
- QByteArray name;
- QByteArray value;
- QByteArray summary;
-};
-
-struct WaylandEnum {
- QByteArray name;
-
- QList<WaylandEnumEntry> entries;
-};
-
-struct WaylandArgument {
- QByteArray name;
- QByteArray type;
- QByteArray interface;
- QByteArray summary;
- bool allowNull;
-};
-
-struct WaylandEvent {
- bool request;
- QByteArray name;
- QByteArray type;
- QList<WaylandArgument> arguments;
-};
-
-struct WaylandInterface {
- QByteArray name;
- int version;
-
- QList<WaylandEnum> enums;
- QList<WaylandEvent> events;
- QList<WaylandEvent> requests;
-};
-
-QByteArray byteArrayValue(const QXmlStreamReader &xml, const char *name)
+QByteArray Scanner::byteArrayValue(const QXmlStreamReader &xml, const char *name)
{
if (xml.attributes().hasAttribute(name))
return xml.attributes().value(name).toUtf8();
return QByteArray();
}
-int intValue(const QXmlStreamReader &xml, const char *name, int defaultValue = 0)
+int Scanner::intValue(const QXmlStreamReader &xml, const char *name, int defaultValue)
{
bool ok;
int result = byteArrayValue(xml, name).toInt(&ok);
return ok ? result : defaultValue;
}
-bool boolValue(const QXmlStreamReader &xml, const char *name)
+bool Scanner::boolValue(const QXmlStreamReader &xml, const char *name)
{
return byteArrayValue(xml, name) == "true";
}
-WaylandEvent readEvent(QXmlStreamReader &xml, bool request)
+Scanner::WaylandEvent Scanner::readEvent(QXmlStreamReader &xml, bool request)
{
WaylandEvent event;
event.request = request;
@@ -148,7 +208,7 @@ WaylandEvent readEvent(QXmlStreamReader &xml, bool request)
return event;
}
-WaylandEnum readEnum(QXmlStreamReader &xml)
+Scanner::WaylandEnum Scanner::readEnum(QXmlStreamReader &xml)
{
WaylandEnum result;
result.name = byteArrayValue(xml, "name");
@@ -168,7 +228,7 @@ WaylandEnum readEnum(QXmlStreamReader &xml)
return result;
}
-WaylandInterface readInterface(QXmlStreamReader &xml)
+Scanner::WaylandInterface Scanner::readInterface(QXmlStreamReader &xml)
{
WaylandInterface interface;
interface.name = byteArrayValue(xml, "name");
@@ -188,7 +248,7 @@ WaylandInterface readInterface(QXmlStreamReader &xml)
return interface;
}
-QByteArray waylandToCType(const QByteArray &waylandType, const QByteArray &interface)
+QByteArray Scanner::waylandToCType(const QByteArray &waylandType, const QByteArray &interface)
{
if (waylandType == "string")
return "const char *";
@@ -212,7 +272,7 @@ QByteArray waylandToCType(const QByteArray &waylandType, const QByteArray &inter
return waylandType;
}
-QByteArray waylandToQtType(const QByteArray &waylandType, const QByteArray &interface, bool cStyleArray)
+QByteArray Scanner::waylandToQtType(const QByteArray &waylandType, const QByteArray &interface, bool cStyleArray)
{
if (waylandType == "string")
return "const QString &";
@@ -222,7 +282,7 @@ QByteArray waylandToQtType(const QByteArray &waylandType, const QByteArray &inte
return waylandToCType(waylandType, interface);
}
-const WaylandArgument *newIdArgument(const QList<WaylandArgument> &arguments)
+const Scanner::WaylandArgument *Scanner::newIdArgument(const QList<WaylandArgument> &arguments)
{
for (int i = 0; i < arguments.size(); ++i) {
if (arguments.at(i).type == "new_id")
@@ -231,7 +291,7 @@ const WaylandArgument *newIdArgument(const QList<WaylandArgument> &arguments)
return nullptr;
}
-void printEvent(const WaylandEvent &e, bool omitNames = false, bool withResource = false)
+void Scanner::printEvent(const WaylandEvent &e, bool omitNames, bool withResource)
{
printf("%s(", e.name.constData());
bool needsComma = false;
@@ -274,7 +334,7 @@ void printEvent(const WaylandEvent &e, bool omitNames = false, bool withResource
printf(")");
}
-void printEventHandlerSignature(const WaylandEvent &e, const char *interfaceName, bool deepIndent = true)
+void Scanner::printEventHandlerSignature(const WaylandEvent &e, const char *interfaceName, bool deepIndent)
{
const char *indent = deepIndent ? " " : "";
printf("handle_%s(\n", e.name.constData());
@@ -299,7 +359,7 @@ void printEventHandlerSignature(const WaylandEvent &e, const char *interfaceName
printf(")");
}
-void printEnums(const QList<WaylandEnum> &enums)
+void Scanner::printEnums(const QList<WaylandEnum> &enums)
{
for (int i = 0; i < enums.size(); ++i) {
printf("\n");
@@ -318,66 +378,73 @@ void printEnums(const QList<WaylandEnum> &enums)
}
}
-QByteArray stripInterfaceName(const QByteArray &name, const QByteArray &prefix)
+QByteArray Scanner::stripInterfaceName(const QByteArray &name)
{
- if (!prefix.isEmpty() && name.startsWith(prefix))
- return name.mid(prefix.size());
+ if (!m_prefix.isEmpty() && name.startsWith(m_prefix))
+ return name.mid(m_prefix.size());
if (name.startsWith("qt_") || name.startsWith("wl_"))
return name.mid(3);
return name;
}
-bool ignoreInterface(const QByteArray &name)
+bool Scanner::ignoreInterface(const QByteArray &name)
{
return name == "wl_display"
|| (isServerSide() && name == "wl_registry");
}
-void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArray &prefix)
+bool Scanner::process()
{
- if (!xml.readNextStartElement())
- return;
+ QFile file(m_protocolFilePath);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ fprintf(stderr, "Unable to open file %s\n", m_protocolFilePath.constData());
+ return false;
+ }
- if (xml.name() != "protocol") {
- xml.raiseError(QStringLiteral("The file is not a wayland protocol file."));
- return;
+ m_xml = new QXmlStreamReader(&file);
+ if (!m_xml->readNextStartElement())
+ return false;
+
+ if (m_xml->name() != "protocol") {
+ m_xml->raiseError(QStringLiteral("The file is not a wayland protocol file."));
+ return false;
}
- protocolName = byteArrayValue(xml, "name");
+ m_protocolName = byteArrayValue(*m_xml, "name");
- if (protocolName.isEmpty()) {
- xml.raiseError(QStringLiteral("Missing protocol name."));
- return;
+ if (m_protocolName.isEmpty()) {
+ m_xml->raiseError(QStringLiteral("Missing protocol name."));
+ return false;
}
//We should convert - to _ so that the preprocessor wont generate code which will lead to unexpected behavior
//However, the wayland-scanner doesn't do so we will do the same for now
- //QByteArray preProcessorProtocolName = QByteArray(protocolName).replace('-', '_').toUpper();
- QByteArray preProcessorProtocolName = QByteArray(protocolName).toUpper();
+ //QByteArray preProcessorProtocolName = QByteArray(m_protocolName).replace('-', '_').toUpper();
+ QByteArray preProcessorProtocolName = QByteArray(m_protocolName).toUpper();
QList<WaylandInterface> interfaces;
- while (xml.readNextStartElement()) {
- if (xml.name() == "interface")
- interfaces << readInterface(xml);
+ while (m_xml->readNextStartElement()) {
+ if (m_xml->name() == "interface")
+ interfaces << readInterface(*m_xml);
else
- xml.skipCurrentElement();
+ m_xml->skipCurrentElement();
}
- if (xml.hasError())
- return;
+ if (m_xml->hasError())
+ return false;
- if (option == ServerHeader) {
+ if (m_option == ServerHeader) {
QByteArray inclusionGuard = QByteArray("QT_WAYLAND_SERVER_") + preProcessorProtocolName.constData();
printf("#ifndef %s\n", inclusionGuard.constData());
printf("#define %s\n", inclusionGuard.constData());
printf("\n");
printf("#include \"wayland-server.h\"\n");
- if (headerPath.isEmpty())
- printf("#include \"wayland-%s-server-protocol.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
+ if (m_headerPath.isEmpty())
+ printf("#include \"wayland-%s-server-protocol.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
else
- printf("#include <%s/wayland-%s-server-protocol.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData());
+ printf("#include <%s/wayland-%s-server-protocol.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
printf("#include <QByteArray>\n");
printf("#include <QMultiMap>\n");
printf("#include <QString>\n");
@@ -396,7 +463,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("QT_WARNING_DISABLE_GCC(\"-Wmissing-field-initializers\")\n");
printf("QT_WARNING_DISABLE_CLANG(\"-Wmissing-field-initializers\")\n");
QByteArray serverExport;
- if (headerPath.size()) {
+ if (m_headerPath.size()) {
serverExport = QByteArray("Q_WAYLAND_SERVER_") + preProcessorProtocolName + "_EXPORT";
printf("\n");
printf("#if !defined(%s)\n", serverExport.constData());
@@ -418,7 +485,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
const char *interfaceName = interface.name.constData();
- QByteArray stripped = stripInterfaceName(interface.name, prefix);
+ QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
printf(" class %s %s\n {\n", serverExport.constData(), interfaceName);
@@ -547,11 +614,11 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("#endif\n");
}
- if (option == ServerCode) {
- if (headerPath.isEmpty())
- printf("#include \"qwayland-server-%s.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
+ if (m_option == ServerCode) {
+ if (m_headerPath.isEmpty())
+ printf("#include \"qwayland-server-%s.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
else
- printf("#include <%s/qwayland-server-%s.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData());
+ printf("#include <%s/qwayland-server-%s.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
printf("\n");
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");
@@ -573,7 +640,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
const char *interfaceName = interface.name.constData();
- QByteArray stripped = stripInterfaceName(interface.name, prefix);
+ QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
printf(" %s::%s(struct ::wl_client *client, int id, int version)\n", interfaceName, interfaceName);
@@ -860,15 +927,15 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("QT_END_NAMESPACE\n");
}
- if (option == ClientHeader) {
+ if (m_option == ClientHeader) {
QByteArray inclusionGuard = QByteArray("QT_WAYLAND_") + preProcessorProtocolName.constData();
printf("#ifndef %s\n", inclusionGuard.constData());
printf("#define %s\n", inclusionGuard.constData());
printf("\n");
- if (headerPath.isEmpty())
- printf("#include \"wayland-%s-client-protocol.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
+ if (m_headerPath.isEmpty())
+ printf("#include \"wayland-%s-client-protocol.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
else
- printf("#include <%s/wayland-%s-client-protocol.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData());
+ printf("#include <%s/wayland-%s-client-protocol.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
printf("#include <QByteArray>\n");
printf("#include <QString>\n");
printf("\n");
@@ -878,7 +945,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
QByteArray clientExport;
- if (headerPath.size()) {
+ if (m_headerPath.size()) {
clientExport = QByteArray("Q_WAYLAND_CLIENT_") + preProcessorProtocolName + "_EXPORT";
printf("\n");
printf("#if !defined(%s)\n", clientExport.constData());
@@ -899,7 +966,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
const char *interfaceName = interface.name.constData();
- QByteArray stripped = stripInterfaceName(interface.name, prefix);
+ QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
printf(" class %s %s\n {\n", clientExport.constData(), interfaceName);
@@ -978,11 +1045,11 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("#endif\n");
}
- if (option == ClientCode) {
- if (headerPath.isEmpty())
- printf("#include \"qwayland-%s.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
+ if (m_option == ClientCode) {
+ if (m_headerPath.isEmpty())
+ printf("#include \"qwayland-%s.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
else
- printf("#include <%s/qwayland-%s.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData());
+ printf("#include <%s/qwayland-%s.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
printf("\n");
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");
@@ -997,7 +1064,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
const char *interfaceName = interface.name.constData();
- QByteArray stripped = stripInterfaceName(interface.name, prefix);
+ QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
bool hasEvents = !interface.events.isEmpty();
@@ -1172,34 +1239,30 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("QT_WARNING_POP\n");
printf("QT_END_NAMESPACE\n");
}
+
+ return true;
}
-int main(int argc, char **argv)
+void Scanner::printErrors()
{
- if (argc <= 2 || !parseOption(argv[1], &option)) {
- fprintf(stderr, "Usage: %s [client-header|server-header|client-code|server-code] specfile [header-path] [prefix]\n", argv[0]);
- return 1;
- }
+ if (m_xml->hasError())
+ fprintf(stderr, "XML error: %s\nLine %lld, column %lld\n", m_xml->errorString().toLocal8Bit().constData(), m_xml->lineNumber(), m_xml->columnNumber());
+}
+int main(int argc, char **argv)
+{
QCoreApplication app(argc, argv);
+ Scanner scanner;
- QByteArray headerPath;
- if (argc >= 4)
- headerPath = QByteArray(argv[3]);
- QByteArray prefix;
- if (argc == 5)
- prefix = QByteArray(argv[4]);
- QFile file(argv[2]);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- fprintf(stderr, "Unable to open file %s\n", argv[2]);
- return 1;
+ if (!scanner.parseArguments(argc, argv)) {
+ scanner.printUsage();
+ return EXIT_FAILURE;
}
- QXmlStreamReader xml(&file);
- process(xml, headerPath, prefix);
-
- if (xml.hasError()) {
- fprintf(stderr, "XML error: %s\nLine %lld, column %lld\n", xml.errorString().toLocal8Bit().constData(), xml.lineNumber(), xml.columnNumber());
- return 1;
+ if (!scanner.process()) {
+ scanner.printErrors();
+ return EXIT_FAILURE;
}
+
+ return EXIT_SUCCESS;
}
diff --git a/sync.profile b/sync.profile
index a2da7dbc4..7d09d0629 100644
--- a/sync.profile
+++ b/sync.profile
@@ -21,23 +21,33 @@
"$basedir/src/client" => [
"^qwayland-hardware-integration.h",
"^qwayland-qt-windowmanager.h",
- "^qwayland-qtkey-extension.h" ,
+ "^qwayland-qt-key-unstable-v1.h" ,
"^qwayland-server-buffer-extension.h",
"^qwayland-surface-extension.h",
"^qwayland-text-input-unstable-v2.h",
"^qwayland-touch-extension.h",
"^qwayland-wayland.h",
- "^qwayland-xdg-shell-unstable-v6.h",
- "^qwayland-xdg-shell.h",
+ "^qwayland-xdg-output-unstable-v1.h",
"^wayland-hardware-integration-client-protocol.h",
"^wayland-qt-windowmanager-client-protocol.h",
- "^wayland-qtkey-extension-client-protocol.h",
+ "^wayland-qt-key-unstable-v1-client-protocol.h",
"^wayland-server-buffer-extension-client-protocol.h",
"^wayland-surface-extension-client-protocol.h",
"^wayland-text-input-unstable-v2-client-protocol.h",
"^wayland-touch-extension-client-protocol.h",
"^wayland-wayland-client-protocol.h",
+ "^wayland-xdg-output-unstable-v1-client-protocol.h",
+ ],
+ "$basedir/src/plugins/shellintegration/xdg-shell" => [
+ "^qwayland-xdg-shell.h",
"^wayland-xdg-shell-client-protocol.h",
+ ],
+ "$basedir/src/plugins/shellintegration/xdg-shell-v5" => [
+ "^qwayland-xdg-shell-unstable-v5.h",
+ "^wayland-xdg-shell-unstable-v5-client-protocol.h",
+ ],
+ "$basedir/src/plugins/shellintegration/xdg-shell-v6" => [
+ "^qwayland-xdg-shell-unstable-v6.h",
"^wayland-xdg-shell-unstable-v6-client-protocol.h",
],
"$basedir/src/compositor" => [
@@ -45,21 +55,21 @@
"^qwayland-server-hardware-integration.h",
"^qwayland-server-ivi-application.h",
"^qwayland-server-qt-windowmanager.h",
- "^qwayland-server-qtkey-extension.h",
+ "^qwayland-server-qt-key-unstable-v1.h",
"^qwayland-server-server-buffer-extension.h",
"^qwayland-server-text-input-unstable-v2.h",
"^qwayland-server-touch-extension.h",
+ "^qwayland-server-xdg-shell-unstable-v5.h",
"^qwayland-server-xdg-shell-unstable-v6.h",
- "^qwayland-server-xdg-shell.h",
"^wayland-hardware-integration-server-protocol.h",
"^wayland-ivi-application-server-protocol.h",
"^wayland-qt-windowmanager-server-protocol.h",
- "^wayland-qtkey-extension-server-protocol.h",
+ "^wayland-qt-key-unstable-v1-server-protocol.h",
"^wayland-server-buffer-extension-server-protocol.h",
"^wayland-text-input-unstable-v2-server-protocol.h",
"^wayland-touch-extension-server-protocol.h",
"^wayland-wayland-server-protocol.h",
- "^wayland-xdg-shell-server-protocol.h",
+ "^wayland-xdg-shell-unstable-v5-server-protocol.h",
"^wayland-xdg-shell-unstable-v6-server-protocol.h",
],
);
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp
index 874de82cc..470db25a4 100644
--- a/tests/auto/client/client/tst_client.cpp
+++ b/tests/auto/client/client/tst_client.cpp
@@ -173,6 +173,7 @@ private slots:
void windowScreens();
void removePrimaryScreen();
void createDestroyWindow();
+ void activeWindowFollowsKeyboardFocus();
void events();
void backingStore();
void touchDrag();
@@ -309,7 +310,7 @@ void tst_WaylandClient::createDestroyWindow()
QTRY_VERIFY(!compositor->surface());
}
-void tst_WaylandClient::events()
+void tst_WaylandClient::activeWindowFollowsKeyboardFocus()
{
TestWindow window;
window.show();
@@ -320,6 +321,9 @@ void tst_WaylandClient::events()
QTRY_VERIFY(window.isExposed());
+ if (compositor->xdgToplevelV6())
+ QSKIP("On xdg-shell v6 focus is handled by configure events");
+
QCOMPARE(window.focusInEventCount, 0);
compositor->setKeyboardFocus(surface);
QTRY_COMPARE(window.focusInEventCount, 1);
@@ -329,9 +333,21 @@ void tst_WaylandClient::events()
compositor->setKeyboardFocus(QSharedPointer<MockSurface>(nullptr));
QTRY_COMPARE(window.focusOutEventCount, 1);
QTRY_COMPARE(QGuiApplication::focusWindow(), static_cast<QWindow *>(nullptr));
+}
+
+void tst_WaylandClient::events()
+{
+ TestWindow window;
+ window.show();
+
+ QSharedPointer<MockSurface> surface;
+ QTRY_VERIFY(surface = compositor->surface());
+ compositor->sendShellSurfaceConfigure(surface);
+
+ QTRY_VERIFY(window.isExposed());
compositor->setKeyboardFocus(surface);
- QTRY_COMPARE(window.focusInEventCount, 2);
+ QTRY_COMPARE(window.focusInEventCount, 1);
QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
uint keyCode = 80; // arbitrarily chosen
diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index 9ef08ad95..077b8ee05 100644
--- a/tests/auto/client/shared/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -236,11 +236,14 @@ void MockCompositor::sendIviSurfaceConfigure(const QSharedPointer<MockIviSurface
processCommand(command);
}
-void MockCompositor::sendXdgToplevelV6Configure(const QSharedPointer<MockXdgToplevelV6> toplevel, const QSize &size)
+void MockCompositor::sendXdgToplevelV6Configure(const QSharedPointer<MockXdgToplevelV6> toplevel, const QSize &size, const QVector<uint> &states)
{
Command command = makeCommand(Impl::Compositor::sendXdgToplevelV6Configure, m_compositor);
command.parameters << QVariant::fromValue(toplevel);
command.parameters << QVariant::fromValue(size);
+ QByteArray statesBytes(reinterpret_cast<const char *>(states.data()),
+ states.size() * static_cast<int>(sizeof(uint)));
+ command.parameters << statesBytes;
processCommand(command);
}
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index 34c20943a..51b6f4bfb 100644
--- a/tests/auto/client/shared/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -175,12 +175,22 @@ private:
Q_DECLARE_METATYPE(QSharedPointer<MockIviSurface>)
-class MockXdgToplevelV6
+class MockXdgToplevelV6 : public QObject
{
+ Q_OBJECT
public:
Impl::XdgToplevelV6 *handle() const { return m_toplevel; }
void sendConfigure(const QSharedPointer<MockXdgToplevelV6> toplevel);
+
+signals:
+ uint setMinimizedRequested();
+ uint setMaximizedRequested();
+ uint unsetMaximizedRequested();
+ uint setFullscreenRequested();
+ uint unsetFullscreenRequested();
+ void windowGeometryRequested(QRect geometry); // NOTE: This is really an xdg surface event
+
private:
MockXdgToplevelV6(Impl::XdgToplevelV6 *toplevel) : m_toplevel(toplevel) {}
friend class Impl::Compositor;
@@ -234,7 +244,8 @@ public:
void sendSurfaceLeave(const QSharedPointer<MockSurface> &surface, QSharedPointer<MockOutput> &output);
void sendShellSurfaceConfigure(const QSharedPointer<MockSurface> surface, const QSize &size = QSize(0, 0));
void sendIviSurfaceConfigure(const QSharedPointer<MockIviSurface> iviSurface, const QSize &size);
- void sendXdgToplevelV6Configure(const QSharedPointer<MockXdgToplevelV6> toplevel, const QSize &size = QSize(0, 0));
+ void sendXdgToplevelV6Configure(const QSharedPointer<MockXdgToplevelV6> toplevel, const QSize &size = QSize(0, 0),
+ const QVector<uint> &states = { ZXDG_TOPLEVEL_V6_STATE_ACTIVATED });
void waitForStartDrag();
QSharedPointer<MockSurface> surface();
diff --git a/tests/auto/client/shared/mocksurface.cpp b/tests/auto/client/shared/mocksurface.cpp
index 81a865f11..82ce37acb 100644
--- a/tests/auto/client/shared/mocksurface.cpp
+++ b/tests/auto/client/shared/mocksurface.cpp
@@ -70,7 +70,10 @@ void Compositor::sendShellSurfaceConfigure(void *data, const QList<QVariant> &pa
QSize size = parameters.at(1).toSize();
Q_ASSERT(size.isValid());
if (auto toplevel = surface->xdgToplevelV6()) {
- toplevel->send_configure(size.width(), size.height(), QByteArray());
+ QVector<uint> states = { ZXDG_TOPLEVEL_V6_STATE_ACTIVATED };
+ auto statesBytes = QByteArray::fromRawData(reinterpret_cast<const char *>(states.data()),
+ states.size() * static_cast<int>(sizeof(uint)));
+ toplevel->send_configure(size.width(), size.height(), statesBytes);
toplevel->xdgSurface()->send_configure(compositor->nextSerial());
} else if (auto wlShellSurface = surface->wlShellSurface()) {
const uint edges = 0;
diff --git a/tests/auto/client/shared/mockxdgshellv6.cpp b/tests/auto/client/shared/mockxdgshellv6.cpp
index 39e03296d..014a24be7 100644
--- a/tests/auto/client/shared/mockxdgshellv6.cpp
+++ b/tests/auto/client/shared/mockxdgshellv6.cpp
@@ -39,8 +39,8 @@ void Compositor::sendXdgToplevelV6Configure(void *data, const QList<QVariant> &p
Q_ASSERT(toplevel && toplevel->resource());
QSize size = parameters.at(1).toSize();
Q_ASSERT(size.isValid());
- QByteArray states;
- toplevel->send_configure(size.width(), size.height(), states);
+ auto statesBytes = parameters.at(2).toByteArray();
+ toplevel->send_configure(size.width(), size.height(), statesBytes);
toplevel->xdgSurface()->send_configure(compositor->nextSerial());
}
@@ -57,6 +57,14 @@ void XdgSurfaceV6::zxdg_surface_v6_get_toplevel(QtWaylandServer::zxdg_surface_v6
m_toplevel = new XdgToplevelV6(this, resource->client(), id, version);
}
+void XdgSurfaceV6::zxdg_surface_v6_set_window_geometry(QtWaylandServer::zxdg_surface_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ if (m_toplevel) {
+ QRect geometry(x, y, width, height);
+ emit m_toplevel->mockToplevel()->windowGeometryRequested(geometry);
+ }
+}
+
void XdgSurfaceV6::zxdg_surface_v6_destroy(QtWaylandServer::zxdg_surface_v6::Resource *resource)
{
Q_ASSERT(!m_toplevel);
@@ -87,6 +95,37 @@ void XdgToplevelV6::zxdg_toplevel_v6_destroy(QtWaylandServer::zxdg_toplevel_v6::
wl_resource_destroy(resource->handle);
}
+void XdgToplevelV6::zxdg_toplevel_v6_set_minimized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource)
+{
+ Q_UNUSED(resource);
+ emit m_mockToplevel->setMinimizedRequested();
+}
+
+void XdgToplevelV6::zxdg_toplevel_v6_set_maximized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource)
+{
+ Q_UNUSED(resource);
+ emit m_mockToplevel->setMaximizedRequested();
+}
+
+void XdgToplevelV6::zxdg_toplevel_v6_unset_maximized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource)
+{
+ Q_UNUSED(resource);
+ emit m_mockToplevel->unsetMaximizedRequested();
+}
+
+void XdgToplevelV6::zxdg_toplevel_v6_set_fullscreen(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *output)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(output);
+ emit m_mockToplevel->setFullscreenRequested();
+}
+
+void XdgToplevelV6::zxdg_toplevel_v6_unset_fullscreen(QtWaylandServer::zxdg_toplevel_v6::Resource *resource)
+{
+ Q_UNUSED(resource);
+ emit m_mockToplevel->unsetFullscreenRequested();
+}
+
void Impl::XdgShellV6::zxdg_shell_v6_get_xdg_surface(QtWaylandServer::zxdg_shell_v6::Resource *resource, uint32_t id, wl_resource *surface)
{
new XdgSurfaceV6(this, Surface::fromResource(surface), resource->client(), id);
diff --git a/tests/auto/client/shared/mockxdgshellv6.h b/tests/auto/client/shared/mockxdgshellv6.h
index 92b808ba8..bd5e13063 100644
--- a/tests/auto/client/shared/mockxdgshellv6.h
+++ b/tests/auto/client/shared/mockxdgshellv6.h
@@ -52,6 +52,7 @@ public:
protected:
void zxdg_surface_v6_destroy_resource(Resource *) override { delete this; }
void zxdg_surface_v6_get_toplevel(Resource *resource, uint32_t id) override;
+ void zxdg_surface_v6_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
void zxdg_surface_v6_destroy(Resource *resource) override;
private:
@@ -74,6 +75,11 @@ public:
protected:
void zxdg_toplevel_v6_destroy_resource(Resource *) override { delete this; }
void zxdg_toplevel_v6_destroy(Resource *resource) override;
+ void zxdg_toplevel_v6_set_minimized(Resource *resource) override;
+ void zxdg_toplevel_v6_set_maximized(Resource *resource) override;
+ void zxdg_toplevel_v6_unset_maximized(Resource *resource) override;
+ void zxdg_toplevel_v6_set_fullscreen(Resource *resource, struct ::wl_resource *output) override;
+ void zxdg_toplevel_v6_unset_fullscreen(Resource *resource) override;
private:
XdgSurfaceV6 *m_xdgSurface = nullptr;
diff --git a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp
index 364cd1099..91679cb57 100644
--- a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp
+++ b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp
@@ -42,6 +42,7 @@ static const QSize screenSize(1600, 1200);
class TestWindow : public QWindow
{
+ Q_OBJECT
public:
TestWindow()
{
@@ -49,6 +50,16 @@ public:
setGeometry(0, 0, 32, 32);
create();
}
+
+ bool event(QEvent *event) override
+ {
+ if (event->type() == QEvent::WindowStateChange)
+ emit windowStateChangeEventReceived(static_cast<QWindowStateChangeEvent *>(event)->oldState());
+ return QWindow::event(event);
+ }
+
+signals:
+ void windowStateChangeEventReceived(uint oldState);
};
class tst_WaylandClientXdgShellV6 : public QObject
@@ -58,6 +69,7 @@ public:
tst_WaylandClientXdgShellV6(MockCompositor *c)
: m_compositor(c)
{
+ qRegisterMetaType<Qt::WindowState>();
QSocketNotifier *notifier = new QSocketNotifier(m_compositor->waylandFileDescriptor(), QSocketNotifier::Read, this);
connect(notifier, &QSocketNotifier::activated, this, &tst_WaylandClientXdgShellV6::processWaylandEvents);
// connect to the event dispatcher to make sure to flush out the outgoing message queue
@@ -82,6 +94,13 @@ public slots:
private slots:
void createDestroyWindow();
void configure();
+ void showMinimized();
+ void setMinimized();
+ void unsetMaximized();
+ void focusWindowFollowsConfigure();
+ void windowStateChangedEvents();
+ void windowGeometrySimple();
+ void windowGeometryFixed();
private:
MockCompositor *m_compositor = nullptr;
@@ -118,10 +137,227 @@ void tst_WaylandClientXdgShellV6::configure()
QSharedPointer<MockXdgToplevelV6> toplevel;
QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6());
+
const QSize newSize(123, 456);
m_compositor->sendXdgToplevelV6Configure(toplevel, newSize);
QTRY_VERIFY(window.isExposed());
+ QTRY_COMPARE(window.visibility(), QWindow::Windowed);
+ QTRY_COMPARE(window.windowStates(), Qt::WindowNoState);
QTRY_COMPARE(window.frameGeometry(), QRect(QPoint(), newSize));
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, screenSize, { ZXDG_TOPLEVEL_V6_STATE_ACTIVATED, ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED });
+ QTRY_COMPARE(window.visibility(), QWindow::Maximized);
+ QTRY_COMPARE(window.windowStates(), Qt::WindowMaximized);
+ QTRY_COMPARE(window.frameGeometry(), QRect(QPoint(), screenSize));
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, screenSize, { ZXDG_TOPLEVEL_V6_STATE_ACTIVATED, ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN });
+ QTRY_COMPARE(window.visibility(), QWindow::FullScreen);
+ QTRY_COMPARE(window.windowStates(), Qt::WindowFullScreen);
+ QTRY_COMPARE(window.frameGeometry(), QRect(QPoint(), screenSize));
+
+ //The window should remember it's original size
+ m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(0, 0), { ZXDG_TOPLEVEL_V6_STATE_ACTIVATED });
+ QTRY_COMPARE(window.visibility(), QWindow::Windowed);
+ QTRY_COMPARE(window.windowStates(), Qt::WindowNoState);
+ QTRY_COMPARE(window.frameGeometry(), QRect(QPoint(), newSize));
+}
+
+void tst_WaylandClientXdgShellV6::showMinimized()
+{
+ // On xdg-shell v6 there's really no way for the compositor to tell the window if it's minimized
+ // There are wl_surface.enter events and so on, but there's really no way to differentiate
+ // between a window preview and an unminimized window.
+ TestWindow window;
+ window.showMinimized();
+ QCOMPARE(window.windowStates(), Qt::WindowMinimized); // should return minimized until
+ QTRY_COMPARE(window.windowStates(), Qt::WindowNoState); // rejected by handleWindowStateChanged
+
+ // Make sure the window on the compositor side is/was created here, and not after the test
+ // finishes, as that may mess up for later tests.
+ QTRY_VERIFY(m_compositor->xdgToplevelV6());
+}
+
+void tst_WaylandClientXdgShellV6::setMinimized()
+{
+ TestWindow window;
+ window.show();
+
+ QSharedPointer<MockXdgToplevelV6> toplevel;
+ QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6());
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel);
+ QTRY_COMPARE(window.visibility(), QWindow::Windowed);
+ QTRY_COMPARE(window.windowStates(), Qt::WindowNoState);
+
+ QSignalSpy setMinimizedSpy(toplevel.data(), SIGNAL(setMinimizedRequested()));
+ QSignalSpy windowStateChangeSpy(&window, SIGNAL(windowStateChangeEventReceived(uint)));
+
+ window.setVisibility(QWindow::Minimized);
+ QCOMPARE(window.visibility(), QWindow::Minimized);
+ QCOMPARE(window.windowStates(), Qt::WindowMinimized);
+ QTRY_COMPARE(setMinimizedSpy.count(), 1);
+ {
+ QTRY_VERIFY(windowStateChangeSpy.count() > 0);
+ Qt::WindowStates oldStates(windowStateChangeSpy.takeFirst().at(0).toUInt());
+ QCOMPARE(oldStates, Qt::WindowNoState);
+ }
+
+ // In the meantime the compositor may minimize, do nothing or reshow the window without
+ // telling us.
+
+ QTRY_COMPARE(window.visibility(), QWindow::Windowed); // verify that we don't know anything
+ QTRY_COMPARE(window.windowStates(), Qt::WindowNoState);
+ {
+ QTRY_COMPARE(windowStateChangeSpy.count(), 1);
+ Qt::WindowStates oldStates(windowStateChangeSpy.takeFirst().at(0).toUInt());
+ QCOMPARE(oldStates, Qt::WindowNoState); // because the window never was minimized
+ }
+
+ // Setting visibility again should send another set_minimized request
+ window.setVisibility(QWindow::Minimized);
+ QTRY_COMPARE(setMinimizedSpy.count(), 2);
+}
+
+void tst_WaylandClientXdgShellV6::unsetMaximized()
+{
+ TestWindow window;
+ window.show();
+
+ QSharedPointer<MockXdgToplevelV6> toplevel;
+ QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6());
+
+ QSignalSpy unsetMaximizedSpy(toplevel.data(), SIGNAL(unsetMaximizedRequested()));
+
+ QSignalSpy windowStateChangedSpy(&window, SIGNAL(windowStateChanged(Qt::WindowState)));
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, screenSize, { ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED });
+
+ QTRY_COMPARE(windowStateChangedSpy.count(), 1);
+ QCOMPARE(windowStateChangedSpy.takeFirst().at(0).toUInt(), Qt::WindowMaximized);
+
+ window.setWindowStates(Qt::WindowNoState);
+
+ QTRY_COMPARE(unsetMaximizedSpy.count(), 1);
+ QTRY_COMPARE(windowStateChangedSpy.count(), 1);
+ QCOMPARE(windowStateChangedSpy.takeFirst().at(0).toUInt(), Qt::WindowNoState);
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(0, 0), {});
+
+ QTRY_COMPARE(windowStateChangedSpy.count(), 1);
+ QCOMPARE(windowStateChangedSpy.takeFirst().at(0).toUInt(), Qt::WindowNoState);
+}
+
+void tst_WaylandClientXdgShellV6::focusWindowFollowsConfigure()
+{
+ TestWindow window;
+ window.show();
+
+ QSharedPointer<MockXdgToplevelV6> toplevel;
+ QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6());
+ QTRY_VERIFY(!window.isActive());
+
+ QSignalSpy windowStateChangeSpy(&window, SIGNAL(windowStateChangeEventReceived(uint)));
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(0, 0), { ZXDG_TOPLEVEL_V6_STATE_ACTIVATED });
+ QTRY_VERIFY(window.isActive());
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(0, 0), {});
+ QTRY_VERIFY(!window.isActive());
+}
+
+void tst_WaylandClientXdgShellV6::windowStateChangedEvents()
+{
+ TestWindow window;
+ window.show();
+
+ QSharedPointer<MockXdgToplevelV6> toplevel;
+ QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6());
+
+ QSignalSpy eventSpy(&window, SIGNAL(windowStateChangeEventReceived(uint)));
+ QSignalSpy signalSpy(&window, SIGNAL(windowStateChanged(Qt::WindowState)));
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, screenSize, { ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED });
+
+ QTRY_COMPARE(window.windowStates(), Qt::WindowMaximized);
+ QTRY_COMPARE(window.windowState(), Qt::WindowMaximized);
+ {
+ QTRY_COMPARE(eventSpy.count(), 1);
+ Qt::WindowStates oldStates(eventSpy.takeFirst().at(0).toUInt());
+ QCOMPARE(oldStates, Qt::WindowNoState);
+
+ QTRY_COMPARE(signalSpy.count(), 1);
+ uint newState = signalSpy.takeFirst().at(0).toUInt();
+ QCOMPARE(newState, Qt::WindowMaximized);
+ }
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, screenSize, { ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN });
+
+ QTRY_COMPARE(window.windowStates(), Qt::WindowFullScreen);
+ QTRY_COMPARE(window.windowState(), Qt::WindowFullScreen);
+ {
+ QTRY_COMPARE(eventSpy.count(), 1);
+ Qt::WindowStates oldStates(eventSpy.takeFirst().at(0).toUInt());
+ QCOMPARE(oldStates, Qt::WindowMaximized);
+
+ QTRY_COMPARE(signalSpy.count(), 1);
+ uint newState = signalSpy.takeFirst().at(0).toUInt();
+ QCOMPARE(newState, Qt::WindowFullScreen);
+ }
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(0, 0), {});
+
+ QTRY_COMPARE(window.windowStates(), Qt::WindowNoState);
+ QTRY_COMPARE(window.windowState(), Qt::WindowNoState);
+ {
+ QTRY_COMPARE(eventSpy.count(), 1);
+ Qt::WindowStates oldStates(eventSpy.takeFirst().at(0).toUInt());
+ QCOMPARE(oldStates, Qt::WindowFullScreen);
+
+ QTRY_COMPARE(signalSpy.count(), 1);
+ uint newState = signalSpy.takeFirst().at(0).toUInt();
+ QCOMPARE(newState, Qt::WindowNoState);
+ }
+}
+
+void tst_WaylandClientXdgShellV6::windowGeometrySimple()
+{
+ QWindow window;
+ window.show();
+
+ QSharedPointer<MockXdgToplevelV6> toplevel;
+ QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6());
+ QSignalSpy geometrySpy(toplevel.data(), SIGNAL(windowGeometryRequested(QRect)));
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel);
+ QTRY_COMPARE(geometrySpy.count(), 1);
+ QCOMPARE(geometrySpy.takeFirst().at(0).toRect().size(), window.frameGeometry().size());
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(123, 456));
+ QTRY_COMPARE(geometrySpy.count(), 1);
+ QCOMPARE(geometrySpy.takeFirst().at(0).toRect().size(), QSize(123, 456));
+}
+
+void tst_WaylandClientXdgShellV6::windowGeometryFixed()
+{
+ QWindow window;
+ window.resize(QSize(1337, 137));
+ window.setMaximumSize(window.size());
+ window.setMinimumSize(window.size());
+ window.show();
+
+ QSharedPointer<MockXdgToplevelV6> toplevel;
+ QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6());
+ QSignalSpy geometrySpy(toplevel.data(), SIGNAL(windowGeometryRequested(QRect)));
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel);
+ QTRY_COMPARE(geometrySpy.count(), 1);
+ QRect initialWindowGeometry = geometrySpy.takeFirst().at(0).toRect();
+ QCOMPARE(initialWindowGeometry.size(), window.frameGeometry().size());
+
+ m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(123, 456));
+ QTRY_COMPARE(geometrySpy.count(), 1);
+ // Configuring the window should not change the window geometry
+ QCOMPARE(geometrySpy.takeFirst().at(0).toRect().size(), initialWindowGeometry.size());
}
int main(int argc, char **argv)
diff --git a/tests/auto/compositor/compositor/compositor.pro b/tests/auto/compositor/compositor/compositor.pro
index 2919fa4bb..d69db4ca5 100644
--- a/tests/auto/compositor/compositor/compositor.pro
+++ b/tests/auto/compositor/compositor/compositor.pro
@@ -11,7 +11,7 @@ qtConfig(xkbcommon-evdev): \
QMAKE_USE += xkbcommon_evdev
WAYLANDCLIENTSOURCES += \
- ../../../../src/3rdparty/protocol/xdg-shell.xml \
+ ../../../../src/3rdparty/protocol/xdg-shell-unstable-v5.xml \
../../../../src/3rdparty/protocol/ivi-application.xml \
SOURCES += \
@@ -21,6 +21,7 @@ SOURCES += \
mockclient.cpp \
mockseat.cpp \
testseat.cpp \
+ mockkeyboard.cpp \
mockpointer.cpp
HEADERS += \
@@ -29,4 +30,5 @@ HEADERS += \
mockclient.h \
mockseat.h \
testseat.h \
+ mockkeyboard.h \
mockpointer.h
diff --git a/tests/auto/compositor/compositor/mockclient.h b/tests/auto/compositor/compositor/mockclient.h
index 6d5bf31df..6bfb652ed 100644
--- a/tests/auto/compositor/compositor/mockclient.h
+++ b/tests/auto/compositor/compositor/mockclient.h
@@ -27,7 +27,7 @@
****************************************************************************/
#include <wayland-client.h>
-#include <wayland-xdg-shell-client-protocol.h>
+#include <qwayland-xdg-shell-unstable-v5.h>
#include <wayland-ivi-application-client-protocol.h>
#include <QObject>
diff --git a/tests/auto/compositor/compositor/mockkeyboard.cpp b/tests/auto/compositor/compositor/mockkeyboard.cpp
new file mode 100644
index 000000000..e5f5f8d36
--- /dev/null
+++ b/tests/auto/compositor/compositor/mockkeyboard.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mockkeyboard.h"
+
+void keyboardKeymap(void *keyboard, struct wl_keyboard *wl_keyboard, uint32_t format, int32_t fd, uint32_t size)
+{
+ Q_UNUSED(keyboard);
+ Q_UNUSED(wl_keyboard);
+ Q_UNUSED(format);
+ Q_UNUSED(fd);
+ Q_UNUSED(size);
+}
+
+void keyboardEnter(void *keyboard, struct wl_keyboard *wl_keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys)
+{
+ Q_UNUSED(wl_keyboard);
+ Q_UNUSED(serial);
+ Q_UNUSED(surface);
+ Q_UNUSED(keys);
+
+ static_cast<MockKeyboard *>(keyboard)->m_enteredSurface = surface;
+}
+
+void keyboardLeave(void *keyboard, struct wl_keyboard *wl_keyboard, uint32_t serial, struct wl_surface *surface)
+{
+ Q_UNUSED(wl_keyboard);
+ Q_UNUSED(serial);
+ Q_UNUSED(surface);
+
+ static_cast<MockKeyboard *>(keyboard)->m_enteredSurface = nullptr;
+}
+
+void keyboardKey(void *keyboard, struct wl_keyboard *wl_keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
+{
+ Q_UNUSED(keyboard);
+ Q_UNUSED(wl_keyboard);
+ Q_UNUSED(serial);
+ Q_UNUSED(time);
+ Q_UNUSED(key);
+ Q_UNUSED(state);
+ auto kb = static_cast<MockKeyboard *>(keyboard);
+ kb->m_lastKeyCode = key;
+ kb->m_lastKeyState = state;
+}
+
+void keyboardModifiers(void *keyboard, struct wl_keyboard *wl_keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
+{
+ Q_UNUSED(keyboard);
+ Q_UNUSED(wl_keyboard);
+ Q_UNUSED(serial);
+ Q_UNUSED(mods_depressed);
+ Q_UNUSED(mods_latched);
+ Q_UNUSED(mods_locked);
+ auto kb = static_cast<MockKeyboard *>(keyboard);
+ kb->m_group = group;
+}
+
+static const struct wl_keyboard_listener keyboardListener = {
+ keyboardKeymap,
+ keyboardEnter,
+ keyboardLeave,
+ keyboardKey,
+ keyboardModifiers
+};
+
+MockKeyboard::MockKeyboard(wl_seat *seat)
+ : m_keyboard(wl_seat_get_keyboard(seat))
+{
+ wl_keyboard_add_listener(m_keyboard, &keyboardListener, this);
+}
+
+MockKeyboard::~MockKeyboard()
+{
+ wl_keyboard_destroy(m_keyboard);
+}
diff --git a/tests/auto/compositor/compositor/mockkeyboard.h b/tests/auto/compositor/compositor/mockkeyboard.h
new file mode 100644
index 000000000..1090db597
--- /dev/null
+++ b/tests/auto/compositor/compositor/mockkeyboard.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKKEYBOARD_H
+#define MOCKKEYBOARD_H
+
+#include <QObject>
+#include <wayland-client.h>
+
+class MockKeyboard : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit MockKeyboard(wl_seat *seat);
+ ~MockKeyboard() override;
+
+ wl_keyboard *m_keyboard = nullptr;
+ wl_surface *m_enteredSurface = nullptr;
+ uint m_lastKeyCode = 0;
+ uint m_lastKeyState = 0;
+ uint m_group = 0;
+};
+
+#endif // MOCKKEYBOARD_H
diff --git a/tests/auto/compositor/compositor/mockseat.cpp b/tests/auto/compositor/compositor/mockseat.cpp
index 052c2f90b..ce873c129 100644
--- a/tests/auto/compositor/compositor/mockseat.cpp
+++ b/tests/auto/compositor/compositor/mockseat.cpp
@@ -31,14 +31,11 @@
MockSeat::MockSeat(wl_seat *seat)
: m_seat(seat)
, m_pointer(new MockPointer(seat))
+ , m_keyboard(new MockKeyboard(seat))
{
- // Bind to the keyboard interface so that the compositor has
- // the right resource associations
- m_keyboard = wl_seat_get_keyboard(seat);
}
MockSeat::~MockSeat()
{
- wl_keyboard_destroy(m_keyboard);
wl_seat_destroy(m_seat);
}
diff --git a/tests/auto/compositor/compositor/mockseat.h b/tests/auto/compositor/compositor/mockseat.h
index 73d289281..f8c103ed4 100644
--- a/tests/auto/compositor/compositor/mockseat.h
+++ b/tests/auto/compositor/compositor/mockseat.h
@@ -29,6 +29,7 @@
#define MOCKSEAT
#include "mockpointer.h"
+#include "mockkeyboard.h"
#include <QObject>
#include <wayland-client.h>
@@ -41,12 +42,13 @@ public:
MockSeat(wl_seat *seat);
~MockSeat() override;
MockPointer *pointer() const { return m_pointer.data(); }
+ MockKeyboard *keyboard() const { return m_keyboard.data(); }
wl_seat *m_seat = nullptr;
- wl_keyboard *m_keyboard = nullptr;
private:
QScopedPointer<MockPointer> m_pointer;
+ QScopedPointer<MockKeyboard> m_keyboard;
};
#endif
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index ae5ea927d..e3c4daccc 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -40,11 +40,13 @@
#include <QtGui/QScreen>
#include <QtWaylandCompositor/QWaylandXdgShellV5>
#include <QtWaylandCompositor/private/qwaylandxdgshellv6_p.h>
+#include <QtWaylandCompositor/private/qwaylandkeyboard_p.h>
#include <QtWaylandCompositor/QWaylandIviApplication>
#include <QtWaylandCompositor/QWaylandIviSurface>
#include <QtWaylandCompositor/QWaylandSurface>
#include <QtWaylandCompositor/QWaylandResource>
-#include <qwayland-xdg-shell.h>
+#include <QtWaylandCompositor/QWaylandKeymap>
+#include <qwayland-xdg-shell-unstable-v5.h>
#include <qwayland-ivi-application.h>
#include <QtTest/QtTest>
@@ -56,6 +58,11 @@ class tst_WaylandCompositor : public QObject
private slots:
void init();
void seatCapabilities();
+#if QT_CONFIG(xkbcommon_evdev)
+ void simpleKeyboard();
+ void keyboardKeymaps();
+ void keyboardLayoutSwitching();
+#endif
void keyboardGrab();
void seatCreation();
void seatKeyboardFocus();
@@ -160,6 +167,121 @@ void tst_WaylandCompositor::multipleClients()
QTRY_COMPARE(compositor.surfaces.size(), 0);
}
+#if QT_CONFIG(xkbcommon_evdev)
+
+void tst_WaylandCompositor::simpleKeyboard()
+{
+ TestCompositor compositor;
+ compositor.create();
+
+ QWaylandSeat* seat = compositor.defaultSeat();
+ seat->keymap()->setLayout("us");
+
+ MockClient client;
+
+ QTRY_COMPARE(client.m_seats.size(), 1);
+ MockKeyboard *mockKeyboard = client.m_seats.at(0)->keyboard();
+
+ wl_surface *mockSurface = client.createSurface();
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+ seat->setKeyboardFocus(compositor.surfaces.at(0));
+
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_enteredSurface, mockSurface);
+
+ seat->sendKeyEvent(Qt::Key_A, true);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyState, 1u);
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 30u); // 30 is the scan code for A on us keyboard layouts
+
+ seat->sendKeyEvent(Qt::Key_A, false);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyState, 0u);
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 30u);
+
+ seat->sendKeyEvent(Qt::Key_Super_L, true);
+ seat->sendKeyEvent(Qt::Key_Super_L, false);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 125u);
+}
+
+void tst_WaylandCompositor::keyboardKeymaps()
+{
+ TestCompositor compositor;
+ compositor.create();
+ QWaylandSeat* seat = compositor.defaultSeat();
+ MockClient client;
+ QTRY_COMPARE(client.m_seats.size(), 1);
+ MockKeyboard *mockKeyboard = client.m_seats.at(0)->keyboard();
+ client.createSurface();
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+ seat->setKeyboardFocus(compositor.surfaces.at(0));
+
+ seat->keymap()->setLayout("us");
+
+ seat->sendKeyEvent(Qt::Key_Y, true);
+ seat->sendKeyEvent(Qt::Key_Y, false);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 21u);
+
+ seat->sendKeyEvent(Qt::Key_Z, true);
+ seat->sendKeyEvent(Qt::Key_Z, false);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 44u);
+
+ seat->keymap()->setLayout("de"); // In the German layout y and z have changed places
+
+ seat->sendKeyEvent(Qt::Key_Y, true);
+ seat->sendKeyEvent(Qt::Key_Y, false);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 44u);
+
+ seat->sendKeyEvent(Qt::Key_Z, true);
+ seat->sendKeyEvent(Qt::Key_Z, false);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 21u);
+}
+
+void tst_WaylandCompositor::keyboardLayoutSwitching()
+{
+ TestCompositor compositor;
+ compositor.create();
+ QWaylandSeat* seat = compositor.defaultSeat();
+ MockClient client;
+ QTRY_COMPARE(client.m_seats.size(), 1);
+ MockKeyboard *mockKeyboard = client.m_seats.at(0)->keyboard();
+ client.createSurface();
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+ seat->setKeyboardFocus(compositor.surfaces.at(0));
+
+ seat->keymap()->setLayout("us,de");
+ seat->keymap()->setOptions("grp:lalt_toggle"); //toggle keyboard layout with left alt
+
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_group, 0u);
+
+ seat->sendKeyEvent(Qt::Key_Y, true);
+ seat->sendKeyEvent(Qt::Key_Y, false);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 21u);
+
+ // It's not currently possible to switch layouts programmatically with the public APIs
+ // We will just fake it with the private APIs here.
+ auto keyboardPrivate = QWaylandKeyboardPrivate::get(seat->keyboard());
+ const uint leftAltCode = 64;
+ keyboardPrivate->updateModifierState(leftAltCode, WL_KEYBOARD_KEY_STATE_PRESSED);
+ keyboardPrivate->updateModifierState(leftAltCode, WL_KEYBOARD_KEY_STATE_RELEASED);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_group, 1u);
+
+ seat->sendKeyEvent(Qt::Key_Y, true);
+ seat->sendKeyEvent(Qt::Key_Y, false);
+ compositor.flushClients();
+ QTRY_COMPARE(mockKeyboard->m_lastKeyCode, 44u);
+}
+
+#endif // QT_CONFIG(xkbcommon_evdev)
+
void tst_WaylandCompositor::keyboardGrab()
{
TestCompositor compositor;
@@ -450,13 +572,24 @@ void tst_WaylandCompositor::seatKeyboardFocus()
// Create client after all the input devices have been set up as the mock client
// does not dynamically listen to new seats
MockClient client;
+
+ QTRY_COMPARE(client.m_seats.size(), 1);
+ MockKeyboard *mockKeyboard = client.m_seats.first()->keyboard();
+ QVERIFY(mockKeyboard);
+ QCOMPARE(mockKeyboard->m_enteredSurface, nullptr);
+
wl_surface *surface = client.createSurface();
QTRY_COMPARE(compositor.surfaces.size(), 1);
QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
- QWaylandSeat* dev = compositor.defaultSeat();
- dev->setKeyboardFocus(waylandSurface);
- QTRY_COMPARE(compositor.defaultSeat()->keyboardFocus(), waylandSurface);
+ QWaylandSeat* seat = compositor.defaultSeat();
+ QVERIFY(seat->setKeyboardFocus(waylandSurface));
+ QCOMPARE(compositor.defaultSeat()->keyboardFocus(), waylandSurface);
+
+ compositor.flushClients();
+
+ qDebug() << mockKeyboard->m_enteredSurface;
+ QTRY_COMPARE(mockKeyboard->m_enteredSurface, surface);
wl_surface_destroy(surface);
QTRY_VERIFY(compositor.surfaces.size() == 0);