ReactOS 0.4.15-dev-7942-gd23573b
input_list.h File Reference
#include "input.h"
#include "locale_list.h"
#include "layout_list.h"
Include dependency graph for input_list.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _INPUT_LIST_NODE
 

Macros

#define INPUT_LIST_NODE_FLAG_EDITED   0x0001
 
#define INPUT_LIST_NODE_FLAG_ADDED   0x0002
 
#define INPUT_LIST_NODE_FLAG_DELETED   0x0004
 
#define INPUT_LIST_NODE_FLAG_DEFAULT   0x0008
 

Typedefs

typedef struct _INPUT_LIST_NODE INPUT_LIST_NODE
 

Functions

VOID InputList_Create (VOID)
 
BOOL InputList_Process (VOID)
 
BOOL InputList_Add (LOCALE_LIST_NODE *pLocale, LAYOUT_LIST_NODE *pLayout)
 
VOID InputList_SetDefault (INPUT_LIST_NODE *pNode)
 
INT InputList_GetAliveCount (VOID)
 
BOOL InputList_Remove (INPUT_LIST_NODE *pNode)
 
BOOL InputList_RemoveByLang (LANGID wLangId)
 
VOID InputList_Sort (VOID)
 
VOID InputList_Destroy (VOID)
 
INPUT_LIST_NODEInputList_GetFirst (VOID)
 

Macro Definition Documentation

◆ INPUT_LIST_NODE_FLAG_ADDED

#define INPUT_LIST_NODE_FLAG_ADDED   0x0002

Definition at line 17 of file input_list.h.

◆ INPUT_LIST_NODE_FLAG_DEFAULT

#define INPUT_LIST_NODE_FLAG_DEFAULT   0x0008

Definition at line 30 of file input_list.h.

◆ INPUT_LIST_NODE_FLAG_DELETED

#define INPUT_LIST_NODE_FLAG_DELETED   0x0004

Definition at line 24 of file input_list.h.

◆ INPUT_LIST_NODE_FLAG_EDITED

#define INPUT_LIST_NODE_FLAG_EDITED   0x0001

Definition at line 11 of file input_list.h.

Typedef Documentation

◆ INPUT_LIST_NODE

Function Documentation

◆ InputList_Add()

BOOL InputList_Add ( LOCALE_LIST_NODE pLocale,
LAYOUT_LIST_NODE pLayout 
)

Definition at line 502 of file input_list.c.

503{
504 WCHAR szIndicator[MAX_STR_LEN];
505 INPUT_LIST_NODE *pInput = NULL;
506
507 if (pLocale == NULL || pLayout == NULL)
508 {
509 return FALSE;
510 }
511
512 for (pInput = _InputList; pInput != NULL; pInput = pInput->pNext)
513 {
515 continue;
516
517 if (pInput->pLocale == pLocale && pInput->pLayout == pLayout)
518 {
519 return FALSE; /* Already exists */
520 }
521 }
522
523 pInput = InputList_AppendNode();
525 pInput->pLocale = pLocale;
526 pInput->pLayout = pLayout;
527
528 if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
530 szIndicator,
531 ARRAYSIZE(szIndicator)))
532 {
533 size_t len = wcslen(szIndicator);
534
535 if (len > 0)
536 {
537 szIndicator[len - 1] = 0;
538 pInput->pszIndicator = _wcsdup(szIndicator);
539 }
540 }
541
542 return TRUE;
543}
#define MAX_STR_LEN
Definition: defines.h:43
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLenum GLsizei len
Definition: glext.h:6722
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static INPUT_LIST_NODE * _InputList
Definition: input_list.c:134
static INPUT_LIST_NODE * InputList_AppendNode(VOID)
Definition: input_list.c:138
#define INPUT_LIST_NODE_FLAG_DELETED
Definition: input_list.h:24
#define INPUT_LIST_NODE_FLAG_ADDED
Definition: input_list.h:17
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
#define LOWORD(l)
Definition: pedump.c:82
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
LPWSTR pszIndicator
Definition: input_list.h:41
struct _INPUT_LIST_NODE * pNext
Definition: input_list.h:44
LAYOUT_LIST_NODE * pLayout
Definition: input_list.h:37
LOCALE_LIST_NODE * pLocale
Definition: input_list.h:36
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:28
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OnCommandAddDialog().

◆ InputList_Create()

VOID InputList_Create ( VOID  )

Definition at line 659 of file input_list.c.

660{
661 INT iLayoutCount, iIndex;
662 WCHAR szIndicator[MAX_STR_LEN];
663 INPUT_LIST_NODE *pInput;
664 HKL *pLayoutList, hklDefault;
665
666 SystemParametersInfoW(SPI_GETDEFAULTINPUTLANG, 0, &hklDefault, 0);
667
668 iLayoutCount = GetKeyboardLayoutList(0, NULL);
669 pLayoutList = (HKL*) malloc(iLayoutCount * sizeof(HKL));
670
671 if (!pLayoutList || GetKeyboardLayoutList(iLayoutCount, pLayoutList) <= 0)
672 {
673 free(pLayoutList);
674 return;
675 }
676
677 for (iIndex = 0; iIndex < iLayoutCount; ++iIndex)
678 {
679 HKL hKL = pLayoutList[iIndex];
682 if (!pLocale || !pLayout)
683 continue;
684
685 pInput = InputList_AppendNode();
686 pInput->pLocale = pLocale;
687 pInput->pLayout = pLayout;
688 pInput->hkl = hKL;
689
690 if (pInput->hkl == hklDefault) /* Default HKL? */
691 {
693 hklDefault = NULL; /* No more default item */
694 }
695
696 /* Get abbrev language name */
697 szIndicator[0] = 0;
698 if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
700 szIndicator,
701 ARRAYSIZE(szIndicator)))
702 {
703 size_t len = wcslen(szIndicator);
704 if (len > 0)
705 {
706 szIndicator[len - 1] = 0;
707 pInput->pszIndicator = _wcsdup(szIndicator);
708 }
709 }
710 }
711
712 free(pLayoutList);
713}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define INPUT_LIST_NODE_FLAG_DEFAULT
Definition: input_list.h:30
LAYOUT_LIST_NODE * LayoutList_GetByHkl(HKL hkl)
Definition: layout_list.c:207
LOCALE_LIST_NODE * LocaleList_GetByHkl(HKL hkl)
Definition: locale_list.c:129
UINT_PTR HKL
Definition: msctf.idl:143
int32_t INT
Definition: typedefs.h:58
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)

Referenced by OnInitSettingsPage().

◆ InputList_Destroy()

VOID InputList_Destroy ( VOID  )

Definition at line 197 of file input_list.c.

198{
199 INPUT_LIST_NODE *pCurrent;
200 INPUT_LIST_NODE *pNext;
201
202 if (_InputList == NULL)
203 return;
204
205 for (pCurrent = _InputList; pCurrent; pCurrent = pNext)
206 {
207 pNext = pCurrent->pNext;
208
209 free(pCurrent->pszIndicator);
210 free(pCurrent);
211 }
212
214}

Referenced by OnDestroySettingsPage().

◆ InputList_GetAliveCount()

INT InputList_GetAliveCount ( VOID  )

Definition at line 783 of file input_list.c.

784{
785 INPUT_LIST_NODE *pNode;
786 INT nCount = 0;
787
788 for (pNode = _InputList; pNode; pNode = pNode->pNext)
789 {
791 continue;
792
793 ++nCount;
794 }
795
796 return nCount;
797}

Referenced by UpdateInputListView().

◆ InputList_GetFirst()

INPUT_LIST_NODE * InputList_GetFirst ( VOID  )

Definition at line 800 of file input_list.c.

801{
802 return _InputList;
803}

Referenced by InitDefaultLangComboBox(), and UpdateInputListView().

◆ InputList_Process()

BOOL InputList_Process ( VOID  )

Definition at line 382 of file input_list.c.

383{
384 INPUT_LIST_NODE *pCurrent;
385 DWORD dwNumber;
386 BOOL bRet = FALSE;
387 HKEY hPreloadKey, hSubstKey;
388 HKL hDefaultKL = NULL;
389
390 if (!InputList_PrepareUserRegistry(&hPreloadKey, &hSubstKey))
391 {
392 if (hPreloadKey)
393 RegCloseKey(hPreloadKey);
394 if (hSubstKey)
395 RegCloseKey(hSubstKey);
396 return FALSE;
397 }
398
399 /* Find change in the IME HKLs */
400 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
401 {
402 if (!IS_IME_HKL(pCurrent->hkl))
403 continue;
404
405 if ((pCurrent->wFlags & INPUT_LIST_NODE_FLAG_ADDED) ||
406 (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_EDITED) ||
408 {
409 bRet = TRUE; /* Reboot is needed */
410 break;
411 }
412 }
413
414 /* Process DELETED and EDITED entries */
415 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
416 {
417 if ((pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED) ||
419 {
420
421 /* Only unload the DELETED and EDITED entries */
422 if (UnloadKeyboardLayout(pCurrent->hkl))
423 {
424 /* But the EDITED entries are used later */
425 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
426 {
427 InputList_RemoveNode(pCurrent);
428 }
429 }
430 }
431 }
432
433 /* Add the DEFAULT entry and set font substitutes */
434 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
435 {
436 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
437 continue;
438
439 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT)
440 {
441 bRet = InputList_SetFontSubstitutes(pCurrent->pLocale->dwId);
442 InputList_AddInputMethodToUserRegistry(hPreloadKey, hSubstKey, 1, pCurrent);
443
444 /* Activate the DEFAULT entry */
445 ActivateKeyboardLayout(pCurrent->hkl, KLF_RESET);
446
447 /* Save it */
448 hDefaultKL = pCurrent->hkl;
449 break;
450 }
451 }
452
453 /* Add entries except DEFAULT to registry */
454 dwNumber = 2;
455 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
456 {
457 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
458 continue;
459 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT)
460 continue;
461
462 InputList_AddInputMethodToUserRegistry(hPreloadKey, hSubstKey, dwNumber, pCurrent);
463
464 ++dwNumber;
465 }
466
467 /* Remove ADDED and EDITED flags */
468 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
469 {
471 }
472
473 /* Change the default keyboard language */
474 if (SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG, 0, &hDefaultKL, 0))
475 {
476 DWORD dwRecipients = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
477
479 &dwRecipients,
480 WM_INPUTLANGCHANGEREQUEST,
481 INPUTLANGCHANGE_SYSCHARSET,
482 (LPARAM)hDefaultKL);
483 }
484
485 /* Retry to delete (in case of failure to delete the default keyboard) */
486 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
487 {
488 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
489 {
490 UnloadKeyboardLayout(pCurrent->hkl);
491 InputList_RemoveNode(pCurrent);
492 }
493 }
494
495 RegCloseKey(hPreloadKey);
496 RegCloseKey(hSubstKey);
497 return bRet;
498}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define BSF_POSTMESSAGE
Definition: dbt.h:58
#define BSM_APPLICATIONS
Definition: dbt.h:48
#define BSM_ALLDESKTOPS
Definition: dbt.h:49
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IS_IME_HKL(hKL)
Definition: imm32_undoc.h:20
static BOOL InputList_PrepareUserRegistry(PHKEY phPreloadKey, PHKEY phSubstKey)
Definition: input_list.c:218
BOOL InputList_SetFontSubstitutes(LCID dwLocaleId)
Definition: input_list.c:50
static VOID InputList_RemoveNode(INPUT_LIST_NODE *pNode)
Definition: input_list.c:170
static VOID InputList_AddInputMethodToUserRegistry(HKEY hPreloadKey, HKEY hSubstKey, DWORD dwNumber, INPUT_LIST_NODE *pNode)
Definition: input_list.c:332
#define INPUT_LIST_NODE_FLAG_EDITED
Definition: input_list.h:11
LONG WINAPI BroadcastSystemMessageW(DWORD dwFlags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam)
Definition: message.c:3408
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI UnloadKeyboardLayout(_In_ HKL)
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)

Referenced by OnNotifySettingsPage().

◆ InputList_Remove()

BOOL InputList_Remove ( INPUT_LIST_NODE pNode)

Definition at line 596 of file input_list.c.

597{
598 BOOL ret = FALSE;
599 BOOL bRemoveNode = FALSE;
600
601 if (pNode == NULL)
602 return FALSE;
603
605 {
606 /*
607 * If the input method has been added to the list, but not yet written
608 * in the registry, then simply remove it from the list
609 */
610 bRemoveNode = TRUE;
611 }
612 else
613 {
615 }
616
618 {
620 if (pCurrent)
622
623 pNode->wFlags &= ~INPUT_LIST_NODE_FLAG_DEFAULT;
624 ret = TRUE; /* default input is changed */
625 }
626
627 if (bRemoveNode)
628 {
630 }
631
632 return ret;
633}
INPUT_LIST_NODE * InputList_FindNextDefault(INPUT_LIST_NODE *pNode)
Definition: input_list.c:568
int ret

Referenced by InputList_RemoveByLang(), and OnCommandSettingsPage().

◆ InputList_RemoveByLang()

BOOL InputList_RemoveByLang ( LANGID  wLangId)

Definition at line 636 of file input_list.c.

637{
638 BOOL ret = FALSE;
639 INPUT_LIST_NODE *pCurrent;
640
641Retry:
642 for (pCurrent = _InputList; pCurrent; pCurrent = pCurrent->pNext)
643 {
644 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
645 continue;
646
647 if (LOWORD(pCurrent->pLocale->dwId) == wLangId)
648 {
649 if (InputList_Remove(pCurrent))
650 ret = TRUE; /* default input is changed */
651 goto Retry;
652 }
653 }
654
655 return ret;
656}
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:312
BOOL InputList_Remove(INPUT_LIST_NODE *pNode)
Definition: input_list.c:596

Referenced by OnCommandSettingsPage().

◆ InputList_SetDefault()

VOID InputList_SetDefault ( INPUT_LIST_NODE pNode)

Definition at line 547 of file input_list.c.

548{
549 INPUT_LIST_NODE *pCurrent;
550
551 if (pNode == NULL)
552 return;
553
554 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
555 {
556 if (pCurrent == pNode)
557 {
559 }
560 else
561 {
562 pCurrent->wFlags &= ~INPUT_LIST_NODE_FLAG_DEFAULT;
563 }
564 }
565}

Referenced by OnCommandSettingsPage().

◆ InputList_Sort()

VOID InputList_Sort ( VOID  )

Definition at line 724 of file input_list.c.

725{
727 INPUT_LIST_NODE *pNext, *pPrev;
728 INPUT_LIST_NODE *pMinimum, *pNode;
729
731
732 while (pList)
733 {
734 /* Find the minimum node */
735 pMinimum = NULL;
736 for (pNode = pList; pNode; pNode = pNext)
737 {
738 pNext = pNode->pNext;
739
740 if (pMinimum == NULL)
741 {
742 pMinimum = pNode;
743 }
744 else if (InputList_Compare(pNode, pMinimum) < 0)
745 {
746 pMinimum = pNode;
747 }
748 }
749
750 // Remove pMinimum from pList
751 pNext = pMinimum->pNext;
752 pPrev = pMinimum->pPrev;
753 if (pNext)
754 pNext->pPrev = pPrev;
755 if (pPrev)
756 pPrev->pNext = pNext;
757 else
758 pList = pNext;
759
760 // Append pMinimum to _InputList
761 if (!_InputList)
762 {
763 pMinimum->pPrev = pMinimum->pNext = NULL;
764 _InputList = pMinimum;
765 }
766 else
767 {
768 /* Find last node */
769 for (pNode = _InputList; pNode->pNext; pNode = pNode->pNext)
770 {
771 NOTHING;
772 }
773
774 /* Add to the end */
775 pNode->pNext = pMinimum;
776 pMinimum->pPrev = pNode;
777 pMinimum->pNext = NULL;
778 }
779 }
780}
FxChildList * pList
static INT InputList_Compare(INPUT_LIST_NODE *pNode1, INPUT_LIST_NODE *pNode2)
Definition: input_list.c:715
#define NOTHING
Definition: input_list.c:10
struct _INPUT_LIST_NODE * pPrev
Definition: input_list.h:43

Referenced by UpdateInputListView().