comparison os2/dw.c @ 1483:73f2ad84d4ec

Fixed OS/2 windows being shown when setting position/size. Moved the OS/2 specific DW_OS2_NEW_WINDOW flag into os2/dw.c. Deprecated and essentially removed DW_FCF_SHELLPOSITION and DW_FCF_NOBYTEALIGN. These were OS/2 specific and are set automatically now... FCF_SHELLPOSITION was causing the positioning problems that necessitated the window being shown to set the size and position. Right now SHELLPOSITION isn't used at all... causing shell positioning to not work. I hope to have a way to allow shell positioning to work again soon but the idea I had to do this did not work.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 23 Dec 2011 15:58:13 +0000
parents 4468ac1db710
children 6771fa426ba4
comparison
equal deleted inserted replaced
1482:dd584f431f9f 1483:73f2ad84d4ec
98 CLR_BLUE, 98 CLR_BLUE,
99 CLR_PINK, 99 CLR_PINK,
100 CLR_CYAN, 100 CLR_CYAN,
101 CLR_WHITE 101 CLR_WHITE
102 }; 102 };
103
104 #define DW_OS2_NEW_WINDOW 1
103 105
104 #define IS_WARP4() (aulBuffer[0] == 20 && aulBuffer[1] >= 40) 106 #define IS_WARP4() (aulBuffer[0] == 20 && aulBuffer[1] >= 40)
105 107
106 #ifndef min 108 #ifndef min
107 #define min(a, b) (((a < b) ? a : b)) 109 #define min(a, b) (((a < b) ? a : b))
4243 * Parameters: 4245 * Parameters:
4244 * handle: The window handle to make visible. 4246 * handle: The window handle to make visible.
4245 */ 4247 */
4246 int API dw_window_show(HWND handle) 4248 int API dw_window_show(HWND handle)
4247 { 4249 {
4248 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW); 4250 int rc = WinShowWindow(handle, TRUE);
4249 HSWITCH hswitch; 4251 HSWITCH hswitch;
4250 SWCNTRL swcntrl; 4252 SWCNTRL swcntrl;
4251 4253
4252 _fix_button_owner(_toplevel_window(handle), 0); 4254 _fix_button_owner(_toplevel_window(handle), 0);
4253 WinSetFocus(HWND_DESKTOP, handle); 4255 WinSetFocus(HWND_DESKTOP, handle);
4265 { 4267 {
4266 WindowData *blah = WinQueryWindowPtr(handle, QWP_USER); 4268 WindowData *blah = WinQueryWindowPtr(handle, QWP_USER);
4267 4269
4268 if(blah && !(blah->flags & DW_OS2_NEW_WINDOW)) 4270 if(blah && !(blah->flags & DW_OS2_NEW_WINDOW))
4269 { 4271 {
4272 /* Make sure windows shown for the first time are
4273 * completely visible if possible.
4274 */
4270 ULONG cx = dw_screen_width(), cy = dw_screen_height(); 4275 ULONG cx = dw_screen_width(), cy = dw_screen_height();
4271 int newx, newy, changed = 0; 4276 int newx, newy, changed = 0;
4272 SWP swp; 4277 SWP swp;
4273 4278
4274 blah->flags |= DW_OS2_NEW_WINDOW; 4279 blah->flags |= DW_OS2_NEW_WINDOW;
4276 WinQueryWindowPos(handle, &swp); 4281 WinQueryWindowPos(handle, &swp);
4277 4282
4278 newx = swp.x; 4283 newx = swp.x;
4279 newy = swp.y; 4284 newy = swp.y;
4280 4285
4281 if((swp.x+swp.cx) > cx) 4286 if(swp.cx < cx && (swp.x+swp.cx) > cx)
4282 { 4287 {
4283 newx = (cx - swp.cx)/2; 4288 newx = (cx - swp.cx)/2;
4284 changed = 1; 4289 changed = 1;
4285 } 4290 }
4286 if((swp.y+swp.cy) > cy) 4291 if(swp.cy < cy && (swp.y+swp.cy) > cy)
4287 { 4292 {
4288 newy = (cy - swp.cy)/2; 4293 newy = (cy - swp.cy)/2;
4289 changed = 1; 4294 changed = 1;
4290 } 4295 }
4291 if(changed) 4296 if(changed)
4920 if(flStyle & DW_FCF_TITLEBAR) 4925 if(flStyle & DW_FCF_TITLEBAR)
4921 newbox->titlebar = 1; 4926 newbox->titlebar = 1;
4922 else 4927 else
4923 flStyle |= FCF_TITLEBAR; 4928 flStyle |= FCF_TITLEBAR;
4924 4929
4925 if(!(flStyle & FCF_SHELLPOSITION))
4926 blah->flags |= DW_OS2_NEW_WINDOW;
4927
4928 if(flStyle & WS_MAXIMIZED) 4930 if(flStyle & WS_MAXIMIZED)
4929 { 4931 {
4930 winStyle |= WS_MAXIMIZED; 4932 winStyle |= WS_MAXIMIZED;
4931 flStyle &= ~WS_MAXIMIZED; 4933 flStyle &= ~WS_MAXIMIZED;
4932 } 4934 }
4934 { 4936 {
4935 winStyle |= WS_MINIMIZED; 4937 winStyle |= WS_MINIMIZED;
4936 flStyle &= ~WS_MINIMIZED; 4938 flStyle &= ~WS_MINIMIZED;
4937 } 4939 }
4938 4940
4941 /* Then create the real window window without FCF_SHELLPOSITION */
4942 flStyle &= ~FCF_SHELLPOSITION;
4939 hwndframe = WinCreateStdWindow(hwndOwner, winStyle, &flStyle, (PSZ)ClassName, (PSZ)title, 0L, NULLHANDLE, 0L, &newbox->hwnd); 4943 hwndframe = WinCreateStdWindow(hwndOwner, winStyle, &flStyle, (PSZ)ClassName, (PSZ)title, 0L, NULLHANDLE, 0L, &newbox->hwnd);
4940 newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR); 4944 newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR);
4941 if(!newbox->titlebar && newbox->hwndtitle) 4945 if(!newbox->titlebar && newbox->hwndtitle)
4942 WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE); 4946 WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE);
4943 blah->oldproc = WinSubclassWindow(hwndframe, _sizeproc); 4947 blah->oldproc = WinSubclassWindow(hwndframe, _sizeproc);
4944 WinSetWindowPtr(hwndframe, QWP_USER, blah); 4948 WinSetWindowPtr(hwndframe, QWP_USER, blah);
4945 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox); 4949 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox);
4946
4947 return hwndframe; 4950 return hwndframe;
4948 } 4951 }
4949 4952
4950 /* 4953 /*
4951 * Create a new Box to be packed. 4954 * Create a new Box to be packed.
6905 /* Attempt to auto-size */ 6908 /* Attempt to auto-size */
6906 if ( width < 1 || height < 1 ) 6909 if ( width < 1 || height < 1 )
6907 _get_window_for_size(handle, &width, &height); 6910 _get_window_for_size(handle, &width, &height);
6908 6911
6909 /* Finally set the size */ 6912 /* Finally set the size */
6910 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE); 6913 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SIZE);
6911 } 6914 }
6912 6915
6913 /* 6916 /*
6914 * Gets the size the system thinks the widget should be. 6917 * Gets the size the system thinks the widget should be.
6915 * Parameters: 6918 * Parameters:
7023 if ( width < 1 || height < 1 ) 7026 if ( width < 1 || height < 1 )
7024 _get_window_for_size(handle, &width, &height); 7027 _get_window_for_size(handle, &width, &height);
7025 7028
7026 _handle_gravity(handle, &x, &y, width, height); 7029 _handle_gravity(handle, &x, &y, width, height);
7027 /* Finally set the size */ 7030 /* Finally set the size */
7028 WinSetWindowPos(handle, NULLHANDLE, x, y, width, height, SWP_SHOW | SWP_MOVE | SWP_SIZE); 7031 WinSetWindowPos(handle, NULLHANDLE, x, y, width, height, SWP_MOVE | SWP_SIZE);
7029 } 7032 }
7030 7033
7031 /* 7034 /*
7032 * Gets the position and size of a given window (widget). 7035 * Gets the position and size of a given window (widget).
7033 * Parameters: 7036 * Parameters:
9061 { 9064 {
9062 HWND window, hbox, vbox, col, button, text; 9065 HWND window, hbox, vbox, col, button, text;
9063 DWDialog *dwwait; 9066 DWDialog *dwwait;
9064 HMTX mtx = dw_mutex_new(); 9067 HMTX mtx = dw_mutex_new();
9065 9068
9066 window = dw_window_new( HWND_DESKTOP, "Choose Color", FCF_SHELLPOSITION | FCF_TITLEBAR | FCF_DLGBORDER | FCF_CLOSEBUTTON | FCF_SYSMENU); 9069 window = dw_window_new( HWND_DESKTOP, "Choose Color", FCF_TITLEBAR | FCF_DLGBORDER | FCF_CLOSEBUTTON | FCF_SYSMENU);
9067 9070
9068 vbox = dw_box_new(DW_VERT, 5); 9071 vbox = dw_box_new(DW_VERT, 5);
9069 9072
9070 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0); 9073 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0);
9071 9074
10877 { 10880 {
10878 HWND window, hbox, vbox, tree, button; 10881 HWND window, hbox, vbox, tree, button;
10879 DWDialog *dwwait; 10882 DWDialog *dwwait;
10880 HMTX mtx = dw_mutex_new(); 10883 HMTX mtx = dw_mutex_new();
10881 10884
10882 window = dw_window_new( HWND_DESKTOP, title, FCF_SHELLPOSITION | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX); 10885 window = dw_window_new( HWND_DESKTOP, title, FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX);
10883 10886
10884 vbox = dw_box_new(DW_VERT, 5); 10887 vbox = dw_box_new(DW_VERT, 5);
10885 10888
10886 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0); 10889 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0);
10887 10890
11291 free(print); 11294 free(print);
11292 return NULL; 11295 return NULL;
11293 } 11296 }
11294 11297
11295 /* Create the print dialog */ 11298 /* Create the print dialog */
11296 window = dw_window_new(HWND_DESKTOP, "Choose Printer", FCF_SHELLPOSITION | FCF_TITLEBAR | FCF_DLGBORDER | FCF_CLOSEBUTTON | FCF_SYSMENU); 11299 window = dw_window_new(HWND_DESKTOP, "Choose Printer", FCF_TITLEBAR | FCF_DLGBORDER | FCF_CLOSEBUTTON | FCF_SYSMENU);
11297 11300
11298 vbox = dw_box_new(DW_VERT, 5); 11301 vbox = dw_box_new(DW_VERT, 5);
11299 11302
11300 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0); 11303 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0);
11301 11304