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
						3c85e2e889
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
#include <layershellqt_logging.h>
 | 
					#include <layershellqt_logging.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QPointer>
 | 
					#include <QPointer>
 | 
				
			||||||
 | 
					#include <optional>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace LayerShellQt;
 | 
					using namespace LayerShellQt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +27,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;
 | 
				
			||||||
    QPointer<QScreen> desiredOutput;
 | 
					    std::optional<QPointer<QScreen>> desiredOutput;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QMap<QWindow *, Window *> s_map;
 | 
					static QMap<QWindow *, Window *> s_map;
 | 
				
			||||||
| 
						 | 
					@ -103,7 +104,12 @@ Window::Layer Window::layer() const
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QScreen *Window::desiredOutput() const
 | 
					QScreen *Window::desiredOutput() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return d->desiredOutput;
 | 
					    // Don't use .value_or here to avoid a temporary QPointer
 | 
				
			||||||
 | 
					    if (d->desiredOutput.has_value()) {
 | 
				
			||||||
 | 
					        return d->desiredOutput.value();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return d->parentWindow->screen();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Window::setDesiredOutput(QScreen *output)
 | 
					void Window::setDesiredOutput(QScreen *output)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue