@@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
2222 interpretation of even the system includes. */
2323#include <config.h>
2424
25+ #include <cairo.h>
2526#include <fcntl.h>
2627#include <math.h>
2728#include <pthread.h>
@@ -63,6 +64,11 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
6364
6465#define FRAME_CR_CONTEXT (f ) ((f)->output_data.pgtk->cr_context)
6566#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+
6672
6773struct pgtk_display_info * x_display_list ; /* Chain of existing displays */
6874extern Lisp_Object tip_frame ;
@@ -4864,6 +4870,7 @@ static void size_allocate(GtkWidget *widget, GtkAllocation *alloc, gpointer *use
48644870 if (f ) {
48654871 PGTK_TRACE ("%dx%d" , alloc -> width , alloc -> height );
48664872 xg_frame_resized (f , alloc -> width , alloc -> height );
4873+ pgtk_cr_update_surface_desired_size (f , alloc -> width , alloc -> height );
48674874 }
48684875}
48694876
@@ -5287,6 +5294,7 @@ static gboolean configure_event(GtkWidget *widget, GdkEvent *event, gpointer *us
52875294 if (f && widget == FRAME_GTK_OUTER_WIDGET (f )) {
52885295 PGTK_TRACE ("%dx%d" , event -> configure .width , event -> configure .height );
52895296 xg_frame_resized (f , event -> configure .width , event -> configure .height );
5297+ pgtk_cr_update_surface_desired_size (f , event -> configure .width , event -> configure .height );
52905298 }
52915299 return TRUE;
52925300}
@@ -6604,6 +6612,40 @@ If set to a non-float value, there will be no wait at all. */);
66046612
66056613}
66066614
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+
66076649cairo_t *
66086650pgtk_begin_cr_clip (struct frame * f )
66096651{
0 commit comments