From 6bbe6da82dd61d050a773602f272dc4750291302 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 10 Oct 2013 14:06:17 +0400 Subject: [PATCH] * keyboard.c (last_event_timestamp): Remove. For X selection and GTK popup menus, it may be obtained from per-frame X display info. (kbd_buffer_store_event_hold, kbd_buffer_get_event) (process_special_events): Adjust users. * keyboard.h (last_event_timestamp): Remove declaration. * xmenu.c (xmenu_show, create_and_show_popup_menu): Lost last arg. Use FRAME_DISPLAY_INFO (f)->last_user_time for gtk_menu_popup. * menu.h (xmenu_show): Adjust prototype. * menu.c (Fx_popup_menu): Adjust user. * xselect.c (x_own_selection, x_get_foreign_selection) (Fx_disown_selection_internal): Use dpyinfo->last_user_time. --- src/ChangeLog | 14 ++++++++++++++ src/keyboard.c | 10 ---------- src/keyboard.h | 4 ---- src/menu.c | 7 +------ src/menu.h | 2 +- src/xmenu.c | 14 +++++++------- src/xselect.c | 6 +++--- 7 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index d5862485a76..bdf3a9fb09f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2013-10-10 Dmitry Antipov + + * keyboard.c (last_event_timestamp): Remove. For X selection and + GTK popup menus, it may be obtained from per-frame X display info. + (kbd_buffer_store_event_hold, kbd_buffer_get_event) + (process_special_events): Adjust users. + * keyboard.h (last_event_timestamp): Remove declaration. + * xmenu.c (xmenu_show, create_and_show_popup_menu): Lost last arg. + Use FRAME_DISPLAY_INFO (f)->last_user_time for gtk_menu_popup. + * menu.h (xmenu_show): Adjust prototype. + * menu.c (Fx_popup_menu): Adjust user. + * xselect.c (x_own_selection, x_get_foreign_selection) + (Fx_disown_selection_internal): Use dpyinfo->last_user_time. + 2013-10-10 Dmitry Antipov * keyboard.c (init_kboard): Now static. Add arg diff --git a/src/keyboard.c b/src/keyboard.c index 9d0ce14ce6f..e0cd4d4fda0 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -218,10 +218,6 @@ static ptrdiff_t last_point_position; 'volatile' here. */ Lisp_Object internal_last_event_frame; -/* The timestamp of the last input event we received from the X server. - X Windows wants this for selection ownership. */ -Time last_event_timestamp; - static Lisp_Object Qx_set_selection, Qhandle_switch_frame; static Lisp_Object Qhandle_select_window; Lisp_Object QPRIMARY; @@ -3632,8 +3628,6 @@ kbd_buffer_store_event_hold (register struct input_event *event, Vlast_event_frame = focus; } - last_event_timestamp = event->timestamp; - handle_interrupt (0); return; } @@ -3938,8 +3932,6 @@ kbd_buffer_get_event (KBOARD **kbp, ? kbd_fetch_ptr : kbd_buffer); - last_event_timestamp = event->timestamp; - *kbp = event_to_kboard (event); if (*kbp == 0) *kbp = current_kboard; /* Better than returning null ptr? */ @@ -4301,8 +4293,6 @@ process_special_events (void) else kbd_fetch_ptr++; - /* X wants last_event_timestamp for selection ownership. */ - last_event_timestamp = copy.timestamp; input_pending = readable_events (0); x_handle_selection_event (©); #else diff --git a/src/keyboard.h b/src/keyboard.h index 26cb862e8a0..6f5593bdf65 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -496,10 +496,6 @@ extern Lisp_Object QCtoggle, QCradio; speed up parse_modifiers. */ extern Lisp_Object Qevent_symbol_element_mask; -/* The timestamp of the last input event we received from the X server. - X Windows wants this for selection ownership. */ -extern Time last_event_timestamp; - extern int quit_char; extern unsigned int timers_run; diff --git a/src/menu.c b/src/menu.c index 9e135b56ce5..d87d495f96b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1440,14 +1440,9 @@ no quit occurs and `x-popup-menu' returns nil. */) else #endif #if (defined (HAVE_X_WINDOWS) || defined (MSDOS)) - /* Assume last_event_timestamp is the timestamp of the button event. - Is this assumption ever violated? We can't use the timestamp - stored within POSITION because there the top bits from the actual - timestamp may be truncated away (Bug#4930). */ if (FRAME_X_P (f) || FRAME_MSDOS_P (f)) selection = xmenu_show (f, xpos, ypos, for_click, - keymaps, title, &error_name, - last_event_timestamp); + keymaps, title, &error_name); else #endif if (FRAME_TERMCAP_P (f)) diff --git a/src/menu.h b/src/menu.h index c83f7431c45..17d66290647 100644 --- a/src/menu.h +++ b/src/menu.h @@ -50,7 +50,7 @@ extern Lisp_Object w32_menu_show (struct frame *, int, int, int, int, extern Lisp_Object ns_menu_show (struct frame *, int, int, bool, bool, Lisp_Object, const char **); extern Lisp_Object xmenu_show (struct frame *, int, int, bool, bool, - Lisp_Object, const char **, Time); + Lisp_Object, const char **); extern Lisp_Object tty_menu_show (struct frame *, int, int, int, int, Lisp_Object, int, const char **); extern ptrdiff_t menu_item_width (const unsigned char *); diff --git a/src/xmenu.c b/src/xmenu.c index fe0e229ef20..d910100f77f 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1262,8 +1262,8 @@ pop_down_menu (void *arg) menu pops down. menu_item_selection will be set to the selection. */ static void -create_and_show_popup_menu (struct frame *f, widget_value *first_wv, int x, int y, - bool for_click, Time timestamp) +create_and_show_popup_menu (struct frame *f, widget_value *first_wv, + int x, int y, bool for_click) { int i; GtkWidget *menu; @@ -1314,7 +1314,7 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, int x, int gtk_widget_show_all (menu); gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, - timestamp ? timestamp : gtk_get_current_event_time ()); + FRAME_DISPLAY_INFO (f)->last_user_time); record_unwind_protect_ptr (pop_down_menu, menu); @@ -1372,7 +1372,7 @@ pop_down_menu (Lisp_Object arg) menu_item_selection will be set to the selection. */ static void create_and_show_popup_menu (struct frame *f, widget_value *first_wv, - int x, int y, bool for_click, Time timestamp) + int x, int y, bool for_click) { int i; Arg av[2]; @@ -1451,7 +1451,7 @@ cleanup_widget_value_tree (void *arg) Lisp_Object xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, - Lisp_Object title, const char **error_name, Time timestamp) + Lisp_Object title, const char **error_name) { int i; widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; @@ -1664,7 +1664,7 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, record_unwind_protect_ptr (cleanup_widget_value_tree, first_wv); /* Actually create and show the menu until popped down. */ - create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp); + create_and_show_popup_menu (f, first_wv, x, y, for_click); unbind_to (specpdl_count, Qnil); @@ -2133,7 +2133,7 @@ pop_down_menu (Lisp_Object arg) Lisp_Object xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, - Lisp_Object title, const char **error_name, Time timestamp) + Lisp_Object title, const char **error_name) { Window root; XMenu *menu; diff --git a/src/xselect.c b/src/xselect.c index 5eb263d8d0c..b4f4f9d43b6 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -320,7 +320,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value, Window selecting_window = FRAME_X_WINDOW (f); struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); Display *display = dpyinfo->display; - Time timestamp = last_event_timestamp; + Time timestamp = dpyinfo->last_user_time; Atom selection_atom = symbol_to_x_atom (dpyinfo, selection_name); block_input (); @@ -1188,7 +1188,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); Display *display = dpyinfo->display; Window requestor_window = FRAME_X_WINDOW (f); - Time requestor_time = last_event_timestamp; + Time requestor_time = dpyinfo->last_user_time; Atom target_property = dpyinfo->Xatom_EMACS_TMP; Atom selection_atom = symbol_to_x_atom (dpyinfo, selection_symbol); Atom type_atom = (CONSP (target_type) @@ -2067,7 +2067,7 @@ On MS-DOS, all this does is return non-nil if we own the selection. */) block_input (); if (NILP (time_object)) - timestamp = last_event_timestamp; + timestamp = dpyinfo->last_user_time; else CONS_TO_INTEGER (time_object, Time, timestamp); XSetSelectionOwner (dpyinfo->display, selection_atom, None, timestamp); -- 2.39.5