vte-0.28.2-scale.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. diff -NurpP --minimal vte-0.28.2.orig/src/vte-private.h vte-0.28.2/src/vte-private.h
  2. --- vte-0.28.2.orig/src/vte-private.h 2011-08-16 21:52:48.000000000 +0000
  3. +++ vte-0.28.2/src/vte-private.h 2012-04-06 00:23:46.000000000 +0000
  4. @@ -281,6 +281,9 @@ struct _VteTerminalPrivate {
  5. gboolean scroll_on_keystroke;
  6. long scrollback_lines;
  7. + /* Scaling options */
  8. + gboolean scale_background;
  9. +
  10. /* Cursor shape */
  11. VteTerminalCursorShape cursor_shape;
  12. float cursor_aspect_ratio;
  13. diff -NurpP --minimal vte-0.28.2.orig/src/vte.c vte-0.28.2/src/vte.c
  14. --- vte-0.28.2.orig/src/vte.c 2011-08-28 21:31:45.000000000 +0000
  15. +++ vte-0.28.2/src/vte.c 2012-04-06 00:23:46.000000000 +0000
  16. @@ -179,7 +179,8 @@ enum {
  17. PROP_SCROLL_ON_OUTPUT,
  18. PROP_WINDOW_TITLE,
  19. PROP_WORD_CHARS,
  20. - PROP_VISIBLE_BELL
  21. + PROP_VISIBLE_BELL,
  22. + PROP_SCALE_BACKGROUND
  23. };
  24. /* these static variables are guarded by the GDK mutex */
  25. @@ -11179,6 +11180,10 @@ vte_terminal_paint(GtkWidget *widget, Gd
  26. 0,
  27. terminal->pvt->screen->scroll_delta *
  28. terminal->char_height);
  29. + } else if (terminal->pvt->scale_background) {
  30. + _vte_draw_set_background_scale(terminal->pvt->draw,
  31. + terminal->char_width * terminal->column_count,
  32. + terminal->char_height * terminal->row_count);
  33. } else {
  34. _vte_draw_set_background_scroll(terminal->pvt->draw, 0, 0);
  35. }
  36. @@ -11574,6 +11579,9 @@ vte_terminal_get_property (GObject *obje
  37. case PROP_SCROLL_BACKGROUND:
  38. g_value_set_boolean (value, pvt->scroll_background);
  39. break;
  40. + case PROP_SCALE_BACKGROUND:
  41. + g_value_set_boolean (value, pvt->scale_background);
  42. + break;
  43. case PROP_SCROLLBACK_LINES:
  44. g_value_set_uint (value, pvt->scrollback_lines);
  45. break;
  46. @@ -11680,6 +11688,9 @@ vte_terminal_set_property (GObject *obje
  47. case PROP_PTY_OBJECT:
  48. vte_terminal_set_pty_object (terminal, g_value_get_object (value));
  49. break;
  50. + case PROP_SCALE_BACKGROUND:
  51. + vte_terminal_set_scale_background (terminal, g_value_get_boolean (value));
  52. + break;
  53. case PROP_SCROLL_BACKGROUND:
  54. vte_terminal_set_scroll_background (terminal, g_value_get_boolean (value));
  55. break;
  56. @@ -12697,6 +12708,19 @@ vte_terminal_class_init(VteTerminalClass
  57. G_PARAM_STATIC_STRINGS));
  58. /**
  59. + * VteTerminal:scale-background:
  60. + *
  61. + * Controls whether or not the terminal will scale the background image
  62. + * (if one is set)
  63. + */
  64. + g_object_class_install_property
  65. + (gobject_class,
  66. + PROP_SCALE_BACKGROUND,
  67. + g_param_spec_boolean ("scale-background", NULL, NULL,
  68. + FALSE,
  69. + G_PARAM_READWRITE | STATIC_PARAMS));
  70. +
  71. + /**
  72. * VteTerminal:scroll-background:
  73. *
  74. * Controls whether or not the terminal will scroll the background image (if
  75. @@ -12991,6 +13015,36 @@ vte_terminal_get_allow_bold(VteTerminal
  76. }
  77. /**
  78. + * vte_terminal_set_scale_background:
  79. + * @terminal: a #VteTerminal
  80. + * @scale: whether the terminal should scale the background
  81. + *
  82. + * Controls whether or not the terminal will scale the background image (if
  83. + * one is set) to the widget size.
  84. + *
  85. + * Since: 0.11
  86. + */
  87. +void
  88. +vte_terminal_set_scale_background(VteTerminal *terminal, gboolean scale)
  89. +{
  90. + VteTerminalPrivate *pvt;
  91. +
  92. + g_return_if_fail(VTE_IS_TERMINAL(terminal));
  93. +
  94. + pvt = terminal->pvt;
  95. +
  96. + scale = scale != FALSE;
  97. + if (scale == pvt->scale_background)
  98. + return;
  99. +
  100. + pvt->scale_background = scale;
  101. +
  102. + g_object_notify (G_OBJECT (terminal), "scale-background");
  103. +
  104. + vte_terminal_queue_background_update(terminal);
  105. +}
  106. +
  107. +/**
  108. * vte_terminal_set_scroll_background:
  109. * @terminal: a #VteTerminal
  110. * @scroll: whether the terminal should scroll the background image along with
  111. diff -NurpP --minimal vte-0.28.2.orig/src/vte.c.orig vte-0.28.2/src/vte.c.orig
  112. diff -NurpP --minimal vte-0.28.2.orig/src/vte.h vte-0.28.2/src/vte.h
  113. --- vte-0.28.2.orig/src/vte.h 2011-08-16 21:52:48.000000000 +0000
  114. +++ vte-0.28.2/src/vte.h 2012-04-06 00:23:46.000000000 +0000
  115. @@ -306,6 +306,7 @@ void vte_terminal_set_audible_bell(VteTe
  116. gboolean vte_terminal_get_audible_bell(VteTerminal *terminal);
  117. void vte_terminal_set_visible_bell(VteTerminal *terminal, gboolean is_visible);
  118. gboolean vte_terminal_get_visible_bell(VteTerminal *terminal);
  119. +void vte_terminal_set_scale_background(VteTerminal *terminal, gboolean scale);
  120. void vte_terminal_set_scroll_background(VteTerminal *terminal, gboolean scroll);
  121. void vte_terminal_set_scroll_on_output(VteTerminal *terminal, gboolean scroll);
  122. void vte_terminal_set_scroll_on_keystroke(VteTerminal *terminal,
  123. diff -NurpP --minimal vte-0.28.2.orig/src/vte.h.orig vte-0.28.2/src/vte.h.orig
  124. diff -NurpP --minimal vte-0.28.2.orig/src/vteapp.c vte-0.28.2/src/vteapp.c
  125. --- vte-0.28.2.orig/src/vteapp.c 2011-08-16 21:52:48.000000000 +0000
  126. +++ vte-0.28.2/src/vteapp.c 2012-04-06 00:23:46.000000000 +0000
  127. @@ -553,7 +553,7 @@ main(int argc, char **argv)
  128. const char *background = NULL;
  129. gboolean transparent = FALSE, audible = TRUE,
  130. debug = FALSE, dingus = FALSE, dbuffer = TRUE,
  131. - console = FALSE, scroll = FALSE, keep = FALSE,
  132. + console = FALSE, scroll = FALSE, scale = FALSE, keep = FALSE,
  133. icon_title = FALSE, shell = TRUE, highlight_set = FALSE,
  134. cursor_set = FALSE, reverse = FALSE, use_geometry_hints = TRUE,
  135. antialias = TRUE, use_scrolled_window = FALSE,
  136. @@ -669,6 +669,11 @@ main(int argc, char **argv)
  137. "Set cursor shape (block|underline|ibeam)", NULL
  138. },
  139. {
  140. + "scale-background", 'z', 0,
  141. + G_OPTION_ARG_NONE, &scale,
  142. + "Enable a scaling background", NULL
  143. + },
  144. + {
  145. "scroll-background", 's', 0,
  146. G_OPTION_ARG_NONE, &scroll,
  147. "Enable a scrolling background", NULL
  148. @@ -891,6 +896,7 @@ main(int argc, char **argv)
  149. vte_terminal_set_audible_bell(terminal, audible);
  150. vte_terminal_set_visible_bell(terminal, !audible);
  151. vte_terminal_set_cursor_blink_mode(terminal, cursor_blink_mode);
  152. + vte_terminal_set_scale_background(terminal, scale);
  153. vte_terminal_set_scroll_background(terminal, scroll);
  154. vte_terminal_set_scroll_on_output(terminal, FALSE);
  155. vte_terminal_set_scroll_on_keystroke(terminal, TRUE);
  156. diff -NurpP --minimal vte-0.28.2.orig/src/vteapp.c.orig vte-0.28.2/src/vteapp.c.orig
  157. diff -NurpP --minimal vte-0.28.2.orig/src/vtebg.c vte-0.28.2/src/vtebg.c
  158. --- vte-0.28.2.orig/src/vtebg.c 2011-08-16 21:52:48.000000000 +0000
  159. +++ vte-0.28.2/src/vtebg.c 2012-04-06 00:23:46.000000000 +0000
  160. @@ -56,6 +56,8 @@ typedef struct {
  161. PangoColor tint_color;
  162. double saturation;
  163. cairo_surface_t *surface;
  164. + int width;
  165. + int height;
  166. } VteBgCacheItem;
  167. static void vte_bg_cache_item_free(VteBgCacheItem *item);
  168. @@ -321,6 +323,8 @@ static void item_surface_destroy_func(vo
  169. "VteBgCacheItem %p surface destroyed\n", item);
  170. item->surface = NULL;
  171. + item->width = 1;
  172. + item->height = 1;
  173. }
  174. /*
  175. @@ -364,7 +368,9 @@ vte_bg_cache_search(VteBg *bg,
  176. const GdkPixbuf *source_pixbuf,
  177. const char *source_file,
  178. const PangoColor *tint,
  179. - double saturation)
  180. + double saturation,
  181. + int *surface_width,
  182. + int *surface_height)
  183. {
  184. GList *i;
  185. @@ -392,6 +398,11 @@ vte_bg_cache_search(VteBg *bg,
  186. break;
  187. }
  188. + if (surface_width)
  189. + *surface_width = item->width;
  190. + if (surface_height)
  191. + *surface_height = item->height;
  192. +
  193. return cairo_surface_reference(item->surface);
  194. }
  195. }
  196. @@ -407,6 +418,8 @@ vte_bg_cache_search(VteBg *bg,
  197. * @tint: a #PangoColor to use as tint color
  198. * @saturation: the saturation as a value between 0.0 and 1.0
  199. * @other: a #cairo_surface_t
  200. + * @surface_width: pointer to store the surface width
  201. + * @surface_height: pointer to store the surface height
  202. *
  203. * Returns: a reference to a #cairo_surface_t, or %NULL on failure
  204. */
  205. @@ -417,7 +430,9 @@ vte_bg_get_surface(VteBg *bg,
  206. const char *source_file,
  207. const PangoColor *tint,
  208. double saturation,
  209. - cairo_surface_t *other)
  210. + cairo_surface_t *other,
  211. + int *surface_width,
  212. + int *surface_height)
  213. {
  214. VteBgPrivate *pvt;
  215. VteBgCacheItem *item;
  216. @@ -440,7 +455,8 @@ vte_bg_get_surface(VteBg *bg,
  217. cached = vte_bg_cache_search(bg, source_type,
  218. source_pixbuf, source_file,
  219. - tint, saturation);
  220. + tint, saturation,
  221. + surface_width, surface_height);
  222. if (cached != NULL) {
  223. return cached;
  224. }
  225. @@ -494,6 +510,13 @@ vte_bg_get_surface(VteBg *bg,
  226. else
  227. goto out;
  228. + if (surface_width)
  229. + *surface_width = width;
  230. + if (surface_height)
  231. + *surface_height = height;
  232. +
  233. + item->width = width;
  234. + item->height = height;
  235. item->surface =
  236. cairo_surface_create_similar(other, CAIRO_CONTENT_COLOR_ALPHA,
  237. width, height);
  238. diff -NurpP --minimal vte-0.28.2.orig/src/vtebg.c.orig vte-0.28.2/src/vtebg.c.orig
  239. diff -NurpP --minimal vte-0.28.2.orig/src/vtebg.h vte-0.28.2/src/vtebg.h
  240. --- vte-0.28.2.orig/src/vtebg.h 2011-08-16 21:52:48.000000000 +0000
  241. +++ vte-0.28.2/src/vtebg.h 2012-04-06 00:23:46.000000000 +0000
  242. @@ -63,7 +63,9 @@ vte_bg_get_surface(VteBg *bg,
  243. const char *source_file,
  244. const PangoColor *tint,
  245. double saturation,
  246. - cairo_surface_t *other);
  247. + cairo_surface_t *other,
  248. + int *surface_width,
  249. + int *surface_height);
  250. G_END_DECLS
  251. diff -NurpP --minimal vte-0.28.2.orig/src/vtedraw.c vte-0.28.2/src/vtedraw.c
  252. --- vte-0.28.2.orig/src/vtedraw.c 2011-08-16 21:52:48.000000000 +0000
  253. +++ vte-0.28.2/src/vtedraw.c 2012-04-06 00:23:46.000000000 +0000
  254. @@ -752,6 +752,7 @@ struct _vte_draw {
  255. struct font_info *font;
  256. struct font_info *font_bold;
  257. cairo_pattern_t *bg_pattern;
  258. + gint bg_width, bg_height;
  259. cairo_t *cr;
  260. };
  261. @@ -839,6 +840,8 @@ _vte_draw_set_background_solid(struct _v
  262. green,
  263. blue,
  264. opacity);
  265. + draw->bg_width = 1;
  266. + draw->bg_height = 1;
  267. }
  268. void
  269. @@ -850,6 +853,7 @@ _vte_draw_set_background_image (struct _
  270. double saturation)
  271. {
  272. cairo_surface_t *surface;
  273. + int surface_width, surface_height;
  274. /* Need a valid draw->cr for cairo_get_target () */
  275. _vte_draw_start (draw);
  276. @@ -857,7 +861,8 @@ _vte_draw_set_background_image (struct _
  277. surface = vte_bg_get_surface (vte_bg_get_for_screen (gtk_widget_get_screen (draw->widget)),
  278. type, pixbuf, filename,
  279. color, saturation,
  280. - cairo_get_target(draw->cr));
  281. + cairo_get_target(draw->cr),
  282. + &surface_width, &surface_height);
  283. _vte_draw_end (draw);
  284. @@ -868,6 +873,8 @@ _vte_draw_set_background_image (struct _
  285. cairo_pattern_destroy (draw->bg_pattern);
  286. draw->bg_pattern = cairo_pattern_create_for_surface (surface);
  287. + draw->bg_width = surface_width;
  288. + draw->bg_height = surface_height;
  289. cairo_surface_destroy (surface);
  290. cairo_pattern_set_extend (draw->bg_pattern, CAIRO_EXTEND_REPEAT);
  291. }
  292. @@ -888,6 +895,24 @@ _vte_draw_set_background_scroll (struct
  293. cairo_pattern_set_matrix (draw->bg_pattern, &matrix);
  294. }
  295. +void
  296. +_vte_draw_set_background_scale (struct _vte_draw *draw,
  297. + gint sx, gint sy)
  298. +{
  299. + cairo_matrix_t matrix;
  300. +
  301. + _vte_debug_print (VTE_DEBUG_DRAW,
  302. + "draw_set_scale (%d, %d)\n",
  303. + sx, sy);
  304. +
  305. + g_return_if_fail (draw->bg_pattern != NULL);
  306. +
  307. + cairo_matrix_init_scale (&matrix,
  308. + (1.0 * draw->bg_width) / sx,
  309. + (1.0 * draw->bg_height) / sy);
  310. + cairo_pattern_set_matrix (draw->bg_pattern, &matrix);
  311. +}
  312. +
  313. void
  314. _vte_draw_clip (struct _vte_draw *draw, GdkRegion *region)
  315. {
  316. diff -NurpP --minimal vte-0.28.2.orig/src/vtedraw.c.orig vte-0.28.2/src/vtedraw.c.orig
  317. diff -NurpP --minimal vte-0.28.2.orig/src/vtedraw.h vte-0.28.2/src/vtedraw.h
  318. --- vte-0.28.2.orig/src/vtedraw.h 2011-08-16 21:52:48.000000000 +0000
  319. +++ vte-0.28.2/src/vtedraw.h 2012-04-06 00:23:46.000000000 +0000
  320. @@ -82,6 +82,8 @@ void _vte_draw_set_background_image(stru
  321. double saturation);
  322. void _vte_draw_set_background_scroll(struct _vte_draw *draw,
  323. gint x, gint y);
  324. +void _vte_draw_set_background_scale(struct _vte_draw *draw,
  325. + gint sx, gint sy);
  326. void _vte_draw_clip(struct _vte_draw *draw, GdkRegion *region);
  327. void _vte_draw_clear(struct _vte_draw *draw,