comparison src/xterm.c @ 54650:9dc8330eda34

(x_mouse_click_focus_ignore_position): New var. (syms_of_xterm): DEFVAR_BOOL it. (ignore_next_mouse_click_timeout): New var. (handle_one_xevent): Clear it on KeyPress, set it on EnterNotify. Use it to filter mouse clicks following focus event.
author Kim F. Storm <storm@cua.dk>
date Mon, 29 Mar 2004 22:49:15 +0000
parents 66000dbe48c9
children ee25175db902
comparison
equal deleted inserted replaced
54649:d6816d5766d3 54650:9dc8330eda34
214 #endif /* USE_X_TOOLKIT */ 214 #endif /* USE_X_TOOLKIT */
215 215
216 /* Non-zero means user is interacting with a toolkit scroll bar. */ 216 /* Non-zero means user is interacting with a toolkit scroll bar. */
217 217
218 static int toolkit_scroll_bar_interaction; 218 static int toolkit_scroll_bar_interaction;
219
220 /* Non-zero means to not move point as a result of clicking on a
221 frame to focus it (when focus-follows-mouse is nil). */
222
223 int x_mouse_click_focus_ignore_position;
224
225 /* Non-zero timeout value means ignore next mouse click if it arrives
226 before that timeout elapses (i.e. as part of the same sequence of
227 events resulting from clicking on a frame to select it). */
228
229 static unsigned long ignore_next_mouse_click_timeout;
219 230
220 /* Mouse movement. 231 /* Mouse movement.
221 232
222 Formerly, we used PointerMotionHintMask (in standard_event_mask) 233 Formerly, we used PointerMotionHintMask (in standard_event_mask)
223 so that we would have to call XQueryPointer after each MotionNotify 234 so that we would have to call XQueryPointer after each MotionNotify
745 : face->foreground), 756 : face->foreground),
746 face->background, depth); 757 face->background, depth);
747 758
748 if (p->overlay_p) 759 if (p->overlay_p)
749 { 760 {
750 clipmask = XCreatePixmapFromBitmapData (display, 761 clipmask = XCreatePixmapFromBitmapData (display,
751 FRAME_X_DISPLAY_INFO (f)->root_window, 762 FRAME_X_DISPLAY_INFO (f)->root_window,
752 bits, p->wd, p->h, 763 bits, p->wd, p->h,
753 1, 0, 1); 764 1, 0, 1);
754 gcv.clip_mask = clipmask; 765 gcv.clip_mask = clipmask;
755 gcv.clip_x_origin = p->x; 766 gcv.clip_x_origin = p->x;
756 gcv.clip_y_origin = p->y; 767 gcv.clip_y_origin = p->y;
757 XChangeGC (display, gc, GCClipMask | GCClipXOrigin | GCClipYOrigin, &gcv); 768 XChangeGC (display, gc, GCClipMask | GCClipXOrigin | GCClipYOrigin, &gcv);
758 } 769 }
759 770
760 XCopyArea (display, pixmap, window, gc, 0, 0, 771 XCopyArea (display, pixmap, window, gc, 0, 0,
761 p->wd, p->h, p->x, p->y); 772 p->wd, p->h, p->x, p->y);
5723 if (! dpyinfo) 5734 if (! dpyinfo)
5724 current_finish = X_EVENT_NORMAL; 5735 current_finish = X_EVENT_NORMAL;
5725 else 5736 else
5726 { 5737 {
5727 current_count += 5738 current_count +=
5728 handle_one_xevent (dpyinfo, xev, &current_finish, 5739 handle_one_xevent (dpyinfo, xev, &current_finish,
5729 current_hold_quit); 5740 current_hold_quit);
5730 } 5741 }
5731 } 5742 }
5732 else 5743 else
5733 current_finish = x_dispatch_event (xev, xev->xany.display); 5744 current_finish = x_dispatch_event (xev, xev->xany.display);
6164 record_asynch_buffer_change (); 6175 record_asynch_buffer_change ();
6165 } 6176 }
6166 goto OTHER; 6177 goto OTHER;
6167 6178
6168 case KeyPress: 6179 case KeyPress:
6180
6181 ignore_next_mouse_click_timeout = 0;
6169 6182
6170 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) 6183 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
6171 /* Dispatch KeyPress events when in menu. */ 6184 /* Dispatch KeyPress events when in menu. */
6172 if (popup_activated ()) 6185 if (popup_activated ())
6173 goto OTHER; 6186 goto OTHER;
6524 case EnterNotify: 6537 case EnterNotify:
6525 x_detect_focus_change (dpyinfo, &event, &inev); 6538 x_detect_focus_change (dpyinfo, &event, &inev);
6526 6539
6527 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window); 6540 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window);
6528 6541
6542 if (f && x_mouse_click_focus_ignore_position)
6543 ignore_next_mouse_click_timeout = event.xmotion.time + 200;
6544
6529 #if 0 6545 #if 0
6530 if (event.xcrossing.focus) 6546 if (event.xcrossing.focus)
6531 { 6547 {
6532 /* Avoid nasty pop/raise loops. */ 6548 /* Avoid nasty pop/raise loops. */
6533 if (f && (!(f->auto_raise) 6549 if (f && (!(f->auto_raise)
6767 || f == dpyinfo->x_focus_frame) 6783 || f == dpyinfo->x_focus_frame)
6768 { 6784 {
6769 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) 6785 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
6770 if (! popup_activated ()) 6786 if (! popup_activated ())
6771 #endif 6787 #endif
6772 construct_mouse_click (&inev, &event, f); 6788 {
6789 if (ignore_next_mouse_click_timeout)
6790 {
6791 if (event.type == ButtonPress
6792 && (int)(event.xbutton.time - ignore_next_mouse_click_timeout) > 0)
6793 {
6794 ignore_next_mouse_click_timeout = 0;
6795 construct_mouse_click (&inev, &event, f);
6796 }
6797 if (event.type == ButtonRelease)
6798 ignore_next_mouse_click_timeout = 0;
6799 }
6800 else
6801 construct_mouse_click (&inev, &event, f);
6802 }
6773 } 6803 }
6774 } 6804 }
6775 else 6805 else
6776 { 6806 {
6777 struct scroll_bar *bar 6807 struct scroll_bar *bar
6915 if (do_help > 0) 6945 if (do_help > 0)
6916 { 6946 {
6917 any_help_event_p = 1; 6947 any_help_event_p = 1;
6918 gen_help_event (help_echo_string, frame, help_echo_window, 6948 gen_help_event (help_echo_string, frame, help_echo_window,
6919 help_echo_object, help_echo_pos); 6949 help_echo_object, help_echo_pos);
6920 } 6950 }
6921 else 6951 else
6922 { 6952 {
6923 help_echo_string = Qnil; 6953 help_echo_string = Qnil;
6924 gen_help_event (Qnil, frame, Qnil, Qnil, 0); 6954 gen_help_event (Qnil, frame, Qnil, Qnil, 0);
6925 } 6955 }
8227 if (yoff < 0) 8257 if (yoff < 0)
8228 f->size_hint_flags |= YNegative; 8258 f->size_hint_flags |= YNegative;
8229 f->win_gravity = NorthWestGravity; 8259 f->win_gravity = NorthWestGravity;
8230 } 8260 }
8231 x_calc_absolute_position (f); 8261 x_calc_absolute_position (f);
8232 8262
8233 BLOCK_INPUT; 8263 BLOCK_INPUT;
8234 x_wm_set_size_hint (f, (long) 0, 0); 8264 x_wm_set_size_hint (f, (long) 0, 0);
8235 8265
8236 modified_left = f->left_pos; 8266 modified_left = f->left_pos;
8237 modified_top = f->top_pos; 8267 modified_top = f->top_pos;
10348 get_bits_and_offset (dpyinfo->visual->blue_mask, 10378 get_bits_and_offset (dpyinfo->visual->blue_mask,
10349 &dpyinfo->blue_bits, &dpyinfo->blue_offset); 10379 &dpyinfo->blue_bits, &dpyinfo->blue_offset);
10350 get_bits_and_offset (dpyinfo->visual->green_mask, 10380 get_bits_and_offset (dpyinfo->visual->green_mask,
10351 &dpyinfo->green_bits, &dpyinfo->green_offset); 10381 &dpyinfo->green_bits, &dpyinfo->green_offset);
10352 } 10382 }
10353 10383
10354 /* See if a private colormap is requested. */ 10384 /* See if a private colormap is requested. */
10355 if (dpyinfo->visual == DefaultVisualOfScreen (dpyinfo->screen)) 10385 if (dpyinfo->visual == DefaultVisualOfScreen (dpyinfo->screen))
10356 { 10386 {
10357 if (dpyinfo->visual->class == PseudoColor) 10387 if (dpyinfo->visual->class == PseudoColor)
10358 { 10388 {
10822 nil means ignore them. If you encounter fonts with bogus 10852 nil means ignore them. If you encounter fonts with bogus
10823 UNDERLINE_POSITION font properties, for example 7x13 on XFree prior 10853 UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
10824 to 4.1, set this to nil. */); 10854 to 4.1, set this to nil. */);
10825 x_use_underline_position_properties = 1; 10855 x_use_underline_position_properties = 1;
10826 10856
10857 DEFVAR_BOOL ("x-mouse-click-focus-ignore-position",
10858 &x_mouse_click_focus_ignore_position,
10859 doc: /* Non-nil means that a mouse click to focus a frame does not move point.
10860 This variable is only used when the window manager requires that you
10861 click on a frame to select it (give it focus). In that case, a value
10862 of nil, means that the selected window and cursor position changes to
10863 reflect the mouse click position, while a non-nil value means that the
10864 selected window or cursor position is preserved. */);
10865 x_mouse_click_focus_ignore_position = 0;
10866
10827 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 10867 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
10828 doc: /* What X toolkit scroll bars Emacs uses. 10868 doc: /* What X toolkit scroll bars Emacs uses.
10829 A value of nil means Emacs doesn't use X toolkit scroll bars. 10869 A value of nil means Emacs doesn't use X toolkit scroll bars.
10830 Otherwise, value is a symbol describing the X toolkit. */); 10870 Otherwise, value is a symbol describing the X toolkit. */);
10831 #ifdef USE_TOOLKIT_SCROLL_BARS 10871 #ifdef USE_TOOLKIT_SCROLL_BARS