Implement frame-scale-factor

* src/frame.c (Fframe_scale_factor): New function.
(syms_of_frame): Add frame-scale-factor.
* src/frame.h: Add FRAME_SCALE_FACTOR.
* src/image.c: Move FRAME_SCALE_FACTOR to frame.h.
This commit is contained in:
Alan Third 2021-03-24 22:50:03 +00:00
parent b0d095b2cd
commit 4e1f92feb3
3 changed files with 19 additions and 8 deletions

View file

@ -3744,6 +3744,17 @@ window state change flag is reset. */)
return (FRAME_WINDOW_STATE_CHANGE (f) = !NILP (arg)) ? Qt : Qnil;
}
DEFUN ("frame-scale-factor", Fframe_scale_factor, Sframe_scale_factor,
0, 1, 0,
doc: /* Return FRAMEs scale factor.
The scale factor is the amount a logical pixel size must be multiplied
to find the real number of pixels. */)
(Lisp_Object frame)
{
struct frame *f = decode_live_frame (frame);
return (make_float (FRAME_SCALE_FACTOR (f)));
}
/***********************************************************************
Frame Parameters
@ -6457,6 +6468,7 @@ iconify the top level frame instead. */);
defsubr (&Sframe_pointer_visible_p);
defsubr (&Sframe_window_state_change);
defsubr (&Sset_frame_window_state_change);
defsubr (&Sframe_scale_factor);
#ifdef HAVE_WINDOW_SYSTEM
defsubr (&Sx_get_resource);

View file

@ -907,6 +907,13 @@ default_pixels_per_inch_y (void)
(WINDOWP (f->minibuffer_window) \
&& XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
/* Scale factor of frame F. */
#if defined HAVE_NS
# define FRAME_SCALE_FACTOR(f) (FRAME_NS_P (f) ? ns_frame_scale_factor (f) : 1)
#else
# define FRAME_SCALE_FACTOR(f) 1;
#endif
/* Pixel width of frame F. */
#define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)

View file

@ -135,14 +135,6 @@ typedef struct ns_bitmap_record Bitmap_Record;
# define COLOR_TABLE_SUPPORT 1
#endif
#ifdef HAVE_RSVG
#if defined HAVE_NS
# define FRAME_SCALE_FACTOR(f) ns_frame_scale_factor (f)
#else
# define FRAME_SCALE_FACTOR(f) 1;
#endif
#endif
static void image_disable_image (struct frame *, struct image *);
static void image_edge_detection (struct frame *, struct image *, Lisp_Object,
Lisp_Object);