diff options
| author | YAMAMOTO Mitsuharu | 2019-05-23 10:53:23 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2019-05-23 10:53:23 +0900 |
| commit | b40dde705af4d53853de6185a2468153b442dc9a (patch) | |
| tree | e8dabba695163c2d07439fad6accff761f8f714c /src | |
| parent | 5d7dafacf4afc888511649f6fc24c28210cd0dfc (diff) | |
| parent | 03feb9376b54c489e24478954a11061e9b0d6db7 (diff) | |
| download | emacs-b40dde705af4d53853de6185a2468153b442dc9a.tar.gz emacs-b40dde705af4d53853de6185a2468153b442dc9a.zip | |
Merge branch 'master' into harfbuzz
Diffstat (limited to 'src')
| -rw-r--r-- | src/.gdbinit | 6 | ||||
| -rw-r--r-- | src/alloc.c | 77 | ||||
| -rw-r--r-- | src/bignum.h | 12 | ||||
| -rw-r--r-- | src/buffer.c | 27 | ||||
| -rw-r--r-- | src/buffer.h | 4 | ||||
| -rw-r--r-- | src/bytecode.c | 2 | ||||
| -rw-r--r-- | src/character.h | 9 | ||||
| -rw-r--r-- | src/coding.c | 23 | ||||
| -rw-r--r-- | src/coding.h | 11 | ||||
| -rw-r--r-- | src/conf_post.h | 6 | ||||
| -rw-r--r-- | src/data.c | 46 | ||||
| -rw-r--r-- | src/dbusbind.c | 8 | ||||
| -rw-r--r-- | src/dispextern.h | 94 | ||||
| -rw-r--r-- | src/dispnew.c | 94 | ||||
| -rw-r--r-- | src/dynlib.h | 2 | ||||
| -rw-r--r-- | src/emacs-module.c | 38 | ||||
| -rw-r--r-- | src/emacs-module.h.in | 2 | ||||
| -rw-r--r-- | src/emacs.c | 3 | ||||
| -rw-r--r-- | src/eval.c | 50 | ||||
| -rw-r--r-- | src/fileio.c | 9 | ||||
| -rw-r--r-- | src/fns.c | 6 | ||||
| -rw-r--r-- | src/font.h | 4 | ||||
| -rw-r--r-- | src/frame.h | 2 | ||||
| -rw-r--r-- | src/ftcrfont.c | 417 | ||||
| -rw-r--r-- | src/ftfont.c | 255 | ||||
| -rw-r--r-- | src/ftfont.h | 18 | ||||
| -rw-r--r-- | src/ftxfont.c | 8 | ||||
| -rw-r--r-- | src/gtkutil.c | 2 | ||||
| -rw-r--r-- | src/gtkutil.h | 2 | ||||
| -rw-r--r-- | src/image.c | 825 | ||||
| -rw-r--r-- | src/indent.c | 7 | ||||
| -rw-r--r-- | src/insdel.c | 13 | ||||
| -rw-r--r-- | src/intervals.c | 39 | ||||
| -rw-r--r-- | src/json.c | 59 | ||||
| -rw-r--r-- | src/keyboard.c | 6 | ||||
| -rw-r--r-- | src/lisp.h | 7 | ||||
| -rw-r--r-- | src/lread.c | 148 | ||||
| -rw-r--r-- | src/macfont.m | 19 | ||||
| -rw-r--r-- | src/marker.c | 4 | ||||
| -rw-r--r-- | src/mini-gmp.c | 559 | ||||
| -rw-r--r-- | src/mini-gmp.h | 2 | ||||
| -rw-r--r-- | src/minibuf.c | 3 | ||||
| -rw-r--r-- | src/msdos.h | 2 | ||||
| -rw-r--r-- | src/nsfont.m | 2 | ||||
| -rw-r--r-- | src/nsgui.h | 62 | ||||
| -rw-r--r-- | src/nsimage.m | 4 | ||||
| -rw-r--r-- | src/nsmenu.m | 7 | ||||
| -rw-r--r-- | src/nsselect.m | 14 | ||||
| -rw-r--r-- | src/nsterm.h | 60 | ||||
| -rw-r--r-- | src/nsterm.m | 193 | ||||
| -rw-r--r-- | src/print.c | 40 | ||||
| -rw-r--r-- | src/search.c | 7 | ||||
| -rw-r--r-- | src/termhooks.h | 15 | ||||
| -rw-r--r-- | src/timefns.c | 5 | ||||
| -rw-r--r-- | src/w32.c | 11 | ||||
| -rw-r--r-- | src/w32fns.c | 27 | ||||
| -rw-r--r-- | src/w32font.c | 2 | ||||
| -rw-r--r-- | src/w32font.h | 2 | ||||
| -rw-r--r-- | src/w32gui.h | 43 | ||||
| -rw-r--r-- | src/w32term.c | 214 | ||||
| -rw-r--r-- | src/w32term.h | 53 | ||||
| -rw-r--r-- | src/window.c | 6 | ||||
| -rw-r--r-- | src/xdisp.c | 346 | ||||
| -rw-r--r-- | src/xfaces.c | 86 | ||||
| -rw-r--r-- | src/xfns.c | 8 | ||||
| -rw-r--r-- | src/xfont.c | 122 | ||||
| -rw-r--r-- | src/xftfont.c | 156 | ||||
| -rw-r--r-- | src/xterm.c | 467 | ||||
| -rw-r--r-- | src/xterm.h | 20 |
69 files changed, 2445 insertions, 2457 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index b8b303104f5..8c9a227ee33 100644 --- a/src/.gdbinit +++ b/src/.gdbinit | |||
| @@ -1059,8 +1059,10 @@ end | |||
| 1059 | define xprintsym | 1059 | define xprintsym |
| 1060 | xsymname $arg0 | 1060 | xsymname $arg0 |
| 1061 | xgetptr $symname | 1061 | xgetptr $symname |
| 1062 | set $sym_name = (struct Lisp_String *) $ptr | 1062 | if $ptr != 0 |
| 1063 | xprintstr $sym_name | 1063 | set $sym_name = (struct Lisp_String *) $ptr |
| 1064 | xprintstr $sym_name | ||
| 1065 | end | ||
| 1064 | end | 1066 | end |
| 1065 | document xprintsym | 1067 | document xprintsym |
| 1066 | Print argument as a symbol. | 1068 | Print argument as a symbol. |
diff --git a/src/alloc.c b/src/alloc.c index 948a0e8a2dc..af4adb3856e 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -1447,9 +1447,7 @@ mark_interval_tree (INTERVAL i) | |||
| 1447 | 1447 | ||
| 1448 | #define LARGE_STRING_BYTES 1024 | 1448 | #define LARGE_STRING_BYTES 1024 |
| 1449 | 1449 | ||
| 1450 | /* The SDATA typedef is a struct or union describing string memory | 1450 | /* The layout of a nonnull string. */ |
| 1451 | sub-allocated from an sblock. This is where the contents of Lisp | ||
| 1452 | strings are stored. */ | ||
| 1453 | 1451 | ||
| 1454 | struct sdata | 1452 | struct sdata |
| 1455 | { | 1453 | { |
| @@ -1468,13 +1466,8 @@ struct sdata | |||
| 1468 | unsigned char data[FLEXIBLE_ARRAY_MEMBER]; | 1466 | unsigned char data[FLEXIBLE_ARRAY_MEMBER]; |
| 1469 | }; | 1467 | }; |
| 1470 | 1468 | ||
| 1471 | #ifdef GC_CHECK_STRING_BYTES | 1469 | /* A union describing string memory sub-allocated from an sblock. |
| 1472 | 1470 | This is where the contents of Lisp strings are stored. */ | |
| 1473 | typedef struct sdata sdata; | ||
| 1474 | #define SDATA_NBYTES(S) (S)->nbytes | ||
| 1475 | #define SDATA_DATA(S) (S)->data | ||
| 1476 | |||
| 1477 | #else | ||
| 1478 | 1471 | ||
| 1479 | typedef union | 1472 | typedef union |
| 1480 | { | 1473 | { |
| @@ -1502,8 +1495,6 @@ typedef union | |||
| 1502 | #define SDATA_NBYTES(S) (S)->n.nbytes | 1495 | #define SDATA_NBYTES(S) (S)->n.nbytes |
| 1503 | #define SDATA_DATA(S) ((struct sdata *) (S))->data | 1496 | #define SDATA_DATA(S) ((struct sdata *) (S))->data |
| 1504 | 1497 | ||
| 1505 | #endif /* not GC_CHECK_STRING_BYTES */ | ||
| 1506 | |||
| 1507 | enum { SDATA_DATA_OFFSET = offsetof (struct sdata, data) }; | 1498 | enum { SDATA_DATA_OFFSET = offsetof (struct sdata, data) }; |
| 1508 | 1499 | ||
| 1509 | /* Structure describing a block of memory which is sub-allocated to | 1500 | /* Structure describing a block of memory which is sub-allocated to |
| @@ -1586,31 +1577,20 @@ static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] = | |||
| 1586 | # define GC_STRING_OVERRUN_COOKIE_SIZE 0 | 1577 | # define GC_STRING_OVERRUN_COOKIE_SIZE 0 |
| 1587 | #endif | 1578 | #endif |
| 1588 | 1579 | ||
| 1589 | /* Value is the size of an sdata structure large enough to hold NBYTES | 1580 | /* Return the size of an sdata structure large enough to hold N bytes |
| 1590 | bytes of string data. The value returned includes a terminating | 1581 | of string data. This counts the sdata structure, the N bytes, a |
| 1591 | NUL byte, the size of the sdata structure, and padding. */ | 1582 | terminating NUL byte, and alignment padding. */ |
| 1592 | |||
| 1593 | #ifdef GC_CHECK_STRING_BYTES | ||
| 1594 | |||
| 1595 | #define SDATA_SIZE(NBYTES) FLEXSIZEOF (struct sdata, data, (NBYTES) + 1) | ||
| 1596 | 1583 | ||
| 1597 | #else /* not GC_CHECK_STRING_BYTES */ | 1584 | static ptrdiff_t |
| 1598 | 1585 | sdata_size (ptrdiff_t n) | |
| 1599 | /* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is | 1586 | { |
| 1600 | less than the size of that member. The 'max' is not needed when | 1587 | /* Reserve space for the nbytes union member even when N + 1 is less |
| 1601 | SDATA_DATA_OFFSET is a multiple of FLEXALIGNOF (struct sdata), | 1588 | than the size of that member. */ |
| 1602 | because then the alignment code reserves enough space. */ | 1589 | ptrdiff_t unaligned_size = max (SDATA_DATA_OFFSET + n + 1, |
| 1603 | 1590 | sizeof (sdata)); | |
| 1604 | #define SDATA_SIZE(NBYTES) \ | 1591 | int sdata_align = max (FLEXALIGNOF (struct sdata), alignof (sdata)); |
| 1605 | ((SDATA_DATA_OFFSET \ | 1592 | return (unaligned_size + sdata_align - 1) & ~(sdata_align - 1); |
| 1606 | + (SDATA_DATA_OFFSET % FLEXALIGNOF (struct sdata) == 0 \ | 1593 | } |
| 1607 | ? NBYTES \ | ||
| 1608 | : max (NBYTES, FLEXALIGNOF (struct sdata) - 1)) \ | ||
| 1609 | + 1 \ | ||
| 1610 | + FLEXALIGNOF (struct sdata) - 1) \ | ||
| 1611 | & ~(FLEXALIGNOF (struct sdata) - 1)) | ||
| 1612 | |||
| 1613 | #endif /* not GC_CHECK_STRING_BYTES */ | ||
| 1614 | 1594 | ||
| 1615 | /* Extra bytes to allocate for each string. */ | 1595 | /* Extra bytes to allocate for each string. */ |
| 1616 | #define GC_STRING_EXTRA GC_STRING_OVERRUN_COOKIE_SIZE | 1596 | #define GC_STRING_EXTRA GC_STRING_OVERRUN_COOKIE_SIZE |
| @@ -1664,21 +1644,14 @@ string_bytes (struct Lisp_String *s) | |||
| 1664 | static void | 1644 | static void |
| 1665 | check_sblock (struct sblock *b) | 1645 | check_sblock (struct sblock *b) |
| 1666 | { | 1646 | { |
| 1667 | sdata *from, *end, *from_end; | 1647 | sdata *end = b->next_free; |
| 1668 | |||
| 1669 | end = b->next_free; | ||
| 1670 | 1648 | ||
| 1671 | for (from = b->data; from < end; from = from_end) | 1649 | for (sdata *from = b->data; from < end; ) |
| 1672 | { | 1650 | { |
| 1673 | /* Compute the next FROM here because copying below may | 1651 | ptrdiff_t nbytes = sdata_size (from->string |
| 1674 | overwrite data we need to compute it. */ | 1652 | ? string_bytes (from->string) |
| 1675 | ptrdiff_t nbytes; | 1653 | : SDATA_NBYTES (from)); |
| 1676 | 1654 | from = (sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); | |
| 1677 | /* Check that the string size recorded in the string is the | ||
| 1678 | same as the one recorded in the sdata structure. */ | ||
| 1679 | nbytes = SDATA_SIZE (from->string ? string_bytes (from->string) | ||
| 1680 | : SDATA_NBYTES (from)); | ||
| 1681 | from_end = (sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); | ||
| 1682 | } | 1655 | } |
| 1683 | } | 1656 | } |
| 1684 | 1657 | ||
| @@ -1810,14 +1783,14 @@ allocate_string_data (struct Lisp_String *s, | |||
| 1810 | { | 1783 | { |
| 1811 | sdata *data, *old_data; | 1784 | sdata *data, *old_data; |
| 1812 | struct sblock *b; | 1785 | struct sblock *b; |
| 1813 | ptrdiff_t needed, old_nbytes; | 1786 | ptrdiff_t old_nbytes; |
| 1814 | 1787 | ||
| 1815 | if (STRING_BYTES_MAX < nbytes) | 1788 | if (STRING_BYTES_MAX < nbytes) |
| 1816 | string_overflow (); | 1789 | string_overflow (); |
| 1817 | 1790 | ||
| 1818 | /* Determine the number of bytes needed to store NBYTES bytes | 1791 | /* Determine the number of bytes needed to store NBYTES bytes |
| 1819 | of string data. */ | 1792 | of string data. */ |
| 1820 | needed = SDATA_SIZE (nbytes); | 1793 | ptrdiff_t needed = sdata_size (nbytes); |
| 1821 | if (s->u.s.data) | 1794 | if (s->u.s.data) |
| 1822 | { | 1795 | { |
| 1823 | old_data = SDATA_OF_STRING (s); | 1796 | old_data = SDATA_OF_STRING (s); |
| @@ -2068,7 +2041,7 @@ compact_small_strings (void) | |||
| 2068 | nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); | 2041 | nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); |
| 2069 | eassert (nbytes <= LARGE_STRING_BYTES); | 2042 | eassert (nbytes <= LARGE_STRING_BYTES); |
| 2070 | 2043 | ||
| 2071 | ptrdiff_t size = SDATA_SIZE (nbytes); | 2044 | ptrdiff_t size = sdata_size (nbytes); |
| 2072 | sdata *from_end = (sdata *) ((char *) from | 2045 | sdata *from_end = (sdata *) ((char *) from |
| 2073 | + size + GC_STRING_EXTRA); | 2046 | + size + GC_STRING_EXTRA); |
| 2074 | 2047 | ||
diff --git a/src/bignum.h b/src/bignum.h index 4c670bd906f..743a18fc0f7 100644 --- a/src/bignum.h +++ b/src/bignum.h | |||
| @@ -94,6 +94,18 @@ bignum_integer (mpz_t *tmp, Lisp_Object i) | |||
| 94 | return &XBIGNUM (i)->value; | 94 | return &XBIGNUM (i)->value; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | /* Set RESULT to the value stored in the Lisp integer I. If I is a | ||
| 98 | big integer, copy it to RESULT. RESULT must already be | ||
| 99 | initialized. */ | ||
| 100 | INLINE void | ||
| 101 | mpz_set_integer (mpz_t result, Lisp_Object i) | ||
| 102 | { | ||
| 103 | if (FIXNUMP (i)) | ||
| 104 | mpz_set_intmax (result, XFIXNUM (i)); | ||
| 105 | else | ||
| 106 | mpz_set (result, XBIGNUM (i)->value); | ||
| 107 | } | ||
| 108 | |||
| 97 | INLINE_HEADER_END | 109 | INLINE_HEADER_END |
| 98 | 110 | ||
| 99 | #endif /* BIGNUM_H */ | 111 | #endif /* BIGNUM_H */ |
diff --git a/src/buffer.c b/src/buffer.c index ab477481912..209e29f0f19 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -2264,7 +2264,7 @@ validate_region (register Lisp_Object *b, register Lisp_Object *e) | |||
| 2264 | /* Advance BYTE_POS up to a character boundary | 2264 | /* Advance BYTE_POS up to a character boundary |
| 2265 | and return the adjusted position. */ | 2265 | and return the adjusted position. */ |
| 2266 | 2266 | ||
| 2267 | static ptrdiff_t | 2267 | ptrdiff_t |
| 2268 | advance_to_char_boundary (ptrdiff_t byte_pos) | 2268 | advance_to_char_boundary (ptrdiff_t byte_pos) |
| 2269 | { | 2269 | { |
| 2270 | int c; | 2270 | int c; |
| @@ -2702,6 +2702,9 @@ current buffer is cleared. */) | |||
| 2702 | 2702 | ||
| 2703 | /* Do this last, so it can calculate the new correspondences | 2703 | /* Do this last, so it can calculate the new correspondences |
| 2704 | between chars and bytes. */ | 2704 | between chars and bytes. */ |
| 2705 | /* FIXME: Is it worth the trouble, really? Couldn't we just throw | ||
| 2706 | away all the text-properties instead of trying to guess how | ||
| 2707 | to adjust them? AFAICT the result is not reliable anyway. */ | ||
| 2705 | set_intervals_multibyte (1); | 2708 | set_intervals_multibyte (1); |
| 2706 | } | 2709 | } |
| 2707 | 2710 | ||
| @@ -5600,17 +5603,17 @@ Use the command `abbrev-mode' to change this variable. */); | |||
| 5600 | doc: /* Non-nil if searches and matches should ignore case. */); | 5603 | doc: /* Non-nil if searches and matches should ignore case. */); |
| 5601 | 5604 | ||
| 5602 | DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column), | 5605 | DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column), |
| 5603 | Qfixnump, | 5606 | Qintegerp, |
| 5604 | doc: /* Column beyond which automatic line-wrapping should happen. | 5607 | doc: /* Column beyond which automatic line-wrapping should happen. |
| 5605 | Interactively, you can set the buffer local value using \\[set-fill-column]. */); | 5608 | Interactively, you can set the buffer local value using \\[set-fill-column]. */); |
| 5606 | 5609 | ||
| 5607 | DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin), | 5610 | DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin), |
| 5608 | Qfixnump, | 5611 | Qintegerp, |
| 5609 | doc: /* Column for the default `indent-line-function' to indent to. | 5612 | doc: /* Column for the default `indent-line-function' to indent to. |
| 5610 | Linefeed indents to this column in Fundamental mode. */); | 5613 | Linefeed indents to this column in Fundamental mode. */); |
| 5611 | 5614 | ||
| 5612 | DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width), | 5615 | DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width), |
| 5613 | Qfixnump, | 5616 | Qintegerp, |
| 5614 | doc: /* Distance between tab stops (for display of tab characters), in columns. | 5617 | doc: /* Distance between tab stops (for display of tab characters), in columns. |
| 5615 | NOTE: This controls the display width of a TAB character, and not | 5618 | NOTE: This controls the display width of a TAB character, and not |
| 5616 | the size of an indentation step. | 5619 | the size of an indentation step. |
| @@ -5781,7 +5784,7 @@ If it is nil, that means don't auto-save this buffer. */); | |||
| 5781 | Backing up is done before the first time the file is saved. */); | 5784 | Backing up is done before the first time the file is saved. */); |
| 5782 | 5785 | ||
| 5783 | DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length), | 5786 | DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length), |
| 5784 | Qfixnump, | 5787 | Qintegerp, |
| 5785 | doc: /* Length of current buffer when last read in, saved or auto-saved. | 5788 | doc: /* Length of current buffer when last read in, saved or auto-saved. |
| 5786 | 0 initially. | 5789 | 0 initially. |
| 5787 | -1 means auto-saving turned off until next real save. | 5790 | -1 means auto-saving turned off until next real save. |
| @@ -5855,7 +5858,7 @@ In addition, a char-table has six extra slots to control the display of: | |||
| 5855 | See also the functions `display-table-slot' and `set-display-table-slot'. */); | 5858 | See also the functions `display-table-slot' and `set-display-table-slot'. */); |
| 5856 | 5859 | ||
| 5857 | DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols), | 5860 | DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols), |
| 5858 | Qfixnump, | 5861 | Qintegerp, |
| 5859 | doc: /* Width in columns of left marginal area for display of a buffer. | 5862 | doc: /* Width in columns of left marginal area for display of a buffer. |
| 5860 | A value of nil means no marginal area. | 5863 | A value of nil means no marginal area. |
| 5861 | 5864 | ||
| @@ -5863,7 +5866,7 @@ Setting this variable does not take effect until a new buffer is displayed | |||
| 5863 | in a window. To make the change take effect, call `set-window-buffer'. */); | 5866 | in a window. To make the change take effect, call `set-window-buffer'. */); |
| 5864 | 5867 | ||
| 5865 | DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols), | 5868 | DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols), |
| 5866 | Qfixnump, | 5869 | Qintegerp, |
| 5867 | doc: /* Width in columns of right marginal area for display of a buffer. | 5870 | doc: /* Width in columns of right marginal area for display of a buffer. |
| 5868 | A value of nil means no marginal area. | 5871 | A value of nil means no marginal area. |
| 5869 | 5872 | ||
| @@ -5871,7 +5874,7 @@ Setting this variable does not take effect until a new buffer is displayed | |||
| 5871 | in a window. To make the change take effect, call `set-window-buffer'. */); | 5874 | in a window. To make the change take effect, call `set-window-buffer'. */); |
| 5872 | 5875 | ||
| 5873 | DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width), | 5876 | DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width), |
| 5874 | Qfixnump, | 5877 | Qintegerp, |
| 5875 | doc: /* Width of this buffer's left fringe (in pixels). | 5878 | doc: /* Width of this buffer's left fringe (in pixels). |
| 5876 | A value of 0 means no left fringe is shown in this buffer's window. | 5879 | A value of 0 means no left fringe is shown in this buffer's window. |
| 5877 | A value of nil means to use the left fringe width from the window's frame. | 5880 | A value of nil means to use the left fringe width from the window's frame. |
| @@ -5880,7 +5883,7 @@ Setting this variable does not take effect until a new buffer is displayed | |||
| 5880 | in a window. To make the change take effect, call `set-window-buffer'. */); | 5883 | in a window. To make the change take effect, call `set-window-buffer'. */); |
| 5881 | 5884 | ||
| 5882 | DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width), | 5885 | DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width), |
| 5883 | Qfixnump, | 5886 | Qintegerp, |
| 5884 | doc: /* Width of this buffer's right fringe (in pixels). | 5887 | doc: /* Width of this buffer's right fringe (in pixels). |
| 5885 | A value of 0 means no right fringe is shown in this buffer's window. | 5888 | A value of 0 means no right fringe is shown in this buffer's window. |
| 5886 | A value of nil means to use the right fringe width from the window's frame. | 5889 | A value of nil means to use the right fringe width from the window's frame. |
| @@ -5897,12 +5900,12 @@ Setting this variable does not take effect until a new buffer is displayed | |||
| 5897 | in a window. To make the change take effect, call `set-window-buffer'. */); | 5900 | in a window. To make the change take effect, call `set-window-buffer'. */); |
| 5898 | 5901 | ||
| 5899 | DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width), | 5902 | DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width), |
| 5900 | Qfixnump, | 5903 | Qintegerp, |
| 5901 | doc: /* Width of this buffer's vertical scroll bars in pixels. | 5904 | doc: /* Width of this buffer's vertical scroll bars in pixels. |
| 5902 | A value of nil means to use the scroll bar width from the window's frame. */); | 5905 | A value of nil means to use the scroll bar width from the window's frame. */); |
| 5903 | 5906 | ||
| 5904 | DEFVAR_PER_BUFFER ("scroll-bar-height", &BVAR (current_buffer, scroll_bar_height), | 5907 | DEFVAR_PER_BUFFER ("scroll-bar-height", &BVAR (current_buffer, scroll_bar_height), |
| 5905 | Qfixnump, | 5908 | Qintegerp, |
| 5906 | doc: /* Height of this buffer's horizontal scroll bars in pixels. | 5909 | doc: /* Height of this buffer's horizontal scroll bars in pixels. |
| 5907 | A value of nil means to use the scroll bar height from the window's frame. */); | 5910 | A value of nil means to use the scroll bar height from the window's frame. */); |
| 5908 | 5911 | ||
| @@ -6172,7 +6175,7 @@ Setting this variable is very fast, much faster than scanning all the text in | |||
| 6172 | the buffer looking for properties to change. */); | 6175 | the buffer looking for properties to change. */); |
| 6173 | 6176 | ||
| 6174 | DEFVAR_PER_BUFFER ("buffer-display-count", | 6177 | DEFVAR_PER_BUFFER ("buffer-display-count", |
| 6175 | &BVAR (current_buffer, display_count), Qfixnump, | 6178 | &BVAR (current_buffer, display_count), Qintegerp, |
| 6176 | doc: /* A number incremented each time this buffer is displayed in a window. | 6179 | doc: /* A number incremented each time this buffer is displayed in a window. |
| 6177 | The function `set-window-buffer' increments it. */); | 6180 | The function `set-window-buffer' increments it. */); |
| 6178 | 6181 | ||
diff --git a/src/buffer.h b/src/buffer.h index f42c3e97b97..2080a6f40b7 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -327,6 +327,10 @@ extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); | |||
| 327 | #define BYTE_TO_CHAR(bytepos) \ | 327 | #define BYTE_TO_CHAR(bytepos) \ |
| 328 | (buf_bytepos_to_charpos (current_buffer, bytepos)) | 328 | (buf_bytepos_to_charpos (current_buffer, bytepos)) |
| 329 | 329 | ||
| 330 | /* For those very rare cases where you may have a "random" pointer into | ||
| 331 | the middle of a multibyte char, this moves to the next boundary. */ | ||
| 332 | extern ptrdiff_t advance_to_char_boundary (ptrdiff_t byte_pos); | ||
| 333 | |||
| 330 | /* Convert PTR, the address of a byte in the buffer, into a byte position. */ | 334 | /* Convert PTR, the address of a byte in the buffer, into a byte position. */ |
| 331 | 335 | ||
| 332 | #define PTR_BYTE_POS(ptr) \ | 336 | #define PTR_BYTE_POS(ptr) \ |
diff --git a/src/bytecode.c b/src/bytecode.c index 40977799bfc..6f601cf0cd5 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -562,7 +562,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 562 | /* Inline the most common case. */ | 562 | /* Inline the most common case. */ |
| 563 | if (SYMBOLP (sym) | 563 | if (SYMBOLP (sym) |
| 564 | && !EQ (val, Qunbound) | 564 | && !EQ (val, Qunbound) |
| 565 | && !XSYMBOL (sym)->u.s.redirect | 565 | && XSYMBOL (sym)->u.s.redirect == SYMBOL_PLAINVAL |
| 566 | && !SYMBOL_TRAPPED_WRITE_P (sym)) | 566 | && !SYMBOL_TRAPPED_WRITE_P (sym)) |
| 567 | SET_SYMBOL_VAL (XSYMBOL (sym), val); | 567 | SET_SYMBOL_VAL (XSYMBOL (sym), val); |
| 568 | else | 568 | else |
diff --git a/src/character.h b/src/character.h index 5dff85aed47..cc57a2a7d5c 100644 --- a/src/character.h +++ b/src/character.h | |||
| @@ -558,12 +558,13 @@ enum | |||
| 558 | 558 | ||
| 559 | /* Return a non-outlandish value for the tab width. */ | 559 | /* Return a non-outlandish value for the tab width. */ |
| 560 | 560 | ||
| 561 | #define SANE_TAB_WIDTH(buf) \ | 561 | #define SANE_TAB_WIDTH(buf) sanitize_tab_width (BVAR (buf, tab_width)) |
| 562 | sanitize_tab_width (XFIXNAT (BVAR (buf, tab_width))) | 562 | |
| 563 | INLINE int | 563 | INLINE int |
| 564 | sanitize_tab_width (EMACS_INT width) | 564 | sanitize_tab_width (Lisp_Object width) |
| 565 | { | 565 | { |
| 566 | return 0 < width && width <= 1000 ? width : 8; | 566 | return (FIXNUMP (width) && 0 < XFIXNUM (width) && XFIXNUM (width) <= 1000 |
| 567 | ? XFIXNUM (width) : 8); | ||
| 567 | } | 568 | } |
| 568 | 569 | ||
| 569 | /* Return the width of ASCII character C. The width is measured by | 570 | /* Return the width of ASCII character C. The width is measured by |
diff --git a/src/coding.c b/src/coding.c index 2c6b2c4d051..9cba6494a8d 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6353,6 +6353,29 @@ utf8_string_p (Lisp_Object string) | |||
| 6353 | return check_utf_8 (&coding) != -1; | 6353 | return check_utf_8 (&coding) != -1; |
| 6354 | } | 6354 | } |
| 6355 | 6355 | ||
| 6356 | /* Like make_string, but always returns a multibyte Lisp string, and | ||
| 6357 | avoids decoding if TEXT encoded in UTF-8. */ | ||
| 6358 | |||
| 6359 | Lisp_Object | ||
| 6360 | make_string_from_utf8 (const char *text, ptrdiff_t nbytes) | ||
| 6361 | { | ||
| 6362 | ptrdiff_t chars, bytes; | ||
| 6363 | parse_str_as_multibyte ((const unsigned char *) text, nbytes, | ||
| 6364 | &chars, &bytes); | ||
| 6365 | /* If TEXT is a valid UTF-8 string, we can convert it to a Lisp | ||
| 6366 | string directly. Otherwise, we need to decode it. */ | ||
| 6367 | if (chars == nbytes || bytes == nbytes) | ||
| 6368 | return make_specified_string (text, chars, nbytes, true); | ||
| 6369 | else | ||
| 6370 | { | ||
| 6371 | struct coding_system coding; | ||
| 6372 | setup_coding_system (Qutf_8_unix, &coding); | ||
| 6373 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 6374 | coding.source = (const unsigned char *) text; | ||
| 6375 | decode_coding_object (&coding, Qnil, 0, 0, nbytes, nbytes, Qt); | ||
| 6376 | return coding.dst_object; | ||
| 6377 | } | ||
| 6378 | } | ||
| 6356 | 6379 | ||
| 6357 | /* Detect how end-of-line of a text of length SRC_BYTES pointed by | 6380 | /* Detect how end-of-line of a text of length SRC_BYTES pointed by |
| 6358 | SOURCE is encoded. If CATEGORY is one of | 6381 | SOURCE is encoded. If CATEGORY is one of |
diff --git a/src/coding.h b/src/coding.h index 0c03d1a44ed..619ca29c8e4 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -695,6 +695,7 @@ extern Lisp_Object raw_text_coding_system (Lisp_Object); | |||
| 695 | extern bool raw_text_coding_system_p (struct coding_system *); | 695 | extern bool raw_text_coding_system_p (struct coding_system *); |
| 696 | extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); | 696 | extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); |
| 697 | extern Lisp_Object complement_process_encoding_system (Lisp_Object); | 697 | extern Lisp_Object complement_process_encoding_system (Lisp_Object); |
| 698 | extern Lisp_Object make_string_from_utf8 (const char *, ptrdiff_t); | ||
| 698 | 699 | ||
| 699 | extern void decode_coding_gap (struct coding_system *, | 700 | extern void decode_coding_gap (struct coding_system *, |
| 700 | ptrdiff_t, ptrdiff_t); | 701 | ptrdiff_t, ptrdiff_t); |
| @@ -762,6 +763,16 @@ surrogates_to_codepoint (int low, int high) | |||
| 762 | return 0x10000 + (low - 0xDC00) + ((high - 0xD800) * 0x400); | 763 | return 0x10000 + (low - 0xDC00) + ((high - 0xD800) * 0x400); |
| 763 | } | 764 | } |
| 764 | 765 | ||
| 766 | /* Like build_string, but always returns a multibyte string, and is | ||
| 767 | optimized for speed when STR is a UTF-8 encoded text string. */ | ||
| 768 | |||
| 769 | INLINE Lisp_Object | ||
| 770 | build_string_from_utf8 (const char *str) | ||
| 771 | { | ||
| 772 | return make_string_from_utf8 (str, strlen (str)); | ||
| 773 | } | ||
| 774 | |||
| 775 | |||
| 765 | extern Lisp_Object preferred_coding_system (void); | 776 | extern Lisp_Object preferred_coding_system (void); |
| 766 | 777 | ||
| 767 | /* Coding system to be used to encode text for terminal display when | 778 | /* Coding system to be used to encode text for terminal display when |
diff --git a/src/conf_post.h b/src/conf_post.h index 7699d2c95bc..4af1ba9331f 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -59,7 +59,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 59 | into the same 1-, 2-, or 4-byte allocation unit in the MinGW | 59 | into the same 1-, 2-, or 4-byte allocation unit in the MinGW |
| 60 | builds. It was also needed to port to pre-C99 compilers, although | 60 | builds. It was also needed to port to pre-C99 compilers, although |
| 61 | we don't care about that any more. */ | 61 | we don't care about that any more. */ |
| 62 | #if NS_IMPL_GNUSTEP || defined(__MINGW32__) | 62 | #if NS_IMPL_GNUSTEP || defined __MINGW32__ |
| 63 | typedef unsigned int bool_bf; | 63 | typedef unsigned int bool_bf; |
| 64 | #else | 64 | #else |
| 65 | typedef bool bool_bf; | 65 | typedef bool bool_bf; |
| @@ -225,7 +225,9 @@ extern void _DebPrint (const char *fmt, ...); | |||
| 225 | extern char *emacs_getenv_TZ (void); | 225 | extern char *emacs_getenv_TZ (void); |
| 226 | extern int emacs_setenv_TZ (char const *); | 226 | extern int emacs_setenv_TZ (char const *); |
| 227 | 227 | ||
| 228 | #if __has_attribute (cold) | 228 | /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at |
| 229 | <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>. */ | ||
| 230 | #if __has_attribute (cold) && !defined __MINGW32__ | ||
| 229 | # define ATTRIBUTE_COLD __attribute__ ((cold)) | 231 | # define ATTRIBUTE_COLD __attribute__ ((cold)) |
| 230 | #else | 232 | #else |
| 231 | # define ATTRIBUTE_COLD | 233 | # define ATTRIBUTE_COLD |
diff --git a/src/data.c b/src/data.c index 7928a1dc41d..c1699aeae73 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -1122,20 +1122,21 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval, | |||
| 1122 | int offset = XBUFFER_OBJFWD (valcontents)->offset; | 1122 | int offset = XBUFFER_OBJFWD (valcontents)->offset; |
| 1123 | Lisp_Object predicate = XBUFFER_OBJFWD (valcontents)->predicate; | 1123 | Lisp_Object predicate = XBUFFER_OBJFWD (valcontents)->predicate; |
| 1124 | 1124 | ||
| 1125 | if (!NILP (newval)) | 1125 | if (!NILP (newval) && !NILP (predicate)) |
| 1126 | { | 1126 | { |
| 1127 | if (SYMBOLP (predicate)) | 1127 | eassert (SYMBOLP (predicate)); |
| 1128 | Lisp_Object choiceprop = Fget (predicate, Qchoice); | ||
| 1129 | if (!NILP (choiceprop)) | ||
| 1128 | { | 1130 | { |
| 1129 | Lisp_Object prop; | 1131 | if (NILP (Fmemq (newval, choiceprop))) |
| 1130 | 1132 | wrong_choice (choiceprop, newval); | |
| 1131 | if ((prop = Fget (predicate, Qchoice), !NILP (prop))) | 1133 | } |
| 1132 | { | 1134 | else |
| 1133 | if (NILP (Fmemq (newval, prop))) | 1135 | { |
| 1134 | wrong_choice (prop, newval); | 1136 | Lisp_Object rangeprop = Fget (predicate, Qrange); |
| 1135 | } | 1137 | if (CONSP (rangeprop)) |
| 1136 | else if ((prop = Fget (predicate, Qrange), !NILP (prop))) | ||
| 1137 | { | 1138 | { |
| 1138 | Lisp_Object min = XCAR (prop), max = XCDR (prop); | 1139 | Lisp_Object min = XCAR (rangeprop), max = XCDR (rangeprop); |
| 1139 | if (! NUMBERP (newval) | 1140 | if (! NUMBERP (newval) |
| 1140 | || NILP (CALLN (Fleq, min, newval, max))) | 1141 | || NILP (CALLN (Fleq, min, newval, max))) |
| 1141 | wrong_range (min, max, newval); | 1142 | wrong_range (min, max, newval); |
| @@ -1301,15 +1302,13 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, | |||
| 1301 | enum Set_Internal_Bind bindflag) | 1302 | enum Set_Internal_Bind bindflag) |
| 1302 | { | 1303 | { |
| 1303 | bool voide = EQ (newval, Qunbound); | 1304 | bool voide = EQ (newval, Qunbound); |
| 1304 | struct Lisp_Symbol *sym; | ||
| 1305 | Lisp_Object tem1; | ||
| 1306 | 1305 | ||
| 1307 | /* If restoring in a dead buffer, do nothing. */ | 1306 | /* If restoring in a dead buffer, do nothing. */ |
| 1308 | /* if (BUFFERP (where) && NILP (XBUFFER (where)->name)) | 1307 | /* if (BUFFERP (where) && NILP (XBUFFER (where)->name)) |
| 1309 | return; */ | 1308 | return; */ |
| 1310 | 1309 | ||
| 1311 | CHECK_SYMBOL (symbol); | 1310 | CHECK_SYMBOL (symbol); |
| 1312 | sym = XSYMBOL (symbol); | 1311 | struct Lisp_Symbol *sym = XSYMBOL (symbol); |
| 1313 | switch (sym->u.s.trapped_write) | 1312 | switch (sym->u.s.trapped_write) |
| 1314 | { | 1313 | { |
| 1315 | case SYMBOL_NOWRITE: | 1314 | case SYMBOL_NOWRITE: |
| @@ -1328,9 +1327,10 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, | |||
| 1328 | bindflag == SET_INTERNAL_UNBIND? Qunlet : | 1327 | bindflag == SET_INTERNAL_UNBIND? Qunlet : |
| 1329 | voide? Qmakunbound : Qset), | 1328 | voide? Qmakunbound : Qset), |
| 1330 | where); | 1329 | where); |
| 1331 | /* FALLTHROUGH! */ | 1330 | break; |
| 1331 | |||
| 1332 | case SYMBOL_UNTRAPPED_WRITE: | 1332 | case SYMBOL_UNTRAPPED_WRITE: |
| 1333 | break; | 1333 | break; |
| 1334 | 1334 | ||
| 1335 | default: emacs_abort (); | 1335 | default: emacs_abort (); |
| 1336 | } | 1336 | } |
| @@ -1363,8 +1363,9 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, | |||
| 1363 | 1363 | ||
| 1364 | /* Find the new binding. */ | 1364 | /* Find the new binding. */ |
| 1365 | XSETSYMBOL (symbol, sym); /* May have changed via aliasing. */ | 1365 | XSETSYMBOL (symbol, sym); /* May have changed via aliasing. */ |
| 1366 | tem1 = assq_no_quit (symbol, | 1366 | Lisp_Object tem1 |
| 1367 | BVAR (XBUFFER (where), local_var_alist)); | 1367 | = assq_no_quit (symbol, |
| 1368 | BVAR (XBUFFER (where), local_var_alist)); | ||
| 1368 | set_blv_where (blv, where); | 1369 | set_blv_where (blv, where); |
| 1369 | blv->found = true; | 1370 | blv->found = true; |
| 1370 | 1371 | ||
| @@ -1649,10 +1650,8 @@ void | |||
| 1649 | set_default_internal (Lisp_Object symbol, Lisp_Object value, | 1650 | set_default_internal (Lisp_Object symbol, Lisp_Object value, |
| 1650 | enum Set_Internal_Bind bindflag) | 1651 | enum Set_Internal_Bind bindflag) |
| 1651 | { | 1652 | { |
| 1652 | struct Lisp_Symbol *sym; | ||
| 1653 | |||
| 1654 | CHECK_SYMBOL (symbol); | 1653 | CHECK_SYMBOL (symbol); |
| 1655 | sym = XSYMBOL (symbol); | 1654 | struct Lisp_Symbol *sym = XSYMBOL (symbol); |
| 1656 | switch (sym->u.s.trapped_write) | 1655 | switch (sym->u.s.trapped_write) |
| 1657 | { | 1656 | { |
| 1658 | case SYMBOL_NOWRITE: | 1657 | case SYMBOL_NOWRITE: |
| @@ -1669,9 +1668,10 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value, | |||
| 1669 | /* Setting due to thread switching doesn't count. */ | 1668 | /* Setting due to thread switching doesn't count. */ |
| 1670 | && bindflag != SET_INTERNAL_THREAD_SWITCH) | 1669 | && bindflag != SET_INTERNAL_THREAD_SWITCH) |
| 1671 | notify_variable_watchers (symbol, value, Qset_default, Qnil); | 1670 | notify_variable_watchers (symbol, value, Qset_default, Qnil); |
| 1672 | /* FALLTHROUGH! */ | 1671 | break; |
| 1672 | |||
| 1673 | case SYMBOL_UNTRAPPED_WRITE: | 1673 | case SYMBOL_UNTRAPPED_WRITE: |
| 1674 | break; | 1674 | break; |
| 1675 | 1675 | ||
| 1676 | default: emacs_abort (); | 1676 | default: emacs_abort (); |
| 1677 | } | 1677 | } |
diff --git a/src/dbusbind.c b/src/dbusbind.c index 0afae6b05ad..850d176c08f 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -346,7 +346,6 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object) | |||
| 346 | int subtype; | 346 | int subtype; |
| 347 | Lisp_Object elt; | 347 | Lisp_Object elt; |
| 348 | char const *subsig; | 348 | char const *subsig; |
| 349 | int subsiglen; | ||
| 350 | char x[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | 349 | char x[DBUS_MAXIMUM_SIGNATURE_LENGTH]; |
| 351 | 350 | ||
| 352 | elt = object; | 351 | elt = object; |
| @@ -430,10 +429,9 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object) | |||
| 430 | elt = CDR_SAFE (XD_NEXT_VALUE (elt)); | 429 | elt = CDR_SAFE (XD_NEXT_VALUE (elt)); |
| 431 | } | 430 | } |
| 432 | 431 | ||
| 433 | subsiglen = snprintf (signature, DBUS_MAXIMUM_SIGNATURE_LENGTH, | 432 | signature[0] = dtype; |
| 434 | "%c%s", dtype, subsig); | 433 | signature[1] = '\0'; |
| 435 | if (! (0 <= subsiglen && subsiglen < DBUS_MAXIMUM_SIGNATURE_LENGTH)) | 434 | xd_signature_cat (signature, subsig); |
| 436 | string_overflow (); | ||
| 437 | break; | 435 | break; |
| 438 | 436 | ||
| 439 | case DBUS_TYPE_VARIANT: | 437 | case DBUS_TYPE_VARIANT: |
diff --git a/src/dispextern.h b/src/dispextern.h index 4d6d0371d38..ec1c9620be4 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -34,16 +34,45 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 34 | #ifdef HAVE_XRENDER | 34 | #ifdef HAVE_XRENDER |
| 35 | # include <X11/extensions/Xrender.h> | 35 | # include <X11/extensions/Xrender.h> |
| 36 | #endif | 36 | #endif |
| 37 | |||
| 38 | typedef XColor Emacs_Color; | ||
| 39 | typedef Cursor Emacs_Cursor; | ||
| 40 | #define No_Cursor (None) | ||
| 41 | typedef Pixmap Emacs_Pixmap; | ||
| 42 | typedef XRectangle Emacs_Rectangle; | ||
| 43 | typedef XGCValues Emacs_GC; | ||
| 37 | #else /* !HAVE_X_WINDOWS */ | 44 | #else /* !HAVE_X_WINDOWS */ |
| 38 | 45 | ||
| 39 | /* X-related stuff used by non-X gui code. */ | 46 | /* XColor-like struct used by non-X code. */ |
| 40 | 47 | ||
| 41 | typedef struct { | 48 | typedef struct |
| 49 | { | ||
| 42 | unsigned long pixel; | 50 | unsigned long pixel; |
| 43 | unsigned short red, green, blue; | 51 | unsigned short red, green, blue; |
| 44 | char flags; | 52 | } Emacs_Color; |
| 45 | char pad; | 53 | |
| 46 | } XColor; | 54 | /* Accommodate X's usage of None as a null resource ID. */ |
| 55 | #define No_Cursor (NULL) | ||
| 56 | |||
| 57 | /* XRectangle-like struct used by non-X GUI code. */ | ||
| 58 | typedef struct | ||
| 59 | { | ||
| 60 | int x, y; | ||
| 61 | unsigned width, height; | ||
| 62 | } Emacs_Rectangle; | ||
| 63 | |||
| 64 | /* XGCValues-like struct used by non-X GUI code. */ | ||
| 65 | typedef struct | ||
| 66 | { | ||
| 67 | unsigned long foreground; | ||
| 68 | unsigned long background; | ||
| 69 | } Emacs_GC; | ||
| 70 | |||
| 71 | /* Mask values to select foreground/background. */ | ||
| 72 | /* FIXME: The GC handling in w32 really should be redesigned as to not | ||
| 73 | need these. */ | ||
| 74 | #define GCForeground 0x01 | ||
| 75 | #define GCBackground 0x02 | ||
| 47 | 76 | ||
| 48 | #endif /* HAVE_X_WINDOWS */ | 77 | #endif /* HAVE_X_WINDOWS */ |
| 49 | 78 | ||
| @@ -63,16 +92,16 @@ xstrcasecmp (char const *a, char const *b) | |||
| 63 | #ifdef HAVE_X_WINDOWS | 92 | #ifdef HAVE_X_WINDOWS |
| 64 | #include <X11/Xresource.h> /* for XrmDatabase */ | 93 | #include <X11/Xresource.h> /* for XrmDatabase */ |
| 65 | typedef struct x_display_info Display_Info; | 94 | typedef struct x_display_info Display_Info; |
| 66 | typedef XImage * XImagePtr; | 95 | typedef XImage *Emacs_Pix_Container; |
| 67 | typedef XImagePtr XImagePtr_or_DC; | 96 | typedef XImage *Emacs_Pix_Context; |
| 68 | #define NativeRectangle XRectangle | 97 | #define NativeRectangle XRectangle |
| 69 | #endif | 98 | #endif |
| 70 | 99 | ||
| 71 | #ifdef HAVE_NTGUI | 100 | #ifdef HAVE_NTGUI |
| 72 | #include "w32gui.h" | 101 | #include "w32gui.h" |
| 73 | typedef struct w32_display_info Display_Info; | 102 | typedef struct w32_display_info Display_Info; |
| 74 | typedef XImage *XImagePtr; | 103 | typedef XImage *Emacs_Pix_Container; |
| 75 | typedef HDC XImagePtr_or_DC; | 104 | typedef HDC Emacs_Pix_Context; |
| 76 | #endif | 105 | #endif |
| 77 | 106 | ||
| 78 | #ifdef HAVE_NS | 107 | #ifdef HAVE_NS |
| @@ -80,8 +109,8 @@ typedef HDC XImagePtr_or_DC; | |||
| 80 | #define FACE_COLOR_TO_PIXEL(face_color, frame) ns_color_index_to_rgba(face_color, frame) | 109 | #define FACE_COLOR_TO_PIXEL(face_color, frame) ns_color_index_to_rgba(face_color, frame) |
| 81 | /* Following typedef needed to accommodate the MSDOS port, believe it or not. */ | 110 | /* Following typedef needed to accommodate the MSDOS port, believe it or not. */ |
| 82 | typedef struct ns_display_info Display_Info; | 111 | typedef struct ns_display_info Display_Info; |
| 83 | typedef Pixmap XImagePtr; | 112 | typedef Emacs_Pixmap Emacs_Pix_Container; |
| 84 | typedef XImagePtr XImagePtr_or_DC; | 113 | typedef Emacs_Pixmap Emacs_Pix_Context; |
| 85 | #else | 114 | #else |
| 86 | #define FACE_COLOR_TO_PIXEL(face_color, frame) face_color | 115 | #define FACE_COLOR_TO_PIXEL(face_color, frame) face_color |
| 87 | #endif | 116 | #endif |
| @@ -92,8 +121,7 @@ typedef XImagePtr XImagePtr_or_DC; | |||
| 92 | #endif | 121 | #endif |
| 93 | 122 | ||
| 94 | #ifndef HAVE_WINDOW_SYSTEM | 123 | #ifndef HAVE_WINDOW_SYSTEM |
| 95 | typedef int Cursor; | 124 | typedef void *Emacs_Cursor; |
| 96 | #define No_Cursor (0) | ||
| 97 | #endif | 125 | #endif |
| 98 | 126 | ||
| 99 | #ifndef NativeRectangle | 127 | #ifndef NativeRectangle |
| @@ -1040,7 +1068,7 @@ struct glyph_row | |||
| 1040 | #ifdef HAVE_WINDOW_SYSTEM | 1068 | #ifdef HAVE_WINDOW_SYSTEM |
| 1041 | /* Non-NULL means the current clipping area. This is temporarily | 1069 | /* Non-NULL means the current clipping area. This is temporarily |
| 1042 | set while exposing a region. Coordinates are frame-relative. */ | 1070 | set while exposing a region. Coordinates are frame-relative. */ |
| 1043 | XRectangle *clip; | 1071 | const Emacs_Rectangle *clip; |
| 1044 | #endif | 1072 | #endif |
| 1045 | }; | 1073 | }; |
| 1046 | 1074 | ||
| @@ -1281,9 +1309,6 @@ struct glyph_string | |||
| 1281 | /* The window on which the glyph string is drawn. */ | 1309 | /* The window on which the glyph string is drawn. */ |
| 1282 | struct window *w; | 1310 | struct window *w; |
| 1283 | 1311 | ||
| 1284 | /* X display and window for convenience. */ | ||
| 1285 | Display *display; | ||
| 1286 | |||
| 1287 | /* The glyph row for which this string was built. It determines the | 1312 | /* The glyph row for which this string was built. It determines the |
| 1288 | y-origin and height of the string. */ | 1313 | y-origin and height of the string. */ |
| 1289 | struct glyph_row *row; | 1314 | struct glyph_row *row; |
| @@ -1292,7 +1317,7 @@ struct glyph_string | |||
| 1292 | enum glyph_row_area area; | 1317 | enum glyph_row_area area; |
| 1293 | 1318 | ||
| 1294 | /* Characters to be drawn, and number of characters. */ | 1319 | /* Characters to be drawn, and number of characters. */ |
| 1295 | XChar2b *char2b; | 1320 | unsigned *char2b; |
| 1296 | int nchars; | 1321 | int nchars; |
| 1297 | 1322 | ||
| 1298 | /* A face-override for drawing cursors, mouse face and similar. */ | 1323 | /* A face-override for drawing cursors, mouse face and similar. */ |
| @@ -1353,7 +1378,7 @@ struct glyph_string | |||
| 1353 | GC gc; | 1378 | GC gc; |
| 1354 | #endif | 1379 | #endif |
| 1355 | #if defined (HAVE_NTGUI) | 1380 | #if defined (HAVE_NTGUI) |
| 1356 | XGCValues *gc; | 1381 | Emacs_GC *gc; |
| 1357 | HDC hdc; | 1382 | HDC hdc; |
| 1358 | #endif | 1383 | #endif |
| 1359 | 1384 | ||
| @@ -1595,8 +1620,11 @@ struct face | |||
| 1595 | 1620 | ||
| 1596 | /* If non-zero, this is a GC that we can use without modification for | 1621 | /* If non-zero, this is a GC that we can use without modification for |
| 1597 | drawing the characters in this face. */ | 1622 | drawing the characters in this face. */ |
| 1623 | # ifdef HAVE_X_WINDOWS | ||
| 1598 | GC gc; | 1624 | GC gc; |
| 1599 | 1625 | # else | |
| 1626 | Emacs_GC *gc; | ||
| 1627 | # endif | ||
| 1600 | /* Background stipple or bitmap used for this face. This is | 1628 | /* Background stipple or bitmap used for this face. This is |
| 1601 | an id as returned from load_pixmap. */ | 1629 | an id as returned from load_pixmap. */ |
| 1602 | ptrdiff_t stipple; | 1630 | ptrdiff_t stipple; |
| @@ -2891,7 +2919,7 @@ struct redisplay_interface | |||
| 2891 | void (*draw_glyph_string) (struct glyph_string *s); | 2919 | void (*draw_glyph_string) (struct glyph_string *s); |
| 2892 | 2920 | ||
| 2893 | /* Define cursor CURSOR on frame F. */ | 2921 | /* Define cursor CURSOR on frame F. */ |
| 2894 | void (*define_frame_cursor) (struct frame *f, Cursor cursor); | 2922 | void (*define_frame_cursor) (struct frame *f, Emacs_Cursor cursor); |
| 2895 | 2923 | ||
| 2896 | /* Clear the area at (X,Y,WIDTH,HEIGHT) of frame F. */ | 2924 | /* Clear the area at (X,Y,WIDTH,HEIGHT) of frame F. */ |
| 2897 | void (*clear_frame_area) (struct frame *f, int x, int y, | 2925 | void (*clear_frame_area) (struct frame *f, int x, int y, |
| @@ -2958,7 +2986,7 @@ struct image | |||
| 2958 | struct timespec timestamp; | 2986 | struct timespec timestamp; |
| 2959 | 2987 | ||
| 2960 | /* Pixmaps of the image. */ | 2988 | /* Pixmaps of the image. */ |
| 2961 | Pixmap pixmap, mask; | 2989 | Emacs_Pixmap pixmap, mask; |
| 2962 | 2990 | ||
| 2963 | #ifdef USE_CAIRO | 2991 | #ifdef USE_CAIRO |
| 2964 | void *cr_data; | 2992 | void *cr_data; |
| @@ -2968,7 +2996,7 @@ struct image | |||
| 2968 | Non-NULL means it and its Pixmap counterpart may be out of sync | 2996 | Non-NULL means it and its Pixmap counterpart may be out of sync |
| 2969 | and the latter is outdated. NULL means the X image has been | 2997 | and the latter is outdated. NULL means the X image has been |
| 2970 | synchronized to Pixmap. */ | 2998 | synchronized to Pixmap. */ |
| 2971 | XImagePtr ximg, mask_img; | 2999 | XImage *ximg, *mask_img; |
| 2972 | 3000 | ||
| 2973 | # ifdef HAVE_NATIVE_SCALING | 3001 | # ifdef HAVE_NATIVE_SCALING |
| 2974 | /* Picture versions of pixmap and mask for compositing. */ | 3002 | /* Picture versions of pixmap and mask for compositing. */ |
| @@ -3039,7 +3067,7 @@ struct image | |||
| 3039 | int hmargin, vmargin; | 3067 | int hmargin, vmargin; |
| 3040 | 3068 | ||
| 3041 | /* Reference to the type of the image. */ | 3069 | /* Reference to the type of the image. */ |
| 3042 | struct image_type *type; | 3070 | struct image_type const *type; |
| 3043 | 3071 | ||
| 3044 | /* True means that loading the image failed. Don't try again. */ | 3072 | /* True means that loading the image failed. Don't try again. */ |
| 3045 | bool load_failed_p; | 3073 | bool load_failed_p; |
| @@ -3314,7 +3342,9 @@ extern void handle_tool_bar_click (struct frame *, | |||
| 3314 | int, int, bool, int); | 3342 | int, int, bool, int); |
| 3315 | 3343 | ||
| 3316 | extern void expose_frame (struct frame *, int, int, int, int); | 3344 | extern void expose_frame (struct frame *, int, int, int, int); |
| 3317 | extern bool gui_intersect_rectangles (XRectangle *, XRectangle *, XRectangle *); | 3345 | extern bool gui_intersect_rectangles (const Emacs_Rectangle *, |
| 3346 | const Emacs_Rectangle *, | ||
| 3347 | Emacs_Rectangle *); | ||
| 3318 | #endif /* HAVE_WINDOW_SYSTEM */ | 3348 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 3319 | 3349 | ||
| 3320 | extern void note_mouse_highlight (struct frame *, int, int); | 3350 | extern void note_mouse_highlight (struct frame *, int, int); |
| @@ -3369,7 +3399,7 @@ extern void x_create_bitmap_mask (struct frame *, ptrdiff_t); | |||
| 3369 | #endif | 3399 | #endif |
| 3370 | extern Lisp_Object image_find_image_file (Lisp_Object); | 3400 | extern Lisp_Object image_find_image_file (Lisp_Object); |
| 3371 | 3401 | ||
| 3372 | void x_kill_gs_process (Pixmap, struct frame *); | 3402 | void x_kill_gs_process (Emacs_Pixmap, struct frame *); |
| 3373 | struct image_cache *make_image_cache (void); | 3403 | struct image_cache *make_image_cache (void); |
| 3374 | void free_image_cache (struct frame *); | 3404 | void free_image_cache (struct frame *); |
| 3375 | void clear_image_caches (Lisp_Object); | 3405 | void clear_image_caches (Lisp_Object); |
| @@ -3387,9 +3417,9 @@ ptrdiff_t lookup_image (struct frame *, Lisp_Object); | |||
| 3387 | #endif | 3417 | #endif |
| 3388 | 3418 | ||
| 3389 | RGB_PIXEL_COLOR image_background (struct image *, struct frame *, | 3419 | RGB_PIXEL_COLOR image_background (struct image *, struct frame *, |
| 3390 | XImagePtr_or_DC ximg); | 3420 | Emacs_Pix_Context img); |
| 3391 | int image_background_transparent (struct image *, struct frame *, | 3421 | int image_background_transparent (struct image *, struct frame *, |
| 3392 | XImagePtr_or_DC mask); | 3422 | Emacs_Pix_Context mask); |
| 3393 | 3423 | ||
| 3394 | int image_ascent (struct image *, struct face *, struct glyph_slice *); | 3424 | int image_ascent (struct image *, struct face *, struct glyph_slice *); |
| 3395 | 3425 | ||
| @@ -3413,8 +3443,8 @@ void x_free_colors (struct frame *, unsigned long *, int); | |||
| 3413 | 3443 | ||
| 3414 | void update_face_from_frame_parameter (struct frame *, Lisp_Object, | 3444 | void update_face_from_frame_parameter (struct frame *, Lisp_Object, |
| 3415 | Lisp_Object); | 3445 | Lisp_Object); |
| 3416 | extern bool tty_defined_color (struct frame *f, const char *, XColor *, bool, | 3446 | extern bool tty_defined_color (struct frame *, const char *, Emacs_Color *, |
| 3417 | bool); | 3447 | bool, bool); |
| 3418 | 3448 | ||
| 3419 | Lisp_Object tty_color_name (struct frame *, int); | 3449 | Lisp_Object tty_color_name (struct frame *, int); |
| 3420 | void clear_face_cache (bool); | 3450 | void clear_face_cache (bool); |
| @@ -3521,6 +3551,10 @@ void clear_glyph_matrix_rows (struct glyph_matrix *, int, int); | |||
| 3521 | void clear_glyph_row (struct glyph_row *); | 3551 | void clear_glyph_row (struct glyph_row *); |
| 3522 | void prepare_desired_row (struct window *, struct glyph_row *, bool); | 3552 | void prepare_desired_row (struct window *, struct glyph_row *, bool); |
| 3523 | void update_single_window (struct window *); | 3553 | void update_single_window (struct window *); |
| 3554 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 3555 | extern void gui_update_window_begin (struct window *); | ||
| 3556 | extern void gui_update_window_end (struct window *, bool, bool); | ||
| 3557 | #endif | ||
| 3524 | void do_pending_window_change (bool); | 3558 | void do_pending_window_change (bool); |
| 3525 | void change_frame_size (struct frame *, int, int, bool, bool, bool, bool); | 3559 | void change_frame_size (struct frame *, int, int, bool, bool, bool, bool); |
| 3526 | void init_display (void); | 3560 | void init_display (void); |
diff --git a/src/dispnew.c b/src/dispnew.c index 25a2d1cd38b..52a7b6d6ee0 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -3390,7 +3390,9 @@ update_window (struct window *w, bool force_p) | |||
| 3390 | struct glyph_matrix *desired_matrix = w->desired_matrix; | 3390 | struct glyph_matrix *desired_matrix = w->desired_matrix; |
| 3391 | bool paused_p; | 3391 | bool paused_p; |
| 3392 | int preempt_count = clip_to_bounds (1, baud_rate / 2400 + 1, INT_MAX); | 3392 | int preempt_count = clip_to_bounds (1, baud_rate / 2400 + 1, INT_MAX); |
| 3393 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 3393 | struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); | 3394 | struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); |
| 3395 | #endif | ||
| 3394 | #ifdef GLYPH_DEBUG | 3396 | #ifdef GLYPH_DEBUG |
| 3395 | /* Check that W's frame doesn't have glyph matrices. */ | 3397 | /* Check that W's frame doesn't have glyph matrices. */ |
| 3396 | eassert (FRAME_WINDOW_P (XFRAME (WINDOW_FRAME (w)))); | 3398 | eassert (FRAME_WINDOW_P (XFRAME (WINDOW_FRAME (w)))); |
| @@ -3411,7 +3413,9 @@ update_window (struct window *w, bool force_p) | |||
| 3411 | bool changed_p = 0, mouse_face_overwritten_p = 0; | 3413 | bool changed_p = 0, mouse_face_overwritten_p = 0; |
| 3412 | int n_updated = 0; | 3414 | int n_updated = 0; |
| 3413 | 3415 | ||
| 3414 | rif->update_window_begin_hook (w); | 3416 | #ifdef HAVE_WINDOW_SYSTEM |
| 3417 | gui_update_window_begin (w); | ||
| 3418 | #endif | ||
| 3415 | yb = window_text_bottom_y (w); | 3419 | yb = window_text_bottom_y (w); |
| 3416 | row = MATRIX_ROW (desired_matrix, 0); | 3420 | row = MATRIX_ROW (desired_matrix, 0); |
| 3417 | end = MATRIX_MODE_LINE_ROW (desired_matrix); | 3421 | end = MATRIX_MODE_LINE_ROW (desired_matrix); |
| @@ -3533,13 +3537,13 @@ update_window (struct window *w, bool force_p) | |||
| 3533 | 3537 | ||
| 3534 | #ifdef HAVE_WINDOW_SYSTEM | 3538 | #ifdef HAVE_WINDOW_SYSTEM |
| 3535 | update_window_fringes (w, 0); | 3539 | update_window_fringes (w, 0); |
| 3536 | #endif | ||
| 3537 | 3540 | ||
| 3538 | /* End the update of window W. Don't set the cursor if we | 3541 | /* End the update of window W. Don't set the cursor if we |
| 3539 | paused updating the display because in this case, | 3542 | paused updating the display because in this case, |
| 3540 | set_window_cursor_after_update hasn't been called, and | 3543 | set_window_cursor_after_update hasn't been called, and |
| 3541 | W->output_cursor doesn't contain the cursor location. */ | 3544 | W->output_cursor doesn't contain the cursor location. */ |
| 3542 | rif->update_window_end_hook (w, !paused_p, mouse_face_overwritten_p); | 3545 | gui_update_window_end (w, !paused_p, mouse_face_overwritten_p); |
| 3546 | #endif | ||
| 3543 | } | 3547 | } |
| 3544 | else | 3548 | else |
| 3545 | paused_p = 1; | 3549 | paused_p = 1; |
| @@ -3555,6 +3559,90 @@ update_window (struct window *w, bool force_p) | |||
| 3555 | return paused_p; | 3559 | return paused_p; |
| 3556 | } | 3560 | } |
| 3557 | 3561 | ||
| 3562 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 3563 | |||
| 3564 | /* Start update of window W. */ | ||
| 3565 | |||
| 3566 | void | ||
| 3567 | gui_update_window_begin (struct window *w) | ||
| 3568 | { | ||
| 3569 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | ||
| 3570 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | ||
| 3571 | |||
| 3572 | block_input (); | ||
| 3573 | |||
| 3574 | if (FRAME_RIF (f)->update_window_begin_hook) | ||
| 3575 | FRAME_RIF (f)->update_window_begin_hook (w); | ||
| 3576 | |||
| 3577 | w->output_cursor = w->cursor; | ||
| 3578 | |||
| 3579 | if (f == hlinfo->mouse_face_mouse_frame) | ||
| 3580 | { | ||
| 3581 | /* Don't do highlighting for mouse motion during the update. */ | ||
| 3582 | hlinfo->mouse_face_defer = true; | ||
| 3583 | |||
| 3584 | /* If the frame needs to be redrawn, simply forget about any | ||
| 3585 | prior mouse highlighting. */ | ||
| 3586 | if (FRAME_GARBAGED_P (f)) | ||
| 3587 | hlinfo->mouse_face_window = Qnil; | ||
| 3588 | } | ||
| 3589 | |||
| 3590 | unblock_input (); | ||
| 3591 | } | ||
| 3592 | |||
| 3593 | /* End update of window W. | ||
| 3594 | |||
| 3595 | Draw vertical borders between horizontally adjacent windows, and | ||
| 3596 | display W's cursor if CURSOR_ON_P is non-zero. | ||
| 3597 | |||
| 3598 | MOUSE_FACE_OVERWRITTEN_P non-zero means that some row containing | ||
| 3599 | glyphs in mouse-face were overwritten. In that case we have to | ||
| 3600 | make sure that the mouse-highlight is properly redrawn. */ | ||
| 3601 | void | ||
| 3602 | gui_update_window_end (struct window *w, bool cursor_on_p, | ||
| 3603 | bool mouse_face_overwritten_p) | ||
| 3604 | { | ||
| 3605 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | ||
| 3606 | |||
| 3607 | block_input (); | ||
| 3608 | |||
| 3609 | /* Pseudo windows don't have cursors, so don't display them here. */ | ||
| 3610 | if (!w->pseudo_window_p) | ||
| 3611 | { | ||
| 3612 | |||
| 3613 | if (cursor_on_p) | ||
| 3614 | display_and_set_cursor (w, true, | ||
| 3615 | w->output_cursor.hpos, w->output_cursor.vpos, | ||
| 3616 | w->output_cursor.x, w->output_cursor.y); | ||
| 3617 | |||
| 3618 | if (draw_window_fringes (w, true)) | ||
| 3619 | { | ||
| 3620 | if (WINDOW_RIGHT_DIVIDER_WIDTH (w)) | ||
| 3621 | gui_draw_right_divider (w); | ||
| 3622 | else | ||
| 3623 | gui_draw_vertical_border (w); | ||
| 3624 | } | ||
| 3625 | } | ||
| 3626 | |||
| 3627 | /* If a row with mouse-face was overwritten, arrange for | ||
| 3628 | frame_up_to_date_hook to redisplay the mouse highlight. */ | ||
| 3629 | if (mouse_face_overwritten_p) | ||
| 3630 | { | ||
| 3631 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | ||
| 3632 | |||
| 3633 | hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; | ||
| 3634 | hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; | ||
| 3635 | hlinfo->mouse_face_window = Qnil; | ||
| 3636 | } | ||
| 3637 | |||
| 3638 | if (FRAME_RIF (f)->update_window_end_hook) | ||
| 3639 | FRAME_RIF (f)->update_window_end_hook (w, | ||
| 3640 | cursor_on_p, | ||
| 3641 | mouse_face_overwritten_p); | ||
| 3642 | unblock_input (); | ||
| 3643 | } | ||
| 3644 | |||
| 3645 | #endif /* HAVE_WINDOW_SYSTEM */ | ||
| 3558 | 3646 | ||
| 3559 | /* Update the display of area AREA in window W, row number VPOS. | 3647 | /* Update the display of area AREA in window W, row number VPOS. |
| 3560 | AREA can be either LEFT_MARGIN_AREA or RIGHT_MARGIN_AREA. */ | 3648 | AREA can be either LEFT_MARGIN_AREA or RIGHT_MARGIN_AREA. */ |
diff --git a/src/dynlib.h b/src/dynlib.h index 2688712a13e..43a0e045f5b 100644 --- a/src/dynlib.h +++ b/src/dynlib.h | |||
| @@ -29,7 +29,7 @@ const char *dynlib_error (void); | |||
| 29 | 29 | ||
| 30 | ATTRIBUTE_MAY_ALIAS void *dynlib_sym (dynlib_handle_ptr h, const char *sym); | 30 | ATTRIBUTE_MAY_ALIAS void *dynlib_sym (dynlib_handle_ptr h, const char *sym); |
| 31 | 31 | ||
| 32 | typedef struct dynlib_function_ptr_nonce *(ATTRIBUTE_MAY_ALIAS *dynlib_function_ptr) (void); | 32 | typedef void (ATTRIBUTE_MAY_ALIAS *dynlib_function_ptr) (void); |
| 33 | dynlib_function_ptr dynlib_func (dynlib_handle_ptr h, const char *sym); | 33 | dynlib_function_ptr dynlib_func (dynlib_handle_ptr h, const char *sym); |
| 34 | 34 | ||
| 35 | /* Sets *FILE to the file name from which PTR was loaded, and *SYM to | 35 | /* Sets *FILE to the file name from which PTR was loaded, and *SYM to |
diff --git a/src/emacs-module.c b/src/emacs-module.c index 80a04bafc2d..907a5d8225a 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -101,11 +101,6 @@ To add a new module function, proceed as follows: | |||
| 101 | # pragma GCC diagnostic ignored "-Wclobbered" | 101 | # pragma GCC diagnostic ignored "-Wclobbered" |
| 102 | #endif | 102 | #endif |
| 103 | 103 | ||
| 104 | /* This module is lackadaisical about function casts. */ | ||
| 105 | #if GNUC_PREREQ (8, 0, 0) | ||
| 106 | # pragma GCC diagnostic ignored "-Wcast-function-type" | ||
| 107 | #endif | ||
| 108 | |||
| 109 | /* We use different strategies for allocating the user-visible objects | 104 | /* We use different strategies for allocating the user-visible objects |
| 110 | (struct emacs_runtime, emacs_env, emacs_value), depending on | 105 | (struct emacs_runtime, emacs_env, emacs_value), depending on |
| 111 | whether the user supplied the -module-assertions flag. If | 106 | whether the user supplied the -module-assertions flag. If |
| @@ -223,8 +218,6 @@ static void module_reset_handlerlist (struct handler **); | |||
| 223 | static bool value_storage_contains_p (const struct emacs_value_storage *, | 218 | static bool value_storage_contains_p (const struct emacs_value_storage *, |
| 224 | emacs_value, ptrdiff_t *); | 219 | emacs_value, ptrdiff_t *); |
| 225 | static Lisp_Object module_encode (Lisp_Object); | 220 | static Lisp_Object module_encode (Lisp_Object); |
| 226 | static Lisp_Object module_decode (Lisp_Object); | ||
| 227 | static Lisp_Object module_decode_copy (Lisp_Object); | ||
| 228 | 221 | ||
| 229 | static bool module_assertions = false; | 222 | static bool module_assertions = false; |
| 230 | 223 | ||
| @@ -532,10 +525,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, | |||
| 532 | function->data = data; | 525 | function->data = data; |
| 533 | 526 | ||
| 534 | if (documentation) | 527 | if (documentation) |
| 535 | { | 528 | function->documentation = build_string_from_utf8 (documentation); |
| 536 | AUTO_STRING (unibyte_doc, documentation); | ||
| 537 | function->documentation = module_decode_copy (unibyte_doc); | ||
| 538 | } | ||
| 539 | 529 | ||
| 540 | Lisp_Object result; | 530 | Lisp_Object result; |
| 541 | XSET_MODULE_FUNCTION (result, function); | 531 | XSET_MODULE_FUNCTION (result, function); |
| @@ -668,8 +658,8 @@ module_make_string (emacs_env *env, const char *str, ptrdiff_t length) | |||
| 668 | MODULE_FUNCTION_BEGIN (NULL); | 658 | MODULE_FUNCTION_BEGIN (NULL); |
| 669 | if (! (0 <= length && length <= STRING_BYTES_BOUND)) | 659 | if (! (0 <= length && length <= STRING_BYTES_BOUND)) |
| 670 | overflow_error (); | 660 | overflow_error (); |
| 671 | Lisp_Object lstr = make_unibyte_string (str, length); | 661 | Lisp_Object lstr = make_string_from_utf8 (str, length); |
| 672 | return lisp_to_value (env, module_decode (lstr)); | 662 | return lisp_to_value (env, lstr); |
| 673 | } | 663 | } |
| 674 | 664 | ||
| 675 | static emacs_value | 665 | static emacs_value |
| @@ -790,10 +780,7 @@ module_extract_big_integer (emacs_env *env, emacs_value value, | |||
| 790 | MODULE_FUNCTION_BEGIN (); | 780 | MODULE_FUNCTION_BEGIN (); |
| 791 | Lisp_Object o = value_to_lisp (value); | 781 | Lisp_Object o = value_to_lisp (value); |
| 792 | CHECK_INTEGER (o); | 782 | CHECK_INTEGER (o); |
| 793 | if (FIXNUMP (o)) | 783 | mpz_set_integer (result->value, o); |
| 794 | mpz_set_intmax (result->value, XFIXNUM (o)); | ||
| 795 | else | ||
| 796 | mpz_set (result->value, XBIGNUM (o)->value); | ||
| 797 | } | 784 | } |
| 798 | 785 | ||
| 799 | static emacs_value | 786 | static emacs_value |
| @@ -907,6 +894,11 @@ funcall_module (Lisp_Object function, ptrdiff_t nargs, Lisp_Object *arglist) | |||
| 907 | memory_full (sizeof *args[i]); | 894 | memory_full (sizeof *args[i]); |
| 908 | } | 895 | } |
| 909 | 896 | ||
| 897 | /* The only possibility of getting an error until here is failure to | ||
| 898 | allocate memory for the arguments, but then we already should | ||
| 899 | have signaled an error before. */ | ||
| 900 | eassert (priv.pending_non_local_exit == emacs_funcall_exit_return); | ||
| 901 | |||
| 910 | emacs_value ret = func->subr (env, nargs, args, func->data); | 902 | emacs_value ret = func->subr (env, nargs, args, func->data); |
| 911 | 903 | ||
| 912 | eassert (&priv == env->private_members); | 904 | eassert (&priv == env->private_members); |
| @@ -1030,18 +1022,6 @@ module_encode (Lisp_Object string) | |||
| 1030 | return code_convert_string (string, Qutf_8_unix, Qt, true, true, true); | 1022 | return code_convert_string (string, Qutf_8_unix, Qt, true, true, true); |
| 1031 | } | 1023 | } |
| 1032 | 1024 | ||
| 1033 | static Lisp_Object | ||
| 1034 | module_decode (Lisp_Object string) | ||
| 1035 | { | ||
| 1036 | return code_convert_string (string, Qutf_8_unix, Qt, false, true, true); | ||
| 1037 | } | ||
| 1038 | |||
| 1039 | static Lisp_Object | ||
| 1040 | module_decode_copy (Lisp_Object string) | ||
| 1041 | { | ||
| 1042 | return code_convert_string (string, Qutf_8_unix, Qt, false, false, true); | ||
| 1043 | } | ||
| 1044 | |||
| 1045 | 1025 | ||
| 1046 | /* Value conversion. */ | 1026 | /* Value conversion. */ |
| 1047 | 1027 | ||
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in index fbc62a61ef4..9955e30eb7a 100644 --- a/src/emacs-module.h.in +++ b/src/emacs-module.h.in | |||
| @@ -32,6 +32,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 32 | #include <gmp.h> | 32 | #include <gmp.h> |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #define EMACS_MAJOR_VERSION @emacs_major_version@ | ||
| 36 | |||
| 35 | #if defined __cplusplus && __cplusplus >= 201103L | 37 | #if defined __cplusplus && __cplusplus >= 201103L |
| 36 | # define EMACS_NOEXCEPT noexcept | 38 | # define EMACS_NOEXCEPT noexcept |
| 37 | #else | 39 | #else |
diff --git a/src/emacs.c b/src/emacs.c index 86d2bc65ac7..fd46540ce22 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -2494,9 +2494,6 @@ You must run Emacs in batch mode in order to dump it. */) | |||
| 2494 | # ifdef WINDOWSNT | 2494 | # ifdef WINDOWSNT |
| 2495 | Vlibrary_cache = Qnil; | 2495 | Vlibrary_cache = Qnil; |
| 2496 | # endif | 2496 | # endif |
| 2497 | # ifdef HAVE_WINDOW_SYSTEM | ||
| 2498 | reset_image_types (); | ||
| 2499 | # endif | ||
| 2500 | 2497 | ||
| 2501 | Vpurify_flag = tem; | 2498 | Vpurify_flag = tem; |
| 2502 | 2499 | ||
diff --git a/src/eval.c b/src/eval.c index 3fd9a40a3a2..567c32e0d75 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -715,6 +715,25 @@ DEFUN ("set-default-toplevel-value", Fset_default_toplevel_value, | |||
| 715 | return Qnil; | 715 | return Qnil; |
| 716 | } | 716 | } |
| 717 | 717 | ||
| 718 | DEFUN ("internal--define-uninitialized-variable", | ||
| 719 | Finternal__define_uninitialized_variable, | ||
| 720 | Sinternal__define_uninitialized_variable, 1, 2, 0, | ||
| 721 | doc: /* Define SYMBOL as a variable, with DOC as its docstring. | ||
| 722 | This is like `defvar' and `defconst' but without affecting the variable's | ||
| 723 | value. */) | ||
| 724 | (Lisp_Object symbol, Lisp_Object doc) | ||
| 725 | { | ||
| 726 | XSYMBOL (symbol)->u.s.declared_special = true; | ||
| 727 | if (!NILP (doc)) | ||
| 728 | { | ||
| 729 | if (!NILP (Vpurify_flag)) | ||
| 730 | doc = Fpurecopy (doc); | ||
| 731 | Fput (symbol, Qvariable_documentation, doc); | ||
| 732 | } | ||
| 733 | LOADHIST_ATTACH (symbol); | ||
| 734 | return Qnil; | ||
| 735 | } | ||
| 736 | |||
| 718 | DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0, | 737 | DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0, |
| 719 | doc: /* Define SYMBOL as a variable, and return SYMBOL. | 738 | doc: /* Define SYMBOL as a variable, and return SYMBOL. |
| 720 | You are not required to define a variable in order to use it, but | 739 | You are not required to define a variable in order to use it, but |
| @@ -754,32 +773,25 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */) | |||
| 754 | { | 773 | { |
| 755 | if (!NILP (XCDR (tail)) && !NILP (XCDR (XCDR (tail)))) | 774 | if (!NILP (XCDR (tail)) && !NILP (XCDR (XCDR (tail)))) |
| 756 | error ("Too many arguments"); | 775 | error ("Too many arguments"); |
| 776 | Lisp_Object exp = XCAR (tail); | ||
| 757 | 777 | ||
| 758 | tem = Fdefault_boundp (sym); | 778 | tem = Fdefault_boundp (sym); |
| 779 | tail = XCDR (tail); | ||
| 759 | 780 | ||
| 760 | /* Do it before evaluating the initial value, for self-references. */ | 781 | /* Do it before evaluating the initial value, for self-references. */ |
| 761 | XSYMBOL (sym)->u.s.declared_special = true; | 782 | Finternal__define_uninitialized_variable (sym, CAR (tail)); |
| 762 | 783 | ||
| 763 | if (NILP (tem)) | 784 | if (NILP (tem)) |
| 764 | Fset_default (sym, eval_sub (XCAR (tail))); | 785 | Fset_default (sym, eval_sub (exp)); |
| 765 | else | 786 | else |
| 766 | { /* Check if there is really a global binding rather than just a let | 787 | { /* Check if there is really a global binding rather than just a let |
| 767 | binding that shadows the global unboundness of the var. */ | 788 | binding that shadows the global unboundness of the var. */ |
| 768 | union specbinding *binding = default_toplevel_binding (sym); | 789 | union specbinding *binding = default_toplevel_binding (sym); |
| 769 | if (binding && EQ (specpdl_old_value (binding), Qunbound)) | 790 | if (binding && EQ (specpdl_old_value (binding), Qunbound)) |
| 770 | { | 791 | { |
| 771 | set_specpdl_old_value (binding, eval_sub (XCAR (tail))); | 792 | set_specpdl_old_value (binding, eval_sub (exp)); |
| 772 | } | 793 | } |
| 773 | } | 794 | } |
| 774 | tail = XCDR (tail); | ||
| 775 | tem = Fcar (tail); | ||
| 776 | if (!NILP (tem)) | ||
| 777 | { | ||
| 778 | if (!NILP (Vpurify_flag)) | ||
| 779 | tem = Fpurecopy (tem); | ||
| 780 | Fput (sym, Qvariable_documentation, tem); | ||
| 781 | } | ||
| 782 | LOADHIST_ATTACH (sym); | ||
| 783 | } | 795 | } |
| 784 | else if (!NILP (Vinternal_interpreter_environment) | 796 | else if (!NILP (Vinternal_interpreter_environment) |
| 785 | && (SYMBOLP (sym) && !XSYMBOL (sym)->u.s.declared_special)) | 797 | && (SYMBOLP (sym) && !XSYMBOL (sym)->u.s.declared_special)) |
| @@ -827,19 +839,12 @@ usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */) | |||
| 827 | docstring = XCAR (XCDR (XCDR (args))); | 839 | docstring = XCAR (XCDR (XCDR (args))); |
| 828 | } | 840 | } |
| 829 | 841 | ||
| 842 | Finternal__define_uninitialized_variable (sym, docstring); | ||
| 830 | tem = eval_sub (XCAR (XCDR (args))); | 843 | tem = eval_sub (XCAR (XCDR (args))); |
| 831 | if (!NILP (Vpurify_flag)) | 844 | if (!NILP (Vpurify_flag)) |
| 832 | tem = Fpurecopy (tem); | 845 | tem = Fpurecopy (tem); |
| 833 | Fset_default (sym, tem); | 846 | Fset_default (sym, tem); /* FIXME: set-default-toplevel-value? */ |
| 834 | XSYMBOL (sym)->u.s.declared_special = true; | 847 | Fput (sym, Qrisky_local_variable, Qt); /* FIXME: Why? */ |
| 835 | if (!NILP (docstring)) | ||
| 836 | { | ||
| 837 | if (!NILP (Vpurify_flag)) | ||
| 838 | docstring = Fpurecopy (docstring); | ||
| 839 | Fput (sym, Qvariable_documentation, docstring); | ||
| 840 | } | ||
| 841 | Fput (sym, Qrisky_local_variable, Qt); | ||
| 842 | LOADHIST_ATTACH (sym); | ||
| 843 | return sym; | 848 | return sym; |
| 844 | } | 849 | } |
| 845 | 850 | ||
| @@ -4198,6 +4203,7 @@ alist of active lexical bindings. */); | |||
| 4198 | defsubr (&Sdefvaralias); | 4203 | defsubr (&Sdefvaralias); |
| 4199 | DEFSYM (Qdefvaralias, "defvaralias"); | 4204 | DEFSYM (Qdefvaralias, "defvaralias"); |
| 4200 | defsubr (&Sdefconst); | 4205 | defsubr (&Sdefconst); |
| 4206 | defsubr (&Sinternal__define_uninitialized_variable); | ||
| 4201 | defsubr (&Smake_var_non_special); | 4207 | defsubr (&Smake_var_non_special); |
| 4202 | defsubr (&Slet); | 4208 | defsubr (&Slet); |
| 4203 | defsubr (&SletX); | 4209 | defsubr (&SletX); |
diff --git a/src/fileio.c b/src/fileio.c index 4ee125d7de2..9e9779967dd 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -5802,6 +5802,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5802 | && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b) | 5802 | && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b) |
| 5803 | && BUF_AUTOSAVE_MODIFF (b) < BUF_MODIFF (b) | 5803 | && BUF_AUTOSAVE_MODIFF (b) < BUF_MODIFF (b) |
| 5804 | /* -1 means we've turned off autosaving for a while--see below. */ | 5804 | /* -1 means we've turned off autosaving for a while--see below. */ |
| 5805 | && FIXNUMP (BVAR (b, save_length)) | ||
| 5805 | && XFIXNUM (BVAR (b, save_length)) >= 0 | 5806 | && XFIXNUM (BVAR (b, save_length)) >= 0 |
| 5806 | && (do_handled_files | 5807 | && (do_handled_files |
| 5807 | || NILP (Ffind_file_name_handler (BVAR (b, auto_save_file_name), | 5808 | || NILP (Ffind_file_name_handler (BVAR (b, auto_save_file_name), |
| @@ -5815,13 +5816,17 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5815 | && before_time.tv_sec - b->auto_save_failure_time < 1200) | 5816 | && before_time.tv_sec - b->auto_save_failure_time < 1200) |
| 5816 | continue; | 5817 | continue; |
| 5817 | 5818 | ||
| 5819 | enum { growth_factor = 4 }; | ||
| 5820 | verify (BUF_BYTES_MAX <= EMACS_INT_MAX / growth_factor); | ||
| 5821 | |||
| 5818 | set_buffer_internal (b); | 5822 | set_buffer_internal (b); |
| 5819 | if (NILP (Vauto_save_include_big_deletions) | 5823 | if (NILP (Vauto_save_include_big_deletions) |
| 5820 | && (XFIXNAT (BVAR (b, save_length)) * 10 | 5824 | && FIXNUMP (BVAR (b, save_length)) |
| 5821 | > (BUF_Z (b) - BUF_BEG (b)) * 13) | ||
| 5822 | /* A short file is likely to change a large fraction; | 5825 | /* A short file is likely to change a large fraction; |
| 5823 | spare the user annoying messages. */ | 5826 | spare the user annoying messages. */ |
| 5824 | && XFIXNAT (BVAR (b, save_length)) > 5000 | 5827 | && XFIXNAT (BVAR (b, save_length)) > 5000 |
| 5828 | && (growth_factor * (BUF_Z (b) - BUF_BEG (b)) | ||
| 5829 | < (growth_factor - 1) * XFIXNAT (BVAR (b, save_length))) | ||
| 5825 | /* These messages are frequent and annoying for `*mail*'. */ | 5830 | /* These messages are frequent and annoying for `*mail*'. */ |
| 5826 | && !NILP (BVAR (b, filename)) | 5831 | && !NILP (BVAR (b, filename)) |
| 5827 | && NILP (no_message)) | 5832 | && NILP (no_message)) |
| @@ -1131,10 +1131,8 @@ string the same way whether it is unibyte or multibyte.) */) | |||
| 1131 | DEFUN ("string-make-unibyte", Fstring_make_unibyte, Sstring_make_unibyte, | 1131 | DEFUN ("string-make-unibyte", Fstring_make_unibyte, Sstring_make_unibyte, |
| 1132 | 1, 1, 0, | 1132 | 1, 1, 0, |
| 1133 | doc: /* Return the unibyte equivalent of STRING. | 1133 | doc: /* Return the unibyte equivalent of STRING. |
| 1134 | Multibyte character codes are converted to unibyte according to | 1134 | Multibyte character codes above 255 are converted to unibyte |
| 1135 | `nonascii-translation-table' or, if that is nil, `nonascii-insert-offset'. | 1135 | by taking just the low 8 bits of each character's code. */) |
| 1136 | If the lookup in the translation table fails, this function takes just | ||
| 1137 | the low 8 bits of each character. */) | ||
| 1138 | (Lisp_Object string) | 1136 | (Lisp_Object string) |
| 1139 | { | 1137 | { |
| 1140 | CHECK_STRING (string); | 1138 | CHECK_STRING (string); |
diff --git a/src/font.h b/src/font.h index 1f62a61f0be..a590bda3db4 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -651,7 +651,7 @@ struct font_driver | |||
| 651 | the font FONT and the sequence of glyph codes CODE, and store the | 651 | the font FONT and the sequence of glyph codes CODE, and store the |
| 652 | result in METRICS. */ | 652 | result in METRICS. */ |
| 653 | void (*text_extents) (struct font *font, | 653 | void (*text_extents) (struct font *font, |
| 654 | unsigned *code, int nglyphs, | 654 | const unsigned *code, int nglyphs, |
| 655 | struct font_metrics *metrics); | 655 | struct font_metrics *metrics); |
| 656 | 656 | ||
| 657 | #ifdef HAVE_WINDOW_SYSTEM | 657 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -920,7 +920,7 @@ extern Lisp_Object ftfont_shape (Lisp_Object, Lisp_Object); | |||
| 920 | extern unsigned ftfont_encode_char (struct font *, int); | 920 | extern unsigned ftfont_encode_char (struct font *, int); |
| 921 | extern void ftfont_close (struct font *); | 921 | extern void ftfont_close (struct font *); |
| 922 | extern void ftfont_filter_properties (Lisp_Object, Lisp_Object); | 922 | extern void ftfont_filter_properties (Lisp_Object, Lisp_Object); |
| 923 | extern void ftfont_text_extents (struct font *, unsigned *, int, | 923 | extern void ftfont_text_extents (struct font *, const unsigned *, int, |
| 924 | struct font_metrics *); | 924 | struct font_metrics *); |
| 925 | #ifdef HAVE_HARFBUZZ | 925 | #ifdef HAVE_HARFBUZZ |
| 926 | extern Lisp_Object fthbfont_combining_capability (struct font *); | 926 | extern Lisp_Object fthbfont_combining_capability (struct font *); |
diff --git a/src/frame.h b/src/frame.h index b8aed823afb..781063340d8 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -1626,7 +1626,7 @@ flush_frame (struct frame *f) | |||
| 1626 | #ifdef HAVE_WINDOW_SYSTEM | 1626 | #ifdef HAVE_WINDOW_SYSTEM |
| 1627 | 1627 | ||
| 1628 | struct MonitorInfo { | 1628 | struct MonitorInfo { |
| 1629 | XRectangle geom, work; | 1629 | Emacs_Rectangle geom, work; |
| 1630 | int mm_width, mm_height; | 1630 | int mm_width, mm_height; |
| 1631 | char *name; | 1631 | char *name; |
| 1632 | }; | 1632 | }; |
diff --git a/src/ftcrfont.c b/src/ftcrfont.c index dc59c2bcadc..79bf68141dc 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c | |||
| @@ -79,7 +79,6 @@ ftcrfont_glyph_extents (struct font *font, | |||
| 79 | cairo_glyph_t cr_glyph = {.index = glyph}; | 79 | cairo_glyph_t cr_glyph = {.index = glyph}; |
| 80 | cairo_text_extents_t extents; | 80 | cairo_text_extents_t extents; |
| 81 | 81 | ||
| 82 | FT_Activate_Size (ftcrfont_info->ft_size_draw); | ||
| 83 | cairo_scaled_font_glyph_extents (ftcrfont_info->cr_scaled_font, | 82 | cairo_scaled_font_glyph_extents (ftcrfont_info->cr_scaled_font, |
| 84 | &cr_glyph, 1, &extents); | 83 | &cr_glyph, 1, &extents); |
| 85 | cache->lbearing = floor (extents.x_bearing); | 84 | cache->lbearing = floor (extents.x_bearing); |
| @@ -110,99 +109,168 @@ ftcrfont_match (struct frame *f, Lisp_Object spec) | |||
| 110 | static Lisp_Object | 109 | static Lisp_Object |
| 111 | ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | 110 | ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) |
| 112 | { | 111 | { |
| 113 | Lisp_Object font_object; | 112 | FcResult result; |
| 114 | 113 | Lisp_Object val, filename, font_object; | |
| 115 | FT_UInt size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX)); | 114 | FcPattern *pat, *match; |
| 115 | struct font_info *ftcrfont_info; | ||
| 116 | struct font *font; | ||
| 117 | double size = 0; | ||
| 118 | cairo_font_face_t *font_face; | ||
| 119 | cairo_font_extents_t extents; | ||
| 120 | FT_Face ft_face; | ||
| 121 | FcMatrix *matrix; | ||
| 122 | |||
| 123 | val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); | ||
| 124 | if (! CONSP (val)) | ||
| 125 | return Qnil; | ||
| 126 | val = XCDR (val); | ||
| 127 | filename = XCAR (val); | ||
| 128 | size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX)); | ||
| 116 | if (size == 0) | 129 | if (size == 0) |
| 117 | size = pixel_size; | 130 | size = pixel_size; |
| 118 | font_object = font_build_object (VECSIZE (struct font_info), | 131 | |
| 119 | AREF (entity, FONT_TYPE_INDEX), | ||
| 120 | entity, size); | ||
| 121 | block_input (); | 132 | block_input (); |
| 122 | font_object = ftfont_open2 (f, entity, pixel_size, font_object); | 133 | |
| 123 | if (FONT_OBJECT_P (font_object)) | 134 | pat = ftfont_entity_pattern (entity, pixel_size); |
| 135 | FcConfigSubstitute (NULL, pat, FcMatchPattern); | ||
| 136 | FcDefaultSubstitute (pat); | ||
| 137 | match = FcFontMatch (NULL, pat, &result); | ||
| 138 | ftfont_fix_match (pat, match); | ||
| 139 | |||
| 140 | FcPatternDestroy (pat); | ||
| 141 | font_face = cairo_ft_font_face_create_for_pattern (match); | ||
| 142 | if (!font_face) | ||
| 124 | { | 143 | { |
| 125 | struct font *font = XFONT_OBJECT (font_object); | 144 | unblock_input (); |
| 126 | struct font_info *ftcrfont_info = (struct font_info *) font; | 145 | FcPatternDestroy (match); |
| 127 | FT_Face ft_face = ftcrfont_info->ft_size->face; | 146 | return Qnil; |
| 147 | } | ||
| 148 | cairo_matrix_t font_matrix, ctm; | ||
| 149 | cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size); | ||
| 150 | cairo_matrix_init_identity (&ctm); | ||
| 151 | cairo_font_options_t *options = cairo_font_options_create (); | ||
| 152 | cairo_scaled_font_t *scaled_font | ||
| 153 | = cairo_scaled_font_create (font_face, &font_matrix, &ctm, options); | ||
| 154 | cairo_font_face_destroy (font_face); | ||
| 155 | cairo_font_options_destroy (options); | ||
| 156 | unblock_input (); | ||
| 128 | 157 | ||
| 158 | font_object = font_build_object (VECSIZE (struct font_info), | ||
| 159 | AREF (entity, FONT_TYPE_INDEX), | ||
| 160 | entity, size); | ||
| 161 | ASET (font_object, FONT_FILE_INDEX, filename); | ||
| 162 | font = XFONT_OBJECT (font_object); | ||
| 163 | font->pixel_size = size; | ||
| 129 | #ifdef HAVE_HARFBUZZ | 164 | #ifdef HAVE_HARFBUZZ |
| 130 | if (EQ (AREF (font_object, FONT_TYPE_INDEX), Qftcrhb)) | 165 | if (EQ (AREF (font_object, FONT_TYPE_INDEX), Qftcrhb)) |
| 131 | font->driver = &ftcrhbfont_driver; | 166 | font->driver = &ftcrhbfont_driver; |
| 132 | else | 167 | else |
| 133 | #endif /* HAVE_HARFBUZZ */ | 168 | #endif /* HAVE_HARFBUZZ */ |
| 134 | font->driver = &ftcrfont_driver; | 169 | font->driver = &ftcrfont_driver; |
| 135 | FT_New_Size (ft_face, &ftcrfont_info->ft_size_draw); | 170 | font->encoding_charset = font->repertory_charset = -1; |
| 136 | FT_Activate_Size (ftcrfont_info->ft_size_draw); | 171 | |
| 137 | if (ftcrfont_info->bitmap_strike_index < 0) | 172 | ftcrfont_info = (struct font_info *) font; |
| 138 | FT_Set_Pixel_Sizes (ft_face, 0, font->pixel_size); | 173 | ftcrfont_info->cr_scaled_font = scaled_font; |
| 139 | else | 174 | |
| 140 | FT_Select_Size (ft_face, ftcrfont_info->bitmap_strike_index); | 175 | /* This means that there's no need of transformation. */ |
| 141 | cairo_font_face_t *font_face = | 176 | ftcrfont_info->matrix.xx = 0; |
| 142 | cairo_ft_font_face_create_for_ft_face (ft_face, 0); | 177 | if (FcPatternGetMatrix (match, FC_MATRIX, 0, &matrix) == FcResultMatch) |
| 143 | cairo_matrix_t font_matrix, ctm; | 178 | { |
| 144 | cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size); | 179 | ftcrfont_info->matrix.xx = 0x10000L * matrix->xx; |
| 145 | cairo_matrix_init_identity (&ctm); | 180 | ftcrfont_info->matrix.yy = 0x10000L * matrix->yy; |
| 146 | cairo_font_options_t *options = cairo_font_options_create (); | 181 | ftcrfont_info->matrix.xy = 0x10000L * matrix->xy; |
| 147 | ftcrfont_info->cr_scaled_font = | 182 | ftcrfont_info->matrix.yx = 0x10000L * matrix->yx; |
| 148 | cairo_scaled_font_create (font_face, &font_matrix, &ctm, options); | 183 | } |
| 149 | cairo_font_face_destroy (font_face); | 184 | |
| 150 | cairo_font_options_destroy (options); | 185 | ftcrfont_info->metrics = NULL; |
| 151 | ftcrfont_info->metrics = NULL; | 186 | ftcrfont_info->metrics_nrows = 0; |
| 152 | ftcrfont_info->metrics_nrows = 0; | 187 | |
| 153 | if (ftcrfont_info->bitmap_strike_index >= 0) | 188 | block_input (); |
| 189 | cairo_glyph_t stack_glyph; | ||
| 190 | int n = 0; | ||
| 191 | font->min_width = font->average_width = font->space_width = 0; | ||
| 192 | for (char c = 32; c < 127; c++) | ||
| 193 | { | ||
| 194 | cairo_glyph_t *glyphs = &stack_glyph; | ||
| 195 | int num_glyphs = 1; | ||
| 196 | cairo_status_t status = | ||
| 197 | cairo_scaled_font_text_to_glyphs (ftcrfont_info->cr_scaled_font, | ||
| 198 | 0, 0, &c, 1, &glyphs, &num_glyphs, | ||
| 199 | NULL, NULL, NULL); | ||
| 200 | |||
| 201 | if (status == CAIRO_STATUS_SUCCESS) | ||
| 154 | { | 202 | { |
| 155 | /* Several members of struct font/font_info set by | 203 | if (glyphs != &stack_glyph) |
| 156 | ftfont_open2 are bogus. Recalculate them with cairo | 204 | cairo_glyph_free (glyphs); |
| 157 | scaled font functions. */ | 205 | else if (stack_glyph.index) |
| 158 | cairo_font_extents_t extents; | ||
| 159 | cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents); | ||
| 160 | font->ascent = lround (extents.ascent); | ||
| 161 | font->descent = lround (extents.descent); | ||
| 162 | font->height = lround (extents.height); | ||
| 163 | |||
| 164 | cairo_glyph_t stack_glyph; | ||
| 165 | int n = 0; | ||
| 166 | font->min_width = font->average_width = font->space_width = 0; | ||
| 167 | for (char c = 32; c < 127; c++) | ||
| 168 | { | 206 | { |
| 169 | cairo_glyph_t *glyphs = &stack_glyph; | 207 | int this_width = ftcrfont_glyph_extents (font, stack_glyph.index, |
| 170 | int num_glyphs = 1; | 208 | NULL); |
| 171 | cairo_status_t status = | 209 | |
| 172 | cairo_scaled_font_text_to_glyphs (ftcrfont_info->cr_scaled_font, | 210 | if (this_width > 0 |
| 173 | 0, 0, &c, 1, | 211 | && (! font->min_width |
| 174 | &glyphs, &num_glyphs, | 212 | || font->min_width > this_width)) |
| 175 | NULL, NULL, NULL); | 213 | font->min_width = this_width; |
| 176 | 214 | if (c == 32) | |
| 177 | if (status == CAIRO_STATUS_SUCCESS) | 215 | font->space_width = this_width; |
| 178 | { | 216 | font->average_width += this_width; |
| 179 | if (glyphs != &stack_glyph) | 217 | n++; |
| 180 | cairo_glyph_free (glyphs); | ||
| 181 | else | ||
| 182 | { | ||
| 183 | int this_width = | ||
| 184 | ftcrfont_glyph_extents (font, stack_glyph.index, NULL); | ||
| 185 | |||
| 186 | if (this_width > 0 | ||
| 187 | && (! font->min_width | ||
| 188 | || font->min_width > this_width)) | ||
| 189 | font->min_width = this_width; | ||
| 190 | if (c == 32) | ||
| 191 | font->space_width = this_width; | ||
| 192 | font->average_width += this_width; | ||
| 193 | n++; | ||
| 194 | } | ||
| 195 | } | ||
| 196 | } | 218 | } |
| 197 | if (n > 0) | ||
| 198 | font->average_width /= n; | ||
| 199 | |||
| 200 | font->underline_position = -1; | ||
| 201 | font->underline_thickness = 0; | ||
| 202 | } | 219 | } |
| 203 | } | 220 | } |
| 221 | if (n > 0) | ||
| 222 | font->average_width /= n; | ||
| 223 | |||
| 224 | cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents); | ||
| 225 | font->ascent = lround (extents.ascent); | ||
| 226 | val = assq_no_quit (QCminspace, AREF (entity, FONT_EXTRA_INDEX)); | ||
| 227 | if (!(CONSP (val) && NILP (XCDR (val)))) | ||
| 228 | { | ||
| 229 | font->descent = lround (extents.descent); | ||
| 230 | font->height = font->ascent + font->descent; | ||
| 231 | } | ||
| 232 | else | ||
| 233 | { | ||
| 234 | font->height = lround (extents.height); | ||
| 235 | font->descent = font->height - font->ascent; | ||
| 236 | } | ||
| 237 | |||
| 238 | ft_face = cairo_ft_scaled_font_lock_face (scaled_font); | ||
| 239 | if (XFIXNUM (AREF (entity, FONT_SIZE_INDEX)) == 0) | ||
| 240 | { | ||
| 241 | int upEM = ft_face->units_per_EM; | ||
| 242 | |||
| 243 | font->underline_position = -ft_face->underline_position * size / upEM; | ||
| 244 | font->underline_thickness = ft_face->underline_thickness * size / upEM; | ||
| 245 | if (font->underline_thickness > 2) | ||
| 246 | font->underline_position -= font->underline_thickness / 2; | ||
| 247 | } | ||
| 248 | else | ||
| 249 | { | ||
| 250 | font->underline_position = -1; | ||
| 251 | font->underline_thickness = 0; | ||
| 252 | } | ||
| 253 | #ifdef HAVE_LIBOTF | ||
| 254 | ftcrfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0; | ||
| 255 | ftcrfont_info->otf = NULL; | ||
| 256 | #endif /* HAVE_LIBOTF */ | ||
| 257 | #ifdef HAVE_HARFBUZZ | ||
| 258 | ftcrfont_info->hb_font = NULL; | ||
| 259 | #endif /* HAVE_HARFBUZZ */ | ||
| 260 | if (ft_face->units_per_EM) | ||
| 261 | ftcrfont_info->bitmap_position_unit = 0; | ||
| 262 | else | ||
| 263 | ftcrfont_info->bitmap_position_unit = (extents.height | ||
| 264 | / ft_face->size->metrics.height); | ||
| 265 | cairo_ft_scaled_font_unlock_face (scaled_font); | ||
| 266 | ftcrfont_info->ft_size = NULL; | ||
| 204 | unblock_input (); | 267 | unblock_input (); |
| 205 | 268 | ||
| 269 | font->baseline_offset = 0; | ||
| 270 | font->relative_compose = 0; | ||
| 271 | font->default_ascent = 0; | ||
| 272 | font->vertical_centering = false; | ||
| 273 | |||
| 206 | return font_object; | 274 | return font_object; |
| 207 | } | 275 | } |
| 208 | 276 | ||
| @@ -213,24 +281,70 @@ ftcrfont_close (struct font *font) | |||
| 213 | return; | 281 | return; |
| 214 | 282 | ||
| 215 | struct font_info *ftcrfont_info = (struct font_info *) font; | 283 | struct font_info *ftcrfont_info = (struct font_info *) font; |
| 216 | int i; | ||
| 217 | 284 | ||
| 218 | block_input (); | 285 | block_input (); |
| 219 | for (i = 0; i < ftcrfont_info->metrics_nrows; i++) | 286 | #ifdef HAVE_LIBOTF |
| 287 | if (ftcrfont_info->otf) | ||
| 288 | { | ||
| 289 | OTF_close (ftcrfont_info->otf); | ||
| 290 | ftcrfont_info->otf = NULL; | ||
| 291 | } | ||
| 292 | #endif | ||
| 293 | #ifdef HAVE_HARFBUZZ | ||
| 294 | if (ftcrfont_info->hb_font) | ||
| 295 | { | ||
| 296 | hb_font_destroy (ftcrfont_info->hb_font); | ||
| 297 | ftcrfont_info->hb_font = NULL; | ||
| 298 | } | ||
| 299 | #endif | ||
| 300 | for (int i = 0; i < ftcrfont_info->metrics_nrows; i++) | ||
| 220 | if (ftcrfont_info->metrics[i]) | 301 | if (ftcrfont_info->metrics[i]) |
| 221 | xfree (ftcrfont_info->metrics[i]); | 302 | xfree (ftcrfont_info->metrics[i]); |
| 222 | if (ftcrfont_info->metrics) | 303 | if (ftcrfont_info->metrics) |
| 223 | xfree (ftcrfont_info->metrics); | 304 | xfree (ftcrfont_info->metrics); |
| 224 | FT_Done_Size (ftcrfont_info->ft_size_draw); | ||
| 225 | cairo_scaled_font_destroy (ftcrfont_info->cr_scaled_font); | 305 | cairo_scaled_font_destroy (ftcrfont_info->cr_scaled_font); |
| 226 | unblock_input (); | 306 | unblock_input (); |
| 307 | } | ||
| 308 | |||
| 309 | static int | ||
| 310 | ftcrfont_has_char (Lisp_Object font, int c) | ||
| 311 | { | ||
| 312 | if (FONT_ENTITY_P (font)) | ||
| 313 | return ftfont_has_char (font, c); | ||
| 314 | |||
| 315 | return -1; | ||
| 316 | } | ||
| 317 | |||
| 318 | static unsigned | ||
| 319 | ftcrfont_encode_char (struct font *font, int c) | ||
| 320 | { | ||
| 321 | struct font_info *ftcrfont_info = (struct font_info *) font; | ||
| 322 | unsigned code = FONT_INVALID_CODE; | ||
| 323 | unsigned char utf8[MAX_MULTIBYTE_LENGTH]; | ||
| 324 | unsigned char *p = utf8; | ||
| 325 | cairo_glyph_t stack_glyph; | ||
| 326 | cairo_glyph_t *glyphs = &stack_glyph; | ||
| 327 | int num_glyphs = 1; | ||
| 328 | |||
| 329 | CHAR_STRING_ADVANCE (c, p); | ||
| 330 | if (cairo_scaled_font_text_to_glyphs (ftcrfont_info->cr_scaled_font, 0, 0, | ||
| 331 | (char *) utf8, p - utf8, | ||
| 332 | &glyphs, &num_glyphs, | ||
| 333 | NULL, NULL, NULL) | ||
| 334 | == CAIRO_STATUS_SUCCESS) | ||
| 335 | { | ||
| 336 | if (glyphs != &stack_glyph) | ||
| 337 | cairo_glyph_free (glyphs); | ||
| 338 | else if (stack_glyph.index) | ||
| 339 | code = stack_glyph.index; | ||
| 340 | } | ||
| 227 | 341 | ||
| 228 | ftfont_close (font); | 342 | return code; |
| 229 | } | 343 | } |
| 230 | 344 | ||
| 231 | static void | 345 | static void |
| 232 | ftcrfont_text_extents (struct font *font, | 346 | ftcrfont_text_extents (struct font *font, |
| 233 | unsigned *code, | 347 | const unsigned *code, |
| 234 | int nglyphs, | 348 | int nglyphs, |
| 235 | struct font_metrics *metrics) | 349 | struct font_metrics *metrics) |
| 236 | { | 350 | { |
| @@ -268,10 +382,18 @@ ftcrfont_get_bitmap (struct font *font, unsigned int code, | |||
| 268 | { | 382 | { |
| 269 | struct font_info *ftcrfont_info = (struct font_info *) font; | 383 | struct font_info *ftcrfont_info = (struct font_info *) font; |
| 270 | 384 | ||
| 271 | if (ftcrfont_info->bitmap_strike_index < 0) | 385 | if (ftcrfont_info->bitmap_position_unit) |
| 272 | return ftfont_get_bitmap (font, code, bitmap, bits_per_pixel); | 386 | return -1; |
| 273 | 387 | ||
| 274 | return -1; | 388 | cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font; |
| 389 | FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font); | ||
| 390 | |||
| 391 | ftcrfont_info->ft_size = ft_face->size; | ||
| 392 | int result = ftfont_get_bitmap (font, code, bitmap, bits_per_pixel); | ||
| 393 | cairo_ft_scaled_font_unlock_face (scaled_font); | ||
| 394 | ftcrfont_info->ft_size = NULL; | ||
| 395 | |||
| 396 | return result; | ||
| 275 | } | 397 | } |
| 276 | 398 | ||
| 277 | static int | 399 | static int |
| @@ -280,25 +402,75 @@ ftcrfont_anchor_point (struct font *font, unsigned int code, int idx, | |||
| 280 | { | 402 | { |
| 281 | struct font_info *ftcrfont_info = (struct font_info *) font; | 403 | struct font_info *ftcrfont_info = (struct font_info *) font; |
| 282 | 404 | ||
| 283 | if (ftcrfont_info->bitmap_strike_index < 0) | 405 | if (ftcrfont_info->bitmap_position_unit) |
| 284 | return ftfont_anchor_point (font, code, idx, x, y); | 406 | return -1; |
| 285 | 407 | ||
| 286 | return -1; | 408 | cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font; |
| 409 | FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font); | ||
| 410 | |||
| 411 | ftcrfont_info->ft_size = ft_face->size; | ||
| 412 | int result = ftfont_anchor_point (font, code, idx, x, y); | ||
| 413 | cairo_ft_scaled_font_unlock_face (scaled_font); | ||
| 414 | ftcrfont_info->ft_size = NULL; | ||
| 415 | |||
| 416 | return result; | ||
| 287 | } | 417 | } |
| 288 | 418 | ||
| 419 | #ifdef HAVE_LIBOTF | ||
| 289 | static Lisp_Object | 420 | static Lisp_Object |
| 290 | ftcrfont_shape (Lisp_Object lgstring, Lisp_Object direction) | 421 | ftcrfont_otf_capability (struct font *font) |
| 291 | { | 422 | { |
| 423 | struct font_info *ftcrfont_info = (struct font_info *) font; | ||
| 424 | cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font; | ||
| 425 | FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font); | ||
| 426 | |||
| 427 | ftcrfont_info->ft_size = ft_face->size; | ||
| 428 | Lisp_Object result = ftfont_otf_capability (font); | ||
| 429 | cairo_ft_scaled_font_unlock_face (scaled_font); | ||
| 430 | ftcrfont_info->ft_size = NULL; | ||
| 431 | |||
| 432 | return result; | ||
| 433 | } | ||
| 434 | #endif | ||
| 435 | |||
| 292 | #if defined HAVE_M17N_FLT && defined HAVE_LIBOTF | 436 | #if defined HAVE_M17N_FLT && defined HAVE_LIBOTF |
| 437 | static Lisp_Object | ||
| 438 | ftcrfont_shape (Lisp_Object lgstring, Lisp_Object direction) | ||
| 439 | { | ||
| 293 | struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); | 440 | struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); |
| 294 | struct font_info *ftcrfont_info = (struct font_info *) font; | 441 | struct font_info *ftcrfont_info = (struct font_info *) font; |
| 295 | 442 | ||
| 296 | if (ftcrfont_info->bitmap_strike_index < 0) | 443 | if (ftcrfont_info->bitmap_position_unit) |
| 297 | return ftfont_shape (lgstring, direction); | 444 | return make_fixnum (0); |
| 445 | |||
| 446 | cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font; | ||
| 447 | FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font); | ||
| 448 | |||
| 449 | ftcrfont_info->ft_size = ft_face->size; | ||
| 450 | Lisp_Object result = ftfont_shape (lgstring, direction); | ||
| 451 | cairo_ft_scaled_font_unlock_face (scaled_font); | ||
| 452 | ftcrfont_info->ft_size = NULL; | ||
| 453 | |||
| 454 | return result; | ||
| 455 | } | ||
| 298 | #endif | 456 | #endif |
| 299 | 457 | ||
| 300 | return make_fixnum (0); | 458 | #ifdef HAVE_OTF_GET_VARIATION_GLYPHS |
| 459 | static int | ||
| 460 | ftcrfont_variation_glyphs (struct font *font, int c, unsigned variations[256]) | ||
| 461 | { | ||
| 462 | struct font_info *ftcrfont_info = (struct font_info *) font; | ||
| 463 | cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font; | ||
| 464 | FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font); | ||
| 465 | |||
| 466 | ftcrfont_info->ft_size = ft_face->size; | ||
| 467 | int result = ftfont_variation_glyphs (font, c, variations); | ||
| 468 | cairo_ft_scaled_font_unlock_face (scaled_font); | ||
| 469 | ftcrfont_info->ft_size = NULL; | ||
| 470 | |||
| 471 | return result; | ||
| 301 | } | 472 | } |
| 473 | #endif /* HAVE_OTF_GET_VARIATION_GLYPHS */ | ||
| 302 | 474 | ||
| 303 | static int | 475 | static int |
| 304 | ftcrfont_draw (struct glyph_string *s, | 476 | ftcrfont_draw (struct glyph_string *s, |
| @@ -309,8 +481,6 @@ ftcrfont_draw (struct glyph_string *s, | |||
| 309 | struct font_info *ftcrfont_info = (struct font_info *) s->font; | 481 | struct font_info *ftcrfont_info = (struct font_info *) s->font; |
| 310 | cairo_t *cr; | 482 | cairo_t *cr; |
| 311 | cairo_glyph_t *glyphs; | 483 | cairo_glyph_t *glyphs; |
| 312 | cairo_surface_t *surface; | ||
| 313 | cairo_surface_type_t surface_type; | ||
| 314 | int len = to - from; | 484 | int len = to - from; |
| 315 | int i; | 485 | int i; |
| 316 | 486 | ||
| @@ -329,28 +499,17 @@ ftcrfont_draw (struct glyph_string *s, | |||
| 329 | glyphs = alloca (sizeof (cairo_glyph_t) * len); | 499 | glyphs = alloca (sizeof (cairo_glyph_t) * len); |
| 330 | for (i = 0; i < len; i++) | 500 | for (i = 0; i < len; i++) |
| 331 | { | 501 | { |
| 332 | unsigned code = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) | 502 | glyphs[i].index = s->char2b[from + i]; |
| 333 | | XCHAR2B_BYTE2 (s->char2b + from + i)); | ||
| 334 | |||
| 335 | glyphs[i].index = code; | ||
| 336 | glyphs[i].x = x; | 503 | glyphs[i].x = x; |
| 337 | glyphs[i].y = y; | 504 | glyphs[i].y = y; |
| 338 | x += (s->padding_p ? 1 : ftcrfont_glyph_extents (s->font, code, NULL)); | 505 | x += (s->padding_p ? 1 : ftcrfont_glyph_extents (s->font, |
| 506 | glyphs[i].index, | ||
| 507 | NULL)); | ||
| 339 | } | 508 | } |
| 340 | 509 | ||
| 341 | x_set_cr_source_with_gc_foreground (f, s->gc); | 510 | x_set_cr_source_with_gc_foreground (f, s->gc); |
| 342 | cairo_set_scaled_font (cr, ftcrfont_info->cr_scaled_font); | 511 | cairo_set_scaled_font (cr, ftcrfont_info->cr_scaled_font); |
| 343 | |||
| 344 | FT_Activate_Size (ftcrfont_info->ft_size_draw); | ||
| 345 | cairo_show_glyphs (cr, glyphs, len); | 512 | cairo_show_glyphs (cr, glyphs, len); |
| 346 | surface = cairo_get_target (cr); | ||
| 347 | /* XXX: It used to be necessary to flush when exporting. It might | ||
| 348 | be the case that this is no longer necessary. */ | ||
| 349 | surface_type = cairo_surface_get_type (surface); | ||
| 350 | if (surface_type != CAIRO_SURFACE_TYPE_XLIB | ||
| 351 | && (surface_type != CAIRO_SURFACE_TYPE_IMAGE | ||
| 352 | || cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32)) | ||
| 353 | cairo_surface_flush (surface); | ||
| 354 | 513 | ||
| 355 | x_end_cr_clip (f); | 514 | x_end_cr_clip (f); |
| 356 | 515 | ||
| @@ -377,20 +536,27 @@ static hb_font_t * | |||
| 377 | ftcrhbfont_begin_hb_font (struct font *font, double *position_unit) | 536 | ftcrhbfont_begin_hb_font (struct font *font, double *position_unit) |
| 378 | { | 537 | { |
| 379 | struct font_info *ftcrfont_info = (struct font_info *) font; | 538 | struct font_info *ftcrfont_info = (struct font_info *) font; |
| 539 | cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font; | ||
| 540 | FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font); | ||
| 380 | 541 | ||
| 381 | FT_Activate_Size (ftcrfont_info->ft_size_draw); | 542 | ftcrfont_info->ft_size = ft_face->size; |
| 382 | hb_font_t *hb_font = fthbfont_begin_hb_font (font, position_unit); | 543 | hb_font_t *hb_font = fthbfont_begin_hb_font (font, position_unit); |
| 383 | int i = ftcrfont_info->bitmap_strike_index; | 544 | if (ftcrfont_info->bitmap_position_unit) |
| 384 | if (i >= 0) | 545 | *position_unit = ftcrfont_info->bitmap_position_unit; |
| 385 | { | ||
| 386 | FT_Face ft_face = ftcrfont_info->ft_size_draw->face; | ||
| 387 | *position_unit = ((double) font->height | ||
| 388 | / ft_face->available_sizes[i].height) / (1 << 6); | ||
| 389 | } | ||
| 390 | 546 | ||
| 391 | return hb_font; | 547 | return hb_font; |
| 392 | } | 548 | } |
| 393 | 549 | ||
| 550 | static void | ||
| 551 | ftcrhbfont_end_hb_font (struct font *font, hb_font_t *hb_font) | ||
| 552 | { | ||
| 553 | struct font_info *ftcrfont_info = (struct font_info *) font; | ||
| 554 | cairo_scaled_font_t *scaled_font = ftcrfont_info->cr_scaled_font; | ||
| 555 | |||
| 556 | cairo_ft_scaled_font_unlock_face (scaled_font); | ||
| 557 | ftcrfont_info->ft_size = NULL; | ||
| 558 | } | ||
| 559 | |||
| 394 | #endif /* HAVE_HARFBUZZ */ | 560 | #endif /* HAVE_HARFBUZZ */ |
| 395 | 561 | ||
| 396 | 562 | ||
| @@ -405,18 +571,20 @@ struct font_driver const ftcrfont_driver = | |||
| 405 | .list_family = ftfont_list_family, | 571 | .list_family = ftfont_list_family, |
| 406 | .open = ftcrfont_open, | 572 | .open = ftcrfont_open, |
| 407 | .close = ftcrfont_close, | 573 | .close = ftcrfont_close, |
| 408 | .has_char = ftfont_has_char, | 574 | .has_char = ftcrfont_has_char, |
| 409 | .encode_char = ftfont_encode_char, | 575 | .encode_char = ftcrfont_encode_char, |
| 410 | .text_extents = ftcrfont_text_extents, | 576 | .text_extents = ftcrfont_text_extents, |
| 411 | .draw = ftcrfont_draw, | 577 | .draw = ftcrfont_draw, |
| 412 | .get_bitmap = ftcrfont_get_bitmap, | 578 | .get_bitmap = ftcrfont_get_bitmap, |
| 413 | .anchor_point = ftcrfont_anchor_point, | 579 | .anchor_point = ftcrfont_anchor_point, |
| 414 | #ifdef HAVE_LIBOTF | 580 | #ifdef HAVE_LIBOTF |
| 415 | .otf_capability = ftfont_otf_capability, | 581 | .otf_capability = ftcrfont_otf_capability, |
| 416 | #endif | 582 | #endif |
| 583 | #if defined HAVE_M17N_FLT && defined HAVE_LIBOTF | ||
| 417 | .shape = ftcrfont_shape, | 584 | .shape = ftcrfont_shape, |
| 585 | #endif | ||
| 418 | #ifdef HAVE_OTF_GET_VARIATION_GLYPHS | 586 | #ifdef HAVE_OTF_GET_VARIATION_GLYPHS |
| 419 | .get_variation_glyphs = ftfont_variation_glyphs, | 587 | .get_variation_glyphs = ftcrfont_variation_glyphs, |
| 420 | #endif | 588 | #endif |
| 421 | .filter_properties = ftfont_filter_properties, | 589 | .filter_properties = ftfont_filter_properties, |
| 422 | .combining_capability = ftfont_combining_capability, | 590 | .combining_capability = ftfont_combining_capability, |
| @@ -447,6 +615,7 @@ syms_of_ftcrfont_for_pdumper (void) | |||
| 447 | ftcrhbfont_driver.shape = fthbfont_shape; | 615 | ftcrhbfont_driver.shape = fthbfont_shape; |
| 448 | ftcrhbfont_driver.combining_capability = fthbfont_combining_capability; | 616 | ftcrhbfont_driver.combining_capability = fthbfont_combining_capability; |
| 449 | ftcrhbfont_driver.begin_hb_font = ftcrhbfont_begin_hb_font; | 617 | ftcrhbfont_driver.begin_hb_font = ftcrhbfont_begin_hb_font; |
| 618 | ftcrhbfont_driver.end_hb_font = ftcrhbfont_end_hb_font; | ||
| 450 | register_font_driver (&ftcrhbfont_driver, NULL); | 619 | register_font_driver (&ftcrhbfont_driver, NULL); |
| 451 | #endif /* HAVE_HARFBUZZ */ | 620 | #endif /* HAVE_HARFBUZZ */ |
| 452 | } | 621 | } |
diff --git a/src/ftfont.c b/src/ftfont.c index 2373af8766a..5694c49aaf9 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -1103,12 +1103,159 @@ ftfont_list_family (struct frame *f) | |||
| 1103 | return list; | 1103 | return list; |
| 1104 | } | 1104 | } |
| 1105 | 1105 | ||
| 1106 | void | ||
| 1107 | ftfont_fix_match (FcPattern *pat, FcPattern *match) | ||
| 1108 | { | ||
| 1109 | /* These values are not used for matching (except antialias), but for | ||
| 1110 | rendering, so make sure they are carried over to the match. | ||
| 1111 | We also put antialias here because most fonts are antialiased, so | ||
| 1112 | the match will have antialias true. */ | ||
| 1113 | |||
| 1114 | FcBool b = FcTrue; | ||
| 1115 | int i; | ||
| 1116 | double dpi; | ||
| 1117 | |||
| 1118 | FcPatternGetBool (pat, FC_ANTIALIAS, 0, &b); | ||
| 1119 | if (! b) | ||
| 1120 | { | ||
| 1121 | FcPatternDel (match, FC_ANTIALIAS); | ||
| 1122 | FcPatternAddBool (match, FC_ANTIALIAS, FcFalse); | ||
| 1123 | } | ||
| 1124 | FcPatternGetBool (pat, FC_HINTING, 0, &b); | ||
| 1125 | if (! b) | ||
| 1126 | { | ||
| 1127 | FcPatternDel (match, FC_HINTING); | ||
| 1128 | FcPatternAddBool (match, FC_HINTING, FcFalse); | ||
| 1129 | } | ||
| 1130 | #ifndef FC_HINT_STYLE | ||
| 1131 | # define FC_HINT_STYLE "hintstyle" | ||
| 1132 | #endif | ||
| 1133 | if (FcResultMatch == FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &i)) | ||
| 1134 | { | ||
| 1135 | FcPatternDel (match, FC_HINT_STYLE); | ||
| 1136 | FcPatternAddInteger (match, FC_HINT_STYLE, i); | ||
| 1137 | } | ||
| 1138 | #ifndef FC_LCD_FILTER | ||
| 1139 | /* Older fontconfig versions don't have FC_LCD_FILTER. */ | ||
| 1140 | #define FC_LCD_FILTER "lcdfilter" | ||
| 1141 | #endif | ||
| 1142 | if (FcResultMatch == FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &i)) | ||
| 1143 | { | ||
| 1144 | FcPatternDel (match, FC_LCD_FILTER); | ||
| 1145 | FcPatternAddInteger (match, FC_LCD_FILTER, i); | ||
| 1146 | } | ||
| 1147 | if (FcResultMatch == FcPatternGetInteger (pat, FC_RGBA, 0, &i)) | ||
| 1148 | { | ||
| 1149 | FcPatternDel (match, FC_RGBA); | ||
| 1150 | FcPatternAddInteger (match, FC_RGBA, i); | ||
| 1151 | } | ||
| 1152 | if (FcResultMatch == FcPatternGetDouble (pat, FC_DPI, 0, &dpi)) | ||
| 1153 | { | ||
| 1154 | FcPatternDel (match, FC_DPI); | ||
| 1155 | FcPatternAddDouble (match, FC_DPI, dpi); | ||
| 1156 | } | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | void | ||
| 1160 | ftfont_add_rendering_parameters (FcPattern *pat, Lisp_Object entity) | ||
| 1161 | { | ||
| 1162 | Lisp_Object tail; | ||
| 1163 | int ival; | ||
| 1164 | |||
| 1165 | for (tail = AREF (entity, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) | ||
| 1166 | { | ||
| 1167 | Lisp_Object key = XCAR (XCAR (tail)); | ||
| 1168 | Lisp_Object val = XCDR (XCAR (tail)); | ||
| 1169 | |||
| 1170 | if (EQ (key, QCantialias)) | ||
| 1171 | FcPatternAddBool (pat, FC_ANTIALIAS, NILP (val) ? FcFalse : FcTrue); | ||
| 1172 | else if (EQ (key, QChinting)) | ||
| 1173 | FcPatternAddBool (pat, FC_HINTING, NILP (val) ? FcFalse : FcTrue); | ||
| 1174 | else if (EQ (key, QCautohint)) | ||
| 1175 | FcPatternAddBool (pat, FC_AUTOHINT, NILP (val) ? FcFalse : FcTrue); | ||
| 1176 | else if (EQ (key, QChintstyle)) | ||
| 1177 | { | ||
| 1178 | if (FIXNUMP (val)) | ||
| 1179 | FcPatternAddInteger (pat, FC_HINT_STYLE, XFIXNUM (val)); | ||
| 1180 | else if (SYMBOLP (val) | ||
| 1181 | && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival)) | ||
| 1182 | FcPatternAddInteger (pat, FC_HINT_STYLE, ival); | ||
| 1183 | } | ||
| 1184 | else if (EQ (key, QCrgba)) | ||
| 1185 | { | ||
| 1186 | if (FIXNUMP (val)) | ||
| 1187 | FcPatternAddInteger (pat, FC_RGBA, XFIXNUM (val)); | ||
| 1188 | else if (SYMBOLP (val) | ||
| 1189 | && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival)) | ||
| 1190 | FcPatternAddInteger (pat, FC_RGBA, ival); | ||
| 1191 | } | ||
| 1192 | else if (EQ (key, QClcdfilter)) | ||
| 1193 | { | ||
| 1194 | if (FIXNUMP (val)) | ||
| 1195 | FcPatternAddInteger (pat, FC_LCD_FILTER, ival = XFIXNUM (val)); | ||
| 1196 | else if (SYMBOLP (val) | ||
| 1197 | && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival)) | ||
| 1198 | FcPatternAddInteger (pat, FC_LCD_FILTER, ival); | ||
| 1199 | } | ||
| 1200 | #ifdef FC_EMBOLDEN | ||
| 1201 | else if (EQ (key, QCembolden)) | ||
| 1202 | FcPatternAddBool (pat, FC_EMBOLDEN, NILP (val) ? FcFalse : FcTrue); | ||
| 1203 | #endif | ||
| 1204 | } | ||
| 1205 | } | ||
| 1206 | |||
| 1207 | FcPattern * | ||
| 1208 | ftfont_entity_pattern (Lisp_Object entity, int pixel_size) | ||
| 1209 | { | ||
| 1210 | Lisp_Object val, filename, idx; | ||
| 1211 | FcPattern *pat; | ||
| 1212 | int i; | ||
| 1213 | |||
| 1214 | val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); | ||
| 1215 | eassert (CONSP (val)); | ||
| 1216 | val = XCDR (val); | ||
| 1217 | filename = XCAR (val); | ||
| 1218 | idx = XCDR (val); | ||
| 1219 | pat = FcPatternCreate (); | ||
| 1220 | FcPatternAddInteger (pat, FC_WEIGHT, FONT_WEIGHT_NUMERIC (entity)); | ||
| 1221 | i = FONT_SLANT_NUMERIC (entity) - 100; | ||
| 1222 | if (i < 0) i = 0; | ||
| 1223 | FcPatternAddInteger (pat, FC_SLANT, i); | ||
| 1224 | FcPatternAddInteger (pat, FC_WIDTH, FONT_WIDTH_NUMERIC (entity)); | ||
| 1225 | FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size); | ||
| 1226 | val = AREF (entity, FONT_FAMILY_INDEX); | ||
| 1227 | if (! NILP (val)) | ||
| 1228 | FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); | ||
| 1229 | val = AREF (entity, FONT_FOUNDRY_INDEX); | ||
| 1230 | if (! NILP (val)) | ||
| 1231 | FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); | ||
| 1232 | val = AREF (entity, FONT_SPACING_INDEX); | ||
| 1233 | if (! NILP (val)) | ||
| 1234 | FcPatternAddInteger (pat, FC_SPACING, XFIXNUM (val)); | ||
| 1235 | val = AREF (entity, FONT_DPI_INDEX); | ||
| 1236 | if (! NILP (val)) | ||
| 1237 | { | ||
| 1238 | double dbl = XFIXNUM (val); | ||
| 1239 | |||
| 1240 | FcPatternAddDouble (pat, FC_DPI, dbl); | ||
| 1241 | } | ||
| 1242 | val = AREF (entity, FONT_AVGWIDTH_INDEX); | ||
| 1243 | if (FIXNUMP (val) && XFIXNUM (val) == 0) | ||
| 1244 | FcPatternAddBool (pat, FC_SCALABLE, FcTrue); | ||
| 1245 | /* This is necessary to identify the exact font (e.g. 10x20.pcf.gz | ||
| 1246 | over 10x20-ISO8859-1.pcf.gz). */ | ||
| 1247 | FcPatternAddCharSet (pat, FC_CHARSET, ftfont_get_fc_charset (entity)); | ||
| 1248 | |||
| 1249 | ftfont_add_rendering_parameters (pat, entity); | ||
| 1250 | |||
| 1251 | FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename)); | ||
| 1252 | FcPatternAddInteger (pat, FC_INDEX, XFIXNUM (idx)); | ||
| 1253 | |||
| 1254 | return pat; | ||
| 1255 | } | ||
| 1106 | 1256 | ||
| 1107 | Lisp_Object | 1257 | Lisp_Object |
| 1108 | ftfont_open2 (struct frame *f, | 1258 | ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) |
| 1109 | Lisp_Object entity, | ||
| 1110 | int pixel_size, | ||
| 1111 | Lisp_Object font_object) | ||
| 1112 | { | 1259 | { |
| 1113 | struct font_info *ftfont_info; | 1260 | struct font_info *ftfont_info; |
| 1114 | struct font *font; | 1261 | struct font *font; |
| @@ -1116,12 +1263,11 @@ ftfont_open2 (struct frame *f, | |||
| 1116 | FT_Face ft_face; | 1263 | FT_Face ft_face; |
| 1117 | FT_Size ft_size; | 1264 | FT_Size ft_size; |
| 1118 | FT_UInt size; | 1265 | FT_UInt size; |
| 1119 | Lisp_Object val, filename, idx, cache; | 1266 | Lisp_Object val, filename, idx, cache, font_object; |
| 1120 | bool scalable; | 1267 | bool scalable; |
| 1121 | int spacing; | 1268 | int spacing; |
| 1122 | int i; | 1269 | int i; |
| 1123 | double upEM; | 1270 | double upEM; |
| 1124 | FT_Int strike_index = -1; | ||
| 1125 | 1271 | ||
| 1126 | val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); | 1272 | val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); |
| 1127 | if (! CONSP (val)) | 1273 | if (! CONSP (val)) |
| @@ -1132,7 +1278,6 @@ ftfont_open2 (struct frame *f, | |||
| 1132 | return Qnil; | 1278 | return Qnil; |
| 1133 | filename = XCAR (val); | 1279 | filename = XCAR (val); |
| 1134 | idx = XCDR (val); | 1280 | idx = XCDR (val); |
| 1135 | val = XCDR (cache); | ||
| 1136 | cache_data = xmint_pointer (XCDR (cache)); | 1281 | cache_data = xmint_pointer (XCDR (cache)); |
| 1137 | ft_face = cache_data->ft_face; | 1282 | ft_face = cache_data->ft_face; |
| 1138 | if (cache_data->face_refcount > 0) | 1283 | if (cache_data->face_refcount > 0) |
| @@ -1151,35 +1296,17 @@ ftfont_open2 (struct frame *f, | |||
| 1151 | size = pixel_size; | 1296 | size = pixel_size; |
| 1152 | if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0) | 1297 | if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0) |
| 1153 | { | 1298 | { |
| 1154 | int min_distance = INT_MAX; | 1299 | if (cache_data->face_refcount == 0) |
| 1155 | bool magnify = true; | ||
| 1156 | |||
| 1157 | for (FT_Int i = 0; i < ft_face->num_fixed_sizes; i++) | ||
| 1158 | { | ||
| 1159 | int distance = ft_face->available_sizes[i].height - (int) size; | ||
| 1160 | |||
| 1161 | /* Prefer down-scaling to upscaling. */ | ||
| 1162 | if (magnify == (distance < 0) ? abs (distance) <= min_distance | ||
| 1163 | : magnify) | ||
| 1164 | { | ||
| 1165 | magnify = distance < 0; | ||
| 1166 | min_distance = abs (distance); | ||
| 1167 | strike_index = i; | ||
| 1168 | } | ||
| 1169 | } | ||
| 1170 | |||
| 1171 | if (strike_index < 0 || FT_Select_Size (ft_face, strike_index) != 0) | ||
| 1172 | { | 1300 | { |
| 1173 | if (cache_data->face_refcount == 0) | 1301 | FT_Done_Face (ft_face); |
| 1174 | { | 1302 | cache_data->ft_face = NULL; |
| 1175 | FT_Done_Face (ft_face); | ||
| 1176 | cache_data->ft_face = NULL; | ||
| 1177 | } | ||
| 1178 | return Qnil; | ||
| 1179 | } | 1303 | } |
| 1304 | return Qnil; | ||
| 1180 | } | 1305 | } |
| 1181 | cache_data->face_refcount++; | 1306 | cache_data->face_refcount++; |
| 1182 | 1307 | ||
| 1308 | font_object = font_build_object (VECSIZE (struct font_info), | ||
| 1309 | Qfreetype, entity, size); | ||
| 1183 | ASET (font_object, FONT_FILE_INDEX, filename); | 1310 | ASET (font_object, FONT_FILE_INDEX, filename); |
| 1184 | font = XFONT_OBJECT (font_object); | 1311 | font = XFONT_OBJECT (font_object); |
| 1185 | ftfont_info = (struct font_info *) font; | 1312 | ftfont_info = (struct font_info *) font; |
| @@ -1192,7 +1319,6 @@ ftfont_open2 (struct frame *f, | |||
| 1192 | #ifdef HAVE_HARFBUZZ | 1319 | #ifdef HAVE_HARFBUZZ |
| 1193 | ftfont_info->hb_font = NULL; | 1320 | ftfont_info->hb_font = NULL; |
| 1194 | #endif /* HAVE_HARFBUZZ */ | 1321 | #endif /* HAVE_HARFBUZZ */ |
| 1195 | ftfont_info->bitmap_strike_index = strike_index; | ||
| 1196 | /* This means that there's no need of transformation. */ | 1322 | /* This means that there's no need of transformation. */ |
| 1197 | ftfont_info->matrix.xx = 0; | 1323 | ftfont_info->matrix.xx = 0; |
| 1198 | font->pixel_size = size; | 1324 | font->pixel_size = size; |
| @@ -1204,20 +1330,38 @@ ftfont_open2 (struct frame *f, | |||
| 1204 | font->driver = &ftfont_driver; | 1330 | font->driver = &ftfont_driver; |
| 1205 | font->encoding_charset = font->repertory_charset = -1; | 1331 | font->encoding_charset = font->repertory_charset = -1; |
| 1206 | 1332 | ||
| 1333 | val = assq_no_quit (QCminspace, AREF (entity, FONT_EXTRA_INDEX)); | ||
| 1334 | bool no_leading_p = !(CONSP (val) && NILP (XCDR (val))); | ||
| 1207 | upEM = ft_face->units_per_EM; | 1335 | upEM = ft_face->units_per_EM; |
| 1208 | scalable = (FIXNUMP (AREF (entity, FONT_AVGWIDTH_INDEX)) | 1336 | scalable = (FIXNUMP (AREF (entity, FONT_AVGWIDTH_INDEX)) |
| 1209 | && XFIXNUM (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0); | 1337 | && XFIXNUM (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0); |
| 1210 | if (scalable) | 1338 | if (scalable) |
| 1211 | { | 1339 | { |
| 1212 | font->ascent = ft_face->ascender * size / upEM + 0.5; | 1340 | font->ascent = ft_face->ascender * size / upEM + 0.5; |
| 1213 | font->descent = - ft_face->descender * size / upEM + 0.5; | 1341 | if (no_leading_p) |
| 1214 | font->height = ft_face->height * size / upEM + 0.5; | 1342 | { |
| 1343 | font->descent = - ft_face->descender * size / upEM + 0.5; | ||
| 1344 | font->height = font->ascent + font->descent; | ||
| 1345 | } | ||
| 1346 | else | ||
| 1347 | { | ||
| 1348 | font->height = ft_face->height * size / upEM + 0.5; | ||
| 1349 | font->descent = font->height - font->ascent; | ||
| 1350 | } | ||
| 1215 | } | 1351 | } |
| 1216 | else | 1352 | else |
| 1217 | { | 1353 | { |
| 1218 | font->ascent = ft_face->size->metrics.ascender >> 6; | 1354 | font->ascent = ft_face->size->metrics.ascender >> 6; |
| 1219 | font->descent = - ft_face->size->metrics.descender >> 6; | 1355 | if (no_leading_p) |
| 1220 | font->height = ft_face->size->metrics.height >> 6; | 1356 | { |
| 1357 | font->descent = - ft_face->size->metrics.descender >> 6; | ||
| 1358 | font->height = font->ascent + font->descent; | ||
| 1359 | } | ||
| 1360 | else | ||
| 1361 | { | ||
| 1362 | font->height = ft_face->size->metrics.height >> 6; | ||
| 1363 | font->descent = font->height - font->ascent; | ||
| 1364 | } | ||
| 1221 | } | 1365 | } |
| 1222 | if (FIXNUMP (AREF (entity, FONT_SPACING_INDEX))) | 1366 | if (FIXNUMP (AREF (entity, FONT_SPACING_INDEX))) |
| 1223 | spacing = XFIXNUM (AREF (entity, FONT_SPACING_INDEX)); | 1367 | spacing = XFIXNUM (AREF (entity, FONT_SPACING_INDEX)); |
| @@ -1273,32 +1417,6 @@ ftfont_open2 (struct frame *f, | |||
| 1273 | return font_object; | 1417 | return font_object; |
| 1274 | } | 1418 | } |
| 1275 | 1419 | ||
| 1276 | Lisp_Object | ||
| 1277 | ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | ||
| 1278 | { | ||
| 1279 | Lisp_Object font_object; | ||
| 1280 | FT_UInt size; | ||
| 1281 | size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX)); | ||
| 1282 | if (size == 0) | ||
| 1283 | size = pixel_size; | ||
| 1284 | font_object = font_build_object (VECSIZE (struct font_info), | ||
| 1285 | AREF (entity, FONT_TYPE_INDEX), | ||
| 1286 | entity, size); | ||
| 1287 | font_object = ftfont_open2 (f, entity, pixel_size, font_object); | ||
| 1288 | if (FONT_OBJECT_P (font_object)) | ||
| 1289 | { | ||
| 1290 | struct font *font = XFONT_OBJECT (font_object); | ||
| 1291 | struct font_info *ftfont_info = (struct font_info *) font; | ||
| 1292 | |||
| 1293 | if (ftfont_info->bitmap_strike_index >= 0) | ||
| 1294 | { | ||
| 1295 | ftfont_close (font); | ||
| 1296 | font_object = Qnil; | ||
| 1297 | } | ||
| 1298 | } | ||
| 1299 | return font_object; | ||
| 1300 | } | ||
| 1301 | |||
| 1302 | void | 1420 | void |
| 1303 | ftfont_close (struct font *font) | 1421 | ftfont_close (struct font *font) |
| 1304 | { | 1422 | { |
| @@ -1391,7 +1509,7 @@ ftfont_glyph_metrics (FT_Face ft_face, int c, int *advance, int *lbearing, | |||
| 1391 | } | 1509 | } |
| 1392 | 1510 | ||
| 1393 | void | 1511 | void |
| 1394 | ftfont_text_extents (struct font *font, unsigned int *code, | 1512 | ftfont_text_extents (struct font *font, const unsigned int *code, |
| 1395 | int nglyphs, struct font_metrics *metrics) | 1513 | int nglyphs, struct font_metrics *metrics) |
| 1396 | { | 1514 | { |
| 1397 | struct font_info *ftfont_info = (struct font_info *) font; | 1515 | struct font_info *ftfont_info = (struct font_info *) font; |
| @@ -3131,6 +3249,17 @@ syms_of_ftfont (void) | |||
| 3131 | DEFSYM (Qsans, "sans"); | 3249 | DEFSYM (Qsans, "sans"); |
| 3132 | DEFSYM (Qsans__serif, "sans serif"); | 3250 | DEFSYM (Qsans__serif, "sans serif"); |
| 3133 | 3251 | ||
| 3252 | /* The boolean-valued font property key specifying the use of leading. */ | ||
| 3253 | DEFSYM (QCminspace, ":minspace"); | ||
| 3254 | |||
| 3255 | /* Fontconfig's rendering parameters. */ | ||
| 3256 | DEFSYM (QChinting, ":hinting"); | ||
| 3257 | DEFSYM (QCautohint, ":autohint"); | ||
| 3258 | DEFSYM (QChintstyle, ":hintstyle"); | ||
| 3259 | DEFSYM (QCrgba, ":rgba"); | ||
| 3260 | DEFSYM (QCembolden, ":embolden"); | ||
| 3261 | DEFSYM (QClcdfilter, ":lcdfilter"); | ||
| 3262 | |||
| 3134 | staticpro (&freetype_font_cache); | 3263 | staticpro (&freetype_font_cache); |
| 3135 | freetype_font_cache = list1 (Qt); | 3264 | freetype_font_cache = list1 (Qt); |
| 3136 | 3265 | ||
diff --git a/src/ftfont.h b/src/ftfont.h index f877860895e..b2280e9aab9 100644 --- a/src/ftfont.h +++ b/src/ftfont.h | |||
| @@ -42,10 +42,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 42 | #endif /* HAVE_LIBOTF */ | 42 | #endif /* HAVE_LIBOTF */ |
| 43 | 43 | ||
| 44 | extern FcCharSet *ftfont_get_fc_charset (Lisp_Object); | 44 | extern FcCharSet *ftfont_get_fc_charset (Lisp_Object); |
| 45 | extern Lisp_Object ftfont_open2 (struct frame *f, | 45 | extern void ftfont_fix_match (FcPattern *, FcPattern *); |
| 46 | Lisp_Object entity, | 46 | extern void ftfont_add_rendering_parameters (FcPattern *, Lisp_Object); |
| 47 | int pixel_size, | 47 | extern FcPattern *ftfont_entity_pattern (Lisp_Object, int); |
| 48 | Lisp_Object font_object); | ||
| 49 | 48 | ||
| 50 | /* This struct is shared by the XFT, Freetype, and Cairo font | 49 | /* This struct is shared by the XFT, Freetype, and Cairo font |
| 51 | backends. Members up to and including 'matrix' are common, the | 50 | backends. Members up to and including 'matrix' are common, the |
| @@ -59,10 +58,6 @@ struct font_info | |||
| 59 | #endif /* HAVE_LIBOTF */ | 58 | #endif /* HAVE_LIBOTF */ |
| 60 | FT_Size ft_size; | 59 | FT_Size ft_size; |
| 61 | int index; | 60 | int index; |
| 62 | /* Index of the bitmap strike used as a fallback for | ||
| 63 | FT_Set_Pixel_Sizes failure. If the value is non-negative, then | ||
| 64 | ft_size is not of the requested size. Otherwise it is -1. */ | ||
| 65 | FT_Int bitmap_strike_index; | ||
| 66 | FT_Matrix matrix; | 61 | FT_Matrix matrix; |
| 67 | #ifdef HAVE_HARFBUZZ | 62 | #ifdef HAVE_HARFBUZZ |
| 68 | hb_font_t *hb_font; | 63 | hb_font_t *hb_font; |
| @@ -70,9 +65,10 @@ struct font_info | |||
| 70 | 65 | ||
| 71 | #ifdef USE_CAIRO | 66 | #ifdef USE_CAIRO |
| 72 | cairo_scaled_font_t *cr_scaled_font; | 67 | cairo_scaled_font_t *cr_scaled_font; |
| 73 | /* To prevent cairo from cluttering the activated FT_Size maintained | 68 | /* Scale factor from the bitmap strike metrics in 1/64 pixels, used |
| 74 | in ftfont.c, we activate this special FT_Size before drawing. */ | 69 | as the hb_position_t value in HarfBuzz, to those in (scaled) |
| 75 | FT_Size ft_size_draw; | 70 | pixels. The value is 0 for scalable fonts. */ |
| 71 | double bitmap_position_unit; | ||
| 76 | /* Font metrics cache. */ | 72 | /* Font metrics cache. */ |
| 77 | struct font_metrics **metrics; | 73 | struct font_metrics **metrics; |
| 78 | short metrics_nrows; | 74 | short metrics_nrows; |
diff --git a/src/ftxfont.c b/src/ftxfont.c index 949ef4c503b..da3e3fbae10 100644 --- a/src/ftxfont.c +++ b/src/ftxfont.c | |||
| @@ -244,7 +244,7 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 244 | struct font *font = s->font; | 244 | struct font *font = s->font; |
| 245 | XPoint p[0x700]; | 245 | XPoint p[0x700]; |
| 246 | int n[7]; | 246 | int n[7]; |
| 247 | unsigned *code; | 247 | unsigned *code = s->char2b + from; |
| 248 | int len = to - from; | 248 | int len = to - from; |
| 249 | int i; | 249 | int i; |
| 250 | GC *gcs; | 250 | GC *gcs; |
| @@ -252,14 +252,9 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 252 | 252 | ||
| 253 | n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0; | 253 | n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0; |
| 254 | 254 | ||
| 255 | USE_SAFE_ALLOCA; | ||
| 256 | SAFE_NALLOCA (code, 1, len); | ||
| 257 | block_input (); | 255 | block_input (); |
| 258 | if (with_background) | 256 | if (with_background) |
| 259 | ftxfont_draw_background (f, font, s->gc, x, y, s->width); | 257 | ftxfont_draw_background (f, font, s->gc, x, y, s->width); |
| 260 | for (i = 0; i < len; i++) | ||
| 261 | code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) | ||
| 262 | | XCHAR2B_BYTE2 (s->char2b + from + i)); | ||
| 263 | 258 | ||
| 264 | if (face->gc == s->gc) | 259 | if (face->gc == s->gc) |
| 265 | { | 260 | { |
| @@ -304,7 +299,6 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 304 | } | 299 | } |
| 305 | 300 | ||
| 306 | unblock_input (); | 301 | unblock_input (); |
| 307 | SAFE_FREE (); | ||
| 308 | 302 | ||
| 309 | return len; | 303 | return len; |
| 310 | } | 304 | } |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 48233576531..43918dd3da5 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -520,7 +520,7 @@ get_utf8_string (const char *str) | |||
| 520 | bool | 520 | bool |
| 521 | xg_check_special_colors (struct frame *f, | 521 | xg_check_special_colors (struct frame *f, |
| 522 | const char *color_name, | 522 | const char *color_name, |
| 523 | XColor *color) | 523 | Emacs_Color *color) |
| 524 | { | 524 | { |
| 525 | bool success_p = 0; | 525 | bool success_p = 0; |
| 526 | bool get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0; | 526 | bool get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0; |
diff --git a/src/gtkutil.h b/src/gtkutil.h index ec899781ca8..229aa08f817 100644 --- a/src/gtkutil.h +++ b/src/gtkutil.h | |||
| @@ -166,7 +166,7 @@ extern void xg_free_frame_widgets (struct frame *f); | |||
| 166 | extern void xg_set_background_color (struct frame *f, unsigned long bg); | 166 | extern void xg_set_background_color (struct frame *f, unsigned long bg); |
| 167 | extern bool xg_check_special_colors (struct frame *f, | 167 | extern bool xg_check_special_colors (struct frame *f, |
| 168 | const char *color_name, | 168 | const char *color_name, |
| 169 | XColor *color); | 169 | Emacs_Color *color); |
| 170 | 170 | ||
| 171 | extern void xg_set_frame_icon (struct frame *f, | 171 | extern void xg_set_frame_icon (struct frame *f, |
| 172 | Pixmap icon_pixmap, | 172 | Pixmap icon_pixmap, |
diff --git a/src/image.c b/src/image.c index bf594987eb8..57b405f6db9 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -132,17 +132,17 @@ static unsigned long *colors_in_color_table (int *n); | |||
| 132 | #ifdef HAVE_NS | 132 | #ifdef HAVE_NS |
| 133 | /* Use with images created by ns_image_for_XPM. */ | 133 | /* Use with images created by ns_image_for_XPM. */ |
| 134 | static unsigned long | 134 | static unsigned long |
| 135 | XGetPixel (XImagePtr ximage, int x, int y) | 135 | XGetPixel (Emacs_Pix_Container image, int x, int y) |
| 136 | { | 136 | { |
| 137 | return ns_get_pixel (ximage, x, y); | 137 | return ns_get_pixel (image, x, y); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | /* Use with images created by ns_image_for_XPM; alpha set to 1; | 140 | /* Use with images created by ns_image_for_XPM; alpha set to 1; |
| 141 | pixel is assumed to be in RGB form. */ | 141 | pixel is assumed to be in RGB form. */ |
| 142 | static void | 142 | static void |
| 143 | XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) | 143 | XPutPixel (Emacs_Pix_Container image, int x, int y, unsigned long pixel) |
| 144 | { | 144 | { |
| 145 | ns_put_pixel (ximage, x, y, pixel); | 145 | ns_put_pixel (image, x, y, pixel); |
| 146 | } | 146 | } |
| 147 | #endif /* HAVE_NS */ | 147 | #endif /* HAVE_NS */ |
| 148 | 148 | ||
| @@ -228,7 +228,7 @@ image_create_bitmap_from_data (struct frame *f, char *bits, | |||
| 228 | 228 | ||
| 229 | #ifdef HAVE_NTGUI | 229 | #ifdef HAVE_NTGUI |
| 230 | Lisp_Object frame UNINIT; /* The value is not used. */ | 230 | Lisp_Object frame UNINIT; /* The value is not used. */ |
| 231 | Pixmap bitmap; | 231 | Emacs_Pixmap bitmap; |
| 232 | bitmap = CreateBitmap (width, height, | 232 | bitmap = CreateBitmap (width, height, |
| 233 | FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes, | 233 | FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes, |
| 234 | FRAME_DISPLAY_INFO (XFRAME (frame))->n_cbits, | 234 | FRAME_DISPLAY_INFO (XFRAME (frame))->n_cbits, |
| @@ -412,17 +412,19 @@ typedef void Picture; | |||
| 412 | #endif | 412 | #endif |
| 413 | 413 | ||
| 414 | static bool image_create_x_image_and_pixmap_1 (struct frame *, int, int, int, | 414 | static bool image_create_x_image_and_pixmap_1 (struct frame *, int, int, int, |
| 415 | XImagePtr *, Pixmap *, Picture *); | 415 | Emacs_Pix_Container *, |
| 416 | static void image_destroy_x_image (XImagePtr ximg); | 416 | Emacs_Pixmap *, Picture *); |
| 417 | static void image_destroy_x_image (Emacs_Pix_Container); | ||
| 417 | 418 | ||
| 418 | #ifdef HAVE_NTGUI | 419 | #ifdef HAVE_NTGUI |
| 419 | static XImagePtr_or_DC image_get_x_image_or_dc (struct frame *, struct image *, | 420 | static HDC image_get_x_image_or_dc (struct frame *, struct image *, |
| 420 | bool, HGDIOBJ *); | 421 | bool, HGDIOBJ *); |
| 421 | static void image_unget_x_image_or_dc (struct image *, bool, XImagePtr_or_DC, | 422 | static void image_unget_x_image_or_dc (struct image *, bool, |
| 422 | HGDIOBJ); | 423 | HDC, HGDIOBJ); |
| 423 | #else | 424 | #else |
| 424 | static XImagePtr image_get_x_image (struct frame *, struct image *, bool); | 425 | static Emacs_Pix_Container image_get_x_image (struct frame *, struct image *, |
| 425 | static void image_unget_x_image (struct image *, bool, XImagePtr); | 426 | bool); |
| 427 | static void image_unget_x_image (struct image *, bool, Emacs_Pix_Container); | ||
| 426 | #define image_get_x_image_or_dc(f, img, mask_p, dummy) \ | 428 | #define image_get_x_image_or_dc(f, img, mask_p, dummy) \ |
| 427 | image_get_x_image (f, img, mask_p) | 429 | image_get_x_image (f, img, mask_p) |
| 428 | #define image_unget_x_image_or_dc(img, mask_p, ximg, dummy) \ | 430 | #define image_unget_x_image_or_dc(img, mask_p, ximg, dummy) \ |
| @@ -436,7 +438,7 @@ static void image_sync_to_pixmaps (struct frame *, struct image *); | |||
| 436 | /* Useful functions defined in the section | 438 | /* Useful functions defined in the section |
| 437 | `Image type independent image structures' below. */ | 439 | `Image type independent image structures' below. */ |
| 438 | 440 | ||
| 439 | static unsigned long four_corners_best (XImagePtr ximg, | 441 | static unsigned long four_corners_best (XImage *ximg, |
| 440 | int *corners, | 442 | int *corners, |
| 441 | unsigned long width, | 443 | unsigned long width, |
| 442 | unsigned long height); | 444 | unsigned long height); |
| @@ -449,7 +451,7 @@ void | |||
| 449 | x_create_bitmap_mask (struct frame *f, ptrdiff_t id) | 451 | x_create_bitmap_mask (struct frame *f, ptrdiff_t id) |
| 450 | { | 452 | { |
| 451 | Pixmap pixmap, mask; | 453 | Pixmap pixmap, mask; |
| 452 | XImagePtr ximg, mask_img; | 454 | XImage *ximg, *mask_img; |
| 453 | unsigned long width, height; | 455 | unsigned long width, height; |
| 454 | bool result; | 456 | bool result; |
| 455 | unsigned long bg; | 457 | unsigned long bg; |
| @@ -548,82 +550,29 @@ struct image_type | |||
| 548 | /* Free resources of image IMG which is used on frame F. */ | 550 | /* Free resources of image IMG which is used on frame F. */ |
| 549 | void (*free) (struct frame *f, struct image *img); | 551 | void (*free) (struct frame *f, struct image *img); |
| 550 | 552 | ||
| 553 | #ifdef WINDOWSNT | ||
| 551 | /* Initialization function (used for dynamic loading of image | 554 | /* Initialization function (used for dynamic loading of image |
| 552 | libraries on Windows), or NULL if none. */ | 555 | libraries on Windows), or NULL if none. */ |
| 553 | bool (*init) (void); | 556 | bool (*init) (void); |
| 554 | 557 | /* An initializer for the init field. */ | |
| 555 | /* Next in list of all supported image types. */ | 558 | # define IMAGE_TYPE_INIT(f) f |
| 556 | struct image_type *next; | 559 | #else |
| 560 | # define IMAGE_TYPE_INIT(f) | ||
| 561 | #endif | ||
| 557 | }; | 562 | }; |
| 558 | 563 | ||
| 559 | /* List of supported image types. Use define_image_type to add new | ||
| 560 | types. Use lookup_image_type to find a type for a given symbol. */ | ||
| 561 | |||
| 562 | static struct image_type *image_types; | ||
| 563 | |||
| 564 | /* Forward function prototypes. */ | 564 | /* Forward function prototypes. */ |
| 565 | 565 | ||
| 566 | static struct image_type *lookup_image_type (Lisp_Object); | 566 | static struct image_type const *lookup_image_type (Lisp_Object); |
| 567 | static void image_laplace (struct frame *, struct image *); | 567 | static void image_laplace (struct frame *, struct image *); |
| 568 | static void image_emboss (struct frame *, struct image *); | 568 | static void image_emboss (struct frame *, struct image *); |
| 569 | static void image_build_heuristic_mask (struct frame *, struct image *, | 569 | static void image_build_heuristic_mask (struct frame *, struct image *, |
| 570 | Lisp_Object); | 570 | Lisp_Object); |
| 571 | #ifdef WINDOWSNT | ||
| 572 | #define CACHE_IMAGE_TYPE(type, status) \ | ||
| 573 | do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0) | ||
| 574 | #else | ||
| 575 | #define CACHE_IMAGE_TYPE(type, status) | ||
| 576 | #endif | ||
| 577 | |||
| 578 | #define ADD_IMAGE_TYPE(type) \ | ||
| 579 | do { Vimage_types = Fcons (type, Vimage_types); } while (0) | ||
| 580 | |||
| 581 | /* Define a new image type from TYPE. This adds a copy of TYPE to | ||
| 582 | image_types and caches the loading status of TYPE. */ | ||
| 583 | 571 | ||
| 584 | static struct image_type * | 572 | static void |
| 585 | define_image_type (struct image_type *type) | 573 | add_image_type (Lisp_Object type) |
| 586 | { | 574 | { |
| 587 | struct image_type *p = NULL; | 575 | Vimage_types = Fcons (type, Vimage_types); |
| 588 | int new_type = type->type; | ||
| 589 | bool type_valid = true; | ||
| 590 | |||
| 591 | block_input (); | ||
| 592 | |||
| 593 | for (p = image_types; p; p = p->next) | ||
| 594 | if (p->type == new_type) | ||
| 595 | goto done; | ||
| 596 | |||
| 597 | if (type->init) | ||
| 598 | { | ||
| 599 | #if defined HAVE_NTGUI && defined WINDOWSNT | ||
| 600 | /* If we failed to load the library before, don't try again. */ | ||
| 601 | Lisp_Object tested = Fassq (builtin_lisp_symbol (new_type), | ||
| 602 | Vlibrary_cache); | ||
| 603 | if (CONSP (tested) && NILP (XCDR (tested))) | ||
| 604 | type_valid = false; | ||
| 605 | else | ||
| 606 | #endif | ||
| 607 | { | ||
| 608 | type_valid = type->init (); | ||
| 609 | CACHE_IMAGE_TYPE (builtin_lisp_symbol (new_type), | ||
| 610 | type_valid ? Qt : Qnil); | ||
| 611 | } | ||
| 612 | } | ||
| 613 | |||
| 614 | if (type_valid) | ||
| 615 | { | ||
| 616 | /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. | ||
| 617 | The initialized data segment is read-only. */ | ||
| 618 | p = xmalloc (sizeof *p); | ||
| 619 | *p = *type; | ||
| 620 | p->next = image_types; | ||
| 621 | image_types = p; | ||
| 622 | } | ||
| 623 | |||
| 624 | done: | ||
| 625 | unblock_input (); | ||
| 626 | return p; | ||
| 627 | } | 576 | } |
| 628 | 577 | ||
| 629 | 578 | ||
| @@ -637,29 +586,24 @@ define_image_type (struct image_type *type) | |||
| 637 | bool | 586 | bool |
| 638 | valid_image_p (Lisp_Object object) | 587 | valid_image_p (Lisp_Object object) |
| 639 | { | 588 | { |
| 640 | bool valid_p = 0; | ||
| 641 | |||
| 642 | if (IMAGEP (object)) | 589 | if (IMAGEP (object)) |
| 643 | { | 590 | { |
| 644 | Lisp_Object tem; | 591 | Lisp_Object tail = XCDR (object); |
| 645 | 592 | FOR_EACH_TAIL_SAFE (tail) | |
| 646 | for (tem = XCDR (object); CONSP (tem); tem = XCDR (tem)) | 593 | if (EQ (XCAR (tail), QCtype)) |
| 647 | if (EQ (XCAR (tem), QCtype)) | ||
| 648 | { | 594 | { |
| 649 | tem = XCDR (tem); | 595 | tail = XCDR (tail); |
| 650 | if (CONSP (tem) && SYMBOLP (XCAR (tem))) | 596 | if (CONSP (tail)) |
| 651 | { | 597 | { |
| 652 | struct image_type *type; | 598 | struct image_type const *type = lookup_image_type (XCAR (tail)); |
| 653 | type = lookup_image_type (XCAR (tem)); | ||
| 654 | if (type) | 599 | if (type) |
| 655 | valid_p = type->valid_p (object); | 600 | return type->valid_p (object); |
| 656 | } | 601 | } |
| 657 | |||
| 658 | break; | 602 | break; |
| 659 | } | 603 | } |
| 660 | } | 604 | } |
| 661 | 605 | ||
| 662 | return valid_p; | 606 | return false; |
| 663 | } | 607 | } |
| 664 | 608 | ||
| 665 | 609 | ||
| @@ -1134,10 +1078,10 @@ image_ascent (struct image *img, struct face *face, struct glyph_slice *slice) | |||
| 1134 | 1078 | ||
| 1135 | #ifdef USE_CAIRO | 1079 | #ifdef USE_CAIRO |
| 1136 | static uint32_t | 1080 | static uint32_t |
| 1137 | xcolor_to_argb32 (XColor xc) | 1081 | emacs_color_to_argb32 (Emacs_Color *ec) |
| 1138 | { | 1082 | { |
| 1139 | return ((0xffu << 24) | ((xc.red / 256) << 16) | 1083 | return ((0xffu << 24) | ((ec->red / 256) << 16) |
| 1140 | | ((xc.green / 256) << 8) | (xc.blue / 256)); | 1084 | | ((ec->green / 256) << 8) | (ec->blue / 256)); |
| 1141 | } | 1085 | } |
| 1142 | 1086 | ||
| 1143 | static uint32_t | 1087 | static uint32_t |
| @@ -1145,11 +1089,11 @@ get_spec_bg_or_alpha_as_argb (struct image *img, | |||
| 1145 | struct frame *f) | 1089 | struct frame *f) |
| 1146 | { | 1090 | { |
| 1147 | uint32_t bgcolor = 0; | 1091 | uint32_t bgcolor = 0; |
| 1148 | XColor xbgcolor; | 1092 | Emacs_Color xbgcolor; |
| 1149 | Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL); | 1093 | Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL); |
| 1150 | 1094 | ||
| 1151 | if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor)) | 1095 | if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor)) |
| 1152 | bgcolor = xcolor_to_argb32 (xbgcolor); | 1096 | bgcolor = emacs_color_to_argb32 (&xbgcolor); |
| 1153 | 1097 | ||
| 1154 | return bgcolor; | 1098 | return bgcolor; |
| 1155 | } | 1099 | } |
| @@ -1179,10 +1123,10 @@ set_cairo_image_surface (struct image *img, cairo_surface_t *surface) | |||
| 1179 | /* Image background colors. */ | 1123 | /* Image background colors. */ |
| 1180 | 1124 | ||
| 1181 | /* Find the "best" corner color of a bitmap. | 1125 | /* Find the "best" corner color of a bitmap. |
| 1182 | On W32, XIMG is assumed to a device context with the bitmap selected. */ | 1126 | On W32, PIMG is assumed to a device context with the bitmap selected. */ |
| 1183 | 1127 | ||
| 1184 | static RGB_PIXEL_COLOR | 1128 | static RGB_PIXEL_COLOR |
| 1185 | four_corners_best (XImagePtr_or_DC ximg, int *corners, | 1129 | four_corners_best (Emacs_Pix_Context pimg, int *corners, |
| 1186 | unsigned long width, unsigned long height) | 1130 | unsigned long width, unsigned long height) |
| 1187 | { | 1131 | { |
| 1188 | RGB_PIXEL_COLOR corner_pixels[4]; | 1132 | RGB_PIXEL_COLOR corner_pixels[4]; |
| @@ -1191,19 +1135,19 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners, | |||
| 1191 | 1135 | ||
| 1192 | if (corners && corners[BOT_CORNER] >= 0) | 1136 | if (corners && corners[BOT_CORNER] >= 0) |
| 1193 | { | 1137 | { |
| 1194 | /* Get the colors at the corner_pixels of ximg. */ | 1138 | /* Get the colors at the corner_pixels of pimg. */ |
| 1195 | corner_pixels[0] = GET_PIXEL (ximg, corners[LEFT_CORNER], corners[TOP_CORNER]); | 1139 | corner_pixels[0] = GET_PIXEL (pimg, corners[LEFT_CORNER], corners[TOP_CORNER]); |
| 1196 | corner_pixels[1] = GET_PIXEL (ximg, corners[RIGHT_CORNER] - 1, corners[TOP_CORNER]); | 1140 | corner_pixels[1] = GET_PIXEL (pimg, corners[RIGHT_CORNER] - 1, corners[TOP_CORNER]); |
| 1197 | corner_pixels[2] = GET_PIXEL (ximg, corners[RIGHT_CORNER] - 1, corners[BOT_CORNER] - 1); | 1141 | corner_pixels[2] = GET_PIXEL (pimg, corners[RIGHT_CORNER] - 1, corners[BOT_CORNER] - 1); |
| 1198 | corner_pixels[3] = GET_PIXEL (ximg, corners[LEFT_CORNER], corners[BOT_CORNER] - 1); | 1142 | corner_pixels[3] = GET_PIXEL (pimg, corners[LEFT_CORNER], corners[BOT_CORNER] - 1); |
| 1199 | } | 1143 | } |
| 1200 | else | 1144 | else |
| 1201 | { | 1145 | { |
| 1202 | /* Get the colors at the corner_pixels of ximg. */ | 1146 | /* Get the colors at the corner_pixels of pimg. */ |
| 1203 | corner_pixels[0] = GET_PIXEL (ximg, 0, 0); | 1147 | corner_pixels[0] = GET_PIXEL (pimg, 0, 0); |
| 1204 | corner_pixels[1] = GET_PIXEL (ximg, width - 1, 0); | 1148 | corner_pixels[1] = GET_PIXEL (pimg, width - 1, 0); |
| 1205 | corner_pixels[2] = GET_PIXEL (ximg, width - 1, height - 1); | 1149 | corner_pixels[2] = GET_PIXEL (pimg, width - 1, height - 1); |
| 1206 | corner_pixels[3] = GET_PIXEL (ximg, 0, height - 1); | 1150 | corner_pixels[3] = GET_PIXEL (pimg, 0, height - 1); |
| 1207 | } | 1151 | } |
| 1208 | /* Choose the most frequently found color as background. */ | 1152 | /* Choose the most frequently found color as background. */ |
| 1209 | for (i = best_count = 0; i < 4; ++i) | 1153 | for (i = best_count = 0; i < 4; ++i) |
| @@ -1221,49 +1165,29 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners, | |||
| 1221 | return best; | 1165 | return best; |
| 1222 | } | 1166 | } |
| 1223 | 1167 | ||
| 1224 | /* Portability macros */ | ||
| 1225 | |||
| 1226 | #ifdef HAVE_NTGUI | ||
| 1227 | |||
| 1228 | #define Free_Pixmap(display, pixmap) \ | ||
| 1229 | DeleteObject (pixmap) | ||
| 1230 | |||
| 1231 | #elif defined (HAVE_NS) | ||
| 1232 | |||
| 1233 | #define Free_Pixmap(display, pixmap) \ | ||
| 1234 | ns_release_object (pixmap) | ||
| 1235 | |||
| 1236 | #else | ||
| 1237 | |||
| 1238 | #define Free_Pixmap(display, pixmap) \ | ||
| 1239 | XFreePixmap (display, pixmap) | ||
| 1240 | |||
| 1241 | #endif /* !HAVE_NTGUI && !HAVE_NS */ | ||
| 1242 | |||
| 1243 | |||
| 1244 | /* Return the `background' field of IMG. If IMG doesn't have one yet, | 1168 | /* Return the `background' field of IMG. If IMG doesn't have one yet, |
| 1245 | it is guessed heuristically. If non-zero, XIMG is an existing | 1169 | it is guessed heuristically. If non-zero, XIMG is an existing |
| 1246 | XImage object (or device context with the image selected on W32) to | 1170 | Emacs_Pix_Context object (device context with the image selected on |
| 1247 | use for the heuristic. */ | 1171 | W32) to use for the heuristic. */ |
| 1248 | 1172 | ||
| 1249 | RGB_PIXEL_COLOR | 1173 | RGB_PIXEL_COLOR |
| 1250 | image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg) | 1174 | image_background (struct image *img, struct frame *f, Emacs_Pix_Context pimg) |
| 1251 | { | 1175 | { |
| 1252 | if (! img->background_valid) | 1176 | if (! img->background_valid) |
| 1253 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ | 1177 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ |
| 1254 | { | 1178 | { |
| 1255 | bool free_ximg = !ximg; | 1179 | bool free_pimg = !pimg; |
| 1256 | #ifdef HAVE_NTGUI | 1180 | #ifdef HAVE_NTGUI |
| 1257 | HGDIOBJ prev; | 1181 | HGDIOBJ prev; |
| 1258 | #endif /* HAVE_NTGUI */ | 1182 | #endif /* HAVE_NTGUI */ |
| 1259 | 1183 | ||
| 1260 | if (free_ximg) | 1184 | if (free_pimg) |
| 1261 | ximg = image_get_x_image_or_dc (f, img, 0, &prev); | 1185 | pimg = image_get_x_image_or_dc (f, img, 0, &prev); |
| 1262 | 1186 | ||
| 1263 | img->background = four_corners_best (ximg, img->corners, img->width, img->height); | 1187 | img->background = four_corners_best (pimg, img->corners, img->width, img->height); |
| 1264 | 1188 | ||
| 1265 | if (free_ximg) | 1189 | if (free_pimg) |
| 1266 | image_unget_x_image_or_dc (img, 0, ximg, prev); | 1190 | image_unget_x_image_or_dc (img, 0, pimg, prev); |
| 1267 | 1191 | ||
| 1268 | img->background_valid = 1; | 1192 | img->background_valid = 1; |
| 1269 | } | 1193 | } |
| @@ -1273,10 +1197,12 @@ image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg) | |||
| 1273 | 1197 | ||
| 1274 | /* Return the `background_transparent' field of IMG. If IMG doesn't | 1198 | /* Return the `background_transparent' field of IMG. If IMG doesn't |
| 1275 | have one yet, it is guessed heuristically. If non-zero, MASK is an | 1199 | have one yet, it is guessed heuristically. If non-zero, MASK is an |
| 1276 | existing XImage object to use for the heuristic. */ | 1200 | existing Emacs_Pix_Context (XImage* on X) object to use for the |
| 1201 | heuristic. */ | ||
| 1277 | 1202 | ||
| 1278 | int | 1203 | int |
| 1279 | image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_DC mask) | 1204 | image_background_transparent (struct image *img, struct frame *f, |
| 1205 | Emacs_Pix_Context mask) | ||
| 1280 | { | 1206 | { |
| 1281 | if (! img->background_transparent_valid) | 1207 | if (! img->background_transparent_valid) |
| 1282 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ | 1208 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ |
| @@ -1328,7 +1254,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags) | |||
| 1328 | { | 1254 | { |
| 1329 | if (img->pixmap) | 1255 | if (img->pixmap) |
| 1330 | { | 1256 | { |
| 1331 | Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap); | 1257 | FRAME_TERMINAL (f)->free_pixmap (f, img->pixmap); |
| 1332 | img->pixmap = NO_PIXMAP; | 1258 | img->pixmap = NO_PIXMAP; |
| 1333 | /* NOTE (HAVE_NS): background color is NOT an indexed color! */ | 1259 | /* NOTE (HAVE_NS): background color is NOT an indexed color! */ |
| 1334 | img->background_valid = 0; | 1260 | img->background_valid = 0; |
| @@ -1347,7 +1273,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags) | |||
| 1347 | { | 1273 | { |
| 1348 | if (img->mask) | 1274 | if (img->mask) |
| 1349 | { | 1275 | { |
| 1350 | Free_Pixmap (FRAME_X_DISPLAY (f), img->mask); | 1276 | FRAME_TERMINAL (f)->free_pixmap (f, img->mask); |
| 1351 | img->mask = NO_PIXMAP; | 1277 | img->mask = NO_PIXMAP; |
| 1352 | img->background_transparent_valid = 0; | 1278 | img->background_transparent_valid = 0; |
| 1353 | } | 1279 | } |
| @@ -1399,7 +1325,7 @@ static unsigned long | |||
| 1399 | image_alloc_image_color (struct frame *f, struct image *img, | 1325 | image_alloc_image_color (struct frame *f, struct image *img, |
| 1400 | Lisp_Object color_name, unsigned long dflt) | 1326 | Lisp_Object color_name, unsigned long dflt) |
| 1401 | { | 1327 | { |
| 1402 | XColor color; | 1328 | Emacs_Color color; |
| 1403 | unsigned long result; | 1329 | unsigned long result; |
| 1404 | 1330 | ||
| 1405 | eassert (STRINGP (color_name)); | 1331 | eassert (STRINGP (color_name)); |
| @@ -2079,7 +2005,7 @@ mark_image_cache (struct image_cache *c) | |||
| 2079 | WIDTH and HEIGHT must both be positive. | 2005 | WIDTH and HEIGHT must both be positive. |
| 2080 | If XIMG is null, assume it is a bitmap. */ | 2006 | If XIMG is null, assume it is a bitmap. */ |
| 2081 | static bool | 2007 | static bool |
| 2082 | image_check_image_size (XImagePtr ximg, int width, int height) | 2008 | image_check_image_size (Emacs_Pix_Container ximg, int width, int height) |
| 2083 | { | 2009 | { |
| 2084 | #ifdef HAVE_X_WINDOWS | 2010 | #ifdef HAVE_X_WINDOWS |
| 2085 | /* Respect Xlib's limits: it cannot deal with images that have more | 2011 | /* Respect Xlib's limits: it cannot deal with images that have more |
| @@ -2113,18 +2039,20 @@ image_check_image_size (XImagePtr ximg, int width, int height) | |||
| 2113 | #endif | 2039 | #endif |
| 2114 | } | 2040 | } |
| 2115 | 2041 | ||
| 2116 | /* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on | 2042 | /* Create an Emacs_Pix_Container and a pixmap of size WIDTH x |
| 2117 | frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created. | 2043 | HEIGHT for use on frame F. Set *PIMG and *PIXMAP to the |
| 2118 | Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated | 2044 | Emacs_Pix_Container and Emacs_Pixmap created. Set (*PIMG)->data |
| 2119 | via xmalloc. Print error messages via image_error if an error | 2045 | to a raster of WIDTH x HEIGHT pixels allocated via xmalloc. Print |
| 2120 | occurs. Value is true if successful. | 2046 | error messages via image_error if an error occurs. Value is true |
| 2047 | if successful. | ||
| 2121 | 2048 | ||
| 2122 | On W32, a DEPTH of zero signifies a 24 bit image, otherwise DEPTH | 2049 | On W32, a DEPTH of zero signifies a 24 bit image, otherwise DEPTH |
| 2123 | should indicate the bit depth of the image. */ | 2050 | should indicate the bit depth of the image. */ |
| 2124 | 2051 | ||
| 2125 | static bool | 2052 | static bool |
| 2126 | image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int depth, | 2053 | image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int depth, |
| 2127 | XImagePtr *ximg, Pixmap *pixmap, Picture *picture) | 2054 | Emacs_Pix_Container *pimg, |
| 2055 | Emacs_Pixmap *pixmap, Picture *picture) | ||
| 2128 | { | 2056 | { |
| 2129 | #ifdef HAVE_X_WINDOWS | 2057 | #ifdef HAVE_X_WINDOWS |
| 2130 | Display *display = FRAME_X_DISPLAY (f); | 2058 | Display *display = FRAME_X_DISPLAY (f); |
| @@ -2135,33 +2063,33 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d | |||
| 2135 | 2063 | ||
| 2136 | if (depth <= 0) | 2064 | if (depth <= 0) |
| 2137 | depth = DefaultDepthOfScreen (screen); | 2065 | depth = DefaultDepthOfScreen (screen); |
| 2138 | *ximg = XCreateImage (display, DefaultVisualOfScreen (screen), | 2066 | *pimg = XCreateImage (display, DefaultVisualOfScreen (screen), |
| 2139 | depth, ZPixmap, 0, NULL, width, height, | 2067 | depth, ZPixmap, 0, NULL, width, height, |
| 2140 | depth > 16 ? 32 : depth > 8 ? 16 : 8, 0); | 2068 | depth > 16 ? 32 : depth > 8 ? 16 : 8, 0); |
| 2141 | if (*ximg == NULL) | 2069 | if (*pimg == NULL) |
| 2142 | { | 2070 | { |
| 2143 | image_error ("Unable to allocate X image"); | 2071 | image_error ("Unable to allocate X image"); |
| 2144 | return 0; | 2072 | return 0; |
| 2145 | } | 2073 | } |
| 2146 | 2074 | ||
| 2147 | if (! image_check_image_size (*ximg, width, height)) | 2075 | if (! image_check_image_size (*pimg, width, height)) |
| 2148 | { | 2076 | { |
| 2149 | image_destroy_x_image (*ximg); | 2077 | image_destroy_x_image (*pimg); |
| 2150 | *ximg = NULL; | 2078 | *pimg = NULL; |
| 2151 | image_error ("Image too large (%dx%d)", | 2079 | image_error ("Image too large (%dx%d)", |
| 2152 | make_fixnum (width), make_fixnum (height)); | 2080 | make_fixnum (width), make_fixnum (height)); |
| 2153 | return 0; | 2081 | return 0; |
| 2154 | } | 2082 | } |
| 2155 | 2083 | ||
| 2156 | /* Allocate image raster. */ | 2084 | /* Allocate image raster. */ |
| 2157 | (*ximg)->data = xmalloc ((*ximg)->bytes_per_line * height); | 2085 | (*pimg)->data = xmalloc ((*pimg)->bytes_per_line * height); |
| 2158 | 2086 | ||
| 2159 | /* Allocate a pixmap of the same size. */ | 2087 | /* Allocate a pixmap of the same size. */ |
| 2160 | *pixmap = XCreatePixmap (display, drawable, width, height, depth); | 2088 | *pixmap = XCreatePixmap (display, drawable, width, height, depth); |
| 2161 | if (*pixmap == NO_PIXMAP) | 2089 | if (*pixmap == NO_PIXMAP) |
| 2162 | { | 2090 | { |
| 2163 | image_destroy_x_image (*ximg); | 2091 | image_destroy_x_image (*pimg); |
| 2164 | *ximg = NULL; | 2092 | *pimg = NULL; |
| 2165 | image_error ("Unable to create X pixmap"); | 2093 | image_error ("Unable to create X pixmap"); |
| 2166 | return 0; | 2094 | return 0; |
| 2167 | } | 2095 | } |
| @@ -2228,10 +2156,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d | |||
| 2228 | if (depth < 16) | 2156 | if (depth < 16) |
| 2229 | palette_colors = 1 << (depth - 1); | 2157 | palette_colors = 1 << (depth - 1); |
| 2230 | 2158 | ||
| 2231 | *ximg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD)); | 2159 | *pimg = xmalloc (sizeof (XImage) + palette_colors * sizeof (RGBQUAD)); |
| 2232 | 2160 | ||
| 2233 | header = &(*ximg)->info.bmiHeader; | 2161 | header = &(*pimg)->info.bmiHeader; |
| 2234 | memset (&(*ximg)->info, 0, sizeof (BITMAPINFO)); | 2162 | memset (&(*pimg)->info, 0, sizeof (BITMAPINFO)); |
| 2235 | header->biSize = sizeof (*header); | 2163 | header->biSize = sizeof (*header); |
| 2236 | header->biWidth = width; | 2164 | header->biWidth = width; |
| 2237 | header->biHeight = -height; /* negative indicates a top-down bitmap. */ | 2165 | header->biHeight = -height; /* negative indicates a top-down bitmap. */ |
| @@ -2243,10 +2171,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d | |||
| 2243 | /* TODO: fill in palette. */ | 2171 | /* TODO: fill in palette. */ |
| 2244 | if (depth == 1) | 2172 | if (depth == 1) |
| 2245 | { | 2173 | { |
| 2246 | (*ximg)->info.bmiColors[0].rgbBlue = 0; | 2174 | (*pimg)->info.bmiColors[0].rgbBlue = 0; |
| 2247 | (*ximg)->info.bmiColors[0].rgbGreen = 0; | 2175 | (*pimg)->info.bmiColors[0].rgbGreen = 0; |
| 2248 | (*ximg)->info.bmiColors[0].rgbRed = 0; | 2176 | (*pimg)->info.bmiColors[0].rgbRed = 0; |
| 2249 | (*ximg)->info.bmiColors[0].rgbReserved = 0; | 2177 | (*pimg)->info.bmiColors[0].rgbReserved = 0; |
| 2250 | /* bmiColors is a variable-length array declared by w32api | 2178 | /* bmiColors is a variable-length array declared by w32api |
| 2251 | headers as bmiColors[1], which triggers a warning under | 2179 | headers as bmiColors[1], which triggers a warning under |
| 2252 | -Warray-bounds; shut that up. */ | 2180 | -Warray-bounds; shut that up. */ |
| @@ -2254,10 +2182,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d | |||
| 2254 | # pragma GCC push_options | 2182 | # pragma GCC push_options |
| 2255 | # pragma GCC diagnostic ignored "-Warray-bounds" | 2183 | # pragma GCC diagnostic ignored "-Warray-bounds" |
| 2256 | # endif | 2184 | # endif |
| 2257 | (*ximg)->info.bmiColors[1].rgbBlue = 255; | 2185 | (*pimg)->info.bmiColors[1].rgbBlue = 255; |
| 2258 | (*ximg)->info.bmiColors[1].rgbGreen = 255; | 2186 | (*pimg)->info.bmiColors[1].rgbGreen = 255; |
| 2259 | (*ximg)->info.bmiColors[1].rgbRed = 255; | 2187 | (*pimg)->info.bmiColors[1].rgbRed = 255; |
| 2260 | (*ximg)->info.bmiColors[1].rgbReserved = 0; | 2188 | (*pimg)->info.bmiColors[1].rgbReserved = 0; |
| 2261 | # if GNUC_PREREQ (4, 4, 0) | 2189 | # if GNUC_PREREQ (4, 4, 0) |
| 2262 | # pragma GCC pop_options | 2190 | # pragma GCC pop_options |
| 2263 | # endif | 2191 | # endif |
| @@ -2267,10 +2195,10 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d | |||
| 2267 | 2195 | ||
| 2268 | /* Create a DIBSection and raster array for the bitmap, | 2196 | /* Create a DIBSection and raster array for the bitmap, |
| 2269 | and store its handle in *pixmap. */ | 2197 | and store its handle in *pixmap. */ |
| 2270 | *pixmap = CreateDIBSection (hdc, &((*ximg)->info), | 2198 | *pixmap = CreateDIBSection (hdc, &((*pimg)->info), |
| 2271 | (depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS, | 2199 | (depth < 16) ? DIB_PAL_COLORS : DIB_RGB_COLORS, |
| 2272 | /* casting avoids a GCC warning */ | 2200 | /* casting avoids a GCC warning */ |
| 2273 | (void **)&((*ximg)->data), NULL, 0); | 2201 | (void **)&((*pimg)->data), NULL, 0); |
| 2274 | 2202 | ||
| 2275 | /* Realize display palette and garbage all frames. */ | 2203 | /* Realize display palette and garbage all frames. */ |
| 2276 | release_frame_dc (f, hdc); | 2204 | release_frame_dc (f, hdc); |
| @@ -2282,8 +2210,8 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d | |||
| 2282 | /* All system errors are < 10000, so the following is safe. */ | 2210 | /* All system errors are < 10000, so the following is safe. */ |
| 2283 | XSETINT (errcode, err); | 2211 | XSETINT (errcode, err); |
| 2284 | image_error ("Unable to create bitmap, error code %d", errcode); | 2212 | image_error ("Unable to create bitmap, error code %d", errcode); |
| 2285 | image_destroy_x_image (*ximg); | 2213 | image_destroy_x_image (*pimg); |
| 2286 | *ximg = NULL; | 2214 | *pimg = NULL; |
| 2287 | return 0; | 2215 | return 0; |
| 2288 | } | 2216 | } |
| 2289 | 2217 | ||
| @@ -2295,69 +2223,70 @@ image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int d | |||
| 2295 | *pixmap = ns_image_for_XPM (width, height, depth); | 2223 | *pixmap = ns_image_for_XPM (width, height, depth); |
| 2296 | if (*pixmap == 0) | 2224 | if (*pixmap == 0) |
| 2297 | { | 2225 | { |
| 2298 | *ximg = NULL; | 2226 | *pimg = NULL; |
| 2299 | image_error ("Unable to allocate NSImage for XPM pixmap"); | 2227 | image_error ("Unable to allocate NSImage for XPM pixmap"); |
| 2300 | return 0; | 2228 | return 0; |
| 2301 | } | 2229 | } |
| 2302 | *ximg = *pixmap; | 2230 | *pimg = *pixmap; |
| 2303 | return 1; | 2231 | return 1; |
| 2304 | #endif | 2232 | #endif |
| 2305 | } | 2233 | } |
| 2306 | 2234 | ||
| 2307 | 2235 | ||
| 2308 | /* Destroy XImage XIMG. Free XIMG->data. */ | 2236 | /* Destroy Emacs_Pix_Container PIMG. Free data associated with PIMG. */ |
| 2309 | 2237 | ||
| 2310 | static void | 2238 | static void |
| 2311 | image_destroy_x_image (XImagePtr ximg) | 2239 | image_destroy_x_image (Emacs_Pix_Container pimg) |
| 2312 | { | 2240 | { |
| 2313 | eassert (input_blocked_p ()); | 2241 | eassert (input_blocked_p ()); |
| 2314 | if (ximg) | 2242 | if (pimg) |
| 2315 | { | 2243 | { |
| 2316 | #ifdef HAVE_X_WINDOWS | 2244 | #ifdef HAVE_X_WINDOWS |
| 2317 | xfree (ximg->data); | 2245 | xfree (pimg->data); |
| 2318 | ximg->data = NULL; | 2246 | pimg->data = NULL; |
| 2319 | XDestroyImage (ximg); | 2247 | XDestroyImage (pimg); |
| 2320 | #endif /* HAVE_X_WINDOWS */ | 2248 | #endif /* HAVE_X_WINDOWS */ |
| 2321 | #ifdef HAVE_NTGUI | 2249 | #ifdef HAVE_NTGUI |
| 2322 | /* Data will be freed by DestroyObject. */ | 2250 | /* Data will be freed by DestroyObject. */ |
| 2323 | ximg->data = NULL; | 2251 | pimg->data = NULL; |
| 2324 | xfree (ximg); | 2252 | xfree (pimg); |
| 2325 | #endif /* HAVE_NTGUI */ | 2253 | #endif /* HAVE_NTGUI */ |
| 2326 | #ifdef HAVE_NS | 2254 | #ifdef HAVE_NS |
| 2327 | ns_release_object (ximg); | 2255 | ns_release_object (pimg); |
| 2328 | #endif /* HAVE_NS */ | 2256 | #endif /* HAVE_NS */ |
| 2329 | } | 2257 | } |
| 2330 | } | 2258 | } |
| 2331 | 2259 | ||
| 2332 | 2260 | ||
| 2333 | /* Put XImage XIMG into pixmap PIXMAP on frame F. WIDTH and HEIGHT | 2261 | /* Put Emacs_Pix_Container PIMG into pixmap PIXMAP on frame F. |
| 2334 | are width and height of both the image and pixmap. */ | 2262 | WIDTH and HEIGHT are width and height of both the image and |
| 2263 | pixmap. */ | ||
| 2335 | 2264 | ||
| 2336 | static void | 2265 | static void |
| 2337 | gui_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, | 2266 | gui_put_x_image (struct frame *f, Emacs_Pix_Container pimg, |
| 2338 | int width, int height) | 2267 | Emacs_Pixmap pixmap, int width, int height) |
| 2339 | { | 2268 | { |
| 2340 | #ifdef HAVE_X_WINDOWS | 2269 | #ifdef HAVE_X_WINDOWS |
| 2341 | GC gc; | 2270 | GC gc; |
| 2342 | 2271 | ||
| 2343 | eassert (input_blocked_p ()); | 2272 | eassert (input_blocked_p ()); |
| 2344 | gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL); | 2273 | gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL); |
| 2345 | XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, | 2274 | XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, pimg, 0, 0, 0, 0, |
| 2346 | ximg->width, ximg->height); | 2275 | pimg->width, pimg->height); |
| 2347 | XFreeGC (FRAME_X_DISPLAY (f), gc); | 2276 | XFreeGC (FRAME_X_DISPLAY (f), gc); |
| 2348 | #endif /* HAVE_X_WINDOWS */ | 2277 | #endif /* HAVE_X_WINDOWS */ |
| 2349 | 2278 | ||
| 2350 | #ifdef HAVE_NTGUI | 2279 | #ifdef HAVE_NTGUI |
| 2351 | #if 0 /* I don't think this is necessary looking at where it is used. */ | 2280 | #if 0 /* I don't think this is necessary looking at where it is used. */ |
| 2352 | HDC hdc = get_frame_dc (f); | 2281 | HDC hdc = get_frame_dc (f); |
| 2353 | SetDIBits (hdc, pixmap, 0, height, ximg->data, &(ximg->info), DIB_RGB_COLORS); | 2282 | SetDIBits (hdc, pixmap, 0, height, pimg->data, &(pimg->info), DIB_RGB_COLORS); |
| 2354 | release_frame_dc (f, hdc); | 2283 | release_frame_dc (f, hdc); |
| 2355 | #endif | 2284 | #endif |
| 2356 | #endif /* HAVE_NTGUI */ | 2285 | #endif /* HAVE_NTGUI */ |
| 2357 | 2286 | ||
| 2358 | #ifdef HAVE_NS | 2287 | #ifdef HAVE_NS |
| 2359 | eassert (ximg == pixmap); | 2288 | eassert (pimg == pixmap); |
| 2360 | ns_retain_object (ximg); | 2289 | ns_retain_object (pimg); |
| 2361 | #endif | 2290 | #endif |
| 2362 | } | 2291 | } |
| 2363 | 2292 | ||
| @@ -2367,7 +2296,7 @@ gui_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, | |||
| 2367 | static bool | 2296 | static bool |
| 2368 | image_create_x_image_and_pixmap (struct frame *f, struct image *img, | 2297 | image_create_x_image_and_pixmap (struct frame *f, struct image *img, |
| 2369 | int width, int height, int depth, | 2298 | int width, int height, int depth, |
| 2370 | XImagePtr *ximg, bool mask_p) | 2299 | Emacs_Pix_Container *ximg, bool mask_p) |
| 2371 | { | 2300 | { |
| 2372 | eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP); | 2301 | eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP); |
| 2373 | 2302 | ||
| @@ -2380,14 +2309,14 @@ image_create_x_image_and_pixmap (struct frame *f, struct image *img, | |||
| 2380 | picture); | 2309 | picture); |
| 2381 | } | 2310 | } |
| 2382 | 2311 | ||
| 2383 | /* Put X image XIMG into image IMG on frame F, as a mask if and only | 2312 | /* Put pixel image PIMG into image IMG on frame F, as a mask if and only |
| 2384 | if MASK_P. On X, this simply records XIMG on a member of IMG, so | 2313 | if MASK_P. On X, this simply records PIMG on a member of IMG, so |
| 2385 | it can be put into the pixmap afterwards via image_sync_to_pixmaps. | 2314 | it can be put into the pixmap afterwards via image_sync_to_pixmaps. |
| 2386 | On the other platforms, it puts XIMG into the pixmap, then frees | 2315 | On the other platforms, it puts PIMG into the pixmap, then frees |
| 2387 | the X image and its buffer. */ | 2316 | the pixel image and its buffer. */ |
| 2388 | 2317 | ||
| 2389 | static void | 2318 | static void |
| 2390 | image_put_x_image (struct frame *f, struct image *img, XImagePtr ximg, | 2319 | image_put_x_image (struct frame *f, struct image *img, Emacs_Pix_Container ximg, |
| 2391 | bool mask_p) | 2320 | bool mask_p) |
| 2392 | { | 2321 | { |
| 2393 | #ifdef HAVE_X_WINDOWS | 2322 | #ifdef HAVE_X_WINDOWS |
| @@ -2435,12 +2364,12 @@ image_sync_to_pixmaps (struct frame *f, struct image *img) | |||
| 2435 | currently selected GDI object into *PREV for future restoration by | 2364 | currently selected GDI object into *PREV for future restoration by |
| 2436 | image_unget_x_image_or_dc. */ | 2365 | image_unget_x_image_or_dc. */ |
| 2437 | 2366 | ||
| 2438 | static XImagePtr_or_DC | 2367 | static HDC |
| 2439 | image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p, | 2368 | image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p, |
| 2440 | HGDIOBJ *prev) | 2369 | HGDIOBJ *prev) |
| 2441 | { | 2370 | { |
| 2442 | HDC frame_dc = get_frame_dc (f); | 2371 | HDC frame_dc = get_frame_dc (f); |
| 2443 | XImagePtr_or_DC ximg = CreateCompatibleDC (frame_dc); | 2372 | HDC ximg = CreateCompatibleDC (frame_dc); |
| 2444 | 2373 | ||
| 2445 | release_frame_dc (f, frame_dc); | 2374 | release_frame_dc (f, frame_dc); |
| 2446 | *prev = SelectObject (ximg, !mask_p ? img->pixmap : img->mask); | 2375 | *prev = SelectObject (ximg, !mask_p ? img->pixmap : img->mask); |
| @@ -2450,7 +2379,7 @@ image_get_x_image_or_dc (struct frame *f, struct image *img, bool mask_p, | |||
| 2450 | 2379 | ||
| 2451 | static void | 2380 | static void |
| 2452 | image_unget_x_image_or_dc (struct image *img, bool mask_p, | 2381 | image_unget_x_image_or_dc (struct image *img, bool mask_p, |
| 2453 | XImagePtr_or_DC ximg, HGDIOBJ prev) | 2382 | HDC ximg, HGDIOBJ prev) |
| 2454 | { | 2383 | { |
| 2455 | SelectObject (ximg, prev); | 2384 | SelectObject (ximg, prev); |
| 2456 | DeleteDC (ximg); | 2385 | DeleteDC (ximg); |
| @@ -2459,11 +2388,11 @@ image_unget_x_image_or_dc (struct image *img, bool mask_p, | |||
| 2459 | /* Get the X image for IMG on frame F. The resulting X image data | 2388 | /* Get the X image for IMG on frame F. The resulting X image data |
| 2460 | should be treated as read-only at least on X. */ | 2389 | should be treated as read-only at least on X. */ |
| 2461 | 2390 | ||
| 2462 | static XImagePtr | 2391 | static Emacs_Pix_Container |
| 2463 | image_get_x_image (struct frame *f, struct image *img, bool mask_p) | 2392 | image_get_x_image (struct frame *f, struct image *img, bool mask_p) |
| 2464 | { | 2393 | { |
| 2465 | #ifdef HAVE_X_WINDOWS | 2394 | #ifdef HAVE_X_WINDOWS |
| 2466 | XImagePtr ximg_in_img = !mask_p ? img->ximg : img->mask_img; | 2395 | XImage *ximg_in_img = !mask_p ? img->ximg : img->mask_img; |
| 2467 | 2396 | ||
| 2468 | if (ximg_in_img) | 2397 | if (ximg_in_img) |
| 2469 | return ximg_in_img; | 2398 | return ximg_in_img; |
| @@ -2471,7 +2400,7 @@ image_get_x_image (struct frame *f, struct image *img, bool mask_p) | |||
| 2471 | return XGetImage (FRAME_X_DISPLAY (f), !mask_p ? img->pixmap : img->mask, | 2400 | return XGetImage (FRAME_X_DISPLAY (f), !mask_p ? img->pixmap : img->mask, |
| 2472 | 0, 0, img->width, img->height, ~0, ZPixmap); | 2401 | 0, 0, img->width, img->height, ~0, ZPixmap); |
| 2473 | #elif defined (HAVE_NS) | 2402 | #elif defined (HAVE_NS) |
| 2474 | XImagePtr pixmap = !mask_p ? img->pixmap : img->mask; | 2403 | Emacs_Pix_Container pixmap = !mask_p ? img->pixmap : img->mask; |
| 2475 | 2404 | ||
| 2476 | ns_retain_object (pixmap); | 2405 | ns_retain_object (pixmap); |
| 2477 | return pixmap; | 2406 | return pixmap; |
| @@ -2479,10 +2408,10 @@ image_get_x_image (struct frame *f, struct image *img, bool mask_p) | |||
| 2479 | } | 2408 | } |
| 2480 | 2409 | ||
| 2481 | static void | 2410 | static void |
| 2482 | image_unget_x_image (struct image *img, bool mask_p, XImagePtr ximg) | 2411 | image_unget_x_image (struct image *img, bool mask_p, Emacs_Pix_Container ximg) |
| 2483 | { | 2412 | { |
| 2484 | #ifdef HAVE_X_WINDOWS | 2413 | #ifdef HAVE_X_WINDOWS |
| 2485 | XImagePtr ximg_in_img = !mask_p ? img->ximg : img->mask_img; | 2414 | XImage *ximg_in_img = !mask_p ? img->ximg : img->mask_img; |
| 2486 | 2415 | ||
| 2487 | if (ximg_in_img) | 2416 | if (ximg_in_img) |
| 2488 | eassert (ximg == ximg_in_img); | 2417 | eassert (ximg == ximg_in_img); |
| @@ -2595,8 +2524,6 @@ slurp_file (int fd, ptrdiff_t *size) | |||
| 2595 | XBM images | 2524 | XBM images |
| 2596 | ***********************************************************************/ | 2525 | ***********************************************************************/ |
| 2597 | 2526 | ||
| 2598 | static bool xbm_load (struct frame *f, struct image *img); | ||
| 2599 | static bool xbm_image_p (Lisp_Object object); | ||
| 2600 | static bool xbm_file_p (Lisp_Object); | 2527 | static bool xbm_file_p (Lisp_Object); |
| 2601 | 2528 | ||
| 2602 | 2529 | ||
| @@ -2640,18 +2567,6 @@ static const struct image_keyword xbm_format[XBM_LAST] = | |||
| 2640 | {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 2567 | {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} |
| 2641 | }; | 2568 | }; |
| 2642 | 2569 | ||
| 2643 | /* Structure describing the image type XBM. */ | ||
| 2644 | |||
| 2645 | static struct image_type xbm_type = | ||
| 2646 | { | ||
| 2647 | SYMBOL_INDEX (Qxbm), | ||
| 2648 | xbm_image_p, | ||
| 2649 | xbm_load, | ||
| 2650 | image_clear_image, | ||
| 2651 | NULL, | ||
| 2652 | NULL | ||
| 2653 | }; | ||
| 2654 | |||
| 2655 | /* Tokens returned from xbm_scan. */ | 2570 | /* Tokens returned from xbm_scan. */ |
| 2656 | 2571 | ||
| 2657 | enum xbm_token | 2572 | enum xbm_token |
| @@ -3377,13 +3292,6 @@ xbm_load (struct frame *f, struct image *img) | |||
| 3377 | XPM images | 3292 | XPM images |
| 3378 | ***********************************************************************/ | 3293 | ***********************************************************************/ |
| 3379 | 3294 | ||
| 3380 | #if defined (HAVE_XPM) || defined (HAVE_NS) | ||
| 3381 | |||
| 3382 | static bool xpm_image_p (Lisp_Object object); | ||
| 3383 | static bool xpm_load (struct frame *f, struct image *img); | ||
| 3384 | |||
| 3385 | #endif /* HAVE_XPM || HAVE_NS */ | ||
| 3386 | |||
| 3387 | #ifdef HAVE_XPM | 3295 | #ifdef HAVE_XPM |
| 3388 | #ifdef HAVE_NTGUI | 3296 | #ifdef HAVE_NTGUI |
| 3389 | /* Indicate to xpm.h that we don't have Xlib. */ | 3297 | /* Indicate to xpm.h that we don't have Xlib. */ |
| @@ -3445,24 +3353,6 @@ static const struct image_keyword xpm_format[XPM_LAST] = | |||
| 3445 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 3353 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} |
| 3446 | }; | 3354 | }; |
| 3447 | 3355 | ||
| 3448 | #if defined HAVE_NTGUI && defined WINDOWSNT | ||
| 3449 | static bool init_xpm_functions (void); | ||
| 3450 | #else | ||
| 3451 | #define init_xpm_functions NULL | ||
| 3452 | #endif | ||
| 3453 | |||
| 3454 | /* Structure describing the image type XPM. */ | ||
| 3455 | |||
| 3456 | static struct image_type xpm_type = | ||
| 3457 | { | ||
| 3458 | SYMBOL_INDEX (Qxpm), | ||
| 3459 | xpm_image_p, | ||
| 3460 | xpm_load, | ||
| 3461 | image_clear_image, | ||
| 3462 | init_xpm_functions, | ||
| 3463 | NULL | ||
| 3464 | }; | ||
| 3465 | |||
| 3466 | #ifdef HAVE_X_WINDOWS | 3356 | #ifdef HAVE_X_WINDOWS |
| 3467 | 3357 | ||
| 3468 | /* Define ALLOC_XPM_COLORS if we can use Emacs' own color allocation | 3358 | /* Define ALLOC_XPM_COLORS if we can use Emacs' own color allocation |
| @@ -4318,7 +4208,7 @@ xpm_load_image (struct frame *f, | |||
| 4318 | #ifndef HAVE_NS | 4208 | #ifndef HAVE_NS |
| 4319 | bool have_mask = false; | 4209 | bool have_mask = false; |
| 4320 | #endif | 4210 | #endif |
| 4321 | XImagePtr ximg = NULL, mask_img = NULL; | 4211 | Emacs_Pix_Container ximg = NULL, mask_img = NULL; |
| 4322 | 4212 | ||
| 4323 | #define match() \ | 4213 | #define match() \ |
| 4324 | LA1 = xpm_scan (&s, end, &beg, &len) | 4214 | LA1 = xpm_scan (&s, end, &beg, &len) |
| @@ -4403,7 +4293,7 @@ xpm_load_image (struct frame *f, | |||
| 4403 | char *color, *max_color; | 4293 | char *color, *max_color; |
| 4404 | int key, next_key, max_key = 0; | 4294 | int key, next_key, max_key = 0; |
| 4405 | Lisp_Object symbol_color = Qnil, color_val; | 4295 | Lisp_Object symbol_color = Qnil, color_val; |
| 4406 | XColor cdef; | 4296 | Emacs_Color cdef; |
| 4407 | 4297 | ||
| 4408 | expect (XPM_TK_STRING); | 4298 | expect (XPM_TK_STRING); |
| 4409 | if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel) | 4299 | if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel) |
| @@ -4889,18 +4779,18 @@ static int laplace_matrix[9] = { | |||
| 4889 | #define COLOR_INTENSITY(R, G, B) ((2 * (R) + 3 * (G) + (B)) / 6) | 4779 | #define COLOR_INTENSITY(R, G, B) ((2 * (R) + 3 * (G) + (B)) / 6) |
| 4890 | 4780 | ||
| 4891 | 4781 | ||
| 4892 | /* On frame F, return an array of XColor structures describing image | 4782 | /* On frame F, return an array of Emacs_Color structures describing image |
| 4893 | IMG->pixmap. Each XColor structure has its pixel color set. RGB_P | 4783 | IMG->pixmap. Each Emacs_Color structure has its pixel color set. RGB_P |
| 4894 | means also fill the red/green/blue members of the XColor | 4784 | means also fill the red/green/blue members of the Emacs_Color |
| 4895 | structures. Value is a pointer to the array of XColors structures, | 4785 | structures. Value is a pointer to the array of Emacs_Color structures, |
| 4896 | allocated with xmalloc; it must be freed by the caller. */ | 4786 | allocated with xmalloc; it must be freed by the caller. */ |
| 4897 | 4787 | ||
| 4898 | static XColor * | 4788 | static Emacs_Color * |
| 4899 | image_to_xcolors (struct frame *f, struct image *img, bool rgb_p) | 4789 | image_to_emacs_colors (struct frame *f, struct image *img, bool rgb_p) |
| 4900 | { | 4790 | { |
| 4901 | int x, y; | 4791 | int x, y; |
| 4902 | XColor *colors, *p; | 4792 | Emacs_Color *colors, *p; |
| 4903 | XImagePtr_or_DC ximg; | 4793 | Emacs_Pix_Context ximg; |
| 4904 | ptrdiff_t nbytes; | 4794 | ptrdiff_t nbytes; |
| 4905 | #ifdef HAVE_NTGUI | 4795 | #ifdef HAVE_NTGUI |
| 4906 | HGDIOBJ prev; | 4796 | HGDIOBJ prev; |
| @@ -4915,13 +4805,13 @@ image_to_xcolors (struct frame *f, struct image *img, bool rgb_p) | |||
| 4915 | /* Get the X image or create a memory device context for IMG. */ | 4805 | /* Get the X image or create a memory device context for IMG. */ |
| 4916 | ximg = image_get_x_image_or_dc (f, img, 0, &prev); | 4806 | ximg = image_get_x_image_or_dc (f, img, 0, &prev); |
| 4917 | 4807 | ||
| 4918 | /* Fill the `pixel' members of the XColor array. I wished there | 4808 | /* Fill the `pixel' members of the Emacs_Color array. I wished there |
| 4919 | were an easy and portable way to circumvent XGetPixel. */ | 4809 | were an easy and portable way to circumvent XGetPixel. */ |
| 4920 | p = colors; | 4810 | p = colors; |
| 4921 | for (y = 0; y < img->height; ++y) | 4811 | for (y = 0; y < img->height; ++y) |
| 4922 | { | 4812 | { |
| 4923 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) | 4813 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) |
| 4924 | XColor *row = p; | 4814 | Emacs_Color *row = p; |
| 4925 | for (x = 0; x < img->width; ++x, ++p) | 4815 | for (x = 0; x < img->width; ++x, ++p) |
| 4926 | p->pixel = GET_PIXEL (ximg, x, y); | 4816 | p->pixel = GET_PIXEL (ximg, x, y); |
| 4927 | if (rgb_p) | 4817 | if (rgb_p) |
| @@ -4956,7 +4846,7 @@ image_to_xcolors (struct frame *f, struct image *img, bool rgb_p) | |||
| 4956 | stored in ximg->data. */ | 4846 | stored in ximg->data. */ |
| 4957 | 4847 | ||
| 4958 | static void | 4848 | static void |
| 4959 | XPutPixel (XImagePtr ximg, int x, int y, COLORREF color) | 4849 | XPutPixel (XImage *ximg, int x, int y, COLORREF color) |
| 4960 | { | 4850 | { |
| 4961 | int width = ximg->info.bmiHeader.biWidth; | 4851 | int width = ximg->info.bmiHeader.biWidth; |
| 4962 | unsigned char * pixel; | 4852 | unsigned char * pixel; |
| @@ -4995,16 +4885,16 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color) | |||
| 4995 | 4885 | ||
| 4996 | #endif /* HAVE_NTGUI */ | 4886 | #endif /* HAVE_NTGUI */ |
| 4997 | 4887 | ||
| 4998 | /* Create IMG->pixmap from an array COLORS of XColor structures, whose | 4888 | /* Create IMG->pixmap from an array COLORS of Emacs_Color structures, whose |
| 4999 | RGB members are set. F is the frame on which this all happens. | 4889 | RGB members are set. F is the frame on which this all happens. |
| 5000 | COLORS will be freed; an existing IMG->pixmap will be freed, too. */ | 4890 | COLORS will be freed; an existing IMG->pixmap will be freed, too. */ |
| 5001 | 4891 | ||
| 5002 | static void | 4892 | static void |
| 5003 | image_from_xcolors (struct frame *f, struct image *img, XColor *colors) | 4893 | image_from_emacs_colors (struct frame *f, struct image *img, Emacs_Color *colors) |
| 5004 | { | 4894 | { |
| 5005 | int x, y; | 4895 | int x, y; |
| 5006 | XImagePtr oimg = NULL; | 4896 | Emacs_Pix_Container oimg = NULL; |
| 5007 | XColor *p; | 4897 | Emacs_Color *p; |
| 5008 | 4898 | ||
| 5009 | init_color_table (); | 4899 | init_color_table (); |
| 5010 | 4900 | ||
| @@ -5042,8 +4932,8 @@ static void | |||
| 5042 | image_detect_edges (struct frame *f, struct image *img, | 4932 | image_detect_edges (struct frame *f, struct image *img, |
| 5043 | int *matrix, int color_adjust) | 4933 | int *matrix, int color_adjust) |
| 5044 | { | 4934 | { |
| 5045 | XColor *colors = image_to_xcolors (f, img, 1); | 4935 | Emacs_Color *colors = image_to_emacs_colors (f, img, 1); |
| 5046 | XColor *new, *p; | 4936 | Emacs_Color *new, *p; |
| 5047 | int x, y, i, sum; | 4937 | int x, y, i, sum; |
| 5048 | ptrdiff_t nbytes; | 4938 | ptrdiff_t nbytes; |
| 5049 | 4939 | ||
| @@ -5086,7 +4976,7 @@ image_detect_edges (struct frame *f, struct image *img, | |||
| 5086 | for (xx = x - 1; xx < x + 2; ++xx, ++i) | 4976 | for (xx = x - 1; xx < x + 2; ++xx, ++i) |
| 5087 | if (matrix[i]) | 4977 | if (matrix[i]) |
| 5088 | { | 4978 | { |
| 5089 | XColor *t = COLOR (colors, xx, yy); | 4979 | Emacs_Color *t = COLOR (colors, xx, yy); |
| 5090 | r += matrix[i] * t->red; | 4980 | r += matrix[i] * t->red; |
| 5091 | g += matrix[i] * t->green; | 4981 | g += matrix[i] * t->green; |
| 5092 | b += matrix[i] * t->blue; | 4982 | b += matrix[i] * t->blue; |
| @@ -5100,7 +4990,7 @@ image_detect_edges (struct frame *f, struct image *img, | |||
| 5100 | } | 4990 | } |
| 5101 | 4991 | ||
| 5102 | xfree (colors); | 4992 | xfree (colors); |
| 5103 | image_from_xcolors (f, img, new); | 4993 | image_from_emacs_colors (f, img, new); |
| 5104 | 4994 | ||
| 5105 | #undef COLOR | 4995 | #undef COLOR |
| 5106 | } | 4996 | } |
| @@ -5183,8 +5073,8 @@ image_disable_image (struct frame *f, struct image *img) | |||
| 5183 | /* Color (or grayscale). Convert to gray, and equalize. Just | 5073 | /* Color (or grayscale). Convert to gray, and equalize. Just |
| 5184 | drawing such images with a stipple can look very odd, so | 5074 | drawing such images with a stipple can look very odd, so |
| 5185 | we're using this method instead. */ | 5075 | we're using this method instead. */ |
| 5186 | XColor *colors = image_to_xcolors (f, img, 1); | 5076 | Emacs_Color *colors = image_to_emacs_colors (f, img, 1); |
| 5187 | XColor *p, *end; | 5077 | Emacs_Color *p, *end; |
| 5188 | const int h = 15000; | 5078 | const int h = 15000; |
| 5189 | const int l = 30000; | 5079 | const int l = 30000; |
| 5190 | 5080 | ||
| @@ -5197,7 +5087,7 @@ image_disable_image (struct frame *f, struct image *img) | |||
| 5197 | p->red = p->green = p->blue = i2; | 5087 | p->red = p->green = p->blue = i2; |
| 5198 | } | 5088 | } |
| 5199 | 5089 | ||
| 5200 | image_from_xcolors (f, img, colors); | 5090 | image_from_emacs_colors (f, img, colors); |
| 5201 | } | 5091 | } |
| 5202 | 5092 | ||
| 5203 | /* Draw a cross over the disabled image, if we must or if we | 5093 | /* Draw a cross over the disabled image, if we must or if we |
| @@ -5275,13 +5165,13 @@ static void | |||
| 5275 | image_build_heuristic_mask (struct frame *f, struct image *img, | 5165 | image_build_heuristic_mask (struct frame *f, struct image *img, |
| 5276 | Lisp_Object how) | 5166 | Lisp_Object how) |
| 5277 | { | 5167 | { |
| 5278 | XImagePtr_or_DC ximg; | 5168 | Emacs_Pix_Context ximg; |
| 5279 | #ifdef HAVE_NTGUI | 5169 | #ifdef HAVE_NTGUI |
| 5280 | HGDIOBJ prev; | 5170 | HGDIOBJ prev; |
| 5281 | char *mask_img; | 5171 | char *mask_img; |
| 5282 | int row_width; | 5172 | int row_width; |
| 5283 | #elif !defined HAVE_NS | 5173 | #elif !defined HAVE_NS |
| 5284 | XImagePtr mask_img; | 5174 | Emacs_Pix_Container mask_img; |
| 5285 | #endif | 5175 | #endif |
| 5286 | int x, y; | 5176 | int x, y; |
| 5287 | bool use_img_background; | 5177 | bool use_img_background; |
| @@ -5384,9 +5274,6 @@ image_build_heuristic_mask (struct frame *f, struct image *img, | |||
| 5384 | PBM (mono, gray, color) | 5274 | PBM (mono, gray, color) |
| 5385 | ***********************************************************************/ | 5275 | ***********************************************************************/ |
| 5386 | 5276 | ||
| 5387 | static bool pbm_image_p (Lisp_Object object); | ||
| 5388 | static bool pbm_load (struct frame *f, struct image *img); | ||
| 5389 | |||
| 5390 | /* Indices of image specification fields in gs_format, below. */ | 5277 | /* Indices of image specification fields in gs_format, below. */ |
| 5391 | 5278 | ||
| 5392 | enum pbm_keyword_index | 5279 | enum pbm_keyword_index |
| @@ -5423,19 +5310,6 @@ static const struct image_keyword pbm_format[PBM_LAST] = | |||
| 5423 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 5310 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} |
| 5424 | }; | 5311 | }; |
| 5425 | 5312 | ||
| 5426 | /* Structure describing the image type `pbm'. */ | ||
| 5427 | |||
| 5428 | static struct image_type pbm_type = | ||
| 5429 | { | ||
| 5430 | SYMBOL_INDEX (Qpbm), | ||
| 5431 | pbm_image_p, | ||
| 5432 | pbm_load, | ||
| 5433 | image_clear_image, | ||
| 5434 | NULL, | ||
| 5435 | NULL | ||
| 5436 | }; | ||
| 5437 | |||
| 5438 | |||
| 5439 | /* Return true if OBJECT is a valid PBM image specification. */ | 5313 | /* Return true if OBJECT is a valid PBM image specification. */ |
| 5440 | 5314 | ||
| 5441 | static bool | 5315 | static bool |
| @@ -5533,7 +5407,7 @@ pbm_load (struct frame *f, struct image *img) | |||
| 5533 | char *contents = NULL; | 5407 | char *contents = NULL; |
| 5534 | char *end, *p; | 5408 | char *end, *p; |
| 5535 | #ifndef USE_CAIRO | 5409 | #ifndef USE_CAIRO |
| 5536 | XImagePtr ximg; | 5410 | Emacs_Pix_Container ximg; |
| 5537 | #endif | 5411 | #endif |
| 5538 | 5412 | ||
| 5539 | specified_file = image_spec_value (img->spec, QCfile, NULL); | 5413 | specified_file = image_spec_value (img->spec, QCfile, NULL); |
| @@ -5655,7 +5529,7 @@ pbm_load (struct frame *f, struct image *img) | |||
| 5655 | unsigned long fg = FRAME_FOREGROUND_PIXEL (f); | 5529 | unsigned long fg = FRAME_FOREGROUND_PIXEL (f); |
| 5656 | unsigned long bg = FRAME_BACKGROUND_PIXEL (f); | 5530 | unsigned long bg = FRAME_BACKGROUND_PIXEL (f); |
| 5657 | #ifdef USE_CAIRO | 5531 | #ifdef USE_CAIRO |
| 5658 | XColor xfg, xbg; | 5532 | Emacs_Color xfg, xbg; |
| 5659 | int fga32, bga32; | 5533 | int fga32, bga32; |
| 5660 | #endif | 5534 | #endif |
| 5661 | /* Parse the image specification. */ | 5535 | /* Parse the image specification. */ |
| @@ -5675,7 +5549,7 @@ pbm_load (struct frame *f, struct image *img) | |||
| 5675 | xfg.pixel = fg; | 5549 | xfg.pixel = fg; |
| 5676 | x_query_colors (f, &xfg, 1); | 5550 | x_query_colors (f, &xfg, 1); |
| 5677 | } | 5551 | } |
| 5678 | fga32 = xcolor_to_argb32 (xfg); | 5552 | fga32 = emacs_color_to_argb32 (&xfg); |
| 5679 | 5553 | ||
| 5680 | if (! fmt[PBM_BACKGROUND].count | 5554 | if (! fmt[PBM_BACKGROUND].count |
| 5681 | || ! STRINGP (fmt[PBM_BACKGROUND].value) | 5555 | || ! STRINGP (fmt[PBM_BACKGROUND].value) |
| @@ -5688,7 +5562,7 @@ pbm_load (struct frame *f, struct image *img) | |||
| 5688 | xbg.pixel = bg; | 5562 | xbg.pixel = bg; |
| 5689 | x_query_colors (f, &xbg, 1); | 5563 | x_query_colors (f, &xbg, 1); |
| 5690 | } | 5564 | } |
| 5691 | bga32 = xcolor_to_argb32 (xbg); | 5565 | bga32 = emacs_color_to_argb32 (&xbg); |
| 5692 | #else | 5566 | #else |
| 5693 | if (fmt[PBM_FOREGROUND].count | 5567 | if (fmt[PBM_FOREGROUND].count |
| 5694 | && STRINGP (fmt[PBM_FOREGROUND].value)) | 5568 | && STRINGP (fmt[PBM_FOREGROUND].value)) |
| @@ -5833,7 +5707,7 @@ pbm_load (struct frame *f, struct image *img) | |||
| 5833 | #else | 5707 | #else |
| 5834 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | 5708 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) |
| 5835 | /* Casting avoids a GCC warning. */ | 5709 | /* Casting avoids a GCC warning. */ |
| 5836 | IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); | 5710 | IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg); |
| 5837 | 5711 | ||
| 5838 | /* Put ximg into the image. */ | 5712 | /* Put ximg into the image. */ |
| 5839 | image_put_x_image (f, img, ximg, 0); | 5713 | image_put_x_image (f, img, ximg, 0); |
| @@ -5854,11 +5728,6 @@ pbm_load (struct frame *f, struct image *img) | |||
| 5854 | 5728 | ||
| 5855 | #if defined (HAVE_PNG) || defined (HAVE_NS) || defined (USE_CAIRO) | 5729 | #if defined (HAVE_PNG) || defined (HAVE_NS) || defined (USE_CAIRO) |
| 5856 | 5730 | ||
| 5857 | /* Function prototypes. */ | ||
| 5858 | |||
| 5859 | static bool png_image_p (Lisp_Object object); | ||
| 5860 | static bool png_load (struct frame *f, struct image *img); | ||
| 5861 | |||
| 5862 | /* Indices of image specification fields in png_format, below. */ | 5731 | /* Indices of image specification fields in png_format, below. */ |
| 5863 | 5732 | ||
| 5864 | enum png_keyword_index | 5733 | enum png_keyword_index |
| @@ -5893,24 +5762,6 @@ static const struct image_keyword png_format[PNG_LAST] = | |||
| 5893 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 5762 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} |
| 5894 | }; | 5763 | }; |
| 5895 | 5764 | ||
| 5896 | #if defined HAVE_NTGUI && defined WINDOWSNT | ||
| 5897 | static bool init_png_functions (void); | ||
| 5898 | #else | ||
| 5899 | #define init_png_functions NULL | ||
| 5900 | #endif | ||
| 5901 | |||
| 5902 | /* Structure describing the image type `png'. */ | ||
| 5903 | |||
| 5904 | static struct image_type png_type = | ||
| 5905 | { | ||
| 5906 | SYMBOL_INDEX (Qpng), | ||
| 5907 | png_image_p, | ||
| 5908 | png_load, | ||
| 5909 | image_clear_image, | ||
| 5910 | init_png_functions, | ||
| 5911 | NULL | ||
| 5912 | }; | ||
| 5913 | |||
| 5914 | /* Return true if OBJECT is a valid PNG image specification. */ | 5765 | /* Return true if OBJECT is a valid PNG image specification. */ |
| 5915 | 5766 | ||
| 5916 | static bool | 5767 | static bool |
| @@ -5951,6 +5802,7 @@ DEF_DLL_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32)); | |||
| 5951 | DEF_DLL_FN (void, png_set_strip_16, (png_structp)); | 5802 | DEF_DLL_FN (void, png_set_strip_16, (png_structp)); |
| 5952 | DEF_DLL_FN (void, png_set_expand, (png_structp)); | 5803 | DEF_DLL_FN (void, png_set_expand, (png_structp)); |
| 5953 | DEF_DLL_FN (void, png_set_gray_to_rgb, (png_structp)); | 5804 | DEF_DLL_FN (void, png_set_gray_to_rgb, (png_structp)); |
| 5805 | DEF_DLL_FN (int, png_set_interlace_handling, (png_structp)); | ||
| 5954 | DEF_DLL_FN (void, png_set_background, | 5806 | DEF_DLL_FN (void, png_set_background, |
| 5955 | (png_structp, png_color_16p, int, int, double)); | 5807 | (png_structp, png_color_16p, int, int, double)); |
| 5956 | DEF_DLL_FN (png_uint_32, png_get_bKGD, | 5808 | DEF_DLL_FN (png_uint_32, png_get_bKGD, |
| @@ -5989,6 +5841,7 @@ init_png_functions (void) | |||
| 5989 | LOAD_DLL_FN (library, png_set_strip_16); | 5841 | LOAD_DLL_FN (library, png_set_strip_16); |
| 5990 | LOAD_DLL_FN (library, png_set_expand); | 5842 | LOAD_DLL_FN (library, png_set_expand); |
| 5991 | LOAD_DLL_FN (library, png_set_gray_to_rgb); | 5843 | LOAD_DLL_FN (library, png_set_gray_to_rgb); |
| 5844 | LOAD_DLL_FN (library, png_set_interlace_handling); | ||
| 5992 | LOAD_DLL_FN (library, png_set_background); | 5845 | LOAD_DLL_FN (library, png_set_background); |
| 5993 | LOAD_DLL_FN (library, png_get_bKGD); | 5846 | LOAD_DLL_FN (library, png_get_bKGD); |
| 5994 | LOAD_DLL_FN (library, png_read_update_info); | 5847 | LOAD_DLL_FN (library, png_read_update_info); |
| @@ -6024,6 +5877,7 @@ init_png_functions (void) | |||
| 6024 | # undef png_set_background | 5877 | # undef png_set_background |
| 6025 | # undef png_set_expand | 5878 | # undef png_set_expand |
| 6026 | # undef png_set_gray_to_rgb | 5879 | # undef png_set_gray_to_rgb |
| 5880 | # undef png_set_interlace_handling | ||
| 6027 | # undef png_set_longjmp_fn | 5881 | # undef png_set_longjmp_fn |
| 6028 | # undef png_set_read_fn | 5882 | # undef png_set_read_fn |
| 6029 | # undef png_set_sig_bytes | 5883 | # undef png_set_sig_bytes |
| @@ -6048,6 +5902,7 @@ init_png_functions (void) | |||
| 6048 | # define png_set_background fn_png_set_background | 5902 | # define png_set_background fn_png_set_background |
| 6049 | # define png_set_expand fn_png_set_expand | 5903 | # define png_set_expand fn_png_set_expand |
| 6050 | # define png_set_gray_to_rgb fn_png_set_gray_to_rgb | 5904 | # define png_set_gray_to_rgb fn_png_set_gray_to_rgb |
| 5905 | # define png_set_interlace_handling fn_png_set_interlace_handling | ||
| 6051 | # define png_set_longjmp_fn fn_png_set_longjmp_fn | 5906 | # define png_set_longjmp_fn fn_png_set_longjmp_fn |
| 6052 | # define png_set_read_fn fn_png_set_read_fn | 5907 | # define png_set_read_fn fn_png_set_read_fn |
| 6053 | # define png_set_sig_bytes fn_png_set_sig_bytes | 5908 | # define png_set_sig_bytes fn_png_set_sig_bytes |
| @@ -6178,7 +6033,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 6178 | cairo_surface_t *surface; | 6033 | cairo_surface_t *surface; |
| 6179 | uint32_t *dataptr; | 6034 | uint32_t *dataptr; |
| 6180 | #else | 6035 | #else |
| 6181 | XImagePtr ximg, mask_img = NULL; | 6036 | Emacs_Pix_Container ximg, mask_img = NULL; |
| 6182 | #endif | 6037 | #endif |
| 6183 | 6038 | ||
| 6184 | /* Find out what file to load. */ | 6039 | /* Find out what file to load. */ |
| @@ -6336,7 +6191,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 6336 | /* png_color_16 *image_bg; */ | 6191 | /* png_color_16 *image_bg; */ |
| 6337 | Lisp_Object specified_bg | 6192 | Lisp_Object specified_bg |
| 6338 | = image_spec_value (img->spec, QCbackground, NULL); | 6193 | = image_spec_value (img->spec, QCbackground, NULL); |
| 6339 | XColor color; | 6194 | Emacs_Color color; |
| 6340 | 6195 | ||
| 6341 | /* If the user specified a color, try to use it; if not, use the | 6196 | /* If the user specified a color, try to use it; if not, use the |
| 6342 | current frame background, ignoring any default background | 6197 | current frame background, ignoring any default background |
| @@ -6362,7 +6217,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 6362 | } | 6217 | } |
| 6363 | } | 6218 | } |
| 6364 | 6219 | ||
| 6365 | /* Update info structure. */ | 6220 | png_set_interlace_handling (png_ptr); |
| 6366 | png_read_update_info (png_ptr, info_ptr); | 6221 | png_read_update_info (png_ptr, info_ptr); |
| 6367 | 6222 | ||
| 6368 | /* Get number of channels. Valid values are 1 for grayscale images | 6223 | /* Get number of channels. Valid values are 1 for grayscale images |
| @@ -6491,7 +6346,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 6491 | #else | 6346 | #else |
| 6492 | /* Maybe fill in the background field while we have ximg handy. | 6347 | /* Maybe fill in the background field while we have ximg handy. |
| 6493 | Casting avoids a GCC warning. */ | 6348 | Casting avoids a GCC warning. */ |
| 6494 | IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); | 6349 | IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg); |
| 6495 | 6350 | ||
| 6496 | /* Put ximg into the image. */ | 6351 | /* Put ximg into the image. */ |
| 6497 | image_put_x_image (f, img, ximg, 0); | 6352 | image_put_x_image (f, img, ximg, 0); |
| @@ -6501,7 +6356,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 6501 | { | 6356 | { |
| 6502 | /* Fill in the background_transparent field while we have the | 6357 | /* Fill in the background_transparent field while we have the |
| 6503 | mask handy. Casting avoids a GCC warning. */ | 6358 | mask handy. Casting avoids a GCC warning. */ |
| 6504 | image_background_transparent (img, f, (XImagePtr_or_DC)mask_img); | 6359 | image_background_transparent (img, f, (Emacs_Pix_Context)mask_img); |
| 6505 | 6360 | ||
| 6506 | image_put_x_image (f, img, mask_img, 1); | 6361 | image_put_x_image (f, img, mask_img, 1); |
| 6507 | } | 6362 | } |
| @@ -6538,9 +6393,6 @@ png_load (struct frame *f, struct image *img) | |||
| 6538 | 6393 | ||
| 6539 | #if defined (HAVE_JPEG) || defined (HAVE_NS) | 6394 | #if defined (HAVE_JPEG) || defined (HAVE_NS) |
| 6540 | 6395 | ||
| 6541 | static bool jpeg_image_p (Lisp_Object object); | ||
| 6542 | static bool jpeg_load (struct frame *f, struct image *img); | ||
| 6543 | |||
| 6544 | /* Indices of image specification fields in gs_format, below. */ | 6396 | /* Indices of image specification fields in gs_format, below. */ |
| 6545 | 6397 | ||
| 6546 | enum jpeg_keyword_index | 6398 | enum jpeg_keyword_index |
| @@ -6575,24 +6427,6 @@ static const struct image_keyword jpeg_format[JPEG_LAST] = | |||
| 6575 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 6427 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} |
| 6576 | }; | 6428 | }; |
| 6577 | 6429 | ||
| 6578 | #if defined HAVE_NTGUI && defined WINDOWSNT | ||
| 6579 | static bool init_jpeg_functions (void); | ||
| 6580 | #else | ||
| 6581 | #define init_jpeg_functions NULL | ||
| 6582 | #endif | ||
| 6583 | |||
| 6584 | /* Structure describing the image type `jpeg'. */ | ||
| 6585 | |||
| 6586 | static struct image_type jpeg_type = | ||
| 6587 | { | ||
| 6588 | SYMBOL_INDEX (Qjpeg), | ||
| 6589 | jpeg_image_p, | ||
| 6590 | jpeg_load, | ||
| 6591 | image_clear_image, | ||
| 6592 | init_jpeg_functions, | ||
| 6593 | NULL | ||
| 6594 | }; | ||
| 6595 | |||
| 6596 | /* Return true if OBJECT is a valid JPEG image specification. */ | 6430 | /* Return true if OBJECT is a valid JPEG image specification. */ |
| 6597 | 6431 | ||
| 6598 | static bool | 6432 | static bool |
| @@ -6735,7 +6569,7 @@ my_error_exit (j_common_ptr cinfo) | |||
| 6735 | 6569 | ||
| 6736 | 6570 | ||
| 6737 | /* Init source method for JPEG data source manager. Called by | 6571 | /* Init source method for JPEG data source manager. Called by |
| 6738 | jpeg_read_header() before any data is actually read. See | 6572 | jpeg_read_header before any data is actually read. See |
| 6739 | libjpeg.doc from the JPEG lib distribution. */ | 6573 | libjpeg.doc from the JPEG lib distribution. */ |
| 6740 | 6574 | ||
| 6741 | static void | 6575 | static void |
| @@ -6745,7 +6579,7 @@ our_common_init_source (j_decompress_ptr cinfo) | |||
| 6745 | 6579 | ||
| 6746 | 6580 | ||
| 6747 | /* Method to terminate data source. Called by | 6581 | /* Method to terminate data source. Called by |
| 6748 | jpeg_finish_decompress() after all data has been processed. */ | 6582 | jpeg_finish_decompress after all data has been processed. */ |
| 6749 | 6583 | ||
| 6750 | static void | 6584 | static void |
| 6751 | our_common_term_source (j_decompress_ptr cinfo) | 6585 | our_common_term_source (j_decompress_ptr cinfo) |
| @@ -6942,7 +6776,7 @@ jpeg_load_body (struct frame *f, struct image *img, | |||
| 6942 | int i, ir, ig, ib; | 6776 | int i, ir, ig, ib; |
| 6943 | #ifndef USE_CAIRO | 6777 | #ifndef USE_CAIRO |
| 6944 | unsigned long *colors; | 6778 | unsigned long *colors; |
| 6945 | XImagePtr ximg = NULL; | 6779 | Emacs_Pix_Container ximg = NULL; |
| 6946 | #endif | 6780 | #endif |
| 6947 | 6781 | ||
| 6948 | /* Open the JPEG file. */ | 6782 | /* Open the JPEG file. */ |
| @@ -7132,7 +6966,7 @@ jpeg_load_body (struct frame *f, struct image *img, | |||
| 7132 | /* Maybe fill in the background field while we have ximg handy. */ | 6966 | /* Maybe fill in the background field while we have ximg handy. */ |
| 7133 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | 6967 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) |
| 7134 | /* Casting avoids a GCC warning. */ | 6968 | /* Casting avoids a GCC warning. */ |
| 7135 | IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); | 6969 | IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg); |
| 7136 | 6970 | ||
| 7137 | /* Put ximg into the image. */ | 6971 | /* Put ximg into the image. */ |
| 7138 | image_put_x_image (f, img, ximg, 0); | 6972 | image_put_x_image (f, img, ximg, 0); |
| @@ -7170,9 +7004,6 @@ jpeg_load (struct frame *f, struct image *img) | |||
| 7170 | 7004 | ||
| 7171 | #if defined (HAVE_TIFF) || defined (HAVE_NS) | 7005 | #if defined (HAVE_TIFF) || defined (HAVE_NS) |
| 7172 | 7006 | ||
| 7173 | static bool tiff_image_p (Lisp_Object object); | ||
| 7174 | static bool tiff_load (struct frame *f, struct image *img); | ||
| 7175 | |||
| 7176 | /* Indices of image specification fields in tiff_format, below. */ | 7007 | /* Indices of image specification fields in tiff_format, below. */ |
| 7177 | 7008 | ||
| 7178 | enum tiff_keyword_index | 7009 | enum tiff_keyword_index |
| @@ -7209,24 +7040,6 @@ static const struct image_keyword tiff_format[TIFF_LAST] = | |||
| 7209 | {":index", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0} | 7040 | {":index", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0} |
| 7210 | }; | 7041 | }; |
| 7211 | 7042 | ||
| 7212 | #if defined HAVE_NTGUI && defined WINDOWSNT | ||
| 7213 | static bool init_tiff_functions (void); | ||
| 7214 | #else | ||
| 7215 | #define init_tiff_functions NULL | ||
| 7216 | #endif | ||
| 7217 | |||
| 7218 | /* Structure describing the image type `tiff'. */ | ||
| 7219 | |||
| 7220 | static struct image_type tiff_type = | ||
| 7221 | { | ||
| 7222 | SYMBOL_INDEX (Qtiff), | ||
| 7223 | tiff_image_p, | ||
| 7224 | tiff_load, | ||
| 7225 | image_clear_image, | ||
| 7226 | init_tiff_functions, | ||
| 7227 | NULL | ||
| 7228 | }; | ||
| 7229 | |||
| 7230 | /* Return true if OBJECT is a valid TIFF image specification. */ | 7043 | /* Return true if OBJECT is a valid TIFF image specification. */ |
| 7231 | 7044 | ||
| 7232 | static bool | 7045 | static bool |
| @@ -7453,7 +7266,7 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7453 | int width, height, x, y, count; | 7266 | int width, height, x, y, count; |
| 7454 | uint32 *buf; | 7267 | uint32 *buf; |
| 7455 | int rc; | 7268 | int rc; |
| 7456 | XImagePtr ximg; | 7269 | Emacs_Pix_Container ximg; |
| 7457 | tiff_memory_source memsrc; | 7270 | tiff_memory_source memsrc; |
| 7458 | Lisp_Object image; | 7271 | Lisp_Object image; |
| 7459 | 7272 | ||
| @@ -7623,7 +7436,7 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7623 | /* Maybe fill in the background field while we have ximg handy. */ | 7436 | /* Maybe fill in the background field while we have ximg handy. */ |
| 7624 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | 7437 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) |
| 7625 | /* Casting avoids a GCC warning on W32. */ | 7438 | /* Casting avoids a GCC warning on W32. */ |
| 7626 | IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); | 7439 | IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg); |
| 7627 | 7440 | ||
| 7628 | /* Put ximg into the image. */ | 7441 | /* Put ximg into the image. */ |
| 7629 | image_put_x_image (f, img, ximg, 0); | 7442 | image_put_x_image (f, img, ximg, 0); |
| @@ -7654,10 +7467,6 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7654 | 7467 | ||
| 7655 | #if defined (HAVE_GIF) || defined (HAVE_NS) | 7468 | #if defined (HAVE_GIF) || defined (HAVE_NS) |
| 7656 | 7469 | ||
| 7657 | static bool gif_image_p (Lisp_Object object); | ||
| 7658 | static bool gif_load (struct frame *f, struct image *img); | ||
| 7659 | static void gif_clear_image (struct frame *f, struct image *img); | ||
| 7660 | |||
| 7661 | /* Indices of image specification fields in gif_format, below. */ | 7470 | /* Indices of image specification fields in gif_format, below. */ |
| 7662 | 7471 | ||
| 7663 | enum gif_keyword_index | 7472 | enum gif_keyword_index |
| @@ -7694,24 +7503,6 @@ static const struct image_keyword gif_format[GIF_LAST] = | |||
| 7694 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 7503 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} |
| 7695 | }; | 7504 | }; |
| 7696 | 7505 | ||
| 7697 | #if defined HAVE_NTGUI && defined WINDOWSNT | ||
| 7698 | static bool init_gif_functions (void); | ||
| 7699 | #else | ||
| 7700 | #define init_gif_functions NULL | ||
| 7701 | #endif | ||
| 7702 | |||
| 7703 | /* Structure describing the image type `gif'. */ | ||
| 7704 | |||
| 7705 | static struct image_type gif_type = | ||
| 7706 | { | ||
| 7707 | SYMBOL_INDEX (Qgif), | ||
| 7708 | gif_image_p, | ||
| 7709 | gif_load, | ||
| 7710 | gif_clear_image, | ||
| 7711 | init_gif_functions, | ||
| 7712 | NULL | ||
| 7713 | }; | ||
| 7714 | |||
| 7715 | /* Free X resources of GIF image IMG which is used on frame F. */ | 7506 | /* Free X resources of GIF image IMG which is used on frame F. */ |
| 7716 | 7507 | ||
| 7717 | static void | 7508 | static void |
| @@ -8033,7 +7824,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 8033 | uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface); | 7824 | uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface); |
| 8034 | if (STRINGP (specified_bg)) | 7825 | if (STRINGP (specified_bg)) |
| 8035 | { | 7826 | { |
| 8036 | XColor color; | 7827 | Emacs_Color color; |
| 8037 | if (FRAME_TERMINAL (f)->defined_color_hook | 7828 | if (FRAME_TERMINAL (f)->defined_color_hook |
| 8038 | (f, SSDATA (specified_bg), &color, false, false)) | 7829 | (f, SSDATA (specified_bg), &color, false, false)) |
| 8039 | { | 7830 | { |
| @@ -8049,7 +7840,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 8049 | } | 7840 | } |
| 8050 | #else | 7841 | #else |
| 8051 | /* Create the X image and pixmap. */ | 7842 | /* Create the X image and pixmap. */ |
| 8052 | XImagePtr ximg; | 7843 | Emacs_Pix_Container ximg; |
| 8053 | if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) | 7844 | if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) |
| 8054 | { | 7845 | { |
| 8055 | gif_close (gif, NULL); | 7846 | gif_close (gif, NULL); |
| @@ -8279,7 +8070,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 8279 | /* Maybe fill in the background field while we have ximg handy. */ | 8070 | /* Maybe fill in the background field while we have ximg handy. */ |
| 8280 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | 8071 | if (NILP (image_spec_value (img->spec, QCbackground, NULL))) |
| 8281 | /* Casting avoids a GCC warning. */ | 8072 | /* Casting avoids a GCC warning. */ |
| 8282 | IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); | 8073 | IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg); |
| 8283 | 8074 | ||
| 8284 | /* Put ximg into the image. */ | 8075 | /* Put ximg into the image. */ |
| 8285 | image_put_x_image (f, img, ximg, 0); | 8076 | image_put_x_image (f, img, ximg, 0); |
| @@ -8309,10 +8100,6 @@ gif_load (struct frame *f, struct image *img) | |||
| 8309 | ImageMagick | 8100 | ImageMagick |
| 8310 | ***********************************************************************/ | 8101 | ***********************************************************************/ |
| 8311 | 8102 | ||
| 8312 | static bool imagemagick_image_p (Lisp_Object); | ||
| 8313 | static bool imagemagick_load (struct frame *, struct image *); | ||
| 8314 | static void imagemagick_clear_image (struct frame *, struct image *); | ||
| 8315 | |||
| 8316 | /* Indices of image specification fields in imagemagick_format. */ | 8103 | /* Indices of image specification fields in imagemagick_format. */ |
| 8317 | 8104 | ||
| 8318 | enum imagemagick_keyword_index | 8105 | enum imagemagick_keyword_index |
| @@ -8361,25 +8148,6 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] = | |||
| 8361 | {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 8148 | {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} |
| 8362 | }; | 8149 | }; |
| 8363 | 8150 | ||
| 8364 | #if defined HAVE_NTGUI && defined WINDOWSNT | ||
| 8365 | static bool init_imagemagick_functions (void); | ||
| 8366 | #else | ||
| 8367 | #define init_imagemagick_functions NULL | ||
| 8368 | #endif | ||
| 8369 | |||
| 8370 | /* Structure describing the image type for any image handled via | ||
| 8371 | ImageMagick. */ | ||
| 8372 | |||
| 8373 | static struct image_type imagemagick_type = | ||
| 8374 | { | ||
| 8375 | SYMBOL_INDEX (Qimagemagick), | ||
| 8376 | imagemagick_image_p, | ||
| 8377 | imagemagick_load, | ||
| 8378 | imagemagick_clear_image, | ||
| 8379 | init_imagemagick_functions, | ||
| 8380 | NULL | ||
| 8381 | }; | ||
| 8382 | |||
| 8383 | /* Free X resources of imagemagick image IMG which is used on frame F. */ | 8151 | /* Free X resources of imagemagick image IMG which is used on frame F. */ |
| 8384 | 8152 | ||
| 8385 | static void | 8153 | static void |
| @@ -8686,7 +8454,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 8686 | size_t image_width, image_height; | 8454 | size_t image_width, image_height; |
| 8687 | MagickBooleanType status; | 8455 | MagickBooleanType status; |
| 8688 | #ifndef USE_CAIRO | 8456 | #ifndef USE_CAIRO |
| 8689 | XImagePtr ximg; | 8457 | Emacs_Pix_Container ximg; |
| 8690 | #endif | 8458 | #endif |
| 8691 | int x, y; | 8459 | int x, y; |
| 8692 | MagickWand *image_wand; | 8460 | MagickWand *image_wand; |
| @@ -8791,7 +8559,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 8791 | 8559 | ||
| 8792 | /* Retrieve the frame's background color, for use later. */ | 8560 | /* Retrieve the frame's background color, for use later. */ |
| 8793 | { | 8561 | { |
| 8794 | XColor bgcolor; | 8562 | Emacs_Color bgcolor; |
| 8795 | Lisp_Object specified_bg; | 8563 | Lisp_Object specified_bg; |
| 8796 | 8564 | ||
| 8797 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 8565 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| @@ -9157,9 +8925,6 @@ and `imagemagick-types-inhibit'. */) | |||
| 9157 | 8925 | ||
| 9158 | /* Function prototypes. */ | 8926 | /* Function prototypes. */ |
| 9159 | 8927 | ||
| 9160 | static bool svg_image_p (Lisp_Object object); | ||
| 9161 | static bool svg_load (struct frame *f, struct image *img); | ||
| 9162 | |||
| 9163 | static bool svg_load_image (struct frame *, struct image *, | 8928 | static bool svg_load_image (struct frame *, struct image *, |
| 9164 | char *, ptrdiff_t, char *); | 8929 | char *, ptrdiff_t, char *); |
| 9165 | 8930 | ||
| @@ -9197,27 +8962,6 @@ static const struct image_keyword svg_format[SVG_LAST] = | |||
| 9197 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 8962 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} |
| 9198 | }; | 8963 | }; |
| 9199 | 8964 | ||
| 9200 | # if defined HAVE_NTGUI && defined WINDOWSNT | ||
| 9201 | static bool init_svg_functions (void); | ||
| 9202 | # else | ||
| 9203 | #define init_svg_functions NULL | ||
| 9204 | # endif | ||
| 9205 | |||
| 9206 | /* Structure describing the image type `svg'. Its the same type of | ||
| 9207 | structure defined for all image formats, handled by emacs image | ||
| 9208 | functions. See struct image_type in dispextern.h. */ | ||
| 9209 | |||
| 9210 | static struct image_type svg_type = | ||
| 9211 | { | ||
| 9212 | SYMBOL_INDEX (Qsvg), | ||
| 9213 | svg_image_p, | ||
| 9214 | svg_load, | ||
| 9215 | image_clear_image, | ||
| 9216 | init_svg_functions, | ||
| 9217 | NULL | ||
| 9218 | }; | ||
| 9219 | |||
| 9220 | |||
| 9221 | /* Return true if OBJECT is a valid SVG image specification. Do | 8965 | /* Return true if OBJECT is a valid SVG image specification. Do |
| 9222 | this by calling parse_image_spec and supplying the keywords that | 8966 | this by calling parse_image_spec and supplying the keywords that |
| 9223 | identify the SVG format. */ | 8967 | identify the SVG format. */ |
| @@ -9248,6 +8992,11 @@ svg_image_p (Lisp_Object object) | |||
| 9248 | 8992 | ||
| 9249 | # include <librsvg/rsvg.h> | 8993 | # include <librsvg/rsvg.h> |
| 9250 | 8994 | ||
| 8995 | /* librsvg is too old for us if it doesn't define this macro. */ | ||
| 8996 | # ifndef LIBRSVG_CHECK_VERSION | ||
| 8997 | # define LIBRSVG_CHECK_VERSION(v, w, x) false | ||
| 8998 | # endif | ||
| 8999 | |||
| 9251 | # ifdef WINDOWSNT | 9000 | # ifdef WINDOWSNT |
| 9252 | 9001 | ||
| 9253 | /* Restore the original definition of __MINGW_MAJOR_VERSION. */ | 9002 | /* Restore the original definition of __MINGW_MAJOR_VERSION. */ |
| @@ -9456,7 +9205,18 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9456 | See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" | 9205 | See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" |
| 9457 | <https://gitlab.gnome.org/GNOME/librsvg/issues/33>. */ | 9206 | <https://gitlab.gnome.org/GNOME/librsvg/issues/33>. */ |
| 9458 | if (filename) | 9207 | if (filename) |
| 9459 | rsvg_handle_set_base_uri(rsvg_handle, filename); | 9208 | rsvg_handle_set_base_uri (rsvg_handle, filename); |
| 9209 | |||
| 9210 | /* Suppress GCC deprecation warnings starting in librsvg 2.45.1 for | ||
| 9211 | rsvg_handle_write and rsvg_handle_close. FIXME: Use functions | ||
| 9212 | like rsvg_handle_new_from_gfile_sync on newer librsvg versions, | ||
| 9213 | and remove this hack. */ | ||
| 9214 | #if GNUC_PREREQ (4, 6, 0) | ||
| 9215 | #pragma GCC diagnostic push | ||
| 9216 | #endif | ||
| 9217 | #if LIBRSVG_CHECK_VERSION (2, 45, 1) && GNUC_PREREQ (4, 2, 0) | ||
| 9218 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||
| 9219 | #endif | ||
| 9460 | 9220 | ||
| 9461 | /* Parse the contents argument and fill in the rsvg_handle. */ | 9221 | /* Parse the contents argument and fill in the rsvg_handle. */ |
| 9462 | rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err); | 9222 | rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err); |
| @@ -9467,6 +9227,10 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9467 | rsvg_handle_close (rsvg_handle, &err); | 9227 | rsvg_handle_close (rsvg_handle, &err); |
| 9468 | if (err) goto rsvg_error; | 9228 | if (err) goto rsvg_error; |
| 9469 | 9229 | ||
| 9230 | #if GNUC_PREREQ (4, 6, 0) | ||
| 9231 | #pragma GCC diagnostic pop | ||
| 9232 | #endif | ||
| 9233 | |||
| 9470 | rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); | 9234 | rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); |
| 9471 | if (! check_image_size (f, dimension_data.width, dimension_data.height)) | 9235 | if (! check_image_size (f, dimension_data.width, dimension_data.height)) |
| 9472 | { | 9236 | { |
| @@ -9521,7 +9285,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9521 | g_object_unref (pixbuf); | 9285 | g_object_unref (pixbuf); |
| 9522 | #else | 9286 | #else |
| 9523 | /* Try to create a x pixmap to hold the svg pixmap. */ | 9287 | /* Try to create a x pixmap to hold the svg pixmap. */ |
| 9524 | XImagePtr ximg; | 9288 | Emacs_Pix_Container ximg; |
| 9525 | if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) | 9289 | if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) |
| 9526 | { | 9290 | { |
| 9527 | g_object_unref (pixbuf); | 9291 | g_object_unref (pixbuf); |
| @@ -9532,7 +9296,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9532 | 9296 | ||
| 9533 | /* Handle alpha channel by combining the image with a background | 9297 | /* Handle alpha channel by combining the image with a background |
| 9534 | color. */ | 9298 | color. */ |
| 9535 | XColor background; | 9299 | Emacs_Color background; |
| 9536 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 9300 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 9537 | if (!STRINGP (specified_bg) | 9301 | if (!STRINGP (specified_bg) |
| 9538 | || !FRAME_TERMINAL (f)->defined_color_hook (f, | 9302 | || !FRAME_TERMINAL (f)->defined_color_hook (f, |
| @@ -9588,7 +9352,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9588 | 9352 | ||
| 9589 | /* Maybe fill in the background field while we have ximg handy. | 9353 | /* Maybe fill in the background field while we have ximg handy. |
| 9590 | Casting avoids a GCC warning. */ | 9354 | Casting avoids a GCC warning. */ |
| 9591 | IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); | 9355 | IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg); |
| 9592 | 9356 | ||
| 9593 | /* Put ximg into the image. */ | 9357 | /* Put ximg into the image. */ |
| 9594 | image_put_x_image (f, img, ximg, 0); | 9358 | image_put_x_image (f, img, ximg, 0); |
| @@ -9621,10 +9385,6 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9621 | 9385 | ||
| 9622 | #ifdef HAVE_GHOSTSCRIPT | 9386 | #ifdef HAVE_GHOSTSCRIPT |
| 9623 | 9387 | ||
| 9624 | static bool gs_image_p (Lisp_Object object); | ||
| 9625 | static bool gs_load (struct frame *f, struct image *img); | ||
| 9626 | static void gs_clear_image (struct frame *f, struct image *img); | ||
| 9627 | |||
| 9628 | /* Indices of image specification fields in gs_format, below. */ | 9388 | /* Indices of image specification fields in gs_format, below. */ |
| 9629 | 9389 | ||
| 9630 | enum gs_keyword_index | 9390 | enum gs_keyword_index |
| @@ -9665,28 +9425,6 @@ static const struct image_keyword gs_format[GS_LAST] = | |||
| 9665 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 9425 | {":background", IMAGE_STRING_OR_NIL_VALUE, 0} |
| 9666 | }; | 9426 | }; |
| 9667 | 9427 | ||
| 9668 | /* Structure describing the image type `ghostscript'. */ | ||
| 9669 | |||
| 9670 | static struct image_type gs_type = | ||
| 9671 | { | ||
| 9672 | SYMBOL_INDEX (Qpostscript), | ||
| 9673 | gs_image_p, | ||
| 9674 | gs_load, | ||
| 9675 | gs_clear_image, | ||
| 9676 | NULL, | ||
| 9677 | NULL | ||
| 9678 | }; | ||
| 9679 | |||
| 9680 | |||
| 9681 | /* Free X resources of Ghostscript image IMG which is used on frame F. */ | ||
| 9682 | |||
| 9683 | static void | ||
| 9684 | gs_clear_image (struct frame *f, struct image *img) | ||
| 9685 | { | ||
| 9686 | image_clear_image (f, img); | ||
| 9687 | } | ||
| 9688 | |||
| 9689 | |||
| 9690 | /* Return true if OBJECT is a valid Ghostscript image | 9428 | /* Return true if OBJECT is a valid Ghostscript image |
| 9691 | specification. */ | 9429 | specification. */ |
| 9692 | 9430 | ||
| @@ -9812,7 +9550,7 @@ gs_load (struct frame *f, struct image *img) | |||
| 9812 | telling Emacs that Ghostscript has finished drawing. */ | 9550 | telling Emacs that Ghostscript has finished drawing. */ |
| 9813 | 9551 | ||
| 9814 | void | 9552 | void |
| 9815 | x_kill_gs_process (Pixmap pixmap, struct frame *f) | 9553 | x_kill_gs_process (Emacs_Pixmap pixmap, struct frame *f) |
| 9816 | { | 9554 | { |
| 9817 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 9555 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 9818 | ptrdiff_t i; | 9556 | ptrdiff_t i; |
| @@ -9842,7 +9580,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f) | |||
| 9842 | img->pixmap. */ | 9580 | img->pixmap. */ |
| 9843 | if (x_mutable_colormap (FRAME_X_VISUAL (f))) | 9581 | if (x_mutable_colormap (FRAME_X_VISUAL (f))) |
| 9844 | { | 9582 | { |
| 9845 | XImagePtr ximg; | 9583 | XImage *ximg; |
| 9846 | 9584 | ||
| 9847 | block_input (); | 9585 | block_input (); |
| 9848 | 9586 | ||
| @@ -9965,87 +9703,86 @@ the library file(s) specified by `dynamic-library-alist'. */) | |||
| 9965 | return lookup_image_type (type) ? Qt : Qnil; | 9703 | return lookup_image_type (type) ? Qt : Qnil; |
| 9966 | } | 9704 | } |
| 9967 | 9705 | ||
| 9968 | /* Look up image type TYPE, and return a pointer to its image_type | 9706 | static bool |
| 9969 | structure. Return 0 if TYPE is not a known image type. */ | 9707 | initialize_image_type (struct image_type const *type) |
| 9970 | |||
| 9971 | static struct image_type * | ||
| 9972 | lookup_image_type (Lisp_Object type) | ||
| 9973 | { | 9708 | { |
| 9974 | /* Types pbm and xbm are built-in and always available. */ | 9709 | #ifdef WINDOWSNT |
| 9975 | if (EQ (type, Qpbm)) | 9710 | Lisp_Object typesym = builtin_lisp_symbol (type->type); |
| 9976 | return define_image_type (&pbm_type); | 9711 | Lisp_Object tested = Fassq (typesym, Vlibrary_cache); |
| 9977 | 9712 | /* If we failed to load the library before, don't try again. */ | |
| 9978 | if (EQ (type, Qxbm)) | 9713 | if (CONSP (tested)) |
| 9979 | return define_image_type (&xbm_type); | 9714 | return !NILP (XCDR (tested)) ? true : false; |
| 9980 | 9715 | ||
| 9981 | #if defined (HAVE_XPM) || defined (HAVE_NS) | 9716 | bool (*init) (void) = type->init; |
| 9982 | if (EQ (type, Qxpm)) | 9717 | if (init) |
| 9983 | return define_image_type (&xpm_type); | 9718 | { |
| 9719 | bool type_valid = init (); | ||
| 9720 | Vlibrary_cache = Fcons (Fcons (typesym, type_valid ? Qt : Qnil), | ||
| 9721 | Vlibrary_cache); | ||
| 9722 | return type_valid; | ||
| 9723 | } | ||
| 9984 | #endif | 9724 | #endif |
| 9725 | return true; | ||
| 9726 | } | ||
| 9985 | 9727 | ||
| 9986 | #if defined (HAVE_JPEG) || defined (HAVE_NS) | 9728 | /* Array of supported image types. */ |
| 9987 | if (EQ (type, Qjpeg)) | ||
| 9988 | return define_image_type (&jpeg_type); | ||
| 9989 | #endif | ||
| 9990 | 9729 | ||
| 9991 | #if defined (HAVE_TIFF) || defined (HAVE_NS) | 9730 | static struct image_type const image_types[] = |
| 9992 | if (EQ (type, Qtiff)) | 9731 | { |
| 9993 | return define_image_type (&tiff_type); | 9732 | #ifdef HAVE_GHOSTSCRIPT |
| 9733 | { SYMBOL_INDEX (Qpostscript), gs_image_p, gs_load, image_clear_image }, | ||
| 9994 | #endif | 9734 | #endif |
| 9995 | 9735 | #ifdef HAVE_IMAGEMAGICK | |
| 9996 | #if defined (HAVE_GIF) || defined (HAVE_NS) | 9736 | { SYMBOL_INDEX (Qimagemagick), imagemagick_image_p, imagemagick_load, |
| 9997 | if (EQ (type, Qgif)) | 9737 | imagemagick_clear_image }, |
| 9998 | return define_image_type (&gif_type); | ||
| 9999 | #endif | 9738 | #endif |
| 10000 | 9739 | #ifdef HAVE_RSVG | |
| 10001 | #if defined (HAVE_PNG) || defined (HAVE_NS) || defined (USE_CAIRO) | 9740 | { SYMBOL_INDEX (Qsvg), svg_image_p, svg_load, image_clear_image, |
| 10002 | if (EQ (type, Qpng)) | 9741 | IMAGE_TYPE_INIT (init_svg_functions) }, |
| 10003 | return define_image_type (&png_type); | ||
| 10004 | #endif | 9742 | #endif |
| 10005 | 9743 | #if defined HAVE_PNG || defined HAVE_NS || defined USE_CAIRO | |
| 10006 | #if defined (HAVE_RSVG) | 9744 | { SYMBOL_INDEX (Qpng), png_image_p, png_load, image_clear_image, |
| 10007 | if (EQ (type, Qsvg)) | 9745 | IMAGE_TYPE_INIT (init_png_functions) }, |
| 10008 | return define_image_type (&svg_type); | ||
| 10009 | #endif | 9746 | #endif |
| 10010 | 9747 | #if defined HAVE_GIF || defined HAVE_NS | |
| 10011 | #if defined (HAVE_IMAGEMAGICK) | 9748 | { SYMBOL_INDEX (Qgif), gif_image_p, gif_load, gif_clear_image, |
| 10012 | if (EQ (type, Qimagemagick)) | 9749 | IMAGE_TYPE_INIT (init_gif_functions) }, |
| 10013 | return define_image_type (&imagemagick_type); | ||
| 10014 | #endif | 9750 | #endif |
| 10015 | 9751 | #if defined HAVE_TIFF || defined HAVE_NS | |
| 10016 | #ifdef HAVE_GHOSTSCRIPT | 9752 | { SYMBOL_INDEX (Qtiff), tiff_image_p, tiff_load, image_clear_image, |
| 10017 | if (EQ (type, Qpostscript)) | 9753 | IMAGE_TYPE_INIT (init_tiff_functions) }, |
| 10018 | return define_image_type (&gs_type); | ||
| 10019 | #endif | 9754 | #endif |
| 9755 | #if defined HAVE_JPEG || defined HAVE_NS | ||
| 9756 | { SYMBOL_INDEX (Qjpeg), jpeg_image_p, jpeg_load, image_clear_image, | ||
| 9757 | IMAGE_TYPE_INIT (init_jpeg_functions) }, | ||
| 9758 | #endif | ||
| 9759 | #if defined HAVE_XPM || defined HAVE_NS | ||
| 9760 | { SYMBOL_INDEX (Qxpm), xpm_image_p, xpm_load, image_clear_image, | ||
| 9761 | IMAGE_TYPE_INIT (init_xpm_functions) }, | ||
| 9762 | #endif | ||
| 9763 | { SYMBOL_INDEX (Qxbm), xbm_image_p, xbm_load, image_clear_image }, | ||
| 9764 | { SYMBOL_INDEX (Qpbm), pbm_image_p, pbm_load, image_clear_image }, | ||
| 9765 | }; | ||
| 10020 | 9766 | ||
| 10021 | return NULL; | 9767 | /* Look up image type TYPE, and return a pointer to its image_type |
| 10022 | } | 9768 | structure. Return 0 if TYPE is not a known image type. */ |
| 10023 | |||
| 10024 | #if defined HAVE_UNEXEC && defined HAVE_WINDOW_SYSTEM | ||
| 10025 | |||
| 10026 | /* Reset image_types before dumping. | ||
| 10027 | Called from Fdump_emacs. */ | ||
| 10028 | 9769 | ||
| 10029 | void | 9770 | static struct image_type const * |
| 10030 | reset_image_types (void) | 9771 | lookup_image_type (Lisp_Object type) |
| 10031 | { | 9772 | { |
| 10032 | while (image_types) | 9773 | for (int i = 0; i < ARRAYELTS (image_types); i++) |
| 10033 | { | 9774 | { |
| 10034 | struct image_type *next = image_types->next; | 9775 | struct image_type const *r = &image_types[i]; |
| 10035 | xfree (image_types); | 9776 | if (EQ (type, builtin_lisp_symbol (r->type))) |
| 10036 | image_types = next; | 9777 | return initialize_image_type (r) ? r : NULL; |
| 10037 | } | 9778 | } |
| 9779 | return NULL; | ||
| 10038 | } | 9780 | } |
| 10039 | #endif | 9781 | |
| 10040 | 9782 | ||
| 10041 | void | 9783 | void |
| 10042 | syms_of_image (void) | 9784 | syms_of_image (void) |
| 10043 | { | 9785 | { |
| 10044 | /* Initialize this only once; it will be reset before dumping. */ | ||
| 10045 | /* The portable dumper will just leave it NULL, so no need to reset. */ | ||
| 10046 | image_types = NULL; | ||
| 10047 | PDUMPER_IGNORE (image_types); | ||
| 10048 | |||
| 10049 | /* Must be defined now because we're going to update it below, while | 9786 | /* Must be defined now because we're going to update it below, while |
| 10050 | defining the supported image types. */ | 9787 | defining the supported image types. */ |
| 10051 | DEFVAR_LISP ("image-types", Vimage_types, | 9788 | DEFVAR_LISP ("image-types", Vimage_types, |
| @@ -10096,7 +9833,7 @@ non-numeric, there is no explicit limit on the size of images. */); | |||
| 10096 | DEFSYM (QCmax_width, ":max-width"); | 9833 | DEFSYM (QCmax_width, ":max-width"); |
| 10097 | DEFSYM (QCmax_height, ":max-height"); | 9834 | DEFSYM (QCmax_height, ":max-height"); |
| 10098 | #ifdef HAVE_GHOSTSCRIPT | 9835 | #ifdef HAVE_GHOSTSCRIPT |
| 10099 | ADD_IMAGE_TYPE (Qpostscript); | 9836 | add_image_type (Qpostscript); |
| 10100 | DEFSYM (QCloader, ":loader"); | 9837 | DEFSYM (QCloader, ":loader"); |
| 10101 | DEFSYM (QCpt_width, ":pt-width"); | 9838 | DEFSYM (QCpt_width, ":pt-width"); |
| 10102 | DEFSYM (QCpt_height, ":pt-height"); | 9839 | DEFSYM (QCpt_height, ":pt-height"); |
| @@ -10136,44 +9873,44 @@ non-numeric, there is no explicit limit on the size of images. */); | |||
| 10136 | #endif | 9873 | #endif |
| 10137 | 9874 | ||
| 10138 | DEFSYM (Qpbm, "pbm"); | 9875 | DEFSYM (Qpbm, "pbm"); |
| 10139 | ADD_IMAGE_TYPE (Qpbm); | 9876 | add_image_type (Qpbm); |
| 10140 | 9877 | ||
| 10141 | DEFSYM (Qxbm, "xbm"); | 9878 | DEFSYM (Qxbm, "xbm"); |
| 10142 | ADD_IMAGE_TYPE (Qxbm); | 9879 | add_image_type (Qxbm); |
| 10143 | 9880 | ||
| 10144 | #if defined (HAVE_XPM) || defined (HAVE_NS) | 9881 | #if defined (HAVE_XPM) || defined (HAVE_NS) |
| 10145 | DEFSYM (Qxpm, "xpm"); | 9882 | DEFSYM (Qxpm, "xpm"); |
| 10146 | ADD_IMAGE_TYPE (Qxpm); | 9883 | add_image_type (Qxpm); |
| 10147 | #endif | 9884 | #endif |
| 10148 | 9885 | ||
| 10149 | #if defined (HAVE_JPEG) || defined (HAVE_NS) | 9886 | #if defined (HAVE_JPEG) || defined (HAVE_NS) |
| 10150 | DEFSYM (Qjpeg, "jpeg"); | 9887 | DEFSYM (Qjpeg, "jpeg"); |
| 10151 | ADD_IMAGE_TYPE (Qjpeg); | 9888 | add_image_type (Qjpeg); |
| 10152 | #endif | 9889 | #endif |
| 10153 | 9890 | ||
| 10154 | #if defined (HAVE_TIFF) || defined (HAVE_NS) | 9891 | #if defined (HAVE_TIFF) || defined (HAVE_NS) |
| 10155 | DEFSYM (Qtiff, "tiff"); | 9892 | DEFSYM (Qtiff, "tiff"); |
| 10156 | ADD_IMAGE_TYPE (Qtiff); | 9893 | add_image_type (Qtiff); |
| 10157 | #endif | 9894 | #endif |
| 10158 | 9895 | ||
| 10159 | #if defined (HAVE_GIF) || defined (HAVE_NS) | 9896 | #if defined (HAVE_GIF) || defined (HAVE_NS) |
| 10160 | DEFSYM (Qgif, "gif"); | 9897 | DEFSYM (Qgif, "gif"); |
| 10161 | ADD_IMAGE_TYPE (Qgif); | 9898 | add_image_type (Qgif); |
| 10162 | #endif | 9899 | #endif |
| 10163 | 9900 | ||
| 10164 | #if defined (HAVE_PNG) || defined (HAVE_NS) | 9901 | #if defined (HAVE_PNG) || defined (HAVE_NS) |
| 10165 | DEFSYM (Qpng, "png"); | 9902 | DEFSYM (Qpng, "png"); |
| 10166 | ADD_IMAGE_TYPE (Qpng); | 9903 | add_image_type (Qpng); |
| 10167 | #endif | 9904 | #endif |
| 10168 | 9905 | ||
| 10169 | #if defined (HAVE_IMAGEMAGICK) | 9906 | #if defined (HAVE_IMAGEMAGICK) |
| 10170 | DEFSYM (Qimagemagick, "imagemagick"); | 9907 | DEFSYM (Qimagemagick, "imagemagick"); |
| 10171 | ADD_IMAGE_TYPE (Qimagemagick); | 9908 | add_image_type (Qimagemagick); |
| 10172 | #endif | 9909 | #endif |
| 10173 | 9910 | ||
| 10174 | #if defined (HAVE_RSVG) | 9911 | #if defined (HAVE_RSVG) |
| 10175 | DEFSYM (Qsvg, "svg"); | 9912 | DEFSYM (Qsvg, "svg"); |
| 10176 | ADD_IMAGE_TYPE (Qsvg); | 9913 | add_image_type (Qsvg); |
| 10177 | #ifdef HAVE_NTGUI | 9914 | #ifdef HAVE_NTGUI |
| 10178 | /* Other libraries used directly by svg code. */ | 9915 | /* Other libraries used directly by svg code. */ |
| 10179 | DEFSYM (Qgdk_pixbuf, "gdk-pixbuf"); | 9916 | DEFSYM (Qgdk_pixbuf, "gdk-pixbuf"); |
diff --git a/src/indent.c b/src/indent.c index a022ae9fa32..f0d709e38b3 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -983,9 +983,10 @@ If specified column is within a character, point goes after that character. | |||
| 983 | If it's past end of line, point goes to end of line. | 983 | If it's past end of line, point goes to end of line. |
| 984 | 984 | ||
| 985 | Optional second argument FORCE non-nil means if COLUMN is in the | 985 | Optional second argument FORCE non-nil means if COLUMN is in the |
| 986 | middle of a tab character, change it to spaces. | 986 | middle of a tab character, either change it to spaces (when |
| 987 | In addition, if FORCE is t, and the line is too short to reach | 987 | `indent-tabs-mode' is nil), or insert enough spaces before it to reach |
| 988 | COLUMN, add spaces/tabs to get there. | 988 | COLUMN (otherwise). In addition, if FORCE is t, and the line is too short |
| 989 | to reach COLUMN, add spaces/tabs to get there. | ||
| 989 | 990 | ||
| 990 | The return value is the current column. */) | 991 | The return value is the current column. */) |
| 991 | (Lisp_Object column, Lisp_Object force) | 992 | (Lisp_Object column, Lisp_Object force) |
diff --git a/src/insdel.c b/src/insdel.c index 1231bb2682b..85fffd8fd16 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -2178,6 +2178,7 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins) | |||
| 2178 | { | 2178 | { |
| 2179 | ptrdiff_t count = SPECPDL_INDEX (); | 2179 | ptrdiff_t count = SPECPDL_INDEX (); |
| 2180 | struct rvoe_arg rvoe_arg; | 2180 | struct rvoe_arg rvoe_arg; |
| 2181 | Lisp_Object tmp; | ||
| 2181 | 2182 | ||
| 2182 | if (inhibit_modification_hooks) | 2183 | if (inhibit_modification_hooks) |
| 2183 | return; | 2184 | return; |
| @@ -2186,7 +2187,16 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins) | |||
| 2186 | and there are no before-change functions, | 2187 | and there are no before-change functions, |
| 2187 | just record the args that we were going to use. */ | 2188 | just record the args that we were going to use. */ |
| 2188 | if (! NILP (Vcombine_after_change_calls) | 2189 | if (! NILP (Vcombine_after_change_calls) |
| 2189 | && NILP (Vbefore_change_functions) | 2190 | /* It's OK to defer after-changes even if syntax-ppss-flush-cache |
| 2191 | * is on before-change-functions, which is common enough to be worth | ||
| 2192 | * adding a special case for it. */ | ||
| 2193 | && (NILP (Vbefore_change_functions) | ||
| 2194 | || (CONSP (Vbefore_change_functions) | ||
| 2195 | && EQ (Qt, XCAR (Vbefore_change_functions)) | ||
| 2196 | && NILP (Fdefault_value (Qbefore_change_functions)) | ||
| 2197 | && CONSP (tmp = XCDR (Vbefore_change_functions)) | ||
| 2198 | && NILP (XCDR (tmp)) | ||
| 2199 | && EQ (XCAR (tmp), Qsyntax_ppss_flush_cache))) | ||
| 2190 | && !buffer_has_overlays ()) | 2200 | && !buffer_has_overlays ()) |
| 2191 | { | 2201 | { |
| 2192 | Lisp_Object elt; | 2202 | Lisp_Object elt; |
| @@ -2343,6 +2353,7 @@ syms_of_insdel (void) | |||
| 2343 | combine_after_change_buffer = Qnil; | 2353 | combine_after_change_buffer = Qnil; |
| 2344 | 2354 | ||
| 2345 | DEFSYM (Qundo_auto__undoable_change, "undo-auto--undoable-change"); | 2355 | DEFSYM (Qundo_auto__undoable_change, "undo-auto--undoable-change"); |
| 2356 | DEFSYM (Qsyntax_ppss_flush_cache, "syntax-ppss-flush-cache"); | ||
| 2346 | 2357 | ||
| 2347 | DEFVAR_LISP ("combine-after-change-calls", Vcombine_after_change_calls, | 2358 | DEFVAR_LISP ("combine-after-change-calls", Vcombine_after_change_calls, |
| 2348 | doc: /* Used internally by the function `combine-after-change-calls' macro. */); | 2359 | doc: /* Used internally by the function `combine-after-change-calls' macro. */); |
diff --git a/src/intervals.c b/src/intervals.c index 8f39c45762f..38367460a52 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -2334,23 +2334,10 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, | |||
| 2334 | 2334 | ||
| 2335 | if (multi_flag) | 2335 | if (multi_flag) |
| 2336 | { | 2336 | { |
| 2337 | ptrdiff_t temp; | 2337 | left_end_byte |
| 2338 | left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i); | 2338 | = advance_to_char_boundary (start_byte + LEFT_TOTAL_LENGTH (i)); |
| 2339 | left_end = BYTE_TO_CHAR (left_end_byte); | 2339 | left_end = BYTE_TO_CHAR (left_end_byte); |
| 2340 | 2340 | eassert (CHAR_TO_BYTE (left_end) == left_end_byte); | |
| 2341 | temp = CHAR_TO_BYTE (left_end); | ||
| 2342 | |||
| 2343 | /* If LEFT_END_BYTE is in the middle of a character, | ||
| 2344 | adjust it and LEFT_END to a char boundary. */ | ||
| 2345 | if (left_end_byte > temp) | ||
| 2346 | { | ||
| 2347 | left_end_byte = temp; | ||
| 2348 | } | ||
| 2349 | if (left_end_byte < temp) | ||
| 2350 | { | ||
| 2351 | left_end--; | ||
| 2352 | left_end_byte = CHAR_TO_BYTE (left_end); | ||
| 2353 | } | ||
| 2354 | } | 2341 | } |
| 2355 | else | 2342 | else |
| 2356 | { | 2343 | { |
| @@ -2367,24 +2354,10 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, | |||
| 2367 | 2354 | ||
| 2368 | if (multi_flag) | 2355 | if (multi_flag) |
| 2369 | { | 2356 | { |
| 2370 | ptrdiff_t temp; | 2357 | right_start_byte |
| 2371 | 2358 | = advance_to_char_boundary (end_byte - RIGHT_TOTAL_LENGTH (i)); | |
| 2372 | right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i); | ||
| 2373 | right_start = BYTE_TO_CHAR (right_start_byte); | 2359 | right_start = BYTE_TO_CHAR (right_start_byte); |
| 2374 | 2360 | eassert (CHAR_TO_BYTE (right_start) == right_start_byte); | |
| 2375 | /* If RIGHT_START_BYTE is in the middle of a character, | ||
| 2376 | adjust it and RIGHT_START to a char boundary. */ | ||
| 2377 | temp = CHAR_TO_BYTE (right_start); | ||
| 2378 | |||
| 2379 | if (right_start_byte < temp) | ||
| 2380 | { | ||
| 2381 | right_start_byte = temp; | ||
| 2382 | } | ||
| 2383 | if (right_start_byte > temp) | ||
| 2384 | { | ||
| 2385 | right_start++; | ||
| 2386 | right_start_byte = CHAR_TO_BYTE (right_start); | ||
| 2387 | } | ||
| 2388 | } | 2361 | } |
| 2389 | else | 2362 | else |
| 2390 | { | 2363 | { |
diff --git a/src/json.c b/src/json.c index 03468e9f338..e2a4424463b 100644 --- a/src/json.c +++ b/src/json.c | |||
| @@ -215,47 +215,11 @@ json_has_suffix (const char *string, const char *suffix) | |||
| 215 | 215 | ||
| 216 | #endif | 216 | #endif |
| 217 | 217 | ||
| 218 | /* Create a multibyte Lisp string from the UTF-8 string in | 218 | /* Note that all callers of make_string_from_utf8 and build_string_from_utf8 |
| 219 | [DATA, DATA + SIZE). If the range [DATA, DATA + SIZE) does not | 219 | below either pass only value UTF-8 strings or use the functionf for |
| 220 | contain a valid UTF-8 string, the returned string will include raw | ||
| 221 | bytes. | ||
| 222 | Note that all callers below either pass only value UTF-8 strings or | ||
| 223 | use this function for formatting error messages; in the latter case | ||
| 224 | correctness isn't critical. */ | ||
| 225 | |||
| 226 | static Lisp_Object | ||
| 227 | json_make_string (const char *data, ptrdiff_t size) | ||
| 228 | { | ||
| 229 | ptrdiff_t chars, bytes; | ||
| 230 | parse_str_as_multibyte ((const unsigned char *) data, size, &chars, &bytes); | ||
| 231 | /* If DATA is a valid UTF-8 string, we can convert it to a Lisp | ||
| 232 | string directly. Otherwise, we need to decode it. */ | ||
| 233 | if (chars == size || bytes == size) | ||
| 234 | return make_specified_string (data, chars, size, true); | ||
| 235 | else | ||
| 236 | { | ||
| 237 | struct coding_system coding; | ||
| 238 | setup_coding_system (Qutf_8_unix, &coding); | ||
| 239 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 240 | coding.source = (const unsigned char *) data; | ||
| 241 | decode_coding_object (&coding, Qnil, 0, 0, size, size, Qt); | ||
| 242 | return coding.dst_object; | ||
| 243 | } | ||
| 244 | } | ||
| 245 | |||
| 246 | /* Create a multibyte Lisp string from the NUL-terminated UTF-8 | ||
| 247 | string beginning at DATA. If the string is not a valid UTF-8 | ||
| 248 | string, an unspecified string is returned. Note that all callers | ||
| 249 | below either pass only value UTF-8 strings or use this function for | ||
| 250 | formatting error messages; in the latter case correctness isn't | 220 | formatting error messages; in the latter case correctness isn't |
| 251 | critical. */ | 221 | critical. */ |
| 252 | 222 | ||
| 253 | static Lisp_Object | ||
| 254 | json_build_string (const char *data) | ||
| 255 | { | ||
| 256 | return json_make_string (data, strlen (data)); | ||
| 257 | } | ||
| 258 | |||
| 259 | /* Return a unibyte string containing the sequence of UTF-8 encoding | 223 | /* Return a unibyte string containing the sequence of UTF-8 encoding |
| 260 | units of the UTF-8 representation of STRING. If STRING does not | 224 | units of the UTF-8 representation of STRING. If STRING does not |
| 261 | represent a sequence of Unicode scalar values, return a string with | 225 | represent a sequence of Unicode scalar values, return a string with |
| @@ -303,9 +267,11 @@ json_parse_error (const json_error_t *error) | |||
| 303 | symbol = Qjson_parse_error; | 267 | symbol = Qjson_parse_error; |
| 304 | #endif | 268 | #endif |
| 305 | xsignal (symbol, | 269 | xsignal (symbol, |
| 306 | list5 (json_build_string (error->text), | 270 | list5 (build_string_from_utf8 (error->text), |
| 307 | json_build_string (error->source), INT_TO_INTEGER (error->line), | 271 | build_string_from_utf8 (error->source), |
| 308 | INT_TO_INTEGER (error->column), INT_TO_INTEGER (error->position))); | 272 | INT_TO_INTEGER (error->line), |
| 273 | INT_TO_INTEGER (error->column), | ||
| 274 | INT_TO_INTEGER (error->position))); | ||
| 309 | } | 275 | } |
| 310 | 276 | ||
| 311 | static void | 277 | static void |
| @@ -648,7 +614,7 @@ usage: (json-serialize OBJECT &rest ARGS) */) | |||
| 648 | json_out_of_memory (); | 614 | json_out_of_memory (); |
| 649 | record_unwind_protect_ptr (json_free, string); | 615 | record_unwind_protect_ptr (json_free, string); |
| 650 | 616 | ||
| 651 | return unbind_to (count, json_build_string (string)); | 617 | return unbind_to (count, build_string_from_utf8 (string)); |
| 652 | } | 618 | } |
| 653 | 619 | ||
| 654 | struct json_buffer_and_size | 620 | struct json_buffer_and_size |
| @@ -855,8 +821,8 @@ json_to_lisp (json_t *json, struct json_configuration *conf) | |||
| 855 | case JSON_REAL: | 821 | case JSON_REAL: |
| 856 | return make_float (json_real_value (json)); | 822 | return make_float (json_real_value (json)); |
| 857 | case JSON_STRING: | 823 | case JSON_STRING: |
| 858 | return json_make_string (json_string_value (json), | 824 | return make_string_from_utf8 (json_string_value (json), |
| 859 | json_string_length (json)); | 825 | json_string_length (json)); |
| 860 | case JSON_ARRAY: | 826 | case JSON_ARRAY: |
| 861 | { | 827 | { |
| 862 | if (++lisp_eval_depth > max_lisp_eval_depth) | 828 | if (++lisp_eval_depth > max_lisp_eval_depth) |
| @@ -915,7 +881,7 @@ json_to_lisp (json_t *json, struct json_configuration *conf) | |||
| 915 | json_t *value; | 881 | json_t *value; |
| 916 | json_object_foreach (json, key_str, value) | 882 | json_object_foreach (json, key_str, value) |
| 917 | { | 883 | { |
| 918 | Lisp_Object key = json_build_string (key_str); | 884 | Lisp_Object key = build_string_from_utf8 (key_str); |
| 919 | EMACS_UINT hash; | 885 | EMACS_UINT hash; |
| 920 | ptrdiff_t i = hash_lookup (h, key, &hash); | 886 | ptrdiff_t i = hash_lookup (h, key, &hash); |
| 921 | /* Keys in JSON objects are unique, so the key can't | 887 | /* Keys in JSON objects are unique, so the key can't |
| @@ -932,7 +898,8 @@ json_to_lisp (json_t *json, struct json_configuration *conf) | |||
| 932 | json_t *value; | 898 | json_t *value; |
| 933 | json_object_foreach (json, key_str, value) | 899 | json_object_foreach (json, key_str, value) |
| 934 | { | 900 | { |
| 935 | Lisp_Object key = Fintern (json_build_string (key_str), Qnil); | 901 | Lisp_Object key |
| 902 | = Fintern (build_string_from_utf8 (key_str), Qnil); | ||
| 936 | result | 903 | result |
| 937 | = Fcons (Fcons (key, json_to_lisp (value, conf)), | 904 | = Fcons (Fcons (key, json_to_lisp (value, conf)), |
| 938 | result); | 905 | result); |
diff --git a/src/keyboard.c b/src/keyboard.c index ea13c7f5bcd..bb4d185c914 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -3909,7 +3909,7 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3909 | case END_SESSION_EVENT: | 3909 | case END_SESSION_EVENT: |
| 3910 | case LANGUAGE_CHANGE_EVENT: | 3910 | case LANGUAGE_CHANGE_EVENT: |
| 3911 | #endif | 3911 | #endif |
| 3912 | #if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (HAVE_NS) | 3912 | #ifdef HAVE_WINDOW_SYSTEM |
| 3913 | case DELETE_WINDOW_EVENT: | 3913 | case DELETE_WINDOW_EVENT: |
| 3914 | case ICONIFY_EVENT: | 3914 | case ICONIFY_EVENT: |
| 3915 | case DEICONIFY_EVENT: | 3915 | case DEICONIFY_EVENT: |
| @@ -5283,7 +5283,7 @@ make_lispy_event (struct input_event *event) | |||
| 5283 | 5283 | ||
| 5284 | switch (event->kind) | 5284 | switch (event->kind) |
| 5285 | { | 5285 | { |
| 5286 | #if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (HAVE_NS) | 5286 | #ifdef HAVE_WINDOW_SYSTEM |
| 5287 | case DELETE_WINDOW_EVENT: | 5287 | case DELETE_WINDOW_EVENT: |
| 5288 | /* Make an event (delete-frame (FRAME)). */ | 5288 | /* Make an event (delete-frame (FRAME)). */ |
| 5289 | return list2 (Qdelete_frame, list1 (event->frame_or_window)); | 5289 | return list2 (Qdelete_frame, list1 (event->frame_or_window)); |
| @@ -9968,7 +9968,7 @@ If CHECK-TIMERS is non-nil, timers that are ready to run will do so. */) | |||
| 9968 | DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0, | 9968 | DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0, |
| 9969 | doc: /* Return vector of last few events, not counting those from keyboard macros. | 9969 | doc: /* Return vector of last few events, not counting those from keyboard macros. |
| 9970 | If INCLUDE-CMDS is non-nil, include the commands that were run, | 9970 | If INCLUDE-CMDS is non-nil, include the commands that were run, |
| 9971 | represented as events of the form (nil . COMMAND). */) | 9971 | represented as pseudo-events of the form (nil . COMMAND). */) |
| 9972 | (Lisp_Object include_cmds) | 9972 | (Lisp_Object include_cmds) |
| 9973 | { | 9973 | { |
| 9974 | bool cmds = !NILP (include_cmds); | 9974 | bool cmds = !NILP (include_cmds); |
diff --git a/src/lisp.h b/src/lisp.h index ca833476c03..6db90596899 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -144,11 +144,13 @@ typedef intmax_t printmax_t; | |||
| 144 | typedef uintmax_t uprintmax_t; | 144 | typedef uintmax_t uprintmax_t; |
| 145 | # define pMd PRIdMAX | 145 | # define pMd PRIdMAX |
| 146 | # define pMu PRIuMAX | 146 | # define pMu PRIuMAX |
| 147 | # define pMx PRIxMAX | ||
| 147 | #else | 148 | #else |
| 148 | typedef EMACS_INT printmax_t; | 149 | typedef EMACS_INT printmax_t; |
| 149 | typedef EMACS_UINT uprintmax_t; | 150 | typedef EMACS_UINT uprintmax_t; |
| 150 | # define pMd pI"d" | 151 | # define pMd pI"d" |
| 151 | # define pMu pI"u" | 152 | # define pMu pI"u" |
| 153 | # define pMx pI"x" | ||
| 152 | #endif | 154 | #endif |
| 153 | 155 | ||
| 154 | /* Use pD to format ptrdiff_t values, which suffice for indexes into | 156 | /* Use pD to format ptrdiff_t values, which suffice for indexes into |
| @@ -2234,7 +2236,7 @@ INLINE int | |||
| 2234 | } | 2236 | } |
| 2235 | 2237 | ||
| 2236 | /* Placeholder for make-docfile to process. The actual symbol | 2238 | /* Placeholder for make-docfile to process. The actual symbol |
| 2237 | definition is done by lread.c's defsym. */ | 2239 | definition is done by lread.c's define_symbol. */ |
| 2238 | #define DEFSYM(sym, name) /* empty */ | 2240 | #define DEFSYM(sym, name) /* empty */ |
| 2239 | 2241 | ||
| 2240 | 2242 | ||
| @@ -2677,7 +2679,7 @@ struct Lisp_Buffer_Objfwd | |||
| 2677 | { | 2679 | { |
| 2678 | enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Buffer_Obj */ | 2680 | enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Buffer_Obj */ |
| 2679 | int offset; | 2681 | int offset; |
| 2680 | /* One of Qnil, Qfixnump, Qsymbolp, Qstringp, Qfloatp or Qnumberp. */ | 2682 | /* One of Qnil, Qintegerp, Qsymbolp, Qstringp, Qfloatp or Qnumberp. */ |
| 2681 | Lisp_Object predicate; | 2683 | Lisp_Object predicate; |
| 2682 | }; | 2684 | }; |
| 2683 | 2685 | ||
| @@ -3641,7 +3643,6 @@ extern void init_fringe_once (void); | |||
| 3641 | 3643 | ||
| 3642 | /* Defined in image.c. */ | 3644 | /* Defined in image.c. */ |
| 3643 | extern int x_bitmap_mask (struct frame *, ptrdiff_t); | 3645 | extern int x_bitmap_mask (struct frame *, ptrdiff_t); |
| 3644 | extern void reset_image_types (void); | ||
| 3645 | extern void syms_of_image (void); | 3646 | extern void syms_of_image (void); |
| 3646 | 3647 | ||
| 3647 | #ifdef HAVE_JSON | 3648 | #ifdef HAVE_JSON |
diff --git a/src/lread.c b/src/lread.c index 1c97805ca7a..5fa90cad3f3 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -44,6 +44,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 44 | #include "blockinput.h" | 44 | #include "blockinput.h" |
| 45 | #include "pdumper.h" | 45 | #include "pdumper.h" |
| 46 | #include <c-ctype.h> | 46 | #include <c-ctype.h> |
| 47 | #include <vla.h> | ||
| 47 | 48 | ||
| 48 | #ifdef MSDOS | 49 | #ifdef MSDOS |
| 49 | #include "msdos.h" | 50 | #include "msdos.h" |
| @@ -2640,90 +2641,83 @@ digit_to_number (int character, int base) | |||
| 2640 | return digit < base ? digit : -1; | 2641 | return digit < base ? digit : -1; |
| 2641 | } | 2642 | } |
| 2642 | 2643 | ||
| 2644 | static char const invalid_radix_integer_format[] = "integer, radix %"pI"d"; | ||
| 2645 | |||
| 2646 | /* Small, as read1 is recursive (Bug#31995). But big enough to hold | ||
| 2647 | the invalid_radix_integer string. */ | ||
| 2648 | enum { stackbufsize = max (64, | ||
| 2649 | (sizeof invalid_radix_integer_format | ||
| 2650 | - sizeof "%"pI"d" | ||
| 2651 | + INT_STRLEN_BOUND (EMACS_INT) + 1)) }; | ||
| 2652 | |||
| 2643 | static void | 2653 | static void |
| 2644 | free_contents (void *p) | 2654 | invalid_radix_integer (EMACS_INT radix, char stackbuf[VLA_ELEMS (stackbufsize)]) |
| 2645 | { | 2655 | { |
| 2646 | void **ptr = (void **) p; | 2656 | sprintf (stackbuf, invalid_radix_integer_format, radix); |
| 2647 | xfree (*ptr); | 2657 | invalid_syntax (stackbuf); |
| 2648 | } | 2658 | } |
| 2649 | 2659 | ||
| 2650 | /* Read an integer in radix RADIX using READCHARFUN to read | 2660 | /* Read an integer in radix RADIX using READCHARFUN to read |
| 2651 | characters. RADIX must be in the interval [2..36]; if it isn't, a | 2661 | characters. RADIX must be in the interval [2..36]. Use STACKBUF |
| 2652 | read error is signaled . Value is the integer read. Signals an | 2662 | for temporary storage as needed. Value is the integer read. |
| 2653 | error if encountering invalid read syntax or if RADIX is out of | 2663 | Signal an error if encountering invalid read syntax. */ |
| 2654 | range. */ | ||
| 2655 | 2664 | ||
| 2656 | static Lisp_Object | 2665 | static Lisp_Object |
| 2657 | read_integer (Lisp_Object readcharfun, EMACS_INT radix) | 2666 | read_integer (Lisp_Object readcharfun, int radix, |
| 2667 | char stackbuf[VLA_ELEMS (stackbufsize)]) | ||
| 2658 | { | 2668 | { |
| 2659 | /* Room for sign, leading 0, other digits, trailing NUL byte. | 2669 | char *read_buffer = stackbuf; |
| 2660 | Also, room for invalid syntax diagnostic. */ | 2670 | ptrdiff_t read_buffer_size = stackbufsize; |
| 2661 | size_t len = max (1 + 1 + UINTMAX_WIDTH + 1, | 2671 | char *p = read_buffer; |
| 2662 | sizeof "integer, radix " + INT_STRLEN_BOUND (EMACS_INT)); | 2672 | char *heapbuf = NULL; |
| 2663 | char *buf = NULL; | ||
| 2664 | char *p = buf; | ||
| 2665 | int valid = -1; /* 1 if valid, 0 if not, -1 if incomplete. */ | 2673 | int valid = -1; /* 1 if valid, 0 if not, -1 if incomplete. */ |
| 2666 | |||
| 2667 | ptrdiff_t count = SPECPDL_INDEX (); | 2674 | ptrdiff_t count = SPECPDL_INDEX (); |
| 2668 | 2675 | ||
| 2669 | if (radix < 2 || radix > 36) | 2676 | int c = READCHAR; |
| 2670 | valid = 0; | 2677 | if (c == '-' || c == '+') |
| 2671 | else | ||
| 2672 | { | 2678 | { |
| 2673 | int c, digit; | 2679 | *p++ = c; |
| 2674 | |||
| 2675 | buf = xmalloc (len); | ||
| 2676 | record_unwind_protect_ptr (free_contents, &buf); | ||
| 2677 | p = buf; | ||
| 2678 | |||
| 2679 | c = READCHAR; | 2680 | c = READCHAR; |
| 2680 | if (c == '-' || c == '+') | 2681 | } |
| 2681 | { | ||
| 2682 | *p++ = c; | ||
| 2683 | c = READCHAR; | ||
| 2684 | } | ||
| 2685 | 2682 | ||
| 2686 | if (c == '0') | 2683 | if (c == '0') |
| 2687 | { | 2684 | { |
| 2688 | *p++ = c; | 2685 | *p++ = c; |
| 2689 | valid = 1; | 2686 | valid = 1; |
| 2690 | 2687 | ||
| 2691 | /* Ignore redundant leading zeros, so the buffer doesn't | 2688 | /* Ignore redundant leading zeros, so the buffer doesn't |
| 2692 | fill up with them. */ | 2689 | fill up with them. */ |
| 2693 | do | 2690 | do |
| 2694 | c = READCHAR; | 2691 | c = READCHAR; |
| 2695 | while (c == '0'); | 2692 | while (c == '0'); |
| 2696 | } | 2693 | } |
| 2697 | 2694 | ||
| 2698 | while ((digit = digit_to_number (c, radix)) >= -1) | 2695 | for (int digit; (digit = digit_to_number (c, radix)) >= -1; ) |
| 2696 | { | ||
| 2697 | if (digit == -1) | ||
| 2698 | valid = 0; | ||
| 2699 | if (valid < 0) | ||
| 2700 | valid = 1; | ||
| 2701 | /* Allow 1 extra byte for the \0. */ | ||
| 2702 | if (p + 1 == read_buffer + read_buffer_size) | ||
| 2699 | { | 2703 | { |
| 2700 | if (digit == -1) | 2704 | ptrdiff_t offset = p - read_buffer; |
| 2701 | valid = 0; | 2705 | read_buffer = grow_read_buffer (read_buffer, offset, |
| 2702 | if (valid < 0) | 2706 | &heapbuf, &read_buffer_size, |
| 2703 | valid = 1; | 2707 | count); |
| 2704 | /* Allow 1 extra byte for the \0. */ | 2708 | p = read_buffer + offset; |
| 2705 | if (p + 1 == buf + len) | ||
| 2706 | { | ||
| 2707 | ptrdiff_t where = p - buf; | ||
| 2708 | len *= 2; | ||
| 2709 | buf = xrealloc (buf, len); | ||
| 2710 | p = buf + where; | ||
| 2711 | } | ||
| 2712 | *p++ = c; | ||
| 2713 | c = READCHAR; | ||
| 2714 | } | 2709 | } |
| 2715 | 2710 | *p++ = c; | |
| 2716 | UNREAD (c); | 2711 | c = READCHAR; |
| 2717 | } | 2712 | } |
| 2718 | 2713 | ||
| 2714 | UNREAD (c); | ||
| 2715 | |||
| 2719 | if (valid != 1) | 2716 | if (valid != 1) |
| 2720 | { | 2717 | invalid_radix_integer (radix, stackbuf); |
| 2721 | sprintf (buf, "integer, radix %"pI"d", radix); | ||
| 2722 | invalid_syntax (buf); | ||
| 2723 | } | ||
| 2724 | 2718 | ||
| 2725 | *p = '\0'; | 2719 | *p = '\0'; |
| 2726 | return unbind_to (count, string_to_number (buf, radix, 0)); | 2720 | return unbind_to (count, string_to_number (read_buffer, radix, NULL)); |
| 2727 | } | 2721 | } |
| 2728 | 2722 | ||
| 2729 | 2723 | ||
| @@ -2739,7 +2733,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 2739 | int c; | 2733 | int c; |
| 2740 | bool uninterned_symbol = false; | 2734 | bool uninterned_symbol = false; |
| 2741 | bool multibyte; | 2735 | bool multibyte; |
| 2742 | char stackbuf[128]; /* Small, as read1 is recursive (Bug#31995). */ | 2736 | char stackbuf[stackbufsize]; |
| 2743 | current_thread->stack_top = stackbuf; | 2737 | current_thread->stack_top = stackbuf; |
| 2744 | 2738 | ||
| 2745 | *pch = 0; | 2739 | *pch = 0; |
| @@ -3109,30 +3103,34 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 3109 | /* ## is the empty symbol. */ | 3103 | /* ## is the empty symbol. */ |
| 3110 | if (c == '#') | 3104 | if (c == '#') |
| 3111 | return Fintern (empty_unibyte_string, Qnil); | 3105 | return Fintern (empty_unibyte_string, Qnil); |
| 3112 | /* Reader forms that can reuse previously read objects. */ | 3106 | |
| 3113 | if (c >= '0' && c <= '9') | 3107 | if (c >= '0' && c <= '9') |
| 3114 | { | 3108 | { |
| 3115 | EMACS_INT n = 0; | 3109 | EMACS_INT n = c - '0'; |
| 3116 | Lisp_Object tem; | ||
| 3117 | bool overflow = false; | 3110 | bool overflow = false; |
| 3118 | 3111 | ||
| 3119 | /* Read a non-negative integer. */ | 3112 | /* Read a non-negative integer. */ |
| 3120 | while (c >= '0' && c <= '9') | 3113 | while ('0' <= (c = READCHAR) && c <= '9') |
| 3121 | { | 3114 | { |
| 3122 | overflow |= INT_MULTIPLY_WRAPV (n, 10, &n); | 3115 | overflow |= INT_MULTIPLY_WRAPV (n, 10, &n); |
| 3123 | overflow |= INT_ADD_WRAPV (n, c - '0', &n); | 3116 | overflow |= INT_ADD_WRAPV (n, c - '0', &n); |
| 3124 | c = READCHAR; | ||
| 3125 | } | 3117 | } |
| 3126 | 3118 | ||
| 3127 | if (!overflow && n <= MOST_POSITIVE_FIXNUM) | 3119 | if (!overflow) |
| 3128 | { | 3120 | { |
| 3129 | if (c == 'r' || c == 'R') | 3121 | if (c == 'r' || c == 'R') |
| 3130 | return read_integer (readcharfun, n); | 3122 | { |
| 3123 | if (! (2 <= n && n <= 36)) | ||
| 3124 | invalid_radix_integer (n, stackbuf); | ||
| 3125 | return read_integer (readcharfun, n, stackbuf); | ||
| 3126 | } | ||
| 3131 | 3127 | ||
| 3132 | if (! NILP (Vread_circle)) | 3128 | if (n <= MOST_POSITIVE_FIXNUM && ! NILP (Vread_circle)) |
| 3133 | { | 3129 | { |
| 3130 | /* Reader forms that can reuse previously read objects. */ | ||
| 3131 | |||
| 3134 | /* #n=object returns object, but associates it with | 3132 | /* #n=object returns object, but associates it with |
| 3135 | n for #n#. */ | 3133 | n for #n#. */ |
| 3136 | if (c == '=') | 3134 | if (c == '=') |
| 3137 | { | 3135 | { |
| 3138 | /* Make a placeholder for #n# to use temporarily. */ | 3136 | /* Make a placeholder for #n# to use temporarily. */ |
| @@ -3161,7 +3159,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 3161 | hash_put (h, number, placeholder, hash); | 3159 | hash_put (h, number, placeholder, hash); |
| 3162 | 3160 | ||
| 3163 | /* Read the object itself. */ | 3161 | /* Read the object itself. */ |
| 3164 | tem = read0 (readcharfun); | 3162 | Lisp_Object tem = read0 (readcharfun); |
| 3165 | 3163 | ||
| 3166 | /* If it can be recursive, remember it for | 3164 | /* If it can be recursive, remember it for |
| 3167 | future substitutions. */ | 3165 | future substitutions. */ |
| @@ -3211,11 +3209,11 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 3211 | /* Fall through to error message. */ | 3209 | /* Fall through to error message. */ |
| 3212 | } | 3210 | } |
| 3213 | else if (c == 'x' || c == 'X') | 3211 | else if (c == 'x' || c == 'X') |
| 3214 | return read_integer (readcharfun, 16); | 3212 | return read_integer (readcharfun, 16, stackbuf); |
| 3215 | else if (c == 'o' || c == 'O') | 3213 | else if (c == 'o' || c == 'O') |
| 3216 | return read_integer (readcharfun, 8); | 3214 | return read_integer (readcharfun, 8, stackbuf); |
| 3217 | else if (c == 'b' || c == 'B') | 3215 | else if (c == 'b' || c == 'B') |
| 3218 | return read_integer (readcharfun, 2); | 3216 | return read_integer (readcharfun, 2, stackbuf); |
| 3219 | 3217 | ||
| 3220 | UNREAD (c); | 3218 | UNREAD (c); |
| 3221 | invalid_syntax ("#"); | 3219 | invalid_syntax ("#"); |
diff --git a/src/macfont.m b/src/macfont.m index 8fcbd50fe33..abdf0ecfe59 100644 --- a/src/macfont.m +++ b/src/macfont.m | |||
| @@ -1647,7 +1647,7 @@ static Lisp_Object macfont_open (struct frame *, Lisp_Object, int); | |||
| 1647 | static void macfont_close (struct font *); | 1647 | static void macfont_close (struct font *); |
| 1648 | static int macfont_has_char (Lisp_Object, int); | 1648 | static int macfont_has_char (Lisp_Object, int); |
| 1649 | static unsigned macfont_encode_char (struct font *, int); | 1649 | static unsigned macfont_encode_char (struct font *, int); |
| 1650 | static void macfont_text_extents (struct font *, unsigned int *, int, | 1650 | static void macfont_text_extents (struct font *, const unsigned int *, int, |
| 1651 | struct font_metrics *); | 1651 | struct font_metrics *); |
| 1652 | static int macfont_draw (struct glyph_string *, int, int, int, int, bool); | 1652 | static int macfont_draw (struct glyph_string *, int, int, int, int, bool); |
| 1653 | static Lisp_Object macfont_shape (Lisp_Object, Lisp_Object); | 1653 | static Lisp_Object macfont_shape (Lisp_Object, Lisp_Object); |
| @@ -2743,7 +2743,7 @@ macfont_encode_char (struct font *font, int c) | |||
| 2743 | } | 2743 | } |
| 2744 | 2744 | ||
| 2745 | static void | 2745 | static void |
| 2746 | macfont_text_extents (struct font *font, unsigned int *code, int nglyphs, | 2746 | macfont_text_extents (struct font *font, const unsigned int *code, int nglyphs, |
| 2747 | struct font_metrics *metrics) | 2747 | struct font_metrics *metrics) |
| 2748 | { | 2748 | { |
| 2749 | int width, i; | 2749 | int width, i; |
| @@ -2826,7 +2826,18 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 2826 | } | 2826 | } |
| 2827 | } | 2827 | } |
| 2828 | 2828 | ||
| 2829 | context = [[NSGraphicsContext currentContext] graphicsPort]; | 2829 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 |
| 2830 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 | ||
| 2831 | if ([[NSGraphicsContext currentContext] respondsToSelector:@selector(CGContext)]) | ||
| 2832 | #endif | ||
| 2833 | context = [[NSGraphicsContext currentContext] CGContext]; | ||
| 2834 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 | ||
| 2835 | else | ||
| 2836 | #endif | ||
| 2837 | #endif | ||
| 2838 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 | ||
| 2839 | context = [[NSGraphicsContext currentContext] graphicsPort]; | ||
| 2840 | #endif | ||
| 2830 | CGContextSaveGState (context); | 2841 | CGContextSaveGState (context); |
| 2831 | 2842 | ||
| 2832 | if (!CGRectIsNull (background_rect)) | 2843 | if (!CGRectIsNull (background_rect)) |
| @@ -3005,7 +3016,7 @@ macfont_shape (Lisp_Object lgstring, Lisp_Object direction) | |||
| 3005 | 3016 | ||
| 3006 | if (NILP (lglyph)) | 3017 | if (NILP (lglyph)) |
| 3007 | { | 3018 | { |
| 3008 | lglyph = make_nil_vector (LGLYPH_SIZE); | 3019 | lglyph = LGLYPH_NEW (); |
| 3009 | LGSTRING_SET_GLYPH (lgstring, i, lglyph); | 3020 | LGSTRING_SET_GLYPH (lgstring, i, lglyph); |
| 3010 | } | 3021 | } |
| 3011 | 3022 | ||
diff --git a/src/marker.c b/src/marker.c index b58051a8c2b..0b2e1bf5c6b 100644 --- a/src/marker.c +++ b/src/marker.c | |||
| @@ -332,6 +332,10 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) | |||
| 332 | if (best_above == best_above_byte) | 332 | if (best_above == best_above_byte) |
| 333 | return bytepos; | 333 | return bytepos; |
| 334 | 334 | ||
| 335 | /* Check bytepos is not in the middle of a character. */ | ||
| 336 | eassert (bytepos >= BUF_Z_BYTE (b) | ||
| 337 | || CHAR_HEAD_P (BUF_FETCH_BYTE (b, bytepos))); | ||
| 338 | |||
| 335 | best_below = BEG; | 339 | best_below = BEG; |
| 336 | best_below_byte = BEG_BYTE; | 340 | best_below_byte = BEG_BYTE; |
| 337 | 341 | ||
diff --git a/src/mini-gmp.c b/src/mini-gmp.c index 90beb6e8327..88b71c3f9a6 100644 --- a/src/mini-gmp.c +++ b/src/mini-gmp.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | Contributed to the GNU project by Niels Möller | 3 | Contributed to the GNU project by Niels Möller |
| 4 | 4 | ||
| 5 | Copyright 1991-1997, 1999-2019 Free Software Foundation, Inc. | 5 | Copyright 1991-1997, 1999-2018 Free Software Foundation, Inc. |
| 6 | 6 | ||
| 7 | This file is part of the GNU MP Library. | 7 | This file is part of the GNU MP Library. |
| 8 | 8 | ||
| @@ -58,7 +58,7 @@ see https://www.gnu.org/licenses/. */ | |||
| 58 | /* Macros */ | 58 | /* Macros */ |
| 59 | #define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT) | 59 | #define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT) |
| 60 | 60 | ||
| 61 | #define GMP_LIMB_MAX (~ (mp_limb_t) 0) | 61 | #define GMP_LIMB_MAX ((mp_limb_t) ~ (mp_limb_t) 0) |
| 62 | #define GMP_LIMB_HIGHBIT ((mp_limb_t) 1 << (GMP_LIMB_BITS - 1)) | 62 | #define GMP_LIMB_HIGHBIT ((mp_limb_t) 1 << (GMP_LIMB_BITS - 1)) |
| 63 | 63 | ||
| 64 | #define GMP_HLIMB_BIT ((mp_limb_t) 1 << (GMP_LIMB_BITS / 2)) | 64 | #define GMP_HLIMB_BIT ((mp_limb_t) 1 << (GMP_LIMB_BITS / 2)) |
| @@ -129,6 +129,20 @@ see https://www.gnu.org/licenses/. */ | |||
| 129 | 129 | ||
| 130 | #define gmp_umul_ppmm(w1, w0, u, v) \ | 130 | #define gmp_umul_ppmm(w1, w0, u, v) \ |
| 131 | do { \ | 131 | do { \ |
| 132 | int LOCAL_GMP_LIMB_BITS = GMP_LIMB_BITS; \ | ||
| 133 | if (sizeof(unsigned int) * CHAR_BIT >= 2 * GMP_LIMB_BITS) \ | ||
| 134 | { \ | ||
| 135 | unsigned int __ww = (unsigned int) (u) * (v); \ | ||
| 136 | w0 = (mp_limb_t) __ww; \ | ||
| 137 | w1 = (mp_limb_t) (__ww >> LOCAL_GMP_LIMB_BITS); \ | ||
| 138 | } \ | ||
| 139 | else if (GMP_ULONG_BITS >= 2 * GMP_LIMB_BITS) \ | ||
| 140 | { \ | ||
| 141 | unsigned long int __ww = (unsigned long int) (u) * (v); \ | ||
| 142 | w0 = (mp_limb_t) __ww; \ | ||
| 143 | w1 = (mp_limb_t) (__ww >> LOCAL_GMP_LIMB_BITS); \ | ||
| 144 | } \ | ||
| 145 | else { \ | ||
| 132 | mp_limb_t __x0, __x1, __x2, __x3; \ | 146 | mp_limb_t __x0, __x1, __x2, __x3; \ |
| 133 | unsigned __ul, __vl, __uh, __vh; \ | 147 | unsigned __ul, __vl, __uh, __vh; \ |
| 134 | mp_limb_t __u = (u), __v = (v); \ | 148 | mp_limb_t __u = (u), __v = (v); \ |
| @@ -150,6 +164,7 @@ see https://www.gnu.org/licenses/. */ | |||
| 150 | \ | 164 | \ |
| 151 | (w1) = __x3 + (__x1 >> (GMP_LIMB_BITS / 2)); \ | 165 | (w1) = __x3 + (__x1 >> (GMP_LIMB_BITS / 2)); \ |
| 152 | (w0) = (__x1 << (GMP_LIMB_BITS / 2)) + (__x0 & GMP_LLIMB_MASK); \ | 166 | (w0) = (__x1 << (GMP_LIMB_BITS / 2)) + (__x0 & GMP_LLIMB_MASK); \ |
| 167 | } \ | ||
| 153 | } while (0) | 168 | } while (0) |
| 154 | 169 | ||
| 155 | #define gmp_udiv_qrnnd_preinv(q, r, nh, nl, d, di) \ | 170 | #define gmp_udiv_qrnnd_preinv(q, r, nh, nl, d, di) \ |
| @@ -753,6 +768,18 @@ mpn_neg (mp_ptr rp, mp_srcptr up, mp_size_t n) | |||
| 753 | mp_limb_t | 768 | mp_limb_t |
| 754 | mpn_invert_3by2 (mp_limb_t u1, mp_limb_t u0) | 769 | mpn_invert_3by2 (mp_limb_t u1, mp_limb_t u0) |
| 755 | { | 770 | { |
| 771 | int GMP_LIMB_BITS_MUL_3 = GMP_LIMB_BITS * 3; | ||
| 772 | if (sizeof (unsigned) * CHAR_BIT > GMP_LIMB_BITS * 3) | ||
| 773 | { | ||
| 774 | return (((unsigned) 1 << GMP_LIMB_BITS_MUL_3) - 1) / | ||
| 775 | (((unsigned) u1 << GMP_LIMB_BITS_MUL_3 / 3) + u0); | ||
| 776 | } | ||
| 777 | else if (GMP_ULONG_BITS > GMP_LIMB_BITS * 3) | ||
| 778 | { | ||
| 779 | return (((unsigned long) 1 << GMP_LIMB_BITS_MUL_3) - 1) / | ||
| 780 | (((unsigned long) u1 << GMP_LIMB_BITS_MUL_3 / 3) + u0); | ||
| 781 | } | ||
| 782 | else { | ||
| 756 | mp_limb_t r, p, m, ql; | 783 | mp_limb_t r, p, m, ql; |
| 757 | unsigned ul, uh, qh; | 784 | unsigned ul, uh, qh; |
| 758 | 785 | ||
| @@ -827,7 +854,7 @@ mpn_invert_3by2 (mp_limb_t u1, mp_limb_t u0) | |||
| 827 | r -= u1; | 854 | r -= u1; |
| 828 | } | 855 | } |
| 829 | 856 | ||
| 830 | /* Now m is the 2/1 invers of u1. If u0 > 0, adjust it to become a | 857 | /* Now m is the 2/1 inverse of u1. If u0 > 0, adjust it to become a |
| 831 | 3/2 inverse. */ | 858 | 3/2 inverse. */ |
| 832 | if (u0 > 0) | 859 | if (u0 > 0) |
| 833 | { | 860 | { |
| @@ -854,6 +881,7 @@ mpn_invert_3by2 (mp_limb_t u1, mp_limb_t u0) | |||
| 854 | } | 881 | } |
| 855 | 882 | ||
| 856 | return m; | 883 | return m; |
| 884 | } | ||
| 857 | } | 885 | } |
| 858 | 886 | ||
| 859 | struct gmp_div_inverse | 887 | struct gmp_div_inverse |
| @@ -964,36 +992,6 @@ mpn_div_qr_1_preinv (mp_ptr qp, mp_srcptr np, mp_size_t nn, | |||
| 964 | return r >> inv->shift; | 992 | return r >> inv->shift; |
| 965 | } | 993 | } |
| 966 | 994 | ||
| 967 | static mp_limb_t | ||
| 968 | mpn_div_qr_1 (mp_ptr qp, mp_srcptr np, mp_size_t nn, mp_limb_t d) | ||
| 969 | { | ||
| 970 | assert (d > 0); | ||
| 971 | |||
| 972 | /* Special case for powers of two. */ | ||
| 973 | if ((d & (d-1)) == 0) | ||
| 974 | { | ||
| 975 | mp_limb_t r = np[0] & (d-1); | ||
| 976 | if (qp) | ||
| 977 | { | ||
| 978 | if (d <= 1) | ||
| 979 | mpn_copyi (qp, np, nn); | ||
| 980 | else | ||
| 981 | { | ||
| 982 | unsigned shift; | ||
| 983 | gmp_ctz (shift, d); | ||
| 984 | mpn_rshift (qp, np, nn, shift); | ||
| 985 | } | ||
| 986 | } | ||
| 987 | return r; | ||
| 988 | } | ||
| 989 | else | ||
| 990 | { | ||
| 991 | struct gmp_div_inverse inv; | ||
| 992 | mpn_div_qr_1_invert (&inv, d); | ||
| 993 | return mpn_div_qr_1_preinv (qp, np, nn, &inv); | ||
| 994 | } | ||
| 995 | } | ||
| 996 | |||
| 997 | static void | 995 | static void |
| 998 | mpn_div_qr_2_preinv (mp_ptr qp, mp_ptr np, mp_size_t nn, | 996 | mpn_div_qr_2_preinv (mp_ptr qp, mp_ptr np, mp_size_t nn, |
| 999 | const struct gmp_div_inverse *inv) | 997 | const struct gmp_div_inverse *inv) |
| @@ -1029,7 +1027,7 @@ mpn_div_qr_2_preinv (mp_ptr qp, mp_ptr np, mp_size_t nn, | |||
| 1029 | 1027 | ||
| 1030 | if (shift > 0) | 1028 | if (shift > 0) |
| 1031 | { | 1029 | { |
| 1032 | assert ((r0 << (GMP_LIMB_BITS - shift)) == 0); | 1030 | assert ((r0 & (GMP_LIMB_MAX >> (GMP_LIMB_BITS - shift))) == 0); |
| 1033 | r0 = (r0 >> shift) | (r1 << (GMP_LIMB_BITS - shift)); | 1031 | r0 = (r0 >> shift) | (r1 << (GMP_LIMB_BITS - shift)); |
| 1034 | r1 >>= shift; | 1032 | r1 >>= shift; |
| 1035 | } | 1033 | } |
| @@ -1252,7 +1250,7 @@ mpn_limb_get_str (unsigned char *sp, mp_limb_t w, | |||
| 1252 | l = w << binv->shift; | 1250 | l = w << binv->shift; |
| 1253 | 1251 | ||
| 1254 | gmp_udiv_qrnnd_preinv (w, r, h, l, binv->d1, binv->di); | 1252 | gmp_udiv_qrnnd_preinv (w, r, h, l, binv->d1, binv->di); |
| 1255 | assert ( (r << (GMP_LIMB_BITS - binv->shift)) == 0); | 1253 | assert ((r & (GMP_LIMB_MAX >> (GMP_LIMB_BITS - binv->shift))) == 0); |
| 1256 | r >>= binv->shift; | 1254 | r >>= binv->shift; |
| 1257 | 1255 | ||
| 1258 | sp[i] = r; | 1256 | sp[i] = r; |
| @@ -1420,7 +1418,7 @@ mpn_set_str (mp_ptr rp, const unsigned char *sp, size_t sn, int base) | |||
| 1420 | void | 1418 | void |
| 1421 | mpz_init (mpz_t r) | 1419 | mpz_init (mpz_t r) |
| 1422 | { | 1420 | { |
| 1423 | static const mp_limb_t dummy_limb = 0xc1a0; | 1421 | static const mp_limb_t dummy_limb = GMP_LIMB_MAX & 0xc1a0; |
| 1424 | 1422 | ||
| 1425 | r->_mp_alloc = 0; | 1423 | r->_mp_alloc = 0; |
| 1426 | r->_mp_size = 0; | 1424 | r->_mp_size = 0; |
| @@ -1478,6 +1476,12 @@ mpz_set_si (mpz_t r, signed long int x) | |||
| 1478 | if (x >= 0) | 1476 | if (x >= 0) |
| 1479 | mpz_set_ui (r, x); | 1477 | mpz_set_ui (r, x); |
| 1480 | else /* (x < 0) */ | 1478 | else /* (x < 0) */ |
| 1479 | if (GMP_LIMB_BITS < GMP_ULONG_BITS) | ||
| 1480 | { | ||
| 1481 | mpz_set_ui (r, GMP_NEG_CAST (unsigned long int, x)); | ||
| 1482 | mpz_neg (r, r); | ||
| 1483 | } | ||
| 1484 | else | ||
| 1481 | { | 1485 | { |
| 1482 | r->_mp_size = -1; | 1486 | r->_mp_size = -1; |
| 1483 | MPZ_REALLOC (r, 1)[0] = GMP_NEG_CAST (unsigned long int, x); | 1487 | MPZ_REALLOC (r, 1)[0] = GMP_NEG_CAST (unsigned long int, x); |
| @@ -1491,6 +1495,15 @@ mpz_set_ui (mpz_t r, unsigned long int x) | |||
| 1491 | { | 1495 | { |
| 1492 | r->_mp_size = 1; | 1496 | r->_mp_size = 1; |
| 1493 | MPZ_REALLOC (r, 1)[0] = x; | 1497 | MPZ_REALLOC (r, 1)[0] = x; |
| 1498 | if (GMP_LIMB_BITS < GMP_ULONG_BITS) | ||
| 1499 | { | ||
| 1500 | int LOCAL_GMP_LIMB_BITS = GMP_LIMB_BITS; | ||
| 1501 | while (x >>= LOCAL_GMP_LIMB_BITS) | ||
| 1502 | { | ||
| 1503 | ++ r->_mp_size; | ||
| 1504 | MPZ_REALLOC (r, r->_mp_size)[r->_mp_size - 1] = x; | ||
| 1505 | } | ||
| 1506 | } | ||
| 1494 | } | 1507 | } |
| 1495 | else | 1508 | else |
| 1496 | r->_mp_size = 0; | 1509 | r->_mp_size = 0; |
| @@ -1537,14 +1550,20 @@ mpz_init_set (mpz_t r, const mpz_t x) | |||
| 1537 | int | 1550 | int |
| 1538 | mpz_fits_slong_p (const mpz_t u) | 1551 | mpz_fits_slong_p (const mpz_t u) |
| 1539 | { | 1552 | { |
| 1540 | mp_size_t us = u->_mp_size; | 1553 | return (LONG_MAX + LONG_MIN == 0 || mpz_cmp_ui (u, LONG_MAX) <= 0) && |
| 1554 | mpz_cmpabs_ui (u, GMP_NEG_CAST (unsigned long int, LONG_MIN)) <= 0; | ||
| 1555 | } | ||
| 1541 | 1556 | ||
| 1542 | if (us == 1) | 1557 | static int |
| 1543 | return u->_mp_d[0] < GMP_LIMB_HIGHBIT; | 1558 | mpn_absfits_ulong_p (mp_srcptr up, mp_size_t un) |
| 1544 | else if (us == -1) | 1559 | { |
| 1545 | return u->_mp_d[0] <= GMP_LIMB_HIGHBIT; | 1560 | int ulongsize = GMP_ULONG_BITS / GMP_LIMB_BITS; |
| 1546 | else | 1561 | mp_limb_t ulongrem = 0; |
| 1547 | return (us == 0); | 1562 | |
| 1563 | if (GMP_ULONG_BITS % GMP_LIMB_BITS != 0) | ||
| 1564 | ulongrem = (mp_limb_t) (ULONG_MAX >> GMP_LIMB_BITS * ulongsize) + 1; | ||
| 1565 | |||
| 1566 | return un <= ulongsize || (up[ulongsize] < ulongrem && un == ulongsize + 1); | ||
| 1548 | } | 1567 | } |
| 1549 | 1568 | ||
| 1550 | int | 1569 | int |
| @@ -1552,22 +1571,36 @@ mpz_fits_ulong_p (const mpz_t u) | |||
| 1552 | { | 1571 | { |
| 1553 | mp_size_t us = u->_mp_size; | 1572 | mp_size_t us = u->_mp_size; |
| 1554 | 1573 | ||
| 1555 | return (us == (us > 0)); | 1574 | return us >= 0 && mpn_absfits_ulong_p (u->_mp_d, us); |
| 1556 | } | 1575 | } |
| 1557 | 1576 | ||
| 1558 | long int | 1577 | long int |
| 1559 | mpz_get_si (const mpz_t u) | 1578 | mpz_get_si (const mpz_t u) |
| 1560 | { | 1579 | { |
| 1580 | unsigned long r = mpz_get_ui (u); | ||
| 1581 | unsigned long c = -LONG_MAX - LONG_MIN; | ||
| 1582 | |||
| 1561 | if (u->_mp_size < 0) | 1583 | if (u->_mp_size < 0) |
| 1562 | /* This expression is necessary to properly handle 0x80000000 */ | 1584 | /* This expression is necessary to properly handle -LONG_MIN */ |
| 1563 | return -1 - (long) ((u->_mp_d[0] - 1) & ~GMP_LIMB_HIGHBIT); | 1585 | return -(long) c - (long) ((r - c) & LONG_MAX); |
| 1564 | else | 1586 | else |
| 1565 | return (long) (mpz_get_ui (u) & ~GMP_LIMB_HIGHBIT); | 1587 | return (long) (r & LONG_MAX); |
| 1566 | } | 1588 | } |
| 1567 | 1589 | ||
| 1568 | unsigned long int | 1590 | unsigned long int |
| 1569 | mpz_get_ui (const mpz_t u) | 1591 | mpz_get_ui (const mpz_t u) |
| 1570 | { | 1592 | { |
| 1593 | if (GMP_LIMB_BITS < GMP_ULONG_BITS) | ||
| 1594 | { | ||
| 1595 | int LOCAL_GMP_LIMB_BITS = GMP_LIMB_BITS; | ||
| 1596 | unsigned long r = 0; | ||
| 1597 | mp_size_t n = GMP_ABS (u->_mp_size); | ||
| 1598 | n = GMP_MIN (n, 1 + (GMP_ULONG_BITS - 1) / GMP_LIMB_BITS); | ||
| 1599 | while (--n >= 0) | ||
| 1600 | r = (r << LOCAL_GMP_LIMB_BITS) + u->_mp_d[n]; | ||
| 1601 | return r; | ||
| 1602 | } | ||
| 1603 | |||
| 1571 | return u->_mp_size == 0 ? 0 : u->_mp_d[0]; | 1604 | return u->_mp_size == 0 ? 0 : u->_mp_d[0]; |
| 1572 | } | 1605 | } |
| 1573 | 1606 | ||
| @@ -1665,7 +1698,7 @@ mpz_set_d (mpz_t r, double x) | |||
| 1665 | r->_mp_size = 0; | 1698 | r->_mp_size = 0; |
| 1666 | return; | 1699 | return; |
| 1667 | } | 1700 | } |
| 1668 | B = 2.0 * (double) GMP_LIMB_HIGHBIT; | 1701 | B = 4.0 * (double) (GMP_LIMB_HIGHBIT >> 1); |
| 1669 | Bi = 1.0 / B; | 1702 | Bi = 1.0 / B; |
| 1670 | for (rn = 1; x >= B; rn++) | 1703 | for (rn = 1; x >= B; rn++) |
| 1671 | x *= Bi; | 1704 | x *= Bi; |
| @@ -1703,7 +1736,7 @@ mpz_get_d (const mpz_t u) | |||
| 1703 | mp_limb_t l; | 1736 | mp_limb_t l; |
| 1704 | mp_size_t un; | 1737 | mp_size_t un; |
| 1705 | double x; | 1738 | double x; |
| 1706 | double B = 2.0 * (double) GMP_LIMB_HIGHBIT; | 1739 | double B = 4.0 * (double) (GMP_LIMB_HIGHBIT >> 1); |
| 1707 | 1740 | ||
| 1708 | un = GMP_ABS (u->_mp_size); | 1741 | un = GMP_ABS (u->_mp_size); |
| 1709 | 1742 | ||
| @@ -1748,7 +1781,7 @@ mpz_cmpabs_d (const mpz_t x, double d) | |||
| 1748 | { | 1781 | { |
| 1749 | xn = GMP_ABS (xn); | 1782 | xn = GMP_ABS (xn); |
| 1750 | 1783 | ||
| 1751 | B = 2.0 * (double) GMP_LIMB_HIGHBIT; | 1784 | B = 4.0 * (double) (GMP_LIMB_HIGHBIT >> 1); |
| 1752 | Bi = 1.0 / B; | 1785 | Bi = 1.0 / B; |
| 1753 | 1786 | ||
| 1754 | /* Scale d so it can be compared with the top limb. */ | 1787 | /* Scale d so it can be compared with the top limb. */ |
| @@ -1807,14 +1840,12 @@ mpz_cmp_si (const mpz_t u, long v) | |||
| 1807 | { | 1840 | { |
| 1808 | mp_size_t usize = u->_mp_size; | 1841 | mp_size_t usize = u->_mp_size; |
| 1809 | 1842 | ||
| 1810 | if (usize < -1) | 1843 | if (v >= 0) |
| 1811 | return -1; | ||
| 1812 | else if (v >= 0) | ||
| 1813 | return mpz_cmp_ui (u, v); | 1844 | return mpz_cmp_ui (u, v); |
| 1814 | else if (usize >= 0) | 1845 | else if (usize >= 0) |
| 1815 | return 1; | 1846 | return 1; |
| 1816 | else /* usize == -1 */ | 1847 | else |
| 1817 | return GMP_CMP (GMP_NEG_CAST (mp_limb_t, v), u->_mp_d[0]); | 1848 | return - mpz_cmpabs_ui (u, GMP_NEG_CAST (unsigned long int, v)); |
| 1818 | } | 1849 | } |
| 1819 | 1850 | ||
| 1820 | int | 1851 | int |
| @@ -1822,12 +1853,10 @@ mpz_cmp_ui (const mpz_t u, unsigned long v) | |||
| 1822 | { | 1853 | { |
| 1823 | mp_size_t usize = u->_mp_size; | 1854 | mp_size_t usize = u->_mp_size; |
| 1824 | 1855 | ||
| 1825 | if (usize > 1) | 1856 | if (usize < 0) |
| 1826 | return 1; | ||
| 1827 | else if (usize < 0) | ||
| 1828 | return -1; | 1857 | return -1; |
| 1829 | else | 1858 | else |
| 1830 | return GMP_CMP (mpz_get_ui (u), v); | 1859 | return mpz_cmpabs_ui (u, v); |
| 1831 | } | 1860 | } |
| 1832 | 1861 | ||
| 1833 | int | 1862 | int |
| @@ -1847,10 +1876,15 @@ mpz_cmp (const mpz_t a, const mpz_t b) | |||
| 1847 | int | 1876 | int |
| 1848 | mpz_cmpabs_ui (const mpz_t u, unsigned long v) | 1877 | mpz_cmpabs_ui (const mpz_t u, unsigned long v) |
| 1849 | { | 1878 | { |
| 1850 | if (GMP_ABS (u->_mp_size) > 1) | 1879 | mp_size_t un = GMP_ABS (u->_mp_size); |
| 1880 | |||
| 1881 | if (! mpn_absfits_ulong_p (u->_mp_d, un)) | ||
| 1851 | return 1; | 1882 | return 1; |
| 1852 | else | 1883 | else |
| 1853 | return GMP_CMP (mpz_get_ui (u), v); | 1884 | { |
| 1885 | unsigned long uu = mpz_get_ui (u); | ||
| 1886 | return GMP_CMP(uu, v); | ||
| 1887 | } | ||
| 1854 | } | 1888 | } |
| 1855 | 1889 | ||
| 1856 | int | 1890 | int |
| @@ -1885,81 +1919,28 @@ mpz_swap (mpz_t u, mpz_t v) | |||
| 1885 | 1919 | ||
| 1886 | /* MPZ addition and subtraction */ | 1920 | /* MPZ addition and subtraction */ |
| 1887 | 1921 | ||
| 1888 | /* Adds to the absolute value. Returns new size, but doesn't store it. */ | ||
| 1889 | static mp_size_t | ||
| 1890 | mpz_abs_add_ui (mpz_t r, const mpz_t a, unsigned long b) | ||
| 1891 | { | ||
| 1892 | mp_size_t an; | ||
| 1893 | mp_ptr rp; | ||
| 1894 | mp_limb_t cy; | ||
| 1895 | |||
| 1896 | an = GMP_ABS (a->_mp_size); | ||
| 1897 | if (an == 0) | ||
| 1898 | { | ||
| 1899 | MPZ_REALLOC (r, 1)[0] = b; | ||
| 1900 | return b > 0; | ||
| 1901 | } | ||
| 1902 | |||
| 1903 | rp = MPZ_REALLOC (r, an + 1); | ||
| 1904 | |||
| 1905 | cy = mpn_add_1 (rp, a->_mp_d, an, b); | ||
| 1906 | rp[an] = cy; | ||
| 1907 | an += cy; | ||
| 1908 | |||
| 1909 | return an; | ||
| 1910 | } | ||
| 1911 | |||
| 1912 | /* Subtract from the absolute value. Returns new size, (or -1 on underflow), | ||
| 1913 | but doesn't store it. */ | ||
| 1914 | static mp_size_t | ||
| 1915 | mpz_abs_sub_ui (mpz_t r, const mpz_t a, unsigned long b) | ||
| 1916 | { | ||
| 1917 | mp_size_t an = GMP_ABS (a->_mp_size); | ||
| 1918 | mp_ptr rp; | ||
| 1919 | |||
| 1920 | if (an == 0) | ||
| 1921 | { | ||
| 1922 | MPZ_REALLOC (r, 1)[0] = b; | ||
| 1923 | return -(b > 0); | ||
| 1924 | } | ||
| 1925 | rp = MPZ_REALLOC (r, an); | ||
| 1926 | if (an == 1 && a->_mp_d[0] < b) | ||
| 1927 | { | ||
| 1928 | rp[0] = b - a->_mp_d[0]; | ||
| 1929 | return -1; | ||
| 1930 | } | ||
| 1931 | else | ||
| 1932 | { | ||
| 1933 | gmp_assert_nocarry (mpn_sub_1 (rp, a->_mp_d, an, b)); | ||
| 1934 | return mpn_normalized_size (rp, an); | ||
| 1935 | } | ||
| 1936 | } | ||
| 1937 | 1922 | ||
| 1938 | void | 1923 | void |
| 1939 | mpz_add_ui (mpz_t r, const mpz_t a, unsigned long b) | 1924 | mpz_add_ui (mpz_t r, const mpz_t a, unsigned long b) |
| 1940 | { | 1925 | { |
| 1941 | if (a->_mp_size >= 0) | 1926 | mpz_t bb; |
| 1942 | r->_mp_size = mpz_abs_add_ui (r, a, b); | 1927 | mpz_init_set_ui (bb, b); |
| 1943 | else | 1928 | mpz_add (r, a, bb); |
| 1944 | r->_mp_size = -mpz_abs_sub_ui (r, a, b); | 1929 | mpz_clear (bb); |
| 1945 | } | 1930 | } |
| 1946 | 1931 | ||
| 1947 | void | 1932 | void |
| 1948 | mpz_sub_ui (mpz_t r, const mpz_t a, unsigned long b) | 1933 | mpz_sub_ui (mpz_t r, const mpz_t a, unsigned long b) |
| 1949 | { | 1934 | { |
| 1950 | if (a->_mp_size < 0) | 1935 | mpz_ui_sub (r, b, a); |
| 1951 | r->_mp_size = -mpz_abs_add_ui (r, a, b); | 1936 | mpz_neg (r, r); |
| 1952 | else | ||
| 1953 | r->_mp_size = mpz_abs_sub_ui (r, a, b); | ||
| 1954 | } | 1937 | } |
| 1955 | 1938 | ||
| 1956 | void | 1939 | void |
| 1957 | mpz_ui_sub (mpz_t r, unsigned long a, const mpz_t b) | 1940 | mpz_ui_sub (mpz_t r, unsigned long a, const mpz_t b) |
| 1958 | { | 1941 | { |
| 1959 | if (b->_mp_size < 0) | 1942 | mpz_neg (r, b); |
| 1960 | r->_mp_size = mpz_abs_add_ui (r, b, a); | 1943 | mpz_add_ui (r, r, a); |
| 1961 | else | ||
| 1962 | r->_mp_size = -mpz_abs_sub_ui (r, b, a); | ||
| 1963 | } | 1944 | } |
| 1964 | 1945 | ||
| 1965 | static mp_size_t | 1946 | static mp_size_t |
| @@ -2046,32 +2027,17 @@ mpz_mul_si (mpz_t r, const mpz_t u, long int v) | |||
| 2046 | mpz_neg (r, r); | 2027 | mpz_neg (r, r); |
| 2047 | } | 2028 | } |
| 2048 | else | 2029 | else |
| 2049 | mpz_mul_ui (r, u, (unsigned long int) v); | 2030 | mpz_mul_ui (r, u, v); |
| 2050 | } | 2031 | } |
| 2051 | 2032 | ||
| 2052 | void | 2033 | void |
| 2053 | mpz_mul_ui (mpz_t r, const mpz_t u, unsigned long int v) | 2034 | mpz_mul_ui (mpz_t r, const mpz_t u, unsigned long int v) |
| 2054 | { | 2035 | { |
| 2055 | mp_size_t un, us; | 2036 | mpz_t vv; |
| 2056 | mp_ptr tp; | 2037 | mpz_init_set_ui (vv, v); |
| 2057 | mp_limb_t cy; | 2038 | mpz_mul (r, u, vv); |
| 2058 | 2039 | mpz_clear (vv); | |
| 2059 | us = u->_mp_size; | 2040 | return; |
| 2060 | |||
| 2061 | if (us == 0 || v == 0) | ||
| 2062 | { | ||
| 2063 | r->_mp_size = 0; | ||
| 2064 | return; | ||
| 2065 | } | ||
| 2066 | |||
| 2067 | un = GMP_ABS (us); | ||
| 2068 | |||
| 2069 | tp = MPZ_REALLOC (r, un + 1); | ||
| 2070 | cy = mpn_mul_1 (tp, u->_mp_d, un, v); | ||
| 2071 | tp[un] = cy; | ||
| 2072 | |||
| 2073 | un += (cy > 0); | ||
| 2074 | r->_mp_size = (us < 0) ? - un : un; | ||
| 2075 | } | 2041 | } |
| 2076 | 2042 | ||
| 2077 | void | 2043 | void |
| @@ -2150,8 +2116,8 @@ void | |||
| 2150 | mpz_addmul_ui (mpz_t r, const mpz_t u, unsigned long int v) | 2116 | mpz_addmul_ui (mpz_t r, const mpz_t u, unsigned long int v) |
| 2151 | { | 2117 | { |
| 2152 | mpz_t t; | 2118 | mpz_t t; |
| 2153 | mpz_init (t); | 2119 | mpz_init_set_ui (t, v); |
| 2154 | mpz_mul_ui (t, u, v); | 2120 | mpz_mul (t, u, t); |
| 2155 | mpz_add (r, r, t); | 2121 | mpz_add (r, r, t); |
| 2156 | mpz_clear (t); | 2122 | mpz_clear (t); |
| 2157 | } | 2123 | } |
| @@ -2160,8 +2126,8 @@ void | |||
| 2160 | mpz_submul_ui (mpz_t r, const mpz_t u, unsigned long int v) | 2126 | mpz_submul_ui (mpz_t r, const mpz_t u, unsigned long int v) |
| 2161 | { | 2127 | { |
| 2162 | mpz_t t; | 2128 | mpz_t t; |
| 2163 | mpz_init (t); | 2129 | mpz_init_set_ui (t, v); |
| 2164 | mpz_mul_ui (t, u, v); | 2130 | mpz_mul (t, u, t); |
| 2165 | mpz_sub (r, r, t); | 2131 | mpz_sub (r, r, t); |
| 2166 | mpz_clear (t); | 2132 | mpz_clear (t); |
| 2167 | } | 2133 | } |
| @@ -2557,56 +2523,20 @@ static unsigned long | |||
| 2557 | mpz_div_qr_ui (mpz_t q, mpz_t r, | 2523 | mpz_div_qr_ui (mpz_t q, mpz_t r, |
| 2558 | const mpz_t n, unsigned long d, enum mpz_div_round_mode mode) | 2524 | const mpz_t n, unsigned long d, enum mpz_div_round_mode mode) |
| 2559 | { | 2525 | { |
| 2560 | mp_size_t ns, qn; | 2526 | unsigned long ret; |
| 2561 | mp_ptr qp; | 2527 | mpz_t rr, dd; |
| 2562 | mp_limb_t rl; | ||
| 2563 | mp_size_t rs; | ||
| 2564 | |||
| 2565 | ns = n->_mp_size; | ||
| 2566 | if (ns == 0) | ||
| 2567 | { | ||
| 2568 | if (q) | ||
| 2569 | q->_mp_size = 0; | ||
| 2570 | if (r) | ||
| 2571 | r->_mp_size = 0; | ||
| 2572 | return 0; | ||
| 2573 | } | ||
| 2574 | |||
| 2575 | qn = GMP_ABS (ns); | ||
| 2576 | if (q) | ||
| 2577 | qp = MPZ_REALLOC (q, qn); | ||
| 2578 | else | ||
| 2579 | qp = NULL; | ||
| 2580 | 2528 | ||
| 2581 | rl = mpn_div_qr_1 (qp, n->_mp_d, qn, d); | 2529 | mpz_init (rr); |
| 2582 | assert (rl < d); | 2530 | mpz_init_set_ui (dd, d); |
| 2583 | 2531 | mpz_div_qr (q, rr, n, dd, mode); | |
| 2584 | rs = rl > 0; | 2532 | mpz_clear (dd); |
| 2585 | rs = (ns < 0) ? -rs : rs; | 2533 | ret = mpz_get_ui (rr); |
| 2586 | |||
| 2587 | if (rl > 0 && ( (mode == GMP_DIV_FLOOR && ns < 0) | ||
| 2588 | || (mode == GMP_DIV_CEIL && ns >= 0))) | ||
| 2589 | { | ||
| 2590 | if (q) | ||
| 2591 | gmp_assert_nocarry (mpn_add_1 (qp, qp, qn, 1)); | ||
| 2592 | rl = d - rl; | ||
| 2593 | rs = -rs; | ||
| 2594 | } | ||
| 2595 | 2534 | ||
| 2596 | if (r) | 2535 | if (r) |
| 2597 | { | 2536 | mpz_swap (r, rr); |
| 2598 | MPZ_REALLOC (r, 1)[0] = rl; | 2537 | mpz_clear (rr); |
| 2599 | r->_mp_size = rs; | ||
| 2600 | } | ||
| 2601 | if (q) | ||
| 2602 | { | ||
| 2603 | qn -= (qp[qn-1] == 0); | ||
| 2604 | assert (qn == 0 || qp[qn-1] > 0); | ||
| 2605 | |||
| 2606 | q->_mp_size = (ns < 0) ? - qn : qn; | ||
| 2607 | } | ||
| 2608 | 2538 | ||
| 2609 | return rl; | 2539 | return ret; |
| 2610 | } | 2540 | } |
| 2611 | 2541 | ||
| 2612 | unsigned long | 2542 | unsigned long |
| @@ -2745,22 +2675,16 @@ mpn_gcd_11 (mp_limb_t u, mp_limb_t v) | |||
| 2745 | unsigned long | 2675 | unsigned long |
| 2746 | mpz_gcd_ui (mpz_t g, const mpz_t u, unsigned long v) | 2676 | mpz_gcd_ui (mpz_t g, const mpz_t u, unsigned long v) |
| 2747 | { | 2677 | { |
| 2748 | mp_size_t un; | 2678 | mpz_t t; |
| 2679 | mpz_init_set_ui(t, v); | ||
| 2680 | mpz_gcd (t, u, t); | ||
| 2681 | if (v > 0) | ||
| 2682 | v = mpz_get_ui (t); | ||
| 2749 | 2683 | ||
| 2750 | if (v == 0) | 2684 | if (g) |
| 2751 | { | 2685 | mpz_swap (t, g); |
| 2752 | if (g) | ||
| 2753 | mpz_abs (g, u); | ||
| 2754 | } | ||
| 2755 | else | ||
| 2756 | { | ||
| 2757 | un = GMP_ABS (u->_mp_size); | ||
| 2758 | if (un != 0) | ||
| 2759 | v = mpn_gcd_11 (mpn_div_qr_1 (NULL, u->_mp_d, un, v), v); | ||
| 2760 | 2686 | ||
| 2761 | if (g) | 2687 | mpz_clear (t); |
| 2762 | mpz_set_ui (g, v); | ||
| 2763 | } | ||
| 2764 | 2688 | ||
| 2765 | return v; | 2689 | return v; |
| 2766 | } | 2690 | } |
| @@ -2854,7 +2778,7 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) | |||
| 2854 | signed long sign = mpz_sgn (v); | 2778 | signed long sign = mpz_sgn (v); |
| 2855 | mpz_abs (g, v); | 2779 | mpz_abs (g, v); |
| 2856 | if (s) | 2780 | if (s) |
| 2857 | mpz_set_ui (s, 0); | 2781 | s->_mp_size = 0; |
| 2858 | if (t) | 2782 | if (t) |
| 2859 | mpz_set_si (t, sign); | 2783 | mpz_set_si (t, sign); |
| 2860 | return; | 2784 | return; |
| @@ -2868,7 +2792,7 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) | |||
| 2868 | if (s) | 2792 | if (s) |
| 2869 | mpz_set_si (s, sign); | 2793 | mpz_set_si (s, sign); |
| 2870 | if (t) | 2794 | if (t) |
| 2871 | mpz_set_ui (t, 0); | 2795 | t->_mp_size = 0; |
| 2872 | return; | 2796 | return; |
| 2873 | } | 2797 | } |
| 2874 | 2798 | ||
| @@ -2993,8 +2917,9 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) | |||
| 2993 | mpz_sub (s0, s0, s1); | 2917 | mpz_sub (s0, s0, s1); |
| 2994 | mpz_add (t0, t0, t1); | 2918 | mpz_add (t0, t0, t1); |
| 2995 | } | 2919 | } |
| 2996 | mpz_divexact_ui (s0, s0, 2); | 2920 | assert (mpz_even_p (t0) && mpz_even_p (s0)); |
| 2997 | mpz_divexact_ui (t0, t0, 2); | 2921 | mpz_tdiv_q_2exp (s0, s0, 1); |
| 2922 | mpz_tdiv_q_2exp (t0, t0, 1); | ||
| 2998 | } | 2923 | } |
| 2999 | 2924 | ||
| 3000 | /* Arrange so that |s| < |u| / 2g */ | 2925 | /* Arrange so that |s| < |u| / 2g */ |
| @@ -3119,7 +3044,10 @@ void | |||
| 3119 | mpz_ui_pow_ui (mpz_t r, unsigned long blimb, unsigned long e) | 3044 | mpz_ui_pow_ui (mpz_t r, unsigned long blimb, unsigned long e) |
| 3120 | { | 3045 | { |
| 3121 | mpz_t b; | 3046 | mpz_t b; |
| 3122 | mpz_pow_ui (r, mpz_roinit_normal_n (b, &blimb, blimb != 0), e); | 3047 | |
| 3048 | mpz_init_set_ui (b, blimb); | ||
| 3049 | mpz_pow_ui (r, b, e); | ||
| 3050 | mpz_clear (b); | ||
| 3123 | } | 3051 | } |
| 3124 | 3052 | ||
| 3125 | void | 3053 | void |
| @@ -3231,7 +3159,10 @@ void | |||
| 3231 | mpz_powm_ui (mpz_t r, const mpz_t b, unsigned long elimb, const mpz_t m) | 3159 | mpz_powm_ui (mpz_t r, const mpz_t b, unsigned long elimb, const mpz_t m) |
| 3232 | { | 3160 | { |
| 3233 | mpz_t e; | 3161 | mpz_t e; |
| 3234 | mpz_powm (r, b, mpz_roinit_normal_n (e, &elimb, elimb != 0), m); | 3162 | |
| 3163 | mpz_init_set_ui (e, elimb); | ||
| 3164 | mpz_powm (r, b, e, m); | ||
| 3165 | mpz_clear (e); | ||
| 3235 | } | 3166 | } |
| 3236 | 3167 | ||
| 3237 | /* x=trunc(y^(1/z)), r=y-x^z */ | 3168 | /* x=trunc(y^(1/z)), r=y-x^z */ |
| @@ -3409,6 +3340,177 @@ mpz_bin_uiui (mpz_t r, unsigned long n, unsigned long k) | |||
| 3409 | 3340 | ||
| 3410 | 3341 | ||
| 3411 | /* Primality testing */ | 3342 | /* Primality testing */ |
| 3343 | |||
| 3344 | /* Computes Kronecker (a/b) with odd b, a!=0 and GCD(a,b) = 1 */ | ||
| 3345 | /* Adapted from JACOBI_BASE_METHOD==4 in mpn/generic/jacbase.c */ | ||
| 3346 | static int | ||
| 3347 | gmp_jacobi_coprime (mp_limb_t a, mp_limb_t b) | ||
| 3348 | { | ||
| 3349 | int c, bit = 0; | ||
| 3350 | |||
| 3351 | assert (b & 1); | ||
| 3352 | assert (a != 0); | ||
| 3353 | /* assert (mpn_gcd_11 (a, b) == 1); */ | ||
| 3354 | |||
| 3355 | /* Below, we represent a and b shifted right so that the least | ||
| 3356 | significant one bit is implicit. */ | ||
| 3357 | b >>= 1; | ||
| 3358 | |||
| 3359 | gmp_ctz(c, a); | ||
| 3360 | a >>= 1; | ||
| 3361 | |||
| 3362 | do | ||
| 3363 | { | ||
| 3364 | a >>= c; | ||
| 3365 | /* (2/b) = -1 if b = 3 or 5 mod 8 */ | ||
| 3366 | bit ^= c & (b ^ (b >> 1)); | ||
| 3367 | if (a < b) | ||
| 3368 | { | ||
| 3369 | bit ^= a & b; | ||
| 3370 | a = b - a; | ||
| 3371 | b -= a; | ||
| 3372 | } | ||
| 3373 | else | ||
| 3374 | { | ||
| 3375 | a -= b; | ||
| 3376 | assert (a != 0); | ||
| 3377 | } | ||
| 3378 | |||
| 3379 | gmp_ctz(c, a); | ||
| 3380 | ++c; | ||
| 3381 | } | ||
| 3382 | while (b > 0); | ||
| 3383 | |||
| 3384 | return bit & 1 ? -1 : 1; | ||
| 3385 | } | ||
| 3386 | |||
| 3387 | static void | ||
| 3388 | gmp_lucas_step_k_2k (mpz_t V, mpz_t Qk, const mpz_t n) | ||
| 3389 | { | ||
| 3390 | mpz_mod (Qk, Qk, n); | ||
| 3391 | /* V_{2k} <- V_k ^ 2 - 2Q^k */ | ||
| 3392 | mpz_mul (V, V, V); | ||
| 3393 | mpz_submul_ui (V, Qk, 2); | ||
| 3394 | mpz_tdiv_r (V, V, n); | ||
| 3395 | /* Q^{2k} = (Q^k)^2 */ | ||
| 3396 | mpz_mul (Qk, Qk, Qk); | ||
| 3397 | } | ||
| 3398 | |||
| 3399 | /* Computes V_k, Q^k (mod n) for the Lucas' sequence */ | ||
| 3400 | /* with P=1, Q=Q; k = (n>>b0)|1. */ | ||
| 3401 | /* Requires an odd n > 4; b0 > 0; -2*Q must not overflow a long */ | ||
| 3402 | /* Returns (U_k == 0) and sets V=V_k and Qk=Q^k. */ | ||
| 3403 | static int | ||
| 3404 | gmp_lucas_mod (mpz_t V, mpz_t Qk, long Q, | ||
| 3405 | mp_bitcnt_t b0, const mpz_t n) | ||
| 3406 | { | ||
| 3407 | mp_bitcnt_t bs; | ||
| 3408 | mpz_t U; | ||
| 3409 | int res; | ||
| 3410 | |||
| 3411 | assert (b0 > 0); | ||
| 3412 | assert (Q <= - (LONG_MIN / 2)); | ||
| 3413 | assert (Q >= - (LONG_MAX / 2)); | ||
| 3414 | assert (mpz_cmp_ui (n, 4) > 0); | ||
| 3415 | assert (mpz_odd_p (n)); | ||
| 3416 | |||
| 3417 | mpz_init_set_ui (U, 1); /* U1 = 1 */ | ||
| 3418 | mpz_set_ui (V, 1); /* V1 = 1 */ | ||
| 3419 | mpz_set_si (Qk, Q); | ||
| 3420 | |||
| 3421 | for (bs = mpz_sizeinbase (n, 2) - 1; --bs >= b0;) | ||
| 3422 | { | ||
| 3423 | /* U_{2k} <- U_k * V_k */ | ||
| 3424 | mpz_mul (U, U, V); | ||
| 3425 | /* V_{2k} <- V_k ^ 2 - 2Q^k */ | ||
| 3426 | /* Q^{2k} = (Q^k)^2 */ | ||
| 3427 | gmp_lucas_step_k_2k (V, Qk, n); | ||
| 3428 | |||
| 3429 | /* A step k->k+1 is performed if the bit in $n$ is 1 */ | ||
| 3430 | /* mpz_tstbit(n,bs) or the the bit is 0 in $n$ but */ | ||
| 3431 | /* should be 1 in $n+1$ (bs == b0) */ | ||
| 3432 | if (b0 == bs || mpz_tstbit (n, bs)) | ||
| 3433 | { | ||
| 3434 | /* Q^{k+1} <- Q^k * Q */ | ||
| 3435 | mpz_mul_si (Qk, Qk, Q); | ||
| 3436 | /* U_{k+1} <- (U_k + V_k) / 2 */ | ||
| 3437 | mpz_swap (U, V); /* Keep in V the old value of U_k */ | ||
| 3438 | mpz_add (U, U, V); | ||
| 3439 | /* We have to compute U/2, so we need an even value, */ | ||
| 3440 | /* equivalent (mod n) */ | ||
| 3441 | if (mpz_odd_p (U)) | ||
| 3442 | mpz_add (U, U, n); | ||
| 3443 | mpz_tdiv_q_2exp (U, U, 1); | ||
| 3444 | /* V_{k+1} <-(D*U_k + V_k) / 2 = | ||
| 3445 | U_{k+1} + (D-1)/2*U_k = U_{k+1} - 2Q*U_k */ | ||
| 3446 | mpz_mul_si (V, V, -2*Q); | ||
| 3447 | mpz_add (V, U, V); | ||
| 3448 | mpz_tdiv_r (V, V, n); | ||
| 3449 | } | ||
| 3450 | mpz_tdiv_r (U, U, n); | ||
| 3451 | } | ||
| 3452 | |||
| 3453 | res = U->_mp_size == 0; | ||
| 3454 | mpz_clear (U); | ||
| 3455 | return res; | ||
| 3456 | } | ||
| 3457 | |||
| 3458 | /* Performs strong Lucas' test on x, with parameters suggested */ | ||
| 3459 | /* for the BPSW test. Qk is only passed to recycle a variable. */ | ||
| 3460 | /* Requires GCD (x,6) = 1.*/ | ||
| 3461 | static int | ||
| 3462 | gmp_stronglucas (const mpz_t x, mpz_t Qk) | ||
| 3463 | { | ||
| 3464 | mp_bitcnt_t b0; | ||
| 3465 | mpz_t V, n; | ||
| 3466 | mp_limb_t maxD, D; /* The absolute value is stored. */ | ||
| 3467 | long Q; | ||
| 3468 | mp_limb_t tl; | ||
| 3469 | |||
| 3470 | /* Test on the absolute value. */ | ||
| 3471 | mpz_roinit_normal_n (n, x->_mp_d, GMP_ABS (x->_mp_size)); | ||
| 3472 | |||
| 3473 | assert (mpz_odd_p (n)); | ||
| 3474 | /* assert (mpz_gcd_ui (NULL, n, 6) == 1); */ | ||
| 3475 | if (mpz_root (Qk, n, 2)) | ||
| 3476 | return 0; /* A square is composite. */ | ||
| 3477 | |||
| 3478 | /* Check Ds up to square root (in case, n is prime) | ||
| 3479 | or avoid overflows */ | ||
| 3480 | maxD = (Qk->_mp_size == 1) ? Qk->_mp_d [0] - 1 : GMP_LIMB_MAX; | ||
| 3481 | |||
| 3482 | D = 3; | ||
| 3483 | /* Search a D such that (D/n) = -1 in the sequence 5,-7,9,-11,.. */ | ||
| 3484 | /* For those Ds we have (D/n) = (n/|D|) */ | ||
| 3485 | do | ||
| 3486 | { | ||
| 3487 | if (D >= maxD) | ||
| 3488 | return 1 + (D != GMP_LIMB_MAX); /* (1 + ! ~ D) */ | ||
| 3489 | D += 2; | ||
| 3490 | tl = mpz_tdiv_ui (n, D); | ||
| 3491 | if (tl == 0) | ||
| 3492 | return 0; | ||
| 3493 | } | ||
| 3494 | while (gmp_jacobi_coprime (tl, D) == 1); | ||
| 3495 | |||
| 3496 | mpz_init (V); | ||
| 3497 | |||
| 3498 | /* n-(D/n) = n+1 = d*2^{b0}, with d = (n>>b0) | 1 */ | ||
| 3499 | b0 = mpz_scan0 (n, 0); | ||
| 3500 | |||
| 3501 | /* D= P^2 - 4Q; P = 1; Q = (1-D)/4 */ | ||
| 3502 | Q = (D & 2) ? (D >> 2) + 1 : -(long) (D >> 2); | ||
| 3503 | |||
| 3504 | if (! gmp_lucas_mod (V, Qk, Q, b0, n)) /* If Ud != 0 */ | ||
| 3505 | while (V->_mp_size != 0 && --b0 != 0) /* while Vk != 0 */ | ||
| 3506 | /* V <- V ^ 2 - 2Q^k */ | ||
| 3507 | /* Q^{2k} = (Q^k)^2 */ | ||
| 3508 | gmp_lucas_step_k_2k (V, Qk, n); | ||
| 3509 | |||
| 3510 | mpz_clear (V); | ||
| 3511 | return (b0 != 0); | ||
| 3512 | } | ||
| 3513 | |||
| 3412 | static int | 3514 | static int |
| 3413 | gmp_millerrabin (const mpz_t n, const mpz_t nm1, mpz_t y, | 3515 | gmp_millerrabin (const mpz_t n, const mpz_t nm1, mpz_t y, |
| 3414 | const mpz_t q, mp_bitcnt_t k) | 3516 | const mpz_t q, mp_bitcnt_t k) |
| @@ -3470,21 +3572,26 @@ mpz_probab_prime_p (const mpz_t n, int reps) | |||
| 3470 | if (mpz_cmpabs_ui (n, 31*31) < 0) | 3572 | if (mpz_cmpabs_ui (n, 31*31) < 0) |
| 3471 | return 2; | 3573 | return 2; |
| 3472 | 3574 | ||
| 3473 | /* Use Miller-Rabin, with a deterministic sequence of bases, a[j] = | ||
| 3474 | j^2 + j + 41 using Euler's polynomial. We potentially stop early, | ||
| 3475 | if a[j] >= n - 1. Since n >= 31*31, this can happen only if reps > | ||
| 3476 | 30 (a[30] == 971 > 31*31 == 961). */ | ||
| 3477 | |||
| 3478 | mpz_init (nm1); | 3575 | mpz_init (nm1); |
| 3479 | mpz_init (q); | 3576 | mpz_init (q); |
| 3480 | mpz_init (y); | ||
| 3481 | 3577 | ||
| 3482 | /* Find q and k, where q is odd and n = 1 + 2**k * q. */ | 3578 | /* Find q and k, where q is odd and n = 1 + 2**k * q. */ |
| 3483 | nm1->_mp_size = mpz_abs_sub_ui (nm1, n, 1); | 3579 | mpz_abs (nm1, n); |
| 3580 | nm1->_mp_d[0] -= 1; | ||
| 3484 | k = mpz_scan1 (nm1, 0); | 3581 | k = mpz_scan1 (nm1, 0); |
| 3485 | mpz_tdiv_q_2exp (q, nm1, k); | 3582 | mpz_tdiv_q_2exp (q, nm1, k); |
| 3486 | 3583 | ||
| 3487 | for (j = 0, is_prime = 1; is_prime & (j < reps); j++) | 3584 | /* BPSW test */ |
| 3585 | mpz_init_set_ui (y, 2); | ||
| 3586 | is_prime = gmp_millerrabin (n, nm1, y, q, k) && gmp_stronglucas (n, y); | ||
| 3587 | reps -= 24; /* skip the first 24 repetitions */ | ||
| 3588 | |||
| 3589 | /* Use Miller-Rabin, with a deterministic sequence of bases, a[j] = | ||
| 3590 | j^2 + j + 41 using Euler's polynomial. We potentially stop early, | ||
| 3591 | if a[j] >= n - 1. Since n >= 31*31, this can happen only if reps > | ||
| 3592 | 30 (a[30] == 971 > 31*31 == 961). */ | ||
| 3593 | |||
| 3594 | for (j = 0; is_prime & (j < reps); j++) | ||
| 3488 | { | 3595 | { |
| 3489 | mpz_set_ui (y, (unsigned long) j*j+j+41); | 3596 | mpz_set_ui (y, (unsigned long) j*j+j+41); |
| 3490 | if (mpz_cmp (y, nm1) >= 0) | 3597 | if (mpz_cmp (y, nm1) >= 0) |
| @@ -3552,7 +3659,7 @@ mpz_tstbit (const mpz_t d, mp_bitcnt_t bit_index) | |||
| 3552 | { | 3659 | { |
| 3553 | /* d < 0. Check if any of the bits below is set: If so, our bit | 3660 | /* d < 0. Check if any of the bits below is set: If so, our bit |
| 3554 | must be complemented. */ | 3661 | must be complemented. */ |
| 3555 | if (shift > 0 && (w << (GMP_LIMB_BITS - shift)) > 0) | 3662 | if (shift > 0 && (mp_limb_t) (w << (GMP_LIMB_BITS - shift)) > 0) |
| 3556 | return bit ^ 1; | 3663 | return bit ^ 1; |
| 3557 | while (--limb_index >= 0) | 3664 | while (--limb_index >= 0) |
| 3558 | if (d->_mp_d[limb_index] > 0) | 3665 | if (d->_mp_d[limb_index] > 0) |
| @@ -3659,8 +3766,8 @@ mpz_combit (mpz_t d, mp_bitcnt_t bit_index) | |||
| 3659 | void | 3766 | void |
| 3660 | mpz_com (mpz_t r, const mpz_t u) | 3767 | mpz_com (mpz_t r, const mpz_t u) |
| 3661 | { | 3768 | { |
| 3662 | mpz_neg (r, u); | 3769 | mpz_add_ui (r, u, 1); |
| 3663 | mpz_sub_ui (r, r, 1); | 3770 | mpz_neg (r, r); |
| 3664 | } | 3771 | } |
| 3665 | 3772 | ||
| 3666 | void | 3773 | void |
| @@ -4000,7 +4107,7 @@ mpz_scan1 (const mpz_t u, mp_bitcnt_t starting_bit) | |||
| 4000 | } | 4107 | } |
| 4001 | 4108 | ||
| 4002 | /* Mask to 0 all bits before starting_bit, thus ignoring them. */ | 4109 | /* Mask to 0 all bits before starting_bit, thus ignoring them. */ |
| 4003 | limb &= (GMP_LIMB_MAX << (starting_bit % GMP_LIMB_BITS)); | 4110 | limb &= GMP_LIMB_MAX << (starting_bit % GMP_LIMB_BITS); |
| 4004 | } | 4111 | } |
| 4005 | 4112 | ||
| 4006 | return mpn_common_scan (limb, i, up, un, ux); | 4113 | return mpn_common_scan (limb, i, up, un, ux); |
| @@ -4030,7 +4137,7 @@ mpz_scan0 (const mpz_t u, mp_bitcnt_t starting_bit) | |||
| 4030 | limb -= mpn_zero_p (up, i); /* limb = ~(~limb + zero_p) */ | 4137 | limb -= mpn_zero_p (up, i); /* limb = ~(~limb + zero_p) */ |
| 4031 | 4138 | ||
| 4032 | /* Mask all bits before starting_bit, thus ignoring them. */ | 4139 | /* Mask all bits before starting_bit, thus ignoring them. */ |
| 4033 | limb &= (GMP_LIMB_MAX << (starting_bit % GMP_LIMB_BITS)); | 4140 | limb &= GMP_LIMB_MAX << (starting_bit % GMP_LIMB_BITS); |
| 4034 | 4141 | ||
| 4035 | return mpn_common_scan (limb, i, up, un, ux); | 4142 | return mpn_common_scan (limb, i, up, un, ux); |
| 4036 | } | 4143 | } |
diff --git a/src/mini-gmp.h b/src/mini-gmp.h index 2586d32db9e..27e0c0671a2 100644 --- a/src/mini-gmp.h +++ b/src/mini-gmp.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* mini-gmp, a minimalistic implementation of a GNU GMP subset. | 1 | /* mini-gmp, a minimalistic implementation of a GNU GMP subset. |
| 2 | 2 | ||
| 3 | Copyright 2011-2015, 2017, 2019 Free Software Foundation, Inc. | 3 | Copyright 2011-2015, 2017 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of the GNU MP Library. | 5 | This file is part of the GNU MP Library. |
| 6 | 6 | ||
diff --git a/src/minibuf.c b/src/minibuf.c index 10fd5e56ac3..2bf6bc25946 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -1062,7 +1062,8 @@ Optional second arg DEF is value to return if user enters an empty line, | |||
| 1062 | Optional third arg REQUIRE-MATCH has the same meaning as the | 1062 | Optional third arg REQUIRE-MATCH has the same meaning as the |
| 1063 | REQUIRE-MATCH argument of `completing-read'. | 1063 | REQUIRE-MATCH argument of `completing-read'. |
| 1064 | Optional arg PREDICATE, if non-nil, is a function limiting the buffers that | 1064 | Optional arg PREDICATE, if non-nil, is a function limiting the buffers that |
| 1065 | can be considered. It will be called with each potential candidate, and | 1065 | can be considered. It will be called with each potential candidate, in |
| 1066 | the form of either a string or a cons cell whose `car' is a string, and | ||
| 1066 | should return non-nil to accept the candidate for completion, nil otherwise. | 1067 | should return non-nil to accept the candidate for completion, nil otherwise. |
| 1067 | If `read-buffer-completion-ignore-case' is non-nil, completion ignores | 1068 | If `read-buffer-completion-ignore-case' is non-nil, completion ignores |
| 1068 | case while reading the buffer name. | 1069 | case while reading the buffer name. |
diff --git a/src/msdos.h b/src/msdos.h index 0d15df7a331..3614c94dd0e 100644 --- a/src/msdos.h +++ b/src/msdos.h | |||
| @@ -86,7 +86,6 @@ typedef int GC; | |||
| 86 | typedef int Pixmap; | 86 | typedef int Pixmap; |
| 87 | typedef int Display; | 87 | typedef int Display; |
| 88 | typedef int Window; | 88 | typedef int Window; |
| 89 | typedef int XRectangle; | ||
| 90 | #define PIX_TYPE unsigned long | 89 | #define PIX_TYPE unsigned long |
| 91 | #define XDISPLAY | 90 | #define XDISPLAY |
| 92 | 91 | ||
| @@ -95,7 +94,6 @@ typedef struct tty_display_info Display_Info; | |||
| 95 | extern struct tty_display_info the_only_display_info; | 94 | extern struct tty_display_info the_only_display_info; |
| 96 | extern struct tty_output the_only_tty_output; | 95 | extern struct tty_output the_only_tty_output; |
| 97 | 96 | ||
| 98 | #define FRAME_X_DISPLAY(f) ((Display *) 0) | ||
| 99 | #define FRAME_FONT(f) ((f)->output_data.tty->font) | 97 | #define FRAME_FONT(f) ((f)->output_data.tty->font) |
| 100 | #define FRAME_DISPLAY_INFO(f) (&the_only_display_info) | 98 | #define FRAME_DISPLAY_INFO(f) (&the_only_display_info) |
| 101 | 99 | ||
diff --git a/src/nsfont.m b/src/nsfont.m index 9721e489357..eca97ab86cc 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -945,7 +945,7 @@ nsfont_encode_char (struct font *font, int c) | |||
| 945 | of METRICS. The glyphs are specified by their glyph codes in | 945 | of METRICS. The glyphs are specified by their glyph codes in |
| 946 | CODE (length NGLYPHS). */ | 946 | CODE (length NGLYPHS). */ |
| 947 | static void | 947 | static void |
| 948 | nsfont_text_extents (struct font *font, unsigned int *code, | 948 | nsfont_text_extents (struct font *font, const unsigned int *code, |
| 949 | int nglyphs, struct font_metrics *metrics) | 949 | int nglyphs, struct font_metrics *metrics) |
| 950 | { | 950 | { |
| 951 | struct nsfont_info *font_info = (struct nsfont_info *)font; | 951 | struct nsfont_info *font_info = (struct nsfont_info *)font; |
diff --git a/src/nsgui.h b/src/nsgui.h index c147f4dec49..c21953593ad 100644 --- a/src/nsgui.h +++ b/src/nsgui.h | |||
| @@ -58,72 +58,22 @@ typedef struct _XCharStruct | |||
| 58 | int descent; | 58 | int descent; |
| 59 | } XCharStruct; | 59 | } XCharStruct; |
| 60 | 60 | ||
| 61 | /* Fake structure from Xlib.h to represent two-byte characters. */ | ||
| 62 | #ifndef __OBJC__ | ||
| 63 | typedef unsigned short unichar; | ||
| 64 | #endif | ||
| 65 | typedef unichar XChar2b; | ||
| 66 | |||
| 67 | #define STORE_XCHAR2B(chp, b1, b2) \ | ||
| 68 | (*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff)))) | ||
| 69 | |||
| 70 | #define XCHAR2B_BYTE1(chp) \ | ||
| 71 | ((*(chp) & 0xff00) >> 8) | ||
| 72 | |||
| 73 | #define XCHAR2B_BYTE2(chp) \ | ||
| 74 | (*(chp) & 0x00ff) | ||
| 75 | |||
| 76 | /* Used in xdisp.c when comparing faces and frame colors. */ | 61 | /* Used in xdisp.c when comparing faces and frame colors. */ |
| 77 | extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f); | 62 | extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f); |
| 78 | 63 | ||
| 79 | /* XXX: xfaces requires these structures, but the question is are we | ||
| 80 | forced to use them? */ | ||
| 81 | typedef struct _XGCValues | ||
| 82 | { | ||
| 83 | unsigned long foreground; | ||
| 84 | unsigned long background; | ||
| 85 | #ifdef __OBJC__ | 64 | #ifdef __OBJC__ |
| 86 | struct ns_font *font; | 65 | typedef id Emacs_Pixmap; |
| 87 | #else | 66 | #else |
| 88 | void *font; | 67 | typedef void *Emacs_Pixmap; |
| 89 | #endif | 68 | #endif |
| 90 | } XGCValues; | ||
| 91 | |||
| 92 | typedef XGCValues * GC; | ||
| 93 | |||
| 94 | #define GCForeground 0x01 | ||
| 95 | #define GCBackground 0x02 | ||
| 96 | #define GCFont 0x03 | ||
| 97 | 69 | ||
| 98 | #ifdef __OBJC__ | 70 | #ifdef __OBJC__ |
| 99 | typedef id Pixmap; | 71 | typedef NSCursor *Emacs_Cursor; |
| 100 | #else | 72 | #else |
| 101 | typedef void *Pixmap; | 73 | typedef void *Emacs_Cursor; |
| 102 | #endif | 74 | #endif |
| 103 | 75 | ||
| 104 | #ifdef __OBJC__ | ||
| 105 | typedef NSCursor * Cursor; | ||
| 106 | #else | ||
| 107 | typedef void *Cursor; | ||
| 108 | #endif | ||
| 109 | |||
| 110 | #define No_Cursor (0) | ||
| 111 | |||
| 112 | #ifdef __OBJC__ | ||
| 113 | typedef NSColor * Color; | ||
| 114 | #else | ||
| 115 | typedef void * Color; | ||
| 116 | #endif | ||
| 117 | typedef int Window; | 76 | typedef int Window; |
| 118 | typedef int Display; | ||
| 119 | |||
| 120 | |||
| 121 | /* Some sort of attempt to normalize rectangle handling. Seems a bit | ||
| 122 | much for what is accomplished. */ | ||
| 123 | typedef struct { | ||
| 124 | int x, y; | ||
| 125 | unsigned width, height; | ||
| 126 | } XRectangle; | ||
| 127 | 77 | ||
| 128 | #ifndef __OBJC__ | 78 | #ifndef __OBJC__ |
| 129 | #if defined (__LP64__) && __LP64__ | 79 | #if defined (__LP64__) && __LP64__ |
| @@ -138,13 +88,13 @@ typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect; | |||
| 138 | 88 | ||
| 139 | #define NativeRectangle NSRect | 89 | #define NativeRectangle NSRect |
| 140 | 90 | ||
| 141 | #define CONVERT_TO_XRECT(xr, nr) \ | 91 | #define CONVERT_TO_EMACS_RECT(xr, nr) \ |
| 142 | ((xr).x = (nr).origin.x, \ | 92 | ((xr).x = (nr).origin.x, \ |
| 143 | (xr).y = (nr).origin.y, \ | 93 | (xr).y = (nr).origin.y, \ |
| 144 | (xr).width = (nr).size.width, \ | 94 | (xr).width = (nr).size.width, \ |
| 145 | (xr).height = (nr).size.height) | 95 | (xr).height = (nr).size.height) |
| 146 | 96 | ||
| 147 | #define CONVERT_FROM_XRECT(xr, nr) \ | 97 | #define CONVERT_FROM_EMACS_RECT(xr, nr) \ |
| 148 | ((nr).origin.x = (xr).x, \ | 98 | ((nr).origin.x = (xr).x, \ |
| 149 | (nr).origin.y = (xr).y, \ | 99 | (nr).origin.y = (xr).y, \ |
| 150 | (nr).size.width = (xr).width, \ | 100 | (nr).size.width = (xr).width, \ |
diff --git a/src/nsimage.m b/src/nsimage.m index 33236c48d42..0249d22acae 100644 --- a/src/nsimage.m +++ b/src/nsimage.m | |||
| @@ -313,8 +313,8 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) | |||
| 313 | if (bmRep == nil || color == nil) | 313 | if (bmRep == nil || color == nil) |
| 314 | return self; | 314 | return self; |
| 315 | 315 | ||
| 316 | if ([color colorSpaceName] != NSCalibratedRGBColorSpace) | 316 | if ([color colorSpace] != [NSColorSpace deviceRGBColorSpace]) |
| 317 | rgbColor = [color colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; | 317 | rgbColor = [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; |
| 318 | else | 318 | else |
| 319 | rgbColor = color; | 319 | rgbColor = color; |
| 320 | 320 | ||
diff --git a/src/nsmenu.m b/src/nsmenu.m index fd1323344b3..3fe06cda02a 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -668,9 +668,9 @@ ns_activate_menubar (struct frame *f) | |||
| 668 | /* Draw radio buttons and tickboxes. */ | 668 | /* Draw radio buttons and tickboxes. */ |
| 669 | if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE || | 669 | if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE || |
| 670 | wv->button_type == BUTTON_TYPE_RADIO)) | 670 | wv->button_type == BUTTON_TYPE_RADIO)) |
| 671 | [item setState: NSOnState]; | 671 | [item setState: NSControlStateValueOn]; |
| 672 | else | 672 | else |
| 673 | [item setState: NSOffState]; | 673 | [item setState: NSControlStateValueOff]; |
| 674 | 674 | ||
| 675 | [item setTag: (NSInteger)wv->call_data]; | 675 | [item setTag: (NSInteger)wv->call_data]; |
| 676 | } | 676 | } |
| @@ -1594,7 +1594,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) | |||
| 1594 | [cell setBordered: NO]; | 1594 | [cell setBordered: NO]; |
| 1595 | [cell setEnabled: NO]; | 1595 | [cell setEnabled: NO]; |
| 1596 | [cell setCellAttribute: NSCellIsInsetButton to: 8]; | 1596 | [cell setCellAttribute: NSCellIsInsetButton to: 8]; |
| 1597 | [cell setBezelStyle: NSRoundedBezelStyle]; | 1597 | [cell setBezelStyle: NSBezelStyleRounded]; |
| 1598 | 1598 | ||
| 1599 | matrix = [[NSMatrix alloc] initWithFrame: contentRect | 1599 | matrix = [[NSMatrix alloc] initWithFrame: contentRect |
| 1600 | mode: NSHighlightModeMatrix | 1600 | mode: NSHighlightModeMatrix |
| @@ -1607,7 +1607,6 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) | |||
| 1607 | [matrix autorelease]; | 1607 | [matrix autorelease]; |
| 1608 | 1608 | ||
| 1609 | [[self contentView] addSubview: matrix]; | 1609 | [[self contentView] addSubview: matrix]; |
| 1610 | [self setOneShot: YES]; | ||
| 1611 | [self setReleasedWhenClosed: YES]; | 1610 | [self setReleasedWhenClosed: YES]; |
| 1612 | [self setHidesOnDeactivate: YES]; | 1611 | [self setHidesOnDeactivate: YES]; |
| 1613 | return self; | 1612 | return self; |
diff --git a/src/nsselect.m b/src/nsselect.m index cf36c869eb1..b044fe6f32d 100644 --- a/src/nsselect.m +++ b/src/nsselect.m | |||
| @@ -57,7 +57,7 @@ symbol_to_nsstring (Lisp_Object sym) | |||
| 57 | if (EQ (sym, QCLIPBOARD)) return NSPasteboardNameGeneral; | 57 | if (EQ (sym, QCLIPBOARD)) return NSPasteboardNameGeneral; |
| 58 | if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; | 58 | if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; |
| 59 | if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; | 59 | if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; |
| 60 | if (EQ (sym, QTEXT)) return NSStringPboardType; | 60 | if (EQ (sym, QTEXT)) return NSPasteboardTypeString; |
| 61 | return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))]; | 61 | return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))]; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| @@ -76,11 +76,11 @@ ns_string_to_symbol (NSString *t) | |||
| 76 | return QPRIMARY; | 76 | return QPRIMARY; |
| 77 | if ([t isEqualToString: NXSecondaryPboard]) | 77 | if ([t isEqualToString: NXSecondaryPboard]) |
| 78 | return QSECONDARY; | 78 | return QSECONDARY; |
| 79 | if ([t isEqualToString: NSStringPboardType]) | 79 | if ([t isEqualToString: NSPasteboardTypeString]) |
| 80 | return QTEXT; | 80 | return QTEXT; |
| 81 | if ([t isEqualToString: NSFilenamesPboardType]) | 81 | if ([t isEqualToString: NSFilenamesPboardType]) |
| 82 | return QFILE_NAME; | 82 | return QFILE_NAME; |
| 83 | if ([t isEqualToString: NSTabularTextPboardType]) | 83 | if ([t isEqualToString: NSPasteboardTypeTabularText]) |
| 84 | return QTEXT; | 84 | return QTEXT; |
| 85 | return intern ([t UTF8String]); | 85 | return intern ([t UTF8String]); |
| 86 | } | 86 | } |
| @@ -193,7 +193,7 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype) | |||
| 193 | else | 193 | else |
| 194 | { | 194 | { |
| 195 | // Used for ns-own-selection-internal. | 195 | // Used for ns-own-selection-internal. |
| 196 | eassert (gtype == NSStringPboardType); | 196 | eassert (gtype == NSPasteboardTypeString); |
| 197 | [pb setString: nsStr forType: gtype]; | 197 | [pb setString: nsStr forType: gtype]; |
| 198 | } | 198 | } |
| 199 | [nsStr release]; | 199 | [nsStr release]; |
| @@ -345,7 +345,7 @@ anything that the functions on `selection-converter-alist' know about. */) | |||
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | /* We only support copy of text. */ | 347 | /* We only support copy of text. */ |
| 348 | type = NSStringPboardType; | 348 | type = NSPasteboardTypeString; |
| 349 | target_symbol = ns_string_to_symbol (type); | 349 | target_symbol = ns_string_to_symbol (type); |
| 350 | if (STRINGP (value)) | 350 | if (STRINGP (value)) |
| 351 | { | 351 | { |
| @@ -472,9 +472,9 @@ nxatoms_of_nsselect (void) | |||
| 472 | [NSNumber numberWithLong:0], NSPasteboardNameGeneral, | 472 | [NSNumber numberWithLong:0], NSPasteboardNameGeneral, |
| 473 | [NSNumber numberWithLong:0], NXPrimaryPboard, | 473 | [NSNumber numberWithLong:0], NXPrimaryPboard, |
| 474 | [NSNumber numberWithLong:0], NXSecondaryPboard, | 474 | [NSNumber numberWithLong:0], NXSecondaryPboard, |
| 475 | [NSNumber numberWithLong:0], NSStringPboardType, | 475 | [NSNumber numberWithLong:0], NSPasteboardTypeString, |
| 476 | [NSNumber numberWithLong:0], NSFilenamesPboardType, | 476 | [NSNumber numberWithLong:0], NSFilenamesPboardType, |
| 477 | [NSNumber numberWithLong:0], NSTabularTextPboardType, | 477 | [NSNumber numberWithLong:0], NSPasteboardTypeTabularText, |
| 478 | nil] retain]; | 478 | nil] retain]; |
| 479 | } | 479 | } |
| 480 | 480 | ||
diff --git a/src/nsterm.h b/src/nsterm.h index 683f2dd9341..1e56276ca3c 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -872,10 +872,10 @@ struct ns_display_info | |||
| 872 | Lisp_Object rdb; | 872 | Lisp_Object rdb; |
| 873 | 873 | ||
| 874 | /* The cursor to use for vertical scroll bars. */ | 874 | /* The cursor to use for vertical scroll bars. */ |
| 875 | Cursor vertical_scroll_bar_cursor; | 875 | Emacs_Cursor vertical_scroll_bar_cursor; |
| 876 | 876 | ||
| 877 | /* The cursor to use for horizontal scroll bars. */ | 877 | /* The cursor to use for horizontal scroll bars. */ |
| 878 | Cursor horizontal_scroll_bar_cursor; | 878 | Emacs_Cursor horizontal_scroll_bar_cursor; |
| 879 | 879 | ||
| 880 | /* Information about the range of text currently shown in | 880 | /* Information about the range of text currently shown in |
| 881 | mouse-face. */ | 881 | mouse-face. */ |
| @@ -931,24 +931,24 @@ struct ns_output | |||
| 931 | #endif | 931 | #endif |
| 932 | 932 | ||
| 933 | /* NSCursors are initialized in initFrameFromEmacs. */ | 933 | /* NSCursors are initialized in initFrameFromEmacs. */ |
| 934 | Cursor text_cursor; | 934 | Emacs_Cursor text_cursor; |
| 935 | Cursor nontext_cursor; | 935 | Emacs_Cursor nontext_cursor; |
| 936 | Cursor modeline_cursor; | 936 | Emacs_Cursor modeline_cursor; |
| 937 | Cursor hand_cursor; | 937 | Emacs_Cursor hand_cursor; |
| 938 | Cursor hourglass_cursor; | 938 | Emacs_Cursor hourglass_cursor; |
| 939 | Cursor horizontal_drag_cursor; | 939 | Emacs_Cursor horizontal_drag_cursor; |
| 940 | Cursor vertical_drag_cursor; | 940 | Emacs_Cursor vertical_drag_cursor; |
| 941 | Cursor left_edge_cursor; | 941 | Emacs_Cursor left_edge_cursor; |
| 942 | Cursor top_left_corner_cursor; | 942 | Emacs_Cursor top_left_corner_cursor; |
| 943 | Cursor top_edge_cursor; | 943 | Emacs_Cursor top_edge_cursor; |
| 944 | Cursor top_right_corner_cursor; | 944 | Emacs_Cursor top_right_corner_cursor; |
| 945 | Cursor right_edge_cursor; | 945 | Emacs_Cursor right_edge_cursor; |
| 946 | Cursor bottom_right_corner_cursor; | 946 | Emacs_Cursor bottom_right_corner_cursor; |
| 947 | Cursor bottom_edge_cursor; | 947 | Emacs_Cursor bottom_edge_cursor; |
| 948 | Cursor bottom_left_corner_cursor; | 948 | Emacs_Cursor bottom_left_corner_cursor; |
| 949 | 949 | ||
| 950 | /* NS-specific */ | 950 | /* NS-specific */ |
| 951 | Cursor current_pointer; | 951 | Emacs_Cursor current_pointer; |
| 952 | 952 | ||
| 953 | /* lord knows why Emacs needs to know about our Window ids.. */ | 953 | /* lord knows why Emacs needs to know about our Window ids.. */ |
| 954 | Window window_desc, parent_desc; | 954 | Window window_desc, parent_desc; |
| @@ -997,12 +997,6 @@ struct x_output | |||
| 997 | #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc) | 997 | #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc) |
| 998 | #define FRAME_NATIVE_WINDOW(f) FRAME_NS_WINDOW (f) | 998 | #define FRAME_NATIVE_WINDOW(f) FRAME_NS_WINDOW (f) |
| 999 | 999 | ||
| 1000 | /* This is the `Display *' which frame F is on. */ | ||
| 1001 | #define FRAME_NS_DISPLAY(f) (0) | ||
| 1002 | #define FRAME_X_DISPLAY(f) (0) | ||
| 1003 | #define FRAME_X_SCREEN(f) (0) | ||
| 1004 | #define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO(f)->visual | ||
| 1005 | |||
| 1006 | #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color) | 1000 | #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color) |
| 1007 | #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color) | 1001 | #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color) |
| 1008 | 1002 | ||
| @@ -1140,10 +1134,10 @@ extern void ns_set_doc_edited (void); | |||
| 1140 | extern bool | 1134 | extern bool |
| 1141 | ns_defined_color (struct frame *f, | 1135 | ns_defined_color (struct frame *f, |
| 1142 | const char *name, | 1136 | const char *name, |
| 1143 | XColor *color_def, bool alloc, | 1137 | Emacs_Color *color_def, bool alloc, |
| 1144 | bool makeIndex); | 1138 | bool makeIndex); |
| 1145 | extern void | 1139 | extern void |
| 1146 | ns_query_color (void *col, XColor *color_def, bool setPixel); | 1140 | ns_query_color (void *col, Emacs_Color *color_def, bool setPixel); |
| 1147 | 1141 | ||
| 1148 | #ifdef __OBJC__ | 1142 | #ifdef __OBJC__ |
| 1149 | extern int ns_lisp_to_color (Lisp_Object color, NSColor **col); | 1143 | extern int ns_lisp_to_color (Lisp_Object color, NSColor **col); |
| @@ -1171,10 +1165,6 @@ extern void ns_release_autorelease_pool (void *); | |||
| 1171 | extern const char *ns_get_defaults_value (const char *key); | 1165 | extern const char *ns_get_defaults_value (const char *key); |
| 1172 | extern void ns_init_locale (void); | 1166 | extern void ns_init_locale (void); |
| 1173 | 1167 | ||
| 1174 | #ifdef NS_IMPL_COCOA | ||
| 1175 | extern void ns_enable_screen_updates (void); | ||
| 1176 | #endif | ||
| 1177 | |||
| 1178 | /* in nsmenu */ | 1168 | /* in nsmenu */ |
| 1179 | extern void update_frame_tool_bar (struct frame *f); | 1169 | extern void update_frame_tool_bar (struct frame *f); |
| 1180 | extern void free_frame_tool_bar (struct frame *f); | 1170 | extern void free_frame_tool_bar (struct frame *f); |
| @@ -1342,4 +1332,14 @@ enum NSWindowTabbingMode | |||
| 1342 | /* Deprecated in macOS 10.13. */ | 1332 | /* Deprecated in macOS 10.13. */ |
| 1343 | #define NSPasteboardNameGeneral NSGeneralPboard | 1333 | #define NSPasteboardNameGeneral NSGeneralPboard |
| 1344 | #endif | 1334 | #endif |
| 1335 | |||
| 1336 | #if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_14) | ||
| 1337 | /* Deprecated in macOS 10.14. */ | ||
| 1338 | #define NSPasteboardTypeString NSStringPboardType | ||
| 1339 | #define NSPasteboardTypeTabularText NSTabularTextPboardType | ||
| 1340 | #define NSPasteboardTypeURL NSURLPboardType | ||
| 1341 | #define NSControlStateValueOn NSOnState | ||
| 1342 | #define NSControlStateValueOff NSOffState | ||
| 1343 | #define NSBezelStyleRounded NSRoundedBezelStyle | ||
| 1344 | #endif | ||
| 1345 | #endif /* HAVE_NS */ | 1345 | #endif /* HAVE_NS */ |
diff --git a/src/nsterm.m b/src/nsterm.m index cdf1916e71b..0cae5e9d448 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -160,20 +160,28 @@ char const * nstrace_fullscreen_type_name (int fs_type) | |||
| 160 | 160 | ||
| 161 | - (NSColor *)colorUsingDefaultColorSpace | 161 | - (NSColor *)colorUsingDefaultColorSpace |
| 162 | { | 162 | { |
| 163 | /* FIXMES: We're checking for colorWithSRGBRed here so this will | 163 | /* FIXME: We're checking for colorWithSRGBRed here so this will only |
| 164 | only work in the same place as in the method above. It should | 164 | work in the same place as in the method above. It should really |
| 165 | really be a check whether we're on macOS 10.7 or above. */ | 165 | be a check whether we're on macOS 10.7 or above. */ |
| 166 | #if defined (NS_IMPL_COCOA) \ | 166 | #if defined (NS_IMPL_COCOA) \ |
| 167 | && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | 167 | && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 |
| 168 | if (ns_use_srgb_colorspace | ||
| 169 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | 168 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 |
| 170 | && [NSColor respondsToSelector: | 169 | if ([NSColor respondsToSelector: |
| 171 | @selector(colorWithSRGBRed:green:blue:alpha:)] | 170 | @selector(colorWithSRGBRed:green:blue:alpha:)]) |
| 172 | #endif | 171 | #endif |
| 173 | ) | 172 | { |
| 174 | return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]]; | 173 | if (ns_use_srgb_colorspace) |
| 174 | return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]]; | ||
| 175 | else | ||
| 176 | return [self colorUsingColorSpace: [NSColorSpace deviceRGBColorSpace]]; | ||
| 177 | } | ||
| 178 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | ||
| 179 | else | ||
| 175 | #endif | 180 | #endif |
| 181 | #endif /* NS_IMPL_COCOA && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */ | ||
| 182 | #if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | ||
| 176 | return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; | 183 | return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; |
| 184 | #endif | ||
| 177 | } | 185 | } |
| 178 | 186 | ||
| 179 | @end | 187 | @end |
| @@ -283,9 +291,6 @@ static int ns_window_num = 0; | |||
| 283 | static BOOL ns_fake_keydown = NO; | 291 | static BOOL ns_fake_keydown = NO; |
| 284 | #ifdef NS_IMPL_COCOA | 292 | #ifdef NS_IMPL_COCOA |
| 285 | static BOOL ns_menu_bar_is_hidden = NO; | 293 | static BOOL ns_menu_bar_is_hidden = NO; |
| 286 | |||
| 287 | /* The number of times NSDisableScreenUpdates has been called. */ | ||
| 288 | static int disable_screen_updates_count = 0; | ||
| 289 | #endif | 294 | #endif |
| 290 | /* static int debug_lock = 0; */ | 295 | /* static int debug_lock = 0; */ |
| 291 | 296 | ||
| @@ -688,40 +693,6 @@ ns_release_autorelease_pool (void *pool) | |||
| 688 | } | 693 | } |
| 689 | 694 | ||
| 690 | 695 | ||
| 691 | #ifdef NS_IMPL_COCOA | ||
| 692 | /* Disabling screen updates can be used to make several actions appear | ||
| 693 | "atomic" to the end user. It seems some actions can still update | ||
| 694 | the display, though. | ||
| 695 | |||
| 696 | When we re-enable screen updates the number of calls to | ||
| 697 | NSEnableScreenUpdates should match the number to | ||
| 698 | NSDisableScreenUpdates. | ||
| 699 | |||
| 700 | We use these functions to prevent the user seeing a blank frame | ||
| 701 | after it has been resized. ns_set_window_size disables updates and | ||
| 702 | when redisplay completes unwind_redisplay enables them again | ||
| 703 | (bug#30699). */ | ||
| 704 | |||
| 705 | static void | ||
| 706 | ns_disable_screen_updates (void) | ||
| 707 | { | ||
| 708 | NSDisableScreenUpdates (); | ||
| 709 | disable_screen_updates_count++; | ||
| 710 | } | ||
| 711 | |||
| 712 | void | ||
| 713 | ns_enable_screen_updates (void) | ||
| 714 | /* Re-enable screen updates. Called from unwind_redisplay. */ | ||
| 715 | { | ||
| 716 | while (disable_screen_updates_count > 0) | ||
| 717 | { | ||
| 718 | NSEnableScreenUpdates (); | ||
| 719 | disable_screen_updates_count--; | ||
| 720 | } | ||
| 721 | } | ||
| 722 | #endif | ||
| 723 | |||
| 724 | |||
| 725 | static BOOL | 696 | static BOOL |
| 726 | ns_menu_bar_should_be_hidden (void) | 697 | ns_menu_bar_should_be_hidden (void) |
| 727 | /* True, if the menu bar should be hidden. */ | 698 | /* True, if the menu bar should be hidden. */ |
| @@ -1106,7 +1077,7 @@ static void | |||
| 1106 | ns_update_begin (struct frame *f) | 1077 | ns_update_begin (struct frame *f) |
| 1107 | /* -------------------------------------------------------------------------- | 1078 | /* -------------------------------------------------------------------------- |
| 1108 | Prepare for a grouped sequence of drawing calls | 1079 | Prepare for a grouped sequence of drawing calls |
| 1109 | external (RIF) call; whole frame, called before update_window_begin | 1080 | external (RIF) call; whole frame, called before gui_update_window_begin |
| 1110 | -------------------------------------------------------------------------- */ | 1081 | -------------------------------------------------------------------------- */ |
| 1111 | { | 1082 | { |
| 1112 | #ifdef NS_IMPL_COCOA | 1083 | #ifdef NS_IMPL_COCOA |
| @@ -1129,80 +1100,10 @@ ns_update_begin (struct frame *f) | |||
| 1129 | 1100 | ||
| 1130 | 1101 | ||
| 1131 | static void | 1102 | static void |
| 1132 | ns_update_window_begin (struct window *w) | ||
| 1133 | /* -------------------------------------------------------------------------- | ||
| 1134 | Prepare for a grouped sequence of drawing calls | ||
| 1135 | external (RIF) call; for one window, called after update_begin | ||
| 1136 | -------------------------------------------------------------------------- */ | ||
| 1137 | { | ||
| 1138 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | ||
| 1139 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | ||
| 1140 | |||
| 1141 | NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_window_begin"); | ||
| 1142 | w->output_cursor = w->cursor; | ||
| 1143 | |||
| 1144 | block_input (); | ||
| 1145 | |||
| 1146 | if (f == hlinfo->mouse_face_mouse_frame) | ||
| 1147 | { | ||
| 1148 | /* Don't do highlighting for mouse motion during the update. */ | ||
| 1149 | hlinfo->mouse_face_defer = 1; | ||
| 1150 | |||
| 1151 | /* If the frame needs to be redrawn, | ||
| 1152 | simply forget about any prior mouse highlighting. */ | ||
| 1153 | if (FRAME_GARBAGED_P (f)) | ||
| 1154 | hlinfo->mouse_face_window = Qnil; | ||
| 1155 | |||
| 1156 | /* (further code for mouse faces ifdef'd out in other terms elided) */ | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | unblock_input (); | ||
| 1160 | } | ||
| 1161 | |||
| 1162 | |||
| 1163 | static void | ||
| 1164 | ns_update_window_end (struct window *w, bool cursor_on_p, | ||
| 1165 | bool mouse_face_overwritten_p) | ||
| 1166 | /* -------------------------------------------------------------------------- | ||
| 1167 | Finished a grouped sequence of drawing calls | ||
| 1168 | external (RIF) call; for one window called before update_end | ||
| 1169 | -------------------------------------------------------------------------- */ | ||
| 1170 | { | ||
| 1171 | NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_window_end"); | ||
| 1172 | |||
| 1173 | /* note: this fn is nearly identical in all terms */ | ||
| 1174 | if (!w->pseudo_window_p) | ||
| 1175 | { | ||
| 1176 | block_input (); | ||
| 1177 | |||
| 1178 | if (cursor_on_p) | ||
| 1179 | display_and_set_cursor (w, 1, | ||
| 1180 | w->output_cursor.hpos, w->output_cursor.vpos, | ||
| 1181 | w->output_cursor.x, w->output_cursor.y); | ||
| 1182 | |||
| 1183 | if (draw_window_fringes (w, 1)) | ||
| 1184 | { | ||
| 1185 | if (WINDOW_RIGHT_DIVIDER_WIDTH (w)) | ||
| 1186 | gui_draw_right_divider (w); | ||
| 1187 | else | ||
| 1188 | gui_draw_vertical_border (w); | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | unblock_input (); | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | /* If a row with mouse-face was overwritten, arrange for | ||
| 1195 | frame_up_to_date to redisplay the mouse highlight. */ | ||
| 1196 | if (mouse_face_overwritten_p) | ||
| 1197 | reset_mouse_highlight (MOUSE_HL_INFO (XFRAME (w->frame))); | ||
| 1198 | } | ||
| 1199 | |||
| 1200 | |||
| 1201 | static void | ||
| 1202 | ns_update_end (struct frame *f) | 1103 | ns_update_end (struct frame *f) |
| 1203 | /* -------------------------------------------------------------------------- | 1104 | /* -------------------------------------------------------------------------- |
| 1204 | Finished a grouped sequence of drawing calls | 1105 | Finished a grouped sequence of drawing calls |
| 1205 | external (RIF) call; for whole frame, called after update_window_end | 1106 | external (RIF) call; for whole frame, called after gui_update_window_end |
| 1206 | -------------------------------------------------------------------------- */ | 1107 | -------------------------------------------------------------------------- */ |
| 1207 | { | 1108 | { |
| 1208 | NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_end"); | 1109 | NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_end"); |
| @@ -1849,15 +1750,6 @@ ns_set_window_size (struct frame *f, | |||
| 1849 | 1750 | ||
| 1850 | block_input (); | 1751 | block_input (); |
| 1851 | 1752 | ||
| 1852 | #ifdef NS_IMPL_COCOA | ||
| 1853 | /* To prevent showing the user a blank frame, stop updates being | ||
| 1854 | flushed to the screen until after redisplay has completed. This | ||
| 1855 | breaks live resize (resizing with a mouse), so don't do it if | ||
| 1856 | we're in a live resize loop. */ | ||
| 1857 | if (![view inLiveResize]) | ||
| 1858 | ns_disable_screen_updates (); | ||
| 1859 | #endif | ||
| 1860 | |||
| 1861 | if (pixelwise) | 1753 | if (pixelwise) |
| 1862 | { | 1754 | { |
| 1863 | pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width); | 1755 | pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width); |
| @@ -2397,7 +2289,7 @@ ns_color_index_to_rgba(int idx, struct frame *f) | |||
| 2397 | } | 2289 | } |
| 2398 | 2290 | ||
| 2399 | void | 2291 | void |
| 2400 | ns_query_color(void *col, XColor *color_def, bool setPixel) | 2292 | ns_query_color(void *col, Emacs_Color *color_def, bool setPixel) |
| 2401 | /* -------------------------------------------------------------------------- | 2293 | /* -------------------------------------------------------------------------- |
| 2402 | Get ARGB values out of NSColor col and put them into color_def. | 2294 | Get ARGB values out of NSColor col and put them into color_def. |
| 2403 | If setPixel, set the pixel to a concatenated version. | 2295 | If setPixel, set the pixel to a concatenated version. |
| @@ -2420,7 +2312,7 @@ ns_query_color(void *col, XColor *color_def, bool setPixel) | |||
| 2420 | bool | 2312 | bool |
| 2421 | ns_defined_color (struct frame *f, | 2313 | ns_defined_color (struct frame *f, |
| 2422 | const char *name, | 2314 | const char *name, |
| 2423 | XColor *color_def, | 2315 | Emacs_Color *color_def, |
| 2424 | bool alloc, | 2316 | bool alloc, |
| 2425 | bool makeIndex) | 2317 | bool makeIndex) |
| 2426 | /* -------------------------------------------------------------------------- | 2318 | /* -------------------------------------------------------------------------- |
| @@ -2448,7 +2340,7 @@ ns_defined_color (struct frame *f, | |||
| 2448 | } | 2340 | } |
| 2449 | 2341 | ||
| 2450 | static void | 2342 | static void |
| 2451 | ns_query_frame_background_color (struct frame *f, XColor *bgcolor) | 2343 | ns_query_frame_background_color (struct frame *f, Emacs_Color *bgcolor) |
| 2452 | /* -------------------------------------------------------------------------- | 2344 | /* -------------------------------------------------------------------------- |
| 2453 | External (hook): Store F's background color into *BGCOLOR | 2345 | External (hook): Store F's background color into *BGCOLOR |
| 2454 | -------------------------------------------------------------------------- */ | 2346 | -------------------------------------------------------------------------- */ |
| @@ -2585,8 +2477,7 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, | |||
| 2585 | 2477 | ||
| 2586 | /* Clear the mouse-moved flag for every frame on this display. */ | 2478 | /* Clear the mouse-moved flag for every frame on this display. */ |
| 2587 | FOR_EACH_FRAME (tail, frame) | 2479 | FOR_EACH_FRAME (tail, frame) |
| 2588 | if (FRAME_NS_P (XFRAME (frame)) | 2480 | if (FRAME_NS_P (XFRAME (frame))) |
| 2589 | && FRAME_NS_DISPLAY (XFRAME (frame)) == FRAME_NS_DISPLAY (*fp)) | ||
| 2590 | XFRAME (frame)->mouse_moved = 0; | 2481 | XFRAME (frame)->mouse_moved = 0; |
| 2591 | 2482 | ||
| 2592 | dpyinfo->last_mouse_scroll_bar = nil; | 2483 | dpyinfo->last_mouse_scroll_bar = nil; |
| @@ -2647,7 +2538,7 @@ ns_frame_up_to_date (struct frame *f) | |||
| 2647 | 2538 | ||
| 2648 | 2539 | ||
| 2649 | static void | 2540 | static void |
| 2650 | ns_define_frame_cursor (struct frame *f, Cursor cursor) | 2541 | ns_define_frame_cursor (struct frame *f, Emacs_Cursor cursor) |
| 2651 | /* -------------------------------------------------------------------------- | 2542 | /* -------------------------------------------------------------------------- |
| 2652 | External (RIF): set frame mouse pointer type. | 2543 | External (RIF): set frame mouse pointer type. |
| 2653 | -------------------------------------------------------------------------- */ | 2544 | -------------------------------------------------------------------------- */ |
| @@ -5038,6 +4929,18 @@ ns_judge_scroll_bars (struct frame *f) | |||
| 5038 | 4929 | ||
| 5039 | /* ========================================================================== | 4930 | /* ========================================================================== |
| 5040 | 4931 | ||
| 4932 | Image Hooks | ||
| 4933 | |||
| 4934 | ========================================================================== */ | ||
| 4935 | |||
| 4936 | static void | ||
| 4937 | ns_free_pixmap (struct frame *_f, Emacs_Pixmap pixmap) | ||
| 4938 | { | ||
| 4939 | ns_release_object (pixmap); | ||
| 4940 | } | ||
| 4941 | |||
| 4942 | /* ========================================================================== | ||
| 4943 | |||
| 5041 | Initialization | 4944 | Initialization |
| 5042 | 4945 | ||
| 5043 | ========================================================================== */ | 4946 | ========================================================================== */ |
| @@ -5166,8 +5069,8 @@ static struct redisplay_interface ns_redisplay_interface = | |||
| 5166 | gui_clear_end_of_line, | 5069 | gui_clear_end_of_line, |
| 5167 | ns_scroll_run, | 5070 | ns_scroll_run, |
| 5168 | ns_after_update_window_line, | 5071 | ns_after_update_window_line, |
| 5169 | ns_update_window_begin, | 5072 | NULL, /* update_window_begin */ |
| 5170 | ns_update_window_end, | 5073 | NULL, /* update_window_end */ |
| 5171 | 0, /* flush_display */ | 5074 | 0, /* flush_display */ |
| 5172 | gui_clear_window_mouse_face, | 5075 | gui_clear_window_mouse_face, |
| 5173 | gui_get_glyph_overhangs, | 5076 | gui_get_glyph_overhangs, |
| @@ -5266,6 +5169,7 @@ ns_create_terminal (struct ns_display_info *dpyinfo) | |||
| 5266 | terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar; | 5169 | terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar; |
| 5267 | terminal->judge_scroll_bars_hook = ns_judge_scroll_bars; | 5170 | terminal->judge_scroll_bars_hook = ns_judge_scroll_bars; |
| 5268 | terminal->get_string_resource_hook = ns_get_string_resource; | 5171 | terminal->get_string_resource_hook = ns_get_string_resource; |
| 5172 | terminal->free_pixmap = ns_free_pixmap; | ||
| 5269 | terminal->delete_frame_hook = ns_destroy_window; | 5173 | terminal->delete_frame_hook = ns_destroy_window; |
| 5270 | terminal->delete_terminal_hook = ns_delete_terminal; | 5174 | terminal->delete_terminal_hook = ns_delete_terminal; |
| 5271 | /* Other hooks are NULL by default. */ | 5175 | /* Other hooks are NULL by default. */ |
| @@ -5517,14 +5421,14 @@ ns_term_init (Lisp_Object display_name) | |||
| 5517 | 5421 | ||
| 5518 | NSTRACE_MSG ("Input/output types"); | 5422 | NSTRACE_MSG ("Input/output types"); |
| 5519 | 5423 | ||
| 5520 | ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain]; | 5424 | ns_send_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil] retain]; |
| 5521 | ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] | 5425 | ns_return_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil] |
| 5522 | retain]; | 5426 | retain]; |
| 5523 | ns_drag_types = [[NSArray arrayWithObjects: | 5427 | ns_drag_types = [[NSArray arrayWithObjects: |
| 5524 | NSStringPboardType, | 5428 | NSPasteboardTypeString, |
| 5525 | NSTabularTextPboardType, | 5429 | NSPasteboardTypeTabularText, |
| 5526 | NSFilenamesPboardType, | 5430 | NSFilenamesPboardType, |
| 5527 | NSURLPboardType, nil] retain]; | 5431 | NSPasteboardTypeURL, nil] retain]; |
| 5528 | 5432 | ||
| 5529 | /* If fullscreen is in init/default-frame-alist, focus isn't set | 5433 | /* If fullscreen is in init/default-frame-alist, focus isn't set |
| 5530 | right for fullscreen windows, so set this. */ | 5434 | right for fullscreen windows, so set this. */ |
| @@ -8334,6 +8238,9 @@ not_in_argv (NSString *arg) | |||
| 8334 | { | 8238 | { |
| 8335 | return NO; | 8239 | return NO; |
| 8336 | } | 8240 | } |
| 8241 | /* FIXME: NSFilenamesPboardType is deprecated in 10.14, but the | ||
| 8242 | NSURL method can only handle one file at a time. Stick with the | ||
| 8243 | existing code at the moment. */ | ||
| 8337 | else if ([type isEqualToString: NSFilenamesPboardType]) | 8244 | else if ([type isEqualToString: NSFilenamesPboardType]) |
| 8338 | { | 8245 | { |
| 8339 | NSArray *files; | 8246 | NSArray *files; |
| @@ -8428,8 +8335,8 @@ not_in_argv (NSString *arg) | |||
| 8428 | 8335 | ||
| 8429 | NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]"); | 8336 | NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]"); |
| 8430 | 8337 | ||
| 8431 | /* We only support NSStringPboardType. */ | 8338 | /* We only support NSPasteboardTypeString. */ |
| 8432 | if ([types containsObject:NSStringPboardType] == NO) { | 8339 | if ([types containsObject:NSPasteboardTypeString] == NO) { |
| 8433 | return NO; | 8340 | return NO; |
| 8434 | } | 8341 | } |
| 8435 | 8342 | ||
| @@ -8443,7 +8350,7 @@ not_in_argv (NSString *arg) | |||
| 8443 | if (! STRINGP (val)) | 8350 | if (! STRINGP (val)) |
| 8444 | return NO; | 8351 | return NO; |
| 8445 | 8352 | ||
| 8446 | typesDeclared = [NSArray arrayWithObject:NSStringPboardType]; | 8353 | typesDeclared = [NSArray arrayWithObject:NSPasteboardTypeString]; |
| 8447 | [pb declareTypes:typesDeclared owner:nil]; | 8354 | [pb declareTypes:typesDeclared owner:nil]; |
| 8448 | ns_string_to_pasteboard (pb, val); | 8355 | ns_string_to_pasteboard (pb, val); |
| 8449 | return YES; | 8356 | return YES; |
| @@ -9105,10 +9012,12 @@ not_in_argv (NSString *arg) | |||
| 9105 | last_hit_part = horizontal ? scroll_bar_before_handle : scroll_bar_above_handle; break; | 9012 | last_hit_part = horizontal ? scroll_bar_before_handle : scroll_bar_above_handle; break; |
| 9106 | case NSScrollerIncrementPage: | 9013 | case NSScrollerIncrementPage: |
| 9107 | last_hit_part = horizontal ? scroll_bar_after_handle : scroll_bar_below_handle; break; | 9014 | last_hit_part = horizontal ? scroll_bar_after_handle : scroll_bar_below_handle; break; |
| 9015 | #if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | ||
| 9108 | case NSScrollerDecrementLine: | 9016 | case NSScrollerDecrementLine: |
| 9109 | last_hit_part = horizontal ? scroll_bar_left_arrow : scroll_bar_up_arrow; break; | 9017 | last_hit_part = horizontal ? scroll_bar_left_arrow : scroll_bar_up_arrow; break; |
| 9110 | case NSScrollerIncrementLine: | 9018 | case NSScrollerIncrementLine: |
| 9111 | last_hit_part = horizontal ? scroll_bar_right_arrow : scroll_bar_down_arrow; break; | 9019 | last_hit_part = horizontal ? scroll_bar_right_arrow : scroll_bar_down_arrow; break; |
| 9020 | #endif | ||
| 9112 | case NSScrollerKnob: | 9021 | case NSScrollerKnob: |
| 9113 | last_hit_part = horizontal ? scroll_bar_horizontal_handle : scroll_bar_handle; break; | 9022 | last_hit_part = horizontal ? scroll_bar_horizontal_handle : scroll_bar_handle; break; |
| 9114 | case NSScrollerKnobSlot: /* GNUstep-only */ | 9023 | case NSScrollerKnobSlot: /* GNUstep-only */ |
diff --git a/src/print.c b/src/print.c index 68ed6781c81..406abbf4a3f 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1361,6 +1361,19 @@ print_prune_string_charset (Lisp_Object string) | |||
| 1361 | return string; | 1361 | return string; |
| 1362 | } | 1362 | } |
| 1363 | 1363 | ||
| 1364 | #ifdef HAVE_MODULES | ||
| 1365 | /* Return a data pointer equal to FUNCPTR. */ | ||
| 1366 | |||
| 1367 | static void const * | ||
| 1368 | data_from_funcptr (void (*funcptr) (void)) | ||
| 1369 | { | ||
| 1370 | /* The module code, and the POSIX API for dynamic linking, already | ||
| 1371 | assume that function and data pointers are represented | ||
| 1372 | interchangeably, so it's OK to assume that here too. */ | ||
| 1373 | return (void const *) funcptr; | ||
| 1374 | } | ||
| 1375 | #endif | ||
| 1376 | |||
| 1364 | static bool | 1377 | static bool |
| 1365 | print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | 1378 | print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, |
| 1366 | char *buf) | 1379 | char *buf) |
| @@ -1788,23 +1801,20 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1788 | { | 1801 | { |
| 1789 | print_c_string ("#<module function ", printcharfun); | 1802 | print_c_string ("#<module function ", printcharfun); |
| 1790 | module_funcptr ptr = module_function_address (XMODULE_FUNCTION (obj)); | 1803 | module_funcptr ptr = module_function_address (XMODULE_FUNCTION (obj)); |
| 1791 | const char *file = NULL; | 1804 | char const *file; |
| 1792 | const char *symbol = NULL; | 1805 | char const *symbol; |
| 1793 | dynlib_addr (ptr, &file, &symbol); | 1806 | dynlib_addr (ptr, &file, &symbol); |
| 1794 | 1807 | ||
| 1795 | if (symbol == NULL) | 1808 | if (symbol == NULL) |
| 1796 | { | 1809 | { |
| 1797 | print_c_string ("at ", printcharfun); | 1810 | uintptr_t ui = (uintptr_t) data_from_funcptr (ptr); |
| 1798 | enum { pointer_bufsize = sizeof ptr * 16 / CHAR_BIT + 2 + 1 }; | 1811 | |
| 1799 | char buffer[pointer_bufsize]; | 1812 | /* In theory this assignment could lose info on pre-C99 |
| 1800 | int needed = snprintf (buffer, sizeof buffer, "%p", ptr); | 1813 | hosts, but in practice it doesn't. */ |
| 1801 | const char p0x[] = "0x"; | 1814 | uprintmax_t up = ui; |
| 1802 | eassert (needed <= sizeof buffer); | 1815 | |
| 1803 | /* ANSI C doesn't guarantee that %p produces a string that | 1816 | int len = sprintf (buf, "at 0x%"pMx, up); |
| 1804 | begins with a "0x". */ | 1817 | strout (buf, len, len, printcharfun); |
| 1805 | if (c_strncasecmp (buffer, p0x, sizeof (p0x) - 1) != 0) | ||
| 1806 | print_c_string (p0x, printcharfun); | ||
| 1807 | print_c_string (buffer, printcharfun); | ||
| 1808 | } | 1818 | } |
| 1809 | else | 1819 | else |
| 1810 | print_c_string (symbol, printcharfun); | 1820 | print_c_string (symbol, printcharfun); |
| @@ -1832,7 +1842,9 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 1832 | { | 1842 | { |
| 1833 | char buf[max (sizeof "from..to..in " + 2 * INT_STRLEN_BOUND (EMACS_INT), | 1843 | char buf[max (sizeof "from..to..in " + 2 * INT_STRLEN_BOUND (EMACS_INT), |
| 1834 | max (sizeof " . #" + INT_STRLEN_BOUND (printmax_t), | 1844 | max (sizeof " . #" + INT_STRLEN_BOUND (printmax_t), |
| 1835 | 40))]; | 1845 | max ((sizeof "at 0x" |
| 1846 | + (sizeof (uprintmax_t) * CHAR_BIT + 4 - 1) / 4), | ||
| 1847 | 40)))]; | ||
| 1836 | current_thread->stack_top = buf; | 1848 | current_thread->stack_top = buf; |
| 1837 | maybe_quit (); | 1849 | maybe_quit (); |
| 1838 | 1850 | ||
diff --git a/src/search.c b/src/search.c index dfbae5c9628..8a0f707b723 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -1324,12 +1324,7 @@ search_buffer_non_re (Lisp_Object string, ptrdiff_t pos, | |||
| 1324 | } | 1324 | } |
| 1325 | else | 1325 | else |
| 1326 | { | 1326 | { |
| 1327 | /* Converting multibyte to single-byte. | 1327 | /* Converting multibyte to single-byte. */ |
| 1328 | |||
| 1329 | ??? Perhaps this conversion should be done in a special way | ||
| 1330 | by subtracting nonascii-insert-offset from each non-ASCII char, | ||
| 1331 | so that only the multibyte chars which really correspond to | ||
| 1332 | the chosen single-byte character set can possibly match. */ | ||
| 1333 | raw_pattern_size = SCHARS (string); | 1328 | raw_pattern_size = SCHARS (string); |
| 1334 | raw_pattern_size_byte = SCHARS (string); | 1329 | raw_pattern_size_byte = SCHARS (string); |
| 1335 | raw_pattern = SAFE_ALLOCA (raw_pattern_size + 1); | 1330 | raw_pattern = SAFE_ALLOCA (raw_pattern_size + 1); |
diff --git a/src/termhooks.h b/src/termhooks.h index 54f09e03033..f1827128f19 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -496,7 +496,7 @@ struct terminal | |||
| 496 | 496 | ||
| 497 | If MAKEINDEX (on NS), set COLOR_DEF pixel to ARGB. */ | 497 | If MAKEINDEX (on NS), set COLOR_DEF pixel to ARGB. */ |
| 498 | bool (*defined_color_hook) (struct frame *f, const char *color_name, | 498 | bool (*defined_color_hook) (struct frame *f, const char *color_name, |
| 499 | XColor *color_def, | 499 | Emacs_Color *color_def, |
| 500 | bool alloc, | 500 | bool alloc, |
| 501 | bool makeIndex); | 501 | bool makeIndex); |
| 502 | 502 | ||
| @@ -515,13 +515,13 @@ struct terminal | |||
| 515 | 515 | ||
| 516 | /* This hook is called to store the frame's background color into | 516 | /* This hook is called to store the frame's background color into |
| 517 | BGCOLOR. */ | 517 | BGCOLOR. */ |
| 518 | void (*query_frame_background_color) (struct frame *f, XColor *bgcolor); | 518 | void (*query_frame_background_color) (struct frame *f, Emacs_Color *bgcolor); |
| 519 | 519 | ||
| 520 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) | 520 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) |
| 521 | /* On frame F, translate pixel colors to RGB values for the NCOLORS | 521 | /* On frame F, translate pixel colors to RGB values for the NCOLORS |
| 522 | colors in COLORS. Use cached information, if available. */ | 522 | colors in COLORS. Use cached information, if available. */ |
| 523 | 523 | ||
| 524 | void (*query_colors) (struct frame *f, XColor *colors, int ncolors); | 524 | void (*query_colors) (struct frame *f, Emacs_Color *colors, int ncolors); |
| 525 | #endif | 525 | #endif |
| 526 | /* Return the current position of the mouse. | 526 | /* Return the current position of the mouse. |
| 527 | 527 | ||
| @@ -741,6 +741,15 @@ struct terminal | |||
| 741 | const char *name, | 741 | const char *name, |
| 742 | const char *class); | 742 | const char *class); |
| 743 | 743 | ||
| 744 | /* Image hooks */ | ||
| 745 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 746 | /* Free the pixmap PIXMAP on F. */ | ||
| 747 | void (*free_pixmap) (struct frame *f, Emacs_Pixmap pixmap); | ||
| 748 | |||
| 749 | #endif | ||
| 750 | |||
| 751 | /* Deletion hooks */ | ||
| 752 | |||
| 744 | /* Called to delete the device-specific portions of a frame that is | 753 | /* Called to delete the device-specific portions of a frame that is |
| 745 | on this terminal device. */ | 754 | on this terminal device. */ |
| 746 | void (*delete_frame_hook) (struct frame *); | 755 | void (*delete_frame_hook) (struct frame *); |
diff --git a/src/timefns.c b/src/timefns.c index 5005c73b7fc..7b5af6a5d24 100644 --- a/src/timefns.c +++ b/src/timefns.c | |||
| @@ -1488,10 +1488,11 @@ usage: (encode-time &optional TIME FORM &rest OBSOLESCENT-ARGUMENTS) */) | |||
| 1488 | tm.tm_mon = check_tm_member (XCAR (a), 1); a = XCDR (a); | 1488 | tm.tm_mon = check_tm_member (XCAR (a), 1); a = XCDR (a); |
| 1489 | tm.tm_year = check_tm_member (XCAR (a), TM_YEAR_BASE); a = XCDR (a); | 1489 | tm.tm_year = check_tm_member (XCAR (a), TM_YEAR_BASE); a = XCDR (a); |
| 1490 | a = XCDR (a); | 1490 | a = XCDR (a); |
| 1491 | if (SYMBOLP (XCAR (a))) | 1491 | Lisp_Object dstflag = XCAR (a); |
| 1492 | tm.tm_isdst = !NILP (XCAR (a)); | ||
| 1493 | a = XCDR (a); | 1492 | a = XCDR (a); |
| 1494 | zone = XCAR (a); | 1493 | zone = XCAR (a); |
| 1494 | if (SYMBOLP (dstflag) && !FIXNUMP (zone) && !CONSP (zone)) | ||
| 1495 | tm.tm_isdst = !NILP (dstflag); | ||
| 1495 | } | 1496 | } |
| 1496 | else if (nargs < 6) | 1497 | else if (nargs < 6) |
| 1497 | xsignal2 (Qwrong_number_of_arguments, Qencode_time, make_fixnum (nargs)); | 1498 | xsignal2 (Qwrong_number_of_arguments, Qencode_time, make_fixnum (nargs)); |
| @@ -2003,6 +2003,13 @@ getloadavg (double loadavg[], int nelem) | |||
| 2003 | loadavg[elem] = avg; | 2003 | loadavg[elem] = avg; |
| 2004 | } | 2004 | } |
| 2005 | 2005 | ||
| 2006 | /* Always return at least one element, otherwise load-average | ||
| 2007 | returns nil, and Lisp programs might decide we cannot measure | ||
| 2008 | system load. For example, jit-lock-stealth-load's defcustom | ||
| 2009 | might decide that feature is "unsupported". */ | ||
| 2010 | if (elem == 0) | ||
| 2011 | loadavg[elem++] = 0.09; /* < display-time-load-average-threshold */ | ||
| 2012 | |||
| 2006 | return elem; | 2013 | return elem; |
| 2007 | } | 2014 | } |
| 2008 | 2015 | ||
| @@ -2644,7 +2651,7 @@ unsetenv (const char *name) | |||
| 2644 | /* It is safe to use 'alloca' with 32K size, since the stack is at | 2651 | /* It is safe to use 'alloca' with 32K size, since the stack is at |
| 2645 | least 2MB, and we set it to 8MB in the link command line. */ | 2652 | least 2MB, and we set it to 8MB in the link command line. */ |
| 2646 | var = alloca (name_len + 2); | 2653 | var = alloca (name_len + 2); |
| 2647 | strncpy (var, name, name_len); | 2654 | memcpy (var, name, name_len); |
| 2648 | var[name_len++] = '='; | 2655 | var[name_len++] = '='; |
| 2649 | var[name_len] = '\0'; | 2656 | var[name_len] = '\0'; |
| 2650 | return _putenv (var); | 2657 | return _putenv (var); |
| @@ -6054,7 +6061,7 @@ readlink (const char *name, char *buf, size_t buf_size) | |||
| 6054 | lname_size = strlen (resolved) + 1; | 6061 | lname_size = strlen (resolved) + 1; |
| 6055 | if (lname_size <= buf_size) | 6062 | if (lname_size <= buf_size) |
| 6056 | size_to_copy = lname_size; | 6063 | size_to_copy = lname_size; |
| 6057 | strncpy (buf, resolved, size_to_copy); | 6064 | memcpy (buf, resolved, size_to_copy); |
| 6058 | /* Success! */ | 6065 | /* Success! */ |
| 6059 | retval = size_to_copy; | 6066 | retval = size_to_copy; |
| 6060 | } | 6067 | } |
diff --git a/src/w32fns.c b/src/w32fns.c index 525642bfaab..bb74fcc1640 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1174,7 +1174,7 @@ gamma_correct (struct frame *f, COLORREF *color) | |||
| 1174 | If ALLOC is nonzero, allocate a new colormap cell. */ | 1174 | If ALLOC is nonzero, allocate a new colormap cell. */ |
| 1175 | 1175 | ||
| 1176 | bool | 1176 | bool |
| 1177 | w32_defined_color (struct frame *f, const char *color, XColor *color_def, | 1177 | w32_defined_color (struct frame *f, const char *color, Emacs_Color *color_def, |
| 1178 | bool alloc_p, bool _makeIndex) | 1178 | bool alloc_p, bool _makeIndex) |
| 1179 | { | 1179 | { |
| 1180 | register Lisp_Object tem; | 1180 | register Lisp_Object tem; |
| @@ -1248,7 +1248,7 @@ w32_defined_color (struct frame *f, const char *color, XColor *color_def, | |||
| 1248 | static int | 1248 | static int |
| 1249 | w32_decode_color (struct frame *f, Lisp_Object arg, int def) | 1249 | w32_decode_color (struct frame *f, Lisp_Object arg, int def) |
| 1250 | { | 1250 | { |
| 1251 | XColor cdef; | 1251 | Emacs_Color cdef; |
| 1252 | 1252 | ||
| 1253 | CHECK_STRING (arg); | 1253 | CHECK_STRING (arg); |
| 1254 | 1254 | ||
| @@ -2247,15 +2247,15 @@ w32_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) | |||
| 2247 | 2247 | ||
| 2248 | /* Subroutines for creating a frame. */ | 2248 | /* Subroutines for creating a frame. */ |
| 2249 | 2249 | ||
| 2250 | Cursor w32_load_cursor (LPCTSTR); | 2250 | HCURSOR w32_load_cursor (LPCTSTR); |
| 2251 | 2251 | ||
| 2252 | Cursor | 2252 | HCURSOR |
| 2253 | w32_load_cursor (LPCTSTR name) | 2253 | w32_load_cursor (LPCTSTR name) |
| 2254 | { | 2254 | { |
| 2255 | /* Try first to load cursor from application resource. */ | 2255 | /* Try first to load cursor from application resource. */ |
| 2256 | Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle (NULL), | 2256 | HCURSOR cursor = LoadImage ((HINSTANCE) GetModuleHandle (NULL), |
| 2257 | name, IMAGE_CURSOR, 0, 0, | 2257 | name, IMAGE_CURSOR, 0, 0, |
| 2258 | LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED); | 2258 | LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED); |
| 2259 | if (!cursor) | 2259 | if (!cursor) |
| 2260 | { | 2260 | { |
| 2261 | /* Then try to load a shared predefined cursor. */ | 2261 | /* Then try to load a shared predefined cursor. */ |
| @@ -5217,7 +5217,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |||
| 5217 | 5217 | ||
| 5218 | case WM_EMACS_SETCURSOR: | 5218 | case WM_EMACS_SETCURSOR: |
| 5219 | { | 5219 | { |
| 5220 | Cursor cursor = (Cursor) wParam; | 5220 | HCURSOR cursor = (HCURSOR) wParam; |
| 5221 | f = w32_window_to_frame (dpyinfo, hwnd); | 5221 | f = w32_window_to_frame (dpyinfo, hwnd); |
| 5222 | if (f && cursor) | 5222 | if (f && cursor) |
| 5223 | { | 5223 | { |
| @@ -5559,22 +5559,19 @@ w32_icon (struct frame *f, Lisp_Object parms) | |||
| 5559 | static void | 5559 | static void |
| 5560 | w32_make_gc (struct frame *f) | 5560 | w32_make_gc (struct frame *f) |
| 5561 | { | 5561 | { |
| 5562 | XGCValues gc_values; | 5562 | Emacs_GC gc_values; |
| 5563 | 5563 | ||
| 5564 | block_input (); | 5564 | block_input (); |
| 5565 | 5565 | ||
| 5566 | /* Create the GC's of this frame. | 5566 | /* Create the GC's of this frame. |
| 5567 | Note that many default values are used. */ | 5567 | Note that many default values are used. */ |
| 5568 | 5568 | ||
| 5569 | /* Normal video */ | ||
| 5570 | gc_values.font = FRAME_FONT (f); | ||
| 5571 | |||
| 5572 | /* Cursor has cursor-color background, background-color foreground. */ | 5569 | /* Cursor has cursor-color background, background-color foreground. */ |
| 5573 | gc_values.foreground = FRAME_BACKGROUND_PIXEL (f); | 5570 | gc_values.foreground = FRAME_BACKGROUND_PIXEL (f); |
| 5574 | gc_values.background = f->output_data.w32->cursor_pixel; | 5571 | gc_values.background = f->output_data.w32->cursor_pixel; |
| 5575 | f->output_data.w32->cursor_gc | 5572 | f->output_data.w32->cursor_gc |
| 5576 | = XCreateGC (NULL, FRAME_W32_WINDOW (f), | 5573 | = XCreateGC (NULL, FRAME_W32_WINDOW (f), |
| 5577 | (GCFont | GCForeground | GCBackground), | 5574 | (GCForeground | GCBackground), |
| 5578 | &gc_values); | 5575 | &gc_values); |
| 5579 | 5576 | ||
| 5580 | /* Reliefs. */ | 5577 | /* Reliefs. */ |
| @@ -6100,7 +6097,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, | |||
| 6100 | doc: /* SKIP: real doc in xfns.c. */) | 6097 | doc: /* SKIP: real doc in xfns.c. */) |
| 6101 | (Lisp_Object color, Lisp_Object frame) | 6098 | (Lisp_Object color, Lisp_Object frame) |
| 6102 | { | 6099 | { |
| 6103 | XColor foo; | 6100 | Emacs_Color foo; |
| 6104 | struct frame *f = decode_window_system_frame (frame); | 6101 | struct frame *f = decode_window_system_frame (frame); |
| 6105 | 6102 | ||
| 6106 | CHECK_STRING (color); | 6103 | CHECK_STRING (color); |
| @@ -6115,7 +6112,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, | |||
| 6115 | doc: /* SKIP: real doc in xfns.c. */) | 6112 | doc: /* SKIP: real doc in xfns.c. */) |
| 6116 | (Lisp_Object color, Lisp_Object frame) | 6113 | (Lisp_Object color, Lisp_Object frame) |
| 6117 | { | 6114 | { |
| 6118 | XColor foo; | 6115 | Emacs_Color foo; |
| 6119 | struct frame *f = decode_window_system_frame (frame); | 6116 | struct frame *f = decode_window_system_frame (frame); |
| 6120 | 6117 | ||
| 6121 | CHECK_STRING (color); | 6118 | CHECK_STRING (color); |
diff --git a/src/w32font.c b/src/w32font.c index 848016da1ca..bd68e22cc90 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -433,7 +433,7 @@ w32font_encode_char (struct font *font, int c) | |||
| 433 | CODE (length NGLYPHS). Apparently metrics can be NULL, in this | 433 | CODE (length NGLYPHS). Apparently metrics can be NULL, in this |
| 434 | case just return the overall width. */ | 434 | case just return the overall width. */ |
| 435 | void | 435 | void |
| 436 | w32font_text_extents (struct font *font, unsigned *code, | 436 | w32font_text_extents (struct font *font, const unsigned *code, |
| 437 | int nglyphs, struct font_metrics *metrics) | 437 | int nglyphs, struct font_metrics *metrics) |
| 438 | { | 438 | { |
| 439 | int i; | 439 | int i; |
diff --git a/src/w32font.h b/src/w32font.h index 65f42a3178d..c7bb7f30570 100644 --- a/src/w32font.h +++ b/src/w32font.h | |||
| @@ -74,7 +74,7 @@ int w32font_open_internal (struct frame *f, Lisp_Object font_entity, | |||
| 74 | int pixel_size, Lisp_Object font_object); | 74 | int pixel_size, Lisp_Object font_object); |
| 75 | void w32font_close (struct font *font); | 75 | void w32font_close (struct font *font); |
| 76 | int w32font_has_char (Lisp_Object entity, int c); | 76 | int w32font_has_char (Lisp_Object entity, int c); |
| 77 | void w32font_text_extents (struct font *font, unsigned *code, int nglyphs, | 77 | void w32font_text_extents (struct font *font, const unsigned *code, int nglyphs, |
| 78 | struct font_metrics *metrics); | 78 | struct font_metrics *metrics); |
| 79 | int w32font_draw (struct glyph_string *s, int from, int to, | 79 | int w32font_draw (struct glyph_string *s, int from, int to, |
| 80 | int x, int y, bool with_background); | 80 | int x, int y, bool with_background); |
diff --git a/src/w32gui.h b/src/w32gui.h index 5dcbbd95166..62bad33c19b 100644 --- a/src/w32gui.h +++ b/src/w32gui.h | |||
| @@ -27,41 +27,11 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 27 | #define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n))) | 27 | #define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n))) |
| 28 | #define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p)))) | 28 | #define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p)))) |
| 29 | 29 | ||
| 30 | /* Emulate X GC's by keeping color and font info in a structure. */ | 30 | typedef HBITMAP Emacs_Pixmap; |
| 31 | typedef struct _XGCValues | ||
| 32 | { | ||
| 33 | COLORREF foreground; | ||
| 34 | COLORREF background; | ||
| 35 | struct font *font; | ||
| 36 | } XGCValues; | ||
| 37 | |||
| 38 | #define GCForeground 0x01 | ||
| 39 | #define GCBackground 0x02 | ||
| 40 | #define GCFont 0x03 | ||
| 41 | |||
| 42 | typedef HBITMAP Pixmap; | ||
| 43 | typedef HBITMAP Bitmap; | ||
| 44 | 31 | ||
| 45 | typedef XGCValues * GC; | ||
| 46 | typedef COLORREF Color; | ||
| 47 | typedef HWND Window; | 32 | typedef HWND Window; |
| 48 | typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */ | 33 | typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */ |
| 49 | typedef HCURSOR Cursor; | 34 | typedef HCURSOR Emacs_Cursor; |
| 50 | |||
| 51 | #define No_Cursor (0) | ||
| 52 | |||
| 53 | #define XChar2b wchar_t | ||
| 54 | |||
| 55 | /* Dealing with bits of wchar_t as if they were an XChar2b. */ | ||
| 56 | #define STORE_XCHAR2B(chp, byte1, byte2) \ | ||
| 57 | ((*(chp)) = ((XChar2b)((((byte1) & 0x00ff) << 8) | ((byte2) & 0x00ff)))) | ||
| 58 | |||
| 59 | #define XCHAR2B_BYTE1(chp) \ | ||
| 60 | (((*(chp)) & 0xff00) >> 8) | ||
| 61 | |||
| 62 | #define XCHAR2B_BYTE2(chp) \ | ||
| 63 | ((*(chp)) & 0x00ff) | ||
| 64 | |||
| 65 | 35 | ||
| 66 | /* Windows equivalent of XImage. */ | 36 | /* Windows equivalent of XImage. */ |
| 67 | typedef struct _XImage | 37 | typedef struct _XImage |
| @@ -110,20 +80,15 @@ extern HINSTANCE hinst; | |||
| 110 | #define PBaseSize (1L << 8) /* program specified base for incrementing */ | 80 | #define PBaseSize (1L << 8) /* program specified base for incrementing */ |
| 111 | #define PWinGravity (1L << 9) /* program specified window gravity */ | 81 | #define PWinGravity (1L << 9) /* program specified window gravity */ |
| 112 | 82 | ||
| 113 | typedef struct { | ||
| 114 | int x, y; | ||
| 115 | unsigned width, height; | ||
| 116 | } XRectangle; | ||
| 117 | |||
| 118 | #define NativeRectangle RECT | 83 | #define NativeRectangle RECT |
| 119 | 84 | ||
| 120 | #define CONVERT_TO_XRECT(xr,nr) \ | 85 | #define CONVERT_TO_EMACS_RECT(xr,nr) \ |
| 121 | ((xr).x = (nr).left, \ | 86 | ((xr).x = (nr).left, \ |
| 122 | (xr).y = (nr).top, \ | 87 | (xr).y = (nr).top, \ |
| 123 | (xr).width = ((nr).right - (nr).left), \ | 88 | (xr).width = ((nr).right - (nr).left), \ |
| 124 | (xr).height = ((nr).bottom - (nr).top)) | 89 | (xr).height = ((nr).bottom - (nr).top)) |
| 125 | 90 | ||
| 126 | #define CONVERT_FROM_XRECT(xr,nr) \ | 91 | #define CONVERT_FROM_EMACS_RECT(xr,nr) \ |
| 127 | ((nr).left = (xr).x, \ | 92 | ((nr).left = (xr).x, \ |
| 128 | (nr).top = (xr).y, \ | 93 | (nr).top = (xr).y, \ |
| 129 | (nr).right = ((xr).x + (xr).width), \ | 94 | (nr).right = ((xr).x + (xr).width), \ |
diff --git a/src/w32term.c b/src/w32term.c index 451dd54dd8a..5726124b0ed 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -85,7 +85,7 @@ static int any_help_event_p; | |||
| 85 | extern unsigned int msh_mousewheel; | 85 | extern unsigned int msh_mousewheel; |
| 86 | 86 | ||
| 87 | extern int w32_codepage_for_font (char *fontname); | 87 | extern int w32_codepage_for_font (char *fontname); |
| 88 | extern Cursor w32_load_cursor (LPCTSTR name); | 88 | extern HCURSOR w32_load_cursor (LPCTSTR name); |
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | /* This is display since w32 does not support multiple ones. */ | 91 | /* This is display since w32 does not support multiple ones. */ |
| @@ -166,7 +166,7 @@ int w32_message_fd = -1; | |||
| 166 | 166 | ||
| 167 | static void w32_handle_tool_bar_click (struct frame *, | 167 | static void w32_handle_tool_bar_click (struct frame *, |
| 168 | struct input_event *); | 168 | struct input_event *); |
| 169 | static void w32_define_cursor (Window, Cursor); | 169 | static void w32_define_cursor (Window, Emacs_Cursor); |
| 170 | 170 | ||
| 171 | static void w32_scroll_bar_clear (struct frame *); | 171 | static void w32_scroll_bar_clear (struct frame *); |
| 172 | static void w32_raise_frame (struct frame *); | 172 | static void w32_raise_frame (struct frame *); |
| @@ -237,23 +237,21 @@ record_event (char *locus, int type) | |||
| 237 | 237 | ||
| 238 | 238 | ||
| 239 | static void | 239 | static void |
| 240 | XChangeGC (void *ignore, XGCValues *gc, unsigned long mask, | 240 | XChangeGC (void *ignore, Emacs_GC *gc, unsigned long mask, |
| 241 | XGCValues *xgcv) | 241 | Emacs_GC *egc) |
| 242 | { | 242 | { |
| 243 | if (mask & GCForeground) | 243 | if (mask & GCForeground) |
| 244 | gc->foreground = xgcv->foreground; | 244 | gc->foreground = egc->foreground; |
| 245 | if (mask & GCBackground) | 245 | if (mask & GCBackground) |
| 246 | gc->background = xgcv->background; | 246 | gc->background = egc->background; |
| 247 | if (mask & GCFont) | ||
| 248 | gc->font = xgcv->font; | ||
| 249 | } | 247 | } |
| 250 | 248 | ||
| 251 | XGCValues * | 249 | Emacs_GC * |
| 252 | XCreateGC (void *ignore, HWND wignore, unsigned long mask, XGCValues *xgcv) | 250 | XCreateGC (void *ignore, HWND wignore, unsigned long mask, Emacs_GC *egc) |
| 253 | { | 251 | { |
| 254 | XGCValues *gc = xzalloc (sizeof (XGCValues)); | 252 | Emacs_GC *gc = xzalloc (sizeof (*gc)); |
| 255 | 253 | ||
| 256 | XChangeGC (ignore, gc, mask, xgcv); | 254 | XChangeGC (ignore, gc, mask, egc); |
| 257 | 255 | ||
| 258 | return gc; | 256 | return gc; |
| 259 | } | 257 | } |
| @@ -337,7 +335,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color) | |||
| 337 | 335 | ||
| 338 | int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = scale_y; | 336 | int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = scale_y; |
| 339 | int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax; | 337 | int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax; |
| 340 | XRectangle wave_clip, string_clip, final_clip; | 338 | Emacs_Rectangle wave_clip, string_clip, final_clip; |
| 341 | RECT w32_final_clip, w32_string_clip; | 339 | RECT w32_final_clip, w32_string_clip; |
| 342 | HPEN hp, oldhp; | 340 | HPEN hp, oldhp; |
| 343 | 341 | ||
| @@ -356,14 +354,14 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color) | |||
| 356 | wave_clip.height = wave_height; | 354 | wave_clip.height = wave_height; |
| 357 | 355 | ||
| 358 | get_glyph_string_clip_rect (s, &w32_string_clip); | 356 | get_glyph_string_clip_rect (s, &w32_string_clip); |
| 359 | CONVERT_TO_XRECT (string_clip, w32_string_clip); | 357 | CONVERT_TO_EMACS_RECT (string_clip, w32_string_clip); |
| 360 | 358 | ||
| 361 | if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) | 359 | if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) |
| 362 | return; | 360 | return; |
| 363 | 361 | ||
| 364 | hp = CreatePen (PS_SOLID, thickness, color); | 362 | hp = CreatePen (PS_SOLID, thickness, color); |
| 365 | oldhp = SelectObject (s->hdc, hp); | 363 | oldhp = SelectObject (s->hdc, hp); |
| 366 | CONVERT_FROM_XRECT (final_clip, w32_final_clip); | 364 | CONVERT_FROM_EMACS_RECT (final_clip, w32_final_clip); |
| 367 | w32_set_clip_rectangle (s->hdc, &w32_final_clip); | 365 | w32_set_clip_rectangle (s->hdc, &w32_final_clip); |
| 368 | 366 | ||
| 369 | /* Draw the waves */ | 367 | /* Draw the waves */ |
| @@ -396,7 +394,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color) | |||
| 396 | 394 | ||
| 397 | /* Draw a hollow rectangle at the specified position. */ | 395 | /* Draw a hollow rectangle at the specified position. */ |
| 398 | static void | 396 | static void |
| 399 | w32_draw_rectangle (HDC hdc, XGCValues *gc, int x, int y, | 397 | w32_draw_rectangle (HDC hdc, Emacs_GC *gc, int x, int y, |
| 400 | int width, int height) | 398 | int width, int height) |
| 401 | { | 399 | { |
| 402 | HBRUSH hb, oldhb; | 400 | HBRUSH hb, oldhb; |
| @@ -529,7 +527,7 @@ w32_display_pixel_width (struct w32_display_info *dpyinfo) | |||
| 529 | 527 | ||
| 530 | /* Start an update of frame F. This function is installed as a hook | 528 | /* Start an update of frame F. This function is installed as a hook |
| 531 | for update_begin, i.e. it is called when update_begin is called. | 529 | for update_begin, i.e. it is called when update_begin is called. |
| 532 | This function is called prior to calls to w32_update_window_begin | 530 | This function is called prior to calls to gui_update_window_begin |
| 533 | for each window being updated. */ | 531 | for each window being updated. */ |
| 534 | 532 | ||
| 535 | static void | 533 | static void |
| @@ -555,58 +553,12 @@ w32_update_begin (struct frame *f) | |||
| 555 | static void | 553 | static void |
| 556 | w32_update_window_begin (struct window *w) | 554 | w32_update_window_begin (struct window *w) |
| 557 | { | 555 | { |
| 558 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | ||
| 559 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | ||
| 560 | |||
| 561 | /* Hide the system caret during an update. */ | 556 | /* Hide the system caret during an update. */ |
| 562 | if (w32_use_visible_system_caret && w32_system_caret_hwnd) | 557 | if (w32_use_visible_system_caret && w32_system_caret_hwnd) |
| 563 | { | 558 | { |
| 564 | SendMessageTimeout (w32_system_caret_hwnd, WM_EMACS_HIDE_CARET, 0, 0, | 559 | SendMessageTimeout (w32_system_caret_hwnd, WM_EMACS_HIDE_CARET, 0, 0, |
| 565 | 0, 6000, NULL); | 560 | 0, 6000, NULL); |
| 566 | } | 561 | } |
| 567 | |||
| 568 | w->output_cursor = w->cursor; | ||
| 569 | |||
| 570 | block_input (); | ||
| 571 | |||
| 572 | if (f == hlinfo->mouse_face_mouse_frame) | ||
| 573 | { | ||
| 574 | /* Don't do highlighting for mouse motion during the update. */ | ||
| 575 | hlinfo->mouse_face_defer = true; | ||
| 576 | |||
| 577 | /* If F needs to be redrawn, simply forget about any prior mouse | ||
| 578 | highlighting. */ | ||
| 579 | if (FRAME_GARBAGED_P (f)) | ||
| 580 | hlinfo->mouse_face_window = Qnil; | ||
| 581 | |||
| 582 | #if 0 /* Rows in a current matrix containing glyphs in mouse-face have | ||
| 583 | their mouse_face_p flag set, which means that they are always | ||
| 584 | unequal to rows in a desired matrix which never have that | ||
| 585 | flag set. So, rows containing mouse-face glyphs are never | ||
| 586 | scrolled, and we don't have to switch the mouse highlight off | ||
| 587 | here to prevent it from being scrolled. */ | ||
| 588 | |||
| 589 | /* Can we tell that this update does not affect the window | ||
| 590 | where the mouse highlight is? If so, no need to turn off. | ||
| 591 | Likewise, don't do anything if the frame is garbaged; | ||
| 592 | in that case, the frame's current matrix that we would use | ||
| 593 | is all wrong, and we will redisplay that line anyway. */ | ||
| 594 | if (!NILP (hlinfo->mouse_face_window) | ||
| 595 | && w == XWINDOW (hlinfo->mouse_face_window)) | ||
| 596 | { | ||
| 597 | int i; | ||
| 598 | |||
| 599 | for (i = 0; i < w->desired_matrix->nrows; ++i) | ||
| 600 | if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i)) | ||
| 601 | break; | ||
| 602 | |||
| 603 | if (i < w->desired_matrix->nrows) | ||
| 604 | clear_mouse_face (hlinfo); | ||
| 605 | } | ||
| 606 | #endif /* 0 */ | ||
| 607 | } | ||
| 608 | |||
| 609 | unblock_input (); | ||
| 610 | } | 562 | } |
| 611 | 563 | ||
| 612 | /* Draw a vertical window border from (x,y0) to (x,y1) */ | 564 | /* Draw a vertical window border from (x,y0) to (x,y1) */ |
| @@ -694,39 +646,8 @@ w32_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1) | |||
| 694 | 646 | ||
| 695 | static void | 647 | static void |
| 696 | w32_update_window_end (struct window *w, bool cursor_on_p, | 648 | w32_update_window_end (struct window *w, bool cursor_on_p, |
| 697 | bool mouse_face_overwritten_p) | 649 | bool mouse_face_overwritten_p) |
| 698 | { | 650 | { |
| 699 | if (!w->pseudo_window_p) | ||
| 700 | { | ||
| 701 | block_input (); | ||
| 702 | |||
| 703 | if (cursor_on_p) | ||
| 704 | display_and_set_cursor (w, true, | ||
| 705 | w->output_cursor.hpos, w->output_cursor.vpos, | ||
| 706 | w->output_cursor.x, w->output_cursor.y); | ||
| 707 | |||
| 708 | if (draw_window_fringes (w, true)) | ||
| 709 | { | ||
| 710 | if (WINDOW_RIGHT_DIVIDER_WIDTH (w)) | ||
| 711 | gui_draw_right_divider (w); | ||
| 712 | else | ||
| 713 | gui_draw_vertical_border (w); | ||
| 714 | } | ||
| 715 | |||
| 716 | unblock_input (); | ||
| 717 | } | ||
| 718 | |||
| 719 | /* If a row with mouse-face was overwritten, arrange for | ||
| 720 | XTframe_up_to_date to redisplay the mouse highlight. */ | ||
| 721 | if (mouse_face_overwritten_p) | ||
| 722 | { | ||
| 723 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); | ||
| 724 | |||
| 725 | hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; | ||
| 726 | hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; | ||
| 727 | hlinfo->mouse_face_window = Qnil; | ||
| 728 | } | ||
| 729 | |||
| 730 | /* Unhide the caret. This won't actually show the cursor, unless it | 651 | /* Unhide the caret. This won't actually show the cursor, unless it |
| 731 | was visible before the corresponding call to HideCaret in | 652 | was visible before the corresponding call to HideCaret in |
| 732 | w32_update_window_begin. */ | 653 | w32_update_window_begin. */ |
| @@ -983,38 +904,37 @@ w32_set_cursor_gc (struct glyph_string *s) | |||
| 983 | else | 904 | else |
| 984 | { | 905 | { |
| 985 | /* Cursor on non-default face: must merge. */ | 906 | /* Cursor on non-default face: must merge. */ |
| 986 | XGCValues xgcv; | 907 | Emacs_GC egc; |
| 987 | unsigned long mask; | 908 | unsigned long mask; |
| 988 | 909 | ||
| 989 | xgcv.background = s->f->output_data.w32->cursor_pixel; | 910 | egc.background = s->f->output_data.w32->cursor_pixel; |
| 990 | xgcv.foreground = s->face->background; | 911 | egc.foreground = s->face->background; |
| 991 | 912 | ||
| 992 | /* If the glyph would be invisible, try a different foreground. */ | 913 | /* If the glyph would be invisible, try a different foreground. */ |
| 993 | if (xgcv.foreground == xgcv.background) | 914 | if (egc.foreground == egc.background) |
| 994 | xgcv.foreground = s->face->foreground; | 915 | egc.foreground = s->face->foreground; |
| 995 | if (xgcv.foreground == xgcv.background) | 916 | if (egc.foreground == egc.background) |
| 996 | xgcv.foreground = s->f->output_data.w32->cursor_foreground_pixel; | 917 | egc.foreground = s->f->output_data.w32->cursor_foreground_pixel; |
| 997 | if (xgcv.foreground == xgcv.background) | 918 | if (egc.foreground == egc.background) |
| 998 | xgcv.foreground = s->face->foreground; | 919 | egc.foreground = s->face->foreground; |
| 999 | 920 | ||
| 1000 | /* Make sure the cursor is distinct from text in this face. */ | 921 | /* Make sure the cursor is distinct from text in this face. */ |
| 1001 | if (xgcv.background == s->face->background | 922 | if (egc.background == s->face->background |
| 1002 | && xgcv.foreground == s->face->foreground) | 923 | && egc.foreground == s->face->foreground) |
| 1003 | { | 924 | { |
| 1004 | xgcv.background = s->face->foreground; | 925 | egc.background = s->face->foreground; |
| 1005 | xgcv.foreground = s->face->background; | 926 | egc.foreground = s->face->background; |
| 1006 | } | 927 | } |
| 1007 | 928 | ||
| 1008 | IF_DEBUG (w32_check_font (s->f, s->font)); | 929 | IF_DEBUG (w32_check_font (s->f, s->font)); |
| 1009 | xgcv.font = s->font; | 930 | mask = GCForeground | GCBackground; |
| 1010 | mask = GCForeground | GCBackground | GCFont; | ||
| 1011 | 931 | ||
| 1012 | if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) | 932 | if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) |
| 1013 | XChangeGC (NULL, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, | 933 | XChangeGC (NULL, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, |
| 1014 | mask, &xgcv); | 934 | mask, &egc); |
| 1015 | else | 935 | else |
| 1016 | FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc | 936 | FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc |
| 1017 | = XCreateGC (NULL, FRAME_W32_WINDOW (s->f), mask, &xgcv); | 937 | = XCreateGC (NULL, FRAME_W32_WINDOW (s->f), mask, &egc); |
| 1018 | 938 | ||
| 1019 | s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; | 939 | s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; |
| 1020 | } | 940 | } |
| @@ -1049,21 +969,20 @@ w32_set_mouse_face_gc (struct glyph_string *s) | |||
| 1049 | { | 969 | { |
| 1050 | /* Otherwise construct scratch_cursor_gc with values from FACE | 970 | /* Otherwise construct scratch_cursor_gc with values from FACE |
| 1051 | but font FONT. */ | 971 | but font FONT. */ |
| 1052 | XGCValues xgcv; | 972 | Emacs_GC egc; |
| 1053 | unsigned long mask; | 973 | unsigned long mask; |
| 1054 | 974 | ||
| 1055 | xgcv.background = s->face->background; | 975 | egc.background = s->face->background; |
| 1056 | xgcv.foreground = s->face->foreground; | 976 | egc.foreground = s->face->foreground; |
| 1057 | IF_DEBUG (w32_check_font (s->f, s->font)); | 977 | IF_DEBUG (w32_check_font (s->f, s->font)); |
| 1058 | xgcv.font = s->font; | 978 | mask = GCForeground | GCBackground; |
| 1059 | mask = GCForeground | GCBackground | GCFont; | ||
| 1060 | 979 | ||
| 1061 | if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) | 980 | if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) |
| 1062 | XChangeGC (NULL, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, | 981 | XChangeGC (NULL, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, |
| 1063 | mask, &xgcv); | 982 | mask, &egc); |
| 1064 | else | 983 | else |
| 1065 | FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc | 984 | FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc |
| 1066 | = XCreateGC (NULL, FRAME_W32_WINDOW (s->f), mask, &xgcv); | 985 | = XCreateGC (NULL, FRAME_W32_WINDOW (s->f), mask, &egc); |
| 1067 | 986 | ||
| 1068 | s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; | 987 | s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; |
| 1069 | } | 988 | } |
| @@ -1178,14 +1097,10 @@ w32_compute_glyph_string_overhangs (struct glyph_string *s) | |||
| 1178 | && s->first_glyph->type == CHAR_GLYPH | 1097 | && s->first_glyph->type == CHAR_GLYPH |
| 1179 | && !s->font_not_found_p) | 1098 | && !s->font_not_found_p) |
| 1180 | { | 1099 | { |
| 1181 | unsigned *code = alloca (sizeof (unsigned) * s->nchars); | ||
| 1182 | struct font *font = s->font; | 1100 | struct font *font = s->font; |
| 1183 | struct font_metrics metrics; | 1101 | struct font_metrics metrics; |
| 1184 | int i; | ||
| 1185 | 1102 | ||
| 1186 | for (i = 0; i < s->nchars; i++) | 1103 | font->driver->text_extents (font, s->char2b, s->nchars, &metrics); |
| 1187 | code[i] = s->char2b[i]; | ||
| 1188 | font->driver->text_extents (font, code, s->nchars, &metrics); | ||
| 1189 | s->right_overhang = (metrics.rbearing > metrics.width | 1104 | s->right_overhang = (metrics.rbearing > metrics.width |
| 1190 | ? metrics.rbearing - metrics.width : 0); | 1105 | ? metrics.rbearing - metrics.width : 0); |
| 1191 | s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0; | 1106 | s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0; |
| @@ -1430,7 +1345,7 @@ static void | |||
| 1430 | w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | 1345 | w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s) |
| 1431 | { | 1346 | { |
| 1432 | struct glyph *glyph = s->first_glyph; | 1347 | struct glyph *glyph = s->first_glyph; |
| 1433 | XChar2b char2b[8]; | 1348 | unsigned char2b[8]; |
| 1434 | int x, i, j; | 1349 | int x, i, j; |
| 1435 | bool with_background; | 1350 | bool with_background; |
| 1436 | 1351 | ||
| @@ -1487,16 +1402,12 @@ w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | |||
| 1487 | { | 1402 | { |
| 1488 | struct font *font = s->font; | 1403 | struct font *font = s->font; |
| 1489 | int upper_len = (len + 1) / 2; | 1404 | int upper_len = (len + 1) / 2; |
| 1490 | unsigned code; | ||
| 1491 | HFONT old_font; | 1405 | HFONT old_font; |
| 1492 | 1406 | ||
| 1493 | old_font = SelectObject (s->hdc, FONT_HANDLE (font)); | 1407 | old_font = SelectObject (s->hdc, FONT_HANDLE (font)); |
| 1494 | /* It is certain that all LEN characters in STR are ASCII. */ | 1408 | /* It is certain that all LEN characters in STR are ASCII. */ |
| 1495 | for (j = 0; j < len; j++) | 1409 | for (j = 0; j < len; j++) |
| 1496 | { | 1410 | char2b[j] = font->driver->encode_char (font, str[j]) & 0xFFFF; |
| 1497 | code = font->driver->encode_char (font, str[j]); | ||
| 1498 | STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF); | ||
| 1499 | } | ||
| 1500 | font->driver->draw (s, 0, upper_len, | 1411 | font->driver->draw (s, 0, upper_len, |
| 1501 | x + glyph->slice.glyphless.upper_xoff, | 1412 | x + glyph->slice.glyphless.upper_xoff, |
| 1502 | s->ybase + glyph->slice.glyphless.upper_yoff, | 1413 | s->ybase + glyph->slice.glyphless.upper_yoff, |
| @@ -1594,7 +1505,7 @@ w32_alloc_lighter_color (struct frame *f, COLORREF *color, | |||
| 1594 | colors in COLORS. On W32, we no longer try to map colors to | 1505 | colors in COLORS. On W32, we no longer try to map colors to |
| 1595 | a palette. */ | 1506 | a palette. */ |
| 1596 | static void | 1507 | static void |
| 1597 | w32_query_colors (struct frame *f, XColor *colors, int ncolors) | 1508 | w32_query_colors (struct frame *f, Emacs_Color *colors, int ncolors) |
| 1598 | { | 1509 | { |
| 1599 | int i; | 1510 | int i; |
| 1600 | 1511 | ||
| @@ -1611,7 +1522,7 @@ w32_query_colors (struct frame *f, XColor *colors, int ncolors) | |||
| 1611 | /* Store F's background color into *BGCOLOR. */ | 1522 | /* Store F's background color into *BGCOLOR. */ |
| 1612 | 1523 | ||
| 1613 | static void | 1524 | static void |
| 1614 | w32_query_frame_background_color (struct frame *f, XColor *bgcolor) | 1525 | w32_query_frame_background_color (struct frame *f, Emacs_Color *bgcolor) |
| 1615 | { | 1526 | { |
| 1616 | bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f); | 1527 | bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f); |
| 1617 | w32_query_colors (f, bgcolor, 1); | 1528 | w32_query_colors (f, bgcolor, 1); |
| @@ -1628,7 +1539,7 @@ static void | |||
| 1628 | w32_setup_relief_color (struct frame *f, struct relief *relief, double factor, | 1539 | w32_setup_relief_color (struct frame *f, struct relief *relief, double factor, |
| 1629 | int delta, COLORREF default_pixel) | 1540 | int delta, COLORREF default_pixel) |
| 1630 | { | 1541 | { |
| 1631 | XGCValues xgcv; | 1542 | Emacs_GC egc; |
| 1632 | struct w32_output *di = f->output_data.w32; | 1543 | struct w32_output *di = f->output_data.w32; |
| 1633 | unsigned long mask = GCForeground; | 1544 | unsigned long mask = GCForeground; |
| 1634 | COLORREF pixel; | 1545 | COLORREF pixel; |
| @@ -1640,22 +1551,21 @@ w32_setup_relief_color (struct frame *f, struct relief *relief, double factor, | |||
| 1640 | /* TODO: Free colors (if using palette)? */ | 1551 | /* TODO: Free colors (if using palette)? */ |
| 1641 | 1552 | ||
| 1642 | /* Allocate new color. */ | 1553 | /* Allocate new color. */ |
| 1643 | xgcv.foreground = default_pixel; | 1554 | egc.foreground = default_pixel; |
| 1644 | pixel = background; | 1555 | pixel = background; |
| 1645 | if (w32_alloc_lighter_color (f, &pixel, factor, delta)) | 1556 | if (w32_alloc_lighter_color (f, &pixel, factor, delta)) |
| 1646 | xgcv.foreground = relief->pixel = pixel; | 1557 | egc.foreground = relief->pixel = pixel; |
| 1647 | 1558 | ||
| 1648 | xgcv.font = NULL; /* avoid compiler warnings */ | ||
| 1649 | if (relief->gc == 0) | 1559 | if (relief->gc == 0) |
| 1650 | { | 1560 | { |
| 1651 | #if 0 /* TODO: stipple */ | 1561 | #if 0 /* TODO: stipple */ |
| 1652 | xgcv.stipple = dpyinfo->gray; | 1562 | egc.stipple = dpyinfo->gray; |
| 1653 | mask |= GCStipple; | 1563 | mask |= GCStipple; |
| 1654 | #endif | 1564 | #endif |
| 1655 | relief->gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, &xgcv); | 1565 | relief->gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, &egc); |
| 1656 | } | 1566 | } |
| 1657 | else | 1567 | else |
| 1658 | XChangeGC (NULL, relief->gc, mask, &xgcv); | 1568 | XChangeGC (NULL, relief->gc, mask, &egc); |
| 1659 | } | 1569 | } |
| 1660 | 1570 | ||
| 1661 | 1571 | ||
| @@ -1704,7 +1614,7 @@ w32_draw_relief_rect (struct frame *f, | |||
| 1704 | RECT *clip_rect) | 1614 | RECT *clip_rect) |
| 1705 | { | 1615 | { |
| 1706 | int i; | 1616 | int i; |
| 1707 | XGCValues gc; | 1617 | Emacs_GC gc; |
| 1708 | HDC hdc = get_frame_dc (f); | 1618 | HDC hdc = get_frame_dc (f); |
| 1709 | 1619 | ||
| 1710 | if (raised_p) | 1620 | if (raised_p) |
| @@ -2363,7 +2273,7 @@ w32_draw_stretch_glyph_string (struct glyph_string *s) | |||
| 2363 | /* Clear rest using the GC of the original non-cursor face. */ | 2273 | /* Clear rest using the GC of the original non-cursor face. */ |
| 2364 | if (width < background_width) | 2274 | if (width < background_width) |
| 2365 | { | 2275 | { |
| 2366 | XGCValues *gc = s->face->gc; | 2276 | Emacs_GC *gc = s->face->gc; |
| 2367 | int y = s->y; | 2277 | int y = s->y; |
| 2368 | int w = background_width - width, h = s->height; | 2278 | int w = background_width - width, h = s->height; |
| 2369 | RECT r; | 2279 | RECT r; |
| @@ -2859,7 +2769,7 @@ w32_scroll_run (struct window *w, struct run *run) | |||
| 2859 | 2769 | ||
| 2860 | block_input (); | 2770 | block_input (); |
| 2861 | 2771 | ||
| 2862 | /* Cursor off. Will be switched on again in w32_update_window_end. */ | 2772 | /* Cursor off. Will be switched on again in gui_update_window_end. */ |
| 2863 | gui_clear_cursor (w); | 2773 | gui_clear_cursor (w); |
| 2864 | 2774 | ||
| 2865 | { | 2775 | { |
| @@ -3506,7 +3416,7 @@ static void w32_horizontal_scroll_bar_report_motion (struct frame **, Lisp_Objec | |||
| 3506 | Lisp_Object *, Lisp_Object *, | 3416 | Lisp_Object *, Lisp_Object *, |
| 3507 | Time *); | 3417 | Time *); |
| 3508 | static void | 3418 | static void |
| 3509 | w32_define_cursor (Window window, Cursor cursor) | 3419 | w32_define_cursor (Window window, Emacs_Cursor cursor) |
| 3510 | { | 3420 | { |
| 3511 | PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0); | 3421 | PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0); |
| 3512 | } | 3422 | } |
| @@ -5883,7 +5793,7 @@ w32_draw_bar_cursor (struct window *w, struct glyph_row *row, | |||
| 5883 | /* RIF: Define cursor CURSOR on frame F. */ | 5793 | /* RIF: Define cursor CURSOR on frame F. */ |
| 5884 | 5794 | ||
| 5885 | static void | 5795 | static void |
| 5886 | w32_define_frame_cursor (struct frame *f, Cursor cursor) | 5796 | w32_define_frame_cursor (struct frame *f, Emacs_Cursor cursor) |
| 5887 | { | 5797 | { |
| 5888 | w32_define_cursor (FRAME_W32_WINDOW (f), cursor); | 5798 | w32_define_cursor (FRAME_W32_WINDOW (f), cursor); |
| 5889 | } | 5799 | } |
| @@ -6946,6 +6856,7 @@ w32_wm_set_size_hint (struct frame *f, long flags, bool user_position) | |||
| 6946 | leave_crit (); | 6856 | leave_crit (); |
| 6947 | } | 6857 | } |
| 6948 | 6858 | ||
| 6859 | |||
| 6949 | /*********************************************************************** | 6860 | /*********************************************************************** |
| 6950 | Fonts | 6861 | Fonts |
| 6951 | ***********************************************************************/ | 6862 | ***********************************************************************/ |
| @@ -7017,6 +6928,18 @@ w32_toggle_invisible_pointer (struct frame *f, bool invisible) | |||
| 7017 | unblock_input (); | 6928 | unblock_input (); |
| 7018 | } | 6929 | } |
| 7019 | 6930 | ||
| 6931 | |||
| 6932 | /*********************************************************************** | ||
| 6933 | Image Hooks | ||
| 6934 | ***********************************************************************/ | ||
| 6935 | |||
| 6936 | static void | ||
| 6937 | w32_free_pixmap (struct frame *_f, Emacs_Pixmap pixmap) | ||
| 6938 | { | ||
| 6939 | DeleteObject (pixmap); | ||
| 6940 | } | ||
| 6941 | |||
| 6942 | |||
| 7020 | /*********************************************************************** | 6943 | /*********************************************************************** |
| 7021 | Initialization | 6944 | Initialization |
| 7022 | ***********************************************************************/ | 6945 | ***********************************************************************/ |
| @@ -7196,6 +7119,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo) | |||
| 7196 | terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar; | 7119 | terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar; |
| 7197 | terminal->judge_scroll_bars_hook = w32_judge_scroll_bars; | 7120 | terminal->judge_scroll_bars_hook = w32_judge_scroll_bars; |
| 7198 | terminal->get_string_resource_hook = w32_get_string_resource; | 7121 | terminal->get_string_resource_hook = w32_get_string_resource; |
| 7122 | terminal->free_pixmap = w32_free_pixmap; | ||
| 7199 | terminal->delete_frame_hook = w32_destroy_window; | 7123 | terminal->delete_frame_hook = w32_destroy_window; |
| 7200 | terminal->delete_terminal_hook = w32_delete_terminal; | 7124 | terminal->delete_terminal_hook = w32_delete_terminal; |
| 7201 | /* Other hooks are NULL by default. */ | 7125 | /* Other hooks are NULL by default. */ |
| @@ -7271,7 +7195,7 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 7271 | 7195 | ||
| 7272 | /* initialize palette with white and black */ | 7196 | /* initialize palette with white and black */ |
| 7273 | { | 7197 | { |
| 7274 | XColor color; | 7198 | Emacs_Color color; |
| 7275 | w32_defined_color (0, "white", &color, true, false); | 7199 | w32_defined_color (0, "white", &color, true, false); |
| 7276 | w32_defined_color (0, "black", &color, true, false); | 7200 | w32_defined_color (0, "black", &color, true, false); |
| 7277 | } | 7201 | } |
diff --git a/src/w32term.h b/src/w32term.h index de372d7e5d7..729e8d0fd49 100644 --- a/src/w32term.h +++ b/src/w32term.h | |||
| @@ -56,7 +56,7 @@ extern BOOL bUseDflt; | |||
| 56 | 56 | ||
| 57 | struct w32_bitmap_record | 57 | struct w32_bitmap_record |
| 58 | { | 58 | { |
| 59 | Pixmap pixmap; | 59 | Emacs_Pixmap pixmap; |
| 60 | char *file; | 60 | char *file; |
| 61 | HINSTANCE hinst; /* Used to load the file */ | 61 | HINSTANCE hinst; /* Used to load the file */ |
| 62 | int refcount; | 62 | int refcount; |
| @@ -114,10 +114,10 @@ struct w32_display_info | |||
| 114 | Window root_window; | 114 | Window root_window; |
| 115 | 115 | ||
| 116 | /* The cursor to use for vertical scroll bars. */ | 116 | /* The cursor to use for vertical scroll bars. */ |
| 117 | Cursor vertical_scroll_bar_cursor; | 117 | HCURSOR vertical_scroll_bar_cursor; |
| 118 | 118 | ||
| 119 | /* The cursor to use for horizontal scroll bars. */ | 119 | /* The cursor to use for horizontal scroll bars. */ |
| 120 | Cursor horizontal_scroll_bar_cursor; | 120 | HCURSOR horizontal_scroll_bar_cursor; |
| 121 | 121 | ||
| 122 | /* Resource data base */ | 122 | /* Resource data base */ |
| 123 | const char *rdb; | 123 | const char *rdb; |
| @@ -142,7 +142,7 @@ struct w32_display_info | |||
| 142 | int smallest_font_height; | 142 | int smallest_font_height; |
| 143 | 143 | ||
| 144 | /* Reusable Graphics Context for drawing a cursor in a non-default face. */ | 144 | /* Reusable Graphics Context for drawing a cursor in a non-default face. */ |
| 145 | XGCValues *scratch_cursor_gc; | 145 | Emacs_GC *scratch_cursor_gc; |
| 146 | 146 | ||
| 147 | /* Information about the range of text currently shown in | 147 | /* Information about the range of text currently shown in |
| 148 | mouse-face. */ | 148 | mouse-face. */ |
| @@ -241,7 +241,7 @@ extern void w32_set_scroll_bar_default_height (struct frame *); | |||
| 241 | 241 | ||
| 242 | extern struct w32_display_info *w32_term_init (Lisp_Object, | 242 | extern struct w32_display_info *w32_term_init (Lisp_Object, |
| 243 | char *, char *); | 243 | char *, char *); |
| 244 | extern bool w32_defined_color (struct frame *, const char *, XColor *, | 244 | extern bool w32_defined_color (struct frame *, const char *, Emacs_Color *, |
| 245 | bool, bool); | 245 | bool, bool); |
| 246 | extern int w32_display_pixel_height (struct w32_display_info *); | 246 | extern int w32_display_pixel_height (struct w32_display_info *); |
| 247 | extern int w32_display_pixel_width (struct w32_display_info *); | 247 | extern int w32_display_pixel_width (struct w32_display_info *); |
| @@ -308,7 +308,7 @@ struct w32_output | |||
| 308 | HPALETTE old_palette; | 308 | HPALETTE old_palette; |
| 309 | 309 | ||
| 310 | /* Here are the Graphics Contexts for the default font. */ | 310 | /* Here are the Graphics Contexts for the default font. */ |
| 311 | XGCValues *cursor_gc; /* cursor drawing */ | 311 | Emacs_GC *cursor_gc; /* cursor drawing */ |
| 312 | 312 | ||
| 313 | /* The window used for this frame. | 313 | /* The window used for this frame. |
| 314 | May be zero while the frame object is being created | 314 | May be zero while the frame object is being created |
| @@ -348,27 +348,27 @@ struct w32_output | |||
| 348 | COLORREF scroll_bar_background_pixel; | 348 | COLORREF scroll_bar_background_pixel; |
| 349 | 349 | ||
| 350 | /* Descriptor for the cursor in use for this window. */ | 350 | /* Descriptor for the cursor in use for this window. */ |
| 351 | Cursor text_cursor; | 351 | HCURSOR text_cursor; |
| 352 | Cursor nontext_cursor; | 352 | HCURSOR nontext_cursor; |
| 353 | Cursor modeline_cursor; | 353 | HCURSOR modeline_cursor; |
| 354 | Cursor hand_cursor; | 354 | HCURSOR hand_cursor; |
| 355 | Cursor hourglass_cursor; | 355 | HCURSOR hourglass_cursor; |
| 356 | Cursor horizontal_drag_cursor; | 356 | HCURSOR horizontal_drag_cursor; |
| 357 | Cursor vertical_drag_cursor; | 357 | HCURSOR vertical_drag_cursor; |
| 358 | Cursor left_edge_cursor; | 358 | HCURSOR left_edge_cursor; |
| 359 | Cursor top_left_corner_cursor; | 359 | HCURSOR top_left_corner_cursor; |
| 360 | Cursor top_edge_cursor; | 360 | HCURSOR top_edge_cursor; |
| 361 | Cursor top_right_corner_cursor; | 361 | HCURSOR top_right_corner_cursor; |
| 362 | Cursor right_edge_cursor; | 362 | HCURSOR right_edge_cursor; |
| 363 | Cursor bottom_right_corner_cursor; | 363 | HCURSOR bottom_right_corner_cursor; |
| 364 | Cursor bottom_edge_cursor; | 364 | HCURSOR bottom_edge_cursor; |
| 365 | Cursor bottom_left_corner_cursor; | 365 | HCURSOR bottom_left_corner_cursor; |
| 366 | 366 | ||
| 367 | /* Non-zero means hourglass cursor is currently displayed. */ | 367 | /* Non-zero means hourglass cursor is currently displayed. */ |
| 368 | unsigned hourglass_p : 1; | 368 | unsigned hourglass_p : 1; |
| 369 | 369 | ||
| 370 | /* Non-hourglass cursor that is currently active. */ | 370 | /* Non-hourglass cursor that is currently active. */ |
| 371 | Cursor current_cursor; | 371 | HCURSOR current_cursor; |
| 372 | 372 | ||
| 373 | DWORD dwStyle; | 373 | DWORD dwStyle; |
| 374 | 374 | ||
| @@ -388,7 +388,7 @@ struct w32_output | |||
| 388 | /* Relief GCs, colors etc. */ | 388 | /* Relief GCs, colors etc. */ |
| 389 | struct relief | 389 | struct relief |
| 390 | { | 390 | { |
| 391 | XGCValues *gc; | 391 | Emacs_GC *gc; |
| 392 | unsigned long pixel; | 392 | unsigned long pixel; |
| 393 | } | 393 | } |
| 394 | black_relief, white_relief; | 394 | black_relief, white_relief; |
| @@ -420,9 +420,6 @@ extern struct w32_output w32term_display; | |||
| 420 | /* This gives the w32_display_info structure for the display F is on. */ | 420 | /* This gives the w32_display_info structure for the display F is on. */ |
| 421 | #define FRAME_DISPLAY_INFO(f) ((void) (f), (&one_w32_display_info)) | 421 | #define FRAME_DISPLAY_INFO(f) ((void) (f), (&one_w32_display_info)) |
| 422 | 422 | ||
| 423 | /* This is the `Display *' which frame F is on. */ | ||
| 424 | #define FRAME_X_DISPLAY(f) (0) | ||
| 425 | |||
| 426 | #define FRAME_NORMAL_PLACEMENT(F) ((F)->output_data.w32->normal_placement) | 423 | #define FRAME_NORMAL_PLACEMENT(F) ((F)->output_data.w32->normal_placement) |
| 427 | #define FRAME_PREV_FSMODE(F) ((F)->output_data.w32->prev_fsmode) | 424 | #define FRAME_PREV_FSMODE(F) ((F)->output_data.w32->prev_fsmode) |
| 428 | 425 | ||
| @@ -724,7 +721,7 @@ extern void complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result); | |||
| 724 | extern BOOL parse_button (int, int, int *, int *); | 721 | extern BOOL parse_button (int, int, int *, int *); |
| 725 | 722 | ||
| 726 | extern void w32_sys_ring_bell (struct frame *f); | 723 | extern void w32_sys_ring_bell (struct frame *f); |
| 727 | extern void w32_query_color (struct frame *, XColor *); | 724 | extern void w32_query_color (struct frame *, Emacs_Color *); |
| 728 | extern void w32_delete_display (struct w32_display_info *dpyinfo); | 725 | extern void w32_delete_display (struct w32_display_info *dpyinfo); |
| 729 | 726 | ||
| 730 | #define FILE_NOTIFICATIONS_SIZE 16384 | 727 | #define FILE_NOTIFICATIONS_SIZE 16384 |
| @@ -808,7 +805,7 @@ typedef struct tagTRACKMOUSEEVENT | |||
| 808 | struct image; | 805 | struct image; |
| 809 | struct face; | 806 | struct face; |
| 810 | 807 | ||
| 811 | XGCValues *XCreateGC (void *, HWND, unsigned long, XGCValues *); | 808 | Emacs_GC *XCreateGC (void *, HWND, unsigned long, Emacs_GC *); |
| 812 | 809 | ||
| 813 | typedef DWORD (WINAPI * ClipboardSequence_Proc) (void); | 810 | typedef DWORD (WINAPI * ClipboardSequence_Proc) (void); |
| 814 | typedef BOOL (WINAPI * AppendMenuW_Proc) ( | 811 | typedef BOOL (WINAPI * AppendMenuW_Proc) ( |
diff --git a/src/window.c b/src/window.c index 30ffad0e513..deeb4f63fe0 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -3947,8 +3947,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, | |||
| 3947 | b->display_error_modiff = 0; | 3947 | b->display_error_modiff = 0; |
| 3948 | 3948 | ||
| 3949 | /* Update time stamps of buffer display. */ | 3949 | /* Update time stamps of buffer display. */ |
| 3950 | if (FIXNUMP (BVAR (b, display_count))) | 3950 | if (INTEGERP (BVAR (b, display_count))) |
| 3951 | bset_display_count (b, make_fixnum (XFIXNUM (BVAR (b, display_count)) + 1)); | 3951 | bset_display_count (b, Fadd1 (BVAR (b, display_count))); |
| 3952 | bset_display_time (b, Fcurrent_time ()); | 3952 | bset_display_time (b, Fcurrent_time ()); |
| 3953 | 3953 | ||
| 3954 | w->window_end_pos = 0; | 3954 | w->window_end_pos = 0; |
| @@ -4089,7 +4089,7 @@ displaying that buffer. */) | |||
| 4089 | return Qt; | 4089 | return Qt; |
| 4090 | } | 4090 | } |
| 4091 | 4091 | ||
| 4092 | if (WINDOWP (object)) | 4092 | if (WINDOW_LIVE_P (object)) |
| 4093 | { | 4093 | { |
| 4094 | struct window *w = XWINDOW (object); | 4094 | struct window *w = XWINDOW (object); |
| 4095 | mark_window_display_accurate (object, false); | 4095 | mark_window_display_accurate (object, false); |
diff --git a/src/xdisp.c b/src/xdisp.c index c677831020f..a448c90d8eb 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -376,7 +376,26 @@ static Lisp_Object list_of_error; | |||
| 376 | || it->s[IT_BYTEPOS (*it)] == '\t')) \ | 376 | || it->s[IT_BYTEPOS (*it)] == '\t')) \ |
| 377 | || (IT_BYTEPOS (*it) < ZV_BYTE \ | 377 | || (IT_BYTEPOS (*it) < ZV_BYTE \ |
| 378 | && (*BYTE_POS_ADDR (IT_BYTEPOS (*it)) == ' ' \ | 378 | && (*BYTE_POS_ADDR (IT_BYTEPOS (*it)) == ' ' \ |
| 379 | || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) \ | 379 | || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) |
| 380 | |||
| 381 | /* If all the conditions needed to print the fill column indicator are | ||
| 382 | met, return the (nonnegative) column number, else return a negative | ||
| 383 | value. */ | ||
| 384 | static int | ||
| 385 | fill_column_indicator_column (struct it *it) | ||
| 386 | { | ||
| 387 | if (Vdisplay_fill_column_indicator | ||
| 388 | && it->continuation_lines_width == 0 | ||
| 389 | && CHARACTERP (Vdisplay_fill_column_indicator_character)) | ||
| 390 | { | ||
| 391 | Lisp_Object col = (EQ (Vdisplay_fill_column_indicator_column, Qt) | ||
| 392 | ? BVAR (current_buffer, fill_column) | ||
| 393 | : Vdisplay_fill_column_indicator_column); | ||
| 394 | if (RANGED_FIXNUMP (0, col, INT_MAX)) | ||
| 395 | return XFIXNUM (col); | ||
| 396 | } | ||
| 397 | return -1; | ||
| 398 | } | ||
| 380 | 399 | ||
| 381 | /* True means print newline to stdout before next mini-buffer message. */ | 400 | /* True means print newline to stdout before next mini-buffer message. */ |
| 382 | 401 | ||
| @@ -2070,7 +2089,7 @@ frame_to_window_pixel_xy (struct window *w, int *x, int *y) | |||
| 2070 | int | 2089 | int |
| 2071 | get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int n) | 2090 | get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int n) |
| 2072 | { | 2091 | { |
| 2073 | XRectangle r; | 2092 | Emacs_Rectangle r; |
| 2074 | 2093 | ||
| 2075 | if (n <= 0) | 2094 | if (n <= 0) |
| 2076 | return 0; | 2095 | return 0; |
| @@ -2132,7 +2151,7 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int | |||
| 2132 | take the intersection with the rectangle of the cursor. */ | 2151 | take the intersection with the rectangle of the cursor. */ |
| 2133 | if (s->for_overlaps & OVERLAPS_ERASED_CURSOR) | 2152 | if (s->for_overlaps & OVERLAPS_ERASED_CURSOR) |
| 2134 | { | 2153 | { |
| 2135 | XRectangle rc, r_save = r; | 2154 | Emacs_Rectangle rc, r_save = r; |
| 2136 | 2155 | ||
| 2137 | rc.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (s->w, s->w->phys_cursor.x); | 2156 | rc.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (s->w, s->w->phys_cursor.x); |
| 2138 | rc.y = s->w->phys_cursor.y; | 2157 | rc.y = s->w->phys_cursor.y; |
| @@ -2198,7 +2217,7 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int | |||
| 2198 | 2217 | ||
| 2199 | if (s->row->clip) | 2218 | if (s->row->clip) |
| 2200 | { | 2219 | { |
| 2201 | XRectangle r_save = r; | 2220 | Emacs_Rectangle r_save = r; |
| 2202 | 2221 | ||
| 2203 | if (! gui_intersect_rectangles (&r_save, s->row->clip, &r)) | 2222 | if (! gui_intersect_rectangles (&r_save, s->row->clip, &r)) |
| 2204 | r.width = 0; | 2223 | r.width = 0; |
| @@ -2207,8 +2226,8 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int | |||
| 2207 | if ((s->for_overlaps & OVERLAPS_BOTH) == 0 | 2226 | if ((s->for_overlaps & OVERLAPS_BOTH) == 0 |
| 2208 | || ((s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1)) | 2227 | || ((s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1)) |
| 2209 | { | 2228 | { |
| 2210 | #ifdef CONVERT_FROM_XRECT | 2229 | #ifdef CONVERT_FROM_EMACS_RECT |
| 2211 | CONVERT_FROM_XRECT (r, *rects); | 2230 | CONVERT_FROM_EMACS_RECT (r, *rects); |
| 2212 | #else | 2231 | #else |
| 2213 | *rects = r; | 2232 | *rects = r; |
| 2214 | #endif | 2233 | #endif |
| @@ -2220,10 +2239,10 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int | |||
| 2220 | multiple clipping rectangles, we exclude the row of the glyph | 2239 | multiple clipping rectangles, we exclude the row of the glyph |
| 2221 | string from the clipping rectangle. This is to avoid drawing | 2240 | string from the clipping rectangle. This is to avoid drawing |
| 2222 | the same text on the environment with anti-aliasing. */ | 2241 | the same text on the environment with anti-aliasing. */ |
| 2223 | #ifdef CONVERT_FROM_XRECT | 2242 | #ifdef CONVERT_FROM_EMACS_RECT |
| 2224 | XRectangle rs[2]; | 2243 | Emacs_Rectangle rs[2]; |
| 2225 | #else | 2244 | #else |
| 2226 | XRectangle *rs = rects; | 2245 | Emacs_Rectangle *rs = rects; |
| 2227 | #endif | 2246 | #endif |
| 2228 | int i = 0, row_y = WINDOW_TO_FRAME_PIXEL_Y (s->w, s->row->y); | 2247 | int i = 0, row_y = WINDOW_TO_FRAME_PIXEL_Y (s->w, s->row->y); |
| 2229 | 2248 | ||
| @@ -2256,9 +2275,9 @@ get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int | |||
| 2256 | } | 2275 | } |
| 2257 | 2276 | ||
| 2258 | n = i; | 2277 | n = i; |
| 2259 | #ifdef CONVERT_FROM_XRECT | 2278 | #ifdef CONVERT_FROM_EMACS_RECT |
| 2260 | for (i = 0; i < n; i++) | 2279 | for (i = 0; i < n; i++) |
| 2261 | CONVERT_FROM_XRECT (rs[i], rects[i]); | 2280 | CONVERT_FROM_EMACS_RECT (rs[i], rects[i]); |
| 2262 | #endif | 2281 | #endif |
| 2263 | return n; | 2282 | return n; |
| 2264 | } | 2283 | } |
| @@ -13977,12 +13996,6 @@ redisplay_internal (void) | |||
| 13977 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) | 13996 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) |
| 13978 | if (popup_activated ()) | 13997 | if (popup_activated ()) |
| 13979 | { | 13998 | { |
| 13980 | #ifdef NS_IMPL_COCOA | ||
| 13981 | /* On macOS we may have disabled screen updates due to window | ||
| 13982 | resizing. We should re-enable them so the popup can be | ||
| 13983 | displayed. */ | ||
| 13984 | ns_enable_screen_updates (); | ||
| 13985 | #endif | ||
| 13986 | return; | 13999 | return; |
| 13987 | } | 14000 | } |
| 13988 | #endif | 14001 | #endif |
| @@ -14785,12 +14798,6 @@ unwind_redisplay (void) | |||
| 14785 | { | 14798 | { |
| 14786 | redisplaying_p = false; | 14799 | redisplaying_p = false; |
| 14787 | unblock_buffer_flips (); | 14800 | unblock_buffer_flips (); |
| 14788 | #ifdef NS_IMPL_COCOA | ||
| 14789 | /* On macOS we may have disabled screen updates due to window | ||
| 14790 | resizing. When redisplay completes we want to re-enable | ||
| 14791 | them. */ | ||
| 14792 | ns_enable_screen_updates (); | ||
| 14793 | #endif | ||
| 14794 | } | 14801 | } |
| 14795 | 14802 | ||
| 14796 | 14803 | ||
| @@ -18031,12 +18038,14 @@ try_window_reusing_current_matrix (struct window *w) | |||
| 18031 | 18038 | ||
| 18032 | if (run.height > 0 && run.current_y != run.desired_y) | 18039 | if (run.height > 0 && run.current_y != run.desired_y) |
| 18033 | { | 18040 | { |
| 18041 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 18034 | update_begin (f); | 18042 | update_begin (f); |
| 18035 | FRAME_RIF (f)->update_window_begin_hook (w); | 18043 | gui_update_window_begin (w); |
| 18036 | FRAME_RIF (f)->clear_window_mouse_face (w); | 18044 | FRAME_RIF (f)->clear_window_mouse_face (w); |
| 18037 | FRAME_RIF (f)->scroll_run_hook (w, &run); | 18045 | FRAME_RIF (f)->scroll_run_hook (w, &run); |
| 18038 | FRAME_RIF (f)->update_window_end_hook (w, false, false); | 18046 | gui_update_window_end (w, false, false); |
| 18039 | update_end (f); | 18047 | update_end (f); |
| 18048 | #endif | ||
| 18040 | } | 18049 | } |
| 18041 | 18050 | ||
| 18042 | /* Shift current matrix down by nrows_scrolled lines. */ | 18051 | /* Shift current matrix down by nrows_scrolled lines. */ |
| @@ -18195,12 +18204,14 @@ try_window_reusing_current_matrix (struct window *w) | |||
| 18195 | 18204 | ||
| 18196 | if (run.height) | 18205 | if (run.height) |
| 18197 | { | 18206 | { |
| 18207 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 18198 | update_begin (f); | 18208 | update_begin (f); |
| 18199 | FRAME_RIF (f)->update_window_begin_hook (w); | 18209 | gui_update_window_begin (w); |
| 18200 | FRAME_RIF (f)->clear_window_mouse_face (w); | 18210 | FRAME_RIF (f)->clear_window_mouse_face (w); |
| 18201 | FRAME_RIF (f)->scroll_run_hook (w, &run); | 18211 | FRAME_RIF (f)->scroll_run_hook (w, &run); |
| 18202 | FRAME_RIF (f)->update_window_end_hook (w, false, false); | 18212 | gui_update_window_end (w, false, false); |
| 18203 | update_end (f); | 18213 | update_end (f); |
| 18214 | #endif | ||
| 18204 | } | 18215 | } |
| 18205 | 18216 | ||
| 18206 | /* Adjust Y positions of reused rows. */ | 18217 | /* Adjust Y positions of reused rows. */ |
| @@ -19148,10 +19159,12 @@ try_window_id (struct window *w) | |||
| 19148 | 19159 | ||
| 19149 | if (FRAME_WINDOW_P (f)) | 19160 | if (FRAME_WINDOW_P (f)) |
| 19150 | { | 19161 | { |
| 19151 | FRAME_RIF (f)->update_window_begin_hook (w); | 19162 | #ifdef HAVE_WINDOW_SYSTEM |
| 19163 | gui_update_window_begin (w); | ||
| 19152 | FRAME_RIF (f)->clear_window_mouse_face (w); | 19164 | FRAME_RIF (f)->clear_window_mouse_face (w); |
| 19153 | FRAME_RIF (f)->scroll_run_hook (w, &run); | 19165 | FRAME_RIF (f)->scroll_run_hook (w, &run); |
| 19154 | FRAME_RIF (f)->update_window_end_hook (w, false, false); | 19166 | gui_update_window_end (w, false, false); |
| 19167 | #endif | ||
| 19155 | } | 19168 | } |
| 19156 | else | 19169 | else |
| 19157 | { | 19170 | { |
| @@ -20147,15 +20160,53 @@ append_space_for_newline (struct it *it, bool default_face_p) | |||
| 20147 | it->what = IT_CHARACTER; | 20160 | it->what = IT_CHARACTER; |
| 20148 | memset (&it->position, 0, sizeof it->position); | 20161 | memset (&it->position, 0, sizeof it->position); |
| 20149 | it->object = Qnil; | 20162 | it->object = Qnil; |
| 20150 | it->c = it->char_to_display = ' '; | ||
| 20151 | it->len = 1; | 20163 | it->len = 1; |
| 20152 | 20164 | ||
| 20165 | int local_default_face_id = | ||
| 20166 | lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID); | ||
| 20167 | struct face* default_face = | ||
| 20168 | FACE_FROM_ID_OR_NULL (it->f, local_default_face_id); | ||
| 20169 | |||
| 20170 | /* Corner case for when display-fill-column-indicator-mode | ||
| 20171 | is active and the extra character should be added in the | ||
| 20172 | same place than the line. */ | ||
| 20173 | int indicator_column = (it->w->pseudo_window_p == 0 | ||
| 20174 | ? fill_column_indicator_column (it) | ||
| 20175 | : -1); | ||
| 20176 | if (0 <= indicator_column) | ||
| 20177 | { | ||
| 20178 | struct font *font = | ||
| 20179 | default_face->font ? | ||
| 20180 | default_face->font : FRAME_FONT (it->f); | ||
| 20181 | const int char_width = | ||
| 20182 | font->average_width ? | ||
| 20183 | font->average_width : font->space_width; | ||
| 20184 | |||
| 20185 | int column_x; | ||
| 20186 | if (!INT_MULTIPLY_WRAPV (indicator_column, char_width, | ||
| 20187 | &column_x) | ||
| 20188 | && !INT_ADD_WRAPV (it->lnum_pixel_width, column_x, | ||
| 20189 | &column_x) | ||
| 20190 | && it->current_x == column_x) | ||
| 20191 | { | ||
| 20192 | it->c = it->char_to_display = | ||
| 20193 | XFIXNAT (Vdisplay_fill_column_indicator_character); | ||
| 20194 | it->face_id = | ||
| 20195 | merge_faces (it->w, Qfill_column_indicator, | ||
| 20196 | 0, saved_face_id); | ||
| 20197 | face = FACE_FROM_ID (it->f, it->face_id); | ||
| 20198 | goto produce_glyphs; | ||
| 20199 | } | ||
| 20200 | } | ||
| 20201 | |||
| 20202 | it->c = it->char_to_display = ' '; | ||
| 20153 | /* If the default face was remapped, be sure to use the | 20203 | /* If the default face was remapped, be sure to use the |
| 20154 | remapped face for the appended newline. */ | 20204 | remapped face for the appended newline. */ |
| 20155 | if (default_face_p) | 20205 | if (default_face_p) |
| 20156 | it->face_id = lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID); | 20206 | it->face_id = local_default_face_id; |
| 20157 | else if (it->face_before_selective_p) | 20207 | else if (it->face_before_selective_p) |
| 20158 | it->face_id = it->saved_face_id; | 20208 | it->face_id = it->saved_face_id; |
| 20209 | |||
| 20159 | face = FACE_FROM_ID (it->f, it->face_id); | 20210 | face = FACE_FROM_ID (it->f, it->face_id); |
| 20160 | it->face_id = FACE_FOR_CHAR (it->f, face, 0, -1, Qnil); | 20211 | it->face_id = FACE_FOR_CHAR (it->f, face, 0, -1, Qnil); |
| 20161 | /* In R2L rows, we will prepend a stretch glyph that will | 20212 | /* In R2L rows, we will prepend a stretch glyph that will |
| @@ -20169,6 +20220,7 @@ append_space_for_newline (struct it *it, bool default_face_p) | |||
| 20169 | && saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x) | 20220 | && saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x) |
| 20170 | it->end_of_box_run_p = false; | 20221 | it->end_of_box_run_p = false; |
| 20171 | 20222 | ||
| 20223 | produce_glyphs: | ||
| 20172 | PRODUCE_GLYPHS (it); | 20224 | PRODUCE_GLYPHS (it); |
| 20173 | 20225 | ||
| 20174 | #ifdef HAVE_WINDOW_SYSTEM | 20226 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -20317,7 +20369,8 @@ extend_face_to_end_of_line (struct it *it) | |||
| 20317 | #ifdef HAVE_WINDOW_SYSTEM | 20369 | #ifdef HAVE_WINDOW_SYSTEM |
| 20318 | && !face->stipple | 20370 | && !face->stipple |
| 20319 | #endif | 20371 | #endif |
| 20320 | && !it->glyph_row->reversed_p) | 20372 | && !it->glyph_row->reversed_p |
| 20373 | && !Vdisplay_fill_column_indicator) | ||
| 20321 | return; | 20374 | return; |
| 20322 | 20375 | ||
| 20323 | /* Set the glyph row flag indicating that the face of the last glyph | 20376 | /* Set the glyph row flag indicating that the face of the last glyph |
| @@ -20369,6 +20422,82 @@ extend_face_to_end_of_line (struct it *it) | |||
| 20369 | default_face->id; | 20422 | default_face->id; |
| 20370 | it->glyph_row->used[RIGHT_MARGIN_AREA] = 1; | 20423 | it->glyph_row->used[RIGHT_MARGIN_AREA] = 1; |
| 20371 | } | 20424 | } |
| 20425 | |||
| 20426 | /* Display fill column indicator if not in modeline or | ||
| 20427 | toolbar and display fill column indicator mode is | ||
| 20428 | active. */ | ||
| 20429 | int indicator_column = (it->w->pseudo_window_p == 0 | ||
| 20430 | ? fill_column_indicator_column (it) | ||
| 20431 | : -1); | ||
| 20432 | if (0 <= indicator_column) | ||
| 20433 | { | ||
| 20434 | struct font *font = | ||
| 20435 | default_face->font ? default_face->font : FRAME_FONT (f); | ||
| 20436 | const int char_width = | ||
| 20437 | font->average_width ? | ||
| 20438 | font->average_width : font->space_width; | ||
| 20439 | |||
| 20440 | int column_x; | ||
| 20441 | if (!INT_MULTIPLY_WRAPV (indicator_column, char_width, &column_x) | ||
| 20442 | && !INT_ADD_WRAPV (it->lnum_pixel_width, column_x, &column_x) | ||
| 20443 | && it->current_x <= column_x | ||
| 20444 | && column_x <= it->last_visible_x) | ||
| 20445 | { | ||
| 20446 | const char saved_char = it->char_to_display; | ||
| 20447 | const struct text_pos saved_pos = it->position; | ||
| 20448 | const bool saved_avoid_cursor = it->avoid_cursor_p; | ||
| 20449 | const int saved_face_id = it->face_id; | ||
| 20450 | const bool saved_box_start = it->start_of_box_run_p; | ||
| 20451 | Lisp_Object save_object = it->object; | ||
| 20452 | |||
| 20453 | /* The stretch width needs to considet the latter | ||
| 20454 | added glyph. */ | ||
| 20455 | const int stretch_width = | ||
| 20456 | column_x - it->current_x - char_width; | ||
| 20457 | |||
| 20458 | memset (&it->position, 0, sizeof it->position); | ||
| 20459 | it->avoid_cursor_p = true; | ||
| 20460 | it->object = Qnil; | ||
| 20461 | |||
| 20462 | /* Only generate a stretch glyph if there is distance | ||
| 20463 | between current_x and and the indicator position. */ | ||
| 20464 | if (stretch_width > 0) | ||
| 20465 | { | ||
| 20466 | int stretch_ascent = (((it->ascent + it->descent) | ||
| 20467 | * FONT_BASE (font)) / FONT_HEIGHT (font)); | ||
| 20468 | append_stretch_glyph (it, Qnil, stretch_width, | ||
| 20469 | it->ascent + it->descent, | ||
| 20470 | stretch_ascent); | ||
| 20471 | } | ||
| 20472 | |||
| 20473 | /* Generate the glyph indicator only if | ||
| 20474 | append_space_for_newline didn't already. */ | ||
| 20475 | if (it->current_x < column_x) | ||
| 20476 | { | ||
| 20477 | it->char_to_display = | ||
| 20478 | XFIXNAT (Vdisplay_fill_column_indicator_character); | ||
| 20479 | it->face_id = | ||
| 20480 | merge_faces (it->w, Qfill_column_indicator, | ||
| 20481 | 0, saved_face_id); | ||
| 20482 | PRODUCE_GLYPHS (it); | ||
| 20483 | } | ||
| 20484 | |||
| 20485 | /* Restore the face after the indicator was generated. */ | ||
| 20486 | it->face_id = saved_face_id; | ||
| 20487 | |||
| 20488 | /* If there is space after the indicator generate an | ||
| 20489 | extra empty glyph to restore the face. Issue was | ||
| 20490 | observed in X systems. */ | ||
| 20491 | it->char_to_display = ' '; | ||
| 20492 | PRODUCE_GLYPHS (it); | ||
| 20493 | |||
| 20494 | it->char_to_display = saved_char; | ||
| 20495 | it->position = saved_pos; | ||
| 20496 | it->avoid_cursor_p = saved_avoid_cursor; | ||
| 20497 | it->start_of_box_run_p = saved_box_start; | ||
| 20498 | it->object = save_object; | ||
| 20499 | } | ||
| 20500 | } | ||
| 20372 | } | 20501 | } |
| 20373 | #ifdef HAVE_WINDOW_SYSTEM | 20502 | #ifdef HAVE_WINDOW_SYSTEM |
| 20374 | if (it->glyph_row->reversed_p) | 20503 | if (it->glyph_row->reversed_p) |
| @@ -20377,7 +20506,7 @@ extend_face_to_end_of_line (struct it *it) | |||
| 20377 | rightmost glyph will be drawn flushed all the way to the | 20506 | rightmost glyph will be drawn flushed all the way to the |
| 20378 | right margin of the window. The stretch glyph that will | 20507 | right margin of the window. The stretch glyph that will |
| 20379 | occupy the empty space, if any, to the left of the | 20508 | occupy the empty space, if any, to the left of the |
| 20380 | glyphs. */ | 20509 | glyph. */ |
| 20381 | struct font *font = face->font ? face->font : FRAME_FONT (f); | 20510 | struct font *font = face->font ? face->font : FRAME_FONT (f); |
| 20382 | struct glyph *row_start = it->glyph_row->glyphs[TEXT_AREA]; | 20511 | struct glyph *row_start = it->glyph_row->glyphs[TEXT_AREA]; |
| 20383 | struct glyph *row_end = row_start + it->glyph_row->used[TEXT_AREA]; | 20512 | struct glyph *row_end = row_start + it->glyph_row->used[TEXT_AREA]; |
| @@ -20490,10 +20619,35 @@ extend_face_to_end_of_line (struct it *it) | |||
| 20490 | it->face_id = default_face->id; | 20619 | it->face_id = default_face->id; |
| 20491 | else | 20620 | else |
| 20492 | it->face_id = face->id; | 20621 | it->face_id = face->id; |
| 20493 | PRODUCE_GLYPHS (it); | ||
| 20494 | 20622 | ||
| 20495 | while (it->current_x <= it->last_visible_x) | 20623 | /* Display fill-column indicator if needed. */ |
| 20496 | PRODUCE_GLYPHS (it); | 20624 | int indicator_column = fill_column_indicator_column (it); |
| 20625 | if (0 <= indicator_column | ||
| 20626 | && INT_ADD_WRAPV (it->lnum_pixel_width, indicator_column, | ||
| 20627 | &indicator_column)) | ||
| 20628 | indicator_column = -1; | ||
| 20629 | do | ||
| 20630 | { | ||
| 20631 | int saved_face_id; | ||
| 20632 | bool indicate = it->current_x == indicator_column; | ||
| 20633 | if (indicate) | ||
| 20634 | { | ||
| 20635 | saved_face_id = it->face_id; | ||
| 20636 | it->face_id = | ||
| 20637 | merge_faces (it->w, Qfill_column_indicator, 0, saved_face_id); | ||
| 20638 | it->c = it->char_to_display = | ||
| 20639 | XFIXNAT (Vdisplay_fill_column_indicator_character); | ||
| 20640 | } | ||
| 20641 | |||
| 20642 | PRODUCE_GLYPHS (it); | ||
| 20643 | |||
| 20644 | if (indicate) | ||
| 20645 | { | ||
| 20646 | it->face_id = saved_face_id; | ||
| 20647 | it->c = it->char_to_display = ' '; | ||
| 20648 | } | ||
| 20649 | } | ||
| 20650 | while (it->current_x <= it->last_visible_x); | ||
| 20497 | 20651 | ||
| 20498 | if (WINDOW_RIGHT_MARGIN_WIDTH (it->w) > 0 | 20652 | if (WINDOW_RIGHT_MARGIN_WIDTH (it->w) > 0 |
| 20499 | && (it->glyph_row->used[RIGHT_MARGIN_AREA] | 20653 | && (it->glyph_row->used[RIGHT_MARGIN_AREA] |
| @@ -20583,7 +20737,8 @@ highlight_trailing_whitespace (struct it *it) | |||
| 20583 | if (!row->reversed_p) | 20737 | if (!row->reversed_p) |
| 20584 | { | 20738 | { |
| 20585 | while (glyph >= start | 20739 | while (glyph >= start |
| 20586 | && glyph->type == CHAR_GLYPH | 20740 | && (glyph->type == CHAR_GLYPH |
| 20741 | || glyph->type == STRETCH_GLYPH) | ||
| 20587 | && NILP (glyph->object)) | 20742 | && NILP (glyph->object)) |
| 20588 | --glyph; | 20743 | --glyph; |
| 20589 | } | 20744 | } |
| @@ -23843,7 +23998,8 @@ display_mode_element (struct it *it, int depth, int field_width, int precision, | |||
| 23843 | ? string_byte_to_char (elt, bytepos) | 23998 | ? string_byte_to_char (elt, bytepos) |
| 23844 | : bytepos); | 23999 | : bytepos); |
| 23845 | spec = decode_mode_spec (it->w, c, field, &string); | 24000 | spec = decode_mode_spec (it->w, c, field, &string); |
| 23846 | multibyte = STRINGP (string) && STRING_MULTIBYTE (string); | 24001 | eassert (NILP (string) || STRINGP (string)); |
| 24002 | multibyte = !NILP (string) && STRING_MULTIBYTE (string); | ||
| 23847 | 24003 | ||
| 23848 | switch (mode_line_target) | 24004 | switch (mode_line_target) |
| 23849 | { | 24005 | { |
| @@ -24519,8 +24675,9 @@ percent99 (ptrdiff_t n, ptrdiff_t d) | |||
| 24519 | 24675 | ||
| 24520 | /* Return a string for the output of a mode line %-spec for window W, | 24676 | /* Return a string for the output of a mode line %-spec for window W, |
| 24521 | generated by character C. FIELD_WIDTH > 0 means pad the string | 24677 | generated by character C. FIELD_WIDTH > 0 means pad the string |
| 24522 | returned with spaces to that value. Return a Lisp string in | 24678 | returned with spaces to that value. Set *STRING to be a Lisp |
| 24523 | *STRING if the resulting string is taken from that Lisp string. | 24679 | string if the resulting string is taken from that Lisp string; |
| 24680 | otherwise, set *STRING to Qnil. | ||
| 24524 | 24681 | ||
| 24525 | Note we operate on the current buffer for most purposes. */ | 24682 | Note we operate on the current buffer for most purposes. */ |
| 24526 | 24683 | ||
| @@ -25729,7 +25886,7 @@ dump_glyph_string (struct glyph_string *s) | |||
| 25729 | #endif /* GLYPH_DEBUG */ | 25886 | #endif /* GLYPH_DEBUG */ |
| 25730 | 25887 | ||
| 25731 | /* Initialize glyph string S. CHAR2B is a suitably allocated vector | 25888 | /* Initialize glyph string S. CHAR2B is a suitably allocated vector |
| 25732 | of XChar2b structures for S; it can't be allocated in | 25889 | of 2-byte unsigned integers for S; it can't be allocated in |
| 25733 | init_glyph_string because it must be allocated via `alloca'. W | 25890 | init_glyph_string because it must be allocated via `alloca'. W |
| 25734 | is the window on which S is drawn. ROW and AREA are the glyph row | 25891 | is the window on which S is drawn. ROW and AREA are the glyph row |
| 25735 | and area within the row from which S is constructed. START is the | 25892 | and area within the row from which S is constructed. START is the |
| @@ -25759,7 +25916,7 @@ init_glyph_string (struct glyph_string *s, | |||
| 25759 | #ifdef HAVE_NTGUI | 25916 | #ifdef HAVE_NTGUI |
| 25760 | HDC hdc, | 25917 | HDC hdc, |
| 25761 | #endif | 25918 | #endif |
| 25762 | XChar2b *char2b, struct window *w, struct glyph_row *row, | 25919 | unsigned *char2b, struct window *w, struct glyph_row *row, |
| 25763 | enum glyph_row_area area, int start, enum draw_glyphs_face hl) | 25920 | enum glyph_row_area area, int start, enum draw_glyphs_face hl) |
| 25764 | { | 25921 | { |
| 25765 | memset (s, 0, sizeof *s); | 25922 | memset (s, 0, sizeof *s); |
| @@ -25768,7 +25925,6 @@ init_glyph_string (struct glyph_string *s, | |||
| 25768 | #ifdef HAVE_NTGUI | 25925 | #ifdef HAVE_NTGUI |
| 25769 | s->hdc = hdc; | 25926 | s->hdc = hdc; |
| 25770 | #endif | 25927 | #endif |
| 25771 | s->display = FRAME_X_DISPLAY (s->f); | ||
| 25772 | s->char2b = char2b; | 25928 | s->char2b = char2b; |
| 25773 | s->hl = hl; | 25929 | s->hl = hl; |
| 25774 | s->row = row; | 25930 | s->row = row; |
| @@ -25839,7 +25995,7 @@ append_glyph_string (struct glyph_string **head, struct glyph_string **tail, | |||
| 25839 | 25995 | ||
| 25840 | static struct face * | 25996 | static struct face * |
| 25841 | get_char_face_and_encoding (struct frame *f, int c, int face_id, | 25997 | get_char_face_and_encoding (struct frame *f, int c, int face_id, |
| 25842 | XChar2b *char2b, bool display_p) | 25998 | unsigned *char2b, bool display_p) |
| 25843 | { | 25999 | { |
| 25844 | struct face *face = FACE_FROM_ID (f, face_id); | 26000 | struct face *face = FACE_FROM_ID (f, face_id); |
| 25845 | unsigned code = 0; | 26001 | unsigned code = 0; |
| @@ -25851,7 +26007,8 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id, | |||
| 25851 | if (code == FONT_INVALID_CODE) | 26007 | if (code == FONT_INVALID_CODE) |
| 25852 | code = 0; | 26008 | code = 0; |
| 25853 | } | 26009 | } |
| 25854 | STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | 26010 | /* Ensure that the code is only 2 bytes wide. */ |
| 26011 | *char2b = code & 0xFFFF; | ||
| 25855 | 26012 | ||
| 25856 | /* Make sure X resources of the face are allocated. */ | 26013 | /* Make sure X resources of the face are allocated. */ |
| 25857 | #ifdef HAVE_X_WINDOWS | 26014 | #ifdef HAVE_X_WINDOWS |
| @@ -25872,7 +26029,7 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id, | |||
| 25872 | 26029 | ||
| 25873 | static struct face * | 26030 | static struct face * |
| 25874 | get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, | 26031 | get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, |
| 25875 | XChar2b *char2b) | 26032 | unsigned *char2b) |
| 25876 | { | 26033 | { |
| 25877 | struct face *face; | 26034 | struct face *face; |
| 25878 | unsigned code = 0; | 26035 | unsigned code = 0; |
| @@ -25894,7 +26051,8 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, | |||
| 25894 | code = 0; | 26051 | code = 0; |
| 25895 | } | 26052 | } |
| 25896 | 26053 | ||
| 25897 | STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | 26054 | /* Ensure that the code is only 2 bytes wide. */ |
| 26055 | *char2b = code & 0xFFFF; | ||
| 25898 | return face; | 26056 | return face; |
| 25899 | } | 26057 | } |
| 25900 | 26058 | ||
| @@ -25903,7 +26061,7 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, | |||
| 25903 | Return true iff FONT has a glyph for C. */ | 26061 | Return true iff FONT has a glyph for C. */ |
| 25904 | 26062 | ||
| 25905 | static bool | 26063 | static bool |
| 25906 | get_char_glyph_code (int c, struct font *font, XChar2b *char2b) | 26064 | get_char_glyph_code (int c, struct font *font, unsigned *char2b) |
| 25907 | { | 26065 | { |
| 25908 | unsigned code; | 26066 | unsigned code; |
| 25909 | 26067 | ||
| @@ -25914,7 +26072,9 @@ get_char_glyph_code (int c, struct font *font, XChar2b *char2b) | |||
| 25914 | 26072 | ||
| 25915 | if (code == FONT_INVALID_CODE) | 26073 | if (code == FONT_INVALID_CODE) |
| 25916 | return false; | 26074 | return false; |
| 25917 | STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | 26075 | |
| 26076 | /* Ensure that the code is only 2 bytes wide. */ | ||
| 26077 | *char2b = code & 0xFFFF; | ||
| 25918 | return true; | 26078 | return true; |
| 25919 | } | 26079 | } |
| 25920 | 26080 | ||
| @@ -26027,7 +26187,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id, | |||
| 26027 | Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i); | 26187 | Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i); |
| 26028 | unsigned code = LGLYPH_CODE (lglyph); | 26188 | unsigned code = LGLYPH_CODE (lglyph); |
| 26029 | 26189 | ||
| 26030 | STORE_XCHAR2B ((s->char2b + i), code >> 8, code & 0xFF); | 26190 | /* Ensure that the code is only 2 bytes wide. */ |
| 26191 | s->char2b[i] = code & 0xFFFF; | ||
| 26031 | } | 26192 | } |
| 26032 | s->width = composition_gstring_width (lgstring, s->cmp_from, s->cmp_to, NULL); | 26193 | s->width = composition_gstring_width (lgstring, s->cmp_from, s->cmp_to, NULL); |
| 26033 | return glyph - s->row->glyphs[s->area]; | 26194 | return glyph - s->row->glyphs[s->area]; |
| @@ -26206,17 +26367,16 @@ fill_stretch_glyph_string (struct glyph_string *s, int start, int end) | |||
| 26206 | } | 26367 | } |
| 26207 | 26368 | ||
| 26208 | static struct font_metrics * | 26369 | static struct font_metrics * |
| 26209 | get_per_char_metric (struct font *font, XChar2b *char2b) | 26370 | get_per_char_metric (struct font *font, const unsigned *char2b) |
| 26210 | { | 26371 | { |
| 26211 | static struct font_metrics metrics; | 26372 | static struct font_metrics metrics; |
| 26212 | unsigned code; | ||
| 26213 | 26373 | ||
| 26214 | if (! font) | 26374 | if (! font) |
| 26215 | return NULL; | 26375 | return NULL; |
| 26216 | code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b); | 26376 | if (*char2b == FONT_INVALID_CODE) |
| 26217 | if (code == FONT_INVALID_CODE) | ||
| 26218 | return NULL; | 26377 | return NULL; |
| 26219 | font->driver->text_extents (font, &code, 1, &metrics); | 26378 | |
| 26379 | font->driver->text_extents (font, char2b, 1, &metrics); | ||
| 26220 | return &metrics; | 26380 | return &metrics; |
| 26221 | } | 26381 | } |
| 26222 | 26382 | ||
| @@ -26234,7 +26394,7 @@ normal_char_ascent_descent (struct font *font, int c, int *ascent, int *descent) | |||
| 26234 | 26394 | ||
| 26235 | if (FONT_TOO_HIGH (font)) | 26395 | if (FONT_TOO_HIGH (font)) |
| 26236 | { | 26396 | { |
| 26237 | XChar2b char2b; | 26397 | unsigned char2b; |
| 26238 | 26398 | ||
| 26239 | /* Get metrics of C, defaulting to a reasonably sized ASCII | 26399 | /* Get metrics of C, defaulting to a reasonably sized ASCII |
| 26240 | character. */ | 26400 | character. */ |
| @@ -26281,7 +26441,7 @@ gui_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int *r | |||
| 26281 | 26441 | ||
| 26282 | if (glyph->type == CHAR_GLYPH) | 26442 | if (glyph->type == CHAR_GLYPH) |
| 26283 | { | 26443 | { |
| 26284 | XChar2b char2b; | 26444 | unsigned char2b; |
| 26285 | struct face *face = get_glyph_face_and_encoding (f, glyph, &char2b); | 26445 | struct face *face = get_glyph_face_and_encoding (f, glyph, &char2b); |
| 26286 | if (face->font) | 26446 | if (face->font) |
| 26287 | { | 26447 | { |
| @@ -26595,7 +26755,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) | |||
| 26595 | do \ | 26755 | do \ |
| 26596 | { \ | 26756 | { \ |
| 26597 | int face_id; \ | 26757 | int face_id; \ |
| 26598 | XChar2b *char2b; \ | 26758 | unsigned *char2b; \ |
| 26599 | \ | 26759 | \ |
| 26600 | face_id = (row)->glyphs[area][START].face_id; \ | 26760 | face_id = (row)->glyphs[area][START].face_id; \ |
| 26601 | \ | 26761 | \ |
| @@ -26624,7 +26784,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) | |||
| 26624 | struct face *base_face = FACE_FROM_ID (f, face_id); \ | 26784 | struct face *base_face = FACE_FROM_ID (f, face_id); \ |
| 26625 | ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \ | 26785 | ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \ |
| 26626 | struct composition *cmp = composition_table[cmp_id]; \ | 26786 | struct composition *cmp = composition_table[cmp_id]; \ |
| 26627 | XChar2b *char2b; \ | 26787 | unsigned *char2b; \ |
| 26628 | struct glyph_string *first_s = NULL; \ | 26788 | struct glyph_string *first_s = NULL; \ |
| 26629 | int n; \ | 26789 | int n; \ |
| 26630 | \ | 26790 | \ |
| @@ -26656,7 +26816,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) | |||
| 26656 | #define BUILD_GSTRING_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ | 26816 | #define BUILD_GSTRING_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ |
| 26657 | do { \ | 26817 | do { \ |
| 26658 | int face_id; \ | 26818 | int face_id; \ |
| 26659 | XChar2b *char2b; \ | 26819 | unsigned *char2b; \ |
| 26660 | Lisp_Object gstring; \ | 26820 | Lisp_Object gstring; \ |
| 26661 | \ | 26821 | \ |
| 26662 | face_id = (row)->glyphs[area][START].face_id; \ | 26822 | face_id = (row)->glyphs[area][START].face_id; \ |
| @@ -28249,7 +28409,7 @@ gui_produce_glyphs (struct it *it) | |||
| 28249 | 28409 | ||
| 28250 | if (it->what == IT_CHARACTER) | 28410 | if (it->what == IT_CHARACTER) |
| 28251 | { | 28411 | { |
| 28252 | XChar2b char2b; | 28412 | unsigned char2b; |
| 28253 | struct face *face = FACE_FROM_ID (it->f, it->face_id); | 28413 | struct face *face = FACE_FROM_ID (it->f, it->face_id); |
| 28254 | struct font *font = face->font; | 28414 | struct font *font = face->font; |
| 28255 | struct font_metrics *pcm = NULL; | 28415 | struct font_metrics *pcm = NULL; |
| @@ -28648,7 +28808,7 @@ gui_produce_glyphs (struct it *it) | |||
| 28648 | int lbearing, rbearing; | 28808 | int lbearing, rbearing; |
| 28649 | int i, width, ascent, descent; | 28809 | int i, width, ascent, descent; |
| 28650 | int c; | 28810 | int c; |
| 28651 | XChar2b char2b; | 28811 | unsigned char2b; |
| 28652 | struct font_metrics *pcm; | 28812 | struct font_metrics *pcm; |
| 28653 | ptrdiff_t pos; | 28813 | ptrdiff_t pos; |
| 28654 | 28814 | ||
| @@ -30969,7 +31129,7 @@ Returns the alist element for the first matching AREA in MAP. */) | |||
| 30969 | 31129 | ||
| 30970 | /* Display frame CURSOR, optionally using shape defined by POINTER. */ | 31130 | /* Display frame CURSOR, optionally using shape defined by POINTER. */ |
| 30971 | static void | 31131 | static void |
| 30972 | define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer) | 31132 | define_frame_cursor1 (struct frame *f, Emacs_Cursor cursor, Lisp_Object pointer) |
| 30973 | { | 31133 | { |
| 30974 | #ifdef HAVE_WINDOW_SYSTEM | 31134 | #ifdef HAVE_WINDOW_SYSTEM |
| 30975 | if (!FRAME_WINDOW_P (f)) | 31135 | if (!FRAME_WINDOW_P (f)) |
| @@ -31021,7 +31181,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y, | |||
| 31021 | struct window *w = XWINDOW (window); | 31181 | struct window *w = XWINDOW (window); |
| 31022 | struct frame *f = XFRAME (w->frame); | 31182 | struct frame *f = XFRAME (w->frame); |
| 31023 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | 31183 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); |
| 31024 | Cursor cursor = No_Cursor; | 31184 | Emacs_Cursor cursor = No_Cursor; |
| 31025 | Lisp_Object pointer = Qnil; | 31185 | Lisp_Object pointer = Qnil; |
| 31026 | int dx, dy, width, height; | 31186 | int dx, dy, width, height; |
| 31027 | ptrdiff_t charpos; | 31187 | ptrdiff_t charpos; |
| @@ -31334,7 +31494,7 @@ note_mouse_highlight (struct frame *f, int x, int y) | |||
| 31334 | enum window_part part = ON_NOTHING; | 31494 | enum window_part part = ON_NOTHING; |
| 31335 | Lisp_Object window; | 31495 | Lisp_Object window; |
| 31336 | struct window *w; | 31496 | struct window *w; |
| 31337 | Cursor cursor = No_Cursor; | 31497 | Emacs_Cursor cursor = No_Cursor; |
| 31338 | Lisp_Object pointer = Qnil; /* Takes precedence over cursor! */ | 31498 | Lisp_Object pointer = Qnil; /* Takes precedence over cursor! */ |
| 31339 | struct buffer *b; | 31499 | struct buffer *b; |
| 31340 | 31500 | ||
| @@ -31642,7 +31802,9 @@ note_mouse_highlight (struct frame *f, int x, int y) | |||
| 31642 | is currently hidden to avoid Bug#30519. */ | 31802 | is currently hidden to avoid Bug#30519. */ |
| 31643 | || (!hlinfo->mouse_face_hidden | 31803 | || (!hlinfo->mouse_face_hidden |
| 31644 | && OVERLAYP (hlinfo->mouse_face_overlay) | 31804 | && OVERLAYP (hlinfo->mouse_face_overlay) |
| 31645 | && mouse_face_overlay_overlaps (hlinfo->mouse_face_overlay))) | 31805 | /* It's possible the overlay was deleted (Bug#35273). */ |
| 31806 | && XMARKER (OVERLAY_START (hlinfo->mouse_face_overlay))->buffer | ||
| 31807 | && mouse_face_overlay_overlaps (hlinfo->mouse_face_overlay))) | ||
| 31646 | { | 31808 | { |
| 31647 | /* Find the highest priority overlay with a mouse-face. */ | 31809 | /* Find the highest priority overlay with a mouse-face. */ |
| 31648 | Lisp_Object overlay = Qnil; | 31810 | Lisp_Object overlay = Qnil; |
| @@ -31951,7 +32113,7 @@ cancel_mouse_face (struct frame *f) | |||
| 31951 | which intersects rectangle R. R is in window-relative coordinates. */ | 32113 | which intersects rectangle R. R is in window-relative coordinates. */ |
| 31952 | 32114 | ||
| 31953 | static void | 32115 | static void |
| 31954 | expose_area (struct window *w, struct glyph_row *row, XRectangle *r, | 32116 | expose_area (struct window *w, struct glyph_row *row, const Emacs_Rectangle *r, |
| 31955 | enum glyph_row_area area) | 32117 | enum glyph_row_area area) |
| 31956 | { | 32118 | { |
| 31957 | struct glyph *first = row->glyphs[area]; | 32119 | struct glyph *first = row->glyphs[area]; |
| @@ -32009,7 +32171,7 @@ expose_area (struct window *w, struct glyph_row *row, XRectangle *r, | |||
| 32009 | true if mouse-face was overwritten. */ | 32171 | true if mouse-face was overwritten. */ |
| 32010 | 32172 | ||
| 32011 | static bool | 32173 | static bool |
| 32012 | expose_line (struct window *w, struct glyph_row *row, XRectangle *r) | 32174 | expose_line (struct window *w, struct glyph_row *row, const Emacs_Rectangle *r) |
| 32013 | { | 32175 | { |
| 32014 | eassert (row->enabled_p); | 32176 | eassert (row->enabled_p); |
| 32015 | 32177 | ||
| @@ -32044,7 +32206,7 @@ static void | |||
| 32044 | expose_overlaps (struct window *w, | 32206 | expose_overlaps (struct window *w, |
| 32045 | struct glyph_row *first_overlapping_row, | 32207 | struct glyph_row *first_overlapping_row, |
| 32046 | struct glyph_row *last_overlapping_row, | 32208 | struct glyph_row *last_overlapping_row, |
| 32047 | XRectangle *r) | 32209 | const Emacs_Rectangle *r) |
| 32048 | { | 32210 | { |
| 32049 | struct glyph_row *row; | 32211 | struct glyph_row *row; |
| 32050 | 32212 | ||
| @@ -32070,9 +32232,9 @@ expose_overlaps (struct window *w, | |||
| 32070 | /* Return true if W's cursor intersects rectangle R. */ | 32232 | /* Return true if W's cursor intersects rectangle R. */ |
| 32071 | 32233 | ||
| 32072 | static bool | 32234 | static bool |
| 32073 | phys_cursor_in_rect_p (struct window *w, XRectangle *r) | 32235 | phys_cursor_in_rect_p (struct window *w, const Emacs_Rectangle *r) |
| 32074 | { | 32236 | { |
| 32075 | XRectangle cr, result; | 32237 | Emacs_Rectangle cr, result; |
| 32076 | struct glyph *cursor_glyph; | 32238 | struct glyph *cursor_glyph; |
| 32077 | struct glyph_row *row; | 32239 | struct glyph_row *row; |
| 32078 | 32240 | ||
| @@ -32230,10 +32392,10 @@ gui_draw_bottom_divider (struct window *w) | |||
| 32230 | mouse-face. */ | 32392 | mouse-face. */ |
| 32231 | 32393 | ||
| 32232 | static bool | 32394 | static bool |
| 32233 | expose_window (struct window *w, XRectangle *fr) | 32395 | expose_window (struct window *w, const Emacs_Rectangle *fr) |
| 32234 | { | 32396 | { |
| 32235 | struct frame *f = XFRAME (w->frame); | 32397 | struct frame *f = XFRAME (w->frame); |
| 32236 | XRectangle wr, r; | 32398 | Emacs_Rectangle wr, r; |
| 32237 | bool mouse_face_overwritten_p = false; | 32399 | bool mouse_face_overwritten_p = false; |
| 32238 | 32400 | ||
| 32239 | /* If window is not yet fully initialized, do nothing. This can | 32401 | /* If window is not yet fully initialized, do nothing. This can |
| @@ -32392,7 +32554,7 @@ expose_window (struct window *w, XRectangle *fr) | |||
| 32392 | true if the exposure overwrites mouse-face. */ | 32554 | true if the exposure overwrites mouse-face. */ |
| 32393 | 32555 | ||
| 32394 | static bool | 32556 | static bool |
| 32395 | expose_window_tree (struct window *w, XRectangle *r) | 32557 | expose_window_tree (struct window *w, const Emacs_Rectangle *r) |
| 32396 | { | 32558 | { |
| 32397 | struct frame *f = XFRAME (w->frame); | 32559 | struct frame *f = XFRAME (w->frame); |
| 32398 | bool mouse_face_overwritten_p = false; | 32560 | bool mouse_face_overwritten_p = false; |
| @@ -32420,7 +32582,7 @@ expose_window_tree (struct window *w, XRectangle *r) | |||
| 32420 | void | 32582 | void |
| 32421 | expose_frame (struct frame *f, int x, int y, int w, int h) | 32583 | expose_frame (struct frame *f, int x, int y, int w, int h) |
| 32422 | { | 32584 | { |
| 32423 | XRectangle r; | 32585 | Emacs_Rectangle r; |
| 32424 | bool mouse_face_overwritten_p = false; | 32586 | bool mouse_face_overwritten_p = false; |
| 32425 | 32587 | ||
| 32426 | TRACE ((stderr, "expose_frame ")); | 32588 | TRACE ((stderr, "expose_frame ")); |
| @@ -32507,10 +32669,11 @@ expose_frame (struct frame *f, int x, int y, int w, int h) | |||
| 32507 | empty. */ | 32669 | empty. */ |
| 32508 | 32670 | ||
| 32509 | bool | 32671 | bool |
| 32510 | gui_intersect_rectangles (XRectangle *r1, XRectangle *r2, XRectangle *result) | 32672 | gui_intersect_rectangles (const Emacs_Rectangle *r1, const Emacs_Rectangle *r2, |
| 32673 | Emacs_Rectangle *result) | ||
| 32511 | { | 32674 | { |
| 32512 | XRectangle *left, *right; | 32675 | const Emacs_Rectangle *left, *right; |
| 32513 | XRectangle *upper, *lower; | 32676 | const Emacs_Rectangle *upper, *lower; |
| 32514 | bool intersection_p = false; | 32677 | bool intersection_p = false; |
| 32515 | 32678 | ||
| 32516 | /* Rearrange so that R1 is the left-most rectangle. */ | 32679 | /* Rearrange so that R1 is the left-most rectangle. */ |
| @@ -32656,6 +32819,9 @@ be let-bound around code that needs to disable messages temporarily. */); | |||
| 32656 | /* Name of a text property which disables line-number display. */ | 32819 | /* Name of a text property which disables line-number display. */ |
| 32657 | DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable"); | 32820 | DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable"); |
| 32658 | 32821 | ||
| 32822 | /* Name of the face used to display fill column indicator character. */ | ||
| 32823 | DEFSYM (Qfill_column_indicator, "fill-column-indicator"); | ||
| 32824 | |||
| 32659 | /* Name and number of the face used to highlight escape glyphs. */ | 32825 | /* Name and number of the face used to highlight escape glyphs. */ |
| 32660 | DEFSYM (Qescape_glyph, "escape-glyph"); | 32826 | DEFSYM (Qescape_glyph, "escape-glyph"); |
| 32661 | 32827 | ||
| @@ -33228,6 +33394,30 @@ either `relative' or `visual'. */); | |||
| 33228 | DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen"); | 33394 | DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen"); |
| 33229 | Fmake_variable_buffer_local (Qdisplay_line_numbers_widen); | 33395 | Fmake_variable_buffer_local (Qdisplay_line_numbers_widen); |
| 33230 | 33396 | ||
| 33397 | DEFVAR_BOOL ("display-fill-column-indicator", Vdisplay_fill_column_indicator, | ||
| 33398 | doc: /* Non-nil means display the fill column indicator. */); | ||
| 33399 | Vdisplay_fill_column_indicator = false; | ||
| 33400 | DEFSYM (Qdisplay_fill_column_indicator, "display-fill-column-indicator"); | ||
| 33401 | Fmake_variable_buffer_local (Qdisplay_fill_column_indicator); | ||
| 33402 | |||
| 33403 | DEFVAR_LISP ("display-fill-column-indicator-column", Vdisplay_fill_column_indicator_column, | ||
| 33404 | doc: /* Column for indicator when `display-fill-column-indicator' | ||
| 33405 | is non-nil. The default value is t which means that the indicator | ||
| 33406 | will use the `fill-column' variable. If it is set to an integer the | ||
| 33407 | indicator will be drawn in that column. */); | ||
| 33408 | Vdisplay_fill_column_indicator_column = Qt; | ||
| 33409 | DEFSYM (Qdisplay_fill_column_indicator_column, "display-fill-column-indicator-column"); | ||
| 33410 | Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_column); | ||
| 33411 | |||
| 33412 | DEFVAR_LISP ("display-fill-column-indicator-character", Vdisplay_fill_column_indicator_character, | ||
| 33413 | doc: /* Character to draw the indicator when | ||
| 33414 | `display-fill-column-indicator' is non-nil. The default is U+2502 but | ||
| 33415 | a good alternative is (ascii 124) if the font in fill-column-indicator | ||
| 33416 | face does not support Unicode characters. */); | ||
| 33417 | Vdisplay_fill_column_indicator_character = Qnil; | ||
| 33418 | DEFSYM (Qdisplay_fill_column_indicator_character, "display-fill-column-indicator-character"); | ||
| 33419 | Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_character); | ||
| 33420 | |||
| 33231 | DEFVAR_BOOL ("inhibit-eval-during-redisplay", inhibit_eval_during_redisplay, | 33421 | DEFVAR_BOOL ("inhibit-eval-during-redisplay", inhibit_eval_during_redisplay, |
| 33232 | doc: /* Non-nil means don't eval Lisp during redisplay. */); | 33422 | doc: /* Non-nil means don't eval Lisp during redisplay. */); |
| 33233 | inhibit_eval_during_redisplay = false; | 33423 | inhibit_eval_during_redisplay = false; |
diff --git a/src/xfaces.c b/src/xfaces.c index 7e04c0e9953..d211ec8c460 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -348,7 +348,7 @@ static void free_face_cache (struct face_cache *); | |||
| 348 | static bool merge_face_ref (struct window *w, | 348 | static bool merge_face_ref (struct window *w, |
| 349 | struct frame *, Lisp_Object, Lisp_Object *, | 349 | struct frame *, Lisp_Object, Lisp_Object *, |
| 350 | bool, struct named_merge_point *); | 350 | bool, struct named_merge_point *); |
| 351 | static int color_distance (XColor *x, XColor *y); | 351 | static int color_distance (Emacs_Color *x, Emacs_Color *y); |
| 352 | 352 | ||
| 353 | #ifdef HAVE_WINDOW_SYSTEM | 353 | #ifdef HAVE_WINDOW_SYSTEM |
| 354 | static void set_font_frame_param (Lisp_Object, Lisp_Object); | 354 | static void set_font_frame_param (Lisp_Object, Lisp_Object); |
| @@ -513,12 +513,12 @@ x_free_gc (struct frame *f, GC gc) | |||
| 513 | #ifdef HAVE_NTGUI | 513 | #ifdef HAVE_NTGUI |
| 514 | /* W32 emulation of GCs */ | 514 | /* W32 emulation of GCs */ |
| 515 | 515 | ||
| 516 | static GC | 516 | static Emacs_GC * |
| 517 | x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv) | 517 | x_create_gc (struct frame *f, unsigned long mask, Emacs_GC *egc) |
| 518 | { | 518 | { |
| 519 | GC gc; | 519 | Emacs_GC *gc; |
| 520 | block_input (); | 520 | block_input (); |
| 521 | gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, xgcv); | 521 | gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, egc); |
| 522 | unblock_input (); | 522 | unblock_input (); |
| 523 | IF_DEBUG (++ngcs); | 523 | IF_DEBUG (++ngcs); |
| 524 | return gc; | 524 | return gc; |
| @@ -528,7 +528,7 @@ x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv) | |||
| 528 | /* Free GC which was used on frame F. */ | 528 | /* Free GC which was used on frame F. */ |
| 529 | 529 | ||
| 530 | static void | 530 | static void |
| 531 | x_free_gc (struct frame *f, GC gc) | 531 | x_free_gc (struct frame *f, Emacs_GC *gc) |
| 532 | { | 532 | { |
| 533 | IF_DEBUG ((--ngcs, eassert (ngcs >= 0))); | 533 | IF_DEBUG ((--ngcs, eassert (ngcs >= 0))); |
| 534 | xfree (gc); | 534 | xfree (gc); |
| @@ -539,18 +539,18 @@ x_free_gc (struct frame *f, GC gc) | |||
| 539 | #ifdef HAVE_NS | 539 | #ifdef HAVE_NS |
| 540 | /* NS emulation of GCs */ | 540 | /* NS emulation of GCs */ |
| 541 | 541 | ||
| 542 | static GC | 542 | static Emacs_GC * |
| 543 | x_create_gc (struct frame *f, | 543 | x_create_gc (struct frame *f, |
| 544 | unsigned long mask, | 544 | unsigned long mask, |
| 545 | XGCValues *xgcv) | 545 | Emacs_GC *egc) |
| 546 | { | 546 | { |
| 547 | GC gc = xmalloc (sizeof *gc); | 547 | Emacs_GC *gc = xmalloc (sizeof *gc); |
| 548 | *gc = *xgcv; | 548 | *gc = *egc; |
| 549 | return gc; | 549 | return gc; |
| 550 | } | 550 | } |
| 551 | 551 | ||
| 552 | static void | 552 | static void |
| 553 | x_free_gc (struct frame *f, GC gc) | 553 | x_free_gc (struct frame *f, Emacs_GC *gc) |
| 554 | { | 554 | { |
| 555 | xfree (gc); | 555 | xfree (gc); |
| 556 | } | 556 | } |
| @@ -802,7 +802,7 @@ load_pixmap (struct frame *f, Lisp_Object name) | |||
| 802 | 802 | ||
| 803 | 803 | ||
| 804 | /*********************************************************************** | 804 | /*********************************************************************** |
| 805 | X Colors | 805 | Color Handling |
| 806 | ***********************************************************************/ | 806 | ***********************************************************************/ |
| 807 | 807 | ||
| 808 | /* Parse RGB_LIST, and fill in the RGB fields of COLOR. | 808 | /* Parse RGB_LIST, and fill in the RGB fields of COLOR. |
| @@ -810,7 +810,7 @@ load_pixmap (struct frame *f, Lisp_Object name) | |||
| 810 | Return true iff RGB_LIST is OK. */ | 810 | Return true iff RGB_LIST is OK. */ |
| 811 | 811 | ||
| 812 | static bool | 812 | static bool |
| 813 | parse_rgb_list (Lisp_Object rgb_list, XColor *color) | 813 | parse_rgb_list (Lisp_Object rgb_list, Emacs_Color *color) |
| 814 | { | 814 | { |
| 815 | #define PARSE_RGB_LIST_FIELD(field) \ | 815 | #define PARSE_RGB_LIST_FIELD(field) \ |
| 816 | if (CONSP (rgb_list) && FIXNUMP (XCAR (rgb_list))) \ | 816 | if (CONSP (rgb_list) && FIXNUMP (XCAR (rgb_list))) \ |
| @@ -835,8 +835,8 @@ parse_rgb_list (Lisp_Object rgb_list, XColor *color) | |||
| 835 | returned in it. */ | 835 | returned in it. */ |
| 836 | 836 | ||
| 837 | static bool | 837 | static bool |
| 838 | tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, | 838 | tty_lookup_color (struct frame *f, Lisp_Object color, Emacs_Color *tty_color, |
| 839 | XColor *std_color) | 839 | Emacs_Color *std_color) |
| 840 | { | 840 | { |
| 841 | Lisp_Object frame, color_desc; | 841 | Lisp_Object frame, color_desc; |
| 842 | 842 | ||
| @@ -897,7 +897,7 @@ tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, | |||
| 897 | 897 | ||
| 898 | bool | 898 | bool |
| 899 | tty_defined_color (struct frame *f, const char *color_name, | 899 | tty_defined_color (struct frame *f, const char *color_name, |
| 900 | XColor *color_def, bool alloc, bool _makeIndex) | 900 | Emacs_Color *color_def, bool alloc, bool _makeIndex) |
| 901 | { | 901 | { |
| 902 | bool status = true; | 902 | bool status = true; |
| 903 | 903 | ||
| @@ -965,7 +965,7 @@ tty_color_name (struct frame *f, int idx) | |||
| 965 | static bool | 965 | static bool |
| 966 | face_color_gray_p (struct frame *f, const char *color_name) | 966 | face_color_gray_p (struct frame *f, const char *color_name) |
| 967 | { | 967 | { |
| 968 | XColor color; | 968 | Emacs_Color color; |
| 969 | bool gray_p; | 969 | bool gray_p; |
| 970 | 970 | ||
| 971 | if (FRAME_TERMINAL (f)->defined_color_hook | 971 | if (FRAME_TERMINAL (f)->defined_color_hook |
| @@ -994,7 +994,7 @@ face_color_supported_p (struct frame *f, const char *color_name, | |||
| 994 | bool background_p) | 994 | bool background_p) |
| 995 | { | 995 | { |
| 996 | Lisp_Object frame; | 996 | Lisp_Object frame; |
| 997 | XColor not_used; | 997 | Emacs_Color not_used; |
| 998 | 998 | ||
| 999 | XSETFRAME (frame, f); | 999 | XSETFRAME (frame, f); |
| 1000 | return | 1000 | return |
| @@ -1043,7 +1043,7 @@ COLOR must be a valid color name. */) | |||
| 1043 | 1043 | ||
| 1044 | static unsigned long | 1044 | static unsigned long |
| 1045 | load_color2 (struct frame *f, struct face *face, Lisp_Object name, | 1045 | load_color2 (struct frame *f, struct face *face, Lisp_Object name, |
| 1046 | enum lface_attribute_index target_index, XColor *color) | 1046 | enum lface_attribute_index target_index, Emacs_Color *color) |
| 1047 | { | 1047 | { |
| 1048 | eassert (STRINGP (name)); | 1048 | eassert (STRINGP (name)); |
| 1049 | eassert (target_index == LFACE_FOREGROUND_INDEX | 1049 | eassert (target_index == LFACE_FOREGROUND_INDEX |
| @@ -1117,7 +1117,7 @@ unsigned long | |||
| 1117 | load_color (struct frame *f, struct face *face, Lisp_Object name, | 1117 | load_color (struct frame *f, struct face *face, Lisp_Object name, |
| 1118 | enum lface_attribute_index target_index) | 1118 | enum lface_attribute_index target_index) |
| 1119 | { | 1119 | { |
| 1120 | XColor color; | 1120 | Emacs_Color color; |
| 1121 | return load_color2 (f, face, name, target_index, &color); | 1121 | return load_color2 (f, face, name, target_index, &color); |
| 1122 | } | 1122 | } |
| 1123 | 1123 | ||
| @@ -1134,7 +1134,7 @@ load_face_colors (struct frame *f, struct face *face, | |||
| 1134 | Lisp_Object attrs[LFACE_VECTOR_SIZE]) | 1134 | Lisp_Object attrs[LFACE_VECTOR_SIZE]) |
| 1135 | { | 1135 | { |
| 1136 | Lisp_Object fg, bg, dfg; | 1136 | Lisp_Object fg, bg, dfg; |
| 1137 | XColor xfg, xbg; | 1137 | Emacs_Color xfg, xbg; |
| 1138 | 1138 | ||
| 1139 | bg = attrs[LFACE_BACKGROUND_INDEX]; | 1139 | bg = attrs[LFACE_BACKGROUND_INDEX]; |
| 1140 | fg = attrs[LFACE_FOREGROUND_INDEX]; | 1140 | fg = attrs[LFACE_FOREGROUND_INDEX]; |
| @@ -2265,11 +2265,12 @@ filter_face_ref (Lisp_Object face_ref, | |||
| 2265 | } | 2265 | } |
| 2266 | 2266 | ||
| 2267 | /* Merge face attributes from the lisp `face reference' FACE_REF on | 2267 | /* Merge face attributes from the lisp `face reference' FACE_REF on |
| 2268 | frame F into the face attribute vector TO. If ERR_MSGS, | 2268 | frame F into the face attribute vector TO as appropriate for |
| 2269 | problems with FACE_REF cause an error message to be shown. Return | 2269 | window W; W is used only for filtering face specs. If ERR_MSGS |
| 2270 | true if no errors occurred (regardless of the value of ERR_MSGS). | 2270 | is non-zero, problems with FACE_REF cause an error message to be |
| 2271 | Use NAMED_MERGE_POINTS to detect loops in face inheritance or | 2271 | shown. Return true if no errors occurred (regardless of the value |
| 2272 | list structure; it may be 0 for most callers. | 2272 | of ERR_MSGS). Use NAMED_MERGE_POINTS to detect loops in face |
| 2273 | inheritance or list structure; it may be 0 for most callers. | ||
| 2273 | 2274 | ||
| 2274 | FACE_REF may be a single face specification or a list of such | 2275 | FACE_REF may be a single face specification or a list of such |
| 2275 | specifications. Each face specification can be: | 2276 | specifications. Each face specification can be: |
| @@ -2286,9 +2287,10 @@ filter_face_ref (Lisp_Object face_ref, | |||
| 2286 | 2287 | ||
| 2287 | 4. Conses of the form | 2288 | 4. Conses of the form |
| 2288 | (:filtered (:window PARAMETER VALUE) FACE-SPECIFICATION), | 2289 | (:filtered (:window PARAMETER VALUE) FACE-SPECIFICATION), |
| 2289 | which applies FACE-SPECIFICATION only if the | 2290 | which applies FACE-SPECIFICATION only if the given face attributes |
| 2290 | given face attributes are being evaluated in the context of a | 2291 | are being evaluated in the context of a window with a parameter |
| 2291 | window with a parameter named PARAMETER being EQ VALUE. | 2292 | named PARAMETER being EQ VALUE. In this case, W specifies the window |
| 2293 | for which the filtered face spec is to be evaluated. | ||
| 2292 | 2294 | ||
| 2293 | 5. nil, which means to merge nothing. | 2295 | 5. nil, which means to merge nothing. |
| 2294 | 2296 | ||
| @@ -4138,25 +4140,25 @@ prepare_face_for_display (struct frame *f, struct face *face) | |||
| 4138 | 4140 | ||
| 4139 | if (face->gc == 0) | 4141 | if (face->gc == 0) |
| 4140 | { | 4142 | { |
| 4141 | XGCValues xgcv; | 4143 | Emacs_GC egc; |
| 4142 | unsigned long mask = GCForeground | GCBackground | GCGraphicsExposures; | 4144 | unsigned long mask = GCForeground | GCBackground | GCGraphicsExposures; |
| 4143 | 4145 | ||
| 4144 | xgcv.foreground = face->foreground; | 4146 | egc.foreground = face->foreground; |
| 4145 | xgcv.background = face->background; | 4147 | egc.background = face->background; |
| 4146 | #ifdef HAVE_X_WINDOWS | 4148 | #ifdef HAVE_X_WINDOWS |
| 4147 | xgcv.graphics_exposures = False; | 4149 | egc.graphics_exposures = False; |
| 4148 | #endif | 4150 | #endif |
| 4149 | 4151 | ||
| 4150 | block_input (); | 4152 | block_input (); |
| 4151 | #ifdef HAVE_X_WINDOWS | 4153 | #ifdef HAVE_X_WINDOWS |
| 4152 | if (face->stipple) | 4154 | if (face->stipple) |
| 4153 | { | 4155 | { |
| 4154 | xgcv.fill_style = FillOpaqueStippled; | 4156 | egc.fill_style = FillOpaqueStippled; |
| 4155 | xgcv.stipple = image_bitmap_pixmap (f, face->stipple); | 4157 | egc.stipple = image_bitmap_pixmap (f, face->stipple); |
| 4156 | mask |= GCFillStyle | GCStipple; | 4158 | mask |= GCFillStyle | GCStipple; |
| 4157 | } | 4159 | } |
| 4158 | #endif | 4160 | #endif |
| 4159 | face->gc = x_create_gc (f, mask, &xgcv); | 4161 | face->gc = x_create_gc (f, mask, &egc); |
| 4160 | if (face->font) | 4162 | if (face->font) |
| 4161 | font_prepare_for_face (f, face); | 4163 | font_prepare_for_face (f, face); |
| 4162 | unblock_input (); | 4164 | unblock_input (); |
| @@ -4168,7 +4170,7 @@ prepare_face_for_display (struct frame *f, struct face *face) | |||
| 4168 | /* Returns the `distance' between the colors X and Y. */ | 4170 | /* Returns the `distance' between the colors X and Y. */ |
| 4169 | 4171 | ||
| 4170 | static int | 4172 | static int |
| 4171 | color_distance (XColor *x, XColor *y) | 4173 | color_distance (Emacs_Color *x, Emacs_Color *y) |
| 4172 | { | 4174 | { |
| 4173 | /* This formula is from a paper titled `Colour metric' by Thiadmer Riemersma. | 4175 | /* This formula is from a paper titled `Colour metric' by Thiadmer Riemersma. |
| 4174 | Quoting from that paper: | 4176 | Quoting from that paper: |
| @@ -4203,7 +4205,7 @@ two lists of the form (RED GREEN BLUE) aforementioned. */) | |||
| 4203 | Lisp_Object metric) | 4205 | Lisp_Object metric) |
| 4204 | { | 4206 | { |
| 4205 | struct frame *f = decode_live_frame (frame); | 4207 | struct frame *f = decode_live_frame (frame); |
| 4206 | XColor cdef1, cdef2; | 4208 | Emacs_Color cdef1, cdef2; |
| 4207 | 4209 | ||
| 4208 | if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1)) | 4210 | if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1)) |
| 4209 | && !(STRINGP (color1) | 4211 | && !(STRINGP (color1) |
| @@ -4883,8 +4885,8 @@ tty_supports_face_attributes_p (struct frame *f, | |||
| 4883 | { | 4885 | { |
| 4884 | int weight, slant; | 4886 | int weight, slant; |
| 4885 | Lisp_Object val, fg, bg; | 4887 | Lisp_Object val, fg, bg; |
| 4886 | XColor fg_tty_color, fg_std_color; | 4888 | Emacs_Color fg_tty_color, fg_std_color; |
| 4887 | XColor bg_tty_color, bg_std_color; | 4889 | Emacs_Color bg_tty_color, bg_std_color; |
| 4888 | unsigned test_caps = 0; | 4890 | unsigned test_caps = 0; |
| 4889 | Lisp_Object *def_attrs = def_face->lface; | 4891 | Lisp_Object *def_attrs = def_face->lface; |
| 4890 | 4892 | ||
| @@ -4986,7 +4988,7 @@ tty_supports_face_attributes_p (struct frame *f, | |||
| 4986 | else | 4988 | else |
| 4987 | /* Make sure the color is really different than the default. */ | 4989 | /* Make sure the color is really different than the default. */ |
| 4988 | { | 4990 | { |
| 4989 | XColor def_fg_color; | 4991 | Emacs_Color def_fg_color; |
| 4990 | if (tty_lookup_color (f, def_fg, &def_fg_color, 0) | 4992 | if (tty_lookup_color (f, def_fg, &def_fg_color, 0) |
| 4991 | && (color_distance (&fg_tty_color, &def_fg_color) | 4993 | && (color_distance (&fg_tty_color, &def_fg_color) |
| 4992 | <= TTY_SAME_COLOR_THRESHOLD)) | 4994 | <= TTY_SAME_COLOR_THRESHOLD)) |
| @@ -5010,7 +5012,7 @@ tty_supports_face_attributes_p (struct frame *f, | |||
| 5010 | else | 5012 | else |
| 5011 | /* Make sure the color is really different than the default. */ | 5013 | /* Make sure the color is really different than the default. */ |
| 5012 | { | 5014 | { |
| 5013 | XColor def_bg_color; | 5015 | Emacs_Color def_bg_color; |
| 5014 | if (tty_lookup_color (f, def_bg, &def_bg_color, 0) | 5016 | if (tty_lookup_color (f, def_bg, &def_bg_color, 0) |
| 5015 | && (color_distance (&bg_tty_color, &def_bg_color) | 5017 | && (color_distance (&bg_tty_color, &def_bg_color) |
| 5016 | <= TTY_SAME_COLOR_THRESHOLD)) | 5018 | <= TTY_SAME_COLOR_THRESHOLD)) |
diff --git a/src/xfns.c b/src/xfns.c index 7ef69f1b222..460dd1316e6 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -653,7 +653,7 @@ gamma_correct (struct frame *f, XColor *color) | |||
| 653 | 653 | ||
| 654 | bool | 654 | bool |
| 655 | x_defined_color (struct frame *f, const char *color_name, | 655 | x_defined_color (struct frame *f, const char *color_name, |
| 656 | XColor *color, bool alloc_p, bool _makeIndex) | 656 | Emacs_Color *color, bool alloc_p, bool _makeIndex) |
| 657 | { | 657 | { |
| 658 | bool success_p = false; | 658 | bool success_p = false; |
| 659 | Colormap cmap = FRAME_X_COLORMAP (f); | 659 | Colormap cmap = FRAME_X_COLORMAP (f); |
| @@ -2784,6 +2784,9 @@ set_up_x_back_buffer (struct frame *f) | |||
| 2784 | block_input (); | 2784 | block_input (); |
| 2785 | if (FRAME_X_WINDOW (f) && !FRAME_X_DOUBLE_BUFFERED_P (f)) | 2785 | if (FRAME_X_WINDOW (f) && !FRAME_X_DOUBLE_BUFFERED_P (f)) |
| 2786 | { | 2786 | { |
| 2787 | #ifdef USE_CAIRO | ||
| 2788 | x_cr_destroy_frame_context (f); | ||
| 2789 | #endif | ||
| 2787 | FRAME_X_RAW_DRAWABLE (f) = FRAME_X_WINDOW (f); | 2790 | FRAME_X_RAW_DRAWABLE (f) = FRAME_X_WINDOW (f); |
| 2788 | if (FRAME_DISPLAY_INFO (f)->supports_xdbe) | 2791 | if (FRAME_DISPLAY_INFO (f)->supports_xdbe) |
| 2789 | { | 2792 | { |
| @@ -2813,6 +2816,9 @@ tear_down_x_back_buffer (struct frame *f) | |||
| 2813 | { | 2816 | { |
| 2814 | if (FRAME_X_DOUBLE_BUFFERED_P (f)) | 2817 | if (FRAME_X_DOUBLE_BUFFERED_P (f)) |
| 2815 | { | 2818 | { |
| 2819 | #ifdef USE_CAIRO | ||
| 2820 | x_cr_destroy_frame_context (f); | ||
| 2821 | #endif | ||
| 2816 | XdbeDeallocateBackBufferName (FRAME_X_DISPLAY (f), | 2822 | XdbeDeallocateBackBufferName (FRAME_X_DISPLAY (f), |
| 2817 | FRAME_X_DRAWABLE (f)); | 2823 | FRAME_X_DRAWABLE (f)); |
| 2818 | FRAME_X_RAW_DRAWABLE (f) = FRAME_X_WINDOW (f); | 2824 | FRAME_X_RAW_DRAWABLE (f) = FRAME_X_WINDOW (f); |
diff --git a/src/xfont.c b/src/xfont.c index 5ecbd6de33b..81808e7a62e 100644 --- a/src/xfont.c +++ b/src/xfont.c | |||
| @@ -46,18 +46,20 @@ struct xfont_info | |||
| 46 | 46 | ||
| 47 | /* Prototypes of support functions. */ | 47 | /* Prototypes of support functions. */ |
| 48 | 48 | ||
| 49 | static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *); | 49 | static XCharStruct *xfont_get_pcm (XFontStruct *, unsigned char2b); |
| 50 | 50 | ||
| 51 | /* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B | 51 | /* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B |
| 52 | is not contained in the font. */ | 52 | is not contained in the font. */ |
| 53 | 53 | ||
| 54 | static XCharStruct * | 54 | static XCharStruct * |
| 55 | xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) | 55 | xfont_get_pcm (XFontStruct *xfont, unsigned char2b) |
| 56 | { | 56 | { |
| 57 | /* The result metric information. */ | 57 | /* The result metric information. */ |
| 58 | XCharStruct *pcm = NULL; | 58 | XCharStruct *pcm = NULL; |
| 59 | const unsigned char byte1 = char2b >> 8; | ||
| 60 | const unsigned char byte2 = char2b & 0xFF; | ||
| 59 | 61 | ||
| 60 | eassert (xfont && char2b); | 62 | eassert (xfont); |
| 61 | 63 | ||
| 62 | if (xfont->per_char != NULL) | 64 | if (xfont->per_char != NULL) |
| 63 | { | 65 | { |
| @@ -66,13 +68,13 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) | |||
| 66 | /* min_char_or_byte2 specifies the linear character index | 68 | /* min_char_or_byte2 specifies the linear character index |
| 67 | corresponding to the first element of the per_char array, | 69 | corresponding to the first element of the per_char array, |
| 68 | max_char_or_byte2 is the index of the last character. A | 70 | max_char_or_byte2 is the index of the last character. A |
| 69 | character with non-zero CHAR2B->byte1 is not in the font. | 71 | character with non-zero byte1 is not in the font. |
| 70 | A character with byte2 less than min_char_or_byte2 or | 72 | A character with byte2 less than min_char_or_byte2 or |
| 71 | greater max_char_or_byte2 is not in the font. */ | 73 | greater max_char_or_byte2 is not in the font. */ |
| 72 | if (char2b->byte1 == 0 | 74 | if (byte1 == 0 |
| 73 | && char2b->byte2 >= xfont->min_char_or_byte2 | 75 | && byte2 >= xfont->min_char_or_byte2 |
| 74 | && char2b->byte2 <= xfont->max_char_or_byte2) | 76 | && byte2 <= xfont->max_char_or_byte2) |
| 75 | pcm = xfont->per_char + char2b->byte2 - xfont->min_char_or_byte2; | 77 | pcm = xfont->per_char + byte2 - xfont->min_char_or_byte2; |
| 76 | } | 78 | } |
| 77 | else | 79 | else |
| 78 | { | 80 | { |
| @@ -89,14 +91,14 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) | |||
| 89 | D = max_char_or_byte2 - min_char_or_byte2 + 1 | 91 | D = max_char_or_byte2 - min_char_or_byte2 + 1 |
| 90 | / = integer division | 92 | / = integer division |
| 91 | \ = integer modulus */ | 93 | \ = integer modulus */ |
| 92 | if (char2b->byte1 >= xfont->min_byte1 | 94 | if (byte1 >= xfont->min_byte1 |
| 93 | && char2b->byte1 <= xfont->max_byte1 | 95 | && byte1 <= xfont->max_byte1 |
| 94 | && char2b->byte2 >= xfont->min_char_or_byte2 | 96 | && byte2 >= xfont->min_char_or_byte2 |
| 95 | && char2b->byte2 <= xfont->max_char_or_byte2) | 97 | && byte2 <= xfont->max_char_or_byte2) |
| 96 | pcm = (xfont->per_char | 98 | pcm = (xfont->per_char |
| 97 | + ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1) | 99 | + ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1) |
| 98 | * (char2b->byte1 - xfont->min_byte1)) | 100 | * (byte1 - xfont->min_byte1)) |
| 99 | + (char2b->byte2 - xfont->min_char_or_byte2)); | 101 | + (byte2 - xfont->min_char_or_byte2)); |
| 100 | } | 102 | } |
| 101 | } | 103 | } |
| 102 | else | 104 | else |
| @@ -104,8 +106,8 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) | |||
| 104 | /* If the per_char pointer is null, all glyphs between the first | 106 | /* If the per_char pointer is null, all glyphs between the first |
| 105 | and last character indexes inclusive have the same | 107 | and last character indexes inclusive have the same |
| 106 | information, as given by both min_bounds and max_bounds. */ | 108 | information, as given by both min_bounds and max_bounds. */ |
| 107 | if (char2b->byte2 >= xfont->min_char_or_byte2 | 109 | if (byte2 >= xfont->min_char_or_byte2 |
| 108 | && char2b->byte2 <= xfont->max_char_or_byte2) | 110 | && byte2 <= xfont->max_char_or_byte2) |
| 109 | pcm = &xfont->max_bounds; | 111 | pcm = &xfont->max_bounds; |
| 110 | } | 112 | } |
| 111 | 113 | ||
| @@ -193,7 +195,6 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, | |||
| 193 | { | 195 | { |
| 194 | int c = XFIXNUM (XCAR (chars)); | 196 | int c = XFIXNUM (XCAR (chars)); |
| 195 | unsigned code = ENCODE_CHAR (charset, c); | 197 | unsigned code = ENCODE_CHAR (charset, c); |
| 196 | XChar2b char2b; | ||
| 197 | 198 | ||
| 198 | if (code == CHARSET_INVALID_CODE (charset)) | 199 | if (code == CHARSET_INVALID_CODE (charset)) |
| 199 | break; | 200 | break; |
| @@ -201,9 +202,7 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, | |||
| 201 | continue; | 202 | continue; |
| 202 | if (code >= 0x10000) | 203 | if (code >= 0x10000) |
| 203 | break; | 204 | break; |
| 204 | char2b.byte1 = code >> 8; | 205 | if (! xfont_get_pcm (xfont, code)) |
| 205 | char2b.byte2 = code & 0xFF; | ||
| 206 | if (! xfont_get_pcm (xfont, &char2b)) | ||
| 207 | break; | 206 | break; |
| 208 | } | 207 | } |
| 209 | return (NILP (chars)); | 208 | return (NILP (chars)); |
| @@ -216,7 +215,6 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, | |||
| 216 | { | 215 | { |
| 217 | int c = XFIXNUM (AREF (chars, i)); | 216 | int c = XFIXNUM (AREF (chars, i)); |
| 218 | unsigned code = ENCODE_CHAR (charset, c); | 217 | unsigned code = ENCODE_CHAR (charset, c); |
| 219 | XChar2b char2b; | ||
| 220 | 218 | ||
| 221 | if (code == CHARSET_INVALID_CODE (charset)) | 219 | if (code == CHARSET_INVALID_CODE (charset)) |
| 222 | continue; | 220 | continue; |
| @@ -224,9 +222,7 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, | |||
| 224 | break; | 222 | break; |
| 225 | if (code >= 0x10000) | 223 | if (code >= 0x10000) |
| 226 | continue; | 224 | continue; |
| 227 | char2b.byte1 = code >> 8; | 225 | if (xfont_get_pcm (xfont, code)) |
| 228 | char2b.byte2 = code & 0xFF; | ||
| 229 | if (xfont_get_pcm (xfont, &char2b)) | ||
| 230 | break; | 226 | break; |
| 231 | } | 227 | } |
| 232 | return (i >= 0); | 228 | return (i >= 0); |
| @@ -801,11 +797,9 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 801 | else | 797 | else |
| 802 | { | 798 | { |
| 803 | XCharStruct *pcm; | 799 | XCharStruct *pcm; |
| 804 | XChar2b char2b; | ||
| 805 | Lisp_Object val; | 800 | Lisp_Object val; |
| 806 | 801 | ||
| 807 | char2b.byte1 = 0x00, char2b.byte2 = 0x20; | 802 | pcm = xfont_get_pcm (xfont, 0x20); |
| 808 | pcm = xfont_get_pcm (xfont, &char2b); | ||
| 809 | if (pcm) | 803 | if (pcm) |
| 810 | font->space_width = pcm->width; | 804 | font->space_width = pcm->width; |
| 811 | else | 805 | else |
| @@ -823,8 +817,8 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 823 | { | 817 | { |
| 824 | int width = font->space_width, n = pcm != NULL; | 818 | int width = font->space_width, n = pcm != NULL; |
| 825 | 819 | ||
| 826 | for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++) | 820 | for (unsigned char2b = 33; char2b <= 126; ++char2b) |
| 827 | if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL) | 821 | if ((pcm = xfont_get_pcm (xfont, char2b)) != NULL) |
| 828 | width += pcm->width, n++; | 822 | width += pcm->width, n++; |
| 829 | if (n > 0) | 823 | if (n > 0) |
| 830 | font->average_width = width / n; | 824 | font->average_width = width / n; |
| @@ -934,7 +928,6 @@ xfont_encode_char (struct font *font, int c) | |||
| 934 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; | 928 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; |
| 935 | struct charset *charset; | 929 | struct charset *charset; |
| 936 | unsigned code; | 930 | unsigned code; |
| 937 | XChar2b char2b; | ||
| 938 | 931 | ||
| 939 | charset = CHARSET_FROM_ID (font->encoding_charset); | 932 | charset = CHARSET_FROM_ID (font->encoding_charset); |
| 940 | code = ENCODE_CHAR (charset, c); | 933 | code = ENCODE_CHAR (charset, c); |
| @@ -946,13 +939,11 @@ xfont_encode_char (struct font *font, int c) | |||
| 946 | return (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset) | 939 | return (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset) |
| 947 | ? code : FONT_INVALID_CODE); | 940 | ? code : FONT_INVALID_CODE); |
| 948 | } | 941 | } |
| 949 | char2b.byte1 = code >> 8; | 942 | return (xfont_get_pcm (xfont, code) ? code : FONT_INVALID_CODE); |
| 950 | char2b.byte2 = code & 0xFF; | ||
| 951 | return (xfont_get_pcm (xfont, &char2b) ? code : FONT_INVALID_CODE); | ||
| 952 | } | 943 | } |
| 953 | 944 | ||
| 954 | static void | 945 | static void |
| 955 | xfont_text_extents (struct font *font, unsigned int *code, | 946 | xfont_text_extents (struct font *font, const unsigned int *code, |
| 956 | int nglyphs, struct font_metrics *metrics) | 947 | int nglyphs, struct font_metrics *metrics) |
| 957 | { | 948 | { |
| 958 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; | 949 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; |
| @@ -961,13 +952,11 @@ xfont_text_extents (struct font *font, unsigned int *code, | |||
| 961 | 952 | ||
| 962 | for (i = 0, first = true; i < nglyphs; i++) | 953 | for (i = 0, first = true; i < nglyphs; i++) |
| 963 | { | 954 | { |
| 964 | XChar2b char2b; | ||
| 965 | static XCharStruct *pcm; | 955 | static XCharStruct *pcm; |
| 966 | 956 | ||
| 967 | if (code[i] >= 0x10000) | 957 | if (code[i] >= 0x10000) |
| 968 | continue; | 958 | continue; |
| 969 | char2b.byte1 = code[i] >> 8, char2b.byte2 = code[i] & 0xFF; | 959 | pcm = xfont_get_pcm (xfont, code[i]); |
| 970 | pcm = xfont_get_pcm (xfont, &char2b); | ||
| 971 | if (! pcm) | 960 | if (! pcm) |
| 972 | continue; | 961 | continue; |
| 973 | if (first) | 962 | if (first) |
| @@ -1000,6 +989,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1000 | bool with_background) | 989 | bool with_background) |
| 1001 | { | 990 | { |
| 1002 | XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; | 991 | XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; |
| 992 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 1003 | int len = to - from; | 993 | int len = to - from; |
| 1004 | GC gc = s->gc; | 994 | GC gc = s->gc; |
| 1005 | int i; | 995 | int i; |
| @@ -1007,7 +997,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1007 | if (s->gc != s->face->gc) | 997 | if (s->gc != s->face->gc) |
| 1008 | { | 998 | { |
| 1009 | block_input (); | 999 | block_input (); |
| 1010 | XSetFont (s->display, gc, xfont->fid); | 1000 | XSetFont (display, gc, xfont->fid); |
| 1011 | unblock_input (); | 1001 | unblock_input (); |
| 1012 | } | 1002 | } |
| 1013 | 1003 | ||
| @@ -1016,26 +1006,26 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1016 | USE_SAFE_ALLOCA; | 1006 | USE_SAFE_ALLOCA; |
| 1017 | char *str = SAFE_ALLOCA (len); | 1007 | char *str = SAFE_ALLOCA (len); |
| 1018 | for (i = 0; i < len ; i++) | 1008 | for (i = 0; i < len ; i++) |
| 1019 | str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); | 1009 | str[i] = s->char2b[from + i] & 0xFF; |
| 1020 | block_input (); | 1010 | block_input (); |
| 1021 | if (with_background) | 1011 | if (with_background) |
| 1022 | { | 1012 | { |
| 1023 | if (s->padding_p) | 1013 | if (s->padding_p) |
| 1024 | for (i = 0; i < len; i++) | 1014 | for (i = 0; i < len; i++) |
| 1025 | XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), | 1015 | XDrawImageString (display, FRAME_X_DRAWABLE (s->f), |
| 1026 | gc, x + i, y, str + i, 1); | 1016 | gc, x + i, y, str + i, 1); |
| 1027 | else | 1017 | else |
| 1028 | XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), | 1018 | XDrawImageString (display, FRAME_X_DRAWABLE (s->f), |
| 1029 | gc, x, y, str, len); | 1019 | gc, x, y, str, len); |
| 1030 | } | 1020 | } |
| 1031 | else | 1021 | else |
| 1032 | { | 1022 | { |
| 1033 | if (s->padding_p) | 1023 | if (s->padding_p) |
| 1034 | for (i = 0; i < len; i++) | 1024 | for (i = 0; i < len; i++) |
| 1035 | XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), | 1025 | XDrawString (display, FRAME_X_DRAWABLE (s->f), |
| 1036 | gc, x + i, y, str + i, 1); | 1026 | gc, x + i, y, str + i, 1); |
| 1037 | else | 1027 | else |
| 1038 | XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), | 1028 | XDrawString (display, FRAME_X_DRAWABLE (s->f), |
| 1039 | gc, x, y, str, len); | 1029 | gc, x, y, str, len); |
| 1040 | } | 1030 | } |
| 1041 | unblock_input (); | 1031 | unblock_input (); |
| @@ -1048,21 +1038,51 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1048 | { | 1038 | { |
| 1049 | if (s->padding_p) | 1039 | if (s->padding_p) |
| 1050 | for (i = 0; i < len; i++) | 1040 | for (i = 0; i < len; i++) |
| 1051 | XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), | 1041 | { |
| 1052 | gc, x + i, y, s->char2b + from + i, 1); | 1042 | const unsigned code = s->char2b[from + i]; |
| 1043 | const XChar2b char2b = { .byte1 = code >> 8, | ||
| 1044 | .byte2 = code & 0xFF }; | ||
| 1045 | XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f), | ||
| 1046 | gc, x + i, y, &char2b, 1); | ||
| 1047 | } | ||
| 1053 | else | 1048 | else |
| 1054 | XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), | 1049 | { |
| 1055 | gc, x, y, s->char2b + from, len); | 1050 | USE_SAFE_ALLOCA; |
| 1051 | const unsigned *code = s->char2b + from; | ||
| 1052 | XChar2b *char2b; | ||
| 1053 | SAFE_NALLOCA (char2b, 1, len); | ||
| 1054 | for (int i = 0; i < len; ++i) | ||
| 1055 | char2b[i] = (XChar2b) { .byte1 = code[i] >> 8, | ||
| 1056 | .byte2 = code[i] & 0xFF }; | ||
| 1057 | XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f), | ||
| 1058 | gc, x, y, char2b, len); | ||
| 1059 | SAFE_FREE (); | ||
| 1060 | } | ||
| 1056 | } | 1061 | } |
| 1057 | else | 1062 | else |
| 1058 | { | 1063 | { |
| 1059 | if (s->padding_p) | 1064 | if (s->padding_p) |
| 1060 | for (i = 0; i < len; i++) | 1065 | for (i = 0; i < len; i++) |
| 1061 | XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), | 1066 | { |
| 1062 | gc, x + i, y, s->char2b + from + i, 1); | 1067 | const unsigned code = s->char2b[from + i]; |
| 1068 | const XChar2b char2b = { .byte1 = code >> 8, | ||
| 1069 | .byte2 = code & 0xFF }; | ||
| 1070 | XDrawString16 (display, FRAME_X_DRAWABLE (s->f), | ||
| 1071 | gc, x + i, y, &char2b, 1); | ||
| 1072 | } | ||
| 1063 | else | 1073 | else |
| 1064 | XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_DRAWABLE (s->f), | 1074 | { |
| 1065 | gc, x, y, s->char2b + from, len); | 1075 | USE_SAFE_ALLOCA; |
| 1076 | const unsigned *code = s->char2b + from; | ||
| 1077 | XChar2b *char2b; | ||
| 1078 | SAFE_NALLOCA (char2b, 1, len); | ||
| 1079 | for (int i = 0; i < len; ++i) | ||
| 1080 | char2b[i] = (XChar2b) { .byte1 = code[i] >> 8, | ||
| 1081 | .byte2 = code[i] & 0xFF }; | ||
| 1082 | XDrawString16 (display, FRAME_X_DRAWABLE (s->f), | ||
| 1083 | gc, x, y, char2b, len); | ||
| 1084 | SAFE_FREE (); | ||
| 1085 | } | ||
| 1066 | } | 1086 | } |
| 1067 | unblock_input (); | 1087 | unblock_input (); |
| 1068 | 1088 | ||
diff --git a/src/xftfont.c b/src/xftfont.c index f7b87f96569..08e4edb535a 100644 --- a/src/xftfont.c +++ b/src/xftfont.c | |||
| @@ -119,120 +119,18 @@ xftfont_match (struct frame *f, Lisp_Object spec) | |||
| 119 | 119 | ||
| 120 | static FcChar8 ascii_printable[95]; | 120 | static FcChar8 ascii_printable[95]; |
| 121 | 121 | ||
| 122 | static void | ||
| 123 | xftfont_fix_match (FcPattern *pat, FcPattern *match) | ||
| 124 | { | ||
| 125 | /* These values are not used for matching (except antialias), but for | ||
| 126 | rendering, so make sure they are carried over to the match. | ||
| 127 | We also put antialias here because most fonts are antialiased, so | ||
| 128 | the match will have antialias true. */ | ||
| 129 | |||
| 130 | FcBool b = FcTrue; | ||
| 131 | int i; | ||
| 132 | double dpi; | ||
| 133 | |||
| 134 | FcPatternGetBool (pat, FC_ANTIALIAS, 0, &b); | ||
| 135 | if (! b) | ||
| 136 | { | ||
| 137 | FcPatternDel (match, FC_ANTIALIAS); | ||
| 138 | FcPatternAddBool (match, FC_ANTIALIAS, FcFalse); | ||
| 139 | } | ||
| 140 | FcPatternGetBool (pat, FC_HINTING, 0, &b); | ||
| 141 | if (! b) | ||
| 142 | { | ||
| 143 | FcPatternDel (match, FC_HINTING); | ||
| 144 | FcPatternAddBool (match, FC_HINTING, FcFalse); | ||
| 145 | } | ||
| 146 | #ifndef FC_HINT_STYLE | ||
| 147 | # define FC_HINT_STYLE "hintstyle" | ||
| 148 | #endif | ||
| 149 | if (FcResultMatch == FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &i)) | ||
| 150 | { | ||
| 151 | FcPatternDel (match, FC_HINT_STYLE); | ||
| 152 | FcPatternAddInteger (match, FC_HINT_STYLE, i); | ||
| 153 | } | ||
| 154 | #ifndef FC_LCD_FILTER | ||
| 155 | /* Older fontconfig versions don't have FC_LCD_FILTER. */ | ||
| 156 | #define FC_LCD_FILTER "lcdfilter" | ||
| 157 | #endif | ||
| 158 | if (FcResultMatch == FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &i)) | ||
| 159 | { | ||
| 160 | FcPatternDel (match, FC_LCD_FILTER); | ||
| 161 | FcPatternAddInteger (match, FC_LCD_FILTER, i); | ||
| 162 | } | ||
| 163 | if (FcResultMatch == FcPatternGetInteger (pat, FC_RGBA, 0, &i)) | ||
| 164 | { | ||
| 165 | FcPatternDel (match, FC_RGBA); | ||
| 166 | FcPatternAddInteger (match, FC_RGBA, i); | ||
| 167 | } | ||
| 168 | if (FcResultMatch == FcPatternGetDouble (pat, FC_DPI, 0, &dpi)) | ||
| 169 | { | ||
| 170 | FcPatternDel (match, FC_DPI); | ||
| 171 | FcPatternAddDouble (match, FC_DPI, dpi); | ||
| 172 | } | ||
| 173 | } | ||
| 174 | |||
| 175 | static void | ||
| 176 | xftfont_add_rendering_parameters (FcPattern *pat, Lisp_Object entity) | ||
| 177 | { | ||
| 178 | Lisp_Object tail; | ||
| 179 | int ival; | ||
| 180 | |||
| 181 | for (tail = AREF (entity, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) | ||
| 182 | { | ||
| 183 | Lisp_Object key = XCAR (XCAR (tail)); | ||
| 184 | Lisp_Object val = XCDR (XCAR (tail)); | ||
| 185 | |||
| 186 | if (EQ (key, QCantialias)) | ||
| 187 | FcPatternAddBool (pat, FC_ANTIALIAS, NILP (val) ? FcFalse : FcTrue); | ||
| 188 | else if (EQ (key, QChinting)) | ||
| 189 | FcPatternAddBool (pat, FC_HINTING, NILP (val) ? FcFalse : FcTrue); | ||
| 190 | else if (EQ (key, QCautohint)) | ||
| 191 | FcPatternAddBool (pat, FC_AUTOHINT, NILP (val) ? FcFalse : FcTrue); | ||
| 192 | else if (EQ (key, QChintstyle)) | ||
| 193 | { | ||
| 194 | if (FIXNUMP (val)) | ||
| 195 | FcPatternAddInteger (pat, FC_HINT_STYLE, XFIXNUM (val)); | ||
| 196 | else if (SYMBOLP (val) | ||
| 197 | && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival)) | ||
| 198 | FcPatternAddInteger (pat, FC_HINT_STYLE, ival); | ||
| 199 | } | ||
| 200 | else if (EQ (key, QCrgba)) | ||
| 201 | { | ||
| 202 | if (FIXNUMP (val)) | ||
| 203 | FcPatternAddInteger (pat, FC_RGBA, XFIXNUM (val)); | ||
| 204 | else if (SYMBOLP (val) | ||
| 205 | && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival)) | ||
| 206 | FcPatternAddInteger (pat, FC_RGBA, ival); | ||
| 207 | } | ||
| 208 | else if (EQ (key, QClcdfilter)) | ||
| 209 | { | ||
| 210 | if (FIXNUMP (val)) | ||
| 211 | FcPatternAddInteger (pat, FC_LCD_FILTER, ival = XFIXNUM (val)); | ||
| 212 | else if (SYMBOLP (val) | ||
| 213 | && FcNameConstant (SDATA (SYMBOL_NAME (val)), &ival)) | ||
| 214 | FcPatternAddInteger (pat, FC_LCD_FILTER, ival); | ||
| 215 | } | ||
| 216 | #ifdef FC_EMBOLDEN | ||
| 217 | else if (EQ (key, QCembolden)) | ||
| 218 | FcPatternAddBool (pat, FC_EMBOLDEN, NILP (val) ? FcFalse : FcTrue); | ||
| 219 | #endif | ||
| 220 | } | ||
| 221 | } | ||
| 222 | |||
| 223 | static Lisp_Object | 122 | static Lisp_Object |
| 224 | xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | 123 | xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) |
| 225 | { | 124 | { |
| 226 | FcResult result; | 125 | FcResult result; |
| 227 | Display *display = FRAME_X_DISPLAY (f); | 126 | Display *display = FRAME_X_DISPLAY (f); |
| 228 | Lisp_Object val, filename, idx, font_object; | 127 | Lisp_Object val, filename, font_object; |
| 229 | FcPattern *pat = NULL, *match; | 128 | FcPattern *pat = NULL, *match; |
| 230 | struct font_info *xftfont_info = NULL; | 129 | struct font_info *xftfont_info = NULL; |
| 231 | struct font *font; | 130 | struct font *font; |
| 232 | double size = 0; | 131 | double size = 0; |
| 233 | XftFont *xftfont = NULL; | 132 | XftFont *xftfont = NULL; |
| 234 | int spacing; | 133 | int spacing; |
| 235 | int i; | ||
| 236 | XGlyphInfo extents; | 134 | XGlyphInfo extents; |
| 237 | FT_Face ft_face; | 135 | FT_Face ft_face; |
| 238 | FcMatrix *matrix; | 136 | FcMatrix *matrix; |
| @@ -242,52 +140,17 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 242 | return Qnil; | 140 | return Qnil; |
| 243 | val = XCDR (val); | 141 | val = XCDR (val); |
| 244 | filename = XCAR (val); | 142 | filename = XCAR (val); |
| 245 | idx = XCDR (val); | ||
| 246 | size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX)); | 143 | size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX)); |
| 247 | if (size == 0) | 144 | if (size == 0) |
| 248 | size = pixel_size; | 145 | size = pixel_size; |
| 249 | pat = FcPatternCreate (); | ||
| 250 | FcPatternAddInteger (pat, FC_WEIGHT, FONT_WEIGHT_NUMERIC (entity)); | ||
| 251 | i = FONT_SLANT_NUMERIC (entity) - 100; | ||
| 252 | if (i < 0) i = 0; | ||
| 253 | FcPatternAddInteger (pat, FC_SLANT, i); | ||
| 254 | FcPatternAddInteger (pat, FC_WIDTH, FONT_WIDTH_NUMERIC (entity)); | ||
| 255 | FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size); | ||
| 256 | val = AREF (entity, FONT_FAMILY_INDEX); | ||
| 257 | if (! NILP (val)) | ||
| 258 | FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); | ||
| 259 | val = AREF (entity, FONT_FOUNDRY_INDEX); | ||
| 260 | if (! NILP (val)) | ||
| 261 | FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); | ||
| 262 | val = AREF (entity, FONT_SPACING_INDEX); | ||
| 263 | if (! NILP (val)) | ||
| 264 | FcPatternAddInteger (pat, FC_SPACING, XFIXNUM (val)); | ||
| 265 | val = AREF (entity, FONT_DPI_INDEX); | ||
| 266 | if (! NILP (val)) | ||
| 267 | { | ||
| 268 | double dbl = XFIXNUM (val); | ||
| 269 | |||
| 270 | FcPatternAddDouble (pat, FC_DPI, dbl); | ||
| 271 | } | ||
| 272 | val = AREF (entity, FONT_AVGWIDTH_INDEX); | ||
| 273 | if (FIXNUMP (val) && XFIXNUM (val) == 0) | ||
| 274 | FcPatternAddBool (pat, FC_SCALABLE, FcTrue); | ||
| 275 | /* This is necessary to identify the exact font (e.g. 10x20.pcf.gz | ||
| 276 | over 10x20-ISO8859-1.pcf.gz). */ | ||
| 277 | FcPatternAddCharSet (pat, FC_CHARSET, ftfont_get_fc_charset (entity)); | ||
| 278 | |||
| 279 | xftfont_add_rendering_parameters (pat, entity); | ||
| 280 | |||
| 281 | FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename)); | ||
| 282 | FcPatternAddInteger (pat, FC_INDEX, XFIXNUM (idx)); | ||
| 283 | |||
| 284 | 146 | ||
| 285 | block_input (); | 147 | block_input (); |
| 286 | 148 | ||
| 149 | pat = ftfont_entity_pattern (entity, pixel_size); | ||
| 287 | /* Substitute in values from X resources and XftDefaultSet. */ | 150 | /* Substitute in values from X resources and XftDefaultSet. */ |
| 288 | XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); | 151 | XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); |
| 289 | match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result); | 152 | match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result); |
| 290 | xftfont_fix_match (pat, match); | 153 | ftfont_fix_match (pat, match); |
| 291 | 154 | ||
| 292 | FcPatternDestroy (pat); | 155 | FcPatternDestroy (pat); |
| 293 | xftfont = XftFontOpenPattern (display, match); | 156 | xftfont = XftFontOpenPattern (display, match); |
| @@ -544,7 +407,7 @@ xftfont_encode_char (struct font *font, int c) | |||
| 544 | } | 407 | } |
| 545 | 408 | ||
| 546 | static void | 409 | static void |
| 547 | xftfont_text_extents (struct font *font, unsigned int *code, | 410 | xftfont_text_extents (struct font *font, const unsigned int *code, |
| 548 | int nglyphs, struct font_metrics *metrics) | 411 | int nglyphs, struct font_metrics *metrics) |
| 549 | { | 412 | { |
| 550 | struct font_info *xftfont_info = (struct font_info *) font; | 413 | struct font_info *xftfont_info = (struct font_info *) font; |
| @@ -629,8 +492,7 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 629 | } | 492 | } |
| 630 | code = alloca (sizeof (FT_UInt) * len); | 493 | code = alloca (sizeof (FT_UInt) * len); |
| 631 | for (i = 0; i < len; i++) | 494 | for (i = 0; i < len; i++) |
| 632 | code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) | 495 | code[i] = s->char2b[from + i]; |
| 633 | | XCHAR2B_BYTE2 (s->char2b + from + i)); | ||
| 634 | 496 | ||
| 635 | if (s->padding_p) | 497 | if (s->padding_p) |
| 636 | for (i = 0; i < len; i++) | 498 | for (i = 0; i < len; i++) |
| @@ -704,7 +566,7 @@ xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object, | |||
| 704 | bool ok = false; | 566 | bool ok = false; |
| 705 | int i1, i2, r1, r2; | 567 | int i1, i2, r1, r2; |
| 706 | 568 | ||
| 707 | xftfont_add_rendering_parameters (pat, entity); | 569 | ftfont_add_rendering_parameters (pat, entity); |
| 708 | XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); | 570 | XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); |
| 709 | 571 | ||
| 710 | r1 = FcPatternGetBool (pat, FC_ANTIALIAS, 0, &b1); | 572 | r1 = FcPatternGetBool (pat, FC_ANTIALIAS, 0, &b1); |
| @@ -818,12 +680,6 @@ syms_of_xftfont (void) | |||
| 818 | #ifdef HAVE_HARFBUZZ | 680 | #ifdef HAVE_HARFBUZZ |
| 819 | DEFSYM (Qxfthb, "xfthb"); | 681 | DEFSYM (Qxfthb, "xfthb"); |
| 820 | #endif /* HAVE_HARFBUZZ */ | 682 | #endif /* HAVE_HARFBUZZ */ |
| 821 | DEFSYM (QChinting, ":hinting"); | ||
| 822 | DEFSYM (QCautohint, ":autohint"); | ||
| 823 | DEFSYM (QChintstyle, ":hintstyle"); | ||
| 824 | DEFSYM (QCrgba, ":rgba"); | ||
| 825 | DEFSYM (QCembolden, ":embolden"); | ||
| 826 | DEFSYM (QClcdfilter, ":lcdfilter"); | ||
| 827 | 683 | ||
| 828 | DEFVAR_BOOL ("xft-font-ascent-descent-override", | 684 | DEFVAR_BOOL ("xft-font-ascent-descent-override", |
| 829 | xft_font_ascent_descent_override, | 685 | xft_font_ascent_descent_override, |
diff --git a/src/xterm.c b/src/xterm.c index dd19b8bde15..559d1b48924 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -201,7 +201,6 @@ enum xembed_message | |||
| 201 | XEMBED_ACTIVATE_ACCELERATOR = 14 | 201 | XEMBED_ACTIVATE_ACCELERATOR = 14 |
| 202 | }; | 202 | }; |
| 203 | 203 | ||
| 204 | static void x_free_cr_resources (struct frame *); | ||
| 205 | static bool x_alloc_nearest_color_1 (Display *, Colormap, XColor *); | 204 | static bool x_alloc_nearest_color_1 (Display *, Colormap, XColor *); |
| 206 | static void x_raise_frame (struct frame *); | 205 | static void x_raise_frame (struct frame *); |
| 207 | static void x_lower_frame (struct frame *); | 206 | static void x_lower_frame (struct frame *); |
| @@ -298,7 +297,10 @@ record_event (char *locus, int type) | |||
| 298 | #ifdef USE_CAIRO | 297 | #ifdef USE_CAIRO |
| 299 | 298 | ||
| 300 | #define FRAME_CR_CONTEXT(f) ((f)->output_data.x->cr_context) | 299 | #define FRAME_CR_CONTEXT(f) ((f)->output_data.x->cr_context) |
| 301 | #define FRAME_CR_SURFACE(f) ((f)->output_data.x->cr_surface) | 300 | #define FRAME_CR_SURFACE_DESIRED_WIDTH(f) \ |
| 301 | ((f)->output_data.x->cr_surface_desired_width) | ||
| 302 | #define FRAME_CR_SURFACE_DESIRED_HEIGHT(f) \ | ||
| 303 | ((f)->output_data.x->cr_surface_desired_height) | ||
| 302 | 304 | ||
| 303 | static struct x_gc_ext_data * | 305 | static struct x_gc_ext_data * |
| 304 | x_gc_get_ext_data (struct frame *f, GC gc, int create_if_not_found_p) | 306 | x_gc_get_ext_data (struct frame *f, GC gc, int create_if_not_found_p) |
| @@ -333,19 +335,28 @@ x_extension_initialize (struct x_display_info *dpyinfo) | |||
| 333 | dpyinfo->ext_codes = ext_codes; | 335 | dpyinfo->ext_codes = ext_codes; |
| 334 | } | 336 | } |
| 335 | 337 | ||
| 336 | static void | 338 | void |
| 337 | x_cr_destroy_surface (struct frame *f) | 339 | x_cr_destroy_frame_context (struct frame *f) |
| 338 | { | 340 | { |
| 339 | if (FRAME_CR_SURFACE (f)) | 341 | if (FRAME_CR_CONTEXT (f)) |
| 340 | { | 342 | { |
| 341 | cairo_t *cr = FRAME_CR_CONTEXT (f); | 343 | cairo_destroy (FRAME_CR_CONTEXT (f)); |
| 342 | cairo_surface_destroy (FRAME_CR_SURFACE (f)); | ||
| 343 | FRAME_CR_SURFACE (f) = 0; | ||
| 344 | if (cr) cairo_destroy (cr); | ||
| 345 | FRAME_CR_CONTEXT (f) = NULL; | 344 | FRAME_CR_CONTEXT (f) = NULL; |
| 346 | } | 345 | } |
| 347 | } | 346 | } |
| 348 | 347 | ||
| 348 | static void | ||
| 349 | x_cr_update_surface_desired_size (struct frame *f, int width, int height) | ||
| 350 | { | ||
| 351 | if (FRAME_CR_SURFACE_DESIRED_WIDTH (f) != width | ||
| 352 | || FRAME_CR_SURFACE_DESIRED_HEIGHT (f) != height) | ||
| 353 | { | ||
| 354 | x_cr_destroy_frame_context (f); | ||
| 355 | FRAME_CR_SURFACE_DESIRED_WIDTH (f) = width; | ||
| 356 | FRAME_CR_SURFACE_DESIRED_HEIGHT (f) = height; | ||
| 357 | } | ||
| 358 | } | ||
| 359 | |||
| 349 | cairo_t * | 360 | cairo_t * |
| 350 | x_begin_cr_clip (struct frame *f, GC gc) | 361 | x_begin_cr_clip (struct frame *f, GC gc) |
| 351 | { | 362 | { |
| @@ -353,21 +364,19 @@ x_begin_cr_clip (struct frame *f, GC gc) | |||
| 353 | 364 | ||
| 354 | if (!cr) | 365 | if (!cr) |
| 355 | { | 366 | { |
| 356 | 367 | int width = FRAME_CR_SURFACE_DESIRED_WIDTH (f); | |
| 357 | if (! FRAME_CR_SURFACE (f)) | 368 | int height = FRAME_CR_SURFACE_DESIRED_HEIGHT (f); |
| 358 | { | 369 | cairo_surface_t *surface; |
| 359 | int scale = 1; | 370 | if (FRAME_X_DOUBLE_BUFFERED_P (f)) |
| 360 | #ifdef USE_GTK | 371 | surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f), |
| 361 | scale = xg_get_scale (f); | 372 | FRAME_X_RAW_DRAWABLE (f), |
| 362 | #endif | 373 | FRAME_X_VISUAL (f), |
| 363 | 374 | width, height); | |
| 364 | FRAME_CR_SURFACE (f) = | 375 | else |
| 365 | cairo_image_surface_create (CAIRO_FORMAT_ARGB32, | 376 | surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, |
| 366 | scale * FRAME_PIXEL_WIDTH (f), | 377 | width, height); |
| 367 | scale * FRAME_PIXEL_HEIGHT (f)); | 378 | cr = FRAME_CR_CONTEXT (f) = cairo_create (surface); |
| 368 | } | 379 | cairo_surface_destroy (surface); |
| 369 | cr = cairo_create (FRAME_CR_SURFACE (f)); | ||
| 370 | FRAME_CR_CONTEXT (f) = cr; | ||
| 371 | } | 380 | } |
| 372 | cairo_save (cr); | 381 | cairo_save (cr); |
| 373 | 382 | ||
| @@ -395,6 +404,8 @@ void | |||
| 395 | x_end_cr_clip (struct frame *f) | 404 | x_end_cr_clip (struct frame *f) |
| 396 | { | 405 | { |
| 397 | cairo_restore (FRAME_CR_CONTEXT (f)); | 406 | cairo_restore (FRAME_CR_CONTEXT (f)); |
| 407 | if (FRAME_X_DOUBLE_BUFFERED_P (f)) | ||
| 408 | x_mark_frame_dirty (f); | ||
| 398 | } | 409 | } |
| 399 | 410 | ||
| 400 | void | 411 | void |
| @@ -532,11 +543,11 @@ x_cr_draw_frame (cairo_t *cr, struct frame *f) | |||
| 532 | width = FRAME_PIXEL_WIDTH (f); | 543 | width = FRAME_PIXEL_WIDTH (f); |
| 533 | height = FRAME_PIXEL_HEIGHT (f); | 544 | height = FRAME_PIXEL_HEIGHT (f); |
| 534 | 545 | ||
| 535 | x_free_cr_resources (f); | 546 | cairo_t *saved_cr = FRAME_CR_CONTEXT (f); |
| 536 | FRAME_CR_CONTEXT (f) = cr; | 547 | FRAME_CR_CONTEXT (f) = cr; |
| 537 | x_clear_area (f, 0, 0, width, height); | 548 | x_clear_area (f, 0, 0, width, height); |
| 538 | expose_frame (f, 0, 0, width, height); | 549 | expose_frame (f, 0, 0, width, height); |
| 539 | FRAME_CR_CONTEXT (f) = NULL; | 550 | FRAME_CR_CONTEXT (f) = saved_cr; |
| 540 | } | 551 | } |
| 541 | 552 | ||
| 542 | static cairo_status_t | 553 | static cairo_status_t |
| @@ -615,11 +626,11 @@ x_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type) | |||
| 615 | 626 | ||
| 616 | while (1) | 627 | while (1) |
| 617 | { | 628 | { |
| 618 | x_free_cr_resources (f); | 629 | cairo_t *saved_cr = FRAME_CR_CONTEXT (f); |
| 619 | FRAME_CR_CONTEXT (f) = cr; | 630 | FRAME_CR_CONTEXT (f) = cr; |
| 620 | x_clear_area (f, 0, 0, width, height); | 631 | x_clear_area (f, 0, 0, width, height); |
| 621 | expose_frame (f, 0, 0, width, height); | 632 | expose_frame (f, 0, 0, width, height); |
| 622 | FRAME_CR_CONTEXT (f) = NULL; | 633 | FRAME_CR_CONTEXT (f) = saved_cr; |
| 623 | 634 | ||
| 624 | if (NILP (frames)) | 635 | if (NILP (frames)) |
| 625 | break; | 636 | break; |
| @@ -654,35 +665,6 @@ x_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type) | |||
| 654 | #endif /* USE_CAIRO */ | 665 | #endif /* USE_CAIRO */ |
| 655 | 666 | ||
| 656 | static void | 667 | static void |
| 657 | x_free_cr_resources (struct frame *f) | ||
| 658 | { | ||
| 659 | #ifdef USE_CAIRO | ||
| 660 | if (f == NULL) | ||
| 661 | { | ||
| 662 | Lisp_Object rest, frame; | ||
| 663 | FOR_EACH_FRAME (rest, frame) | ||
| 664 | if (FRAME_X_P (XFRAME (frame))) | ||
| 665 | x_free_cr_resources (XFRAME (frame)); | ||
| 666 | } | ||
| 667 | else | ||
| 668 | { | ||
| 669 | cairo_t *cr = FRAME_CR_CONTEXT (f); | ||
| 670 | |||
| 671 | if (cr) | ||
| 672 | { | ||
| 673 | cairo_surface_t *surface = cairo_get_target (cr); | ||
| 674 | |||
| 675 | if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_XLIB) | ||
| 676 | { | ||
| 677 | cairo_destroy (cr); | ||
| 678 | FRAME_CR_CONTEXT (f) = NULL; | ||
| 679 | } | ||
| 680 | } | ||
| 681 | } | ||
| 682 | #endif | ||
| 683 | } | ||
| 684 | |||
| 685 | static void | ||
| 686 | x_set_clip_rectangles (struct frame *f, GC gc, XRectangle *rectangles, int n) | 668 | x_set_clip_rectangles (struct frame *f, GC gc, XRectangle *rectangles, int n) |
| 687 | { | 669 | { |
| 688 | XSetClipRectangles (FRAME_X_DISPLAY (f), gc, 0, 0, rectangles, n, Unsorted); | 670 | XSetClipRectangles (FRAME_X_DISPLAY (f), gc, 0, 0, rectangles, n, Unsorted); |
| @@ -989,77 +971,16 @@ x_set_frame_alpha (struct frame *f) | |||
| 989 | 971 | ||
| 990 | /* Start an update of frame F. This function is installed as a hook | 972 | /* Start an update of frame F. This function is installed as a hook |
| 991 | for update_begin, i.e. it is called when update_begin is called. | 973 | for update_begin, i.e. it is called when update_begin is called. |
| 992 | This function is called prior to calls to x_update_window_begin for | 974 | This function is called prior to calls to gui_update_window_begin for |
| 993 | each window being updated. Currently, there is nothing to do here | 975 | each window being updated. Currently, there is nothing to do here |
| 994 | because all interesting stuff is done on a window basis. */ | 976 | because all interesting stuff is done on a window basis. */ |
| 995 | 977 | ||
| 996 | static void | 978 | static void |
| 997 | x_update_begin (struct frame *f) | 979 | x_update_begin (struct frame *f) |
| 998 | { | 980 | { |
| 999 | #ifdef USE_CAIRO | 981 | /* Nothing to do. */ |
| 1000 | if (FRAME_TOOLTIP_P (f) && !FRAME_VISIBLE_P (f)) | ||
| 1001 | return; | ||
| 1002 | |||
| 1003 | if (! FRAME_CR_SURFACE (f)) | ||
| 1004 | { | ||
| 1005 | int width, height; | ||
| 1006 | #ifdef USE_GTK | ||
| 1007 | if (FRAME_GTK_WIDGET (f)) | ||
| 1008 | { | ||
| 1009 | GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f)); | ||
| 1010 | int scale = xg_get_scale (f); | ||
| 1011 | width = scale * gdk_window_get_width (w); | ||
| 1012 | height = scale * gdk_window_get_height (w); | ||
| 1013 | } | ||
| 1014 | else | ||
| 1015 | #endif | ||
| 1016 | { | ||
| 1017 | width = FRAME_PIXEL_WIDTH (f); | ||
| 1018 | height = FRAME_PIXEL_HEIGHT (f); | ||
| 1019 | if (! FRAME_EXTERNAL_TOOL_BAR (f)) | ||
| 1020 | height += FRAME_TOOL_BAR_HEIGHT (f); | ||
| 1021 | if (! FRAME_EXTERNAL_MENU_BAR (f)) | ||
| 1022 | height += FRAME_MENU_BAR_HEIGHT (f); | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | if (width > 0 && height > 0) | ||
| 1026 | { | ||
| 1027 | block_input(); | ||
| 1028 | FRAME_CR_SURFACE (f) = cairo_image_surface_create | ||
| 1029 | (CAIRO_FORMAT_ARGB32, width, height); | ||
| 1030 | unblock_input(); | ||
| 1031 | } | ||
| 1032 | } | ||
| 1033 | #endif /* USE_CAIRO */ | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | /* Start update of window W. */ | ||
| 1037 | |||
| 1038 | static void | ||
| 1039 | x_update_window_begin (struct window *w) | ||
| 1040 | { | ||
| 1041 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | ||
| 1042 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | ||
| 1043 | |||
| 1044 | w->output_cursor = w->cursor; | ||
| 1045 | |||
| 1046 | block_input (); | ||
| 1047 | |||
| 1048 | if (f == hlinfo->mouse_face_mouse_frame) | ||
| 1049 | { | ||
| 1050 | /* Don't do highlighting for mouse motion during the update. */ | ||
| 1051 | hlinfo->mouse_face_defer = true; | ||
| 1052 | |||
| 1053 | /* If F needs to be redrawn, simply forget about any prior mouse | ||
| 1054 | highlighting. */ | ||
| 1055 | if (FRAME_GARBAGED_P (f)) | ||
| 1056 | hlinfo->mouse_face_window = Qnil; | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | unblock_input (); | ||
| 1060 | } | 982 | } |
| 1061 | 983 | ||
| 1062 | |||
| 1063 | /* Draw a vertical window border from (x,y0) to (x,y1) */ | 984 | /* Draw a vertical window border from (x,y0) to (x,y1) */ |
| 1064 | 985 | ||
| 1065 | static void | 986 | static void |
| @@ -1139,55 +1060,6 @@ x_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1) | |||
| 1139 | } | 1060 | } |
| 1140 | } | 1061 | } |
| 1141 | 1062 | ||
| 1142 | /* End update of window W. | ||
| 1143 | |||
| 1144 | Draw vertical borders between horizontally adjacent windows, and | ||
| 1145 | display W's cursor if CURSOR_ON_P is non-zero. | ||
| 1146 | |||
| 1147 | MOUSE_FACE_OVERWRITTEN_P non-zero means that some row containing | ||
| 1148 | glyphs in mouse-face were overwritten. In that case we have to | ||
| 1149 | make sure that the mouse-highlight is properly redrawn. | ||
| 1150 | |||
| 1151 | W may be a menu bar pseudo-window in case we don't have X toolkit | ||
| 1152 | support. Such windows don't have a cursor, so don't display it | ||
| 1153 | here. */ | ||
| 1154 | |||
| 1155 | static void | ||
| 1156 | x_update_window_end (struct window *w, bool cursor_on_p, | ||
| 1157 | bool mouse_face_overwritten_p) | ||
| 1158 | { | ||
| 1159 | if (!w->pseudo_window_p) | ||
| 1160 | { | ||
| 1161 | block_input (); | ||
| 1162 | |||
| 1163 | if (cursor_on_p) | ||
| 1164 | display_and_set_cursor (w, true, | ||
| 1165 | w->output_cursor.hpos, w->output_cursor.vpos, | ||
| 1166 | w->output_cursor.x, w->output_cursor.y); | ||
| 1167 | |||
| 1168 | if (draw_window_fringes (w, true)) | ||
| 1169 | { | ||
| 1170 | if (WINDOW_RIGHT_DIVIDER_WIDTH (w)) | ||
| 1171 | gui_draw_right_divider (w); | ||
| 1172 | else | ||
| 1173 | gui_draw_vertical_border (w); | ||
| 1174 | } | ||
| 1175 | |||
| 1176 | unblock_input (); | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | /* If a row with mouse-face was overwritten, arrange for | ||
| 1180 | XTframe_up_to_date to redisplay the mouse highlight. */ | ||
| 1181 | if (mouse_face_overwritten_p) | ||
| 1182 | { | ||
| 1183 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); | ||
| 1184 | |||
| 1185 | hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; | ||
| 1186 | hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; | ||
| 1187 | hlinfo->mouse_face_window = Qnil; | ||
| 1188 | } | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | /* Show the frame back buffer. If frame is double-buffered, | 1063 | /* Show the frame back buffer. If frame is double-buffered, |
| 1192 | atomically publish to the user's screen graphics updates made since | 1064 | atomically publish to the user's screen graphics updates made since |
| 1193 | the last call to show_back_buffer. */ | 1065 | the last call to show_back_buffer. */ |
| @@ -1198,6 +1070,11 @@ show_back_buffer (struct frame *f) | |||
| 1198 | if (FRAME_X_DOUBLE_BUFFERED_P (f)) | 1070 | if (FRAME_X_DOUBLE_BUFFERED_P (f)) |
| 1199 | { | 1071 | { |
| 1200 | #ifdef HAVE_XDBE | 1072 | #ifdef HAVE_XDBE |
| 1073 | #ifdef USE_CAIRO | ||
| 1074 | cairo_t *cr = FRAME_CR_CONTEXT (f); | ||
| 1075 | if (cr) | ||
| 1076 | cairo_surface_flush (cairo_get_target (cr)); | ||
| 1077 | #endif | ||
| 1201 | XdbeSwapInfo swap_info; | 1078 | XdbeSwapInfo swap_info; |
| 1202 | memset (&swap_info, 0, sizeof (swap_info)); | 1079 | memset (&swap_info, 0, sizeof (swap_info)); |
| 1203 | swap_info.swap_window = FRAME_X_WINDOW (f); | 1080 | swap_info.swap_window = FRAME_X_WINDOW (f); |
| @@ -1234,30 +1111,33 @@ x_update_end (struct frame *f) | |||
| 1234 | MOUSE_HL_INFO (f)->mouse_face_defer = false; | 1111 | MOUSE_HL_INFO (f)->mouse_face_defer = false; |
| 1235 | 1112 | ||
| 1236 | #ifdef USE_CAIRO | 1113 | #ifdef USE_CAIRO |
| 1237 | if (FRAME_CR_SURFACE (f)) | 1114 | if (!FRAME_X_DOUBLE_BUFFERED_P (f)) |
| 1238 | { | 1115 | { |
| 1239 | cairo_t *cr; | ||
| 1240 | cairo_surface_t *surface; | ||
| 1241 | int width, height; | ||
| 1242 | |||
| 1243 | block_input (); | 1116 | block_input (); |
| 1244 | width = FRAME_PIXEL_WIDTH (f); | 1117 | cairo_surface_t *source_surface = cairo_get_target (FRAME_CR_CONTEXT (f)); |
| 1245 | height = FRAME_PIXEL_HEIGHT (f); | 1118 | if (source_surface) |
| 1246 | if (! FRAME_EXTERNAL_TOOL_BAR (f)) | 1119 | { |
| 1247 | height += FRAME_TOOL_BAR_HEIGHT (f); | 1120 | cairo_t *cr; |
| 1248 | if (! FRAME_EXTERNAL_MENU_BAR (f)) | 1121 | cairo_surface_t *surface; |
| 1249 | height += FRAME_MENU_BAR_HEIGHT (f); | 1122 | int width, height; |
| 1250 | surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f), | 1123 | |
| 1251 | FRAME_X_DRAWABLE (f), | 1124 | width = FRAME_PIXEL_WIDTH (f); |
| 1252 | FRAME_DISPLAY_INFO (f)->visual, | 1125 | height = FRAME_PIXEL_HEIGHT (f); |
| 1253 | width, | 1126 | if (! FRAME_EXTERNAL_TOOL_BAR (f)) |
| 1254 | height); | 1127 | height += FRAME_TOOL_BAR_HEIGHT (f); |
| 1255 | cr = cairo_create (surface); | 1128 | if (! FRAME_EXTERNAL_MENU_BAR (f)) |
| 1256 | cairo_surface_destroy (surface); | 1129 | height += FRAME_MENU_BAR_HEIGHT (f); |
| 1257 | 1130 | surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f), | |
| 1258 | cairo_set_source_surface (cr, FRAME_CR_SURFACE (f), 0, 0); | 1131 | FRAME_X_DRAWABLE (f), |
| 1259 | cairo_paint (cr); | 1132 | FRAME_X_VISUAL (f), |
| 1260 | cairo_destroy (cr); | 1133 | width, height); |
| 1134 | cr = cairo_create (surface); | ||
| 1135 | cairo_surface_destroy (surface); | ||
| 1136 | |||
| 1137 | cairo_set_source_surface (cr, source_surface, 0, 0); | ||
| 1138 | cairo_paint (cr); | ||
| 1139 | cairo_destroy (cr); | ||
| 1140 | } | ||
| 1261 | unblock_input (); | 1141 | unblock_input (); |
| 1262 | } | 1142 | } |
| 1263 | #endif | 1143 | #endif |
| @@ -1530,6 +1410,7 @@ x_set_cursor_gc (struct glyph_string *s) | |||
| 1530 | /* Cursor on non-default face: must merge. */ | 1410 | /* Cursor on non-default face: must merge. */ |
| 1531 | XGCValues xgcv; | 1411 | XGCValues xgcv; |
| 1532 | unsigned long mask; | 1412 | unsigned long mask; |
| 1413 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 1533 | 1414 | ||
| 1534 | xgcv.background = s->f->output_data.x->cursor_pixel; | 1415 | xgcv.background = s->f->output_data.x->cursor_pixel; |
| 1535 | xgcv.foreground = s->face->background; | 1416 | xgcv.foreground = s->face->background; |
| @@ -1555,11 +1436,11 @@ x_set_cursor_gc (struct glyph_string *s) | |||
| 1555 | mask = GCForeground | GCBackground | GCGraphicsExposures; | 1436 | mask = GCForeground | GCBackground | GCGraphicsExposures; |
| 1556 | 1437 | ||
| 1557 | if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) | 1438 | if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) |
| 1558 | XChangeGC (s->display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, | 1439 | XChangeGC (display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, |
| 1559 | mask, &xgcv); | 1440 | mask, &xgcv); |
| 1560 | else | 1441 | else |
| 1561 | FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc | 1442 | FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc |
| 1562 | = XCreateGC (s->display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); | 1443 | = XCreateGC (display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); |
| 1563 | 1444 | ||
| 1564 | s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; | 1445 | s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; |
| 1565 | } | 1446 | } |
| @@ -1595,6 +1476,7 @@ x_set_mouse_face_gc (struct glyph_string *s) | |||
| 1595 | except for FONT. */ | 1476 | except for FONT. */ |
| 1596 | XGCValues xgcv; | 1477 | XGCValues xgcv; |
| 1597 | unsigned long mask; | 1478 | unsigned long mask; |
| 1479 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 1598 | 1480 | ||
| 1599 | xgcv.background = s->face->background; | 1481 | xgcv.background = s->face->background; |
| 1600 | xgcv.foreground = s->face->foreground; | 1482 | xgcv.foreground = s->face->foreground; |
| @@ -1602,11 +1484,11 @@ x_set_mouse_face_gc (struct glyph_string *s) | |||
| 1602 | mask = GCForeground | GCBackground | GCGraphicsExposures; | 1484 | mask = GCForeground | GCBackground | GCGraphicsExposures; |
| 1603 | 1485 | ||
| 1604 | if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) | 1486 | if (FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc) |
| 1605 | XChangeGC (s->display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, | 1487 | XChangeGC (display, FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc, |
| 1606 | mask, &xgcv); | 1488 | mask, &xgcv); |
| 1607 | else | 1489 | else |
| 1608 | FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc | 1490 | FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc |
| 1609 | = XCreateGC (s->display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); | 1491 | = XCreateGC (display, FRAME_X_DRAWABLE (s->f), mask, &xgcv); |
| 1610 | 1492 | ||
| 1611 | s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; | 1493 | s->gc = FRAME_DISPLAY_INFO (s->f)->scratch_cursor_gc; |
| 1612 | 1494 | ||
| @@ -1717,13 +1599,8 @@ x_compute_glyph_string_overhangs (struct glyph_string *s) | |||
| 1717 | 1599 | ||
| 1718 | if (s->first_glyph->type == CHAR_GLYPH) | 1600 | if (s->first_glyph->type == CHAR_GLYPH) |
| 1719 | { | 1601 | { |
| 1720 | unsigned *code = alloca (sizeof (unsigned) * s->nchars); | ||
| 1721 | struct font *font = s->font; | 1602 | struct font *font = s->font; |
| 1722 | int i; | 1603 | font->driver->text_extents (font, s->char2b, s->nchars, &metrics); |
| 1723 | |||
| 1724 | for (i = 0; i < s->nchars; i++) | ||
| 1725 | code[i] = (s->char2b[i].byte1 << 8) | s->char2b[i].byte2; | ||
| 1726 | font->driver->text_extents (font, code, s->nchars, &metrics); | ||
| 1727 | } | 1604 | } |
| 1728 | else | 1605 | else |
| 1729 | { | 1606 | { |
| @@ -1748,11 +1625,12 @@ x_compute_glyph_string_overhangs (struct glyph_string *s) | |||
| 1748 | static void | 1625 | static void |
| 1749 | x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h) | 1626 | x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h) |
| 1750 | { | 1627 | { |
| 1628 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 1751 | XGCValues xgcv; | 1629 | XGCValues xgcv; |
| 1752 | XGetGCValues (s->display, s->gc, GCForeground | GCBackground, &xgcv); | 1630 | XGetGCValues (display, s->gc, GCForeground | GCBackground, &xgcv); |
| 1753 | XSetForeground (s->display, s->gc, xgcv.background); | 1631 | XSetForeground (display, s->gc, xgcv.background); |
| 1754 | x_fill_rectangle (s->f, s->gc, x, y, w, h); | 1632 | x_fill_rectangle (s->f, s->gc, x, y, w, h); |
| 1755 | XSetForeground (s->display, s->gc, xgcv.foreground); | 1633 | XSetForeground (display, s->gc, xgcv.foreground); |
| 1756 | } | 1634 | } |
| 1757 | 1635 | ||
| 1758 | 1636 | ||
| @@ -1773,13 +1651,15 @@ x_draw_glyph_string_background (struct glyph_string *s, bool force_p) | |||
| 1773 | 1651 | ||
| 1774 | if (s->stippled_p) | 1652 | if (s->stippled_p) |
| 1775 | { | 1653 | { |
| 1654 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 1655 | |||
| 1776 | /* Fill background with a stipple pattern. */ | 1656 | /* Fill background with a stipple pattern. */ |
| 1777 | XSetFillStyle (s->display, s->gc, FillOpaqueStippled); | 1657 | XSetFillStyle (display, s->gc, FillOpaqueStippled); |
| 1778 | x_fill_rectangle (s->f, s->gc, s->x, | 1658 | x_fill_rectangle (s->f, s->gc, s->x, |
| 1779 | s->y + box_line_width, | 1659 | s->y + box_line_width, |
| 1780 | s->background_width, | 1660 | s->background_width, |
| 1781 | s->height - 2 * box_line_width); | 1661 | s->height - 2 * box_line_width); |
| 1782 | XSetFillStyle (s->display, s->gc, FillSolid); | 1662 | XSetFillStyle (display, s->gc, FillSolid); |
| 1783 | s->background_filled_p = true; | 1663 | s->background_filled_p = true; |
| 1784 | } | 1664 | } |
| 1785 | else if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width | 1665 | else if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width |
| @@ -1946,7 +1826,7 @@ static void | |||
| 1946 | x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | 1826 | x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) |
| 1947 | { | 1827 | { |
| 1948 | struct glyph *glyph = s->first_glyph; | 1828 | struct glyph *glyph = s->first_glyph; |
| 1949 | XChar2b char2b[8]; | 1829 | unsigned char2b[8]; |
| 1950 | int x, i, j; | 1830 | int x, i, j; |
| 1951 | 1831 | ||
| 1952 | /* If first glyph of S has a left box line, start drawing the text | 1832 | /* If first glyph of S has a left box line, start drawing the text |
| @@ -1997,14 +1877,10 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | |||
| 1997 | if (str) | 1877 | if (str) |
| 1998 | { | 1878 | { |
| 1999 | int upper_len = (len + 1) / 2; | 1879 | int upper_len = (len + 1) / 2; |
| 2000 | unsigned code; | ||
| 2001 | 1880 | ||
| 2002 | /* It is assured that all LEN characters in STR is ASCII. */ | 1881 | /* It is assured that all LEN characters in STR is ASCII. */ |
| 2003 | for (j = 0; j < len; j++) | 1882 | for (j = 0; j < len; j++) |
| 2004 | { | 1883 | char2b[j] = s->font->driver->encode_char (s->font, str[j]) & 0xFFFF; |
| 2005 | code = s->font->driver->encode_char (s->font, str[j]); | ||
| 2006 | STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF); | ||
| 2007 | } | ||
| 2008 | s->font->driver->draw (s, 0, upper_len, | 1884 | s->font->driver->draw (s, 0, upper_len, |
| 2009 | x + glyph->slice.glyphless.upper_xoff, | 1885 | x + glyph->slice.glyphless.upper_xoff, |
| 2010 | s->ybase + glyph->slice.glyphless.upper_yoff, | 1886 | s->ybase + glyph->slice.glyphless.upper_yoff, |
| @@ -2667,7 +2543,7 @@ x_setup_relief_colors (struct glyph_string *s) | |||
| 2667 | XGCValues xgcv; | 2543 | XGCValues xgcv; |
| 2668 | 2544 | ||
| 2669 | /* Get the background color of the face. */ | 2545 | /* Get the background color of the face. */ |
| 2670 | XGetGCValues (s->display, s->gc, GCBackground, &xgcv); | 2546 | XGetGCValues (FRAME_X_DISPLAY (s->f), s->gc, GCBackground, &xgcv); |
| 2671 | color = xgcv.background; | 2547 | color = xgcv.background; |
| 2672 | } | 2548 | } |
| 2673 | 2549 | ||
| @@ -2877,10 +2753,11 @@ x_draw_box_rect (struct glyph_string *s, | |||
| 2877 | int left_x, int top_y, int right_x, int bottom_y, int width, | 2753 | int left_x, int top_y, int right_x, int bottom_y, int width, |
| 2878 | bool left_p, bool right_p, XRectangle *clip_rect) | 2754 | bool left_p, bool right_p, XRectangle *clip_rect) |
| 2879 | { | 2755 | { |
| 2756 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 2880 | XGCValues xgcv; | 2757 | XGCValues xgcv; |
| 2881 | 2758 | ||
| 2882 | XGetGCValues (s->display, s->gc, GCForeground, &xgcv); | 2759 | XGetGCValues (display, s->gc, GCForeground, &xgcv); |
| 2883 | XSetForeground (s->display, s->gc, s->face->box_color); | 2760 | XSetForeground (display, s->gc, s->face->box_color); |
| 2884 | x_set_clip_rectangles (s->f, s->gc, clip_rect, 1); | 2761 | x_set_clip_rectangles (s->f, s->gc, clip_rect, 1); |
| 2885 | 2762 | ||
| 2886 | /* Top. */ | 2763 | /* Top. */ |
| @@ -2901,7 +2778,7 @@ x_draw_box_rect (struct glyph_string *s, | |||
| 2901 | x_fill_rectangle (s->f, s->gc, | 2778 | x_fill_rectangle (s->f, s->gc, |
| 2902 | right_x - width + 1, top_y, width, bottom_y - top_y + 1); | 2779 | right_x - width + 1, top_y, width, bottom_y - top_y + 1); |
| 2903 | 2780 | ||
| 2904 | XSetForeground (s->display, s->gc, xgcv.foreground); | 2781 | XSetForeground (display, s->gc, xgcv.foreground); |
| 2905 | x_reset_clip_rectangles (s->f, s->gc); | 2782 | x_reset_clip_rectangles (s->f, s->gc); |
| 2906 | } | 2783 | } |
| 2907 | 2784 | ||
| @@ -2964,6 +2841,7 @@ x_composite_image (struct glyph_string *s, Pixmap dest, | |||
| 2964 | int srcX, int srcY, int dstX, int dstY, | 2841 | int srcX, int srcY, int dstX, int dstY, |
| 2965 | int width, int height) | 2842 | int width, int height) |
| 2966 | { | 2843 | { |
| 2844 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 2967 | #ifdef HAVE_XRENDER | 2845 | #ifdef HAVE_XRENDER |
| 2968 | if (s->img->picture) | 2846 | if (s->img->picture) |
| 2969 | { | 2847 | { |
| @@ -2973,27 +2851,27 @@ x_composite_image (struct glyph_string *s, Pixmap dest, | |||
| 2973 | 2851 | ||
| 2974 | /* FIXME: Should we do this each time or would it make sense to | 2852 | /* FIXME: Should we do this each time or would it make sense to |
| 2975 | store destination in the frame struct? */ | 2853 | store destination in the frame struct? */ |
| 2976 | default_format = XRenderFindVisualFormat (s->display, | 2854 | default_format = XRenderFindVisualFormat (display, |
| 2977 | DefaultVisual (s->display, 0)); | 2855 | DefaultVisual (display, 0)); |
| 2978 | destination = XRenderCreatePicture (s->display, dest, | 2856 | destination = XRenderCreatePicture (display, dest, |
| 2979 | default_format, 0, &attr); | 2857 | default_format, 0, &attr); |
| 2980 | 2858 | ||
| 2981 | /* FIXME: It may make sense to use PictOpSrc instead of | 2859 | /* FIXME: It may make sense to use PictOpSrc instead of |
| 2982 | PictOpOver, as I don't know if we care about alpha values too | 2860 | PictOpOver, as I don't know if we care about alpha values too |
| 2983 | much here. */ | 2861 | much here. */ |
| 2984 | XRenderComposite (s->display, PictOpOver, | 2862 | XRenderComposite (display, PictOpOver, |
| 2985 | s->img->picture, s->img->mask_picture, destination, | 2863 | s->img->picture, s->img->mask_picture, destination, |
| 2986 | srcX, srcY, | 2864 | srcX, srcY, |
| 2987 | srcX, srcY, | 2865 | srcX, srcY, |
| 2988 | dstX, dstY, | 2866 | dstX, dstY, |
| 2989 | width, height); | 2867 | width, height); |
| 2990 | 2868 | ||
| 2991 | XRenderFreePicture (s->display, destination); | 2869 | XRenderFreePicture (display, destination); |
| 2992 | return; | 2870 | return; |
| 2993 | } | 2871 | } |
| 2994 | #endif | 2872 | #endif |
| 2995 | 2873 | ||
| 2996 | XCopyArea (s->display, s->img->pixmap, | 2874 | XCopyArea (display, s->img->pixmap, |
| 2997 | dest, s->gc, | 2875 | dest, s->gc, |
| 2998 | srcX, srcY, | 2876 | srcX, srcY, |
| 2999 | width, height, dstX, dstY); | 2877 | width, height, dstX, dstY); |
| @@ -3068,7 +2946,7 @@ x_draw_image_foreground (struct glyph_string *s) | |||
| 3068 | xgcv.clip_x_origin = x; | 2946 | xgcv.clip_x_origin = x; |
| 3069 | xgcv.clip_y_origin = y; | 2947 | xgcv.clip_y_origin = y; |
| 3070 | xgcv.function = GXcopy; | 2948 | xgcv.function = GXcopy; |
| 3071 | XChangeGC (s->display, s->gc, mask, &xgcv); | 2949 | XChangeGC (FRAME_X_DISPLAY (s->f), s->gc, mask, &xgcv); |
| 3072 | 2950 | ||
| 3073 | get_glyph_string_clip_rect (s, &clip_rect); | 2951 | get_glyph_string_clip_rect (s, &clip_rect); |
| 3074 | image_rect.x = x; | 2952 | image_rect.x = x; |
| @@ -3217,6 +3095,8 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap) | |||
| 3217 | 3095 | ||
| 3218 | if (s->img->pixmap) | 3096 | if (s->img->pixmap) |
| 3219 | { | 3097 | { |
| 3098 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3099 | |||
| 3220 | if (s->img->mask) | 3100 | if (s->img->mask) |
| 3221 | { | 3101 | { |
| 3222 | /* We can't set both a clip mask and use XSetClipRectangles | 3102 | /* We can't set both a clip mask and use XSetClipRectangles |
| @@ -3232,16 +3112,16 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap) | |||
| 3232 | xgcv.clip_x_origin = x - s->slice.x; | 3112 | xgcv.clip_x_origin = x - s->slice.x; |
| 3233 | xgcv.clip_y_origin = y - s->slice.y; | 3113 | xgcv.clip_y_origin = y - s->slice.y; |
| 3234 | xgcv.function = GXcopy; | 3114 | xgcv.function = GXcopy; |
| 3235 | XChangeGC (s->display, s->gc, mask, &xgcv); | 3115 | XChangeGC (display, s->gc, mask, &xgcv); |
| 3236 | 3116 | ||
| 3237 | XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, | 3117 | XCopyArea (display, s->img->pixmap, pixmap, s->gc, |
| 3238 | s->slice.x, s->slice.y, | 3118 | s->slice.x, s->slice.y, |
| 3239 | s->slice.width, s->slice.height, x, y); | 3119 | s->slice.width, s->slice.height, x, y); |
| 3240 | XSetClipMask (s->display, s->gc, None); | 3120 | XSetClipMask (display, s->gc, None); |
| 3241 | } | 3121 | } |
| 3242 | else | 3122 | else |
| 3243 | { | 3123 | { |
| 3244 | XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, | 3124 | XCopyArea (display, s->img->pixmap, pixmap, s->gc, |
| 3245 | s->slice.x, s->slice.y, | 3125 | s->slice.x, s->slice.y, |
| 3246 | s->slice.width, s->slice.height, x, y); | 3126 | s->slice.width, s->slice.height, x, y); |
| 3247 | 3127 | ||
| @@ -3276,10 +3156,12 @@ x_draw_glyph_string_bg_rect (struct glyph_string *s, int x, int y, int w, int h) | |||
| 3276 | { | 3156 | { |
| 3277 | if (s->stippled_p) | 3157 | if (s->stippled_p) |
| 3278 | { | 3158 | { |
| 3159 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3160 | |||
| 3279 | /* Fill background with a stipple pattern. */ | 3161 | /* Fill background with a stipple pattern. */ |
| 3280 | XSetFillStyle (s->display, s->gc, FillOpaqueStippled); | 3162 | XSetFillStyle (display, s->gc, FillOpaqueStippled); |
| 3281 | x_fill_rectangle (s->f, s->gc, x, y, w, h); | 3163 | x_fill_rectangle (s->f, s->gc, x, y, w, h); |
| 3282 | XSetFillStyle (s->display, s->gc, FillSolid); | 3164 | XSetFillStyle (display, s->gc, FillSolid); |
| 3283 | } | 3165 | } |
| 3284 | else | 3166 | else |
| 3285 | x_clear_glyph_string_rect (s, x, y, w, h); | 3167 | x_clear_glyph_string_rect (s, x, y, w, h); |
| @@ -3307,6 +3189,7 @@ x_draw_image_glyph_string (struct glyph_string *s) | |||
| 3307 | int box_line_vwidth = max (s->face->box_line_width, 0); | 3189 | int box_line_vwidth = max (s->face->box_line_width, 0); |
| 3308 | int height; | 3190 | int height; |
| 3309 | #ifndef USE_CAIRO | 3191 | #ifndef USE_CAIRO |
| 3192 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3310 | Pixmap pixmap = None; | 3193 | Pixmap pixmap = None; |
| 3311 | #endif | 3194 | #endif |
| 3312 | 3195 | ||
| @@ -3337,34 +3220,34 @@ x_draw_image_glyph_string (struct glyph_string *s) | |||
| 3337 | int depth = DefaultDepthOfScreen (screen); | 3220 | int depth = DefaultDepthOfScreen (screen); |
| 3338 | 3221 | ||
| 3339 | /* Create a pixmap as large as the glyph string. */ | 3222 | /* Create a pixmap as large as the glyph string. */ |
| 3340 | pixmap = XCreatePixmap (s->display, FRAME_X_DRAWABLE (s->f), | 3223 | pixmap = XCreatePixmap (display, FRAME_X_DRAWABLE (s->f), |
| 3341 | s->background_width, | 3224 | s->background_width, |
| 3342 | s->height, depth); | 3225 | s->height, depth); |
| 3343 | 3226 | ||
| 3344 | /* Don't clip in the following because we're working on the | 3227 | /* Don't clip in the following because we're working on the |
| 3345 | pixmap. */ | 3228 | pixmap. */ |
| 3346 | XSetClipMask (s->display, s->gc, None); | 3229 | XSetClipMask (display, s->gc, None); |
| 3347 | 3230 | ||
| 3348 | /* Fill the pixmap with the background color/stipple. */ | 3231 | /* Fill the pixmap with the background color/stipple. */ |
| 3349 | if (s->stippled_p) | 3232 | if (s->stippled_p) |
| 3350 | { | 3233 | { |
| 3351 | /* Fill background with a stipple pattern. */ | 3234 | /* Fill background with a stipple pattern. */ |
| 3352 | XSetFillStyle (s->display, s->gc, FillOpaqueStippled); | 3235 | XSetFillStyle (display, s->gc, FillOpaqueStippled); |
| 3353 | XSetTSOrigin (s->display, s->gc, - s->x, - s->y); | 3236 | XSetTSOrigin (display, s->gc, - s->x, - s->y); |
| 3354 | XFillRectangle (s->display, pixmap, s->gc, | 3237 | XFillRectangle (display, pixmap, s->gc, |
| 3355 | 0, 0, s->background_width, s->height); | 3238 | 0, 0, s->background_width, s->height); |
| 3356 | XSetFillStyle (s->display, s->gc, FillSolid); | 3239 | XSetFillStyle (display, s->gc, FillSolid); |
| 3357 | XSetTSOrigin (s->display, s->gc, 0, 0); | 3240 | XSetTSOrigin (display, s->gc, 0, 0); |
| 3358 | } | 3241 | } |
| 3359 | else | 3242 | else |
| 3360 | { | 3243 | { |
| 3361 | XGCValues xgcv; | 3244 | XGCValues xgcv; |
| 3362 | XGetGCValues (s->display, s->gc, GCForeground | GCBackground, | 3245 | XGetGCValues (display, s->gc, GCForeground | GCBackground, |
| 3363 | &xgcv); | 3246 | &xgcv); |
| 3364 | XSetForeground (s->display, s->gc, xgcv.background); | 3247 | XSetForeground (display, s->gc, xgcv.background); |
| 3365 | XFillRectangle (s->display, pixmap, s->gc, | 3248 | XFillRectangle (display, pixmap, s->gc, |
| 3366 | 0, 0, s->background_width, s->height); | 3249 | 0, 0, s->background_width, s->height); |
| 3367 | XSetForeground (s->display, s->gc, xgcv.foreground); | 3250 | XSetForeground (display, s->gc, xgcv.foreground); |
| 3368 | } | 3251 | } |
| 3369 | } | 3252 | } |
| 3370 | else | 3253 | else |
| @@ -3396,9 +3279,9 @@ x_draw_image_glyph_string (struct glyph_string *s) | |||
| 3396 | { | 3279 | { |
| 3397 | x_draw_image_foreground_1 (s, pixmap); | 3280 | x_draw_image_foreground_1 (s, pixmap); |
| 3398 | x_set_glyph_string_clipping (s); | 3281 | x_set_glyph_string_clipping (s); |
| 3399 | XCopyArea (s->display, pixmap, FRAME_X_DRAWABLE (s->f), s->gc, | 3282 | XCopyArea (display, pixmap, FRAME_X_DRAWABLE (s->f), s->gc, |
| 3400 | 0, 0, s->background_width, s->height, s->x, s->y); | 3283 | 0, 0, s->background_width, s->height, s->x, s->y); |
| 3401 | XFreePixmap (s->display, pixmap); | 3284 | XFreePixmap (display, pixmap); |
| 3402 | } | 3285 | } |
| 3403 | else | 3286 | else |
| 3404 | #endif /* ! USE_CAIRO */ | 3287 | #endif /* ! USE_CAIRO */ |
| @@ -3459,6 +3342,7 @@ x_draw_stretch_glyph_string (struct glyph_string *s) | |||
| 3459 | { | 3342 | { |
| 3460 | int y = s->y; | 3343 | int y = s->y; |
| 3461 | int w = background_width - width, h = s->height; | 3344 | int w = background_width - width, h = s->height; |
| 3345 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3462 | XRectangle r; | 3346 | XRectangle r; |
| 3463 | GC gc; | 3347 | GC gc; |
| 3464 | 3348 | ||
| @@ -3481,17 +3365,17 @@ x_draw_stretch_glyph_string (struct glyph_string *s) | |||
| 3481 | if (s->face->stipple) | 3365 | if (s->face->stipple) |
| 3482 | { | 3366 | { |
| 3483 | /* Fill background with a stipple pattern. */ | 3367 | /* Fill background with a stipple pattern. */ |
| 3484 | XSetFillStyle (s->display, gc, FillOpaqueStippled); | 3368 | XSetFillStyle (display, gc, FillOpaqueStippled); |
| 3485 | x_fill_rectangle (s->f, gc, x, y, w, h); | 3369 | x_fill_rectangle (s->f, gc, x, y, w, h); |
| 3486 | XSetFillStyle (s->display, gc, FillSolid); | 3370 | XSetFillStyle (display, gc, FillSolid); |
| 3487 | } | 3371 | } |
| 3488 | else | 3372 | else |
| 3489 | { | 3373 | { |
| 3490 | XGCValues xgcv; | 3374 | XGCValues xgcv; |
| 3491 | XGetGCValues (s->display, gc, GCForeground | GCBackground, &xgcv); | 3375 | XGetGCValues (display, gc, GCForeground | GCBackground, &xgcv); |
| 3492 | XSetForeground (s->display, gc, xgcv.background); | 3376 | XSetForeground (display, gc, xgcv.background); |
| 3493 | x_fill_rectangle (s->f, gc, x, y, w, h); | 3377 | x_fill_rectangle (s->f, gc, x, y, w, h); |
| 3494 | XSetForeground (s->display, gc, xgcv.foreground); | 3378 | XSetForeground (display, gc, xgcv.foreground); |
| 3495 | } | 3379 | } |
| 3496 | 3380 | ||
| 3497 | x_reset_clip_rectangles (s->f, gc); | 3381 | x_reset_clip_rectangles (s->f, gc); |
| @@ -3546,10 +3430,12 @@ x_get_scale_factor(Display *disp, int *scale_x, int *scale_y) | |||
| 3546 | static void | 3430 | static void |
| 3547 | x_draw_underwave (struct glyph_string *s) | 3431 | x_draw_underwave (struct glyph_string *s) |
| 3548 | { | 3432 | { |
| 3433 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3434 | |||
| 3549 | /* Adjust for scale/HiDPI. */ | 3435 | /* Adjust for scale/HiDPI. */ |
| 3550 | int scale_x, scale_y; | 3436 | int scale_x, scale_y; |
| 3551 | 3437 | ||
| 3552 | x_get_scale_factor (s->display, &scale_x, &scale_y); | 3438 | x_get_scale_factor (display, &scale_x, &scale_y); |
| 3553 | 3439 | ||
| 3554 | int wave_height = 3 * scale_y, wave_length = 2 * scale_x; | 3440 | int wave_height = 3 * scale_y, wave_length = 2 * scale_x; |
| 3555 | 3441 | ||
| @@ -3579,7 +3465,7 @@ x_draw_underwave (struct glyph_string *s) | |||
| 3579 | if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) | 3465 | if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) |
| 3580 | return; | 3466 | return; |
| 3581 | 3467 | ||
| 3582 | XSetClipRectangles (s->display, s->gc, 0, 0, &final_clip, 1, Unsorted); | 3468 | XSetClipRectangles (display, s->gc, 0, 0, &final_clip, 1, Unsorted); |
| 3583 | 3469 | ||
| 3584 | /* Draw the waves */ | 3470 | /* Draw the waves */ |
| 3585 | 3471 | ||
| @@ -3598,16 +3484,16 @@ x_draw_underwave (struct glyph_string *s) | |||
| 3598 | 3484 | ||
| 3599 | while (x1 <= xmax) | 3485 | while (x1 <= xmax) |
| 3600 | { | 3486 | { |
| 3601 | XSetLineAttributes (s->display, s->gc, thickness, LineSolid, CapButt, | 3487 | XSetLineAttributes (display, s->gc, thickness, LineSolid, CapButt, |
| 3602 | JoinRound); | 3488 | JoinRound); |
| 3603 | XDrawLine (s->display, FRAME_X_DRAWABLE (s->f), s->gc, x1, y1, x2, y2); | 3489 | XDrawLine (display, FRAME_X_DRAWABLE (s->f), s->gc, x1, y1, x2, y2); |
| 3604 | x1 = x2, y1 = y2; | 3490 | x1 = x2, y1 = y2; |
| 3605 | x2 += dx, y2 = y0 + odd*dy; | 3491 | x2 += dx, y2 = y0 + odd*dy; |
| 3606 | odd = !odd; | 3492 | odd = !odd; |
| 3607 | } | 3493 | } |
| 3608 | 3494 | ||
| 3609 | /* Restore previous clipping rectangle(s) */ | 3495 | /* Restore previous clipping rectangle(s) */ |
| 3610 | XSetClipRectangles (s->display, s->gc, 0, 0, s->clip, s->num_clips, Unsorted); | 3496 | XSetClipRectangles (display, s->gc, 0, 0, s->clip, s->num_clips, Unsorted); |
| 3611 | #endif /* not USE_CAIRO */ | 3497 | #endif /* not USE_CAIRO */ |
| 3612 | } | 3498 | } |
| 3613 | 3499 | ||
| @@ -3724,11 +3610,12 @@ x_draw_glyph_string (struct glyph_string *s) | |||
| 3724 | x_draw_underwave (s); | 3610 | x_draw_underwave (s); |
| 3725 | else | 3611 | else |
| 3726 | { | 3612 | { |
| 3613 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3727 | XGCValues xgcv; | 3614 | XGCValues xgcv; |
| 3728 | XGetGCValues (s->display, s->gc, GCForeground, &xgcv); | 3615 | XGetGCValues (display, s->gc, GCForeground, &xgcv); |
| 3729 | XSetForeground (s->display, s->gc, s->face->underline_color); | 3616 | XSetForeground (display, s->gc, s->face->underline_color); |
| 3730 | x_draw_underwave (s); | 3617 | x_draw_underwave (s); |
| 3731 | XSetForeground (s->display, s->gc, xgcv.foreground); | 3618 | XSetForeground (display, s->gc, xgcv.foreground); |
| 3732 | } | 3619 | } |
| 3733 | } | 3620 | } |
| 3734 | else if (s->face->underline_type == FACE_UNDER_LINE) | 3621 | else if (s->face->underline_type == FACE_UNDER_LINE) |
| @@ -3808,12 +3695,13 @@ x_draw_glyph_string (struct glyph_string *s) | |||
| 3808 | s->x, y, s->width, thickness); | 3695 | s->x, y, s->width, thickness); |
| 3809 | else | 3696 | else |
| 3810 | { | 3697 | { |
| 3698 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3811 | XGCValues xgcv; | 3699 | XGCValues xgcv; |
| 3812 | XGetGCValues (s->display, s->gc, GCForeground, &xgcv); | 3700 | XGetGCValues (display, s->gc, GCForeground, &xgcv); |
| 3813 | XSetForeground (s->display, s->gc, s->face->underline_color); | 3701 | XSetForeground (display, s->gc, s->face->underline_color); |
| 3814 | x_fill_rectangle (s->f, s->gc, | 3702 | x_fill_rectangle (s->f, s->gc, |
| 3815 | s->x, y, s->width, thickness); | 3703 | s->x, y, s->width, thickness); |
| 3816 | XSetForeground (s->display, s->gc, xgcv.foreground); | 3704 | XSetForeground (display, s->gc, xgcv.foreground); |
| 3817 | } | 3705 | } |
| 3818 | } | 3706 | } |
| 3819 | } | 3707 | } |
| @@ -3827,12 +3715,13 @@ x_draw_glyph_string (struct glyph_string *s) | |||
| 3827 | s->width, h); | 3715 | s->width, h); |
| 3828 | else | 3716 | else |
| 3829 | { | 3717 | { |
| 3718 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3830 | XGCValues xgcv; | 3719 | XGCValues xgcv; |
| 3831 | XGetGCValues (s->display, s->gc, GCForeground, &xgcv); | 3720 | XGetGCValues (display, s->gc, GCForeground, &xgcv); |
| 3832 | XSetForeground (s->display, s->gc, s->face->overline_color); | 3721 | XSetForeground (display, s->gc, s->face->overline_color); |
| 3833 | x_fill_rectangle (s->f, s->gc, s->x, s->y + dy, | 3722 | x_fill_rectangle (s->f, s->gc, s->x, s->y + dy, |
| 3834 | s->width, h); | 3723 | s->width, h); |
| 3835 | XSetForeground (s->display, s->gc, xgcv.foreground); | 3724 | XSetForeground (display, s->gc, xgcv.foreground); |
| 3836 | } | 3725 | } |
| 3837 | } | 3726 | } |
| 3838 | 3727 | ||
| @@ -3856,12 +3745,13 @@ x_draw_glyph_string (struct glyph_string *s) | |||
| 3856 | s->width, h); | 3745 | s->width, h); |
| 3857 | else | 3746 | else |
| 3858 | { | 3747 | { |
| 3748 | Display *display = FRAME_X_DISPLAY (s->f); | ||
| 3859 | XGCValues xgcv; | 3749 | XGCValues xgcv; |
| 3860 | XGetGCValues (s->display, s->gc, GCForeground, &xgcv); | 3750 | XGetGCValues (display, s->gc, GCForeground, &xgcv); |
| 3861 | XSetForeground (s->display, s->gc, s->face->strike_through_color); | 3751 | XSetForeground (display, s->gc, s->face->strike_through_color); |
| 3862 | x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy, | 3752 | x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy, |
| 3863 | s->width, h); | 3753 | s->width, h); |
| 3864 | XSetForeground (s->display, s->gc, xgcv.foreground); | 3754 | XSetForeground (display, s->gc, xgcv.foreground); |
| 3865 | } | 3755 | } |
| 3866 | } | 3756 | } |
| 3867 | 3757 | ||
| @@ -4306,11 +4196,25 @@ x_scroll_run (struct window *w, struct run *run) | |||
| 4306 | 4196 | ||
| 4307 | block_input (); | 4197 | block_input (); |
| 4308 | 4198 | ||
| 4309 | /* Cursor off. Will be switched on again in x_update_window_end. */ | 4199 | /* Cursor off. Will be switched on again in gui_update_window_end. */ |
| 4310 | gui_clear_cursor (w); | 4200 | gui_clear_cursor (w); |
| 4311 | 4201 | ||
| 4312 | #ifdef USE_CAIRO | 4202 | #ifdef USE_CAIRO |
| 4313 | if (FRAME_CR_CONTEXT (f)) | 4203 | if (FRAME_X_DOUBLE_BUFFERED_P (f)) |
| 4204 | { | ||
| 4205 | cairo_t *cr = FRAME_CR_CONTEXT (f); | ||
| 4206 | if (cr) | ||
| 4207 | cairo_surface_flush (cairo_get_target (cr)); | ||
| 4208 | XCopyArea (FRAME_X_DISPLAY (f), | ||
| 4209 | FRAME_X_DRAWABLE (f), FRAME_X_DRAWABLE (f), | ||
| 4210 | f->output_data.x->normal_gc, | ||
| 4211 | x, from_y, | ||
| 4212 | width, height, | ||
| 4213 | x, to_y); | ||
| 4214 | if (cr) | ||
| 4215 | cairo_surface_mark_dirty (cairo_get_target (cr)); | ||
| 4216 | } | ||
| 4217 | else if (FRAME_CR_CONTEXT (f)) | ||
| 4314 | { | 4218 | { |
| 4315 | cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, | 4219 | cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, |
| 4316 | width, height); | 4220 | width, height); |
| @@ -8287,7 +8191,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 8287 | fit in 81 bytes. So, we must prepare sufficient | 8191 | fit in 81 bytes. So, we must prepare sufficient |
| 8288 | bytes for copy_buffer. 513 bytes (256 chars for | 8192 | bytes for copy_buffer. 513 bytes (256 chars for |
| 8289 | two-byte character set) seems to be a fairly good | 8193 | two-byte character set) seems to be a fairly good |
| 8290 | approximation. -- 2000.8.10 handa@etl.go.jp */ | 8194 | approximation. -- 2000.8.10 handa@gnu.org */ |
| 8291 | unsigned char copy_buffer[513]; | 8195 | unsigned char copy_buffer[513]; |
| 8292 | unsigned char *copy_bufptr = copy_buffer; | 8196 | unsigned char *copy_bufptr = copy_buffer; |
| 8293 | int copy_bufsiz = sizeof (copy_buffer); | 8197 | int copy_bufsiz = sizeof (copy_buffer); |
| @@ -8768,7 +8672,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 8768 | font_drop_xrender_surfaces (f); | 8672 | font_drop_xrender_surfaces (f); |
| 8769 | unblock_input (); | 8673 | unblock_input (); |
| 8770 | #ifdef USE_CAIRO | 8674 | #ifdef USE_CAIRO |
| 8771 | if (f) x_cr_destroy_surface (f); | 8675 | if (f) |
| 8676 | x_cr_update_surface_desired_size (f, configureEvent.xconfigure.width, | ||
| 8677 | configureEvent.xconfigure.height); | ||
| 8772 | #endif | 8678 | #endif |
| 8773 | #ifdef USE_GTK | 8679 | #ifdef USE_GTK |
| 8774 | if (!f | 8680 | if (!f |
| @@ -8782,7 +8688,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 8782 | xg_frame_resized (f, configureEvent.xconfigure.width, | 8688 | xg_frame_resized (f, configureEvent.xconfigure.width, |
| 8783 | configureEvent.xconfigure.height); | 8689 | configureEvent.xconfigure.height); |
| 8784 | #ifdef USE_CAIRO | 8690 | #ifdef USE_CAIRO |
| 8785 | x_cr_destroy_surface (f); | 8691 | x_cr_update_surface_desired_size (f, configureEvent.xconfigure.width, |
| 8692 | configureEvent.xconfigure.height); | ||
| 8786 | #endif | 8693 | #endif |
| 8787 | f = 0; | 8694 | f = 0; |
| 8788 | } | 8695 | } |
| @@ -9440,7 +9347,7 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text | |||
| 9440 | /* RIF: Define cursor CURSOR on frame F. */ | 9347 | /* RIF: Define cursor CURSOR on frame F. */ |
| 9441 | 9348 | ||
| 9442 | static void | 9349 | static void |
| 9443 | x_define_frame_cursor (struct frame *f, Cursor cursor) | 9350 | x_define_frame_cursor (struct frame *f, Emacs_Cursor cursor) |
| 9444 | { | 9351 | { |
| 9445 | if (!f->pointer_invisible | 9352 | if (!f->pointer_invisible |
| 9446 | && f->output_data.x->current_cursor != cursor) | 9353 | && f->output_data.x->current_cursor != cursor) |
| @@ -11892,7 +11799,9 @@ x_free_frame_resources (struct frame *f) | |||
| 11892 | free_frame_xic (f); | 11799 | free_frame_xic (f); |
| 11893 | #endif | 11800 | #endif |
| 11894 | 11801 | ||
| 11895 | x_free_cr_resources (f); | 11802 | #ifdef USE_CAIRO |
| 11803 | x_cr_destroy_frame_context (f); | ||
| 11804 | #endif | ||
| 11896 | #ifdef USE_X_TOOLKIT | 11805 | #ifdef USE_X_TOOLKIT |
| 11897 | if (f->output_data.x->widget) | 11806 | if (f->output_data.x->widget) |
| 11898 | { | 11807 | { |
| @@ -12239,6 +12148,17 @@ x_check_font (struct frame *f, struct font *font) | |||
| 12239 | 12148 | ||
| 12240 | 12149 | ||
| 12241 | /*********************************************************************** | 12150 | /*********************************************************************** |
| 12151 | Image Hooks | ||
| 12152 | ***********************************************************************/ | ||
| 12153 | |||
| 12154 | static void | ||
| 12155 | x_free_pixmap (struct frame *f, Emacs_Pixmap pixmap) | ||
| 12156 | { | ||
| 12157 | XFreePixmap (FRAME_X_DISPLAY (f), pixmap); | ||
| 12158 | } | ||
| 12159 | |||
| 12160 | |||
| 12161 | /*********************************************************************** | ||
| 12242 | Initialization | 12162 | Initialization |
| 12243 | ***********************************************************************/ | 12163 | ***********************************************************************/ |
| 12244 | 12164 | ||
| @@ -13145,8 +13065,8 @@ static struct redisplay_interface x_redisplay_interface = | |||
| 13145 | gui_clear_end_of_line, | 13065 | gui_clear_end_of_line, |
| 13146 | x_scroll_run, | 13066 | x_scroll_run, |
| 13147 | x_after_update_window_line, | 13067 | x_after_update_window_line, |
| 13148 | x_update_window_begin, | 13068 | NULL, /* update_window_begin */ |
| 13149 | x_update_window_end, | 13069 | NULL, /* update_window_end */ |
| 13150 | x_flip_and_flush, | 13070 | x_flip_and_flush, |
| 13151 | gui_clear_window_mouse_face, | 13071 | gui_clear_window_mouse_face, |
| 13152 | gui_get_glyph_overhangs, | 13072 | gui_get_glyph_overhangs, |
| @@ -13314,6 +13234,7 @@ x_create_terminal (struct x_display_info *dpyinfo) | |||
| 13314 | terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar; | 13234 | terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar; |
| 13315 | terminal->judge_scroll_bars_hook = XTjudge_scroll_bars; | 13235 | terminal->judge_scroll_bars_hook = XTjudge_scroll_bars; |
| 13316 | terminal->get_string_resource_hook = x_get_string_resource; | 13236 | terminal->get_string_resource_hook = x_get_string_resource; |
| 13237 | terminal->free_pixmap = x_free_pixmap; | ||
| 13317 | terminal->delete_frame_hook = x_destroy_window; | 13238 | terminal->delete_frame_hook = x_destroy_window; |
| 13318 | terminal->delete_terminal_hook = x_delete_terminal; | 13239 | terminal->delete_terminal_hook = x_delete_terminal; |
| 13319 | /* Other hooks are NULL by default. */ | 13240 | /* Other hooks are NULL by default. */ |
diff --git a/src/xterm.h b/src/xterm.h index 266a42afa08..ce1443c381c 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -725,13 +725,12 @@ struct x_output | |||
| 725 | #ifdef USE_CAIRO | 725 | #ifdef USE_CAIRO |
| 726 | /* Cairo drawing context. */ | 726 | /* Cairo drawing context. */ |
| 727 | cairo_t *cr_context; | 727 | cairo_t *cr_context; |
| 728 | /* Cairo surface for double buffering */ | 728 | /* Width and height reported by the last ConfigureNotify event. |
| 729 | cairo_surface_t *cr_surface; | 729 | They are used when creating the cairo surface next time. */ |
| 730 | int cr_surface_desired_width, cr_surface_desired_height; | ||
| 730 | #endif | 731 | #endif |
| 731 | }; | 732 | }; |
| 732 | 733 | ||
| 733 | #define No_Cursor (None) | ||
| 734 | |||
| 735 | enum | 734 | enum |
| 736 | { | 735 | { |
| 737 | /* Values for focus_state, used as bit mask. | 736 | /* Values for focus_state, used as bit mask. |
| @@ -1107,6 +1106,7 @@ extern int x_dispatch_event (XEvent *, Display *); | |||
| 1107 | #endif | 1106 | #endif |
| 1108 | extern int x_x_to_emacs_modifiers (struct x_display_info *, int); | 1107 | extern int x_x_to_emacs_modifiers (struct x_display_info *, int); |
| 1109 | #ifdef USE_CAIRO | 1108 | #ifdef USE_CAIRO |
| 1109 | extern void x_cr_destroy_frame_context (struct frame *); | ||
| 1110 | extern cairo_t *x_begin_cr_clip (struct frame *, GC); | 1110 | extern cairo_t *x_begin_cr_clip (struct frame *, GC); |
| 1111 | extern void x_end_cr_clip (struct frame *); | 1111 | extern void x_end_cr_clip (struct frame *); |
| 1112 | extern void x_set_cr_source_with_gc_foreground (struct frame *, GC); | 1112 | extern void x_set_cr_source_with_gc_foreground (struct frame *, GC); |
| @@ -1222,7 +1222,8 @@ extern void destroy_frame_xic (struct frame *); | |||
| 1222 | extern void xic_set_preeditarea (struct window *, int, int); | 1222 | extern void xic_set_preeditarea (struct window *, int, int); |
| 1223 | extern void xic_set_statusarea (struct frame *); | 1223 | extern void xic_set_statusarea (struct frame *); |
| 1224 | extern void xic_set_xfontset (struct frame *, const char *); | 1224 | extern void xic_set_xfontset (struct frame *, const char *); |
| 1225 | extern bool x_defined_color (struct frame *, const char *, XColor *, bool, bool); | 1225 | extern bool x_defined_color (struct frame *, const char *, Emacs_Color *, |
| 1226 | bool, bool); | ||
| 1226 | #ifdef HAVE_X_I18N | 1227 | #ifdef HAVE_X_I18N |
| 1227 | extern void free_frame_xic (struct frame *); | 1228 | extern void free_frame_xic (struct frame *); |
| 1228 | # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT | 1229 | # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT |
| @@ -1261,15 +1262,6 @@ extern void x_session_close (void); | |||
| 1261 | 1262 | ||
| 1262 | #define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0) | 1263 | #define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0) |
| 1263 | 1264 | ||
| 1264 | #define STORE_XCHAR2B(chp, b1, b2) \ | ||
| 1265 | ((chp)->byte1 = (b1), (chp)->byte2 = (b2)) | ||
| 1266 | |||
| 1267 | #define XCHAR2B_BYTE1(chp) \ | ||
| 1268 | ((chp)->byte1) | ||
| 1269 | |||
| 1270 | #define XCHAR2B_BYTE2(chp) \ | ||
| 1271 | ((chp)->byte2) | ||
| 1272 | |||
| 1273 | #define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight) \ | 1265 | #define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight) \ |
| 1274 | ((nr).x = (rx), \ | 1266 | ((nr).x = (rx), \ |
| 1275 | (nr).y = (ry), \ | 1267 | (nr).y = (ry), \ |