diff os2/dw.c @ 39:3aa9ef0b3996

Added focus fixes and set-focus fixes on all three platforms.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 19 Oct 2001 14:16:50 +0000
parents 538db2a48bac
children 88c9c7410c22
line wrap: on
line diff
--- a/os2/dw.c	Wed Oct 17 19:22:39 2001 +0000
+++ b/os2/dw.c	Fri Oct 19 14:16:50 2001 +0000
@@ -1255,6 +1255,14 @@
 			return FALSE;
 		}
 		break;
+	case WM_BUTTON1DOWN:
+	case WM_BUTTON2DOWN:
+	case WM_BUTTON3DOWN:
+		_run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE);
+		break;
+	case WM_SETFOCUS:
+		_run_event(hWnd, msg, mp1, mp2);
+		break;
 	case WM_PAINT:
 		{
 			HWND parent = WinQueryWindow(hWnd, QW_PARENT);
@@ -1568,8 +1576,9 @@
 							int (*listboxselectfunc)(HWND, int, void *) = (int (*)(HWND, int, void *))tmp->signalfunction;
 							int id = SHORT1FROMMP(mp1);
 							HWND conthwnd = dw_window_from_id(hWnd, id);
-
-							if(tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2))
+							static int _recursing = 0;
+
+							if(_recursing == 0 && (tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2)))
 							{
 								char buf1[500], classbuf[100];
 								unsigned int index = dw_listbox_selected(tmp->window);
@@ -1578,6 +1587,8 @@
 
 								WinQueryClassName(tmp->window, 99, classbuf);
 
+								_recursing = 1;
+
 								if(id && strncmp(classbuf, "#2", 3)==0)
 								{
 									char *buf2;
@@ -1596,6 +1607,7 @@
 								else
 									result = listboxselectfunc(tmp->window, index, tmp->data);
 
+								_recursing = 0;
 								tmp = NULL;
 							}
 						}
@@ -1734,7 +1746,11 @@
 				mybox->flags = DW_MINIMIZED;
 
 			if(mybox && (swp->fl & SWP_RESTORE))
+			{
+				if(!mybox->titlebar && mybox->hwndtitle)
+					WinSetParent(mybox->hwndtitle, HWND_OBJECT, FALSE);
 				mybox->flags = 0;
+			}
 
 			if(mybox && (swp->fl & SWP_MAXIMIZE))
 			{
@@ -2184,7 +2200,10 @@
 	{
 #ifndef NO_SIGNALS
 	case WM_SETFOCUS:
-		_wndproc(hwnd, msg, mp1, mp2);
+		if(mp2)
+			_run_event(hwnd, msg, mp1, mp2);
+		else
+			WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0);
 		break;
 	case WM_BUTTON1UP:
 		{
@@ -2260,6 +2279,7 @@
 			if(SHORT1FROMMP(mp2) == '\t')
 			{
 				_shift_focus(hwnd);
+				WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0);
 				return FALSE;
 			}
 		}
@@ -2615,6 +2635,19 @@
  */
 int dw_window_minimize(HWND handle)
 {
+	HWND hwndclient = WinWindowFromID(handle, FID_CLIENT);
+
+	if(hwndclient)
+	{
+		Box *box = (Box *)WinQueryWindowPtr(hwndclient, QWP_USER);
+
+		if(box)
+		{
+			if(!box->titlebar && box->hwndtitle)
+				WinSetParent(box->hwndtitle, handle, FALSE);
+		}
+	}
+
 	return WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE);
 }
 
@@ -2796,7 +2829,15 @@
 
 	flStyle |= FCF_NOBYTEALIGN;
 
+	if(flStyle & DW_FCF_TITLEBAR)
+		newbox->titlebar = 1;
+	else
+		flStyle |= FCF_TITLEBAR;
+
 	hwndframe = WinCreateStdWindow(hwndOwner, 0L, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &hwndclient);
+	newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR);
+	if(!newbox->titlebar && newbox->hwndtitle)
+		WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE);
 	*blah = WinSubclassWindow(hwndframe, _sizeproc);
 	WinSetWindowPtr(hwndframe, QWP_USER, blah);
 	WinSetWindowPtr(hwndclient, QWP_USER, newbox);