*/
+/* Xt features made by Fred Pierresteguy. */
+
#define NEW_SELECTIONS
/* On 4.3 these lose if they come after xterm.h. */
#include <config.h>
+/* Need syssignal.h for various externs and definitions that may be required
+ * by some configurations for calls to signal() later in this source file.
+ */
+#include "syssignal.h"
+
#ifdef HAVE_X_WINDOWS
#include "lisp.h"
#include "buffer.h"
#include "window.h"
+#ifdef USE_X_TOOLKIT
+extern XtAppContext Xt_app_con;
+extern Widget Xt_app_shell;
+#endif /* USE_X_TOOLKIT */
+
#ifdef HAVE_X11
#define XMapWindow XMapRaised /* Raise them when mapping. */
#else /* ! defined (HAVE_X11) */
static void flashback ();
static void redraw_previous_char ();
+static unsigned int x_x_to_emacs_modifiers ();
#ifndef HAVE_X11
static void dumpqueue ();
{
int mask;
- if (updating_frame == 0
- || updating_frame != f)
- abort ();
-
BLOCK_INPUT;
#ifndef HAVE_X11
dumpqueue ();
XFreeModifiermap (mods);
}
+/* Prepare a menu-event in *RESULT for placement in the input queue. */
+
+static Lisp_Object
+construct_menu_click (result, event, f)
+ struct input_event *result;
+ XButtonEvent *event;
+ struct frame *f;
+{
+ /* Make the event type no_event; we'll change that when we decide
+ otherwise. */
+ result->kind = mouse_click;
+ XSET (result->code, Lisp_Int, event->button - Button1);
+ result->timestamp = event->time;
+ result->modifiers = (x_x_to_emacs_modifiers (event->state)
+ | (event->type == ButtonRelease
+ ? up_modifier
+ : down_modifier));
+
+ {
+ XFASTINT (result->x) = event->x;
+ XFASTINT (result->y) = -1; /* special meaning for menubar */
+ XSET (result->frame_or_window, Lisp_Frame, f);
+ }
+}
/* Convert between the modifier bits X uses and the modifier bits
Emacs uses. */
{
XSetWindowAttributes a;
unsigned long mask;
-
a.background_pixel = frame->display.x->background_pixel;
a.event_mask = (ButtonPressMask | ButtonReleaseMask
| ButtonMotionMask | PointerMotionHintMask
mask = (CWBackPixel | CWEventMask | CWCursor);
- SET_SCROLL_BAR_X_WINDOW
+#if 0
+
+ ac = 0;
+ XtSetArg (al[ac], XtNx, left); ac++;
+ XtSetArg (al[ac], XtNy, top); ac++;
+ XtSetArg (al[ac], XtNwidth, width); ac++;
+ XtSetArg (al[ac], XtNheight, height); ac++;
+ XtSetArg (al[ac], XtNborderWidth, 0); ac++;
+ sb_widget = XtCreateManagedWidget ("box",
+ boxWidgetClass,
+ frame->display.x->edit_widget, al, ac);
+ SET_SCROLL_BAR_X_WINDOW
+ (bar, sb_widget->core.window);
+#endif
+ SET_SCROLL_BAR_X_WINDOW
(bar,
XCreateWindow (x_current_display, FRAME_X_WINDOW (frame),
0, 0, 0, 0, True);
}
+/* This processes Expose events from the menubar specific X event
+ loop in menubar.c. This allows to redisplay the frame if necessary
+ when handling menubar or popup items. */
+
+void
+process_expose_from_menu (event)
+ XEvent event;
+{
+ FRAME_PTR f;
+
+ f = x_window_to_frame (event.xexpose.window);
+ if (f)
+ {
+ if (f->async_visible == 0)
+ {
+ f->async_visible = 1;
+ f->async_iconified = 0;
+ SET_FRAME_GARBAGED (f);
+ }
+ else
+ {
+ dumprectangle (x_window_to_frame (event.xexpose.window),
+ event.xexpose.x, event.xexpose.y,
+ event.xexpose.width, event.xexpose.height);
+ }
+ }
+ else
+ {
+ struct scroll_bar *bar
+ = x_window_to_scroll_bar (event.xexpose.window);
+
+ if (bar)
+ x_scroll_bar_expose (bar, &event);
+ }
+}
\f
/* The main X event-reading loop - XTread_socket. */
{
if (event.xclient.data.l[0] == Xatom_wm_take_focus)
{
+#ifdef USE_X_TOOLKIT
+ /* f = x_any_window_to_frame (event.xclient.window); */
f = x_window_to_frame (event.xclient.window);
+#else
+ f = x_window_to_frame (event.xclient.window);
+#endif
if (f)
x_focus_on_frame (f);
/* Not certain about handling scroll bars here */
#ifdef NEW_SELECTIONS
case SelectionNotify:
+#ifdef USE_X_TOOLKIT
+ if (x_window_to_frame (event.xselection.requestor))
+ x_handle_selection_notify (&event);
+ else
+ goto OTHER;
+#else /* not USE_X_TOOLKIT */
x_handle_selection_notify (&event);
+#endif /* not USE_X_TOOLKIT */
break;
-#endif
+#endif /* NEW_SELECTIONS */
case SelectionClear: /* Someone has grabbed ownership. */
#ifdef NEW_SELECTIONS
{
+#ifdef USE_X_TOOLKIT
+ if (x_window_to_frame (event.xselectionclear.window))
+ {
+#endif /* USE_X_TOOLKIT */
XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event;
if (numchars == 0)
count += 1;
numchars -= 1;
+#ifdef USE_X_TOOLKIT
}
-#else
+ else
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
+ }
+#else /* not NEW_SELECTIONS */
x_disown_selection (event.xselectionclear.window,
event.xselectionclear.selection,
event.xselectionclear.time);
-#endif
+#endif /* not NEW_SELECTIONS */
break;
case SelectionRequest: /* Someone wants our selection. */
#ifdef NEW_SELECTIONS
{
+#ifdef USE_X_TOOLKIT
+ if (x_window_to_frame (event.xselectionrequest.owner))
+ {
+#endif /* USE_X_TOOLKIT */
XSelectionRequestEvent *eventp = (XSelectionRequestEvent *) &event;
if (numchars == 0)
count += 1;
numchars -= 1;
+#ifdef USE_X_TOOLKIT
}
-#else
+ else
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
+ }
+#else /* not NEW_SELECTIONS */
x_answer_selection_request (event);
-#endif
+#endif /* not NEW_SELECTIONS */
break;
case PropertyNotify:
#ifdef NEW_SELECTIONS
+#ifdef USE_X_TOOLKIT
+ if (x_any_window_to_frame (event.xproperty.window))
+ x_handle_property_notify (&event);
+ else
+ goto OTHER;
+#else /* not USE_X_TOOLKIT */
x_handle_property_notify (&event);
-#else
+#endif /* not USE_X_TOOLKIT */
+#else /* not NEW_SELECTIONS */
/* If we're being told about a root window property, then it's
a cut buffer change. */
if (event.xproperty.window == ROOT_WINDOW)
about re-selecting. */
x_send_incremental (event);
}
-#endif
+#endif /* not NEW_SELECTIONS */
break;
case ReparentNotify:
{
struct scroll_bar *bar
= x_window_to_scroll_bar (event.xexpose.window);
-
+
if (bar)
- x_scroll_bar_expose (bar, &event);
+ x_scroll_bar_expose (bar, &event);
+#ifdef USE_X_TOOLKIT
+ else
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
}
break;
event.xgraphicsexpose.width,
event.xgraphicsexpose.height);
}
+#ifdef USE_X_TOOLKIT
+ else
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
break;
case NoExpose: /* This occurs when an XCopyArea's
if (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f))
f->async_iconified = 1;
}
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
break;
case MapNotify:
+#ifdef USE_X_TOOLKIT
+ f = x_any_window_to_frame (event.xmap.window);
+#else /* not USE_X_TOOLKIT */
f = x_window_to_frame (event.xmap.window);
+#endif /* not USE_X_TOOLKIT */
if (f)
{
f->async_visible = 1;
the frame's display structures. */
SET_FRAME_GARBAGED (f);
}
- break;
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
+ break;
/* Turn off processing if we become fully obscured. */
case VisibilityNotify:
}
else if (f == x_focus_frame)
x_new_focus_frame (0);
-
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
break;
case FocusIn:
x_focus_event_frame = f;
if (f)
x_new_focus_frame (f);
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
break;
if (f == x_focus_frame)
x_new_focus_frame (0);
}
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
break;
case FocusOut:
x_focus_event_frame = 0;
if (f && f == x_focus_frame)
x_new_focus_frame (0);
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
break;
#else /* ! defined (HAVE_X11) */
x_scroll_bar_note_movement (bar, &event);
}
}
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
break;
case ConfigureNotify:
+#ifdef USE_X_TOOLKIT
+ /* process done in widget.c */
+ goto OTHER;
+#else /* not USE_X_TOOLKIT */
f = x_window_to_frame (event.xconfigure.window);
if (f)
{
f->display.x->left_pos = event.xconfigure.x;
f->display.x->top_pos = event.xconfigure.y;
}
+#endif /* not USE_X_TOOLKIT */
break;
case ButtonPress:
if (bar)
x_scroll_bar_handle_click (bar, &event, &emacs_event);
+#ifdef USE_X_TOOLKIT
+ else
+ {
+ f = x_any_window_to_frame (event.xbutton.window);
+ if (f && event.type == ButtonPress)
+ construct_menu_click (&emacs_event,
+ &event, f);
+ }
+#endif /* USE_X_TOOLKIT */
}
if (numchars >= 1 && emacs_event.kind != no_event)
count++;
numchars--;
}
+
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
}
break;
case MappingKeyboard:
XRefreshKeyboardMapping (&event.xmapping);
}
+#ifdef USE_X_TOOLKIT
+ goto OTHER;
+#endif /* USE_X_TOOLKIT */
break;
default:
+#ifdef USE_X_TOOLKIT
+ OTHER:
+ BLOCK_INPUT;
+ XtDispatchEvent (&event);
+ UNBLOCK_INPUT;
+#endif /* USE_X_TOOLKIT */
break;
}
}
}
#endif /* ! defined (HAVE_X11) */
\f
-/* X Window sizes and positions. */
-
x_calc_absolute_position (f)
struct frame *f;
{
x_calc_absolute_position (f);
BLOCK_INPUT;
+#ifdef USE_X_TOOLKIT
+ XMoveWindow (XDISPLAY XtWindow (f->display.x->widget),
+ f->display.x->left_pos, f->display.x->top_pos);
+#else /* not USE_X_TOOLKIT */
XMoveWindow (XDISPLAY FRAME_X_WINDOW (f),
f->display.x->left_pos, f->display.x->top_pos);
+#endif /* not USE_X_TOOLKIT */
#ifdef HAVE_X11
x_wm_set_size_hint (f, 0, xoff, yoff);
#endif /* ! defined (HAVE_X11) */
pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
+#if 0
+#ifdef USE_X_TOOLKIT
+ EmacsFrameSetCharSize (f->display.x->edit_widget, cols, rows);
+#endif /* USE_X_TOOLKIT */
+#endif
#ifdef HAVE_X11
x_wm_set_size_hint (f, 0, 0, 0);
#endif /* ! defined (HAVE_X11) */
if (f->async_visible)
{
BLOCK_INPUT;
+#ifdef USE_X_TOOLKIT
+ XRaiseWindow (XDISPLAY XtWindow (f->display.x->widget));
+#else /* not USE_X_TOOLKIT */
XRaiseWindow (XDISPLAY FRAME_X_WINDOW (f));
+#endif /* not USE_X_TOOLKIT */
XFlushQueue ();
UNBLOCK_INPUT;
}
if (f->async_visible)
{
BLOCK_INPUT;
+#ifdef USE_X_TOOLKIT
+ XLowerWindow (XDISPLAY XtWindow (f->display.x->widget));
+#else /* not USE_X_TOOLKIT */
XLowerWindow (XDISPLAY FRAME_X_WINDOW (f));
+#endif /* not USE_X_TOOLKIT */
XFlushQueue ();
UNBLOCK_INPUT;
}
#ifdef HAVE_X11
if (! EQ (Vx_no_window_manager, Qt))
x_wm_set_window_state (f, NormalState);
-
+#ifdef USE_X_TOOLKIT
+ XtPopup (f->display.x->widget, XtGrabNone);
+#else /* not USE_X_TOOLKIT */
XMapWindow (XDISPLAY FRAME_X_WINDOW (f));
+#endif /* not USE_X_TOOLKIT */
if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
XMapSubwindows (x_current_display, FRAME_X_WINDOW (f));
#else /* ! defined (HAVE_X11) */
struct frame *f;
{
int mask;
+ int result;
/* Don't keep the highlight on an invisible frame. */
if (x_highlight_frame == f)
if (f->async_iconified)
return;
+#ifdef USE_X_TOOLKIT
+ BLOCK_INPUT;
+ result = XIconifyWindow (x_current_display,
+ XtWindow(f->display.x->widget),
+ DefaultScreen (x_current_display));
+ UNBLOCK_INPUT;
+
+ if (!result)
+ error ("Can't notify window manager of iconification.");
+
+ f->async_iconified = 1;
+#else /* not USE_X_TOOLKIT */
+
BLOCK_INPUT;
#ifdef HAVE_X11
refreshicon (f);
}
#endif /* ! defined (HAVE_X11) */
+#endif /* not USE_X_TOOLKIT */
XFlushQueue ();
UNBLOCK_INPUT;
if (f->display.x->icon_desc != 0)
XDestroyWindow (XDISPLAY f->display.x->icon_desc);
XDestroyWindow (XDISPLAY f->display.x->window_desc);
+#ifdef USE_X_TOOLKIT
+ XtDestroyWidget (f->display.x->widget);
+#endif /* USE_X_TOOLKIT */
+
free_frame_faces (f);
XFlushQueue ();
int spec_x, spec_y;
{
XSizeHints size_hints;
+
+#ifdef USE_X_TOOLKIT
+ Window window = XtWindow(f->display.x->widget);
+#else /* not USE_X_TOOLKIT */
Window window = FRAME_X_WINDOW (f);
+#endif /* not USE_X_TOOLKIT */
size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
size_hints.win_gravity = NorthWestGravity;
break;
case 1:
- size_hints.win_gravity = SouthWestGravity;
+ size_hints.win_gravity = NorthEastGravity;
break;
case 2:
- size_hints.win_gravity = NorthEastGravity;
+ size_hints.win_gravity = SouthWestGravity;
break;
case 3:
size_hints.win_gravity = SouthEastGravity;
struct frame *f;
int state;
{
+#ifdef USE_X_TOOLKIT
+ Window window = XtWindow(f->display.x->widget);
+#else /* not USE_X_TOOLKIT */
Window window = FRAME_X_WINDOW (f);
+#endif /* not USE_X_TOOLKIT */
f->display.x->wm_hints.flags |= StateHint;
f->display.x->wm_hints.initial_state = state;
\f
/* Initialization. */
+#ifdef USE_X_TOOLKIT
+static XrmOptionDescRec emacs_options[] = {
+ {"-geometry", ".geometry", XrmoptionSepArg, NULL},
+ {"-iconic", ".iconic", XrmoptionNoArg, (XtPointer) "yes"},
+
+ {"-internal-border-width", "*EmacsScreen.internalBorderWidth",
+ XrmoptionSepArg, NULL},
+ {"-ib", "*EmacsScreen.internalBorderWidth", XrmoptionSepArg, NULL},
+
+ {"-T", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
+ {"-wn", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
+ {"-title", "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
+ {"-iconname", "*EmacsShell.iconName", XrmoptionSepArg, (XtPointer) NULL},
+ {"-in", "*EmacsShell.iconName", XrmoptionSepArg, (XtPointer) NULL},
+ {"-mc", "*pointerColor", XrmoptionSepArg, (XtPointer) NULL},
+ {"-cr", "*cursorColor", XrmoptionSepArg, (XtPointer) NULL}
+};
+#endif /* USE_X_TOOLKIT */
+
void
x_term_init (display_name)
char *display_name;
{
Lisp_Object frame;
char *defaultvalue;
+ int argc = 0;
+ char** argv = 0;
#ifndef F_SETOWN_BUG
#ifdef F_SETOWN
extern int old_fcntl_owner;
x_focus_frame = x_highlight_frame = 0;
+#ifdef USE_X_TOOLKIT
+ argv = XtMalloc (3 * sizeof (char *));
+ argv [0] = "";
+ argv [1] = "-display";
+ argv [2] = display_name;
+ argc = 3;
+ Xt_app_shell = XtAppInitialize (&Xt_app_con, "Emacs",
+ emacs_options, XtNumber(emacs_options),
+ &argc, argv,
+ NULL, NULL, 0);
+ XtFree (argv);
+ x_current_display = XtDisplay (Xt_app_shell);
+
+#else /* not USE_X_TOOLKIT */
x_current_display = XOpenDisplay (display_name);
+#endif /* not USE_X_TOOLKIT */
if (x_current_display == 0)
fatal ("X server %s not responding.\n\
Check the DISPLAY environment variable or use \"-d\"\n",