From 592badc3571cc3bb315db8f08ee38db4f6a8cb82 Mon Sep 17 00:00:00 2001 From: Jeff Walsh Date: Fri, 12 Jun 2020 21:44:18 +1000 Subject: [PATCH] Early toolbar improvements * src/xdisp.c (redisplay_tool_bar): * src/pgtkterm.h: * src/pgtkterm.c: (pgtk_make_frame_visible, pgtk_make_frame_invisible) (pgtk_update_begin, pgtk_parse_color, pgtk_query_colors) (syms_of_pgtkterm): * src/pgtkfns.c: cleanup function * src/image.c (image_create_bitmap_from_file): * src/gtkutil.c (xg_get_pixbuf_from_pix_and_mask): --- src/gtkutil.c | 20 ++++++++++++++++---- src/image.c | 17 ++++++++++++++++- src/pgtkfns.c | 16 ---------------- src/pgtkterm.c | 51 +++++++++++++++++++++++++++++++++++++++++--------- src/pgtkterm.h | 2 +- src/xdisp.c | 2 -- 6 files changed, 75 insertions(+), 33 deletions(-) diff --git a/src/gtkutil.c b/src/gtkutil.c index 10120422ae3..9655c8dfc12 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -316,8 +316,8 @@ xg_create_default_cursor (GdkDisplay *gdpy) static GdkPixbuf * xg_get_pixbuf_from_pix_and_mask (struct frame *f, - Pixmap pix, - Pixmap mask) + Emacs_Pixmap pix, + Emacs_Pixmap mask) { GdkPixbuf *icon_buf = 0; int iunused; @@ -327,7 +327,7 @@ xg_get_pixbuf_from_pix_and_mask (struct frame *f, #ifndef HAVE_PGTK if (FRAME_DISPLAY_INFO (f)->red_bits != 8) return 0; -#endif + XGetGeometry (FRAME_X_DISPLAY (f), pix, &wunused, &iunused, &iunused, &width, &height, &uunused, &depth); if (depth != 24) @@ -359,10 +359,20 @@ xg_get_pixbuf_from_pix_and_mask (struct frame *f, XDestroyImage (xmm); XDestroyImage (xim); } +#else + width = pix->width; + height = pix->height; + depth = pix->bits_per_pixel; + + icon_buf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height); + + +#endif return icon_buf; } -#endif + + #if defined USE_CAIRO && !defined HAVE_GTK3 static GdkPixbuf * @@ -414,6 +424,8 @@ xg_get_pixbuf_from_surface (cairo_surface_t *surface) } #endif /* USE_CAIRO && !HAVE_GTK3 */ +#endif /* !HAVE_PGTK */ + static Lisp_Object file_for_image (Lisp_Object image) { diff --git a/src/image.c b/src/image.c index 74cd6b854d7..9beb35c484b 100644 --- a/src/image.c +++ b/src/image.c @@ -507,7 +507,22 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object file) #endif #ifdef HAVE_PGTK - return -1; // fixme: + GError *err; + ptrdiff_t id; + void * bitmap = gdk_pixbuf_new_from_file(SSDATA(file), &err); + + if (!bitmap) + return -1; + + id = image_allocate_bitmap_record(f); + + dpyinfo->bitmaps[id - 1].img = bitmap; + dpyinfo->bitmaps[id - 1].refcount = 1; + dpyinfo->bitmaps[id - 1].file = xlispstrdup (file); + //dpyinfo->bitmaps[id - 1].depth = 1; + dpyinfo->bitmaps[id - 1].height = gdk_pixbuf_get_width (bitmap); + dpyinfo->bitmaps[id - 1].width = gdk_pixbuf_get_height (bitmap); + return id; #endif #ifdef HAVE_X_WINDOWS diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 34effd13464..b726d1bcaf4 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -1394,22 +1394,6 @@ This function is an internal primitive--use `make-frame' instead. */) return unbind_to (count, frame); } -void -x_focus_frame (struct frame *f, bool noactivate) -{ - struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); - -#if 0 - if (dpyinfo->x_focus_frame != f) - { - EmacsView *view = FRAME_PGTK_VIEW (f); - block_input (); - [NSApp activateIgnoringOtherApps: YES]; - [[view window] makeKeyAndOrderFront: view]; - unblock_input (); - } -#endif -} #if 0 static int diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 9fbf41c6fbc..e081d8c23e1 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -80,6 +80,8 @@ static struct event_queue_t { static Time ignore_next_mouse_click_timeout; +static Lisp_Object xg_default_icon_file; + static void pgtk_delete_display (struct pgtk_display_info *dpyinfo); static void pgtk_clear_frame_area(struct frame *f, int x, int y, int width, int height); static void pgtk_fill_rectangle(struct frame *f, unsigned long color, int x, int y, int width, int height); @@ -475,6 +477,11 @@ pgtk_make_frame_visible (struct frame *f) -------------------------------------------------------------------------- */ { PGTK_TRACE("pgtk_make_frame_visible"); + + GtkWidget *win = FRAME_OUTPUT_DATA(f)->widget; + + gtk_widget_show(win); + #if 0 NSTRACE ("x_make_frame_visible"); /* XXX: at some points in past this was not needed, as the only place that @@ -529,6 +536,11 @@ pgtk_make_frame_invisible (struct frame *f) -------------------------------------------------------------------------- */ { PGTK_TRACE("pgtk_make_frame_invisible"); + + GtkWidget *win = FRAME_OUTPUT_DATA(f)->widget; + + gtk_widget_hide(win); + #if 0 NSView *view; NSTRACE ("x_make_frame_invisible"); @@ -2766,16 +2778,30 @@ pgtk_update_begin (struct frame *f) if (! FRAME_CR_SURFACE (f)) { - int width = FRAME_PIXEL_WIDTH (f); - int height = FRAME_PIXEL_HEIGHT (f); + int width, height; + if (FRAME_GTK_WIDGET (f)) + { + GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f)); + width = gdk_window_get_width (w); + height = gdk_window_get_height (w); + } + else + { + width = FRAME_PIXEL_WIDTH (f); + height = FRAME_PIXEL_HEIGHT (f); + if (! FRAME_EXTERNAL_TOOL_BAR (f)) + height += FRAME_TOOL_BAR_HEIGHT (f); + if (! FRAME_EXTERNAL_MENU_BAR (f)) + height += FRAME_MENU_BAR_HEIGHT (f); + } if (width > 0 && height > 0) - { - block_input(); - FRAME_CR_SURFACE (f) = cairo_image_surface_create - (CAIRO_FORMAT_ARGB32, width, height); - unblock_input(); - } + { + block_input(); + FRAME_CR_SURFACE (f) = cairo_image_surface_create + (CAIRO_FORMAT_ARGB32, width, height); + unblock_input(); + } } pgtk_clear_under_internal_border (f); @@ -6123,7 +6149,7 @@ pgtk_defined_color (struct frame *f, int pgtk_parse_color (const char *color_name, Emacs_Color *color) { - // PGTK_TRACE("pgtk_parse_color: %s", color_name); + PGTK_TRACE("pgtk_parse_color: %s", color_name); GdkRGBA rgba; if (gdk_rgba_parse(&rgba, color_name)) { @@ -6173,6 +6199,7 @@ pgtk_query_colors (struct frame *f, Emacs_Color *colors, int ncolors) colors[i].red = GetRValue (pixel) * 257; colors[i].green = GetGValue (pixel) * 257; colors[i].blue = GetBValue (pixel) * 257; + PGTK_TRACE("pixel: %lx, red: %d, blue %d, green %d", colors[i].pixel, colors[i].red, colors[i].blue, colors[i].green); } } @@ -6217,6 +6244,12 @@ syms_of_pgtkterm (void) DEFSYM (Qlatin_1, "latin-1"); + xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); + staticpro (&xg_default_icon_file); + + DEFSYM (Qx_gtk_map_stock, "x-gtk-map-stock"); + + Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier)); diff --git a/src/pgtkterm.h b/src/pgtkterm.h index 6bb03697a50..4b585079b86 100644 --- a/src/pgtkterm.h +++ b/src/pgtkterm.h @@ -574,7 +574,7 @@ extern void pgtk_make_frame_invisible (struct frame *f); extern void x_wm_set_size_hint (struct frame *, long, bool); extern void x_free_frame_resources (struct frame *); extern void pgtk_iconify_frame (struct frame *f); -extern void x_focus_frame (struct frame *f, bool noactivate); +extern void pgtk_focus_frame (struct frame *f, bool noactivate); extern void pgtk_set_scroll_bar_default_width (struct frame *f); extern void pgtk_set_scroll_bar_default_height (struct frame *f); extern Lisp_Object x_get_focus_frame (struct frame *frame); diff --git a/src/xdisp.c b/src/xdisp.c index c523111fbd1..3dabfea23d2 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14330,10 +14330,8 @@ redisplay_tool_bar (struct frame *f) f->tool_bar_redisplayed = true; #ifdef HAVE_EXT_TOOL_BAR -#if 0 if (FRAME_EXTERNAL_TOOL_BAR (f)) update_frame_tool_bar (f); -#endif return false; #else /* ! (HAVE_EXT_TOOL_BAR) */ -- 2.39.5