aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-01-26 05:25:06 +0000
committerRichard M. Stallman1994-01-26 05:25:06 +0000
commit3afe33e7ec3d31d67e920aeffde0eda8b6b16a9c (patch)
tree92ffb086cb21b1564f29f4ffdbe3ffde583d8543 /src
parent9ef48a9decdf3b33c0e341c589dc8ce0229e0e48 (diff)
downloademacs-3afe33e7ec3d31d67e920aeffde0eda8b6b16a9c.tar.gz
emacs-3afe33e7ec3d31d67e920aeffde0eda8b6b16a9c.zip
(x_wm_set_size_hint): Swap southeast and northwest.
(XTupdate_end): No need to test updating_frame. (construct_mouse_click): New function, in #ifdef USE_X_TOOLKIT. (process_expose_from_menu): Likewise. (XTread_socket, x_set_offset, x_set_window_size): Handle USE_X_TOOLKIT. (x_raise_frame, x_lower_frame, x_make_frame_visible): Likewise. (x_iconify_frame, x_destroy_window, x_wm_set_window_state): Likewise. (x_term_init): Likewise. (x_term_init): Pass argv, argc to XtAppInitialize with the display_name value. Include syssignal.h. The following belongs in a previous version's log entry: (XTread_socket): temp_buffer and temp_index deleted. Put all vendor-specific keys into the buffer. (x_is_vendor_fkey): Function deleted. (XTread_socket): Don't call it.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c304
1 files changed, 282 insertions, 22 deletions
diff --git a/src/xterm.c b/src/xterm.c
index c4a4d18829a..2e7ed52597b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -25,6 +25,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 25
26*/ 26*/
27 27
28/* Xt features made by Fred Pierresteguy. */
29
28#define NEW_SELECTIONS 30#define NEW_SELECTIONS
29 31
30/* On 4.3 these lose if they come after xterm.h. */ 32/* On 4.3 these lose if they come after xterm.h. */
@@ -35,6 +37,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
35 37
36#include <config.h> 38#include <config.h>
37 39
40/* Need syssignal.h for various externs and definitions that may be required
41 * by some configurations for calls to signal() later in this source file.
42 */
43#include "syssignal.h"
44
38#ifdef HAVE_X_WINDOWS 45#ifdef HAVE_X_WINDOWS
39 46
40#include "lisp.h" 47#include "lisp.h"
@@ -86,6 +93,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
86#include "buffer.h" 93#include "buffer.h"
87#include "window.h" 94#include "window.h"
88 95
96#ifdef USE_X_TOOLKIT
97extern XtAppContext Xt_app_con;
98extern Widget Xt_app_shell;
99#endif /* USE_X_TOOLKIT */
100
89#ifdef HAVE_X11 101#ifdef HAVE_X11
90#define XMapWindow XMapRaised /* Raise them when mapping. */ 102#define XMapWindow XMapRaised /* Raise them when mapping. */
91#else /* ! defined (HAVE_X11) */ 103#else /* ! defined (HAVE_X11) */
@@ -316,6 +328,7 @@ extern FONT_TYPE *XOpenFont ();
316 328
317static void flashback (); 329static void flashback ();
318static void redraw_previous_char (); 330static void redraw_previous_char ();
331static unsigned int x_x_to_emacs_modifiers ();
319 332
320#ifndef HAVE_X11 333#ifndef HAVE_X11
321static void dumpqueue (); 334static void dumpqueue ();
@@ -366,10 +379,6 @@ XTupdate_end (f)
366{ 379{
367 int mask; 380 int mask;
368 381
369 if (updating_frame == 0
370 || updating_frame != f)
371 abort ();
372
373 BLOCK_INPUT; 382 BLOCK_INPUT;
374#ifndef HAVE_X11 383#ifndef HAVE_X11
375 dumpqueue (); 384 dumpqueue ();
@@ -1589,6 +1598,30 @@ x_find_modifier_meanings ()
1589 XFreeModifiermap (mods); 1598 XFreeModifiermap (mods);
1590} 1599}
1591 1600
1601/* Prepare a menu-event in *RESULT for placement in the input queue. */
1602
1603static Lisp_Object
1604construct_menu_click (result, event, f)
1605 struct input_event *result;
1606 XButtonEvent *event;
1607 struct frame *f;
1608{
1609 /* Make the event type no_event; we'll change that when we decide
1610 otherwise. */
1611 result->kind = mouse_click;
1612 XSET (result->code, Lisp_Int, event->button - Button1);
1613 result->timestamp = event->time;
1614 result->modifiers = (x_x_to_emacs_modifiers (event->state)
1615 | (event->type == ButtonRelease
1616 ? up_modifier
1617 : down_modifier));
1618
1619 {
1620 XFASTINT (result->x) = event->x;
1621 XFASTINT (result->y) = -1; /* special meaning for menubar */
1622 XSET (result->frame_or_window, Lisp_Frame, f);
1623 }
1624}
1592 1625
1593/* Convert between the modifier bits X uses and the modifier bits 1626/* Convert between the modifier bits X uses and the modifier bits
1594 Emacs uses. */ 1627 Emacs uses. */
@@ -1993,7 +2026,6 @@ x_scroll_bar_create (window, top, left, width, height)
1993 { 2026 {
1994 XSetWindowAttributes a; 2027 XSetWindowAttributes a;
1995 unsigned long mask; 2028 unsigned long mask;
1996
1997 a.background_pixel = frame->display.x->background_pixel; 2029 a.background_pixel = frame->display.x->background_pixel;
1998 a.event_mask = (ButtonPressMask | ButtonReleaseMask 2030 a.event_mask = (ButtonPressMask | ButtonReleaseMask
1999 | ButtonMotionMask | PointerMotionHintMask 2031 | ButtonMotionMask | PointerMotionHintMask
@@ -2002,7 +2034,21 @@ x_scroll_bar_create (window, top, left, width, height)
2002 2034
2003 mask = (CWBackPixel | CWEventMask | CWCursor); 2035 mask = (CWBackPixel | CWEventMask | CWCursor);
2004 2036
2005 SET_SCROLL_BAR_X_WINDOW 2037#if 0
2038
2039 ac = 0;
2040 XtSetArg (al[ac], XtNx, left); ac++;
2041 XtSetArg (al[ac], XtNy, top); ac++;
2042 XtSetArg (al[ac], XtNwidth, width); ac++;
2043 XtSetArg (al[ac], XtNheight, height); ac++;
2044 XtSetArg (al[ac], XtNborderWidth, 0); ac++;
2045 sb_widget = XtCreateManagedWidget ("box",
2046 boxWidgetClass,
2047 frame->display.x->edit_widget, al, ac);
2048 SET_SCROLL_BAR_X_WINDOW
2049 (bar, sb_widget->core.window);
2050#endif
2051 SET_SCROLL_BAR_X_WINDOW
2006 (bar, 2052 (bar,
2007 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame), 2053 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame),
2008 2054
@@ -2593,6 +2639,41 @@ x_scroll_bar_clear (f)
2593 0, 0, 0, 0, True); 2639 0, 0, 0, 0, True);
2594} 2640}
2595 2641
2642/* This processes Expose events from the menubar specific X event
2643 loop in menubar.c. This allows to redisplay the frame if necessary
2644 when handling menubar or popup items. */
2645
2646void
2647process_expose_from_menu (event)
2648 XEvent event;
2649{
2650 FRAME_PTR f;
2651
2652 f = x_window_to_frame (event.xexpose.window);
2653 if (f)
2654 {
2655 if (f->async_visible == 0)
2656 {
2657 f->async_visible = 1;
2658 f->async_iconified = 0;
2659 SET_FRAME_GARBAGED (f);
2660 }
2661 else
2662 {
2663 dumprectangle (x_window_to_frame (event.xexpose.window),
2664 event.xexpose.x, event.xexpose.y,
2665 event.xexpose.width, event.xexpose.height);
2666 }
2667 }
2668 else
2669 {
2670 struct scroll_bar *bar
2671 = x_window_to_scroll_bar (event.xexpose.window);
2672
2673 if (bar)
2674 x_scroll_bar_expose (bar, &event);
2675 }
2676}
2596 2677
2597 2678
2598/* The main X event-reading loop - XTread_socket. */ 2679/* The main X event-reading loop - XTread_socket. */
@@ -2708,7 +2789,12 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2708 { 2789 {
2709 if (event.xclient.data.l[0] == Xatom_wm_take_focus) 2790 if (event.xclient.data.l[0] == Xatom_wm_take_focus)
2710 { 2791 {
2792#ifdef USE_X_TOOLKIT
2793 /* f = x_any_window_to_frame (event.xclient.window); */
2711 f = x_window_to_frame (event.xclient.window); 2794 f = x_window_to_frame (event.xclient.window);
2795#else
2796 f = x_window_to_frame (event.xclient.window);
2797#endif
2712 if (f) 2798 if (f)
2713 x_focus_on_frame (f); 2799 x_focus_on_frame (f);
2714 /* Not certain about handling scroll bars here */ 2800 /* Not certain about handling scroll bars here */
@@ -2764,13 +2850,24 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2764 2850
2765#ifdef NEW_SELECTIONS 2851#ifdef NEW_SELECTIONS
2766 case SelectionNotify: 2852 case SelectionNotify:
2853#ifdef USE_X_TOOLKIT
2854 if (x_window_to_frame (event.xselection.requestor))
2855 x_handle_selection_notify (&event);
2856 else
2857 goto OTHER;
2858#else /* not USE_X_TOOLKIT */
2767 x_handle_selection_notify (&event); 2859 x_handle_selection_notify (&event);
2860#endif /* not USE_X_TOOLKIT */
2768 break; 2861 break;
2769#endif 2862#endif /* NEW_SELECTIONS */
2770 2863
2771 case SelectionClear: /* Someone has grabbed ownership. */ 2864 case SelectionClear: /* Someone has grabbed ownership. */
2772#ifdef NEW_SELECTIONS 2865#ifdef NEW_SELECTIONS
2773 { 2866 {
2867#ifdef USE_X_TOOLKIT
2868 if (x_window_to_frame (event.xselectionclear.window))
2869 {
2870#endif /* USE_X_TOOLKIT */
2774 XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event; 2871 XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event;
2775 2872
2776 if (numchars == 0) 2873 if (numchars == 0)
@@ -2784,17 +2881,26 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2784 2881
2785 count += 1; 2882 count += 1;
2786 numchars -= 1; 2883 numchars -= 1;
2884#ifdef USE_X_TOOLKIT
2787 } 2885 }
2788#else 2886 else
2887 goto OTHER;
2888#endif /* USE_X_TOOLKIT */
2889 }
2890#else /* not NEW_SELECTIONS */
2789 x_disown_selection (event.xselectionclear.window, 2891 x_disown_selection (event.xselectionclear.window,
2790 event.xselectionclear.selection, 2892 event.xselectionclear.selection,
2791 event.xselectionclear.time); 2893 event.xselectionclear.time);
2792#endif 2894#endif /* not NEW_SELECTIONS */
2793 break; 2895 break;
2794 2896
2795 case SelectionRequest: /* Someone wants our selection. */ 2897 case SelectionRequest: /* Someone wants our selection. */
2796#ifdef NEW_SELECTIONS 2898#ifdef NEW_SELECTIONS
2797 { 2899 {
2900#ifdef USE_X_TOOLKIT
2901 if (x_window_to_frame (event.xselectionrequest.owner))
2902 {
2903#endif /* USE_X_TOOLKIT */
2798 XSelectionRequestEvent *eventp = (XSelectionRequestEvent *) &event; 2904 XSelectionRequestEvent *eventp = (XSelectionRequestEvent *) &event;
2799 2905
2800 if (numchars == 0) 2906 if (numchars == 0)
@@ -2811,16 +2917,28 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2811 2917
2812 count += 1; 2918 count += 1;
2813 numchars -= 1; 2919 numchars -= 1;
2920#ifdef USE_X_TOOLKIT
2814 } 2921 }
2815#else 2922 else
2923 goto OTHER;
2924#endif /* USE_X_TOOLKIT */
2925 }
2926#else /* not NEW_SELECTIONS */
2816 x_answer_selection_request (event); 2927 x_answer_selection_request (event);
2817#endif 2928#endif /* not NEW_SELECTIONS */
2818 break; 2929 break;
2819 2930
2820 case PropertyNotify: 2931 case PropertyNotify:
2821#ifdef NEW_SELECTIONS 2932#ifdef NEW_SELECTIONS
2933#ifdef USE_X_TOOLKIT
2934 if (x_any_window_to_frame (event.xproperty.window))
2935 x_handle_property_notify (&event);
2936 else
2937 goto OTHER;
2938#else /* not USE_X_TOOLKIT */
2822 x_handle_property_notify (&event); 2939 x_handle_property_notify (&event);
2823#else 2940#endif /* not USE_X_TOOLKIT */
2941#else /* not NEW_SELECTIONS */
2824 /* If we're being told about a root window property, then it's 2942 /* If we're being told about a root window property, then it's
2825 a cut buffer change. */ 2943 a cut buffer change. */
2826 if (event.xproperty.window == ROOT_WINDOW) 2944 if (event.xproperty.window == ROOT_WINDOW)
@@ -2834,7 +2952,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2834 about re-selecting. */ 2952 about re-selecting. */
2835 x_send_incremental (event); 2953 x_send_incremental (event);
2836 } 2954 }
2837#endif 2955#endif /* not NEW_SELECTIONS */
2838 break; 2956 break;
2839 2957
2840 case ReparentNotify: 2958 case ReparentNotify:
@@ -2864,9 +2982,13 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2864 { 2982 {
2865 struct scroll_bar *bar 2983 struct scroll_bar *bar
2866 = x_window_to_scroll_bar (event.xexpose.window); 2984 = x_window_to_scroll_bar (event.xexpose.window);
2867 2985
2868 if (bar) 2986 if (bar)
2869 x_scroll_bar_expose (bar, &event); 2987 x_scroll_bar_expose (bar, &event);
2988#ifdef USE_X_TOOLKIT
2989 else
2990 goto OTHER;
2991#endif /* USE_X_TOOLKIT */
2870 } 2992 }
2871 break; 2993 break;
2872 2994
@@ -2881,6 +3003,10 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2881 event.xgraphicsexpose.width, 3003 event.xgraphicsexpose.width,
2882 event.xgraphicsexpose.height); 3004 event.xgraphicsexpose.height);
2883 } 3005 }
3006#ifdef USE_X_TOOLKIT
3007 else
3008 goto OTHER;
3009#endif /* USE_X_TOOLKIT */
2884 break; 3010 break;
2885 3011
2886 case NoExpose: /* This occurs when an XCopyArea's 3012 case NoExpose: /* This occurs when an XCopyArea's
@@ -2952,10 +3078,17 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2952 if (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)) 3078 if (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f))
2953 f->async_iconified = 1; 3079 f->async_iconified = 1;
2954 } 3080 }
3081#ifdef USE_X_TOOLKIT
3082 goto OTHER;
3083#endif /* USE_X_TOOLKIT */
2955 break; 3084 break;
2956 3085
2957 case MapNotify: 3086 case MapNotify:
3087#ifdef USE_X_TOOLKIT
3088 f = x_any_window_to_frame (event.xmap.window);
3089#else /* not USE_X_TOOLKIT */
2958 f = x_window_to_frame (event.xmap.window); 3090 f = x_window_to_frame (event.xmap.window);
3091#endif /* not USE_X_TOOLKIT */
2959 if (f) 3092 if (f)
2960 { 3093 {
2961 f->async_visible = 1; 3094 f->async_visible = 1;
@@ -2965,7 +3098,10 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2965 the frame's display structures. */ 3098 the frame's display structures. */
2966 SET_FRAME_GARBAGED (f); 3099 SET_FRAME_GARBAGED (f);
2967 } 3100 }
2968 break; 3101#ifdef USE_X_TOOLKIT
3102 goto OTHER;
3103#endif /* USE_X_TOOLKIT */
3104 break;
2969 3105
2970 /* Turn off processing if we become fully obscured. */ 3106 /* Turn off processing if we become fully obscured. */
2971 case VisibilityNotify: 3107 case VisibilityNotify:
@@ -3191,7 +3327,9 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3191 } 3327 }
3192 else if (f == x_focus_frame) 3328 else if (f == x_focus_frame)
3193 x_new_focus_frame (0); 3329 x_new_focus_frame (0);
3194 3330#ifdef USE_X_TOOLKIT
3331 goto OTHER;
3332#endif /* USE_X_TOOLKIT */
3195 break; 3333 break;
3196 3334
3197 case FocusIn: 3335 case FocusIn:
@@ -3200,6 +3338,9 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3200 x_focus_event_frame = f; 3338 x_focus_event_frame = f;
3201 if (f) 3339 if (f)
3202 x_new_focus_frame (f); 3340 x_new_focus_frame (f);
3341#ifdef USE_X_TOOLKIT
3342 goto OTHER;
3343#endif /* USE_X_TOOLKIT */
3203 break; 3344 break;
3204 3345
3205 3346
@@ -3220,6 +3361,9 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3220 if (f == x_focus_frame) 3361 if (f == x_focus_frame)
3221 x_new_focus_frame (0); 3362 x_new_focus_frame (0);
3222 } 3363 }
3364#ifdef USE_X_TOOLKIT
3365 goto OTHER;
3366#endif /* USE_X_TOOLKIT */
3223 break; 3367 break;
3224 3368
3225 case FocusOut: 3369 case FocusOut:
@@ -3229,6 +3373,9 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3229 x_focus_event_frame = 0; 3373 x_focus_event_frame = 0;
3230 if (f && f == x_focus_frame) 3374 if (f && f == x_focus_frame)
3231 x_new_focus_frame (0); 3375 x_new_focus_frame (0);
3376#ifdef USE_X_TOOLKIT
3377 goto OTHER;
3378#endif /* USE_X_TOOLKIT */
3232 break; 3379 break;
3233 3380
3234#else /* ! defined (HAVE_X11) */ 3381#else /* ! defined (HAVE_X11) */
@@ -3285,9 +3432,16 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3285 x_scroll_bar_note_movement (bar, &event); 3432 x_scroll_bar_note_movement (bar, &event);
3286 } 3433 }
3287 } 3434 }
3435#ifdef USE_X_TOOLKIT
3436 goto OTHER;
3437#endif /* USE_X_TOOLKIT */
3288 break; 3438 break;
3289 3439
3290 case ConfigureNotify: 3440 case ConfigureNotify:
3441#ifdef USE_X_TOOLKIT
3442 /* process done in widget.c */
3443 goto OTHER;
3444#else /* not USE_X_TOOLKIT */
3291 f = x_window_to_frame (event.xconfigure.window); 3445 f = x_window_to_frame (event.xconfigure.window);
3292 if (f) 3446 if (f)
3293 { 3447 {
@@ -3338,6 +3492,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3338 f->display.x->left_pos = event.xconfigure.x; 3492 f->display.x->left_pos = event.xconfigure.x;
3339 f->display.x->top_pos = event.xconfigure.y; 3493 f->display.x->top_pos = event.xconfigure.y;
3340 } 3494 }
3495#endif /* not USE_X_TOOLKIT */
3341 break; 3496 break;
3342 3497
3343 case ButtonPress: 3498 case ButtonPress:
@@ -3361,6 +3516,15 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3361 3516
3362 if (bar) 3517 if (bar)
3363 x_scroll_bar_handle_click (bar, &event, &emacs_event); 3518 x_scroll_bar_handle_click (bar, &event, &emacs_event);
3519#ifdef USE_X_TOOLKIT
3520 else
3521 {
3522 f = x_any_window_to_frame (event.xbutton.window);
3523 if (f && event.type == ButtonPress)
3524 construct_menu_click (&emacs_event,
3525 &event, f);
3526 }
3527#endif /* USE_X_TOOLKIT */
3364 } 3528 }
3365 3529
3366 if (numchars >= 1 && emacs_event.kind != no_event) 3530 if (numchars >= 1 && emacs_event.kind != no_event)
@@ -3370,6 +3534,10 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3370 count++; 3534 count++;
3371 numchars--; 3535 numchars--;
3372 } 3536 }
3537
3538#ifdef USE_X_TOOLKIT
3539 goto OTHER;
3540#endif /* USE_X_TOOLKIT */
3373 } 3541 }
3374 break; 3542 break;
3375 3543
@@ -3434,9 +3602,18 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
3434 case MappingKeyboard: 3602 case MappingKeyboard:
3435 XRefreshKeyboardMapping (&event.xmapping); 3603 XRefreshKeyboardMapping (&event.xmapping);
3436 } 3604 }
3605#ifdef USE_X_TOOLKIT
3606 goto OTHER;
3607#endif /* USE_X_TOOLKIT */
3437 break; 3608 break;
3438 3609
3439 default: 3610 default:
3611#ifdef USE_X_TOOLKIT
3612 OTHER:
3613 BLOCK_INPUT;
3614 XtDispatchEvent (&event);
3615 UNBLOCK_INPUT;
3616#endif /* USE_X_TOOLKIT */
3440 break; 3617 break;
3441 } 3618 }
3442 } 3619 }
@@ -4258,8 +4435,6 @@ x_new_font (f, newname)
4258} 4435}
4259#endif /* ! defined (HAVE_X11) */ 4436#endif /* ! defined (HAVE_X11) */
4260 4437
4261/* X Window sizes and positions. */
4262
4263x_calc_absolute_position (f) 4438x_calc_absolute_position (f)
4264 struct frame *f; 4439 struct frame *f;
4265{ 4440{
@@ -4324,8 +4499,13 @@ x_set_offset (f, xoff, yoff)
4324 x_calc_absolute_position (f); 4499 x_calc_absolute_position (f);
4325 4500
4326 BLOCK_INPUT; 4501 BLOCK_INPUT;
4502#ifdef USE_X_TOOLKIT
4503 XMoveWindow (XDISPLAY XtWindow (f->display.x->widget),
4504 f->display.x->left_pos, f->display.x->top_pos);
4505#else /* not USE_X_TOOLKIT */
4327 XMoveWindow (XDISPLAY FRAME_X_WINDOW (f), 4506 XMoveWindow (XDISPLAY FRAME_X_WINDOW (f),
4328 f->display.x->left_pos, f->display.x->top_pos); 4507 f->display.x->left_pos, f->display.x->top_pos);
4508#endif /* not USE_X_TOOLKIT */
4329#ifdef HAVE_X11 4509#ifdef HAVE_X11
4330 x_wm_set_size_hint (f, 0, xoff, yoff); 4510 x_wm_set_size_hint (f, 0, xoff, yoff);
4331#endif /* ! defined (HAVE_X11) */ 4511#endif /* ! defined (HAVE_X11) */
@@ -4351,6 +4531,11 @@ x_set_window_size (f, cols, rows)
4351 pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols); 4531 pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
4352 pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows); 4532 pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
4353 4533
4534#if 0
4535#ifdef USE_X_TOOLKIT
4536 EmacsFrameSetCharSize (f->display.x->edit_widget, cols, rows);
4537#endif /* USE_X_TOOLKIT */
4538#endif
4354#ifdef HAVE_X11 4539#ifdef HAVE_X11
4355 x_wm_set_size_hint (f, 0, 0, 0); 4540 x_wm_set_size_hint (f, 0, 0, 0);
4356#endif /* ! defined (HAVE_X11) */ 4541#endif /* ! defined (HAVE_X11) */
@@ -4454,7 +4639,11 @@ x_raise_frame (f)
4454 if (f->async_visible) 4639 if (f->async_visible)
4455 { 4640 {
4456 BLOCK_INPUT; 4641 BLOCK_INPUT;
4642#ifdef USE_X_TOOLKIT
4643 XRaiseWindow (XDISPLAY XtWindow (f->display.x->widget));
4644#else /* not USE_X_TOOLKIT */
4457 XRaiseWindow (XDISPLAY FRAME_X_WINDOW (f)); 4645 XRaiseWindow (XDISPLAY FRAME_X_WINDOW (f));
4646#endif /* not USE_X_TOOLKIT */
4458 XFlushQueue (); 4647 XFlushQueue ();
4459 UNBLOCK_INPUT; 4648 UNBLOCK_INPUT;
4460 } 4649 }
@@ -4468,7 +4657,11 @@ x_lower_frame (f)
4468 if (f->async_visible) 4657 if (f->async_visible)
4469 { 4658 {
4470 BLOCK_INPUT; 4659 BLOCK_INPUT;
4660#ifdef USE_X_TOOLKIT
4661 XLowerWindow (XDISPLAY XtWindow (f->display.x->widget));
4662#else /* not USE_X_TOOLKIT */
4471 XLowerWindow (XDISPLAY FRAME_X_WINDOW (f)); 4663 XLowerWindow (XDISPLAY FRAME_X_WINDOW (f));
4664#endif /* not USE_X_TOOLKIT */
4472 XFlushQueue (); 4665 XFlushQueue ();
4473 UNBLOCK_INPUT; 4666 UNBLOCK_INPUT;
4474 } 4667 }
@@ -4500,8 +4693,11 @@ x_make_frame_visible (f)
4500#ifdef HAVE_X11 4693#ifdef HAVE_X11
4501 if (! EQ (Vx_no_window_manager, Qt)) 4694 if (! EQ (Vx_no_window_manager, Qt))
4502 x_wm_set_window_state (f, NormalState); 4695 x_wm_set_window_state (f, NormalState);
4503 4696#ifdef USE_X_TOOLKIT
4697 XtPopup (f->display.x->widget, XtGrabNone);
4698#else /* not USE_X_TOOLKIT */
4504 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); 4699 XMapWindow (XDISPLAY FRAME_X_WINDOW (f));
4700#endif /* not USE_X_TOOLKIT */
4505 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) 4701 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
4506 XMapSubwindows (x_current_display, FRAME_X_WINDOW (f)); 4702 XMapSubwindows (x_current_display, FRAME_X_WINDOW (f));
4507#else /* ! defined (HAVE_X11) */ 4703#else /* ! defined (HAVE_X11) */
@@ -4594,6 +4790,7 @@ x_iconify_frame (f)
4594 struct frame *f; 4790 struct frame *f;
4595{ 4791{
4596 int mask; 4792 int mask;
4793 int result;
4597 4794
4598 /* Don't keep the highlight on an invisible frame. */ 4795 /* Don't keep the highlight on an invisible frame. */
4599 if (x_highlight_frame == f) 4796 if (x_highlight_frame == f)
@@ -4602,6 +4799,19 @@ x_iconify_frame (f)
4602 if (f->async_iconified) 4799 if (f->async_iconified)
4603 return; 4800 return;
4604 4801
4802#ifdef USE_X_TOOLKIT
4803 BLOCK_INPUT;
4804 result = XIconifyWindow (x_current_display,
4805 XtWindow(f->display.x->widget),
4806 DefaultScreen (x_current_display));
4807 UNBLOCK_INPUT;
4808
4809 if (!result)
4810 error ("Can't notify window manager of iconification.");
4811
4812 f->async_iconified = 1;
4813#else /* not USE_X_TOOLKIT */
4814
4605 BLOCK_INPUT; 4815 BLOCK_INPUT;
4606 4816
4607#ifdef HAVE_X11 4817#ifdef HAVE_X11
@@ -4653,6 +4863,7 @@ x_iconify_frame (f)
4653 refreshicon (f); 4863 refreshicon (f);
4654 } 4864 }
4655#endif /* ! defined (HAVE_X11) */ 4865#endif /* ! defined (HAVE_X11) */
4866#endif /* not USE_X_TOOLKIT */
4656 4867
4657 XFlushQueue (); 4868 XFlushQueue ();
4658 UNBLOCK_INPUT; 4869 UNBLOCK_INPUT;
@@ -4668,6 +4879,10 @@ x_destroy_window (f)
4668 if (f->display.x->icon_desc != 0) 4879 if (f->display.x->icon_desc != 0)
4669 XDestroyWindow (XDISPLAY f->display.x->icon_desc); 4880 XDestroyWindow (XDISPLAY f->display.x->icon_desc);
4670 XDestroyWindow (XDISPLAY f->display.x->window_desc); 4881 XDestroyWindow (XDISPLAY f->display.x->window_desc);
4882#ifdef USE_X_TOOLKIT
4883 XtDestroyWidget (f->display.x->widget);
4884#endif /* USE_X_TOOLKIT */
4885
4671 free_frame_faces (f); 4886 free_frame_faces (f);
4672 XFlushQueue (); 4887 XFlushQueue ();
4673 4888
@@ -4768,7 +4983,12 @@ x_wm_set_size_hint (f, prompting, spec_x, spec_y)
4768 int spec_x, spec_y; 4983 int spec_x, spec_y;
4769{ 4984{
4770 XSizeHints size_hints; 4985 XSizeHints size_hints;
4986
4987#ifdef USE_X_TOOLKIT
4988 Window window = XtWindow(f->display.x->widget);
4989#else /* not USE_X_TOOLKIT */
4771 Window window = FRAME_X_WINDOW (f); 4990 Window window = FRAME_X_WINDOW (f);
4991#endif /* not USE_X_TOOLKIT */
4772 4992
4773 size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */; 4993 size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
4774 4994
@@ -4842,10 +5062,10 @@ x_wm_set_size_hint (f, prompting, spec_x, spec_y)
4842 size_hints.win_gravity = NorthWestGravity; 5062 size_hints.win_gravity = NorthWestGravity;
4843 break; 5063 break;
4844 case 1: 5064 case 1:
4845 size_hints.win_gravity = SouthWestGravity; 5065 size_hints.win_gravity = NorthEastGravity;
4846 break; 5066 break;
4847 case 2: 5067 case 2:
4848 size_hints.win_gravity = NorthEastGravity; 5068 size_hints.win_gravity = SouthWestGravity;
4849 break; 5069 break;
4850 case 3: 5070 case 3:
4851 size_hints.win_gravity = SouthEastGravity; 5071 size_hints.win_gravity = SouthEastGravity;
@@ -4866,7 +5086,11 @@ x_wm_set_window_state (f, state)
4866 struct frame *f; 5086 struct frame *f;
4867 int state; 5087 int state;
4868{ 5088{
5089#ifdef USE_X_TOOLKIT
5090 Window window = XtWindow(f->display.x->widget);
5091#else /* not USE_X_TOOLKIT */
4869 Window window = FRAME_X_WINDOW (f); 5092 Window window = FRAME_X_WINDOW (f);
5093#endif /* not USE_X_TOOLKIT */
4870 5094
4871 f->display.x->wm_hints.flags |= StateHint; 5095 f->display.x->wm_hints.flags |= StateHint;
4872 f->display.x->wm_hints.initial_state = state; 5096 f->display.x->wm_hints.initial_state = state;
@@ -4907,12 +5131,33 @@ x_wm_set_icon_position (f, icon_x, icon_y)
4907 5131
4908/* Initialization. */ 5132/* Initialization. */
4909 5133
5134#ifdef USE_X_TOOLKIT
5135static XrmOptionDescRec emacs_options[] = {
5136 {"-geometry", ".geometry", XrmoptionSepArg, NULL},
5137 {"-iconic", ".iconic", XrmoptionNoArg, (XtPointer) "yes"},
5138
5139 {"-internal-border-width", "*EmacsScreen.internalBorderWidth",
5140 XrmoptionSepArg, NULL},
5141 {"-ib", "*EmacsScreen.internalBorderWidth", XrmoptionSepArg, NULL},
5142
5143 {"-T", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
5144 {"-wn", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
5145 {"-title", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
5146 {"-iconname", "*EmacsShell.iconName", XrmoptionSepArg, (XtPointer) NULL},
5147 {"-in", "*EmacsShell.iconName", XrmoptionSepArg, (XtPointer) NULL},
5148 {"-mc", "*pointerColor", XrmoptionSepArg, (XtPointer) NULL},
5149 {"-cr", "*cursorColor", XrmoptionSepArg, (XtPointer) NULL}
5150};
5151#endif /* USE_X_TOOLKIT */
5152
4910void 5153void
4911x_term_init (display_name) 5154x_term_init (display_name)
4912 char *display_name; 5155 char *display_name;
4913{ 5156{
4914 Lisp_Object frame; 5157 Lisp_Object frame;
4915 char *defaultvalue; 5158 char *defaultvalue;
5159 int argc = 0;
5160 char** argv = 0;
4916#ifndef F_SETOWN_BUG 5161#ifndef F_SETOWN_BUG
4917#ifdef F_SETOWN 5162#ifdef F_SETOWN
4918 extern int old_fcntl_owner; 5163 extern int old_fcntl_owner;
@@ -4921,7 +5166,22 @@ x_term_init (display_name)
4921 5166
4922 x_focus_frame = x_highlight_frame = 0; 5167 x_focus_frame = x_highlight_frame = 0;
4923 5168
5169#ifdef USE_X_TOOLKIT
5170 argv = XtMalloc (3 * sizeof (char *));
5171 argv [0] = "";
5172 argv [1] = "-display";
5173 argv [2] = display_name;
5174 argc = 3;
5175 Xt_app_shell = XtAppInitialize (&Xt_app_con, "Emacs",
5176 emacs_options, XtNumber(emacs_options),
5177 &argc, argv,
5178 NULL, NULL, 0);
5179 XtFree (argv);
5180 x_current_display = XtDisplay (Xt_app_shell);
5181
5182#else /* not USE_X_TOOLKIT */
4924 x_current_display = XOpenDisplay (display_name); 5183 x_current_display = XOpenDisplay (display_name);
5184#endif /* not USE_X_TOOLKIT */
4925 if (x_current_display == 0) 5185 if (x_current_display == 0)
4926 fatal ("X server %s not responding.\n\ 5186 fatal ("X server %s not responding.\n\
4927Check the DISPLAY environment variable or use \"-d\"\n", 5187Check the DISPLAY environment variable or use \"-d\"\n",