unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Evgeny Zajcev <lg.zevlg@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: [PATCH] Fix display box cursor under image with margins
Date: Sat, 25 Apr 2020 16:57:11 +0300	[thread overview]
Message-ID: <CAO=W_Zq+bL9Mp9htwJ7WuEvjWOeARq4AcuoL4VJmEhf8wXN0Jg@mail.gmail.com> (raw)
In-Reply-To: <jwv4kt7ojjc.fsf-monnier+emacs@gnu.org>


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

сб, 25 апр. 2020 г. в 15:09, Stefan Monnier <monnier@iro.umontreal.ca>:

> > Here is first screenshot how hollow cursor looks on image with margin -
> > http://lgarc.narod.ru/pics/emacs-hollow-cursor.png
> >
> > And here is how it looks with patch applied -
> > http://lgarc.narod.ru/pics/emacs-box-cursor.png
>
> Would it be possible to keep the two thin horizontal lines when the
> window is active?
>
>
I figured out, how to do this in "easy" way.  Here is patches update

And screenshots: http://lgarc.narod.ru/pics/emacs-box-margin1.png
http://lgarc.narod.ru/pics/emacs-box-margin2.png

This patch introduces new cursor type - COMBINED_BOX_CURSOR (used only
internally for box cursor under images with mask or margins)

Thanks

-- 
lg

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

[-- Attachment #2: 0001-Fix-display-box-cursor-under-image-with-margins.patch --]
[-- Type: text/x-patch, Size: 1340 bytes --]

From f63be59b0be41d0a96eb83e1ba2926d332311bca Mon Sep 17 00:00:00 2001
From: Zajcev Evgeny <zevlg@yandex.ru>
Date: Sat, 18 Apr 2020 20:22:40 +0300
Subject: [PATCH 1/2] Fix display box cursor under image with margins

* src/xdisp.c (get_window_cursor_type): Do not make box cursor hollow
if cursor is under image with any margin.
---
 src/xdisp.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 193cc372b0..d3294e1e99 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -30896,10 +30896,11 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
 		     font size.  So, setting cursor-type to (box . 32)
 		     should cover most of the "tiny" icons people may
 		     use.  */
-		  if (!img->mask
-		      || (CONSP (BVAR (b, cursor_type))
-			  && img->width > max (*width, WINDOW_FRAME_COLUMN_WIDTH (w))
-			  && img->height > max (*width, WINDOW_FRAME_LINE_HEIGHT (w))))
+		  if (!img->hmargin && !img->vmargin
+                      && (!img->mask
+                          || (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.17.1


[-- Attachment #3: 0002-New-COMBINED_BOX_CURSOR-cursor-type-introduced-for-i.patch --]
[-- Type: text/x-patch, Size: 3123 bytes --]

From d95e7c992b62d17a01637165cc5530fe435ab3a7 Mon Sep 17 00:00:00 2001
From: Zajcev Evgeny <zevlg@yandex.ru>
Date: Sat, 25 Apr 2020 16:51:04 +0300
Subject: [PATCH 2/2] New COMBINED_BOX_CURSOR cursor type introduced for
 internal use

* src/dispextern.h (text_cursor_kinds): COMBINED_BOX_CURSOR added

* src/w32term.c, src/xterm.c: Support for COMBINED_BOX_CURSOR cursor
  type

* src/xdisp.c (get_window_cursor_type): Use COMBINED_BOX_CURSOR for
  box cursor under images with mask or any margin
---
 src/dispextern.h |  7 ++++++-
 src/w32term.c    |  3 +++
 src/xdisp.c      | 10 +++++-----
 src/xterm.c      |  3 +++
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/dispextern.h b/src/dispextern.h
index ae994d7f9b..a1a0922e92 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -156,7 +156,12 @@ #define NativeRectangle int
   FILLED_BOX_CURSOR,
   HOLLOW_BOX_CURSOR,
   BAR_CURSOR,
-  HBAR_CURSOR
+  HBAR_CURSOR,
+
+  /* box cursor combining FILLED_BOX_CURSOR and HOLLOW_BOX_CURSOR
+   * For internal use only
+   */
+  COMBINED_BOX_CURSOR
 };
 
 /* Values returned from coordinates_in_window.  */
diff --git a/src/w32term.c b/src/w32term.c
index 5fa77d58e1..49cd3e4a8c 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -6069,6 +6069,9 @@ w32_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
 
       switch (cursor_type)
 	{
+	case COMBINED_BOX_CURSOR:
+	  draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+          /* FALLTHROUGH */
 	case HOLLOW_BOX_CURSOR:
 	  w32_draw_hollow_cursor (w, glyph_row);
 	  break;
diff --git a/src/xdisp.c b/src/xdisp.c
index d3294e1e99..7fc07f4691 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -30896,11 +30896,11 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
 		     font size.  So, setting cursor-type to (box . 32)
 		     should cover most of the "tiny" icons people may
 		     use.  */
-		  if (!img->hmargin && !img->vmargin
-                      && (!img->mask
-                          || (CONSP (BVAR (b, cursor_type))
-                              && img->width > max (*width, WINDOW_FRAME_COLUMN_WIDTH (w))
-                              && img->height > max (*width, WINDOW_FRAME_LINE_HEIGHT (w)))))
+                  if (img->mask || img->hmargin || img->vmargin)
+                    cursor_type = COMBINED_BOX_CURSOR;
+                  else if (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;
 		}
 	    }
diff --git a/src/xterm.c b/src/xterm.c
index ae5dad9289..0f1ec4dec3 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9670,6 +9670,9 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
 	{
 	  switch (cursor_type)
 	    {
+            case COMBINED_BOX_CURSOR:
+	      draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
+              /* FALLTHROUGH */
 	    case HOLLOW_BOX_CURSOR:
 	      x_draw_hollow_cursor (w, glyph_row);
 	      break;
-- 
2.17.1


  parent reply	other threads:[~2020-04-25 13:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-18 17:28 [PATCH] Fix display box cursor under image with margins Evgeny Zajcev
2020-04-18 17:44 ` Eli Zaretskii
2020-04-18 18:05   ` Evgeny Zajcev
2020-04-25 10:35     ` Eli Zaretskii
2020-04-25 10:48       ` Evgeny Zajcev
2020-04-25 10:55       ` Evgeny Zajcev
2020-04-25 11:22       ` Basil L. Contovounesios
2020-04-25 13:19       ` Clément Pit-Claudel
2020-04-25 12:09     ` Stefan Monnier
2020-04-25 12:44       ` Evgeny Zajcev
2020-04-25 13:57       ` Evgeny Zajcev [this message]
2020-05-10 12:14         ` Evgeny Zajcev
2020-05-10 14:09           ` Eli Zaretskii
2020-06-13 15:55             ` Basil L. Contovounesios
2020-07-24 11:45               ` Stefan Kangas
2020-05-10 12:52         ` Stefan Kangas
2020-05-10 14:08           ` Evgeny Zajcev
2020-05-10 15:38             ` Michael Welsh Duggan
2020-05-10 16:48               ` Stefan Monnier
2020-05-11 15:51             ` Stefan Kangas
2020-05-11 16:34               ` andres.ramirez

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_Zq+bL9Mp9htwJ7WuEvjWOeARq4AcuoL4VJmEhf8wXN0Jg@mail.gmail.com' \
    --to=lg.zevlg@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).