From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.devel Subject: Re: C equivalent for: (face-attribute 'region :background (selected-frame) 'default) Date: Tue, 26 Sep 2017 17:24:44 -0700 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1506471902 17205 195.159.176.226 (27 Sep 2017 00:25:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 27 Sep 2017 00:25:02 +0000 (UTC) Cc: emacs-devel@gnu.org To: YAMAMOTO Mitsuharu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 27 02:24:56 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx09l-0003iG-BN for ged-emacs-devel@m.gmane.org; Wed, 27 Sep 2017 02:24:53 +0200 Original-Received: from localhost ([::1]:51596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dx09r-0006LH-2b for ged-emacs-devel@m.gmane.org; Tue, 26 Sep 2017 20:24:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dx09k-0006Kz-6V for emacs-devel@gnu.org; Tue, 26 Sep 2017 20:24:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dx09h-00038x-2W for emacs-devel@gnu.org; Tue, 26 Sep 2017 20:24:52 -0400 Original-Received: from gateway23.websitewelcome.com ([192.185.50.104]:20721) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dx09g-00037D-Qq for emacs-devel@gnu.org; Tue, 26 Sep 2017 20:24:49 -0400 Original-Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 877A81892A for ; Tue, 26 Sep 2017 19:24:46 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id x0BfdZJdmVBtnx0Bfd8Lii; Tue, 26 Sep 2017 19:26:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3TndOn6Zr8xqGEk+A2g70Hc4wfifuopRzVzmpknQ9dY=; b=Z7VYouAlNrbY3Ya+z2w7T81wvB raN6zm+akAYm+torfp5M+Rs0x5EzY2e6WRhgh+Q+++e0uveaqeQuIoIK4DV9bTH5Y9EbE+OCDlzWr Dt8gqZW+wLJSCYVO2v3C883dgRpjysnuAgvWkF6Gs+V6FhBCuBTeE5hjJw9i1E8dIT1r5+AVLUxzJ EIYd2G4C1dvrsBs4Nh0U3oUTtumPDiQLJHGloZZWDe/XhA5FUjO09aQrqCCjt9fe7hwnBPARcH/X3 VQkBgyA0VaMiHOeoelbL0MishkhR4jn2ZjOaZd5qCAjgokgo4HvXoTkdzNGBy0xVdO9qm4E7/srrr 7Rj3OwFg==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50713 helo=server.private) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1dx09d-000EpH-Lb; Tue, 26 Sep 2017 19:24:45 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Exim-ID: 1dx09d-000EpH-Lb X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private) [45.48.239.195]:50713 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 192.185.50.104 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218816 Archived-At: 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 > > * * * > > 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. > > * * *