Mercurial > emacs
comparison src/xterm.c @ 9537:f025140f7ff7
(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.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 15 Oct 1994 04:49:14 +0000 |
parents | c84536ef5fa9 |
children | f8b7a65a94bc |
comparison
equal
deleted
inserted
replaced
9536:ecaa7babab17 | 9537:f025140f7ff7 |
---|---|
339 | 339 |
340 static int fast_find_position (); | 340 static int fast_find_position (); |
341 static void note_mouse_highlight (); | 341 static void note_mouse_highlight (); |
342 static void clear_mouse_face (); | 342 static void clear_mouse_face (); |
343 static void show_mouse_face (); | 343 static void show_mouse_face (); |
344 static void do_line_dance (); | |
344 | 345 |
345 void dumpborder (); | 346 void dumpborder (); |
346 static int XTcursor_to (); | 347 static int XTcursor_to (); |
347 static int XTclear_end_of_line (); | 348 static 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 |
354 of the frame being updated, so that the XT... functions do not | 355 of the frame being updated, so that the XT... functions do not |
355 need to take a frame as argument. Most of the XT... functions | 356 need to take a frame as argument. Most of the XT... functions |
359 extern int mouse_track_top, mouse_track_left, mouse_track_width; | 360 extern int mouse_track_top, mouse_track_left, mouse_track_width; |
360 | 361 |
361 static | 362 static |
362 XTupdate_begin (f) | 363 XTupdate_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) |
368 abort (); | 369 abort (); |
369 | 370 |
408 } | 409 } |
409 | 410 |
410 static | 411 static |
411 XTupdate_end (f) | 412 XTupdate_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) |
421 mouse_face_defer = 0; | 423 mouse_face_defer = 0; |
422 #if 0 | 424 #if 0 |
772 int mask; | 774 int mask; |
773 struct frame *f; | 775 struct frame *f; |
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 { |
780 f = selected_frame; | 783 f = selected_frame; |
781 /* If not within an update, | 784 /* If not within an update, |
792 /* If we drew on top of the cursor, note that it is turned off. */ | 795 /* If we drew on top of the cursor, note that it is turned off. */ |
793 if (curs_y == f->phys_cursor_y | 796 if (curs_y == f->phys_cursor_y |
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; |
801 x_display_cursor (f, 1); | 804 x_display_cursor (f, 1); |
802 f->cursor_x -= len; | 805 f->cursor_x -= len; |
809 | 812 |
810 /* Clear to the end of the line. | 813 /* Clear to the end of the line. |
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 |
815 static int | 818 static int |
816 XTclear_end_of_line (first_unused) | 819 XTclear_end_of_line (first_unused) |
817 register int first_unused; | 820 register int first_unused; |
818 { | 821 { |
819 struct frame *f = updating_frame; | 822 struct frame *f = updating_frame; |
860 f = selected_frame; | 863 f = selected_frame; |
861 | 864 |
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)); |
869 | 872 |
870 /* We have to clear the scroll bars, too. If we have changed | 873 /* We have to clear the scroll bars, too. If we have changed |
971 s = &font->max_bounds; | 974 s = &font->max_bounds; |
972 else | 975 else |
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; |
980 if (!(within >= font->min_char_or_byte2 | 983 if (!(within >= font->min_char_or_byte2 |
981 && within <= font->max_char_or_byte2 | 984 && within <= font->max_char_or_byte2 |
1016 s = &font->max_bounds; | 1019 s = &font->max_bounds; |
1017 else | 1020 else |
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; |
1025 if (!(within >= font->min_char_or_byte2 | 1028 if (!(within >= font->min_char_or_byte2 |
1026 && within <= font->max_char_or_byte2 | 1029 && within <= font->max_char_or_byte2 |
1100 XGCValues values; | 1103 XGCValues values; |
1101 | 1104 |
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 } |
1109 | 1112 |
1110 { | 1113 { |
1139 | 1142 |
1140 /* Try to wait that long--but we might wake up sooner. */ | 1143 /* Try to wait that long--but we might wake up sooner. */ |
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); |
1148 XFlush (x_current_display); | 1151 XFlush (x_current_display); |
1149 } | 1152 } |
1179 | 1182 |
1180 /* Insert and delete character. | 1183 /* Insert and delete character. |
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 |
1184 static | 1187 static |
1185 XTinsert_glyphs (start, len) | 1188 XTinsert_glyphs (start, len) |
1186 register char *start; | 1189 register char *start; |
1187 register int len; | 1190 register int len; |
1188 { | 1191 { |
1189 abort (); | 1192 abort (); |
1190 } | 1193 } |
1191 | 1194 |
1192 static | 1195 static |
1193 XTdelete_glyphs (n) | 1196 XTdelete_glyphs (n) |
1194 register int n; | 1197 register int n; |
1195 { | 1198 { |
1196 abort (); | 1199 abort (); |
1197 } | 1200 } |
1212 flexlines = updating_frame->height; | 1215 flexlines = updating_frame->height; |
1213 else | 1216 else |
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 |
1219 | 1222 to move to line i, or -1 if we want a blank line there. */ |
1220 static void | 1223 static int *line_dance; |
1221 stufflines (n) | 1224 |
1222 register int n; | 1225 /* Allocated length of that array. */ |
1223 { | 1226 static int line_dance_len; |
1224 register int topregion, bottomregion; | 1227 |
1225 register int length, newtop, mask; | 1228 /* Flag indicating whether we've done any work. */ |
1226 register struct frame *f = updating_frame; | 1229 static int line_dance_in_progress; |
1227 int intborder = f->display.x->internal_border_width; | |
1228 | |
1229 if (curs_y >= flexlines) | |
1230 return; | |
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 | |
1254 /* Perform a delete-lines operation, deleting N lines | |
1255 at a vertical position curs_y. */ | |
1256 | |
1257 static void | |
1258 scraplines (n) | |
1259 register int n; | |
1260 { | |
1261 int mask; | |
1262 register struct frame *f = updating_frame; | |
1263 int intborder = f->display.x->internal_border_width; | |
1264 | |
1265 if (curs_y >= flexlines) | |
1266 return; | |
1267 | |
1268 if ((curs_y + n) >= flexlines) | |
1269 { | |
1270 if (flexlines >= (curs_y + 1)) | |
1271 XClearArea (x_current_display, FRAME_X_WINDOW (f), intborder, | |
1272 CHAR_TO_PIXEL_ROW (f, curs_y), | |
1273 f->width * FONT_WIDTH (f->display.x->font), | |
1274 (flexlines - curs_y) * f->display.x->line_height, False); | |
1275 } | |
1276 else | |
1277 { | |
1278 XCopyArea (x_current_display, FRAME_X_WINDOW (f), | |
1279 FRAME_X_WINDOW (f), f->display.x->normal_gc, | |
1280 intborder, | |
1281 CHAR_TO_PIXEL_ROW (f, curs_y + n), | |
1282 f->width * FONT_WIDTH (f->display.x->font), | |
1283 (flexlines - (curs_y + n)) * f->display.x->line_height, | |
1284 intborder, CHAR_TO_PIXEL_ROW (f, curs_y)); | |
1285 XClearArea (x_current_display, FRAME_X_WINDOW (f), | |
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 } | |
1291 } | |
1292 | 1230 |
1293 /* Perform an insert-lines or delete-lines operation, | 1231 /* Perform an insert-lines or delete-lines operation, |
1294 inserting N lines or deleting -N lines at vertical position VPOS. */ | 1232 inserting N lines or deleting -N lines at vertical position VPOS. */ |
1295 | |
1296 XTins_del_lines (vpos, n) | 1233 XTins_del_lines (vpos, n) |
1297 int vpos, n; | 1234 int vpos, n; |
1298 { | 1235 { |
1299 if (updating_frame == 0) | 1236 register int fence, i; |
1237 | |
1238 if (vpos >= flexlines) | |
1239 return; | |
1240 | |
1241 if (!line_dance_in_progress) | |
1242 { | |
1243 int ht = updating_frame->height; | |
1244 if (ht > line_dance_len) | |
1245 { | |
1246 line_dance = (int *)xrealloc (line_dance, ht * sizeof (int)); | |
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; | |
1261 } | |
1262 else | |
1263 { | |
1264 n = -n; | |
1265 if (n > flexlines - vpos) | |
1266 n = flexlines - vpos; | |
1267 fence = flexlines - n; | |
1268 for (i = vpos; i < fence; ++i) | |
1269 line_dance[i] = line_dance[i + n]; | |
1270 for (i = fence; i < flexlines; ++i) | |
1271 line_dance[i] = -1; | |
1272 } | |
1273 } | |
1274 | |
1275 /* Here's where we actually move the pixels around. | |
1276 Must be called with input blocked. */ | |
1277 static void | |
1278 do_line_dance () | |
1279 { | |
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) |
1306 | 1300 if (line_dance[i] != -1 && (distance = line_dance[i]-i) > 0) |
1307 BLOCK_INPUT; | 1301 { |
1308 if (n >= 0) | 1302 for (j = i; (j < ht && line_dance[j] != -1 |
1309 stufflines (n); | 1303 && line_dance[j]-j == distance); ++j); |
1310 else | 1304 /* Copy [i,j) upward from [i+distance,j+distance) */ |
1311 scraplines (-n); | 1305 XCopyArea (x_current_display, FRAME_X_WINDOW (f), |
1312 XFlushQueue (); | 1306 FRAME_X_WINDOW (f), f->display.x->normal_gc, |
1313 UNBLOCK_INPUT; | 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 } | |
1313 | |
1314 for (i = ht; --i >=0; ) | |
1315 if (line_dance[i] != -1 && (distance = line_dance[i]-i) < 0) | |
1316 { | |
1317 for (j = i; (--j >= 0 && line_dance[j] != -1 | |
1318 && line_dance[j]-j == distance); --j); | |
1319 /* Copy (j,i] downward from (j+distance, i+distance] */ | |
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. */ |
1317 static void clear_cursor (); | 1344 static void clear_cursor (); |
1318 | 1345 |
1336 return; | 1363 return; |
1337 | 1364 |
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); |
1345 left = PIXEL_TO_CHAR_COL (f, left); | 1372 left = PIXEL_TO_CHAR_COL (f, left); |
1346 bottom += (f->display.x->line_height - 1); | 1373 bottom += (f->display.x->line_height - 1); |
1442 struct frame *old_focus = x_focus_frame; | 1469 struct frame *old_focus = x_focus_frame; |
1443 int events_enqueued = 0; | 1470 int events_enqueued = 0; |
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 |
1451 if (old_focus && old_focus->auto_lower) | 1478 if (old_focus && old_focus->auto_lower) |
1452 x_lower_frame (old_focus); | 1479 x_lower_frame (old_focus); |
1508 With each keystroke, X returns eight bits indicating which modifier | 1535 With each keystroke, X returns eight bits indicating which modifier |
1509 keys were held down when the key was pressed. The interpretation | 1536 keys were held down when the key was pressed. The interpretation |
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 |
1521 only be affected by the lock modifier bit if XK_Shift_Lock is in | 1548 only be affected by the lock modifier bit if XK_Shift_Lock is in |
1522 use; XK_Caps_Lock should only affect alphabetic keys. With this | 1549 use; XK_Caps_Lock should only affect alphabetic keys. With this |
1539 x_meta_mod_mask = 0; | 1566 x_meta_mod_mask = 0; |
1540 x_shift_lock_mask = 0; | 1567 x_shift_lock_mask = 0; |
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 |
1548 min_code = x_current_display->min_keycode; | 1575 min_code = x_current_display->min_keycode; |
1549 max_code = x_current_display->max_keycode; | 1576 max_code = x_current_display->max_keycode; |
1552 syms = XGetKeyboardMapping (x_current_display, | 1579 syms = XGetKeyboardMapping (x_current_display, |
1553 min_code, max_code - min_code + 1, | 1580 min_code, max_code - min_code + 1, |
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. */ |
1561 | 1588 |
1562 for (row = 3; row < 8; row++) | 1589 for (row = 3; row < 8; row++) |
1621 make them just meta, not alt. */ | 1648 make them just meta, not alt. */ |
1622 if (x_alt_mod_mask & x_meta_mod_mask) | 1649 if (x_alt_mod_mask & x_meta_mod_mask) |
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 } |
1630 | 1657 |
1631 /* Convert between the modifier bits X uses and the modifier bits | 1658 /* Convert between the modifier bits X uses and the modifier bits |
1730 result->kind = mouse_click; | 1757 result->kind = mouse_click; |
1731 result->code = event->button - Button1; | 1758 result->code = event->button - Button1; |
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 { |
1739 int row, column; | 1766 int row, column; |
1740 | 1767 |
1762 result->kind = mouse_click; | 1789 result->kind = mouse_click; |
1763 XSETINT (result->code, event->button - Button1); | 1790 XSETINT (result->code, event->button - Button1); |
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); |
1771 XSETINT (result->y, -1); | 1798 XSETINT (result->y, -1); |
1772 XSETFRAME (result->frame_or_window, f); | 1799 XSETFRAME (result->frame_or_window, f); |
1834 /* It's on the same glyph. Call XQueryPointer so we'll get an | 1861 /* It's on the same glyph. Call XQueryPointer so we'll get an |
1835 event the next time the mouse moves and we can see if it's | 1862 event the next time the mouse moves and we can see if it's |
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, |
1843 (unsigned int *) &dummy); | 1870 (unsigned int *) &dummy); |
1844 } | 1871 } |
2218 /* Trash which we can't trust if the pointer is on | 2245 /* Trash which we can't trust if the pointer is on |
2219 a different screen. */ | 2246 a different screen. */ |
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, |
2227 | 2254 |
2228 /* Modifier keys and pointer buttons, about which | 2255 /* Modifier keys and pointer buttons, about which |
2290 never use them in that case.) */ | 2317 never use them in that case.) */ |
2291 | 2318 |
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 { |
2299 struct scroll_bar *bar = x_window_to_scroll_bar (win); | 2326 struct scroll_bar *bar = x_window_to_scroll_bar (win); |
2300 | 2327 |
2402 sb_widget = XtCreateManagedWidget ("box", | 2429 sb_widget = XtCreateManagedWidget ("box", |
2403 boxWidgetClass, | 2430 boxWidgetClass, |
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. */ |
2413 left, top, width, height, | 2440 left, top, width, height, |
2414 | 2441 |
2444 | 2471 |
2445 /* Draw BAR's handle in the proper position. | 2472 /* Draw BAR's handle in the proper position. |
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 |
2453 handle, we want to let them drag it down all the way, so that the | 2480 handle, we want to let them drag it down all the way, so that the |
2454 bar's top is as far down as it goes; otherwise, there's no way to | 2481 bar's top is as far down as it goes; otherwise, there's no way to |
2562 | 2589 |
2563 if (left != XINT (bar->left)) mask |= CWX; | 2590 if (left != XINT (bar->left)) mask |= CWX; |
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); |
2571 } | 2598 } |
2572 | 2599 |
2665 from the fiery pit when we actually redisplay its window. */ | 2692 from the fiery pit when we actually redisplay its window. */ |
2666 | 2693 |
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. */ |
2670 static void | 2697 static void |
2671 XTcondemn_scroll_bars (frame) | 2698 XTcondemn_scroll_bars (frame) |
2672 FRAME_PTR frame; | 2699 FRAME_PTR frame; |
2673 { | 2700 { |
2674 /* The condemned list should be empty at this point; if it's not, | 2701 /* The condemned list should be empty at this point; if it's not, |
2675 then the rest of Emacs isn't using the condemn/redeem/judge | 2702 then the rest of Emacs isn't using the condemn/redeem/judge |
2845 bar->dragging = Qnil; | 2872 bar->dragging = Qnil; |
2846 } | 2873 } |
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; |
2854 else | 2881 else |
2855 XSETINT (emacs_event->x, y); | 2882 XSETINT (emacs_event->x, y); |
2882 int new_start = event->xmotion.y - XINT (bar->dragging); | 2909 int new_start = event->xmotion.y - XINT (bar->dragging); |
2883 | 2910 |
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 } |
2891 | 2918 |
2892 /* Call XQueryPointer so we'll get an event the next time the mouse | 2919 /* Call XQueryPointer so we'll get an event the next time the mouse |
2893 moves and we can see *still* on the same position. */ | 2920 moves and we can see *still* on the same position. */ |
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, |
2901 (unsigned int *) &dummy); | 2928 (unsigned int *) &dummy); |
2902 } | 2929 } |
3023 } | 3050 } |
3024 else | 3051 else |
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 } |
3032 | 3059 |
3033 UNBLOCK_INPUT; | 3060 UNBLOCK_INPUT; |
3053 XEvent *event; | 3080 XEvent *event; |
3054 { | 3081 { |
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; |
3062 queue = queue_tmp; | 3089 queue = queue_tmp; |
3063 } | 3090 } |
3067 so that they get processed afresh. */ | 3094 so that they get processed afresh. */ |
3068 | 3095 |
3069 static void | 3096 static void |
3070 x_unqueue_events () | 3097 x_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); |
3076 queue = queue_tmp->next; | 3103 queue = queue_tmp->next; |
3077 free ((char *)queue_tmp); | 3104 free ((char *)queue_tmp); |
3101 but we have to put it out here, since static variables within functions | 3128 but we have to put it out here, since static variables within functions |
3102 sometimes don't work. */ | 3129 sometimes don't work. */ |
3103 static Time enter_timestamp; | 3130 static 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 |
3110 This must be defined outside of XTread_socket, for the same reasons | 3137 This must be defined outside of XTread_socket, for the same reasons |
3111 given for enter_timestamp, above. */ | 3138 given for enter_timestamp, above. */ |
3269 } | 3296 } |
3270 else if (event.xclient.message_type == Xatom_wm_window_moved) | 3297 else if (event.xclient.message_type == Xatom_wm_window_moved) |
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 |
3278 if (f) | 3305 if (f) |
3279 { | 3306 { |
3386 } | 3413 } |
3387 else | 3414 else |
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 |
3395 else | 3422 else |
3396 goto OTHER; | 3423 goto OTHER; |
3628 #endif /* USE_X_TOOLKIT */ | 3655 #endif /* USE_X_TOOLKIT */ |
3629 break; | 3656 break; |
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); |
3637 #ifdef USE_X_TOOLKIT | 3664 #ifdef USE_X_TOOLKIT |
3638 goto OTHER; | 3665 goto OTHER; |
3654 if (! x_focus_event_frame) | 3681 if (! x_focus_event_frame) |
3655 x_new_focus_frame (0); | 3682 x_new_focus_frame (0); |
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; |
3663 if (f == x_focus_frame) | 3690 if (f == x_focus_frame) |
3664 x_new_focus_frame (0); | 3691 x_new_focus_frame (0); |
3788 the window, in the root coordinate system. Don't | 3815 the window, in the root coordinate system. Don't |
3789 refer to the parent window here; we may be processing | 3816 refer to the parent window here; we may be processing |
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, |
3797 | 3824 |
3798 /* From-position, to-position. */ | 3825 /* From-position, to-position. */ |
3923 } | 3950 } |
3924 } | 3951 } |
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 |
3945 in 1988 has been fixed in Xlib or the X server. */ | 3972 in 1988 has been fixed in Xlib or the X server. */ |
3946 #ifdef HAVE_SELECT | 3973 #ifdef HAVE_SELECT |
4266 if (icon_name) | 4293 if (icon_name) |
4267 f->display.x->icon_label = icon_name; | 4294 f->display.x->icon_label = 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 |
4280 return 0; | 4307 return 0; |
4281 } | 4308 } |
4304 Display *display; | 4331 Display *display; |
4305 XErrorEvent *error; | 4332 XErrorEvent *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)); |
4313 fprintf (stderr, "X protocol error: %s on protocol request %d\n", | 4340 fprintf (stderr, "X protocol error: %s on protocol request %d\n", |
4314 buf, error->request_code); | 4341 buf, error->request_code); |
4504 fontname = x_font_table[i].full_name; | 4531 fontname = x_font_table[i].full_name; |
4505 goto found_font; | 4532 goto found_font; |
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; |
4513 /* Otherwise, load the font and add it to the table. */ | 4540 /* Otherwise, load the font and add it to the table. */ |
4514 else | 4541 else |
4516 int i; | 4543 int i; |
4517 char *full_name; | 4544 char *full_name; |
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) |
4525 break; | 4552 break; |
4526 #else | 4553 #else |
4655 the inner window, with respect to the outer window. */ | 4682 the inner window, with respect to the outer window. */ |
4656 if (f->display.x->parent_desc != ROOT_WINDOW) | 4683 if (f->display.x->parent_desc != ROOT_WINDOW) |
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, |
4664 | 4691 |
4665 /* From-position, to-position. */ | 4692 /* From-position, to-position. */ |
4671 } | 4698 } |
4672 | 4699 |
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); |
4680 | 4707 |
4681 if (flags & YNegative) | 4708 if (flags & YNegative) |
5139 | 5166 |
5140 /* X11R4: send a ClientMessage to the window manager using the | 5167 /* X11R4: send a ClientMessage to the window manager using the |
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; |
5148 message.xclient.format = 32; | 5175 message.xclient.format = 32; |
5149 message.xclient.data.l[0] = IconicState; | 5176 message.xclient.data.l[0] = IconicState; |
5157 UNBLOCK_INPUT_RESIGNAL; | 5184 UNBLOCK_INPUT_RESIGNAL; |
5158 error ("Can't notify window manager of iconification"); | 5185 error ("Can't notify window manager of iconification"); |
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 |
5166 if (!FRAME_VISIBLE_P (f)) | 5193 if (!FRAME_VISIBLE_P (f)) |
5167 { | 5194 { |
5281 /* The window manager uses the base width hints to calculate the | 5308 /* The window manager uses the base width hints to calculate the |
5282 current number of rows and columns in the frame while | 5309 current number of rows and columns in the frame while |
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. */ |
5290 | 5317 |
5291 #ifdef HAVE_X11R4 | 5318 #ifdef HAVE_X11R4 |
5312 value = XGetWMNormalHints (x_current_display, window, &hints, | 5339 value = XGetWMNormalHints (x_current_display, window, &hints, |
5313 &supplied_return); | 5340 &supplied_return); |
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) |
5321 size_hints.flags |= PSize; | 5348 size_hints.flags |= PSize; |
5322 if (hints.flags & PPosition) | 5349 if (hints.flags & PPosition) |
5438 #ifndef F_SETOWN_BUG | 5465 #ifndef F_SETOWN_BUG |
5439 #ifdef F_SETOWN | 5466 #ifdef F_SETOWN |
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; |
5447 | 5474 |
5448 #ifdef USE_X_TOOLKIT | 5475 #ifdef USE_X_TOOLKIT |
5549 frame_raise_lower_hook = XTframe_raise_lower; | 5576 frame_raise_lower_hook = XTframe_raise_lower; |
5550 set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar; | 5577 set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar; |
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); |
5570 | 5597 |
5571 /* Disable Window Change signals; they are handled by X events. */ | 5598 /* Disable Window Change signals; they are handled by X events. */ |