@@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
22
22
interpretation of even the system includes. */
23
23
#include <config.h>
24
24
25
+ #include <cairo.h>
25
26
#include <fcntl.h>
26
27
#include <math.h>
27
28
#include <pthread.h>
@@ -63,6 +64,11 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
63
64
64
65
#define FRAME_CR_CONTEXT (f ) ((f)->output_data.pgtk->cr_context)
65
66
#define FRAME_CR_SURFACE (f ) ((f)->output_data.pgtk->cr_surface)
67
+ #define FRAME_CR_SURFACE_DESIRED_WIDTH (f ) \
68
+ ((f)->output_data.pgtk->cr_surface_desired_width)
69
+ #define FRAME_CR_SURFACE_DESIRED_HEIGHT (f ) \
70
+ ((f)->output_data.pgtk->cr_surface_desired_height)
71
+
66
72
67
73
struct pgtk_display_info * x_display_list ; /* Chain of existing displays */
68
74
extern Lisp_Object tip_frame ;
@@ -4864,6 +4870,7 @@ static void size_allocate(GtkWidget *widget, GtkAllocation *alloc, gpointer *use
4864
4870
if (f ) {
4865
4871
PGTK_TRACE ("%dx%d" , alloc -> width , alloc -> height );
4866
4872
xg_frame_resized (f , alloc -> width , alloc -> height );
4873
+ pgtk_cr_update_surface_desired_size (f , alloc -> width , alloc -> height );
4867
4874
}
4868
4875
}
4869
4876
@@ -5287,6 +5294,7 @@ static gboolean configure_event(GtkWidget *widget, GdkEvent *event, gpointer *us
5287
5294
if (f && widget == FRAME_GTK_OUTER_WIDGET (f )) {
5288
5295
PGTK_TRACE ("%dx%d" , event -> configure .width , event -> configure .height );
5289
5296
xg_frame_resized (f , event -> configure .width , event -> configure .height );
5297
+ pgtk_cr_update_surface_desired_size (f , event -> configure .width , event -> configure .height );
5290
5298
}
5291
5299
return TRUE;
5292
5300
}
@@ -6604,6 +6612,40 @@ If set to a non-float value, there will be no wait at all. */);
6604
6612
6605
6613
}
6606
6614
6615
+
6616
+ void
6617
+ pgtk_cr_update_surface_desired_size (struct frame * f , int width , int height )
6618
+ {
6619
+ PGTK_TRACE ("pgtk_cr_update_surface_desired_size" );
6620
+
6621
+ if (FRAME_CR_SURFACE_DESIRED_WIDTH (f ) != width
6622
+ || FRAME_CR_SURFACE_DESIRED_HEIGHT (f ) != height )
6623
+ {
6624
+ cairo_surface_t * old_surface = FRAME_CR_SURFACE (f );
6625
+ cairo_t * cr = NULL ;
6626
+ cairo_t * old_cr = FRAME_CR_CONTEXT (f );
6627
+ FRAME_CR_SURFACE (f ) = gdk_window_create_similar_surface (gtk_widget_get_window (FRAME_GTK_WIDGET (f )),
6628
+ CAIRO_CONTENT_COLOR_ALPHA ,
6629
+ width ,
6630
+ height );
6631
+
6632
+ if (old_surface ){
6633
+ cr = cairo_create (FRAME_CR_SURFACE (f ));
6634
+ cairo_set_source_surface (cr , old_surface , 0 , 0 );
6635
+
6636
+ cairo_paint (cr );
6637
+ FRAME_CR_CONTEXT (f ) = cr ;
6638
+
6639
+ cairo_destroy (old_cr );
6640
+ cairo_surface_destroy (old_surface );
6641
+ }
6642
+ gtk_widget_queue_draw (FRAME_GTK_WIDGET (f ));
6643
+ FRAME_CR_SURFACE_DESIRED_WIDTH (f ) = width ;
6644
+ FRAME_CR_SURFACE_DESIRED_HEIGHT (f ) = height ;
6645
+ }
6646
+ }
6647
+
6648
+
6607
6649
cairo_t *
6608
6650
pgtk_begin_cr_clip (struct frame * f )
6609
6651
{
0 commit comments