Replace Window::desiredOutput with a Window::screenConfiguration enum
To not overlap with QWindow::screen too much, introduce an enum to make it more clear what the options and the resulting behaviour are.
This commit is contained in:
		
							parent
							
								
									511b92f4ab
								
							
						
					
					
						commit
						49f31bb22d
					
				
					 3 changed files with 20 additions and 20 deletions
				
			
		| 
						 | 
					@ -34,7 +34,7 @@ public:
 | 
				
			||||||
    Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityExclusive;
 | 
					    Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityExclusive;
 | 
				
			||||||
    Window::Layer layer = Window::LayerTop;
 | 
					    Window::Layer layer = Window::LayerTop;
 | 
				
			||||||
    QMargins margins;
 | 
					    QMargins margins;
 | 
				
			||||||
    std::optional<QPointer<QScreen>> desiredOutput;
 | 
					    Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QMap<QWindow *, Window *> s_map;
 | 
					static QMap<QWindow *, Window *> s_map;
 | 
				
			||||||
| 
						 | 
					@ -109,19 +109,14 @@ Window::Layer Window::layer() const
 | 
				
			||||||
    return d->layer;
 | 
					    return d->layer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QScreen *Window::desiredOutput() const
 | 
					Window::ScreenConfiguration Window::screenConfiguration() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    // Don't use .value_or here to avoid a temporary QPointer
 | 
					    return d->screenConfiguration;
 | 
				
			||||||
    if (d->desiredOutput.has_value()) {
 | 
					 | 
				
			||||||
        return d->desiredOutput.value();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return d->parentWindow->screen();
 | 
					void Window::setScreenConfiguration(Window::ScreenConfiguration screenConfiguration)
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void Window::setDesiredOutput(QScreen *output)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    d->desiredOutput = output;
 | 
					    d->screenConfiguration = screenConfiguration;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
 | 
					#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,6 +58,17 @@ public:
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    Q_ENUM(KeyboardInteractivity)
 | 
					    Q_ENUM(KeyboardInteractivity)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * This enum type is used to specify which screen to place the surface on.
 | 
				
			||||||
 | 
					     * ScreenFromQWindow (the default) reads QWindow::screen() while ScreenFromCompositor
 | 
				
			||||||
 | 
					     * passes nil and lets the compositor decide.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    enum ScreenConfiguration {
 | 
				
			||||||
 | 
					        ScreenFromQWindow = 0,
 | 
				
			||||||
 | 
					        ScreenFromCompositor = 1,
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    Q_ENUM(ScreenConfiguration)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setAnchors(Anchors anchor);
 | 
					    void setAnchors(Anchors anchor);
 | 
				
			||||||
    Anchors anchors() const;
 | 
					    Anchors anchors() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,13 +84,8 @@ public:
 | 
				
			||||||
    void setLayer(Layer layer);
 | 
					    void setLayer(Layer layer);
 | 
				
			||||||
    Layer layer() const;
 | 
					    Layer layer() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    void setScreenConfiguration(ScreenConfiguration screenConfiguration);
 | 
				
			||||||
     * If set, the compositor will try to put the window on the given screen.
 | 
					    ScreenConfiguration screenConfiguration() const;
 | 
				
			||||||
     * If its not set, then the compositor will decide where to put the window.
 | 
					 | 
				
			||||||
     * Under normal circumstances, this should be the active output.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    void setDesiredOutput(QScreen *output);
 | 
					 | 
				
			||||||
    QScreen *desiredOutput() const;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sets a string based identifier for this window.
 | 
					     * Sets a string based identifier for this window.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,9 +23,8 @@ QWaylandLayerSurface::QWaylandLayerSurface(QtWayland::zwlr_layer_shell_v1 *shell
 | 
				
			||||||
    Q_ASSERT(interface);
 | 
					    Q_ASSERT(interface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    wl_output *output = nullptr;
 | 
					    wl_output *output = nullptr;
 | 
				
			||||||
    QScreen *screen = interface->desiredOutput();
 | 
					    if (interface->screenConfiguration() == Window::ScreenFromQWindow) {
 | 
				
			||||||
    if (screen) {
 | 
					        auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(window->window()->screen()->handle());
 | 
				
			||||||
        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
 | 
					        // Qt will always assign a screen to a window, but if the compositor has no screens available a dummy QScreen object is created
 | 
				
			||||||
        // this will not cast to a QWaylandScreen
 | 
					        // this will not cast to a QWaylandScreen
 | 
				
			||||||
        if (!waylandScreen) {
 | 
					        if (!waylandScreen) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue