# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1317228716 0 # Node ID 452a5b1b2aa5e86354f561b127129331cb84843b # Parent 9b021f787ad1112c6e954cf515cb917c0f2e236f Fixed a longstanding issue on OS/2 of event handlers being triggered by events on the wrong window when more than one slider/percent control is in a box. Removed that from the known issues, although it was incorrectly attributed as a Windows bug instead of an OS/2 bug. Also createda GlobalID() function that will keep the global ID used by unspecified controls within the "short" range. diff -r 9b021f787ad1 -r 452a5b1b2aa5 os2/dw.c --- a/os2/dw.c Wed Sep 28 15:29:05 2011 +0000 +++ b/os2/dw.c Wed Sep 28 16:51:56 2011 +0000 @@ -58,7 +58,7 @@ HWND hwndApp = NULLHANDLE, hwndBubble = NULLHANDLE, hwndBubbleLast = NULLHANDLE, hwndEmph = NULLHANDLE; PRECORDCORE pCoreEmph = NULL; -ULONG aulBuffer[4], GlobalID = 10000; +ULONG aulBuffer[4]; HWND lasthcnr = 0, lastitem = 0, popup = 0, desktop; HMOD wpconfig = 0; @@ -129,6 +129,19 @@ { CN_EXPANDTREE, DW_SIGNAL_TREE_EXPAND } }; +/* Internal function to keep a semi-unique ID within valid range */ +USHORT _GlobalID(void) +{ + static USHORT GlobalID = 9999; + + GlobalID++; + if(GlobalID == 65535) + { + GlobalID = 10000; + } + return GlobalID; +} + /* This function adds a signal handler callback into the linked list. */ void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data) @@ -2465,6 +2478,9 @@ (tmp->message == SLN_SLIDERTRACK && SHORT2FROMMP(mp1) == SLN_CHANGE)) { int svar = SLN_SLIDERTRACK; + int id = SHORT1FROMMP(mp1); + HWND notifyhwnd = dw_window_from_id(hWnd, id); + if(origmsg == WM_CONTROL) svar = SHORT2FROMMP(mp1); @@ -2473,8 +2489,6 @@ case CN_ENTER: { int (* API containerselectfunc)(HWND, char *, void *) = (int (* API)(HWND, char *, void *))tmp->signalfunction; - int id = SHORT1FROMMP(mp1); - HWND conthwnd = dw_window_from_id(hWnd, id); char *text = NULL; if(mp2) @@ -2486,7 +2500,7 @@ text = pre->pszIcon; } - if(tmp->window == conthwnd) + if(tmp->window == notifyhwnd) { result = containerselectfunc(tmp->window, text, tmp->data); tmp = NULL; @@ -2496,10 +2510,8 @@ case CN_EXPANDTREE: { int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))tmp->signalfunction; - int id = SHORT1FROMMP(mp1); - HWND conthwnd = dw_window_from_id(hWnd, id); - - if(tmp->window == conthwnd) + + if(tmp->window == notifyhwnd) { result = treeexpandfunc(tmp->window, (HTREEITEM)mp2, tmp->data); tmp = NULL; @@ -2509,8 +2521,6 @@ case CN_CONTEXTMENU: { int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))tmp->signalfunction; - int id = SHORT1FROMMP(mp1); - HWND conthwnd = dw_window_from_id(hWnd, id); char *text = NULL; void *user = NULL; LONG x,y; @@ -2527,7 +2537,7 @@ dw_pointer_query_pos(&x, &y); - if(tmp->window == conthwnd) + if(tmp->window == notifyhwnd) { int container = (int)dw_window_get_data(tmp->window, "_dw_container"); @@ -2611,7 +2621,7 @@ { int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; - if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd) + if(tmp->window == hWnd || notifyhwnd == hWnd) { static int lastvalue = -1; static HWND lasthwnd = NULLHANDLE; @@ -2628,11 +2638,9 @@ else { int (* API listboxselectfunc)(HWND, int, void *) = (int (* API )(HWND, int, void *))tmp->signalfunction; - int id = SHORT1FROMMP(mp1); - HWND conthwnd = dw_window_from_id(hWnd, id); static int _recursing = 0; - if(_recursing == 0 && (tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2))) + if(_recursing == 0 && (tmp->window == notifyhwnd || (!id && tmp->window == (HWND)mp2))) { char buf1[500]; int index = dw_listbox_selected(tmp->window); @@ -2672,7 +2680,7 @@ if(origmsg == WM_CONTROL) { /* Handle Slider control */ - if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd) + if(tmp->window == hWnd || tmp->window == notifyhwnd) { static int lastvalue = -1; static HWND lasthwnd = NULLHANDLE; @@ -2690,7 +2698,7 @@ else { /* Handle scrollbar control */ - if(tmp->window > 65535 && tmp->window == WinWindowFromID(hWnd, (ULONG)mp1)) + if(tmp->window > 65535 && tmp->window == notifyhwnd) { int pos = _HandleScroller(tmp->window, (int)SHORT1FROMMP(mp2), (int)SHORT2FROMMP(mp2));; @@ -4850,7 +4858,7 @@ 0,0,2000,1000, NULLHANDLE, HWND_TOP, - id ? id : (GlobalID++), + id ? id : _GlobalID(), NULL, NULL); blah->oldproc = WinSubclassWindow(tmp, _TreeProc); @@ -4878,7 +4886,7 @@ 0,0,2000,1000, NULLHANDLE, HWND_TOP, - id ? id : (GlobalID++), + id ? id : _GlobalID(), NULL, NULL); @@ -5053,7 +5061,7 @@ 0,0,2000,1000, NULLHANDLE, HWND_TOP, - id, + id ? id : _GlobalID(), NULL, NULL); HENUM henum = WinBeginEnumWindows(tmp); @@ -5476,7 +5484,7 @@ 0,0,2000,1000, NULLHANDLE, HWND_TOP, - id, + id ? id : _GlobalID(), &sldcData, NULL); @@ -5502,7 +5510,7 @@ 0,0,2000,1000, NULLHANDLE, HWND_TOP, - id ? id : (GlobalID++), + id ? id : _GlobalID(), NULL, NULL); } @@ -5523,7 +5531,7 @@ 0,0,2000,1000, NULLHANDLE, HWND_TOP, - id, + id ? id : _GlobalID(), NULL, NULL); blah->oldproc = WinSubclassWindow(tmp, _percentproc); @@ -5577,7 +5585,7 @@ 0,0,2000,1000, NULLHANDLE, HWND_TOP, - id ? id : (GlobalID++), + id ? id : _GlobalID(), NULL, NULL); blah->oldproc = WinSubclassWindow(tmp, _entryproc); diff -r 9b021f787ad1 -r 452a5b1b2aa5 readme --- a/readme Wed Sep 28 15:29:05 2011 +0000 +++ b/readme Wed Sep 28 16:51:56 2011 +0000 @@ -22,10 +22,6 @@ It is not safe on all platforms to operate on widgets before they are packed. For portability pack widgets before operating on them. -On Windows a slider control will only work properly if it is the -only slider in a box. If there is more than one slider control -in a box then signals may get misdirected to the wrong control. - On Unix (GTK) the window manager border is not a constant value so environment variables DW_BORDER_WIDTH and DW_BORDER_HEIGHT are used for proper positioning.