aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorJoakim Verona2010-08-27 10:58:44 +0200
committerJoakim Verona2010-08-27 10:58:44 +0200
commit362120833bcbbaea94976b6701633e2ed75f6051 (patch)
tree632690a24a934bb51a32303add5172d63b6b9e00 /src/xterm.c
parent1800c4865b15a9e1154bf1f03d87d1aaf750a527 (diff)
parent1a868076f51b5d6f1cf78117463e6f9c614551ec (diff)
downloademacs-362120833bcbbaea94976b6701633e2ed75f6051.tar.gz
emacs-362120833bcbbaea94976b6701633e2ed75f6051.zip
merge from trunk, fix conflicts
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c1159
1 files changed, 386 insertions, 773 deletions
diff --git a/src/xterm.c b/src/xterm.c
index ac6ee55954b..a07279f987e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -22,11 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22/* Xt features made by Fred Pierresteguy. */ 22/* Xt features made by Fred Pierresteguy. */
23 23
24#include <config.h> 24#include <config.h>
25
26/* On 4.3 these lose if they come after xterm.h. */
27/* Putting these at the beginning seems to be standard for other .c files. */
28#include <signal.h> 25#include <signal.h>
29
30#include <stdio.h> 26#include <stdio.h>
31#include <setjmp.h> 27#include <setjmp.h>
32 28
@@ -105,13 +101,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
105#endif 101#endif
106 102
107#ifdef USE_LUCID 103#ifdef USE_LUCID
108extern int xlwmenu_window_p P_ ((Widget w, Window window)); 104#include "../lwlib/xlwmenu.h"
109extern void xlwmenu_redisplay P_ ((Widget));
110#endif
111
112#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
113
114extern void free_frame_menubar P_ ((struct frame *));
115#endif 105#endif
116 106
117#ifdef USE_X_TOOLKIT 107#ifdef USE_X_TOOLKIT
@@ -295,23 +285,6 @@ static int input_signal_count;
295 285
296static int x_noop_count; 286static int x_noop_count;
297 287
298/* Initial values of argv and argc. */
299
300extern char **initial_argv;
301extern int initial_argc;
302
303extern Lisp_Object Vcommand_line_args, Vsystem_name;
304
305/* Tells if a window manager is present or not. */
306
307extern Lisp_Object Vx_no_window_manager;
308
309extern Lisp_Object Qeql;
310
311/* A mask of extra modifier bits to put into every keyboard char. */
312
313extern EMACS_INT extra_keyboard_modifiers;
314
315/* The keysyms to use for the various modifiers. */ 288/* The keysyms to use for the various modifiers. */
316 289
317Lisp_Object Vx_alt_keysym, Vx_hyper_keysym, Vx_meta_keysym, Vx_super_keysym; 290Lisp_Object Vx_alt_keysym, Vx_hyper_keysym, Vx_meta_keysym, Vx_super_keysym;
@@ -329,65 +302,66 @@ static Lisp_Object xg_default_icon_file;
329Lisp_Object Qx_gtk_map_stock; 302Lisp_Object Qx_gtk_map_stock;
330#endif 303#endif
331 304
305/* Some functions take this as char *, not const char *. */
306static char emacs_class[] = EMACS_CLASS;
307
332/* Used in x_flush. */ 308/* Used in x_flush. */
333 309
334extern Lisp_Object Vinhibit_redisplay; 310extern XrmDatabase x_load_resources (Display *, const char *, const char *,
335 311 const char *);
336extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *)); 312extern int x_bitmap_mask (FRAME_PTR, int);
337extern int x_bitmap_mask P_ ((FRAME_PTR, int)); 313
338 314static int x_alloc_nearest_color_1 (Display *, Colormap, XColor *);
339static int x_alloc_nearest_color_1 P_ ((Display *, Colormap, XColor *)); 315static void x_set_window_size_1 (struct frame *, int, int, int);
340static void x_set_window_size_1 P_ ((struct frame *, int, int, int)); 316static const XColor *x_color_cells (Display *, int *);
341static const XColor *x_color_cells P_ ((Display *, int *)); 317static void x_update_window_end (struct window *, int, int);
342static void x_update_window_end P_ ((struct window *, int, int)); 318
343 319static int x_io_error_quitter (Display *);
344static int x_io_error_quitter P_ ((Display *)); 320static struct terminal *x_create_terminal (struct x_display_info *);
345static struct terminal *x_create_terminal P_ ((struct x_display_info *)); 321void x_delete_terminal (struct terminal *);
346void x_delete_terminal P_ ((struct terminal *)); 322static void x_update_end (struct frame *);
347static void x_update_end P_ ((struct frame *)); 323static void XTframe_up_to_date (struct frame *);
348static void XTframe_up_to_date P_ ((struct frame *)); 324static void XTset_terminal_modes (struct terminal *);
349static void XTset_terminal_modes P_ ((struct terminal *)); 325static void XTreset_terminal_modes (struct terminal *);
350static void XTreset_terminal_modes P_ ((struct terminal *)); 326static void x_clear_frame (struct frame *);
351static void x_clear_frame P_ ((struct frame *)); 327static void frame_highlight (struct frame *);
352static void frame_highlight P_ ((struct frame *)); 328static void frame_unhighlight (struct frame *);
353static void frame_unhighlight P_ ((struct frame *)); 329static void x_new_focus_frame (struct x_display_info *, struct frame *);
354static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *)); 330static void x_focus_changed (int, int, struct x_display_info *,
355static void x_focus_changed P_ ((int, int, struct x_display_info *, 331 struct frame *, struct input_event *);
356 struct frame *, struct input_event *)); 332static void x_detect_focus_change (struct x_display_info *,
357static void x_detect_focus_change P_ ((struct x_display_info *, 333 XEvent *, struct input_event *);
358 XEvent *, struct input_event *)); 334static void XTframe_rehighlight (struct frame *);
359static void XTframe_rehighlight P_ ((struct frame *)); 335static void x_frame_rehighlight (struct x_display_info *);
360static void x_frame_rehighlight P_ ((struct x_display_info *)); 336static void x_draw_hollow_cursor (struct window *, struct glyph_row *);
361static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 337static void x_draw_bar_cursor (struct window *, struct glyph_row *, int,
362static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, 338 enum text_cursor_kinds);
363 enum text_cursor_kinds)); 339
364 340static void x_clip_to_row (struct window *, struct glyph_row *, int, GC);
365static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC)); 341static void x_flush (struct frame *f);
366static void x_flush P_ ((struct frame *f)); 342static void x_update_begin (struct frame *);
367static void x_update_begin P_ ((struct frame *)); 343static void x_update_window_begin (struct window *);
368static void x_update_window_begin P_ ((struct window *)); 344static void x_after_update_window_line (struct glyph_row *);
369static void x_after_update_window_line P_ ((struct glyph_row *)); 345static struct scroll_bar *x_window_to_scroll_bar (Display *, Window);
370static struct scroll_bar *x_window_to_scroll_bar P_ ((Display *, Window)); 346static void x_scroll_bar_report_motion (struct frame **, Lisp_Object *,
371static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *, 347 enum scroll_bar_part *,
372 enum scroll_bar_part *, 348 Lisp_Object *, Lisp_Object *,
373 Lisp_Object *, Lisp_Object *, 349 unsigned long *);
374 unsigned long *)); 350static void x_handle_net_wm_state (struct frame *, XPropertyEvent *);
375static void x_handle_net_wm_state P_ ((struct frame *, XPropertyEvent *)); 351static void x_check_fullscreen (struct frame *);
376static void x_check_fullscreen P_ ((struct frame *)); 352static void x_check_expected_move (struct frame *, int, int);
377static void x_check_expected_move P_ ((struct frame *, int, int)); 353static void x_sync_with_move (struct frame *, int, int, int);
378static void x_sync_with_move P_ ((struct frame *, int, int, int)); 354static int handle_one_xevent (struct x_display_info *, XEvent *,
379static int handle_one_xevent P_ ((struct x_display_info *, XEvent *, 355 int *, struct input_event *);
380 int *, struct input_event *));
381/* Don't declare this NO_RETURN because we want no 356/* Don't declare this NO_RETURN because we want no
382 interference with debugging failing X calls. */ 357 interference with debugging failing X calls. */
383static SIGTYPE x_connection_closed P_ ((Display *, char *)); 358static SIGTYPE x_connection_closed (Display *, const char *);
384 359
385 360
386/* Flush display of frame F, or of all frames if F is null. */ 361/* Flush display of frame F, or of all frames if F is null. */
387 362
388static void 363static void
389x_flush (f) 364x_flush (struct frame *f)
390 struct frame *f;
391{ 365{
392 /* Don't call XFlush when it is not safe to redisplay; the X 366 /* Don't call XFlush when it is not safe to redisplay; the X
393 connection may be broken. */ 367 connection may be broken. */
@@ -456,8 +430,7 @@ record_event (locus, type)
456/* Return the struct x_display_info corresponding to DPY. */ 430/* Return the struct x_display_info corresponding to DPY. */
457 431
458struct x_display_info * 432struct x_display_info *
459x_display_info_for_display (dpy) 433x_display_info_for_display (Display *dpy)
460 Display *dpy;
461{ 434{
462 struct x_display_info *dpyinfo; 435 struct x_display_info *dpyinfo;
463 436
@@ -472,8 +445,7 @@ x_display_info_for_display (dpy)
472#define OPACITY "_NET_WM_WINDOW_OPACITY" 445#define OPACITY "_NET_WM_WINDOW_OPACITY"
473 446
474void 447void
475x_set_frame_alpha (f) 448x_set_frame_alpha (struct frame *f)
476 struct frame *f;
477{ 449{
478 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 450 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
479 Display *dpy = FRAME_X_DISPLAY (f); 451 Display *dpy = FRAME_X_DISPLAY (f);
@@ -485,7 +457,7 @@ x_set_frame_alpha (f)
485 if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc) 457 if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc)
486 /* Since the WM decoration lies under the FRAME_OUTER_WINDOW, 458 /* Since the WM decoration lies under the FRAME_OUTER_WINDOW,
487 we must treat the former instead of the latter. */ 459 we must treat the former instead of the latter. */
488 win = FRAME_X_OUTPUT(f)->parent_desc; 460 win = FRAME_X_OUTPUT (f)->parent_desc;
489 461
490 if (dpyinfo->x_highlight_frame == f) 462 if (dpyinfo->x_highlight_frame == f)
491 alpha = f->alpha[0]; 463 alpha = f->alpha[0];
@@ -514,10 +486,10 @@ x_set_frame_alpha (f)
514 unsigned long n, left; 486 unsigned long n, left;
515 487
516 x_catch_errors (dpy); 488 x_catch_errors (dpy);
517 rc = XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False), 489 rc = XGetWindowProperty (dpy, win, XInternAtom(dpy, OPACITY, False),
518 0L, 1L, False, XA_CARDINAL, 490 0L, 1L, False, XA_CARDINAL,
519 &actual, &format, &n, &left, 491 &actual, &format, &n, &left,
520 &data); 492 &data);
521 493
522 if (rc == Success && actual != None) 494 if (rc == Success && actual != None)
523 if (*(unsigned long *)data == opac) 495 if (*(unsigned long *)data == opac)
@@ -539,15 +511,13 @@ x_set_frame_alpha (f)
539} 511}
540 512
541int 513int
542x_display_pixel_height (dpyinfo) 514x_display_pixel_height (struct x_display_info *dpyinfo)
543 struct x_display_info *dpyinfo;
544{ 515{
545 return HeightOfScreen (dpyinfo->screen); 516 return HeightOfScreen (dpyinfo->screen);
546} 517}
547 518
548int 519int
549x_display_pixel_width (dpyinfo) 520x_display_pixel_width (struct x_display_info *dpyinfo)
550 struct x_display_info *dpyinfo;
551{ 521{
552 return WidthOfScreen (dpyinfo->screen); 522 return WidthOfScreen (dpyinfo->screen);
553} 523}
@@ -564,8 +534,7 @@ x_display_pixel_width (dpyinfo)
564 because all interesting stuff is done on a window basis. */ 534 because all interesting stuff is done on a window basis. */
565 535
566static void 536static void
567x_update_begin (f) 537x_update_begin (struct frame *f)
568 struct frame *f;
569{ 538{
570 /* Nothing to do. */ 539 /* Nothing to do. */
571} 540}
@@ -576,8 +545,7 @@ x_update_begin (f)
576 position of W. */ 545 position of W. */
577 546
578static void 547static void
579x_update_window_begin (w) 548x_update_window_begin (struct window *w)
580 struct window *w;
581{ 549{
582 struct frame *f = XFRAME (WINDOW_FRAME (w)); 550 struct frame *f = XFRAME (WINDOW_FRAME (w));
583 struct x_display_info *display_info = FRAME_X_DISPLAY_INFO (f); 551 struct x_display_info *display_info = FRAME_X_DISPLAY_INFO (f);
@@ -605,9 +573,7 @@ x_update_window_begin (w)
605/* Draw a vertical window border from (x,y0) to (x,y1) */ 573/* Draw a vertical window border from (x,y0) to (x,y1) */
606 574
607static void 575static void
608x_draw_vertical_window_border (w, x, y0, y1) 576x_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
609 struct window *w;
610 int x, y0, y1;
611{ 577{
612 struct frame *f = XFRAME (WINDOW_FRAME (w)); 578 struct frame *f = XFRAME (WINDOW_FRAME (w));
613 struct face *face; 579 struct face *face;
@@ -635,9 +601,7 @@ x_draw_vertical_window_border (w, x, y0, y1)
635 here. */ 601 here. */
636 602
637static void 603static void
638x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) 604x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p)
639 struct window *w;
640 int cursor_on_p, mouse_face_overwritten_p;
641{ 605{
642 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); 606 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
643 607
@@ -673,8 +637,7 @@ x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
673 update_end. */ 637 update_end. */
674 638
675static void 639static void
676x_update_end (f) 640x_update_end (struct frame *f)
677 struct frame *f;
678{ 641{
679 /* Mouse highlight may be displayed again. */ 642 /* Mouse highlight may be displayed again. */
680 FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0; 643 FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0;
@@ -692,8 +655,7 @@ x_update_end (f)
692 updated_window is not available here. */ 655 updated_window is not available here. */
693 656
694static void 657static void
695XTframe_up_to_date (f) 658XTframe_up_to_date (struct frame *f)
696 struct frame *f;
697{ 659{
698 if (FRAME_X_P (f)) 660 if (FRAME_X_P (f))
699 { 661 {
@@ -722,8 +684,7 @@ XTframe_up_to_date (f)
722 between bitmaps to be drawn between current row and DESIRED_ROW. */ 684 between bitmaps to be drawn between current row and DESIRED_ROW. */
723 685
724static void 686static void
725x_after_update_window_line (desired_row) 687x_after_update_window_line (struct glyph_row *desired_row)
726 struct glyph_row *desired_row;
727{ 688{
728 struct window *w = updated_window; 689 struct window *w = updated_window;
729 struct frame *f; 690 struct frame *f;
@@ -761,34 +722,16 @@ x_after_update_window_line (desired_row)
761} 722}
762 723
763static void 724static void
764x_draw_fringe_bitmap (w, row, p) 725x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fringe_bitmap_params *p)
765 struct window *w;
766 struct glyph_row *row;
767 struct draw_fringe_bitmap_params *p;
768{ 726{
769 struct frame *f = XFRAME (WINDOW_FRAME (w)); 727 struct frame *f = XFRAME (WINDOW_FRAME (w));
770 Display *display = FRAME_X_DISPLAY (f); 728 Display *display = FRAME_X_DISPLAY (f);
771 Window window = FRAME_X_WINDOW (f); 729 Window window = FRAME_X_WINDOW (f);
772 GC gc = f->output_data.x->normal_gc; 730 GC gc = f->output_data.x->normal_gc;
773 struct face *face = p->face; 731 struct face *face = p->face;
774 int rowY;
775 732
776 /* Must clip because of partially visible lines. */ 733 /* Must clip because of partially visible lines. */
777 rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 734 x_clip_to_row (w, row, -1, gc);
778 if (p->y < rowY)
779 {
780 /* Adjust position of "bottom aligned" bitmap on partially
781 visible last row. */
782 int oldY = row->y;
783 int oldVH = row->visible_height;
784 row->visible_height = p->h;
785 row->y -= rowY - p->y;
786 x_clip_to_row (w, row, -1, gc);
787 row->y = oldY;
788 row->visible_height = oldVH;
789 }
790 else
791 x_clip_to_row (w, row, -1, gc);
792 735
793 if (!p->overlay_p) 736 if (!p->overlay_p)
794 { 737 {
@@ -932,37 +875,37 @@ XTreset_terminal_modes (struct terminal *terminal)
932 875
933 876
934 877
935static void x_set_glyph_string_clipping P_ ((struct glyph_string *)); 878static void x_set_glyph_string_clipping (struct glyph_string *);
936static void x_set_glyph_string_gc P_ ((struct glyph_string *)); 879static void x_set_glyph_string_gc (struct glyph_string *);
937static void x_draw_glyph_string_background P_ ((struct glyph_string *, 880static void x_draw_glyph_string_background (struct glyph_string *,
938 int)); 881 int);
939static void x_draw_glyph_string_foreground P_ ((struct glyph_string *)); 882static void x_draw_glyph_string_foreground (struct glyph_string *);
940static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *)); 883static void x_draw_composite_glyph_string_foreground (struct glyph_string *);
941static void x_draw_glyph_string_box P_ ((struct glyph_string *)); 884static void x_draw_glyph_string_box (struct glyph_string *);
942static void x_draw_glyph_string P_ ((struct glyph_string *)); 885static void x_draw_glyph_string (struct glyph_string *);
943static void x_compute_glyph_string_overhangs P_ ((struct glyph_string *)); 886static void x_compute_glyph_string_overhangs (struct glyph_string *);
944static void x_set_cursor_gc P_ ((struct glyph_string *)); 887static void x_set_cursor_gc (struct glyph_string *);
945static void x_set_mode_line_face_gc P_ ((struct glyph_string *)); 888static void x_set_mode_line_face_gc (struct glyph_string *);
946static void x_set_mouse_face_gc P_ ((struct glyph_string *)); 889static void x_set_mouse_face_gc (struct glyph_string *);
947static int x_alloc_lighter_color P_ ((struct frame *, Display *, Colormap, 890static int x_alloc_lighter_color (struct frame *, Display *, Colormap,
948 unsigned long *, double, int)); 891 unsigned long *, double, int);
949static void x_setup_relief_color P_ ((struct frame *, struct relief *, 892static void x_setup_relief_color (struct frame *, struct relief *,
950 double, int, unsigned long)); 893 double, int, unsigned long);
951static void x_setup_relief_colors P_ ((struct glyph_string *)); 894static void x_setup_relief_colors (struct glyph_string *);
952static void x_draw_image_glyph_string P_ ((struct glyph_string *)); 895static void x_draw_image_glyph_string (struct glyph_string *);
953static void x_draw_image_relief P_ ((struct glyph_string *)); 896static void x_draw_image_relief (struct glyph_string *);
954static void x_draw_image_foreground P_ ((struct glyph_string *)); 897static void x_draw_image_foreground (struct glyph_string *);
955static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap)); 898static void x_draw_image_foreground_1 (struct glyph_string *, Pixmap);
956static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, 899static void x_clear_glyph_string_rect (struct glyph_string *, int,
957 int, int, int)); 900 int, int, int);
958static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int, 901static void x_draw_relief_rect (struct frame *, int, int, int, int,
959 int, int, int, int, int, int, 902 int, int, int, int, int, int,
960 XRectangle *)); 903 XRectangle *);
961static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, 904static void x_draw_box_rect (struct glyph_string *, int, int, int, int,
962 int, int, int, XRectangle *)); 905 int, int, int, XRectangle *);
963 906
964#if GLYPH_DEBUG 907#if GLYPH_DEBUG
965static void x_check_font P_ ((struct frame *, struct font *)); 908static void x_check_font (struct frame *, struct font *);
966#endif 909#endif
967 910
968 911
@@ -970,8 +913,7 @@ static void x_check_font P_ ((struct frame *, struct font *));
970 face. */ 913 face. */
971 914
972static void 915static void
973x_set_cursor_gc (s) 916x_set_cursor_gc (struct glyph_string *s)
974 struct glyph_string *s;
975{ 917{
976 if (s->font == FRAME_FONT (s->f) 918 if (s->font == FRAME_FONT (s->f)
977 && s->face->background == FRAME_BACKGROUND_PIXEL (s->f) 919 && s->face->background == FRAME_BACKGROUND_PIXEL (s->f)
@@ -1022,8 +964,7 @@ x_set_cursor_gc (s)
1022/* Set up S->gc of glyph string S for drawing text in mouse face. */ 964/* Set up S->gc of glyph string S for drawing text in mouse face. */
1023 965
1024static void 966static void
1025x_set_mouse_face_gc (s) 967x_set_mouse_face_gc (struct glyph_string *s)
1026 struct glyph_string *s;
1027{ 968{
1028 int face_id; 969 int face_id;
1029 struct face *face; 970 struct face *face;
@@ -1074,8 +1015,7 @@ x_set_mouse_face_gc (s)
1074 matrix was built, so there isn't much to do, here. */ 1015 matrix was built, so there isn't much to do, here. */
1075 1016
1076static INLINE void 1017static INLINE void
1077x_set_mode_line_face_gc (s) 1018x_set_mode_line_face_gc (struct glyph_string *s)
1078 struct glyph_string *s;
1079{ 1019{
1080 s->gc = s->face->gc; 1020 s->gc = s->face->gc;
1081} 1021}
@@ -1086,8 +1026,7 @@ x_set_mode_line_face_gc (s)
1086 pattern. */ 1026 pattern. */
1087 1027
1088static INLINE void 1028static INLINE void
1089x_set_glyph_string_gc (s) 1029x_set_glyph_string_gc (struct glyph_string *s)
1090 struct glyph_string *s;
1091{ 1030{
1092 PREPARE_FACE_FOR_DISPLAY (s->f, s->face); 1031 PREPARE_FACE_FOR_DISPLAY (s->f, s->face);
1093 1032
@@ -1132,8 +1071,7 @@ x_set_glyph_string_gc (s)
1132 line or menu if we don't have X toolkit support. */ 1071 line or menu if we don't have X toolkit support. */
1133 1072
1134static INLINE void 1073static INLINE void
1135x_set_glyph_string_clipping (s) 1074x_set_glyph_string_clipping (struct glyph_string *s)
1136 struct glyph_string *s;
1137{ 1075{
1138 XRectangle *r = s->clip; 1076 XRectangle *r = s->clip;
1139 int n = get_glyph_string_clip_rects (s, r, 2); 1077 int n = get_glyph_string_clip_rects (s, r, 2);
@@ -1149,8 +1087,7 @@ x_set_glyph_string_clipping (s)
1149 the area of SRC. */ 1087 the area of SRC. */
1150 1088
1151static void 1089static void
1152x_set_glyph_string_clipping_exactly (src, dst) 1090x_set_glyph_string_clipping_exactly (struct glyph_string *src, struct glyph_string *dst)
1153 struct glyph_string *src, *dst;
1154{ 1091{
1155 XRectangle r; 1092 XRectangle r;
1156 1093
@@ -1168,8 +1105,7 @@ x_set_glyph_string_clipping_exactly (src, dst)
1168 Compute left and right overhang of glyph string S. */ 1105 Compute left and right overhang of glyph string S. */
1169 1106
1170static void 1107static void
1171x_compute_glyph_string_overhangs (s) 1108x_compute_glyph_string_overhangs (struct glyph_string *s)
1172 struct glyph_string *s;
1173{ 1109{
1174 if (s->cmp == NULL 1110 if (s->cmp == NULL
1175 && (s->first_glyph->type == CHAR_GLYPH 1111 && (s->first_glyph->type == CHAR_GLYPH
@@ -1208,9 +1144,7 @@ x_compute_glyph_string_overhangs (s)
1208/* Fill rectangle X, Y, W, H with background color of glyph string S. */ 1144/* Fill rectangle X, Y, W, H with background color of glyph string S. */
1209 1145
1210static INLINE void 1146static INLINE void
1211x_clear_glyph_string_rect (s, x, y, w, h) 1147x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h)
1212 struct glyph_string *s;
1213 int x, y, w, h;
1214{ 1148{
1215 XGCValues xgcv; 1149 XGCValues xgcv;
1216 XGetGCValues (s->display, s->gc, GCForeground | GCBackground, &xgcv); 1150 XGetGCValues (s->display, s->gc, GCForeground | GCBackground, &xgcv);
@@ -1227,9 +1161,7 @@ x_clear_glyph_string_rect (s, x, y, w, h)
1227 contains the first component of a composition. */ 1161 contains the first component of a composition. */
1228 1162
1229static void 1163static void
1230x_draw_glyph_string_background (s, force_p) 1164x_draw_glyph_string_background (struct glyph_string *s, int force_p)
1231 struct glyph_string *s;
1232 int force_p;
1233{ 1165{
1234 /* Nothing to do if background has already been drawn or if it 1166 /* Nothing to do if background has already been drawn or if it
1235 shouldn't be drawn in the first place. */ 1167 shouldn't be drawn in the first place. */
@@ -1265,8 +1197,7 @@ x_draw_glyph_string_background (s, force_p)
1265/* Draw the foreground of glyph string S. */ 1197/* Draw the foreground of glyph string S. */
1266 1198
1267static void 1199static void
1268x_draw_glyph_string_foreground (s) 1200x_draw_glyph_string_foreground (struct glyph_string *s)
1269 struct glyph_string *s;
1270{ 1201{
1271 int i, x; 1202 int i, x;
1272 1203
@@ -1314,8 +1245,7 @@ x_draw_glyph_string_foreground (s)
1314/* Draw the foreground of composite glyph string S. */ 1245/* Draw the foreground of composite glyph string S. */
1315 1246
1316static void 1247static void
1317x_draw_composite_glyph_string_foreground (s) 1248x_draw_composite_glyph_string_foreground (struct glyph_string *s)
1318 struct glyph_string *s;
1319{ 1249{
1320 int i, j, x; 1250 int i, j, x;
1321 struct font *font = s->font; 1251 struct font *font = s->font;
@@ -1402,19 +1332,18 @@ x_draw_composite_glyph_string_foreground (s)
1402 1332
1403#ifdef USE_X_TOOLKIT 1333#ifdef USE_X_TOOLKIT
1404 1334
1405static struct frame *x_frame_of_widget P_ ((Widget)); 1335static struct frame *x_frame_of_widget (Widget);
1406static Boolean cvt_string_to_pixel P_ ((Display *, XrmValue *, Cardinal *, 1336static Boolean cvt_string_to_pixel (Display *, XrmValue *, Cardinal *,
1407 XrmValue *, XrmValue *, XtPointer *)); 1337 XrmValue *, XrmValue *, XtPointer *);
1408static void cvt_pixel_dtor P_ ((XtAppContext, XrmValue *, XtPointer, 1338static void cvt_pixel_dtor (XtAppContext, XrmValue *, XtPointer,
1409 XrmValue *, Cardinal *)); 1339 XrmValue *, Cardinal *);
1410 1340
1411 1341
1412/* Return the frame on which widget WIDGET is used.. Abort if frame 1342/* Return the frame on which widget WIDGET is used.. Abort if frame
1413 cannot be determined. */ 1343 cannot be determined. */
1414 1344
1415static struct frame * 1345static struct frame *
1416x_frame_of_widget (widget) 1346x_frame_of_widget (Widget widget)
1417 Widget widget;
1418{ 1347{
1419 struct x_display_info *dpyinfo; 1348 struct x_display_info *dpyinfo;
1420 Lisp_Object tail; 1349 Lisp_Object tail;
@@ -1450,10 +1379,7 @@ x_frame_of_widget (widget)
1450 if successful. This is called from lwlib. */ 1379 if successful. This is called from lwlib. */
1451 1380
1452int 1381int
1453x_alloc_nearest_color_for_widget (widget, cmap, color) 1382x_alloc_nearest_color_for_widget (Widget widget, Colormap cmap, XColor *color)
1454 Widget widget;
1455 Colormap cmap;
1456 XColor *color;
1457{ 1383{
1458 struct frame *f = x_frame_of_widget (widget); 1384 struct frame *f = x_frame_of_widget (widget);
1459 return x_alloc_nearest_color (f, cmap, color); 1385 return x_alloc_nearest_color (f, cmap, color);
@@ -1468,13 +1394,8 @@ x_alloc_nearest_color_for_widget (widget, cmap, color)
1468 Value is non-zero if successful. */ 1394 Value is non-zero if successful. */
1469 1395
1470int 1396int
1471x_alloc_lighter_color_for_widget (widget, display, cmap, pixel, factor, delta) 1397x_alloc_lighter_color_for_widget (Widget widget, Display *display, Colormap cmap,
1472 Widget widget; 1398 unsigned long *pixel, double factor, int delta)
1473 Display *display;
1474 Colormap cmap;
1475 unsigned long *pixel;
1476 double factor;
1477 int delta;
1478{ 1399{
1479 struct frame *f = x_frame_of_widget (widget); 1400 struct frame *f = x_frame_of_widget (widget);
1480 return x_alloc_lighter_color (f, display, cmap, pixel, factor, delta); 1401 return x_alloc_lighter_color (f, display, cmap, pixel, factor, delta);
@@ -1517,12 +1438,9 @@ static Pixel cvt_string_to_pixel_value;
1517 Value is True if successful, False otherwise. */ 1438 Value is True if successful, False otherwise. */
1518 1439
1519static Boolean 1440static Boolean
1520cvt_string_to_pixel (dpy, args, nargs, from, to, closure_ret) 1441cvt_string_to_pixel (Display *dpy, XrmValue *args, Cardinal *nargs,
1521 Display *dpy; 1442 XrmValue *from, XrmValue *to,
1522 XrmValue *args; 1443 XtPointer *closure_ret)
1523 Cardinal *nargs;
1524 XrmValue *from, *to;
1525 XtPointer *closure_ret;
1526{ 1444{
1527 Screen *screen; 1445 Screen *screen;
1528 Colormap cmap; 1446 Colormap cmap;
@@ -1606,12 +1524,8 @@ cvt_string_to_pixel (dpy, args, nargs, from, to, closure_ret)
1606 ARGS and NARGS are like for cvt_string_to_pixel. */ 1524 ARGS and NARGS are like for cvt_string_to_pixel. */
1607 1525
1608static void 1526static void
1609cvt_pixel_dtor (app, to, closure, args, nargs) 1527cvt_pixel_dtor (XtAppContext app, XrmValuePtr to, XtPointer closure, XrmValuePtr args,
1610 XtAppContext app; 1528 Cardinal *nargs)
1611 XrmValuePtr to;
1612 XtPointer closure;
1613 XrmValuePtr args;
1614 Cardinal *nargs;
1615{ 1529{
1616 if (*nargs != 2) 1530 if (*nargs != 2)
1617 { 1531 {
@@ -1640,9 +1554,7 @@ cvt_pixel_dtor (app, to, closure, args, nargs)
1640 say a 24-bit TrueColor map. */ 1554 say a 24-bit TrueColor map. */
1641 1555
1642static const XColor * 1556static const XColor *
1643x_color_cells (dpy, ncells) 1557x_color_cells (Display *dpy, int *ncells)
1644 Display *dpy;
1645 int *ncells;
1646{ 1558{
1647 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 1559 struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
1648 1560
@@ -1673,10 +1585,7 @@ x_color_cells (dpy, ncells)
1673 colors in COLORS. Use cached information, if available. */ 1585 colors in COLORS. Use cached information, if available. */
1674 1586
1675void 1587void
1676x_query_colors (f, colors, ncolors) 1588x_query_colors (struct frame *f, XColor *colors, int ncolors)
1677 struct frame *f;
1678 XColor *colors;
1679 int ncolors;
1680{ 1589{
1681 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 1590 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
1682 1591
@@ -1700,9 +1609,7 @@ x_query_colors (f, colors, ncolors)
1700 COLOR. Use cached information, if available. */ 1609 COLOR. Use cached information, if available. */
1701 1610
1702void 1611void
1703x_query_color (f, color) 1612x_query_color (struct frame *f, XColor *color)
1704 struct frame *f;
1705 XColor *color;
1706{ 1613{
1707 x_query_colors (f, color, 1); 1614 x_query_colors (f, color, 1);
1708} 1615}
@@ -1714,10 +1621,7 @@ x_query_color (f, color)
1714 allocated. */ 1621 allocated. */
1715 1622
1716static int 1623static int
1717x_alloc_nearest_color_1 (dpy, cmap, color) 1624x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
1718 Display *dpy;
1719 Colormap cmap;
1720 XColor *color;
1721{ 1625{
1722 int rc; 1626 int rc;
1723 1627
@@ -1787,10 +1691,7 @@ x_alloc_nearest_color_1 (dpy, cmap, color)
1787 allocated. */ 1691 allocated. */
1788 1692
1789int 1693int
1790x_alloc_nearest_color (f, cmap, color) 1694x_alloc_nearest_color (struct frame *f, Colormap cmap, XColor *color)
1791 struct frame *f;
1792 Colormap cmap;
1793 XColor *color;
1794{ 1695{
1795 gamma_correct (f, color); 1696 gamma_correct (f, color);
1796 return x_alloc_nearest_color_1 (FRAME_X_DISPLAY (f), cmap, color); 1697 return x_alloc_nearest_color_1 (FRAME_X_DISPLAY (f), cmap, color);
@@ -1802,9 +1703,7 @@ x_alloc_nearest_color (f, cmap, color)
1802 get color reference counts right. */ 1703 get color reference counts right. */
1803 1704
1804unsigned long 1705unsigned long
1805x_copy_color (f, pixel) 1706x_copy_color (struct frame *f, long unsigned int pixel)
1806 struct frame *f;
1807 unsigned long pixel;
1808{ 1707{
1809 XColor color; 1708 XColor color;
1810 1709
@@ -1825,10 +1724,7 @@ x_copy_color (f, pixel)
1825 get color reference counts right. */ 1724 get color reference counts right. */
1826 1725
1827unsigned long 1726unsigned long
1828x_copy_dpy_color (dpy, cmap, pixel) 1727x_copy_dpy_color (Display *dpy, Colormap cmap, long unsigned int pixel)
1829 Display *dpy;
1830 Colormap cmap;
1831 unsigned long pixel;
1832{ 1728{
1833 XColor color; 1729 XColor color;
1834 1730
@@ -1866,13 +1762,7 @@ x_copy_dpy_color (dpy, cmap, pixel)
1866 Value is non-zero if successful. */ 1762 Value is non-zero if successful. */
1867 1763
1868static int 1764static int
1869x_alloc_lighter_color (f, display, cmap, pixel, factor, delta) 1765x_alloc_lighter_color (struct frame *f, Display *display, Colormap cmap, long unsigned int *pixel, double factor, int delta)
1870 struct frame *f;
1871 Display *display;
1872 Colormap cmap;
1873 unsigned long *pixel;
1874 double factor;
1875 int delta;
1876{ 1766{
1877 XColor color, new; 1767 XColor color, new;
1878 long bright; 1768 long bright;
@@ -1948,12 +1838,7 @@ x_alloc_lighter_color (f, display, cmap, pixel, factor, delta)
1948 be allocated, use DEFAULT_PIXEL, instead. */ 1838 be allocated, use DEFAULT_PIXEL, instead. */
1949 1839
1950static void 1840static void
1951x_setup_relief_color (f, relief, factor, delta, default_pixel) 1841x_setup_relief_color (struct frame *f, struct relief *relief, double factor, int delta, long unsigned int default_pixel)
1952 struct frame *f;
1953 struct relief *relief;
1954 double factor;
1955 int delta;
1956 unsigned long default_pixel;
1957{ 1842{
1958 XGCValues xgcv; 1843 XGCValues xgcv;
1959 struct x_output *di = f->output_data.x; 1844 struct x_output *di = f->output_data.x;
@@ -2001,8 +1886,7 @@ x_setup_relief_color (f, relief, factor, delta, default_pixel)
2001/* Set up colors for the relief lines around glyph string S. */ 1886/* Set up colors for the relief lines around glyph string S. */
2002 1887
2003static void 1888static void
2004x_setup_relief_colors (s) 1889x_setup_relief_colors (struct glyph_string *s)
2005 struct glyph_string *s;
2006{ 1890{
2007 struct x_output *di = s->f->output_data.x; 1891 struct x_output *di = s->f->output_data.x;
2008 unsigned long color; 1892 unsigned long color;
@@ -2043,12 +1927,10 @@ x_setup_relief_colors (s)
2043 when drawing. */ 1927 when drawing. */
2044 1928
2045static void 1929static void
2046x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, 1930x_draw_relief_rect (struct frame *f,
2047 raised_p, top_p, bot_p, left_p, right_p, clip_rect) 1931 int left_x, int top_y, int right_x, int bottom_y, int width,
2048 struct frame *f; 1932 int raised_p, int top_p, int bot_p, int left_p, int right_p,
2049 int left_x, top_y, right_x, bottom_y, width; 1933 XRectangle *clip_rect)
2050 int top_p, bot_p, left_p, right_p, raised_p;
2051 XRectangle *clip_rect;
2052{ 1934{
2053 Display *dpy = FRAME_X_DISPLAY (f); 1935 Display *dpy = FRAME_X_DISPLAY (f);
2054 Window window = FRAME_X_WINDOW (f); 1936 Window window = FRAME_X_WINDOW (f);
@@ -2106,11 +1988,9 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2106 rectangle to use when drawing. */ 1988 rectangle to use when drawing. */
2107 1989
2108static void 1990static void
2109x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width, 1991x_draw_box_rect (struct glyph_string *s,
2110 left_p, right_p, clip_rect) 1992 int left_x, int top_y, int right_x, int bottom_y, int width,
2111 struct glyph_string *s; 1993 int left_p, int right_p, XRectangle *clip_rect)
2112 int left_x, top_y, right_x, bottom_y, width, left_p, right_p;
2113 XRectangle *clip_rect;
2114{ 1994{
2115 XGCValues xgcv; 1995 XGCValues xgcv;
2116 1996
@@ -2144,8 +2024,7 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
2144/* Draw a box around glyph string S. */ 2024/* Draw a box around glyph string S. */
2145 2025
2146static void 2026static void
2147x_draw_glyph_string_box (s) 2027x_draw_glyph_string_box (struct glyph_string *s)
2148 struct glyph_string *s;
2149{ 2028{
2150 int width, left_x, right_x, top_y, bottom_y, last_x, raised_p; 2029 int width, left_x, right_x, top_y, bottom_y, last_x, raised_p;
2151 int left_p, right_p; 2030 int left_p, right_p;
@@ -2196,8 +2075,7 @@ x_draw_glyph_string_box (s)
2196/* Draw foreground of image glyph string S. */ 2075/* Draw foreground of image glyph string S. */
2197 2076
2198static void 2077static void
2199x_draw_image_foreground (s) 2078x_draw_image_foreground (struct glyph_string *s)
2200 struct glyph_string *s;
2201{ 2079{
2202 int x = s->x; 2080 int x = s->x;
2203 int y = s->ybase - image_ascent (s->img, s->face, &s->slice); 2081 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
@@ -2287,8 +2165,7 @@ x_draw_image_foreground (s)
2287/* Draw a relief around the image glyph string S. */ 2165/* Draw a relief around the image glyph string S. */
2288 2166
2289static void 2167static void
2290x_draw_image_relief (s) 2168x_draw_image_relief (struct glyph_string *s)
2291 struct glyph_string *s;
2292{ 2169{
2293 int x0, y0, x1, y1, thick, raised_p, extra; 2170 int x0, y0, x1, y1, thick, raised_p, extra;
2294 XRectangle r; 2171 XRectangle r;
@@ -2323,7 +2200,7 @@ x_draw_image_relief (s)
2323 2200
2324 extra = s->face->id == TOOL_BAR_FACE_ID 2201 extra = s->face->id == TOOL_BAR_FACE_ID
2325 ? XINT (Vtool_bar_button_margin) : 0; 2202 ? XINT (Vtool_bar_button_margin) : 0;
2326 2203
2327 x0 = x - thick - extra; 2204 x0 = x - thick - extra;
2328 y0 = y - thick - extra; 2205 y0 = y - thick - extra;
2329 x1 = x + s->slice.width + thick - 1 + extra; 2206 x1 = x + s->slice.width + thick - 1 + extra;
@@ -2343,9 +2220,7 @@ x_draw_image_relief (s)
2343/* Draw the foreground of image glyph string S to PIXMAP. */ 2220/* Draw the foreground of image glyph string S to PIXMAP. */
2344 2221
2345static void 2222static void
2346x_draw_image_foreground_1 (s, pixmap) 2223x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap)
2347 struct glyph_string *s;
2348 Pixmap pixmap;
2349{ 2224{
2350 int x = 0; 2225 int x = 0;
2351 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice); 2226 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
@@ -2420,10 +2295,8 @@ x_draw_image_foreground_1 (s, pixmap)
2420/* Draw part of the background of glyph string S. X, Y, W, and H 2295/* Draw part of the background of glyph string S. X, Y, W, and H
2421 give the rectangle to draw. */ 2296 give the rectangle to draw. */
2422 2297
2423 void 2298static void
2424x_draw_glyph_string_bg_rect (s, x, y, w, h) 2299x_draw_glyph_string_bg_rect (struct glyph_string *s, int x, int y, int w, int h)
2425 struct glyph_string *s;
2426 int x, y, w, h;
2427{ 2300{
2428 if (s->stippled_p) 2301 if (s->stippled_p)
2429 { 2302 {
@@ -2452,8 +2325,7 @@ x_draw_glyph_string_bg_rect (s, x, y, w, h)
2452 */ 2325 */
2453 2326
2454static void 2327static void
2455x_draw_image_glyph_string (s) 2328x_draw_image_glyph_string (struct glyph_string *s)
2456 struct glyph_string *s;
2457{ 2329{
2458 int box_line_hwidth = eabs (s->face->box_line_width); 2330 int box_line_hwidth = eabs (s->face->box_line_width);
2459 int box_line_vwidth = max (s->face->box_line_width, 0); 2331 int box_line_vwidth = max (s->face->box_line_width, 0);
@@ -2557,25 +2429,41 @@ x_draw_image_glyph_string (s)
2557/* Draw stretch glyph string S. */ 2429/* Draw stretch glyph string S. */
2558 2430
2559static void 2431static void
2560x_draw_stretch_glyph_string (s) 2432x_draw_stretch_glyph_string (struct glyph_string *s)
2561 struct glyph_string *s;
2562{ 2433{
2563 xassert (s->first_glyph->type == STRETCH_GLYPH); 2434 xassert (s->first_glyph->type == STRETCH_GLYPH);
2564 2435
2565 if (s->hl == DRAW_CURSOR 2436 if (s->hl == DRAW_CURSOR
2566 && !x_stretch_cursor_p) 2437 && !x_stretch_cursor_p)
2567 { 2438 {
2568 /* If `x-stretch-block-cursor' is nil, don't draw a block cursor 2439 /* If `x-stretch-cursor' is nil, don't draw a block cursor as
2569 as wide as the stretch glyph. */ 2440 wide as the stretch glyph. */
2570 int width, background_width = s->background_width; 2441 int width, background_width = s->background_width;
2571 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); 2442 int x = s->x;
2572 2443
2573 if (x < left_x) 2444 if (!s->row->reversed_p)
2574 { 2445 {
2575 background_width -= left_x - x; 2446 int left_x = window_box_left_offset (s->w, TEXT_AREA);
2576 x = left_x; 2447
2448 if (x < left_x)
2449 {
2450 background_width -= left_x - x;
2451 x = left_x;
2452 }
2453 }
2454 else
2455 {
2456 /* In R2L rows, draw the cursor on the right edge of the
2457 stretch glyph. */
2458 int right_x = window_box_right_offset (s->w, TEXT_AREA);
2459
2460 if (x + background_width > right_x)
2461 background_width -= x - right_x;
2462 x += background_width;
2577 } 2463 }
2578 width = min (FRAME_COLUMN_WIDTH (s->f), background_width); 2464 width = min (FRAME_COLUMN_WIDTH (s->f), background_width);
2465 if (s->row->reversed_p)
2466 x -= width;
2579 2467
2580 /* Draw cursor. */ 2468 /* Draw cursor. */
2581 x_draw_glyph_string_bg_rect (s, x, s->y, width, s->height); 2469 x_draw_glyph_string_bg_rect (s, x, s->y, width, s->height);
@@ -2588,7 +2476,10 @@ x_draw_stretch_glyph_string (s)
2588 XRectangle r; 2476 XRectangle r;
2589 GC gc; 2477 GC gc;
2590 2478
2591 x += width; 2479 if (!s->row->reversed_p)
2480 x += width;
2481 else
2482 x = s->x;
2592 if (s->row->mouse_face_p 2483 if (s->row->mouse_face_p
2593 && cursor_in_mouse_face_p (s->w)) 2484 && cursor_in_mouse_face_p (s->w))
2594 { 2485 {
@@ -2641,8 +2532,7 @@ x_draw_stretch_glyph_string (s)
2641/* Draw glyph string S. */ 2532/* Draw glyph string S. */
2642 2533
2643static void 2534static void
2644x_draw_glyph_string (s) 2535x_draw_glyph_string (struct glyph_string *s)
2645 struct glyph_string *s;
2646{ 2536{
2647 int relief_drawn_p = 0; 2537 int relief_drawn_p = 0;
2648 2538
@@ -2902,9 +2792,7 @@ x_draw_glyph_string (s)
2902/* Shift display to make room for inserted glyphs. */ 2792/* Shift display to make room for inserted glyphs. */
2903 2793
2904void 2794void
2905x_shift_glyphs_for_insert (f, x, y, width, height, shift_by) 2795x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height, int shift_by)
2906 struct frame *f;
2907 int x, y, width, height, shift_by;
2908{ 2796{
2909 XCopyArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), FRAME_X_WINDOW (f), 2797 XCopyArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), FRAME_X_WINDOW (f),
2910 f->output_data.x->normal_gc, 2798 f->output_data.x->normal_gc,
@@ -2916,9 +2804,7 @@ x_shift_glyphs_for_insert (f, x, y, width, height, shift_by)
2916 for X frames. */ 2804 for X frames. */
2917 2805
2918static void 2806static void
2919x_delete_glyphs (f, n) 2807x_delete_glyphs (struct frame *f, register int n)
2920 struct frame *f;
2921 register int n;
2922{ 2808{
2923 abort (); 2809 abort ();
2924} 2810}
@@ -2928,12 +2814,7 @@ x_delete_glyphs (f, n)
2928 If they are <= 0, this is probably an error. */ 2814 If they are <= 0, this is probably an error. */
2929 2815
2930void 2816void
2931x_clear_area (dpy, window, x, y, width, height, exposures) 2817x_clear_area (Display *dpy, Window window, int x, int y, int width, int height, int exposures)
2932 Display *dpy;
2933 Window window;
2934 int x, y;
2935 int width, height;
2936 int exposures;
2937{ 2818{
2938 xassert (width > 0 && height > 0); 2819 xassert (width > 0 && height > 0);
2939 XClearArea (dpy, window, x, y, width, height, exposures); 2820 XClearArea (dpy, window, x, y, width, height, exposures);
@@ -2963,9 +2844,10 @@ x_clear_frame (struct frame *f)
2963#if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS) 2844#if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)
2964 /* Make sure scroll bars are redrawn. As they aren't redrawn by 2845 /* Make sure scroll bars are redrawn. As they aren't redrawn by
2965 redisplay, do it here. */ 2846 redisplay, do it here. */
2966 gtk_widget_queue_draw (FRAME_GTK_WIDGET (f)); 2847 if (FRAME_GTK_WIDGET (f))
2848 gtk_widget_queue_draw (FRAME_GTK_WIDGET (f));
2967#endif 2849#endif
2968 2850
2969 XFlush (FRAME_X_DISPLAY (f)); 2851 XFlush (FRAME_X_DISPLAY (f));
2970 2852
2971 UNBLOCK_INPUT; 2853 UNBLOCK_INPUT;
@@ -2985,8 +2867,7 @@ x_clear_frame (struct frame *f)
2985 *RESULT. Return 1 if the difference is negative, otherwise 0. */ 2867 *RESULT. Return 1 if the difference is negative, otherwise 0. */
2986 2868
2987static int 2869static int
2988timeval_subtract (result, x, y) 2870timeval_subtract (struct timeval *result, struct timeval x, struct timeval y)
2989 struct timeval *result, x, y;
2990{ 2871{
2991 /* Perform the carry for the later subtraction by updating y. This 2872 /* Perform the carry for the later subtraction by updating y. This
2992 is safer because on some systems the tv_sec member is unsigned. */ 2873 is safer because on some systems the tv_sec member is unsigned. */
@@ -3015,8 +2896,7 @@ timeval_subtract (result, x, y)
3015} 2896}
3016 2897
3017void 2898void
3018XTflash (f) 2899XTflash (struct frame *f)
3019 struct frame *f;
3020{ 2900{
3021 BLOCK_INPUT; 2901 BLOCK_INPUT;
3022 2902
@@ -3024,18 +2904,16 @@ XTflash (f)
3024#ifdef USE_GTK 2904#ifdef USE_GTK
3025 /* Use Gdk routines to draw. This way, we won't draw over scroll bars 2905 /* Use Gdk routines to draw. This way, we won't draw over scroll bars
3026 when the scroll bars and the edit widget share the same X window. */ 2906 when the scroll bars and the edit widget share the same X window. */
2907 GdkWindow *window = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
3027 GdkGCValues vals; 2908 GdkGCValues vals;
3028 GdkGC *gc; 2909 GdkGC *gc;
3029 vals.foreground.pixel = (FRAME_FOREGROUND_PIXEL (f) 2910 vals.foreground.pixel = (FRAME_FOREGROUND_PIXEL (f)
3030 ^ FRAME_BACKGROUND_PIXEL (f)); 2911 ^ FRAME_BACKGROUND_PIXEL (f));
3031 vals.function = GDK_XOR; 2912 vals.function = GDK_XOR;
3032 gc = gdk_gc_new_with_values (FRAME_GTK_WIDGET (f)->window, 2913 gc = gdk_gc_new_with_values (window,
3033 &vals, 2914 &vals, GDK_GC_FUNCTION | GDK_GC_FOREGROUND);
3034 GDK_GC_FUNCTION
3035 | GDK_GC_FOREGROUND);
3036#define XFillRectangle(d, win, gc, x, y, w, h) \ 2915#define XFillRectangle(d, win, gc, x, y, w, h) \
3037 gdk_draw_rectangle (FRAME_GTK_WIDGET (f)->window, \ 2916 gdk_draw_rectangle (window, gc, TRUE, x, y, w, h)
3038 gc, TRUE, x, y, w, h)
3039#else 2917#else
3040 GC gc; 2918 GC gc;
3041 2919
@@ -3173,12 +3051,10 @@ XTflash (f)
3173 3051
3174 3052
3175static void 3053static void
3176XTtoggle_invisible_pointer (f, invisible) 3054XTtoggle_invisible_pointer (FRAME_PTR f, int invisible)
3177 FRAME_PTR f;
3178 int invisible;
3179{ 3055{
3180 BLOCK_INPUT; 3056 BLOCK_INPUT;
3181 if (invisible) 3057 if (invisible)
3182 { 3058 {
3183 if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor != 0) 3059 if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor != 0)
3184 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3060 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
@@ -3195,10 +3071,8 @@ XTtoggle_invisible_pointer (f, invisible)
3195/* Make audible bell. */ 3071/* Make audible bell. */
3196 3072
3197void 3073void
3198XTring_bell () 3074XTring_bell (struct frame *f)
3199{ 3075{
3200 struct frame *f = SELECTED_FRAME ();
3201
3202 if (FRAME_X_DISPLAY (f)) 3076 if (FRAME_X_DISPLAY (f))
3203 { 3077 {
3204#if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT) 3078#if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT)
@@ -3222,8 +3096,7 @@ XTring_bell ()
3222 that is bounded by calls to x_update_begin and x_update_end. */ 3096 that is bounded by calls to x_update_begin and x_update_end. */
3223 3097
3224static void 3098static void
3225XTset_terminal_window (n) 3099XTset_terminal_window (struct frame *f, int n)
3226 register int n;
3227{ 3100{
3228 /* This function intentionally left blank. */ 3101 /* This function intentionally left blank. */
3229} 3102}
@@ -3238,9 +3111,7 @@ XTset_terminal_window (n)
3238 lines or deleting -N lines at vertical position VPOS. */ 3111 lines or deleting -N lines at vertical position VPOS. */
3239 3112
3240static void 3113static void
3241x_ins_del_lines (f, vpos, n) 3114x_ins_del_lines (struct frame *f, int vpos, int n)
3242 struct frame *f;
3243 int vpos, n;
3244{ 3115{
3245 abort (); 3116 abort ();
3246} 3117}
@@ -3249,9 +3120,7 @@ x_ins_del_lines (f, vpos, n)
3249/* Scroll part of the display as described by RUN. */ 3120/* Scroll part of the display as described by RUN. */
3250 3121
3251static void 3122static void
3252x_scroll_run (w, run) 3123x_scroll_run (struct window *w, struct run *run)
3253 struct window *w;
3254 struct run *run;
3255{ 3124{
3256 struct frame *f = XFRAME (w->frame); 3125 struct frame *f = XFRAME (w->frame);
3257 int x, y, width, height, from_y, to_y, bottom_y; 3126 int x, y, width, height, from_y, to_y, bottom_y;
@@ -3308,8 +3177,7 @@ x_scroll_run (w, run)
3308 3177
3309 3178
3310static void 3179static void
3311frame_highlight (f) 3180frame_highlight (struct frame *f)
3312 struct frame *f;
3313{ 3181{
3314 /* We used to only do this if Vx_no_window_manager was non-nil, but 3182 /* We used to only do this if Vx_no_window_manager was non-nil, but
3315 the ICCCM (section 4.1.6) says that the window's border pixmap 3183 the ICCCM (section 4.1.6) says that the window's border pixmap
@@ -3324,8 +3192,7 @@ frame_highlight (f)
3324} 3192}
3325 3193
3326static void 3194static void
3327frame_unhighlight (f) 3195frame_unhighlight (struct frame *f)
3328 struct frame *f;
3329{ 3196{
3330 /* We used to only do this if Vx_no_window_manager was non-nil, but 3197 /* We used to only do this if Vx_no_window_manager was non-nil, but
3331 the ICCCM (section 4.1.6) says that the window's border pixmap 3198 the ICCCM (section 4.1.6) says that the window's border pixmap
@@ -3346,9 +3213,7 @@ frame_unhighlight (f)
3346 Lisp code can tell when the switch took place by examining the events. */ 3213 Lisp code can tell when the switch took place by examining the events. */
3347 3214
3348static void 3215static void
3349x_new_focus_frame (dpyinfo, frame) 3216x_new_focus_frame (struct x_display_info *dpyinfo, struct frame *frame)
3350 struct x_display_info *dpyinfo;
3351 struct frame *frame;
3352{ 3217{
3353 struct frame *old_focus = dpyinfo->x_focus_frame; 3218 struct frame *old_focus = dpyinfo->x_focus_frame;
3354 3219
@@ -3375,12 +3240,7 @@ x_new_focus_frame (dpyinfo, frame)
3375 a FOCUS_IN_EVENT into *BUFP. */ 3240 a FOCUS_IN_EVENT into *BUFP. */
3376 3241
3377static void 3242static void
3378x_focus_changed (type, state, dpyinfo, frame, bufp) 3243x_focus_changed (int type, int state, struct x_display_info *dpyinfo, struct frame *frame, struct input_event *bufp)
3379 int type;
3380 int state;
3381 struct x_display_info *dpyinfo;
3382 struct frame *frame;
3383 struct input_event *bufp;
3384{ 3244{
3385 if (type == FocusIn) 3245 if (type == FocusIn)
3386 { 3246 {
@@ -3432,10 +3292,7 @@ x_focus_changed (type, state, dpyinfo, frame, bufp)
3432 Returns FOCUS_IN_EVENT event in *BUFP. */ 3292 Returns FOCUS_IN_EVENT event in *BUFP. */
3433 3293
3434static void 3294static void
3435x_detect_focus_change (dpyinfo, event, bufp) 3295x_detect_focus_change (struct x_display_info *dpyinfo, XEvent *event, struct input_event *bufp)
3436 struct x_display_info *dpyinfo;
3437 XEvent *event;
3438 struct input_event *bufp;
3439{ 3296{
3440 struct frame *frame; 3297 struct frame *frame;
3441 3298
@@ -3484,8 +3341,7 @@ x_detect_focus_change (dpyinfo, event, bufp)
3484/* Handle an event saying the mouse has moved out of an Emacs frame. */ 3341/* Handle an event saying the mouse has moved out of an Emacs frame. */
3485 3342
3486void 3343void
3487x_mouse_leave (dpyinfo) 3344x_mouse_leave (struct x_display_info *dpyinfo)
3488 struct x_display_info *dpyinfo;
3489{ 3345{
3490 x_new_focus_frame (dpyinfo, dpyinfo->x_focus_event_frame); 3346 x_new_focus_frame (dpyinfo, dpyinfo->x_focus_event_frame);
3491} 3347}
@@ -3499,15 +3355,13 @@ x_mouse_leave (dpyinfo)
3499 the appropriate X display info. */ 3355 the appropriate X display info. */
3500 3356
3501static void 3357static void
3502XTframe_rehighlight (frame) 3358XTframe_rehighlight (struct frame *frame)
3503 struct frame *frame;
3504{ 3359{
3505 x_frame_rehighlight (FRAME_X_DISPLAY_INFO (frame)); 3360 x_frame_rehighlight (FRAME_X_DISPLAY_INFO (frame));
3506} 3361}
3507 3362
3508static void 3363static void
3509x_frame_rehighlight (dpyinfo) 3364x_frame_rehighlight (struct x_display_info *dpyinfo)
3510 struct x_display_info *dpyinfo;
3511{ 3365{
3512 struct frame *old_highlight = dpyinfo->x_highlight_frame; 3366 struct frame *old_highlight = dpyinfo->x_highlight_frame;
3513 3367
@@ -3541,8 +3395,7 @@ x_frame_rehighlight (dpyinfo)
3541 3395
3542/* Initialize mode_switch_bit and modifier_meaning. */ 3396/* Initialize mode_switch_bit and modifier_meaning. */
3543static void 3397static void
3544x_find_modifier_meanings (dpyinfo) 3398x_find_modifier_meanings (struct x_display_info *dpyinfo)
3545 struct x_display_info *dpyinfo;
3546{ 3399{
3547 int min_code, max_code; 3400 int min_code, max_code;
3548 KeySym *syms; 3401 KeySym *syms;
@@ -3653,9 +3506,7 @@ x_find_modifier_meanings (dpyinfo)
3653 Emacs uses. */ 3506 Emacs uses. */
3654 3507
3655unsigned int 3508unsigned int
3656x_x_to_emacs_modifiers (dpyinfo, state) 3509x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, unsigned int state)
3657 struct x_display_info *dpyinfo;
3658 unsigned int state;
3659{ 3510{
3660 EMACS_UINT mod_meta = meta_modifier; 3511 EMACS_UINT mod_meta = meta_modifier;
3661 EMACS_UINT mod_alt = alt_modifier; 3512 EMACS_UINT mod_alt = alt_modifier;
@@ -3682,9 +3533,7 @@ x_x_to_emacs_modifiers (dpyinfo, state)
3682} 3533}
3683 3534
3684static unsigned int 3535static unsigned int
3685x_emacs_to_x_modifiers (dpyinfo, state) 3536x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, unsigned int state)
3686 struct x_display_info *dpyinfo;
3687 unsigned int state;
3688{ 3537{
3689 EMACS_UINT mod_meta = meta_modifier; 3538 EMACS_UINT mod_meta = meta_modifier;
3690 EMACS_UINT mod_alt = alt_modifier; 3539 EMACS_UINT mod_alt = alt_modifier;
@@ -3714,8 +3563,7 @@ x_emacs_to_x_modifiers (dpyinfo, state)
3714/* Convert a keysym to its name. */ 3563/* Convert a keysym to its name. */
3715 3564
3716char * 3565char *
3717x_get_keysym_name (keysym) 3566x_get_keysym_name (int keysym)
3718 KeySym keysym;
3719{ 3567{
3720 char *value; 3568 char *value;
3721 3569
@@ -3736,10 +3584,7 @@ x_get_keysym_name (keysym)
3736 the mouse. */ 3584 the mouse. */
3737 3585
3738static Lisp_Object 3586static Lisp_Object
3739construct_mouse_click (result, event, f) 3587construct_mouse_click (struct input_event *result, XButtonEvent *event, struct frame *f)
3740 struct input_event *result;
3741 XButtonEvent *event;
3742 struct frame *f;
3743{ 3588{
3744 /* Make the event type NO_EVENT; we'll change that when we decide 3589 /* Make the event type NO_EVENT; we'll change that when we decide
3745 otherwise. */ 3590 otherwise. */
@@ -3772,9 +3617,7 @@ static XMotionEvent last_mouse_motion_event;
3772static Lisp_Object last_mouse_motion_frame; 3617static Lisp_Object last_mouse_motion_frame;
3773 3618
3774static int 3619static int
3775note_mouse_movement (frame, event) 3620note_mouse_movement (FRAME_PTR frame, XMotionEvent *event)
3776 FRAME_PTR frame;
3777 XMotionEvent *event;
3778{ 3621{
3779 last_mouse_movement_time = event->time; 3622 last_mouse_movement_time = event->time;
3780 last_mouse_motion_event = *event; 3623 last_mouse_motion_event = *event;
@@ -3818,7 +3661,7 @@ note_mouse_movement (frame, event)
3818 ************************************************************************/ 3661 ************************************************************************/
3819 3662
3820static void 3663static void
3821redo_mouse_highlight () 3664redo_mouse_highlight (void)
3822{ 3665{
3823 if (!NILP (last_mouse_motion_frame) 3666 if (!NILP (last_mouse_motion_frame)
3824 && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame))) 3667 && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame)))
@@ -3850,13 +3693,7 @@ redo_mouse_highlight ()
3850 movement. */ 3693 movement. */
3851 3694
3852static void 3695static void
3853XTmouse_position (fp, insist, bar_window, part, x, y, time) 3696XTmouse_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)
3854 FRAME_PTR *fp;
3855 int insist;
3856 Lisp_Object *bar_window;
3857 enum scroll_bar_part *part;
3858 Lisp_Object *x, *y;
3859 unsigned long *time;
3860{ 3697{
3861 FRAME_PTR f1; 3698 FRAME_PTR f1;
3862 3699
@@ -4058,9 +3895,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
4058 bits. */ 3895 bits. */
4059 3896
4060static struct scroll_bar * 3897static struct scroll_bar *
4061x_window_to_scroll_bar (display, window_id) 3898x_window_to_scroll_bar (Display *display, Window window_id)
4062 Display *display;
4063 Window window_id;
4064{ 3899{
4065 Lisp_Object tail; 3900 Lisp_Object tail;
4066 3901
@@ -4105,8 +3940,7 @@ x_window_to_scroll_bar (display, window_id)
4105 if WINDOW is not part of a menu bar. */ 3940 if WINDOW is not part of a menu bar. */
4106 3941
4107static Widget 3942static Widget
4108x_window_to_menu_bar (window) 3943x_window_to_menu_bar (Window window)
4109 Window window;
4110{ 3944{
4111 Lisp_Object tail; 3945 Lisp_Object tail;
4112 3946
@@ -4134,12 +3968,12 @@ x_window_to_menu_bar (window)
4134 3968
4135#ifdef USE_TOOLKIT_SCROLL_BARS 3969#ifdef USE_TOOLKIT_SCROLL_BARS
4136 3970
4137static void x_scroll_bar_to_input_event P_ ((XEvent *, struct input_event *)); 3971static void x_scroll_bar_to_input_event (XEvent *, struct input_event *);
4138static void x_send_scroll_bar_event P_ ((Lisp_Object, int, int, int)); 3972static void x_send_scroll_bar_event (Lisp_Object, int, int, int);
4139static void x_create_toolkit_scroll_bar P_ ((struct frame *, 3973static void x_create_toolkit_scroll_bar (struct frame *,
4140 struct scroll_bar *)); 3974 struct scroll_bar *);
4141static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *, 3975static void x_set_toolkit_scroll_bar_thumb (struct scroll_bar *,
4142 int, int, int)); 3976 int, int, int);
4143 3977
4144 3978
4145/* Lisp window being scrolled. Set when starting to interact with 3979/* Lisp window being scrolled. Set when starting to interact with
@@ -4173,14 +4007,8 @@ static Boolean xaw3d_pick_top;
4173 a `end-scroll' SCROLL_BAR_CLICK_EVENT' event if so. */ 4007 a `end-scroll' SCROLL_BAR_CLICK_EVENT' event if so. */
4174 4008
4175static void 4009static void
4176xt_action_hook (widget, client_data, action_name, event, params, 4010xt_action_hook (Widget widget, XtPointer client_data, String action_name,
4177 num_params) 4011 XEvent *event, String *params, Cardinal *num_params)
4178 Widget widget;
4179 XtPointer client_data;
4180 String action_name;
4181 XEvent *event;
4182 String *params;
4183 Cardinal *num_params;
4184{ 4012{
4185 int scroll_bar_p; 4013 int scroll_bar_p;
4186 char *end_action; 4014 char *end_action;
@@ -4231,9 +4059,7 @@ static int scroll_bar_windows_size;
4231 amount to scroll of a whole of WHOLE. */ 4059 amount to scroll of a whole of WHOLE. */
4232 4060
4233static void 4061static void
4234x_send_scroll_bar_event (window, part, portion, whole) 4062x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole)
4235 Lisp_Object window;
4236 int part, portion, whole;
4237{ 4063{
4238 XEvent event; 4064 XEvent event;
4239 XClientMessageEvent *ev = (XClientMessageEvent *) &event; 4065 XClientMessageEvent *ev = (XClientMessageEvent *) &event;
@@ -4266,7 +4092,7 @@ x_send_scroll_bar_event (window, part, portion, whole)
4266 4092
4267 scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows, 4093 scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows,
4268 nbytes); 4094 nbytes);
4269 bzero (&scroll_bar_windows[i], nbytes - old_nbytes); 4095 memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes);
4270 scroll_bar_windows_size = new_size; 4096 scroll_bar_windows_size = new_size;
4271 } 4097 }
4272 4098
@@ -4295,9 +4121,7 @@ x_send_scroll_bar_event (window, part, portion, whole)
4295 in *IEVENT. */ 4121 in *IEVENT. */
4296 4122
4297static void 4123static void
4298x_scroll_bar_to_input_event (event, ievent) 4124x_scroll_bar_to_input_event (XEvent *event, struct input_event *ievent)
4299 XEvent *event;
4300 struct input_event *ievent;
4301{ 4125{
4302 XClientMessageEvent *ev = (XClientMessageEvent *) event; 4126 XClientMessageEvent *ev = (XClientMessageEvent *) event;
4303 Lisp_Object window; 4127 Lisp_Object window;
@@ -4338,9 +4162,7 @@ x_scroll_bar_to_input_event (event, ievent)
4338 CALL_DATA is a pointer to a XmScrollBarCallbackStruct. */ 4162 CALL_DATA is a pointer to a XmScrollBarCallbackStruct. */
4339 4163
4340static void 4164static void
4341xm_scroll_callback (widget, client_data, call_data) 4165xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4342 Widget widget;
4343 XtPointer client_data, call_data;
4344{ 4166{
4345 struct scroll_bar *bar = (struct scroll_bar *) client_data; 4167 struct scroll_bar *bar = (struct scroll_bar *) client_data;
4346 XmScrollBarCallbackStruct *cs = (XmScrollBarCallbackStruct *) call_data; 4168 XmScrollBarCallbackStruct *cs = (XmScrollBarCallbackStruct *) call_data;
@@ -4435,7 +4257,8 @@ xg_scroll_callback (GtkRange *range,
4435 && FRAME_X_DISPLAY_INFO (f)->grabbed < (1 << 4)) 4257 && FRAME_X_DISPLAY_INFO (f)->grabbed < (1 << 4))
4436 { 4258 {
4437 part = scroll_bar_handle; 4259 part = scroll_bar_handle;
4438 whole = adj->upper - adj->page_size; 4260 whole = gtk_adjustment_get_upper (adj) -
4261 gtk_adjustment_get_page_size (adj);
4439 portion = min ((int)position, whole); 4262 portion = min ((int)position, whole);
4440 bar->dragging = make_number ((int)portion); 4263 bar->dragging = make_number ((int)portion);
4441 } 4264 }
@@ -4496,9 +4319,7 @@ xg_end_scroll_callback (GtkWidget *widget,
4496 the thumb is. */ 4319 the thumb is. */
4497 4320
4498static void 4321static void
4499xaw_jump_callback (widget, client_data, call_data) 4322xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4500 Widget widget;
4501 XtPointer client_data, call_data;
4502{ 4323{
4503 struct scroll_bar *bar = (struct scroll_bar *) client_data; 4324 struct scroll_bar *bar = (struct scroll_bar *) client_data;
4504 float top = *(float *) call_data; 4325 float top = *(float *) call_data;
@@ -4540,9 +4361,7 @@ xaw_jump_callback (widget, client_data, call_data)
4540 Values < height of scroll bar mean line-wise movement. */ 4361 Values < height of scroll bar mean line-wise movement. */
4541 4362
4542static void 4363static void
4543xaw_scroll_callback (widget, client_data, call_data) 4364xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4544 Widget widget;
4545 XtPointer client_data, call_data;
4546{ 4365{
4547 struct scroll_bar *bar = (struct scroll_bar *) client_data; 4366 struct scroll_bar *bar = (struct scroll_bar *) client_data;
4548 /* The position really is stored cast to a pointer. */ 4367 /* The position really is stored cast to a pointer. */
@@ -4580,11 +4399,9 @@ xaw_scroll_callback (widget, client_data, call_data)
4580 4399
4581#ifdef USE_GTK 4400#ifdef USE_GTK
4582static void 4401static void
4583x_create_toolkit_scroll_bar (f, bar) 4402x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
4584 struct frame *f;
4585 struct scroll_bar *bar;
4586{ 4403{
4587 char *scroll_bar_name = SCROLL_BAR_NAME; 4404 const char *scroll_bar_name = SCROLL_BAR_NAME;
4588 4405
4589 BLOCK_INPUT; 4406 BLOCK_INPUT;
4590 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback), 4407 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback),
@@ -4596,9 +4413,7 @@ x_create_toolkit_scroll_bar (f, bar)
4596#else /* not USE_GTK */ 4413#else /* not USE_GTK */
4597 4414
4598static void 4415static void
4599x_create_toolkit_scroll_bar (f, bar) 4416x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
4600 struct frame *f;
4601 struct scroll_bar *bar;
4602{ 4417{
4603 Window xwindow; 4418 Window xwindow;
4604 Widget widget; 4419 Widget widget;
@@ -4691,7 +4506,7 @@ x_create_toolkit_scroll_bar (f, bar)
4691 if (f->output_data.x->scroll_bar_top_shadow_pixel == -1) 4506 if (f->output_data.x->scroll_bar_top_shadow_pixel == -1)
4692 { 4507 {
4693 pixel = f->output_data.x->scroll_bar_background_pixel; 4508 pixel = f->output_data.x->scroll_bar_background_pixel;
4694 if (pixel != -1) 4509 if (pixel != -1)
4695 { 4510 {
4696 if (!x_alloc_lighter_color (f, FRAME_X_DISPLAY (f), 4511 if (!x_alloc_lighter_color (f, FRAME_X_DISPLAY (f),
4697 FRAME_X_COLORMAP (f), 4512 FRAME_X_COLORMAP (f),
@@ -4703,7 +4518,7 @@ x_create_toolkit_scroll_bar (f, bar)
4703 if (f->output_data.x->scroll_bar_bottom_shadow_pixel == -1) 4518 if (f->output_data.x->scroll_bar_bottom_shadow_pixel == -1)
4704 { 4519 {
4705 pixel = f->output_data.x->scroll_bar_background_pixel; 4520 pixel = f->output_data.x->scroll_bar_background_pixel;
4706 if (pixel != -1) 4521 if (pixel != -1)
4707 { 4522 {
4708 if (!x_alloc_lighter_color (f, FRAME_X_DISPLAY (f), 4523 if (!x_alloc_lighter_color (f, FRAME_X_DISPLAY (f),
4709 FRAME_X_COLORMAP (f), 4524 FRAME_X_COLORMAP (f),
@@ -4719,8 +4534,11 @@ x_create_toolkit_scroll_bar (f, bar)
4719 || f->output_data.x->scroll_bar_bottom_shadow_pixel == -1) 4534 || f->output_data.x->scroll_bar_bottom_shadow_pixel == -1)
4720 /* We tried to allocate a color for the top/bottom shadow, and 4535 /* We tried to allocate a color for the top/bottom shadow, and
4721 failed, so tell Xaw3d to use dithering instead. */ 4536 failed, so tell Xaw3d to use dithering instead. */
4537 /* But only if we have a small colormap. Xaw3d can allocate nice
4538 colors itself. */
4722 { 4539 {
4723 XtSetArg (av[ac], XtNbeNiceToColormap, True); 4540 XtSetArg (av[ac], XtNbeNiceToColormap,
4541 DefaultDepthOfScreen (FRAME_X_SCREEN (f)) < 16);
4724 ++ac; 4542 ++ac;
4725 } 4543 }
4726 else 4544 else
@@ -4798,18 +4616,15 @@ x_create_toolkit_scroll_bar (f, bar)
4798 4616
4799#ifdef USE_GTK 4617#ifdef USE_GTK
4800static void 4618static void
4801x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) 4619x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position, int whole)
4802 struct scroll_bar *bar;
4803 int portion, position, whole;
4804{ 4620{
4805 xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); 4621 xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole);
4806} 4622}
4807 4623
4808#else /* not USE_GTK */ 4624#else /* not USE_GTK */
4809static void 4625static void
4810x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) 4626x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position,
4811 struct scroll_bar *bar; 4627 int whole)
4812 int portion, position, whole;
4813{ 4628{
4814 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 4629 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
4815 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); 4630 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
@@ -4924,9 +4739,7 @@ x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
4924 scroll bar. */ 4739 scroll bar. */
4925 4740
4926static struct scroll_bar * 4741static struct scroll_bar *
4927x_scroll_bar_create (w, top, left, width, height) 4742x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
4928 struct window *w;
4929 int top, left, width, height;
4930{ 4743{
4931 struct frame *f = XFRAME (w->frame); 4744 struct frame *f = XFRAME (w->frame);
4932 struct scroll_bar *bar 4745 struct scroll_bar *bar
@@ -5040,10 +4853,7 @@ x_scroll_bar_create (w, top, left, width, height)
5040 to move to the very end of the buffer. */ 4853 to move to the very end of the buffer. */
5041 4854
5042static void 4855static void
5043x_scroll_bar_set_handle (bar, start, end, rebuild) 4856x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild)
5044 struct scroll_bar *bar;
5045 int start, end;
5046 int rebuild;
5047{ 4857{
5048 int dragging = ! NILP (bar->dragging); 4858 int dragging = ! NILP (bar->dragging);
5049 Window w = bar->x_window; 4859 Window w = bar->x_window;
@@ -5141,8 +4951,7 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
5141 nil. */ 4951 nil. */
5142 4952
5143static void 4953static void
5144x_scroll_bar_remove (bar) 4954x_scroll_bar_remove (struct scroll_bar *bar)
5145 struct scroll_bar *bar;
5146{ 4955{
5147 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 4956 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5148 BLOCK_INPUT; 4957 BLOCK_INPUT;
@@ -5170,9 +4979,7 @@ x_scroll_bar_remove (bar)
5170 create one. */ 4979 create one. */
5171 4980
5172static void 4981static void
5173XTset_vertical_scroll_bar (w, portion, whole, position) 4982XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int position)
5174 struct window *w;
5175 int portion, whole, position;
5176{ 4983{
5177 struct frame *f = XFRAME (w->frame); 4984 struct frame *f = XFRAME (w->frame);
5178 struct scroll_bar *bar; 4985 struct scroll_bar *bar;
@@ -5389,8 +5196,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
5389 `*redeem_scroll_bar_hook' is applied to its window before the judgment. */ 5196 `*redeem_scroll_bar_hook' is applied to its window before the judgment. */
5390 5197
5391static void 5198static void
5392XTcondemn_scroll_bars (frame) 5199XTcondemn_scroll_bars (FRAME_PTR frame)
5393 FRAME_PTR frame;
5394{ 5200{
5395 /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */ 5201 /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */
5396 while (! NILP (FRAME_SCROLL_BARS (frame))) 5202 while (! NILP (FRAME_SCROLL_BARS (frame)))
@@ -5411,8 +5217,7 @@ XTcondemn_scroll_bars (frame)
5411 Note that WINDOW isn't necessarily condemned at all. */ 5217 Note that WINDOW isn't necessarily condemned at all. */
5412 5218
5413static void 5219static void
5414XTredeem_scroll_bar (window) 5220XTredeem_scroll_bar (struct window *window)
5415 struct window *window;
5416{ 5221{
5417 struct scroll_bar *bar; 5222 struct scroll_bar *bar;
5418 struct frame *f; 5223 struct frame *f;
@@ -5457,8 +5262,7 @@ XTredeem_scroll_bar (window)
5457 last call to `*condemn_scroll_bars_hook'. */ 5262 last call to `*condemn_scroll_bars_hook'. */
5458 5263
5459static void 5264static void
5460XTjudge_scroll_bars (f) 5265XTjudge_scroll_bars (FRAME_PTR f)
5461 FRAME_PTR f;
5462{ 5266{
5463 Lisp_Object bar, next; 5267 Lisp_Object bar, next;
5464 5268
@@ -5491,9 +5295,7 @@ XTjudge_scroll_bars (f)
5491 mark bits. */ 5295 mark bits. */
5492 5296
5493static void 5297static void
5494x_scroll_bar_expose (bar, event) 5298x_scroll_bar_expose (struct scroll_bar *bar, XEvent *event)
5495 struct scroll_bar *bar;
5496 XEvent *event;
5497{ 5299{
5498 Window w = bar->x_window; 5300 Window w = bar->x_window;
5499 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 5301 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
@@ -5535,10 +5337,7 @@ x_scroll_bar_expose (bar, event)
5535 5337
5536 5338
5537static void 5339static void
5538x_scroll_bar_handle_click (bar, event, emacs_event) 5340x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event)
5539 struct scroll_bar *bar;
5540 XEvent *event;
5541 struct input_event *emacs_event;
5542{ 5341{
5543 if (! WINDOWP (bar->window)) 5342 if (! WINDOWP (bar->window))
5544 abort (); 5343 abort ();
@@ -5596,9 +5395,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
5596 mark bits. */ 5395 mark bits. */
5597 5396
5598static void 5397static void
5599x_scroll_bar_note_movement (bar, event) 5398x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event)
5600 struct scroll_bar *bar;
5601 XEvent *event;
5602{ 5399{
5603 FRAME_PTR f = XFRAME (XWINDOW (bar->window)->frame); 5400 FRAME_PTR f = XFRAME (XWINDOW (bar->window)->frame);
5604 5401
@@ -5628,12 +5425,7 @@ x_scroll_bar_note_movement (bar, event)
5628 on the scroll bar. */ 5425 on the scroll bar. */
5629 5426
5630static void 5427static void
5631x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) 5428x_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)
5632 FRAME_PTR *fp;
5633 Lisp_Object *bar_window;
5634 enum scroll_bar_part *part;
5635 Lisp_Object *x, *y;
5636 unsigned long *time;
5637{ 5429{
5638 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 5430 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
5639 Window w = bar->x_window; 5431 Window w = bar->x_window;
@@ -5705,8 +5497,7 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
5705 redraw them. */ 5497 redraw them. */
5706 5498
5707void 5499void
5708x_scroll_bar_clear (f) 5500x_scroll_bar_clear (FRAME_PTR f)
5709 FRAME_PTR f;
5710{ 5501{
5711#ifndef USE_TOOLKIT_SCROLL_BARS 5502#ifndef USE_TOOLKIT_SCROLL_BARS
5712 Lisp_Object bar; 5503 Lisp_Object bar;
@@ -5759,22 +5550,18 @@ struct x_display_info *XTread_socket_fake_io_error;
5759 5550
5760static struct x_display_info *next_noop_dpyinfo; 5551static struct x_display_info *next_noop_dpyinfo;
5761 5552
5762#define SET_SAVED_MENU_EVENT(size) \ 5553#define SET_SAVED_BUTTON_EVENT \
5763 do \ 5554 do \
5764 { \ 5555 { \
5765 if (f->output_data.x->saved_menu_event == 0) \ 5556 if (f->output_data.x->saved_menu_event == 0) \
5766 f->output_data.x->saved_menu_event \ 5557 f->output_data.x->saved_menu_event \
5767 = (XEvent *) xmalloc (sizeof (XEvent)); \ 5558 = (XEvent *) xmalloc (sizeof (XEvent)); \
5768 bcopy (&event, f->output_data.x->saved_menu_event, size); \ 5559 *f->output_data.x->saved_menu_event = event; \
5769 inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; \ 5560 inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; \
5770 XSETFRAME (inev.ie.frame_or_window, f); \ 5561 XSETFRAME (inev.ie.frame_or_window, f); \
5771 } \ 5562 } \
5772 while (0) 5563 while (0)
5773 5564
5774#define SET_SAVED_BUTTON_EVENT SET_SAVED_MENU_EVENT (sizeof (XButtonEvent))
5775#define SET_SAVED_KEY_EVENT SET_SAVED_MENU_EVENT (sizeof (XKeyEvent))
5776
5777
5778enum 5565enum
5779{ 5566{
5780 X_EVENT_NORMAL, 5567 X_EVENT_NORMAL,
@@ -5792,9 +5579,7 @@ enum
5792 5579
5793#ifdef HAVE_X_I18N 5580#ifdef HAVE_X_I18N
5794static int 5581static int
5795x_filter_event (dpyinfo, event) 5582x_filter_event (struct x_display_info *dpyinfo, XEvent *event)
5796 struct x_display_info *dpyinfo;
5797 XEvent *event;
5798{ 5583{
5799 /* XFilterEvent returns non-zero if the input method has 5584 /* XFilterEvent returns non-zero if the input method has
5800 consumed the event. We pass the frame's X window to 5585 consumed the event. We pass the frame's X window to
@@ -5817,10 +5602,7 @@ static struct input_event *current_hold_quit;
5817 It is invoked before the XEvent is translated to a GdkEvent, 5602 It is invoked before the XEvent is translated to a GdkEvent,
5818 so we have a chance to act on the event before GTK. */ 5603 so we have a chance to act on the event before GTK. */
5819static GdkFilterReturn 5604static GdkFilterReturn
5820event_handler_gdk (gxev, ev, data) 5605event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data)
5821 GdkXEvent *gxev;
5822 GdkEvent *ev;
5823 gpointer data;
5824{ 5606{
5825 XEvent *xev = (XEvent *) gxev; 5607 XEvent *xev = (XEvent *) gxev;
5826 5608
@@ -5873,11 +5655,7 @@ event_handler_gdk (gxev, ev, data)
5873 We return the number of characters stored into the buffer. */ 5655 We return the number of characters stored into the buffer. */
5874 5656
5875static int 5657static int
5876handle_one_xevent (dpyinfo, eventp, finish, hold_quit) 5658handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish, struct input_event *hold_quit)
5877 struct x_display_info *dpyinfo;
5878 XEvent *eventp;
5879 int *finish;
5880 struct input_event *hold_quit;
5881{ 5659{
5882 union { 5660 union {
5883 struct input_event ie; 5661 struct input_event ie;
@@ -5913,7 +5691,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5913 5691
5914 if (pending_event_wait.eventtype == event.type) 5692 if (pending_event_wait.eventtype == event.type)
5915 pending_event_wait.eventtype = 0; /* Indicates we got it. */ 5693 pending_event_wait.eventtype = 0; /* Indicates we got it. */
5916 5694
5917 switch (event.type) 5695 switch (event.type)
5918 { 5696 {
5919 case ClientMessage: 5697 case ClientMessage:
@@ -6430,7 +6208,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6430 this enables ComposeCharacter to work whether or 6208 this enables ComposeCharacter to work whether or
6431 not it is combined with Meta. */ 6209 not it is combined with Meta. */
6432 if (modifiers & dpyinfo->meta_mod_mask) 6210 if (modifiers & dpyinfo->meta_mod_mask)
6433 bzero (&compose_status, sizeof (compose_status)); 6211 memset (&compose_status, 0, sizeof (compose_status));
6434 6212
6435#ifdef HAVE_X_I18N 6213#ifdef HAVE_X_I18N
6436 if (FRAME_XIC (f)) 6214 if (FRAME_XIC (f))
@@ -6478,7 +6256,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6478 if (compose_status.chars_matched > 0 && nbytes == 0) 6256 if (compose_status.chars_matched > 0 && nbytes == 0)
6479 break; 6257 break;
6480 6258
6481 bzero (&compose_status, sizeof (compose_status)); 6259 memset (&compose_status, 0, sizeof (compose_status));
6482 orig_keysym = keysym; 6260 orig_keysym = keysym;
6483 6261
6484 /* Common for all keysym input events. */ 6262 /* Common for all keysym input events. */
@@ -6837,7 +6615,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6837 event.xconfigure.height); 6615 event.xconfigure.height);
6838 f = 0; 6616 f = 0;
6839 } 6617 }
6840#endif 6618#endif
6841 if (f) 6619 if (f)
6842 { 6620 {
6843#ifndef USE_X_TOOLKIT 6621#ifndef USE_X_TOOLKIT
@@ -6871,7 +6649,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6871 /* GTK creates windows but doesn't map them. 6649 /* GTK creates windows but doesn't map them.
6872 Only get real positions when mapped. */ 6650 Only get real positions when mapped. */
6873 if (FRAME_GTK_OUTER_WIDGET (f) 6651 if (FRAME_GTK_OUTER_WIDGET (f)
6874 && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f))) 6652 && gtk_widget_get_mapped (FRAME_GTK_OUTER_WIDGET (f)))
6875#endif 6653#endif
6876 { 6654 {
6877 x_real_positions (f, &f->left_pos, &f->top_pos); 6655 x_real_positions (f, &f->left_pos, &f->top_pos);
@@ -6892,7 +6670,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6892 by the rest of Emacs, we put it here. */ 6670 by the rest of Emacs, we put it here. */
6893 int tool_bar_p = 0; 6671 int tool_bar_p = 0;
6894 6672
6895 bzero (&compose_status, sizeof (compose_status)); 6673 memset (&compose_status, 0, sizeof (compose_status));
6896 last_mouse_glyph_frame = 0; 6674 last_mouse_glyph_frame = 0;
6897 last_user_time = event.xbutton.time; 6675 last_user_time = event.xbutton.time;
6898 6676
@@ -6990,20 +6768,18 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6990 f->mouse_moved = 0; 6768 f->mouse_moved = 0;
6991 6769
6992#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 6770#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
6993 f = x_menubar_window_to_frame (dpyinfo, event.xbutton.window); 6771 f = x_menubar_window_to_frame (dpyinfo, &event);
6994 /* For a down-event in the menu bar, 6772 /* For a down-event in the menu bar,
6995 don't pass it to Xt right now. 6773 don't pass it to Xt right now.
6996 Instead, save it away 6774 Instead, save it away
6997 and we will pass it to Xt from kbd_buffer_get_event. 6775 and we will pass it to Xt from kbd_buffer_get_event.
6998 That way, we can run some Lisp code first. */ 6776 That way, we can run some Lisp code first. */
6999 if ( 6777 if (! popup_activated ()
7000#ifdef USE_GTK 6778#ifdef USE_GTK
7001 ! popup_activated ()
7002 /* Gtk+ menus only react to the first three buttons. */ 6779 /* Gtk+ menus only react to the first three buttons. */
7003 && event.xbutton.button < 3 6780 && event.xbutton.button < 3
7004 &&
7005#endif 6781#endif
7006 f && event.type == ButtonPress 6782 && f && event.type == ButtonPress
7007 /* Verify the event is really within the menu bar 6783 /* Verify the event is really within the menu bar
7008 and not just sent to it due to grabbing. */ 6784 and not just sent to it due to grabbing. */
7009 && event.xbutton.x >= 0 6785 && event.xbutton.x >= 0
@@ -7014,30 +6790,13 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
7014 { 6790 {
7015 SET_SAVED_BUTTON_EVENT; 6791 SET_SAVED_BUTTON_EVENT;
7016 XSETFRAME (last_mouse_press_frame, f); 6792 XSETFRAME (last_mouse_press_frame, f);
7017#ifdef USE_GTK
7018 *finish = X_EVENT_DROP; 6793 *finish = X_EVENT_DROP;
7019#endif
7020 } 6794 }
7021 else if (event.type == ButtonPress) 6795 else if (event.type == ButtonPress)
7022 { 6796 {
7023 last_mouse_press_frame = Qnil; 6797 last_mouse_press_frame = Qnil;
7024 goto OTHER; 6798 goto OTHER;
7025 } 6799 }
7026
7027#ifdef USE_MOTIF /* This should do not harm for Lucid,
7028 but I am trying to be cautious. */
7029 else if (event.type == ButtonRelease)
7030 {
7031 if (!NILP (last_mouse_press_frame))
7032 {
7033 f = XFRAME (last_mouse_press_frame);
7034 if (f->output_data.x)
7035 SET_SAVED_BUTTON_EVENT;
7036 }
7037 else
7038 goto OTHER;
7039 }
7040#endif /* USE_MOTIF */
7041 else 6800 else
7042 goto OTHER; 6801 goto OTHER;
7043#endif /* USE_X_TOOLKIT || USE_GTK */ 6802#endif /* USE_X_TOOLKIT || USE_GTK */
@@ -7123,9 +6882,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
7123 6882
7124 Returns the value handle_one_xevent sets in the finish argument. */ 6883 Returns the value handle_one_xevent sets in the finish argument. */
7125int 6884int
7126x_dispatch_event (event, display) 6885x_dispatch_event (XEvent *event, Display *display)
7127 XEvent *event;
7128 Display *display;
7129{ 6886{
7130 struct x_display_info *dpyinfo; 6887 struct x_display_info *dpyinfo;
7131 int finish = X_EVENT_NORMAL; 6888 int finish = X_EVENT_NORMAL;
@@ -7151,10 +6908,7 @@ x_dispatch_event (event, display)
7151 EXPECTED is nonzero if the caller knows input is available. */ 6908 EXPECTED is nonzero if the caller knows input is available. */
7152 6909
7153static int 6910static int
7154XTread_socket (terminal, expected, hold_quit) 6911XTread_socket (struct terminal *terminal, int expected, struct input_event *hold_quit)
7155 struct terminal *terminal;
7156 int expected;
7157 struct input_event *hold_quit;
7158{ 6912{
7159 int count = 0; 6913 int count = 0;
7160 XEvent event; 6914 XEvent event;
@@ -7305,11 +7059,7 @@ XTread_socket (terminal, expected, hold_quit)
7305 mode lines must be clipped to the whole window. */ 7059 mode lines must be clipped to the whole window. */
7306 7060
7307static void 7061static void
7308x_clip_to_row (w, row, area, gc) 7062x_clip_to_row (struct window *w, struct glyph_row *row, int area, GC gc)
7309 struct window *w;
7310 struct glyph_row *row;
7311 int area;
7312 GC gc;
7313{ 7063{
7314 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7064 struct frame *f = XFRAME (WINDOW_FRAME (w));
7315 XRectangle clip_rect; 7065 XRectangle clip_rect;
@@ -7330,9 +7080,7 @@ x_clip_to_row (w, row, area, gc)
7330/* Draw a hollow box cursor on window W in glyph row ROW. */ 7080/* Draw a hollow box cursor on window W in glyph row ROW. */
7331 7081
7332static void 7082static void
7333x_draw_hollow_cursor (w, row) 7083x_draw_hollow_cursor (struct window *w, struct glyph_row *row)
7334 struct window *w;
7335 struct glyph_row *row;
7336{ 7084{
7337 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7085 struct frame *f = XFRAME (WINDOW_FRAME (w));
7338 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 7086 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
@@ -7377,11 +7125,7 @@ x_draw_hollow_cursor (w, row)
7377 --gerd. */ 7125 --gerd. */
7378 7126
7379static void 7127static void
7380x_draw_bar_cursor (w, row, width, kind) 7128x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text_cursor_kinds kind)
7381 struct window *w;
7382 struct glyph_row *row;
7383 int width;
7384 enum text_cursor_kinds kind;
7385{ 7129{
7386 struct frame *f = XFRAME (w->frame); 7130 struct frame *f = XFRAME (w->frame);
7387 struct glyph *cursor_glyph; 7131 struct glyph *cursor_glyph;
@@ -7434,14 +7178,20 @@ x_draw_bar_cursor (w, row, width, kind)
7434 7178
7435 if (kind == BAR_CURSOR) 7179 if (kind == BAR_CURSOR)
7436 { 7180 {
7181 int x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
7182
7437 if (width < 0) 7183 if (width < 0)
7438 width = FRAME_CURSOR_WIDTH (f); 7184 width = FRAME_CURSOR_WIDTH (f);
7439 width = min (cursor_glyph->pixel_width, width); 7185 width = min (cursor_glyph->pixel_width, width);
7440 7186
7441 w->phys_cursor_width = width; 7187 w->phys_cursor_width = width;
7442 7188
7443 XFillRectangle (dpy, window, gc, 7189 /* If the character under cursor is R2L, draw the bar cursor
7444 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x), 7190 on the right of its glyph, rather than on the left. */
7191 if ((cursor_glyph->resolved_level & 1) != 0)
7192 x += cursor_glyph->pixel_width - width;
7193
7194 XFillRectangle (dpy, window, gc, x,
7445 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), 7195 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
7446 width, row->height); 7196 width, row->height);
7447 } 7197 }
@@ -7472,9 +7222,7 @@ x_draw_bar_cursor (w, row, width, kind)
7472/* RIF: Define cursor CURSOR on frame F. */ 7222/* RIF: Define cursor CURSOR on frame F. */
7473 7223
7474static void 7224static void
7475x_define_frame_cursor (f, cursor) 7225x_define_frame_cursor (struct frame *f, Cursor cursor)
7476 struct frame *f;
7477 Cursor cursor;
7478{ 7226{
7479 if (!f->pointer_invisible 7227 if (!f->pointer_invisible
7480 && f->output_data.x->current_cursor != cursor) 7228 && f->output_data.x->current_cursor != cursor)
@@ -7486,9 +7234,7 @@ x_define_frame_cursor (f, cursor)
7486/* RIF: Clear area on frame F. */ 7234/* RIF: Clear area on frame F. */
7487 7235
7488static void 7236static void
7489x_clear_frame_area (f, x, y, width, height) 7237x_clear_frame_area (struct frame *f, int x, int y, int width, int height)
7490 struct frame *f;
7491 int x, y, width, height;
7492{ 7238{
7493 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 7239 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
7494 x, y, width, height, False); 7240 x, y, width, height, False);
@@ -7503,12 +7249,7 @@ x_clear_frame_area (f, x, y, width, height)
7503/* RIF: Draw cursor on window W. */ 7249/* RIF: Draw cursor on window W. */
7504 7250
7505static void 7251static void
7506x_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, active_p) 7252x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int y, int cursor_type, int cursor_width, int on_p, int active_p)
7507 struct window *w;
7508 struct glyph_row *glyph_row;
7509 int x, y;
7510 int cursor_type, cursor_width;
7511 int on_p, active_p;
7512{ 7253{
7513 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7254 struct frame *f = XFRAME (WINDOW_FRAME (w));
7514 7255
@@ -7572,9 +7313,7 @@ x_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, activ
7572/* Make the x-window of frame F use the gnu icon bitmap. */ 7313/* Make the x-window of frame F use the gnu icon bitmap. */
7573 7314
7574int 7315int
7575x_bitmap_icon (f, file) 7316x_bitmap_icon (struct frame *f, Lisp_Object file)
7576 struct frame *f;
7577 Lisp_Object file;
7578{ 7317{
7579 int bitmap_id; 7318 int bitmap_id;
7580 7319
@@ -7651,9 +7390,7 @@ x_bitmap_icon (f, file)
7651 Use ICON_NAME as the text. */ 7390 Use ICON_NAME as the text. */
7652 7391
7653int 7392int
7654x_text_icon (f, icon_name) 7393x_text_icon (struct frame *f, const char *icon_name)
7655 struct frame *f;
7656 char *icon_name;
7657{ 7394{
7658 if (FRAME_X_WINDOW (f) == 0) 7395 if (FRAME_X_WINDOW (f) == 0)
7659 return 1; 7396 return 1;
@@ -7696,9 +7433,7 @@ static struct x_error_message_stack *x_error_message;
7696 x_catch_errors is in effect. */ 7433 x_catch_errors is in effect. */
7697 7434
7698static void 7435static void
7699x_error_catcher (display, error) 7436x_error_catcher (Display *display, XErrorEvent *error)
7700 Display *display;
7701 XErrorEvent *error;
7702{ 7437{
7703 XGetErrorText (display, error->error_code, 7438 XGetErrorText (display, error->error_code,
7704 x_error_message->string, 7439 x_error_message->string,
@@ -7718,11 +7453,10 @@ x_error_catcher (display, error)
7718 7453
7719 Calling x_uncatch_errors resumes the normal error handling. */ 7454 Calling x_uncatch_errors resumes the normal error handling. */
7720 7455
7721void x_check_errors (); 7456void x_check_errors (Display *dpy, const char *format);
7722 7457
7723void 7458void
7724x_catch_errors (dpy) 7459x_catch_errors (Display *dpy)
7725 Display *dpy;
7726{ 7460{
7727 struct x_error_message_stack *data = xmalloc (sizeof (*data)); 7461 struct x_error_message_stack *data = xmalloc (sizeof (*data));
7728 7462
@@ -7739,7 +7473,7 @@ x_catch_errors (dpy)
7739 DPY should be the display that was passed to x_catch_errors. */ 7473 DPY should be the display that was passed to x_catch_errors. */
7740 7474
7741void 7475void
7742x_uncatch_errors () 7476x_uncatch_errors (void)
7743{ 7477{
7744 struct x_error_message_stack *tmp; 7478 struct x_error_message_stack *tmp;
7745 7479
@@ -7761,9 +7495,7 @@ x_uncatch_errors ()
7761 sprintf (a buffer, FORMAT, the x error message text) as the text. */ 7495 sprintf (a buffer, FORMAT, the x error message text) as the text. */
7762 7496
7763void 7497void
7764x_check_errors (dpy, format) 7498x_check_errors (Display *dpy, const char *format)
7765 Display *dpy;
7766 char *format;
7767{ 7499{
7768 /* Make sure to catch any errors incurred so far. */ 7500 /* Make sure to catch any errors incurred so far. */
7769 XSync (dpy, False); 7501 XSync (dpy, False);
@@ -7771,7 +7503,7 @@ x_check_errors (dpy, format)
7771 if (x_error_message->string[0]) 7503 if (x_error_message->string[0])
7772 { 7504 {
7773 char string[X_ERROR_MESSAGE_SIZE]; 7505 char string[X_ERROR_MESSAGE_SIZE];
7774 bcopy (x_error_message->string, string, X_ERROR_MESSAGE_SIZE); 7506 memcpy (string, x_error_message->string, X_ERROR_MESSAGE_SIZE);
7775 x_uncatch_errors (); 7507 x_uncatch_errors ();
7776 error (format, string); 7508 error (format, string);
7777 } 7509 }
@@ -7781,8 +7513,7 @@ x_check_errors (dpy, format)
7781 since we did x_catch_errors on DPY. */ 7513 since we did x_catch_errors on DPY. */
7782 7514
7783int 7515int
7784x_had_errors_p (dpy) 7516x_had_errors_p (Display *dpy)
7785 Display *dpy;
7786{ 7517{
7787 /* Make sure to catch any errors incurred so far. */ 7518 /* Make sure to catch any errors incurred so far. */
7788 XSync (dpy, False); 7519 XSync (dpy, False);
@@ -7793,8 +7524,7 @@ x_had_errors_p (dpy)
7793/* Forget about any errors we have had, since we did x_catch_errors on DPY. */ 7524/* Forget about any errors we have had, since we did x_catch_errors on DPY. */
7794 7525
7795void 7526void
7796x_clear_errors (dpy) 7527x_clear_errors (Display *dpy)
7797 Display *dpy;
7798{ 7528{
7799 x_error_message->string[0] = 0; 7529 x_error_message->string[0] = 0;
7800} 7530}
@@ -7804,7 +7534,7 @@ x_clear_errors (dpy)
7804/* Close off all unclosed x_catch_errors calls. */ 7534/* Close off all unclosed x_catch_errors calls. */
7805 7535
7806void 7536void
7807x_fully_uncatch_errors () 7537x_fully_uncatch_errors (void)
7808{ 7538{
7809 while (x_error_message) 7539 while (x_error_message)
7810 x_uncatch_errors (); 7540 x_uncatch_errors ();
@@ -7814,14 +7544,14 @@ x_fully_uncatch_errors ()
7814/* Nonzero if x_catch_errors has been done and not yet canceled. */ 7544/* Nonzero if x_catch_errors has been done and not yet canceled. */
7815 7545
7816int 7546int
7817x_catching_errors () 7547x_catching_errors (void)
7818{ 7548{
7819 return x_error_message != 0; 7549 return x_error_message != 0;
7820} 7550}
7821 7551
7822#if 0 7552#if 0
7823static unsigned int x_wire_count; 7553static unsigned int x_wire_count;
7824x_trace_wire () 7554x_trace_wire (void)
7825{ 7555{
7826 fprintf (stderr, "Lib call: %d\n", ++x_wire_count); 7556 fprintf (stderr, "Lib call: %d\n", ++x_wire_count);
7827} 7557}
@@ -7835,8 +7565,8 @@ x_trace_wire ()
7835 which will do the appropriate cleanup for us. */ 7565 which will do the appropriate cleanup for us. */
7836 7566
7837static SIGTYPE 7567static SIGTYPE
7838x_connection_signal (signalnum) /* If we don't have an argument, */ 7568x_connection_signal (int signalnum) /* If we don't have an argument, */
7839 int signalnum; /* some compilers complain in signal calls. */ 7569 /* some compilers complain in signal calls. */
7840{ 7570{
7841#ifdef USG 7571#ifdef USG
7842 /* USG systems forget handlers when they are used; 7572 /* USG systems forget handlers when they are used;
@@ -7859,7 +7589,7 @@ static char *error_msg;
7859 instead of dumping core when XtCloseDisplay fails. */ 7589 instead of dumping core when XtCloseDisplay fails. */
7860 7590
7861static void 7591static void
7862x_fatal_error_signal () 7592x_fatal_error_signal (void)
7863{ 7593{
7864 fprintf (stderr, "%s\n", error_msg); 7594 fprintf (stderr, "%s\n", error_msg);
7865 exit (70); 7595 exit (70);
@@ -7869,9 +7599,7 @@ x_fatal_error_signal ()
7869 the text of an error message that lead to the connection loss. */ 7599 the text of an error message that lead to the connection loss. */
7870 7600
7871static SIGTYPE 7601static SIGTYPE
7872x_connection_closed (dpy, error_message) 7602x_connection_closed (Display *dpy, const char *error_message)
7873 Display *dpy;
7874 char *error_message;
7875{ 7603{
7876 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 7604 struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
7877 Lisp_Object frame, tail; 7605 Lisp_Object frame, tail;
@@ -7946,7 +7674,6 @@ x_connection_closed (dpy, error_message)
7946 /* If DPYINFO is null, this means we didn't open the display 7674 /* If DPYINFO is null, this means we didn't open the display
7947 in the first place, so don't try to close it. */ 7675 in the first place, so don't try to close it. */
7948 { 7676 {
7949 extern void (*fatal_error_signal_hook) P_ ((void));
7950 fatal_error_signal_hook = x_fatal_error_signal; 7677 fatal_error_signal_hook = x_fatal_error_signal;
7951 XtCloseDisplay (dpy); 7678 XtCloseDisplay (dpy);
7952 fatal_error_signal_hook = NULL; 7679 fatal_error_signal_hook = NULL;
@@ -8007,15 +7734,13 @@ x_connection_closed (dpy, error_message)
8007 7734
8008/* We specifically use it before defining it, so that gcc doesn't inline it, 7735/* We specifically use it before defining it, so that gcc doesn't inline it,
8009 otherwise gdb doesn't know how to properly put a breakpoint on it. */ 7736 otherwise gdb doesn't know how to properly put a breakpoint on it. */
8010static void x_error_quitter P_ ((Display *, XErrorEvent *)); 7737static void x_error_quitter (Display *, XErrorEvent *);
8011 7738
8012/* This is the first-level handler for X protocol errors. 7739/* This is the first-level handler for X protocol errors.
8013 It calls x_error_quitter or x_error_catcher. */ 7740 It calls x_error_quitter or x_error_catcher. */
8014 7741
8015static int 7742static int
8016x_error_handler (display, error) 7743x_error_handler (Display *display, XErrorEvent *error)
8017 Display *display;
8018 XErrorEvent *error;
8019{ 7744{
8020 if (x_error_message) 7745 if (x_error_message)
8021 x_error_catcher (display, error); 7746 x_error_catcher (display, error);
@@ -8046,9 +7771,7 @@ x_error_handler (display, error)
8046 after x_error_handler prevents inlining into the former. */ 7771 after x_error_handler prevents inlining into the former. */
8047 7772
8048static void NO_INLINE 7773static void NO_INLINE
8049x_error_quitter (display, error) 7774x_error_quitter (Display *display, XErrorEvent *error)
8050 Display *display;
8051 XErrorEvent *error;
8052{ 7775{
8053 char buf[256], buf1[356]; 7776 char buf[256], buf1[356];
8054 7777
@@ -8073,8 +7796,7 @@ x_error_quitter (display, error)
8073 If that was the only one, it prints an error message and kills Emacs. */ 7796 If that was the only one, it prints an error message and kills Emacs. */
8074 7797
8075static int 7798static int
8076x_io_error_quitter (display) 7799x_io_error_quitter (Display *display)
8077 Display *display;
8078{ 7800{
8079 char buf[256]; 7801 char buf[256];
8080 7802
@@ -8091,10 +7813,7 @@ x_io_error_quitter (display)
8091 FONT-OBJECT. */ 7813 FONT-OBJECT. */
8092 7814
8093Lisp_Object 7815Lisp_Object
8094x_new_font (f, font_object, fontset) 7816x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
8095 struct frame *f;
8096 Lisp_Object font_object;
8097 int fontset;
8098{ 7817{
8099 struct font *font = XFONT_OBJECT (font_object); 7818 struct font *font = XFONT_OBJECT (font_object);
8100 7819
@@ -8163,10 +7882,7 @@ x_new_font (f, font_object, fontset)
8163 pointer to the x_display_info structure corresponding to XIM. */ 7882 pointer to the x_display_info structure corresponding to XIM. */
8164 7883
8165static void 7884static void
8166xim_destroy_callback (xim, client_data, call_data) 7885xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data)
8167 XIM xim;
8168 XPointer client_data;
8169 XPointer call_data;
8170{ 7886{
8171 struct x_display_info *dpyinfo = (struct x_display_info *) client_data; 7887 struct x_display_info *dpyinfo = (struct x_display_info *) client_data;
8172 Lisp_Object frame, tail; 7888 Lisp_Object frame, tail;
@@ -8194,16 +7910,14 @@ xim_destroy_callback (xim, client_data, call_data)
8194 7910
8195#ifdef HAVE_X11R6 7911#ifdef HAVE_X11R6
8196/* This isn't prototyped in OSF 5.0 or 5.1a. */ 7912/* This isn't prototyped in OSF 5.0 or 5.1a. */
8197extern char *XSetIMValues P_ ((XIM, ...)); 7913extern char *XSetIMValues (XIM, ...);
8198#endif 7914#endif
8199 7915
8200/* Open the connection to the XIM server on display DPYINFO. 7916/* Open the connection to the XIM server on display DPYINFO.
8201 RESOURCE_NAME is the resource name Emacs uses. */ 7917 RESOURCE_NAME is the resource name Emacs uses. */
8202 7918
8203static void 7919static void
8204xim_open_dpy (dpyinfo, resource_name) 7920xim_open_dpy (struct x_display_info *dpyinfo, char *resource_name)
8205 struct x_display_info *dpyinfo;
8206 char *resource_name;
8207{ 7921{
8208 XIM xim; 7922 XIM xim;
8209 7923
@@ -8213,7 +7927,7 @@ xim_open_dpy (dpyinfo, resource_name)
8213 if (dpyinfo->xim) 7927 if (dpyinfo->xim)
8214 XCloseIM (dpyinfo->xim); 7928 XCloseIM (dpyinfo->xim);
8215 xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, 7929 xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name,
8216 EMACS_CLASS); 7930 emacs_class);
8217 dpyinfo->xim = xim; 7931 dpyinfo->xim = xim;
8218 7932
8219 if (xim) 7933 if (xim)
@@ -8247,10 +7961,7 @@ xim_open_dpy (dpyinfo, resource_name)
8247 when the callback was registered. */ 7961 when the callback was registered. */
8248 7962
8249static void 7963static void
8250xim_instantiate_callback (display, client_data, call_data) 7964xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_data)
8251 Display *display;
8252 XPointer client_data;
8253 XPointer call_data;
8254{ 7965{
8255 struct xim_inst_t *xim_inst = (struct xim_inst_t *) client_data; 7966 struct xim_inst_t *xim_inst = (struct xim_inst_t *) client_data;
8256 struct x_display_info *dpyinfo = xim_inst->dpyinfo; 7967 struct x_display_info *dpyinfo = xim_inst->dpyinfo;
@@ -8300,9 +8011,7 @@ xim_instantiate_callback (display, client_data, call_data)
8300 in the XIM instantiate callback function. */ 8011 in the XIM instantiate callback function. */
8301 8012
8302static void 8013static void
8303xim_initialize (dpyinfo, resource_name) 8014xim_initialize (struct x_display_info *dpyinfo, char *resource_name)
8304 struct x_display_info *dpyinfo;
8305 char *resource_name;
8306{ 8015{
8307 dpyinfo->xim = NULL; 8016 dpyinfo->xim = NULL;
8308#ifdef HAVE_XIM 8017#ifdef HAVE_XIM
@@ -8317,9 +8026,9 @@ xim_initialize (dpyinfo, resource_name)
8317 xim_inst->dpyinfo = dpyinfo; 8026 xim_inst->dpyinfo = dpyinfo;
8318 len = strlen (resource_name); 8027 len = strlen (resource_name);
8319 xim_inst->resource_name = (char *) xmalloc (len + 1); 8028 xim_inst->resource_name = (char *) xmalloc (len + 1);
8320 bcopy (resource_name, xim_inst->resource_name, len + 1); 8029 memcpy (xim_inst->resource_name, resource_name, len + 1);
8321 XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, 8030 XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
8322 resource_name, EMACS_CLASS, 8031 resource_name, emacs_class,
8323 xim_instantiate_callback, 8032 xim_instantiate_callback,
8324 /* This is XPointer in XFree86 8033 /* This is XPointer in XFree86
8325 but (XPointer *) on Tru64, at 8034 but (XPointer *) on Tru64, at
@@ -8336,8 +8045,7 @@ xim_initialize (dpyinfo, resource_name)
8336/* Close the connection to the XIM server on display DPYINFO. */ 8045/* Close the connection to the XIM server on display DPYINFO. */
8337 8046
8338static void 8047static void
8339xim_close_dpy (dpyinfo) 8048xim_close_dpy (struct x_display_info *dpyinfo)
8340 struct x_display_info *dpyinfo;
8341{ 8049{
8342#ifdef HAVE_XIM 8050#ifdef HAVE_XIM
8343 if (use_xim) 8051 if (use_xim)
@@ -8345,7 +8053,7 @@ xim_close_dpy (dpyinfo)
8345#ifdef HAVE_X11R6_XIM 8053#ifdef HAVE_X11R6_XIM
8346 if (dpyinfo->display) 8054 if (dpyinfo->display)
8347 XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, 8055 XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
8348 NULL, EMACS_CLASS, 8056 NULL, emacs_class,
8349 xim_instantiate_callback, NULL); 8057 xim_instantiate_callback, NULL);
8350 xfree (dpyinfo->xim_callback_data->resource_name); 8058 xfree (dpyinfo->xim_callback_data->resource_name);
8351 xfree (dpyinfo->xim_callback_data); 8059 xfree (dpyinfo->xim_callback_data);
@@ -8366,8 +8074,7 @@ xim_close_dpy (dpyinfo)
8366 from its current recorded position values and gravity. */ 8074 from its current recorded position values and gravity. */
8367 8075
8368void 8076void
8369x_calc_absolute_position (f) 8077x_calc_absolute_position (struct frame *f)
8370 struct frame *f;
8371{ 8078{
8372 int flags = f->size_hint_flags; 8079 int flags = f->size_hint_flags;
8373 8080
@@ -8419,10 +8126,7 @@ x_calc_absolute_position (f)
8419 which means, do adjust for borders but don't change the gravity. */ 8126 which means, do adjust for borders but don't change the gravity. */
8420 8127
8421void 8128void
8422x_set_offset (f, xoff, yoff, change_gravity) 8129x_set_offset (struct frame *f, register int xoff, register int yoff, int change_gravity)
8423 struct frame *f;
8424 register int xoff, yoff;
8425 int change_gravity;
8426{ 8130{
8427 int modified_top, modified_left; 8131 int modified_top, modified_left;
8428 8132
@@ -8491,9 +8195,7 @@ x_set_offset (f, xoff, yoff, change_gravity)
8491 http://freedesktop.org/wiki/Specifications/wm-spec. */ 8195 http://freedesktop.org/wiki/Specifications/wm-spec. */
8492 8196
8493static int 8197static int
8494wm_supports (f, atomname) 8198wm_supports (struct frame *f, const char *atomname)
8495 struct frame *f;
8496 const char *atomname;
8497{ 8199{
8498 Atom actual_type; 8200 Atom actual_type;
8499 unsigned long actual_size, bytes_remaining; 8201 unsigned long actual_size, bytes_remaining;
@@ -8582,11 +8284,7 @@ wm_supports (f, atomname)
8582} 8284}
8583 8285
8584static void 8286static void
8585set_wm_state (frame, add, what, what2) 8287set_wm_state (Lisp_Object frame, int add, const char *what, const char *what2)
8586 Lisp_Object frame;
8587 int add;
8588 const char *what;
8589 const char *what2;
8590{ 8288{
8591 const char *atom = "_NET_WM_STATE"; 8289 const char *atom = "_NET_WM_STATE";
8592 Fx_send_client_event (frame, make_number (0), frame, 8290 Fx_send_client_event (frame, make_number (0), frame,
@@ -8604,9 +8302,7 @@ set_wm_state (frame, add, what, what2)
8604} 8302}
8605 8303
8606void 8304void
8607x_set_sticky (f, new_value, old_value) 8305x_set_sticky (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
8608 struct frame *f;
8609 Lisp_Object new_value, old_value;
8610{ 8306{
8611 Lisp_Object frame; 8307 Lisp_Object frame;
8612 8308
@@ -8618,8 +8314,7 @@ x_set_sticky (f, new_value, old_value)
8618/* Do fullscreen as specified in extended window manager hints */ 8314/* Do fullscreen as specified in extended window manager hints */
8619 8315
8620static int 8316static int
8621do_ewmh_fullscreen (f) 8317do_ewmh_fullscreen (struct frame *f)
8622 struct frame *f;
8623{ 8318{
8624 int have_net_atom = wm_supports (f, "_NET_WM_STATE"); 8319 int have_net_atom = wm_supports (f, "_NET_WM_STATE");
8625 8320
@@ -8640,7 +8335,7 @@ do_ewmh_fullscreen (f)
8640 set_wm_state (frame, 0, fs, NULL); 8335 set_wm_state (frame, 0, fs, NULL);
8641 set_wm_state (frame, 0, fh, NULL); 8336 set_wm_state (frame, 0, fh, NULL);
8642 set_wm_state (frame, 0, fw, NULL); 8337 set_wm_state (frame, 0, fw, NULL);
8643 8338
8644 /* If there are _NET_ atoms we assume we have extended window manager 8339 /* If there are _NET_ atoms we assume we have extended window manager
8645 hints. */ 8340 hints. */
8646 switch (f->want_fullscreen) 8341 switch (f->want_fullscreen)
@@ -8667,8 +8362,7 @@ do_ewmh_fullscreen (f)
8667} 8362}
8668 8363
8669static void 8364static void
8670XTfullscreen_hook (f) 8365XTfullscreen_hook (FRAME_PTR f)
8671 FRAME_PTR f;
8672{ 8366{
8673 if (f->async_visible) 8367 if (f->async_visible)
8674 { 8368 {
@@ -8681,9 +8375,7 @@ XTfullscreen_hook (f)
8681 8375
8682 8376
8683static void 8377static void
8684x_handle_net_wm_state (f, event) 8378x_handle_net_wm_state (struct frame *f, XPropertyEvent *event)
8685 struct frame *f;
8686 XPropertyEvent *event;
8687{ 8379{
8688 Atom actual_type; 8380 Atom actual_type;
8689 unsigned long actual_size, bytes_remaining; 8381 unsigned long actual_size, bytes_remaining;
@@ -8716,7 +8408,7 @@ x_handle_net_wm_state (f, event)
8716 for (i = 0; i < actual_size; ++i) 8408 for (i = 0; i < actual_size; ++i)
8717 { 8409 {
8718 Atom a = ((Atom*)tmp_data)[i]; 8410 Atom a = ((Atom*)tmp_data)[i];
8719 if (a == dpyinfo->Xatom_net_wm_state_maximized_horz) 8411 if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)
8720 { 8412 {
8721 if (value == FULLSCREEN_HEIGHT) 8413 if (value == FULLSCREEN_HEIGHT)
8722 value = FULLSCREEN_MAXIMIZED; 8414 value = FULLSCREEN_MAXIMIZED;
@@ -8737,7 +8429,7 @@ x_handle_net_wm_state (f, event)
8737 } 8429 }
8738 8430
8739 lval = Qnil; 8431 lval = Qnil;
8740 switch (value) 8432 switch (value)
8741 { 8433 {
8742 case FULLSCREEN_WIDTH: 8434 case FULLSCREEN_WIDTH:
8743 lval = Qfullwidth; 8435 lval = Qfullwidth;
@@ -8752,7 +8444,7 @@ x_handle_net_wm_state (f, event)
8752 lval = Qmaximized; 8444 lval = Qmaximized;
8753 break; 8445 break;
8754 } 8446 }
8755 8447
8756 store_frame_param (f, Qfullscreen, lval); 8448 store_frame_param (f, Qfullscreen, lval);
8757 store_frame_param (f, Qsticky, sticky ? Qt : Qnil); 8449 store_frame_param (f, Qsticky, sticky ? Qt : Qnil);
8758 8450
@@ -8763,8 +8455,7 @@ x_handle_net_wm_state (f, event)
8763/* Check if we need to resize the frame due to a fullscreen request. 8455/* Check if we need to resize the frame due to a fullscreen request.
8764 If so needed, resize the frame. */ 8456 If so needed, resize the frame. */
8765static void 8457static void
8766x_check_fullscreen (f) 8458x_check_fullscreen (struct frame *f)
8767 struct frame *f;
8768{ 8459{
8769 if (do_ewmh_fullscreen (f)) 8460 if (do_ewmh_fullscreen (f))
8770 return; 8461 return;
@@ -8791,7 +8482,7 @@ x_check_fullscreen (f)
8791 case FULLSCREEN_HEIGHT: 8482 case FULLSCREEN_HEIGHT:
8792 height = x_display_pixel_height (dpyinfo); 8483 height = x_display_pixel_height (dpyinfo);
8793 } 8484 }
8794 8485
8795 if (FRAME_COLS (f) != width || FRAME_LINES (f) != height) 8486 if (FRAME_COLS (f) != width || FRAME_LINES (f) != height)
8796 { 8487 {
8797 change_frame_size (f, height, width, 0, 1, 0); 8488 change_frame_size (f, height, width, 0, 1, 0);
@@ -8810,10 +8501,7 @@ x_check_fullscreen (f)
8810 compensate by moving the window right and down by the proper amount. */ 8501 compensate by moving the window right and down by the proper amount. */
8811 8502
8812static void 8503static void
8813x_check_expected_move (f, expected_left, expected_top) 8504x_check_expected_move (struct frame *f, int expected_left, int expected_top)
8814 struct frame *f;
8815 int expected_left;
8816 int expected_top;
8817{ 8505{
8818 int current_left = 0, current_top = 0; 8506 int current_left = 0, current_top = 0;
8819 8507
@@ -8858,9 +8546,7 @@ x_check_expected_move (f, expected_left, expected_top)
8858 of an exact comparison. */ 8546 of an exact comparison. */
8859 8547
8860static void 8548static void
8861x_sync_with_move (f, left, top, fuzzy) 8549x_sync_with_move (struct frame *f, int left, int top, int fuzzy)
8862 struct frame *f;
8863 int left, top, fuzzy;
8864{ 8550{
8865 int count = 0; 8551 int count = 0;
8866 8552
@@ -8897,9 +8583,7 @@ x_sync_with_move (f, left, top, fuzzy)
8897 8583
8898/* Wait for an event on frame F matching EVENTTYPE. */ 8584/* Wait for an event on frame F matching EVENTTYPE. */
8899void 8585void
8900x_wait_for_event (f, eventtype) 8586x_wait_for_event (struct frame *f, int eventtype)
8901 struct frame *f;
8902 int eventtype;
8903{ 8587{
8904 int level = interrupt_input_blocked; 8588 int level = interrupt_input_blocked;
8905 8589
@@ -8926,7 +8610,7 @@ x_wait_for_event (f, eventtype)
8926 8610
8927 FD_ZERO (&fds); 8611 FD_ZERO (&fds);
8928 FD_SET (fd, &fds); 8612 FD_SET (fd, &fds);
8929 8613
8930 EMACS_GET_TIME (time_now); 8614 EMACS_GET_TIME (time_now);
8931 EMACS_SUB_TIME (tmo, tmo_at, time_now); 8615 EMACS_SUB_TIME (tmo, tmo_at, time_now);
8932 8616
@@ -8944,10 +8628,7 @@ x_wait_for_event (f, eventtype)
8944 size changes. Otherwise we leave the window gravity unchanged. */ 8628 size changes. Otherwise we leave the window gravity unchanged. */
8945 8629
8946static void 8630static void
8947x_set_window_size_1 (f, change_gravity, cols, rows) 8631x_set_window_size_1 (struct frame *f, int change_gravity, int cols, int rows)
8948 struct frame *f;
8949 int change_gravity;
8950 int cols, rows;
8951{ 8632{
8952 int pixelwidth, pixelheight; 8633 int pixelwidth, pixelheight;
8953 8634
@@ -8955,13 +8636,12 @@ x_set_window_size_1 (f, change_gravity, cols, rows)
8955 f->scroll_bar_actual_width 8636 f->scroll_bar_actual_width
8956 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f) 8637 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
8957 ? 0 8638 ? 0
8958 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 8639 : FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f));
8959 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)
8960 : (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)));
8961 8640
8962 compute_fringe_widths (f, 0); 8641 compute_fringe_widths (f, 0);
8963 8642
8964 pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); 8643 pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols)
8644 + FRAME_TOOLBAR_WIDTH (f);
8965 pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows) 8645 pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows)
8966 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); 8646 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
8967 8647
@@ -9012,17 +8692,14 @@ x_set_window_size_1 (f, change_gravity, cols, rows)
9012 Otherwise we leave the window gravity unchanged. */ 8692 Otherwise we leave the window gravity unchanged. */
9013 8693
9014void 8694void
9015x_set_window_size (f, change_gravity, cols, rows) 8695x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
9016 struct frame *f;
9017 int change_gravity;
9018 int cols, rows;
9019{ 8696{
9020 BLOCK_INPUT; 8697 BLOCK_INPUT;
9021 8698
9022 if (NILP (tip_frame) || XFRAME (tip_frame) != f) 8699 if (NILP (tip_frame) || XFRAME (tip_frame) != f)
9023 { 8700 {
9024 int r, c; 8701 int r, c;
9025 8702
9026 /* When the frame is maximized/fullscreen or running under for 8703 /* When the frame is maximized/fullscreen or running under for
9027 example Xmonad, x_set_window_size_1 will be a no-op. 8704 example Xmonad, x_set_window_size_1 will be a no-op.
9028 In that case, the right thing to do is extend rows/cols to 8705 In that case, the right thing to do is extend rows/cols to
@@ -9071,9 +8748,7 @@ x_set_window_size (f, change_gravity, cols, rows)
9071/* Mouse warping. */ 8748/* Mouse warping. */
9072 8749
9073void 8750void
9074x_set_mouse_position (f, x, y) 8751x_set_mouse_position (struct frame *f, int x, int y)
9075 struct frame *f;
9076 int x, y;
9077{ 8752{
9078 int pix_x, pix_y; 8753 int pix_x, pix_y;
9079 8754
@@ -9096,9 +8771,7 @@ x_set_mouse_position (f, x, y)
9096/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */ 8771/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */
9097 8772
9098void 8773void
9099x_set_mouse_pixel_position (f, pix_x, pix_y) 8774x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
9100 struct frame *f;
9101 int pix_x, pix_y;
9102{ 8775{
9103 BLOCK_INPUT; 8776 BLOCK_INPUT;
9104 8777
@@ -9110,8 +8783,7 @@ x_set_mouse_pixel_position (f, pix_x, pix_y)
9110/* focus shifting, raising and lowering. */ 8783/* focus shifting, raising and lowering. */
9111 8784
9112void 8785void
9113x_focus_on_frame (f) 8786x_focus_on_frame (struct frame *f)
9114 struct frame *f;
9115{ 8787{
9116#if 0 8788#if 0
9117 /* I don't think that the ICCCM allows programs to do things like this 8789 /* I don't think that the ICCCM allows programs to do things like this
@@ -9123,8 +8795,7 @@ x_focus_on_frame (f)
9123} 8795}
9124 8796
9125void 8797void
9126x_unfocus_frame (f) 8798x_unfocus_frame (struct frame *f)
9127 struct frame *f;
9128{ 8799{
9129#if 0 8800#if 0
9130 /* Look at the remarks in x_focus_on_frame. */ 8801 /* Look at the remarks in x_focus_on_frame. */
@@ -9137,8 +8808,7 @@ x_unfocus_frame (f)
9137/* Raise frame F. */ 8808/* Raise frame F. */
9138 8809
9139void 8810void
9140x_raise_frame (f) 8811x_raise_frame (struct frame *f)
9141 struct frame *f;
9142{ 8812{
9143 BLOCK_INPUT; 8813 BLOCK_INPUT;
9144 if (f->async_visible) 8814 if (f->async_visible)
@@ -9151,8 +8821,7 @@ x_raise_frame (f)
9151/* Lower frame F. */ 8821/* Lower frame F. */
9152 8822
9153void 8823void
9154x_lower_frame (f) 8824x_lower_frame (struct frame *f)
9155 struct frame *f;
9156{ 8825{
9157 if (f->async_visible) 8826 if (f->async_visible)
9158 { 8827 {
@@ -9166,8 +8835,7 @@ x_lower_frame (f)
9166/* Activate frame with Extended Window Manager Hints */ 8835/* Activate frame with Extended Window Manager Hints */
9167 8836
9168void 8837void
9169x_ewmh_activate_frame (f) 8838x_ewmh_activate_frame (FRAME_PTR f)
9170 FRAME_PTR f;
9171{ 8839{
9172 /* See Window Manager Specification/Extended Window Manager Hints at 8840 /* See Window Manager Specification/Extended Window Manager Hints at
9173 http://freedesktop.org/wiki/Specifications/wm-spec */ 8841 http://freedesktop.org/wiki/Specifications/wm-spec */
@@ -9187,9 +8855,7 @@ x_ewmh_activate_frame (f)
9187} 8855}
9188 8856
9189static void 8857static void
9190XTframe_raise_lower (f, raise_flag) 8858XTframe_raise_lower (FRAME_PTR f, int raise_flag)
9191 FRAME_PTR f;
9192 int raise_flag;
9193{ 8859{
9194 if (raise_flag) 8860 if (raise_flag)
9195 x_raise_frame (f); 8861 x_raise_frame (f);
@@ -9200,9 +8866,7 @@ XTframe_raise_lower (f, raise_flag)
9200/* XEmbed implementation. */ 8866/* XEmbed implementation. */
9201 8867
9202void 8868void
9203xembed_set_info (f, flags) 8869xembed_set_info (struct frame *f, enum xembed_info flags)
9204 struct frame *f;
9205 enum xembed_info flags;
9206{ 8870{
9207 Atom atom; 8871 Atom atom;
9208 unsigned long data[2]; 8872 unsigned long data[2];
@@ -9217,13 +8881,7 @@ xembed_set_info (f, flags)
9217} 8881}
9218 8882
9219void 8883void
9220xembed_send_message (f, time, message, detail, data1, data2) 8884xembed_send_message (struct frame *f, Time time, enum xembed_message message, long int detail, long int data1, long int data2)
9221 struct frame *f;
9222 Time time;
9223 enum xembed_message message;
9224 long detail;
9225 long data1;
9226 long data2;
9227{ 8885{
9228 XEvent event; 8886 XEvent event;
9229 8887
@@ -9252,8 +8910,7 @@ xembed_send_message (f, time, message, detail, data1, data2)
9252 finishes with it. */ 8910 finishes with it. */
9253 8911
9254void 8912void
9255x_make_frame_visible (f) 8913x_make_frame_visible (struct frame *f)
9256 struct frame *f;
9257{ 8914{
9258 Lisp_Object type; 8915 Lisp_Object type;
9259 int original_top, original_left; 8916 int original_top, original_left;
@@ -9384,7 +9041,6 @@ x_make_frame_visible (f)
9384 /* It could be confusing if a real alarm arrives while 9041 /* It could be confusing if a real alarm arrives while
9385 processing the fake one. Turn it off and let the 9042 processing the fake one. Turn it off and let the
9386 handler reset it. */ 9043 handler reset it. */
9387 extern void poll_for_input_1 P_ ((void));
9388 int old_poll_suppress_count = poll_suppress_count; 9044 int old_poll_suppress_count = poll_suppress_count;
9389 poll_suppress_count = 1; 9045 poll_suppress_count = 1;
9390 poll_for_input_1 (); 9046 poll_for_input_1 ();
@@ -9416,8 +9072,7 @@ x_make_frame_visible (f)
9416/* Make the frame visible (mapped and not iconified). */ 9072/* Make the frame visible (mapped and not iconified). */
9417 9073
9418void 9074void
9419x_make_frame_invisible (f) 9075x_make_frame_invisible (struct frame *f)
9420 struct frame *f;
9421{ 9076{
9422 Window window; 9077 Window window;
9423 9078
@@ -9474,8 +9129,7 @@ x_make_frame_invisible (f)
9474/* Change window state from mapped to iconified. */ 9129/* Change window state from mapped to iconified. */
9475 9130
9476void 9131void
9477x_iconify_frame (f) 9132x_iconify_frame (struct frame *f)
9478 struct frame *f;
9479{ 9133{
9480 int result; 9134 int result;
9481 Lisp_Object type; 9135 Lisp_Object type;
@@ -9601,8 +9255,7 @@ x_iconify_frame (f)
9601/* Free X resources of frame F. */ 9255/* Free X resources of frame F. */
9602 9256
9603void 9257void
9604x_free_frame_resources (f) 9258x_free_frame_resources (struct frame *f)
9605 struct frame *f;
9606{ 9259{
9607 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 9260 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
9608 Lisp_Object bar; 9261 Lisp_Object bar;
@@ -9655,14 +9308,7 @@ x_free_frame_resources (f)
9655#else /* !USE_X_TOOLKIT */ 9308#else /* !USE_X_TOOLKIT */
9656 9309
9657#ifdef USE_GTK 9310#ifdef USE_GTK
9658 /* In the GTK version, tooltips are normal X 9311 xg_free_frame_widgets (f);
9659 frames. We must check and free both types. */
9660 if (FRAME_GTK_OUTER_WIDGET (f))
9661 {
9662 gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f));
9663 FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow below */
9664 FRAME_GTK_OUTER_WIDGET (f) = 0;
9665 }
9666#endif /* USE_GTK */ 9312#endif /* USE_GTK */
9667 9313
9668 if (FRAME_X_WINDOW (f)) 9314 if (FRAME_X_WINDOW (f))
@@ -9725,8 +9371,7 @@ x_free_frame_resources (f)
9725/* Destroy the X window of frame F. */ 9371/* Destroy the X window of frame F. */
9726 9372
9727void 9373void
9728x_destroy_window (f) 9374x_destroy_window (struct frame *f)
9729 struct frame *f;
9730{ 9375{
9731 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 9376 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
9732 9377
@@ -9750,10 +9395,7 @@ x_destroy_window (f)
9750 9395
9751#ifndef USE_GTK 9396#ifndef USE_GTK
9752void 9397void
9753x_wm_set_size_hint (f, flags, user_position) 9398x_wm_set_size_hint (struct frame *f, long flags, int user_position)
9754 struct frame *f;
9755 long flags;
9756 int user_position;
9757{ 9399{
9758 XSizeHints size_hints; 9400 XSizeHints size_hints;
9759 Window window = FRAME_OUTER_WINDOW (f); 9401 Window window = FRAME_OUTER_WINDOW (f);
@@ -9853,9 +9495,7 @@ x_wm_set_size_hint (f, flags, user_position)
9853/* Used for IconicState or NormalState */ 9495/* Used for IconicState or NormalState */
9854 9496
9855void 9497void
9856x_wm_set_window_state (f, state) 9498x_wm_set_window_state (struct frame *f, int state)
9857 struct frame *f;
9858 int state;
9859{ 9499{
9860#ifdef USE_X_TOOLKIT 9500#ifdef USE_X_TOOLKIT
9861 Arg al[1]; 9501 Arg al[1];
@@ -9873,9 +9513,7 @@ x_wm_set_window_state (f, state)
9873} 9513}
9874 9514
9875void 9515void
9876x_wm_set_icon_pixmap (f, pixmap_id) 9516x_wm_set_icon_pixmap (struct frame *f, int pixmap_id)
9877 struct frame *f;
9878 int pixmap_id;
9879{ 9517{
9880 Pixmap icon_pixmap, icon_mask; 9518 Pixmap icon_pixmap, icon_mask;
9881 9519
@@ -9923,9 +9561,7 @@ x_wm_set_icon_pixmap (f, pixmap_id)
9923} 9561}
9924 9562
9925void 9563void
9926x_wm_set_icon_position (f, icon_x, icon_y) 9564x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y)
9927 struct frame *f;
9928 int icon_x, icon_y;
9929{ 9565{
9930 Window window = FRAME_OUTER_WINDOW (f); 9566 Window window = FRAME_OUTER_WINDOW (f);
9931 9567
@@ -9947,9 +9583,7 @@ x_wm_set_icon_position (f, icon_x, icon_y)
9947 font table. */ 9583 font table. */
9948 9584
9949static void 9585static void
9950x_check_font (f, font) 9586x_check_font (struct frame *f, struct font *font)
9951 struct frame *f;
9952 struct font *font;
9953{ 9587{
9954 Lisp_Object frame; 9588 Lisp_Object frame;
9955 9589
@@ -9998,8 +9632,7 @@ static int x_session_initialized;
9998/* Test whether two display-name strings agree up to the dot that separates 9632/* Test whether two display-name strings agree up to the dot that separates
9999 the screen number from the server number. */ 9633 the screen number from the server number. */
10000static int 9634static int
10001same_x_server (name1, name2) 9635same_x_server (const char *name1, const char *name2)
10002 const char *name1, *name2;
10003{ 9636{
10004 int seen_colon = 0; 9637 int seen_colon = 0;
10005 const unsigned char *system_name = SDATA (Vsystem_name); 9638 const unsigned char *system_name = SDATA (Vsystem_name);
@@ -10046,10 +9679,7 @@ same_x_server (name1, name2)
10046 get to the first bit. With MASK 0x7e0, *BITS is set to 6, and *OFFSET 9679 get to the first bit. With MASK 0x7e0, *BITS is set to 6, and *OFFSET
10047 to 5. */ 9680 to 5. */
10048static void 9681static void
10049get_bits_and_offset (mask, bits, offset) 9682get_bits_and_offset (long unsigned int mask, int *bits, int *offset)
10050 unsigned long mask;
10051 int *bits;
10052 int *offset;
10053{ 9683{
10054 int nr = 0; 9684 int nr = 0;
10055 int off = 0; 9685 int off = 0;
@@ -10074,8 +9704,7 @@ get_bits_and_offset (mask, bits, offset)
10074 But don't permanently open it, just test its availability. */ 9704 But don't permanently open it, just test its availability. */
10075 9705
10076int 9706int
10077x_display_ok (display) 9707x_display_ok (const char *display)
10078 const char *display;
10079{ 9708{
10080 int dpy_ok = 1; 9709 int dpy_ok = 1;
10081 Display *dpy; 9710 Display *dpy;
@@ -10090,26 +9719,19 @@ x_display_ok (display)
10090 9719
10091#ifdef USE_GTK 9720#ifdef USE_GTK
10092static void 9721static void
10093my_log_handler (log_domain, log_level, message, user_data) 9722my_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
10094 const gchar *log_domain;
10095 GLogLevelFlags log_level;
10096 const gchar *message;
10097 gpointer user_data;
10098{ 9723{
10099 if (!strstr (message, "g_set_prgname")) 9724 if (!strstr (message, "g_set_prgname"))
10100 fprintf (stderr, "%s-WARNING **: %s\n", log_domain, message); 9725 fprintf (stderr, "%s-WARNING **: %s\n", log_domain, message);
10101} 9726}
10102#endif 9727#endif
10103 9728
10104/* Open a connection to X display DISPLAY_NAME, and return 9729/* Open a connection to X display DISPLAY_NAME, and return
10105 the structure that describes the open display. 9730 the structure that describes the open display.
10106 If we cannot contact the display, return null. */ 9731 If we cannot contact the display, return null. */
10107 9732
10108struct x_display_info * 9733struct x_display_info *
10109x_term_init (display_name, xrm_option, resource_name) 9734x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10110 Lisp_Object display_name;
10111 char *xrm_option;
10112 char *resource_name;
10113{ 9735{
10114 int connection; 9736 int connection;
10115 Display *dpy; 9737 Display *dpy;
@@ -10135,23 +9757,16 @@ x_term_init (display_name, xrm_option, resource_name)
10135 char *argv[NUM_ARGV]; 9757 char *argv[NUM_ARGV];
10136 char **argv2 = argv; 9758 char **argv2 = argv;
10137 guint id; 9759 guint id;
10138#ifndef HAVE_GTK_MULTIDISPLAY
10139 if (!EQ (Vinitial_window_system, Qx))
10140 error ("Sorry, you cannot connect to X servers with the GTK toolkit");
10141#endif
10142 9760
10143 if (x_initialized++ > 1) 9761 if (x_initialized++ > 1)
10144 { 9762 {
10145#ifdef HAVE_GTK_MULTIDISPLAY 9763 xg_display_open (SDATA (display_name), &dpy);
10146 /* Opening another display. If xg_display_open returns less
10147 than zero, we are probably on GTK 2.0, which can only handle
10148 one display. GTK 2.2 or later can handle more than one. */
10149 if (xg_display_open (SDATA (display_name), &dpy) < 0)
10150#endif
10151 error ("Sorry, this version of GTK can only handle one display");
10152 } 9764 }
10153 else 9765 else
10154 { 9766 {
9767 static char display_opt[] = "--display";
9768 static char name_opt[] = "--name";
9769
10155 for (argc = 0; argc < NUM_ARGV; ++argc) 9770 for (argc = 0; argc < NUM_ARGV; ++argc)
10156 argv[argc] = 0; 9771 argv[argc] = 0;
10157 9772
@@ -10160,11 +9775,11 @@ x_term_init (display_name, xrm_option, resource_name)
10160 9775
10161 if (! NILP (display_name)) 9776 if (! NILP (display_name))
10162 { 9777 {
10163 argv[argc++] = "--display"; 9778 argv[argc++] = display_opt;
10164 argv[argc++] = SDATA (display_name); 9779 argv[argc++] = SDATA (display_name);
10165 } 9780 }
10166 9781
10167 argv[argc++] = "--name"; 9782 argv[argc++] = name_opt;
10168 argv[argc++] = resource_name; 9783 argv[argc++] = resource_name;
10169 9784
10170 XSetLocaleModifiers (""); 9785 XSetLocaleModifiers ("");
@@ -10187,7 +9802,7 @@ x_term_init (display_name, xrm_option, resource_name)
10187 9802
10188 /* Load our own gtkrc if it exists. */ 9803 /* Load our own gtkrc if it exists. */
10189 { 9804 {
10190 char *file = "~/.emacs.d/gtkrc"; 9805 const char *file = "~/.emacs.d/gtkrc";
10191 Lisp_Object s, abs_file; 9806 Lisp_Object s, abs_file;
10192 9807
10193 s = make_string (file, strlen (file)); 9808 s = make_string (file, strlen (file));
@@ -10252,7 +9867,7 @@ x_term_init (display_name, xrm_option, resource_name)
10252 /* We have definitely succeeded. Record the new connection. */ 9867 /* We have definitely succeeded. Record the new connection. */
10253 9868
10254 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info)); 9869 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
10255 bzero (dpyinfo, sizeof *dpyinfo); 9870 memset (dpyinfo, 0, sizeof *dpyinfo);
10256 9871
10257 terminal = x_create_terminal (dpyinfo); 9872 terminal = x_create_terminal (dpyinfo);
10258 9873
@@ -10530,7 +10145,11 @@ x_term_init (display_name, xrm_option, resource_name)
10530 = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE", False); 10145 = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE", False);
10531 dpyinfo->Xatom_net_window_type_tooltip 10146 dpyinfo->Xatom_net_window_type_tooltip
10532 = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE_TOOLTIP", False); 10147 = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE_TOOLTIP", False);
10533 10148 dpyinfo->Xatom_net_wm_icon_name
10149 = XInternAtom (dpyinfo->display, "_NET_WM_ICON_NAME", False);
10150 dpyinfo->Xatom_net_wm_name
10151 = XInternAtom (dpyinfo->display, "_NET_WM_NAME", False);
10152
10534 dpyinfo->cut_buffers_initialized = 0; 10153 dpyinfo->cut_buffers_initialized = 0;
10535 10154
10536 dpyinfo->x_dnd_atoms_size = 8; 10155 dpyinfo->x_dnd_atoms_size = 8;
@@ -10546,8 +10165,6 @@ x_term_init (display_name, xrm_option, resource_name)
10546 dpyinfo->connection = connection; 10165 dpyinfo->connection = connection;
10547 10166
10548 { 10167 {
10549 extern int gray_bitmap_width, gray_bitmap_height;
10550 extern char *gray_bitmap_bits;
10551 dpyinfo->gray 10168 dpyinfo->gray
10552 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, 10169 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window,
10553 gray_bitmap_bits, 10170 gray_bitmap_bits,
@@ -10561,11 +10178,9 @@ x_term_init (display_name, xrm_option, resource_name)
10561 10178
10562 xsettings_initialize (dpyinfo); 10179 xsettings_initialize (dpyinfo);
10563 10180
10564#ifdef subprocesses
10565 /* This is only needed for distinguishing keyboard and process input. */ 10181 /* This is only needed for distinguishing keyboard and process input. */
10566 if (connection != 0) 10182 if (connection != 0)
10567 add_keyboard_wait_descriptor (connection); 10183 add_keyboard_wait_descriptor (connection);
10568#endif
10569 10184
10570#ifdef F_SETOWN 10185#ifdef F_SETOWN
10571 fcntl (connection, F_SETOWN, getpid ()); 10186 fcntl (connection, F_SETOWN, getpid ());
@@ -10647,8 +10262,7 @@ x_term_init (display_name, xrm_option, resource_name)
10647 and without sending any more commands to the X server. */ 10262 and without sending any more commands to the X server. */
10648 10263
10649void 10264void
10650x_delete_display (dpyinfo) 10265x_delete_display (struct x_display_info *dpyinfo)
10651 struct x_display_info *dpyinfo;
10652{ 10266{
10653 struct terminal *t; 10267 struct terminal *t;
10654 10268
@@ -10660,7 +10274,7 @@ x_delete_display (dpyinfo)
10660#ifdef HAVE_X_SM 10274#ifdef HAVE_X_SM
10661 /* Close X session management when we close its display. */ 10275 /* Close X session management when we close its display. */
10662 if (t->id == 1 && x_session_have_connection ()) 10276 if (t->id == 1 && x_session_have_connection ())
10663 x_session_close(); 10277 x_session_close ();
10664#endif 10278#endif
10665 delete_terminal (t); 10279 delete_terminal (t);
10666 break; 10280 break;
@@ -10717,8 +10331,7 @@ x_delete_display (dpyinfo)
10717 that slows us down. */ 10331 that slows us down. */
10718 10332
10719static void 10333static void
10720x_process_timeouts (timer) 10334x_process_timeouts (struct atimer *timer)
10721 struct atimer *timer;
10722{ 10335{
10723 BLOCK_INPUT; 10336 BLOCK_INPUT;
10724 x_timeout_atimer_activated_flag = 0; 10337 x_timeout_atimer_activated_flag = 0;
@@ -10741,7 +10354,7 @@ x_process_timeouts (timer)
10741 processed, these widgets don't behave normally. */ 10354 processed, these widgets don't behave normally. */
10742 10355
10743void 10356void
10744x_activate_timeout_atimer () 10357x_activate_timeout_atimer (void)
10745{ 10358{
10746 BLOCK_INPUT; 10359 BLOCK_INPUT;
10747 if (!x_timeout_atimer_activated_flag) 10360 if (!x_timeout_atimer_activated_flag)
@@ -10917,7 +10530,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
10917} 10530}
10918 10531
10919void 10532void
10920x_initialize () 10533x_initialize (void)
10921{ 10534{
10922 baud_rate = 19200; 10535 baud_rate = 19200;
10923 10536
@@ -10975,7 +10588,7 @@ x_initialize ()
10975 10588
10976 10589
10977void 10590void
10978syms_of_xterm () 10591syms_of_xterm (void)
10979{ 10592{
10980 x_error_message = NULL; 10593 x_error_message = NULL;
10981 10594