logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0007-Revert-wayland-drop-buffer-scale-for-cursor-as-well.patch (4399B)


  1. From 59550f4615bbf0a4e8bca23df163abfe37c52636 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Wed, 14 Aug 2024 22:52:17 -0700
  4. Subject: [PATCH] Revert "wayland: drop buffer scale for cursor as well"
  5. This reverts commit f0a6578259f508a8863afcf9a1487872d7ae1878.
  6. ---
  7. video/out/wayland_common.c | 32 +++++++++++++++++++++++---------
  8. video/out/wayland_common.h | 1 -
  9. 2 files changed, 23 insertions(+), 10 deletions(-)
  10. diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
  11. index edcc922122..4ccd4bda9c 100644
  12. --- a/video/out/wayland_common.c
  13. +++ b/video/out/wayland_common.c
  14. @@ -893,6 +893,7 @@ static void output_handle_done(void *data, struct wl_output *wl_output)
  15. * geometry and scaling should be recalculated. */
  16. if (wl->current_output && wl->current_output->output == wl_output) {
  17. set_surface_scaling(wl);
  18. + spawn_cursor(wl);
  19. set_geometry(wl, false);
  20. prepare_resize(wl);
  21. }
  22. @@ -957,6 +958,23 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface,
  23. if (outputs == 1)
  24. update_output_geometry(wl, old_geometry, old_output_geometry);
  25. + wl->current_output->has_surface = true;
  26. + bool force_resize = false;
  27. +
  28. + if (wl->scaling != wl->current_output->scale) {
  29. + set_surface_scaling(wl);
  30. + spawn_cursor(wl);
  31. + force_resize = true;
  32. + }
  33. +
  34. + if (!mp_rect_equals(&old_output_geometry, &wl->current_output->geometry)) {
  35. + set_geometry(wl, false);
  36. + force_resize = true;
  37. + }
  38. +
  39. + if (!mp_rect_equals(&old_geometry, &wl->geometry) || force_resize)
  40. + prepare_resize(wl);
  41. +
  42. MP_VERBOSE(wl, "Surface entered output %s %s (0x%x), scale = %f, refresh rate = %f Hz\n",
  43. wl->current_output->make, wl->current_output->model,
  44. wl->current_output->id, wl->scaling, wl->current_output->refresh_rate);
  45. @@ -1696,7 +1714,6 @@ static bool create_input(struct vo_wayland_state *wl)
  46. static int create_viewports(struct vo_wayland_state *wl)
  47. {
  48. wl->viewport = wp_viewporter_get_viewport(wl->viewporter, wl->surface);
  49. - wl->cursor_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->cursor_surface);
  50. wl->osd_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->osd_surface);
  51. wl->video_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->video_surface);
  52. @@ -2009,8 +2026,7 @@ static int set_cursor_visibility(struct vo_wayland_seat *s, bool on)
  53. int scale = MPMAX(wl->scaling, 1);
  54. wl_pointer_set_cursor(s->pointer, s->pointer_enter_serial, wl->cursor_surface,
  55. img->hotspot_x / scale, img->hotspot_y / scale);
  56. - wp_viewport_set_destination(wl->cursor_viewport, lround(img->width / scale),
  57. - img->height / scale);
  58. + wl_surface_set_buffer_scale(wl->cursor_surface, scale);
  59. wl_surface_attach(wl->cursor_surface, buffer, 0, 0);
  60. wl_surface_damage_buffer(wl->cursor_surface, 0, 0, img->width, img->height);
  61. }
  62. @@ -2145,11 +2161,12 @@ static bool single_output_spanned(struct vo_wayland_state *wl)
  63. static int spawn_cursor(struct vo_wayland_state *wl)
  64. {
  65. - if (wl->allocated_cursor_scale == wl->scaling) {
  66. + if (wl->cursor_shape_manager)
  67. + return 0;
  68. + if (wl->allocated_cursor_scale == wl->scaling)
  69. return 0;
  70. - } else if (wl->cursor_theme) {
  71. + else if (wl->cursor_theme)
  72. wl_cursor_theme_destroy(wl->cursor_theme);
  73. - }
  74. const char *xcursor_theme = getenv("XCURSOR_THEME");
  75. const char *size_str = getenv("XCURSOR_SIZE");
  76. @@ -2801,9 +2818,6 @@ void vo_wayland_uninit(struct vo *vo)
  77. if (wl->viewport)
  78. wp_viewport_destroy(wl->viewport);
  79. - if (wl->cursor_viewport)
  80. - wp_viewport_destroy(wl->cursor_viewport);
  81. -
  82. if (wl->osd_viewport)
  83. wp_viewport_destroy(wl->osd_viewport);
  84. diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
  85. index 7a2f31918e..f5fcb80445 100644
  86. --- a/video/out/wayland_common.h
  87. +++ b/video/out/wayland_common.h
  88. @@ -139,7 +139,6 @@ struct vo_wayland_state {
  89. /* viewporter */
  90. struct wp_viewporter *viewporter;
  91. struct wp_viewport *viewport;
  92. - struct wp_viewport *cursor_viewport;
  93. struct wp_viewport *osd_viewport;
  94. struct wp_viewport *video_viewport;
  95. --
  96. 2.44.0