From 02205c87b8515d35ffdbae6ae3775905a0255d0d Mon Sep 17 00:00:00 2001 From: Roland Mainz Date: Thu, 13 Jan 2005 03:56:07 +0000 Subject: xc/programs/Xserver/hw/xwin/ChangeLog xc/programs/Xserver/hw/xwin/winkeybd.h xc/programs/Xserver/hw/xwin/winkeyhook.c xc/programs/Xserver/hw/xwin/winmultiwindowclass.c xc/programs/Xserver/hw/xwin/winmultiwindowwindow.c xc/programs/Xserver/hw/xwin/winmultiwindowwm.c //bugs.freedesktop.org/show_bug.cgi?id=1831) attachment #1656 (https://bugs.freedesktop.org/attachment.cgi?id=1656): CGYWIN update, including the following fixes: - Make keyhook feature work in multiwindowmode too - Hook windows keys - Fix crash with non-nullterminated strings (reported by Øyvind Harboe) - From Bug #1945: Stop unnecessary reordering. Patch by Alexander Gottwald and Kensuke Matsuzaki. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw/xwin/ChangeLog | 19 +++++++++++++++++++ hw/xwin/winkeybd.h | 6 +++--- hw/xwin/winkeyhook.c | 5 ++--- hw/xwin/winmultiwindowclass.c | 11 ++++++----- hw/xwin/winmultiwindowwindow.c | 3 ++- hw/xwin/winmultiwindowwm.c | 5 ++++- hw/xwin/winwndproc.c | 4 ++-- 7 files changed, 38 insertions(+), 15 deletions(-) diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog index 5cdbb70e4..05319a130 100644 --- a/hw/xwin/ChangeLog +++ b/hw/xwin/ChangeLog @@ -1,3 +1,22 @@ +2005-01-10 Alexander Gottwald + + * winkeybd.h + * winkeyhook.c + * winwndproc.c: + Make keyhook feature work in multiwindowmode too + Hook windows keys + +2005-01-06 Alexander Gottwald + + * winmultiwindowclass.c: + * winmultiwindowwm.c: + Fix crash with non-nullterminated strings (reported by Øyvind Harboe) + +2004-12-27 Alexander Gottwald + + * winmultiwindowwindow.c: + Bug #1945: Stop unnecessary reordering. (Kensuke Matsuzaki) + 2004-12-14 Alexander Gottwald * InitOutput.c: diff --git a/hw/xwin/winkeybd.h b/hw/xwin/winkeybd.h index f320c98e7..31c0cbc23 100644 --- a/hw/xwin/winkeybd.h +++ b/hw/xwin/winkeybd.h @@ -140,9 +140,9 @@ g_iKeyMap [] = { /* 88 */ 0, 0, 0, /* 89 */ 0, 0, 0, /* 90 */ 0, 0, 0, - /* 91 */ 0, 0, 0, - /* 92 */ 0, 0, 0, - /* 93 */ 0, 0, 0, + /* 91 */ VK_LWIN, KEY_LMeta, 0, + /* 92 */ VK_RWIN, KEY_RMeta, 0, + /* 93 */ VK_APPS, KEY_Menu, 0, /* 94 */ 0, 0, 0, /* 95 */ 0, 0, 0, /* 96 */ 0, 0, 0, diff --git a/hw/xwin/winkeyhook.c b/hw/xwin/winkeyhook.c index 60176d9ad..edc51c99f 100755 --- a/hw/xwin/winkeyhook.c +++ b/hw/xwin/winkeyhook.c @@ -65,6 +65,7 @@ winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam) { BOOL fPassKeystroke = FALSE; PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam; + HWND hwnd = GetActiveWindow(); /* Pass keystrokes on to our main message loop */ if (iCode == HC_ACTION) @@ -79,9 +80,7 @@ winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam) case WM_KEYUP: case WM_SYSKEYUP: fPassKeystroke = ((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) -#if 0 || (p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN) -#endif ; break; } @@ -107,7 +106,7 @@ winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam) lParamKey = lParamKey | (0x80000000 & ((p->flags & LLKHF_UP) << 24)); /* Send message to our main window that has the keyboard focus */ - PostMessage (g_hwndKeyboardFocus, + PostMessage (hwnd, (UINT) wParam, (WPARAM) p->vkCode, lParamKey); diff --git a/hw/xwin/winmultiwindowclass.c b/hw/xwin/winmultiwindowclass.c index d369db70e..ddbbf143a 100755 --- a/hw/xwin/winmultiwindowclass.c +++ b/hw/xwin/winmultiwindowclass.c @@ -175,7 +175,7 @@ winMultiWindowGetWindowRole (WindowPtr pWin, char **res_role) && prop->format == 8 && prop->data) { - len_role= strlen ((char *) prop->data); + len_role= prop->size; (*res_role) = malloc (len_role + 1); @@ -185,7 +185,8 @@ winMultiWindowGetWindowRole (WindowPtr pWin, char **res_role) return 0; } - strcpy ((*res_role), prop->data); + strncpy ((*res_role), prop->data, len_role); + (*res_role)[len_role] = 0; return 1; } @@ -299,7 +300,7 @@ winMultiWindowGetWMName (WindowPtr pWin, char **wmName) && prop->type == XA_STRING && prop->data) { - len_name = strlen ((char *) prop->data); + len_name = prop->size; (*wmName) = malloc (len_name + 1); @@ -309,8 +310,8 @@ winMultiWindowGetWMName (WindowPtr pWin, char **wmName) return 0; } - /* Add one to len_name to allow copying of trailing 0 */ - strncpy ((*wmName), prop->data, len_name+1); + strncpy ((*wmName), prop->data, len_name); + (*wmName)[len_name] = 0; return 1; } diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 1c5e2fbbf..5034ec0d6 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -394,7 +394,8 @@ winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib) * Calling winReorderWindowsMultiWindow here means our window manager * (i.e. Windows Explorer) has initiative to determine Z order. */ - winReorderWindowsMultiWindow (); + if (pWin->nextSib != pOldNextSib) + winReorderWindowsMultiWindow (); #else /* Bail out if no window privates or window handle is invalid */ if (!pWinPriv || !pWinPriv->hWnd) diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 3c82aee90..1a0ddf519 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -405,7 +405,10 @@ GetWindowName (Display *pDisplay, Window iWin, char **ppName) /* */ if (xtpName.value) { - *ppName = strdup ((char*)xtpName.value); + int size = xtpName.nitems * (xtpName.format >> 3); + *ppName = malloc(size + 1); + strncpy(*ppName, xtpName.value, size); + (*ppName)[size] = 0; XFree (xtpName.value); } diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index 6188425dd..d41d00421 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -1012,7 +1012,7 @@ winWindowProc (HWND hwnd, UINT message, * be returned to Windows. We may be able to trap the Windows keys, * but we should determine if that is desirable before doing so. */ - if (wParam == VK_LWIN || wParam == VK_RWIN) + if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL) break; #ifdef XKB @@ -1053,7 +1053,7 @@ winWindowProc (HWND hwnd, UINT message, * be returned to Windows. We may be able to trap the Windows keys, * but we should determine if that is desirable before doing so. */ - if (wParam == VK_LWIN || wParam == VK_RWIN) + if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL) break; /* Ignore the fake Ctrl_L that follows an AltGr release */ -- cgit v1.2.3