From 045e25278bdec3e08c3c069a537e4ae7a66de262 Mon Sep 17 00:00:00 2001 From: Yuuki Harano Date: Sat, 13 Jan 2018 20:27:11 +0900 Subject: [PATCH] Add support for cursor_foreground_colors MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * ../src/pgtkterm.c (x_set_cursor_gc): * ../src/pgtkfns.c (x_set_cursor_color, Fx_create_frame) (syms_of_pgtkfns): * src/pgtkterm.h (struct pgtk_output): cursor_foreground_color 対応。 あんまり意味なかった感じ。 --- src/pgtkfns.c | 60 ++++++++++++++++++++++++++++++++++++-------------- src/pgtkterm.c | 4 +--- src/pgtkterm.h | 5 ++++- 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 67391fac86f..b08b81a885c 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -197,25 +197,49 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) static void x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { + unsigned long fore_pixel, pixel; + struct pgtk_output *x = f->output_data.pgtk; Emacs_Color col; - block_input (); - if (pgtk_lisp_to_color (arg, &col)) + if (!NILP (Vx_cursor_fore_pixel)) { - store_frame_param (f, Qcursor_color, oldval); - unblock_input (); - error ("Unknown color"); + if (pgtk_lisp_to_color(Vx_cursor_fore_pixel, &col)) + signal_error ("Undefined color", Vx_cursor_fore_pixel); + fore_pixel = col.pixel; } + else + fore_pixel = FRAME_BACKGROUND_PIXEL (f); - FRAME_CURSOR_COLOR (f) = col.pixel; + if (pgtk_lisp_to_color(arg, &col)) + signal_error ("Undefined color", arg); + pixel = col.pixel; - if (FRAME_VISIBLE_P (f)) + /* Make sure that the cursor color differs from the background color. */ + if (pixel == FRAME_BACKGROUND_PIXEL (f)) + { + pixel = x->mouse_color; + if (pixel == fore_pixel) + { + fore_pixel = FRAME_BACKGROUND_PIXEL (f); + } + } + + x->cursor_foreground_color = fore_pixel; + x->cursor_color = pixel; + + if (FRAME_X_WINDOW (f) != 0) { - x_update_cursor (f, 0); - x_update_cursor (f, 1); + x->cursor_xgcv.background = x->cursor_color; + x->cursor_xgcv.foreground = fore_pixel; + + if (FRAME_VISIBLE_P (f)) + { + x_update_cursor (f, false); + x_update_cursor (f, true); + } } + update_face_from_frame_parameter (f, Qcursor_color, arg); - unblock_input (); } @@ -1029,11 +1053,11 @@ This function is an internal primitive--use `make-frame' instead. */) FRAME_FOREGROUND_PIXEL (f) = -1; FRAME_BACKGROUND_PIXEL (f) = -1; FRAME_X_OUTPUT(f)->cursor_color = -1; + FRAME_X_OUTPUT(f)->cursor_foreground_color = -1; #if 0 - FRAME_X_OUTPUT(f)->cursor_foreground_pixel = -1; FRAME_X_OUTPUT(f)->border_pixel = -1; - FRAME_X_OUTPUT(f)->mouse_pixel = -1; #endif + FRAME_X_OUTPUT(f)->mouse_color = -1; black = build_string ("black"); FRAME_FOREGROUND_PIXEL (f) @@ -1042,14 +1066,14 @@ This function is an internal primitive--use `make-frame' instead. */) = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); FRAME_X_OUTPUT(f)->cursor_color = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); -#if 0 - FRAME_X_OUTPUT(f)->cursor_foreground_pixel + FRAME_X_OUTPUT(f)->cursor_foreground_color = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); +#if 0 FRAME_X_OUTPUT(f)->border_pixel = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); - FRAME_X_OUTPUT(f)->mouse_pixel - = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); #endif + FRAME_X_OUTPUT(f)->mouse_color + = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); } /* Specify the parent under which to make this X window. */ @@ -2615,6 +2639,10 @@ syms_of_pgtkfns (void) DEFSYM (Qicon_title_format, "icon-title-format"); DEFSYM (Qdark, "dark"); + DEFVAR_LISP ("x-cursor-fore-pixel", Vx_cursor_fore_pixel, + doc: /* A string indicating the foreground color of the cursor box. */); + Vx_cursor_fore_pixel = Qnil; + DEFVAR_LISP ("pgtk-icon-type-alist", Vpgtk_icon_type_alist, doc: /* Alist of elements (REGEXP . IMAGE) for images of icons associated to frames. If the title of a frame matches REGEXP, then IMAGE.tiff is diff --git a/src/pgtkterm.c b/src/pgtkterm.c index a1c42eb2748..4f2c4542372 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -765,10 +765,8 @@ x_set_cursor_gc (struct glyph_string *s) if (xgcv.foreground == xgcv.background) xgcv.foreground = s->face->foreground; PGTK_TRACE("x_set_cursor_gc: 4. %08lx, %08lx.", xgcv.background, xgcv.foreground); -#if 0 if (xgcv.foreground == xgcv.background) - xgcv.foreground = FRAME_X_OUTPUT(s->f)->cursor_foreground_pixel; -#endif + xgcv.foreground = FRAME_X_OUTPUT(s->f)->cursor_foreground_color; if (xgcv.foreground == xgcv.background) xgcv.foreground = s->face->foreground; PGTK_TRACE("x_set_cursor_gc: 5. %08lx, %08lx.", xgcv.background, xgcv.foreground); diff --git a/src/pgtkterm.h b/src/pgtkterm.h index c01d846748e..6cd6da4ccb3 100644 --- a/src/pgtkterm.h +++ b/src/pgtkterm.h @@ -226,7 +226,6 @@ struct pgtk_output void *view; void *miniimage; #endif - unsigned long cursor_color; unsigned long foreground_color; unsigned long background_color; void *toolbar; @@ -269,6 +268,10 @@ struct pgtk_output value contains an ID of the fontset, else -1. */ int fontset; /* only used with font_backend */ + unsigned long mouse_color; + unsigned long cursor_color; + unsigned long cursor_foreground_color; + int icon_top; int icon_left; -- 2.39.5