unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Same frame-positioning bug as before: negative top/left values on Windows
       [not found] <MEEKKIABFKKDFJMPIOEBKEHDDDAA.drew.adams@oracle.com>
@ 2006-07-18 13:09 ` Fran Litterio
  2006-07-18 13:32   ` Drew Adams
       [not found]   ` <m3vepvkq2g.fsf@kfs-l.imdomain.dk>
  0 siblings, 2 replies; 5+ messages in thread
From: Fran Litterio @ 2006-07-18 13:09 UTC (permalink / raw)


Drew,

You are seeing this bug because my patch to fix frame positioning with
negative X/Y values on Windows has not been applied. Now that the FSF
has my copyright assignment papers, they should be able to apply my
patch (below).
--
Fran Litterio

On 7/18/06, Drew Adams <drew.adams@oracle.com> wrote:
> This is an old bug. I thought this was going to be fixed by Fran's bug
> fix, but I see that it is not. See my bug report of May 3, 2005, below.
>
> emacs -q
>
> In scratch buffer evaluate: (make-frame '((top . -1) (left . -1)))
>
> The new frame does not have its bottom at the display bottom. The
> frame bottom is below the frame bottom.
>
> I've been waiting for this fix for a year and a half. I use a
> standalone minibuffer frame, and I have code that positions it at the
> display bottom, no matter the size of the display. The code works
> perfectly in Emacs 20, but this bug causes the frame to be too low on
> the display in Emacs 22(and since the frame is only two rows high,
> it is essentially off the bottom of the display).
>
> Can someone please fix this bug? Emacs should be able to correctly handle
> negative `top' frame parameter values.
>
> Thanks.


--- w32term.c	5 Jun 2006 21:20:59 -0000	1.246
+++ w32term.c	18 Jul 2006 13:03:33 -0000
@@ -5312,17 +5312,58 @@
 {
   int flags = f->size_hint_flags;

-  /* Treat negative positions as relative to the leftmost bottommost
+  /* left_right_borders_width holds the sum of the widths of the frame's left
+     and right borders (in pixels) drawn by Windows. */
+
+  unsigned int left_right_borders_width = 8;   /* A sensible default value. */
+
+  /* top_bottom_borders_height holds the sum of the heights of the
frame's top and
+     bottom borders (in pixels) drawn by Windows. */
+
+  unsigned int top_bottom_borders_height = 32;  /* A sensible default value. */
+
+  /* Now obtain the actual values of the above two variables.  If we fail to
+     obtain the actual values, we will use the defaults assigned
above.  We compute
+     the border width (height) by subtracting the width (height) of the frame's
+     client area from the width (height) of the frame's entire window.
+  */
+
+  WINDOWPLACEMENT wp = { 0 };
+
+  BOOL status = GetWindowPlacement (FRAME_W32_WINDOW (f), &wp);
+
+  if (status != FALSE)
+  {
+      RECT client_rect = { 0 };
+
+      status = GetClientRect (FRAME_W32_WINDOW (f), &client_rect);
+
+      if (status != FALSE)
+      {
+	  left_right_borders_width =
+	      (wp.rcNormalPosition.right - wp.rcNormalPosition.left) -
+	      (client_rect.right - client_rect.left);
+
+	  top_bottom_borders_height =
+	      (wp.rcNormalPosition.bottom - wp.rcNormalPosition.top) -
+	      (client_rect.bottom - client_rect.top);
+      }
+  }
+
+  /* Treat negative positions as relative to the rightmost bottommost
      position that fits on the screen.  */
   if (flags & XNegative)
     f->left_pos = (FRAME_W32_DISPLAY_INFO (f)->width
 		   - FRAME_PIXEL_WIDTH (f)
-		   + f->left_pos);
+		   + f->left_pos
+		   - (left_right_borders_width - 1));

   if (flags & YNegative)
     f->top_pos = (FRAME_W32_DISPLAY_INFO (f)->height
 		  - FRAME_PIXEL_HEIGHT (f)
-		  + f->top_pos);
+		  + f->top_pos
+                  - (top_bottom_borders_height - 1));
+
   /* The left_pos and top_pos
      are now relative to the top and left screen edges,
      so the flags should correspond.  */

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

* RE: Same frame-positioning bug as before: negative top/left values on Windows
  2006-07-18 13:09 ` Same frame-positioning bug as before: negative top/left values on Windows Fran Litterio
@ 2006-07-18 13:32   ` Drew Adams
       [not found]   ` <m3vepvkq2g.fsf@kfs-l.imdomain.dk>
  1 sibling, 0 replies; 5+ messages in thread
From: Drew Adams @ 2006-07-18 13:32 UTC (permalink / raw)


    You are seeing this bug because my patch to fix frame positioning with
    negative X/Y values on Windows has not been applied. Now that the FSF
    has my copyright assignment papers, they should be able to apply my
    patch (below).

Thanks Fran. Good to hear. I thought it had already been applied.  - Drew

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

* Re: Same frame-positioning bug as before: negative top/left values on Windows
       [not found]   ` <m3vepvkq2g.fsf@kfs-l.imdomain.dk>
@ 2006-07-18 16:14     ` Fran Litterio
  2006-07-18 23:05       ` Kim F. Storm
  0 siblings, 1 reply; 5+ messages in thread
From: Fran Litterio @ 2006-07-18 16:14 UTC (permalink / raw)
  Cc: Drew Adams

> > You are seeing this bug because my patch to fix frame positioning with
> > negative X/Y values on Windows has not been applied. Now that the FSF
> > has my copyright assignment papers, they should be able to apply my
> > patch (below).
>
> I will install it if you send me a ChangeLog entry for it.

Kim,

Thanks.  Here's the full patch, including the src/Changelog patch.
Let me know if you need anything else.  This patch fixes the problem
where

    (set-frame-position (selected-frame) -1 -1)

fails to position the selected frame exactly in the lower right corner
of the display.
--
Fran Litterio


Index: src/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/src/ChangeLog,v
retrieving revision 1.5194
diff -w -u -r1.5194 ChangeLog
--- src/ChangeLog	18 Jul 2006 13:25:28 -0000	1.5194
+++ src/ChangeLog	18 Jul 2006 16:11:19 -0000
@@ -1,3 +1,8 @@
+2006-07-18  Francis Litterio  <franl@world.std.com>
+
+	* w32term.c (x_calc_absolute_position): Fix frame positioning on
+	Windows with negative X/Y coordinates.
+
 2006-07-18  Kim F. Storm  <storm@cua.dk>

 	Cleanup Fsignal calls that never returns; now only use it for Qquit.
Index: src/w32term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
retrieving revision 1.247
diff -w -u -r1.247 w32term.c
--- src/w32term.c	30 Jun 2006 13:41:15 -0000	1.247
+++ src/w32term.c	18 Jul 2006 16:11:28 -0000
@@ -5312,17 +5312,58 @@
 {
   int flags = f->size_hint_flags;

-  /* Treat negative positions as relative to the leftmost bottommost
+  /* left_right_borders_width holds the sum of the widths of the frame's left
+     and right borders (in pixels) drawn by Windows. */
+
+  unsigned int left_right_borders_width = 8;   /* A sensible default value. */
+
+  /* top_bottom_borders_height holds the sum of the heights of the
frame's top and
+     bottom borders (in pixels) drawn by Windows. */
+
+  unsigned int top_bottom_borders_height = 32;  /* A sensible default value. */
+
+  /* Now obtain the actual values of the above two variables.  If we fail to
+     obtain the actual values, we will use the defaults assigned
above.  We compute
+     the border width (height) by subtracting the width (height) of the frame's
+     client area from the width (height) of the frame's entire window.
+  */
+
+  WINDOWPLACEMENT wp = { 0 };
+
+  BOOL status = GetWindowPlacement (FRAME_W32_WINDOW (f), &wp);
+
+  if (status != FALSE)
+  {
+      RECT client_rect = { 0 };
+
+      status = GetClientRect (FRAME_W32_WINDOW (f), &client_rect);
+
+      if (status != FALSE)
+      {
+	  left_right_borders_width =
+	      (wp.rcNormalPosition.right - wp.rcNormalPosition.left) -
+	      (client_rect.right - client_rect.left);
+
+	  top_bottom_borders_height =
+	      (wp.rcNormalPosition.bottom - wp.rcNormalPosition.top) -
+	      (client_rect.bottom - client_rect.top);
+      }
+  }
+
+  /* Treat negative positions as relative to the rightmost bottommost
      position that fits on the screen.  */
   if (flags & XNegative)
     f->left_pos = (FRAME_W32_DISPLAY_INFO (f)->width
 		   - FRAME_PIXEL_WIDTH (f)
-		   + f->left_pos);
+		   + f->left_pos
+		   - (left_right_borders_width - 1));

   if (flags & YNegative)
     f->top_pos = (FRAME_W32_DISPLAY_INFO (f)->height
 		  - FRAME_PIXEL_HEIGHT (f)
-		  + f->top_pos);
+		  + f->top_pos
+                  - (top_bottom_borders_height - 1));
+
   /* The left_pos and top_pos
      are now relative to the top and left screen edges,
      so the flags should correspond.  */

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

* Re: Same frame-positioning bug as before: negative top/left values on Windows
  2006-07-18 16:14     ` Fran Litterio
@ 2006-07-18 23:05       ` Kim F. Storm
  2006-07-19 14:23         ` Fran Litterio
  0 siblings, 1 reply; 5+ messages in thread
From: Kim F. Storm @ 2006-07-18 23:05 UTC (permalink / raw)
  Cc: Drew Adams, emacs-devel

"Fran Litterio" <flitterio@gmail.com> writes:

> Thanks.  Here's the full patch, including the src/Changelog patch.
> Let me know if you need anything else.

I have installed the patch -- in a slightly edited version, as the
original patch didn't install cleanly (it seems your mailer has
messed up whitespace and line wrapping.)

Pls. verify that it still works.

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

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

* Re: Same frame-positioning bug as before: negative top/left values on Windows
  2006-07-18 23:05       ` Kim F. Storm
@ 2006-07-19 14:23         ` Fran Litterio
  0 siblings, 0 replies; 5+ messages in thread
From: Fran Litterio @ 2006-07-19 14:23 UTC (permalink / raw)
  Cc: Drew Adams, emacs-devel

Kim,

Yes, it still works.  Thanks for installing this patch.
--
Fran Litterio


On 7/18/06, Kim F. Storm <storm@cua.dk> wrote:
> "Fran Litterio" <flitterio@gmail.com> writes:
>
> > Thanks.  Here's the full patch, including the src/Changelog patch.
> > Let me know if you need anything else.
>
> I have installed the patch -- in a slightly edited version, as the
> original patch didn't install cleanly (it seems your mailer has
> messed up whitespace and line wrapping.)
>
> Pls. verify that it still works.
>
> --
> Kim F. Storm <storm@cua.dk> http://www.cua.dk
>
>

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

end of thread, other threads:[~2006-07-19 14:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <MEEKKIABFKKDFJMPIOEBKEHDDDAA.drew.adams@oracle.com>
2006-07-18 13:09 ` Same frame-positioning bug as before: negative top/left values on Windows Fran Litterio
2006-07-18 13:32   ` Drew Adams
     [not found]   ` <m3vepvkq2g.fsf@kfs-l.imdomain.dk>
2006-07-18 16:14     ` Fran Litterio
2006-07-18 23:05       ` Kim F. Storm
2006-07-19 14:23         ` Fran Litterio

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