From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ben Key Newsgroups: gmane.emacs.devel Subject: Patch to ensure that the hbar cursor is drawn correctly on Mac OS X Date: Sat, 5 Mar 2011 22:20:16 -0600 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=bcaec5196de36c5994049dc8b310 X-Trace: dough.gmane.org 1299385257 4497 80.91.229.12 (6 Mar 2011 04:20:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 6 Mar 2011 04:20:57 +0000 (UTC) To: Emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 06 05:20:45 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pw5SW-0004i1-2a for ged-emacs-devel@m.gmane.org; Sun, 06 Mar 2011 05:20:44 +0100 Original-Received: from localhost ([127.0.0.1]:35778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pw5SV-0005gh-DF for ged-emacs-devel@m.gmane.org; Sat, 05 Mar 2011 23:20:43 -0500 Original-Received: from [140.186.70.92] (port=51835 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pw5SQ-0005fQ-St for Emacs-devel@gnu.org; Sat, 05 Mar 2011 23:20:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pw5SP-0006H0-DK for Emacs-devel@gnu.org; Sat, 05 Mar 2011 23:20:38 -0500 Original-Received: from mail-bw0-f41.google.com ([209.85.214.41]:51097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pw5SO-0006Go-Tz for Emacs-devel@gnu.org; Sat, 05 Mar 2011 23:20:37 -0500 Original-Received: by bwz17 with SMTP id 17so3513307bwz.0 for ; Sat, 05 Mar 2011 20:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=wI+nTcyoKdGqGN5jodiECo7VC5EFPX/LQt2fzAzm79w=; b=x/NtvZQzEE9W+B5M+rCcLGdCvg4nT76OfCyy35B9i5DgDni6KB1FC8Q0epj+HccVwy G3uruR4EVJkjYqhOZBQo5v/6KAdit5UKxinguBCSBSfbIuSgiRsemzi6qLlpeE4foPoG omWHMqVvRDLpjSWAjrb/f8Omj3McZiuAtdoho= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=rdacIi7FmpI48YZbSWZYv6cmfzDBbecWClwG7CRms3gkfXg0B/aOiDKIaQFekjsPG1 dybPXJ39PZ4rqZ19WkrIm+f4kiDEcVfsVJ+5okQNcH4Iyba5u1yDpTCdd0QPXHPeX/5x /Qw8SJ80O0kH7Sp/t8i8DVZ5avr8o/jq2Yf5Q= Original-Received: by 10.204.174.1 with SMTP id r1mr2094907bkz.28.1299385236084; Sat, 05 Mar 2011 20:20:36 -0800 (PST) Original-Received: by 10.204.14.212 with HTTP; Sat, 5 Mar 2011 20:20:16 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.214.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:136804 Archived-At: --bcaec5196de36c5994049dc8b310 Content-Type: text/plain; charset=ISO-8859-1 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. As I mentioned in an earlier message, when the user sets the cursor-type variable to the form (hbar . HEIGHT), the user specified value for HEIGHT is being used as the cursor width even though the expected behavior is for the cursor to be as wide as the glyph at point. This patch also fixes a long standing problem that caused the user specified cursor height to be ignored in this case (the cursor height was set to 25% of the height of the glyph at point instead). This problem goes back to at least Emacs 23.2. === modified file 'src/nsterm.m' --- src/nsterm.m 2011-03-05 23:55:43 +0000 +++ src/nsterm.m 2011-03-06 03:58:47 +0000 @@ -2232,6 +2232,9 @@ /* -------------------------------------------------------------------------- External call (RIF): draw cursor. Note that CURSOR_WIDTH is meaningful only for (h)bar cursors. + Despite the parameter name, cursor_width is set to the user + specified cursor width for a bar cursor and the user specified + cursor height for a hbar cursor. -------------------------------------------------------------------------- */ { NSRect r, s; @@ -2280,7 +2283,7 @@ /* 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) + if (cursor_type == BAR_CURSOR) { if (cursor_width < 1) cursor_width = max (FRAME_CURSOR_WIDTH (f), 1); @@ -2338,8 +2341,29 @@ break; case HBAR_CURSOR: s = r; - s.origin.y += lrint (0.75 * s.size.height); - s.size.height = lrint (s.size.height * 0.25); + /* + When the user sets the cursor-type variable to the form + (hbar . HEIGHT), the cursor_width parameter is equal to the user + specified value for height when this function is called. + Previously Emacs was not honoring this value. The following if + statement is designed to resolve this problem. Note that at + this point, s.origin.y is equal to the pixel position of the top + of the character at point. The expectation is for the cursor to + be placed at the bottom of the character at point. It is + important to keep this in mind when modifying s here. At this + point, s.size.height is equal to the height of the glyph at + point. + */ + if (cursor_width > 1) + { + s.origin.y += s.size.height - cursor_width; + s.size.height = cursor_width; + } + else + { + s.origin.y += lrint (0.75 * s.size.height); + s.size.height = lrint (s.size.height * 0.25); + } NSRectFill (s); break; case BAR_CURSOR: With this change, the cursor is drawn correctly on Mac OS X when the cursor-type variable is set to a value with the form (bar . WIDTH) or the form (hbar . HEIGHT). --bcaec5196de36c5994049dc8b310 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello,

The following patch fixes problems with the = hbar cursor on Mac OS X that were caused by recent changes to ns_draw_windo= w_cursor.=A0 As I mentioned in an earlier message, when the user sets the c= ursor-type variable to the form (hbar . HEIGHT), the user specified value f= or HEIGHT is being used as the cursor width even though the expected behavi= or is for the cursor to be as wide as the glyph at point.=A0 This patch als= o fixes a long standing problem that caused the user specified cursor heigh= t to be ignored in this case (the cursor height was set to 25% of the heigh= t of the glyph at point instead).=A0 This problem goes back to at least Ema= cs 23.2.
=A0
<patch>
=3D=3D=3D modified file 'src/nsterm.m'
-= -- src/nsterm.m=A0=A0=A0 2011-03-05 23:55:43 +0000
+++ src/nsterm.m=A0= =A0=A0 2011-03-06 03:58:47 +0000
@@ -2232,6 +2232,9 @@
=A0/* --------= ------------------------------------------------------------------
=A0=A0=A0=A0=A0 External call (RIF): draw cursor.
=A0=A0=A0=A0=A0 Note t= hat CURSOR_WIDTH is meaningful only for (h)bar cursors.
+=A0=A0=A0=A0 De= spite the parameter name, cursor_width is set to the user
+=A0=A0=A0=A0 = specified cursor width for a bar cursor and the user specified
+=A0=A0=A0=A0 cursor height for a hbar cursor.
=A0=A0=A0 ---------------= ----------------------------------------------------------- */
=A0{
= =A0=A0 NSRect r, s;
@@ -2280,7 +2283,7 @@
=A0
=A0=A0 /* The above = get_phys_cursor_geometry call set w->phys_cursor_width
=A0=A0=A0=A0=A0 to the glyph width; replace with CURSOR_WIDTH for bar curso= rs. */
-=A0 if (cursor_type =3D=3D BAR_CURSOR || cursor_type =3D=3D HBAR= _CURSOR)
+=A0 if (cursor_type =3D=3D BAR_CURSOR)
=A0=A0=A0=A0 {
= =A0=A0=A0=A0=A0=A0 if (cursor_width < 1)
=A0=A0=A0=A0 cursor_width =3D max (FRAME_CURSOR_WIDTH (f), 1);
@@ -2338,= 8 +2341,29 @@
=A0=A0=A0=A0=A0=A0 break;
=A0=A0=A0=A0 case HBAR_CURSOR= :
=A0=A0=A0=A0=A0=A0 s =3D r;
-=A0=A0=A0=A0=A0 s.origin.y +=3D lrint = (0.75 * s.size.height);
-=A0=A0=A0=A0=A0 s.size.height =3D lrint (s.size= .height * 0.25);
+=A0=A0=A0=A0=A0 /*
+=A0=A0=A0=A0=A0 When the user sets the cursor-type = variable to the form
+=A0=A0=A0=A0=A0 (hbar . HEIGHT), the cursor_width = parameter is equal to the user
+=A0=A0=A0=A0=A0 specified value for heig= ht when this function is called.
+=A0=A0=A0=A0=A0 Previously Emacs was not honoring this value.=A0 The follo= wing if
+=A0=A0=A0=A0=A0 statement is designed to resolve this problem.= =A0 Note that at
+=A0=A0=A0=A0=A0 this point, s.origin.y is equal to the= pixel position of the top
+=A0=A0=A0=A0=A0 of the character at point.=A0 The expectation is for the c= ursor to
+=A0=A0=A0=A0=A0 be placed at the bottom of the character at point.=A0 It i= s
+=A0=A0=A0=A0=A0 important to keep this in mind when modifying s here.= =A0 At this
+=A0=A0=A0=A0=A0 point, s.size.height is equal to the height= of the glyph at
+=A0=A0=A0=A0=A0 point.
+=A0=A0=A0=A0=A0 */
+=A0=A0=A0=A0=A0 if (cursor_width > 1)
+=A0=A0= =A0=A0=A0=A0=A0 {
+=A0=A0=A0=A0=A0=A0=A0=A0=A0 s.origin.y +=3D s.size.he= ight - cursor_width;
+=A0=A0=A0=A0=A0=A0=A0=A0=A0 s.size.height =3D curs= or_width;=A0=A0=A0=A0=A0=A0
+=A0=A0=A0=A0=A0=A0=A0 }
+=A0=A0=A0=A0= =A0 else
+=A0=A0=A0=A0=A0=A0=A0 {
+=A0=A0=A0=A0=A0=A0=A0=A0=A0 s.orig= in.y +=3D lrint (0.75 * s.size.height);
+=A0=A0=A0=A0=A0=A0=A0=A0=A0 s.size.height =3D lrint (s.size.height * 0.25)= ;
+=A0=A0=A0=A0=A0=A0=A0 }
=A0=A0=A0=A0=A0=A0 NSRectFill (s);
=A0= =A0=A0=A0=A0=A0 break;
=A0=A0=A0=A0 case BAR_CURSOR:

</patch&g= t;

With this change, the cursor is drawn correctly on Mac OS X when = the cursor-type variable is set to a value with the form (bar . WIDTH) or t= he form (hbar . HEIGHT).

--bcaec5196de36c5994049dc8b310--