diff options
| author | Yuuki Harano | 2020-10-26 22:05:55 +0900 |
|---|---|---|
| committer | Jeff Walsh | 2020-11-24 12:24:40 +1100 |
| commit | e405404d10ef5b24e06d02f626c4bf27a3ae525d (patch) | |
| tree | 4d0e23b75fdab263a9f159e96806ea7705d3d245 /src | |
| parent | 948e2fa582ff33b58d25186ea35f41adaa9d6cbe (diff) | |
| download | emacs-e405404d10ef5b24e06d02f626c4bf27a3ae525d.tar.gz emacs-e405404d10ef5b24e06d02f626c4bf27a3ae525d.zip | |
Fix startup failure on svg-unsupported environments
* src/pgtkterm.c (pgtk_bitmap_icon): Re-port X-code.
(pgtk_term_init): Add member initialization.
* src/pgtkterm.h (struct pgtk_display_info): Add member.
(struct pgtk_output): Add member.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pgtkterm.c | 57 | ||||
| -rw-r--r-- | src/pgtkterm.h | 8 |
2 files changed, 60 insertions, 5 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 6e2c87f8210..5527b7fc2a0 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -52,6 +52,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 52 | #include "termhooks.h" | 52 | #include "termhooks.h" |
| 53 | #include "termopts.h" | 53 | #include "termopts.h" |
| 54 | #include "termchar.h" | 54 | #include "termchar.h" |
| 55 | #include "emacs-icon.h" | ||
| 55 | #include "menu.h" | 56 | #include "menu.h" |
| 56 | #include "window.h" | 57 | #include "window.h" |
| 57 | #include "keyboard.h" | 58 | #include "keyboard.h" |
| @@ -3029,25 +3030,69 @@ pgtk_scroll_run (struct window *w, struct run *run) | |||
| 3029 | static bool | 3030 | static bool |
| 3030 | pgtk_bitmap_icon (struct frame *f, Lisp_Object file) | 3031 | pgtk_bitmap_icon (struct frame *f, Lisp_Object file) |
| 3031 | { | 3032 | { |
| 3033 | ptrdiff_t bitmap_id; | ||
| 3034 | |||
| 3032 | if (FRAME_GTK_WIDGET (f) == 0) | 3035 | if (FRAME_GTK_WIDGET (f) == 0) |
| 3033 | return true; | 3036 | return true; |
| 3034 | 3037 | ||
| 3038 | /* Free up our existing icon bitmap and mask if any. */ | ||
| 3039 | if (f->output_data.pgtk->icon_bitmap > 0) | ||
| 3040 | image_destroy_bitmap (f, f->output_data.pgtk->icon_bitmap); | ||
| 3041 | f->output_data.pgtk->icon_bitmap = 0; | ||
| 3042 | |||
| 3035 | if (STRINGP (file)) | 3043 | if (STRINGP (file)) |
| 3036 | { | 3044 | { |
| 3037 | /* Use gtk_window_set_icon_from_file () if available, | 3045 | /* Use gtk_window_set_icon_from_file () if available, |
| 3038 | It's not restricted to bitmaps */ | 3046 | It's not restricted to bitmaps */ |
| 3039 | if (xg_set_icon (f, file)) | 3047 | if (xg_set_icon (f, file)) |
| 3040 | return false; | 3048 | return false; |
| 3049 | bitmap_id = image_create_bitmap_from_file (f, file); | ||
| 3050 | } | ||
| 3051 | else | ||
| 3052 | { | ||
| 3053 | /* Create the GNU bitmap and mask if necessary. */ | ||
| 3054 | if (FRAME_DISPLAY_INFO (f)->icon_bitmap_id < 0) | ||
| 3055 | { | ||
| 3056 | ptrdiff_t rc = -1; | ||
| 3041 | 3057 | ||
| 3042 | return true; | 3058 | if (xg_set_icon (f, xg_default_icon_file) |
| 3059 | || xg_set_icon_from_xpm_data (f, gnu_xpm_bits)) | ||
| 3060 | { | ||
| 3061 | FRAME_DISPLAY_INFO (f)->icon_bitmap_id = -2; | ||
| 3062 | return false; | ||
| 3063 | } | ||
| 3064 | |||
| 3065 | /* If all else fails, use the (black and white) xbm image. */ | ||
| 3066 | if (rc == -1) | ||
| 3067 | { | ||
| 3068 | rc = image_create_bitmap_from_data (f, | ||
| 3069 | (char *) gnu_xbm_bits, | ||
| 3070 | gnu_xbm_width, | ||
| 3071 | gnu_xbm_height); | ||
| 3072 | if (rc == -1) | ||
| 3073 | return true; | ||
| 3074 | |||
| 3075 | FRAME_DISPLAY_INFO (f)->icon_bitmap_id = rc; | ||
| 3076 | } | ||
| 3077 | } | ||
| 3078 | |||
| 3079 | /* The first time we create the GNU bitmap and mask, | ||
| 3080 | this increments the ref-count one extra time. | ||
| 3081 | As a result, the GNU bitmap and mask are never freed. | ||
| 3082 | That way, we don't have to worry about allocating it again. */ | ||
| 3083 | image_reference_bitmap (f, FRAME_DISPLAY_INFO (f)->icon_bitmap_id); | ||
| 3084 | |||
| 3085 | bitmap_id = FRAME_DISPLAY_INFO (f)->icon_bitmap_id; | ||
| 3043 | } | 3086 | } |
| 3044 | 3087 | ||
| 3045 | if (xg_set_icon (f, xg_default_icon_file)) | 3088 | if (FRAME_DISPLAY_INFO (f)->bitmaps[bitmap_id - 1].img != NULL) |
| 3046 | { | 3089 | { |
| 3047 | return false; | 3090 | gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), |
| 3091 | FRAME_DISPLAY_INFO (f)->bitmaps[bitmap_id - 1].img); | ||
| 3048 | } | 3092 | } |
| 3093 | f->output_data.pgtk->icon_bitmap = bitmap_id; | ||
| 3049 | 3094 | ||
| 3050 | return true; | 3095 | return false; |
| 3051 | } | 3096 | } |
| 3052 | 3097 | ||
| 3053 | 3098 | ||
| @@ -6837,6 +6882,8 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) | |||
| 6837 | dpyinfo->horizontal_scroll_bar_cursor | 6882 | dpyinfo->horizontal_scroll_bar_cursor |
| 6838 | = gdk_cursor_new_for_display (dpyinfo->gdpy, GDK_SB_H_DOUBLE_ARROW); | 6883 | = gdk_cursor_new_for_display (dpyinfo->gdpy, GDK_SB_H_DOUBLE_ARROW); |
| 6839 | 6884 | ||
| 6885 | dpyinfo->icon_bitmap_id = -1; | ||
| 6886 | |||
| 6840 | reset_mouse_highlight (&dpyinfo->mouse_highlight); | 6887 | reset_mouse_highlight (&dpyinfo->mouse_highlight); |
| 6841 | 6888 | ||
| 6842 | { | 6889 | { |
diff --git a/src/pgtkterm.h b/src/pgtkterm.h index ad66039648b..a2714a3afe0 100644 --- a/src/pgtkterm.h +++ b/src/pgtkterm.h | |||
| @@ -172,6 +172,10 @@ struct pgtk_display_info | |||
| 172 | 172 | ||
| 173 | int color_p; | 173 | int color_p; |
| 174 | 174 | ||
| 175 | /* Emacs bitmap-id of the default icon bitmap for this frame. | ||
| 176 | Or -1 if none has been allocated yet. */ | ||
| 177 | ptrdiff_t icon_bitmap_id; | ||
| 178 | |||
| 175 | Window root_window; | 179 | Window root_window; |
| 176 | 180 | ||
| 177 | /* Xism */ | 181 | /* Xism */ |
| @@ -296,6 +300,10 @@ struct pgtk_output | |||
| 296 | Window window_desc, parent_desc; | 300 | Window window_desc, parent_desc; |
| 297 | char explicit_parent; | 301 | char explicit_parent; |
| 298 | 302 | ||
| 303 | /* If >=0, a bitmap index. The indicated bitmap is used for the | ||
| 304 | icon. */ | ||
| 305 | ptrdiff_t icon_bitmap; | ||
| 306 | |||
| 299 | struct font *font; | 307 | struct font *font; |
| 300 | int baseline_offset; | 308 | int baseline_offset; |
| 301 | 309 | ||