Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs16:/tmp/cvs-serv9569/src
Modified Files:
local.c mswindow.c
Log Message:
More esoteric windows nonsense for dealing with caption and sizing
borders to get exact screen coordinates of the local/map window after
it's finished resizing. Would need to use similar sort of checks to implement
saving the main window size and position between sessions.
Index: mswindow.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/mswindow.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- mswindow.c 11 Apr 2007 01:10:05 -0000 1.66
+++ mswindow.c 11 Apr 2007 08:03:08 -0000 1.67
@@ -1953,6 +1953,7 @@
//Disable possibility to move internal windows
{ // have to add bracket to be able to declare variables
int width, height;
+ RECT baseRect; // baseWin rectangle
RECT winRect; // current window rectangle
GET_STRUCT_PTR;
@@ -1966,6 +1967,7 @@
if (windowMove && (Window *) w != NULL && win->hwnd == ((Window *) w)->hwnd)
{
GetWindowRect (((Window *) w)->hwnd, &winRect);
+ GetWindowRect (((Window *) baseWin)->hwnd, &baseRect);
// Have to reinitialize SDB
SelectObject (localSDB->mem_dc, localSDB->old_bmp);
@@ -1986,11 +1988,32 @@
height = width;
TWINSIDE = width - 2 * win->border;
- /* In case of WS_CAPTION (titlebar on) we have to subtract caption size */
- if (GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION)
- winRect.top -= GetSystemMetrics (SM_CYCAPTION);
+ /* Have to take into account basewin border */
+ winRect.left -= baseRect.left;
+ winRect.top -= baseRect.top;
+
+ /* In case of WS_CAPTION (titlebar on) we have to subtract caption size and
+ additional borders to get screen coordinates.
+ If the main window is also resizeable then border sizes change from SM_CnFIXEDFRAME
+ to SM_CnSIZEFRAME
+ */
+ if (GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION && !mainResizeable)
+ {
+ winRect.left -= GetSystemMetrics (SM_CXFIXEDFRAME);
+ winRect.top -= (GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION));
+ }
+ else if (GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION && mainResizeable)
+ {
+ winRect.left -= GetSystemMetrics (SM_CXSIZEFRAME);
+ winRect.top -= (GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION));
+ }
+ else if (!(GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION) && mainResizeable)
+ {
+ winRect.left -= GetSystemMetrics (SM_CXSIZEFRAME) - 1;
+ winRect.top -= GetSystemMetrics (SM_CYSIZEFRAME) - 1;
+ }
- MoveWindow (((Window *) w)->hwnd, winRect.left - win->border, winRect.top - win->border,
+ MoveWindow (((Window *) w)->hwnd, winRect.left, winRect.top,
width, height, TRUE);
// All windows based on TWINSIDE are out of position now, but the team
@@ -2013,6 +2036,7 @@
else if (windowMove && (Window *) mapw != NULL && win->hwnd == ((Window *) mapw)->hwnd)
{
GetWindowRect (((Window *) mapw)->hwnd, &winRect);
+ GetWindowRect (((Window *) baseWin)->hwnd, &baseRect);
// Have to reinitialize SDB
SelectObject (mapSDB->mem_dc, mapSDB->old_bmp);
@@ -2030,12 +2054,33 @@
else
height = width;
GWINSIDE = width - 2 * win->border;
-
- /* In case of WS_CAPTION (titlebar on) we have to subtract caption size */
- if (GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION)
- winRect.top -= GetSystemMetrics (SM_CYCAPTION);
- MoveWindow (((Window *) mapw)->hwnd, winRect.left - win->border, winRect.top - win->border,
+ /* Have to take into account basewin border */
+ winRect.left -= baseRect.left;
+ winRect.top -= baseRect.top;
+
+ /* In case of WS_CAPTION (titlebar on) we have to subtract caption size and
+ additional borders to get screen coordinates.
+ If the main window is also resizeable then border sizes change from SM_CnFIXEDFRAME
+ to SM_CnSIZEFRAME
+ */
+ if (GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION && !mainResizeable)
+ {
+ winRect.left -= GetSystemMetrics (SM_CXFIXEDFRAME);
+ winRect.top -= (GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION));
+ }
+ else if (GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION && mainResizeable)
+ {
+ winRect.left -= GetSystemMetrics (SM_CXSIZEFRAME);
+ winRect.top -= (GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION));
+ }
+ else if (!(GetWindowLongPtr (((Window *) baseWin)->hwnd, GWL_STYLE) & WS_CAPTION) && mainResizeable)
+ {
+ winRect.left -= GetSystemMetrics (SM_CXSIZEFRAME) - 1;
+ winRect.top -= GetSystemMetrics (SM_CYSIZEFRAME) - 1;
+ }
+
+ MoveWindow (((Window *) mapw)->hwnd, winRect.left, winRect.top,
width, height, TRUE);
redrawall = 1;
Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- local.c 11 Apr 2007 01:10:04 -0000 1.93
+++ local.c 11 Apr 2007 08:03:08 -0000 1.94
@@ -735,8 +735,7 @@
/* Twarp sounds put up here so observers can hear them */
#ifdef SOUND
/* Have to use me->p_flags because server doesn't send us twarp flag info
- on other players. Current Vanilla does not let observer change players
- if the player they are observing is transwarping. */
+ on other players. */
if (twarpflag != (me->p_flags & PFTWARP))
{
/* change in warp state */