Conversation
fafdb68 to
ea60c06
Compare
|
I like it, @marmarta what do you think? |
|
PipelineRetry |
OpenQA test summaryComplete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026091612-devel&flavor=pull-requests Test run included the following:
New failures, excluding unstableCompared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026050504-devel&flavor=update
Failed tests18 failures
Fixed failuresCompared to: https://openqa.qubes-os.org/tests/176874#dependencies 32 fixed
Unstable testsDetails
Performance TestsPerformance degradation:No issues Remaining performance tests:71 tests
|
|
I generally like it, but I have questions: how does it look when the icon has some transparency? I wonder if this remains readable with colorful icons - I don't see that many colorful icons in notifications in general, though. |
|
It doesn't appear to work :( For the size, either the limit should be higher, or the client should scale it down to allowed size. The current limit seems to be 255, so almost... Maybe dbus notification spec includes suggested limits? As for the |
|
Suggestion: If you intend for this pull request to resolve the associated issue and would like for it to be linked to the issue automatically, you can put |
ea60c06 to
4f2ed18
Compare
Thank you changed. |
|
nm-applet now looks to work: https://openqa.qubes-os.org/tests/194312#step/startup/8 (click the image icon to see colors) :) |
| fn mix(colour: [u8; 3], target: [u8; 3], amount: f32) -> [u8; 3] { | ||
| let mut out = [0; 3]; | ||
| for i in 0..3 { | ||
| out[i] = (colour[i] as f32 + (target[i] as f32 - colour[i] as f32) * amount).round() as u8; | ||
| } | ||
| out | ||
| } | ||
|
|
||
| /// Averages each `factor` x `factor` block into one pixel. | ||
| fn downsample(src: &Image, factor: u32) -> Image { | ||
| let mut out = Image::new(src.width / factor, src.height / factor); | ||
| for y in 0..out.height { | ||
| for x in 0..out.width { | ||
| let (mut sa, mut sr, mut sg, mut sb) = (0u32, 0u32, 0u32, 0u32); | ||
| for dy in 0..factor { | ||
| for dx in 0..factor { | ||
| let p = src.pixel(x * factor + dx, y * factor + dy); | ||
| let a = p[3] as u32; | ||
| sa += a; | ||
| sr += p[0] as u32 * a; | ||
| sg += p[1] as u32 * a; | ||
| sb += p[2] as u32 * a; | ||
| } | ||
| } | ||
| let n = factor * factor; | ||
| let px = if sa == 0 { | ||
| [0, 0, 0, 0] | ||
| } else { | ||
| [ | ||
| (sr / sa) as u8, | ||
| (sg / sa) as u8, | ||
| (sb / sa) as u8, | ||
| (sa / n) as u8, | ||
| ] | ||
| }; | ||
| out.set_pixel(x, y, px); | ||
| } | ||
| } | ||
| out | ||
| } | ||
|
|
||
| /// Where the solid cube sits. | ||
| const CUBE_MAIN_X: f32 = 0.46; | ||
| const CUBE_MAIN_Y: f32 = 0.56; | ||
| const CUBE_RADIUS: f32 = 0.26; | ||
| const CUBE_GHOST_X: f32 = 0.74; | ||
| const CUBE_GHOST_Y: f32 = 0.77; | ||
| const CUBE_GHOST_TINT: f32 = 0.62; | ||
| const CUBE_GHOST_ALPHA: f32 = 0.88; | ||
|
|
||
| const WHITE: [u8; 3] = [0xFF, 0xFF, 0xFF]; | ||
| const BLACK: [u8; 3] = [0x00, 0x00, 0x00]; | ||
|
|
||
| /// Draws one cube with its centre at `(cx, cy)`, on top of what is already | ||
| /// there. | ||
| fn draw_cube(img: &mut Image, cx: f32, cy: f32, r: f32, colour: [u8; 3], alpha: f32) { | ||
| let w = r * 0.866; // cos(30 degrees) | ||
|
|
||
| let top = mix(colour, WHITE, 0.34); | ||
| let right = mix(colour, WHITE, 0.05); | ||
| let left = mix(colour, BLACK, 0.32); | ||
| let a = (alpha.clamp(0.0, 1.0) * 255.0).round() as u8; | ||
|
|
||
| let lo_x = (cx - w).floor().max(0.0) as u32; | ||
| let hi_x = (cx + w).ceil().min(img.width as f32 - 1.0) as u32; | ||
| let lo_y = (cy - r).floor().max(0.0) as u32; | ||
| let hi_y = (cy + r).ceil().min(img.height as f32 - 1.0) as u32; | ||
|
|
||
| for y in lo_y..=hi_y { | ||
| for x in lo_x..=hi_x { | ||
| let dx = x as f32 - cx; | ||
| let dy = y as f32 - cy; | ||
| let slope = dx.abs() * r / (2.0 * w); | ||
| let [red, green, blue] = if dx.abs() > w || dy.abs() > r - slope { | ||
| continue; | ||
| } else if dy <= -slope { | ||
| top | ||
| } else if dx >= 0.0 { | ||
| right | ||
| } else { | ||
| left | ||
| }; | ||
| let under = img.pixel(x, y); | ||
| img.set_pixel(x, y, blend(under, [red, green, blue, a])); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Draws the mark: a solid cube with a paler cube behind it, both in the | ||
| /// qube's label colour. | ||
| pub fn cube_mark(colour: [u8; 3]) -> Image { | ||
| const SS: u32 = 3; | ||
|
|
||
| let big = MARK_SIZE * SS; | ||
| let mut img = Image::new(big, big); | ||
| let edge = big as f32 - 1.0; | ||
| let r = big as f32 * CUBE_RADIUS; | ||
|
|
||
| // Pale cube first, so the solid one covers it and not the other way round. | ||
| draw_cube( | ||
| &mut img, | ||
| edge * CUBE_GHOST_X, | ||
| edge * CUBE_GHOST_Y, | ||
| r, | ||
| mix(colour, WHITE, CUBE_GHOST_TINT), | ||
| CUBE_GHOST_ALPHA, | ||
| ); | ||
| draw_cube( | ||
| &mut img, | ||
| edge * CUBE_MAIN_X, | ||
| edge * CUBE_MAIN_Y, | ||
| r, | ||
| colour, | ||
| 1.0, | ||
| ); | ||
| downsample(&img, SS) | ||
| } |
There was a problem hiding this comment.
The overlay was supposed to be just qube icon, which you can load from the icon theme based on default_icon of NotificationEmitter. You don't need to draw it manually...
There was a problem hiding this comment.
I somehow assumed that we wanted to support any color of the cube, not just the ones defined by the icons.
I’ll fix it then - to use the icons.
4f2ed18 to
ebb16d7
Compare
|
It is better now :) Few more observations:
|
ebb16d7 to
c25e037
Compare
|
I have moved the mark to the top-left. I'm not sure if it looks best there. Maybe bottom-left? The client now resizes images before sending them to dom0. I also optimized the client's parsing of the hints. |
forgot to git add a file? |
c25e037 to
7a1709b
Compare
🤦♂️ |

This is what I got:
Closes QubesOS/qubes-issues#9648