unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Adrian Robert <Adrian.B.Robert@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Patch to ensure that the hbar cursor is drawn correctly on Mac OS X
Date: Sun, 6 Mar 2011 09:00:03 +0000 (UTC)	[thread overview]
Message-ID: <loom.20110306T095331-982@post.gmane.org> (raw)
In-Reply-To: AANLkTimf7eEFX8hLOCMvwZjaaLi5eVa0RNKpEScThG+o@mail.gmail.com

Ben Key <bkey76 <at> gmail.com> writes:

> 
> Hello,The following patch fixes problems with the hbar cursor on
> Mac OS X that were caused by recent changes to ns_draw_window_cursor.


Hi,

Thanks a lot for this patch.  Could you try this one instead?
It's based on yours, but I'd rather keep the "width"-handling in one place.
Also, a height of 1 seems acceptable.

thanks,
Adrian




=== modified file 'src/nsterm.m'
--- src/nsterm.m	2011-03-05 23:55:43 +0000
+++ src/nsterm.m	2011-03-06 08:46:02 +0000
@@ -2235,7 +2235,7 @@ ns_draw_window_cursor (struct window *w,
    ---------------------------------------------------------
----------------- */
 {
   NSRect r, s;
-  int fx, fy, h;
+  int fx, fy, h, cursor_height;
   struct frame *f = WINDOW_XFRAME (w);
   struct glyph *phys_cursor_glyph;
   int overspill;
@@ -2279,13 +2279,20 @@ ns_draw_window_cursor (struct window *w,
   get_phys_cursor_geometry (w, glyph_row, phys_cursor_glyph, &fx, &fy, &h);
 
   /* The above get_phys_cursor_geometry call set w->phys_cursor_width
-     to the glyph width; replace with CURSOR_WIDTH for bar cursors. */
-  if (cursor_type == BAR_CURSOR || cursor_type == HBAR_CURSOR)
+     to the glyph width; replace with CURSOR_WIDTH for (V)BAR cursors. */
+  if (cursor_type == BAR_CURSOR)
     {
       if (cursor_width < 1)
 	cursor_width = max (FRAME_CURSOR_WIDTH (f), 1);
       w->phys_cursor_width = cursor_width;
     }
+  /* If we have an HBAR, "cursor_width" MAY specify height. */
+  else if (cursor_type == HBAR_CURSOR)
+    {
+      cursor_height = (cursor_width < 1) ? lrint (0.25 * h) : cursor_width;
+      fy += h - cursor_height;
+      h = cursor_height;
+    }
 
   r.origin.x = fx, r.origin.y = fy;
   r.size.height = h;
@@ -2337,10 +2344,7 @@ ns_draw_window_cursor (struct window *w,
       [FRAME_CURSOR_COLOR (f) set];
       break;
     case HBAR_CURSOR:
-      s = r;
-      s.origin.y += lrint (0.75 * s.size.height);
-      s.size.height = lrint (s.size.height * 0.25);
-      NSRectFill (s);
+      NSRectFill (r);
       break;
     case BAR_CURSOR:
       s = r;





  reply	other threads:[~2011-03-06  9:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-06  4:20 Patch to ensure that the hbar cursor is drawn correctly on Mac OS X Ben Key
2011-03-06  9:00 ` Adrian Robert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-03-06 14:24 Ben Key
2011-03-07  9:20 ` Adrian Robert

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=loom.20110306T095331-982@post.gmane.org \
    --to=adrian.b.robert@gmail.com \
    --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).