Author: cfinck
Date: Sun Jun 22 16:59:27 2008
New Revision: 34053
URL:
http://svn.reactos.org/svn/reactos?rev=34053&view=rev
Log:
- Rebuild the left popup menu containing the keyboard layouts on every click to take care
of keyboard layout changes.
I know this is probably not the best way for doing the job, but I don't know of any
other method to achieve the same.
- Change the right popup menu to only show the "Options" and "Exit"
menu items (like ctfmon does)
- Add the missing 'return 0;' statements, when a message was handled
See issue #3372 for more details.
Modified:
trunk/reactos/base/applications/kbswitch/kbswitch.c
trunk/reactos/base/applications/kbswitch/lang/bg-BG.rc
trunk/reactos/base/applications/kbswitch/lang/cs-CZ.rc
trunk/reactos/base/applications/kbswitch/lang/de-DE.rc
trunk/reactos/base/applications/kbswitch/lang/en-US.rc
trunk/reactos/base/applications/kbswitch/lang/es-ES.rc
trunk/reactos/base/applications/kbswitch/lang/fr-FR.rc
trunk/reactos/base/applications/kbswitch/lang/lt-LT.rc
trunk/reactos/base/applications/kbswitch/lang/pl-PL.rc
trunk/reactos/base/applications/kbswitch/lang/ru-RU.rc
trunk/reactos/base/applications/kbswitch/lang/sk-SK.rc
Modified: trunk/reactos/base/applications/kbswitch/kbswitch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/kbswitch.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/kbswitch.c [iso-8859-1] Sun Jun 22 16:59:27
2008
@@ -142,7 +142,7 @@
tnid.uCallbackMessage = WM_NOTIFYICONMSG;
tnid.hIcon = CreateTrayIcon(szLCID);
- lstrcpyn(tnid.szTip, szName, sizeof(tnid.szTip));
+ lstrcpyn(tnid.szTip, szName, sizeof(tnid.szTip));
Shell_NotifyIcon(NIM_MODIFY, &tnid);
}
@@ -210,7 +210,7 @@
TCHAR szBuf[MAX_PATH], szDispName[MAX_PATH], szIndex[MAX_PATH], szPath[MAX_PATH];
TCHAR szLCID[CCH_LAYOUT_ID + 1];
HANDLE hLib;
- int i, j, k;
+ UINT i, j, k;
if(!GetLayoutID(szLayoutNum, szLCID))
return FALSE;
@@ -329,52 +329,6 @@
return hMenu;
}
-static HMENU
-BuildRightPopupMenu()
-{
- HMENU hMenu;
- HMENU hMenuTemplate;
- DWORD dwIndex;
- LPTSTR pszMenuItem;
- MENUITEMINFO mii;
-
- // Add the keyboard layouts to the popup menu
- hMenu = BuildLeftPopupMenu();
-
- // Add the menu items from the popup menu template
- hMenuTemplate = GetSubMenu(LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP)), 0);
- dwIndex = 0;
-
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID;
- mii.dwTypeData = NULL;
-
- while(GetMenuItemInfo(hMenuTemplate, dwIndex, TRUE, &mii))
- {
- if(mii.cch > 0)
- {
- mii.cch++;
- pszMenuItem = (LPTSTR)HeapAlloc(hProcessHeap, 0, mii.cch * sizeof(TCHAR));
-
- mii.dwTypeData = pszMenuItem;
- GetMenuItemInfo(hMenuTemplate, dwIndex, TRUE, &mii);
-
- AppendMenu(hMenu, mii.fType, mii.wID, mii.dwTypeData);
-
- HeapFree(hProcessHeap, 0, pszMenuItem);
- mii.dwTypeData = NULL;
- }
- else
- {
- AppendMenu(hMenu, mii.fType, 0, NULL);
- }
-
- dwIndex++;
- }
-
- return hMenu;
-}
-
BOOL
SetHooks()
{
@@ -430,7 +384,7 @@
LRESULT CALLBACK
WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
- static HMENU hLeftPopupMenu, hRightPopupMenu;
+ static HMENU hRightPopupMenu;
static TCHAR szLCID[MAX_PATH], szLangName[MAX_PATH];
switch (Message)
@@ -439,32 +393,35 @@
{
SetHooks();
AddTrayIcon(hwnd);
- hLeftPopupMenu = BuildLeftPopupMenu(hwnd);
- hRightPopupMenu = BuildRightPopupMenu(hwnd);
- }
- break;
+ hRightPopupMenu = GetSubMenu(LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP)),
0);
+
+ return 0;
+ }
case WM_LANG_CHANGED:
{
GetLayoutIDByHkl((HKL)lParam, szLCID);
GetLocaleInfo((LANGID)_tcstoul(szLCID, NULL, 16), LOCALE_SLANGUAGE,
(LPTSTR)szLangName, sizeof(szLangName) / sizeof(TCHAR));
UpdateTrayIcon(hwnd, szLCID, szLangName);
- }
- break;
+
+ return 0;
+ }
case WM_LOAD_LAYOUT:
{
ActivateLayout(hwnd, GetNextLayout());
- }
- break;
+
+ return 0;
+ }
case WM_WINDOW_ACTIVATE:
{
GetLayoutIDByHkl(GetKeyboardLayout(GetWindowThreadProcessId((HWND)wParam,
0)), szLCID);
GetLocaleInfo((LANGID)_tcstoul(szLCID, NULL, 16), LOCALE_SLANGUAGE,
(LPTSTR)szLangName, sizeof(szLangName) / sizeof(TCHAR));
UpdateTrayIcon(hwnd, szLCID, szLangName);
- }
- break;
+
+ return 0;
+ }
case WM_NOTIFYICONMSG:
switch (lParam)
@@ -476,13 +433,25 @@
GetCursorPos(&pt);
SetForegroundWindow(hwnd);
+
if (lParam == WM_LBUTTONDOWN)
+ {
+ HMENU hLeftPopupMenu;
+
+ /* Rebuild the left popup menu on every click to take care of
keyboard layout changes */
+ hLeftPopupMenu = BuildLeftPopupMenu();
TrackPopupMenu(hLeftPopupMenu, 0, pt.x, pt.y, 0, hwnd, NULL);
+ DestroyMenu(hLeftPopupMenu);
+ }
else
+ {
TrackPopupMenu(hRightPopupMenu, 0, pt.x, pt.y, 0, hwnd, NULL);
+ }
+
PostMessage(hwnd, WM_NULL, 0, 0);
+
+ return 0;
}
- break;
}
break;
@@ -491,7 +460,7 @@
{
case ID_EXIT:
SendMessage(hwnd, WM_CLOSE, 0, 0);
- break;
+ return 0;
case ID_PREFERENCES:
{
@@ -506,16 +475,15 @@
if (!ShellExecuteEx(&shInputDll))
MessageBox(hwnd, _T("Can't start input.dll"), NULL,
MB_OK | MB_ICONERROR);
}
- break;
default:
ActivateLayout(hwnd, LOWORD(wParam));
- break;
+ return 0;
}
break;
case WM_SETTINGCHANGE:
- {
+ {
if (wParam == SPI_SETDEFAULTINPUTLANG)
{
//FIXME: Should detect default language changes by CPL applet or by
other tools and update UI
@@ -526,12 +494,12 @@
case WM_DESTROY:
{
DeleteHooks();
- DestroyMenu(hLeftPopupMenu);
DestroyMenu(hRightPopupMenu);
DelTrayIcon(hwnd);
PostQuitMessage(0);
- }
- break;
+
+ return 0;
+ }
}
return DefWindowProc(hwnd, Message, wParam, lParam);
Modified: trunk/reactos/base/applications/kbswitch/lang/bg-BG.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/bg-BG.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/bg-BG.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -4,7 +4,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Ïðåäïî÷èòàíèÿ...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "Èç&õîä", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/cs-CZ.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/cs-CZ.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/cs-CZ.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -9,7 +9,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Pøedvolby...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "&Ukonèit", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/de-DE.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/de-DE.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/de-DE.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -4,7 +4,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Einstellungen...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "&Beenden", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/en-US.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -4,7 +4,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Preferences...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "&Exit", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/es-ES.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/es-ES.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/es-ES.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -4,7 +4,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Preferencias...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "&Salir", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/fr-FR.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/fr-FR.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/fr-FR.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -4,7 +4,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Préférences...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "Quitt&er", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/lt-LT.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/lt-LT.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/lt-LT.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -6,7 +6,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Nuostatos...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "&Baigti", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/pl-PL.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/pl-PL.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/pl-PL.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -11,7 +11,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Ustawienia...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "&Wyjcie", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/ru-RU.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/ru-RU.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/ru-RU.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -4,7 +4,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Ïàðàìåòðû...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "&Âûõîä", ID_EXIT
Modified: trunk/reactos/base/applications/kbswitch/lang/sk-SK.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/lang/sk-SK.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/lang/sk-SK.rc [iso-8859-1] Sun Jun 22
16:59:27 2008
@@ -8,7 +8,6 @@
BEGIN
POPUP "popup"
BEGIN
- MENUITEM SEPARATOR
MENUITEM "&Nastavenia...", ID_PREFERENCES
MENUITEM SEPARATOR
MENUITEM "&Zavrie", ID_EXIT