aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2006-03-04 23:07:13 +0000
committerKaroly Lorentey2006-03-04 23:07:13 +0000
commit00bc10dab1f80e3fcf1b8e67dd7618c32ae3926d (patch)
tree875ed4fe8e87a4a52d5ea46140b3c70487847c81 /src
parentbdf36482bbea390390ae7ab1461b14b807c4fb1f (diff)
parent5e9edb94b78ef77981213fca9319d591c7362855 (diff)
downloademacs-00bc10dab1f80e3fcf1b8e67dd7618c32ae3926d.tar.gz
emacs-00bc10dab1f80e3fcf1b8e67dd7618c32ae3926d.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-128 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-129 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-130 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-131 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-132 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-133 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-134 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-135 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-43 Munge arch explicit ids in etc/images to match Emacs * emacs@sv.gnu.org/gnus--rel--5.10--patch-44 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-45 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-46 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-47 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-48 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-524
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog36
-rw-r--r--src/frame.h1
-rw-r--r--src/search.c2
-rw-r--r--src/window.c43
-rw-r--r--src/xdisp.c99
-rw-r--r--src/xselect.c39
6 files changed, 179 insertions, 41 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 79db6d09d0b..11fe6f910e4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,39 @@
12006-03-02 Kim F. Storm <storm@cua.dk>
2
3 * frame.h (struct frame): New member n_tool_bar_rows.
4
5 * xdisp.c: Minimize the unpleasent visual impact of the requirement
6 that non-toolkit tool-bars must occupy an integral number of screen
7 lines, by distributing the rows evenly over the tool-bar screen area.
8 (Vtool_bar_border): New variable.
9 (syms_of_xdisp): DEFVAR_LISP it.
10 (display_tool_bar_line): Add HEIGHT arg for desired row height. Make
11 tool-bar row the desired height. Use default face for border below
12 tool-bar.
13 (tool_bar_lines_needed): Add N_ROWS arg. Use it to return number of
14 actual tool-bar rows.
15 (redisplay_tool_bar): Calculate f->n_tool_bar_rows initially.
16 Adjust the height of the tool-bar rows to fill tool-bar screen area.
17 (redisplay_tool_bar): Calculate f->n_tool_bar_rows when tool-bar area
18 is resized.
19
202006-03-01 Luc Teirlinck <teirllm@auburn.edu>
21
22 * search.c (Fregexp_quote): Do not precede a literal `]' with two
23 backslashes to try to make clear that it has a literal meaning; it
24 does not do that. (It could close a character alternative
25 containing a backslash.)
26
272006-02-28 Chong Yidong <cyd@stupidchicken.com>
28
29 * xselect.c (x_catch_errors_unwind): New function.
30 (x_reply_selection_request): Put x_uncatch_errors in an unwind.
31 (Fx_get_atom_name): Call x_uncatch_errors earlier.
32
33 * window.c (Qscroll_up, Qscroll_down): New syms.
34 (window_scroll_pixel_based): Make preserve_y static to avoid
35 getting point stuck when scrolling 1 line.
36
12006-02-26 Chong Yidong <cyd@stupidchicken.com> 372006-02-26 Chong Yidong <cyd@stupidchicken.com>
2 38
3 * xterm.h, xterm.c (x_uncatch_errors): Delete unneccessary 39 * xterm.h, xterm.c (x_uncatch_errors): Delete unneccessary
diff --git a/src/frame.h b/src/frame.h
index ae80c03f9ca..aa4a00d6dfa 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -205,6 +205,7 @@ struct frame
205 /* Margin at the top of the frame. Used to display the tool-bar. */ 205 /* Margin at the top of the frame. Used to display the tool-bar. */
206 int tool_bar_lines; 206 int tool_bar_lines;
207 207
208 int n_tool_bar_rows;
208 int n_tool_bar_items; 209 int n_tool_bar_items;
209 210
210 /* A buffer for decode_mode_line. */ 211 /* A buffer for decode_mode_line. */
diff --git a/src/search.c b/src/search.c
index 04b58c78d3f..b92812597d5 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3066,7 +3066,7 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0,
3066 3066
3067 for (; in != end; in++) 3067 for (; in != end; in++)
3068 { 3068 {
3069 if (*in == '[' || *in == ']' 3069 if (*in == '['
3070 || *in == '*' || *in == '.' || *in == '\\' 3070 || *in == '*' || *in == '.' || *in == '\\'
3071 || *in == '?' || *in == '+' 3071 || *in == '?' || *in == '+'
3072 || *in == '^' || *in == '$') 3072 || *in == '^' || *in == '$')
diff --git a/src/window.c b/src/window.c
index 29701a1ac62..36050ac649e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -52,6 +52,7 @@ Boston, MA 02110-1301, USA. */
52 52
53 53
54Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; 54Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
55Lisp_Object Qscroll_up, Qscroll_down;
55Lisp_Object Qwindow_size_fixed; 56Lisp_Object Qwindow_size_fixed;
56extern Lisp_Object Qleft_margin, Qright_margin; 57extern Lisp_Object Qleft_margin, Qright_margin;
57 58
@@ -4723,9 +4724,9 @@ window_scroll_pixel_based (window, n, whole, noerror)
4723 struct text_pos start; 4724 struct text_pos start;
4724 Lisp_Object tem; 4725 Lisp_Object tem;
4725 int this_scroll_margin; 4726 int this_scroll_margin;
4726 int preserve_y;
4727 /* True if we fiddled the window vscroll field without really scrolling. */ 4727 /* True if we fiddled the window vscroll field without really scrolling. */
4728 int vscrolled = 0; 4728 int vscrolled = 0;
4729 static int preserve_y = -1;
4729 4730
4730 SET_TEXT_POS_FROM_MARKER (start, w->start); 4731 SET_TEXT_POS_FROM_MARKER (start, w->start);
4731 4732
@@ -4789,9 +4790,18 @@ window_scroll_pixel_based (window, n, whole, noerror)
4789 point in the same window line as it is now, so get that line. */ 4790 point in the same window line as it is now, so get that line. */
4790 if (!NILP (Vscroll_preserve_screen_position)) 4791 if (!NILP (Vscroll_preserve_screen_position))
4791 { 4792 {
4792 start_display (&it, w, start); 4793 /* We preserve the goal pixel coordinate across consecutive
4793 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); 4794 calls to scroll-up or scroll-down. This avoids the
4794 preserve_y = it.current_y; 4795 possibility of point becoming "stuck" on a tall line when
4796 scrolling by one line. */
4797 if (preserve_y < 0
4798 || (current_kboard->Vlast_command != Qscroll_up
4799 && current_kboard->Vlast_command != Qscroll_down))
4800 {
4801 start_display (&it, w, start);
4802 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
4803 preserve_y = it.current_y;
4804 }
4795 } 4805 }
4796 else 4806 else
4797 preserve_y = -1; 4807 preserve_y = -1;
@@ -4928,10 +4938,9 @@ window_scroll_pixel_based (window, n, whole, noerror)
4928 { 4938 {
4929 /* If we have a header line, take account of it. 4939 /* If we have a header line, take account of it.
4930 This is necessary because we set it.current_y to 0, above. */ 4940 This is necessary because we set it.current_y to 0, above. */
4931 if (WINDOW_WANTS_HEADER_LINE_P (w)) 4941 move_it_to (&it, -1, -1,
4932 preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w); 4942 preserve_y - (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0 ),
4933 4943 -1, MOVE_TO_Y);
4934 move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
4935 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 4944 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
4936 } 4945 }
4937 else 4946 else
@@ -4985,15 +4994,9 @@ window_scroll_pixel_based (window, n, whole, noerror)
4985 { 4994 {
4986 SET_TEXT_POS_FROM_MARKER (start, w->start); 4995 SET_TEXT_POS_FROM_MARKER (start, w->start);
4987 start_display (&it, w, start); 4996 start_display (&it, w, start);
4988#if 0 /* It's wrong to subtract this here 4997 /* It would be wrong to subtract CURRENT_HEADER_LINE_HEIGHT
4989 because we called start_display again 4998 here because we called start_display again and did not
4990 and did not alter it.current_y this time. */ 4999 alter it.current_y this time. */
4991
4992 /* If we have a header line, take account of it. */
4993 if (WINDOW_WANTS_HEADER_LINE_P (w))
4994 preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
4995#endif
4996
4997 move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y); 5000 move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
4998 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 5001 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
4999 } 5002 }
@@ -6990,6 +6993,12 @@ init_window ()
6990void 6993void
6991syms_of_window () 6994syms_of_window ()
6992{ 6995{
6996 Qscroll_up = intern ("scroll-up");
6997 staticpro (&Qscroll_up);
6998
6999 Qscroll_down = intern ("scroll-down");
7000 staticpro (&Qscroll_down);
7001
6993 Qwindow_size_fixed = intern ("window-size-fixed"); 7002 Qwindow_size_fixed = intern ("window-size-fixed");
6994 staticpro (&Qwindow_size_fixed); 7003 staticpro (&Qwindow_size_fixed);
6995 Fset (Qwindow_size_fixed, Qnil); 7004 Fset (Qwindow_size_fixed, Qnil);
diff --git a/src/xdisp.c b/src/xdisp.c
index 1361607010a..41c8546aac9 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -269,6 +269,12 @@ int auto_raise_tool_bar_buttons_p;
269 269
270int make_cursor_line_fully_visible_p; 270int make_cursor_line_fully_visible_p;
271 271
272/* Margin below tool bar in pixels. 0 or nil means no margin.
273 If value is `internal-border-width' or `border-width',
274 the corresponding frame parameter is used. */
275
276Lisp_Object Vtool_bar_border;
277
272/* Margin around tool bar buttons in pixels. */ 278/* Margin around tool bar buttons in pixels. */
273 279
274Lisp_Object Vtool_bar_button_margin; 280Lisp_Object Vtool_bar_button_margin;
@@ -839,7 +845,7 @@ static void store_mode_line_noprop_char P_ ((char));
839static int store_mode_line_noprop P_ ((const unsigned char *, int, int)); 845static int store_mode_line_noprop P_ ((const unsigned char *, int, int));
840static void x_consider_frame_title P_ ((Lisp_Object)); 846static void x_consider_frame_title P_ ((Lisp_Object));
841static void handle_stop P_ ((struct it *)); 847static void handle_stop P_ ((struct it *));
842static int tool_bar_lines_needed P_ ((struct frame *)); 848static int tool_bar_lines_needed P_ ((struct frame *, int *));
843static int single_display_spec_intangible_p P_ ((Lisp_Object)); 849static int single_display_spec_intangible_p P_ ((Lisp_Object));
844static void ensure_echo_area_buffers P_ ((void)); 850static void ensure_echo_area_buffers P_ ((void));
845static Lisp_Object unwind_with_echo_area_buffer P_ ((Lisp_Object)); 851static Lisp_Object unwind_with_echo_area_buffer P_ ((Lisp_Object));
@@ -950,7 +956,7 @@ static int in_ellipses_for_invisible_text_p P_ ((struct display_pos *,
950static void update_tool_bar P_ ((struct frame *, int)); 956static void update_tool_bar P_ ((struct frame *, int));
951static void build_desired_tool_bar_string P_ ((struct frame *f)); 957static void build_desired_tool_bar_string P_ ((struct frame *f));
952static int redisplay_tool_bar P_ ((struct frame *)); 958static int redisplay_tool_bar P_ ((struct frame *));
953static void display_tool_bar_line P_ ((struct it *)); 959static void display_tool_bar_line P_ ((struct it *, int));
954static void notice_overwritten_cursor P_ ((struct window *, 960static void notice_overwritten_cursor P_ ((struct window *,
955 enum glyph_row_area, 961 enum glyph_row_area,
956 int, int, int, int)); 962 int, int, int, int));
@@ -9429,11 +9435,17 @@ build_desired_tool_bar_string (f)
9429} 9435}
9430 9436
9431 9437
9432/* Display one line of the tool-bar of frame IT->f. */ 9438/* Display one line of the tool-bar of frame IT->f.
9439
9440 HEIGHT specifies the desired height of the tool-bar line.
9441 If the actual height of the glyph row is less than HEIGHT, the
9442 row's height is increased to HEIGHT, and the icons are centered
9443 vertically in the new height. */
9433 9444
9434static void 9445static void
9435display_tool_bar_line (it) 9446display_tool_bar_line (it, height)
9436 struct it *it; 9447 struct it *it;
9448 int height;
9437{ 9449{
9438 struct glyph_row *row = it->glyph_row; 9450 struct glyph_row *row = it->glyph_row;
9439 int max_x = it->last_visible_x; 9451 int max_x = it->last_visible_x;
@@ -9489,11 +9501,22 @@ display_tool_bar_line (it)
9489 out:; 9501 out:;
9490 9502
9491 row->displays_text_p = row->used[TEXT_AREA] != 0; 9503 row->displays_text_p = row->used[TEXT_AREA] != 0;
9504 /* Use default face for the border below the tool bar. */
9505 if (!row->displays_text_p)
9506 it->face_id = DEFAULT_FACE_ID;
9492 extend_face_to_end_of_line (it); 9507 extend_face_to_end_of_line (it);
9493 last = row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1; 9508 last = row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1;
9494 last->right_box_line_p = 1; 9509 last->right_box_line_p = 1;
9495 if (last == row->glyphs[TEXT_AREA]) 9510 if (last == row->glyphs[TEXT_AREA])
9496 last->left_box_line_p = 1; 9511 last->left_box_line_p = 1;
9512
9513 /* Make line the desired height and center it vertically. */
9514 if ((height -= it->max_ascent + it->max_descent) > 0)
9515 {
9516 it->max_ascent += height / 2;
9517 it->max_descent += (height + 1) / 2;
9518 }
9519
9497 compute_line_metrics (it); 9520 compute_line_metrics (it);
9498 9521
9499 /* If line is empty, make it occupy the rest of the tool-bar. */ 9522 /* If line is empty, make it occupy the rest of the tool-bar. */
@@ -9517,11 +9540,13 @@ display_tool_bar_line (it)
9517 9540
9518 9541
9519/* Value is the number of screen lines needed to make all tool-bar 9542/* Value is the number of screen lines needed to make all tool-bar
9520 items of frame F visible. */ 9543 items of frame F visible. The number of actual rows needed is
9544 returned in *N_ROWS if non-NULL. */
9521 9545
9522static int 9546static int
9523tool_bar_lines_needed (f) 9547tool_bar_lines_needed (f, n_rows)
9524 struct frame *f; 9548 struct frame *f;
9549 int *n_rows;
9525{ 9550{
9526 struct window *w = XWINDOW (f->tool_bar_window); 9551 struct window *w = XWINDOW (f->tool_bar_window);
9527 struct it it; 9552 struct it it;
@@ -9537,9 +9562,12 @@ tool_bar_lines_needed (f)
9537 { 9562 {
9538 it.glyph_row = w->desired_matrix->rows; 9563 it.glyph_row = w->desired_matrix->rows;
9539 clear_glyph_row (it.glyph_row); 9564 clear_glyph_row (it.glyph_row);
9540 display_tool_bar_line (&it); 9565 display_tool_bar_line (&it, 0);
9541 } 9566 }
9542 9567
9568 if (n_rows)
9569 *n_rows = it.vpos;
9570
9543 return (it.current_y + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f); 9571 return (it.current_y + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f);
9544} 9572}
9545 9573
@@ -9568,7 +9596,7 @@ DEFUN ("tool-bar-lines-needed", Ftool_bar_lines_needed, Stool_bar_lines_needed,
9568 if (f->n_tool_bar_items) 9596 if (f->n_tool_bar_items)
9569 { 9597 {
9570 build_desired_tool_bar_string (f); 9598 build_desired_tool_bar_string (f);
9571 nlines = tool_bar_lines_needed (f); 9599 nlines = tool_bar_lines_needed (f, NULL);
9572 } 9600 }
9573 } 9601 }
9574 9602
@@ -9613,9 +9641,50 @@ redisplay_tool_bar (f)
9613 build_desired_tool_bar_string (f); 9641 build_desired_tool_bar_string (f);
9614 reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1); 9642 reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1);
9615 9643
9644 if (f->n_tool_bar_rows == 0)
9645 {
9646 (void)tool_bar_lines_needed (f, &f->n_tool_bar_rows);
9647 if (f->n_tool_bar_rows == 0)
9648 f->n_tool_bar_rows = -1;
9649 }
9650
9616 /* Display as many lines as needed to display all tool-bar items. */ 9651 /* Display as many lines as needed to display all tool-bar items. */
9617 while (it.current_y < it.last_visible_y) 9652
9618 display_tool_bar_line (&it); 9653 if (f->n_tool_bar_rows > 0)
9654 {
9655 int border, rows, height, extra;
9656
9657 if (INTEGERP (Vtool_bar_border))
9658 border = XINT (Vtool_bar_border);
9659 else if (EQ (Vtool_bar_border, Qinternal_border_width))
9660 border = FRAME_INTERNAL_BORDER_WIDTH (f);
9661 else if (EQ (Vtool_bar_border, Qborder_width))
9662 border = f->border_width;
9663 else
9664 border = 0;
9665 if (border < 0)
9666 border = 0;
9667
9668 rows = f->n_tool_bar_rows;
9669 height = (it.last_visible_y - border) / rows;
9670 extra = it.last_visible_y - border - height * rows;
9671
9672 while (it.current_y < it.last_visible_y)
9673 {
9674 int h = 0;
9675 if (extra > 0 && rows-- > 0)
9676 {
9677 h = (extra + rows - 1) / rows;
9678 extra -= h;
9679 }
9680 display_tool_bar_line (&it, height + h);
9681 }
9682 }
9683 else
9684 {
9685 while (it.current_y < it.last_visible_y)
9686 display_tool_bar_line (&it, 0);
9687 }
9619 9688
9620 /* It doesn't make much sense to try scrolling in the tool-bar 9689 /* It doesn't make much sense to try scrolling in the tool-bar
9621 window, so don't do it. */ 9690 window, so don't do it. */
@@ -9648,7 +9717,7 @@ redisplay_tool_bar (f)
9648 /* Resize windows as needed by changing the `tool-bar-lines' 9717 /* Resize windows as needed by changing the `tool-bar-lines'
9649 frame parameter. */ 9718 frame parameter. */
9650 if (change_height_p 9719 if (change_height_p
9651 && (nlines = tool_bar_lines_needed (f), 9720 && (nlines = tool_bar_lines_needed (f, &f->n_tool_bar_rows),
9652 nlines != WINDOW_TOTAL_LINES (w))) 9721 nlines != WINDOW_TOTAL_LINES (w)))
9653 { 9722 {
9654 extern Lisp_Object Qtool_bar_lines; 9723 extern Lisp_Object Qtool_bar_lines;
@@ -23661,6 +23730,14 @@ otherwise. */);
23661 doc: /* *Non-nil means to scroll (recenter) cursor line if it is not fully visible. */); 23730 doc: /* *Non-nil means to scroll (recenter) cursor line if it is not fully visible. */);
23662 make_cursor_line_fully_visible_p = 1; 23731 make_cursor_line_fully_visible_p = 1;
23663 23732
23733 DEFVAR_LISP ("tool-bar-border", &Vtool_bar_border,
23734 doc: /* *Border below tool-bar in pixels.
23735If an integer, use it as the height of the border.
23736If it is one of `internal-border-width' or `border-width', use the
23737value of the corresponding frame parameter.
23738Otherwise, no border is added below the tool-bar. */);
23739 Vtool_bar_border = Qinternal_border_width;
23740
23664 DEFVAR_LISP ("tool-bar-button-margin", &Vtool_bar_button_margin, 23741 DEFVAR_LISP ("tool-bar-button-margin", &Vtool_bar_button_margin,
23665 doc: /* *Margin around tool-bar buttons in pixels. 23742 doc: /* *Margin around tool-bar buttons in pixels.
23666If an integer, use that for both horizontal and vertical margins. 23743If an integer, use that for both horizontal and vertical margins.
diff --git a/src/xselect.c b/src/xselect.c
index 8c82a4b85d3..6776e732734 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -55,6 +55,7 @@ static void x_decline_selection_request P_ ((struct input_event *));
55static Lisp_Object x_selection_request_lisp_error P_ ((Lisp_Object)); 55static Lisp_Object x_selection_request_lisp_error P_ ((Lisp_Object));
56static Lisp_Object queue_selection_requests_unwind P_ ((Lisp_Object)); 56static Lisp_Object queue_selection_requests_unwind P_ ((Lisp_Object));
57static Lisp_Object some_frame_on_display P_ ((struct x_display_info *)); 57static Lisp_Object some_frame_on_display P_ ((struct x_display_info *));
58static Lisp_Object x_catch_errors_unwind P_ ((Lisp_Object));
58static void x_reply_selection_request P_ ((struct input_event *, int, 59static void x_reply_selection_request P_ ((struct input_event *, int,
59 unsigned char *, int, Atom)); 60 unsigned char *, int, Atom));
60static int waiting_for_other_props_on_window P_ ((Display *, Window)); 61static int waiting_for_other_props_on_window P_ ((Display *, Window));
@@ -618,6 +619,15 @@ x_selection_request_lisp_error (ignore)
618 x_decline_selection_request (x_selection_current_request); 619 x_decline_selection_request (x_selection_current_request);
619 return Qnil; 620 return Qnil;
620} 621}
622
623static Lisp_Object
624x_catch_errors_unwind (dummy)
625 Lisp_Object dummy;
626{
627 BLOCK_INPUT;
628 x_uncatch_errors ();
629 UNBLOCK_INPUT;
630}
621 631
622 632
623/* This stuff is so that INCR selections are reentrant (that is, so we can 633/* This stuff is so that INCR selections are reentrant (that is, so we can
@@ -711,8 +721,11 @@ x_reply_selection_request (event, format, data, size, type)
711 if (reply.property == None) 721 if (reply.property == None)
712 reply.property = reply.target; 722 reply.property = reply.target;
713 723
714 /* #### XChangeProperty can generate BadAlloc, and we must handle it! */
715 BLOCK_INPUT; 724 BLOCK_INPUT;
725 /* The protected block contains wait_for_property_change, which can
726 run random lisp code (process handlers) or signal. Therefore, we
727 put the x_uncatch_errors call in an unwind. */
728 record_unwind_protect (x_catch_errors_unwind, Qnil);
716 x_catch_errors (display); 729 x_catch_errors (display);
717 730
718#ifdef TRACE_SELECTION 731#ifdef TRACE_SELECTION
@@ -866,9 +879,8 @@ x_reply_selection_request (event, format, data, size, type)
866 UNBLOCK to enter the event loop and get possible errors delivered, 879 UNBLOCK to enter the event loop and get possible errors delivered,
867 and then BLOCK again because x_uncatch_errors requires it. */ 880 and then BLOCK again because x_uncatch_errors requires it. */
868 BLOCK_INPUT; 881 BLOCK_INPUT;
869 882 /* This calls x_uncatch_errors. */
870 unbind_to (count, Qnil); 883 unbind_to (count, Qnil);
871 x_uncatch_errors ();
872 UNBLOCK_INPUT; 884 UNBLOCK_INPUT;
873} 885}
874 886
@@ -1378,7 +1390,7 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
1378 Atom selection_atom; 1390 Atom selection_atom;
1379 Atom type_atom; 1391 Atom type_atom;
1380 int secs, usecs; 1392 int secs, usecs;
1381 int count; 1393 int count = SPECPDL_INDEX ();
1382 Lisp_Object frame; 1394 Lisp_Object frame;
1383 1395
1384 if (! FRAME_X_P (sf)) 1396 if (! FRAME_X_P (sf))
@@ -1409,6 +1421,10 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
1409 1421
1410 BLOCK_INPUT; 1422 BLOCK_INPUT;
1411 1423
1424 /* The protected block contains wait_reading_process_output, which
1425 can run random lisp code (process handlers) or signal.
1426 Therefore, we put the x_uncatch_errors call in an unwind. */
1427 record_unwind_protect (x_catch_errors_unwind, Qnil);
1412 x_catch_errors (display); 1428 x_catch_errors (display);
1413 1429
1414 TRACE2 ("Get selection %s, type %s", 1430 TRACE2 ("Get selection %s, type %s",
@@ -1426,8 +1442,6 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
1426 1442
1427 frame = some_frame_on_display (dpyinfo); 1443 frame = some_frame_on_display (dpyinfo);
1428 1444
1429 count = SPECPDL_INDEX ();
1430
1431 /* If the display no longer has frames, we can't expect 1445 /* If the display no longer has frames, we can't expect
1432 to get many more selection requests from it, so don't 1446 to get many more selection requests from it, so don't
1433 bother trying to queue them. */ 1447 bother trying to queue them. */
@@ -1449,9 +1463,10 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
1449 TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply))); 1463 TRACE1 (" Got event = %d", !NILP (XCAR (reading_selection_reply)));
1450 1464
1451 BLOCK_INPUT; 1465 BLOCK_INPUT;
1466 if (x_had_errors_p (display))
1467 error ("Cannot get selection");
1468 /* This calls x_uncatch_errors. */
1452 unbind_to (count, Qnil); 1469 unbind_to (count, Qnil);
1453 x_check_errors (display, "Cannot get selection: %s");
1454 x_uncatch_errors ();
1455 UNBLOCK_INPUT; 1470 UNBLOCK_INPUT;
1456 1471
1457 if (NILP (XCAR (reading_selection_reply))) 1472 if (NILP (XCAR (reading_selection_reply)))
@@ -2687,6 +2702,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
2687 Lisp_Object ret = Qnil; 2702 Lisp_Object ret = Qnil;
2688 Display *dpy = FRAME_X_DISPLAY (f); 2703 Display *dpy = FRAME_X_DISPLAY (f);
2689 Atom atom; 2704 Atom atom;
2705 int had_errors;
2690 2706
2691 if (INTEGERP (value)) 2707 if (INTEGERP (value))
2692 atom = (Atom) XUINT (value); 2708 atom = (Atom) XUINT (value);
@@ -2699,14 +2715,13 @@ If the value is 0 or the atom is not known, return the empty string. */)
2699 2715
2700 BLOCK_INPUT; 2716 BLOCK_INPUT;
2701 x_catch_errors (dpy); 2717 x_catch_errors (dpy);
2702
2703 name = atom ? XGetAtomName (dpy, atom) : ""; 2718 name = atom ? XGetAtomName (dpy, atom) : "";
2719 had_errors = x_had_errors_p (dpy);
2720 x_uncatch_errors ();
2704 2721
2705 if (! x_had_errors_p (dpy)) 2722 if (!had_errors)
2706 ret = make_string (name, strlen (name)); 2723 ret = make_string (name, strlen (name));
2707 2724
2708 x_uncatch_errors ();
2709
2710 if (atom && name) XFree (name); 2725 if (atom && name) XFree (name);
2711 if (NILP (ret)) ret = make_string ("", 0); 2726 if (NILP (ret)) ret = make_string ("", 0);
2712 2727