changeset 1495:3b4dc98d753b

Initial gravity obstacles support for OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 25 Dec 2011 04:45:59 +0000
parents cf960e266444
children 8b84b752a363
files os2/dw.c
diffstat 1 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Sun Dec 25 03:55:24 2011 +0000
+++ b/os2/dw.c	Sun Dec 25 04:45:59 2011 +0000
@@ -62,6 +62,7 @@
 int _load_bitmap_file(char *file, HWND handle, HBITMAP *hbm, HDC *hdc, HPS *hps, unsigned long *width, unsigned long *height);
 void _free_menu_data(HWND menu);
 ULONG (API_FUNC _PmPrintfString)(char *String) = 0;
+BOOL (API_FUNC _WinQueryDesktopWorkArea)(HWND hwndDesktop, PWRECT pwrcWorkArea) = 0;
 
 char ClassName[] = "dynamicwindows";
 char SplitbarClassName[] = "dwsplitbar";
@@ -79,7 +80,7 @@
 PRECORDCORE pCoreEmph = NULL;
 ULONG aulBuffer[4];
 HWND lasthcnr = 0, lastitem = 0, popup = 0, desktop;
-HMOD wpconfig = 0, pmprintf = 0;
+HMOD wpconfig = 0, pmprintf = 0, pmmerge = 0;
 static char _dw_exec_dir[MAX_PATH+1] = {0};
 
 unsigned long _colors[] = {
@@ -3998,6 +3999,8 @@
    DosLoadModule((PSZ)objnamebuf, sizeof(objnamebuf), (PSZ)"WPCONFIG", &wpconfig);
    if(!DosLoadModule((PSZ)objnamebuf, sizeof(objnamebuf), (PSZ)"PMPRINTF", &pmprintf))
        DosQueryProcAddr(pmprintf, 0, (PSZ)"PmPrintfString", (PFN*)&_PmPrintfString);
+   if(!DosLoadModule((PSZ)objnamebuf, sizeof(objnamebuf), (PSZ)"PMMERGE", &pmmerge))
+       DosQueryProcAddr(pmmerge, 5469, NULL, (PFN*)&_WinQueryDesktopWorkArea);
    return rc;
 }
 
@@ -4286,7 +4289,7 @@
              /* If the MDI parent isn't visible...
               * we can't calculate. Drop out.
               */
-             if(cx < 1 | cy < 1)
+             if(cx < 1 || cy < 1)
              {
                  WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_MOVE);
                  return rc;
@@ -7047,6 +7050,28 @@
       *x = newx;
       *y = newy;
    }            
+   /* Adjust the values to avoid WarpCenter/XCenter/eCenter if requested */
+   if(_WinQueryDesktopWorkArea && (horz | vert) & DW_GRAV_OBSTACLES)
+   {
+       RECTL rect;
+
+       _WinQueryDesktopWorkArea(HWND_DESKTOP, &rect);
+
+       if(horz & DW_GRAV_OBSTACLES)
+       {
+           if((horz & 0xf) == DW_GRAV_LEFT)
+               *x += rect.xLeft;
+           else if((horz & 0xf) == DW_GRAV_RIGHT)
+               *x -= dw_screen_width() - rect.xRight;
+       }
+       if(vert & DW_GRAV_OBSTACLES)
+       {
+           if((vert & 0xf) == DW_GRAV_BOTTOM)
+               *y += rect.yBottom;
+           else if((vert & 0xf) == DW_GRAV_TOP)
+               *y -= dw_screen_height() - rect.yTop;
+       }
+    }
 }
 
 /*