emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C equivalent for: (face-attribute 'region :background (selected-fram


From: Keith David Bershatsky
Subject: Re: C equivalent for: (face-attribute 'region :background (selected-frame) 'default)
Date: Tue, 26 Sep 2017 17:24:44 -0700

Thank you, YAMAMOTO Mitsuharu, for the example functions `mac_gc_for_face_id` 
and `mac_draw_window_divider'.  I do indeed use a couple of sections in xterm.c 
to draw multiple fake cursors (#22873) and crosshairs (#17684) when Emacs is 
built `--with-x` on OSX.  The current design passes the LSL color vector to 
`x_draw_window_cursor'.  I then multiply each color (red/green/blue) by 65535 
and pass that along to `x_make_truecolor_pixel`.  Depending upon the 
`cursor_type`, I hijack either `f->output_data.x->cursor_pixel` or 
`f->output_data.x->cursor_gc' and I borrow the functionality of `x_make_gc`.

I am still implementing the new features for the GUI version of Emacs built 
`--with-ns` and have not yet done any testing to see whether I can draw/erase 
glyphless (floating) fake cursors in an Emacs build `--with-x` for X11 and/or 
on an Emacs for Windows build.  It works well `--with-ns`.  Essentially, I draw 
just the cursors and suppress the creation of glyphs when calling 
`draw_window_cursor` (which becomes `ns_draw_window_cursor') -- i.e., I 
suppress the call to `draw_phys_cursor_glyph`.  I am hoping that the Emacs 
builds for X11 and Windows will permit a similar design -- i.e., just draw a 
floating fake cursor in certain areas of the visible window that do not have 
any text.

To erase the floating glyphless fake cursors (with no text), I draw the shape 
of the cursor using the current background color.  The current design is to get 
everything into the LSL color vector, and then treat it differently once I get 
over to nsterm.m, w32term.c, or xterm.c depending upon the Emacs build.  In 
terms of the active region face, I needed to get the LSL equivalent for the 
region background.  Today, I ported from Lisp to C the functions 
`face-attribute` and `face-attribute-merged-with` which gets me the color 
string:

https://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00917.html

I use the following function to convert the color string to an LSL color vector:

mc_color_vector_calculate (struct window *w, Lisp_Object color)
{
  Lisp_Object target_frame = w->frame;
  Lisp_Object color_values;
  double valmax = XINT (XCAR (Fxw_color_values (build_string ("#ffffff"), 
target_frame)));
  Lisp_Object vlist;
  ptrdiff_t x;
  int i = 0;
  Lisp_Object temp = Qnil;
  Lisp_Object vector = (Fmake_vector (make_number (3), Qnil));
  if (!NILP (Fmemq ((Fframep (target_frame)), listn (CONSTYPE_HEAP, 3, Qx, 
Qw32, Qns))))
    {
      color_values = (Fxw_color_values (color, target_frame));
      for (vlist = color_values;
           CONSP (vlist);
           vlist = XCDR (vlist))
        {
          x = XINT (XCAR (vlist));
          temp = make_float (x / valmax);
          ASET (vector, i, temp);
          i = i + 1;
        }
    }
  return vector;

I will study your example functions (`mac_gc_for_face_id` and 
`mac_draw_window_divider') further and see if I can incorporate certain aspects 
into Emacs `--with-x` with respect to the new features that I am developing.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DATE:  [09-26-2017 16:19:29] <27 Sep 2017 08:19:29 +0900>
FROM:  YAMAMOTO Mitsuharu <address@hidden>
> 
>  * * *
> 
> Do you need xterm.c-level drawing functions?  Then perhaps you want
> GCs rather than the color strings.  In the Mac port, I use the
> following function.
> 
> * * *



reply via email to

[Prev in Thread] Current Thread [Next in Thread]