unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Evgeny Zajcev <lg.zevlg@gmail.com>
To: Alan Third <alan@idiocy.org>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: Hollow cursor under images
Date: Mon, 27 Jan 2020 15:54:56 +0300	[thread overview]
Message-ID: <CAO=W_ZoQ+RrWog0kGh7kfNEegFVYwYgsT4yTBSaSRHucqdH2AQ@mail.gmail.com> (raw)
In-Reply-To: <CAO=W_ZpiDSWCU0o1e6GJpHzxxVDUo07vL4QG5pG4x4vkn48q0Q@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1431 bytes --]

сб, 14 сент. 2019 г. в 14:48, Evgeny Zajcev <lg.zevlg@gmail.com>:

>
>
> вт, 5 мар. 2019 г. в 13:19, Evgeny Zajcev <lg.zevlg@gmail.com>:
>
>> [...]
>>
> In my case 32 for width is the trigger and `(frame-char-height) == 53' for
>> height triggers the hollow cursor behaviour.
>>
>> Looks like a bug
>>
>
> I've found this in xdisp.c:
>
> ....
>   if (cursor_type == FILLED_BOX_CURSOR)
>    {
>      /* Using a block cursor on large images can be very annoying.
> So use a hollow cursor for "large" images.
> If image is not transparent (no mask), also use hollow cursor.  */
>      struct image *img = IMAGE_OPT_FROM_ID (f, glyph->u.img_id);
>      if (img != NULL && IMAGEP (img->spec))
> {
>  /* Arbitrarily, interpret "Large" as >32x32 and >NxN
>     where N = size of default frame font size.
>     This should cover most of the "tiny" icons people may use.  */
>  if (!img->mask
>      || img->width > max (32, WINDOW_FRAME_COLUMN_WIDTH (w))
>      || img->height > max (32, WINDOW_FRAME_LINE_HEIGHT (w)))
>    cursor_type = HOLLOW_BOX_CURSOR;
> }
> ....
>
> Maybe introduce some property in image spec to control cursor behaviour?
> Or make customizable definition for "tiny" icons?
>
> Thanks
>

This patch implements (box . WIDTH) cursor type, allowing user to define
his own notion for "Large" image

Could you please include it into master

Thanks

-- 
lg

[-- Attachment #1.2: Type: text/html, Size: 2682 bytes --]

[-- Attachment #2: 0001-Support-for-box-.-WIDTH-cursor-type.patch --]
[-- Type: text/x-patch, Size: 3489 bytes --]

From 6406d198e9f3f5b2d93987ed0fd4fe22bd590624 Mon Sep 17 00:00:00 2001
From: Zajcev Evgeny <zevlg@yandex.ru>
Date: Mon, 27 Jan 2020 15:49:46 +0300
Subject: [PATCH] * Support for (box . WIDTH) `cursor-type'

Before this commit, block cursor becomes hollow under "large" masked
images.  Notion for "large" was hardcoded to be image larger then
32x32 in any dimension.

This patch allows user to define his own notion for "large" image,
taking full control of block cursor look under masked images.

With cursor-type equal to `box' cursor will always be block under
masked images.  This differs from former behavior for box cursor.
To get former behavior, set `cursor-type' to (box . 32)
---
 src/buffer.c |  4 ++++
 src/xdisp.c  | 19 +++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 80eaa97..4c47e9b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -6247,6 +6247,9 @@ from (abs POSITION).  If POSITION is positive, point was at the front
   t               use the cursor specified for the frame
   nil             don't display a cursor
   box             display a filled box cursor
+  (box . WIDTH)   display a filled box cursor, but make it
+                  hollow if cursor is under masked image larger then
+                  WIDTH in either dimention.
   hollow          display a hollow box cursor
   bar             display a vertical bar cursor with default width
   (bar . WIDTH)   display a vertical bar cursor with width WIDTH
@@ -6255,6 +6258,7 @@ from (abs POSITION).  If POSITION is positive, point was at the front
   ANYTHING ELSE   display a hollow box cursor
 
 WIDTH and HEIGHT can't exceed the frame's canonical character size.
+Except for (box . WIDTH) case.
 
 When the buffer is displayed in a non-selected window, the
 cursor's appearance is instead controlled by the variable
diff --git a/src/xdisp.c b/src/xdisp.c
index 3080f89..371589c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -30683,6 +30683,14 @@ get_specified_cursor_type (Lisp_Object arg, int *width)
   if (EQ (arg, Qbox))
     return FILLED_BOX_CURSOR;
 
+  if (CONSP (arg)
+      && EQ (XCAR (arg), Qbox)
+      && RANGED_FIXNUMP (0, XCDR (arg), INT_MAX))
+    {
+      *width = XFIXNUM (XCDR (arg));
+      return FILLED_BOX_CURSOR;
+    }
+
   if (EQ (arg, Qhollow))
     return HOLLOW_BOX_CURSOR;
 
@@ -30849,12 +30857,15 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
 	      struct image *img = IMAGE_OPT_FROM_ID (f, glyph->u.img_id);
 	      if (img != NULL && IMAGEP (img->spec))
 		{
-		  /* Arbitrarily, interpret "Large" as >32x32 and >NxN
+		  /* Interpret "large" as >WIDTHxWIDTH and >NxN
+                     where WIDTH is the value from cursor-type in form (box . WIDTH),
 		     where N = size of default frame font size.
-		     This should cover most of the "tiny" icons people may use.  */
+                     So, setting cursor-type to (box . 32) should cover most of
+                     the "tiny" icons people may use.  */
 		  if (!img->mask
-		      || img->width > max (32, WINDOW_FRAME_COLUMN_WIDTH (w))
-		      || img->height > max (32, WINDOW_FRAME_LINE_HEIGHT (w)))
+                      || (CONSP (BVAR (b, cursor_type))
+                          && img->width > max (*width, WINDOW_FRAME_COLUMN_WIDTH (w))
+                          && img->height > max (*width, WINDOW_FRAME_LINE_HEIGHT (w))))
 		    cursor_type = HOLLOW_BOX_CURSOR;
 		}
 	    }
-- 
2.7.4


  reply	other threads:[~2020-01-27 12:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 18:14 Hollow cursor under images Evgeny Zajcev
2019-03-04 19:05 ` Eli Zaretskii
2019-03-04 20:04   ` Evgeny Zajcev
2019-03-04 20:22     ` Eli Zaretskii
2019-03-04 20:27       ` Evgeny Zajcev
2019-03-05  3:24         ` Eli Zaretskii
2019-03-04 22:36     ` Alan Third
2019-03-05 10:19       ` Evgeny Zajcev
2019-09-14 11:48         ` Evgeny Zajcev
2020-01-27 12:54           ` Evgeny Zajcev [this message]
2020-01-27 18:33             ` Eli Zaretskii
2020-01-28  8:46               ` Evgeny Zajcev
2020-01-28 18:16                 ` Eli Zaretskii
2020-01-28 11:55               ` Evgeny Zajcev
2020-01-28 18:22                 ` Eli Zaretskii
2020-02-03 11:24                   ` Evgeny Zajcev
2020-02-07 10:12                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO=W_ZoQ+RrWog0kGh7kfNEegFVYwYgsT4yTBSaSRHucqdH2AQ@mail.gmail.com' \
    --to=lg.zevlg@gmail.com \
    --cc=alan@idiocy.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).