From 3649d303b0e78aaeb4894389f5be6375837f88b8 Mon Sep 17 00:00:00 2001 From: Jan Djärv Date: Mon, 1 Nov 2010 12:30:33 +0100 Subject: Backport fix for Bug#6571 from trunk. NOTE: May cause merge conflicts. * src/keyboard.c (input_available_signal): Declare. (kbd_buffer_nr_stored): New function. (kbd_buffer_store_event_hold): If kbd_buffer_nr_stored returns more than KBD_BUFFER_SIZE/2, stop reding input (Bug#6571). (kbd_buffer_get_event): If input is suspended and kbd_buffer_nr_stored returns less than KBD_BUFFER_SIZE/4, resume reding input (Bug#6571). (tty_read_avail_input): If input is on hold, return. Don't read more that free slots in kbd_buffer (Bug#6571). * src/process.c (kbd_is_on_hold): New variable. (hold_keyboard_input, unhold_keyboard_input, kbd_on_hold_p): New functions. (wait_reading_process_output): If kbd_on_hold_p returns non-zero, select on empty input mask. (init_process): Initialize kbd_is_on_hold to 0. * src/process.h (hold_keyboard_input, unhold_keyboard_input) (kbd_on_hold_p): Declare. --- src/ChangeLog | 21 +++++++++++++++++++++ src/keyboard.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/process.c | 35 ++++++++++++++++++++++++++++++++++- src/process.h | 4 ++++ 4 files changed, 105 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 391dc3eaa07..33552c0ed57 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2010-11-01 Jan Djärv + + * process.c (kbd_is_on_hold): New variable. + (hold_keyboard_input, unhold_keyboard_input, kbd_on_hold_p): + New functions. + (wait_reading_process_output): If kbd_on_hold_p returns non-zero, + select on empty input mask. + (init_process): Initialize kbd_is_on_hold to 0. + + * process.h (hold_keyboard_input, unhold_keyboard_input) + (kbd_on_hold_p): Declare. + + * keyboard.c (input_available_signal): Declare. + (kbd_buffer_nr_stored): New function. + (kbd_buffer_store_event_hold): If kbd_buffer_nr_stored returns + more than KBD_BUFFER_SIZE/2, stop reding input (Bug#6571). + (kbd_buffer_get_event): If input is suspended and kbd_buffer_nr_stored + returns less than KBD_BUFFER_SIZE/4, resume reding input (Bug#6571). + (tty_read_avail_input): If input is on hold, return. + Don't read more that free slots in kbd_buffer (Bug#6571). + 2010-10-31 Chong Yidong * xterm.c (x_connection_closed): Print informative error message diff --git a/src/keyboard.c b/src/keyboard.c index 22c58985a56..311f42fbb3b 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -642,6 +642,9 @@ static Lisp_Object apply_modifiers P_ ((int, Lisp_Object)); static void clear_event P_ ((struct input_event *)); static Lisp_Object restore_kboard_configuration P_ ((Lisp_Object)); static SIGTYPE interrupt_signal P_ ((int signalnum)); +#ifdef SIGIO +static SIGTYPE input_available_signal (int signo); +#endif static void handle_interrupt P_ ((void)); static void timer_start_idle P_ ((void)); static void timer_stop_idle P_ ((void)); @@ -3780,6 +3783,18 @@ event_to_kboard (event) return FRAME_KBOARD (XFRAME (frame)); } +/* Return the number of slots occupied in kbd_buffer. */ + +static int +kbd_buffer_nr_stored (void) +{ + return kbd_fetch_ptr == kbd_store_ptr + ? 0 + : (kbd_fetch_ptr < kbd_store_ptr + ? kbd_store_ptr - kbd_fetch_ptr + : ((kbd_buffer + KBD_BUFFER_SIZE) - kbd_fetch_ptr + + (kbd_store_ptr - kbd_buffer))); +} Lisp_Object Vthrow_on_input; @@ -3903,6 +3918,17 @@ kbd_buffer_store_event_hold (event, hold_quit) { *kbd_store_ptr = *event; ++kbd_store_ptr; + if (kbd_buffer_nr_stored () > KBD_BUFFER_SIZE/2 && ! kbd_on_hold_p ()) + { + /* Don't read keyboard input until we have processed kbd_buffer. + This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ + hold_keyboard_input (); +#ifdef SIGIO + if (!noninteractive) + signal (SIGIO, SIG_IGN); +#endif + stop_polling (); + } } /* If we're inside while-no-input, and this event qualifies @@ -4071,6 +4097,18 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time) register int c; Lisp_Object obj; + if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4) + { + /* Start reading input again, we have processed enough so we can + accept new events again. */ + unhold_keyboard_input (); +#ifdef SIGIO + if (!noninteractive) + signal (SIGIO, input_available_signal); +#endif /* SIGIO */ + start_polling (); + } + if (noninteractive /* In case we are running as a daemon, only do this before detaching from the terminal. */ @@ -7270,6 +7308,10 @@ tty_read_avail_input (struct terminal *terminal, int n_to_read, i; struct tty_display_info *tty = terminal->display_info.tty; int nread = 0; + int buffer_free = KBD_BUFFER_SIZE - kbd_buffer_nr_stored () - 1; + + if (kbd_on_hold_p () || buffer_free <= 0) + return 0; if (!terminal->name) /* Don't read from a dead terminal. */ return 0; @@ -7351,6 +7393,10 @@ tty_read_avail_input (struct terminal *terminal, #endif #endif + /* Don't read more than we can store. */ + if (n_to_read > buffer_free) + n_to_read = buffer_free; + /* Now read; for one reason or another, this will not block. NREAD is set to the number of chars read. */ do diff --git a/src/process.c b/src/process.c index 3e2aa61ffe6..567300e2f64 100644 --- a/src/process.c +++ b/src/process.c @@ -346,6 +346,9 @@ static int max_keyboard_desc; /* The largest descriptor currently in use for gpm mouse input. */ static int max_gpm_desc; +/* Non-zero if keyboard input is on hold, zero otherwise. */ +static int kbd_is_on_hold; + /* Nonzero means delete a process right away if it exits. */ static int delete_exited_processes; @@ -4795,7 +4798,11 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, SELECT_TYPE Ctemp; #endif - Atemp = input_wait_mask; + if (kbd_on_hold_p ()) + FD_ZERO (&Atemp); + else + Atemp = input_wait_mask; + IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); EMACS_SET_SECS_USECS (timeout, 0, 0); @@ -7224,6 +7231,31 @@ keyboard_bit_set (mask) return 0; } + +/* Stop reading input from keyboard sources. */ + +void +hold_keyboard_input (void) +{ + kbd_is_on_hold = 1; +} + +/* Resume reading input from keyboard sources. */ + +void +unhold_keyboard_input (void) +{ + kbd_is_on_hold = 0; +} + +/* Return non-zero if keyboard input is on hold, zero otherwise. */ + +int +kbd_on_hold_p (void) +{ + return kbd_is_on_hold; +} + /* Enumeration of and access to system processes a-la ps(1). */ @@ -8039,6 +8071,7 @@ integer or floating point values. void init_process () { + kbd_is_on_hold = 0; } void diff --git a/src/process.h b/src/process.h index a8cd0a02da6..12b91d697b9 100644 --- a/src/process.h +++ b/src/process.h @@ -170,5 +170,9 @@ extern Lisp_Object Qtime, Qctime; extern Lisp_Object list_system_processes (void); extern Lisp_Object system_process_attributes (Lisp_Object); +extern void hold_keyboard_input (void); +extern void unhold_keyboard_input (void); +extern int kbd_on_hold_p (void); + /* arch-tag: dffedfc4-d7bc-4b58-a26f-c16155449c72 (do not change this comment) */ -- cgit v1.2.1 From 754996bcf8e980648b63afa3e8bbaedcefdc22bc Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 3 Nov 2010 14:55:19 -0400 Subject: Fix for Bug#5655, backported from trunk. * configure.in (CRT_DIR): New output variable. (--with-crt-dir): New option. (Bug#5655) (HAVE_LIB64_DIR): Remove. * src/Makefile.in (CRT_DIR): New variable, set by configure. * src/m/amdx86-64.h, m/ibms390x.h (START_FILES, LIB_STANDARD): Use $CRT_DIR rather than HAVE_LIB64_DIR. (Bug#5655) --- src/ChangeLog | 6 ++++++ src/Makefile.in | 3 +++ src/m/amdx86-64.h | 17 ++++++----------- src/m/ibms390x.h | 12 ++---------- 4 files changed, 17 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 33552c0ed57..a44fdbb7e42 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-11-03 Glenn Morris + + * Makefile.in (CRT_DIR): New variable, set by configure. + * m/amdx86-64.h, m/ibms390x.h (START_FILES, LIB_STANDARD): + Use $CRT_DIR rather than HAVE_LIB64_DIR. (Bug#5655) + 2010-11-01 Jan Djärv * process.c (kbd_is_on_hold): New variable. diff --git a/src/Makefile.in b/src/Makefile.in index 9caa01d9066..1b0fbdb8b63 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -67,6 +67,9 @@ bootstrap_exe = ../src/bootstrap-emacs${EXEEXT} OTHER_FILES = @OTHER_FILES@ +## Only used by amdx86-64 and ibms390x GNU/Linux. +CRT_DIR=@CRT_DIR@ + # ========================== start of cpp stuff ======================= /* From here on, comments must be done in C syntax. */ diff --git a/src/m/amdx86-64.h b/src/m/amdx86-64.h index 4bea30d12de..0401b8bf90f 100644 --- a/src/m/amdx86-64.h +++ b/src/m/amdx86-64.h @@ -80,7 +80,7 @@ along with GNU Emacs. If not, see . */ a native binary of Emacs on FreeBSD/amd64 we can just point to /usr/lib. */ #undef START_FILES -#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o +#define START_FILES pre-crt0.o $(CRT_DIR)/crt1.o $(CRT_DIR)/crti.o /* The duplicate -lgcc is intentional in the definition of LIB_STANDARD. The reason is that some functions in libgcc.a call functions from libc.a, @@ -88,14 +88,14 @@ along with GNU Emacs. If not, see . */ versions of ld are one-pass linkers, we need to mention -lgcc twice, or else we risk getting unresolved externals. */ #undef LIB_STANDARD -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o +#define LIB_STANDARD -lgcc -lc -lgcc $(CRT_DIR)/crtn.o #elif defined(__OpenBSD__) #undef START_FILES -#define START_FILES pre-crt0.o /usr/lib/crt0.o /usr/lib/crtbegin.o +#define START_FILES pre-crt0.o $(CRT_DIR)/crt0.o $(CRT_DIR)/crtbegin.o #undef LIB_STANDARD -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtend.o +#define LIB_STANDARD -lgcc -lc -lgcc $(CRT_DIR)/crtend.o #elif defined(__NetBSD__) @@ -119,13 +119,8 @@ along with GNU Emacs. If not, see . */ or else we risk getting unresolved externals. */ #undef START_FILES #undef LIB_STANDARD -#ifdef HAVE_LIB64_DIR -#define START_FILES pre-crt0.o /usr/lib64/crt1.o /usr/lib64/crti.o -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib64/crtn.o -#else -#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o -#endif +#define START_FILES pre-crt0.o $(CRT_DIR)/crt1.o $(CRT_DIR)/crti.o +#define LIB_STANDARD -lgcc -lc -lgcc $(CRT_DIR)/crtn.o #endif /* __FreeBSD__ */ #endif /* !i386 */ diff --git a/src/m/ibms390x.h b/src/m/ibms390x.h index 9429e4282bf..ea0fa11ec3f 100644 --- a/src/m/ibms390x.h +++ b/src/m/ibms390x.h @@ -91,18 +91,10 @@ NOTE-END */ #define XPNTR(a) XUINT (a) #undef START_FILES -#ifdef HAVE_LIB64_DIR -#define START_FILES pre-crt0.o /usr/lib64/crt1.o /usr/lib64/crti.o -#else -#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o -#endif +#define START_FILES pre-crt0.o $(CRT_DIR)/crt1.o $(CRT_DIR)/crti.o #undef LIB_STANDARD -#ifdef HAVE_LIB64_DIR -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib64/crtn.o -#else -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o -#endif +#define LIB_STANDARD -lgcc -lc -lgcc $(CRT_DIR)/crtn.o /* arch-tag: 4b87653c-6add-4663-8691-7d9dc17b5519 (do not change this comment) */ -- cgit v1.2.1 From d75c99921883af96fe9152cf9d1766e5ec0e5126 Mon Sep 17 00:00:00 2001 From: Jan Djärv Date: Thu, 4 Nov 2010 09:41:25 +0100 Subject: Get window position by reading _NET_FRAME_EXTENTS (Bug#5721). * src/xfns.c (x_real_positions): Try to get _NET_FRAME_EXTENTS first before traversing window tree (Bug#5721). * src/xterm.c (x_term_init): Initialize Xatom_net_frame_extents. * src/xterm.h (struct x_display_info): Xatom_net_frame_extents is new. --- src/ChangeLog | 9 +++++++++ src/xfns.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- src/xterm.c | 3 ++- src/xterm.h | 4 ++-- 4 files changed, 63 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index a44fdbb7e42..a1a049c66c1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2010-11-04 Jan Djärv + + * xterm.c (x_term_init): Initialize Xatom_net_frame_extents. + + * xterm.h (struct x_display_info): Xatom_net_frame_extents is new. + + * xfns.c (x_real_positions): Try to get _NET_FRAME_EXTENTS first + before traversing window tree (Bug#5721). + 2010-11-03 Glenn Morris * Makefile.in (CRT_DIR): New variable, set by configure. diff --git a/src/xfns.c b/src/xfns.c index 1d7d3d03580..0b0f1cd0d96 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -532,12 +532,60 @@ x_real_positions (f, xptr, yptr) int win_x, win_y, outer_x, outer_y; int real_x = 0, real_y = 0; int had_errors = 0; - Window win = f->output_data.x->parent_desc; + Window win; + Atom actual_type; + unsigned long actual_size, bytes_remaining; + int i, rc, actual_format; + struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); + long max_len = 400; + Display *dpy = FRAME_X_DISPLAY (f); + unsigned char *tmp_data = NULL; + Atom target_type = XA_CARDINAL; BLOCK_INPUT; - x_catch_errors (FRAME_X_DISPLAY (f)); + x_catch_errors (dpy); + + win = FRAME_OUTER_WINDOW (f); + /* Try _NET_FRAME_EXTENTS first. */ + rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_frame_extents, + 0, max_len, False, target_type, + &actual_type, &actual_format, &actual_size, + &bytes_remaining, &tmp_data); + + if (0 && rc == Success && actual_type == target_type && !x_had_errors_p (dpy) + && actual_size == 4 && actual_format == 32) + { + int ign; + Window rootw; + + XGetGeometry (FRAME_X_DISPLAY (f), win, + &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); + long *fe = (long *)tmp_data; + + FRAME_X_OUTPUT (f)->x_pixels_outer_diff = fe[0]; + FRAME_X_OUTPUT (f)->y_pixels_outer_diff = fe[2]; + *xptr = real_x - fe[0]; + *yptr = real_y - fe[2]; + + if (FRAME_X_WINDOW (f) != win) + { + XGetGeometry (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), + &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); + + f->x_pixels_diff = real_x; + f->y_pixels_diff = real_y; + } + + if (tmp_data) XFree (tmp_data); + x_uncatch_errors (); + UNBLOCK_INPUT; + return; + } + + if (tmp_data) XFree (tmp_data); + win = f->output_data.x->parent_desc; if (win == FRAME_X_DISPLAY_INFO (f)->root_window) win = FRAME_OUTER_WINDOW (f); diff --git a/src/xterm.c b/src/xterm.c index 808eaad3f5f..22019e2279b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10522,7 +10522,8 @@ x_term_init (display_name, xrm_option, resource_name) = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE", False); dpyinfo->Xatom_net_window_type_tooltip = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE_TOOLTIP", False); - + dpyinfo->Xatom_net_frame_extents + = XInternAtom (dpyinfo->display, "_NET_FRAME_EXTENTS", False); dpyinfo->cut_buffers_initialized = 0; dpyinfo->x_dnd_atoms_size = 8; diff --git a/src/xterm.h b/src/xterm.h index c8601b8c43d..07eaec3060c 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -362,10 +362,10 @@ struct x_display_info Window net_supported_window; Atom Xatom_net_window_type, Xatom_net_window_type_tooltip; - /* Atoms dealing with maximization and fullscreen */ + /* Atoms dealing with EWMH (i.e. _NET_...) */ Atom Xatom_net_wm_state, Xatom_net_wm_state_fullscreen_atom, Xatom_net_wm_state_maximized_horz, Xatom_net_wm_state_maximized_vert, - Xatom_net_wm_state_sticky; + Xatom_net_wm_state_sticky, Xatom_net_frame_extents; /* XSettings atoms and windows. */ Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr; -- cgit v1.2.1 From 69ee5b0fd692a0280fe6955efe064bcadc3759a3 Mon Sep 17 00:00:00 2001 From: Jan Djärv Date: Thu, 4 Nov 2010 13:17:46 +0100 Subject: Remove debug code. --- src/xfns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xfns.c b/src/xfns.c index 0b0f1cd0d96..c07ea49e663 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -553,7 +553,7 @@ x_real_positions (f, xptr, yptr) &actual_type, &actual_format, &actual_size, &bytes_remaining, &tmp_data); - if (0 && rc == Success && actual_type == target_type && !x_had_errors_p (dpy) + if (rc == Success && actual_type == target_type && !x_had_errors_p (dpy) && actual_size == 4 && actual_format == 32) { int ign; -- cgit v1.2.1 From 31887d45e8c5cf28b1e85f76a0aba40186f7f1a5 Mon Sep 17 00:00:00 2001 From: Jan Djärv Date: Thu, 4 Nov 2010 13:37:17 +0100 Subject: * xfns.c (x_real_positions): Only use _NET_FRAME_EXTENTS if our parent is the root window. Check this after traversing window tree. --- src/ChangeLog | 3 +++ src/xfns.c | 72 +++++++++++++++++++++++++---------------------------------- 2 files changed, 33 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index a1a049c66c1..a16e35df108 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2010-11-04 Jan Djärv + * xfns.c (x_real_positions): Only use _NET_FRAME_EXTENTS if our + parent is the root window. Check this after traversing window tree. + * xterm.c (x_term_init): Initialize Xatom_net_frame_extents. * xterm.h (struct x_display_info): Xatom_net_frame_extents is new. diff --git a/src/xfns.c b/src/xfns.c index c07ea49e663..635264ea862 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -532,7 +532,7 @@ x_real_positions (f, xptr, yptr) int win_x, win_y, outer_x, outer_y; int real_x = 0, real_y = 0; int had_errors = 0; - Window win; + Window win = f->output_data.x->parent_desc; Atom actual_type; unsigned long actual_size, bytes_remaining; int i, rc, actual_format; @@ -546,47 +546,7 @@ x_real_positions (f, xptr, yptr) x_catch_errors (dpy); - win = FRAME_OUTER_WINDOW (f); - /* Try _NET_FRAME_EXTENTS first. */ - rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_frame_extents, - 0, max_len, False, target_type, - &actual_type, &actual_format, &actual_size, - &bytes_remaining, &tmp_data); - - if (rc == Success && actual_type == target_type && !x_had_errors_p (dpy) - && actual_size == 4 && actual_format == 32) - { - int ign; - Window rootw; - - XGetGeometry (FRAME_X_DISPLAY (f), win, - &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); - long *fe = (long *)tmp_data; - - FRAME_X_OUTPUT (f)->x_pixels_outer_diff = fe[0]; - FRAME_X_OUTPUT (f)->y_pixels_outer_diff = fe[2]; - *xptr = real_x - fe[0]; - *yptr = real_y - fe[2]; - - if (FRAME_X_WINDOW (f) != win) - { - XGetGeometry (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); - - f->x_pixels_diff = real_x; - f->y_pixels_diff = real_y; - } - - if (tmp_data) XFree (tmp_data); - x_uncatch_errors (); - UNBLOCK_INPUT; - return; - } - - if (tmp_data) XFree (tmp_data); - - win = f->output_data.x->parent_desc; - if (win == FRAME_X_DISPLAY_INFO (f)->root_window) + if (win == dpyinfo->root_window) win = FRAME_OUTER_WINDOW (f); /* This loop traverses up the containment tree until we hit the root @@ -671,6 +631,34 @@ x_real_positions (f, xptr, yptr) had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); } + + if (dpyinfo->root_window == f->output_data.x->parent_desc) + { + /* Try _NET_FRAME_EXTENTS if our parent is the root window. */ + rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_frame_extents, + 0, max_len, False, target_type, + &actual_type, &actual_format, &actual_size, + &bytes_remaining, &tmp_data); + + if (rc == Success && actual_type == target_type && !x_had_errors_p (dpy) + && actual_size == 4 && actual_format == 32) + { + int ign; + Window rootw; + + XGetGeometry (FRAME_X_DISPLAY (f), win, + &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); + long *fe = (long *)tmp_data; + + outer_x = -fe[0]; + outer_y = -fe[2]; + real_x -= fe[0]; + real_y -= fe[2]; + } + } + + if (tmp_data) XFree (tmp_data); + x_uncatch_errors (); UNBLOCK_INPUT; -- cgit v1.2.1 From c698128618583af08186c80dfc949dedf73f3b07 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Thu, 4 Nov 2010 15:34:11 -0400 Subject: Backport from trunk. --- src/ChangeLog | 5 +++++ src/xfns.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index a16e35df108..b4c9cbcc159 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-04-09 Jan Djärv + + * xfns.c (Fx_show_tip): Call try_window in a loop until + fonts_changed_p is zero (Bug#2423). + 2010-11-04 Jan Djärv * xfns.c (x_real_positions): Only use _NET_FRAME_EXTENTS if our diff --git a/src/xfns.c b/src/xfns.c index 635264ea862..5979c81e7b7 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5221,10 +5221,14 @@ Text larger than the specified size is clipped. */) old_buffer = current_buffer; set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); current_buffer->truncate_lines = Qnil; - clear_glyph_matrix (w->desired_matrix); - clear_glyph_matrix (w->current_matrix); - SET_TEXT_POS (pos, BEGV, BEGV_BYTE); - try_window (FRAME_ROOT_WINDOW (f), pos, 0); + + do { + fonts_changed_p = 0; + clear_glyph_matrix (w->desired_matrix); + clear_glyph_matrix (w->current_matrix); + SET_TEXT_POS (pos, BEGV, BEGV_BYTE); + try_window (FRAME_ROOT_WINDOW (f), pos, 0); + } while (fonts_changed_p); /* Compute width and height of the tooltip. */ width = height = 0; -- cgit v1.2.1 From fa884f18e117267c0b2d740112fcd46410334913 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Thu, 4 Nov 2010 15:34:50 -0400 Subject: Backport 2010-04-10T10:39:16Z!mituharu@math.s.chiba-u.ac.jp from trunk --- src/ChangeLog | 4 ++++ src/xfns.c | 12 ++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index b4c9cbcc159..4a8a46e4cf3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-04-10 YAMAMOTO Mitsuharu + + * xfns.c (Fx_show_tip): Undo last change. + 2010-04-09 Jan Djärv * xfns.c (Fx_show_tip): Call try_window in a loop until diff --git a/src/xfns.c b/src/xfns.c index 5979c81e7b7..635264ea862 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5221,14 +5221,10 @@ Text larger than the specified size is clipped. */) old_buffer = current_buffer; set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); current_buffer->truncate_lines = Qnil; - - do { - fonts_changed_p = 0; - clear_glyph_matrix (w->desired_matrix); - clear_glyph_matrix (w->current_matrix); - SET_TEXT_POS (pos, BEGV, BEGV_BYTE); - try_window (FRAME_ROOT_WINDOW (f), pos, 0); - } while (fonts_changed_p); + clear_glyph_matrix (w->desired_matrix); + clear_glyph_matrix (w->current_matrix); + SET_TEXT_POS (pos, BEGV, BEGV_BYTE); + try_window (FRAME_ROOT_WINDOW (f), pos, 0); /* Compute width and height of the tooltip. */ width = height = 0; -- cgit v1.2.1 From 2511e8e04fb3adf5e90685f9973665e2710255ed Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Thu, 4 Nov 2010 15:35:32 -0400 Subject: Backport 2010-04-10T10:52:30Z!mituharu@math.s.chiba-u.ac.jp from trunk --- src/ChangeLog | 11 ++++++++++- src/dispextern.h | 4 ++++ src/xdisp.c | 14 ++++++++------ src/xfns.c | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 4a8a46e4cf3..2df31f6e57f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,15 @@ 2010-04-10 YAMAMOTO Mitsuharu - * xfns.c (Fx_show_tip): Undo last change. + * dispextern.h (TRY_WINDOW_CHECK_MARGINS) + (TRY_WINDOW_IGNORE_FONTS_CHANGE): New defines. + + * xdisp.c (try_window): Change arg from CHECK_MARGINS to FLAGS. + Don't abort with fonts change if TRY_WINDOW_IGNORE_FONTS_CHANGE is + set in FLAGS. Callers with non-zero CHECK_MARGINS changed to use + TRY_WINDOW_CHECK_MARGINS. + + * xfns.c (Fx_show_tip): Undo last change. Call try_window with + TRY_WINDOW_IGNORE_FONTS_CHANGE (Bug#2423). 2010-04-09 Jan Djärv diff --git a/src/dispextern.h b/src/dispextern.h index ca91c5b6812..bc34aec2dd5 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2841,6 +2841,10 @@ extern int x_intersect_rectangles P_ ((XRectangle *, XRectangle *, XRectangle *)); #endif +/* Flags passed to try_window. */ +#define TRY_WINDOW_CHECK_MARGINS (1 << 0) +#define TRY_WINDOW_IGNORE_FONTS_CHANGE (1 << 1) + /* Defined in fringe.c */ int lookup_fringe_bitmap (Lisp_Object); diff --git a/src/xdisp.c b/src/xdisp.c index 59e38e440e4..a416c8ff435 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13577,7 +13577,7 @@ redisplay_window (window, just_this_one_p) = try_window_reusing_current_matrix (w))) { IF_DEBUG (debug_method_add (w, "1")); - if (try_window (window, startp, 1) < 0) + if (try_window (window, startp, TRY_WINDOW_CHECK_MARGINS) < 0) /* -1 means we need to scroll. 0 means we need new matrices, but fonts_changed_p is set in that case, so we will detect it below. */ @@ -13936,13 +13936,15 @@ redisplay_window (window, just_this_one_p) Value is 1 if successful. It is zero if fonts were loaded during redisplay which makes re-adjusting glyph matrices necessary, and -1 if point would appear in the scroll margins. - (We check that only if CHECK_MARGINS is nonzero. */ + (We check the former only if TRY_WINDOW_IGNORE_FONTS_CHANGE is + unset in FLAGS, and the latter only if TRY_WINDOW_CHECK_MARGINS is + set in FLAGS.) */ int -try_window (window, pos, check_margins) +try_window (window, pos, flags) Lisp_Object window; struct text_pos pos; - int check_margins; + int flags; { struct window *w = XWINDOW (window); struct it it; @@ -13964,12 +13966,12 @@ try_window (window, pos, check_margins) { if (display_line (&it)) last_text_row = it.glyph_row - 1; - if (fonts_changed_p) + if (fonts_changed_p && !(flags & TRY_WINDOW_IGNORE_FONTS_CHANGE)) return 0; } /* Don't let the cursor end in the scroll margins. */ - if (check_margins + if ((flags & TRY_WINDOW_CHECK_MARGINS) && !MINI_WINDOW_P (w)) { int this_scroll_margin; diff --git a/src/xfns.c b/src/xfns.c index 635264ea862..b65323f199f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5224,7 +5224,7 @@ Text larger than the specified size is clipped. */) clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->current_matrix); SET_TEXT_POS (pos, BEGV, BEGV_BYTE); - try_window (FRAME_ROOT_WINDOW (f), pos, 0); + try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE); /* Compute width and height of the tooltip. */ width = height = 0; -- cgit v1.2.1 From 68ae6cda9e2a55c23d9680953bf9a402616e6901 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Thu, 4 Nov 2010 15:46:30 -0400 Subject: Backport 2010-05-27T04:24:30Z!handa@etlken from trunk --- src/ChangeLog | 7 +++++++ src/font.c | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 1e084a4bc3a..077385d6f6c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-11-04 Kenichi Handa + + * font.c (font_delete_unmatched): Check Vface_ignored_fonts. + Don't sheck SPEC if it is nil. + (font_list_entities): Call font_delete_unmatched if + Vface_ignored_fonts is non-nil. + 2010-11-04 YAMAMOTO Mitsuharu * dispextern.h (TRY_WINDOW_CHECK_MARGINS) diff --git a/src/font.c b/src/font.c index 77f43c81d71..f65b04255e2 100644 --- a/src/font.c +++ b/src/font.c @@ -2821,6 +2821,14 @@ font_clear_cache (f, cache, driver) static Lisp_Object scratch_font_spec, scratch_font_prefer; +/* Check each font-entity in VEC, and return a list of font-entities + that satisfy this condition: + (1) matches with SPEC and SIZE if SPEC is not nil, and + (2) doesn't match with any regexps in Vface_ignored_fonts (if non-nil). +*/ + +extern Lisp_Object Vface_ignored_fonts; + Lisp_Object font_delete_unmatched (vec, spec, size) Lisp_Object vec, spec; @@ -2833,6 +2841,29 @@ font_delete_unmatched (vec, spec, size) for (val = Qnil, i = ASIZE (vec) - 1; i >= 0; i--) { entity = AREF (vec, i); + if (! NILP (Vface_ignored_fonts)) + { + char name[256]; + Lisp_Object tail, regexp; + + if (font_unparse_xlfd (entity, 0, name, 256) >= 0) + { + for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) + { + regexp = XCAR (tail); + if (STRINGP (regexp) + && fast_c_string_match_ignore_case (regexp, name) >= 0) + break; + } + if (CONSP (tail)) + continue; + } + } + if (NILP (spec)) + { + val = Fcons (entity, val); + continue; + } for (prop = FONT_WEIGHT_INDEX; prop < FONT_SIZE_INDEX; prop++) if (INTEGERP (AREF (spec, prop)) && ((XINT (AREF (spec, prop)) >> 8) @@ -2932,8 +2963,10 @@ font_list_entities (frame, spec) ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache))); } - if (ASIZE (val) > 0 && need_filtering) - val = font_delete_unmatched (val, spec, size); + if (ASIZE (val) > 0 + && (need_filtering + || ! NILP (Vface_ignored_fonts))) + val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size); if (ASIZE (val) > 0) list = Fcons (val, list); } -- cgit v1.2.1 From c2e124a95b5f1dcb7d8e7f2ea1549d30fd54bc17 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Thu, 4 Nov 2010 15:53:28 -0400 Subject: Backport 2010-03-25T08:48:52Z!mituharu@math.s.chiba-u.ac.jp from trunk --- src/ChangeLog | 5 +++++ src/process.c | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 077385d6f6c..f3bbfe05dac 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-03-25 Helmut Eller + + * process.c (Fmake_network_process): Call `select' for interrupted + `connect' rather than creating new socket (Bug#5173). + 2010-11-04 Kenichi Handa * font.c (font_delete_unmatched): Check Vface_ignored_fonts. diff --git a/src/process.c b/src/process.c index 567300e2f64..77490adaa79 100644 --- a/src/process.c +++ b/src/process.c @@ -3573,8 +3573,6 @@ usage: (make-network-process &rest ARGS) */) { int optn, optbits; - retry_connect: - s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); if (s < 0) { @@ -3691,6 +3689,38 @@ usage: (make-network-process &rest ARGS) */) #endif #endif #endif + if (xerrno == EINTR) + { + /* Unlike most other syscalls connect() cannot be called + again. (That would return EALREADY.) The proper way to + wait for completion is select(). */ + int sc; + SELECT_TYPE fdset; + retry_select: + FD_ZERO (&fdset); + FD_SET (s, &fdset); + QUIT; + sc = select (s + 1, (SELECT_TYPE *)0, &fdset, (SELECT_TYPE *)0, + (EMACS_TIME *)0); + if (sc == -1) + { + if (errno == EINTR) + goto retry_select; + else + report_file_error ("select failed", Qnil); + } + eassert (sc > 0); + { + int len = sizeof xerrno; + eassert (FD_ISSET (s, &fdset)); + if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) + report_file_error ("getsockopt failed", Qnil); + if (xerrno != 0) + errno = xerrno, report_file_error ("error during connect", Qnil); + else + break; + } + } immediate_quit = 0; @@ -3698,9 +3728,6 @@ usage: (make-network-process &rest ARGS) */) specpdl_ptr = specpdl + count1; emacs_close (s); s = -1; - - if (xerrno == EINTR) - goto retry_connect; } if (s >= 0) -- cgit v1.2.1 From bd80a88673b755ccf9d850b907e65fec5308e6b4 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Thu, 4 Nov 2010 15:54:14 -0400 Subject: Backport 2010-03-25T08:56:15Z!mituharu@math.s.chiba-u.ac.jp from trunk --- src/ChangeLog | 5 +++++ src/process.c | 14 -------------- 2 files changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index f3bbfe05dac..1420114ea5b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-03-25 YAMAMOTO Mitsuharu + + * process.c (Fmake_network_process): Don't call turn_on_atimers around + `connect' (Bug#5723). + 2010-03-25 Helmut Eller * process.c (Fmake_network_process): Call `select' for interrupted diff --git a/src/process.c b/src/process.c index 77490adaa79..e3622c79386 100644 --- a/src/process.c +++ b/src/process.c @@ -3654,23 +3654,9 @@ usage: (make-network-process &rest ARGS) */) immediate_quit = 1; QUIT; - /* This turns off all alarm-based interrupts; the - bind_polling_period call above doesn't always turn all the - short-interval ones off, especially if interrupt_input is - set. - - It'd be nice to be able to control the connect timeout - though. Would non-blocking connect calls be portable? - - This used to be conditioned by HAVE_GETADDRINFO. Why? */ - - turn_on_atimers (0); - ret = connect (s, lres->ai_addr, lres->ai_addrlen); xerrno = errno; - turn_on_atimers (1); - if (ret == 0 || xerrno == EISCONN) { /* The unwind-protect will be discarded afterwards. -- cgit v1.2.1 From 184765cc7a4f8c0ff5e7522ee4e1584b441b742f Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Thu, 4 Nov 2010 15:54:28 -0400 Subject: Backport 2010-03-27T00:45:32Z!cyd@stupidchicken.com from trunk --- src/ChangeLog | 5 +++++ src/process.c | 35 ++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 1420114ea5b..16703ef5201 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-03-27 Chong Yidong + + * process.c (Fmake_network_process): Don't apply Bug#5173 fix for + Windows. + 2010-03-25 YAMAMOTO Mitsuharu * process.c (Fmake_network_process): Don't call turn_on_atimers around diff --git a/src/process.c b/src/process.c index e3622c79386..df30adcf0be 100644 --- a/src/process.c +++ b/src/process.c @@ -3573,6 +3573,8 @@ usage: (make-network-process &rest ARGS) */) { int optn, optbits; + retry_connect: + s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); if (s < 0) { @@ -3675,12 +3677,14 @@ usage: (make-network-process &rest ARGS) */) #endif #endif #endif + +#ifndef WINDOWSNT if (xerrno == EINTR) { /* Unlike most other syscalls connect() cannot be called again. (That would return EALREADY.) The proper way to wait for completion is select(). */ - int sc; + int sc, len; SELECT_TYPE fdset; retry_select: FD_ZERO (&fdset); @@ -3690,23 +3694,23 @@ usage: (make-network-process &rest ARGS) */) (EMACS_TIME *)0); if (sc == -1) { - if (errno == EINTR) + if (errno == EINTR) goto retry_select; - else + else report_file_error ("select failed", Qnil); } eassert (sc > 0); - { - int len = sizeof xerrno; - eassert (FD_ISSET (s, &fdset)); - if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) - report_file_error ("getsockopt failed", Qnil); - if (xerrno != 0) - errno = xerrno, report_file_error ("error during connect", Qnil); - else - break; - } + + len = sizeof xerrno; + eassert (FD_ISSET (s, &fdset)); + if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) + report_file_error ("getsockopt failed", Qnil); + if (xerrno) + errno = xerrno, report_file_error ("error during connect", Qnil); + else + break; } +#endif /* !WINDOWSNT */ immediate_quit = 0; @@ -3714,6 +3718,11 @@ usage: (make-network-process &rest ARGS) */) specpdl_ptr = specpdl + count1; emacs_close (s); s = -1; + +#ifdef WINDOWSNT + if (xerrno == EINTR) + goto retry_connect; +#endif } if (s >= 0) -- cgit v1.2.1 From be3faa809a959dcd7e985a0d536ac815d5138976 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Fri, 5 Nov 2010 14:28:19 -0400 Subject: Fix the fix for Bug#6426 (Bug#7210), avoiding frame garbaging loop. * image.c (free_image): Don't garbage the frame here, since this function can be called while redisplaying (Bug#7210). (uncache_image): Garbage the frame here (Bug#6426). --- src/ChangeLog | 6 ++++++ src/image.c | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index b803582e5f6..cba2b4b478d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-11-05 Chong Yidong + + * image.c (free_image): Don't garbage the frame here, since this + function can be called while redisplaying (Bug#7210). + (uncache_image): Garbage the frame here (Bug#6426). + 2010-11-04 Chong Yidong * process.c (Fmake_network_process): Don't apply Bug#5173 fix for diff --git a/src/image.c b/src/image.c index e7db3a7df1b..0fa0a0cd064 100644 --- a/src/image.c +++ b/src/image.c @@ -1094,10 +1094,6 @@ free_image (f, img) /* Free resources, then free IMG. */ img->type->free (f, img); xfree (img); - - /* As display glyphs may still be referring to the image ID, we - must garbage the frame (Bug#6426). */ - SET_FRAME_GARBAGED (f); } } @@ -1544,7 +1540,12 @@ uncache_image (f, spec) { struct image *img = search_image_cache (f, spec, sxhash (spec, 0)); if (img) - free_image (f, img); + { + free_image (f, img); + /* As display glyphs may still be referring to the image ID, we + must garbage the frame (Bug#6426). */ + SET_FRAME_GARBAGED (f); + } } -- cgit v1.2.1 From c00980655bc15ca019fd6c559c69601be18f2407 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 9 Nov 2010 15:55:52 +0200 Subject: xfns.c (x_real_positions): Fix declaration-after-statement problem. --- src/ChangeLog | 5 +++++ src/xfns.c | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index cba2b4b478d..c52c84961fa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-11-09 Eli Zaretskii + + * xfns.c (x_real_positions): Fix declaration-after-statement + problem. + 2010-11-05 Chong Yidong * image.c (free_image): Don't garbage the frame here, since this diff --git a/src/xfns.c b/src/xfns.c index b65323f199f..2e2bda49246 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -645,11 +645,10 @@ x_real_positions (f, xptr, yptr) { int ign; Window rootw; + long *fe = (long *)tmp_data; XGetGeometry (FRAME_X_DISPLAY (f), win, &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); - long *fe = (long *)tmp_data; - outer_x = -fe[0]; outer_y = -fe[2]; real_x -= fe[0]; -- cgit v1.2.1