diff options
| author | Juri Linkov | 2019-09-15 23:52:22 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-09-15 23:52:22 +0300 |
| commit | 6474abc36359a438338e5d6186dbeaf24f200387 (patch) | |
| tree | 1d7a4c74483031759169d66a3b12aa722635240c /src | |
| parent | 8d30e1bce3c1bddf85272fa31b7d314ed421d29e (diff) | |
| download | emacs-6474abc36359a438338e5d6186dbeaf24f200387.tar.gz emacs-6474abc36359a438338e5d6186dbeaf24f200387.zip | |
Use images for new/close buttons in tab-bar and tab-line.
* etc/images/tabs/new.xpm:
* etc/images/tabs/close.xpm:
New files.
* lisp/tab-bar.el (tab-bar-separator): New face.
(tab-bar-separator, tab-bar-button-new, tab-bar-button-close):
Use display property with images in default values.
* lisp/tab-line.el (tab-line-button-new, tab-line-button-close):
Use display property with images in default values.
* src/xdisp.c (tab_bar_item_info): Add new arg close_p and set it
to the value of property `close' at charpos.
(get_tab_bar_item): Add new arg close_p.
(handle_tab_bar_click): Add ctrl_modifier when close_p is non-nil.
(Fdump_tab_bar_row): Fix crash for non-X builds.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index e2a4df1c008..f4386884184 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -12666,7 +12666,6 @@ display_tab_bar (struct window *w) | |||
| 12666 | struct it it; | 12666 | struct it it; |
| 12667 | Lisp_Object items; | 12667 | Lisp_Object items; |
| 12668 | int i; | 12668 | int i; |
| 12669 | bool has_menu_bar_p = FRAME_MENU_BAR_LINES (f) > 0; | ||
| 12670 | 12669 | ||
| 12671 | /* Don't do all this for graphical frames. */ | 12670 | /* Don't do all this for graphical frames. */ |
| 12672 | #ifdef HAVE_NTGUI | 12671 | #ifdef HAVE_NTGUI |
| @@ -12685,7 +12684,7 @@ display_tab_bar (struct window *w) | |||
| 12685 | 12684 | ||
| 12686 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) | 12685 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) |
| 12687 | eassert (!FRAME_WINDOW_P (f)); | 12686 | eassert (!FRAME_WINDOW_P (f)); |
| 12688 | init_iterator (&it, w, -1, -1, f->desired_matrix->rows + (has_menu_bar_p ? 1 : 0), TAB_BAR_FACE_ID); | 12687 | init_iterator (&it, w, -1, -1, f->desired_matrix->rows + (FRAME_MENU_BAR_LINES (f) > 0 ? 1 : 0), TAB_BAR_FACE_ID); |
| 12689 | it.first_visible_x = 0; | 12688 | it.first_visible_x = 0; |
| 12690 | it.last_visible_x = FRAME_PIXEL_WIDTH (f); | 12689 | it.last_visible_x = FRAME_PIXEL_WIDTH (f); |
| 12691 | #elif defined (HAVE_X_WINDOWS) /* X without toolkit. */ | 12690 | #elif defined (HAVE_X_WINDOWS) /* X without toolkit. */ |
| @@ -12695,7 +12694,7 @@ display_tab_bar (struct window *w) | |||
| 12695 | dummy window tab_bar_window. */ | 12694 | dummy window tab_bar_window. */ |
| 12696 | struct window *tab_w; | 12695 | struct window *tab_w; |
| 12697 | tab_w = XWINDOW (f->tab_bar_window); | 12696 | tab_w = XWINDOW (f->tab_bar_window); |
| 12698 | init_iterator (&it, tab_w, -1, -1, tab_w->desired_matrix->rows + (has_menu_bar_p ? 1 : 0), | 12697 | init_iterator (&it, tab_w, -1, -1, tab_w->desired_matrix->rows, |
| 12699 | TAB_BAR_FACE_ID); | 12698 | TAB_BAR_FACE_ID); |
| 12700 | it.first_visible_x = 0; | 12699 | it.first_visible_x = 0; |
| 12701 | it.last_visible_x = FRAME_PIXEL_WIDTH (f); | 12700 | it.last_visible_x = FRAME_PIXEL_WIDTH (f); |
| @@ -12705,7 +12704,7 @@ display_tab_bar (struct window *w) | |||
| 12705 | { | 12704 | { |
| 12706 | /* This is a TTY frame, i.e. character hpos/vpos are used as | 12705 | /* This is a TTY frame, i.e. character hpos/vpos are used as |
| 12707 | pixel x/y. */ | 12706 | pixel x/y. */ |
| 12708 | init_iterator (&it, w, -1, -1, f->desired_matrix->rows + (has_menu_bar_p ? 1 : 0), | 12707 | init_iterator (&it, w, -1, -1, f->desired_matrix->rows + (FRAME_MENU_BAR_LINES (f) > 0 ? 1 : 0), |
| 12709 | TAB_BAR_FACE_ID); | 12708 | TAB_BAR_FACE_ID); |
| 12710 | it.first_visible_x = 0; | 12709 | it.first_visible_x = 0; |
| 12711 | it.last_visible_x = FRAME_COLS (f); | 12710 | it.last_visible_x = FRAME_COLS (f); |
| @@ -12737,10 +12736,9 @@ display_tab_bar (struct window *w) | |||
| 12737 | if (NILP (string)) | 12736 | if (NILP (string)) |
| 12738 | break; | 12737 | break; |
| 12739 | 12738 | ||
| 12740 | /* Display the item, pad with one space. */ | ||
| 12741 | if (it.current_x < it.last_visible_x) | 12739 | if (it.current_x < it.last_visible_x) |
| 12742 | display_string (NULL, string, Qnil, 0, 0, &it, | 12740 | display_string (NULL, string, Qnil, 0, 0, &it, |
| 12743 | SCHARS (string) + 1, 0, 0, STRING_MULTIBYTE (string)); | 12741 | SCHARS (string), 0, 0, STRING_MULTIBYTE (string)); |
| 12744 | } | 12742 | } |
| 12745 | 12743 | ||
| 12746 | /* Fill out the line with spaces. */ | 12744 | /* Fill out the line with spaces. */ |
| @@ -13159,7 +13157,7 @@ redisplay_tab_bar (struct frame *f) | |||
| 13159 | GLYPH doesn't display a tab-bar item. */ | 13157 | GLYPH doesn't display a tab-bar item. */ |
| 13160 | 13158 | ||
| 13161 | static bool | 13159 | static bool |
| 13162 | tab_bar_item_info (struct frame *f, struct glyph *glyph, int *prop_idx) | 13160 | tab_bar_item_info (struct frame *f, struct glyph *glyph, int *prop_idx, bool *close_p) |
| 13163 | { | 13161 | { |
| 13164 | Lisp_Object prop; | 13162 | Lisp_Object prop; |
| 13165 | int charpos; | 13163 | int charpos; |
| @@ -13178,6 +13176,11 @@ tab_bar_item_info (struct frame *f, struct glyph *glyph, int *prop_idx) | |||
| 13178 | if (! FIXNUMP (prop)) | 13176 | if (! FIXNUMP (prop)) |
| 13179 | return false; | 13177 | return false; |
| 13180 | *prop_idx = XFIXNUM (prop); | 13178 | *prop_idx = XFIXNUM (prop); |
| 13179 | |||
| 13180 | *close_p = !NILP (Fget_text_property (make_fixnum (charpos), | ||
| 13181 | Qclose, | ||
| 13182 | f->current_tab_bar_string)); | ||
| 13183 | |||
| 13181 | return true; | 13184 | return true; |
| 13182 | } | 13185 | } |
| 13183 | 13186 | ||
| @@ -13194,7 +13197,7 @@ tab_bar_item_info (struct frame *f, struct glyph *glyph, int *prop_idx) | |||
| 13194 | 13197 | ||
| 13195 | static int | 13198 | static int |
| 13196 | get_tab_bar_item (struct frame *f, int x, int y, struct glyph **glyph, | 13199 | get_tab_bar_item (struct frame *f, int x, int y, struct glyph **glyph, |
| 13197 | int *hpos, int *vpos, int *prop_idx) | 13200 | int *hpos, int *vpos, int *prop_idx, bool *close_p) |
| 13198 | { | 13201 | { |
| 13199 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | 13202 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); |
| 13200 | struct window *w = XWINDOW (f->tab_bar_window); | 13203 | struct window *w = XWINDOW (f->tab_bar_window); |
| @@ -13207,7 +13210,7 @@ get_tab_bar_item (struct frame *f, int x, int y, struct glyph **glyph, | |||
| 13207 | 13210 | ||
| 13208 | /* Get the start of this tab-bar item's properties in | 13211 | /* Get the start of this tab-bar item's properties in |
| 13209 | f->tab_bar_items. */ | 13212 | f->tab_bar_items. */ |
| 13210 | if (!tab_bar_item_info (f, *glyph, prop_idx)) | 13213 | if (!tab_bar_item_info (f, *glyph, prop_idx, close_p)) |
| 13211 | return -1; | 13214 | return -1; |
| 13212 | 13215 | ||
| 13213 | /* Is mouse on the highlighted item? */ | 13216 | /* Is mouse on the highlighted item? */ |
| @@ -13238,6 +13241,7 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, | |||
| 13238 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | 13241 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); |
| 13239 | struct window *w = XWINDOW (f->tab_bar_window); | 13242 | struct window *w = XWINDOW (f->tab_bar_window); |
| 13240 | int hpos, vpos, prop_idx; | 13243 | int hpos, vpos, prop_idx; |
| 13244 | bool close_p; | ||
| 13241 | struct glyph *glyph; | 13245 | struct glyph *glyph; |
| 13242 | Lisp_Object enabled_p; | 13246 | Lisp_Object enabled_p; |
| 13243 | int ts; | 13247 | int ts; |
| @@ -13250,7 +13254,7 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, | |||
| 13250 | highlight, since tab-bar items are not highlighted in that | 13254 | highlight, since tab-bar items are not highlighted in that |
| 13251 | case. */ | 13255 | case. */ |
| 13252 | frame_to_window_pixel_xy (w, &x, &y); | 13256 | frame_to_window_pixel_xy (w, &x, &y); |
| 13253 | ts = get_tab_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx); | 13257 | ts = get_tab_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx, &close_p); |
| 13254 | if (ts == -1 | 13258 | if (ts == -1 |
| 13255 | || (ts != 0 && !NILP (Vmouse_highlight))) | 13259 | || (ts != 0 && !NILP (Vmouse_highlight))) |
| 13256 | return; | 13260 | return; |
| @@ -13294,7 +13298,7 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, | |||
| 13294 | event.kind = TAB_BAR_EVENT; | 13298 | event.kind = TAB_BAR_EVENT; |
| 13295 | event.frame_or_window = frame; | 13299 | event.frame_or_window = frame; |
| 13296 | event.arg = key; | 13300 | event.arg = key; |
| 13297 | event.modifiers = modifiers; | 13301 | event.modifiers = close_p ? ctrl_modifier | modifiers : modifiers; |
| 13298 | kbd_buffer_store_event (&event); | 13302 | kbd_buffer_store_event (&event); |
| 13299 | f->last_tab_bar_item = -1; | 13303 | f->last_tab_bar_item = -1; |
| 13300 | } | 13304 | } |
| @@ -13318,6 +13322,7 @@ note_tab_bar_highlight (struct frame *f, int x, int y) | |||
| 13318 | int i; | 13322 | int i; |
| 13319 | Lisp_Object enabled_p; | 13323 | Lisp_Object enabled_p; |
| 13320 | int prop_idx; | 13324 | int prop_idx; |
| 13325 | bool close_p; | ||
| 13321 | enum draw_glyphs_face draw = DRAW_IMAGE_RAISED; | 13326 | enum draw_glyphs_face draw = DRAW_IMAGE_RAISED; |
| 13322 | bool mouse_down_p; | 13327 | bool mouse_down_p; |
| 13323 | int rc; | 13328 | int rc; |
| @@ -13330,7 +13335,7 @@ note_tab_bar_highlight (struct frame *f, int x, int y) | |||
| 13330 | return; | 13335 | return; |
| 13331 | } | 13336 | } |
| 13332 | 13337 | ||
| 13333 | rc = get_tab_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx); | 13338 | rc = get_tab_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx, &close_p); |
| 13334 | if (rc < 0) | 13339 | if (rc < 0) |
| 13335 | { | 13340 | { |
| 13336 | /* Not on tab-bar item. */ | 13341 | /* Not on tab-bar item. */ |
| @@ -20803,11 +20808,13 @@ do nothing. */) | |||
| 20803 | { | 20808 | { |
| 20804 | #if defined (HAVE_WINDOW_SYSTEM) | 20809 | #if defined (HAVE_WINDOW_SYSTEM) |
| 20805 | struct frame *sf = SELECTED_FRAME (); | 20810 | struct frame *sf = SELECTED_FRAME (); |
| 20806 | struct glyph_matrix *m = XWINDOW (sf->tab_bar_window)->current_matrix; | 20811 | struct glyph_matrix *m = WINDOWP (sf->tab_bar_window) |
| 20812 | ? XWINDOW (sf->tab_bar_window)->current_matrix | ||
| 20813 | : sf->current_matrix; | ||
| 20807 | EMACS_INT vpos; | 20814 | EMACS_INT vpos; |
| 20808 | 20815 | ||
| 20809 | if (NILP (row)) | 20816 | if (NILP (row)) |
| 20810 | vpos = 0; | 20817 | vpos = WINDOWP (sf->tab_bar_window) ? 0 : FRAME_MENU_BAR_LINES (sf) > 0 ? 1 : 0; |
| 20811 | else | 20818 | else |
| 20812 | { | 20819 | { |
| 20813 | CHECK_FIXNUM (row); | 20820 | CHECK_FIXNUM (row); |