From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Adrian Robert Newsgroups: gmane.emacs.devel 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) Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1299402048 30326 80.91.229.12 (6 Mar 2011 09:00:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 6 Mar 2011 09:00:48 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 06 10:00:44 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 1Pw9pT-0000xX-RL for ged-emacs-devel@m.gmane.org; Sun, 06 Mar 2011 10:00:44 +0100 Original-Received: from localhost ([127.0.0.1]:40321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pw9pT-00037W-8s for ged-emacs-devel@m.gmane.org; Sun, 06 Mar 2011 04:00:43 -0500 Original-Received: from [140.186.70.92] (port=33291 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pw9pA-00033t-7I for emacs-devel@gnu.org; Sun, 06 Mar 2011 04:00:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pw9p3-00025r-1n for emacs-devel@gnu.org; Sun, 06 Mar 2011 04:00:24 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:35646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pw9p2-00024F-Fm for emacs-devel@gnu.org; Sun, 06 Mar 2011 04:00:16 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pw9oz-0000nX-Or for emacs-devel@gnu.org; Sun, 06 Mar 2011 10:00:13 +0100 Original-Received: from dsl-hkibrasgw2-fefade00-174.dhcp.inet.fi ([80.222.250.174]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 Mar 2011 10:00:13 +0100 Original-Received: from Adrian.B.Robert by dsl-hkibrasgw2-fefade00-174.dhcp.inet.fi with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 Mar 2011 10:00:13 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 68 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 80.222.250.174 (Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 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:136808 Archived-At: Ben Key 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;