comparison src/xterm.c @ 11536:c4d3218acd7e

(x_focus_frame, x_focus_event_frame, x_highlight_frame): Delete these vars; now part of struct x_display_info. (x_new_focus_frame): New arg DPYINFO. Callers changed. Use the struct members instead of the globals. Call x_frame_rehighlight instead of XTframe_rehighlight, so we can pass on the dpyinfo pointer. (x_mouse_leave): New arg DPYINFO. Callers changed. (XTframe_rehighlight): New arg FRAME. Callers changed. Now does all the work in x_frame_rehighlight. (x_frame_rehighlight): New function, code from XTframe_rehighlight. (XTread_socket): Use the struct members instead of the globals. (x_unfocus_frame, x_iconify_frame, x_destroy_window): Likewise. (x_display_box_cursor, x_make_frame_invisible): Likewise. (x_term_init): Initialize the struct members. (x_initialize): Delete initialization of deleted globals.
author Karl Heuer <kwzh@gnu.org>
date Mon, 24 Apr 1995 18:27:33 +0000
parents 9829d3c035f2
children cc965273a769
comparison
equal deleted inserted replaced
11535:ae282c46aec2 11536:c4d3218acd7e
116 XT functions. It is zero while not inside an update. 116 XT functions. It is zero while not inside an update.
117 In that case, the XT functions assume that `selected_frame' 117 In that case, the XT functions assume that `selected_frame'
118 is the frame to apply to. */ 118 is the frame to apply to. */
119 extern struct frame *updating_frame; 119 extern struct frame *updating_frame;
120 120
121 /* The frame (if any) which has the X window that has keyboard focus.
122 Zero if none. This is examined by Ffocus_frame in frame.c. Note
123 that a mere EnterNotify event can set this; if you need to know the
124 last frame specified in a FocusIn or FocusOut event, use
125 x_focus_event_frame. */
126 struct frame *x_focus_frame;
127
128 /* This is a frame waiting to be autoraised, within XTread_socket. */ 121 /* This is a frame waiting to be autoraised, within XTread_socket. */
129 struct frame *pending_autoraise_frame; 122 struct frame *pending_autoraise_frame;
130
131 /* The last frame mentioned in a FocusIn or FocusOut event. This is
132 separate from x_focus_frame, because whether or not LeaveNotify
133 events cause us to lose focus depends on whether or not we have
134 received a FocusIn event for it. */
135 struct frame *x_focus_event_frame;
136
137 /* The frame which currently has the visual highlight, and should get
138 keyboard input (other sorts of input have the frame encoded in the
139 event). It points to the X focus frame's selected window's
140 frame. It differs from x_focus_frame when we're using a global
141 minibuffer. */
142 static struct frame *x_highlight_frame;
143 123
144 #ifdef USE_X_TOOLKIT 124 #ifdef USE_X_TOOLKIT
145 /* The application context for Xt use. */ 125 /* The application context for Xt use. */
146 XtAppContext Xt_app_con; 126 XtAppContext Xt_app_con;
147 #endif 127 #endif
1418 UNBLOCK_INPUT; 1398 UNBLOCK_INPUT;
1419 x_display_cursor (f, 1); 1399 x_display_cursor (f, 1);
1420 } 1400 }
1421 1401
1422 static void XTframe_rehighlight (); 1402 static void XTframe_rehighlight ();
1403 static void x_frame_rehighlight ();
1423 1404
1424 /* The focus has changed. Update the frames as necessary to reflect 1405 /* The focus has changed. Update the frames as necessary to reflect
1425 the new situation. Note that we can't change the selected frame 1406 the new situation. Note that we can't change the selected frame
1426 here, because the Lisp code we are interrupting might become confused. 1407 here, because the Lisp code we are interrupting might become confused.
1427 Each event gets marked with the frame in which it occurred, so the 1408 Each event gets marked with the frame in which it occurred, so the
1428 Lisp code can tell when the switch took place by examining the events. */ 1409 Lisp code can tell when the switch took place by examining the events. */
1429 1410
1430 static void 1411 static void
1431 x_new_focus_frame (frame) 1412 x_new_focus_frame (dpyinfo, frame)
1413 struct x_display_info *dpyinfo;
1432 struct frame *frame; 1414 struct frame *frame;
1433 { 1415 {
1434 struct frame *old_focus = x_focus_frame; 1416 struct frame *old_focus = dpyinfo->x_focus_frame;
1435 int events_enqueued = 0; 1417 int events_enqueued = 0;
1436 1418
1437 if (frame != x_focus_frame) 1419 if (frame != dpyinfo->x_focus_frame)
1438 { 1420 {
1439 /* Set this before calling other routines, so that they see 1421 /* Set this before calling other routines, so that they see
1440 the correct value of x_focus_frame. */ 1422 the correct value of x_focus_frame. */
1441 x_focus_frame = frame; 1423 dpyinfo->x_focus_frame = frame;
1442 1424
1443 if (old_focus && old_focus->auto_lower) 1425 if (old_focus && old_focus->auto_lower)
1444 x_lower_frame (old_focus); 1426 x_lower_frame (old_focus);
1445 1427
1446 #if 0 1428 #if 0
1449 selected_frame); 1431 selected_frame);
1450 Fselect_window (selected_frame->selected_window); 1432 Fselect_window (selected_frame->selected_window);
1451 choose_minibuf_frame (); 1433 choose_minibuf_frame ();
1452 #endif /* ! 0 */ 1434 #endif /* ! 0 */
1453 1435
1454 if (x_focus_frame && x_focus_frame->auto_raise) 1436 if (dpyinfo->x_focus_frame && dpyinfo->x_focus_frame->auto_raise)
1455 pending_autoraise_frame = x_focus_frame; 1437 pending_autoraise_frame = dpyinfo->x_focus_frame;
1456 else 1438 else
1457 pending_autoraise_frame = 0; 1439 pending_autoraise_frame = 0;
1458 } 1440 }
1459 1441
1460 XTframe_rehighlight (); 1442 x_frame_rehighlight (dpyinfo);
1461 } 1443 }
1462 1444
1463 /* Handle an event saying the mouse has moved out of an Emacs frame. */ 1445 /* Handle an event saying the mouse has moved out of an Emacs frame. */
1464 1446
1465 void 1447 void
1466 x_mouse_leave () 1448 x_mouse_leave (dpyinfo)
1467 { 1449 struct x_display_info *dpyinfo;
1468 if (! x_focus_event_frame) 1450 {
1469 x_new_focus_frame (NULL); 1451 x_new_focus_frame (dpyinfo, dpyinfo->x_focus_event_frame);
1470 else
1471 x_new_focus_frame (x_focus_event_frame); /* Was f, but that seems wrong. */
1472 } 1452 }
1473 1453
1474 /* The focus has changed, or we have redirected a frame's focus to 1454 /* The focus has changed, or we have redirected a frame's focus to
1475 another frame (this happens when a frame uses a surrogate 1455 another frame (this happens when a frame uses a surrogate
1476 minibuffer frame). Shift the highlight as appropriate. */ 1456 minibuffer frame). Shift the highlight as appropriate.
1457
1458 The FRAME argument doesn't necessarily have anything to do with which
1459 frame is being highlighted or unhighlighted; we only use it to find
1460 the appropriate X display info. */
1477 static void 1461 static void
1478 XTframe_rehighlight () 1462 XTframe_rehighlight (frame)
1479 { 1463 struct frame *frame;
1480 struct frame *old_highlight = x_highlight_frame; 1464 {
1481 1465 x_frame_rehighlight (FRAME_X_DISPLAY_INFO (frame));
1482 if (x_focus_frame) 1466 }
1483 { 1467
1484 x_highlight_frame 1468 static void
1485 = ((GC_FRAMEP (FRAME_FOCUS_FRAME (x_focus_frame))) 1469 x_frame_rehighlight (dpyinfo)
1486 ? XFRAME (FRAME_FOCUS_FRAME (x_focus_frame)) 1470 struct x_display_info *dpyinfo;
1487 : x_focus_frame); 1471 {
1488 if (! FRAME_LIVE_P (x_highlight_frame)) 1472 struct frame *old_highlight = dpyinfo->x_highlight_frame;
1473
1474 if (dpyinfo->x_focus_frame)
1475 {
1476 dpyinfo->x_highlight_frame
1477 = ((GC_FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame)))
1478 ? XFRAME (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame))
1479 : dpyinfo->x_focus_frame);
1480 if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame))
1489 { 1481 {
1490 FRAME_FOCUS_FRAME (x_focus_frame) = Qnil; 1482 FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame) = Qnil;
1491 x_highlight_frame = x_focus_frame; 1483 dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame;
1492 } 1484 }
1493 } 1485 }
1494 else 1486 else
1495 x_highlight_frame = 0; 1487 dpyinfo->x_highlight_frame = 0;
1496 1488
1497 if (x_highlight_frame != old_highlight) 1489 if (dpyinfo->x_highlight_frame != old_highlight)
1498 { 1490 {
1499 if (old_highlight) 1491 if (old_highlight)
1500 frame_unhighlight (old_highlight); 1492 frame_unhighlight (old_highlight);
1501 if (x_highlight_frame) 1493 if (dpyinfo->x_highlight_frame)
1502 frame_highlight (x_highlight_frame); 1494 frame_highlight (dpyinfo->x_highlight_frame);
1503 } 1495 }
1504 } 1496 }
1505 1497
1506 /* Keyboard processing - modifier keys, vendor-specific keysyms, etc. */ 1498 /* Keyboard processing - modifier keys, vendor-specific keysyms, etc. */
1507 1499
3699 /* Avoid nasty pop/raise loops. */ 3691 /* Avoid nasty pop/raise loops. */
3700 if (f && (!(f->auto_raise) 3692 if (f && (!(f->auto_raise)
3701 || !(f->auto_lower) 3693 || !(f->auto_lower)
3702 || (event.xcrossing.time - enter_timestamp) > 500)) 3694 || (event.xcrossing.time - enter_timestamp) > 500))
3703 { 3695 {
3704 x_new_focus_frame (f); 3696 x_new_focus_frame (dpyinfo, f);
3705 enter_timestamp = event.xcrossing.time; 3697 enter_timestamp = event.xcrossing.time;
3706 } 3698 }
3707 } 3699 }
3708 else if (f == x_focus_frame) 3700 else if (f == dpyinfo->x_focus_frame)
3709 x_new_focus_frame (0); 3701 x_new_focus_frame (dpyinfo, 0);
3710 /* EnterNotify counts as mouse movement, 3702 /* EnterNotify counts as mouse movement,
3711 so update things that depend on mouse position. */ 3703 so update things that depend on mouse position. */
3712 if (f) 3704 if (f)
3713 note_mouse_movement (f, &event.xmotion); 3705 note_mouse_movement (f, &event.xmotion);
3714 #ifdef USE_X_TOOLKIT 3706 #ifdef USE_X_TOOLKIT
3717 break; 3709 break;
3718 3710
3719 case FocusIn: 3711 case FocusIn:
3720 f = x_any_window_to_frame (dpyinfo, event.xfocus.window); 3712 f = x_any_window_to_frame (dpyinfo, event.xfocus.window);
3721 if (event.xfocus.detail != NotifyPointer) 3713 if (event.xfocus.detail != NotifyPointer)
3722 x_focus_event_frame = f; 3714 dpyinfo->x_focus_event_frame = f;
3723 if (f) 3715 if (f)
3724 x_new_focus_frame (f); 3716 x_new_focus_frame (dpyinfo, f);
3725 #ifdef USE_X_TOOLKIT 3717 #ifdef USE_X_TOOLKIT
3726 goto OTHER; 3718 goto OTHER;
3727 #endif /* USE_X_TOOLKIT */ 3719 #endif /* USE_X_TOOLKIT */
3728 break; 3720 break;
3729 3721
3736 /* If we move outside the frame, 3728 /* If we move outside the frame,
3737 then we're certainly no longer on any text in the frame. */ 3729 then we're certainly no longer on any text in the frame. */
3738 clear_mouse_face (dpyinfo); 3730 clear_mouse_face (dpyinfo);
3739 3731
3740 if (event.xcrossing.focus) 3732 if (event.xcrossing.focus)
3741 x_mouse_leave (); 3733 x_mouse_leave (dpyinfo);
3742 else 3734 else
3743 { 3735 {
3744 if (f == x_focus_event_frame) 3736 if (f == dpyinfo->x_focus_event_frame)
3745 x_focus_event_frame = 0; 3737 dpyinfo->x_focus_event_frame = 0;
3746 if (f == x_focus_frame) 3738 if (f == dpyinfo->x_focus_frame)
3747 x_new_focus_frame (0); 3739 x_new_focus_frame (dpyinfo, 0);
3748 } 3740 }
3749 } 3741 }
3750 #ifdef USE_X_TOOLKIT 3742 #ifdef USE_X_TOOLKIT
3751 goto OTHER; 3743 goto OTHER;
3752 #endif /* USE_X_TOOLKIT */ 3744 #endif /* USE_X_TOOLKIT */
3753 break; 3745 break;
3754 3746
3755 case FocusOut: 3747 case FocusOut:
3756 f = x_any_window_to_frame (dpyinfo, event.xfocus.window); 3748 f = x_any_window_to_frame (dpyinfo, event.xfocus.window);
3757 if (event.xfocus.detail != NotifyPointer 3749 if (event.xfocus.detail != NotifyPointer
3758 && f == x_focus_event_frame) 3750 && f == dpyinfo->x_focus_event_frame)
3759 x_focus_event_frame = 0; 3751 dpyinfo->x_focus_event_frame = 0;
3760 if (f && f == x_focus_frame) 3752 if (f && f == dpyinfo->x_focus_frame)
3761 x_new_focus_frame (0); 3753 x_new_focus_frame (dpyinfo, 0);
3762 #ifdef USE_X_TOOLKIT 3754 #ifdef USE_X_TOOLKIT
3763 goto OTHER; 3755 goto OTHER;
3764 #endif /* USE_X_TOOLKIT */ 3756 #endif /* USE_X_TOOLKIT */
3765 break; 3757 break;
3766 3758
3905 else 3897 else
3906 f = x_window_to_frame (dpyinfo, event.xmotion.window); 3898 f = x_window_to_frame (dpyinfo, event.xmotion.window);
3907 3899
3908 if (f) 3900 if (f)
3909 { 3901 {
3910 if (!x_focus_frame || (f == x_focus_frame)) 3902 if (!dpyinfo->x_focus_frame || f == dpyinfo->x_focus_frame)
3911 construct_mouse_click (&emacs_event, &event, f); 3903 construct_mouse_click (&emacs_event, &event, f);
3912 } 3904 }
3913 else 3905 else
3914 { 3906 {
3915 struct scroll_bar *bar 3907 struct scroll_bar *bar
4171 if (f->phys_cursor_x >= 0 4163 if (f->phys_cursor_x >= 0
4172 && (!on 4164 && (!on
4173 || f->phys_cursor_x != curs_x 4165 || f->phys_cursor_x != curs_x
4174 || f->phys_cursor_y != curs_y 4166 || f->phys_cursor_y != curs_y
4175 || (f->display.x->current_cursor != hollow_box_cursor 4167 || (f->display.x->current_cursor != hollow_box_cursor
4176 && (f != x_highlight_frame)))) 4168 && (f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame))))
4177 { 4169 {
4178 int mouse_face_here = 0; 4170 int mouse_face_here = 0;
4179 struct frame_glyphs *active_glyphs = FRAME_CURRENT_GLYPHS (f); 4171 struct frame_glyphs *active_glyphs = FRAME_CURRENT_GLYPHS (f);
4180 4172
4181 /* If the cursor is in the mouse face area, redisplay that when 4173 /* If the cursor is in the mouse face area, redisplay that when
4216 or we want a box cursor and it's not so, 4208 or we want a box cursor and it's not so,
4217 write it in the right place. */ 4209 write it in the right place. */
4218 if (on 4210 if (on
4219 && (f->phys_cursor_x < 0 4211 && (f->phys_cursor_x < 0
4220 || (f->display.x->current_cursor != filled_box_cursor 4212 || (f->display.x->current_cursor != filled_box_cursor
4221 && f == x_highlight_frame))) 4213 && f == FRAME_X_DISPLAY_INFO (f)->x_highlight_frame)))
4222 { 4214 {
4223 f->phys_cursor_glyph 4215 f->phys_cursor_glyph
4224 = ((current_glyphs->enable[curs_y] 4216 = ((current_glyphs->enable[curs_y]
4225 && curs_x < current_glyphs->used[curs_y]) 4217 && curs_x < current_glyphs->used[curs_y])
4226 ? current_glyphs->glyphs[curs_y][curs_x] 4218 ? current_glyphs->glyphs[curs_y][curs_x]
4227 : SPACEGLYPH); 4219 : SPACEGLYPH);
4228 if (f != x_highlight_frame) 4220 if (f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame)
4229 { 4221 {
4230 x_draw_box (f); 4222 x_draw_box (f);
4231 f->display.x->current_cursor = hollow_box_cursor; 4223 f->display.x->current_cursor = hollow_box_cursor;
4232 } 4224 }
4233 else 4225 else
4960 x_unfocus_frame (f) 4952 x_unfocus_frame (f)
4961 struct frame *f; 4953 struct frame *f;
4962 { 4954 {
4963 #if 0 4955 #if 0
4964 /* Look at the remarks in x_focus_on_frame. */ 4956 /* Look at the remarks in x_focus_on_frame. */
4965 if (x_focus_frame == f) 4957 if (FRAME_X_DISPLAY_INFO (f)->x_focus_frame == f)
4966 XSetInputFocus (FRAME_X_DISPLAY (f), PointerRoot, 4958 XSetInputFocus (FRAME_X_DISPLAY (f), PointerRoot,
4967 RevertToPointerRoot, CurrentTime); 4959 RevertToPointerRoot, CurrentTime);
4968 #endif /* ! 0 */ 4960 #endif /* ! 0 */
4969 } 4961 }
4970 4962
5115 #else /* not USE_X_TOOLKIT */ 5107 #else /* not USE_X_TOOLKIT */
5116 window = FRAME_X_WINDOW (f); 5108 window = FRAME_X_WINDOW (f);
5117 #endif /* not USE_X_TOOLKIT */ 5109 #endif /* not USE_X_TOOLKIT */
5118 5110
5119 /* Don't keep the highlight on an invisible frame. */ 5111 /* Don't keep the highlight on an invisible frame. */
5120 if (x_highlight_frame == f) 5112 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f)
5121 x_highlight_frame = 0; 5113 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0;
5122 5114
5123 #if 0/* This might add unreliability; I don't trust it -- rms. */ 5115 #if 0/* This might add unreliability; I don't trust it -- rms. */
5124 if (! f->async_visible && ! f->async_iconified) 5116 if (! f->async_visible && ! f->async_iconified)
5125 return; 5117 return;
5126 #endif 5118 #endif
5191 int mask; 5183 int mask;
5192 int result; 5184 int result;
5193 Lisp_Object type; 5185 Lisp_Object type;
5194 5186
5195 /* Don't keep the highlight on an invisible frame. */ 5187 /* Don't keep the highlight on an invisible frame. */
5196 if (x_highlight_frame == f) 5188 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f)
5197 x_highlight_frame = 0; 5189 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0;
5198 5190
5199 if (f->async_iconified) 5191 if (f->async_iconified)
5200 return; 5192 return;
5201 5193
5202 BLOCK_INPUT; 5194 BLOCK_INPUT;
5299 free_frame_faces (f); 5291 free_frame_faces (f);
5300 XFlush (FRAME_X_DISPLAY (f)); 5292 XFlush (FRAME_X_DISPLAY (f));
5301 5293
5302 xfree (f->display.x); 5294 xfree (f->display.x);
5303 f->display.x = 0; 5295 f->display.x = 0;
5304 if (f == x_focus_frame) 5296 if (f == dpyinfo->x_focus_frame)
5305 x_focus_frame = 0; 5297 dpyinfo->x_focus_frame = 0;
5306 if (f == x_focus_event_frame) 5298 if (f == dpyinfo->x_focus_event_frame)
5307 x_focus_event_frame = 0; 5299 dpyinfo->x_focus_event_frame = 0;
5308 if (f == x_highlight_frame) 5300 if (f == dpyinfo->x_highlight_frame)
5309 x_highlight_frame = 0; 5301 dpyinfo->x_highlight_frame = 0;
5310 5302
5311 dpyinfo->reference_count--; 5303 dpyinfo->reference_count--;
5312 5304
5313 if (f == dpyinfo->mouse_face_mouse_frame) 5305 if (f == dpyinfo->mouse_face_mouse_frame)
5314 { 5306 {
5701 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 5693 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
5702 dpyinfo->mouse_face_face_id = 0; 5694 dpyinfo->mouse_face_face_id = 0;
5703 dpyinfo->mouse_face_window = Qnil; 5695 dpyinfo->mouse_face_window = Qnil;
5704 dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0; 5696 dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0;
5705 dpyinfo->mouse_face_defer = 0; 5697 dpyinfo->mouse_face_defer = 0;
5698 dpyinfo->x_focus_frame = 0;
5699 dpyinfo->x_focus_event_frame = 0;
5700 dpyinfo->x_highlight_frame = 0;
5706 5701
5707 dpyinfo->Xatom_wm_protocols 5702 dpyinfo->Xatom_wm_protocols
5708 = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False); 5703 = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False);
5709 dpyinfo->Xatom_wm_take_focus 5704 dpyinfo->Xatom_wm_take_focus
5710 = XInternAtom (dpyinfo->display, "WM_TAKE_FOCUS", False); 5705 = XInternAtom (dpyinfo->display, "WM_TAKE_FOCUS", False);
5862 off the bottom */ 5857 off the bottom */
5863 baud_rate = 19200; 5858 baud_rate = 19200;
5864 5859
5865 x_noop_count = 0; 5860 x_noop_count = 0;
5866 5861
5867 x_focus_frame = x_highlight_frame = 0;
5868
5869 /* Try to use interrupt input; if we can't, then start polling. */ 5862 /* Try to use interrupt input; if we can't, then start polling. */
5870 Fset_input_mode (Qt, Qnil, Qt, Qnil); 5863 Fset_input_mode (Qt, Qnil, Qt, Qnil);
5871 5864
5872 #ifdef USE_X_TOOLKIT 5865 #ifdef USE_X_TOOLKIT
5873 XtToolkitInitialize (); 5866 XtToolkitInitialize ();