1. Description: Corrected support for buttons backgrounds with transparency
  2. Added 'no background' if there is only one button and backgrounds no more
  3. overlap if transparency used.
  4. Corrected bug with left button clickable region when window is
  5. maximized
  6. Origin: Ubuntu
  7. Bug: https://bugzilla.gnome.org/show_bug.cgi?id=608511
  8. Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/metacity/+bug/535088
  9. Author: Nicolas Desfontaine <noop@free.fr>
  10.  
  11. Index: metacity-2.28.1/src/ui/theme.c
  12. ===================================================================
  13. --- metacity-2.28.1/src/ui/theme.c (revision 1)
  14. +++ metacity-2.28.1/src/ui/theme.c (revision 53)
  15. @@ -702,29 +702,40 @@
  16. right_bg_rects[i] = NULL;
  17. }
  18.  
  19. for (i = 0; i < n_left; i++)
  20. {
  21. - if (i == 0) /* prefer left background if only one button */
  22. - left_bg_rects[i] = &fgeom->left_left_background;
  23. + if (i == 0) /* For the first button (From left to right) */
  24. + {
  25. + if (n_left > 1) /* Set left_left_background
  26. + if we have more than one button */
  27. + left_bg_rects[i] = &fgeom->left_left_background;
  28. + else /* No background if we have only one single button */
  29. + left_bg_rects[i] = &fgeom->left_single_background;
  30. + }
  31. else if (i == (n_left - 1))
  32. left_bg_rects[i] = &fgeom->left_right_background;
  33. else
  34. left_bg_rects[i] = &fgeom->left_middle_backgrounds[i - 1];
  35. }
  36.  
  37. for (i = 0; i < n_right; i++)
  38. {
  39. - /* prefer right background if only one button */
  40. - if (i == (n_right - 1))
  41. - right_bg_rects[i] = &fgeom->right_right_background;
  42. + if (i == (n_right - 1)) /* For the first button (From right to left) */
  43. + {
  44. + if (n_right > 1) /* Set right_right_background
  45. + if we have more than one button */
  46. + right_bg_rects[i] = &fgeom->right_right_background;
  47. + else /* No background if we have only one single button */
  48. + right_bg_rects[i] = &fgeom->right_single_background;
  49. + }
  50. else if (i == 0)
  51. right_bg_rects[i] = &fgeom->right_left_background;
  52. else
  53. right_bg_rects[i] = &fgeom->right_middle_backgrounds[i - 1];
  54. }
  55. -
  56. +
  57. /* Be sure buttons fit */
  58. while (n_left > 0 || n_right > 0)
  59. {
  60. int space_used_by_buttons;
  61. int space_available;
  62. @@ -836,13 +847,13 @@
  63. rect->visible.height = button_height;
  64.  
  65. if (flags & META_FRAME_MAXIMIZED)
  66. {
  67. rect->clickable.x = rect->visible.x;
  68. - rect->clickable.y = 0;
  69. - rect->clickable.width = rect->visible.width;
  70. - rect->clickable.height = button_height + button_y;
  71. + rect->clickable.y = rect->visible.y;
  72. + rect->clickable.width = button_width;
  73. + rect->clickable.height = button_height;
  74.  
  75. if (i == n_right - 1)
  76. rect->clickable.width += layout->right_titlebar_edge + layout->right_width + layout->button_border.right;
  77.  
  78. }
  79. @@ -874,27 +885,17 @@
  80. rect->visible.width = button_width;
  81. rect->visible.height = button_height;
  82.  
  83. if (flags & META_FRAME_MAXIMIZED)
  84. {
  85. - if (i==0)
  86. - {
  87. - rect->clickable.x = 0;
  88. - rect->clickable.width = button_width + x;
  89. - }
  90. - else
  91. - {
  92. - rect->clickable.x = rect->visible.x;
  93. - rect->clickable.width = button_width;
  94. - }
  95. -
  96. - rect->clickable.y = 0;
  97. - rect->clickable.height = button_height + button_y;
  98. - }
  99. - else
  100. - g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
  101. -
  102. + rect->clickable.x = rect->visible.x;
  103. + rect->clickable.y = rect->visible.y;
  104. + rect->clickable.width = button_width;
  105. + rect->clickable.height = button_height;
  106. + }
  107. + else
  108. + g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
  109.  
  110. x = rect->visible.x + rect->visible.width + layout->button_border.right;
  111. if (left_buttons_has_spacer[i])
  112. x += (button_width * 0.75);
  113.  
  114. @@ -4523,11 +4524,11 @@
  115. }
  116.  
  117. /* MIDDLE_BACKGROUND type may get drawn more than once */
  118. if ((j == META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND ||
  119. j == META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND) &&
  120. - middle_bg_offset < MAX_MIDDLE_BACKGROUNDS)
  121. + (middle_bg_offset < (MAX_MIDDLE_BACKGROUNDS - 1)))
  122. {
  123. ++middle_bg_offset;
  124. }
  125. else
  126. {
  127. Index: metacity-2.28.1/src/ui/theme.h
  128. ===================================================================
  129. --- metacity-2.28.1/src/ui/theme.h (revision 1)
  130. +++ metacity-2.28.1/src/ui/theme.h (revision 39)
  131. @@ -198,13 +198,15 @@
  132. MetaButtonSpace unshade_rect;
  133. MetaButtonSpace unabove_rect;
  134. MetaButtonSpace unstick_rect;
  135.  
  136. #define MAX_MIDDLE_BACKGROUNDS (MAX_BUTTONS_PER_CORNER - 2)
  137. + GdkRectangle left_single_background;
  138. GdkRectangle left_left_background;
  139. GdkRectangle left_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
  140. GdkRectangle left_right_background;
  141. + GdkRectangle right_single_background;
  142. GdkRectangle right_left_background;
  143. GdkRectangle right_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
  144. GdkRectangle right_right_background;
  145. /* End of button rects (if changed adjust memset hack) */