ReactOS 0.4.15-dev-6675-gcbc63d8
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 482 of file input_list.c.

483{
484 WCHAR szIndicator[MAX_STR_LEN];
485 INPUT_LIST_NODE *pInput = NULL;
486
487 if (pLocale == NULL || pLayout == NULL)
488 {
489 return FALSE;
490 }
491
492 for (pInput = _InputList; pInput != NULL; pInput = pInput->pNext)
493 {
495 continue;
496
497 if (pInput->pLocale == pLocale && pInput->pLayout == pLayout)
498 {
499 return FALSE; /* Already exists */
500 }
501 }
502
503 pInput = InputList_AppendNode();
505 pInput->pLocale = pLocale;
506 pInput->pLayout = pLayout;
507
508 if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
510 szIndicator,
511 ARRAYSIZE(szIndicator)))
512 {
513 size_t len = wcslen(szIndicator);
514
515 if (len > 0)
516 {
517 szIndicator[len - 1] = 0;
518 pInput->pszIndicator = _wcsdup(szIndicator);
519 }
520 }
521
522 return TRUE;
523}
#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 639 of file input_list.c.

640{
641 INT iLayoutCount, iIndex;
642 WCHAR szIndicator[MAX_STR_LEN];
643 INPUT_LIST_NODE *pInput;
644 HKL *pLayoutList, hklDefault;
645
646 SystemParametersInfoW(SPI_GETDEFAULTINPUTLANG, 0, &hklDefault, 0);
647
648 iLayoutCount = GetKeyboardLayoutList(0, NULL);
649 pLayoutList = (HKL*) malloc(iLayoutCount * sizeof(HKL));
650
651 if (!pLayoutList || GetKeyboardLayoutList(iLayoutCount, pLayoutList) <= 0)
652 {
653 free(pLayoutList);
654 return;
655 }
656
657 for (iIndex = 0; iIndex < iLayoutCount; ++iIndex)
658 {
659 HKL hKL = pLayoutList[iIndex];
662 if (!pLocale || !pLayout)
663 continue;
664
665 pInput = InputList_AppendNode();
666 pInput->pLocale = pLocale;
667 pInput->pLayout = pLayout;
668 pInput->hkl = hKL;
669
670 if (pInput->hkl == hklDefault) /* Default HKL? */
671 {
673 hklDefault = NULL; /* No more default item */
674 }
675
676 /* Get abbrev language name */
677 szIndicator[0] = 0;
678 if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
680 szIndicator,
681 ARRAYSIZE(szIndicator)))
682 {
683 size_t len = wcslen(szIndicator);
684 if (len > 0)
685 {
686 szIndicator[len - 1] = 0;
687 pInput->pszIndicator = _wcsdup(szIndicator);
688 }
689 }
690 }
691
692 free(pLayoutList);
693}
#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:104
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 763 of file input_list.c.

764{
765 INPUT_LIST_NODE *pNode;
766 INT nCount = 0;
767
768 for (pNode = _InputList; pNode; pNode = pNode->pNext)
769 {
771 continue;
772
773 ++nCount;
774 }
775
776 return nCount;
777}

Referenced by UpdateInputListView().

◆ InputList_GetFirst()

INPUT_LIST_NODE * InputList_GetFirst ( VOID  )

Definition at line 780 of file input_list.c.

781{
782 return _InputList;
783}

Referenced by InitDefaultLangComboBox(), IsRebootNeeded(), 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
389 if (!InputList_PrepareUserRegistry(&hPreloadKey, &hSubstKey))
390 {
391 if (hPreloadKey)
392 RegCloseKey(hPreloadKey);
393 if (hSubstKey)
394 RegCloseKey(hSubstKey);
395 return FALSE;
396 }
397
398 /* Process DELETED and EDITED entries */
399 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
400 {
401 if ((pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED) ||
403 {
404 /* Only unload the DELETED and EDITED entries */
405 if (UnloadKeyboardLayout(pCurrent->hkl))
406 {
407 /* But the EDITED entries are used later */
408 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
409 {
410 InputList_RemoveNode(pCurrent);
411 }
412 }
413 }
414 }
415
416 /* Add the DEFAULT entry and set font substitutes */
417 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
418 {
419 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
420 continue;
421
422 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT)
423 {
424 bRet = InputList_SetFontSubstitutes(pCurrent->pLocale->dwId);
425 InputList_AddInputMethodToUserRegistry(hPreloadKey, hSubstKey, 1, pCurrent);
426
427 /* Activate the DEFAULT entry */
428 ActivateKeyboardLayout(pCurrent->hkl, KLF_RESET);
429 break;
430 }
431 }
432
433 /* Add entries except DEFAULT to registry */
434 dwNumber = 2;
435 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
436 {
437 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
438 continue;
439 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT)
440 continue;
441
442 InputList_AddInputMethodToUserRegistry(hPreloadKey, hSubstKey, dwNumber, pCurrent);
443
444 ++dwNumber;
445 }
446
447 /* Remove ADDED and EDITED flags */
448 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
449 {
451 }
452
453 /* Change the default keyboard language */
454 if (SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG, 0, &pCurrent->hkl, 0))
455 {
456 DWORD dwRecipients = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
457
459 &dwRecipients,
460 WM_INPUTLANGCHANGEREQUEST,
461 INPUTLANGCHANGE_SYSCHARSET,
462 (LPARAM)pCurrent->hkl);
463 }
464
465 /* Retry to delete (in case of failure to delete the default keyboard) */
466 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
467 {
468 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
469 {
470 UnloadKeyboardLayout(pCurrent->hkl);
471 InputList_RemoveNode(pCurrent);
472 }
473 }
474
475 RegCloseKey(hPreloadKey);
476 RegCloseKey(hSubstKey);
477 return bRet;
478}
#define RegCloseKey(hKey)
Definition: registry.h:47
#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
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 576 of file input_list.c.

577{
578 BOOL ret = FALSE;
579 BOOL bRemoveNode = FALSE;
580
581 if (pNode == NULL)
582 return FALSE;
583
585 {
586 /*
587 * If the input method has been added to the list, but not yet written
588 * in the registry, then simply remove it from the list
589 */
590 bRemoveNode = TRUE;
591 }
592 else
593 {
595 }
596
598 {
600 if (pCurrent)
602
603 pNode->wFlags &= ~INPUT_LIST_NODE_FLAG_DEFAULT;
604 ret = TRUE; /* default input is changed */
605 }
606
607 if (bRemoveNode)
608 {
610 }
611
612 return ret;
613}
INPUT_LIST_NODE * InputList_FindNextDefault(INPUT_LIST_NODE *pNode)
Definition: input_list.c:548
int ret

Referenced by InputList_RemoveByLang(), and OnCommandSettingsPage().

◆ InputList_RemoveByLang()

BOOL InputList_RemoveByLang ( LANGID  wLangId)

Definition at line 616 of file input_list.c.

617{
618 BOOL ret = FALSE;
619 INPUT_LIST_NODE *pCurrent;
620
621Retry:
622 for (pCurrent = _InputList; pCurrent; pCurrent = pCurrent->pNext)
623 {
624 if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED)
625 continue;
626
627 if (LOWORD(pCurrent->pLocale->dwId) == wLangId)
628 {
629 if (InputList_Remove(pCurrent))
630 ret = TRUE; /* default input is changed */
631 goto Retry;
632 }
633 }
634
635 return ret;
636}
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:312
BOOL InputList_Remove(INPUT_LIST_NODE *pNode)
Definition: input_list.c:576

Referenced by OnCommandSettingsPage().

◆ InputList_SetDefault()

VOID InputList_SetDefault ( INPUT_LIST_NODE pNode)

Definition at line 527 of file input_list.c.

528{
529 INPUT_LIST_NODE *pCurrent;
530
531 if (pNode == NULL)
532 return;
533
534 for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
535 {
536 if (pCurrent == pNode)
537 {
539 }
540 else
541 {
542 pCurrent->wFlags &= ~INPUT_LIST_NODE_FLAG_DEFAULT;
543 }
544 }
545}

Referenced by OnCommandSettingsPage().

◆ InputList_Sort()

VOID InputList_Sort ( VOID  )

Definition at line 704 of file input_list.c.

705{
707 INPUT_LIST_NODE *pNext, *pPrev;
708 INPUT_LIST_NODE *pMinimum, *pNode;
709
711
712 while (pList)
713 {
714 /* Find the minimum node */
715 pMinimum = NULL;
716 for (pNode = pList; pNode; pNode = pNext)
717 {
718 pNext = pNode->pNext;
719
720 if (pMinimum == NULL)
721 {
722 pMinimum = pNode;
723 }
724 else if (InputList_Compare(pNode, pMinimum) < 0)
725 {
726 pMinimum = pNode;
727 }
728 }
729
730 // Remove pMinimum from pList
731 pNext = pMinimum->pNext;
732 pPrev = pMinimum->pPrev;
733 if (pNext)
734 pNext->pPrev = pPrev;
735 if (pPrev)
736 pPrev->pNext = pNext;
737 else
738 pList = pNext;
739
740 // Append pMinimum to _InputList
741 if (!_InputList)
742 {
743 pMinimum->pPrev = pMinimum->pNext = NULL;
744 _InputList = pMinimum;
745 }
746 else
747 {
748 /* Find last node */
749 for (pNode = _InputList; pNode->pNext; pNode = pNode->pNext)
750 {
751 NOTHING;
752 }
753
754 /* Add to the end */
755 pNode->pNext = pMinimum;
756 pMinimum->pPrev = pNode;
757 pMinimum->pNext = NULL;
758 }
759 }
760}
FxChildList * pList
static INT InputList_Compare(INPUT_LIST_NODE *pNode1, INPUT_LIST_NODE *pNode2)
Definition: input_list.c:695
#define NOTHING
Definition: input_list.c:10
struct _INPUT_LIST_NODE * pPrev
Definition: input_list.h:43

Referenced by UpdateInputListView().