From: Yuuki Harano Date: Sun, 7 Jul 2019 13:43:59 +0000 (+0900) Subject: border_color/pixel width X-Git-Tag: emacs-29.0.90~3841 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=da3c3518ed1ca12fad4a6b2a76d286056a4a3a87;p=emacs.git border_color/pixel width * src/pgtkterm.h (struct pgtk_output): * src/pgtkterm.c (x_free_frame_resources, frame_highlight) (frame_unhighlight, pgtk_frame_rehighlight): use css information * src/pgtkfns.c (x_set_border_color, pgtk_frame_parm_handlers) (Fx_create_frame): new functions connected * src/frame.c (gui_set_border_width): ifdef for PGTK border_color/pixel 対応。 --- diff --git a/src/frame.c b/src/frame.c index 2c549a1d4d8..82735491d08 100644 --- a/src/frame.c +++ b/src/frame.c @@ -4643,8 +4643,10 @@ gui_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) if (border_width == f->border_width) return; +#ifndef HAVE_PGTK if (FRAME_NATIVE_WINDOW (f) != 0) error ("Cannot change the border width of a frame"); +#endif f->border_width = border_width; } diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 3f31c086f2d..a9293c5bbbc 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -48,6 +48,7 @@ static int as_status; static ptrdiff_t image_cache_refcount; +static int x_decode_color (struct frame *f, Lisp_Object color_name, int mono_color); static struct pgtk_display_info *pgtk_display_info_for_name (Lisp_Object); static void pgtk_set_name_as_filename (struct frame *); @@ -193,6 +194,16 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) unblock_input (); } +static void +x_set_border_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +{ + int pix; + + CHECK_STRING (arg); + pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); + FRAME_X_OUTPUT(f)->border_pixel = pix; + pgtk_frame_rehighlight (FRAME_DISPLAY_INFO (f)); +} static void x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) @@ -710,8 +721,8 @@ frame_parm_handler pgtk_frame_parm_handlers[] = gui_set_autoraise, /* generic OK */ gui_set_autolower, /* generic OK */ x_set_background_color, - 0, /* x_set_border_color, may be impossible under Nextstep */ - 0, /* x_set_border_width, may be impossible under Nextstep */ + x_set_border_color, + gui_set_border_width, x_set_cursor_color, x_set_cursor_type, gui_set_font, /* generic OK */ @@ -1382,6 +1393,8 @@ This function is an internal primitive--use `make-frame' instead. */) if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem)))) fset_param_alist (f, Fcons (XCAR (tem), f->param_alist)); + FRAME_X_OUTPUT(f)->border_color_css_provider = NULL; + FRAME_X_OUTPUT(f)->cr_surface_visible_bell = NULL; FRAME_X_OUTPUT(f)->atimer_visible_bell = NULL; diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 56a05dac9b8..6d0dc9695ad 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -196,6 +196,13 @@ x_free_frame_resources (struct frame *f) gtk_widget_destroy(FRAME_GTK_OUTER_WIDGET(f)); + if (FRAME_X_OUTPUT(f)->border_color_css_provider != NULL) { + GtkStyleContext *ctxt = gtk_widget_get_style_context(FRAME_GTK_OUTER_WIDGET(f)); + GtkCssProvider *old = FRAME_X_OUTPUT(f)->border_color_css_provider; + gtk_style_context_remove_provider(ctxt, GTK_STYLE_PROVIDER(old)); + FRAME_X_OUTPUT(f)->border_color_css_provider = NULL; + } + if (FRAME_X_OUTPUT(f)->cr_surface_visible_bell != NULL) { cairo_surface_destroy(FRAME_X_OUTPUT(f)->cr_surface_visible_bell); FRAME_X_OUTPUT(f)->cr_surface_visible_bell = NULL; @@ -4432,12 +4439,20 @@ frame_highlight (struct frame *f) the window-manager in use, tho something more is at play since I've been using that same window-manager binary for ever. Let's not crash just because of this (bug#9310). */ -#if 0 - x_catch_errors (FRAME_X_DISPLAY (f)); - XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - FRAME_X_OUTPUT(f)->border_pixel); - x_uncatch_errors (); -#endif + + char *css = g_strdup_printf("decoration { border: solid %dpx #%06x; }", f->border_width, (unsigned int) FRAME_X_OUTPUT(f)->border_pixel & 0x00ffffff); + GtkStyleContext *ctxt = gtk_widget_get_style_context(FRAME_GTK_OUTER_WIDGET(f)); + GtkCssProvider *css_provider = gtk_css_provider_new(); + gtk_css_provider_load_from_data(css_provider, css, -1, NULL); + gtk_style_context_add_provider(ctxt, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); + g_object_unref(css_provider); + g_free(css); + + GtkCssProvider *old = FRAME_X_OUTPUT(f)->border_color_css_provider; + FRAME_X_OUTPUT(f)->border_color_css_provider = css_provider; + if (old != NULL) + gtk_style_context_remove_provider(ctxt, GTK_STYLE_PROVIDER(old)); + unblock_input (); gui_update_cursor (f, true); x_set_frame_alpha (f); @@ -4452,19 +4467,27 @@ frame_unhighlight (struct frame *f) client", so we can always change it to whatever we want. */ block_input (); /* Same as above for XSetWindowBorder (bug#9310). */ -#if 0 - x_catch_errors (FRAME_X_DISPLAY (f)); - XSetWindowBorderPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - FRAME_X_OUTPUT(f)->border_tile); - x_uncatch_errors (); -#endif + + char *css = g_strdup_printf("decoration { border: dotted %dpx #ffffff; }", f->border_width); + GtkStyleContext *ctxt = gtk_widget_get_style_context(FRAME_GTK_OUTER_WIDGET(f)); + GtkCssProvider *css_provider = gtk_css_provider_new(); + gtk_css_provider_load_from_data(css_provider, css, -1, NULL); + gtk_style_context_add_provider(ctxt, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); + g_object_unref(css_provider); + g_free(css); + + GtkCssProvider *old = FRAME_X_OUTPUT(f)->border_color_css_provider; + FRAME_X_OUTPUT(f)->border_color_css_provider = css_provider; + if (old != NULL) + gtk_style_context_remove_provider(ctxt, GTK_STYLE_PROVIDER(old)); + unblock_input (); gui_update_cursor (f, true); x_set_frame_alpha (f); } -static void +void pgtk_frame_rehighlight (struct pgtk_display_info *dpyinfo) { struct frame *old_highlight = dpyinfo->highlight_frame; @@ -4484,13 +4507,10 @@ pgtk_frame_rehighlight (struct pgtk_display_info *dpyinfo) else dpyinfo->highlight_frame = 0; - if (dpyinfo->highlight_frame != old_highlight) - { - if (old_highlight) - frame_unhighlight (old_highlight); - if (dpyinfo->highlight_frame) - frame_highlight (dpyinfo->highlight_frame); - } + if (old_highlight) + frame_unhighlight (old_highlight); + if (dpyinfo->highlight_frame) + frame_highlight (dpyinfo->highlight_frame); } /* The focus has changed, or we have redirected a frame's focus to diff --git a/src/pgtkterm.h b/src/pgtkterm.h index 91990b203bd..c48b1b3e00f 100644 --- a/src/pgtkterm.h +++ b/src/pgtkterm.h @@ -251,6 +251,10 @@ struct pgtk_output /* PGTK-specific */ Emacs_Cursor current_pointer; + /* border color */ + unsigned long border_pixel; + GtkCssProvider *border_color_css_provider; + /* Widget whose cursor is hourglass_cursor. This widget is temporarily mapped to display an hourglass cursor. */ GtkWidget *hourglass_widget;