Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 102415. ------------------------------------------------------------ revno: 102415 committer: Katsumi Yamaoka branch nick: trunk timestamp: Wed 2010-11-17 07:22:19 +0000 message: gnus-art.el (gnus-inhibit-images): New user option. * gnus-art.el (gnus-inhibit-images): New user option. (gnus-mime-display-single): Don't display image if it is non-nil. * mm-decode.el (mm-shr): Bind shr-inhibit-images to the value of gnus-inhibit-images. * shr.el (shr-image-displayer): New function. (shr-tag-img): Use it. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2010-11-16 23:05:02 +0000 +++ lisp/gnus/ChangeLog 2010-11-17 07:22:19 +0000 @@ -1,3 +1,14 @@ +2010-11-17 Katsumi Yamaoka + + * gnus-art.el (gnus-inhibit-images): New user option. + (gnus-mime-display-single): Don't display image if it is non-nil. + + * mm-decode.el (mm-shr): Bind shr-inhibit-images to the value of + gnus-inhibit-images. + + * shr.el (shr-image-displayer): New function. + (shr-tag-img): Use it. + 2010-11-16 Daniel Dehennin * mml2015.el (mml2015-epg-sign): Use From header. === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2010-11-15 23:45:55 +0000 +++ lisp/gnus/gnus-art.el 2010-11-17 07:22:19 +0000 @@ -1636,6 +1636,12 @@ :group 'gnus-article :type 'boolean) +(defcustom gnus-inhibit-images nil + "Non-nil means inhibit displaying of images inline in the article body." + :version "24.1" + :group 'gnus-article + :type 'boolean) + (defcustom gnus-blocked-images 'gnus-block-private-groups "Images that have URLs matching this regexp will be blocked. This can also be a function to be evaluated. If so, it will be @@ -5845,7 +5851,9 @@ (while ignored (when (string-match (pop ignored) type) (throw 'ignored nil))) - (if (and (setq not-attachment + (if (and (not (and gnus-inhibit-images + (string-match "\\`image/" type))) + (setq not-attachment (and (not (mm-inline-override-p handle)) (or (not (mm-handle-disposition handle)) (equal (car (mm-handle-disposition handle)) === modified file 'lisp/gnus/mm-decode.el' --- lisp/gnus/mm-decode.el 2010-11-11 23:51:05 +0000 +++ lisp/gnus/mm-decode.el 2010-11-17 07:22:19 +0000 @@ -1687,6 +1687,7 @@ (start end &optional base-url)) (declare-function shr-insert-document "shr" (dom)) (defvar shr-blocked-images) +(defvar gnus-inhibit-images) (autoload 'gnus-blocked-images "gnus-art") (defun mm-shr (handle) @@ -1703,6 +1704,7 @@ (when handle (mm-with-part handle (buffer-string)))))) + (shr-inhibit-images gnus-inhibit-images) charset) (unless handle (setq handle (mm-dissect-buffer t))) === modified file 'lisp/gnus/shr.el' --- lisp/gnus/shr.el 2010-11-15 23:45:55 +0000 +++ lisp/gnus/shr.el 2010-11-17 07:22:19 +0000 @@ -435,6 +435,26 @@ (search-forward "\r\n\r\n" nil t)) (buffer-substring (point) (point-max)))))) +(defun shr-image-displayer (content-function) + "Return a function to display an image. +CONTENT-FUNCTION is a function to retrieve an image for a cid url that +is an argument. The function to be returned takes three arguments URL, +START, and END." + `(lambda (url start end) + (if (string-match "\\`cid:" url) + ,(when content-function + `(let ((image (funcall ,content-function + (substring url (match-end 0))))) + (when image + (goto-char start) + (shr-put-image image + (prog1 + (buffer-substring-no-properties start end) + (delete-region start end)))))) + (url-retrieve url 'shr-image-fetched + (list (current-buffer) start end) + t)))) + (defun shr-heading (cont &rest types) (shr-ensure-paragraph) (apply #'shr-fontize-cont cont types) @@ -574,10 +594,7 @@ (put-text-property start (point) 'shr-alt alt) (put-text-property start (point) 'image-url url) (put-text-property start (point) 'image-displayer - (lambda (url start end) - (url-retrieve url 'shr-image-fetched - (list (current-buffer) start end) - t))) + (shr-image-displayer shr-content-function)) (put-text-property start (point) 'help-echo alt) (setq shr-state 'image))))) ------------------------------------------------------------ revno: 102414 [merge] committer: Kenichi Handa branch nick: trunk timestamp: Wed 2010-11-17 14:51:36 +0900 message: coding.c (Fset_terminal_coding_system_internal): Fix previous change (set charset-ID list instead of charset-symbol list). diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2010-11-17 02:37:45 +0000 +++ src/ChangeLog 2010-11-17 05:51:09 +0000 @@ -1,3 +1,8 @@ +2010-11-17 Kenichi Handa + + * coding.c (Fset_terminal_coding_system_internal): Fix previous + change (set charset-ID list instead of charset-symbol list). + 2010-11-16 Chong Yidong * keyboard.c (make_lispy_position): For text area clicks, record Y === modified file 'src/coding.c' --- src/coding.c 2010-11-04 22:37:06 +0000 +++ src/coding.c 2010-11-17 05:51:09 +0000 @@ -9310,7 +9310,7 @@ if (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK) term->charset_list = coding_charset_list (terminal_coding); else - term->charset_list = Fcons (Qascii, Qnil); + term->charset_list = Fcons (make_number (charset_ascii), Qnil); return Qnil; } ------------------------------------------------------------ revno: 102413 committer: Chong Yidong branch nick: trunk timestamp: Tue 2010-11-16 21:37:45 -0500 message: Cleanup of window coordinate positioning code. Now, text area click input events measure Y from the top of the text area, excluding the header line if any. * src/dispnew.c (buffer_posn_from_coords): Assume that X counts from the start of the text area. * src/keyboard.c (make_lispy_position): For text area clicks, record Y pixel position relative to the text area, excluding header line. Also change X and Y to Lisp_Objects, not pointers; don't return coordinate values via pointers. Pass ON_TEXT_AREA coordinate to buffer_posn_from_coords counting from the start of the text area. (Fposn_at_x_y, make_lispy_event): Callers changed. * src/w32term.c (w32_read_socket): * src/msdos.c (dos_rawgetc): * src/xterm.c (handle_one_xevent): Likewise. * src/window.c (coordinates_in_window): Change X and Y to ints rather than pointers; don't return coordinates via pointers. (struct check_window_data): Change X and Y from pointers to ints. (window_from_coordinates): Remove args WX and WY; don't return coordinates via pointers. (Fcoordinates_in_window_p, window_from_coordinates): (check_window_containing, Fwindow_at): Callers changed. (window_relative_x_coord): New function. * src/window.h (window_from_coordinates, window_relative_x_coord): Update prototypes. * src/xdisp.c (remember_mouse_glyph): Change window_from_coordinates call. Use window_relative_x_coord. (note_mouse_highlight): Change window_from_coordinates call. diff: === modified file 'etc/NEWS' --- etc/NEWS 2010-11-16 21:47:43 +0000 +++ etc/NEWS 2010-11-17 02:37:45 +0000 @@ -560,6 +560,11 @@ * Incompatible Lisp Changes in Emacs 24.1 +** For mouse click input events in the text area, the Y pixel +coordinate in the POSITION list now counts from the top of the text +area, excluding any header line. Previously, it counted from the top +of the header line. + ** Remove obsolete name `e' (use `float-e' instead). ** A backquote not followed by a space is now always treated as new-style. === modified file 'src/ChangeLog' --- src/ChangeLog 2010-11-16 21:47:43 +0000 +++ src/ChangeLog 2010-11-17 02:37:45 +0000 @@ -1,3 +1,35 @@ +2010-11-16 Chong Yidong + + * keyboard.c (make_lispy_position): For text area clicks, record Y + pixel position relative to the text area, excluding header line. + Also change X and Y to Lisp_Objects, not pointers; don't return + coordinate values via pointers. Pass ON_TEXT_AREA coordinate to + buffer_posn_from_coords counting from the start of the text area. + (Fposn_at_x_y, make_lispy_event): Callers changed. + + * window.c (coordinates_in_window): Change X and Y to ints rather + than pointers; don't return coordinates via pointers. + (struct check_window_data): Change X and Y from pointers to ints. + (window_from_coordinates): Remove args WX and WY; don't return + coordinates via pointers. + (Fcoordinates_in_window_p, window_from_coordinates): + (check_window_containing, Fwindow_at): Callers changed. + (window_relative_x_coord): New function. + + * window.h (window_from_coordinates, window_relative_x_coord): + Update prototypes. + + * dispnew.c (buffer_posn_from_coords): Assume that X counts from + the start of the text area. + + * xdisp.c (remember_mouse_glyph): Change window_from_coordinates + call. Use window_relative_x_coord. + (note_mouse_highlight): Change window_from_coordinates call. + + * w32term.c (w32_read_socket): + * msdos.c (dos_rawgetc): + * xterm.c (handle_one_xevent): Likewise. + 2010-11-16 Dan Nicolaescu * strftime.c (LOCALE_PARAM_DECL): Update for standard C. === modified file 'src/dispnew.c' --- src/dispnew.c 2010-11-16 21:47:43 +0000 +++ src/dispnew.c 2010-11-17 02:37:45 +0000 @@ -5393,7 +5393,7 @@ BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp))); start_display (&it, w, startp); - x0 = *x - WINDOW_LEFT_MARGIN_WIDTH (w); + x0 = *x; /* First, move to the beginning of the row corresponding to *Y. We need to be in that row to get the correct value of base paragraph === modified file 'src/keyboard.c' --- src/keyboard.c 2010-11-16 21:47:43 +0000 +++ src/keyboard.c 2010-11-17 02:37:45 +0000 @@ -5243,24 +5243,22 @@ int double_click_count; -/* Return position of a mouse click or wheel event */ +/* X and Y are frame-relative coordinates for a click or wheel event. + Return a Lisp-style event list. */ static Lisp_Object -make_lispy_position (struct frame *f, Lisp_Object *x, Lisp_Object *y, +make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y, unsigned long time) { - Lisp_Object window; enum window_part part; Lisp_Object posn = Qnil; Lisp_Object extra_info = Qnil; - int wx, wy; - - /* Set `window' to the window under frame pixel coordinates (x,y) */ - if (f) - window = window_from_coordinates (f, XINT (*x), XINT (*y), - &part, &wx, &wy, 0); - else - window = Qnil; + /* Coordinate pixel positions to return. */ + int xret = 0, yret = 0; + /* The window under frame pixel coordinates (x,y) */ + Lisp_Object window = f + ? window_from_coordinates (f, XINT (x), XINT (y), &part, 0) + : Qnil; if (WINDOWP (window)) { @@ -5268,102 +5266,113 @@ struct window *w = XWINDOW (window); Lisp_Object string_info = Qnil; EMACS_INT textpos = -1; - int rx = -1, ry = -1; - int dx = -1, dy = -1; + int col = -1, row = -1; + int dx = -1, dy = -1; int width = -1, height = -1; Lisp_Object object = Qnil; - /* Set event coordinates to window-relative coordinates - for constructing the Lisp event below. */ - XSETINT (*x, wx); - XSETINT (*y, wy); + /* Pixel coordinates relative to the window corner. */ + int wx = XINT (x) - WINDOW_LEFT_EDGE_X (w); + int wy = XINT (y) - WINDOW_TOP_EDGE_Y (w); + /* For text area clicks, return X, Y relative to the corner of + this text area. Note that dX, dY etc are set below, by + buffer_posn_from_coords. */ if (part == ON_TEXT) { - wx += WINDOW_LEFT_MARGIN_WIDTH (w); + xret = XINT (x) - window_box_left (w, TEXT_AREA); + yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } + /* For mode line and header line clicks, return X relative to + the left window edge; ignore Y. Use mode_line_string to look + for a string on the click position. */ else if (part == ON_MODE_LINE || part == ON_HEADER_LINE) { - /* Mode line or header line. Look for a string under - the mouse that may have a `local-map' property. */ Lisp_Object string; EMACS_INT charpos; - posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; - rx = wx, ry = wy; - string = mode_line_string (w, part, &rx, &ry, &charpos, + posn = (part == ON_MODE_LINE) ? Qmode_line : Qheader_line; + /* Note that mode_line_string takes COL, ROW as pixels and + converts them to characters. */ + col = wx; + row = wy; + string = mode_line_string (w, part, &col, &row, &charpos, &object, &dx, &dy, &width, &height); if (STRINGP (string)) string_info = Fcons (string, make_number (charpos)); - if (w == XWINDOW (selected_window) - && current_buffer == XBUFFER (w->buffer)) - textpos = PT; - else - textpos = XMARKER (w->pointm)->charpos; - } - else if (part == ON_VERTICAL_BORDER) - { - posn = Qvertical_line; - wx = -1; - dx = 0; - width = 1; - } + textpos = (w == XWINDOW (selected_window) + && current_buffer == XBUFFER (w->buffer)) + ? PT : XMARKER (w->pointm)->charpos; + + xret = wx; + } + /* For fringes and margins, Y is relative to the area's (and the + window's) top edge, while X is meaningless. */ else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) { Lisp_Object string; EMACS_INT charpos; posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; - rx = wx, ry = wy; - string = marginal_area_string (w, part, &rx, &ry, &charpos, + col = wx; + row = wy; + string = marginal_area_string (w, part, &col, &row, &charpos, &object, &dx, &dy, &width, &height); if (STRINGP (string)) string_info = Fcons (string, make_number (charpos)); - if (part == ON_LEFT_MARGIN) - wx = 0; - else - wx = window_box_right_offset (w, TEXT_AREA) - 1; + yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } else if (part == ON_LEFT_FRINGE) { posn = Qleft_fringe; - rx = 0; - dx = wx; - wx = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? 0 - : window_box_width (w, LEFT_MARGIN_AREA)); - dx -= wx; + col = 0; + dx = wx + - (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) + ? 0 : window_box_width (w, LEFT_MARGIN_AREA)); + dy = yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } else if (part == ON_RIGHT_FRINGE) { posn = Qright_fringe; - rx = 0; - dx = wx; - wx = (window_box_width (w, LEFT_MARGIN_AREA) - + window_box_width (w, TEXT_AREA) - + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? window_box_width (w, RIGHT_MARGIN_AREA) - : 0)); - dx -= wx; + col = 0; + dx = wx + - window_box_width (w, LEFT_MARGIN_AREA) + - window_box_width (w, TEXT_AREA) + - (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) + ? window_box_width (w, RIGHT_MARGIN_AREA) + : 0); + dy = yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } - else + else if (part == ON_VERTICAL_BORDER) { - /* Note: We have no special posn for part == ON_SCROLL_BAR. */ - wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx); + posn = Qvertical_line; + width = 1; + dx = 0; + dy = yret = wy; } + /* Nothing special for part == ON_SCROLL_BAR. */ + /* For clicks in the text area, fringes, or margins, call + buffer_posn_from_coords to extract TEXTPOS, the buffer + position nearest to the click. */ if (textpos < 0) { Lisp_Object string2, object2 = Qnil; struct display_pos p; int dx2, dy2; int width2, height2; - string2 = buffer_posn_from_coords (w, &wx, &wy, &p, + /* The pixel X coordinate passed to buffer_posn_from_coords + is the X coordinate relative to the text area for + text-area clicks, zero otherwise. */ + int x2 = (part == ON_TEXT) ? xret : 0; + int y2 = wy; + + string2 = buffer_posn_from_coords (w, &x2, &y2, &p, &object2, &dx2, &dy2, &width2, &height2); textpos = CHARPOS (p.pos); - if (rx < 0) rx = wx; - if (ry < 0) ry = wy; + if (col < 0) col = x2; + if (row < 0) row = y2; if (dx < 0) dx = dx2; if (dy < 0) dy = dy2; if (width < 0) width = width2; @@ -5394,34 +5403,27 @@ #endif /* Object info */ - extra_info = Fcons (object, - Fcons (Fcons (make_number (dx), - make_number (dy)), - Fcons (Fcons (make_number (width), - make_number (height)), - Qnil))); + extra_info + = list3 (object, + Fcons (make_number (dx), make_number (dy)), + Fcons (make_number (width), make_number (height))); /* String info */ extra_info = Fcons (string_info, Fcons (make_number (textpos), - Fcons (Fcons (make_number (rx), - make_number (ry)), + Fcons (Fcons (make_number (col), + make_number (row)), extra_info))); } else if (f != 0) - { - XSETFRAME (window, f); - } + XSETFRAME (window, f); else - { - window = Qnil; - XSETFASTINT (*x, 0); - XSETFASTINT (*y, 0); - } + window = Qnil; return Fcons (window, Fcons (posn, - Fcons (Fcons (*x, *y), + Fcons (Fcons (make_number (xret), + make_number (yret)), Fcons (make_number (time), extra_info)))); } @@ -5610,14 +5612,6 @@ int hpos; int i; -#if 0 - /* Activate the menu bar on the down event. If the - up event comes in before the menu code can deal with it, - just ignore it. */ - if (! (event->modifiers & down_modifier)) - return Qnil; -#endif - /* Find the menu bar item under `column'. */ item = Qnil; items = FRAME_MENU_BAR_ITEMS (f); @@ -5649,7 +5643,7 @@ } #endif /* not USE_X_TOOLKIT && not USE_GTK && not HAVE_NS */ - position = make_lispy_position (f, &event->x, &event->y, + position = make_lispy_position (f, event->x, event->y, event->timestamp); } #ifndef USE_TOOLKIT_SCROLL_BARS @@ -5749,23 +5743,21 @@ return Qnil; event->modifiers &= ~up_modifier; -#if 0 /* Formerly we treated an up with no down as a click event. */ - if (!CONSP (start_pos)) - event->modifiers |= click_modifier; - else -#endif + { - Lisp_Object down; + Lisp_Object new_down, down; EMACS_INT xdiff = double_click_fuzz, ydiff = double_click_fuzz; /* The third element of every position should be the (x,y) pair. */ down = Fcar (Fcdr (Fcdr (start_pos))); + new_down = Fcar (Fcdr (Fcdr (position))); + if (CONSP (down) && INTEGERP (XCAR (down)) && INTEGERP (XCDR (down))) { - xdiff = XINT (event->x) - XINT (XCAR (down)); - ydiff = XINT (event->y) - XINT (XCDR (down)); + xdiff = XINT (XCAR (new_down)) - XINT (XCAR (down)); + ydiff = XINT (XCDR (new_down)) - XINT (XCDR (down)); } if (ignore_mouse_drag_p) @@ -5848,7 +5840,7 @@ if (! FRAME_LIVE_P (f)) return Qnil; - position = make_lispy_position (f, &event->x, &event->y, + position = make_lispy_position (f, event->x, event->y, event->timestamp); /* Set double or triple modifiers to indicate the wheel speed. */ @@ -5868,10 +5860,8 @@ else abort (); - if (FRAME_WINDOW_P (f)) - fuzz = double_click_fuzz; - else - fuzz = double_click_fuzz / 8; + fuzz = FRAME_WINDOW_P (f) + ? double_click_fuzz : double_click_fuzz / 8; if (event->modifiers & up_modifier) { @@ -6009,7 +5999,7 @@ if (! FRAME_LIVE_P (f)) return Qnil; - position = make_lispy_position (f, &event->x, &event->y, + position = make_lispy_position (f, event->x, event->y, event->timestamp); head = modify_event_symbol (0, event->modifiers, @@ -6092,8 +6082,8 @@ start_pos_ptr = &AREF (button_down_location, button); start_pos = *start_pos_ptr; - position = make_lispy_position (f, &event->x, &event->y, - event->timestamp); + position = make_lispy_position (f, event->x, event->y, + event->timestamp); if (event->modifiers & down_modifier) *start_pos_ptr = Fcopy_alist (position); @@ -6152,25 +6142,19 @@ part_sym = *scroll_bar_parts[(int) part]; return Fcons (Qscroll_bar_movement, - (Fcons (Fcons (bar_window, - Fcons (Qvertical_scroll_bar, - Fcons (Fcons (x, y), - Fcons (make_number (time), - Fcons (part_sym, - Qnil))))), - Qnil))); + Fcons (list5 (bar_window, + Qvertical_scroll_bar, + Fcons (x, y), + make_number (time), + part_sym), + Qnil)); } - /* Or is it an ordinary mouse movement? */ else { Lisp_Object position; - - position = make_lispy_position (frame, &x, &y, time); - - return Fcons (Qmouse_movement, - Fcons (position, - Qnil)); + position = make_lispy_position (frame, x, y, time); + return list2 (Qmouse_movement, position); } } @@ -11327,7 +11311,7 @@ CHECK_LIVE_FRAME (frame_or_window); - return make_lispy_position (XFRAME (frame_or_window), &x, &y, 0); + return make_lispy_position (XFRAME (frame_or_window), x, y, 0); } DEFUN ("posn-at-point", Fposn_at_point, Sposn_at_point, 0, 2, 0, === modified file 'src/msdos.c' --- src/msdos.c 2010-11-16 21:47:43 +0000 +++ src/msdos.c 2010-11-17 02:37:45 +0000 @@ -2698,7 +2698,7 @@ mouse_window = window_from_coordinates (SELECTED_FRAME(), mouse_last_x, mouse_last_y, - 0, 0, 0, 0); + 0, 0); /* A window will be selected only when it is not selected now, and the last mouse movement event was not in it. A minibuffer window will be selected iff === modified file 'src/w32term.c' --- src/w32term.c 2010-11-16 21:47:43 +0000 +++ src/w32term.c 2010-11-17 02:37:45 +0000 @@ -4317,7 +4317,7 @@ int x = LOWORD (msg.msg.lParam); int y = HIWORD (msg.msg.lParam); - window = window_from_coordinates (f, x, y, 0, 0, 0, 0); + window = window_from_coordinates (f, x, y, 0, 0); /* Window will be selected only when it is not selected now and last mouse movement event was @@ -4396,7 +4396,7 @@ int x = XFASTINT (inev.x); int y = XFASTINT (inev.y); - window = window_from_coordinates (f, x, y, 0, 0, 0, 1); + window = window_from_coordinates (f, x, y, 0, 1); if (EQ (window, f->tool_bar_window)) { === modified file 'src/window.c' --- src/window.c 2010-11-16 21:47:43 +0000 +++ src/window.c 2010-11-17 02:37:45 +0000 @@ -755,32 +755,26 @@ - WINDOW_MODE_LINE_HEIGHT (w) + add_y)); } -/* Test if the character at column *X, row *Y is within window W. +/* Test if the character at column X, row Y is within window W. If it is not, return ON_NOTHING; - if it is in the window's text area, - set *x and *y to its location relative to the upper left corner - of the window, and - return ON_TEXT; + if it is in the window's text area, return ON_TEXT; if it is on the window's modeline, return ON_MODE_LINE; if it is on the border between the window and its right sibling, return ON_VERTICAL_BORDER. - if it is on a scroll bar, - return ON_SCROLL_BAR. + if it is on a scroll bar, return ON_SCROLL_BAR. if it is on the window's top line, return ON_HEADER_LINE; if it is in left or right fringe of the window, - return ON_LEFT_FRINGE or ON_RIGHT_FRINGE, and convert *X and *Y - to window-relative coordinates; + return ON_LEFT_FRINGE or ON_RIGHT_FRINGE; if it is in the marginal area to the left/right of the window, - return ON_LEFT_MARGIN or ON_RIGHT_MARGIN, and convert *X and *Y - to window-relative coordinates. + return ON_LEFT_MARGIN or ON_RIGHT_MARGIN. X and Y are frame relative pixel coordinates. */ static enum window_part -coordinates_in_window (register struct window *w, register int *x, register int *y) +coordinates_in_window (register struct window *w, int x, int y) { struct frame *f = XFRAME (WINDOW_FRAME (w)); - int left_x, right_x, top_y, bottom_y; + int left_x, right_x; enum window_part part; int ux = FRAME_COLUMN_WIDTH (f); int x0 = WINDOW_LEFT_EDGE_X (w); @@ -789,6 +783,12 @@ (Between mode lines for instance. */ int grabbable_width = ux; int lmargin_width, rmargin_width, text_left, text_right; + int top_y = WINDOW_TOP_EDGE_Y (w); + int bottom_y = WINDOW_BOTTOM_EDGE_Y (w); + + /* Outside any interesting row? */ + if (y < top_y || y >= bottom_y) + return ON_NOTHING; /* In what's below, we subtract 1 when computing right_x because we want the rightmost pixel, which is given by left_pixel+width-1. */ @@ -796,21 +796,13 @@ { left_x = 0; right_x = WINDOW_TOTAL_WIDTH (w) - 1; - top_y = WINDOW_TOP_EDGE_Y (w); - bottom_y = WINDOW_BOTTOM_EDGE_Y (w); } else { left_x = WINDOW_BOX_LEFT_EDGE_X (w); right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1; - top_y = WINDOW_TOP_EDGE_Y (w); - bottom_y = WINDOW_BOTTOM_EDGE_Y (w); } - /* Outside any interesting row? */ - if (*y < top_y || *y >= bottom_y) - return ON_NOTHING; - /* On the mode line or header line? If it's near the start of the mode or header line of window that's has a horizontal sibling, say it's on the vertical line. That's to be able @@ -818,7 +810,7 @@ scroll bars. */ if (WINDOW_WANTS_MODELINE_P (w) - && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) + && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) { part = ON_MODE_LINE; @@ -827,60 +819,37 @@ between mode lines of horizontally adjacent mode lines as the vertical border. If scroll bars on the left, return the right window. */ - if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) - || WINDOW_RIGHTMOST_P (w)) - { - if (!WINDOW_LEFTMOST_P (w) && eabs (*x - x0) < grabbable_width) - { - /* Convert X and Y to window relative coordinates. - Vertical border is at the left edge of window. */ - *x = max (0, *x - x0); - *y -= top_y; - return ON_VERTICAL_BORDER; - } - } - else - { - /* Make sure we're not at the rightmost position of a - mode-/header-line and there's yet another window on - the right. (Bug#1372) */ - if ((WINDOW_RIGHTMOST_P (w) || *x < x1) - && eabs (*x - x1) < grabbable_width) - { - /* Convert X and Y to window relative coordinates. - Vertical border is at the right edge of window. */ - *x = min (x1, *x) - x0; - *y -= top_y; - return ON_VERTICAL_BORDER; - } - } - - if (*x < x0 || *x >= x1) + if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) + || WINDOW_RIGHTMOST_P (w)) + && !WINDOW_LEFTMOST_P (w) + && eabs (x - x0) < grabbable_width) + return ON_VERTICAL_BORDER; + + /* Make sure we're not at the rightmost position of a + mode-/header-line and there's yet another window on the + right. (Bug#1372) */ + else if ((WINDOW_RIGHTMOST_P (w) || x < x1) + && eabs (x - x1) < grabbable_width) + return ON_VERTICAL_BORDER; + + if (x < x0 || x >= x1) return ON_NOTHING; - /* Convert X and Y to window relative coordinates. - Mode line starts at left edge of window. */ - *x -= x0; - *y -= top_y; return part; } if (WINDOW_WANTS_HEADER_LINE_P (w) - && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) + && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) { part = ON_HEADER_LINE; goto header_vertical_border_check; } - if (*x < x0 || *x >= x1) - return ON_NOTHING; + if (x < x0 || x >= x1) return ON_NOTHING; /* Outside any interesting column? */ - if (*x < left_x || *x > right_x) - { - *y -= top_y; - return ON_SCROLL_BAR; - } + if (x < left_x || x > right_x) + return ON_SCROLL_BAR; lmargin_width = window_box_width (w, LEFT_MARGIN_AREA); rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA); @@ -893,77 +862,79 @@ if (!w->pseudo_window_p && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w) && !WINDOW_RIGHTMOST_P (w) - && (eabs (*x - right_x) < grabbable_width)) - { - /* Convert X and Y to window relative coordinates. - Vertical border is at the right edge of window. */ - *x = min (right_x, *x) - left_x; - *y -= top_y; - return ON_VERTICAL_BORDER; - } - } - else - { - /* Need to say "*x > right_x" rather than >=, since on character - terminals, the vertical line's x coordinate is right_x. */ - if (!w->pseudo_window_p - && !WINDOW_RIGHTMOST_P (w) - && *x > right_x - ux) - { - /* On the border on the right side of the window? Assume that - this area begins at RIGHT_X minus a canonical char width. */ - *x = min (right_x, *x) - left_x; - *y -= top_y; - return ON_VERTICAL_BORDER; - } - } + && (eabs (x - right_x) < grabbable_width)) + return ON_VERTICAL_BORDER; + } + /* Need to say "x > right_x" rather than >=, since on character + terminals, the vertical line's x coordinate is right_x. */ + else if (!w->pseudo_window_p + && !WINDOW_RIGHTMOST_P (w) + && x > right_x - ux) + return ON_VERTICAL_BORDER; - if (*x < text_left) + if (x < text_left) { if (lmargin_width > 0 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? (*x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w)) - : (*x < left_x + lmargin_width))) - { - *x -= left_x; - if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) - *x -= WINDOW_LEFT_FRINGE_WIDTH (w); - *y -= top_y; - return ON_LEFT_MARGIN; - } + ? (x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w)) + : (x < left_x + lmargin_width))) + return ON_LEFT_MARGIN; - /* Convert X and Y to window-relative pixel coordinates. */ - *x -= left_x; - *y -= top_y; return ON_LEFT_FRINGE; } - if (*x >= text_right) + if (x >= text_right) { if (rmargin_width > 0 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? (*x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w)) - : (*x >= right_x - rmargin_width))) - { - *x -= right_x - rmargin_width; - if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) - *x += WINDOW_RIGHT_FRINGE_WIDTH (w); - *y -= top_y; - return ON_RIGHT_MARGIN; - } + ? (x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w)) + : (x >= right_x - rmargin_width))) + return ON_RIGHT_MARGIN; - /* Convert X and Y to window-relative pixel coordinates. */ - *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w); - *y -= top_y; return ON_RIGHT_FRINGE; } /* Everything special ruled out - must be on text area */ - *x -= text_left; - *y -= top_y; return ON_TEXT; } +/* Take X is the frame-relative pixel x-coordinate, and return the + x-coordinate relative to part PART of window W. */ +int +window_relative_x_coord (struct window *w, enum window_part part, int x) +{ + int left_x = (w->pseudo_window_p) ? 0 : WINDOW_BOX_LEFT_EDGE_X (w); + + switch (part) + { + case ON_TEXT: + return x - window_box_left (w, TEXT_AREA); + + case ON_LEFT_FRINGE: + return x - left_x; + + case ON_RIGHT_FRINGE: + return x - left_x - WINDOW_LEFT_FRINGE_WIDTH (w); + + case ON_LEFT_MARGIN: + return (x - left_x + - ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) + ? WINDOW_LEFT_FRINGE_WIDTH (w) : 0)); + + case ON_RIGHT_MARGIN: + return (x + 1 + - ((w->pseudo_window_p) + ? WINDOW_TOTAL_WIDTH (w) + : WINDOW_BOX_RIGHT_EDGE_X (w)) + + window_box_width (w, RIGHT_MARGIN_AREA) + + ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) + ? WINDOW_RIGHT_FRINGE_WIDTH (w) : 0)); + } + + /* ON_SCROLL_BAR, ON_NOTHING, and ON_VERTICAL_BORDER: */ + return 0; +} + DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, Scoordinates_in_window_p, 2, 2, 0, @@ -1000,14 +971,16 @@ x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f); y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH (f); - switch (coordinates_in_window (w, &x, &y)) + switch (coordinates_in_window (w, x, y)) { case ON_NOTHING: return Qnil; case ON_TEXT: - /* X and Y are now window relative pixel coordinates. Convert - them to canonical char units before returning them. */ + /* Convert X and Y to window relative pixel coordinates, and + return the canonical char units. */ + x -= window_box_left (w, TEXT_AREA); + y -= WINDOW_TOP_EDGE_Y (w); return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f, x), FRAME_CANON_Y_FROM_PIXEL_Y (f, y)); @@ -1054,7 +1027,7 @@ struct check_window_data { Lisp_Object *window; - int *x, *y; + int x, y; enum window_part *part; }; @@ -1081,8 +1054,7 @@ return it as a Lisp_Object. If X, Y is on one of the window's special `window_part' elements, - set *PART to the id of that element, and return X and Y converted - to window relative coordinates in WX and WY. + set *PART to the id of that element. If there is no window under X, Y return nil and leave *PART unmodified. TOOL_BAR_P non-zero means detect tool-bar windows. @@ -1097,7 +1069,8 @@ case. */ Lisp_Object -window_from_coordinates (struct frame *f, int x, int y, enum window_part *part, int *wx, int *wy, int tool_bar_p) +window_from_coordinates (struct frame *f, int x, int y, + enum window_part *part, int tool_bar_p) { Lisp_Object window; struct check_window_data cw; @@ -1107,7 +1080,7 @@ part = &dummy; window = Qnil; - cw.window = &window, cw.x = &x, cw.y = &y; cw.part = part; + cw.window = &window, cw.x = x, cw.y = y; cw.part = part; foreach_window (f, check_window_containing, &cw); /* If not found above, see if it's in the tool bar window, if a tool @@ -1116,16 +1089,13 @@ && tool_bar_p && WINDOWP (f->tool_bar_window) && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0 - && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y) + && (coordinates_in_window (XWINDOW (f->tool_bar_window), x, y) != ON_NOTHING)) { *part = ON_TEXT; window = f->tool_bar_window; } - if (wx) *wx = x; - if (wy) *wy = y; - return window; } @@ -1152,7 +1122,7 @@ + FRAME_INTERNAL_BORDER_WIDTH (f)), (FRAME_PIXEL_Y_FROM_CANON_Y (f, y) + FRAME_INTERNAL_BORDER_WIDTH (f)), - 0, 0, 0, 0); + 0, 0); } DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, === modified file 'src/window.h' --- src/window.h 2010-11-16 21:47:43 +0000 +++ src/window.h 2010-11-17 02:37:45 +0000 @@ -788,8 +788,7 @@ extern Lisp_Object make_window (void); extern void delete_window (Lisp_Object); extern Lisp_Object window_from_coordinates (struct frame *, int, int, - enum window_part *, - int *, int*, int); + enum window_part *, int); EXFUN (Fwindow_dedicated_p, 1); extern int window_height (Lisp_Object); extern int window_width (Lisp_Object); @@ -804,6 +803,7 @@ void *); extern void grow_mini_window (struct window *, int); extern void shrink_mini_window (struct window *); +extern int window_relative_x_coord (struct window *, enum window_part, int); void run_window_configuration_change_hook (struct frame *f); === modified file 'src/xdisp.c' --- src/xdisp.c 2010-11-16 21:47:43 +0000 +++ src/xdisp.c 2010-11-17 02:37:45 +0000 @@ -2218,7 +2218,7 @@ frame pixel coordinates X/Y on frame F. */ if (!f->glyphs_initialized_p - || (window = window_from_coordinates (f, gx, gy, &part, &x, &y, 0), + || (window = window_from_coordinates (f, gx, gy, &part, 0), NILP (window))) { width = FRAME_SMALLEST_CHAR_WIDTH (f); @@ -2230,6 +2230,9 @@ width = WINDOW_FRAME_COLUMN_WIDTH (w); height = WINDOW_FRAME_LINE_HEIGHT (w); + x = window_relative_x_coord (w, part, gx); + y = gy - WINDOW_TOP_EDGE_Y (w); + r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w); @@ -25383,7 +25386,7 @@ } /* Which window is that in? */ - window = window_from_coordinates (f, x, y, &part, 0, 0, 1); + window = window_from_coordinates (f, x, y, &part, 1); /* If we were displaying active text in another window, clear that. Also clear if we move out of text area in same window. */ === modified file 'src/xterm.c' --- src/xterm.c 2010-11-16 21:47:43 +0000 +++ src/xterm.c 2010-11-17 02:37:45 +0000 @@ -6658,7 +6658,7 @@ window = window_from_coordinates (f, event.xmotion.x, event.xmotion.y, - 0, 0, 0, 0); + 0, 0); /* Window will be selected only when it is not selected now and last mouse movement event was not in it. Minibuffer window @@ -6797,7 +6797,7 @@ int x = event.xbutton.x; int y = event.xbutton.y; - window = window_from_coordinates (f, x, y, 0, 0, 0, 1); + window = window_from_coordinates (f, x, y, 0, 1); tool_bar_p = EQ (window, f->tool_bar_window); if (tool_bar_p && event.xbutton.button < 4) ------------------------------------------------------------ revno: 102412 author: Daniel Dehennin committer: Katsumi Yamaoka branch nick: trunk timestamp: Tue 2010-11-16 23:05:02 +0000 message: mml2015-epg-sign: Use From header. mml2015.el (mml2015-epg-sign): New variable 'sender' is (message-options-get 'message-sender) and append it to mml2015-signers. If mm-sign-option is not 'guided, mml2015-signers and sender sign the mail. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2010-11-16 00:04:25 +0000 +++ lisp/gnus/ChangeLog 2010-11-16 23:05:02 +0000 @@ -1,3 +1,7 @@ +2010-11-16 Daniel Dehennin + + * mml2015.el (mml2015-epg-sign): Use From header. + 2010-11-15 Lars Magne Ingebrigtsen * gnus-html.el (gnus-html-wash-images): Register a displayer. === modified file 'lisp/gnus/mml2015.el' --- lisp/gnus/mml2015.el 2010-10-11 23:29:33 +0000 +++ lisp/gnus/mml2015.el 2010-11-16 23:05:02 +0000 @@ -941,6 +941,7 @@ (let* ((inhibit-redisplay t) (context (epg-make-context)) (boundary (mml-compute-boundary cont)) + (sender (message-options-get 'message-sender)) signer-key (signers (or (message-options-get 'mml2015-epg-signers) @@ -950,8 +951,8 @@ (epa-select-keys context "\ Select keys for signing. If no one is selected, default secret key is used. " - mml2015-signers t) - (if mml2015-signers + (cons sender mml2015-signers) t) + (if (or sender mml2015-signers) (delq nil (mapcar (lambda (signer) @@ -965,7 +966,7 @@ signer))) (error "No secret key for %s" signer)) signer-key) - mml2015-signers))))))) + (cons sender mml2015-signers)))))))) signature micalg) (epg-context-set-armor context t) (epg-context-set-textmode context t) @@ -1008,6 +1009,7 @@ (let ((inhibit-redisplay t) (context (epg-make-context)) (config (epg-configuration)) + (sender (message-options-get 'message-sender)) (recipients (message-options-get 'mml2015-epg-recipients)) cipher signers (boundary (mml-compute-boundary cont)) @@ -1025,9 +1027,9 @@ (read-string "Recipients: "))) "[ \f\t\n\r\v,]+")))) (when mml2015-encrypt-to-self - (unless mml2015-signers - (error "mml2015-signers not set")) - (setq recipients (nconc recipients mml2015-signers))) + (unless (or sender mml2015-signers) + (error "Message sender and mml2015-signers not set")) + (setq recipients (nconc recipients (cons sender mml2015-signers)))) (if (eq mm-encrypt-option 'guided) (setq recipients (epa-select-keys context "\ @@ -1060,8 +1062,8 @@ (epa-select-keys context "\ Select keys for signing. If no one is selected, default secret key is used. " - mml2015-signers t) - (if mml2015-signers + (cons mml2015-signers) t) + (if (or sender mml2015-signers) (delq nil (mapcar (lambda (signer) @@ -1075,7 +1077,7 @@ signer))) (error "No secret key for %s" signer)) signer-key) - mml2015-signers))))))) + (cons mml2015-signers)))))))) (epg-context-set-signers context signers)) (epg-context-set-armor context t) (epg-context-set-textmode context t) ------------------------------------------------------------ revno: 102411 committer: Chong Yidong branch nick: trunk timestamp: Tue 2010-11-16 16:47:43 -0500 message: Revert changes in revision 102407 diff: === modified file 'etc/NEWS' --- etc/NEWS 2010-11-16 21:14:46 +0000 +++ etc/NEWS 2010-11-16 21:47:43 +0000 @@ -560,11 +560,6 @@ * Incompatible Lisp Changes in Emacs 24.1 -** For mouse click input events in the text area, the Y pixel -coordinate in the POSITION list now counts from the top of the text -area, excluding any header line. Previously, it counted from the top -of the header line. - ** Remove obsolete name `e' (use `float-e' instead). ** A backquote not followed by a space is now always treated as new-style. === modified file 'src/ChangeLog' --- src/ChangeLog 2010-11-16 19:59:24 +0000 +++ src/ChangeLog 2010-11-16 21:47:43 +0000 @@ -1,35 +1,3 @@ -2010-11-16 Chong Yidong - - * keyboard.c (make_lispy_position): For text area clicks, record Y - pixel position relative to the text area, excluding header line. - Also change X and Y to Lisp_Objects, not pointers; don't return - coordinate values via pointers. Pass ON_TEXT_AREA coordinate to - buffer_posn_from_coords counting from the start of the text area. - (Fposn_at_x_y, make_lispy_event): Callers changed. - - * window.c (coordinates_in_window): Change X and Y to ints rather - than pointers; don't return coordinates via pointers. - (struct check_window_data): Change X and Y from pointers to ints. - (window_from_coordinates): Remove args WX and WY; don't return - coordinates via pointers. - (Fcoordinates_in_window_p, window_from_coordinates): - (check_window_containing, Fwindow_at): Callers changed. - (window_relative_x_coord): New function. - - * window.h (window_from_coordinates, window_relative_x_coord): - Update prototypes. - - * dispnew.c (buffer_posn_from_coords): Assume that X counts from - the start of the text area. - - * xdisp.c (remember_mouse_glyph): Change window_from_coordinates - call. Use window_relative_x_coord. - (note_mouse_highlight): Change window_from_coordinates call. - - * w32term.c (w32_read_socket): - * msdos.c (dos_rawgetc): - * xterm.c (handle_one_xevent): Likewise. - 2010-11-16 Dan Nicolaescu * strftime.c (LOCALE_PARAM_DECL): Update for standard C. === modified file 'src/dispnew.c' --- src/dispnew.c 2010-11-16 19:59:24 +0000 +++ src/dispnew.c 2010-11-16 21:47:43 +0000 @@ -5393,7 +5393,7 @@ BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp))); start_display (&it, w, startp); - x0 = *x; + x0 = *x - WINDOW_LEFT_MARGIN_WIDTH (w); /* First, move to the beginning of the row corresponding to *Y. We need to be in that row to get the correct value of base paragraph === modified file 'src/keyboard.c' --- src/keyboard.c 2010-11-16 21:38:37 +0000 +++ src/keyboard.c 2010-11-16 21:47:43 +0000 @@ -5243,22 +5243,24 @@ int double_click_count; -/* X and Y are frame-relative coordinates for a click or wheel event. - Return a Lisp-style event list. */ +/* Return position of a mouse click or wheel event */ static Lisp_Object -make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y, +make_lispy_position (struct frame *f, Lisp_Object *x, Lisp_Object *y, unsigned long time) { + Lisp_Object window; enum window_part part; Lisp_Object posn = Qnil; Lisp_Object extra_info = Qnil; - /* Coordinate pixel positions to return. */ - int xret = 0, yret = 0; - /* The window under frame pixel coordinates (x,y) */ - Lisp_Object window = f - ? window_from_coordinates (f, XINT (x), XINT (y), &part, 0) - : Qnil; + int wx, wy; + + /* Set `window' to the window under frame pixel coordinates (x,y) */ + if (f) + window = window_from_coordinates (f, XINT (*x), XINT (*y), + &part, &wx, &wy, 0); + else + window = Qnil; if (WINDOWP (window)) { @@ -5266,113 +5268,102 @@ struct window *w = XWINDOW (window); Lisp_Object string_info = Qnil; EMACS_INT textpos = -1; - int col = -1, row = -1; - int dx = -1, dy = -1; + int rx = -1, ry = -1; + int dx = -1, dy = -1; int width = -1, height = -1; Lisp_Object object = Qnil; - /* Pixel coordinates relative to the window corner. */ - int wx = XINT (x) - WINDOW_LEFT_EDGE_X (w); - int wy = XINT (y) - WINDOW_TOP_EDGE_Y (w); + /* Set event coordinates to window-relative coordinates + for constructing the Lisp event below. */ + XSETINT (*x, wx); + XSETINT (*y, wy); - /* For text area clicks, return X, Y relative to the corner of - this text area. Note that dX, dY etc are set below, by - buffer_posn_from_coords. */ if (part == ON_TEXT) { - xret = XINT (x) - window_box_left (w, TEXT_AREA); - yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); + wx += WINDOW_LEFT_MARGIN_WIDTH (w); } - /* For mode line and header line clicks, return X relative to - the left window edge; ignore Y. Use mode_line_string to look - for a string on the click position. */ else if (part == ON_MODE_LINE || part == ON_HEADER_LINE) { + /* Mode line or header line. Look for a string under + the mouse that may have a `local-map' property. */ Lisp_Object string; EMACS_INT charpos; - posn = (part == ON_MODE_LINE) ? Qmode_line : Qheader_line; - /* Note that mode_line_string takes COL, ROW as pixels and - converts them to characters. */ - col = wx; - row = wy; - string = mode_line_string (w, part, &col, &row, &charpos, + posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; + rx = wx, ry = wy; + string = mode_line_string (w, part, &rx, &ry, &charpos, &object, &dx, &dy, &width, &height); if (STRINGP (string)) string_info = Fcons (string, make_number (charpos)); - textpos = (w == XWINDOW (selected_window) - && current_buffer == XBUFFER (w->buffer)) - ? PT : XMARKER (w->pointm)->charpos; - - xret = wx; - } - /* For fringes and margins, Y is relative to the area's (and the - window's) top edge, while X is meaningless. */ + if (w == XWINDOW (selected_window) + && current_buffer == XBUFFER (w->buffer)) + textpos = PT; + else + textpos = XMARKER (w->pointm)->charpos; + } + else if (part == ON_VERTICAL_BORDER) + { + posn = Qvertical_line; + wx = -1; + dx = 0; + width = 1; + } else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) { Lisp_Object string; EMACS_INT charpos; posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; - col = wx; - row = wy; - string = marginal_area_string (w, part, &col, &row, &charpos, + rx = wx, ry = wy; + string = marginal_area_string (w, part, &rx, &ry, &charpos, &object, &dx, &dy, &width, &height); if (STRINGP (string)) string_info = Fcons (string, make_number (charpos)); - yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); + if (part == ON_LEFT_MARGIN) + wx = 0; + else + wx = window_box_right_offset (w, TEXT_AREA) - 1; } else if (part == ON_LEFT_FRINGE) { posn = Qleft_fringe; - col = 0; - dx = wx - - (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? 0 : window_box_width (w, LEFT_MARGIN_AREA)); - dy = yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); + rx = 0; + dx = wx; + wx = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) + ? 0 + : window_box_width (w, LEFT_MARGIN_AREA)); + dx -= wx; } else if (part == ON_RIGHT_FRINGE) { posn = Qright_fringe; - col = 0; - dx = wx - - window_box_width (w, LEFT_MARGIN_AREA) - - window_box_width (w, TEXT_AREA) - - (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? window_box_width (w, RIGHT_MARGIN_AREA) - : 0); - dy = yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); + rx = 0; + dx = wx; + wx = (window_box_width (w, LEFT_MARGIN_AREA) + + window_box_width (w, TEXT_AREA) + + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) + ? window_box_width (w, RIGHT_MARGIN_AREA) + : 0)); + dx -= wx; } - else if (part == ON_VERTICAL_BORDER) + else { - posn = Qvertical_line; - width = 1; - dx = 0; - dy = yret = wy; + /* Note: We have no special posn for part == ON_SCROLL_BAR. */ + wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx); } - /* Nothing special for part == ON_SCROLL_BAR. */ - /* For clicks in the text area, fringes, or margins, call - buffer_posn_from_coords to extract TEXTPOS, the buffer - position nearest to the click. */ if (textpos < 0) { Lisp_Object string2, object2 = Qnil; struct display_pos p; int dx2, dy2; int width2, height2; - /* The pixel X coordinate passed to buffer_posn_from_coords - is the X coordinate relative to the text area for - text-area clicks, zero otherwise. */ - int x2 = (part == ON_TEXT) ? xret : 0; - int y2 = wy; - - string2 = buffer_posn_from_coords (w, &x2, &y2, &p, + string2 = buffer_posn_from_coords (w, &wx, &wy, &p, &object2, &dx2, &dy2, &width2, &height2); textpos = CHARPOS (p.pos); - if (col < 0) col = x2; - if (row < 0) row = y2; + if (rx < 0) rx = wx; + if (ry < 0) ry = wy; if (dx < 0) dx = dx2; if (dy < 0) dy = dy2; if (width < 0) width = width2; @@ -5403,27 +5394,34 @@ #endif /* Object info */ - extra_info - = list3 (object, - Fcons (make_number (dx), make_number (dy)), - Fcons (make_number (width), make_number (height))); + extra_info = Fcons (object, + Fcons (Fcons (make_number (dx), + make_number (dy)), + Fcons (Fcons (make_number (width), + make_number (height)), + Qnil))); /* String info */ extra_info = Fcons (string_info, Fcons (make_number (textpos), - Fcons (Fcons (make_number (col), - make_number (row)), + Fcons (Fcons (make_number (rx), + make_number (ry)), extra_info))); } else if (f != 0) - XSETFRAME (window, f); + { + XSETFRAME (window, f); + } else - window = Qnil; + { + window = Qnil; + XSETFASTINT (*x, 0); + XSETFASTINT (*y, 0); + } return Fcons (window, Fcons (posn, - Fcons (Fcons (make_number (xret), - make_number (yret)), + Fcons (Fcons (*x, *y), Fcons (make_number (time), extra_info)))); } @@ -5612,6 +5610,14 @@ int hpos; int i; +#if 0 + /* Activate the menu bar on the down event. If the + up event comes in before the menu code can deal with it, + just ignore it. */ + if (! (event->modifiers & down_modifier)) + return Qnil; +#endif + /* Find the menu bar item under `column'. */ item = Qnil; items = FRAME_MENU_BAR_ITEMS (f); @@ -5643,7 +5649,7 @@ } #endif /* not USE_X_TOOLKIT && not USE_GTK && not HAVE_NS */ - position = make_lispy_position (f, event->x, event->y, + position = make_lispy_position (f, &event->x, &event->y, event->timestamp); } #ifndef USE_TOOLKIT_SCROLL_BARS @@ -5743,21 +5749,23 @@ return Qnil; event->modifiers &= ~up_modifier; - +#if 0 /* Formerly we treated an up with no down as a click event. */ + if (!CONSP (start_pos)) + event->modifiers |= click_modifier; + else +#endif { - Lisp_Object new_down, down; + Lisp_Object down; EMACS_INT xdiff = double_click_fuzz, ydiff = double_click_fuzz; /* The third element of every position should be the (x,y) pair. */ down = Fcar (Fcdr (Fcdr (start_pos))); - new_down = Fcar (Fcdr (Fcdr (position))); - if (CONSP (down) && INTEGERP (XCAR (down)) && INTEGERP (XCDR (down))) { - xdiff = XINT (XCAR (new_down)) - XINT (XCAR (down)); - ydiff = XINT (XCDR (new_down)) - XINT (XCDR (down)); + xdiff = XINT (event->x) - XINT (XCAR (down)); + ydiff = XINT (event->y) - XINT (XCDR (down)); } if (ignore_mouse_drag_p) @@ -5840,7 +5848,7 @@ if (! FRAME_LIVE_P (f)) return Qnil; - position = make_lispy_position (f, event->x, event->y, + position = make_lispy_position (f, &event->x, &event->y, event->timestamp); /* Set double or triple modifiers to indicate the wheel speed. */ @@ -5860,8 +5868,10 @@ else abort (); - fuzz = FRAME_WINDOW_P (f) - ? double_click_fuzz : double_click_fuzz / 8; + if (FRAME_WINDOW_P (f)) + fuzz = double_click_fuzz; + else + fuzz = double_click_fuzz / 8; if (event->modifiers & up_modifier) { @@ -5999,7 +6009,7 @@ if (! FRAME_LIVE_P (f)) return Qnil; - position = make_lispy_position (f, event->x, event->y, + position = make_lispy_position (f, &event->x, &event->y, event->timestamp); head = modify_event_symbol (0, event->modifiers, @@ -6082,8 +6092,8 @@ start_pos_ptr = &AREF (button_down_location, button); start_pos = *start_pos_ptr; - position = make_lispy_position (f, event->x, event->y, - event->timestamp); + position = make_lispy_position (f, &event->x, &event->y, + event->timestamp); if (event->modifiers & down_modifier) *start_pos_ptr = Fcopy_alist (position); @@ -6142,19 +6152,25 @@ part_sym = *scroll_bar_parts[(int) part]; return Fcons (Qscroll_bar_movement, - Fcons (list5 (bar_window, - Qvertical_scroll_bar, - Fcons (x, y), - make_number (time), - part_sym), - Qnil)); + (Fcons (Fcons (bar_window, + Fcons (Qvertical_scroll_bar, + Fcons (Fcons (x, y), + Fcons (make_number (time), + Fcons (part_sym, + Qnil))))), + Qnil))); } + /* Or is it an ordinary mouse movement? */ else { Lisp_Object position; - position = make_lispy_position (frame, x, y, time); - return list2 (Qmouse_movement, position); + + position = make_lispy_position (frame, &x, &y, time); + + return Fcons (Qmouse_movement, + Fcons (position, + Qnil)); } } @@ -11311,7 +11327,7 @@ CHECK_LIVE_FRAME (frame_or_window); - return make_lispy_position (XFRAME (frame_or_window), x, y, 0); + return make_lispy_position (XFRAME (frame_or_window), &x, &y, 0); } DEFUN ("posn-at-point", Fposn_at_point, Sposn_at_point, 0, 2, 0, === modified file 'src/msdos.c' --- src/msdos.c 2010-11-16 19:59:24 +0000 +++ src/msdos.c 2010-11-16 21:47:43 +0000 @@ -2698,7 +2698,7 @@ mouse_window = window_from_coordinates (SELECTED_FRAME(), mouse_last_x, mouse_last_y, - 0, 0); + 0, 0, 0, 0); /* A window will be selected only when it is not selected now, and the last mouse movement event was not in it. A minibuffer window will be selected iff === modified file 'src/w32term.c' --- src/w32term.c 2010-11-16 19:59:24 +0000 +++ src/w32term.c 2010-11-16 21:47:43 +0000 @@ -4317,7 +4317,7 @@ int x = LOWORD (msg.msg.lParam); int y = HIWORD (msg.msg.lParam); - window = window_from_coordinates (f, x, y, 0, 0); + window = window_from_coordinates (f, x, y, 0, 0, 0, 0); /* Window will be selected only when it is not selected now and last mouse movement event was @@ -4396,7 +4396,7 @@ int x = XFASTINT (inev.x); int y = XFASTINT (inev.y); - window = window_from_coordinates (f, x, y, 0, 1); + window = window_from_coordinates (f, x, y, 0, 0, 0, 1); if (EQ (window, f->tool_bar_window)) { === modified file 'src/window.c' --- src/window.c 2010-11-16 19:59:24 +0000 +++ src/window.c 2010-11-16 21:47:43 +0000 @@ -755,26 +755,32 @@ - WINDOW_MODE_LINE_HEIGHT (w) + add_y)); } -/* Test if the character at column X, row Y is within window W. +/* Test if the character at column *X, row *Y is within window W. If it is not, return ON_NOTHING; - if it is in the window's text area, return ON_TEXT; + if it is in the window's text area, + set *x and *y to its location relative to the upper left corner + of the window, and + return ON_TEXT; if it is on the window's modeline, return ON_MODE_LINE; if it is on the border between the window and its right sibling, return ON_VERTICAL_BORDER. - if it is on a scroll bar, return ON_SCROLL_BAR. + if it is on a scroll bar, + return ON_SCROLL_BAR. if it is on the window's top line, return ON_HEADER_LINE; if it is in left or right fringe of the window, - return ON_LEFT_FRINGE or ON_RIGHT_FRINGE; + return ON_LEFT_FRINGE or ON_RIGHT_FRINGE, and convert *X and *Y + to window-relative coordinates; if it is in the marginal area to the left/right of the window, - return ON_LEFT_MARGIN or ON_RIGHT_MARGIN. + return ON_LEFT_MARGIN or ON_RIGHT_MARGIN, and convert *X and *Y + to window-relative coordinates. X and Y are frame relative pixel coordinates. */ static enum window_part -coordinates_in_window (register struct window *w, int x, int y) +coordinates_in_window (register struct window *w, register int *x, register int *y) { struct frame *f = XFRAME (WINDOW_FRAME (w)); - int left_x, right_x; + int left_x, right_x, top_y, bottom_y; enum window_part part; int ux = FRAME_COLUMN_WIDTH (f); int x0 = WINDOW_LEFT_EDGE_X (w); @@ -783,12 +789,6 @@ (Between mode lines for instance. */ int grabbable_width = ux; int lmargin_width, rmargin_width, text_left, text_right; - int top_y = WINDOW_TOP_EDGE_Y (w); - int bottom_y = WINDOW_BOTTOM_EDGE_Y (w); - - /* Outside any interesting row? */ - if (y < top_y || y >= bottom_y) - return ON_NOTHING; /* In what's below, we subtract 1 when computing right_x because we want the rightmost pixel, which is given by left_pixel+width-1. */ @@ -796,13 +796,21 @@ { left_x = 0; right_x = WINDOW_TOTAL_WIDTH (w) - 1; + top_y = WINDOW_TOP_EDGE_Y (w); + bottom_y = WINDOW_BOTTOM_EDGE_Y (w); } else { left_x = WINDOW_BOX_LEFT_EDGE_X (w); right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1; + top_y = WINDOW_TOP_EDGE_Y (w); + bottom_y = WINDOW_BOTTOM_EDGE_Y (w); } + /* Outside any interesting row? */ + if (*y < top_y || *y >= bottom_y) + return ON_NOTHING; + /* On the mode line or header line? If it's near the start of the mode or header line of window that's has a horizontal sibling, say it's on the vertical line. That's to be able @@ -810,7 +818,7 @@ scroll bars. */ if (WINDOW_WANTS_MODELINE_P (w) - && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) + && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) { part = ON_MODE_LINE; @@ -819,37 +827,60 @@ between mode lines of horizontally adjacent mode lines as the vertical border. If scroll bars on the left, return the right window. */ - if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) - || WINDOW_RIGHTMOST_P (w)) - && !WINDOW_LEFTMOST_P (w) - && eabs (x - x0) < grabbable_width) - return ON_VERTICAL_BORDER; - - /* Make sure we're not at the rightmost position of a - mode-/header-line and there's yet another window on the - right. (Bug#1372) */ - else if ((WINDOW_RIGHTMOST_P (w) || x < x1) - && eabs (x - x1) < grabbable_width) - return ON_VERTICAL_BORDER; - - if (x < x0 || x >= x1) + if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) + || WINDOW_RIGHTMOST_P (w)) + { + if (!WINDOW_LEFTMOST_P (w) && eabs (*x - x0) < grabbable_width) + { + /* Convert X and Y to window relative coordinates. + Vertical border is at the left edge of window. */ + *x = max (0, *x - x0); + *y -= top_y; + return ON_VERTICAL_BORDER; + } + } + else + { + /* Make sure we're not at the rightmost position of a + mode-/header-line and there's yet another window on + the right. (Bug#1372) */ + if ((WINDOW_RIGHTMOST_P (w) || *x < x1) + && eabs (*x - x1) < grabbable_width) + { + /* Convert X and Y to window relative coordinates. + Vertical border is at the right edge of window. */ + *x = min (x1, *x) - x0; + *y -= top_y; + return ON_VERTICAL_BORDER; + } + } + + if (*x < x0 || *x >= x1) return ON_NOTHING; + /* Convert X and Y to window relative coordinates. + Mode line starts at left edge of window. */ + *x -= x0; + *y -= top_y; return part; } if (WINDOW_WANTS_HEADER_LINE_P (w) - && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) + && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) { part = ON_HEADER_LINE; goto header_vertical_border_check; } - if (x < x0 || x >= x1) return ON_NOTHING; + if (*x < x0 || *x >= x1) + return ON_NOTHING; /* Outside any interesting column? */ - if (x < left_x || x > right_x) - return ON_SCROLL_BAR; + if (*x < left_x || *x > right_x) + { + *y -= top_y; + return ON_SCROLL_BAR; + } lmargin_width = window_box_width (w, LEFT_MARGIN_AREA); rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA); @@ -862,79 +893,77 @@ if (!w->pseudo_window_p && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w) && !WINDOW_RIGHTMOST_P (w) - && (eabs (x - right_x) < grabbable_width)) - return ON_VERTICAL_BORDER; - } - /* Need to say "x > right_x" rather than >=, since on character - terminals, the vertical line's x coordinate is right_x. */ - else if (!w->pseudo_window_p - && !WINDOW_RIGHTMOST_P (w) - && x > right_x - ux) - return ON_VERTICAL_BORDER; + && (eabs (*x - right_x) < grabbable_width)) + { + /* Convert X and Y to window relative coordinates. + Vertical border is at the right edge of window. */ + *x = min (right_x, *x) - left_x; + *y -= top_y; + return ON_VERTICAL_BORDER; + } + } + else + { + /* Need to say "*x > right_x" rather than >=, since on character + terminals, the vertical line's x coordinate is right_x. */ + if (!w->pseudo_window_p + && !WINDOW_RIGHTMOST_P (w) + && *x > right_x - ux) + { + /* On the border on the right side of the window? Assume that + this area begins at RIGHT_X minus a canonical char width. */ + *x = min (right_x, *x) - left_x; + *y -= top_y; + return ON_VERTICAL_BORDER; + } + } - if (x < text_left) + if (*x < text_left) { if (lmargin_width > 0 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? (x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w)) - : (x < left_x + lmargin_width))) - return ON_LEFT_MARGIN; + ? (*x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w)) + : (*x < left_x + lmargin_width))) + { + *x -= left_x; + if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) + *x -= WINDOW_LEFT_FRINGE_WIDTH (w); + *y -= top_y; + return ON_LEFT_MARGIN; + } + /* Convert X and Y to window-relative pixel coordinates. */ + *x -= left_x; + *y -= top_y; return ON_LEFT_FRINGE; } - if (x >= text_right) + if (*x >= text_right) { if (rmargin_width > 0 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? (x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w)) - : (x >= right_x - rmargin_width))) - return ON_RIGHT_MARGIN; + ? (*x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w)) + : (*x >= right_x - rmargin_width))) + { + *x -= right_x - rmargin_width; + if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) + *x += WINDOW_RIGHT_FRINGE_WIDTH (w); + *y -= top_y; + return ON_RIGHT_MARGIN; + } + /* Convert X and Y to window-relative pixel coordinates. */ + *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w); + *y -= top_y; return ON_RIGHT_FRINGE; } /* Everything special ruled out - must be on text area */ + *x -= text_left; + *y -= top_y; return ON_TEXT; } -/* Take X is the frame-relative pixel x-coordinate, and return the - x-coordinate relative to part PART of window W. */ -int -window_relative_x_coord (struct window *w, enum window_part part, int x) -{ - int left_x = (w->pseudo_window_p) ? 0 : WINDOW_BOX_LEFT_EDGE_X (w); - - switch (part) - { - case ON_TEXT: - return x - window_box_left (w, TEXT_AREA); - - case ON_LEFT_FRINGE: - return x - left_x; - - case ON_RIGHT_FRINGE: - return x - left_x - WINDOW_LEFT_FRINGE_WIDTH (w); - - case ON_LEFT_MARGIN: - return (x - left_x - - ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) - ? WINDOW_LEFT_FRINGE_WIDTH (w) : 0)); - - case ON_RIGHT_MARGIN: - return (x + 1 - - ((w->pseudo_window_p) - ? WINDOW_TOTAL_WIDTH (w) - : WINDOW_BOX_RIGHT_EDGE_X (w)) - + window_box_width (w, RIGHT_MARGIN_AREA) - + ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) - ? WINDOW_RIGHT_FRINGE_WIDTH (w) : 0)); - } - - /* ON_SCROLL_BAR, ON_NOTHING, and ON_VERTICAL_BORDER: */ - return 0; -} - DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, Scoordinates_in_window_p, 2, 2, 0, @@ -971,16 +1000,14 @@ x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f); y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH (f); - switch (coordinates_in_window (w, x, y)) + switch (coordinates_in_window (w, &x, &y)) { case ON_NOTHING: return Qnil; case ON_TEXT: - /* Convert X and Y to window relative pixel coordinates, and - return the canonical char units. */ - x -= window_box_left (w, TEXT_AREA); - y -= WINDOW_TOP_EDGE_Y (w); + /* X and Y are now window relative pixel coordinates. Convert + them to canonical char units before returning them. */ return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f, x), FRAME_CANON_Y_FROM_PIXEL_Y (f, y)); @@ -1027,7 +1054,7 @@ struct check_window_data { Lisp_Object *window; - int x, y; + int *x, *y; enum window_part *part; }; @@ -1054,7 +1081,8 @@ return it as a Lisp_Object. If X, Y is on one of the window's special `window_part' elements, - set *PART to the id of that element. + set *PART to the id of that element, and return X and Y converted + to window relative coordinates in WX and WY. If there is no window under X, Y return nil and leave *PART unmodified. TOOL_BAR_P non-zero means detect tool-bar windows. @@ -1069,8 +1097,7 @@ case. */ Lisp_Object -window_from_coordinates (struct frame *f, int x, int y, - enum window_part *part, int tool_bar_p) +window_from_coordinates (struct frame *f, int x, int y, enum window_part *part, int *wx, int *wy, int tool_bar_p) { Lisp_Object window; struct check_window_data cw; @@ -1080,7 +1107,7 @@ part = &dummy; window = Qnil; - cw.window = &window, cw.x = x, cw.y = y; cw.part = part; + cw.window = &window, cw.x = &x, cw.y = &y; cw.part = part; foreach_window (f, check_window_containing, &cw); /* If not found above, see if it's in the tool bar window, if a tool @@ -1089,13 +1116,16 @@ && tool_bar_p && WINDOWP (f->tool_bar_window) && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0 - && (coordinates_in_window (XWINDOW (f->tool_bar_window), x, y) + && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y) != ON_NOTHING)) { *part = ON_TEXT; window = f->tool_bar_window; } + if (wx) *wx = x; + if (wy) *wy = y; + return window; } @@ -1122,7 +1152,7 @@ + FRAME_INTERNAL_BORDER_WIDTH (f)), (FRAME_PIXEL_Y_FROM_CANON_Y (f, y) + FRAME_INTERNAL_BORDER_WIDTH (f)), - 0, 0); + 0, 0, 0, 0); } DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, === modified file 'src/window.h' --- src/window.h 2010-11-16 19:59:24 +0000 +++ src/window.h 2010-11-16 21:47:43 +0000 @@ -788,7 +788,8 @@ extern Lisp_Object make_window (void); extern void delete_window (Lisp_Object); extern Lisp_Object window_from_coordinates (struct frame *, int, int, - enum window_part *, int); + enum window_part *, + int *, int*, int); EXFUN (Fwindow_dedicated_p, 1); extern int window_height (Lisp_Object); extern int window_width (Lisp_Object); @@ -803,7 +804,6 @@ void *); extern void grow_mini_window (struct window *, int); extern void shrink_mini_window (struct window *); -extern int window_relative_x_coord (struct window *, enum window_part, int); void run_window_configuration_change_hook (struct frame *f); === modified file 'src/xdisp.c' --- src/xdisp.c 2010-11-16 19:59:24 +0000 +++ src/xdisp.c 2010-11-16 21:47:43 +0000 @@ -2218,7 +2218,7 @@ frame pixel coordinates X/Y on frame F. */ if (!f->glyphs_initialized_p - || (window = window_from_coordinates (f, gx, gy, &part, 0), + || (window = window_from_coordinates (f, gx, gy, &part, &x, &y, 0), NILP (window))) { width = FRAME_SMALLEST_CHAR_WIDTH (f); @@ -2230,9 +2230,6 @@ width = WINDOW_FRAME_COLUMN_WIDTH (w); height = WINDOW_FRAME_LINE_HEIGHT (w); - x = window_relative_x_coord (w, part, gx); - y = gy - WINDOW_TOP_EDGE_Y (w); - r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w); @@ -25386,7 +25383,7 @@ } /* Which window is that in? */ - window = window_from_coordinates (f, x, y, &part, 1); + window = window_from_coordinates (f, x, y, &part, 0, 0, 1); /* If we were displaying active text in another window, clear that. Also clear if we move out of text area in same window. */ === modified file 'src/xterm.c' --- src/xterm.c 2010-11-16 19:59:24 +0000 +++ src/xterm.c 2010-11-16 21:47:43 +0000 @@ -6658,7 +6658,7 @@ window = window_from_coordinates (f, event.xmotion.x, event.xmotion.y, - 0, 0); + 0, 0, 0, 0); /* Window will be selected only when it is not selected now and last mouse movement event was not in it. Minibuffer window @@ -6797,7 +6797,7 @@ int x = event.xbutton.x; int y = event.xbutton.y; - window = window_from_coordinates (f, x, y, 0, 1); + window = window_from_coordinates (f, x, y, 0, 0, 0, 1); tool_bar_p = EQ (window, f->tool_bar_window); if (tool_bar_p && event.xbutton.button < 4) ------------------------------------------------------------ revno: 102410 committer: Chong Yidong branch nick: trunk timestamp: Tue 2010-11-16 16:38:37 -0500 message: * src/keyboard.c (make_lispy_position): Fix pixel calculation error in last commit. diff: === modified file 'src/keyboard.c' --- src/keyboard.c 2010-11-16 19:59:24 +0000 +++ src/keyboard.c 2010-11-16 21:38:37 +0000 @@ -5280,7 +5280,7 @@ buffer_posn_from_coords. */ if (part == ON_TEXT) { - xret = wx - window_box_left (w, TEXT_AREA); + xret = XINT (x) - window_box_left (w, TEXT_AREA); yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } /* For mode line and header line clicks, return X relative to ------------------------------------------------------------ revno: 102409 committer: Stefan Monnier branch nick: trunk timestamp: Tue 2010-11-16 16:19:34 -0500 message: * lisp/progmodes/octave-mod.el: Rely on elecric-*-modes. (octave-mode-map): Don't bind ;, SPC, and LF. (octave-auto-indent, octave-auto-newline): Remove. (electric-layout-rules): Declare. (octave-mode): Set electric-layout-rules. (octave-indent-new-comment-line): Use reindent-then-newline-and-indent. (octave-reindent-then-newline-and-indent, octave-electric-semi) (octave-electric-space): Remove. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-11-16 21:14:46 +0000 +++ lisp/ChangeLog 2010-11-16 21:19:34 +0000 @@ -1,5 +1,14 @@ 2010-11-16 Stefan Monnier + * progmodes/octave-mod.el: Rely on elecric-*-modes. + (octave-mode-map): Don't bind ;, SPC, and LF. + (octave-auto-indent, octave-auto-newline): Remove. + (electric-layout-rules): Declare. + (octave-mode): Set electric-layout-rules. + (octave-indent-new-comment-line): Use reindent-then-newline-and-indent. + (octave-reindent-then-newline-and-indent, octave-electric-semi) + (octave-electric-space): Remove. + * electric.el (electric-layout-mode): New minor mode. (electric--after-char-pos): New function. (electric-indent-post-self-insert-function): Use it. === modified file 'lisp/progmodes/octave-mod.el' --- lisp/progmodes/octave-mod.el 2010-11-10 08:21:06 +0000 +++ lisp/progmodes/octave-mod.el 2010-11-16 21:19:34 +0000 @@ -212,9 +212,6 @@ (defvar octave-mode-map (let ((map (make-sparse-keymap))) (define-key map "`" 'octave-abbrev-start) - (define-key map ";" 'octave-electric-semi) - (define-key map " " 'octave-electric-space) - (define-key map "\n" 'octave-reindent-then-newline-and-indent) (define-key map "\e\n" 'octave-indent-new-comment-line) (define-key map "\M-\C-q" 'octave-indent-defun) (define-key map "\C-c\C-b" 'octave-submit-bug-report) @@ -319,16 +316,6 @@ table) "Syntax table in use in `octave-mode' buffers.") -(defcustom octave-auto-indent nil - "Non-nil means indent line after a semicolon or space in Octave mode." - :type 'boolean - :group 'octave) - -(defcustom octave-auto-newline nil - "Non-nil means automatically newline after a semicolon in Octave mode." - :type 'boolean - :group 'octave) - (defcustom octave-blink-matching-block t "Control the blinking of matching Octave block keywords. Non-nil means show matching begin of block when inserting a space, @@ -536,7 +523,7 @@ ;; (if (smie-parent-p "switch") 4) 0)))) -(defvar electric-indent-chars) +(defvar electric-layout-rules) ;;;###autoload (define-derived-mode octave-mode prog-mode "Octave" @@ -567,14 +554,6 @@ Variables you can use to customize Octave mode ============================================== -`octave-auto-indent' - Non-nil means indent current line after a semicolon or space. - Default is nil. - -`octave-auto-newline' - Non-nil means auto-insert a newline and indent after a semicolon. - Default is nil. - `octave-blink-matching-block' Non-nil means show matching begin of block when inserting a space, newline or semicolon after an else or end keyword. Default is t. @@ -636,6 +615,9 @@ (set (make-local-variable 'electric-indent-chars) (cons ?\; electric-indent-chars)) + ;; IIUC matlab-mode takes the opposite approach: it makes RET insert + ;; a ";" at those places where it's correct (i.e. outside of parens). + (set (make-local-variable 'electric-layout-rules) '((?\; . after))) (set (make-local-variable 'comment-start) octave-comment-start) (set (make-local-variable 'comment-end) "") @@ -736,7 +718,7 @@ (error "Cannot split a code line inside a string")) (t (insert (concat " " octave-continuation-string)) - (octave-reindent-then-newline-and-indent)))) + (reindent-then-newline-and-indent)))) (defun octave-indent-defun () "Properly indent the Octave function which contains point." @@ -1017,45 +999,6 @@ (apply 'completion-in-region (octave-completion-at-point-function))) ;;; Electric characters && friends -(defun octave-reindent-then-newline-and-indent () - "Reindent current Octave line, insert newline, and indent the new line. -If Abbrev mode is on, expand abbrevs first." - ;; FIXME: None of this is Octave-specific. - (interactive) - (reindent-then-newline-and-indent)) - -(defun octave-electric-semi () - "Insert a semicolon in Octave mode. -Maybe expand abbrevs and blink matching block open keywords. -Reindent the line if `octave-auto-indent' is non-nil. -Insert a newline if `octave-auto-newline' is non-nil." - (interactive) - (setq last-command-event ?\;) - (if (not (octave-not-in-string-or-comment-p)) - (self-insert-command 1) - (if octave-auto-indent - (indent-according-to-mode)) - (self-insert-command 1) - (if octave-auto-newline - (newline-and-indent)))) - -(defun octave-electric-space () - "Insert a space in Octave mode. -Maybe expand abbrevs and blink matching block open keywords. -Reindent the line if `octave-auto-indent' is non-nil." - (interactive) - (setq last-command-event ? ) - (if (and octave-auto-indent - (not (octave-not-in-string-or-comment-p))) - (progn - (indent-according-to-mode) - (self-insert-command 1)) - (if (and octave-auto-indent - (save-excursion - (skip-syntax-backward " ") - (not (bolp)))) - (indent-according-to-mode)) - (self-insert-command 1))) (defun octave-abbrev-start () "Start entering an Octave abbreviation. @@ -1213,8 +1156,6 @@ octave-maintainer-address (concat "Emacs version " emacs-version) (list - 'octave-auto-indent - 'octave-auto-newline 'octave-blink-matching-block 'octave-block-offset 'octave-comment-char ------------------------------------------------------------ revno: 102408 committer: Stefan Monnier branch nick: trunk timestamp: Tue 2010-11-16 16:14:46 -0500 message: * lisp/electric.el (electric-layout-mode): New minor mode. (electric--after-char-pos): New function. (electric-indent-post-self-insert-function): Use it. (electric-layout-rules): New var. (electric-layout-post-self-insert-function): New function. (electric-indent-mode): Make them interact better. diff: === modified file 'etc/NEWS' --- etc/NEWS 2010-11-16 19:59:24 +0000 +++ etc/NEWS 2010-11-16 21:14:46 +0000 @@ -543,7 +543,8 @@ * New Modes and Packages in Emacs 24.1 -** New global minor modes electric-pair-mode and electric-indent-mode. +** New global minor modes electric-pair-mode, electric-indent-mode, +and electric-layout-mode. ** pcase.el provides the ML-style pattern matching macro `pcase'. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-11-15 21:40:30 +0000 +++ lisp/ChangeLog 2010-11-16 21:14:46 +0000 @@ -1,3 +1,12 @@ +2010-11-16 Stefan Monnier + + * electric.el (electric-layout-mode): New minor mode. + (electric--after-char-pos): New function. + (electric-indent-post-self-insert-function): Use it. + (electric-layout-rules): New var. + (electric-layout-post-self-insert-function): New function. + (electric-indent-mode): Make them interact better. + 2010-11-15 Stefan Monnier * emacs-lisp/checkdoc.el (checkdoc-syntax-table): Fix last change. === modified file 'lisp/electric.el' --- lisp/electric.el 2010-10-27 14:26:01 +0000 +++ lisp/electric.el 2010-11-16 21:14:46 +0000 @@ -176,6 +176,20 @@ "Electric behavior for self inserting keys." :group 'editing) +(defun electric--after-char-pos () + "Return the position after the char we just inserted. +Returns nil when we can't find this char." + (let ((pos (point))) + (when (or (eq (char-before) last-command-event) ;; Sanity check. + (save-excursion + (or (progn (skip-chars-backward " \t") + (setq pos (point)) + (eq (char-before) last-command-event)) + (progn (skip-chars-backward " \n\t") + (setq pos (point)) + (eq (char-before) last-command-event))))) + pos))) + ;; Electric indentation. ;; Autoloading variables is generally undesirable, but major modes @@ -193,35 +207,35 @@ ;; electric-pair-mode wrapping a region with a pair of parens. ;; There might be a way to get it working by analyzing buffer-undo-list, but ;; it looks challenging. - (when (and (memq last-command-event electric-indent-chars) - ;; Don't reindent while inserting spaces at beginning of line. - (or (not (memq last-command-event '(?\s ?\t))) - (save-excursion (skip-chars-backward " \t") (not (bolp)))) - ;; Not in a string or comment. - (not (nth 8 (syntax-ppss)))) - ;; For newline, we want to reindent both lines and basically behave like - ;; reindent-then-newline-and-indent (whose code we hence copied). - (when (and (eq last-command-event ?\n) - ;; Don't reindent the previous line if the indentation function - ;; is not a real one. - (not (memq indent-line-function - '(indent-relative indent-relative-maybe))) - ;; Sanity check. - (eq (char-before) last-command-event)) - (let ((pos (copy-marker (1- (point)) t))) - (save-excursion - (goto-char pos) - (indent-according-to-mode) - ;; We are at EOL before the call to indent-according-to-mode, and - ;; after it we usually are as well, but not always. We tried to - ;; address it with `save-excursion' but that uses a normal marker - ;; whereas we need `move after insertion', so we do the - ;; save/restore by hand. - (goto-char pos) - ;; Remove the trailing whitespace after indentation because - ;; indentation may (re)introduce the whitespace. - (delete-horizontal-space t)))) - (indent-according-to-mode))) + (let (pos) + (when (and (memq last-command-event electric-indent-chars) + ;; Don't reindent while inserting spaces at beginning of line. + (or (not (memq last-command-event '(?\s ?\t))) + (save-excursion (skip-chars-backward " \t") (not (bolp)))) + (setq pos (electric--after-char-pos)) + ;; Not in a string or comment. + (not (nth 8 (save-excursion (syntax-ppss pos))))) + ;; For newline, we want to reindent both lines and basically behave like + ;; reindent-then-newline-and-indent (whose code we hence copied). + (when (and (< (1- pos) (line-beginning-position)) + ;; Don't reindent the previous line if the indentation + ;; function is not a real one. + (not (memq indent-line-function + '(indent-relative indent-relative-maybe)))) + (let ((before (copy-marker (1- pos) t))) + (save-excursion + (goto-char before) + (indent-according-to-mode) + ;; We are at EOL before the call to indent-according-to-mode, and + ;; after it we usually are as well, but not always. We tried to + ;; address it with `save-excursion' but that uses a normal marker + ;; whereas we need `move after insertion', so we do the + ;; save/restore by hand. + (goto-char before) + ;; Remove the trailing whitespace after indentation because + ;; indentation may (re)introduce the whitespace. + (delete-horizontal-space t)))) + (indent-according-to-mode)))) ;;;###autoload (define-minor-mode electric-indent-mode @@ -233,7 +247,17 @@ (add-hook 'post-self-insert-hook #'electric-indent-post-self-insert-function) (remove-hook 'post-self-insert-hook - #'electric-indent-post-self-insert-function))) + #'electric-indent-post-self-insert-function)) + ;; FIXME: electric-indent-mode and electric-layout-mode interact + ;; in non-trivial ways. It turns out that electric-indent-mode works + ;; better if it is run *after* electric-layout-mode's hook. + (when (memq #'electric-layout-post-self-insert-function + (memq #'electric-indent-post-self-insert-function + (default-value 'post-self-insert-hook))) + (remove-hook 'post-self-insert-hook + #'electric-layout-post-self-insert-function) + (add-hook 'post-self-insert-hook + #'electric-layout-post-self-insert-function))) ;; Electric pairing. @@ -302,7 +326,48 @@ #'electric-pair-post-self-insert-function) (remove-hook 'post-self-insert-hook #'electric-pair-post-self-insert-function))) - + +;; Automatically add newlines after/before/around some chars. + +(defvar electric-layout-rules '() + "List of rules saying where to automatically insert newlines. +Each rule has the form (CHAR . WHERE) where CHAR is the char +that was just inserted and WHERE specifies where to insert newlines +and can be: nil, `before', `after', `around', or a function that returns +one of those symbols.") + +(defun electric-layout-post-self-insert-function () + (let* ((rule (cdr (assq last-command-event electric-layout-rules))) + pos) + (when (and rule + (setq pos (electric--after-char-pos)) + ;; Not in a string or comment. + (not (nth 8 (save-excursion (syntax-ppss pos))))) + (let ((end (copy-marker (point) t))) + (goto-char pos) + (case (if (functionp rule) (funcall rule) rule) + ;; FIXME: we used `newline' down here which called + ;; self-insert-command and ran post-self-insert-hook recursively. + ;; It happened to make electric-indent-mode work automatically with + ;; electric-layout-mode (at the cost of re-indenting lines + ;; multiple times), but I'm not sure it's what we want. + (before (goto-char (1- pos)) (insert "\n")) + (after (insert "\n")) + (around (goto-char (1- pos)) (insert "\n") + (forward-char 1) (insert "\n"))) + (goto-char end))))) + +;;;###autoload +(define-minor-mode electric-layout-mode + "Automatically insert newlines around some chars." + :global t + :group 'electricity + (if electric-layout-mode + (add-hook 'post-self-insert-hook + #'electric-layout-post-self-insert-function) + (remove-hook 'post-self-insert-hook + #'electric-layout-post-self-insert-function))) + (provide 'electric) ;; arch-tag: dae045eb-dc2d-4fb7-9f27-9cc2ce277be8 ------------------------------------------------------------ revno: 102407 committer: Chong Yidong branch nick: trunk timestamp: Tue 2010-11-16 14:59:24 -0500 message: Cleanup of window coordinate positioning code. Now, text area click input events measure Y from the top of the text area, excluding the header line if any. * src/dispnew.c (buffer_posn_from_coords): Assume that X counts from the start of the text area. * src/keyboard.c (make_lispy_position): For text area clicks, record Y pixel position relative to the text area, excluding header line. Also change X and Y to Lisp_Objects, not pointers; don't return coordinate values via pointers. Pass ON_TEXT_AREA coordinate to buffer_posn_from_coords counting from the start of the text area. (Fposn_at_x_y, make_lispy_event): Callers changed. * src/w32term.c (w32_read_socket): * src/msdos.c (dos_rawgetc): * src/xterm.c (handle_one_xevent): Likewise. * src/window.c (coordinates_in_window): Change X and Y to ints rather than pointers; don't return coordinates via pointers. (struct check_window_data): Change X and Y from pointers to ints. (window_from_coordinates): Remove args WX and WY; don't return coordinates via pointers. (Fcoordinates_in_window_p, window_from_coordinates): (check_window_containing, Fwindow_at): Callers changed. (window_relative_x_coord): New function. * src/window.h (window_from_coordinates, window_relative_x_coord): Update prototypes. * src/xdisp.c (remember_mouse_glyph): Change window_from_coordinates call. Use window_relative_x_coord. (note_mouse_highlight): Change window_from_coordinates call. diff: === modified file 'etc/NEWS' --- etc/NEWS 2010-11-13 13:29:31 +0000 +++ etc/NEWS 2010-11-16 19:59:24 +0000 @@ -559,6 +559,11 @@ * Incompatible Lisp Changes in Emacs 24.1 +** For mouse click input events in the text area, the Y pixel +coordinate in the POSITION list now counts from the top of the text +area, excluding any header line. Previously, it counted from the top +of the header line. + ** Remove obsolete name `e' (use `float-e' instead). ** A backquote not followed by a space is now always treated as new-style. === modified file 'src/ChangeLog' --- src/ChangeLog 2010-11-16 06:44:51 +0000 +++ src/ChangeLog 2010-11-16 19:59:24 +0000 @@ -1,3 +1,35 @@ +2010-11-16 Chong Yidong + + * keyboard.c (make_lispy_position): For text area clicks, record Y + pixel position relative to the text area, excluding header line. + Also change X and Y to Lisp_Objects, not pointers; don't return + coordinate values via pointers. Pass ON_TEXT_AREA coordinate to + buffer_posn_from_coords counting from the start of the text area. + (Fposn_at_x_y, make_lispy_event): Callers changed. + + * window.c (coordinates_in_window): Change X and Y to ints rather + than pointers; don't return coordinates via pointers. + (struct check_window_data): Change X and Y from pointers to ints. + (window_from_coordinates): Remove args WX and WY; don't return + coordinates via pointers. + (Fcoordinates_in_window_p, window_from_coordinates): + (check_window_containing, Fwindow_at): Callers changed. + (window_relative_x_coord): New function. + + * window.h (window_from_coordinates, window_relative_x_coord): + Update prototypes. + + * dispnew.c (buffer_posn_from_coords): Assume that X counts from + the start of the text area. + + * xdisp.c (remember_mouse_glyph): Change window_from_coordinates + call. Use window_relative_x_coord. + (note_mouse_highlight): Change window_from_coordinates call. + + * w32term.c (w32_read_socket): + * msdos.c (dos_rawgetc): + * xterm.c (handle_one_xevent): Likewise. + 2010-11-16 Dan Nicolaescu * strftime.c (LOCALE_PARAM_DECL): Update for standard C. === modified file 'src/dispnew.c' --- src/dispnew.c 2010-11-05 12:11:22 +0000 +++ src/dispnew.c 2010-11-16 19:59:24 +0000 @@ -5393,7 +5393,7 @@ BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp))); start_display (&it, w, startp); - x0 = *x - WINDOW_LEFT_MARGIN_WIDTH (w); + x0 = *x; /* First, move to the beginning of the row corresponding to *Y. We need to be in that row to get the correct value of base paragraph === modified file 'src/keyboard.c' --- src/keyboard.c 2010-11-15 06:18:50 +0000 +++ src/keyboard.c 2010-11-16 19:59:24 +0000 @@ -5243,24 +5243,22 @@ int double_click_count; -/* Return position of a mouse click or wheel event */ +/* X and Y are frame-relative coordinates for a click or wheel event. + Return a Lisp-style event list. */ static Lisp_Object -make_lispy_position (struct frame *f, Lisp_Object *x, Lisp_Object *y, +make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y, unsigned long time) { - Lisp_Object window; enum window_part part; Lisp_Object posn = Qnil; Lisp_Object extra_info = Qnil; - int wx, wy; - - /* Set `window' to the window under frame pixel coordinates (x,y) */ - if (f) - window = window_from_coordinates (f, XINT (*x), XINT (*y), - &part, &wx, &wy, 0); - else - window = Qnil; + /* Coordinate pixel positions to return. */ + int xret = 0, yret = 0; + /* The window under frame pixel coordinates (x,y) */ + Lisp_Object window = f + ? window_from_coordinates (f, XINT (x), XINT (y), &part, 0) + : Qnil; if (WINDOWP (window)) { @@ -5268,102 +5266,113 @@ struct window *w = XWINDOW (window); Lisp_Object string_info = Qnil; EMACS_INT textpos = -1; - int rx = -1, ry = -1; - int dx = -1, dy = -1; + int col = -1, row = -1; + int dx = -1, dy = -1; int width = -1, height = -1; Lisp_Object object = Qnil; - /* Set event coordinates to window-relative coordinates - for constructing the Lisp event below. */ - XSETINT (*x, wx); - XSETINT (*y, wy); + /* Pixel coordinates relative to the window corner. */ + int wx = XINT (x) - WINDOW_LEFT_EDGE_X (w); + int wy = XINT (y) - WINDOW_TOP_EDGE_Y (w); + /* For text area clicks, return X, Y relative to the corner of + this text area. Note that dX, dY etc are set below, by + buffer_posn_from_coords. */ if (part == ON_TEXT) { - wx += WINDOW_LEFT_MARGIN_WIDTH (w); + xret = wx - window_box_left (w, TEXT_AREA); + yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } + /* For mode line and header line clicks, return X relative to + the left window edge; ignore Y. Use mode_line_string to look + for a string on the click position. */ else if (part == ON_MODE_LINE || part == ON_HEADER_LINE) { - /* Mode line or header line. Look for a string under - the mouse that may have a `local-map' property. */ Lisp_Object string; EMACS_INT charpos; - posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; - rx = wx, ry = wy; - string = mode_line_string (w, part, &rx, &ry, &charpos, + posn = (part == ON_MODE_LINE) ? Qmode_line : Qheader_line; + /* Note that mode_line_string takes COL, ROW as pixels and + converts them to characters. */ + col = wx; + row = wy; + string = mode_line_string (w, part, &col, &row, &charpos, &object, &dx, &dy, &width, &height); if (STRINGP (string)) string_info = Fcons (string, make_number (charpos)); - if (w == XWINDOW (selected_window) - && current_buffer == XBUFFER (w->buffer)) - textpos = PT; - else - textpos = XMARKER (w->pointm)->charpos; - } - else if (part == ON_VERTICAL_BORDER) - { - posn = Qvertical_line; - wx = -1; - dx = 0; - width = 1; - } + textpos = (w == XWINDOW (selected_window) + && current_buffer == XBUFFER (w->buffer)) + ? PT : XMARKER (w->pointm)->charpos; + + xret = wx; + } + /* For fringes and margins, Y is relative to the area's (and the + window's) top edge, while X is meaningless. */ else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) { Lisp_Object string; EMACS_INT charpos; posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; - rx = wx, ry = wy; - string = marginal_area_string (w, part, &rx, &ry, &charpos, + col = wx; + row = wy; + string = marginal_area_string (w, part, &col, &row, &charpos, &object, &dx, &dy, &width, &height); if (STRINGP (string)) string_info = Fcons (string, make_number (charpos)); - if (part == ON_LEFT_MARGIN) - wx = 0; - else - wx = window_box_right_offset (w, TEXT_AREA) - 1; + yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } else if (part == ON_LEFT_FRINGE) { posn = Qleft_fringe; - rx = 0; - dx = wx; - wx = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? 0 - : window_box_width (w, LEFT_MARGIN_AREA)); - dx -= wx; + col = 0; + dx = wx + - (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) + ? 0 : window_box_width (w, LEFT_MARGIN_AREA)); + dy = yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } else if (part == ON_RIGHT_FRINGE) { posn = Qright_fringe; - rx = 0; - dx = wx; - wx = (window_box_width (w, LEFT_MARGIN_AREA) - + window_box_width (w, TEXT_AREA) - + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? window_box_width (w, RIGHT_MARGIN_AREA) - : 0)); - dx -= wx; + col = 0; + dx = wx + - window_box_width (w, LEFT_MARGIN_AREA) + - window_box_width (w, TEXT_AREA) + - (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) + ? window_box_width (w, RIGHT_MARGIN_AREA) + : 0); + dy = yret = wy - WINDOW_HEADER_LINE_HEIGHT (w); } - else + else if (part == ON_VERTICAL_BORDER) { - /* Note: We have no special posn for part == ON_SCROLL_BAR. */ - wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx); + posn = Qvertical_line; + width = 1; + dx = 0; + dy = yret = wy; } + /* Nothing special for part == ON_SCROLL_BAR. */ + /* For clicks in the text area, fringes, or margins, call + buffer_posn_from_coords to extract TEXTPOS, the buffer + position nearest to the click. */ if (textpos < 0) { Lisp_Object string2, object2 = Qnil; struct display_pos p; int dx2, dy2; int width2, height2; - string2 = buffer_posn_from_coords (w, &wx, &wy, &p, + /* The pixel X coordinate passed to buffer_posn_from_coords + is the X coordinate relative to the text area for + text-area clicks, zero otherwise. */ + int x2 = (part == ON_TEXT) ? xret : 0; + int y2 = wy; + + string2 = buffer_posn_from_coords (w, &x2, &y2, &p, &object2, &dx2, &dy2, &width2, &height2); textpos = CHARPOS (p.pos); - if (rx < 0) rx = wx; - if (ry < 0) ry = wy; + if (col < 0) col = x2; + if (row < 0) row = y2; if (dx < 0) dx = dx2; if (dy < 0) dy = dy2; if (width < 0) width = width2; @@ -5394,34 +5403,27 @@ #endif /* Object info */ - extra_info = Fcons (object, - Fcons (Fcons (make_number (dx), - make_number (dy)), - Fcons (Fcons (make_number (width), - make_number (height)), - Qnil))); + extra_info + = list3 (object, + Fcons (make_number (dx), make_number (dy)), + Fcons (make_number (width), make_number (height))); /* String info */ extra_info = Fcons (string_info, Fcons (make_number (textpos), - Fcons (Fcons (make_number (rx), - make_number (ry)), + Fcons (Fcons (make_number (col), + make_number (row)), extra_info))); } else if (f != 0) - { - XSETFRAME (window, f); - } + XSETFRAME (window, f); else - { - window = Qnil; - XSETFASTINT (*x, 0); - XSETFASTINT (*y, 0); - } + window = Qnil; return Fcons (window, Fcons (posn, - Fcons (Fcons (*x, *y), + Fcons (Fcons (make_number (xret), + make_number (yret)), Fcons (make_number (time), extra_info)))); } @@ -5610,14 +5612,6 @@ int hpos; int i; -#if 0 - /* Activate the menu bar on the down event. If the - up event comes in before the menu code can deal with it, - just ignore it. */ - if (! (event->modifiers & down_modifier)) - return Qnil; -#endif - /* Find the menu bar item under `column'. */ item = Qnil; items = FRAME_MENU_BAR_ITEMS (f); @@ -5649,7 +5643,7 @@ } #endif /* not USE_X_TOOLKIT && not USE_GTK && not HAVE_NS */ - position = make_lispy_position (f, &event->x, &event->y, + position = make_lispy_position (f, event->x, event->y, event->timestamp); } #ifndef USE_TOOLKIT_SCROLL_BARS @@ -5749,23 +5743,21 @@ return Qnil; event->modifiers &= ~up_modifier; -#if 0 /* Formerly we treated an up with no down as a click event. */ - if (!CONSP (start_pos)) - event->modifiers |= click_modifier; - else -#endif + { - Lisp_Object down; + Lisp_Object new_down, down; EMACS_INT xdiff = double_click_fuzz, ydiff = double_click_fuzz; /* The third element of every position should be the (x,y) pair. */ down = Fcar (Fcdr (Fcdr (start_pos))); + new_down = Fcar (Fcdr (Fcdr (position))); + if (CONSP (down) && INTEGERP (XCAR (down)) && INTEGERP (XCDR (down))) { - xdiff = XINT (event->x) - XINT (XCAR (down)); - ydiff = XINT (event->y) - XINT (XCDR (down)); + xdiff = XINT (XCAR (new_down)) - XINT (XCAR (down)); + ydiff = XINT (XCDR (new_down)) - XINT (XCDR (down)); } if (ignore_mouse_drag_p) @@ -5848,7 +5840,7 @@ if (! FRAME_LIVE_P (f)) return Qnil; - position = make_lispy_position (f, &event->x, &event->y, + position = make_lispy_position (f, event->x, event->y, event->timestamp); /* Set double or triple modifiers to indicate the wheel speed. */ @@ -5868,10 +5860,8 @@ else abort (); - if (FRAME_WINDOW_P (f)) - fuzz = double_click_fuzz; - else - fuzz = double_click_fuzz / 8; + fuzz = FRAME_WINDOW_P (f) + ? double_click_fuzz : double_click_fuzz / 8; if (event->modifiers & up_modifier) { @@ -6009,7 +5999,7 @@ if (! FRAME_LIVE_P (f)) return Qnil; - position = make_lispy_position (f, &event->x, &event->y, + position = make_lispy_position (f, event->x, event->y, event->timestamp); head = modify_event_symbol (0, event->modifiers, @@ -6092,8 +6082,8 @@ start_pos_ptr = &AREF (button_down_location, button); start_pos = *start_pos_ptr; - position = make_lispy_position (f, &event->x, &event->y, - event->timestamp); + position = make_lispy_position (f, event->x, event->y, + event->timestamp); if (event->modifiers & down_modifier) *start_pos_ptr = Fcopy_alist (position); @@ -6152,25 +6142,19 @@ part_sym = *scroll_bar_parts[(int) part]; return Fcons (Qscroll_bar_movement, - (Fcons (Fcons (bar_window, - Fcons (Qvertical_scroll_bar, - Fcons (Fcons (x, y), - Fcons (make_number (time), - Fcons (part_sym, - Qnil))))), - Qnil))); + Fcons (list5 (bar_window, + Qvertical_scroll_bar, + Fcons (x, y), + make_number (time), + part_sym), + Qnil)); } - /* Or is it an ordinary mouse movement? */ else { Lisp_Object position; - - position = make_lispy_position (frame, &x, &y, time); - - return Fcons (Qmouse_movement, - Fcons (position, - Qnil)); + position = make_lispy_position (frame, x, y, time); + return list2 (Qmouse_movement, position); } } @@ -11327,7 +11311,7 @@ CHECK_LIVE_FRAME (frame_or_window); - return make_lispy_position (XFRAME (frame_or_window), &x, &y, 0); + return make_lispy_position (XFRAME (frame_or_window), x, y, 0); } DEFUN ("posn-at-point", Fposn_at_point, Sposn_at_point, 0, 2, 0, === modified file 'src/msdos.c' --- src/msdos.c 2010-11-05 10:03:17 +0000 +++ src/msdos.c 2010-11-16 19:59:24 +0000 @@ -2698,7 +2698,7 @@ mouse_window = window_from_coordinates (SELECTED_FRAME(), mouse_last_x, mouse_last_y, - 0, 0, 0, 0); + 0, 0); /* A window will be selected only when it is not selected now, and the last mouse movement event was not in it. A minibuffer window will be selected iff === modified file 'src/w32term.c' --- src/w32term.c 2010-11-13 13:29:31 +0000 +++ src/w32term.c 2010-11-16 19:59:24 +0000 @@ -4317,7 +4317,7 @@ int x = LOWORD (msg.msg.lParam); int y = HIWORD (msg.msg.lParam); - window = window_from_coordinates (f, x, y, 0, 0, 0, 0); + window = window_from_coordinates (f, x, y, 0, 0); /* Window will be selected only when it is not selected now and last mouse movement event was @@ -4396,7 +4396,7 @@ int x = XFASTINT (inev.x); int y = XFASTINT (inev.y); - window = window_from_coordinates (f, x, y, 0, 0, 0, 1); + window = window_from_coordinates (f, x, y, 0, 1); if (EQ (window, f->tool_bar_window)) { === modified file 'src/window.c' --- src/window.c 2010-11-13 18:49:22 +0000 +++ src/window.c 2010-11-16 19:59:24 +0000 @@ -755,32 +755,26 @@ - WINDOW_MODE_LINE_HEIGHT (w) + add_y)); } -/* Test if the character at column *X, row *Y is within window W. +/* Test if the character at column X, row Y is within window W. If it is not, return ON_NOTHING; - if it is in the window's text area, - set *x and *y to its location relative to the upper left corner - of the window, and - return ON_TEXT; + if it is in the window's text area, return ON_TEXT; if it is on the window's modeline, return ON_MODE_LINE; if it is on the border between the window and its right sibling, return ON_VERTICAL_BORDER. - if it is on a scroll bar, - return ON_SCROLL_BAR. + if it is on a scroll bar, return ON_SCROLL_BAR. if it is on the window's top line, return ON_HEADER_LINE; if it is in left or right fringe of the window, - return ON_LEFT_FRINGE or ON_RIGHT_FRINGE, and convert *X and *Y - to window-relative coordinates; + return ON_LEFT_FRINGE or ON_RIGHT_FRINGE; if it is in the marginal area to the left/right of the window, - return ON_LEFT_MARGIN or ON_RIGHT_MARGIN, and convert *X and *Y - to window-relative coordinates. + return ON_LEFT_MARGIN or ON_RIGHT_MARGIN. X and Y are frame relative pixel coordinates. */ static enum window_part -coordinates_in_window (register struct window *w, register int *x, register int *y) +coordinates_in_window (register struct window *w, int x, int y) { struct frame *f = XFRAME (WINDOW_FRAME (w)); - int left_x, right_x, top_y, bottom_y; + int left_x, right_x; enum window_part part; int ux = FRAME_COLUMN_WIDTH (f); int x0 = WINDOW_LEFT_EDGE_X (w); @@ -789,6 +783,12 @@ (Between mode lines for instance. */ int grabbable_width = ux; int lmargin_width, rmargin_width, text_left, text_right; + int top_y = WINDOW_TOP_EDGE_Y (w); + int bottom_y = WINDOW_BOTTOM_EDGE_Y (w); + + /* Outside any interesting row? */ + if (y < top_y || y >= bottom_y) + return ON_NOTHING; /* In what's below, we subtract 1 when computing right_x because we want the rightmost pixel, which is given by left_pixel+width-1. */ @@ -796,21 +796,13 @@ { left_x = 0; right_x = WINDOW_TOTAL_WIDTH (w) - 1; - top_y = WINDOW_TOP_EDGE_Y (w); - bottom_y = WINDOW_BOTTOM_EDGE_Y (w); } else { left_x = WINDOW_BOX_LEFT_EDGE_X (w); right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1; - top_y = WINDOW_TOP_EDGE_Y (w); - bottom_y = WINDOW_BOTTOM_EDGE_Y (w); } - /* Outside any interesting row? */ - if (*y < top_y || *y >= bottom_y) - return ON_NOTHING; - /* On the mode line or header line? If it's near the start of the mode or header line of window that's has a horizontal sibling, say it's on the vertical line. That's to be able @@ -818,7 +810,7 @@ scroll bars. */ if (WINDOW_WANTS_MODELINE_P (w) - && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) + && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) { part = ON_MODE_LINE; @@ -827,60 +819,37 @@ between mode lines of horizontally adjacent mode lines as the vertical border. If scroll bars on the left, return the right window. */ - if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) - || WINDOW_RIGHTMOST_P (w)) - { - if (!WINDOW_LEFTMOST_P (w) && eabs (*x - x0) < grabbable_width) - { - /* Convert X and Y to window relative coordinates. - Vertical border is at the left edge of window. */ - *x = max (0, *x - x0); - *y -= top_y; - return ON_VERTICAL_BORDER; - } - } - else - { - /* Make sure we're not at the rightmost position of a - mode-/header-line and there's yet another window on - the right. (Bug#1372) */ - if ((WINDOW_RIGHTMOST_P (w) || *x < x1) - && eabs (*x - x1) < grabbable_width) - { - /* Convert X and Y to window relative coordinates. - Vertical border is at the right edge of window. */ - *x = min (x1, *x) - x0; - *y -= top_y; - return ON_VERTICAL_BORDER; - } - } - - if (*x < x0 || *x >= x1) + if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) + || WINDOW_RIGHTMOST_P (w)) + && !WINDOW_LEFTMOST_P (w) + && eabs (x - x0) < grabbable_width) + return ON_VERTICAL_BORDER; + + /* Make sure we're not at the rightmost position of a + mode-/header-line and there's yet another window on the + right. (Bug#1372) */ + else if ((WINDOW_RIGHTMOST_P (w) || x < x1) + && eabs (x - x1) < grabbable_width) + return ON_VERTICAL_BORDER; + + if (x < x0 || x >= x1) return ON_NOTHING; - /* Convert X and Y to window relative coordinates. - Mode line starts at left edge of window. */ - *x -= x0; - *y -= top_y; return part; } if (WINDOW_WANTS_HEADER_LINE_P (w) - && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) + && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) { part = ON_HEADER_LINE; goto header_vertical_border_check; } - if (*x < x0 || *x >= x1) - return ON_NOTHING; + if (x < x0 || x >= x1) return ON_NOTHING; /* Outside any interesting column? */ - if (*x < left_x || *x > right_x) - { - *y -= top_y; - return ON_SCROLL_BAR; - } + if (x < left_x || x > right_x) + return ON_SCROLL_BAR; lmargin_width = window_box_width (w, LEFT_MARGIN_AREA); rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA); @@ -893,77 +862,79 @@ if (!w->pseudo_window_p && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w) && !WINDOW_RIGHTMOST_P (w) - && (eabs (*x - right_x) < grabbable_width)) - { - /* Convert X and Y to window relative coordinates. - Vertical border is at the right edge of window. */ - *x = min (right_x, *x) - left_x; - *y -= top_y; - return ON_VERTICAL_BORDER; - } - } - else - { - /* Need to say "*x > right_x" rather than >=, since on character - terminals, the vertical line's x coordinate is right_x. */ - if (!w->pseudo_window_p - && !WINDOW_RIGHTMOST_P (w) - && *x > right_x - ux) - { - /* On the border on the right side of the window? Assume that - this area begins at RIGHT_X minus a canonical char width. */ - *x = min (right_x, *x) - left_x; - *y -= top_y; - return ON_VERTICAL_BORDER; - } - } + && (eabs (x - right_x) < grabbable_width)) + return ON_VERTICAL_BORDER; + } + /* Need to say "x > right_x" rather than >=, since on character + terminals, the vertical line's x coordinate is right_x. */ + else if (!w->pseudo_window_p + && !WINDOW_RIGHTMOST_P (w) + && x > right_x - ux) + return ON_VERTICAL_BORDER; - if (*x < text_left) + if (x < text_left) { if (lmargin_width > 0 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? (*x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w)) - : (*x < left_x + lmargin_width))) - { - *x -= left_x; - if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) - *x -= WINDOW_LEFT_FRINGE_WIDTH (w); - *y -= top_y; - return ON_LEFT_MARGIN; - } + ? (x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w)) + : (x < left_x + lmargin_width))) + return ON_LEFT_MARGIN; - /* Convert X and Y to window-relative pixel coordinates. */ - *x -= left_x; - *y -= top_y; return ON_LEFT_FRINGE; } - if (*x >= text_right) + if (x >= text_right) { if (rmargin_width > 0 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) - ? (*x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w)) - : (*x >= right_x - rmargin_width))) - { - *x -= right_x - rmargin_width; - if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) - *x += WINDOW_RIGHT_FRINGE_WIDTH (w); - *y -= top_y; - return ON_RIGHT_MARGIN; - } + ? (x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w)) + : (x >= right_x - rmargin_width))) + return ON_RIGHT_MARGIN; - /* Convert X and Y to window-relative pixel coordinates. */ - *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w); - *y -= top_y; return ON_RIGHT_FRINGE; } /* Everything special ruled out - must be on text area */ - *x -= text_left; - *y -= top_y; return ON_TEXT; } +/* Take X is the frame-relative pixel x-coordinate, and return the + x-coordinate relative to part PART of window W. */ +int +window_relative_x_coord (struct window *w, enum window_part part, int x) +{ + int left_x = (w->pseudo_window_p) ? 0 : WINDOW_BOX_LEFT_EDGE_X (w); + + switch (part) + { + case ON_TEXT: + return x - window_box_left (w, TEXT_AREA); + + case ON_LEFT_FRINGE: + return x - left_x; + + case ON_RIGHT_FRINGE: + return x - left_x - WINDOW_LEFT_FRINGE_WIDTH (w); + + case ON_LEFT_MARGIN: + return (x - left_x + - ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) + ? WINDOW_LEFT_FRINGE_WIDTH (w) : 0)); + + case ON_RIGHT_MARGIN: + return (x + 1 + - ((w->pseudo_window_p) + ? WINDOW_TOTAL_WIDTH (w) + : WINDOW_BOX_RIGHT_EDGE_X (w)) + + window_box_width (w, RIGHT_MARGIN_AREA) + + ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) + ? WINDOW_RIGHT_FRINGE_WIDTH (w) : 0)); + } + + /* ON_SCROLL_BAR, ON_NOTHING, and ON_VERTICAL_BORDER: */ + return 0; +} + DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, Scoordinates_in_window_p, 2, 2, 0, @@ -1000,14 +971,16 @@ x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f); y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH (f); - switch (coordinates_in_window (w, &x, &y)) + switch (coordinates_in_window (w, x, y)) { case ON_NOTHING: return Qnil; case ON_TEXT: - /* X and Y are now window relative pixel coordinates. Convert - them to canonical char units before returning them. */ + /* Convert X and Y to window relative pixel coordinates, and + return the canonical char units. */ + x -= window_box_left (w, TEXT_AREA); + y -= WINDOW_TOP_EDGE_Y (w); return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f, x), FRAME_CANON_Y_FROM_PIXEL_Y (f, y)); @@ -1054,7 +1027,7 @@ struct check_window_data { Lisp_Object *window; - int *x, *y; + int x, y; enum window_part *part; }; @@ -1081,8 +1054,7 @@ return it as a Lisp_Object. If X, Y is on one of the window's special `window_part' elements, - set *PART to the id of that element, and return X and Y converted - to window relative coordinates in WX and WY. + set *PART to the id of that element. If there is no window under X, Y return nil and leave *PART unmodified. TOOL_BAR_P non-zero means detect tool-bar windows. @@ -1097,7 +1069,8 @@ case. */ Lisp_Object -window_from_coordinates (struct frame *f, int x, int y, enum window_part *part, int *wx, int *wy, int tool_bar_p) +window_from_coordinates (struct frame *f, int x, int y, + enum window_part *part, int tool_bar_p) { Lisp_Object window; struct check_window_data cw; @@ -1107,7 +1080,7 @@ part = &dummy; window = Qnil; - cw.window = &window, cw.x = &x, cw.y = &y; cw.part = part; + cw.window = &window, cw.x = x, cw.y = y; cw.part = part; foreach_window (f, check_window_containing, &cw); /* If not found above, see if it's in the tool bar window, if a tool @@ -1116,16 +1089,13 @@ && tool_bar_p && WINDOWP (f->tool_bar_window) && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0 - && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y) + && (coordinates_in_window (XWINDOW (f->tool_bar_window), x, y) != ON_NOTHING)) { *part = ON_TEXT; window = f->tool_bar_window; } - if (wx) *wx = x; - if (wy) *wy = y; - return window; } @@ -1152,7 +1122,7 @@ + FRAME_INTERNAL_BORDER_WIDTH (f)), (FRAME_PIXEL_Y_FROM_CANON_Y (f, y) + FRAME_INTERNAL_BORDER_WIDTH (f)), - 0, 0, 0, 0); + 0, 0); } DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, === modified file 'src/window.h' --- src/window.h 2010-07-02 09:26:33 +0000 +++ src/window.h 2010-11-16 19:59:24 +0000 @@ -788,8 +788,7 @@ extern Lisp_Object make_window (void); extern void delete_window (Lisp_Object); extern Lisp_Object window_from_coordinates (struct frame *, int, int, - enum window_part *, - int *, int*, int); + enum window_part *, int); EXFUN (Fwindow_dedicated_p, 1); extern int window_height (Lisp_Object); extern int window_width (Lisp_Object); @@ -804,6 +803,7 @@ void *); extern void grow_mini_window (struct window *, int); extern void shrink_mini_window (struct window *); +extern int window_relative_x_coord (struct window *, enum window_part, int); void run_window_configuration_change_hook (struct frame *f); === modified file 'src/xdisp.c' --- src/xdisp.c 2010-11-13 13:29:31 +0000 +++ src/xdisp.c 2010-11-16 19:59:24 +0000 @@ -2218,7 +2218,7 @@ frame pixel coordinates X/Y on frame F. */ if (!f->glyphs_initialized_p - || (window = window_from_coordinates (f, gx, gy, &part, &x, &y, 0), + || (window = window_from_coordinates (f, gx, gy, &part, 0), NILP (window))) { width = FRAME_SMALLEST_CHAR_WIDTH (f); @@ -2230,6 +2230,9 @@ width = WINDOW_FRAME_COLUMN_WIDTH (w); height = WINDOW_FRAME_LINE_HEIGHT (w); + x = window_relative_x_coord (w, part, gx); + y = gy - WINDOW_TOP_EDGE_Y (w); + r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w); @@ -25383,7 +25386,7 @@ } /* Which window is that in? */ - window = window_from_coordinates (f, x, y, &part, 0, 0, 1); + window = window_from_coordinates (f, x, y, &part, 1); /* If we were displaying active text in another window, clear that. Also clear if we move out of text area in same window. */ === modified file 'src/xterm.c' --- src/xterm.c 2010-11-14 10:21:16 +0000 +++ src/xterm.c 2010-11-16 19:59:24 +0000 @@ -6658,7 +6658,7 @@ window = window_from_coordinates (f, event.xmotion.x, event.xmotion.y, - 0, 0, 0, 0); + 0, 0); /* Window will be selected only when it is not selected now and last mouse movement event was not in it. Minibuffer window @@ -6797,7 +6797,7 @@ int x = event.xbutton.x; int y = event.xbutton.y; - window = window_from_coordinates (f, x, y, 0, 0, 0, 1); + window = window_from_coordinates (f, x, y, 0, 1); tool_bar_p = EQ (window, f->tool_bar_window); if (tool_bar_p && event.xbutton.button < 4) ------------------------------------------------------------ revno: 102406 committer: Lars Magne Ingebrigtsen branch nick: trunk timestamp: Tue 2010-11-16 14:46:12 +0100 message: Avoid interpreting file:/foo:/bar URLs via tramp. diff: === modified file 'lisp/url/ChangeLog' --- lisp/url/ChangeLog 2010-10-14 21:35:03 +0000 +++ lisp/url/ChangeLog 2010-11-16 13:46:12 +0000 @@ -1,3 +1,8 @@ +2010-11-16 Lars Magne Ingebrigtsen + + * url-file.el (url-file-build-filename): Avoid interpreting + file:/foo:/bar URLs via tramp. + 2010-10-14 Lars Magne Ingebrigtsen * url-gw.el (url-open-stream): Use open-gnutls-stream if it exists. === modified file 'lisp/url/url-file.el' --- lisp/url/url-file.el 2010-01-13 08:35:10 +0000 +++ lisp/url/url-file.el 2010-11-16 13:46:12 +0000 @@ -103,12 +103,19 @@ (format "%s#%d" host port)) host)) (file (url-unhex-string (url-filename url))) - (filename (if (or user (not (url-file-host-is-local-p host))) - (concat "/" (or user "anonymous") "@" site ":" file) - (if (and (memq system-type '(ms-dos windows-nt)) - (string-match "^/[a-zA-Z]:/" file)) - (substring file 1) - file))) + (filename (cond + ;; ftp: URL. + ((or user (not (url-file-host-is-local-p host))) + (concat "/" (or user "anonymous") "@" site ":" file)) + ;; file: URL on Windows. + ((and (string-match "\\`/[a-zA-Z]:/" file) + (memq system-type '(ms-dos windows-nt))) + (substring file 1)) + ;; file: URL with a file:/bar:/foo-like spec. + ((string-match "\\`/[^/]+:/" file) + (concat "/:" file)) + (t + file))) pos-index) (and user pass ------------------------------------------------------------ revno: 102405 committer: Dan Nicolaescu branch nick: trunk timestamp: Mon 2010-11-15 22:44:51 -0800 message: Convert definitions to standard C. * src/strftime.c (LOCALE_PARAM_DECL): Update for standard C. (LOCALE_PARAM, LOCALE_PARAM_PROTO): Remove, unused. (memcpy_lowcase, so_week_days, extra_args_spec, emacs_strftimeu): Convert definitions to standard C. * src/regex.c: Do not include , config.h does it. Include unistd.h. (xrealloc, init_syntax_once, re_match, regcomp, regexec) (regerror, regfree): Convert definitions to standard C. * src/mktime.c (my_mktime_localtime_r, ydhms_tm_diff, ranged_convert) (__mktime_internal): Convert definitions to standard C. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2010-11-15 17:21:18 +0000 +++ src/ChangeLog 2010-11-16 06:44:51 +0000 @@ -1,3 +1,16 @@ +2010-11-16 Dan Nicolaescu + + * strftime.c (LOCALE_PARAM_DECL): Update for standard C. + (LOCALE_PARAM, LOCALE_PARAM_PROTO): Remove, unused. + (memcpy_lowcase, so_week_days, extra_args_spec, emacs_strftimeu): + Convert definitions to standard C. + * regex.c: Do not include , config.h does it. + Include unistd.h. + (xrealloc, init_syntax_once, re_match, regcomp, regexec) + (regerror, regfree): Convert definitions to standard C. + * mktime.c (my_mktime_localtime_r, ydhms_tm_diff, ranged_convert) + (__mktime_internal): Convert definitions to standard C. + 2010-11-15 Dan Nicolaescu * w32proc.c: === modified file 'src/mktime.c' --- src/mktime.c 2010-07-02 12:55:51 +0000 +++ src/mktime.c 2010-11-16 06:44:51 +0000 @@ -110,9 +110,7 @@ localtime to localtime_r, since many localtime_r implementations are buggy. */ static struct tm * -my_mktime_localtime_r (t, tp) - const time_t *t; - struct tm *tp; +my_mktime_localtime_r (const time_t *t, struct tm *tp) { struct tm *l = localtime (t); if (! l) @@ -130,9 +128,7 @@ If TP is null, return a nonzero value. If overflow occurs, yield the low order bits of the correct answer. */ static time_t -ydhms_tm_diff (year, yday, hour, min, sec, tp) - int year, yday, hour, min, sec; - const struct tm *tp; +ydhms_tm_diff (int year, int yday, int hour, int min, int sec, const struct tm *tp) { if (!tp) return 1; @@ -163,14 +159,8 @@ If *T is out of range for conversion, adjust it so that it is the nearest in-range value and then convert that. */ static struct tm * -ranged_convert (convert, t, tp) -#ifdef PROTOTYPES - struct tm *(*convert) (const time_t *, struct tm *); -#else - struct tm *(*convert)(); -#endif - time_t *t; - struct tm *tp; +ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), + time_t *t, struct tm *tp) { struct tm *r; @@ -217,14 +207,8 @@ compared to what the result would be for UTC without leap seconds. If *OFFSET's guess is correct, only one CONVERT call is needed. */ time_t -__mktime_internal (tp, convert, offset) - struct tm *tp; -#ifdef PROTOTYPES - struct tm *(*convert) (const time_t *, struct tm *); -#else - struct tm *(*convert)(); -#endif - time_t *offset; +__mktime_internal (struct tm *tp, struct tm *(*convert) (const time_t *, struct tm *), + time_t *offset) { time_t t, dt, t0, t1, t2; struct tm tm; @@ -558,5 +542,3 @@ End: */ -/* arch-tag: 9456752f-7ddd-47cb-8286-fa807b1355ae - (do not change this comment) */ === modified file 'src/regex.c' --- src/regex.c 2010-10-14 14:32:27 +0000 +++ src/regex.c 2010-11-16 06:44:51 +0000 @@ -196,18 +196,14 @@ even if config.h says that we can. */ # undef REL_ALLOC -# if defined STDC_HEADERS || defined _LIBC -# include -# else -char *malloc (); -char *realloc (); +# ifdef HAVE_UNISTD_H +# include # endif /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ void * -xmalloc (size) - size_t size; +xmalloc (size_t size) { register void *val; val = (void *) malloc (size); @@ -220,9 +216,7 @@ } void * -xrealloc (block, size) - void *block; - size_t size; +xrealloc (void *block, size_t size) { register void *val; /* We must call malloc explicitly when BLOCK is 0, since some @@ -435,7 +429,7 @@ static char re_syntax_table[CHAR_SET_SIZE]; static void -init_syntax_once () +init_syntax_once (void) { register int c; static int done = 0; @@ -4978,11 +4972,8 @@ /* re_match is like re_match_2 except it takes only a single string. */ int -re_match (bufp, string, size, pos, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, pos; - struct re_registers *regs; +re_match (struct re_pattern_buffer *bufp, const char *string, + int size, int pos, struct re_registers *regs) { int result = re_match_2_internal (bufp, NULL, 0, (re_char*) string, size, pos, regs, size); @@ -6534,10 +6525,8 @@ the return codes and their meanings.) */ int -regcomp (preg, pattern, cflags) - regex_t *__restrict preg; - const char *__restrict pattern; - int cflags; +regcomp (regex_t *__restrict preg, const char *__restrict pattern, + int cflags) { reg_errcode_t ret; reg_syntax_t syntax @@ -6619,12 +6608,8 @@ We return 0 if we find a match and REG_NOMATCH if not. */ int -regexec (preg, string, nmatch, pmatch, eflags) - const regex_t *__restrict preg; - const char *__restrict string; - size_t nmatch; - regmatch_t pmatch[__restrict_arr]; - int eflags; +regexec (const regex_t *__restrict preg, const char *__restrict string, + size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) { int ret; struct re_registers regs; @@ -6696,11 +6681,7 @@ error with msvc8 compiler. */ size_t -regerror (err_code, preg, errbuf, errbuf_size) - int err_code; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; +regerror (int err_code, const regex_t *preg, char *errbuf, size_t errbuf_size) { const char *msg; size_t msg_size; @@ -6736,8 +6717,7 @@ /* Free dynamically allocated space used by PREG. */ void -regfree (preg) - regex_t *preg; +regfree (regex_t *preg) { free (preg->buffer); preg->buffer = NULL; @@ -6756,5 +6736,3 @@ #endif /* not emacs */ -/* arch-tag: 4ffd68ba-2a9e-435b-a21a-018990f9eeb2 - (do not change this comment) */ === modified file 'src/strftime.c' --- src/strftime.c 2010-07-04 20:42:36 +0000 +++ src/strftime.c 2010-11-16 06:44:51 +0000 @@ -318,14 +318,10 @@ # undef _NL_CURRENT # define _NL_CURRENT(category, item) \ (current->values[_NL_ITEM_INDEX (item)].string) -# define LOCALE_PARAM , loc # define LOCALE_ARG , loc -# define LOCALE_PARAM_DECL __locale_t loc; -# define LOCALE_PARAM_PROTO , __locale_t loc +# define LOCALE_PARAM_DECL , __locale_t loc # define HELPER_LOCALE_ARG , current #else -# define LOCALE_PARAM -# define LOCALE_PARAM_PROTO # define LOCALE_ARG # define LOCALE_PARAM_DECL # ifdef _LIBC @@ -363,30 +359,16 @@ more reliable way to accept other sets of digits. */ #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) -static CHAR_T *memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO); - static CHAR_T * -memcpy_lowcase (dest, src, len LOCALE_PARAM) - CHAR_T *dest; - const CHAR_T *src; - size_t len; - LOCALE_PARAM_DECL +memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_DECL) { while (len-- > 0) dest[len] = TOLOWER ((UCHAR_T) src[len], loc); return dest; } -static CHAR_T *memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO); - static CHAR_T * -memcpy_uppcase (dest, src, len LOCALE_PARAM) - CHAR_T *dest; - const CHAR_T *src; - size_t len; - LOCALE_PARAM_DECL +memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_DECL) { while (len-- > 0) dest[len] = TOUPPER ((UCHAR_T) src[len], loc); @@ -437,9 +419,7 @@ __inline__ #endif static int -iso_week_days (yday, wday) - int yday; - int wday; +iso_week_days (int yday, int wday) { /* Add enough to the first operand of % to make it nonnegative. */ int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; @@ -470,7 +450,7 @@ #ifdef my_strftime # define extra_args , ut, ns -# define extra_args_spec int ut; int ns; +# define extra_args_spec , int ut, int ns # define extra_args_spec_iso , int ut, int ns #else # ifdef COMPILE_WIDE @@ -517,13 +497,8 @@ anywhere, so to determine how many characters would be written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ size_t -my_strftime (s, maxsize, format, tp extra_args LOCALE_PARAM) - CHAR_T *s; - size_t maxsize; - const CHAR_T *format; - const struct tm *tp; - extra_args_spec - LOCALE_PARAM_DECL +my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, + const struct tm *tp extra_args_spec LOCALE_PARAM_DECL) { #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL struct locale_data *const current = loc->__locales[LC_TIME]; @@ -1474,16 +1449,10 @@ /* For Emacs we have a separate interface which corresponds to the normal strftime function plus the ut argument, but without the ns argument. */ size_t -emacs_strftimeu (s, maxsize, format, tp, ut) - char *s; - size_t maxsize; - const char *format; - const struct tm *tp; - int ut; +emacs_strftimeu (char *s, size_t maxsize, const char *format, + const struct tm *tp, int ut) { return my_strftime (s, maxsize, format, tp, ut, 0); } #endif -/* arch-tag: 662bc9c4-f8e2-41b6-bf96-b8346d0ce0d8 - (do not change this comment) */ ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.