/* X Communication module for terminals which understand the X protocol.
- Copyright (C) 1989, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1989, 93, 94, 95, 1996 Free Software Foundation, Inc.
This file is part of GNU Emacs.
You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
/* Xt features made by Fred Pierresteguy. */
#include "keyboard.h"
#include "intervals.h"
+#ifdef USE_X_TOOLKIT
+#include <X11/Shell.h>
+#endif
+
#ifdef USE_X_TOOLKIT
extern void free_frame_menubar ();
-extern void _XEditResCheckMessages ();
extern FRAME_PTR x_menubar_window_to_frame ();
+#if (XtSpecificationRelease >= 5) && !defined(NO_EDITRES)
+#define HACK_EDITRES
+extern void _XEditResCheckMessages ();
+#endif /* not NO_EDITRES */
#endif /* USE_X_TOOLKIT */
#ifndef USE_X_TOOLKIT
#endif
#endif
-#ifdef HAVE_X11XTR6
+#ifdef HAVE_SETLOCALE
/* So we can do setlocale. */
#include <locale.h>
#endif
+#ifdef SOLARIS2
+/* memmove will be defined as a macro in Xfuncs.h unless
+ <string.h> is included beforehand. The declaration for memmove in
+ <string.h> will cause a syntax error when Xfuncs.h later includes it. */
+#include <string.h>
+#endif
+
+#ifndef min
#define min(a,b) ((a)<(b) ? (a) : (b))
+#endif
+#ifndef max
#define max(a,b) ((a)>(b) ? (a) : (b))
+#endif
\f
/* This is a chain of structures for all the X displays currently in use. */
struct x_display_info *x_display_list;
is the frame to apply to. */
extern struct frame *updating_frame;
+extern waiting_for_input;
+
/* This is a frame waiting to be autoraised, within XTread_socket. */
struct frame *pending_autoraise_frame;
/* Mouse movement.
+ Formerly, we used PointerMotionHintMask (in STANDARD_EVENT_MASK)
+ so that we would have to call XQueryPointer after each MotionNotify
+ event to ask for another such event. However, this made mouse tracking
+ slow, and there was a bug that made it eventually stop.
+
+ Simply asking for MotionNotify all the time seems to work better.
+
In order to avoid asking for motion events and then throwing most
of them away or busy-polling the server for mouse positions, we ask
the server for pointer motion hints. This means that we get only
get another MotionNotify event the next time the mouse moves. This
is at least as efficient as getting motion events when mouse
tracking is on, and I suspect only negligibly worse when tracking
- is off.
-
- The silly O'Reilly & Associates Nutshell guides barely document
- pointer motion hints at all (I think you have to infer how they
- work from an example), and the description of XQueryPointer doesn't
- mention that calling it causes you to get another motion hint from
- the server, which is very important. */
+ is off. */
/* Where the mouse was last time we reported a mouse event. */
static FRAME_PTR last_mouse_frame;
static XRectangle last_mouse_glyph;
+static Lisp_Object last_mouse_press_frame;
+
/* The scroll bar in which the last X motion event occurred.
If the last X motion event occurred in a scroll bar, we set this
extern Lisp_Object Vx_no_window_manager;
-/* Nonzero enables some debugging for the X interface code. */
-extern int _Xdebug;
-
extern Lisp_Object Qface, Qmouse_face;
extern int errno;
BLOCK_INPUT;
+ curs_x = FRAME_CURSOR_X (f);
+ curs_y = FRAME_CURSOR_Y (f);
+
if (f == FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame)
{
/* Don't do highlighting for mouse motion during the update. */
BLOCK_INPUT;
do_line_dance ();
- x_display_cursor (f, 1);
+ x_display_cursor (f, 1, curs_x, curs_y);
- if (f == FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame)
- FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0;
+ FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0;
#if 0
/* This fails in the case of having updated only the echo area
if we have switched buffers. In that case, FRAME_CURRENT_GLYPHS
XTframe_up_to_date (f)
FRAME_PTR f;
{
+ BLOCK_INPUT;
if (FRAME_X_DISPLAY_INFO (f)->mouse_face_deferred_gc
|| f == FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame)
{
FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_y);
FRAME_X_DISPLAY_INFO (f)->mouse_face_deferred_gc = 0;
}
+ UNBLOCK_INPUT;
}
\f
/* External interface to control of standout mode.
if (updating_frame == 0)
{
BLOCK_INPUT;
- x_display_cursor (selected_frame, 1);
+ x_display_cursor (selected_frame, 1, curs_x, curs_y);
XFlush (FRAME_X_DISPLAY (selected_frame));
UNBLOCK_INPUT;
}
f->phys_cursor_x = -1;
if (updating_frame == 0)
- {
- f->cursor_x += len;
- x_display_cursor (f, 1);
- f->cursor_x -= len;
- }
+ x_display_cursor (f, 1, FRAME_CURSOR_X (f) + len, FRAME_CURSOR_Y (f));
else
curs_x += len;
{
/* If char is out of range, try the font's default char instead. */
c = font->default_char;
- row = c >> (INTBITS - 8);
+ row = c >> (BITS_PER_INT - 8);
within = c & 0177;
}
if (!(within >= font->min_char_or_byte2
{
/* If char is out of range, try the font's default char instead. */
c = font->default_char;
- row = c >> (INTBITS - 8);
+ row = c >> (BITS_PER_INT - 8);
within = c & 0177;
}
if (!(within >= font->min_char_or_byte2
ht = f->height;
intborder = f->output_data.x->internal_border_width;
- x_display_cursor (updating_frame, 0);
+ x_update_cursor (updating_frame, 0);
for (i = 0; i < ht; ++i)
if (line_dance[i] != -1 && (distance = line_dance[i]-i) > 0)
/* Turn the cursor on if we turned it off. */
if (cursor_cleared)
- x_display_cursor (f, 1);
+ x_update_cursor (f, 1);
}
\f
static void
#ifdef HAVE_X11R4
XDisplayKeycodes (dpyinfo->display, &min_code, &max_code);
#else
- min_code = display->min_keycode;
- max_code = display->max_keycode;
+ min_code = dpyinfo->display->min_keycode;
+ max_code = dpyinfo->display->max_keycode;
#endif
syms = XGetKeyboardMapping (dpyinfo->display,
last_mouse_scroll_bar = Qnil;
note_mouse_highlight (frame, -1, -1);
-
- /* Ask for another mouse motion event. */
- {
- int dummy;
- Window dummy_window;
-
- XQueryPointer (event->display, FRAME_X_WINDOW (frame),
- &dummy_window, &dummy_window,
- &dummy, &dummy, &dummy, &dummy,
- (unsigned int *) &dummy);
- }
}
/* Has the mouse moved off the glyph it was on at the last sighting? */
last_mouse_scroll_bar = Qnil;
note_mouse_highlight (frame, event->x, event->y);
-
- /* Ask for another mouse motion event. */
- {
- int dummy;
- Window dummy_window;
-
- XQueryPointer (event->display, FRAME_X_WINDOW (frame),
- &dummy_window, &dummy_window,
- &dummy, &dummy, &dummy, &dummy,
- (unsigned int *) &dummy);
- }
- }
- else
- {
- /* It's on the same glyph. Call XQueryPointer so we'll get an
- event the next time the mouse moves and we can see if it's
- *still* on the same glyph. */
- int dummy;
- Window dummy_window;
-
- XQueryPointer (event->display, FRAME_X_WINDOW (frame),
- &dummy_window, &dummy_window,
- &dummy, &dummy, &dummy, &dummy,
- (unsigned int *) &dummy);
}
}
if (WINDOWP (window) && portion == 0 && row >= 0 && column >= 0
&& row < FRAME_HEIGHT (f) && column < FRAME_WIDTH (f)
&& EQ (w->window_end_valid, w->buffer)
- && w->last_modified == BUF_MODIFF (XBUFFER (w->buffer)))
+ && w->last_modified == BUF_MODIFF (XBUFFER (w->buffer))
+ && w->last_overlay_modified == BUF_OVERLAY_MODIFF (XBUFFER (w->buffer)))
{
int *ptr = FRAME_CURRENT_GLYPHS (f)->charstarts[row];
int i, pos;
before = Foverlay_start (overlay);
after = Foverlay_end (overlay);
/* Record this as the current active region. */
- fast_find_position (window, before,
+ fast_find_position (window, XFASTINT (before),
&FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row);
FRAME_X_DISPLAY_INFO (f)->mouse_face_past_end
- = !fast_find_position (window, after,
+ = !fast_find_position (window, XFASTINT (after),
&FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row);
FRAME_X_DISPLAY_INFO (f)->mouse_face_window = window;
= Fnext_single_property_change (position, Qmouse_face,
w->buffer, end);
/* Record this as the current active region. */
- fast_find_position (window, before,
+ fast_find_position (window, XFASTINT (before),
&FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row);
FRAME_X_DISPLAY_INFO (f)->mouse_face_past_end
- = !fast_find_position (window, after,
+ = !fast_find_position (window, XFASTINT (after),
&FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row);
FRAME_X_DISPLAY_INFO (f)->mouse_face_window = window;
if (maybe_next_line)
{
row++;
- i = 0;
+ lastcol = left;
}
*rowp = row + top;
FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
int i;
int cursor_off = 0;
- int old_curs_x = curs_x;
- int old_curs_y = curs_y;
-
- /* Set these variables temporarily
- so that if we have to turn the cursor off and on again
- we will put it back at the same place. */
- curs_x = f->phys_cursor_x;
- curs_y = f->phys_cursor_y;
for (i = FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row;
i <= FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row; i++)
/* If the cursor's in the text we are about to rewrite,
turn the cursor off. */
if (i == curs_y
- && curs_x >= FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col - 1
- && curs_x <= FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col)
+ && curs_x >= column - 1
+ && curs_x <= endcolumn)
{
- x_display_cursor (f, 0);
+ x_update_cursor (f, 0);
cursor_off = 1;
}
/* If we turned the cursor off, turn it back on. */
if (cursor_off)
- x_display_cursor (f, 1);
-
- curs_x = old_curs_x;
- curs_y = old_curs_y;
+ x_update_cursor (f, 1);
/* Change the mouse cursor according to the value of HL. */
if (hl > 0)
Don't store anything if we don't have a valid set of values to report.
This clears the mouse_moved flag, so we can wait for the next mouse
- movement. This also calls XQueryPointer, which will cause the
- server to give us another MotionNotify when the mouse moves
- again. */
+ movement. */
static void
XTmouse_position (fp, insist, bar_window, part, x, y, time)
/* Child of win. */
&child);
- if (child == None)
+ if (child == None || child == win)
break;
win = child;
XTcondemn_scroll_bars (frame)
FRAME_PTR frame;
{
- /* The condemned list should be empty at this point; if it's not,
- then the rest of Emacs isn't using the condemn/redeem/judge
- protocol correctly. */
- if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame)))
- abort ();
-
- /* Move them all to the "condemned" list. */
- FRAME_CONDEMNED_SCROLL_BARS (frame) = FRAME_SCROLL_BARS (frame);
- FRAME_SCROLL_BARS (frame) = Qnil;
+ /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */
+ while (! NILP (FRAME_SCROLL_BARS (frame)))
+ {
+ Lisp_Object bar;
+ bar = FRAME_SCROLL_BARS (frame);
+ FRAME_SCROLL_BARS (frame) = XSCROLL_BAR (bar)->next;
+ XSCROLL_BAR (bar)->next = FRAME_CONDEMNED_SCROLL_BARS (frame);
+ XSCROLL_BAR (bar)->prev = Qnil;
+ if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame)))
+ XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar;
+ FRAME_CONDEMNED_SCROLL_BARS (frame) = bar;
+ }
}
/* Unmark WINDOW's scroll bar for deletion in this judgement cycle.
x_scroll_bar_set_handle (bar, new_start, new_end, 0);
}
}
-
- /* Call XQueryPointer so we'll get an event the next time the mouse
- moves and we can see *still* on the same position. */
- {
- int dummy;
- Window dummy_window;
-
- XQueryPointer (event->xmotion.display, event->xmotion.window,
- &dummy_window, &dummy_window,
- &dummy, &dummy, &dummy, &dummy,
- (unsigned int *) &dummy);
- }
}
/* Return information to the user about the current position of the mouse
{
Lisp_Object bar;
- for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar);
- bar = XSCROLL_BAR (bar)->next)
- XClearArea (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
- 0, 0, 0, 0, True);
+ /* We can have scroll bars even if this is 0,
+ if we just turned off scroll bar mode.
+ But in that case we should not clear them. */
+ if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
+ for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar);
+ bar = XSCROLL_BAR (bar)->next)
+ XClearArea (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
+ 0, 0, 0, 0, True);
}
/* This processes Expose events from the menubar specific X event
This variable is used for cycling thru the displays. */
static struct x_display_info *next_noop_dpyinfo;
+#define SET_SAVED_MENU_EVENT(size) { \
+ if (f->output_data.x->saved_menu_event == 0) \
+ f->output_data.x->saved_menu_event = (XEvent*)xmalloc (sizeof (XEvent)); \
+ bcopy (&event, f->output_data.x->saved_menu_event, size); \
+ if (numchars >= 1) \
+ { \
+ bufp->kind = menu_bar_activate_event; \
+ XSETFRAME (bufp->frame_or_window, f); \
+ bufp++; \
+ count++; \
+ numchars--; \
+ } \
+ }
+#define SET_SAVED_BUTTON_EVENT SET_SAVED_MENU_EVENT (sizeof (XButtonEvent))
+#define SET_SAVED_KEY_EVENT SET_SAVED_MENU_EVENT (sizeof (XKeyEvent))
+
/* Read events coming from the X server.
This routine is called by the SIGIO handler.
We return as soon as there are no more events to be read.
int
XTread_socket (sd, bufp, numchars, waitp, expected)
register int sd;
- register struct input_event *bufp;
- register int numchars;
+ /* register */ struct input_event *bufp;
+ /* register */ int numchars;
int waitp;
int expected;
{
int prefix;
Lisp_Object part;
struct x_display_info *dpyinfo;
+#ifdef HAVE_X_I18N
+ Status status_return;
+#endif
if (interrupt_input_blocked)
{
#ifdef FIOSNBIO
/* If available, Xlib uses FIOSNBIO to make the socket
non-blocking, and then looks for EWOULDBLOCK. If O_NDELAY is set,
- FIOSNBIO is ignored, and instead of signalling EWOULDBLOCK,
+ FIOSNBIO is ignored, and instead of signaling EWOULDBLOCK,
a read returns 0, which Xlib interprets as equivalent to EPIPE. */
fcntl (dpyinfo->connection, F_SETFL, 0);
#endif /* ! defined (FIOSNBIO) */
while (XPending (dpyinfo->display) != 0)
{
+#ifdef USE_X_TOOLKIT
+ /* needed to raise Motif submenus */
+ XtAppNextEvent (Xt_app_con, &event);
+#else
XNextEvent (dpyinfo->display, &event);
+#endif
+#ifdef HAVE_X_I18N
+ {
+ struct frame *f1 = x_any_window_to_frame (dpyinfo,
+ &event.xclient.window);
+ /* The necessity of the following line took me
+ a full work-day to decipher from the docs!! */
+ if (f1 != 0 && FRAME_XIC (f1) && XFilterEvent (&event, None))
+ break;
+ }
+#endif
event_found = 1;
switch (event.type)
/* Since we set WM_TAKE_FOCUS, we must call
XSetInputFocus explicitly. But not if f is null,
since that might be an event for a deleted frame. */
+#ifdef HAVE_X_I18N
+ /* Not quite sure this is needed -pd */
+ if (f)
+ XSetICFocus (FRAME_XIC (f));
+#endif
if (f)
XSetInputFocus (event.xclient.display,
event.xclient.window,
XSetCommand (FRAME_X_DISPLAY (f),
event.xclient.window,
initial_argv, initial_argc);
- else
+ else if (f)
XSetCommand (FRAME_X_DISPLAY (f),
event.xclient.window,
0, 0);
f->output_data.x->top_pos = new_y;
}
}
-#if defined (USE_X_TOOLKIT) && defined (HAVE_X11R5)
+#ifdef HACK_EDITRES
else if (event.xclient.message_type
== dpyinfo->Xatom_editres)
{
_XEditResCheckMessages (f->output_data.x->widget, NULL,
&event, NULL);
}
-#endif /* USE_X_TOOLKIT and HAVE_X11R5 */
+#endif /* HACK_EDITRES */
}
break;
SELECTION_EVENT_DISPLAY (bufp) = eventp->display;
SELECTION_EVENT_SELECTION (bufp) = eventp->selection;
SELECTION_EVENT_TIME (bufp) = eventp->time;
+ bufp->frame_or_window = Qnil;
bufp++;
count += 1;
SELECTION_EVENT_TARGET (bufp) = eventp->target;
SELECTION_EVENT_PROPERTY (bufp) = eventp->property;
SELECTION_EVENT_TIME (bufp) = eventp->time;
+ bufp->frame_or_window = Qnil;
bufp++;
count += 1;
/* We can't distinguish, from the event, whether the window
has become iconified or invisible. So assume, if it
was previously visible, than now it is iconified.
- We depend on x_make_frame_invisible to mark it iconified. */
+ We depend on x_make_frame_invisible to mark it invisible. */
if (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f))
f->async_iconified = 1;
count++;
numchars--;
}
-#ifdef USE_X_TOOLKIT
goto OTHER;
-#endif /* USE_X_TOOLKIT */
- break;
case MapNotify:
/* We use x_top_window_to_frame because map events can come
count++;
numchars--;
}
- else
+ else if (! NILP(Vframe_list)
+ && ! NILP (XCONS (Vframe_list)->cdr))
/* Force a redisplay sooner or later
to update the frame titles
in case this is the second frame. */
record_asynch_buffer_change ();
}
-#ifdef USE_X_TOOLKIT
goto OTHER;
-#endif /* USE_X_TOOLKIT */
- break;
/* Turn off processing if we become fully obscured. */
case VisibilityNotify:
unsigned char copy_buffer[81];
int modifiers;
+#if 0 /* This was how we made f10 work in Motif.
+ The drawback is, you can't type at Emacs when the
+ the mouse is in the menu bar. So it is better to
+ turn off f10 in Motif and let Emacs handle it. */
+#ifdef USE_MOTIF
+ if (lw_window_is_in_menubar (event.xkey.window,
+ f->output_data.x->menubar_widget
+ ))
+ {
+ SET_SAVED_KEY_EVENT;
+ break;
+ }
+#endif /* USE_MOTIF */
+#endif /* 0 */
+
event.xkey.state
|= x_emacs_to_x_modifiers (FRAME_X_DISPLAY_INFO (f),
extra_keyboard_modifiers);
| dpyinfo->hyper_mod_mask
| dpyinfo->alt_mod_mask);
+#ifdef HAVE_X_I18N
+ if (FRAME_XIC (f))
+ {
+ nbytes = XmbLookupString (FRAME_XIC (f),
+ &event.xkey, copy_buffer,
+ 80, &keysym,
+ &status_return);
+ }
+ else
+ nbytes = XLookupString (&event.xkey, copy_buffer,
+ 80, &keysym, &compose_status);
+#else
nbytes = XLookupString (&event.xkey, copy_buffer,
80, &keysym, &compose_status);
+#endif
orig_keysym = keysym;
else
abort ();
}
- break;
+ goto OTHER;
/* Here's a possible interpretation of the whole
FocusIn-EnterNotify FocusOut-LeaveNotify mess. If you get a
so update things that depend on mouse position. */
if (f)
note_mouse_movement (f, &event.xmotion);
-#ifdef USE_X_TOOLKIT
goto OTHER;
-#endif /* USE_X_TOOLKIT */
- break;
case FocusIn:
f = x_any_window_to_frame (dpyinfo, event.xfocus.window);
dpyinfo->x_focus_event_frame = f;
if (f)
x_new_focus_frame (dpyinfo, f);
-#ifdef USE_X_TOOLKIT
- goto OTHER;
-#endif /* USE_X_TOOLKIT */
- break;
+#ifdef HAVE_X_I18N
+ if (f && FRAME_XIC (f))
+ XSetICFocus (FRAME_XIC (f));
+#endif
+
+ goto OTHER;
case LeaveNotify:
f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
x_new_focus_frame (dpyinfo, 0);
}
}
-#ifdef USE_X_TOOLKIT
goto OTHER;
-#endif /* USE_X_TOOLKIT */
- break;
case FocusOut:
f = x_any_window_to_frame (dpyinfo, event.xfocus.window);
dpyinfo->x_focus_event_frame = 0;
if (f && f == dpyinfo->x_focus_frame)
x_new_focus_frame (dpyinfo, 0);
-#ifdef USE_X_TOOLKIT
+
+#ifdef HAVE_X_I18N
+ if (f && FRAME_XIC (f))
+ XUnsetICFocus (FRAME_XIC (f));
+#endif
+
goto OTHER;
-#endif /* USE_X_TOOLKIT */
- break;
case MotionNotify:
{
clear_mouse_face (dpyinfo);
}
}
-#ifdef USE_X_TOOLKIT
goto OTHER;
-#endif /* USE_X_TOOLKIT */
- break;
case ConfigureNotify:
f = x_any_window_to_frame (dpyinfo, event.xconfigure.window);
/* #endif */
}
}
-#ifdef USE_X_TOOLKIT
goto OTHER;
-#else
- break;
-#endif
case ButtonPress:
case ButtonRelease:
Instead, save it away
and we will pass it to Xt from kbd_buffer_get_event.
That way, we can run some Lisp code first. */
- if (f && event.type == ButtonPress)
+ if (f && event.type == ButtonPress
+ /* Verify the event is really within the menu bar
+ and not just sent to it due to grabbing. */
+ && event.xbutton.x >= 0
+ && event.xbutton.x < f->output_data.x->pixel_width
+ && event.xbutton.y >= 0
+ && event.xbutton.y < f->output_data.x->menubar_height
+ && event.xbutton.same_screen)
+ {
+ SET_SAVED_BUTTON_EVENT;
+ XSETFRAME (last_mouse_press_frame, f);
+ }
+ else if (event.type == ButtonPress)
+ {
+ last_mouse_press_frame = Qnil;
+ goto OTHER;
+ }
+#ifdef USE_MOTIF /* This should do not harm for Lucid,
+ but I am trying to be cautious. */
+ else if (event.type == ButtonRelease)
{
- if (f->output_data.x->saved_button_event == 0)
- f->output_data.x->saved_button_event
- = (XButtonEvent *) xmalloc (sizeof (XButtonEvent));
- bcopy (&event, f->output_data.x->saved_button_event,
- sizeof (XButtonEvent));
- if (numchars >= 1)
+ if (!NILP (last_mouse_press_frame))
{
- bufp->kind = menu_bar_activate_event;
- XSETFRAME (bufp->frame_or_window, f);
- bufp++;
- count++;
- numchars--;
+ f = XFRAME (last_mouse_press_frame);
+ if (f->output_data.x)
+ {
+ SET_SAVED_BUTTON_EVENT;
+ }
}
+ else
+ goto OTHER;
}
+#endif /* USE_MOTIF */
else
goto OTHER;
#endif /* USE_X_TOOLKIT */
case MappingKeyboard:
XRefreshKeyboardMapping (&event.xmapping);
}
-#ifdef USE_X_TOOLKIT
goto OTHER;
-#endif /* USE_X_TOOLKIT */
- break;
default:
-#ifdef USE_X_TOOLKIT
OTHER:
+#ifdef USE_X_TOOLKIT
BLOCK_INPUT;
XtDispatchEvent (&event);
UNBLOCK_INPUT;
|| f->phys_cursor_x < 0)
return;
- x_display_cursor (f, 0);
+ x_update_cursor (f, 0);
f->phys_cursor_x = -1;
}
}
/* Display the cursor on frame F, or clear it, according to ON.
- Use the position specified by curs_x and curs_y
- if we are doing an update of frame F now.
- Otherwise use the position in the FRAME_CURSOR_X and FRAME_CURSOR_Y fields
- of F. */
+ Also set the frame's cursor position to X and Y. */
-x_display_cursor (f, on)
+x_display_cursor (f, on, x, y)
struct frame *f;
int on;
+ int x, y;
{
BLOCK_INPUT;
- /* If we're not updating, then don't change the physical cursor
- position. Just change (if appropriate) the style of display. */
- if (f != updating_frame)
- {
- curs_x = FRAME_CURSOR_X (f);
- curs_y = FRAME_CURSOR_Y (f);
- }
-
if (FRAME_DESIRED_CURSOR (f) == filled_box_cursor)
- x_display_box_cursor (f, on, curs_x, curs_y);
+ x_display_box_cursor (f, on, x, y);
else if (FRAME_DESIRED_CURSOR (f) == bar_cursor)
- x_display_bar_cursor (f, on, curs_x, curs_y);
+ x_display_bar_cursor (f, on, x, y);
else
/* Those are the only two we have implemented! */
abort ();
struct frame *f;
int on;
{
+ /* If we don't have any previous cursor position to use,
+ leave the cursor off. */
+ if (f->phys_cursor_x < 0)
+ return;
+
BLOCK_INPUT;
if (FRAME_DESIRED_CURSOR (f) == filled_box_cursor)
struct x_display_info *dpyinfo = x_display_info_for_display (display);
Lisp_Object frame, tail;
- /* Whatever we were in the middle of, we are going to throw out of it,
- so reassure various things that have error checks about being
- called with input blocked. */
- TOTALLY_UNBLOCK_INPUT;
+ /* Indicate that this display is dead. */
- if (_Xdebug)
- abort ();
+ #ifdef USE_X_TOOLKIT
+ XtCloseDisplay (display);
+ #endif
+
+ dpyinfo->display = 0;
/* First delete frames whose minibuffers are on frames
that are on the dead display. */
Fdelete_frame (frame, Qt);
}
- x_delete_display (dpyinfo);
+ if (dpyinfo)
+ x_delete_display (dpyinfo);
if (x_display_list == 0)
{
- fprintf (stderr, "%s", error_message);
+ fprintf (stderr, "%s\n", error_message);
shut_down_emacs (0, 0, Qnil);
exit (70);
}
sigunblock (sigmask (SIGALRM));
TOTALLY_UNBLOCK_INPUT;
+ clear_waiting_for_input ();
error ("%s", error_message);
}
-static SIGTYPE
-x_connection_signal (signalnum) /* If we don't have an argument, */
- int signalnum; /* some compilers complain in signal calls. */
-{
- /* We really ought to close the connection to the display
- that actually failed.
- But do we actually get this signal ever with X11? */
- fprintf (stderr, "X connection closed");
- shut_down_emacs (0, 0, Qnil);
- exit (70);
-}
-
/* This is the usual handler for X protocol errors.
It kills all frames on the display that we got the error for.
If that was the only one, it prints an error message and kills Emacs. */
x_connection_closed (display, buf);
}
\f
+/* Handle SIGPIPE, which can happen when the connection to a server
+ simply goes away. SIGPIPE is handled by x_connection_signal.
+ Don't need to do anything, because the write which caused the
+ SIGPIPE will fail, causing Xlib to invoke the X IO error handler,
+ which will do the appropriate cleanup for us. */
+
+static SIGTYPE
+x_connection_signal (signalnum) /* If we don't have an argument, */
+ int signalnum; /* some compilers complain in signal calls. */
+{
+#ifdef USG
+ /* USG systems forget handlers when they are used;
+ must reestablish each time */
+ signal (signalnum, x_connection_signal);
+#endif /* USG */
+}
+\f
/* A buffer for storing X error messages. */
static char *x_caught_error_message;
#define X_CAUGHT_ERROR_MESSAGE_SIZE 200
full_name = 0;
for (i = 0; i < font->n_properties; i++)
{
- char *atom
- = XGetAtomName (FRAME_X_DISPLAY (f), font->properties[i].name);
- if (!strcmp (atom, "FONT"))
+ if (FRAME_X_DISPLAY_INFO (f)->Xatom_FONT == font->properties[i].name)
{
char *name = XGetAtomName (FRAME_X_DISPLAY (f),
(Atom) (font->properties[i].card32));
break;
}
-
- XFree (atom);
}
n_fonts = FRAME_X_DISPLAY_INFO (f)->n_fonts;
}
}
\f
+/* Calculate the absolute position in frame F
+ from its current recorded position values and gravity. */
+
x_calc_absolute_position (f)
struct frame *f;
{
position that fits on the screen. */
if (flags & XNegative)
f->output_data.x->left_pos = (FRAME_X_DISPLAY_INFO (f)->width
- - 2 * f->output_data.x->border_width - win_x
- - PIXEL_WIDTH (f)
- + f->output_data.x->left_pos);
+ - 2 * f->output_data.x->border_width - win_x
+ - PIXEL_WIDTH (f)
+ + f->output_data.x->left_pos);
if (flags & YNegative)
+ /* We used to subtract f->output_data.x->menubar_height here
+ in the toolkit case, but PIXEL_HEIGHT already includes that. */
f->output_data.x->top_pos = (FRAME_X_DISPLAY_INFO (f)->height
- - 2 * f->output_data.x->border_width - win_y
- - PIXEL_HEIGHT (f)
- - (FRAME_EXTERNAL_MENU_BAR (f)
- ? f->output_data.x->menubar_height : 0)
- + f->output_data.x->top_pos);
+ - 2 * f->output_data.x->border_width - win_y
+ - PIXEL_HEIGHT (f)
+ + f->output_data.x->top_pos);
+
/* The left_pos and top_pos
are now relative to the top and left screen edges,
so the flags should correspond. */
{
int pixelwidth, pixelheight;
int mask;
+ Lisp_Object window;
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
-#ifdef USE_X_TOOLKIT
BLOCK_INPUT;
+
+#ifdef USE_X_TOOLKIT
{
/* The x and y position of the widget is clobbered by the
call to XtSetValues within EmacsFrameSetCharSize.
f->output_data.x->widget->core.x = xpos;
f->output_data.x->widget->core.y = ypos;
}
- UNBLOCK_INPUT;
#else /* not USE_X_TOOLKIT */
- BLOCK_INPUT;
-
check_frame_size (f, &rows, &cols);
f->output_data.x->vertical_scroll_bar_extra
= (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
PIXEL_WIDTH (f) = pixelwidth;
PIXEL_HEIGHT (f) = pixelheight;
+ /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
+ receive in the ConfigureNotify event; if we get what we asked
+ for, then the event won't cause the screen to become garbaged, so
+ we have to make sure to do it here. */
+ SET_FRAME_GARBAGED (f);
+
+ XFlush (FRAME_X_DISPLAY (f));
+
+#endif /* not USE_X_TOOLKIT */
+
/* If cursor was outside the new size, mark it as off. */
if (f->phys_cursor_y >= rows
|| f->phys_cursor_x >= cols)
f->phys_cursor_y = -1;
}
- /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
- receive in the ConfigureNotify event; if we get what we asked
- for, then the event won't cause the screen to become garbaged, so
- we have to make sure to do it here. */
- SET_FRAME_GARBAGED (f);
+ /* Clear out any recollection of where the mouse highlighting was,
+ since it might be in a place that's outside the new frame size.
+ Actually checking whether it is outside is a pain in the neck,
+ so don't try--just let the highlighting be done afresh with new size. */
+ window = dpyinfo->mouse_face_window;
+ if (! NILP (window) && XFRAME (window) == f)
+ {
+ dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
+ dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
+ dpyinfo->mouse_face_window = Qnil;
+ }
- XFlush (FRAME_X_DISPLAY (f));
UNBLOCK_INPUT;
-#endif /* not USE_X_TOOLKIT */
}
\f
/* Mouse warping. */
}
static void
-XTframe_raise_lower (f, raise)
+XTframe_raise_lower (f, raise_flag)
FRAME_PTR f;
- int raise;
+ int raise_flag;
{
- if (raise)
+ if (raise_flag)
x_raise_frame (f);
else
x_lower_frame (f);
BLOCK_INPUT;
+ FRAME_SAMPLE_VISIBILITY (f);
+
type = x_icon_type (f);
if (!NILP (type))
x_bitmap_icon (f, type);
x_wm_set_window_state (f, IconicState);
/* This was XtPopup, but that did nothing for an iconified frame. */
XtMapWidget (f->output_data.x->widget);
+ /* The server won't give us any event to indicate
+ that an invisible frame was changed to an icon,
+ so we have to record it here. */
+ f->iconified = 1;
+ f->async_iconified = 1;
UNBLOCK_INPUT;
return;
}
BLOCK_INPUT;
- if (f->output_data.x->icon_desc != 0)
- XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->icon_desc);
- XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->window_desc);
+ /* If a display connection is dead, don't try sending more
+ commands to the X server. */
+ if (dpyinfo->display != 0)
+ {
+ if (f->output_data.x->icon_desc != 0)
+ XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->icon_desc);
+#ifdef HAVE_X_I18N
+ if (FRAME_XIM (f))
+ {
+ XDestroyIC (FRAME_XIC (f));
+#if ! defined (SOLARIS2) || defined (HAVE_X11R6)
+ /* This line causes crashes on Solaris with Openwin,
+ due to an apparent bug in XCloseIM.
+ X11R6 seems not to have the bug. */
+ XCloseIM (FRAME_XIM (f));
+#endif
+ }
+#endif
+ XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->window_desc);
#ifdef USE_X_TOOLKIT
- XtDestroyWidget (f->output_data.x->widget);
- free_frame_menubar (f);
+ XtDestroyWidget (f->output_data.x->widget);
+ free_frame_menubar (f);
#endif /* USE_X_TOOLKIT */
- free_frame_faces (f);
- XFlush (FRAME_X_DISPLAY (f));
+ free_frame_faces (f);
+ XFlush (FRAME_X_DISPLAY (f));
+ }
xfree (f->output_data.x);
f->output_data.x = 0;
struct frame *f;
int pixmap_id;
{
+ Pixmap icon_pixmap;
+
#ifdef USE_X_TOOLKIT
Window window = XtWindow (f->output_data.x->widget);
#else
if (pixmap_id > 0)
{
- Pixmap icon_pixmap = x_bitmap_pixmap (f, pixmap_id);
+ icon_pixmap = x_bitmap_pixmap (f, pixmap_id);
f->output_data.x->wm_hints.icon_pixmap = icon_pixmap;
}
else
- f->output_data.x->wm_hints.icon_pixmap = None;
+ {
+ /* It seems there is no way to turn off use of an icon pixmap.
+ The following line does it, only if no icon has yet been created,
+ for some window managers. But with mwm it crashes.
+ Some people say it should clear the IconPixmapHint bit in this case,
+ but that doesn't work, and the X consortium said it isn't the
+ right thing at all. Since there is no way to win,
+ best to explicitly give up. */
+#if 0
+ f->output_data.x->wm_hints.icon_pixmap = None;
+#else
+ return;
+#endif
+ }
+#ifdef USE_X_TOOLKIT /* same as in x_wm_set_window_state. */
+
+ {
+ Arg al[1];
+ XtSetArg (al[0], XtNiconPixmap, icon_pixmap);
+ XtSetValues (f->output_data.x->widget, al, 1);
+ }
+
+#else /* not USE_X_TOOLKIT */
+
f->output_data.x->wm_hints.flags |= IconPixmapHint;
XSetWMHints (FRAME_X_DISPLAY (f), window, &f->output_data.x->wm_hints);
+
+#endif /* not USE_X_TOOLKIT */
}
x_wm_set_icon_position (f, icon_x, icon_y)
x_initialized = 1;
}
+#ifdef HAVE_X_I18N
+ setlocale (LC_ALL, "");
+ /* In case we just overrode what init_lread did, redo it. */
+ setlocale (LC_NUMERIC, "C");
+ setlocale (LC_TIME, "C");
+#endif
+
#ifdef USE_X_TOOLKIT
/* weiner@footloose.sps.mot.com reports that this causes
errors with X11R5:
&argc, argv);
#ifdef HAVE_X11XTR6
+ /* I think this is to compensate for XtSetLanguageProc. */
setlocale (LC_NUMERIC, "C");
setlocale (LC_TIME, "C");
#endif
= XInternAtom (dpyinfo->display, "WM_MOVED", False);
dpyinfo->Xatom_editres
= XInternAtom (dpyinfo->display, "Editres", False);
+ dpyinfo->Xatom_FONT
+ = XInternAtom (dpyinfo->display, "FONT", False);
dpyinfo->Xatom_CLIPBOARD
= XInternAtom (dpyinfo->display, "CLIPBOARD", False);
dpyinfo->Xatom_TIMESTAMP
init_sigio (connection);
#endif /* ! defined (SIGIO) */
+#ifdef USE_LUCID
+ /* Make sure that we have a valid font for dialog boxes
+ so that Xt does not crash. */
+ {
+ Display *dpy = dpyinfo->display;
+ XrmValue d, fr, to;
+ Font font;
+
+ d.addr = (XPointer)&dpy;
+ d.size = sizeof (Display *);
+ fr.addr = XtDefaultFont;
+ fr.size = sizeof (XtDefaultFont);
+ to.size = sizeof (Font *);
+ to.addr = (XPointer)&font;
+ x_catch_errors (dpy);
+ if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
+ abort ();
+ if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
+ XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
+ x_uncatch_errors (dpy);
+ }
+#endif
+
+
UNBLOCK_INPUT;
return dpyinfo;
tail->next = tail->next->next;
}
-#ifndef USE_X_TOOLKIT
- /* I'm told Xt does this itself. */
+#ifndef USE_X_TOOLKIT /* I'm told Xt does this itself. */
+#ifndef AIX /* On AIX, XCloseDisplay calls this. */
XrmDestroyDatabase (dpyinfo->xrdb);
#endif
+#endif
#ifdef MULTI_KBOARD
if (--dpyinfo->kboard->reference_count == 0)
delete_kboard (dpyinfo->kboard);
staticpro (&Qvendor_specific_keysyms);
Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");
+
+ staticpro (&last_mouse_press_frame);
+ last_mouse_press_frame = Qnil;
}
-#endif /* ! defined (HAVE_X_WINDOWS) */
+
+#endif /* not HAVE_X_WINDOWS */