Commit cc06d768 authored by Alexander Gramiak's avatar Alexander Gramiak

Define macros to abstract support for external menu/tool-bars

* src/lisp.h (HAVE_EXT_MENU_BAR)
(HAVE_EXT_TOOL_BAR): Define.

*src/dispnew.c:
*src/frame.c:
*src/frame.h:
*src/keyboard.c:
*src/menu.c:
*src/menu.h:
*src/window.c:
*src/window.h:
*src/xdisp.c:
*src/xfns: Use the new macros.
parent 7d8fe1f9
Pipeline #1007 passed with stage
in 50 minutes and 15 seconds
......@@ -767,7 +767,7 @@ clear_current_matrices (register struct frame *f)
clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix);
#endif
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
/* Clear the matrix of the tool-bar window, if any. */
if (WINDOWP (f->tool_bar_window))
clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
......@@ -792,7 +792,7 @@ clear_desired_matrices (register struct frame *f)
clear_glyph_matrix (XWINDOW (f->menu_bar_window)->desired_matrix);
#endif
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
if (WINDOWP (f->tool_bar_window))
clear_glyph_matrix (XWINDOW (f->tool_bar_window)->desired_matrix);
#endif
......@@ -2106,7 +2106,7 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f)
}
#endif
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
{
/* Allocate/ reallocate matrices of the tool bar window. If we
don't have a tool bar window yet, make one. */
......@@ -2188,7 +2188,7 @@ free_glyphs (struct frame *f)
}
#endif
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
/* Free the tool bar window and its glyph matrices. */
if (!NILP (f->tool_bar_window))
{
......@@ -3082,7 +3082,7 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p)
update_window (XWINDOW (f->menu_bar_window), true);
#endif
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
/* Update the tool-bar window, if present. */
if (WINDOWP (f->tool_bar_window))
{
......
......@@ -70,7 +70,7 @@ static struct frame *last_nonminibuf_frame;
bool frame_garbaged;
/* The default tool bar height for future frames. */
#if defined USE_GTK || defined HAVE_NS
#ifdef HAVE_EXT_TOOL_BAR
enum { frame_default_tool_bar_height = 0 };
#else
int frame_default_tool_bar_height;
......@@ -712,7 +712,7 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
FrameCols (FRAME_TTY (f)) = new_cols;
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
if (WINDOWP (f->tool_bar_window))
{
XWINDOW (f->tool_bar_window)->pixel_width = new_windows_width;
......@@ -848,7 +848,7 @@ make_frame (bool mini_p)
f->no_accept_focus = false;
f->z_group = z_group_none;
f->tooltip = false;
#if ! defined (USE_GTK) && ! defined (HAVE_NS)
#ifndef HAVE_EXT_TOOL_BAR
f->last_tool_bar_item = -1;
#endif
#ifdef NS_IMPL_COCOA
......
......@@ -181,7 +181,7 @@ struct frame
Lisp_Object menu_bar_window;
#endif
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
/* A window used to display the tool-bar of a frame. */
Lisp_Object tool_bar_window;
......@@ -209,7 +209,7 @@ struct frame
/* Cache of realized faces. */
struct face_cache *face_cache;
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
/* Tool-bar item index of the item on which a mouse button was pressed. */
int last_tool_bar_item;
#endif
......@@ -257,13 +257,13 @@ struct frame
/* Set to true when current redisplay has updated frame. */
bool_bf updated_p : 1;
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
/* Set to true to minimize tool-bar height even when
auto-resize-tool-bar is set to grow-only. */
bool_bf minimize_tool_bar_window_p : 1;
#endif
#if defined (USE_GTK) || defined (HAVE_NS)
#ifdef HAVE_EXT_TOOL_BAR
/* True means using a tool bar that comes from the toolkit. */
bool_bf external_tool_bar : 1;
#endif
......@@ -278,9 +278,8 @@ struct frame
/* True if it needs to be redisplayed. */
bool_bf redisplay : 1;
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
/* True means using a menu bar that comes from the X toolkit. */
#ifdef HAVE_EXT_MENU_BAR
/* True means using a menu bar that comes from the toolkit. */
bool_bf external_menu_bar : 1;
#endif
......@@ -714,7 +713,7 @@ fset_tool_bar_position (struct frame *f, Lisp_Object val)
f->tool_bar_position = val;
}
#endif /* USE_GTK */
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
INLINE void
fset_tool_bar_window (struct frame *f, Lisp_Object val)
{
......@@ -882,7 +881,7 @@ default_pixels_per_inch_y (void)
/* True if this frame should display a tool bar
in a way that does not use any text lines. */
#if defined (USE_GTK) || defined (HAVE_NS)
#ifdef HAVE_EXT_TOOL_BAR
#define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
#else
#define FRAME_EXTERNAL_TOOL_BAR(f) false
......@@ -911,8 +910,7 @@ default_pixels_per_inch_y (void)
/* True if this frame should display a menu bar
in a way that does not use any text lines. */
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
#ifdef HAVE_EXT_MENU_BAR
#define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
#else
#define FRAME_EXTERNAL_MENU_BAR(f) false
......@@ -1258,7 +1256,7 @@ SET_FRAME_VISIBLE (struct frame *f, int v)
extern Lisp_Object selected_frame;
extern Lisp_Object old_selected_frame;
#if ! (defined USE_GTK || defined HAVE_NS)
#ifndef HAVE_EXT_TOOL_BAR
extern int frame_default_tool_bar_height;
#endif
......
......@@ -3869,8 +3869,7 @@ kbd_buffer_get_event (KBOARD **kbp,
}
break;
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
#ifdef HAVE_EXT_MENU_BAR
case MENU_BAR_ACTIVATE_EVENT:
{
kbd_fetch_ptr = next_kbd_event (event);
......@@ -3950,8 +3949,7 @@ kbd_buffer_get_event (KBOARD **kbp,
{
obj = make_lispy_event (&event->ie);
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
#ifdef HAVE_EXT_MENU_BAR
/* If this was a menu selection, then set the flag to inhibit
writing to last_nonmenu_event. Don't do this if the event
we're returning is (menu-bar), though; that indicates the
......@@ -5232,7 +5230,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
static bool
toolkit_menubar_in_use (struct frame *f)
{
#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI)
#ifdef HAVE_EXT_MENU_BAR
return !(!FRAME_WINDOW_P (f));
#else
return false;
......@@ -5925,8 +5923,7 @@ make_lispy_event (struct input_event *event)
return list3 (head, position, files);
}
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
#ifdef HAVE_EXT_MENU_BAR
case MENU_BAR_EVENT:
if (EQ (event->arg, event->frame_or_window))
/* This is the prefix key. We translate this to
......@@ -8136,7 +8133,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
if (menu_separator_name_p (SSDATA (caption)))
{
set_prop (TOOL_BAR_ITEM_TYPE, Qt);
#if !defined (USE_GTK) && !defined (HAVE_NS)
#ifndef HAVE_EXT_TOOL_BAR
/* If we use build_desired_tool_bar_string to render the
tool bar, the separator is rendered as an image. */
set_prop (TOOL_BAR_ITEM_IMAGES,
......
......@@ -3327,6 +3327,17 @@ extern int staticidx;
struct window;
struct frame;
/* Define if the windowing system provides a menu bar. */
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
#define HAVE_EXT_MENU_BAR true
#endif
/* Define if the windowing system provides a tool-bar. */
#if defined (USE_GTK) || defined (HAVE_NS)
#define HAVE_EXT_TOOL_BAR true
#endif
/* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET. */
INLINE void
......
......@@ -170,8 +170,7 @@ ensure_menu_items (int items)
}
}
#if (defined USE_X_TOOLKIT || defined USE_GTK || defined HAVE_NS \
|| defined HAVE_NTGUI)
#ifdef HAVE_EXT_MENU_BAR
/* Begin a submenu. */
......@@ -195,7 +194,7 @@ push_submenu_end (void)
menu_items_submenu_depth--;
}
#endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NS || defined HAVE_NTGUI */
#endif /* HAVE_EXT_MENU_BAR */
/* Indicate boundary between left and right. */
......
......@@ -35,8 +35,7 @@ extern void discard_menu_items (void);
extern void save_menu_items (void);
extern bool parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object);
extern void list_of_panes (Lisp_Object);
#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS)
#ifdef HAVE_EXT_MENU_BAR
extern void free_menubar_widget_value_tree (widget_value *);
extern void update_submenu_strings (widget_value *);
extern void find_and_call_menu_selection (struct frame *, int,
......
......@@ -1599,7 +1599,7 @@ window_from_coordinates (struct frame *f, int x, int y,
cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
foreach_window (f, check_window_containing, &cw);
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
/* If not found above, see if it's in the tool bar window, if a tool
bar exists. */
if (NILP (window)
......@@ -6398,7 +6398,7 @@ and redisplay normally--don't erase and redraw the frame. */)
/* Invalidate pixel data calculated for all compositions. */
for (i = 0; i < n_compositions; i++)
composition_table[i]->font = NULL;
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
WINDOW_XFRAME (w)->minimize_tool_bar_window_p = 1;
#endif
Fredraw_frame (WINDOW_FRAME (w));
......
......@@ -739,7 +739,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
#endif
/* True if W is a tool bar window. */
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
#define WINDOW_TOOL_BAR_P(W) \
(WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
&& (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
......
......@@ -12237,8 +12237,7 @@ update_menu_bar (struct frame *f, bool save_match_data, bool hooks_run)
if (FRAME_WINDOW_P (f)
?
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
#ifdef HAVE_EXT_MENU_BAR
FRAME_EXTERNAL_MENU_BAR (f)
#else
FRAME_MENU_BAR_LINES (f) > 0
......@@ -12291,8 +12290,7 @@ update_menu_bar (struct frame *f, bool save_match_data, bool hooks_run)
fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f)));
/* Redisplay the menu bar in case we changed it. */
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
#ifdef HAVE_EXT_MENU_BAR
if (FRAME_WINDOW_P (f))
{
#if defined (HAVE_NS)
......@@ -12306,11 +12304,11 @@ update_menu_bar (struct frame *f, bool save_match_data, bool hooks_run)
/* On a terminal screen, the menu bar is an ordinary screen
line, and this makes it get updated. */
w->update_mode_line = true;
#else /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
#else /* ! (HAVE_EXT_MENU_BAR) */
/* In the non-toolkit version, the menu bar is an ordinary screen
line, and this makes it get updated. */
w->update_mode_line = true;
#endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
#endif /* HAVE_EXT_MENU_BAR */
unbind_to (count, Qnil);
set_buffer_internal_1 (prev);
......@@ -12348,7 +12346,7 @@ fast_set_selected_frame (Lisp_Object frame)
static void
update_tool_bar (struct frame *f, bool save_match_data)
{
#if defined (USE_GTK) || defined (HAVE_NS)
#ifdef HAVE_EXT_TOOL_BAR
bool do_update = FRAME_EXTERNAL_TOOL_BAR (f);
#else
bool do_update = (WINDOWP (f->tool_bar_window)
......@@ -12433,7 +12431,7 @@ update_tool_bar (struct frame *f, bool save_match_data)
}
}
#if ! defined (USE_GTK) && ! defined (HAVE_NS)
#ifndef HAVE_EXT_TOOL_BAR
/* Set F->desired_tool_bar_string to a Lisp string representing frame
F's desired tool-bar contents. F->tool_bar_items must have
......@@ -12768,7 +12766,7 @@ tool_bar_height (struct frame *f, int *n_rows, bool pixelwise)
return (it.current_y + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f);
}
#endif /* !USE_GTK && !HAVE_NS */
#endif /* ! (HAVE_EXT_TOOL_BAR) */
DEFUN ("tool-bar-height", Ftool_bar_height, Stool_bar_height,
0, 2, 0,
......@@ -12779,7 +12777,7 @@ PIXELWISE non-nil means return the height of the tool bar in pixels. */)
{
int height = 0;
#if ! defined (USE_GTK) && ! defined (HAVE_NS)
#ifndef HAVE_EXT_TOOL_BAR
struct frame *f = decode_any_frame (frame);
if (WINDOWP (f->tool_bar_window)
......@@ -12804,13 +12802,13 @@ static bool
redisplay_tool_bar (struct frame *f)
{
f->tool_bar_redisplayed = true;
#if defined (USE_GTK) || defined (HAVE_NS)
#ifdef HAVE_EXT_TOOL_BAR
if (FRAME_EXTERNAL_TOOL_BAR (f))
update_frame_tool_bar (f);
return false;
#else /* !USE_GTK && !HAVE_NS */
#else /* ! (HAVE_EXT_TOOL_BAR) */
struct window *w;
struct it it;
......@@ -12959,10 +12957,10 @@ redisplay_tool_bar (struct frame *f)
f->minimize_tool_bar_window_p = false;
return false;
#endif /* USE_GTK || HAVE_NS */
#endif /* HAVE_EXT_TOOL_BAR */
}
#if ! defined (USE_GTK) && ! defined (HAVE_NS)
#ifndef HAVE_EXT_TOOL_BAR
/* Get information about the tool-bar item which is displayed in GLYPH
on frame F. Return in *PROP_IDX the index where tool-bar item
......@@ -13200,7 +13198,7 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
help_echo_string = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_CAPTION);
}
#endif /* !USE_GTK && !HAVE_NS */
#endif /* ! (HAVE_EXT_TOOL_BAR) */
#endif /* HAVE_WINDOW_SYSTEM */
......@@ -17658,8 +17656,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
if (FRAME_WINDOW_P (f))
{
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
#ifdef HAVE_EXT_MENU_BAR
redisplay_menu_p = FRAME_EXTERNAL_MENU_BAR (f);
#else
redisplay_menu_p = FRAME_MENU_BAR_LINES (f) > 0;
......@@ -17674,7 +17671,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
{
#if defined (USE_GTK) || defined (HAVE_NS)
#ifdef HAVE_EXT_TOOL_BAR
if (FRAME_EXTERNAL_TOOL_BAR (f))
redisplay_tool_bar (f);
#else
......@@ -19709,7 +19706,7 @@ If there's no tool-bar, or if the tool-bar is not drawn by Emacs,
do nothing. */)
(Lisp_Object row, Lisp_Object glyphs)
{
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
struct frame *sf = SELECTED_FRAME ();
struct glyph_matrix *m = XWINDOW (sf->tool_bar_window)->current_matrix;
EMACS_INT vpos;
......@@ -20335,7 +20332,7 @@ extend_face_to_end_of_line (struct it *it)
/* Mode line and the header line don't have margins, and
likewise the frame's tool-bar window, if there is any. */
if (!(it->glyph_row->mode_line_p
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
|| (WINDOWP (f->tool_bar_window)
&& it->w == XWINDOW (f->tool_bar_window))
#endif
......@@ -30020,7 +30017,7 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
/* Change the mouse cursor. */
if (FRAME_WINDOW_P (f) && NILP (do_mouse_tracking))
{
#if ! defined (USE_GTK) && ! defined (HAVE_NS)
#ifndef HAVE_EXT_TOOL_BAR
if (draw == DRAW_NORMAL_TEXT
&& !EQ (hlinfo->mouse_face_window, f->tool_bar_window))
FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
......@@ -31422,7 +31419,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
w = XWINDOW (window);
frame_to_window_pixel_xy (w, &x, &y);
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
/* Handle tool-bar window differently since it doesn't display a
buffer. */
if (EQ (window, f->tool_bar_window))
......@@ -32447,7 +32444,7 @@ expose_frame (struct frame *f, int x, int y, int w, int h)
TRACE ((stderr, "(%d, %d, %d, %d)\n", r.x, r.y, r.width, r.height));
mouse_face_overwritten_p = expose_window_tree (XWINDOW (f->root_window), &r);
#if ! defined (USE_GTK) && ! defined (HAVE_NS)
#ifndef HAVE_EXT_TOOL_BAR
if (WINDOWP (f->tool_bar_window))
mouse_face_overwritten_p
|= expose_window (XWINDOW (f->tool_bar_window), &r);
......@@ -5132,7 +5132,7 @@ frame_geometry (Lisp_Object frame, Lisp_Object attribute)
inner_right = native_right - internal_border_width;
inner_bottom = native_bottom - internal_border_width;
#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
#ifdef HAVE_EXT_MENU_BAR
menu_bar_external = true;
menu_bar_height = FRAME_MENUBAR_HEIGHT (f);
native_top += menu_bar_height;
......@@ -5143,7 +5143,7 @@ frame_geometry (Lisp_Object frame, Lisp_Object attribute)
#endif
menu_bar_width = menu_bar_height ? native_width : 0;
#if defined (USE_GTK)
#ifdef HAVE_EXT_TOOL_BAR
tool_bar_external = true;
if (EQ (FRAME_TOOL_BAR_POSITION (f), Qleft))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment