Mercurial > emacs
view lwlib/lwlib-Xlw.c @ 111413:d53ee71e7e89
Unify mouse-highlight code for all GUI and TTY sessions.
term.c: Remove static mouse_face_* variables. All users
changed.
(term_show_mouse_face, term_clear_mouse_face)
(fast_find_position, term_mouse_highlight): Functions deleted.
(tty_draw_row_with_mouse_face): New function.
(term_mouse_movement): Call note_mouse_highlight instead of
term_mouse_highlight.
nsterm.m (ns_update_window_begin, ns_update_window_end)
(ns_update_end, x_destroy_window, ns_frame_up_to_date)
(ns_dumpglyphs_box_or_relief, ns_maybe_dumpglyphs_background)
(ns_dumpglyphs_image, ns_dumpglyphs_stretch)
(ns_initialize_display_info, keyDown, mouseMoved, mouseExited):
Replace Display_Info with Mouse_HLInfo everywhere where
mouse_face_* members were accessed for mouse highlight purposes.
xterm.c (x_update_window_begin, x_update_window_end)
(x_update_end, XTframe_up_to_date, x_set_mouse_face_gc)
(handle_one_xevent, x_free_frame_resources, x_term_init): Replace
Display_Info with Mouse_HLInfo everywhere where mouse_face_*
members were accessed for mouse highlight purposes.
w32term.c (x_update_window_begin, x_update_window_end)
(x_update_end, w32_read_socket, x_free_frame_resources)
(w32_initialize_display_info): Replace Display_Info with
Mouse_HLInfo everywhere where mouse_face_* members were accessed
for mouse highlight purposes.
xdisp.c (show_mouse_face, note_mode_line_or_margin_highlight)
(note_mouse_highlight) [HAVE_WINDOW_SYSTEM]: Don't run GUI code
unless the frame is on a window-system.
(get_tool_bar_item, handle_tool_bar_click)
(note_tool_bar_highlight, draw_glyphs, erase_phys_cursor)
(show_mouse_face, clear_mouse_face, coords_in_mouse_face_p)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(x_clear_window_mouse_face, cancel_mouse_face, expose_frame):
Replace Display_Info with Mouse_HLInfo everywhere where
mouse_face_* members were accessed for mouse highlight purposes.
(coords_in_mouse_face_p): Move prototype out of the
HAVE_WINDOW_SYSTEM conditional.
(x_y_to_hpos_vpos, frame_to_window_pixel_xy): Move out of the
HAVE_WINDOW_SYSTEM block.
(try_window_id) [HAVE_GPM || MSDOS]: Call
x_clear_window_mouse_face.
(draw_row_with_mouse_face): Implementation for HAVE_WINDOW_SYSTEM
systems. Call tty_draw_row_with_mouse_face for TTY systems.
(show_mouse_face): Call draw_row_with_mouse_face, instead of
calling draw_glyphs directly.
(show_mouse_face, clear_mouse_face, coords_in_mouse_face_p)
(cursor_in_mouse_face_p, rows_from_pos_range)
(mouse_face_from_buffer_pos, mouse_face_from_string_pos)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(x_clear_window_mouse_face, cancel_mouse_face): Move out of the
HAVE_WINDOW_SYSTEM block. Ifdef away window-system specific
fragments.
(note_mouse_highlight): Call popup_activated for MSDOS as well.
Clear mouse highlight if pointer is over glyphs whose OBJECT is an
integer.
(mouse_face_from_buffer_pos): Add parentheses around && within ||.
(x_consider_frame_title, tool_bar_lines_needed): Move
prototypes to HAVE_WINDOW_SYSTEM-only part.
(get_window_cursor_type): Move inside a HAVE_WINDOW_SYSTEM-only
part. Remove "#ifdef HAVE_WINDOW_SYSTEM" from body of function.
(null_glyph_slice): Move declaration into HAVE_WINDOW_SYSTEM-only
part.
dispnew.c (mirror_make_current): Set Y coordinate of the
mode-line and header-line rows.
(init_display): Setup initial frame's output_data for text
terminal frames.
xmenu.c (popup_activated): Don't define on MSDOS, which now has
its own definition on msdos.c.
msdos.c (show_mouse_face, clear_mouse_face)
(fast_find_position, IT_note_mode_line_highlight)
(IT_note_mouse_highlight): Functions deleted.
(IT_frame_up_to_date, dos_rawgetc): Call note_mouse_highlight
instead of IT_note_mouse_highlight.
(draw_row_with_mouse_face, popup_activated): New functions.
(dos_set_window_size, draw_row_with_mouse_face, IT_update_begin)
(IT_update_end, IT_frame_up_to_date, internal_terminal_init)
(dos_rawgetc): Replace Display_Info with Mouse_HLInfo everywhere
where mouse_face_* members were accessed for mouse highlight
purposes.
msdos.h (initialize_msdos_display): Add prototype.
frame.h (MOUSE_HL_INFO): New macro.
lisp.h (Mouse_HLInfo): New data type.
xterm.h (struct x_display_info):
w32term.h (struct w32_display_info):
nsterm.h (struct ns_display_info):
termchar.h (struct tty_display_info): Use it instead of
mouse_face_* members.
dispextern.h (show_mouse_face, clear_mouse_face): Update type of
1st argument.
(frame_to_window_pixel_xy, note_mouse_highlight)
(x_clear_window_mouse_face, cancel_mouse_face, clear_mouse_face)
(show_mouse_face, cursor_in_mouse_face_p): Move prototypes out of
HAVE_WINDOW_SYSTEM conditional.
(draw_row_with_mouse_face): Declare prototype.
(tty_draw_row_with_mouse_face): Declare prototype.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 06 Nov 2010 10:28:31 +0200 |
parents | 33021b778d4d |
children | 417b1e4d63cd |
line wrap: on
line source
/* The lwlib interface to "xlwmenu" menus. Copyright (C) 1992 Lucid, Inc. Copyright (C) 1994, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the Lucid Widget Library. The Lucid Widget Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. The Lucid Widget Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <setjmp.h> #include "lisp.h" #include "lwlib-Xlw.h" #include <X11/StringDefs.h> #include <X11/IntrinsicP.h> #include <X11/ObjectP.h> #include <X11/CompositeP.h> #include <X11/Shell.h> #include "xlwmenu.h" #if 0 #include <stdio.h> /* Print the complete X resource name of widget WIDGET to stderr. This is sometimes handy to have available. */ void x_print_complete_resource_name (Widget widget) { int i; String names[100]; for (i = 0; i < 100 && widget != NULL; ++i) { names[i] = XtName (widget); widget = XtParent (widget); } for (--i; i >= 1; --i) fprintf (stderr, "%s.", names[i]); fprintf (stderr, "%s\n", names[0]); } #endif /* 0 */ /* Menu callbacks */ /* Callback XtNhighlightCallback for Lucid menus. W is the menu widget, CLIENT_DATA contains a pointer to the widget_instance for the menu, CALL_DATA contains a pointer to the widget_value structure for the highlighted menu item. The latter may be null if there isn't any highlighted menu item. */ static void highlight_hook (Widget w, XtPointer client_data, XtPointer call_data) { widget_instance *instance = (widget_instance *) client_data; if (instance->info->highlight_cb && !w->core.being_destroyed) instance->info->highlight_cb (w, instance->info->id, call_data); } static void enter_hook (Widget w, XtPointer client_data, XtPointer call_data) { highlight_hook (w, client_data, call_data); } static void leave_hook (Widget w, XtPointer client_data, XtPointer call_data) { highlight_hook (w, client_data, NULL); } static void pre_hook (Widget w, XtPointer client_data, XtPointer call_data) { widget_instance* instance = (widget_instance*)client_data; widget_value* val; if (w->core.being_destroyed) return; val = lw_get_widget_value_for_widget (instance, w); if (instance->info->pre_activate_cb) instance->info->pre_activate_cb (w, instance->info->id, val ? val->call_data : NULL); } static void pick_hook (Widget w, XtPointer client_data, XtPointer call_data) { widget_instance* instance = (widget_instance*)client_data; widget_value* contents_val = (widget_value*)call_data; widget_value* widget_val; XtPointer widget_arg; if (w->core.being_destroyed) return; if (instance->info->selection_cb && contents_val && contents_val->enabled && !contents_val->contents) instance->info->selection_cb (w, instance->info->id, contents_val->call_data); widget_val = lw_get_widget_value_for_widget (instance, w); widget_arg = widget_val ? widget_val->call_data : NULL; if (instance->info->post_activate_cb) instance->info->post_activate_cb (w, instance->info->id, widget_arg); } /* creation functions */ static Widget xlw_create_menubar (widget_instance *instance) { Widget widget; Arg al[5]; int ac = 0; XtSetArg (al[ac], XtNmenu, instance->info->val); ac++; #ifdef emacs XtSetArg (al[ac], XtNshowGrip, 0); ac++; XtSetArg (al[ac], XtNresizeToPreferred, 1); ac++; XtSetArg (al[ac], XtNallowResize, 1); ac++; #endif /* This used to use XtVaCreateWidget, but an old Xt version has a bug in XtVaCreateWidget that frees instance->info->name. */ widget = XtCreateWidget (instance->info->name, xlwMenuWidgetClass, instance->parent, al, ac); XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance); XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); XtAddCallback (widget, XtNleaveCallback, leave_hook, (XtPointer)instance); XtAddCallback (widget, XtNenterCallback, enter_hook, (XtPointer)instance); return widget; } static Widget xlw_create_popup_menu (widget_instance *instance) { Widget popup_shell = XtCreatePopupShell (instance->info->name, overrideShellWidgetClass, instance->parent, NULL, 0); Widget widget; Arg al[2]; int ac = 0; XtSetArg (al[ac], XtNmenu, instance->info->val); ac++; XtSetArg (al[ac], XtNhorizontal, False); ac++; /* This used to use XtVaManagedCreateWidget, but an old Xt version has a bug in XtVaManagedCreateWidget that frees instance->info->name. */ widget = XtCreateManagedWidget ("popup", xlwMenuWidgetClass, popup_shell, al, ac); XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); XtAddCallback (widget, XtNleaveCallback, leave_hook, (XtPointer)instance); XtAddCallback (widget, XtNenterCallback, enter_hook, (XtPointer)instance); return popup_shell; } widget_creation_entry xlw_creation_table [] = { {"menubar", xlw_create_menubar}, {"popup", xlw_create_popup_menu}, {NULL, NULL} }; Boolean lw_lucid_widget_p (Widget widget) { WidgetClass the_class = XtClass (widget); if (the_class == xlwMenuWidgetClass) return True; if (the_class == overrideShellWidgetClass) return (XtClass (((CompositeWidget)widget)->composite.children [0]) == xlwMenuWidgetClass); return False; } void xlw_update_one_widget (widget_instance* instance, Widget widget, widget_value* val, Boolean deep_p) { Arg al[1]; /* This used to use XtVaSetValues, but some old Xt versions that have a bug in XtVaCreateWidget might have it here too. */ XtSetArg (al[0], XtNmenu, instance->info->val); XtSetValues (widget, al, 1); } void xlw_update_one_value (widget_instance *instance, Widget widget, widget_value *val) { return; } void xlw_pop_instance (widget_instance* instance, Boolean up) { } void xlw_popup_menu (Widget widget, XEvent *event) { XlwMenuWidget mw; if (!XtIsShell (widget)) return; mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0]; if (event) XtCallActionProc ((Widget) mw, "start", event, NULL, 0); else { XEvent dummy; XButtonPressedEvent *bd = &dummy.xbutton; bd->type = ButtonPress; bd->serial = 0; bd->send_event = 0; bd->display = XtDisplay (widget); bd->window = XtWindow (XtParent (widget)); bd->time = CurrentTime; bd->button = 0; XQueryPointer (bd->display, bd->window, &bd->root, &bd->subwindow, &bd->x_root, &bd->y_root, &bd->x, &bd->y, &bd->state); XtCallActionProc ((Widget) mw, "start", &dummy, NULL, 0); } } /* Destruction of instances */ void xlw_destroy_instance (widget_instance *instance) { if (instance->widget) XtDestroyWidget (instance->widget); } /* arch-tag: 541e3912-477d-406e-9bf2-dbf2b7ff8c3b (do not change this comment) */