You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

92 lines
1.9 KiB

  1. #include "quirks.h"
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. #include <string.h>
  5. #define LOG_MODULE "quirks"
  6. #define LOG_ENABLE_DBG 0
  7. #include "log.h"
  8. #include "util.h"
  9. static bool
  10. is_weston(void)
  11. {
  12. static bool is_weston = false;
  13. static bool initialized = false;
  14. if (!initialized) {
  15. initialized = true;
  16. is_weston = getenv("WESTON_CONFIG_FILE") != NULL;
  17. if (is_weston)
  18. LOG_WARN("applying wl_subsurface_set_desync() workaround for weston");
  19. }
  20. return is_weston;
  21. }
  22. void
  23. quirk_weston_subsurface_desync_on(struct wl_subsurface *sub)
  24. {
  25. if (!is_weston())
  26. return;
  27. wl_subsurface_set_desync(sub);
  28. }
  29. void
  30. quirk_weston_subsurface_desync_off(struct wl_subsurface *sub)
  31. {
  32. if (!is_weston())
  33. return;
  34. wl_subsurface_set_sync(sub);
  35. }
  36. void
  37. quirk_weston_csd_on(struct terminal *term)
  38. {
  39. if (term->window->use_csd != CSD_YES)
  40. return;
  41. if (term->window->is_fullscreen)
  42. return;
  43. for (int i = 0; i < ALEN(term->window->csd.surface); i++)
  44. quirk_weston_subsurface_desync_on(term->window->csd.sub_surface[i]);
  45. }
  46. void
  47. quirk_weston_csd_off(struct terminal *term)
  48. {
  49. if (term->window->use_csd != CSD_YES)
  50. return;
  51. if (term->window->is_fullscreen)
  52. return;
  53. for (int i = 0; i < ALEN(term->window->csd.surface); i++)
  54. quirk_weston_subsurface_desync_off(term->window->csd.sub_surface[i]);
  55. }
  56. void
  57. quirk_kde_damage_before_attach(struct wl_surface *surface)
  58. {
  59. static bool is_kde = false;
  60. static bool initialized = false;
  61. if (!initialized) {
  62. initialized = true;
  63. const char *cur_desktop = getenv("XDG_CURRENT_DESKTOP");
  64. if (cur_desktop != NULL)
  65. is_kde = strcasestr(cur_desktop, "kde") != NULL;
  66. if (is_kde)
  67. LOG_WARN("applying wl_surface_damage_buffer() workaround for KDE");
  68. }
  69. if (!is_kde)
  70. return;
  71. wl_surface_damage_buffer(surface, 0, 0, INT32_MAX, INT32_MAX);
  72. }