aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c222
1 files changed, 105 insertions, 117 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 909b6978f5a..fd7ffd68e62 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -279,10 +279,6 @@ Lisp_Object Qx_gtk_map_stock;
279/* Some functions take this as char *, not const char *. */ 279/* Some functions take this as char *, not const char *. */
280static char emacs_class[] = EMACS_CLASS; 280static char emacs_class[] = EMACS_CLASS;
281 281
282/* XEmbed implementation. */
283
284#define XEMBED_VERSION 0
285
286enum xembed_info 282enum xembed_info
287 { 283 {
288 XEMBED_MAPPED = 1 << 0 284 XEMBED_MAPPED = 1 << 0
@@ -321,6 +317,7 @@ static void XTframe_up_to_date (struct frame *);
321static void XTset_terminal_modes (struct terminal *); 317static void XTset_terminal_modes (struct terminal *);
322static void XTreset_terminal_modes (struct terminal *); 318static void XTreset_terminal_modes (struct terminal *);
323static void x_clear_frame (struct frame *); 319static void x_clear_frame (struct frame *);
320static void x_ins_del_lines (struct frame *, int, int) NO_RETURN;
324static void frame_highlight (struct frame *); 321static void frame_highlight (struct frame *);
325static void frame_unhighlight (struct frame *); 322static void frame_unhighlight (struct frame *);
326static void x_new_focus_frame (struct x_display_info *, struct frame *); 323static void x_new_focus_frame (struct x_display_info *, struct frame *);
@@ -877,6 +874,7 @@ static void x_draw_glyph_string_foreground (struct glyph_string *);
877static void x_draw_composite_glyph_string_foreground (struct glyph_string *); 874static void x_draw_composite_glyph_string_foreground (struct glyph_string *);
878static void x_draw_glyph_string_box (struct glyph_string *); 875static void x_draw_glyph_string_box (struct glyph_string *);
879static void x_draw_glyph_string (struct glyph_string *); 876static void x_draw_glyph_string (struct glyph_string *);
877static void x_delete_glyphs (struct frame *, int) NO_RETURN;
880static void x_compute_glyph_string_overhangs (struct glyph_string *); 878static void x_compute_glyph_string_overhangs (struct glyph_string *);
881static void x_set_cursor_gc (struct glyph_string *); 879static void x_set_cursor_gc (struct glyph_string *);
882static void x_set_mode_line_face_gc (struct glyph_string *); 880static void x_set_mode_line_face_gc (struct glyph_string *);
@@ -1791,27 +1789,6 @@ x_copy_color (struct frame *f, long unsigned int pixel)
1791} 1789}
1792 1790
1793 1791
1794/* Allocate color PIXEL on display DPY. PIXEL must already be allocated.
1795 It's necessary to do this instead of just using PIXEL directly to
1796 get color reference counts right. */
1797
1798unsigned long
1799x_copy_dpy_color (Display *dpy, Colormap cmap, long unsigned int pixel)
1800{
1801 XColor color;
1802
1803 color.pixel = pixel;
1804 BLOCK_INPUT;
1805 XQueryColor (dpy, cmap, &color);
1806 XAllocColor (dpy, cmap, &color);
1807 UNBLOCK_INPUT;
1808#ifdef DEBUG_X_COLORS
1809 register_color (pixel);
1810#endif
1811 return color.pixel;
1812}
1813
1814
1815/* Brightness beyond which a color won't have its highlight brightness 1792/* Brightness beyond which a color won't have its highlight brightness
1816 boosted. 1793 boosted.
1817 1794
@@ -2260,12 +2237,12 @@ x_draw_image_foreground (struct glyph_string *s)
2260 nothing here for mouse-face. */ 2237 nothing here for mouse-face. */
2261 if (s->hl == DRAW_CURSOR) 2238 if (s->hl == DRAW_CURSOR)
2262 { 2239 {
2263 int r = s->img->relief; 2240 int relief = s->img->relief;
2264 if (r < 0) r = -r; 2241 if (relief < 0) relief = -relief;
2265 XDrawRectangle (s->display, s->window, s->gc, 2242 XDrawRectangle (s->display, s->window, s->gc,
2266 x - r, y - r, 2243 x - relief, y - relief,
2267 s->slice.width + r*2 - 1, 2244 s->slice.width + relief*2 - 1,
2268 s->slice.height + r*2 - 1); 2245 s->slice.height + relief*2 - 1);
2269 } 2246 }
2270 } 2247 }
2271 } 2248 }
@@ -2907,7 +2884,7 @@ x_draw_glyph_string (struct glyph_string *s)
2907 2884
2908/* Shift display to make room for inserted glyphs. */ 2885/* Shift display to make room for inserted glyphs. */
2909 2886
2910void 2887static void
2911x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height, int shift_by) 2888x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height, int shift_by)
2912{ 2889{
2913 XCopyArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), FRAME_X_WINDOW (f), 2890 XCopyArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), FRAME_X_WINDOW (f),
@@ -3011,7 +2988,7 @@ timeval_subtract (struct timeval *result, struct timeval x, struct timeval y)
3011 return x.tv_sec < y.tv_sec; 2988 return x.tv_sec < y.tv_sec;
3012} 2989}
3013 2990
3014void 2991static void
3015XTflash (struct frame *f) 2992XTflash (struct frame *f)
3016{ 2993{
3017 BLOCK_INPUT; 2994 BLOCK_INPUT;
@@ -3021,6 +2998,17 @@ XTflash (struct frame *f)
3021 /* Use Gdk routines to draw. This way, we won't draw over scroll bars 2998 /* Use Gdk routines to draw. This way, we won't draw over scroll bars
3022 when the scroll bars and the edit widget share the same X window. */ 2999 when the scroll bars and the edit widget share the same X window. */
3023 GdkWindow *window = gtk_widget_get_window (FRAME_GTK_WIDGET (f)); 3000 GdkWindow *window = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
3001#ifdef HAVE_GTK3
3002 cairo_t *cr = gdk_cairo_create (window);
3003 cairo_set_source_rgb (cr, 1, 1, 1);
3004 cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE);
3005#define XFillRectangle(d, win, gc, x, y, w, h) \
3006 do { \
3007 cairo_rectangle (cr, x, y, w, h); \
3008 cairo_fill (cr); \
3009 } \
3010 while (0)
3011#else /* ! HAVE_GTK3 */
3024 GdkGCValues vals; 3012 GdkGCValues vals;
3025 GdkGC *gc; 3013 GdkGC *gc;
3026 vals.foreground.pixel = (FRAME_FOREGROUND_PIXEL (f) 3014 vals.foreground.pixel = (FRAME_FOREGROUND_PIXEL (f)
@@ -3030,7 +3018,8 @@ XTflash (struct frame *f)
3030 &vals, GDK_GC_FUNCTION | GDK_GC_FOREGROUND); 3018 &vals, GDK_GC_FUNCTION | GDK_GC_FOREGROUND);
3031#define XFillRectangle(d, win, gc, x, y, w, h) \ 3019#define XFillRectangle(d, win, gc, x, y, w, h) \
3032 gdk_draw_rectangle (window, gc, TRUE, x, y, w, h) 3020 gdk_draw_rectangle (window, gc, TRUE, x, y, w, h)
3033#else 3021#endif /* ! HAVE_GTK3 */
3022#else /* ! USE_GTK */
3034 GC gc; 3023 GC gc;
3035 3024
3036 /* Create a GC that will use the GXxor function to flip foreground 3025 /* Create a GC that will use the GXxor function to flip foreground
@@ -3151,7 +3140,11 @@ XTflash (struct frame *f)
3151 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); 3140 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
3152 3141
3153#ifdef USE_GTK 3142#ifdef USE_GTK
3143#ifdef HAVE_GTK3
3144 cairo_destroy (cr);
3145#else
3154 g_object_unref (G_OBJECT (gc)); 3146 g_object_unref (G_OBJECT (gc));
3147#endif
3155#undef XFillRectangle 3148#undef XFillRectangle
3156#else 3149#else
3157 XFreeGC (FRAME_X_DISPLAY (f), gc); 3150 XFreeGC (FRAME_X_DISPLAY (f), gc);
@@ -3186,7 +3179,7 @@ XTtoggle_invisible_pointer (FRAME_PTR f, int invisible)
3186 3179
3187/* Make audible bell. */ 3180/* Make audible bell. */
3188 3181
3189void 3182static void
3190XTring_bell (struct frame *f) 3183XTring_bell (struct frame *f)
3191{ 3184{
3192 if (FRAME_X_DISPLAY (f)) 3185 if (FRAME_X_DISPLAY (f))
@@ -3800,7 +3793,7 @@ redo_mouse_highlight (void)
3800 mouse is on, *BAR_WINDOW to nil, and *X and *Y to the character cell 3793 mouse is on, *BAR_WINDOW to nil, and *X and *Y to the character cell
3801 the mouse is over. 3794 the mouse is over.
3802 3795
3803 Set *TIME to the server time-stamp for the time at which the mouse 3796 Set *TIMESTAMP to the server time-stamp for the time at which the mouse
3804 was at this position. 3797 was at this position.
3805 3798
3806 Don't store anything if we don't have a valid set of values to report. 3799 Don't store anything if we don't have a valid set of values to report.
@@ -3809,14 +3802,16 @@ redo_mouse_highlight (void)
3809 movement. */ 3802 movement. */
3810 3803
3811static void 3804static void
3812XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, long unsigned int *time) 3805XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
3806 enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y,
3807 long unsigned int *timestamp)
3813{ 3808{
3814 FRAME_PTR f1; 3809 FRAME_PTR f1;
3815 3810
3816 BLOCK_INPUT; 3811 BLOCK_INPUT;
3817 3812
3818 if (! NILP (last_mouse_scroll_bar) && insist == 0) 3813 if (! NILP (last_mouse_scroll_bar) && insist == 0)
3819 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); 3814 x_scroll_bar_report_motion (fp, bar_window, part, x, y, timestamp);
3820 else 3815 else
3821 { 3816 {
3822 Window root; 3817 Window root;
@@ -3989,7 +3984,7 @@ XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, enum scrol
3989 *fp = f1; 3984 *fp = f1;
3990 XSETINT (*x, win_x); 3985 XSETINT (*x, win_x);
3991 XSETINT (*y, win_y); 3986 XSETINT (*y, win_y);
3992 *time = last_mouse_movement_time; 3987 *timestamp = last_mouse_movement_time;
3993 } 3988 }
3994 } 3989 }
3995 } 3990 }
@@ -5541,7 +5536,9 @@ x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event)
5541 on the scroll bar. */ 5536 on the scroll bar. */
5542 5537
5543static void 5538static void
5544x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, long unsigned int *time) 5539x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window,
5540 enum scroll_bar_part *part, Lisp_Object *x,
5541 Lisp_Object *y, long unsigned int *timestamp)
5545{ 5542{
5546 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 5543 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
5547 Window w = bar->x_window; 5544 Window w = bar->x_window;
@@ -5601,7 +5598,7 @@ x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window, enum scroll_
5601 last_mouse_scroll_bar = Qnil; 5598 last_mouse_scroll_bar = Qnil;
5602 } 5599 }
5603 5600
5604 *time = last_mouse_movement_time; 5601 *timestamp = last_mouse_movement_time;
5605 5602
5606 UNBLOCK_INPUT; 5603 UNBLOCK_INPUT;
5607} 5604}
@@ -5775,7 +5772,8 @@ static void xembed_send_message (struct frame *f, Time time,
5775 We return the number of characters stored into the buffer. */ 5772 We return the number of characters stored into the buffer. */
5776 5773
5777static int 5774static int
5778handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish, struct input_event *hold_quit) 5775handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
5776 int *finish, struct input_event *hold_quit)
5779{ 5777{
5780 union { 5778 union {
5781 struct input_event ie; 5779 struct input_event ie;
@@ -5786,7 +5784,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
5786 int nbytes = 0; 5784 int nbytes = 0;
5787 struct frame *f = NULL; 5785 struct frame *f = NULL;
5788 struct coding_system coding; 5786 struct coding_system coding;
5789 XEvent event = *eventp; 5787 XEvent event = *eventptr;
5790 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; 5788 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
5791 5789
5792 *finish = X_EVENT_NORMAL; 5790 *finish = X_EVENT_NORMAL;
@@ -6486,7 +6484,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
6486 6484
6487 { /* Raw bytes, not keysym. */ 6485 { /* Raw bytes, not keysym. */
6488 register int i; 6486 register int i;
6489 register int c;
6490 int nchars, len; 6487 int nchars, len;
6491 6488
6492 for (i = 0, nchars = 0; i < nbytes; i++) 6489 for (i = 0, nchars = 0; i < nbytes; i++)
@@ -6526,14 +6523,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
6526 character events. */ 6523 character events. */
6527 for (i = 0; i < nbytes; i += len) 6524 for (i = 0; i < nbytes; i += len)
6528 { 6525 {
6526 int ch;
6529 if (nchars == nbytes) 6527 if (nchars == nbytes)
6530 c = copy_bufptr[i], len = 1; 6528 ch = copy_bufptr[i], len = 1;
6531 else 6529 else
6532 c = STRING_CHAR_AND_LENGTH (copy_bufptr + i, len); 6530 ch = STRING_CHAR_AND_LENGTH (copy_bufptr + i, len);
6533 inev.ie.kind = (SINGLE_BYTE_CHAR_P (c) 6531 inev.ie.kind = (SINGLE_BYTE_CHAR_P (ch)
6534 ? ASCII_KEYSTROKE_EVENT 6532 ? ASCII_KEYSTROKE_EVENT
6535 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 6533 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
6536 inev.ie.code = c; 6534 inev.ie.code = ch;
6537 kbd_buffer_store_event_hold (&inev.ie, hold_quit); 6535 kbd_buffer_store_event_hold (&inev.ie, hold_quit);
6538 } 6536 }
6539 6537
@@ -6972,7 +6970,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
6972 count++; 6970 count++;
6973 } 6971 }
6974 6972
6975 *eventp = event; 6973 *eventptr = event;
6976 return count; 6974 return count;
6977} 6975}
6978 6976
@@ -7012,7 +7010,6 @@ static int
7012XTread_socket (struct terminal *terminal, int expected, struct input_event *hold_quit) 7010XTread_socket (struct terminal *terminal, int expected, struct input_event *hold_quit)
7013{ 7011{
7014 int count = 0; 7012 int count = 0;
7015 XEvent event;
7016 int event_found = 0; 7013 int event_found = 0;
7017 7014
7018 if (interrupt_input_blocked) 7015 if (interrupt_input_blocked)
@@ -7046,6 +7043,7 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7046 while (XPending (terminal->display_info.x->display)) 7043 while (XPending (terminal->display_info.x->display))
7047 { 7044 {
7048 int finish; 7045 int finish;
7046 XEvent event;
7049 7047
7050 XNextEvent (terminal->display_info.x->display, &event); 7048 XNextEvent (terminal->display_info.x->display, &event);
7051 7049
@@ -7063,6 +7061,8 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7063 goto out; 7061 goto out;
7064 } 7062 }
7065 7063
7064 out:;
7065
7066#else /* USE_GTK */ 7066#else /* USE_GTK */
7067 7067
7068 /* For GTK we must use the GTK event loop. But XEvents gets passed 7068 /* For GTK we must use the GTK event loop. But XEvents gets passed
@@ -7089,8 +7089,6 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7089 } 7089 }
7090#endif /* USE_GTK */ 7090#endif /* USE_GTK */
7091 7091
7092 out:;
7093
7094 /* On some systems, an X bug causes Emacs to get no more events 7092 /* On some systems, an X bug causes Emacs to get no more events
7095 when the window is destroyed. Detect that. (1994.) */ 7093 when the window is destroyed. Detect that. (1994.) */
7096 if (! event_found) 7094 if (! event_found)
@@ -7226,9 +7224,9 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
7226 the bar might not be in the window. */ 7224 the bar might not be in the window. */
7227 if (cursor_glyph->type == IMAGE_GLYPH) 7225 if (cursor_glyph->type == IMAGE_GLYPH)
7228 { 7226 {
7229 struct glyph_row *row; 7227 struct glyph_row *r;
7230 row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos); 7228 r = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos);
7231 draw_phys_cursor_glyph (w, row, DRAW_CURSOR); 7229 draw_phys_cursor_glyph (w, r, DRAW_CURSOR);
7232 } 7230 }
7233 else 7231 else
7234 { 7232 {
@@ -7517,9 +7515,9 @@ static struct x_error_message_stack *x_error_message;
7517 x_catch_errors is in effect. */ 7515 x_catch_errors is in effect. */
7518 7516
7519static void 7517static void
7520x_error_catcher (Display *display, XErrorEvent *error) 7518x_error_catcher (Display *display, XErrorEvent *event)
7521{ 7519{
7522 XGetErrorText (display, error->error_code, 7520 XGetErrorText (display, event->error_code,
7523 x_error_message->string, 7521 x_error_message->string,
7524 X_ERROR_MESSAGE_SIZE); 7522 X_ERROR_MESSAGE_SIZE);
7525} 7523}
@@ -7668,17 +7666,6 @@ x_connection_signal (int signalnum) /* If we don't have an argument, */
7668 7666
7669static char *error_msg; 7667static char *error_msg;
7670 7668
7671/* Function installed as fatal_error_signal_hook in
7672 x_connection_closed. Print the X error message, and exit normally,
7673 instead of dumping core when XtCloseDisplay fails. */
7674
7675static void
7676x_fatal_error_signal (void)
7677{
7678 fprintf (stderr, "%s\n", error_msg);
7679 exit (70);
7680}
7681
7682/* Handle the loss of connection to display DPY. ERROR_MESSAGE is 7669/* Handle the loss of connection to display DPY. ERROR_MESSAGE is
7683 the text of an error message that lead to the connection loss. */ 7670 the text of an error message that lead to the connection loss. */
7684 7671
@@ -7687,7 +7674,7 @@ x_connection_closed (Display *dpy, const char *error_message)
7687{ 7674{
7688 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 7675 struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
7689 Lisp_Object frame, tail; 7676 Lisp_Object frame, tail;
7690 int index = SPECPDL_INDEX (); 7677 int idx = SPECPDL_INDEX ();
7691 7678
7692 error_msg = (char *) alloca (strlen (error_message) + 1); 7679 error_msg = (char *) alloca (strlen (error_message) + 1);
7693 strcpy (error_msg, error_message); 7680 strcpy (error_msg, error_message);
@@ -7782,8 +7769,12 @@ For details, see etc/PROBLEMS.\n",
7782 sigunblock (sigmask (SIGALRM)); 7769 sigunblock (sigmask (SIGALRM));
7783 TOTALLY_UNBLOCK_INPUT; 7770 TOTALLY_UNBLOCK_INPUT;
7784 7771
7785 unbind_to (index, Qnil); 7772 unbind_to (idx, Qnil);
7786 clear_waiting_for_input (); 7773 clear_waiting_for_input ();
7774
7775 /* Tell GCC not to suggest attribute 'noreturn' for this function. */
7776 IF_LINT (if (! terminal_list) return; )
7777
7787 /* Here, we absolutely have to use a non-local exit (e.g. signal, throw, 7778 /* Here, we absolutely have to use a non-local exit (e.g. signal, throw,
7788 longjmp), because returning from this function would get us back into 7779 longjmp), because returning from this function would get us back into
7789 Xlib's code which will directly call `exit'. */ 7780 Xlib's code which will directly call `exit'. */
@@ -7798,12 +7789,12 @@ static void x_error_quitter (Display *, XErrorEvent *);
7798 It calls x_error_quitter or x_error_catcher. */ 7789 It calls x_error_quitter or x_error_catcher. */
7799 7790
7800static int 7791static int
7801x_error_handler (Display *display, XErrorEvent *error) 7792x_error_handler (Display *display, XErrorEvent *event)
7802{ 7793{
7803 if (x_error_message) 7794 if (x_error_message)
7804 x_error_catcher (display, error); 7795 x_error_catcher (display, event);
7805 else 7796 else
7806 x_error_quitter (display, error); 7797 x_error_quitter (display, event);
7807 return 0; 7798 return 0;
7808} 7799}
7809 7800
@@ -7817,22 +7808,22 @@ x_error_handler (Display *display, XErrorEvent *error)
7817 after x_error_handler prevents inlining into the former. */ 7808 after x_error_handler prevents inlining into the former. */
7818 7809
7819static void NO_INLINE 7810static void NO_INLINE
7820x_error_quitter (Display *display, XErrorEvent *error) 7811x_error_quitter (Display *display, XErrorEvent *event)
7821{ 7812{
7822 char buf[256], buf1[356]; 7813 char buf[256], buf1[356];
7823 7814
7824 /* Ignore BadName errors. They can happen because of fonts 7815 /* Ignore BadName errors. They can happen because of fonts
7825 or colors that are not defined. */ 7816 or colors that are not defined. */
7826 7817
7827 if (error->error_code == BadName) 7818 if (event->error_code == BadName)
7828 return; 7819 return;
7829 7820
7830 /* Note that there is no real way portable across R3/R4 to get the 7821 /* Note that there is no real way portable across R3/R4 to get the
7831 original error handler. */ 7822 original error handler. */
7832 7823
7833 XGetErrorText (display, error->error_code, buf, sizeof (buf)); 7824 XGetErrorText (display, event->error_code, buf, sizeof (buf));
7834 sprintf (buf1, "X protocol error: %s on protocol request %d", 7825 sprintf (buf1, "X protocol error: %s on protocol request %d",
7835 buf, error->request_code); 7826 buf, event->request_code);
7836 x_connection_closed (display, buf1); 7827 x_connection_closed (display, buf1);
7837} 7828}
7838 7829
@@ -8119,7 +8110,7 @@ xim_close_dpy (struct x_display_info *dpyinfo)
8119/* Calculate the absolute position in frame F 8110/* Calculate the absolute position in frame F
8120 from its current recorded position values and gravity. */ 8111 from its current recorded position values and gravity. */
8121 8112
8122void 8113static void
8123x_calc_absolute_position (struct frame *f) 8114x_calc_absolute_position (struct frame *f)
8124{ 8115{
8125 int flags = f->size_hint_flags; 8116 int flags = f->size_hint_flags;
@@ -8862,31 +8853,6 @@ x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
8862 UNBLOCK_INPUT; 8853 UNBLOCK_INPUT;
8863} 8854}
8864 8855
8865/* focus shifting, raising and lowering. */
8866
8867void
8868x_focus_on_frame (struct frame *f)
8869{
8870#if 0
8871 /* I don't think that the ICCCM allows programs to do things like this
8872 without the interaction of the window manager. Whatever you end up
8873 doing with this code, do it to x_unfocus_frame too. */
8874 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
8875 RevertToPointerRoot, CurrentTime);
8876#endif /* ! 0 */
8877}
8878
8879void
8880x_unfocus_frame (struct frame *f)
8881{
8882#if 0
8883 /* Look at the remarks in x_focus_on_frame. */
8884 if (FRAME_X_DISPLAY_INFO (f)->x_focus_frame == f)
8885 XSetInputFocus (FRAME_X_DISPLAY (f), PointerRoot,
8886 RevertToPointerRoot, CurrentTime);
8887#endif /* ! 0 */
8888}
8889
8890/* Raise frame F. */ 8856/* Raise frame F. */
8891 8857
8892void 8858void
@@ -8947,6 +8913,12 @@ XTframe_raise_lower (FRAME_PTR f, int raise_flag)
8947 8913
8948/* XEmbed implementation. */ 8914/* XEmbed implementation. */
8949 8915
8916#if defined USE_X_TOOLKIT || ! defined USE_GTK
8917
8918/* XEmbed implementation. */
8919
8920#define XEMBED_VERSION 0
8921
8950static void 8922static void
8951xembed_set_info (struct frame *f, enum xembed_info flags) 8923xembed_set_info (struct frame *f, enum xembed_info flags)
8952{ 8924{
@@ -8960,9 +8932,11 @@ xembed_set_info (struct frame *f, enum xembed_info flags)
8960 dpyinfo->Xatom_XEMBED_INFO, dpyinfo->Xatom_XEMBED_INFO, 8932 dpyinfo->Xatom_XEMBED_INFO, dpyinfo->Xatom_XEMBED_INFO,
8961 32, PropModeReplace, (unsigned char *) data, 2); 8933 32, PropModeReplace, (unsigned char *) data, 2);
8962} 8934}
8935#endif /* defined USE_X_TOOLKIT || ! defined USE_GTK */
8963 8936
8964static void 8937static void
8965xembed_send_message (struct frame *f, Time time, enum xembed_message message, long int detail, long int data1, long int data2) 8938xembed_send_message (struct frame *f, Time t, enum xembed_message msg,
8939 long int detail, long int data1, long int data2)
8966{ 8940{
8967 XEvent event; 8941 XEvent event;
8968 8942
@@ -8970,8 +8944,8 @@ xembed_send_message (struct frame *f, Time time, enum xembed_message message, lo
8970 event.xclient.window = FRAME_X_OUTPUT (f)->parent_desc; 8944 event.xclient.window = FRAME_X_OUTPUT (f)->parent_desc;
8971 event.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_XEMBED; 8945 event.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_XEMBED;
8972 event.xclient.format = 32; 8946 event.xclient.format = 32;
8973 event.xclient.data.l[0] = time; 8947 event.xclient.data.l[0] = t;
8974 event.xclient.data.l[1] = message; 8948 event.xclient.data.l[1] = msg;
8975 event.xclient.data.l[2] = detail; 8949 event.xclient.data.l[2] = detail;
8976 event.xclient.data.l[3] = data1; 8950 event.xclient.data.l[3] = data1;
8977 event.xclient.data.l[4] = data2; 8951 event.xclient.data.l[4] = data2;
@@ -9212,7 +9186,9 @@ x_make_frame_invisible (struct frame *f)
9212void 9186void
9213x_iconify_frame (struct frame *f) 9187x_iconify_frame (struct frame *f)
9214{ 9188{
9189#ifdef USE_X_TOOLKIT
9215 int result; 9190 int result;
9191#endif
9216 Lisp_Object type; 9192 Lisp_Object type;
9217 9193
9218 /* Don't keep the highlight on an invisible frame. */ 9194 /* Don't keep the highlight on an invisible frame. */
@@ -9295,19 +9271,19 @@ x_iconify_frame (struct frame *f)
9295 /* X11R4: send a ClientMessage to the window manager using the 9271 /* X11R4: send a ClientMessage to the window manager using the
9296 WM_CHANGE_STATE type. */ 9272 WM_CHANGE_STATE type. */
9297 { 9273 {
9298 XEvent message; 9274 XEvent msg;
9299 9275
9300 message.xclient.window = FRAME_X_WINDOW (f); 9276 msg.xclient.window = FRAME_X_WINDOW (f);
9301 message.xclient.type = ClientMessage; 9277 msg.xclient.type = ClientMessage;
9302 message.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_change_state; 9278 msg.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_change_state;
9303 message.xclient.format = 32; 9279 msg.xclient.format = 32;
9304 message.xclient.data.l[0] = IconicState; 9280 msg.xclient.data.l[0] = IconicState;
9305 9281
9306 if (! XSendEvent (FRAME_X_DISPLAY (f), 9282 if (! XSendEvent (FRAME_X_DISPLAY (f),
9307 DefaultRootWindow (FRAME_X_DISPLAY (f)), 9283 DefaultRootWindow (FRAME_X_DISPLAY (f)),
9308 False, 9284 False,
9309 SubstructureRedirectMask | SubstructureNotifyMask, 9285 SubstructureRedirectMask | SubstructureNotifyMask,
9310 &message)) 9286 &msg))
9311 { 9287 {
9312 UNBLOCK_INPUT_RESIGNAL; 9288 UNBLOCK_INPUT_RESIGNAL;
9313 error ("Can't notify window manager of iconification"); 9289 error ("Can't notify window manager of iconification");
@@ -9339,9 +9315,11 @@ void
9339x_free_frame_resources (struct frame *f) 9315x_free_frame_resources (struct frame *f)
9340{ 9316{
9341 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 9317 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
9318 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
9319#ifdef USE_X_TOOLKIT
9342 Lisp_Object bar; 9320 Lisp_Object bar;
9343 struct scroll_bar *b; 9321 struct scroll_bar *b;
9344 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; 9322#endif
9345 9323
9346 BLOCK_INPUT; 9324 BLOCK_INPUT;
9347 9325
@@ -9797,10 +9775,11 @@ x_display_ok (const char *display)
9797 9775
9798#ifdef USE_GTK 9776#ifdef USE_GTK
9799static void 9777static void
9800my_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) 9778my_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
9779 const gchar *msg, gpointer user_data)
9801{ 9780{
9802 if (!strstr (message, "g_set_prgname")) 9781 if (!strstr (msg, "g_set_prgname"))
9803 fprintf (stderr, "%s-WARNING **: %s\n", log_domain, message); 9782 fprintf (stderr, "%s-WARNING **: %s\n", log_domain, msg);
9804} 9783}
9805#endif 9784#endif
9806 9785
@@ -9863,6 +9842,13 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9863 9842
9864 XSetLocaleModifiers (""); 9843 XSetLocaleModifiers ("");
9865 9844
9845 /* Emacs can only handle core input events, so make sure
9846 Gtk doesn't use Xinput or Xinput2 extensions. */
9847 {
9848 static char fix_events[] = "GDK_CORE_DEVICE_EVENTS=1";
9849 putenv (fix_events);
9850 }
9851
9866 /* Work around GLib bug that outputs a faulty warning. See 9852 /* Work around GLib bug that outputs a faulty warning. See
9867 https://bugzilla.gnome.org/show_bug.cgi?id=563627. */ 9853 https://bugzilla.gnome.org/show_bug.cgi?id=563627. */
9868 id = g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL 9854 id = g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
@@ -9874,11 +9860,12 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9874 fixup_locale (); 9860 fixup_locale ();
9875 xg_initialize (); 9861 xg_initialize ();
9876 9862
9877 dpy = GDK_DISPLAY (); 9863 dpy = DEFAULT_GDK_DISPLAY ();
9878 9864
9879 /* NULL window -> events for all windows go to our function */ 9865 /* NULL window -> events for all windows go to our function */
9880 gdk_window_add_filter (NULL, event_handler_gdk, NULL); 9866 gdk_window_add_filter (NULL, event_handler_gdk, NULL);
9881 9867
9868#if GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION <= 90
9882 /* Load our own gtkrc if it exists. */ 9869 /* Load our own gtkrc if it exists. */
9883 { 9870 {
9884 const char *file = "~/.emacs.d/gtkrc"; 9871 const char *file = "~/.emacs.d/gtkrc";
@@ -9890,6 +9877,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9890 if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file))) 9877 if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file)))
9891 gtk_rc_parse (SSDATA (abs_file)); 9878 gtk_rc_parse (SSDATA (abs_file));
9892 } 9879 }
9880#endif
9893 9881
9894 XSetErrorHandler (x_error_handler); 9882 XSetErrorHandler (x_error_handler);
9895 XSetIOErrorHandler (x_io_error_quitter); 9883 XSetIOErrorHandler (x_io_error_quitter);