#include <Xm/Xm.h>
#include <Xm/DialogS.h>
#include <Xm/FileSB.h>
+#include <Xm/List.h>
+#include <Xm/TextF.h>
+#endif
+
+#ifdef USE_LUCID
+#include "../lwlib/xlwmenu.h"
#endif
#if !defined(NO_EDITRES)
int x_gtk_whole_detached_tool_bar;
+/* If non-zero, use Gtk+ tooltips. */
+
+static int x_gtk_use_system_tooltips;
+
/* The background and shape of the mouse pointer, and shape when not
over text or in the modeline. */
Lisp_Object Qcompound_text, Qcancel_timer;
Lisp_Object Qfont_param;
-/* In dispnew.c */
-
-extern Lisp_Object Vwindow_system_version;
-
-/* In editfns.c */
-
-extern Lisp_Object Vsystem_name;
-
-/* The below are defined in frame.c. */
-
-extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode;
-
#if GLYPH_DEBUG
int image_cache_refcount, dpyinfo_refcount;
#endif
/* Likewise, but consider only the menu bar widget. */
struct frame *
-x_menubar_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
+x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event)
{
+ Window wdesc = event->xany.window;
Lisp_Object tail, frame;
struct frame *f;
struct x_output *x;
if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
continue;
x = f->output_data.x;
- /* Match if the window is this frame's menubar. */
#ifdef USE_GTK
- if (x->menubar_widget)
- {
- GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
-
- /* This gives false positives, but the rectangle check in xterm.c
- where this is called takes care of that. */
- if (gwdesc != 0
- && (gwdesc == x->menubar_widget
- || gtk_widget_is_ancestor (x->menubar_widget, gwdesc)
- || gtk_widget_is_ancestor (gwdesc, x->menubar_widget)))
- return f;
- }
+ if (x->menubar_widget && xg_event_is_for_menubar (f, event))
+ return f;
#else
+ /* Match if the window is this frame's menubar. */
if (x->menubar_widget
&& lw_window_is_in_menubar (wdesc, x->menubar_widget))
return f;
static Lisp_Object x_default_scroll_bar_color_parameter (struct frame *,
Lisp_Object,
Lisp_Object,
- char *, char *,
+ const char *, const char *,
int);
\f
no color could be allocated. */
int
-x_defined_color (struct frame *f, char *color_name, XColor *color, int alloc_p)
+x_defined_color (struct frame *f, const char *color_name,
+ XColor *color, int alloc_p)
{
- int success_p;
+ int success_p = 0;
Display *dpy = FRAME_X_DISPLAY (f);
Colormap cmap = FRAME_X_COLORMAP (f);
BLOCK_INPUT;
- success_p = XParseColor (dpy, cmap, color_name, color);
+#ifdef USE_GTK
+ success_p = xg_check_special_colors (f, color_name, color);
+#endif
+ if (!success_p)
+ success_p = XParseColor (dpy, cmap, color_name, color);
if (success_p && alloc_p)
success_p = x_alloc_nearest_color (f, cmap, color);
UNBLOCK_INPUT;
f->output_data.x->wait_for_wm = !NILP (new_value);
}
+static void
+x_set_tool_bar_position (struct frame *f,
+ Lisp_Object new_value,
+ Lisp_Object old_value)
+{
+ if (! EQ (new_value, Qleft) && ! EQ (new_value, Qright)
+ && ! EQ (new_value, Qbottom) && ! EQ (new_value, Qtop))
+ return;
+ if (EQ (new_value, old_value)) return;
+
+#ifdef USE_GTK
+ if (xg_change_toolbar_position (f, new_value))
+ f->tool_bar_position = new_value;
+#endif
+}
+
#ifdef USE_GTK
/* Set icon from FILE for frame F. By using GTK functions the icon
}
int
-xg_set_icon_from_xpm_data (FRAME_PTR f, char **data)
+xg_set_icon_from_xpm_data (FRAME_PTR f, const char **data)
{
int result = 0;
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) data);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (data);
if (!pixbuf)
return 0;
if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor == 0)
FRAME_X_DISPLAY_INFO (f)->invisible_cursor = make_invisible_cursor (f);
-
+
if (cursor != x->text_cursor
&& x->text_cursor != 0)
XFreeCursor (dpy, x->text_cursor);
named NAME. If that is not found either, use the value DEFLT. */
static Lisp_Object
-x_default_scroll_bar_color_parameter (f, alist, prop, xprop, xclass,
- foreground_p)
- struct frame *f;
- Lisp_Object alist;
- Lisp_Object prop;
- char *xprop;
- char *xclass;
- int foreground_p;
+x_default_scroll_bar_color_parameter (struct frame *f,
+ Lisp_Object alist, Lisp_Object prop,
+ const char *xprop, const char *xclass,
+ int foreground_p)
{
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
Lisp_Object tem;
for example, but Xt doesn't). */
static void
-hack_wm_protocols (f, widget)
- FRAME_PTR f;
- Widget widget;
+hack_wm_protocols (FRAME_PTR f, Widget widget)
{
Display *dpy = XtDisplay (widget);
Window w = XtWindow (widget);
/* Create an X fontset on frame F with base font name BASE_FONTNAME. */
-char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
+const char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
/* Create an Xt fontset spec from the name of a base font.
If `motif' is True use the Motif syntax. */
char *
-xic_create_fontsetname (char *base_fontname, int motif)
+xic_create_fontsetname (const char *base_fontname, int motif)
{
const char *sep = motif ? ";" : ",";
char *fontsetname;
- the base font.
- the base font where the charset spec is replaced by -*-*.
- the same but with the family also replaced with -*-*-. */
- char *p = base_fontname;
+ const char *p = base_fontname;
int i;
for (i = 0; *p; p++)
else
{
int len;
- char *p1 = NULL, *p2 = NULL, *p3 = NULL;
+ const char *p1 = NULL, *p2 = NULL, *p3 = NULL;
char *font_allcs = NULL;
char *font_allfamilies = NULL;
char *font_all = NULL;
- char *allcs = "*-*-*-*-*-*-*";
- char *allfamilies = "-*-*-";
- char *all = "*-*-*-*-";
+ const char *allcs = "*-*-*-*-*-*-*";
+ const char *allfamilies = "-*-*-";
+ const char *all = "*-*-*-*-";
char *base;
for (i = 0, p = base_fontname; i < 8; p++)
char **missing_list;
int missing_count;
char *def_string;
- char *xlfd_format = "-*-*-medium-r-normal--%d-*-*-*-*-*";
+ const char *xlfd_format = "-*-*-medium-r-normal--%d-*-*-*-*-*";
sprintf (buf, xlfd_format, pixel_size);
missing_list = NULL;
}
if (! xfs)
{
- char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
+ const char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
missing_list = NULL;
xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort,
area.x = FRAME_PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f);
area.y = (FRAME_PIXEL_HEIGHT (f) - area.height
- FRAME_MENUBAR_HEIGHT (f)
- - FRAME_TOOLBAR_HEIGHT (f)
+ - FRAME_TOOLBAR_TOP_HEIGHT (f)
- FRAME_INTERNAL_BORDER_WIDTH (f));
XFree (needed);
BASE_FONTNAME. Called when a new Emacs fontset is chosen. */
void
-xic_set_xfontset (struct frame *f, char *base_fontname)
+xic_set_xfontset (struct frame *f, const char *base_fontname)
{
XVaNestedList attr;
XFontSet xfs;
/* Create and set up the X widget for frame F. */
static void
-x_window (f, window_prompting, minibuffer_only)
- struct frame *f;
- long window_prompting;
- int minibuffer_only;
+x_window (struct frame *f, long window_prompting, int minibuffer_only)
{
XClassHint class_hints;
XSetWindowAttributes attributes;
/* Create and set up the X window for frame F. */
void
-x_window (f)
- struct frame *f;
-
+x_window (struct frame *f)
{
XClassHint class_hints;
XSetWindowAttributes attributes;
if (! FONTP (font) && ! STRINGP (font))
{
- char *names[]
+ const char *names[]
= {
#ifdef HAVE_XFT
/* This will find the normal Xft font. */
"waitForWM", "WaitForWM", RES_TYPE_BOOLEAN);
x_default_parameter (f, parms, Qfullscreen, Qnil,
"fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
+ x_default_parameter (f, parms, Qtool_bar_position,
+ f->tool_bar_position, 0, 0, RES_TYPE_SYMBOL);
/* Compute the size of the X window. */
window_prompting = x_figure_window_size (f, parms, 1);
(Lisp_Object terminal)
{
struct x_display_info *dpyinfo = check_x_display_info (terminal);
- char *vendor = ServerVendor (dpyinfo->display);
+ const char *vendor = ServerVendor (dpyinfo->display);
if (! vendor) vendor = "";
return build_string (vendor);
static struct visual_class
{
- char *name;
+ const char *name;
int class;
}
visual_classes[] =
XVisualInfo vinfo;
strcpy (s, SDATA (value));
- dash = index (s, '-');
+ dash = strchr (s, '-');
if (dash)
{
dpyinfo->n_planes = atoi (dash + 1);
when this happens. */
static Lisp_Object
-x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms, Lisp_Object text)
+x_create_tip_frame (struct x_display_info *dpyinfo,
+ Lisp_Object parms,
+ Lisp_Object text)
{
struct frame *f;
Lisp_Object frame, tem;
change_frame_size (f, height, width, 1, 0, 0);
/* Add `tooltip' frame parameter's default value. */
- if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
- Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
- Qnil));
+ if (NILP (Fframe_parameter (frame, Qtooltip)))
+ Fmodify_frame_parameters (frame, Fcons (Fcons (Qtooltip, Qt), Qnil));
/* FIXME - can this be done in a similar way to normal frames?
http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg00641.html */
else
CHECK_NUMBER (dy);
+#ifdef USE_GTK
+ if (x_gtk_use_system_tooltips)
+ {
+ int ok;
+
+ /* Hide a previous tip, if any. */
+ Fx_hide_tip ();
+
+ BLOCK_INPUT;
+ if ((ok = xg_prepare_tooltip (f, string, &width, &height)) != 0)
+ {
+ compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
+ xg_show_tooltip (f, root_x, root_y);
+ /* This is used in Fx_hide_tip. */
+ XSETFRAME (tip_frame, f);
+ }
+ UNBLOCK_INPUT;
+ if (ok) goto start_timer;
+ }
+#endif /* USE_GTK */
+
if (NILP (last_show_tip_args))
last_show_tip_args = Fmake_vector (make_number (3), Qnil);
int count;
Lisp_Object deleted, frame, timer;
struct gcpro gcpro1, gcpro2;
+ struct frame *f;
/* Return quickly if nothing to do. */
if (NILP (tip_timer) && NILP (tip_frame))
if (!NILP (timer))
call1 (Qcancel_timer, timer);
+#ifdef USE_GTK
+ /* When using system tooltip, tip_frame is the Emacs frame on which
+ the tip is shown. */
+ f = XFRAME (frame);
+ if (FRAME_LIVE_P (f) && xg_hide_tooltip (f))
+ frame = Qnil;
+#endif
+
if (FRAMEP (frame))
{
delete_frame (frame, Qnil);
redisplay procedure is not called when a tip frame over menu
items is unmapped. Redisplay the menu manually... */
{
- struct frame *f = SELECTED_FRAME ();
- Widget w = f->output_data.x->menubar_widget;
- extern void xlwmenu_redisplay (Widget);
+ Widget w;
+ f = SELECTED_FRAME ();
+ w = f->output_data.x->menubar_widget;
if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen)
&& w != NULL)
(void)
{
#ifdef USE_GTK
- extern int use_dialog_box;
- extern int use_file_dialog;
-
if (use_dialog_box
&& use_file_dialog
&& have_menus_p ()
/* Callback for "OK" and "Cancel" on file selection dialog. */
static void
-file_dialog_cb (widget, client_data, call_data)
- Widget widget;
- XtPointer call_data, client_data;
+file_dialog_cb (Widget widget, XtPointer client_data, XtPointer call_data)
{
int *result = (int *) client_data;
XmAnyCallbackStruct *cb = (XmAnyCallbackStruct *) call_data;
in this case. */
static void
-file_dialog_unmap_cb (widget, client_data, call_data)
- Widget widget;
- XtPointer call_data, client_data;
+file_dialog_unmap_cb (Widget widget, XtPointer client_data, XtPointer call_data)
{
int *result = (int *) client_data;
*result = XmCR_CANCEL;
}
static Lisp_Object
-clean_up_file_dialog (arg)
- Lisp_Object arg;
+clean_up_file_dialog (Lisp_Object arg)
{
struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
Widget dialog = (Widget) p->pointer;
Widget dialog, text, help;
Arg al[10];
int ac = 0;
- extern XtAppContext Xt_app_con;
XmString dir_xmstring, pattern_xmstring;
int count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
font_param = Ffont_get (font, intern (":name"));
if (STRINGP (font_param))
default_name = xstrdup (SDATA (font_param));
- else
+ else
{
font_param = Fframe_parameter (frame, Qfont_param);
if (STRINGP (font_param))
default_name = xstrdup (x_last_font_name);
/* Convert fontconfig names to Gtk names, i.e. remove - before number */
- if (default_name)
+ if (default_name)
{
char *p = strrchr (default_name, '-');
if (p)
x_set_font_backend,
x_set_alpha,
x_set_sticky,
+ x_set_tool_bar_position,
};
void
Vx_cursor_fore_pixel = Qnil;
DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
- doc: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS).
-Text larger than this is clipped. */);
+ doc: /* Maximum size for tooltips.
+Value is a pair (COLUMNS . ROWS). Text larger than this is clipped. */);
Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
the tool bar buttons. */);
x_gtk_whole_detached_tool_bar = 0;
+ DEFVAR_BOOL ("x-gtk-use-system-tooltips", &x_gtk_use_system_tooltips,
+ doc: /* *If non-nil with a Gtk+ built Emacs, the Gtk+ toolip is used.
+Otherwise use Emacs own tooltip implementation.
+When using Gtk+ tooltips, the tooltip face is not used. */);
+ x_gtk_use_system_tooltips = 1;
+
Fprovide (intern_c_string ("x"), Qnil);
#ifdef USE_X_TOOLKIT
accepts --with-x-toolkit=gtk. */
Fprovide (intern_c_string ("x-toolkit"), Qnil);
Fprovide (intern_c_string ("gtk"), Qnil);
+ Fprovide (intern_c_string ("move-toolbar"), Qnil);
DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string,
doc: /* Version info for GTK+. */);