From: Po Lu Date: Wed, 19 Jan 2022 11:06:53 +0000 (+0800) Subject: Port some X11 tooltip code to XCB X-Git-Tag: emacs-29.0.90~2948 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9693eb4aef637ba54c04a22c939028c34b38460a;p=emacs.git Port some X11 tooltip code to XCB * configure.ac: Require `xcb-aux' to be present before using XCB. * src/xfns.c (x_sync): (x_create_tip_frame): (Fx_show_tip): Port window related code to XCB. --- diff --git a/configure.ac b/configure.ac index 4b5316f4de1..6e15c1727ac 100644 --- a/configure.ac +++ b/configure.ac @@ -3722,20 +3722,24 @@ AC_SUBST(LIBOTF_LIBS) AC_SUBST(M17N_FLT_CFLAGS) AC_SUBST(M17N_FLT_LIBS) +XCB_LIBS= if test "${HAVE_X11}" = "yes"; then AC_CHECK_HEADER(X11/Xlib-xcb.h, AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes)) if test "${HAVE_XCB}" = "yes"; then AC_CHECK_LIB(X11-xcb, XGetXCBConnection, HAVE_X11_XCB=yes) if test "${HAVE_X11_XCB}" = "yes"; then - AC_DEFINE(USE_XCB, 1, + AC_CHECK_LIB(xcb-util, xcb_aux_sync, HAVE_XCB_UTIL=yes) + if test "${HAVE_XCB_UTIL}" = "yes"; then + AC_DEFINE(USE_XCB, 1, [Define to 1 if you have the XCB library and X11-XCB library for mixed - X11/XCB programming.]) - XCB_LIBS="-lX11-xcb -lxcb" - AC_SUBST(XCB_LIBS) + X11/XCB programming.]) + XCB_LIBS="-lX11-xcb -lxcb -lxcb-util" + fi fi fi fi +AC_SUBST(XCB_LIBS) ### Use -lXpm if available, unless '--with-xpm=no'. ### mingw32 doesn't use -lXpm, since it loads the library dynamically. diff --git a/src/xfns.c b/src/xfns.c index 5f0e91332b6..29dc575081c 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -40,6 +40,12 @@ along with GNU Emacs. If not, see . */ #include #include +#ifdef USE_XCB +#include +#include +#include +#endif + #include "bitmaps/gray.xbm" #include "xsettings.h" @@ -6482,7 +6488,11 @@ void x_sync (struct frame *f) { block_input (); +#ifndef USE_XCB XSync (FRAME_X_DISPLAY (f), False); +#else + xcb_aux_sync (FRAME_DISPLAY_INFO (f)->xcb_connection); +#endif unblock_input (); } @@ -7103,6 +7113,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms) gui_figure_window_size (f, parms, false, false); { +#ifndef USE_XCB XSetWindowAttributes attrs; unsigned long mask; Atom type = FRAME_DISPLAY_INFO (f)->Xatom_net_window_type_tooltip; @@ -7139,6 +7150,44 @@ x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms) XA_ATOM, 32, PropModeReplace, (unsigned char *)&type, 1); unblock_input (); +#else + uint32_t value_list[4]; + f->output_data.x->current_cursor = f->output_data.x->text_cursor; + /* Values are set in the order of their enumeration in `enum + xcb_cw_t'. */ + value_list[0] = FRAME_BACKGROUND_PIXEL (f); + value_list[1] = true; + value_list[2] = XCB_EVENT_MASK_STRUCTURE_NOTIFY; + value_list[3] = (xcb_cursor_t) f->output_data.x->text_cursor; + + block_input (); + tip_window + = FRAME_X_WINDOW (f) + = (Window) xcb_generate_id (dpyinfo->xcb_connection); + + xcb_create_window (dpyinfo->xcb_connection, + XCB_COPY_FROM_PARENT, + (xcb_window_t) tip_window, + (xcb_window_t) dpyinfo->root_window, + 0, 0, 1, 1, f->border_width, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + XCB_COPY_FROM_PARENT, + (XCB_CW_BACK_PIXEL + | XCB_CW_OVERRIDE_REDIRECT + | XCB_CW_EVENT_MASK + | XCB_CW_CURSOR), + &value_list); + + xcb_change_property (dpyinfo->xcb_connection, + XCB_PROP_MODE_REPLACE, + (xcb_window_t) tip_window, + (xcb_atom_t) dpyinfo->Xatom_net_window_type, + (xcb_atom_t) dpyinfo->Xatom_ATOM, + 32, 1, &dpyinfo->Xatom_net_window_type_tooltip); + + initial_set_up_x_back_buffer (f); + unblock_input (); +#endif } x_make_gc (f); @@ -7761,9 +7810,23 @@ Text larger than the specified size is clipped. */) /* Show tooltip frame. */ block_input (); +#ifndef USE_XCB XMoveResizeWindow (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f), root_x, root_y, width, height); XMapRaised (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f)); +#else + uint32_t values[] = { root_x, root_y, width, height, XCB_STACK_MODE_ABOVE }; + + xcb_configure_window (FRAME_DISPLAY_INFO (tip_f)->xcb_connection, + (xcb_window_t) FRAME_X_WINDOW (tip_f), + (XCB_CONFIG_WINDOW_X + | XCB_CONFIG_WINDOW_Y + | XCB_CONFIG_WINDOW_WIDTH + | XCB_CONFIG_WINDOW_HEIGHT + | XCB_CONFIG_WINDOW_STACK_MODE), &values); + xcb_map_window (FRAME_DISPLAY_INFO (tip_f)->xcb_connection, + (xcb_window_t) FRAME_X_WINDOW (tip_f)); +#endif unblock_input (); #ifdef USE_CAIRO