mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-06-03 17:18:16 -04:00
Use the QScreen of the QWindow as default output
If the Window::setDesiredOutput API was not called for the QWindow, use QWindow::screen(). This allows assigning QWindows to specific screens using the plain Qt API. Passing nullptr to Window::setDesiredOutput explicitly results in nil as desired output for the layer, which lets the compositor select a screen.
This commit is contained in:
parent
b9f8f6447d
commit
9e5c32e1ab
@ -8,6 +8,7 @@
|
||||
#include <layershellqt_logging.h>
|
||||
|
||||
#include <QPointer>
|
||||
#include <optional>
|
||||
|
||||
using namespace LayerShellQt;
|
||||
|
||||
@ -26,7 +27,7 @@ public:
|
||||
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityExclusive;
|
||||
Window::Layer layer = Window::LayerTop;
|
||||
QMargins margins;
|
||||
QPointer<QScreen> desiredOutput;
|
||||
std::optional<QPointer<QScreen>> desiredOutput;
|
||||
};
|
||||
|
||||
static QMap<QWindow *, Window *> s_map;
|
||||
@ -103,7 +104,7 @@ Window::Layer Window::layer() const
|
||||
|
||||
QScreen *Window::desiredOutput() const
|
||||
{
|
||||
return d->desiredOutput;
|
||||
return d->desiredOutput.value_or(nullptr);
|
||||
}
|
||||
|
||||
void Window::setDesiredOutput(QScreen *output)
|
||||
@ -111,6 +112,11 @@ void Window::setDesiredOutput(QScreen *output)
|
||||
d->desiredOutput = output;
|
||||
}
|
||||
|
||||
bool Window::desiredOutputSet() const
|
||||
{
|
||||
return d->desiredOutput.has_value();
|
||||
}
|
||||
|
||||
Window::Window(QWindow *window)
|
||||
: QObject(window)
|
||||
, d(new WindowPrivate(window))
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
*/
|
||||
void setDesiredOutput(QScreen *output);
|
||||
QScreen *desiredOutput() const;
|
||||
bool desiredOutputSet() const;
|
||||
|
||||
/**
|
||||
* Sets a string based identifier for this window.
|
||||
|
@ -24,7 +24,7 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandC
|
||||
Q_ASSERT(interface);
|
||||
|
||||
wl_output *output = nullptr;
|
||||
QScreen *screen = interface->desiredOutput();
|
||||
QScreen *screen = interface->desiredOutputSet() ? interface->desiredOutput() : window->window()->screen();
|
||||
if (screen) {
|
||||
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(screen->handle());
|
||||
// Qt will always assign a screen to a window, but if the compositor has no screens available a dummy QScreen object is created
|
||||
|
Loading…
x
Reference in New Issue
Block a user