aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Walsh2020-06-12 21:44:18 +1000
committerJeff Walsh2020-11-22 14:46:55 +1100
commit592badc3571cc3bb315db8f08ee38db4f6a8cb82 (patch)
tree246cb6f7bb025918996a325065454a77df2ca1c7 /src
parent164800da6f673afeba729befbfbfd0e6131eadb8 (diff)
downloademacs-592badc3571cc3bb315db8f08ee38db4f6a8cb82.tar.gz
emacs-592badc3571cc3bb315db8f08ee38db4f6a8cb82.zip
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):
Diffstat (limited to 'src')
-rw-r--r--src/gtkutil.c20
-rw-r--r--src/image.c17
-rw-r--r--src/pgtkfns.c16
-rw-r--r--src/pgtkterm.c51
-rw-r--r--src/pgtkterm.h2
-rw-r--r--src/xdisp.c2
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)
316 316
317static GdkPixbuf * 317static GdkPixbuf *
318xg_get_pixbuf_from_pix_and_mask (struct frame *f, 318xg_get_pixbuf_from_pix_and_mask (struct frame *f,
319 Pixmap pix, 319 Emacs_Pixmap pix,
320 Pixmap mask) 320 Emacs_Pixmap mask)
321{ 321{
322 GdkPixbuf *icon_buf = 0; 322 GdkPixbuf *icon_buf = 0;
323 int iunused; 323 int iunused;
@@ -327,7 +327,7 @@ xg_get_pixbuf_from_pix_and_mask (struct frame *f,
327#ifndef HAVE_PGTK 327#ifndef HAVE_PGTK
328 if (FRAME_DISPLAY_INFO (f)->red_bits != 8) 328 if (FRAME_DISPLAY_INFO (f)->red_bits != 8)
329 return 0; 329 return 0;
330#endif 330
331 XGetGeometry (FRAME_X_DISPLAY (f), pix, &wunused, &iunused, &iunused, 331 XGetGeometry (FRAME_X_DISPLAY (f), pix, &wunused, &iunused, &iunused,
332 &width, &height, &uunused, &depth); 332 &width, &height, &uunused, &depth);
333 if (depth != 24) 333 if (depth != 24)
@@ -359,10 +359,20 @@ xg_get_pixbuf_from_pix_and_mask (struct frame *f,
359 XDestroyImage (xmm); 359 XDestroyImage (xmm);
360 XDestroyImage (xim); 360 XDestroyImage (xim);
361 } 361 }
362#else
363 width = pix->width;
364 height = pix->height;
365 depth = pix->bits_per_pixel;
366
367 icon_buf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
368
369
370#endif
362 371
363 return icon_buf; 372 return icon_buf;
364} 373}
365#endif 374
375
366 376
367#if defined USE_CAIRO && !defined HAVE_GTK3 377#if defined USE_CAIRO && !defined HAVE_GTK3
368static GdkPixbuf * 378static GdkPixbuf *
@@ -414,6 +424,8 @@ xg_get_pixbuf_from_surface (cairo_surface_t *surface)
414} 424}
415#endif /* USE_CAIRO && !HAVE_GTK3 */ 425#endif /* USE_CAIRO && !HAVE_GTK3 */
416 426
427#endif /* !HAVE_PGTK */
428
417static Lisp_Object 429static Lisp_Object
418file_for_image (Lisp_Object image) 430file_for_image (Lisp_Object image)
419{ 431{
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)
507#endif 507#endif
508 508
509#ifdef HAVE_PGTK 509#ifdef HAVE_PGTK
510 return -1; // fixme: 510 GError *err;
511 ptrdiff_t id;
512 void * bitmap = gdk_pixbuf_new_from_file(SSDATA(file), &err);
513
514 if (!bitmap)
515 return -1;
516
517 id = image_allocate_bitmap_record(f);
518
519 dpyinfo->bitmaps[id - 1].img = bitmap;
520 dpyinfo->bitmaps[id - 1].refcount = 1;
521 dpyinfo->bitmaps[id - 1].file = xlispstrdup (file);
522 //dpyinfo->bitmaps[id - 1].depth = 1;
523 dpyinfo->bitmaps[id - 1].height = gdk_pixbuf_get_width (bitmap);
524 dpyinfo->bitmaps[id - 1].width = gdk_pixbuf_get_height (bitmap);
525 return id;
511#endif 526#endif
512 527
513#ifdef HAVE_X_WINDOWS 528#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. */)
1394 return unbind_to (count, frame); 1394 return unbind_to (count, frame);
1395} 1395}
1396 1396
1397void
1398x_focus_frame (struct frame *f, bool noactivate)
1399{
1400 struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
1401
1402#if 0
1403 if (dpyinfo->x_focus_frame != f)
1404 {
1405 EmacsView *view = FRAME_PGTK_VIEW (f);
1406 block_input ();
1407 [NSApp activateIgnoringOtherApps: YES];
1408 [[view window] makeKeyAndOrderFront: view];
1409 unblock_input ();
1410 }
1411#endif
1412}
1413 1397
1414#if 0 1398#if 0
1415static int 1399static 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 {
80 80
81static Time ignore_next_mouse_click_timeout; 81static Time ignore_next_mouse_click_timeout;
82 82
83static Lisp_Object xg_default_icon_file;
84
83static void pgtk_delete_display (struct pgtk_display_info *dpyinfo); 85static void pgtk_delete_display (struct pgtk_display_info *dpyinfo);
84static void pgtk_clear_frame_area(struct frame *f, int x, int y, int width, int height); 86static void pgtk_clear_frame_area(struct frame *f, int x, int y, int width, int height);
85static void pgtk_fill_rectangle(struct frame *f, unsigned long color, int x, int y, int width, int height); 87static 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)
475 -------------------------------------------------------------------------- */ 477 -------------------------------------------------------------------------- */
476{ 478{
477 PGTK_TRACE("pgtk_make_frame_visible"); 479 PGTK_TRACE("pgtk_make_frame_visible");
480
481 GtkWidget *win = FRAME_OUTPUT_DATA(f)->widget;
482
483 gtk_widget_show(win);
484
478#if 0 485#if 0
479 NSTRACE ("x_make_frame_visible"); 486 NSTRACE ("x_make_frame_visible");
480 /* XXX: at some points in past this was not needed, as the only place that 487 /* 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)
529 -------------------------------------------------------------------------- */ 536 -------------------------------------------------------------------------- */
530{ 537{
531 PGTK_TRACE("pgtk_make_frame_invisible"); 538 PGTK_TRACE("pgtk_make_frame_invisible");
539
540 GtkWidget *win = FRAME_OUTPUT_DATA(f)->widget;
541
542 gtk_widget_hide(win);
543
532#if 0 544#if 0
533 NSView *view; 545 NSView *view;
534 NSTRACE ("x_make_frame_invisible"); 546 NSTRACE ("x_make_frame_invisible");
@@ -2766,16 +2778,30 @@ pgtk_update_begin (struct frame *f)
2766 2778
2767 if (! FRAME_CR_SURFACE (f)) 2779 if (! FRAME_CR_SURFACE (f))
2768 { 2780 {
2769 int width = FRAME_PIXEL_WIDTH (f); 2781 int width, height;
2770 int height = FRAME_PIXEL_HEIGHT (f); 2782 if (FRAME_GTK_WIDGET (f))
2783 {
2784 GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
2785 width = gdk_window_get_width (w);
2786 height = gdk_window_get_height (w);
2787 }
2788 else
2789 {
2790 width = FRAME_PIXEL_WIDTH (f);
2791 height = FRAME_PIXEL_HEIGHT (f);
2792 if (! FRAME_EXTERNAL_TOOL_BAR (f))
2793 height += FRAME_TOOL_BAR_HEIGHT (f);
2794 if (! FRAME_EXTERNAL_MENU_BAR (f))
2795 height += FRAME_MENU_BAR_HEIGHT (f);
2796 }
2771 2797
2772 if (width > 0 && height > 0) 2798 if (width > 0 && height > 0)
2773 { 2799 {
2774 block_input(); 2800 block_input();
2775 FRAME_CR_SURFACE (f) = cairo_image_surface_create 2801 FRAME_CR_SURFACE (f) = cairo_image_surface_create
2776 (CAIRO_FORMAT_ARGB32, width, height); 2802 (CAIRO_FORMAT_ARGB32, width, height);
2777 unblock_input(); 2803 unblock_input();
2778 } 2804 }
2779 } 2805 }
2780 2806
2781 pgtk_clear_under_internal_border (f); 2807 pgtk_clear_under_internal_border (f);
@@ -6123,7 +6149,7 @@ pgtk_defined_color (struct frame *f,
6123 6149
6124int pgtk_parse_color (const char *color_name, Emacs_Color *color) 6150int pgtk_parse_color (const char *color_name, Emacs_Color *color)
6125{ 6151{
6126 // PGTK_TRACE("pgtk_parse_color: %s", color_name); 6152 PGTK_TRACE("pgtk_parse_color: %s", color_name);
6127 6153
6128 GdkRGBA rgba; 6154 GdkRGBA rgba;
6129 if (gdk_rgba_parse(&rgba, color_name)) { 6155 if (gdk_rgba_parse(&rgba, color_name)) {
@@ -6173,6 +6199,7 @@ pgtk_query_colors (struct frame *f, Emacs_Color *colors, int ncolors)
6173 colors[i].red = GetRValue (pixel) * 257; 6199 colors[i].red = GetRValue (pixel) * 257;
6174 colors[i].green = GetGValue (pixel) * 257; 6200 colors[i].green = GetGValue (pixel) * 257;
6175 colors[i].blue = GetBValue (pixel) * 257; 6201 colors[i].blue = GetBValue (pixel) * 257;
6202 PGTK_TRACE("pixel: %lx, red: %d, blue %d, green %d", colors[i].pixel, colors[i].red, colors[i].blue, colors[i].green);
6176 } 6203 }
6177} 6204}
6178 6205
@@ -6217,6 +6244,12 @@ syms_of_pgtkterm (void)
6217 6244
6218 DEFSYM (Qlatin_1, "latin-1"); 6245 DEFSYM (Qlatin_1, "latin-1");
6219 6246
6247 xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg");
6248 staticpro (&xg_default_icon_file);
6249
6250 DEFSYM (Qx_gtk_map_stock, "x-gtk-map-stock");
6251
6252
6220 Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); 6253 Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier));
6221 Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); 6254 Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier));
6222 Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier)); 6255 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);
574extern void x_wm_set_size_hint (struct frame *, long, bool); 574extern void x_wm_set_size_hint (struct frame *, long, bool);
575extern void x_free_frame_resources (struct frame *); 575extern void x_free_frame_resources (struct frame *);
576extern void pgtk_iconify_frame (struct frame *f); 576extern void pgtk_iconify_frame (struct frame *f);
577extern void x_focus_frame (struct frame *f, bool noactivate); 577extern void pgtk_focus_frame (struct frame *f, bool noactivate);
578extern void pgtk_set_scroll_bar_default_width (struct frame *f); 578extern void pgtk_set_scroll_bar_default_width (struct frame *f);
579extern void pgtk_set_scroll_bar_default_height (struct frame *f); 579extern void pgtk_set_scroll_bar_default_height (struct frame *f);
580extern Lisp_Object x_get_focus_frame (struct frame *frame); 580extern 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)
14330 f->tool_bar_redisplayed = true; 14330 f->tool_bar_redisplayed = true;
14331#ifdef HAVE_EXT_TOOL_BAR 14331#ifdef HAVE_EXT_TOOL_BAR
14332 14332
14333#if 0
14334 if (FRAME_EXTERNAL_TOOL_BAR (f)) 14333 if (FRAME_EXTERNAL_TOOL_BAR (f))
14335 update_frame_tool_bar (f); 14334 update_frame_tool_bar (f);
14336#endif
14337 return false; 14335 return false;
14338 14336
14339#else /* ! (HAVE_EXT_TOOL_BAR) */ 14337#else /* ! (HAVE_EXT_TOOL_BAR) */