aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1991-07-31 19:54:05 +0000
committerJim Blandy1991-07-31 19:54:05 +0000
commit6d4238f39ba8e37b12f5738df75b2d6201a10ad2 (patch)
treefd6b80b74a4e8b331243b8707d0967bf11e064e8 /src
parent6e8290aada30afd252649ef7cc412af6379c077c (diff)
downloademacs-6d4238f39ba8e37b12f5738df75b2d6201a10ad2.tar.gz
emacs-6d4238f39ba8e37b12f5738df75b2d6201a10ad2.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c180
1 files changed, 100 insertions, 80 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 17a0c46992e..3e5da255c12 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -93,9 +93,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
93#include "gnu.h" 93#include "gnu.h"
94#include "screen.h" 94#include "screen.h"
95#include "disptab.h" 95#include "disptab.h"
96#include "window.h"
97#include "buffer.h" 96#include "buffer.h"
98#include "xfns.h"
99 97
100#ifdef HAVE_X11 98#ifdef HAVE_X11
101#define XMapWindow XMapRaised /* Raise them when mapping. */ 99#define XMapWindow XMapRaised /* Raise them when mapping. */
@@ -178,10 +176,16 @@ Display *x_current_display;
178static struct screen *updating_screen; 176static struct screen *updating_screen;
179 177
180/* The screen (if any) which has the X window that has keyboard focus. 178/* The screen (if any) which has the X window that has keyboard focus.
181 Zero if none. This is examined by Ffocus_screen in screen.c */ 179 Zero if none. This is examined by Ffocus_screen in screen.c. */
182
183struct screen *x_focus_screen; 180struct screen *x_focus_screen;
184 181
182/* The screen which currently has the visual highlight, and should get
183 keyboard input (other sorts of input have the screen encoded in the
184 event). It points to the X focus screen's selected window's
185 screen. It differs from x_focus_screen when we're using a global
186 minibuffer. */
187static struct screen *x_highlight_screen;
188
185/* From .Xdefaults, the value of "emacs.WarpMouse". If non-zero, 189/* From .Xdefaults, the value of "emacs.WarpMouse". If non-zero,
186 mouse is moved to inside of screen when screen is de-iconified. */ 190 mouse is moved to inside of screen when screen is de-iconified. */
187 191
@@ -287,18 +291,11 @@ XTupdate_begin (s)
287 flexlines = s->height; 291 flexlines = s->height;
288 highlight = 0; 292 highlight = 0;
289 293
290#if 0
291 if (mouse_track_width != 0)
292 {
293 x_rectangle (s, s->display.x->reverse_gc,
294 mouse_track_top, mouse_track_left, mouse_track_width, 1);
295 mouse_track_width = 0;
296 }
297#endif
298 BLOCK_INPUT; 294 BLOCK_INPUT;
299#ifndef HAVE_X11 295#ifndef HAVE_X11
300 dumpqueue (); 296 dumpqueue ();
301#endif 297#endif
298 x_display_cursor (s, 0);
302 UNBLOCK_INPUT; 299 UNBLOCK_INPUT;
303} 300}
304 301
@@ -1215,61 +1212,71 @@ dumpborder (s, always)
1215} 1212}
1216#endif /* X10 */ 1213#endif /* X10 */
1217 1214
1215static void XTscreen_rehighlight ();
1216
1218/* The focus has changed. Update the screens as necessary to reflect 1217/* The focus has changed. Update the screens as necessary to reflect
1219 the new situation. Note that we can't change the selected screen 1218 the new situation. Note that we can't change the selected screen
1220 here, because the lisp code we are interrupting might become confused. 1219 here, because the lisp code we are interrupting might become confused.
1221 For that, we enqueue a screen_selected event. 1220 Each event gets marked with the screen in which it occured, so the
1221 lisp code can tell when the switch took place by examining the events. */
1222 1222
1223 Return the number of events stored at bufp. */ 1223static void
1224static int 1224x_new_focus_screen (screen)
1225x_new_focus_screen (screen, bufp, buf_free)
1226 struct screen *screen; 1225 struct screen *screen;
1227 struct input_event *bufp;
1228 int buf_free;
1229{ 1226{
1230 struct screen *old_focus = x_focus_screen; 1227 struct screen *old_focus = x_focus_screen;
1231 int events_enqueued = 0; 1228 int events_enqueued = 0;
1232 1229
1233 if (screen == x_focus_screen) 1230 if (screen != x_focus_screen)
1234 return 0;
1235
1236 /* Set this before calling screen_{un,}highlight, so that they see
1237 the correct value of x_focus_screen. */
1238 x_focus_screen = screen;
1239
1240 if (old_focus)
1241 { 1231 {
1242 if (old_focus->auto_lower) 1232 /* Set this before calling other routines, so that they see
1233 the correct value of x_focus_screen. */
1234 x_focus_screen = screen;
1235
1236 if (old_focus && old_focus->auto_lower)
1243 x_lower_screen (old_focus); 1237 x_lower_screen (old_focus);
1244 screen_unhighlight (old_focus);
1245 }
1246 1238
1247#if 0 1239#if 0
1248 selected_screen = screen; 1240 selected_screen = screen;
1249 XSET (XWINDOW (selected_screen->selected_window)->screen, 1241 XSET (XWINDOW (selected_screen->selected_window)->screen,
1250 Lisp_Screen, selected_screen); 1242 Lisp_Screen, selected_screen);
1251 Fselect_window (selected_screen->selected_window); 1243 Fselect_window (selected_screen->selected_window);
1252 choose_minibuf_screen (); 1244 choose_minibuf_screen ();
1253#endif 1245#endif
1254 1246
1255 if (x_focus_screen) 1247 if (x_focus_screen && x_focus_screen->auto_raise)
1256 {
1257 if (x_focus_screen->auto_raise)
1258 x_raise_screen (x_focus_screen); 1248 x_raise_screen (x_focus_screen);
1259 screen_highlight (x_focus_screen); 1249 }
1260 1250
1261 /* Enqueue an event. It's kind of important not to drop these 1251 XTscreen_rehighlight ();
1262 events, but the event queue's fixed size is a real pain 1252}
1263 anyway. */ 1253
1264 if (buf_free > 0) 1254
1265 { 1255/* The focus has changed, or we have make a screen's selected window
1266 bufp->kind = screen_selected; 1256 point to a window on a different screen (this happens with global
1267 bufp->screen = screen; 1257 minibuffer screens). Shift the highlight as appropriate. */
1268 events_enqueued++; 1258static void
1269 } 1259XTscreen_rehighlight ()
1260{
1261 struct screen *old_highlight = x_highlight_screen;
1262
1263 if (x_focus_screen)
1264 {
1265 x_highlight_screen = XSCREEN (SCREEN_FOCUS_SCREEN (x_focus_screen));
1266 if (x_highlight_screen->display.nothing == 0)
1267 XSET (SCREEN_FOCUS_SCREEN (x_focus_screen), Lisp_Screen,
1268 (x_highlight_screen = x_focus_screen));
1270 } 1269 }
1270 else
1271 x_highlight_screen = 0;
1271 1272
1272 return events_enqueued; 1273 if (x_highlight_screen != old_highlight)
1274 {
1275 if (old_highlight)
1276 screen_unhighlight (old_highlight);
1277 if (x_highlight_screen)
1278 screen_highlight (x_highlight_screen);
1279 }
1273} 1280}
1274 1281
1275enum window_type 1282enum window_type
@@ -1806,6 +1813,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1806 { 1813 {
1807 bufp->kind = non_ascii_keystroke; 1814 bufp->kind = non_ascii_keystroke;
1808 bufp->code = (unsigned) keysym - 0xff50; 1815 bufp->code = (unsigned) keysym - 0xff50;
1816 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
1809 bufp->modifiers = x_convert_modifiers (event.xkey.state); 1817 bufp->modifiers = x_convert_modifiers (event.xkey.state);
1810 bufp++; 1818 bufp++;
1811 count++; 1819 count++;
@@ -1820,6 +1828,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1820 if (event.xkey.state & Mod1Mask) 1828 if (event.xkey.state & Mod1Mask)
1821 *copy_buffer |= METABIT; 1829 *copy_buffer |= METABIT;
1822 bufp->kind = ascii_keystroke; 1830 bufp->kind = ascii_keystroke;
1831 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
1823 XSET (bufp->code, Lisp_Int, *copy_buffer); 1832 XSET (bufp->code, Lisp_Int, *copy_buffer);
1824 bufp++; 1833 bufp++;
1825 } 1834 }
@@ -1828,6 +1837,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1828 { 1837 {
1829 bufp->kind = ascii_keystroke; 1838 bufp->kind = ascii_keystroke;
1830 XSET (bufp->code, Lisp_Int, copy_buffer[i]); 1839 XSET (bufp->code, Lisp_Int, copy_buffer[i]);
1840 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
1831 bufp++; 1841 bufp++;
1832 } 1842 }
1833 1843
@@ -1875,6 +1885,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1875 { 1885 {
1876 bufp->kind = ascii_keystroke; 1886 bufp->kind = ascii_keystroke;
1877 XSET (bufp->code, Lisp_Int, where_mapping[i]); 1887 XSET (bufp->code, Lisp_Int, where_mapping[i]);
1888 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
1878 bufp++; 1889 bufp++;
1879 } 1890 }
1880 count += nbytes; 1891 count += nbytes;
@@ -1886,6 +1897,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1886 1897
1887#ifdef HAVE_X11 1898#ifdef HAVE_X11
1888 case EnterNotify: 1899 case EnterNotify:
1900 s = x_window_to_screen (event.xcrossing.window);
1901
1889 if (event.xcrossing.detail == NotifyInferior) /* Left Scrollbar */ 1902 if (event.xcrossing.detail == NotifyInferior) /* Left Scrollbar */
1890 ; 1903 ;
1891 else if (event.xcrossing.focus) /* Entered Window */ 1904 else if (event.xcrossing.focus) /* Entered Window */
@@ -1895,17 +1908,12 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1895 struct input_event emacs_event; 1908 struct input_event emacs_event;
1896 emacs_event.kind = no_event; 1909 emacs_event.kind = no_event;
1897 1910
1898 s = x_window_to_screen (event.xcrossing.window);
1899
1900 /* Avoid nasty pop/raise loops. */ 1911 /* Avoid nasty pop/raise loops. */
1901 if (s && (!(s->auto_raise) 1912 if (s && (!(s->auto_raise)
1902 || !(s->auto_lower) 1913 || !(s->auto_lower)
1903 || (event.xcrossing.time - enter_timestamp) > 500)) 1914 || (event.xcrossing.time - enter_timestamp) > 500))
1904 { 1915 {
1905 int n = x_new_focus_screen (s, bufp, numchars); 1916 x_new_focus_screen (s);
1906 bufp += n;
1907 count += n;
1908 numchars -= n;
1909 enter_timestamp = event.xcrossing.time; 1917 enter_timestamp = event.xcrossing.time;
1910 } 1918 }
1911#if 0 1919#if 0
@@ -1929,6 +1937,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1929 } 1937 }
1930#endif 1938#endif
1931 } 1939 }
1940 else if (s == x_focus_screen)
1941 x_new_focus_screen (0);
1932#if 0 1942#if 0
1933 else if (s = x_window_to_screen (event.xcrossing.window)) 1943 else if (s = x_window_to_screen (event.xcrossing.window))
1934 x_mouse_screen = s; 1944 x_mouse_screen = s;
@@ -1939,12 +1949,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1939 case FocusIn: 1949 case FocusIn:
1940 s = x_window_to_screen (event.xfocus.window); 1950 s = x_window_to_screen (event.xfocus.window);
1941 if (s) 1951 if (s)
1942 { 1952 x_new_focus_screen (s);
1943 int n = x_new_focus_screen (s, bufp, numchars);
1944 bufp += n;
1945 count += n;
1946 numchars -= n;
1947 }
1948 break; 1953 break;
1949 1954
1950 case LeaveNotify: 1955 case LeaveNotify:
@@ -1952,27 +1957,18 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1952 && event.xcrossing.subwindow == None 1957 && event.xcrossing.subwindow == None
1953 && event.xcrossing.mode == NotifyNormal) 1958 && event.xcrossing.mode == NotifyNormal)
1954 { 1959 {
1960 s = x_window_to_screen (event.xcrossing.window);
1955 if (event.xcrossing.focus) 1961 if (event.xcrossing.focus)
1956 { 1962 x_new_focus_screen (s);
1957 int n; 1963 else if (s == x_focus_screen)
1958 s = x_window_to_screen (event.xcrossing.window); 1964 x_new_focus_screen (0);
1959 n = x_new_focus_screen (s, bufp, numchars);
1960 bufp += n;
1961 count += n;
1962 numchars -= n;
1963 }
1964 } 1965 }
1965 break; 1966 break;
1966 1967
1967 case FocusOut: 1968 case FocusOut:
1968 s = x_window_to_screen (event.xfocus.window); 1969 s = x_window_to_screen (event.xfocus.window);
1969 if (s && s == x_focus_screen) 1970 if (s && s == x_focus_screen)
1970 { 1971 x_new_focus_screen (0);
1971 int n = x_new_focus_screen (0, bufp, numchars);
1972 bufp += n;
1973 count += n;
1974 numchars -= n;
1975 }
1976 break; 1972 break;
1977 1973
1978#else /* not HAVE_X11 */ 1974#else /* not HAVE_X11 */
@@ -1991,7 +1987,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1991 x_mouse_screen = s; 1987 x_mouse_screen = s;
1992 1988
1993 if (waiting_for_input && x_focus_screen == 0) 1989 if (waiting_for_input && x_focus_screen == 0)
1994 x_new_selected_screen (s); 1990 x_new_focus_screen (s);
1995 } 1991 }
1996 break; 1992 break;
1997 1993
@@ -2140,10 +2136,12 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2140 { 2136 {
2141 bufp->kind = ascii_keystroke; 2137 bufp->kind = ascii_keystroke;
2142 bufp->code = (char) 'X' & 037; /* C-x */ 2138 bufp->code = (char) 'X' & 037; /* C-x */
2139 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
2143 bufp++; 2140 bufp++;
2144 2141
2145 bufp->kind = ascii_keystroke; 2142 bufp->kind = ascii_keystroke;
2146 bufp->code = (char) 0; /* C-@ */ 2143 bufp->code = (char) 0; /* C-@ */
2144 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
2147 bufp++; 2145 bufp++;
2148 2146
2149 count += 2; 2147 count += 2;
@@ -2397,7 +2395,7 @@ x_display_bar_cursor (s, on)
2397 s->phys_cursor_x = phys_x = -1; 2395 s->phys_cursor_x = phys_x = -1;
2398 } 2396 }
2399 2397
2400 if (on && s == x_focus_screen) 2398 if (on && s == x_highlight_screen)
2401 { 2399 {
2402 x1 = s->cursor_x * FONT_WIDTH (s->display.x->font) 2400 x1 = s->cursor_x * FONT_WIDTH (s->display.x->font)
2403 + s->display.x->internal_border_width; 2401 + s->display.x->internal_border_width;
@@ -2493,7 +2491,7 @@ x_display_box_cursor (s, on)
2493 || s->phys_cursor_x != s->cursor_x 2491 || s->phys_cursor_x != s->cursor_x
2494 || s->phys_cursor_y != s->cursor_y 2492 || s->phys_cursor_y != s->cursor_y
2495 || (s->display.x->text_cursor_kind != hollow_box_cursor 2493 || (s->display.x->text_cursor_kind != hollow_box_cursor
2496 && (s != x_focus_screen)))) 2494 && (s != x_highlight_screen))))
2497 { 2495 {
2498 /* Erase the cursor by redrawing the character underneath it. */ 2496 /* Erase the cursor by redrawing the character underneath it. */
2499 x_draw_single_glyph (s, s->phys_cursor_y, s->phys_cursor_x, 2497 x_draw_single_glyph (s, s->phys_cursor_y, s->phys_cursor_x,
@@ -2509,9 +2507,9 @@ x_display_box_cursor (s, on)
2509 if (on 2507 if (on
2510 && (s->phys_cursor_x < 0 2508 && (s->phys_cursor_x < 0
2511 || (s->display.x->text_cursor_kind != filled_box_cursor 2509 || (s->display.x->text_cursor_kind != filled_box_cursor
2512 && s == x_focus_screen))) 2510 && s == x_highlight_screen)))
2513 { 2511 {
2514 if (s != x_focus_screen) 2512 if (s != x_highlight_screen)
2515 { 2513 {
2516 x_draw_box (s); 2514 x_draw_box (s);
2517 s->display.x->text_cursor_kind = hollow_box_cursor; 2515 s->display.x->text_cursor_kind = hollow_box_cursor;
@@ -3170,16 +3168,24 @@ x_focus_on_screen (s)
3170 struct screen *s; 3168 struct screen *s;
3171{ 3169{
3172 x_raise_screen (s); 3170 x_raise_screen (s);
3171#if 0
3172 /* I don't think that the ICCCM allows programs to do things like this
3173 without the interaction of the window manager. Whatever you end up
3174 doing with this code, do it to x_unfocus_screen too. */
3173 XSetInputFocus (x_current_display, s->display.x->window_desc, 3175 XSetInputFocus (x_current_display, s->display.x->window_desc,
3174 RevertToPointerRoot, CurrentTime); 3176 RevertToPointerRoot, CurrentTime);
3177#endif
3175} 3178}
3176 3179
3177x_unfocus_screen (s) 3180x_unfocus_screen (s)
3178 struct screen *s; 3181 struct screen *s;
3179{ 3182{
3183#if 0
3184 /* Look at the remarks in x_focus_on_screen. */
3180 if (x_focus_screen == s) 3185 if (x_focus_screen == s)
3181 XSetInputFocus (x_current_display, PointerRoot, 3186 XSetInputFocus (x_current_display, PointerRoot,
3182 RevertToPointerRoot, CurrentTime); 3187 RevertToPointerRoot, CurrentTime);
3188#endif
3183} 3189}
3184 3190
3185#endif 3191#endif
@@ -3390,6 +3396,8 @@ x_destroy_window (s, displ)
3390 free (displ.x); 3396 free (displ.x);
3391 if (s == x_focus_screen) 3397 if (s == x_focus_screen)
3392 x_focus_screen = 0; 3398 x_focus_screen = 0;
3399 if (s == x_highlight_screen)
3400 x_highlight_screen = 0;
3393} 3401}
3394 3402
3395#ifndef HAVE_X11 3403#ifndef HAVE_X11
@@ -3580,6 +3588,8 @@ x_term_init (display_name)
3580#ifdef F_SETOWN 3588#ifdef F_SETOWN
3581 extern int old_fcntl_owner; 3589 extern int old_fcntl_owner;
3582#endif 3590#endif
3591
3592 x_focus_screen = x_highlight_screen = 0;
3583 3593
3584 x_current_display = XOpenDisplay (display_name); 3594 x_current_display = XOpenDisplay (display_name);
3585 if (x_current_display == 0) 3595 if (x_current_display == 0)
@@ -3622,8 +3632,17 @@ x_term_init (display_name)
3622 } 3632 }
3623 3633
3624 dup2 (ConnectionNumber (x_current_display), 0); 3634 dup2 (ConnectionNumber (x_current_display), 0);
3635
3636#ifndef SYSV_STREAMS
3637 /* Streams somehow keeps track of which descriptor number
3638 is being used to talk to X. So it is not safe to substitute
3639 descriptor 0. But it is safe to make descriptor 0 a copy of it. */
3625 close (ConnectionNumber (x_current_display)); 3640 close (ConnectionNumber (x_current_display));
3626 ConnectionNumber (x_current_display) = 0; 3641 ConnectionNumber (x_current_display) = 0; /* Looks a little strange?
3642 * check the def of the macro;
3643 * it is a genuine lvalue */
3644#endif /* not SYSV_STREAMS */
3645
3627#endif /* HAVE_X11 */ 3646#endif /* HAVE_X11 */
3628 3647
3629#ifdef F_SETOWN 3648#ifdef F_SETOWN
@@ -3662,6 +3681,7 @@ x_term_init (display_name)
3662 read_socket_hook = XTread_socket; 3681 read_socket_hook = XTread_socket;
3663 cursor_to_hook = XTcursor_to; 3682 cursor_to_hook = XTcursor_to;
3664 reassert_line_highlight_hook = XTreassert_line_highlight; 3683 reassert_line_highlight_hook = XTreassert_line_highlight;
3684 screen_rehighlight_hook = XTscreen_rehighlight;
3665 mouse_tracking_enable_hook = XTmouse_tracking_enable; 3685 mouse_tracking_enable_hook = XTmouse_tracking_enable;
3666 3686
3667 scroll_region_ok = 1; /* we'll scroll partial screens */ 3687 scroll_region_ok = 1; /* we'll scroll partial screens */