Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor draw code to use cairo_surface_set_device_scale #1337

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bynect
Copy link
Member

@bynect bynect commented Apr 16, 2024

This fixes something that has been bugging me for a while.
Basically now dunst is scaling itself when drawing every single shape and text (with cairo and pango).
With this patch we render everything at a uniform scaling factor of 1 and scale everything afterwards using cairo_surface_set_device_scale.

This should have some advantages (apart from conciseness), like making scaling on wayland possible (like I discussed with @alebastr under #1316)

NOTE: Everything works on Xorg, however I can't test it on Wayland and my display is not Hi-Dpi, so I am not sure if the pango dpi scaling is being applied correctly. If someone can test it it would be great 👍🏻

@bynect
Copy link
Member Author

bynect commented Apr 16, 2024

I think that all the get_icon_width and get_*scale*icon function aren't needed anymore

@bynect
Copy link
Member Author

bynect commented Apr 16, 2024

I have no clue about why the test are failing 😢

@bynect
Copy link
Member Author

bynect commented Apr 19, 2024

I am trying to debug the use of uninitialized variables but even with libAsan I can't find it

@@ -100,7 +103,8 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
uint32_t button_state) {
struct dunst_seat *seat = data;

input_handle_click(button, button_state, seat->pointer.x, seat->pointer.y);
double scale = wl_get_scale();
input_handle_click(button, button_state, seat->pointer.x/scale, seat->pointer.y/scale);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before wayland didn't scale the user input

@bynect
Copy link
Member Author

bynect commented Apr 19, 2024

Finally figured it out. Basically I forgot that the test didn't call draw_setup. Since I moved the initialization of the PangoContext in draw_setup it was undefined and thus buggy, but only in tests.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 57.52212% with 48 lines in your changes are missing coverage. Please review.

Project coverage is 65.85%. Comparing base (4384521) to head (b0620ce).
Report is 15 commits behind head on master.

Files Patch % Lines
src/draw.c 57.14% 24 Missing ⚠️
src/wayland/wl.c 0.00% 14 Missing ⚠️
src/wayland/wl_seat.c 0.00% 4 Missing ⚠️
src/x11/x.c 0.00% 3 Missing ⚠️
test/draw.c 82.35% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1337      +/-   ##
==========================================
- Coverage   65.92%   65.85%   -0.08%     
==========================================
  Files          50       50              
  Lines        8070     8217     +147     
  Branches      925      961      +36     
==========================================
+ Hits         5320     5411      +91     
- Misses       2750     2806      +56     
Flag Coverage Δ
unittests 65.85% <57.52%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bynect
Copy link
Member Author

bynect commented Apr 19, 2024

Everything things to work. I think it is ready for merge.

Things we may want to consider

  • remove the icon scaling code (since we don't use it anymore). Alternatively we can render icons separately over the cairo surface to not downscale->upscale them. But this can be done in another pr.
  • integrate the new scaling method with wayland for per-monitor-dpi

@bynect
Copy link
Member Author

bynect commented May 1, 2024

@alebastr Where do you think should we place scale code so that the wayland backend can correctly get the scale needed? (to solve #1316)

Note that the pr is still not quite ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants