aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1994-10-15 04:49:14 +0000
committerKarl Heuer1994-10-15 04:49:14 +0000
commit58769bee4dd24a08492658cbae306af4ffdc7f95 (patch)
treed7a6ed84fb2e258078af315b841104c070713a97 /src
parent9171f37fd2a593cecac4ff71022d5527fbb7db65 (diff)
downloademacs-58769bee4dd24a08492658cbae306af4ffdc7f95.tar.gz
emacs-58769bee4dd24a08492658cbae306af4ffdc7f95.zip
(stuffline, scraplines): Functions deleted.
(line_dance, line_dance_len, line_dance_in_progress): New vars. (XTins_del_lines): Don't do any X calls; just update the array. (do_line_dance): New function. Do the X calls here. (XTupdate_end, XTwrite_glyphs): Call do_line_dance.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c299
1 files changed, 163 insertions, 136 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 5e1c7353001..8523880ef75 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -341,13 +341,14 @@ static int fast_find_position ();
341static void note_mouse_highlight (); 341static void note_mouse_highlight ();
342static void clear_mouse_face (); 342static void clear_mouse_face ();
343static void show_mouse_face (); 343static void show_mouse_face ();
344static void do_line_dance ();
344 345
345void dumpborder (); 346void dumpborder ();
346static int XTcursor_to (); 347static int XTcursor_to ();
347static int XTclear_end_of_line (); 348static int XTclear_end_of_line ();
348 349
349 350
350/* Starting and ending updates. 351/* Starting and ending updates.
351 352
352 These hooks are called by update_frame at the beginning and end 353 These hooks are called by update_frame at the beginning and end
353 of a frame update. We record in `updating_frame' the identity 354 of a frame update. We record in `updating_frame' the identity
@@ -361,7 +362,7 @@ extern int mouse_track_top, mouse_track_left, mouse_track_width;
361static 362static
362XTupdate_begin (f) 363XTupdate_begin (f)
363 struct frame *f; 364 struct frame *f;
364{ 365{
365 int mask; 366 int mask;
366 367
367 if (f == 0) 368 if (f == 0)
@@ -410,11 +411,12 @@ XTupdate_begin (f)
410static 411static
411XTupdate_end (f) 412XTupdate_end (f)
412 struct frame *f; 413 struct frame *f;
413{ 414{
414 int mask; 415 int mask;
415 416
416 BLOCK_INPUT; 417 BLOCK_INPUT;
417 418
419 do_line_dance ();
418 x_display_cursor (f, 1); 420 x_display_cursor (f, 1);
419 421
420 if (f == mouse_face_mouse_frame) 422 if (f == mouse_face_mouse_frame)
@@ -774,6 +776,7 @@ XTwrite_glyphs (start, len)
774 776
775 BLOCK_INPUT; 777 BLOCK_INPUT;
776 778
779 do_line_dance ();
777 f = updating_frame; 780 f = updating_frame;
778 if (f == 0) 781 if (f == 0)
779 { 782 {
@@ -794,7 +797,7 @@ XTwrite_glyphs (start, len)
794 && curs_x <= f->phys_cursor_x 797 && curs_x <= f->phys_cursor_x
795 && curs_x + len > f->phys_cursor_x) 798 && curs_x + len > f->phys_cursor_x)
796 f->phys_cursor_x = -1; 799 f->phys_cursor_x = -1;
797 800
798 if (updating_frame == 0) 801 if (updating_frame == 0)
799 { 802 {
800 f->cursor_x += len; 803 f->cursor_x += len;
@@ -811,7 +814,7 @@ XTwrite_glyphs (start, len)
811 Erase the current text line from the nominal cursor position (inclusive) 814 Erase the current text line from the nominal cursor position (inclusive)
812 to column FIRST_UNUSED (exclusive). The idea is that everything 815 to column FIRST_UNUSED (exclusive). The idea is that everything
813 from FIRST_UNUSED onward is already erased. */ 816 from FIRST_UNUSED onward is already erased. */
814 817
815static int 818static int
816XTclear_end_of_line (first_unused) 819XTclear_end_of_line (first_unused)
817 register int first_unused; 820 register int first_unused;
@@ -862,7 +865,7 @@ XTclear_frame ()
862 f->phys_cursor_x = -1; /* Cursor not visible. */ 865 f->phys_cursor_x = -1; /* Cursor not visible. */
863 curs_x = 0; /* Nominal cursor position is top left. */ 866 curs_x = 0; /* Nominal cursor position is top left. */
864 curs_y = 0; 867 curs_y = 0;
865 868
866 BLOCK_INPUT; 869 BLOCK_INPUT;
867 870
868 XClear (FRAME_X_WINDOW (f)); 871 XClear (FRAME_X_WINDOW (f));
@@ -973,7 +976,7 @@ font_char_overlap_left (font, c)
973 { 976 {
974 int rowlen = font->max_char_or_byte2 - font->min_char_or_byte2 + 1; 977 int rowlen = font->max_char_or_byte2 - font->min_char_or_byte2 + 1;
975 int row, within; 978 int row, within;
976 979
977 /* Decode char into row number (byte 1) and code within row (byte 2). */ 980 /* Decode char into row number (byte 1) and code within row (byte 2). */
978 row = c >> 8; 981 row = c >> 8;
979 within = c & 0177; 982 within = c & 0177;
@@ -1018,7 +1021,7 @@ font_char_overlap_right (font, c)
1018 { 1021 {
1019 int rowlen = font->max_char_or_byte2 - font->min_char_or_byte2 + 1; 1022 int rowlen = font->max_char_or_byte2 - font->min_char_or_byte2 + 1;
1020 int row, within; 1023 int row, within;
1021 1024
1022 /* Decode char into row number (byte 1) and code within row (byte 2). */ 1025 /* Decode char into row number (byte 1) and code within row (byte 2). */
1023 row = c >> 8; 1026 row = c >> 8;
1024 within = c & 0177; 1027 within = c & 0177;
@@ -1102,7 +1105,7 @@ XTflash (f)
1102 values.function = GXxor; 1105 values.function = GXxor;
1103 values.foreground = (f->display.x->foreground_pixel 1106 values.foreground = (f->display.x->foreground_pixel
1104 ^ f->display.x->background_pixel); 1107 ^ f->display.x->background_pixel);
1105 1108
1106 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f), 1109 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f),
1107 GCFunction | GCForeground, &values); 1110 GCFunction | GCForeground, &values);
1108 } 1111 }
@@ -1141,7 +1144,7 @@ XTflash (f)
1141 select (0, 0, 0, 0, &timeout); 1144 select (0, 0, 0, 0, &timeout);
1142 } 1145 }
1143 } 1146 }
1144 1147
1145 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), gc, 1148 XFillRectangle (x_current_display, FRAME_X_WINDOW (f), gc,
1146 width/4, height/4, width/2, height/2); 1149 width/4, height/4, width/2, height/2);
1147 XFreeGC (x_current_display, gc); 1150 XFreeGC (x_current_display, gc);
@@ -1181,7 +1184,7 @@ XTring_bell ()
1181 These are not supposed to be used because we are supposed to turn 1184 These are not supposed to be used because we are supposed to turn
1182 off the feature of using them. */ 1185 off the feature of using them. */
1183 1186
1184static 1187static
1185XTinsert_glyphs (start, len) 1188XTinsert_glyphs (start, len)
1186 register char *start; 1189 register char *start;
1187 register int len; 1190 register int len;
@@ -1189,7 +1192,7 @@ XTinsert_glyphs (start, len)
1189 abort (); 1192 abort ();
1190} 1193}
1191 1194
1192static 1195static
1193XTdelete_glyphs (n) 1196XTdelete_glyphs (n)
1194 register int n; 1197 register int n;
1195{ 1198{
@@ -1214,103 +1217,127 @@ XTset_terminal_window (n)
1214 flexlines = n; 1217 flexlines = n;
1215} 1218}
1216 1219
1217/* Perform an insert-lines operation. 1220/* Array of line numbers from cached insert/delete operations.
1218 Insert N lines at a vertical position curs_y. */ 1221 line_dance[i] is the old position of the line that we want
1222 to move to line i, or -1 if we want a blank line there. */
1223static int *line_dance;
1219 1224
1220static void 1225/* Allocated length of that array. */
1221stufflines (n) 1226static int line_dance_len;
1222 register int n;
1223{
1224 register int topregion, bottomregion;
1225 register int length, newtop, mask;
1226 register struct frame *f = updating_frame;
1227 int intborder = f->display.x->internal_border_width;
1228 1227
1229 if (curs_y >= flexlines) 1228/* Flag indicating whether we've done any work. */
1230 return; 1229static int line_dance_in_progress;
1231
1232 topregion = curs_y;
1233 bottomregion = flexlines - (n + 1);
1234 newtop = topregion + n;
1235 length = (bottomregion - topregion) + 1;
1236
1237 if ((length > 0) && (newtop <= flexlines))
1238 XCopyArea (x_current_display, FRAME_X_WINDOW (f),
1239 FRAME_X_WINDOW (f), f->display.x->normal_gc,
1240 intborder, CHAR_TO_PIXEL_ROW (f, topregion),
1241 f->width * FONT_WIDTH (f->display.x->font),
1242 length * f->display.x->line_height, intborder,
1243 CHAR_TO_PIXEL_ROW (f, newtop));
1244
1245 newtop = min (newtop, (flexlines - 1));
1246 length = newtop - topregion;
1247 if (length > 0)
1248 XClearArea (x_current_display, FRAME_X_WINDOW (f), intborder,
1249 CHAR_TO_PIXEL_ROW (f, topregion),
1250 f->width * FONT_WIDTH (f->display.x->font),
1251 n * f->display.x->line_height, False);
1252}
1253 1230
1254/* Perform a delete-lines operation, deleting N lines 1231/* Perform an insert-lines or delete-lines operation,
1255 at a vertical position curs_y. */ 1232 inserting N lines or deleting -N lines at vertical position VPOS. */
1256 1233XTins_del_lines (vpos, n)
1257static void 1234 int vpos, n;
1258scraplines (n)
1259 register int n;
1260{ 1235{
1261 int mask; 1236 register int fence, i;
1262 register struct frame *f = updating_frame;
1263 int intborder = f->display.x->internal_border_width;
1264 1237
1265 if (curs_y >= flexlines) 1238 if (vpos >= flexlines)
1266 return; 1239 return;
1267 1240
1268 if ((curs_y + n) >= flexlines) 1241 if (!line_dance_in_progress)
1269 { 1242 {
1270 if (flexlines >= (curs_y + 1)) 1243 int ht = updating_frame->height;
1271 XClearArea (x_current_display, FRAME_X_WINDOW (f), intborder, 1244 if (ht > line_dance_len)
1272 CHAR_TO_PIXEL_ROW (f, curs_y), 1245 {
1273 f->width * FONT_WIDTH (f->display.x->font), 1246 line_dance = (int *)xrealloc (line_dance, ht * sizeof (int));
1274 (flexlines - curs_y) * f->display.x->line_height, False); 1247 line_dance_len = ht;
1248 }
1249 for (i = 0; i < ht; ++i) line_dance[i] = i;
1250 line_dance_in_progress = 1;
1251 }
1252 if (n >= 0)
1253 {
1254 if (n > flexlines - vpos)
1255 n = flexlines - vpos;
1256 fence = vpos + n;
1257 for (i = flexlines; --i >= fence;)
1258 line_dance[i] = line_dance[i-n];
1259 for (i = fence; --i >= vpos;)
1260 line_dance[i] = -1;
1275 } 1261 }
1276 else 1262 else
1277 { 1263 {
1278 XCopyArea (x_current_display, FRAME_X_WINDOW (f), 1264 n = -n;
1279 FRAME_X_WINDOW (f), f->display.x->normal_gc, 1265 if (n > flexlines - vpos)
1280 intborder, 1266 n = flexlines - vpos;
1281 CHAR_TO_PIXEL_ROW (f, curs_y + n), 1267 fence = flexlines - n;
1282 f->width * FONT_WIDTH (f->display.x->font), 1268 for (i = vpos; i < fence; ++i)
1283 (flexlines - (curs_y + n)) * f->display.x->line_height, 1269 line_dance[i] = line_dance[i + n];
1284 intborder, CHAR_TO_PIXEL_ROW (f, curs_y)); 1270 for (i = fence; i < flexlines; ++i)
1285 XClearArea (x_current_display, FRAME_X_WINDOW (f), 1271 line_dance[i] = -1;
1286 intborder,
1287 CHAR_TO_PIXEL_ROW (f, flexlines - n),
1288 f->width * FONT_WIDTH (f->display.x->font),
1289 n * f->display.x->line_height, False);
1290 } 1272 }
1291} 1273}
1292 1274
1293/* Perform an insert-lines or delete-lines operation, 1275/* Here's where we actually move the pixels around.
1294 inserting N lines or deleting -N lines at vertical position VPOS. */ 1276 Must be called with input blocked. */
1295 1277static void
1296XTins_del_lines (vpos, n) 1278do_line_dance ()
1297 int vpos, n;
1298{ 1279{
1299 if (updating_frame == 0) 1280 register int i, j, distance;
1281 register struct frame *f;
1282 int ht;
1283 int intborder;
1284
1285 /* Must check this flag first. If it's not set, then not only is the
1286 array uninitialized, but we might not even have a frame. */
1287 if (!line_dance_in_progress)
1288 return;
1289
1290 f = updating_frame;
1291 if (f == 0)
1300 abort (); 1292 abort ();
1301 1293
1302 /* Hide the cursor. */ 1294 ht = f->height;
1295 intborder = f->display.x->internal_border_width;
1296
1303 x_display_cursor (updating_frame, 0); 1297 x_display_cursor (updating_frame, 0);
1304 1298
1305 XTcursor_to (vpos, 0); 1299 for (i = 0; i < ht; ++i)
1300 if (line_dance[i] != -1 && (distance = line_dance[i]-i) > 0)
1301 {
1302 for (j = i; (j < ht && line_dance[j] != -1
1303 && line_dance[j]-j == distance); ++j);
1304 /* Copy [i,j) upward from [i+distance,j+distance) */
1305 XCopyArea (x_current_display, FRAME_X_WINDOW (f),
1306 FRAME_X_WINDOW (f), f->display.x->normal_gc,
1307 intborder, CHAR_TO_PIXEL_ROW (f, i+distance),
1308 f->width * FONT_WIDTH (f->display.x->font),
1309 (j-i) * f->display.x->line_height,
1310 intborder, CHAR_TO_PIXEL_ROW (f, i));
1311 i = j-1;
1312 }
1306 1313
1307 BLOCK_INPUT; 1314 for (i = ht; --i >=0; )
1308 if (n >= 0) 1315 if (line_dance[i] != -1 && (distance = line_dance[i]-i) < 0)
1309 stufflines (n); 1316 {
1310 else 1317 for (j = i; (--j >= 0 && line_dance[j] != -1
1311 scraplines (-n); 1318 && line_dance[j]-j == distance); --j);
1312 XFlushQueue (); 1319 /* Copy (j,i] downward from (j+distance, i+distance] */
1313 UNBLOCK_INPUT; 1320 XCopyArea (x_current_display, FRAME_X_WINDOW (f),
1321 FRAME_X_WINDOW (f), f->display.x->normal_gc,
1322 intborder, CHAR_TO_PIXEL_ROW (f, j+1+distance),
1323 f->width * FONT_WIDTH (f->display.x->font),
1324 (i-j) * f->display.x->line_height,
1325 intborder, CHAR_TO_PIXEL_ROW (f, j+1));
1326 i = j+1;
1327 }
1328
1329 for (i = 0; i < ht; ++i)
1330 if (line_dance[i] == -1)
1331 {
1332 for (j = i; j < ht && line_dance[j] == -1; ++j);
1333 /* Clear [i,j) */
1334 XClearArea (x_current_display, FRAME_X_WINDOW (f),
1335 intborder, CHAR_TO_PIXEL_ROW (f, i),
1336 f->width * FONT_WIDTH (f->display.x->font),
1337 (j-i) * f->display.x->line_height, False);
1338 i = j-1;
1339 }
1340 line_dance_in_progress = 0;
1314} 1341}
1315 1342
1316/* Support routines for exposure events. */ 1343/* Support routines for exposure events. */
@@ -1338,7 +1365,7 @@ dumprectangle (f, left, top, cols, rows)
1338 /* Express rectangle as four edges, instead of position-and-size. */ 1365 /* Express rectangle as four edges, instead of position-and-size. */
1339 bottom = top + rows; 1366 bottom = top + rows;
1340 right = left + cols; 1367 right = left + cols;
1341 1368
1342 /* Convert rectangle edges in pixels to edges in chars. 1369 /* Convert rectangle edges in pixels to edges in chars.
1343 Round down for left and top, up for right and bottom. */ 1370 Round down for left and top, up for right and bottom. */
1344 top = PIXEL_TO_CHAR_ROW (f, top); 1371 top = PIXEL_TO_CHAR_ROW (f, top);
@@ -1444,7 +1471,7 @@ x_new_focus_frame (frame)
1444 1471
1445 if (frame != x_focus_frame) 1472 if (frame != x_focus_frame)
1446 { 1473 {
1447 /* Set this before calling other routines, so that they see 1474 /* Set this before calling other routines, so that they see
1448 the correct value of x_focus_frame. */ 1475 the correct value of x_focus_frame. */
1449 x_focus_frame = frame; 1476 x_focus_frame = frame;
1450 1477
@@ -1510,11 +1537,11 @@ XTframe_rehighlight ()
1510 of the top five modifier bits depends on what keys are attached 1537 of the top five modifier bits depends on what keys are attached
1511 to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5 1538 to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5
1512 is the meta bit. 1539 is the meta bit.
1513 1540
1514 x_meta_mod_mask is a mask containing the bits used for the meta key. 1541 x_meta_mod_mask is a mask containing the bits used for the meta key.
1515 It may have more than one bit set, if more than one modifier bit 1542 It may have more than one bit set, if more than one modifier bit
1516 has meta keys on it. Basically, if EVENT is a KeyPress event, 1543 has meta keys on it. Basically, if EVENT is a KeyPress event,
1517 the meta key is pressed if (EVENT.state & x_meta_mod_mask) != 0. 1544 the meta key is pressed if (EVENT.state & x_meta_mod_mask) != 0.
1518 1545
1519 x_shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the 1546 x_shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the
1520 lock modifier bit, or zero otherwise. Non-alphabetic keys should 1547 lock modifier bit, or zero otherwise. Non-alphabetic keys should
@@ -1541,7 +1568,7 @@ x_find_modifier_meanings ()
1541 x_alt_mod_mask = 0; 1568 x_alt_mod_mask = 0;
1542 x_super_mod_mask = 0; 1569 x_super_mod_mask = 0;
1543 x_hyper_mod_mask = 0; 1570 x_hyper_mod_mask = 0;
1544 1571
1545#ifdef HAVE_X11R4 1572#ifdef HAVE_X11R4
1546 XDisplayKeycodes (x_current_display, &min_code, &max_code); 1573 XDisplayKeycodes (x_current_display, &min_code, &max_code);
1547#else 1574#else
@@ -1554,7 +1581,7 @@ x_find_modifier_meanings ()
1554 &syms_per_code); 1581 &syms_per_code);
1555 mods = XGetModifierMapping (x_current_display); 1582 mods = XGetModifierMapping (x_current_display);
1556 1583
1557 /* Scan the modifier table to see which modifier bits the Meta and 1584 /* Scan the modifier table to see which modifier bits the Meta and
1558 Alt keysyms are on. */ 1585 Alt keysyms are on. */
1559 { 1586 {
1560 int row, col; /* The row and column in the modifier table. */ 1587 int row, col; /* The row and column in the modifier table. */
@@ -1623,7 +1650,7 @@ x_find_modifier_meanings ()
1623 { 1650 {
1624 x_alt_mod_mask &= ~x_meta_mod_mask; 1651 x_alt_mod_mask &= ~x_meta_mod_mask;
1625 } 1652 }
1626 1653
1627 XFree ((char *) syms); 1654 XFree ((char *) syms);
1628 XFreeModifiermap (mods); 1655 XFreeModifiermap (mods);
1629} 1656}
@@ -1732,7 +1759,7 @@ construct_mouse_click (result, event, f)
1732 result->timestamp = event->time; 1759 result->timestamp = event->time;
1733 result->modifiers = (x_x_to_emacs_modifiers (event->state) 1760 result->modifiers = (x_x_to_emacs_modifiers (event->state)
1734 | (event->type == ButtonRelease 1761 | (event->type == ButtonRelease
1735 ? up_modifier 1762 ? up_modifier
1736 : down_modifier)); 1763 : down_modifier));
1737 1764
1738 { 1765 {
@@ -1764,7 +1791,7 @@ construct_menu_click (result, event, f)
1764 result->timestamp = event->time; 1791 result->timestamp = event->time;
1765 result->modifiers = (x_x_to_emacs_modifiers (event->state) 1792 result->modifiers = (x_x_to_emacs_modifiers (event->state)
1766 | (event->type == ButtonRelease 1793 | (event->type == ButtonRelease
1767 ? up_modifier 1794 ? up_modifier
1768 : down_modifier)); 1795 : down_modifier));
1769 1796
1770 XSETINT (result->x, event->x); 1797 XSETINT (result->x, event->x);
@@ -1836,7 +1863,7 @@ note_mouse_movement (frame, event)
1836 *still* on the same glyph. */ 1863 *still* on the same glyph. */
1837 int dummy; 1864 int dummy;
1838 Window dummy_window; 1865 Window dummy_window;
1839 1866
1840 XQueryPointer (event->display, FRAME_X_WINDOW (frame), 1867 XQueryPointer (event->display, FRAME_X_WINDOW (frame),
1841 &dummy_window, &dummy_window, 1868 &dummy_window, &dummy_window,
1842 &dummy, &dummy, &dummy, &dummy, 1869 &dummy, &dummy, &dummy, &dummy,
@@ -2220,7 +2247,7 @@ XTmouse_position (f, bar_window, part, x, y, time)
2220 &dummy_window, 2247 &dummy_window,
2221 2248
2222 /* The position on that root window. */ 2249 /* The position on that root window. */
2223 &root_x, &root_y, 2250 &root_x, &root_y,
2224 2251
2225 /* More trash we can't trust. */ 2252 /* More trash we can't trust. */
2226 &dummy, &dummy, 2253 &dummy, &dummy,
@@ -2292,7 +2319,7 @@ XTmouse_position (f, bar_window, part, x, y, time)
2292 /* Is win one of our frames? */ 2319 /* Is win one of our frames? */
2293 f1 = x_any_window_to_frame (win); 2320 f1 = x_any_window_to_frame (win);
2294 } 2321 }
2295 2322
2296 /* If not, is it one of our scroll bars? */ 2323 /* If not, is it one of our scroll bars? */
2297 if (! f1) 2324 if (! f1)
2298 { 2325 {
@@ -2404,9 +2431,9 @@ x_scroll_bar_create (window, top, left, width, height)
2404 frame->display.x->edit_widget, al, ac); 2431 frame->display.x->edit_widget, al, ac);
2405 SET_SCROLL_BAR_X_WINDOW 2432 SET_SCROLL_BAR_X_WINDOW
2406 (bar, sb_widget->core.window); 2433 (bar, sb_widget->core.window);
2407#endif 2434#endif
2408 SET_SCROLL_BAR_X_WINDOW 2435 SET_SCROLL_BAR_X_WINDOW
2409 (bar, 2436 (bar,
2410 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame), 2437 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame),
2411 2438
2412 /* Position and size of scroll bar. */ 2439 /* Position and size of scroll bar. */
@@ -2446,7 +2473,7 @@ x_scroll_bar_create (window, top, left, width, height)
2446 If the handle is already drawn from START to END, don't bother 2473 If the handle is already drawn from START to END, don't bother
2447 redrawing it, unless REBUILD is non-zero; in that case, always 2474 redrawing it, unless REBUILD is non-zero; in that case, always
2448 redraw it. (REBUILD is handy for drawing the handle after expose 2475 redraw it. (REBUILD is handy for drawing the handle after expose
2449 events.) 2476 events.)
2450 2477
2451 Normally, we want to constrain the start and end of the handle to 2478 Normally, we want to constrain the start and end of the handle to
2452 fit inside its rectangle, but if the user is dragging the scroll bar 2479 fit inside its rectangle, but if the user is dragging the scroll bar
@@ -2564,7 +2591,7 @@ x_scroll_bar_move (bar, top, left, width, height)
2564 if (top != XINT (bar->top)) mask |= CWY; 2591 if (top != XINT (bar->top)) mask |= CWY;
2565 if (width != XINT (bar->width)) mask |= CWWidth; 2592 if (width != XINT (bar->width)) mask |= CWWidth;
2566 if (height != XINT (bar->height)) mask |= CWHeight; 2593 if (height != XINT (bar->height)) mask |= CWHeight;
2567 2594
2568 if (mask) 2595 if (mask)
2569 XConfigureWindow (x_current_display, SCROLL_BAR_X_WINDOW (bar), 2596 XConfigureWindow (x_current_display, SCROLL_BAR_X_WINDOW (bar),
2570 mask, &wc); 2597 mask, &wc);
@@ -2667,7 +2694,7 @@ XTset_vertical_scroll_bar (window, portion, whole, position)
2667/* Arrange for all scroll bars on FRAME to be removed at the next call 2694/* Arrange for all scroll bars on FRAME to be removed at the next call
2668 to `*judge_scroll_bars_hook'. A scroll bar may be spared if 2695 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
2669 `*redeem_scroll_bar_hook' is applied to its window before the judgement. */ 2696 `*redeem_scroll_bar_hook' is applied to its window before the judgement. */
2670static void 2697static void
2671XTcondemn_scroll_bars (frame) 2698XTcondemn_scroll_bars (frame)
2672 FRAME_PTR frame; 2699 FRAME_PTR frame;
2673{ 2700{
@@ -2847,7 +2874,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
2847 2874
2848 /* Same deal here as the other #if 0. */ 2875 /* Same deal here as the other #if 0. */
2849#if 0 2876#if 0
2850 /* Clicks on the handle are always reported as occurring at the top of 2877 /* Clicks on the handle are always reported as occurring at the top of
2851 the handle. */ 2878 the handle. */
2852 if (emacs_event->part == scroll_bar_handle) 2879 if (emacs_event->part == scroll_bar_handle)
2853 emacs_event->x = bar->start; 2880 emacs_event->x = bar->start;
@@ -2884,7 +2911,7 @@ x_scroll_bar_note_movement (bar, event)
2884 if (new_start != XINT (bar->start)) 2911 if (new_start != XINT (bar->start))
2885 { 2912 {
2886 int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); 2913 int new_end = new_start + (XINT (bar->end) - XINT (bar->start));
2887 2914
2888 x_scroll_bar_set_handle (bar, new_start, new_end, 0); 2915 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
2889 } 2916 }
2890 } 2917 }
@@ -2894,7 +2921,7 @@ x_scroll_bar_note_movement (bar, event)
2894 { 2921 {
2895 int dummy; 2922 int dummy;
2896 Window dummy_window; 2923 Window dummy_window;
2897 2924
2898 XQueryPointer (event->xmotion.display, event->xmotion.window, 2925 XQueryPointer (event->xmotion.display, event->xmotion.window,
2899 &dummy_window, &dummy_window, 2926 &dummy_window, &dummy_window,
2900 &dummy, &dummy, &dummy, &dummy, 2927 &dummy, &dummy, &dummy, &dummy,
@@ -3025,7 +3052,7 @@ process_expose_from_menu (event)
3025 { 3052 {
3026 struct scroll_bar *bar 3053 struct scroll_bar *bar
3027 = x_window_to_scroll_bar (event.xexpose.window); 3054 = x_window_to_scroll_bar (event.xexpose.window);
3028 3055
3029 if (bar) 3056 if (bar)
3030 x_scroll_bar_expose (bar, &event); 3057 x_scroll_bar_expose (bar, &event);
3031 } 3058 }
@@ -3055,7 +3082,7 @@ x_queue_event (event)
3055 struct selection_event_queue *queue_tmp 3082 struct selection_event_queue *queue_tmp
3056 = (struct selection_event_queue *) malloc (sizeof (struct selection_event_queue)); 3083 = (struct selection_event_queue *) malloc (sizeof (struct selection_event_queue));
3057 3084
3058 if (queue_tmp != NULL) 3085 if (queue_tmp != NULL)
3059 { 3086 {
3060 queue_tmp->event = *event; 3087 queue_tmp->event = *event;
3061 queue_tmp->next = queue; 3088 queue_tmp->next = queue;
@@ -3069,7 +3096,7 @@ x_queue_event (event)
3069static void 3096static void
3070x_unqueue_events () 3097x_unqueue_events ()
3071{ 3098{
3072 while (queue != NULL) 3099 while (queue != NULL)
3073 { 3100 {
3074 struct selection_event_queue *queue_tmp = queue; 3101 struct selection_event_queue *queue_tmp = queue;
3075 XPutBackEvent (XDISPLAY &queue_tmp->event); 3102 XPutBackEvent (XDISPLAY &queue_tmp->event);
@@ -3103,7 +3130,7 @@ x_stop_queuing_selection_requests ()
3103static Time enter_timestamp; 3130static Time enter_timestamp;
3104 3131
3105/* This holds the state XLookupString needs to implement dead keys 3132/* This holds the state XLookupString needs to implement dead keys
3106 and other tricks known as "compose processing". _X Window System_ 3133 and other tricks known as "compose processing". _X Window System_
3107 says that a portable program can't use this, but Stephen Gildea assures 3134 says that a portable program can't use this, but Stephen Gildea assures
3108 me that letting the compiler initialize it to zeros will work okay. 3135 me that letting the compiler initialize it to zeros will work okay.
3109 3136
@@ -3271,7 +3298,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3271 { 3298 {
3272 int new_x, new_y; 3299 int new_x, new_y;
3273 struct frame *f = x_window_to_frame (event.xclient.window); 3300 struct frame *f = x_window_to_frame (event.xclient.window);
3274 3301
3275 new_x = event.xclient.data.s[0]; 3302 new_x = event.xclient.data.s[0];
3276 new_y = event.xclient.data.s[1]; 3303 new_y = event.xclient.data.s[1];
3277 3304
@@ -3388,7 +3415,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3388 { 3415 {
3389 struct scroll_bar *bar 3416 struct scroll_bar *bar
3390 = x_window_to_scroll_bar (event.xexpose.window); 3417 = x_window_to_scroll_bar (event.xexpose.window);
3391 3418
3392 if (bar) 3419 if (bar)
3393 x_scroll_bar_expose (bar, &event); 3420 x_scroll_bar_expose (bar, &event);
3394#ifdef USE_X_TOOLKIT 3421#ifdef USE_X_TOOLKIT
@@ -3630,7 +3657,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3630 3657
3631 case FocusIn: 3658 case FocusIn:
3632 f = x_any_window_to_frame (event.xfocus.window); 3659 f = x_any_window_to_frame (event.xfocus.window);
3633 if (event.xfocus.detail != NotifyPointer) 3660 if (event.xfocus.detail != NotifyPointer)
3634 x_focus_event_frame = f; 3661 x_focus_event_frame = f;
3635 if (f) 3662 if (f)
3636 x_new_focus_frame (f); 3663 x_new_focus_frame (f);
@@ -3656,7 +3683,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3656 else 3683 else
3657 x_new_focus_frame (f); 3684 x_new_focus_frame (f);
3658 } 3685 }
3659 else 3686 else
3660 { 3687 {
3661 if (f == x_focus_event_frame) 3688 if (f == x_focus_event_frame)
3662 x_focus_event_frame = 0; 3689 x_focus_event_frame = 0;
@@ -3790,7 +3817,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3790 this event after the window manager has changed our 3817 this event after the window manager has changed our
3791 parent, but before we have reached the ReparentNotify. */ 3818 parent, but before we have reached the ReparentNotify. */
3792 XTranslateCoordinates (x_current_display, 3819 XTranslateCoordinates (x_current_display,
3793 3820
3794 /* From-window, to-window. */ 3821 /* From-window, to-window. */
3795 f->display.x->window_desc, 3822 f->display.x->window_desc,
3796 ROOT_WINDOW, 3823 ROOT_WINDOW,
@@ -3925,20 +3952,20 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3925 3952
3926 /* On some systems, an X bug causes Emacs to get no more events 3953 /* On some systems, an X bug causes Emacs to get no more events
3927 when the window is destroyed. Detect that. (1994.) */ 3954 when the window is destroyed. Detect that. (1994.) */
3928 if (! event_found) 3955 if (! event_found)
3929 { 3956 {
3930 /* Emacs and the X Server eats up CPU time if XNoOp is done every time. 3957 /* Emacs and the X Server eats up CPU time if XNoOp is done every time.
3931 One XNOOP in 100 loops will make Emacs terminate. 3958 One XNOOP in 100 loops will make Emacs terminate.
3932 B. Bretthauer, 1994 */ 3959 B. Bretthauer, 1994 */
3933 x_noop_count++; 3960 x_noop_count++;
3934 if (x_noop_count >= 100) 3961 if (x_noop_count >= 100)
3935 { 3962 {
3936 x_noop_count=0; 3963 x_noop_count=0;
3937 XNoOp (x_current_display); 3964 XNoOp (x_current_display);
3938 } 3965 }
3939 } 3966 }
3940 3967
3941#if 0 /* This fails for serial-line connections to the X server, 3968#if 0 /* This fails for serial-line connections to the X server,
3942 because the characters arrive one by one, and a partial 3969 because the characters arrive one by one, and a partial
3943 command makes select return but gives nothing to read. 3970 command makes select return but gives nothing to read.
3944 We'll have to hope that the bug that this tried to fix 3971 We'll have to hope that the bug that this tried to fix
@@ -4268,12 +4295,12 @@ x_text_icon (f, icon_name)
4268 else 4295 else
4269 if (! f->display.x->icon_label) 4296 if (! f->display.x->icon_label)
4270 f->display.x->icon_label = " *emacs* "; 4297 f->display.x->icon_label = " *emacs* ";
4271 4298
4272#if 0 4299#if 0
4273 XSetIconName (x_current_display, FRAME_X_WINDOW (f), 4300 XSetIconName (x_current_display, FRAME_X_WINDOW (f),
4274 (char *) f->display.x->icon_label); 4301 (char *) f->display.x->icon_label);
4275#endif 4302#endif
4276 4303
4277 f->display.x->icon_bitmap_flag = 0; 4304 f->display.x->icon_bitmap_flag = 0;
4278 x_wm_set_icon_pixmap (f, 0); 4305 x_wm_set_icon_pixmap (f, 0);
4279 4306
@@ -4306,7 +4333,7 @@ x_error_quitter (display, error)
4306{ 4333{
4307 char buf[256]; 4334 char buf[256];
4308 4335
4309 /* Note that there is no real way portable across R3/R4 to get the 4336 /* Note that there is no real way portable across R3/R4 to get the
4310 original error handler. */ 4337 original error handler. */
4311 4338
4312 XGetErrorText (display, error->error_code, buf, sizeof (buf)); 4339 XGetErrorText (display, error->error_code, buf, sizeof (buf));
@@ -4506,7 +4533,7 @@ x_new_font (f, fontname)
4506 } 4533 }
4507 } 4534 }
4508 found_font: 4535 found_font:
4509 4536
4510 /* If we have, just return it from the table. */ 4537 /* If we have, just return it from the table. */
4511 if (already_loaded >= 0) 4538 if (already_loaded >= 0)
4512 f->display.x->font = x_font_table[already_loaded].font; 4539 f->display.x->font = x_font_table[already_loaded].font;
@@ -4518,7 +4545,7 @@ x_new_font (f, fontname)
4518 XFontStruct *font; 4545 XFontStruct *font;
4519 4546
4520 /* Try to find a character-cell font in the list. */ 4547 /* Try to find a character-cell font in the list. */
4521#if 0 4548#if 0
4522 /* A laudable goal, but this isn't how to do it. */ 4549 /* A laudable goal, but this isn't how to do it. */
4523 for (i = 0; i < n_matching_fonts; i++) 4550 for (i = 0; i < n_matching_fonts; i++)
4524 if (! font_info[i].per_char) 4551 if (! font_info[i].per_char)
@@ -4657,7 +4684,7 @@ x_calc_absolute_position (f)
4657 { 4684 {
4658 BLOCK_INPUT; 4685 BLOCK_INPUT;
4659 XTranslateCoordinates (x_current_display, 4686 XTranslateCoordinates (x_current_display,
4660 4687
4661 /* From-window, to-window. */ 4688 /* From-window, to-window. */
4662 f->display.x->window_desc, 4689 f->display.x->window_desc,
4663 f->display.x->parent_desc, 4690 f->display.x->parent_desc,
@@ -4673,7 +4700,7 @@ x_calc_absolute_position (f)
4673 /* Treat negative positions as relative to the leftmost bottommost 4700 /* Treat negative positions as relative to the leftmost bottommost
4674 position that fits on the screen. */ 4701 position that fits on the screen. */
4675 if (flags & XNegative) 4702 if (flags & XNegative)
4676 f->display.x->left_pos = (x_screen_width 4703 f->display.x->left_pos = (x_screen_width
4677 - 2 * f->display.x->border_width - win_x 4704 - 2 * f->display.x->border_width - win_x
4678 - PIXEL_WIDTH (f) 4705 - PIXEL_WIDTH (f)
4679 + f->display.x->left_pos); 4706 + f->display.x->left_pos);
@@ -5141,7 +5168,7 @@ x_iconify_frame (f)
5141 WM_CHANGE_STATE type. */ 5168 WM_CHANGE_STATE type. */
5142 { 5169 {
5143 XEvent message; 5170 XEvent message;
5144 5171
5145 message.xclient.window = FRAME_X_WINDOW (f); 5172 message.xclient.window = FRAME_X_WINDOW (f);
5146 message.xclient.type = ClientMessage; 5173 message.xclient.type = ClientMessage;
5147 message.xclient.message_type = Xatom_wm_change_state; 5174 message.xclient.message_type = Xatom_wm_change_state;
@@ -5159,7 +5186,7 @@ x_iconify_frame (f)
5159 } 5186 }
5160 } 5187 }
5161 5188
5162 /* X11R3: set the initial_state field of the window manager hints to 5189 /* X11R3: set the initial_state field of the window manager hints to
5163 IconicState. */ 5190 IconicState. */
5164 x_wm_set_window_state (f, IconicState); 5191 x_wm_set_window_state (f, IconicState);
5165 5192
@@ -5283,7 +5310,7 @@ x_wm_set_size_hint (f, flags, user_position)
5283 resizing; min_width and min_height aren't useful for this 5310 resizing; min_width and min_height aren't useful for this
5284 purpose, since they might not give the dimensions for a 5311 purpose, since they might not give the dimensions for a
5285 zero-row, zero-column frame. 5312 zero-row, zero-column frame.
5286 5313
5287 We use the base_width and base_height members if we have 5314 We use the base_width and base_height members if we have
5288 them; otherwise, we set the min_width and min_height members 5315 them; otherwise, we set the min_width and min_height members
5289 to the size for a zero x zero frame. */ 5316 to the size for a zero x zero frame. */
@@ -5314,7 +5341,7 @@ x_wm_set_size_hint (f, flags, user_position)
5314#else 5341#else
5315 value = XGetNormalHints (x_current_display, window, &hints); 5342 value = XGetNormalHints (x_current_display, window, &hints);
5316#endif 5343#endif
5317 5344
5318 if (value == 0) 5345 if (value == 0)
5319 hints.flags = 0; 5346 hints.flags = 0;
5320 if (hints.flags & PSize) 5347 if (hints.flags & PSize)
@@ -5440,7 +5467,7 @@ x_term_init (display_name, xrm_option, resource_name)
5440 extern int old_fcntl_owner; 5467 extern int old_fcntl_owner;
5441#endif /* ! defined (F_SETOWN) */ 5468#endif /* ! defined (F_SETOWN) */
5442#endif /* F_SETOWN_BUG */ 5469#endif /* F_SETOWN_BUG */
5443 5470
5444 x_noop_count = 0; 5471 x_noop_count = 0;
5445 5472
5446 x_focus_frame = x_highlight_frame = 0; 5473 x_focus_frame = x_highlight_frame = 0;
@@ -5551,19 +5578,19 @@ Check the DISPLAY environment variable or use \"-d\"\n",
5551 condemn_scroll_bars_hook = XTcondemn_scroll_bars; 5578 condemn_scroll_bars_hook = XTcondemn_scroll_bars;
5552 redeem_scroll_bar_hook = XTredeem_scroll_bar; 5579 redeem_scroll_bar_hook = XTredeem_scroll_bar;
5553 judge_scroll_bars_hook = XTjudge_scroll_bars; 5580 judge_scroll_bars_hook = XTjudge_scroll_bars;
5554 5581
5555 scroll_region_ok = 1; /* we'll scroll partial frames */ 5582 scroll_region_ok = 1; /* we'll scroll partial frames */
5556 char_ins_del_ok = 0; /* just as fast to write the line */ 5583 char_ins_del_ok = 0; /* just as fast to write the line */
5557 line_ins_del_ok = 1; /* we'll just blt 'em */ 5584 line_ins_del_ok = 1; /* we'll just blt 'em */
5558 fast_clear_end_of_line = 1; /* X does this well */ 5585 fast_clear_end_of_line = 1; /* X does this well */
5559 memory_below_frame = 0; /* we don't remember what scrolls 5586 memory_below_frame = 0; /* we don't remember what scrolls
5560 off the bottom */ 5587 off the bottom */
5561 baud_rate = 19200; 5588 baud_rate = 19200;
5562 5589
5563 /* Try to use interrupt input; if we can't, then start polling. */ 5590 /* Try to use interrupt input; if we can't, then start polling. */
5564 Fset_input_mode (Qt, Qnil, Qt, Qnil); 5591 Fset_input_mode (Qt, Qnil, Qt, Qnil);
5565 5592
5566 /* Note that there is no real way portable across R3/R4 to get the 5593 /* Note that there is no real way portable across R3/R4 to get the
5567 original error handler. */ 5594 original error handler. */
5568 XHandleError (x_error_quitter); 5595 XHandleError (x_error_quitter);
5569 XHandleIOError (x_io_error_quitter); 5596 XHandleIOError (x_io_error_quitter);