From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Francis Litterio Newsgroups: gmane.emacs.devel,gmane.emacs.windows Subject: Patch to fix frame positioning with negative top/left values on Windows Date: Thu, 07 Jul 2005 12:23:36 -0400 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1120754048 25835 80.91.229.2 (7 Jul 2005 16:34:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 7 Jul 2005 16:34:08 +0000 (UTC) Cc: help-emacs-windows@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 07 18:34:06 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DqZJM-0003wV-By for ged-emacs-devel@m.gmane.org; Thu, 07 Jul 2005 18:33:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DqZKJ-0006ox-TH for ged-emacs-devel@m.gmane.org; Thu, 07 Jul 2005 12:34:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DqZJh-0006kF-Cs for emacs-devel@gnu.org; Thu, 07 Jul 2005 12:33:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DqZJZ-0006eY-KG for emacs-devel@gnu.org; Thu, 07 Jul 2005 12:33:32 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DqZJZ-0006eT-EO for emacs-devel@gnu.org; Thu, 07 Jul 2005 12:33:29 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DqZOU-0003A2-G0 for emacs-devel@gnu.org; Thu, 07 Jul 2005 12:38:34 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DqZHa-0003cQ-Js for emacs-devel@gnu.org; Thu, 07 Jul 2005 18:31:26 +0200 Original-Received: from brick.estc.com ([209.27.151.2]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Jul 2005 18:31:26 +0200 Original-Received: from franl by brick.estc.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Jul 2005 18:31:26 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Followup-To: gmane.emacs.devel Original-Lines: 82 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: brick.estc.com X-Draft-From: ("nntp+news.gmane.org:gmane.emacs.devel" "") Gcc: nnfolder:sent-usenet X-Random-Quote: Pale Death with impartial tread beats at the poor man's cottage door and at the palaces of kings. -- Horace (65 BC - 8 BC), Odes User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt) Cancel-Lock: sha1:eBLRguJsR7Oinx4ZuX2FdCgoesc= 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:40566 gmane.emacs.windows:2763 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:40566 Emacs developers, This patch to the CVS Emacs sources fixes the way that function x_calc_absolute_position() accounts for the Windows-drawn borders around a frame when converting a negative 'top or 'left parameter into the equivalent positive value. I have submitted this patch before, but RMS told me that the FSF needed a copyright assignment from me before it could applied. The FSF now has mysigned the copyright assignment, so please let me know if there's any problem with this patch. I've been running Emacs with it for some months with no problems. -- Francis Litterio franl world . std . com diff -w -u -u -w -r1.228 w32term.c --- w32term.c 4 Jul 2005 16:06:37 -0000 1.228 +++ w32term.c 7 Jul 2005 16:19:39 -0000 @@ -5438,17 +5438,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. */