Shape the window when there is no compositor
On Xfce with compositing off, X11 has no alpha to blend against, so the transparent background came out as a black box around the cat. When a window comes up without an alpha channel, TNCat now cuts the window down to the pixels the drawing covers, using the X11 shape extension, and refreshes that 15 times a second so it follows the animation. A sitting cat in a 120 x 106 window comes out as 96 rectangles over 29 percent of the window, so most of the box is gone. Edges are harder than with a compositor, one bit per pixel, and the log says so and names the Xfce setting that gives smooth ones instead. The image-to-rectangles step is platform independent and folds every device row into its window row, which both halves the rectangle count on a scaled display and keeps a pixel that is opaque in only one of them. xcb and xcb-shape are picked up through pkg-config on Unix and the build still works without them. Opaque mode now paints a neutral card rather than the coat colour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0aceb3665d
commit
d685bf492a
9 files changed
+284
-11
No files matched your search
+14
-1
@@ -17,7 +17,9 @@ Window {
|
||||
height: Math.round(width * sprite.implicitHeight / sprite.implicitWidth)
|
||||
x: cat.x
|
||||
y: Screen.desktopAvailableHeight - height - settings.bottomMargin
|
||||
color: Platform.opaqueBackground ? settings.coat : "transparent"
|
||||
// A neutral card reads better than the coat colour when the background
|
||||
// cannot be transparent at all.
|
||||
color: Platform.opaqueBackground ? "#f2f0ec" : "transparent"
|
||||
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool
|
||||
| Qt.NoDropShadowWindowHint | Qt.WindowDoesNotAcceptFocus
|
||||
| (Platform.bypassWindowManager ? Qt.X11BypassWindowManagerHint : 0)
|
||||
@@ -48,6 +50,17 @@ Window {
|
||||
}
|
||||
Screen.onDesktopAvailableWidthChanged: cat.stageWidth = Screen.desktopAvailableWidth
|
||||
|
||||
// Without a compositor the window is cut to the cat's own outline. The
|
||||
// drawing animates, so the shape has to be refreshed; 15 Hz is enough for
|
||||
// a swinging leg and cheap enough for a window this small.
|
||||
Timer {
|
||||
interval: 66
|
||||
repeat: true
|
||||
running: Platform.shapeWindows && win.visible
|
||||
triggeredOnStart: true
|
||||
onTriggered: Platform.updateWindowShape(win)
|
||||
}
|
||||
|
||||
// The eyes need to know where the face sits on the desktop.
|
||||
Binding {
|
||||
target: win.cat
|
||||
|
||||
@@ -27,6 +27,14 @@ Window {
|
||||
NumberAnimation { duration: 320; easing.type: Easing.OutQuad }
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 66
|
||||
repeat: true
|
||||
running: Platform.shapeWindows && win.visible
|
||||
triggeredOnStart: true
|
||||
onTriggered: Platform.updateWindowShape(win)
|
||||
}
|
||||
|
||||
Chip {
|
||||
id: curl
|
||||
anchors.fill: parent
|
||||
|
||||
@@ -22,6 +22,14 @@ Window {
|
||||
| (Platform.bypassWindowManager ? Qt.X11BypassWindowManagerHint : 0)
|
||||
visible: cat.cupVisible
|
||||
|
||||
Timer {
|
||||
interval: 66
|
||||
repeat: true
|
||||
running: Platform.shapeWindows && win.visible
|
||||
triggeredOnStart: true
|
||||
onTriggered: Platform.updateWindowShape(win)
|
||||
}
|
||||
|
||||
Cup {
|
||||
id: mug
|
||||
anchors.fill: parent
|
||||
|
||||
Reference in new issue
Block a user