#include "fontset.h"
#include "font.h"
#include "xsettings.h"
+#include "atimer.h"
#ifdef HAVE_PGTK
RES_TYPE_STRING);
}
+static void update_watched_scale_factor(struct atimer *timer)
+{
+ struct frame *f = timer->client_data;
+
+ double scale_factor = FRAME_SCALE_FACTOR (f);
+ if (scale_factor != FRAME_X_OUTPUT (f)->watched_scale_factor)
+ {
+ FRAME_X_OUTPUT (f)->watched_scale_factor = scale_factor;
+ pgtk_cr_update_surface_desired_size (f,
+ FRAME_CR_SURFACE_DESIRED_WIDTH (f),
+ FRAME_CR_SURFACE_DESIRED_HEIGHT (f),
+ true);
+ }
+}
+
/* ==========================================================================
Lisp definitions
FRAME_X_OUTPUT (f)->cr_surface_visible_bell = NULL;
FRAME_X_OUTPUT (f)->atimer_visible_bell = NULL;
+ FRAME_X_OUTPUT (f)->watched_scale_factor = 1.0;
+ struct timespec ts = make_timespec (1, 0);
+ FRAME_X_OUTPUT (f)->scale_factor_atimer = start_atimer(ATIMER_CONTINUOUS,
+ ts,
+ update_watched_scale_factor,
+ f);
/* Make sure windows on this frame appear in calls to next-window
and similar functions. */
gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (tip_f)), root_x, root_y);
unblock_input ();
- pgtk_cr_update_surface_desired_size (tip_f, width, height);
+ pgtk_cr_update_surface_desired_size (tip_f, width, height, false);
w->must_be_updated_p = true;
update_single_window (w);
#define FRAME_CR_CONTEXT(f) ((f)->output_data.pgtk->cr_context)
#define FRAME_CR_ACTIVE_CONTEXT(f) ((f)->output_data.pgtk->cr_active)
#define FRAME_CR_SURFACE(f) (cairo_get_target (FRAME_CR_CONTEXT (f)))
-#define FRAME_CR_SURFACE_DESIRED_WIDTH(f) \
- ((f)->output_data.pgtk->cr_surface_desired_width)
-#define FRAME_CR_SURFACE_DESIRED_HEIGHT(f) \
- ((f)->output_data.pgtk->cr_surface_desired_height)
/* Non-zero means that a HELP_EVENT has been generated since Emacs
start. */
free_frame_faces (f);
+ if (FRAME_X_OUTPUT (f)->scale_factor_atimer != NULL)
+ {
+ cancel_atimer (FRAME_X_OUTPUT (f)->scale_factor_atimer);
+ FRAME_X_OUTPUT (f)->scale_factor_atimer = NULL;
+ }
+
#define CLEAR_IF_EQ(FIELD) \
do { if (f == dpyinfo->FIELD) dpyinfo->FIELD = 0; } while (false)
if (f)
{
xg_frame_resized (f, alloc->width, alloc->height);
- pgtk_cr_update_surface_desired_size (f, alloc->width, alloc->height);
+ pgtk_cr_update_surface_desired_size (f, alloc->width, alloc->height, false);
}
}
* until a redrawn frame is completed.
*/
void
-pgtk_cr_update_surface_desired_size (struct frame *f, int width, int height)
+pgtk_cr_update_surface_desired_size (struct frame *f, int width, int height, bool force)
{
if (FRAME_CR_SURFACE_DESIRED_WIDTH (f) != width
- || FRAME_CR_SURFACE_DESIRED_HEIGHT (f) != height)
+ || FRAME_CR_SURFACE_DESIRED_HEIGHT (f) != height
+ || force)
{
pgtk_cr_destroy_frame_context (f);
FRAME_CR_SURFACE_DESIRED_WIDTH (f) = width;
frame, or IMPLICIT if we received an EnterNotify.
FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
int focus_state;
+
+ /* Keep track of scale factor. If monitor's scale factor is changed, or
+ monitor is switched and scale factor is changed, then recreate cairo_t
+ and cairo_surface_t. I need GTK's such signal, but there isn't, so
+ I watch it periodically with atimer. */
+ double watched_scale_factor;
+ struct atimer *scale_factor_atimer;
};
/* this dummy decl needed to support TTYs */
(! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
: FRAME_SCROLL_BAR_COLS (f))
+#define FRAME_CR_SURFACE_DESIRED_WIDTH(f) \
+ ((f)->output_data.pgtk->cr_surface_desired_width)
+#define FRAME_CR_SURFACE_DESIRED_HEIGHT(f) \
+ ((f)->output_data.pgtk->cr_surface_desired_height)
/* Display init/shutdown functions implemented in pgtkterm.c */
extern struct pgtk_display_info *pgtk_term_init (Lisp_Object display_name,
Lisp_Object old_value);
/* Cairo related functions implemented in pgtkterm.c */
-extern void pgtk_cr_update_surface_desired_size (struct frame *, int, int);
+extern void pgtk_cr_update_surface_desired_size (struct frame *, int, int, bool);
extern cairo_t *pgtk_begin_cr_clip (struct frame *f);
extern void pgtk_end_cr_clip (struct frame *f);
extern void pgtk_set_cr_source_with_gc_foreground (struct frame *f,