diff options
| author | Dmitry Antipov | 2014-05-13 18:18:54 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-05-13 18:18:54 +0400 |
| commit | d3e5c0ea8f4c5902a11b6bc36170336a7a7f01b6 (patch) | |
| tree | 62a09fcdabf646d80f7bae5bfbcd802e14c6182b /src | |
| parent | bd098f41af3d0201d6b8156ecb577dbff53fa50c (diff) | |
| download | emacs-d3e5c0ea8f4c5902a11b6bc36170336a7a7f01b6.tar.gz emacs-d3e5c0ea8f4c5902a11b6bc36170336a7a7f01b6.zip | |
If available, use Xfixes extension to do pointer blanking.
* configure.ac (HAVE_XFIXES): Define if available.
(XFIXES_CFLAGS, XFIXES_LIBS): New AC_SUBSTs.
* src/Makefile.in (XFIXES_CFLAGS, XFIXES_LIBS): New var.
* src/xfns.c (x_set_mouse_color): Do not call make_invisible_cursor here.
(make_invisible_cursor): Move to...
* src/xterm.c (make_invisible_cursor): ...here.
(x_probe_xfixes_extension, xfixes_toggle_visible_pointer)
(x_toggle_visible_pointer, x_setup_pointer_blanking): New functions.
(x_term_init): Call to x_setup_pointer_blanking.
(XTtoggle_invisible_pointer): Use blanking specific to this display.
* src/xterm.h (struct x_display_info): New member toggle_visible_pointer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/Makefile.in | 9 | ||||
| -rw-r--r-- | src/xfns.c | 32 | ||||
| -rw-r--r-- | src/xterm.c | 106 | ||||
| -rw-r--r-- | src/xterm.h | 6 |
5 files changed, 120 insertions, 46 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index cc16cf8f274..e79c163cb0c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2014-05-13 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | If available, use Xfixes extension to do pointer blanking. | ||
| 4 | * Makefile.in (XFIXES_CFLAGS, XFIXES_LIBS): New var. | ||
| 5 | * xfns.c (x_set_mouse_color): Do not call make_invisible_cursor here. | ||
| 6 | (make_invisible_cursor): Move to... | ||
| 7 | * xterm.c (make_invisible_cursor): ...here. | ||
| 8 | (x_probe_xfixes_extension, xfixes_toggle_visible_pointer) | ||
| 9 | (x_toggle_visible_pointer, x_setup_pointer_blanking): New functions. | ||
| 10 | (x_term_init): Call to x_setup_pointer_blanking. | ||
| 11 | (XTtoggle_invisible_pointer): Use blanking specific to this display. | ||
| 12 | * xterm.h (struct x_display_info): New member toggle_visible_pointer. | ||
| 13 | |||
| 1 | 2014-05-12 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 14 | 2014-05-12 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
| 2 | 15 | ||
| 3 | * xdisp.c (draw_glyphs): Set clipping to highlight boundaries. | 16 | * xdisp.c (draw_glyphs): Set clipping to highlight boundaries. |
diff --git a/src/Makefile.in b/src/Makefile.in index c35e38bb290..b4e9eae330b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -231,6 +231,9 @@ XRANDR_CFLAGS = @XRANDR_CFLAGS@ | |||
| 231 | XINERAMA_LIBS = @XINERAMA_LIBS@ | 231 | XINERAMA_LIBS = @XINERAMA_LIBS@ |
| 232 | XINERAMA_CFLAGS = @XINERAMA_CFLAGS@ | 232 | XINERAMA_CFLAGS = @XINERAMA_CFLAGS@ |
| 233 | 233 | ||
| 234 | XFIXES_LIBS = @XFIXES_LIBS@ | ||
| 235 | XFIXES_CFLAGS = @XFIXES_CFLAGS@ | ||
| 236 | |||
| 234 | ## widget.o if USE_X_TOOLKIT, otherwise empty. | 237 | ## widget.o if USE_X_TOOLKIT, otherwise empty. |
| 235 | WIDGET_OBJ=@WIDGET_OBJ@ | 238 | WIDGET_OBJ=@WIDGET_OBJ@ |
| 236 | 239 | ||
| @@ -326,8 +329,8 @@ ALL_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \ | |||
| 326 | -I$(lib) -I$(srcdir)/../lib \ | 329 | -I$(lib) -I$(srcdir)/../lib \ |
| 327 | $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ | 330 | $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ |
| 328 | $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ | 331 | $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ |
| 329 | $(PNG_CFLAGS) \ | 332 | $(PNG_CFLAGS) $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ |
| 330 | $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) \ | 333 | $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) $(XFIXES_CFLAGS) \ |
| 331 | $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ | 334 | $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ |
| 332 | $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \ | 335 | $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \ |
| 333 | $(LIBGNUTLS_CFLAGS) $(GFILENOTIFY_CFLAGS) \ | 336 | $(LIBGNUTLS_CFLAGS) $(GFILENOTIFY_CFLAGS) \ |
| @@ -407,7 +410,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ | |||
| 407 | $(LIBX_OTHER) $(LIBSOUND) \ | 410 | $(LIBX_OTHER) $(LIBSOUND) \ |
| 408 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(LIB_CLOCK_GETTIME) \ | 411 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(LIB_CLOCK_GETTIME) \ |
| 409 | $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \ | 412 | $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \ |
| 410 | $(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) \ | 413 | $(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) $(XFIXES_LIBS) \ |
| 411 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ | 414 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ |
| 412 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ | 415 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ |
| 413 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ | 416 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ |
diff --git a/src/xfns.c b/src/xfns.c index 13b4c6e7879..8e00a1cfbd6 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -577,35 +577,6 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 577 | } | 577 | } |
| 578 | } | 578 | } |
| 579 | 579 | ||
| 580 | static Cursor | ||
| 581 | make_invisible_cursor (struct frame *f) | ||
| 582 | { | ||
| 583 | Display *dpy = FRAME_X_DISPLAY (f); | ||
| 584 | static char const no_data[] = { 0 }; | ||
| 585 | Pixmap pix; | ||
| 586 | XColor col; | ||
| 587 | Cursor c = 0; | ||
| 588 | |||
| 589 | x_catch_errors (dpy); | ||
| 590 | pix = XCreateBitmapFromData (dpy, FRAME_DISPLAY_INFO (f)->root_window, | ||
| 591 | no_data, 1, 1); | ||
| 592 | if (! x_had_errors_p (dpy) && pix != None) | ||
| 593 | { | ||
| 594 | Cursor pixc; | ||
| 595 | col.pixel = 0; | ||
| 596 | col.red = col.green = col.blue = 0; | ||
| 597 | col.flags = DoRed | DoGreen | DoBlue; | ||
| 598 | pixc = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0); | ||
| 599 | if (! x_had_errors_p (dpy) && pixc != None) | ||
| 600 | c = pixc; | ||
| 601 | XFreePixmap (dpy, pix); | ||
| 602 | } | ||
| 603 | |||
| 604 | x_uncatch_errors (); | ||
| 605 | |||
| 606 | return c; | ||
| 607 | } | ||
| 608 | |||
| 609 | static void | 580 | static void |
| 610 | x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | 581 | x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
| 611 | { | 582 | { |
| @@ -723,9 +694,6 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 723 | XDefineCursor (dpy, FRAME_X_WINDOW (f), | 694 | XDefineCursor (dpy, FRAME_X_WINDOW (f), |
| 724 | f->output_data.x->current_cursor = cursor); | 695 | f->output_data.x->current_cursor = cursor); |
| 725 | 696 | ||
| 726 | if (FRAME_DISPLAY_INFO (f)->invisible_cursor == 0) | ||
| 727 | FRAME_DISPLAY_INFO (f)->invisible_cursor = make_invisible_cursor (f); | ||
| 728 | |||
| 729 | if (cursor != x->text_cursor | 697 | if (cursor != x->text_cursor |
| 730 | && x->text_cursor != 0) | 698 | && x->text_cursor != 0) |
| 731 | XFreeCursor (dpy, x->text_cursor); | 699 | XFreeCursor (dpy, x->text_cursor); |
diff --git a/src/xterm.c b/src/xterm.c index 85daee66717..5c21bfae144 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -32,6 +32,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 32 | #include "xterm.h" | 32 | #include "xterm.h" |
| 33 | #include <X11/cursorfont.h> | 33 | #include <X11/cursorfont.h> |
| 34 | 34 | ||
| 35 | /* If we have Xfixes extension, use it for pointer blanking. */ | ||
| 36 | #ifdef HAVE_XFIXES | ||
| 37 | #include <X11/extensions/Xfixes.h> | ||
| 38 | #endif | ||
| 39 | |||
| 35 | /* Load sys/types.h if not already loaded. | 40 | /* Load sys/types.h if not already loaded. |
| 36 | In some systems loading it twice is suicidal. */ | 41 | In some systems loading it twice is suicidal. */ |
| 37 | #ifndef makedev | 42 | #ifndef makedev |
| @@ -3096,16 +3101,7 @@ static void | |||
| 3096 | XTtoggle_invisible_pointer (struct frame *f, int invisible) | 3101 | XTtoggle_invisible_pointer (struct frame *f, int invisible) |
| 3097 | { | 3102 | { |
| 3098 | block_input (); | 3103 | block_input (); |
| 3099 | if (invisible) | 3104 | FRAME_DISPLAY_INFO (f)->toggle_visible_pointer (f, invisible); |
| 3100 | { | ||
| 3101 | if (FRAME_DISPLAY_INFO (f)->invisible_cursor != 0) | ||
| 3102 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 3103 | FRAME_DISPLAY_INFO (f)->invisible_cursor); | ||
| 3104 | } | ||
| 3105 | else | ||
| 3106 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 3107 | f->output_data.x->current_cursor); | ||
| 3108 | f->pointer_invisible = invisible; | ||
| 3109 | unblock_input (); | 3105 | unblock_input (); |
| 3110 | } | 3106 | } |
| 3111 | 3107 | ||
| @@ -9720,6 +9716,94 @@ my_log_handler (const gchar *log_domain, GLogLevelFlags log_level, | |||
| 9720 | } | 9716 | } |
| 9721 | #endif | 9717 | #endif |
| 9722 | 9718 | ||
| 9719 | /* Create invisible cursor on X display referred by DPYINFO. */ | ||
| 9720 | |||
| 9721 | static Cursor | ||
| 9722 | make_invisible_cursor (struct x_display_info *dpyinfo) | ||
| 9723 | { | ||
| 9724 | Display *dpy = dpyinfo->display; | ||
| 9725 | static char const no_data[] = { 0 }; | ||
| 9726 | Pixmap pix; | ||
| 9727 | XColor col; | ||
| 9728 | Cursor c = 0; | ||
| 9729 | |||
| 9730 | x_catch_errors (dpy); | ||
| 9731 | pix = XCreateBitmapFromData (dpy, dpyinfo->root_window, no_data, 1, 1); | ||
| 9732 | if (! x_had_errors_p (dpy) && pix != None) | ||
| 9733 | { | ||
| 9734 | Cursor pixc; | ||
| 9735 | col.pixel = 0; | ||
| 9736 | col.red = col.green = col.blue = 0; | ||
| 9737 | col.flags = DoRed | DoGreen | DoBlue; | ||
| 9738 | pixc = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0); | ||
| 9739 | if (! x_had_errors_p (dpy) && pixc != None) | ||
| 9740 | c = pixc; | ||
| 9741 | XFreePixmap (dpy, pix); | ||
| 9742 | } | ||
| 9743 | |||
| 9744 | x_uncatch_errors (); | ||
| 9745 | |||
| 9746 | return c; | ||
| 9747 | } | ||
| 9748 | |||
| 9749 | /* True if DPY supports Xfixes extension >= 4. */ | ||
| 9750 | |||
| 9751 | static bool | ||
| 9752 | x_probe_xfixes_extension (Display *dpy) | ||
| 9753 | { | ||
| 9754 | #ifdef HAVE_XFIXES | ||
| 9755 | int major, minor; | ||
| 9756 | return XFixesQueryVersion (dpy, &major, &minor) && major >= 4; | ||
| 9757 | #else | ||
| 9758 | return false; | ||
| 9759 | #endif /* HAVE_XFIXES */ | ||
| 9760 | } | ||
| 9761 | |||
| 9762 | /* Toggle mouse pointer visibility on frame F by using Xfixes functions. */ | ||
| 9763 | |||
| 9764 | static void | ||
| 9765 | xfixes_toggle_visible_pointer (struct frame *f, bool invisible) | ||
| 9766 | { | ||
| 9767 | #ifdef HAVE_XFIXES | ||
| 9768 | if (invisible) | ||
| 9769 | XFixesHideCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | ||
| 9770 | else | ||
| 9771 | XFixesShowCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | ||
| 9772 | f->pointer_invisible = invisible; | ||
| 9773 | #else | ||
| 9774 | emacs_abort (); | ||
| 9775 | #endif /* HAVE_XFIXES */ | ||
| 9776 | } | ||
| 9777 | |||
| 9778 | /* Toggle mouse pointer visibility on frame F by using invisible cursor. */ | ||
| 9779 | |||
| 9780 | static void | ||
| 9781 | x_toggle_visible_pointer (struct frame *f, bool invisible) | ||
| 9782 | { | ||
| 9783 | eassert (FRAME_DISPLAY_INFO (f)->invisible_cursor != 0); | ||
| 9784 | if (invisible) | ||
| 9785 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 9786 | FRAME_DISPLAY_INFO (f)->invisible_cursor); | ||
| 9787 | else | ||
| 9788 | XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 9789 | f->output_data.x->current_cursor); | ||
| 9790 | f->pointer_invisible = invisible; | ||
| 9791 | } | ||
| 9792 | |||
| 9793 | /* Setup pointer blanking, prefer Xfixes if available. */ | ||
| 9794 | |||
| 9795 | static void | ||
| 9796 | x_setup_pointer_blanking (struct x_display_info *dpyinfo) | ||
| 9797 | { | ||
| 9798 | if (x_probe_xfixes_extension (dpyinfo->display)) | ||
| 9799 | dpyinfo->toggle_visible_pointer = xfixes_toggle_visible_pointer; | ||
| 9800 | else | ||
| 9801 | { | ||
| 9802 | dpyinfo->toggle_visible_pointer = x_toggle_visible_pointer; | ||
| 9803 | dpyinfo->invisible_cursor = make_invisible_cursor (dpyinfo); | ||
| 9804 | } | ||
| 9805 | } | ||
| 9806 | |||
| 9723 | /* Current X display connection identifier. Incremented for each next | 9807 | /* Current X display connection identifier. Incremented for each next |
| 9724 | connection established. */ | 9808 | connection established. */ |
| 9725 | static unsigned x_display_id; | 9809 | static unsigned x_display_id; |
| @@ -10148,6 +10232,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10148 | gray_bits, gray_width, gray_height, | 10232 | gray_bits, gray_width, gray_height, |
| 10149 | 1, 0, 1); | 10233 | 1, 0, 1); |
| 10150 | 10234 | ||
| 10235 | x_setup_pointer_blanking (dpyinfo); | ||
| 10236 | |||
| 10151 | #ifdef HAVE_X_I18N | 10237 | #ifdef HAVE_X_I18N |
| 10152 | xim_initialize (dpyinfo, resource_name); | 10238 | xim_initialize (dpyinfo, resource_name); |
| 10153 | #endif | 10239 | #endif |
diff --git a/src/xterm.h b/src/xterm.h index 90d2e131717..3e79de10976 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -174,9 +174,13 @@ struct x_display_info | |||
| 174 | /* The cursor to use for vertical scroll bars. */ | 174 | /* The cursor to use for vertical scroll bars. */ |
| 175 | Cursor vertical_scroll_bar_cursor; | 175 | Cursor vertical_scroll_bar_cursor; |
| 176 | 176 | ||
| 177 | /* The invisible cursor used for pointer blanking. */ | 177 | /* The invisible cursor used for pointer blanking. |
| 178 | Unused if this display supports Xfixes extension. */ | ||
| 178 | Cursor invisible_cursor; | 179 | Cursor invisible_cursor; |
| 179 | 180 | ||
| 181 | /* Function used to toggle pointer visibility on this display. */ | ||
| 182 | void (*toggle_visible_pointer) (struct frame *, bool); | ||
| 183 | |||
| 180 | #ifdef USE_GTK | 184 | #ifdef USE_GTK |
| 181 | /* The GDK cursor for scroll bars and popup menus. */ | 185 | /* The GDK cursor for scroll bars and popup menus. */ |
| 182 | GdkCursor *xg_cursor; | 186 | GdkCursor *xg_cursor; |