[Interest] some challenges setting window mask from QML

Florian Hänel florian.haenel at echtzeit.solutions
Tue Oct 24 13:34:06 CEST 2023


I set about implementing a type that allows a user to set the window 
mask (aka wayland input region, i.e. non-rectangular windows) from QML.

I ended up with a qml Item that works like this:

|Window|

|{
|

|    WaylandInputRegion {|

|        item: theMenu
|

|    }|

|    Rectangle {|

|        id: theMenu|

|        radius:50|

|        //etc pp
|

|    }
|

|}|

|
|

behind the scenes it uses grabToImage, then QBitMap::fromImage, 
QRegion(QBitmap&) and finally window()->handle()->setMask()

I also added a fast path for when item is null to use the 
WaylandInputRegion itself as a simple rectangular region.


However, the current implementation has the following issues that I 
would appreciate input for:

using an external item as the bitmap source requires us to track changes 
in that item including its scene position to correctly reflect that in 
the window mask.

I haven't found a way to do that so I rely on explicit calls to 
updateRegion() from qml code at known points when animations stop.

Also for items anchored to the windows contentItem, position is invalid 
as the contentItem geometry appears to be 0x0, 0,0 for some time after 
start.


Florian

-- 
Florian Hänel
Geschäftsführer

echtzeit.solutions GmbH
Handelsregistergericht München HRB 231056
Ust-ID DE310379807
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20231024/b67a5d2a/attachment.htm>


More information about the Interest mailing list