unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Cursor in non-selected windows is 1 pixel too small
@ 2006-03-03 10:16 Markus Gritsch
  2006-03-04  9:54 ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Gritsch @ 2006-03-03 10:16 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 239 bytes --]

Hi,

The cursor displayed in non-selected windows is one pixel too small in 
the vertical direction.  The attachment shows a magnified screenshot.

GNU Emacs 22.0.50.1 (i386-mingw-nt5.2.3790) of 2006-02-21 on MGROOVY

Kind regards,
Markus

[-- Attachment #2: inactive_cursor.png --]
[-- Type: image/png, Size: 3211 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-03 10:16 Cursor in non-selected windows is 1 pixel too small Markus Gritsch
@ 2006-03-04  9:54 ` Eli Zaretskii
  2006-03-04 10:04   ` Markus Gritsch
  0 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2006-03-04  9:54 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Fri, 03 Mar 2006 11:16:07 +0100
> From: Markus Gritsch <gritsch@iue.tuwien.ac.at>
> 
> The cursor displayed in non-selected windows is one pixel too small in 
> the vertical direction.  The attachment shows a magnified screenshot.

Thanks, but how do you see from that screenshot that the cursor is one
pixel too short?  I found nothing to compare it with.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04  9:54 ` Eli Zaretskii
@ 2006-03-04 10:04   ` Markus Gritsch
  2006-03-04 10:18     ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Gritsch @ 2006-03-04 10:04 UTC (permalink / raw)
  Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

Eli Zaretskii wrote:
>>Date: Fri, 03 Mar 2006 11:16:07 +0100
>>From: Markus Gritsch <gritsch@iue.tuwien.ac.at>
>>
>>The cursor displayed in non-selected windows is one pixel too small in 
>>the vertical direction.  The attachment shows a magnified screenshot.
> 
> 
> Thanks, but how do you see from that screenshot that the cursor is one
> pixel too short?  I found nothing to compare it with.

If the window is the *selected* window, the cursor is displayed as a 
filled box, and is one pixel taller at the bottom.

Kind regards,
Markus

[-- Attachment #2: window_selected.png --]
[-- Type: image/png, Size: 510 bytes --]

[-- Attachment #3: window_not_selected.png --]
[-- Type: image/png, Size: 589 bytes --]

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 10:04   ` Markus Gritsch
@ 2006-03-04 10:18     ` Eli Zaretskii
  2006-03-04 10:33       ` Markus Gritsch
  0 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2006-03-04 10:18 UTC (permalink / raw)
  Cc: emacs-devel

> Date: Sat, 04 Mar 2006 11:04:49 +0100
> From: Markus Gritsch <gritsch@iue.tuwien.ac.at>
> CC:  emacs-devel@gnu.org
> 
> >>The cursor displayed in non-selected windows is one pixel too small in 
> >>the vertical direction.  The attachment shows a magnified screenshot.
> > 
> > 
> > Thanks, but how do you see from that screenshot that the cursor is one
> > pixel too short?  I found nothing to compare it with.
> 
> If the window is the *selected* window, the cursor is displayed as a 
> filled box, and is one pixel taller at the bottom.

Sorry, I don't see this on my machine (Windows XP).  To me, both
cursors look identical in their dimensions.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 10:18     ` Eli Zaretskii
@ 2006-03-04 10:33       ` Markus Gritsch
  2006-03-04 11:01         ` Markus Gritsch
  2006-03-04 14:16         ` Eli Zaretskii
  0 siblings, 2 replies; 18+ messages in thread
From: Markus Gritsch @ 2006-03-04 10:33 UTC (permalink / raw)
  Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 934 bytes --]

Eli Zaretskii wrote:

>>Date: Sat, 04 Mar 2006 11:04:49 +0100
>>From: Markus Gritsch <gritsch@iue.tuwien.ac.at>
>>CC:  emacs-devel@gnu.org
>>
>>
>>>>The cursor displayed in non-selected windows is one pixel too small in 
>>>>the vertical direction.  The attachment shows a magnified screenshot.
>>>
>>>
>>>Thanks, but how do you see from that screenshot that the cursor is one
>>>pixel too short?  I found nothing to compare it with.
>>
>>If the window is the *selected* window, the cursor is displayed as a 
>>filled box, and is one pixel taller at the bottom.
> 
> Sorry, I don't see this on my machine (Windows XP).  To me, both
> cursors look identical in their dimensions.

I am also using WinXP. The attached screenshot shows an Emacs started 
with -q. The cursor seen there in the lower window is clearly one pixel 
smaller in vertical direction. You are of course running a recent CVS 
Emacs, arn't you?

Kind regards,
Markus

[-- Attachment #2: emacs.png --]
[-- Type: image/png, Size: 20871 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 10:33       ` Markus Gritsch
@ 2006-03-04 11:01         ` Markus Gritsch
  2006-03-04 14:16         ` Eli Zaretskii
  1 sibling, 0 replies; 18+ messages in thread
From: Markus Gritsch @ 2006-03-04 11:01 UTC (permalink / raw)
  Cc: emacs-devel

Markus Gritsch wrote:

> Eli Zaretskii wrote:
> 
>>> Date: Sat, 04 Mar 2006 11:04:49 +0100
>>> From: Markus Gritsch <gritsch@iue.tuwien.ac.at>
>>> CC:  emacs-devel@gnu.org
>>>
>>>
>>>>> The cursor displayed in non-selected windows is one pixel too small 
>>>>> in the vertical direction.  The attachment shows a magnified 
>>>>> screenshot.
>>>>
>>>> Thanks, but how do you see from that screenshot that the cursor is one
>>>> pixel too short?  I found nothing to compare it with.
>>>
>>> If the window is the *selected* window, the cursor is displayed as a 
>>> filled box, and is one pixel taller at the bottom.
>>
>> Sorry, I don't see this on my machine (Windows XP).  To me, both
>> cursors look identical in their dimensions.
> 
> I am also using WinXP. The attached screenshot shows an Emacs started 
> with -q. The cursor seen there in the lower window is clearly one pixel 
> smaller in vertical direction.

I'm sorry, I should have written "the hollow cursor in the *upper* 
window is one pixel smaller."

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 10:33       ` Markus Gritsch
  2006-03-04 11:01         ` Markus Gritsch
@ 2006-03-04 14:16         ` Eli Zaretskii
  2006-03-04 14:29           ` Markus Gritsch
  2006-03-04 22:19           ` Kim F. Storm
  1 sibling, 2 replies; 18+ messages in thread
From: Eli Zaretskii @ 2006-03-04 14:16 UTC (permalink / raw)
  Cc: emacs-devel, storm

> Date: Sat, 04 Mar 2006 11:33:11 +0100
> From: Markus Gritsch <gritsch@iue.tuwien.ac.at>
> CC:  emacs-devel@gnu.org
> 
> I am also using WinXP. The attached screenshot shows an Emacs started 
> with -q. The cursor seen there in the lower window is clearly one pixel 
> smaller in vertical direction.

Well, I wouldn't say it's ``clearly one pixel smaller''.  Perhaps I'm
too blind.

Anyway, I eventually convinced myself you were right.  Does the
following patch give good results?

> You are of course running a recent CVS Emacs, arn't you?

Yes.

Btw, I'm not sure I understand why xdisp.c:get_phys_cursor_geometry
decrements by one the value of height it computes:

  *heightp = h - 1;

Kim, can you comment on that?  Is it possible that this problem is not
specific to MS-Windows?


Index: src/w32term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
retrieving revision 1.238
diff -u -p -r1.238 w32term.c
--- src/w32term.c	6 Feb 2006 15:23:22 -0000	1.238
+++ src/w32term.c	4 Mar 2006 14:11:40 -0000
@@ -4946,7 +4946,7 @@ x_draw_hollow_cursor (w, row)
   /* Compute frame-relative coordinates for phys cursor.  */
   rect.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
   rect.top = get_phys_cursor_geometry (w, row, cursor_glyph, &h);
-  rect.bottom = rect.top + h;
+  rect.bottom = rect.top + h + 1;
   rect.right = rect.left + w->phys_cursor_width;
 
   hdc = get_frame_dc (f);

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 14:16         ` Eli Zaretskii
@ 2006-03-04 14:29           ` Markus Gritsch
  2006-03-04 14:51             ` Eli Zaretskii
  2006-03-04 22:19           ` Kim F. Storm
  1 sibling, 1 reply; 18+ messages in thread
From: Markus Gritsch @ 2006-03-04 14:29 UTC (permalink / raw)
  Cc: emacs-devel, storm

Eli Zaretskii wrote:

> Well, I wouldn't say it's ``clearly one pixel smaller''.

Therefore I proposed all the magnified screenshots in my previous posts :)

> Anyway, I eventually convinced myself you were right.  Does the
> following patch give good results?

Yes, with this patch the cursor in non-selected windows has the correct 
height.

Thanks,
Markus

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 14:29           ` Markus Gritsch
@ 2006-03-04 14:51             ` Eli Zaretskii
  0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2006-03-04 14:51 UTC (permalink / raw)
  Cc: emacs-devel, storm

> Date: Sat, 04 Mar 2006 15:29:56 +0100
> From: Markus Gritsch <gritsch@iue.tuwien.ac.at>
> CC:  storm@cua.dk,  emacs-devel@gnu.org
> 
> Eli Zaretskii wrote:
> 
> > Well, I wouldn't say it's ``clearly one pixel smaller''.
> 
> Therefore I proposed all the magnified screenshots in my previous posts :)

The magnified screenshot has nothing to compare the hollow cursor
with, as I already told you.

> > Anyway, I eventually convinced myself you were right.  Does the
> > following patch give good results?
> 
> Yes, with this patch the cursor in non-selected windows has the correct 
> height.

Thanks for testing it.  I will wait for Kim to look into the code in
get_phys_cursor_geometry before I commit the patch, since it's
possible that what actually needs patching is get_phys_cursor_geometry.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 14:16         ` Eli Zaretskii
  2006-03-04 14:29           ` Markus Gritsch
@ 2006-03-04 22:19           ` Kim F. Storm
  2006-03-05  9:14             ` YAMAMOTO Mitsuharu
  2006-03-11 12:06             ` Eli Zaretskii
  1 sibling, 2 replies; 18+ messages in thread
From: Kim F. Storm @ 2006-03-04 22:19 UTC (permalink / raw)
  Cc: Markus Gritsch, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Sat, 04 Mar 2006 11:33:11 +0100
>> From: Markus Gritsch <gritsch@iue.tuwien.ac.at>
>> CC:  emacs-devel@gnu.org
>> 
>> I am also using WinXP. The attached screenshot shows an Emacs started 
>> with -q. The cursor seen there in the lower window is clearly one pixel 
>> smaller in vertical direction.
>
> Well, I wouldn't say it's ``clearly one pixel smaller''.  Perhaps I'm
> too blind.
>
> Anyway, I eventually convinced myself you were right.  Does the
> following patch give good results?
>
>> You are of course running a recent CVS Emacs, arn't you?
>
> Yes.
>
> Btw, I'm not sure I understand why xdisp.c:get_phys_cursor_geometry
> decrements by one the value of height it computes:
>
>   *heightp = h - 1;
>
> Kim, can you comment on that?

The code in xdisp.c:get_phys_cursor_geometry is simply based on the
code in xterm.c, w32term.c and macterm.c when I merged the X, W32, and
MAC codes for cursor display.  I didn't validate that the functionality
was sensible -- only that the code on all three cases was identical.

>  Is it possible that this problem is not
> specific to MS-Windows?

I believe it works for X, fails for w32, and ... MAC?

However, it does seem to make sense to fix the height returned by
get_phys_cursor_geometry (don't subtract 1), and then fix the use
in xterm.c and macterm.c(?) to subtract 1 from the returned height.
(and leave w32termc. as is).

Will you make those changes?

>
>
> Index: src/w32term.c
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
> retrieving revision 1.238
> diff -u -p -r1.238 w32term.c
> --- src/w32term.c	6 Feb 2006 15:23:22 -0000	1.238
> +++ src/w32term.c	4 Mar 2006 14:11:40 -0000
> @@ -4946,7 +4946,7 @@ x_draw_hollow_cursor (w, row)
>    /* Compute frame-relative coordinates for phys cursor.  */
>    rect.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
>    rect.top = get_phys_cursor_geometry (w, row, cursor_glyph, &h);
> -  rect.bottom = rect.top + h;
> +  rect.bottom = rect.top + h + 1;
>    rect.right = rect.left + w->phys_cursor_width;
>  
>    hdc = get_frame_dc (f);
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
>
>

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 22:19           ` Kim F. Storm
@ 2006-03-05  9:14             ` YAMAMOTO Mitsuharu
  2006-03-05 19:50               ` Eli Zaretskii
  2006-03-11 12:09               ` Eli Zaretskii
  2006-03-11 12:06             ` Eli Zaretskii
  1 sibling, 2 replies; 18+ messages in thread
From: YAMAMOTO Mitsuharu @ 2006-03-05  9:14 UTC (permalink / raw)
  Cc: Eli Zaretskii, Markus Gritsch, emacs-devel

>>>>> On Sat, 04 Mar 2006 23:19:40 +0100, storm@cua.dk (Kim F. Storm) said:

>> Is it possible that this problem is not specific to MS-Windows?

> I believe it works for X, fails for w32, and ... MAC?

Also works for Mac, because some adjustment is made in the drawing
routine mac_draw_rectangle (in macterm.c) so it simulates
XDrawRectangle.

  SetRect (&r, x, y, x + width + 1, y + height + 1);
  FrameRect (&r);

By the way, Quartz 2D (as opposed to QuickDraw above) needs another
kind of adjustment to get the same result:

  CGContextStrokeRect (context,
                       CGRectMake (x + 0.5f, y + 0.5f, width, height));

> However, it does seem to make sense to fix the height returned by
> get_phys_cursor_geometry (don't subtract 1), and then fix the use in
> xterm.c and macterm.c(?) to subtract 1 from the returned height.
> (and leave w32termc. as is).

The W32 port seems to have an adjustment for the cursor width in
get_phys_cursor_geometry:

  wd = glyph->pixel_width - 1;
#ifdef HAVE_NTGUI
  wd++; /* Why? */
#endif

So, wherever we add adjustment, it should be done in a consistent way
between width and height, I think.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-05  9:14             ` YAMAMOTO Mitsuharu
@ 2006-03-05 19:50               ` Eli Zaretskii
  2006-03-06  1:48                 ` YAMAMOTO Mitsuharu
  2006-03-06 10:54                 ` Kim F. Storm
  2006-03-11 12:09               ` Eli Zaretskii
  1 sibling, 2 replies; 18+ messages in thread
From: Eli Zaretskii @ 2006-03-05 19:50 UTC (permalink / raw)
  Cc: gritsch, emacs-devel, storm

> Date: Sun, 05 Mar 2006 18:14:03 +0900
> From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
> Cc: Eli Zaretskii <eliz@gnu.org>,
> 	Markus Gritsch <gritsch@iue.tuwien.ac.at>, emacs-devel@gnu.org
> 
> The W32 port seems to have an adjustment for the cursor width in
> get_phys_cursor_geometry:
> 
>   wd = glyph->pixel_width - 1;
> #ifdef HAVE_NTGUI
>   wd++; /* Why? */
> #endif
> 
> So, wherever we add adjustment, it should be done in a consistent way
> between width and height, I think.

I don't have an easy access to an X Windows platform for a moment.
Can someone who has please verify positively that the hollow cursor in
non-selected windows there is _exactly_ the same size in pixels as the
solid block cursor in the selected window?  I looked at the man pages
of XDrawRectangle, and it sounds like it needs the same arguments as
the MS-Windows FrameRect, so I wonder whether we simply missed this on
all platforms.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-05 19:50               ` Eli Zaretskii
@ 2006-03-06  1:48                 ` YAMAMOTO Mitsuharu
  2006-03-06 10:54                 ` Kim F. Storm
  1 sibling, 0 replies; 18+ messages in thread
From: YAMAMOTO Mitsuharu @ 2006-03-06  1:48 UTC (permalink / raw)
  Cc: gritsch, emacs-devel, storm

>>>>> On Sun, 05 Mar 2006 21:50:35 +0200, Eli Zaretskii <eliz@gnu.org> said:

> I don't have an easy access to an X Windows platform for a moment.
> Can someone who has please verify positively that the hollow cursor
> in non-selected windows there is _exactly_ the same size in pixels
> as the solid block cursor in the selected window?

They have exactly the same size with respect to the outer edges as far
as I tested on XFree86 4.3.0 and 4.4.0.

> I looked at the man pages of XDrawRectangle, and it sounds like it
> needs the same arguments as the MS-Windows FrameRect, so I wonder
> whether we simply missed this on all platforms.

I think it is not unnatural that there are some differences about box
drawing among platforms/APIs because:

  1) Each line that constitutes a box has non-zero (in this case 1)
     width.  There are some possibilities about including or excluding
     this line-width in the specified rectangle size especially when
     the line-width is odd.
  2) Some platforms (e.g., W32) define that a pixel is located on a
     crosspoint of coordinate lines, but others (e.g., Mac) define
     that it is located between coordinate lines.  I'm not sure how
     X11 defines that.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-05 19:50               ` Eli Zaretskii
  2006-03-06  1:48                 ` YAMAMOTO Mitsuharu
@ 2006-03-06 10:54                 ` Kim F. Storm
  1 sibling, 0 replies; 18+ messages in thread
From: Kim F. Storm @ 2006-03-06 10:54 UTC (permalink / raw)
  Cc: gritsch, YAMAMOTO Mitsuharu, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Sun, 05 Mar 2006 18:14:03 +0900
>> From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
>> Cc: Eli Zaretskii <eliz@gnu.org>,
>> 	Markus Gritsch <gritsch@iue.tuwien.ac.at>, emacs-devel@gnu.org
>> 
>> The W32 port seems to have an adjustment for the cursor width in
>> get_phys_cursor_geometry:
>> 
>>   wd = glyph->pixel_width - 1;
>> #ifdef HAVE_NTGUI
>>   wd++; /* Why? */
>> #endif
>> 
>> So, wherever we add adjustment, it should be done in a consistent way
>> between width and height, I think.
>
> I don't have an easy access to an X Windows platform for a moment.
> Can someone who has please verify positively that the hollow cursor in
> non-selected windows there is _exactly_ the same size in pixels as the
> solid block cursor in the selected window? 

It is!

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-04 22:19           ` Kim F. Storm
  2006-03-05  9:14             ` YAMAMOTO Mitsuharu
@ 2006-03-11 12:06             ` Eli Zaretskii
  1 sibling, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2006-03-11 12:06 UTC (permalink / raw)
  Cc: gritsch, emacs-devel

> Cc: Markus Gritsch <gritsch@iue.tuwien.ac.at>,  emacs-devel@gnu.org
> From: storm@cua.dk (Kim F. Storm)
> Date: Sat, 04 Mar 2006 23:19:40 +0100
> 
> However, it does seem to make sense to fix the height returned by
> get_phys_cursor_geometry (don't subtract 1), and then fix the use
> in xterm.c and macterm.c(?) to subtract 1 from the returned height.
> (and leave w32termc. as is).
> 
> Will you make those changes?

Done.  Please test the changes on X and the Mac.  I've verified on
W32.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-05  9:14             ` YAMAMOTO Mitsuharu
  2006-03-05 19:50               ` Eli Zaretskii
@ 2006-03-11 12:09               ` Eli Zaretskii
  2006-03-11 13:17                 ` YAMAMOTO Mitsuharu
  1 sibling, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2006-03-11 12:09 UTC (permalink / raw)
  Cc: gritsch, emacs-devel, storm

> Date: Sun, 05 Mar 2006 18:14:03 +0900
> From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
> Cc: Eli Zaretskii <eliz@gnu.org>,
> 	Markus Gritsch <gritsch@iue.tuwien.ac.at>, emacs-devel@gnu.org
> 
> Also works for Mac, because some adjustment is made in the drawing
> routine mac_draw_rectangle (in macterm.c) so it simulates
> XDrawRectangle.
> 
>   SetRect (&r, x, y, x + width + 1, y + height + 1);
>   FrameRect (&r);

Yes, and then all the callers of mac_draw_rectangle except
x_draw_hollow_cursor need to subtract 1 from width and height.  Funny.

I modified mac_draw_rectangle to not add 1 to these two dimensions,
and then removed the decrements from its callers.

> By the way, Quartz 2D (as opposed to QuickDraw above) needs another
> kind of adjustment to get the same result:
> 
>   CGContextStrokeRect (context,
>                        CGRectMake (x + 0.5f, y + 0.5f, width, height));

I cannot find this code in Emacs.

> The W32 port seems to have an adjustment for the cursor width in
> get_phys_cursor_geometry:
> 
>   wd = glyph->pixel_width - 1;
> #ifdef HAVE_NTGUI
>   wd++; /* Why? */
> #endif
> 
> So, wherever we add adjustment, it should be done in a consistent way
> between width and height, I think.

I didn't do anything about this bit.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-11 12:09               ` Eli Zaretskii
@ 2006-03-11 13:17                 ` YAMAMOTO Mitsuharu
  2006-03-11 14:42                   ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: YAMAMOTO Mitsuharu @ 2006-03-11 13:17 UTC (permalink / raw)
  Cc: gritsch, emacs-devel, storm

>>>>> On Sat, 11 Mar 2006 14:09:22 +0200, Eli Zaretskii <eliz@gnu.org> said:

> Yes, and then all the callers of mac_draw_rectangle except
> x_draw_hollow_cursor need to subtract 1 from width and height.
> Funny.

> I modified mac_draw_rectangle to not add 1 to these two dimensions,
> and then removed the decrements from its callers.

Hmm, I'd rather prefer to keep the arguments compatible with the X11
version so as to make synchronization easy.

>> By the way, Quartz 2D (as opposed to QuickDraw above) needs another
>> kind of adjustment to get the same result:
>> 
>> CGContextStrokeRect (context, CGRectMake (x + 0.5f, y + 0.5f, width, height));

> I cannot find this code in Emacs.

Not installed yet.  I was planning to make the change like this:

  /* Mac replacement for XDrawRectangle: dest is a window.  */
  
  static void
  mac_draw_rectangle (f, gc, x, y, width, height)
       struct frame *f;
       GC gc;
       int x, y;
       unsigned int width, height;
  {
  #if USE_CG_DRAWING
    CGContextRef context;

    context = mac_begin_cg_clip (f, gc);
    CG_SET_STROKE_COLOR (context, gc->xgcv.foreground);
    CGContextStrokeRect (context,
			 CGRectMake (x + 0.5f, y + 0.5f, width, height));
    mac_end_cg_clip (f);
  #else
    Rect r;

    SetPortWindowPort (FRAME_MAC_WINDOW (f));

    RGBForeColor (GC_FORE_COLOR (gc));
    SetRect (&r, x, y, x + width + 1, y + height + 1);

    mac_begin_clip (gc);
    FrameRect (&r); /* using foreground color of gc */
    mac_end_clip (gc);
  #endif
  }

So, if the callers does not subtract 1 from width and height, then the
callee need to do so when USE_CG_DRAWING == 1.  That's another reason
why I'd prefer to keep the meaning of the arguments.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Cursor in non-selected windows is 1 pixel too small
  2006-03-11 13:17                 ` YAMAMOTO Mitsuharu
@ 2006-03-11 14:42                   ` Eli Zaretskii
  0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2006-03-11 14:42 UTC (permalink / raw)
  Cc: gritsch, emacs-devel, storm

> Date: Sat, 11 Mar 2006 22:17:17 +0900 (JST)
> Cc: storm@cua.dk, gritsch@iue.tuwien.ac.at, emacs-devel@gnu.org
> From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
> 
> >>>>> On Sat, 11 Mar 2006 14:09:22 +0200, Eli Zaretskii <eliz@gnu.org> said:
> 
> > Yes, and then all the callers of mac_draw_rectangle except
> > x_draw_hollow_cursor need to subtract 1 from width and height.
> > Funny.
> 
> > I modified mac_draw_rectangle to not add 1 to these two dimensions,
> > and then removed the decrements from its callers.
> 
> Hmm, I'd rather prefer to keep the arguments compatible with the X11
> version so as to make synchronization easy.

Feel free to make a different change, then.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2006-03-11 14:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-03 10:16 Cursor in non-selected windows is 1 pixel too small Markus Gritsch
2006-03-04  9:54 ` Eli Zaretskii
2006-03-04 10:04   ` Markus Gritsch
2006-03-04 10:18     ` Eli Zaretskii
2006-03-04 10:33       ` Markus Gritsch
2006-03-04 11:01         ` Markus Gritsch
2006-03-04 14:16         ` Eli Zaretskii
2006-03-04 14:29           ` Markus Gritsch
2006-03-04 14:51             ` Eli Zaretskii
2006-03-04 22:19           ` Kim F. Storm
2006-03-05  9:14             ` YAMAMOTO Mitsuharu
2006-03-05 19:50               ` Eli Zaretskii
2006-03-06  1:48                 ` YAMAMOTO Mitsuharu
2006-03-06 10:54                 ` Kim F. Storm
2006-03-11 12:09               ` Eli Zaretskii
2006-03-11 13:17                 ` YAMAMOTO Mitsuharu
2006-03-11 14:42                   ` Eli Zaretskii
2006-03-11 12:06             ` Eli Zaretskii

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).