aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2015-12-31 14:18:09 +0900
committerYAMAMOTO Mitsuharu2015-12-31 14:18:09 +0900
commitce5ad125ef982648185d26f45995f02fc5ae132e (patch)
treeff3417a71770e2e28262ce0b4616d05418ca4393 /src
parent30f4a892eccf5bae7f824b1845222db104246258 (diff)
downloademacs-ce5ad125ef982648185d26f45995f02fc5ae132e.tar.gz
emacs-ce5ad125ef982648185d26f45995f02fc5ae132e.zip
Clean up cairo printing code
* src/gtkutil.c (xg_get_page_setup): Use listn. * src/xfns.c (Fx_export_frames, Fx_print_frames_dialog): Doc fix. Use decode_window_system_frame and FRAME_VISIBLE_P. (Fx_print_frames_dialog): Use redisplay_preserve_echo_area instead of Fdisplay. * src/xterm.c (x_cr_export_frames): Use redisplay_preserve_echo_area instead of Fdisplay. Temporarily unblock_input around QUIT.
Diffstat (limited to 'src')
-rw-r--r--src/gtkutil.c41
-rw-r--r--src/xfns.c46
-rw-r--r--src/xterm.c16
3 files changed, 47 insertions, 56 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 90683eba7b8..1cf8ae7c5ab 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -4084,31 +4084,11 @@ xg_page_setup_dialog (void)
4084Lisp_Object 4084Lisp_Object
4085xg_get_page_setup (void) 4085xg_get_page_setup (void)
4086{ 4086{
4087 Lisp_Object result, orientation_symbol;
4088 GtkPageOrientation orientation; 4087 GtkPageOrientation orientation;
4088 Lisp_Object orientation_symbol;
4089 4089
4090 if (page_setup == NULL) 4090 if (page_setup == NULL)
4091 page_setup = gtk_page_setup_new (); 4091 page_setup = gtk_page_setup_new ();
4092 result = list4 (Fcons (Qleft_margin,
4093 make_float (gtk_page_setup_get_left_margin (page_setup,
4094 GTK_UNIT_POINTS))),
4095 Fcons (Qright_margin,
4096 make_float (gtk_page_setup_get_right_margin (page_setup,
4097 GTK_UNIT_POINTS))),
4098 Fcons (Qtop_margin,
4099 make_float (gtk_page_setup_get_top_margin (page_setup,
4100 GTK_UNIT_POINTS))),
4101 Fcons (Qbottom_margin,
4102 make_float (gtk_page_setup_get_bottom_margin (page_setup,
4103 GTK_UNIT_POINTS))));
4104 result = Fcons (Fcons (Qheight,
4105 make_float (gtk_page_setup_get_page_height (page_setup,
4106 GTK_UNIT_POINTS))),
4107 result);
4108 result = Fcons (Fcons (Qwidth,
4109 make_float (gtk_page_setup_get_page_width (page_setup,
4110 GTK_UNIT_POINTS))),
4111 result);
4112 orientation = gtk_page_setup_get_orientation (page_setup); 4092 orientation = gtk_page_setup_get_orientation (page_setup);
4113 if (orientation == GTK_PAGE_ORIENTATION_PORTRAIT) 4093 if (orientation == GTK_PAGE_ORIENTATION_PORTRAIT)
4114 orientation_symbol = Qportrait; 4094 orientation_symbol = Qportrait;
@@ -4118,9 +4098,24 @@ xg_get_page_setup (void)
4118 orientation_symbol = Qreverse_portrait; 4098 orientation_symbol = Qreverse_portrait;
4119 else if (orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE) 4099 else if (orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE)
4120 orientation_symbol = Qreverse_landscape; 4100 orientation_symbol = Qreverse_landscape;
4121 result = Fcons (Fcons (Qorientation, orientation_symbol), result);
4122 4101
4123 return result; 4102 return listn (CONSTYPE_HEAP, 7,
4103 Fcons (Qorientation, orientation_symbol),
4104#define MAKE_FLOAT_PAGE_SETUP(f) make_float (f (page_setup, GTK_UNIT_POINTS))
4105 Fcons (Qwidth,
4106 MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_page_width)),
4107 Fcons (Qheight,
4108 MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_page_height)),
4109 Fcons (Qleft_margin,
4110 MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_left_margin)),
4111 Fcons (Qright_margin,
4112 MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_right_margin)),
4113 Fcons (Qtop_margin,
4114 MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_top_margin)),
4115 Fcons (Qbottom_margin,
4116 MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_bottom_margin))
4117#undef MAKE_FLOAT_PAGE_SETUP
4118 );
4124} 4119}
4125 4120
4126static void 4121static void
diff --git a/src/xfns.c b/src/xfns.c
index 3f95f7b79fb..d8ba49587f1 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -6564,31 +6564,27 @@ present and mapped to the usual X keysyms. */)
6564DEFUN ("x-export-frames", Fx_export_frames, Sx_export_frames, 0, 2, 0, 6564DEFUN ("x-export-frames", Fx_export_frames, Sx_export_frames, 0, 2, 0,
6565 doc: /* Return image data of FRAMES in TYPE format. 6565 doc: /* Return image data of FRAMES in TYPE format.
6566FRAMES should be nil (the selected frame), a frame, or a list of 6566FRAMES should be nil (the selected frame), a frame, or a list of
6567frames (each of which corresponds to one page). Optional arg TYPE 6567frames (each of which corresponds to one page). Each frame should be
6568should be either `pdf' (default), `png', `postscript', or `svg'. 6568visible. Optional arg TYPE should be either `pdf' (default), `png',
6569Supported types are determined by the compile-time configuration of 6569`postscript', or `svg'. Supported types are determined by the
6570cairo. */) 6570compile-time configuration of cairo. */)
6571 (Lisp_Object frames, Lisp_Object type) 6571 (Lisp_Object frames, Lisp_Object type)
6572{ 6572{
6573 Lisp_Object result, rest, tmp; 6573 Lisp_Object rest, tmp;
6574 cairo_surface_type_t surface_type; 6574 cairo_surface_type_t surface_type;
6575 6575
6576 if (NILP (frames))
6577 frames = selected_frame;
6578 if (!CONSP (frames)) 6576 if (!CONSP (frames))
6579 frames = list1 (frames); 6577 frames = list1 (frames);
6580 6578
6581 tmp = Qnil; 6579 tmp = Qnil;
6582 for (rest = frames; CONSP (rest); rest = XCDR (rest)) 6580 for (rest = frames; CONSP (rest); rest = XCDR (rest))
6583 { 6581 {
6584 struct frame *f = XFRAME (XCAR (rest)); 6582 struct frame *f = decode_window_system_frame (XCAR (rest));
6585
6586 if (! FRAME_LIVE_P (f) || ! FRAME_X_P (f) || ! FRAME_LIVE_P (f))
6587 error ("Invalid frame");
6588
6589 Lisp_Object frame; 6583 Lisp_Object frame;
6590 6584
6591 XSETFRAME (frame, f); 6585 XSETFRAME (frame, f);
6586 if (!FRAME_VISIBLE_P (f))
6587 error ("Frames to be exported must be visible.");
6592 tmp = Fcons (frame, tmp); 6588 tmp = Fcons (frame, tmp);
6593 } 6589 }
6594 frames = Fnreverse (tmp); 6590 frames = Fnreverse (tmp);
@@ -6624,9 +6620,7 @@ cairo. */)
6624#endif 6620#endif
6625 error ("Unsupported export type"); 6621 error ("Unsupported export type");
6626 6622
6627 result = x_cr_export_frames (frames, surface_type); 6623 return x_cr_export_frames (frames, surface_type);
6628
6629 return result;
6630} 6624}
6631 6625
6632#ifdef USE_GTK 6626#ifdef USE_GTK
@@ -6654,8 +6648,12 @@ The return value is an alist containing the following keys:
6654 on, in points. 6648 on, in points.
6655 6649
6656The paper width can be obtained as the sum of width, left-margin, and 6650The paper width can be obtained as the sum of width, left-margin, and
6657right-margin values. Likewise, the paper height is the sum of height, 6651right-margin values if the page orientation is `portrait' or
6658top-margin, and bottom-margin values. */) 6652`reverse-portrait'. Otherwise, it is the sum of width, top-margin,
6653and bottom-margin values. Likewise, the paper height is the sum of
6654height, top-margin, and bottom-margin values if the page orientation
6655is `portrait' or `reverse-portrait'. Otherwise, it is the sum of
6656height, left-margin, and right-margin values. */)
6659 (void) 6657 (void)
6660{ 6658{
6661 Lisp_Object result; 6659 Lisp_Object result;
@@ -6675,29 +6673,29 @@ visible. */)
6675 (Lisp_Object frames) 6673 (Lisp_Object frames)
6676{ 6674{
6677 Lisp_Object rest, tmp; 6675 Lisp_Object rest, tmp;
6676 int count;
6678 6677
6679 if (NILP (frames))
6680 frames = selected_frame;
6681 if (!CONSP (frames)) 6678 if (!CONSP (frames))
6682 frames = list1 (frames); 6679 frames = list1 (frames);
6683 6680
6684 tmp = Qnil; 6681 tmp = Qnil;
6685 for (rest = frames; CONSP (rest); rest = XCDR (rest)) 6682 for (rest = frames; CONSP (rest); rest = XCDR (rest))
6686 { 6683 {
6687 struct frame *f = XFRAME (XCAR (rest)); 6684 struct frame *f = decode_window_system_frame (XCAR (rest));
6688 if (! FRAME_LIVE_P (f) || ! FRAME_X_P (f) || ! FRAME_LIVE_P (f))
6689 error ("Invalid frame");
6690 Lisp_Object frame; 6685 Lisp_Object frame;
6691 6686
6692 XSETFRAME (frame, f); 6687 XSETFRAME (frame, f);
6693 if (!EQ (Fframe_visible_p (frame), Qt)) 6688 if (!FRAME_VISIBLE_P (f))
6694 error ("Frames to be printed must be visible."); 6689 error ("Frames to be printed must be visible.");
6695 tmp = Fcons (frame, tmp); 6690 tmp = Fcons (frame, tmp);
6696 } 6691 }
6697 frames = Fnreverse (tmp); 6692 frames = Fnreverse (tmp);
6698 6693
6699 /* Make sure the current matrices are up-to-date. */ 6694 /* Make sure the current matrices are up-to-date. */
6700 Fredisplay (Qt); 6695 count = SPECPDL_INDEX ();
6696 specbind (Qredisplay_dont_pause, Qt);
6697 redisplay_preserve_echo_area (32);
6698 unbind_to (count, Qnil);
6701 6699
6702 block_input (); 6700 block_input ();
6703 xg_print_frames_dialog (frames); 6701 xg_print_frames_dialog (frames);
diff --git a/src/xterm.c b/src/xterm.c
index acb6566d51d..c5c8b5f70fd 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -569,7 +569,8 @@ x_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type)
569 Lisp_Object acc = Qnil; 569 Lisp_Object acc = Qnil;
570 int count = SPECPDL_INDEX (); 570 int count = SPECPDL_INDEX ();
571 571
572 Fredisplay (Qt); 572 specbind (Qredisplay_dont_pause, Qt);
573 redisplay_preserve_echo_area (31);
573 574
574 f = XFRAME (XCAR (frames)); 575 f = XFRAME (XCAR (frames));
575 frames = XCDR (frames); 576 frames = XCDR (frames);
@@ -611,24 +612,18 @@ x_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type)
611 cr = cairo_create (surface); 612 cr = cairo_create (surface);
612 cairo_surface_destroy (surface); 613 cairo_surface_destroy (surface);
613 record_unwind_protect (x_cr_destroy, make_save_ptr (cr)); 614 record_unwind_protect (x_cr_destroy, make_save_ptr (cr));
614 unblock_input ();
615 615
616 while (1) 616 while (1)
617 { 617 {
618 QUIT;
619
620 block_input ();
621 x_free_cr_resources (f); 618 x_free_cr_resources (f);
622 FRAME_CR_CONTEXT (f) = cr; 619 FRAME_CR_CONTEXT (f) = cr;
623 x_clear_area (f, 0, 0, width, height); 620 x_clear_area (f, 0, 0, width, height);
624 expose_frame (f, 0, 0, width, height); 621 expose_frame (f, 0, 0, width, height);
625 FRAME_CR_CONTEXT (f) = NULL; 622 FRAME_CR_CONTEXT (f) = NULL;
626 unblock_input ();
627 623
628 if (NILP (frames)) 624 if (NILP (frames))
629 break; 625 break;
630 626
631 block_input ();
632 cairo_surface_show_page (surface); 627 cairo_surface_show_page (surface);
633 f = XFRAME (XCAR (frames)); 628 f = XFRAME (XCAR (frames));
634 frames = XCDR (frames); 629 frames = XCDR (frames);
@@ -636,18 +631,21 @@ x_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type)
636 height = FRAME_PIXEL_HEIGHT (f); 631 height = FRAME_PIXEL_HEIGHT (f);
637 if (surface_set_size_func) 632 if (surface_set_size_func)
638 (*surface_set_size_func) (surface, width, height); 633 (*surface_set_size_func) (surface, width, height);
634
639 unblock_input (); 635 unblock_input ();
636 QUIT;
637 block_input ();
640 } 638 }
641 639
642#ifdef CAIRO_HAS_PNG_FUNCTIONS 640#ifdef CAIRO_HAS_PNG_FUNCTIONS
643 if (surface_type == CAIRO_SURFACE_TYPE_IMAGE) 641 if (surface_type == CAIRO_SURFACE_TYPE_IMAGE)
644 { 642 {
645 block_input ();
646 cairo_surface_flush (surface); 643 cairo_surface_flush (surface);
647 cairo_surface_write_to_png_stream (surface, x_cr_accumulate_data, &acc); 644 cairo_surface_write_to_png_stream (surface, x_cr_accumulate_data, &acc);
648 unblock_input ();
649 } 645 }
650#endif 646#endif
647 unblock_input ();
648
651 unbind_to (count, Qnil); 649 unbind_to (count, Qnil);
652 650
653 return CALLN (Fapply, intern ("concat"), Fnreverse (acc)); 651 return CALLN (Fapply, intern ("concat"), Fnreverse (acc));