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/>. */ | |||
| 40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
| 41 | #include <sys/stat.h> | 41 | #include <sys/stat.h> |
| 42 | 42 | ||
| 43 | #ifdef USE_XCB | ||
| 44 | #include <xcb/xcb.h> | ||
| 45 | #include <xcb/xproto.h> | ||
| 46 | #include <xcb/xcb_aux.h> | ||
| 47 | #endif | ||
| 48 | |||
| 43 | #include "bitmaps/gray.xbm" | 49 | #include "bitmaps/gray.xbm" |
| 44 | #include "xsettings.h" | 50 | #include "xsettings.h" |
| 45 | 51 | ||
| @@ -2643,11 +2649,7 @@ best_xim_style (struct x_display_info *dpyinfo, | |||
| 2643 | int nr_supported = ARRAYELTS (supported_xim_styles); | 2649 | int nr_supported = ARRAYELTS (supported_xim_styles); |
| 2644 | 2650 | ||
| 2645 | if (dpyinfo->preferred_xim_style) | 2651 | if (dpyinfo->preferred_xim_style) |
| 2646 | { | 2652 | return dpyinfo->preferred_xim_style; |
| 2647 | for (j = 0; j < xim->count_styles; ++j) | ||
| 2648 | if (dpyinfo->preferred_xim_style == xim->supported_styles[j]) | ||
| 2649 | return dpyinfo->preferred_xim_style; | ||
| 2650 | } | ||
| 2651 | 2653 | ||
| 2652 | for (i = 0; i < nr_supported; ++i) | 2654 | for (i = 0; i < nr_supported; ++i) |
| 2653 | for (j = 0; j < xim->count_styles; ++j) | 2655 | for (j = 0; j < xim->count_styles; ++j) |
| @@ -3049,7 +3051,7 @@ x_xim_text_to_utf8_unix (XIMText *text, ptrdiff_t *length) | |||
| 3049 | } | 3051 | } |
| 3050 | 3052 | ||
| 3051 | nbytes = strlen (text->string.multi_byte); | 3053 | nbytes = strlen (text->string.multi_byte); |
| 3052 | setup_coding_system (Qutf_8_unix, &coding); | 3054 | setup_coding_system (Vlocale_coding_system, &coding); |
| 3053 | coding.mode |= (CODING_MODE_LAST_BLOCK | 3055 | coding.mode |= (CODING_MODE_LAST_BLOCK |
| 3054 | | CODING_MODE_SAFE_ENCODING); | 3056 | | CODING_MODE_SAFE_ENCODING); |
| 3055 | coding.source = (const unsigned char *) text->string.multi_byte; | 3057 | coding.source = (const unsigned char *) text->string.multi_byte; |
| @@ -6486,7 +6488,11 @@ void | |||
| 6486 | x_sync (struct frame *f) | 6488 | x_sync (struct frame *f) |
| 6487 | { | 6489 | { |
| 6488 | block_input (); | 6490 | block_input (); |
| 6491 | #ifndef USE_XCB | ||
| 6489 | XSync (FRAME_X_DISPLAY (f), False); | 6492 | XSync (FRAME_X_DISPLAY (f), False); |
| 6493 | #else | ||
| 6494 | xcb_aux_sync (FRAME_DISPLAY_INFO (f)->xcb_connection); | ||
| 6495 | #endif | ||
| 6490 | unblock_input (); | 6496 | unblock_input (); |
| 6491 | } | 6497 | } |
| 6492 | 6498 | ||
| @@ -7107,6 +7113,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms) | |||
| 7107 | gui_figure_window_size (f, parms, false, false); | 7113 | gui_figure_window_size (f, parms, false, false); |
| 7108 | 7114 | ||
| 7109 | { | 7115 | { |
| 7116 | #ifndef USE_XCB | ||
| 7110 | XSetWindowAttributes attrs; | 7117 | XSetWindowAttributes attrs; |
| 7111 | unsigned long mask; | 7118 | unsigned long mask; |
| 7112 | Atom type = FRAME_DISPLAY_INFO (f)->Xatom_net_window_type_tooltip; | 7119 | 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) | |||
| 7143 | XA_ATOM, 32, PropModeReplace, | 7150 | XA_ATOM, 32, PropModeReplace, |
| 7144 | (unsigned char *)&type, 1); | 7151 | (unsigned char *)&type, 1); |
| 7145 | unblock_input (); | 7152 | unblock_input (); |
| 7153 | #else | ||
| 7154 | uint32_t value_list[4]; | ||
| 7155 | xcb_atom_t net_wm_window_type_tooltip | ||
| 7156 | = (xcb_atom_t) dpyinfo->Xatom_net_window_type_tooltip; | ||
| 7157 | |||
| 7158 | f->output_data.x->current_cursor = f->output_data.x->text_cursor; | ||
| 7159 | /* Values are set in the order of their enumeration in `enum | ||
| 7160 | xcb_cw_t'. */ | ||
| 7161 | value_list[0] = FRAME_BACKGROUND_PIXEL (f); | ||
| 7162 | value_list[1] = true; | ||
| 7163 | value_list[2] = XCB_EVENT_MASK_STRUCTURE_NOTIFY; | ||
| 7164 | value_list[3] = (xcb_cursor_t) f->output_data.x->text_cursor; | ||
| 7165 | |||
| 7166 | block_input (); | ||
| 7167 | tip_window | ||
| 7168 | = FRAME_X_WINDOW (f) | ||
| 7169 | = (Window) xcb_generate_id (dpyinfo->xcb_connection); | ||
| 7170 | |||
| 7171 | xcb_create_window (dpyinfo->xcb_connection, | ||
| 7172 | XCB_COPY_FROM_PARENT, | ||
| 7173 | (xcb_window_t) tip_window, | ||
| 7174 | (xcb_window_t) dpyinfo->root_window, | ||
| 7175 | 0, 0, 1, 1, f->border_width, | ||
| 7176 | XCB_WINDOW_CLASS_INPUT_OUTPUT, | ||
| 7177 | XCB_COPY_FROM_PARENT, | ||
| 7178 | (XCB_CW_BACK_PIXEL | ||
| 7179 | | XCB_CW_OVERRIDE_REDIRECT | ||
| 7180 | | XCB_CW_EVENT_MASK | ||
| 7181 | | XCB_CW_CURSOR), | ||
| 7182 | &value_list); | ||
| 7183 | |||
| 7184 | xcb_change_property (dpyinfo->xcb_connection, | ||
| 7185 | XCB_PROP_MODE_REPLACE, | ||
| 7186 | (xcb_window_t) tip_window, | ||
| 7187 | (xcb_atom_t) dpyinfo->Xatom_net_window_type, | ||
| 7188 | (xcb_atom_t) dpyinfo->Xatom_ATOM, | ||
| 7189 | 32, 1, &net_wm_window_type_tooltip); | ||
| 7190 | |||
| 7191 | initial_set_up_x_back_buffer (f); | ||
| 7192 | unblock_input (); | ||
| 7193 | #endif | ||
| 7146 | } | 7194 | } |
| 7147 | 7195 | ||
| 7148 | x_make_gc (f); | 7196 | x_make_gc (f); |
| @@ -7361,13 +7409,13 @@ x_hide_tip (bool delete) | |||
| 7361 | } | 7409 | } |
| 7362 | 7410 | ||
| 7363 | #ifdef USE_GTK | 7411 | #ifdef USE_GTK |
| 7364 | /* Any GTK+ system tooltip can be found via the x_output structure of | 7412 | /* Any GTK+ system tooltip can be found via the x_output structure |
| 7365 | tip_last_frame, provided that frame is still live. Any Emacs | 7413 | of tip_last_frame, provided that frame is still live. Any Emacs |
| 7366 | tooltip is found via the tip_frame variable. Note that the current | 7414 | tooltip is found via the tip_frame variable. Note that the |
| 7367 | value of x_gtk_use_system_tooltips might not be the same as used | 7415 | current value of use_system_tooltips might not be the same as |
| 7368 | for the tooltip we have to hide, see Bug#30399. */ | 7416 | used for the tooltip we have to hide, see Bug#30399. */ |
| 7369 | if ((NILP (tip_last_frame) && NILP (tip_frame)) | 7417 | if ((NILP (tip_last_frame) && NILP (tip_frame)) |
| 7370 | || (!x_gtk_use_system_tooltips | 7418 | || (!use_system_tooltips |
| 7371 | && !delete | 7419 | && !delete |
| 7372 | && !NILP (tip_frame) | 7420 | && !NILP (tip_frame) |
| 7373 | && FRAME_LIVE_P (XFRAME (tip_frame)) | 7421 | && FRAME_LIVE_P (XFRAME (tip_frame)) |
| @@ -7400,7 +7448,7 @@ x_hide_tip (bool delete) | |||
| 7400 | /* When using GTK+ system tooltips (compare Bug#41200) reset | 7448 | /* When using GTK+ system tooltips (compare Bug#41200) reset |
| 7401 | tip_last_frame. It will be reassigned when showing the next | 7449 | tip_last_frame. It will be reassigned when showing the next |
| 7402 | GTK+ system tooltip. */ | 7450 | GTK+ system tooltip. */ |
| 7403 | if (x_gtk_use_system_tooltips) | 7451 | if (use_system_tooltips) |
| 7404 | tip_last_frame = Qnil; | 7452 | tip_last_frame = Qnil; |
| 7405 | 7453 | ||
| 7406 | /* Now look whether there's an Emacs tip around. */ | 7454 | /* Now look whether there's an Emacs tip around. */ |
| @@ -7410,7 +7458,7 @@ x_hide_tip (bool delete) | |||
| 7410 | 7458 | ||
| 7411 | if (FRAME_LIVE_P (f)) | 7459 | if (FRAME_LIVE_P (f)) |
| 7412 | { | 7460 | { |
| 7413 | if (delete || x_gtk_use_system_tooltips) | 7461 | if (delete || use_system_tooltips) |
| 7414 | { | 7462 | { |
| 7415 | /* Delete the Emacs tooltip frame when DELETE is true | 7463 | /* Delete the Emacs tooltip frame when DELETE is true |
| 7416 | or we change the tooltip type from an Emacs one to | 7464 | or we change the tooltip type from an Emacs one to |
| @@ -7569,7 +7617,7 @@ Text larger than the specified size is clipped. */) | |||
| 7569 | CHECK_FIXNUM (dy); | 7617 | CHECK_FIXNUM (dy); |
| 7570 | 7618 | ||
| 7571 | #ifdef USE_GTK | 7619 | #ifdef USE_GTK |
| 7572 | if (x_gtk_use_system_tooltips) | 7620 | if (use_system_tooltips) |
| 7573 | { | 7621 | { |
| 7574 | bool ok; | 7622 | bool ok; |
| 7575 | 7623 | ||
| @@ -7765,9 +7813,23 @@ Text larger than the specified size is clipped. */) | |||
| 7765 | 7813 | ||
| 7766 | /* Show tooltip frame. */ | 7814 | /* Show tooltip frame. */ |
| 7767 | block_input (); | 7815 | block_input (); |
| 7816 | #ifndef USE_XCB | ||
| 7768 | XMoveResizeWindow (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f), | 7817 | XMoveResizeWindow (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f), |
| 7769 | root_x, root_y, width, height); | 7818 | root_x, root_y, width, height); |
| 7770 | XMapRaised (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f)); | 7819 | XMapRaised (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f)); |
| 7820 | #else | ||
| 7821 | uint32_t values[] = { root_x, root_y, width, height, XCB_STACK_MODE_ABOVE }; | ||
| 7822 | |||
| 7823 | xcb_configure_window (FRAME_DISPLAY_INFO (tip_f)->xcb_connection, | ||
| 7824 | (xcb_window_t) FRAME_X_WINDOW (tip_f), | ||
| 7825 | (XCB_CONFIG_WINDOW_X | ||
| 7826 | | XCB_CONFIG_WINDOW_Y | ||
| 7827 | | XCB_CONFIG_WINDOW_WIDTH | ||
| 7828 | | XCB_CONFIG_WINDOW_HEIGHT | ||
| 7829 | | XCB_CONFIG_WINDOW_STACK_MODE), &values); | ||
| 7830 | xcb_map_window (FRAME_DISPLAY_INFO (tip_f)->xcb_connection, | ||
| 7831 | (xcb_window_t) FRAME_X_WINDOW (tip_f)); | ||
| 7832 | #endif | ||
| 7771 | unblock_input (); | 7833 | unblock_input (); |
| 7772 | 7834 | ||
| 7773 | #ifdef USE_CAIRO | 7835 | #ifdef USE_CAIRO |
| @@ -8651,12 +8713,6 @@ If more space for files in the file chooser dialog is wanted, set this to nil | |||
| 8651 | to turn the additional text off. */); | 8713 | to turn the additional text off. */); |
| 8652 | x_gtk_file_dialog_help_text = true; | 8714 | x_gtk_file_dialog_help_text = true; |
| 8653 | 8715 | ||
| 8654 | DEFVAR_BOOL ("x-gtk-use-system-tooltips", x_gtk_use_system_tooltips, | ||
| 8655 | doc: /* If non-nil with a Gtk+ built Emacs, the Gtk+ tooltip is used. | ||
| 8656 | Otherwise use Emacs own tooltip implementation. | ||
| 8657 | When using Gtk+ tooltips, the tooltip face is not used. */); | ||
| 8658 | x_gtk_use_system_tooltips = true; | ||
| 8659 | |||
| 8660 | DEFVAR_LISP ("x-gtk-resize-child-frames", x_gtk_resize_child_frames, | 8716 | DEFVAR_LISP ("x-gtk-resize-child-frames", x_gtk_resize_child_frames, |
| 8661 | doc: /* If non-nil, resize child frames specially with GTK builds. | 8717 | doc: /* If non-nil, resize child frames specially with GTK builds. |
| 8662 | If this is nil, resize child frames like any other frames. This is the | 8718 | If this is nil, resize child frames like any other frames. This is the |