diff options
Diffstat (limited to 'src/xfns.c')
-rw-r--r-- | src/xfns.c | 98 |
1 files changed, 77 insertions, 21 deletions
diff --git a/src/xfns.c b/src/xfns.c index ffad0bc3d1a..7123198724a 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -40,6 +40,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/stat.h> +#ifdef USE_XCB +#include <xcb/xcb.h> +#include <xcb/xproto.h> +#include <xcb/xcb_aux.h> +#endif + #include "bitmaps/gray.xbm" #include "xsettings.h" @@ -2643,11 +2649,7 @@ best_xim_style (struct x_display_info *dpyinfo, int nr_supported = ARRAYELTS (supported_xim_styles); if (dpyinfo->preferred_xim_style) - { - for (j = 0; j < xim->count_styles; ++j) - if (dpyinfo->preferred_xim_style == xim->supported_styles[j]) - return dpyinfo->preferred_xim_style; - } + return dpyinfo->preferred_xim_style; for (i = 0; i < nr_supported; ++i) for (j = 0; j < xim->count_styles; ++j) @@ -3049,7 +3051,7 @@ x_xim_text_to_utf8_unix (XIMText *text, ptrdiff_t *length) } nbytes = strlen (text->string.multi_byte); - setup_coding_system (Qutf_8_unix, &coding); + setup_coding_system (Vlocale_coding_system, &coding); coding.mode |= (CODING_MODE_LAST_BLOCK | CODING_MODE_SAFE_ENCODING); coding.source = (const unsigned char *) text->string.multi_byte; @@ -6486,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 (); } @@ -7107,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; @@ -7143,6 +7150,47 @@ 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]; + xcb_atom_t net_wm_window_type_tooltip + = (xcb_atom_t) dpyinfo->Xatom_net_window_type_tooltip; + + 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, &net_wm_window_type_tooltip); + + initial_set_up_x_back_buffer (f); + unblock_input (); +#endif } x_make_gc (f); @@ -7361,13 +7409,13 @@ x_hide_tip (bool delete) } #ifdef USE_GTK - /* Any GTK+ system tooltip can be found via the x_output structure of - tip_last_frame, provided that frame is still live. Any Emacs - tooltip is found via the tip_frame variable. Note that the current - value of x_gtk_use_system_tooltips might not be the same as used - for the tooltip we have to hide, see Bug#30399. */ + /* Any GTK+ system tooltip can be found via the x_output structure + of tip_last_frame, provided that frame is still live. Any Emacs + tooltip is found via the tip_frame variable. Note that the + current value of use_system_tooltips might not be the same as + used for the tooltip we have to hide, see Bug#30399. */ if ((NILP (tip_last_frame) && NILP (tip_frame)) - || (!x_gtk_use_system_tooltips + || (!use_system_tooltips && !delete && !NILP (tip_frame) && FRAME_LIVE_P (XFRAME (tip_frame)) @@ -7400,7 +7448,7 @@ x_hide_tip (bool delete) /* When using GTK+ system tooltips (compare Bug#41200) reset tip_last_frame. It will be reassigned when showing the next GTK+ system tooltip. */ - if (x_gtk_use_system_tooltips) + if (use_system_tooltips) tip_last_frame = Qnil; /* Now look whether there's an Emacs tip around. */ @@ -7410,7 +7458,7 @@ x_hide_tip (bool delete) if (FRAME_LIVE_P (f)) { - if (delete || x_gtk_use_system_tooltips) + if (delete || use_system_tooltips) { /* Delete the Emacs tooltip frame when DELETE is true or we change the tooltip type from an Emacs one to @@ -7569,7 +7617,7 @@ Text larger than the specified size is clipped. */) CHECK_FIXNUM (dy); #ifdef USE_GTK - if (x_gtk_use_system_tooltips) + if (use_system_tooltips) { bool ok; @@ -7765,9 +7813,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 @@ -8651,12 +8713,6 @@ If more space for files in the file chooser dialog is wanted, set this to nil to turn the additional text off. */); x_gtk_file_dialog_help_text = true; - DEFVAR_BOOL ("x-gtk-use-system-tooltips", x_gtk_use_system_tooltips, - doc: /* If non-nil with a Gtk+ built Emacs, the Gtk+ tooltip is used. -Otherwise use Emacs own tooltip implementation. -When using Gtk+ tooltips, the tooltip face is not used. */); - x_gtk_use_system_tooltips = true; - DEFVAR_LISP ("x-gtk-resize-child-frames", x_gtk_resize_child_frames, doc: /* If non-nil, resize child frames specially with GTK builds. If this is nil, resize child frames like any other frames. This is the |