[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/pgtk e405404 095/100: Fix startup failure on svg-unsupported env
From: |
Yuuki Harano |
Subject: |
feature/pgtk e405404 095/100: Fix startup failure on svg-unsupported environments |
Date: |
Tue, 24 Nov 2020 08:02:45 -0500 (EST) |
branch: feature/pgtk
commit e405404d10ef5b24e06d02f626c4bf27a3ae525d
Author: Yuuki Harano <masm+github@masm11.me>
Commit: Jeff Walsh <jeff.walsh@drtusers-MacBook-Pro.local>
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.
---
src/pgtkterm.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
src/pgtkterm.h | 8 ++++++++
2 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 6e2c87f..5527b7f 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/>. */
#include "termhooks.h"
#include "termopts.h"
#include "termchar.h"
+#include "emacs-icon.h"
#include "menu.h"
#include "window.h"
#include "keyboard.h"
@@ -3029,25 +3030,69 @@ pgtk_scroll_run (struct window *w, struct run *run)
static bool
pgtk_bitmap_icon (struct frame *f, Lisp_Object file)
{
+ ptrdiff_t bitmap_id;
+
if (FRAME_GTK_WIDGET (f) == 0)
return true;
+ /* Free up our existing icon bitmap and mask if any. */
+ if (f->output_data.pgtk->icon_bitmap > 0)
+ image_destroy_bitmap (f, f->output_data.pgtk->icon_bitmap);
+ f->output_data.pgtk->icon_bitmap = 0;
+
if (STRINGP (file))
{
/* Use gtk_window_set_icon_from_file () if available,
- It's not restricted to bitmaps */
+ It's not restricted to bitmaps */
if (xg_set_icon (f, file))
return false;
+ bitmap_id = image_create_bitmap_from_file (f, file);
+ }
+ else
+ {
+ /* Create the GNU bitmap and mask if necessary. */
+ if (FRAME_DISPLAY_INFO (f)->icon_bitmap_id < 0)
+ {
+ ptrdiff_t rc = -1;
- return true;
+ if (xg_set_icon (f, xg_default_icon_file)
+ || xg_set_icon_from_xpm_data (f, gnu_xpm_bits))
+ {
+ FRAME_DISPLAY_INFO (f)->icon_bitmap_id = -2;
+ return false;
+ }
+
+ /* If all else fails, use the (black and white) xbm image. */
+ if (rc == -1)
+ {
+ rc = image_create_bitmap_from_data (f,
+ (char *) gnu_xbm_bits,
+ gnu_xbm_width,
+ gnu_xbm_height);
+ if (rc == -1)
+ return true;
+
+ FRAME_DISPLAY_INFO (f)->icon_bitmap_id = rc;
+ }
+ }
+
+ /* The first time we create the GNU bitmap and mask,
+ this increments the ref-count one extra time.
+ As a result, the GNU bitmap and mask are never freed.
+ That way, we don't have to worry about allocating it again. */
+ image_reference_bitmap (f, FRAME_DISPLAY_INFO (f)->icon_bitmap_id);
+
+ bitmap_id = FRAME_DISPLAY_INFO (f)->icon_bitmap_id;
}
- if (xg_set_icon (f, xg_default_icon_file))
+ if (FRAME_DISPLAY_INFO (f)->bitmaps[bitmap_id - 1].img != NULL)
{
- return false;
+ gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ FRAME_DISPLAY_INFO (f)->bitmaps[bitmap_id - 1].img);
}
+ f->output_data.pgtk->icon_bitmap = bitmap_id;
- return true;
+ return false;
}
@@ -6837,6 +6882,8 @@ pgtk_term_init (Lisp_Object display_name, char
*resource_name)
dpyinfo->horizontal_scroll_bar_cursor
= gdk_cursor_new_for_display (dpyinfo->gdpy, GDK_SB_H_DOUBLE_ARROW);
+ dpyinfo->icon_bitmap_id = -1;
+
reset_mouse_highlight (&dpyinfo->mouse_highlight);
{
diff --git a/src/pgtkterm.h b/src/pgtkterm.h
index ad66039..a2714a3 100644
--- a/src/pgtkterm.h
+++ b/src/pgtkterm.h
@@ -172,6 +172,10 @@ struct pgtk_display_info
int color_p;
+ /* Emacs bitmap-id of the default icon bitmap for this frame.
+ Or -1 if none has been allocated yet. */
+ ptrdiff_t icon_bitmap_id;
+
Window root_window;
/* Xism */
@@ -296,6 +300,10 @@ struct pgtk_output
Window window_desc, parent_desc;
char explicit_parent;
+ /* If >=0, a bitmap index. The indicated bitmap is used for the
+ icon. */
+ ptrdiff_t icon_bitmap;
+
struct font *font;
int baseline_offset;
- feature/pgtk 1d549fa 015/100: Add support for make-frame-(in)visible, (continued)
- feature/pgtk 1d549fa 015/100: Add support for make-frame-(in)visible, Yuuki Harano, 2020/11/24
- feature/pgtk 19da22e 018/100: Add support for handing the internal border, Yuuki Harano, 2020/11/24
- feature/pgtk e021e23 043/100: End Resize flickering by copying surface rather than just clearing, Yuuki Harano, 2020/11/24
- feature/pgtk fd61a86 030/100: improve some efficiency - simplify draws, Yuuki Harano, 2020/11/24
- feature/pgtk 330a346 012/100: Migrate to Emacs_GC, Yuuki Harano, 2020/11/24
- feature/pgtk b1cc62c 037/100: Add support for Jpeglib, Yuuki Harano, 2020/11/24
- feature/pgtk fe2297c 055/100: * pgtkmenu.c (set_frame_menubar): fix empty menu., Yuuki Harano, 2020/11/24
- feature/pgtk a167e23 057/100: * src/pgtkmenu.c (set_frame_menubar): Suppress gcc warning, Yuuki Harano, 2020/11/24
- feature/pgtk 5a72a07 053/100: * pgtk-win.el: fix compile-time warnings., Yuuki Harano, 2020/11/24
- feature/pgtk bb6862d 089/100: Fix crash on drag and drop, Yuuki Harano, 2020/11/24
- feature/pgtk e405404 095/100: Fix startup failure on svg-unsupported environments,
Yuuki Harano <=